原子操作API
出现以下:warning: implicit declaration of function ‘ATOMIC_CLEAR_BIT’ is invalid in C99 [-Wimplicit-function-declaration]
原因是直接使用ST的官方库 在stm32g4xx.h 中 缺少原子操作API在stcubemx生成的库文件中复制替换或者直接复制添加上。
/* Use of CMSIS compiler intrinsics for register exclusive access */
/* Atomic 32-bit register access macro to set one or several bits */
#define ATOMIC_SET_BIT(REG, BIT) \
do {
\
uint32_t val; \
do {
\
val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
} while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
} while(0)
/* Atomic 32-bit register access macro to clear one or several bits */
#define ATOMIC_CLEAR_BIT(REG, BIT)