Mutex used for protecting resources. More...
Macros | |
#define | NRF_MTX_LOCKED 1 |
#define | NRF_MTX_UNLOCKED 0 |
Typedefs | |
typedef nrf_atomic_u32_t | nrf_mtx_t |
Mutex data type. More... | |
Functions | |
__STATIC_INLINE void | nrf_mtx_init (nrf_mtx_t *p_mtx) |
Initialize mutex. More... | |
__STATIC_INLINE bool | nrf_mtx_trylock (nrf_mtx_t *p_mtx) |
Try to lock a mutex. More... | |
__STATIC_INLINE void | nrf_mtx_unlock (nrf_mtx_t *p_mtx) |
Unlock a mutex. More... | |
Mutex used for protecting resources.
This module provides a mutex that can be used to ensure only one context may enter a critical section holding the lock.
typedef nrf_atomic_u32_t nrf_mtx_t |
Mutex data type.
All fields in this struct are internal, and should never be modified outside of the nrf_mtx_* functions.
__STATIC_INLINE void nrf_mtx_init | ( | nrf_mtx_t * | p_mtx | ) |
Initialize mutex.
This function must be called before nrf_mtx_trylock() and nrf_mtx_unlock() functions.
[out] | p_mtx | The mutex to be initialized. |
__STATIC_INLINE bool nrf_mtx_trylock | ( | nrf_mtx_t * | p_mtx | ) |
Try to lock a mutex.
If the mutex is already held by another context, this function will return immediately.
[in,out] | p_mtx | The mutex to be locked. |
__STATIC_INLINE void nrf_mtx_unlock | ( | nrf_mtx_t * | p_mtx | ) |
Unlock a mutex.
This function must only be called when holding the lock. Unlocking a mutex which you do not hold will give undefined behavior.
[in,out] | p_mtx | The mutex to be unlocked. |