Hello,
the well known problem of the nRF5SDK is that if you want to use nrfx drivers, you should enable in NRFX_DEFINEs and LEGACY_DEFINEs in config file. For example, we want to work with RTC0, using nrfx_rtc. So, we need setup following in sdk_config.h:
// <e> NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver //========================================================== #ifndef NRFX_RTC_ENABLED #define NRFX_RTC_ENABLED 1 #endif // <q> NRFX_RTC0_ENABLED - Enable RTC0 instance #ifndef NRFX_RTC0_ENABLED #define NRFX_RTC0_ENABLED 1 #endif ... // <e> RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer //========================================================== #ifndef RTC_ENABLED #define RTC_ENABLED 1 #endif ... // <q> RTC0_ENABLED - Enable RTC0 instance #ifndef RTC0_ENABLED #define RTC0_ENABLED 1 #endif
Of course, it's not obiously. Why we have to set RTC_ENABLED 1, if we not use nrf_drv? NRFX_RTC_ENABLED should be enough! So, abovementoined setup is not proper way (it's works, but it's not intuitive and not proper on my opinion). The proper setup is:
// <e> NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver //========================================================== #ifndef NRFX_RTC_ENABLED #define NRFX_RTC_ENABLED 1 #endif // <q> NRFX_RTC0_ENABLED - Enable RTC0 instance #ifndef NRFX_RTC0_ENABLED #define NRFX_RTC0_ENABLED 1 #endif ... // <e> RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer //========================================================== #ifndef RTC_ENABLED #define RTC_ENABLED 0 #endif ... // <q> RTC0_ENABLED - Enable RTC0 instance #ifndef RTC0_ENABLED #define RTC0_ENABLED 0 #endif
But this setup in not working. This problem coming from legacy/apply_old_config.h :
#if defined(RTC_ENABLED) #undef NRFX_RTC_ENABLED #define NRFX_RTC_ENABLED RTC_ENABLED #if defined(RTC0_ENABLED) #undef NRFX_RTC0_ENABLED #define NRFX_RTC0_ENABLED RTC0_ENABLED #endif
the condition #if defined(RTC_ENABLED) always true if RTC_ENABLE is defined. It could be 0, but it's defined. So, even if RTC_ENABLED==0, NRFX_RTC_ENABLED will be redefined. And then, in nrfx_rtc.c file all code will not be compiled because NRFX_RTC_ENABLED = RTC_ENABLED = 0.
BUT, if in the app_old_config.h the check would not be for a definition, but for equal to 1, it will work. I mean:
// instead this: #if defined(RTC_ENABLED) #undef NRFX_RTC_ENABLED #define NRFX_RTC_ENABLED RTC_ENABLED // this #if (RTC_ENABLED == 1) #undef NRFX_RTC_ENABLED #define NRFX_RTC_ENABLED RTC_ENABLED
Of course I can do it by myself, but I don't want to modify SDK files. Another option is to remove #define RTC_ENABLE 0 from sdk_config.h, but I don't want to modify code of this file, I work with this file using CMSIS Wizard.
So my question is why Nordic team don't design apply_old_config.h file by proposed way?