Atomic operations API

nRF5 SDK v17.1.0

This module implements C11 stdatomic.h simplified API. More...

Typedefs

typedef volatile uint32_t nrfx_atomic_u32_t
Atomic 32-bit unsigned type.
typedef volatile uint32_t nrfx_atomic_flag_t
Atomic 1-bit flag type (technically 32-bit).

Functions

uint32_t nrfx_atomic_u32_fetch_store ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for storing a value to an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_u32_store ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for storing a value to an atomic object and returning its new value. More...
uint32_t nrfx_atomic_u32_fetch_or ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running a logical OR operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_u32_or ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running a logical OR operation on an atomic object and returning its new value. More...
uint32_t nrfx_atomic_u32_fetch_and ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running a logical AND operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_u32_and ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running a logical AND operation on an atomic object and returning its new value. More...
uint32_t nrfx_atomic_u32_fetch_xor ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running a logical XOR operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_u32_xor ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running a logical XOR operation on an atomic object and returning its new value. More...
uint32_t nrfx_atomic_u32_fetch_add ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running an arithmetic ADD operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_u32_add ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running an arithmetic ADD operation on an atomic object and returning its new value. More...
uint32_t nrfx_atomic_u32_fetch_sub ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running an arithmetic SUB operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_u32_sub ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running an arithmetic SUB operation on an atomic object and returning its new value. More...
bool nrfx_atomic_u32_cmp_exch ( nrfx_atomic_u32_t *p_data, uint32_t *p_expected, uint32_t desired)
Function for atomic conditional value replacement. More...
uint32_t nrfx_atomic_u32_fetch_sub_hs ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running an arithmetic SUB operation on an atomic object if object >= value, and returning its previous value. More...
uint32_t nrfx_atomic_u32_sub_hs ( nrfx_atomic_u32_t *p_data, uint32_t value)
Function for running an arithmetic SUB operation on an atomic object if object >= value, and returning its new value. More...
uint32_t nrfx_atomic_flag_set_fetch ( nrfx_atomic_flag_t *p_data)
Function for running a logical one bit flag set operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_flag_set ( nrfx_atomic_flag_t *p_data)
Function for running a logical one bit flag set operation on an atomic object and returning its new value. More...
uint32_t nrfx_atomic_flag_clear_fetch ( nrfx_atomic_flag_t *p_data)
Function for running a logical one bit flag clear operation on an atomic object and returning its previous value. More...
uint32_t nrfx_atomic_flag_clear ( nrfx_atomic_flag_t *p_data)
Function for running a logical one bit flag clear operation on an atomic object and returning its new value. More...

Detailed Description

This module implements C11 stdatomic.h simplified API.

At this point, only Cortex-M3 and M4 cores are supported (LDREX/STREX instructions). Atomic types are limited to nrfx_atomic_u32_t and nrfx_atomic_flag_t .

Function Documentation

uint32_t nrfx_atomic_flag_clear ( nrfx_atomic_flag_t * p_data )

Function for running a logical one bit flag clear operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic flag memory pointer.
Returns
New flag value.
uint32_t nrfx_atomic_flag_clear_fetch ( nrfx_atomic_flag_t * p_data )

Function for running a logical one bit flag clear operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic flag memory pointer.
Returns
Previous flag value.
uint32_t nrfx_atomic_flag_set ( nrfx_atomic_flag_t * p_data )

Function for running a logical one bit flag set operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic flag memory pointer.
Returns
New flag value.
uint32_t nrfx_atomic_flag_set_fetch ( nrfx_atomic_flag_t * p_data )

Function for running a logical one bit flag set operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic flag memory pointer.
Returns
Previous flag value.
uint32_t nrfx_atomic_u32_add ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running an arithmetic ADD operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the ADD operation.
Returns
New value stored in the atomic object.
uint32_t nrfx_atomic_u32_and ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running a logical AND operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the AND operation.
Returns
New value stored in the atomic object.
bool nrfx_atomic_u32_cmp_exch ( nrfx_atomic_u32_t * p_data ,
uint32_t * p_expected ,
uint32_t desired
)

Function for atomic conditional value replacement.

Atomically compares the value pointed to by p_data with the value pointed to by p_expected . If those are equal, replaces the former with desired. Otherwise, loads the actual value pointed to by p_data into *p_expected .

Parameters
p_data Atomic memory pointer to test and modify.
p_expected Pointer to the test value.
desired Value to be stored to atomic memory.
Return values
true *p_data was equal to *p_expected .
false *p_data was not equal to *p_expected .
uint32_t nrfx_atomic_u32_fetch_add ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running an arithmetic ADD operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the ADD operation.
Returns
Previous value stored in the atomic object.
uint32_t nrfx_atomic_u32_fetch_and ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running a logical AND operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the AND operation.
Returns
Previous value stored in the atomic object.
uint32_t nrfx_atomic_u32_fetch_or ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running a logical OR operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the OR operation.
Returns
Previous value stored in the atomic object.
uint32_t nrfx_atomic_u32_fetch_store ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for storing a value to an atomic object and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value to store.
Returns
Previous value stored in the atomic object.
uint32_t nrfx_atomic_u32_fetch_sub ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running an arithmetic SUB operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the SUB operation.
Returns
Old value stored in the atomic object.
uint32_t nrfx_atomic_u32_fetch_sub_hs ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running an arithmetic SUB operation on an atomic object if object >= value, and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the SUB operation.
Returns
Previous value stored in the atomic object.
uint32_t nrfx_atomic_u32_fetch_xor ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running a logical XOR operation on an atomic object and returning its previous value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the XOR operation.
Returns
Previous value stored in the atomic object.
uint32_t nrfx_atomic_u32_or ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running a logical OR operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the OR operation.
Returns
New value stored in the atomic object.
uint32_t nrfx_atomic_u32_store ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for storing a value to an atomic object and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value to store.
Returns
New value stored in the atomic object.
uint32_t nrfx_atomic_u32_sub ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running an arithmetic SUB operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the SUB operation.
Returns
New value stored in the atomic object.
uint32_t nrfx_atomic_u32_sub_hs ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running an arithmetic SUB operation on an atomic object if object >= value, and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the SUB operation.
Returns
New value stored in the atomic object.
uint32_t nrfx_atomic_u32_xor ( nrfx_atomic_u32_t * p_data ,
uint32_t value
)

Function for running a logical XOR operation on an atomic object and returning its new value.

Parameters
[in] p_data Atomic memory pointer.
[in] value Value of the second operand in the XOR operation.
Returns
New value stored in the atomic object.