2.2.7. Programming hints for the synchronization primitives

ISO/IEC C cannot directly generate the exclusive access instructions. CMSIS provides intrinsic functions for generation of these instructions:

Table 2.13. CMSIS functions for exclusive access instructions

InstructionCMSIS function
LDREXuint32_t __LDREXW (uint32_t *addr)
LDREXHuint16_t __LDREXH (uint16_t *addr)
LDREXBuint8_t __LDREXB (uint8_t *addr)
STREXuint32_t __STREXW (uint32_t value, uint32_t *addr)
STREXHuint32_t __STREXH (uint16_t value, uint16_t *addr)
STREXBuint32_t __STREXB (uint8_t value, uint8_t *addr)
CLREXvoid __CLREX (void)

For example:

uint16_t  value                ;
uint16_t *address = 0x20001002 ;
value = __LDREXH (address)     ;    // load 16-bit value from memory address 0x20001002
Copyright © 2015, 2018 Arm. All rights reserved.ARM DUI 0646C