firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
atomic.h File Reference

FreeRTOS atomic operation support. More...

#include <stdint.h>
Include dependency graph for atomic.h:

Go to the source code of this file.

Macros

#define ATOMIC_ENTER_CRITICAL()
#define ATOMIC_EXIT_CRITICAL()
#define portFORCE_INLINE
#define ATOMIC_COMPARE_AND_SWAP_SUCCESS   0x1U
#define ATOMIC_COMPARE_AND_SWAP_FAILURE   0x0U

Functions

static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32 (uint32_t volatile *pulDestination, uint32_t ulExchange, uint32_t ulComparand)
 Performs an atomic compare-and-swap operation on the specified values.
static portFORCE_INLINE void * Atomic_SwapPointers_p32 (void *volatile *ppvDestination, void *pvExchange)
 Atomically sets the address pointed to by *ppvDestination to the value of *pvExchange.
static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32 (void *volatile *ppvDestination, void *pvExchange, void *pvComparand)
 Performs an atomic compare-and-swap operation on the specified pointer values.
static portFORCE_INLINE uint32_t Atomic_Add_u32 (uint32_t volatile *pulAddend, uint32_t ulCount)
 Atomically adds count to the value of the specified pointer points to.
static portFORCE_INLINE uint32_t Atomic_Subtract_u32 (uint32_t volatile *pulAddend, uint32_t ulCount)
 Atomically subtracts count from the value of the specified pointer pointers to.
static portFORCE_INLINE uint32_t Atomic_Increment_u32 (uint32_t volatile *pulAddend)
 Atomically increments the value of the specified pointer points to.
static portFORCE_INLINE uint32_t Atomic_Decrement_u32 (uint32_t volatile *pulAddend)
 Atomically decrements the value of the specified pointer points to.
static portFORCE_INLINE uint32_t Atomic_OR_u32 (uint32_t volatile *pulDestination, uint32_t ulValue)
 Performs an atomic OR operation on the specified values.
static portFORCE_INLINE uint32_t Atomic_AND_u32 (uint32_t volatile *pulDestination, uint32_t ulValue)
 Performs an atomic AND operation on the specified values.
static portFORCE_INLINE uint32_t Atomic_NAND_u32 (uint32_t volatile *pulDestination, uint32_t ulValue)
 Performs an atomic NAND operation on the specified values.
static portFORCE_INLINE uint32_t Atomic_XOR_u32 (uint32_t volatile *pulDestination, uint32_t ulValue)
 Performs an atomic XOR operation on the specified values.

Detailed Description

FreeRTOS atomic operation support.

This file implements atomic functions by disabling interrupts globally. Implementations with architecture specific atomic instructions can be provided under each compiler directory.

The atomic interface can be used in FreeRTOS tasks on all FreeRTOS ports. It can also be used in Interrupt Service Routines (ISRs) on FreeRTOS ports that support nested interrupts (i.e. portHAS_NESTED_INTERRUPTS is set to 1). The atomic interface must not be used in ISRs on FreeRTOS ports that do not support nested interrupts (i.e. portHAS_NESTED_INTERRUPTS is set to 0) because ISRs on these ports cannot be interrupted and therefore, do not need atomics in ISRs.

Macro Definition Documentation

◆ ATOMIC_COMPARE_AND_SWAP_FAILURE

#define ATOMIC_COMPARE_AND_SWAP_FAILURE   0x0U

Compare and swap failed, did not swap.

◆ ATOMIC_COMPARE_AND_SWAP_SUCCESS

#define ATOMIC_COMPARE_AND_SWAP_SUCCESS   0x1U

Compare and swap succeeded, swapped.

◆ ATOMIC_ENTER_CRITICAL

#define ATOMIC_ENTER_CRITICAL ( )
Value:
#define portENTER_CRITICAL()
Definition portmacro.h:120

◆ ATOMIC_EXIT_CRITICAL

#define ATOMIC_EXIT_CRITICAL ( )
Value:
#define portEXIT_CRITICAL()
Definition portmacro.h:121

◆ portFORCE_INLINE

#define portFORCE_INLINE

Function Documentation

◆ Atomic_Add_u32()

portFORCE_INLINE uint32_t Atomic_Add_u32 ( uint32_t volatile * pulAddend,
uint32_t ulCount )
static

Atomically adds count to the value of the specified pointer points to.

Atomic add

Parameters
[in,out]pulAddendPointer to memory location from where value is to be loaded and written back to.
[in]ulCountValue to be added to *pulAddend.
Returns
previous *pulAddend value.

