This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to enable SPI2 in sdk14.2

Hi All,

i am stuck in SPI2 enable. i am using sdk 14.2 for our design in previous i am using sdk 12.0

i am simply follow these steps in 14.2 and 12.0 to enable spi2.

it will return error code 17(dec).

#define SPI2_INSTANCE 2
static const nrf_drv_spi_t spi_2; // = NRF_DRV_SPI_INSTANCE(SPI2_INSTANCE); // Error code 17
static const nrf_drv_spi_t spi_2 = NRF_DRV_SPI_INSTANCE(SPI2_INSTANCE); // error :: SPI2_IRQ not defined
void spi_2_event_handler(nrf_drv_spi_evt_t const * p_event,void * p_context)
{
    spi1TrCompleteFlag = true;
}
uint32_t spiMaster2Init(void)
{
// spi_2 init as master mode
    uint32_t ret = SPI_SUCCESS;
    nrf_drv_spi_config_t spi_2_config = NRF_DRV_SPI_DEFAULT_CONFIG;

    spi_2_config.ss_pin = SPI2_CS;
    spi_2_config.miso_pin = SPI2_MISO;
    spi_2_config.mosi_pin = SPI2_MOSI;
    spi_2_config.sck_pin = SPI2_CLK;
    spi_2_config.frequency = NRF_DRV_SPI_FREQ_4M;

    ret = nrf_drv_spi_init(&spi_2, &spi_2_config, NULL,NULL);
    return ret;
}

and in SDK_config.h

#ifndef SPI_ENABLED
#define SPI_ENABLED 1
#endif
#ifndef SPI2_ENABLED
#define SPI2_ENABLED 1
#endif
#ifndef SPI2_USE_EASY_DMA
#define SPI2_USE_EASY_DMA 1
#endif

please help me to resolved this error, in SDK 12.0 these steps is working but in 14.2 not working.

thank you.

Related