nRF5 SDK v15.2.0
Modules | Typedefs | Functions
Atomic operations API

This module implements C11 stdatomic.h simplified API. At this point only Cortex-M3/M4 cores are supported (LDREX/STREX instructions). Atomic types are limited to nrf_atomic_u32_t and nrf_atomic_flag_t. More...

Modules

 Atomic operations internals
 

Typedefs

typedef volatile uint32_t nrf_atomic_u32_t
 Atomic 32 bit unsigned type.
 
typedef volatile uint32_t nrf_atomic_flag_t
 Atomic 1 bit flag type (technically 32 bit)
 

Functions

uint32_t nrf_atomic_u32_fetch_store (nrf_atomic_u32_t *p_data, uint32_t value)
 Stores value to an atomic object. More...
 
uint32_t nrf_atomic_u32_store (nrf_atomic_u32_t *p_data, uint32_t value)
 Stores value to an atomic object. More...
 
uint32_t nrf_atomic_u32_fetch_or (nrf_atomic_u32_t *p_data, uint32_t value)
 Logical OR operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_or (nrf_atomic_u32_t *p_data, uint32_t value)
 Logical OR operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_fetch_and (nrf_atomic_u32_t *p_data, uint32_t value)
 Logical AND operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_and (nrf_atomic_u32_t *p_data, uint32_t value)
 Logical AND operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_fetch_xor (nrf_atomic_u32_t *p_data, uint32_t value)
 Logical XOR operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_xor (nrf_atomic_u32_t *p_data, uint32_t value)
 Logical XOR operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_fetch_add (nrf_atomic_u32_t *p_data, uint32_t value)
 Arithmetic ADD operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_add (nrf_atomic_u32_t *p_data, uint32_t value)
 Arithmetic ADD operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_fetch_sub (nrf_atomic_u32_t *p_data, uint32_t value)
 Arithmetic SUB operation on an atomic object. More...
 
uint32_t nrf_atomic_u32_sub (nrf_atomic_u32_t *p_data, uint32_t value)
 Arithmetic SUB operation on an atomic object. More...
 
bool nrf_atomic_u32_cmp_exch (nrf_atomic_u32_t *p_data, uint32_t *p_expected, uint32_t desired)
 If value at pointer is equal to expected value, changes value at pointer to desired. More...
 
uint32_t nrf_atomic_u32_fetch_sub_hs (nrf_atomic_u32_t *p_data, uint32_t value)
 Arithmetic SUB operation on an atomic object performed if object >= value. More...
 
uint32_t nrf_atomic_u32_sub_hs (nrf_atomic_u32_t *p_data, uint32_t value)
 Arithmetic SUB operation on an atomic object performed if object >= value. More...
 
uint32_t nrf_atomic_flag_set_fetch (nrf_atomic_flag_t *p_data)
 Logic one bit flag set operation on an atomic object. More...
 
uint32_t nrf_atomic_flag_set (nrf_atomic_flag_t *p_data)
 Logic one bit flag set operation on an atomic object. More...
 
uint32_t nrf_atomic_flag_clear_fetch (nrf_atomic_flag_t *p_data)
 Logic one bit flag clear operation on an atomic object. More...
 
uint32_t nrf_atomic_flag_clear (nrf_atomic_flag_t *p_data)
 Logic one bit flag clear operation on an atomic object. More...
 

Detailed Description

This module implements C11 stdatomic.h simplified API. At this point only Cortex-M3/M4 cores are supported (LDREX/STREX instructions). Atomic types are limited to nrf_atomic_u32_t and nrf_atomic_flag_t.

Function Documentation

uint32_t nrf_atomic_flag_clear ( nrf_atomic_flag_t p_data)

Logic one bit flag clear operation on an atomic object.

Parameters
[in]p_dataAtomic flag memory pointer
Returns
New flag value
uint32_t nrf_atomic_flag_clear_fetch ( nrf_atomic_flag_t p_data)

Logic one bit flag clear operation on an atomic object.

Parameters
[in]p_dataAtomic flag memory pointer
Returns
Old flag value
uint32_t nrf_atomic_flag_set ( nrf_atomic_flag_t p_data)

Logic one bit flag set operation on an atomic object.

Parameters
[in]p_dataAtomic flag memory pointer
Returns
New flag value
uint32_t nrf_atomic_flag_set_fetch ( nrf_atomic_flag_t p_data)

Logic one bit flag set operation on an atomic object.

Parameters
[in]p_dataAtomic flag memory pointer
Returns
Old flag value
uint32_t nrf_atomic_u32_add ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Arithmetic ADD operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand ADD operation
Returns
New value stored into atomic object
uint32_t nrf_atomic_u32_and ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Logical AND operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand AND operation
Returns
New value stored into atomic object
bool nrf_atomic_u32_cmp_exch ( nrf_atomic_u32_t p_data,
uint32_t *  p_expected,
uint32_t  desired 
)

If value at pointer is equal to expected value, changes value at pointer to desired.

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

Parameters
p_dataAtomic memory pointer to test and modify.
p_expectedPointer to test value.
desiredValue 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 nrf_atomic_u32_fetch_add ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Arithmetic ADD operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand ADD operation
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_fetch_and ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Logical AND operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand AND operation
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_fetch_or ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Logical OR operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand OR operation
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_fetch_store ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Stores value to an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue to store
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_fetch_sub ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Arithmetic SUB operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand SUB operation
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_fetch_sub_hs ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Arithmetic SUB operation on an atomic object performed if object >= value.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand SUB operation
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_fetch_xor ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Logical XOR operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand XOR operation
Returns
Old value stored into atomic object
uint32_t nrf_atomic_u32_or ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Logical OR operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand OR operation
Returns
New value stored into atomic object
uint32_t nrf_atomic_u32_store ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Stores value to an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue to store
Returns
New value stored into atomic object
uint32_t nrf_atomic_u32_sub ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Arithmetic SUB operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand SUB operation
Returns
New value stored into atomic object
uint32_t nrf_atomic_u32_sub_hs ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Arithmetic SUB operation on an atomic object performed if object >= value.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand SUB operation
Returns
New value stored into atomic object
uint32_t nrf_atomic_u32_xor ( nrf_atomic_u32_t p_data,
uint32_t  value 
)

Logical XOR operation on an atomic object.

Parameters
[in]p_dataAtomic memory pointer
[in]valueValue of second operand XOR operation
Returns
New value stored into atomic object

Documentation feedback | Developer Zone | Subscribe | Updated