◆ Atomic_AND_u32()

portFORCE_INLINE uint32_t Atomic_AND_u32 ( uint32_t volatile * pulDestination,
uint32_t ulValue )
static

Performs an atomic AND operation on the specified values.

Atomic AND

Parameters
[in,out]pulDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be ANDed with *pulDestination.
Returns
The original value of *pulDestination.

◆ Atomic_CompareAndSwap_u32()

portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32 ( uint32_t volatile * pulDestination,
uint32_t ulExchange,
uint32_t ulComparand )
static

Performs an atomic compare-and-swap operation on the specified values.

Atomic compare-and-swap

Parameters
[in,out]pulDestinationPointer to memory location from where value is to be loaded and checked.
[in]ulExchangeIf condition meets, write this value to memory.
[in]ulComparandSwap condition.
Returns
Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
Note
This function only swaps *pulDestination with ulExchange, if previous *pulDestination value equals ulComparand.

◆ Atomic_CompareAndSwapPointers_p32()

portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32 ( void *volatile * ppvDestination,
void * pvExchange,
void * pvComparand )
static

Performs an atomic compare-and-swap operation on the specified pointer values.

Atomic compare-and-swap (pointers)

Parameters
[in,out]ppvDestinationPointer to memory location from where a pointer value is to be loaded and checked.
[in]pvExchangeIf condition meets, write this value to memory.
[in]pvComparandSwap condition.
Returns
Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
Note
This function only swaps *ppvDestination with pvExchange, if previous *ppvDestination value equals pvComparand.

◆ Atomic_Decrement_u32()

portFORCE_INLINE uint32_t Atomic_Decrement_u32 ( uint32_t volatile * pulAddend)
static

Atomically decrements the value of the specified pointer points to.

Atomic decrement

Parameters
[in,out]pulAddendPointer to memory location from where value is to be loaded and written back to.
Returns
*pulAddend value before decrement.

◆ Atomic_Increment_u32()

portFORCE_INLINE uint32_t Atomic_Increment_u32 ( uint32_t volatile * pulAddend)
static

Atomically increments the value of the specified pointer points to.

Atomic increment

Parameters
[in,out]pulAddendPointer to memory location from where value is to be loaded and written back to.
Returns
*pulAddend value before increment.

◆ Atomic_NAND_u32()

portFORCE_INLINE uint32_t Atomic_NAND_u32 ( uint32_t volatile * pulDestination,
uint32_t ulValue )
static

Performs an atomic NAND operation on the specified values.

Atomic NAND

Parameters
[in,out]pulDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be NANDed with *pulDestination.
Returns
The original value of *pulDestination.

◆ Atomic_OR_u32()

portFORCE_INLINE uint32_t Atomic_OR_u32 ( uint32_t volatile * pulDestination,
uint32_t ulValue )
static

Performs an atomic OR operation on the specified values.

Atomic OR

Parameters
[in,out]pulDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be ORed with *pulDestination.
Returns
The original value of *pulDestination.

◆ Atomic_Subtract_u32()

portFORCE_INLINE uint32_t Atomic_Subtract_u32 ( uint32_t volatile * pulAddend,
uint32_t ulCount )
static

Atomically subtracts count from the value of the specified pointer pointers to.

Atomic subtract

Parameters
[in,out]pulAddendPointer to memory location from where value is to be loaded and written back to.
[in]ulCountValue to be subtract from *pulAddend.
Returns
previous *pulAddend value.

◆ Atomic_SwapPointers_p32()

portFORCE_INLINE void * Atomic_SwapPointers_p32 ( void *volatile * ppvDestination,
void * pvExchange )
static

Atomically sets the address pointed to by *ppvDestination to the value of *pvExchange.

Atomic swap (pointers)

Parameters
[in,out]ppvDestinationPointer to memory location from where a pointer value is to be loaded and written back to.
[in]pvExchangePointer value to be written to *ppvDestination.
Returns
The initial value of *ppvDestination.

◆ Atomic_XOR_u32()

portFORCE_INLINE uint32_t Atomic_XOR_u32 ( uint32_t volatile * pulDestination,
uint32_t ulValue )
static

Performs an atomic XOR operation on the specified values.

Atomic XOR

Parameters
[in,out]pulDestinationPointer to memory location from where value is to be loaded and written back to.
[in]ulValueValue to be XORed with *pulDestination.
Returns
The original value of *pulDestination.