Hi Nordic,
I did some further research and need your assistance in figuring out this Mystery ....
recap - I'm trying to implement twi support on freertos ble project (SDK15.0) the following way -
- My target project is a copy of ble_app_hrs_freertos folder
- My reference project is twi_sensor
- Added nrfx_twi.c & nrfx_twim.c to the nRF_Drivers group of the target project (imported from <SDK_folder>\modules\nrfx\drivers\src as in the reference project)
- Included the following at the beginning of main.c:
#include <nrfx.h>
#include "sdk_config.h"
#include "nrf_drv_twi.h"
- In sdk_config.h I've enabled NRFX_TWI_ENABLED & NRFX_TWIM_ENABLED and their immediate child NRFX_TWI0_ENABLED & ERFX_TWIM0_ENABLED
- in my main.c just before main() I've copied two lines from the reference project:
/* TWI instance ID. */
#define TWI_INSTANCE_ID 0
/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID)
Mysteriously I keep getting "NRF_DRV_TWI_INSTANCE_0 undefined" error and noticed that although I've enabled TWI & TWIM in sdk_config.h they remained undef'd when looking in nrfx_twi.c & nrfx_twim.c (code grayed out). See screen capture
What make it even stranger is that in the reference project, again, both NRF_TWI_ENABLED & NRF_TWIM_ENABLED are set to 1 in sdk_config.h, but this time nrfx_twim.c become enabled while nerfx_twi.c remains grayed out...
I tried to follow the definition route and everything looks OK so I'm pretty lost here......
Thanks in advance for any support
In SDK14.2 it works fine !
- Included #include "nrf_drv_twi.h"
- added nrf_drv_twi.c from <SDK142 folder>\components\drivers_nrf\twi_master to nRF_Drivers group
- In sdk_config.h enabled TWI_ENABLE & TWI0_ENABLED
- Add twi init code
Voilla, compiles without errors
Problem solved!
Hello, eyalasko, I had the same problem, and I did exactly what you did.
I followed the NRFX_TWI0_ENABLED of the line #if NRFX_CHECK(NRFX_TWI0_ENABLED)
and it got me to this kind of transition file name apply_old_config.h and at this file NRFX_TWI0_ENABLED and NRFX_TWI_ENABLED appear as a combination of TWI0_ENABLED and TWI_ENABLED and so on, as you can see in the image below.
So I basically did the same sdk_config.h as you and also enabled TWI0_ENABLED and TWI_ENABLED and it worked like that!
Hope it also solves your issue ;) !
I think there is an error in this file apply_old_config.h
it is:
#if defined(TWI_ENABLED) #undef NRFX_TWI_ENABLED #define NRFX_TWI_ENABLED (TWI_ENABLED && (NRFX_TWI0_ENABLED || NRFX_TWI1_ENABLED))
but in sdk_config.h is
#define TWI_ENABLED 0
which actually DEFINES but does not ENABLES the preprocessor defines TWI_ENABLED
Correct should be:
#if TWI_ENABLED #undef NRFX_TWI_ENABLED #define NRFX_TWI_ENABLED (TWI_ENABLED && (NRFX_TWI0_ENABLED || NRFX_TWI1_ENABLED))
And so there comes this misunderstanding. ....
I hope this will be fixed.
Regards, Adib.