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

If the softdevice is enabled, can I call the function of "nrf_mtx.h"? If I could, would something bad happen?

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;
}

Parents Reply Children
Related