nrfx 2.10
Functions
Generic flag allocator

Generic flag allocator. More...

Functions

__STATIC_INLINE void nrfx_flag32_init (nrfx_atomic_t *p_mask, uint32_t init_mask)
 Function for initializing allocator mask. More...
 
bool nrfx_flag32_is_allocated (nrfx_atomic_t mask, uint8_t bitpos)
 Function for checking if given flag is allocated. More...
 
nrfx_err_t nrfx_flag32_alloc (nrfx_atomic_t *p_mask, uint8_t *p_flag)
 Function for allocating a flag in the mask. More...
 
nrfx_err_t nrfx_flag32_free (nrfx_atomic_t *p_mask, uint8_t flag)
 Function for freeing a flag allocated with nrfx_flag32_alloc. More...
 

Detailed Description

Generic flag allocator.

Function Documentation

◆ nrfx_flag32_alloc()

nrfx_err_t nrfx_flag32_alloc ( nrfx_atomic_t p_mask,
uint8_t *  p_flag 
)

Function for allocating a flag in the mask.

Note
Function is thread safe, it uses NRFX_ATOMIC_CAS macro. No further synchronization mechanism is needed, provided the macro is properly implemented (see nrfx_glue.h).

Mask must be initialized before first allocation. Flags are allocated from the highest bit position, e.g. if mask is set to 0x0000000A, 3 is returned and bit 3 is cleared in the mask. Mask is set to 0x00000002 on return after successful allocation.

Parameters
[in,out]p_maskMask with available flags set. On successful allocation flag is cleared.
[out]p_flagIndex of the allocated flag.
Return values
NRFX_SUCCESSAllocation was successful.
NRFX_ERROR_NO_MEMNo resource available.

◆ nrfx_flag32_free()

nrfx_err_t nrfx_flag32_free ( nrfx_atomic_t p_mask,
uint8_t  flag 
)

Function for freeing a flag allocated with nrfx_flag32_alloc.

Note
Function is thread safe, it uses NRFX_ATOMIC_CAS macro. No further synchronization mechanism is needed, provided the macro is properly implemented (see nrfx_glue.h).
Parameters
[in,out]p_maskMask with available flags set. On successful allocation flag is set.
[in]flagFlag index.
Return values
NRFX_SUCCESSFreeing was successful.
NRFX_ERROR_INVALID_PARAMFlag was not allocated.

◆ nrfx_flag32_init()

__STATIC_INLINE void nrfx_flag32_init ( nrfx_atomic_t p_mask,
uint32_t  init_mask 
)

Function for initializing allocator mask.

Initialization value contains mask where each bit indicates availablility of a given flag, e.g. init value 0x0000000A indicates that flag 3 and 1 (counting from 0) can be allocated.

Alternatively, mask can be set to init value by direct assignment.

Parameters
[out]p_maskMask to be initilized.
[in]init_maskMask with pool of available flags where bit being set means that flag is free and can be allocated.

◆ nrfx_flag32_is_allocated()

bool nrfx_flag32_is_allocated ( nrfx_atomic_t  mask,
uint8_t  bitpos 
)

Function for checking if given flag is allocated.

Note
This check may not be valid if context is preempted and state is changed.
Parameters
[in]maskMask.
[in]bitposFlag bit position.
Returns
True if specified flag is allocated, false otherwise.

Documentation feedback | Developer Zone | Subscribe | Updated