38 #ifndef __CORE_CMFUNC_H 39 #define __CORE_CMFUNC_H 48 #if defined ( __CC_ARM ) 51 #if (__ARMCC_VERSION < 400677) 52 #error "Please use ARM Compiler Toolchain V4.0.677 or later!" 64 __STATIC_INLINE uint32_t __get_CONTROL(
void)
66 register uint32_t __regControl __ASM(
"control");
77 __STATIC_INLINE
void __set_CONTROL(uint32_t control)
79 register uint32_t __regControl __ASM(
"control");
80 __regControl = control;
90 __STATIC_INLINE uint32_t __get_IPSR(
void)
92 register uint32_t __regIPSR __ASM(
"ipsr");
103 __STATIC_INLINE uint32_t __get_APSR(
void)
105 register uint32_t __regAPSR __ASM(
"apsr");
116 __STATIC_INLINE uint32_t __get_xPSR(
void)
118 register uint32_t __regXPSR __ASM(
"xpsr");
129 __STATIC_INLINE uint32_t __get_PSP(
void)
131 register uint32_t __regProcessStackPointer __ASM(
"psp");
132 return(__regProcessStackPointer);
142 __STATIC_INLINE
void __set_PSP(uint32_t topOfProcStack)
144 register uint32_t __regProcessStackPointer __ASM(
"psp");
145 __regProcessStackPointer = topOfProcStack;
155 __STATIC_INLINE uint32_t __get_MSP(
void)
157 register uint32_t __regMainStackPointer __ASM(
"msp");
158 return(__regMainStackPointer);
168 __STATIC_INLINE
void __set_MSP(uint32_t topOfMainStack)
170 register uint32_t __regMainStackPointer __ASM(
"msp");
171 __regMainStackPointer = topOfMainStack;
181 __STATIC_INLINE uint32_t __get_PRIMASK(
void)
183 register uint32_t __regPriMask __ASM(
"primask");
184 return(__regPriMask);
194 __STATIC_INLINE
void __set_PRIMASK(uint32_t priMask)
196 register uint32_t __regPriMask __ASM(
"primask");
197 __regPriMask = (priMask);
201 #if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) 208 #define __enable_fault_irq __enable_fiq 216 #define __disable_fault_irq __disable_fiq 225 __STATIC_INLINE uint32_t __get_BASEPRI(
void)
227 register uint32_t __regBasePri __ASM(
"basepri");
228 return(__regBasePri);
238 __STATIC_INLINE
void __set_BASEPRI(uint32_t basePri)
240 register uint32_t __regBasePri __ASM(
"basepri");
241 __regBasePri = (basePri & 0xff);
251 __STATIC_INLINE uint32_t __get_FAULTMASK(
void)
253 register uint32_t __regFaultMask __ASM(
"faultmask");
254 return(__regFaultMask);
264 __STATIC_INLINE
void __set_FAULTMASK(uint32_t faultMask)
266 register uint32_t __regFaultMask __ASM(
"faultmask");
267 __regFaultMask = (faultMask & (uint32_t)1);
273 #if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) 281 __STATIC_INLINE uint32_t __get_FPSCR(
void)
283 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 284 register uint32_t __regfpscr __ASM(
"fpscr");
298 __STATIC_INLINE
void __set_FPSCR(uint32_t fpscr)
300 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 301 register uint32_t __regfpscr __ASM(
"fpscr");
302 __regfpscr = (fpscr);
309 #elif defined ( __GNUC__ ) 317 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __enable_irq(
void)
319 __ASM
volatile (
"cpsie i" : : :
"memory");
328 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __disable_irq(
void)
330 __ASM
volatile (
"cpsid i" : : :
"memory");
340 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(
void)
344 __ASM
volatile (
"MRS %0, control" :
"=r" (result) );
355 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_CONTROL(uint32_t control)
357 __ASM
volatile (
"MSR control, %0" : :
"r" (control) :
"memory");
367 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(
void)
371 __ASM
volatile (
"MRS %0, ipsr" :
"=r" (result) );
382 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(
void)
386 __ASM
volatile (
"MRS %0, apsr" :
"=r" (result) );
397 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(
void)
401 __ASM
volatile (
"MRS %0, xpsr" :
"=r" (result) );
412 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(
void)
414 register uint32_t result;
416 __ASM
volatile (
"MRS %0, psp\n" :
"=r" (result) );
427 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_PSP(uint32_t topOfProcStack)
429 __ASM
volatile (
"MSR psp, %0\n" : :
"r" (topOfProcStack) :
"sp");
439 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(
void)
441 register uint32_t result;
443 __ASM
volatile (
"MRS %0, msp\n" :
"=r" (result) );
454 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_MSP(uint32_t topOfMainStack)
456 __ASM
volatile (
"MSR msp, %0\n" : :
"r" (topOfMainStack) :
"sp");
466 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(
void)
470 __ASM
volatile (
"MRS %0, primask" :
"=r" (result) );
481 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_PRIMASK(uint32_t priMask)
483 __ASM
volatile (
"MSR primask, %0" : :
"r" (priMask) :
"memory");
487 #if (__CORTEX_M >= 0x03) 494 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __enable_fault_irq(
void)
496 __ASM
volatile (
"cpsie f" : : :
"memory");
505 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __disable_fault_irq(
void)
507 __ASM
volatile (
"cpsid f" : : :
"memory");
517 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(
void)
521 __ASM
volatile (
"MRS %0, basepri_max" :
"=r" (result) );
532 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_BASEPRI(uint32_t value)
534 __ASM
volatile (
"MSR basepri, %0" : :
"r" (value) :
"memory");
544 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(
void)
548 __ASM
volatile (
"MRS %0, faultmask" :
"=r" (result) );
559 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_FAULTMASK(uint32_t faultMask)
561 __ASM
volatile (
"MSR faultmask, %0" : :
"r" (faultMask) :
"memory");
567 #if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) 575 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(
void)
577 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 582 __ASM
volatile (
"VMRS %0, fpscr" :
"=r" (result) );
597 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __set_FPSCR(uint32_t fpscr)
599 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) 602 __ASM
volatile (
"VMSR fpscr, %0" : :
"r" (fpscr) :
"vfpcc");
610 #elif defined ( __ICCARM__ ) 612 #include <cmsis_iar.h> 615 #elif defined ( __TMS470__ ) 617 #include <cmsis_ccs.h> 620 #elif defined ( __TASKING__ ) 629 #elif defined ( __CSMC__ ) 631 #include <cmsis_csm.h> struct __attribute__((packed))