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

'NRFX_TWI0_INST_IDX' undeclared - possible solution and bug found

A while back I was working on I2C and came across the compiler error " 'NRFX_TWI0_INST_IDX' undeclared ", which seemed to be related to NRF drivers vs NRFX drivers confusion. I recall researching here and not finding anything. I am sorry I don't recall every little detail, but still wanted to share:

I wonder whether there is a bug in apply_old_config.h line 1116 in SDK16.0.0

It reads "#if defined(TWI_ENABLED)", and in this case #undef's a number of NRFX related defines.

Since in the sdk_config.h file (at least in many examples), TWI_ENABLED is almost always #defined (just sometimes a 0), the above statement is almost always true.

I believe the line should read something along the lines of 

#if defined(TWI_ENABLED) && (TWI_ENABLED==1)

I also recall, that apply_old_config.h is unconditionally included through many levels, starting with #include "nrfx_twi.h" in my main.c and cascading into nrfx_glue.h . Ie, you can't avoid the line above in apply_old_config.h .

An alternate solution for me was, to change the sdk_config.h line 

// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer
//==========================================================
#ifndef TWI_ENABLED
#define TWI_ENABLED 0
#endif

to

//#define TWI_ENABLED 0

Hope this is of help to someone. And maybe Nordic can review the #define in apply_old_config.h

Parents Reply Children
No Data
Related