<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23488/a-nrf52-function-mapping-to-nrf51</link><description>Hi all, 
 I am working on interfacing an SD card as well as an OLED Display with my nrf51422 on SDK 12.2.0. 
 Although, both are on SPI and hence i need to configure them as multiple slaves using multiple master instances instead. I got a way on how</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 31 Jul 2018 21:17:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23488/a-nrf52-function-mapping-to-nrf51" /><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/142265?ContentTypeID=1</link><pubDate>Tue, 31 Jul 2018 21:17:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24b9544b-6a8c-450a-b6e3-232a5db6bc4b</guid><dc:creator>benkokes</dc:creator><description>&lt;p&gt;Would it be possible to get an update of your answer to SDK 15? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/124863?ContentTypeID=1</link><pubDate>Sat, 17 Mar 2018 13:35:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:deeeae71-f3c4-4846-94b9-69f488c7cb84</guid><dc:creator>Charles Custon</dc:creator><description>&lt;p&gt;I&amp;#39;d like to add that &lt;span&gt;J&amp;oslash;rgen&amp;#39;s&amp;nbsp;&lt;/span&gt;solution worked for me in SDK14.2. &lt;strong&gt;Any chance this will get added to the SDK?&lt;/strong&gt; Thank you,&amp;nbsp;&lt;span&gt;J&amp;oslash;rgen.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92263?ContentTypeID=1</link><pubDate>Sat, 22 Jul 2017 06:08:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15f71e36-1953-4c47-9317-0a7e6287e865</guid><dc:creator>YASH</dc:creator><description>&lt;p&gt;Hello, Thank you very much.. The chip select between my card and display was not happening because of a small mistake that i was doing, now it is working very fine.&lt;/p&gt;
&lt;p&gt;I wanted to know if there is any other method to do this? I don&amp;#39;t want to alter any of my drv files
and i wanted to know the necessity of this line. I am a beginner:-&lt;/p&gt;
&lt;p&gt;APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));
while (!spi_xfer_done)
{
__WFE();
}&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92265?ContentTypeID=1</link><pubDate>Tue, 18 Jul 2017 08:24:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd838241-5d07-49d5-b899-37c626447f4e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;How does your init function for that device look? Which call is is getting stuck at?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92264?ContentTypeID=1</link><pubDate>Mon, 17 Jul 2017 13:43:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba8c6549-c323-4645-ae4f-16b96f7365bb</guid><dc:creator>YASH</dc:creator><description>&lt;p&gt;Hello, thank you for your support, although i have a doubt, my one slave is working perfectly fine with this, the second one is not getting initialized in debug session, what could be the possible mistake that i am committing.?&lt;/p&gt;
&lt;p&gt;My second device is SD card and in debugging, it is getting stuck in initializing it.&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92266?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2017 11:44:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b50118b-2cd1-4ec4-adac-80b501498d75</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Please vote and accept the answer by clicking the checkmark next to it if this was helpful!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92261?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2017 10:01:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7eb78862-615d-46b8-8f12-089f09f5ccc5</guid><dc:creator>YASH</dc:creator><description>&lt;p&gt;Thank You so much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92262?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2017 12:49:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:535e9a04-6b6f-4686-8dfb-5bd6e2f2fd6b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;This was not meant as a full example. You need to merge it into the SPI example from the SDK. m_rx_buffer, rx_length, spi_xfer_done, m_tx_buf, m_length, m_rx_buf, amd m_length is defined there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92260?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2017 12:46:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a87ea274-6e53-4b8e-8970-a85120bc5053</guid><dc:creator>YASH</dc:creator><description>&lt;p&gt;Thank You so much. Sorry to bother you again, i am a beginner, but i am getting an error from here:-&lt;/p&gt;
&lt;p&gt;// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, m_length);
spi_xfer_done = false;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));

    while (!spi_xfer_done)
    {
        __WFE();
    }
    nrf_drv_spi_switch_chips(&amp;amp;spi, SPI_SS_PIN_2);

    APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));

    while (!spi_xfer_done)
    {
        __WFE();
    }
    nrf_drv_spi_switch_chips(&amp;amp;spi, SPI_SS_PIN_1);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it is saying these are undefined:-
m_rx_buffer, rx_length, spi_xfer_done, m_tx_buf, m_length, m_rx_buf, m_length,&lt;/p&gt;
&lt;p&gt;Please help me out.&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: a Nrf52 function mapping to nrf51</title><link>https://devzone.nordicsemi.com/thread/92259?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2017 11:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b71eeb5-212d-44f7-af39-999ea6e05d99</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I looked into this futher, and don&amp;#39;t understand exactly how the solution is meant to work. I propose the following alternative, which require less changes to the files:&lt;/p&gt;
&lt;p&gt;Declare the function &lt;code&gt;nrf_drv_spi_switch_chips()&lt;/code&gt; in &lt;em&gt;nrf_drv_spi.h&lt;/em&gt;, right below &lt;code&gt;nrf_drv_spi_uninit()&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void nrf_drv_spi_switch_chips( nrf_drv_spi_t const * const p_instance,
                               uint32_t                    chip_select );
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Implement the function in &lt;em&gt;nrf_drv_spi.c&lt;/em&gt; (below &lt;code&gt;nrf_drv_spi_uninit()&lt;/code&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void nrf_drv_spi_switch_chips( nrf_drv_spi_t const * const p_instance,
                               uint32_t                    chip_select )
{
    spi_control_block_t * p_cb  = &amp;amp;m_cb[p_instance-&amp;gt;drv_inst_idx];
    p_cb-&amp;gt;ss_pin = chip_select;

    //A Slave select must be set as high before setting it as output,
    //because during connect it to the pin it causes glitches.
    nrf_gpio_pin_set(p_cb-&amp;gt;ss_pin);
    nrf_gpio_cfg_output(p_cb-&amp;gt;ss_pin);
    nrf_gpio_pin_set(p_cb-&amp;gt;ss_pin);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can now call the function with the SPI instance and SS pin as argument from any files including &lt;em&gt;nrf_drv_spi.h&lt;/em&gt; (modified SPI master example from SDK 12.3.0):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */
#define SPI_SS_PIN_1 29
#define SPI_SS_PIN_2 30

...

int main(void)
{
    NRF_LOG_INFO(&amp;quot;SPI example\r\n&amp;quot;);

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS_PIN;
    spi_config.miso_pin = SPI_MISO_PIN;
    spi_config.mosi_pin = SPI_MOSI_PIN;
    spi_config.sck_pin  = SPI_SCK_PIN;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler));

    while (1)
    {
        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;

        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));

        while (!spi_xfer_done)
        {
            __WFE();
        }
        nrf_drv_spi_switch_chips(&amp;amp;spi, SPI_SS_PIN_2);

        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));

        while (!spi_xfer_done)
        {
            __WFE();
        }
        nrf_drv_spi_switch_chips(&amp;amp;spi, SPI_SS_PIN_1);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>