<?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>SPI nrf52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30373/spi-nrf52832</link><description>hi, 
 I am trying to add SPI (master) codes into the ble_app_uart. 
 My setting for SPI is as follows: 
 #define SPI1_ENABLED 1 // #define SPI_INSTANCE 1 /**&amp;lt; SPI instance index. */ //#define SPI0_ENABLED 0 #define SPIM_IN_USE 0 #define SPI_IN_USE 1 </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 Feb 2019 13:19:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30373/spi-nrf52832" /><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/173044?ContentTypeID=1</link><pubDate>Tue, 26 Feb 2019 13:19:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8656a53-1b2d-4c57-afe5-db4d4245a70c</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;You&amp;#39;ve either forgot to include the necessary source/header files, or the compiler does not compile the code in the source/header files because the necessary definitions are not set in sdk_config.h.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/171546?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 07:27:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28bf0d37-1979-4b22-9d5c-83ff6c060ca4</guid><dc:creator>gauthamranganathan</dc:creator><description>&lt;p&gt;Hi haakonsh I have the exact same problem. I am unable to successfully build the project after merging SPI and ble_app_uart example. I get an undefined symbol nrfx_spi_init. (refered from nrf_drv_spi.o)&lt;/p&gt;
&lt;p&gt;can you please help me with this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/168847?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 11:10:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b036e6e-d916-447b-935a-24084cc1ff31</guid><dc:creator>Darshansm5549</dc:creator><description>&lt;p&gt;i included &amp;quot;nrf_drv_spi.h&amp;quot; in main and &amp;quot;nrf_drv_spi.c&amp;quot; in project&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/166215?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 12:31:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c0a6c0b-8cef-4bab-806c-2ed47cdb7242</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Have you included the spi driver in your project?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/166125?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 06:03:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3808f909-2f58-42e6-9dea-b3d84a93a9b1</guid><dc:creator>Darshansm5549</dc:creator><description>&lt;p&gt;Hi Haakonsh,&lt;/p&gt;
&lt;p&gt;i am trying this, i am getting error&lt;/p&gt;
&lt;p&gt;undefined reference to `nrf_drv_spi_init&amp;#39;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/120570?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2018 13:02:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62576b50-b1a4-4c04-afe1-40ed16b17ba8</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;No problem maslooo :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/120559?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2018 12:00:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92944e37-cc50-44e7-a5e0-daba7decc3eb</guid><dc:creator>masloooo</dc:creator><description>&lt;p&gt;hi haakonsh&lt;/p&gt;
&lt;p&gt;Thanks for your help, this time it went well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI nrf52832</title><link>https://devzone.nordicsemi.com/thread/120527?ContentTypeID=1</link><pubDate>Mon, 12 Feb 2018 09:20:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0906316-d4fb-47bc-a8a1-658298e4c4c7</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey maslooo,&lt;/p&gt;
&lt;p&gt;You should add the following lines of code to your sdk_config.h file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef SPI_SCK_PIN
#define SPI_SCK_PIN YOUR_PIN_NUMBER
#endif

#ifndef SPI_MISO_PIN
#define SPI_MISO_PIN YOUR_PIN_NUMBER
#endif

#ifndef SPI_MOSI_PIN
#define SPI_MOSI_PIN YOUR_PIN_NUMBER
#endif

#ifndef SPI_SS_PIN
#define SPI_SS_PIN YOUR_PIN_NUMBER
#endif


// &amp;lt;e&amp;gt; SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver
//==========================================================
#ifndef SPI_ENABLED
#define SPI_ENABLED 1
#endif
// &amp;lt;o&amp;gt; SPI_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
 

// &amp;lt;i&amp;gt; Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7 

#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 7
#endif

// &amp;lt;o&amp;gt; SPI_DEFAULT_FREQUENCY  - SPI frequency
 
// &amp;lt;33554432=&amp;gt; 125 kHz 
// &amp;lt;67108864=&amp;gt; 250 kHz 
// &amp;lt;134217728=&amp;gt; 500 kHz 
// &amp;lt;268435456=&amp;gt; 1 MHz 
// &amp;lt;536870912=&amp;gt; 2 MHz 
// &amp;lt;1073741824=&amp;gt; 4 MHz 
// &amp;lt;2147483648=&amp;gt; 8 MHz 

#ifndef SPI_DEFAULT_FREQUENCY
#define SPI_DEFAULT_FREQUENCY 1073741824
#endif

// &amp;lt;o&amp;gt; NRF_SPI_DRV_MISO_PULLUP_CFG  - MISO PIN pull-up configuration.
 
// &amp;lt;0=&amp;gt; NRF_GPIO_PIN_NOPULL 
// &amp;lt;1=&amp;gt; NRF_GPIO_PIN_PULLDOWN 
// &amp;lt;3=&amp;gt; NRF_GPIO_PIN_PULLUP 

#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG
#define NRF_SPI_DRV_MISO_PULLUP_CFG 1
#endif

// &amp;lt;e&amp;gt; SPI0_ENABLED - Enable SPI0 instance
//==========================================================
#ifndef SPI0_ENABLED
#define SPI0_ENABLED 1
#endif
// &amp;lt;q&amp;gt; SPI0_USE_EASY_DMA  - Use EasyDMA
 

#ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;main.c:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;nrf_drv_spi.h&amp;quot;

#define SPI_INSTANCE  0 /**&amp;lt; SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */
static volatile bool spi_xfer_done;  /**&amp;lt; Flag used to indicate that SPI instance completed the transfer. */

#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[] = TEST_STRING;           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */

/**
 * @brief SPI user event handler.
 * @param event
 */
void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    spi_xfer_done = true;
}

void spi_init(void)
{
    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, NULL));
}

int main(void)
{
   spi_init();
   
    while (1)
    {   /*** transfer the test string every 200ms***/
    
        // 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_delay_ms(200);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>