NRF5 SDK legacy vs nrfx drivers

Hi Team,

I'm a little confuse regarding the legacy vs nrfx new drivers. From the documents, the majority legacy nrf is aliased to nrfx drivers via macros in the headers. To use nrfx module, I would need to enable that nrfx module in sdk_config.h I tried to add a timer module to ble_app_hrs_freertos_pca10056_s140 with nrfx timer0 but it didn't seem to work.

#define NRFX_TIMER_ENABLED 1

#define NRFX_TIMER0_ENABLED 1

But those defines are checked in 

nRF5_SDK_17.1.0_ddde560/modules/nrfx/drivers/include/nrfx_timer.h

Somehow, if when I enable legacy TIMER0_ENABLED 1 then it would work. My intention is to use nrfx, yet enabling nrfx in sdk_config.h doesn't work but enabling the legacy TIMER0_ENABLED in sdk_config.h works. I wonder why. The sdk_config.h from example ble_app_hrs_freertos_pca10056_s140 has both legacy and nrfx, but enabling nrfx doesn't do anything. This applied to PWM instance as well. Do you know why? Thanks

  • Hi,

    This can be a bit confusing. There are some exceptions where the old driver API also adds some features (typically related to coexistence with the SoftDevice), but generally the legacy API is only a set of header files with macros, and you end up wth the exact same code. So it does not matter in most cases if you use the nrfx API directly or the legacy API.

    That said, the issue you are seeing is probably related to apply_old_config.h, which is described under Continue using nrf_drv drivers. In short, as long as there are defines for the legacy API, these will be used, and will overwrite any NRFX_ defines. So you either need to remove the legacy configuration defines or set them to whatever you want the nrfx defines set to.

    As a side note, there will with high degree of certainty never some a nRF5 SDK release without the legacy API, and as the API difference is mostly handled by the preprocessor and nod runtime, it probably does not make sense to spend a lot of effort on migrating (if that causes problems).

Related