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

Configuring SPI -- is the legacy layer required?

Hello,

I am migrating a BLE project from SDK 13.1 to SDK 15, and am running into an issue with SPI functionality.  I have followed the migration guide for 14.2 to 15, changed the variable/function/macro names as appropriate, but it still does not function.

It appears that there are now several places within  SDK 15 where NRFX_SPIM_ENABLED is defined. ( namely the sdk_config for the particular project, then again for each modules\templates\nRF52*\)

I am using NRFX_SPIM0_ENABLED for my particular project.

Also within the nrfx_glue.h, there is the include apply_old_config.h which looks like:

#undef NRFX_SPI0_ENABLED
#define NRFX_SPI0_ENABLED (SPI0_ENABLED && !SPI0_USE_EASY_DMA)
#undef NRFX_SPIM0_ENABLED
#define NRFX_SPIM0_ENABLED (SPI0_ENABLED && SPI0_USE_EASY_DMA)

I don't understand this. Isn't SPI0_ENABLED part of the legacy SPI driver? The Migration document recommends to fully implement the new NRFX drivers as the older ones will be depreciated.

Could I get some advice on this? Maybe the sdk_configs at a minimum? I have vigorously reviewed the nrfx_spi example, which has not borne fruit.

Thanks!

Parents
  • Hi,

    You do not need the legacy layer when switching to the new NRFX drivers. 

    You should remove the old config for legacy driver from sdk_config.h file, to avoid the configuration to be overwritten by apply_old_config file.

    Attached an example that show how this should be done: spi_nrfx.zip

    Best regards,
    Jørgen

  • It may be the _intention_ that the legacy driver is not required, but the configuration for it _IS_ required, due to (in my opinion) a bug in SDK 15.0 apply_old_config.h.  Here's what I wrote in response to another ticket (206140) for the same issue:

    I have the same problem, and just spent an hour tracking it down. It is caused by the legacy adapter code in apply_old_config.h, which is included from nrf_glue.h, which is included from nrfx.h, which is included from just about everything peripheral-related.

    If you're not using the legacy interface, this should leave your NRFX_SPI0_ENABLED etc. unchanged, but unfortunately it does not. If you don't also have SPI0_ENABLED, it redefines NRFX_SPI0_ENABLED to 0. In my opinion, this is a serious defect in the SDK; using the new NRFX drivers shouldn't require having the legacy defines also set.

    The workaround is to define SPI<n>_ENABLED to have the same value as NRFX_SPI<n>_ENABLED, to prevent apply_old_config from changing it.

Reply
  • It may be the _intention_ that the legacy driver is not required, but the configuration for it _IS_ required, due to (in my opinion) a bug in SDK 15.0 apply_old_config.h.  Here's what I wrote in response to another ticket (206140) for the same issue:

    I have the same problem, and just spent an hour tracking it down. It is caused by the legacy adapter code in apply_old_config.h, which is included from nrf_glue.h, which is included from nrfx.h, which is included from just about everything peripheral-related.

    If you're not using the legacy interface, this should leave your NRFX_SPI0_ENABLED etc. unchanged, but unfortunately it does not. If you don't also have SPI0_ENABLED, it redefines NRFX_SPI0_ENABLED to 0. In my opinion, this is a serious defect in the SDK; using the new NRFX drivers shouldn't require having the legacy defines also set.

    The workaround is to define SPI<n>_ENABLED to have the same value as NRFX_SPI<n>_ENABLED, to prevent apply_old_config from changing it.

Children
No Data
Related