Go to the documentation of this file.
19 #ifndef ATOMIC_UTILS_ARCH_H
20 #define ATOMIC_UTILS_ARCH_H
24 #include "periph_cpu.h"
33 #define HAS_ATOMIC_LOAD_U8
36 return __atomic_load_1(var, __ATOMIC_SEQ_CST);
39 #define HAS_ATOMIC_LOAD_U16
42 return __atomic_load_2(var, __ATOMIC_SEQ_CST);
45 #define HAS_ATOMIC_LOAD_U32
48 return __atomic_load_4(var, __ATOMIC_SEQ_CST);
51 #define HAS_ATOMIC_STORE_U8
54 __atomic_store_1(dest, val, __ATOMIC_SEQ_CST);
57 #define HAS_ATOMIC_STORE_U16
60 __atomic_store_2(dest, val, __ATOMIC_SEQ_CST);
63 #define HAS_ATOMIC_STORE_U32
66 __atomic_store_4(dest, val, __ATOMIC_SEQ_CST);
72 #define HAS_ATOMIC_BIT
79 static inline void __attribute__((always_inline)) _bit_barrier_pre(
void)
81 __asm__
volatile (
"" : : :
"memory");
84 static inline void __attribute__((always_inline)) _bit_barrier_post(
void)
86 __asm__
volatile (
"" : : :
"memory");
89 static inline bool _is_addr_valid_for_bitbanding(
void *_addr)
93 uintptr_t addr = (uintptr_t)_addr;
94 if ((addr < 0x20000000UL) || (addr > 0x400fffffUL)) {
98 if ((addr >= 0x200fffffUL) && (addr < 0x40000000UL)) {
107 assert(_is_addr_valid_for_bitbanding(dest));
113 assert(_is_addr_valid_for_bitbanding(dest));
119 assert(_is_addr_valid_for_bitbanding(dest));
125 assert(_is_addr_valid_for_bitbanding(dest));
static atomic_bit_u32_t atomic_bit_u32(uint32_t *dest, uint8_t bit)
Create a reference to a bit in an uint32_t
Type specifying a bit in an uint64_t
static atomic_bit_u8_t atomic_bit_u8(uint8_t *dest, uint8_t bit)
Create a reference to a bit in an uint8_t
static void atomic_store_u32(uint32_t *dest, uint32_t val)
Store an uint32_t atomically.
#define assert(cond)
abort the program if assertion is false
static volatile void * bitband_addr(volatile void *ptr, uintptr_t bit)
Convert bit band region address and bit number to bit band alias address.
static void atomic_clear_bit_u32(atomic_bit_u32_t bit)
Atomic version of *dest &= ~(1 << bit)
static void atomic_clear_bit_u16(atomic_bit_u16_t bit)
Atomic version of *dest &= ~(1 << bit)
static void atomic_set_bit_u16(atomic_bit_u16_t bit)
Atomic version of *dest |= (1 << bit)
static void atomic_set_bit_u8(atomic_bit_u8_t bit)
Atomic version of *dest |= (1 << bit)
static void atomic_clear_bit_u64(atomic_bit_u64_t bit)
Atomic version of *dest &= ~(1 << bit)
static void atomic_clear_bit_u8(atomic_bit_u8_t bit)
Atomic version of *dest &= ~(1 << bit)
static void atomic_store_u16(uint16_t *dest, uint16_t val)
Store an uint16_t atomically.
static uint16_t atomic_load_u16(const uint16_t *var)
Load an uint16_t atomically.
static void atomic_store_u8(uint8_t *dest, uint8_t val)
Store an uint8_t atomically.
static atomic_bit_u64_t atomic_bit_u64(uint64_t *dest, uint8_t bit)
Create a reference to a bit in an uint64_t
Type specifying a bit in an uint16_t
static atomic_bit_u16_t atomic_bit_u16(uint16_t *dest, uint8_t bit)
Create a reference to a bit in an uint16_t
static uint32_t atomic_load_u32(const uint32_t *var)
Load an uint32_t atomically.
Type specifying a bit in an uint8_t
Bit access macros for Cortex-M based CPUs.
Type specifying a bit in an uint32_t
static uint8_t atomic_load_u8(const uint8_t *var)
Load an uint8_t atomically.
static void atomic_set_bit_u32(atomic_bit_u32_t bit)
Atomic version of *dest |= (1 << bit)
static void atomic_set_bit_u64(atomic_bit_u64_t bit)
Atomic version of *dest |= (1 << bit)