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

Using SPI after disable SD

Hello,

I have got a problem with use SPI. I get hard fault after call spi_master_open(), exactly when sd_nvic_ClearPendingIRQ function is call. This situation is so specific because i use SD at the begining and after that i disable it and try to use SPI. How should i work with spi after disable SD?

Regards Michal,

Parents
  • You use SD API calls (the ones that begin with sd_) only when your softdevice is enabled. If you disable your softdevice, you should use non-sd ones, so something like NVIC_ClearPendingIRQ in this case.

  • Any sd_* function calls into the softdevice so they will all fail if you're building for softdevice use but have it disabled. So you'd need to modify them all. In the case of the pending IRQ clear, that's easy, however things like sd_nvic_critical_region_* are not, because those you really do want to call into the softdevice.

    That gives you two options, either you use the function sd_softdevice_is_enabled() everywhere you 're just about to call an sd_ function and call the equivalent NVIC function (or nothing at all), or just leave the softdevice enabled. Actually 3 options, you could also just write your own SPI driver to do what you need if the changes to the standard one are too extensive.

    for the critical enter/exit, you can decide whether you need that at all if the softdevice isn't enabled, you may not. If you do, then just disable IRQs and enable them again.

Reply
  • Any sd_* function calls into the softdevice so they will all fail if you're building for softdevice use but have it disabled. So you'd need to modify them all. In the case of the pending IRQ clear, that's easy, however things like sd_nvic_critical_region_* are not, because those you really do want to call into the softdevice.

    That gives you two options, either you use the function sd_softdevice_is_enabled() everywhere you 're just about to call an sd_ function and call the equivalent NVIC function (or nothing at all), or just leave the softdevice enabled. Actually 3 options, you could also just write your own SPI driver to do what you need if the changes to the standard one are too extensive.

    for the critical enter/exit, you can decide whether you need that at all if the softdevice isn't enabled, you may not. If you do, then just disable IRQs and enable them again.

Children
No Data
Related