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

NRFX_SPI instantiation fails using NRFX, why?

Hello,

I am facing a really annoying issue when updating my SPI settings from the old nrf_drv_ towards the newer one nrfx , in SDK15.  I am following the recommendtations of this link, but I am getting stuck when trying to create the SPI instance.

I follow these steps, the instantiation of the SPI is done like this

#define SPI_INSTANCE_2 2/**< SPI instance/
static const nrfx_spi_t spi = NRFX_SPI_INSTANCE(SPI_INSTANCE_2);  /**< SPI instance. */
static volatile bool spi_xfer_done;  /**< Flag used to indicate that SPI instance completed the transfer. */

I have enabled the interface in the sdk_config.h like this

// <e> NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver
//==========================================================
#ifndef NRFX_SPI_ENABLED
#define NRFX_SPI_ENABLED 1
#endif
// <q> NRFX_SPI0_ENABLED  - Enable SPI0 instance
// <q> NRFX_SPI0_ENABLED  - Enable SPI0 instance
 

#ifndef NRFX_SPI0_ENABLED
#define NRFX_SPI0_ENABLED 0
#endif

// <q> NRFX_SPI1_ENABLED  - Enable SPI1 instance
 

#ifndef NRFX_SPI1_ENABLED
#define NRFX_SPI1_ENABLED 0
#endif

// <q> NRFX_SPI2_ENABLED  - Enable SPI2 instance
 

#ifndef NRFX_SPI2_ENABLED
#define NRFX_SPI2_ENABLED 1
#endif

And I am getting the error while compiling, shown as well in the image

'NRFX_SPI2_INST_IDX' undeclared here (not in a function)

in definition of macro 'NRFX_CONCAT_3_'

in expansion of macro 'NRFX_CONCAT_3'

in expansion of macro 'NRFX_SPI_INSTANCE'

Why do I get this error and how can I ride of it? Furthermore, why is not a clear documentation of how to use the new driver ? I can reproduce the exact same problem in the SPI example if I change the SPI instance from 0 to 2 ( previously enabling SPI Instance 2 on the sdk_config.h)

Thanks

Parents
  • Any news of this in SDK 15.2?

    Looks like its still an issue.

  • OK well I have all of the above enabled but it is not being picked up in the nrfx_spi.h

    line 68 doesnt detect that this has been set to 1.

    #if NRFX_CHECK(NRFX_SPI0_ENABLED)
    NRFX_SPI0_INST_IDX,
    #endif

    From my sdk_config.h

    Legacy:

    #ifndef SPI_ENABLED
    #define SPI_ENABLED 1
    #endif

    // <e> SPI0_ENABLED - Enable SPI0 instance
    //==========================================================
    #ifndef SPI0_ENABLED
    #define SPI0_ENABLED 1
    #endif
    // <q> SPI0_USE_EASY_DMA - Use EasyDMA

    #ifndef SPI0_USE_EASY_DMA
    #define SPI0_USE_EASY_DMA 1
    #endif

    // <e> NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver
    //==========================================================
    #ifndef NRFX_SPI_ENABLED
    #define NRFX_SPI_ENABLED 1
    #endif
    // <q> NRFX_SPI0_ENABLED - Enable SPI0 instance

    #ifndef NRFX_SPI0_ENABLED
    #define NRFX_SPI0_ENABLED 1
    #endif

    So it looks like it is now only picking up if I create a nrfx_confg file.........   Is this correct? 

Reply
  • OK well I have all of the above enabled but it is not being picked up in the nrfx_spi.h

    line 68 doesnt detect that this has been set to 1.

    #if NRFX_CHECK(NRFX_SPI0_ENABLED)
    NRFX_SPI0_INST_IDX,
    #endif

    From my sdk_config.h

    Legacy:

    #ifndef SPI_ENABLED
    #define SPI_ENABLED 1
    #endif

    // <e> SPI0_ENABLED - Enable SPI0 instance
    //==========================================================
    #ifndef SPI0_ENABLED
    #define SPI0_ENABLED 1
    #endif
    // <q> SPI0_USE_EASY_DMA - Use EasyDMA

    #ifndef SPI0_USE_EASY_DMA
    #define SPI0_USE_EASY_DMA 1
    #endif

    // <e> NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver
    //==========================================================
    #ifndef NRFX_SPI_ENABLED
    #define NRFX_SPI_ENABLED 1
    #endif
    // <q> NRFX_SPI0_ENABLED - Enable SPI0 instance

    #ifndef NRFX_SPI0_ENABLED
    #define NRFX_SPI0_ENABLED 1
    #endif

    So it looks like it is now only picking up if I create a nrfx_confg file.........   Is this correct? 

Children
Related