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

This NRFX crap is driving me crazy

So, another 2 hours down tonight converting to NRFX, this time it is trying to get the SPI to work.

This line -> static const nrfx_spi_t m_spi_master_0 = NRFX_SPI_INSTANCE(0);

yields the all to familiar to me now compiler error: ../nRF5_SDK_15.0.0_a53641a/modules/nrfx/drivers/include/nrfx_spi.h:86:35: error: 'NRFX_SPI0_INST_IDX' undeclared here (not in a function)

In my SDK_Config.h file (and NRFX_Config.h) I have: 

#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

I have also tried it with SPI_ENABLED 1 and 0 and also with SPI0_ENABLED 1 and 0

This cannot possibly be this complicated, how many hours is reasonable to stuff around with code that was working fine trying to get it to run on a new system ??

The example in the SDK is useless since it is still based on the nrf_drv system

WTF am I missing? 

  • OK, finally figured this out, another post led me to look at the file apply_old_config.h 

    Basically, if SPI_ENABLED is defined somewhere in the project (even if it is defined as 0), this file happily messes around with your code, undefining things that you have deliberately defined, without being obvious that it is doing so. 

    So, completely remove the lines 

    #ifndef SPI_ENABLED
    #define SPI_ENABLED 0
    #endif

    from your config file and it will work.

Related