2.6.2 CMSIS Functions

ISO/IEC C code cannot directly access some Cortex-M3 processor instructions. This section describes intrinsic functions that can generate these instructions, provided by the CMSIS and that might be provided by a C compiler. If a C compiler does not support an appropriate intrinsic function, you might have to use inline assembler to access some instructions.

The following table lists the intrinsic functions that the CMSIS provides to generate instructions that ISO/IEC C code cannot directly access.

Table 2-21. CMSIS Functions to Generate some Cortex-M3 Processor instructions
InstructionCMSIS function
CPSIE Ivoid __enable_irq(void)
CPSID Ivoid __disable_irq(void)
CPSIE Fvoid __enable_fault_irq(void)
CPSID Fvoid __disable_fault_irq(void)
ISBvoid __ISB(void)
DSBvoid __DSB(void)
DMBvoid __DMB(void)
REVuint32_t __REV(uint32_t int value)
REV16uint32_t __REV16(uint32_t int value)
REVSHuint32_t __REVSH(uint32_t int value)
RBITuint32_t __RBIT(uint32_t int value)
SEVvoid __SEV(void)
WFEvoid __WFE(void)
WFIvoid __WFI(void)

The following table lists the functions that CMSIS provides for accessing the special registers using MRS and MSR instructions.

Table 2-22. CMSIS Functions to Access the Special Registers
Special RegisterAccessCMSIS function
PRIMASKReaduint32_t __get_PRIMASK (void)
Writevoid __set_PRIMASK (uint32_t value)
FAULTMASKReaduint32_t __get_FAULTMASK (void)
Writevoid __set_FAULTMASK (uint32_t value)
BASEPRIReaduint32_t __get_BASEPRI (void)
Writevoid __set_BASEPRI (uint32_t value)
CONTROLReaduint32_t __get_CONTROL (void)
Writevoid __set_CONTROL (uint32_t value)
MSPReaduint32_t __get_MSP (void)
Writevoid __set_MSP (uint32_t TopOfMainStack)
PSPReaduint32_t __get_PSP (void)
Writevoid __set_PSP (uint32_t TopOfProcStack)