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

Fullscreen
1
2
3
#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. */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// <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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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