Hi.
As the subject said,I want to know that if the softdevice is enabled, can I call the function of "nrf_mtx.h"?
such as:
Hi.
As the subject said,I want to know that if the softdevice is enabled, can I call the function of "nrf_mtx.h"?
such as:
__STATIC_INLINE bool nrf_mtx_trylock(nrf_mtx_t * p_mtx) { ASSERT(p_mtx != NULL); uint32_t old_val = nrf_atomic_u32_fetch_store(p_mtx, NRF_MTX_LOCKED); // Add memory barrier to ensure that the mutex is locked before any memory operations protected // by the mutex are started. __DMB(); return (old_val == NRF_MTX_UNLOCKED); } __STATIC_INLINE void nrf_mtx_unlock(nrf_mtx_t * p_mtx) { ASSERT(p_mtx != NULL); ASSERT(*p_mtx == NRF_MTX_LOCKED); // Add memory barrier to ensure that any memory operations protected by the mutex complete // before the mutex is unlocked. __DMB(); *p_mtx = NRF_MTX_UNLOCKED; }
Hi
When using the SoftDevice, I would suggest using the sd_mutex functions which are an implementation of mutex that can be used by the application. The mutex functionality itself is handled by the SoftDevice, and due to the characteristics of SVC calls in the ARM architecture, it's atomic. When the SoftDevice is running, you can never interrupt the "lower stack" interrupts. Here, the mutex is atomic, in the sense that grabbing/releasing it is a process that can't be interrupted as it will run through the SoftDevice supervisor call.
Best regards,
Simon
Hi
Yes, if you're using the nrf_mtx library in an application also sporting the SoftDevice the nrf_mtx functions will be prone to interrupts by the SoftDevice. The sd_mutex functions will be handled by the SoftDevice itself, so the SoftDevice will make sure that it won't be interrupted.
Best regards,
Simon