25#ifndef __CMSIS_ARMCC_H
26#define __CMSIS_ARMCC_H
29#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
30 #error "Please use Arm Compiler Toolchain V4.0.677 or later!"
34#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
35 (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
36 #define __ARM_ARCH_6M__ 1
39#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
40 #define __ARM_ARCH_7M__ 1
43#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
44 #define __ARM_ARCH_7EM__ 1
51#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
52 #define __ARM_FEATURE_DSP 1
60 #define __INLINE __inline
62#ifndef __STATIC_INLINE
63 #define __STATIC_INLINE static __inline
65#ifndef __STATIC_FORCEINLINE
66 #define __STATIC_FORCEINLINE static __forceinline
69 #define __NO_RETURN __declspec(noreturn)
72 #define __USED __attribute__((used))
75 #define __WEAK __attribute__((weak))
78 #define __PACKED __attribute__((packed))
80#ifndef __PACKED_STRUCT
81 #define __PACKED_STRUCT __packed struct
84 #define __PACKED_UNION __packed union
86#ifndef __UNALIGNED_UINT32
87 #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
89#ifndef __UNALIGNED_UINT16_WRITE
90 #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
92#ifndef __UNALIGNED_UINT16_READ
93 #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
95#ifndef __UNALIGNED_UINT32_WRITE
96 #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
98#ifndef __UNALIGNED_UINT32_READ
99 #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
102 #define __ALIGNED(x) __attribute__((aligned(x)))
105 #define __RESTRICT __restrict
136 register uint32_t __regControl __ASM(
"control");
137 return(__regControl);
148 register uint32_t __regControl __ASM(
"control");
149 __regControl = control;
160 register uint32_t __regIPSR __ASM(
"ipsr");
172 register uint32_t __regAPSR __ASM(
"apsr");
184 register uint32_t __regXPSR __ASM(
"xpsr");
196 register uint32_t __regProcessStackPointer __ASM(
"psp");
197 return(__regProcessStackPointer);
208 register uint32_t __regProcessStackPointer __ASM(
"psp");
209 __regProcessStackPointer = topOfProcStack;
220 register uint32_t __regMainStackPointer __ASM(
"msp");
221 return(__regMainStackPointer);
232 register uint32_t __regMainStackPointer __ASM(
"msp");
233 __regMainStackPointer = topOfMainStack;
244 register uint32_t __regPriMask __ASM(
"primask");
245 return(__regPriMask);
256 register uint32_t __regPriMask __ASM(
"primask");
257 __regPriMask = (priMask);
261#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
262 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
269#define __enable_fault_irq __enable_fiq
277#define __disable_fault_irq __disable_fiq
285__STATIC_INLINE uint32_t __get_BASEPRI(
void)
287 register uint32_t __regBasePri __ASM(
"basepri");
288 return(__regBasePri);
297__STATIC_INLINE
void __set_BASEPRI(uint32_t basePri)
299 register uint32_t __regBasePri __ASM(
"basepri");
300 __regBasePri = (basePri & 0xFFU);
310__STATIC_INLINE
void __set_BASEPRI_MAX(uint32_t basePri)
312 register uint32_t __regBasePriMax __ASM(
"basepri_max");
313 __regBasePriMax = (basePri & 0xFFU);
322__STATIC_INLINE uint32_t __get_FAULTMASK(
void)
324 register uint32_t __regFaultMask __ASM(
"faultmask");
325 return(__regFaultMask);
334__STATIC_INLINE
void __set_FAULTMASK(uint32_t faultMask)
336 register uint32_t __regFaultMask __ASM(
"faultmask");
337 __regFaultMask = (faultMask & (uint32_t)1U);
351#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
352 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
353 register uint32_t __regfpscr __ASM(
"fpscr");
368#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
369 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
370 register uint32_t __regfpscr __ASM(
"fpscr");
371 __regfpscr = (fpscr);
423 __schedule_barrier();\
425 __schedule_barrier();\
434 __schedule_barrier();\
436 __schedule_barrier();\
445 __schedule_barrier();\
447 __schedule_barrier();\
466#ifndef __NO_EMBEDDED_ASM
481#ifndef __NO_EMBEDDED_ASM
507#define __BKPT(value) __breakpoint(value)
516#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
517 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
518 #define __RBIT __rbit
523 uint32_t s = (4U * 8U) - 1U;
526 for (value >>= 1U; value != 0U; value >>= 1U)
529 result |= value & 1U;
547#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
548 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
556#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
557 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
559 #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
569#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
570 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
572 #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
582#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
583 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
585 #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
597#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
598 #define __STREXB(value, ptr) __strex(value, ptr)
600 #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
612#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
613 #define __STREXH(value, ptr) __strex(value, ptr)
615 #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
627#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
628 #define __STREXW(value, ptr) __strex(value, ptr)
630 #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
638#define __CLREX __clrex
668#ifndef __NO_EMBEDDED_ASM
669__attribute__((section(
".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
683#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
692#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
701#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
710#define __STRBT(value, ptr) __strt(value, ptr)
719#define __STRHT(value, ptr) __strt(value, ptr)
728#define __STRT(value, ptr) __strt(value, ptr)
742 if ((sat >= 1U) && (sat <= 32U))
744 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
745 const int32_t min = -1 - max ;
769 const uint32_t max = ((1U << sat) - 1U);
770 if (val > (int32_t)max)
779 return (uint32_t)val;
794#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
796#define __SADD8 __sadd8
797#define __QADD8 __qadd8
798#define __SHADD8 __shadd8
799#define __UADD8 __uadd8
800#define __UQADD8 __uqadd8
801#define __UHADD8 __uhadd8
802#define __SSUB8 __ssub8
803#define __QSUB8 __qsub8
804#define __SHSUB8 __shsub8
805#define __USUB8 __usub8
806#define __UQSUB8 __uqsub8
807#define __UHSUB8 __uhsub8
808#define __SADD16 __sadd16
809#define __QADD16 __qadd16
810#define __SHADD16 __shadd16
811#define __UADD16 __uadd16
812#define __UQADD16 __uqadd16
813#define __UHADD16 __uhadd16
814#define __SSUB16 __ssub16
815#define __QSUB16 __qsub16
816#define __SHSUB16 __shsub16
817#define __USUB16 __usub16
818#define __UQSUB16 __uqsub16
819#define __UHSUB16 __uhsub16
822#define __SHASX __shasx
824#define __UQASX __uqasx
825#define __UHASX __uhasx
828#define __SHSAX __shsax
830#define __UQSAX __uqsax
831#define __UHSAX __uhsax
832#define __USAD8 __usad8
833#define __USADA8 __usada8
834#define __SSAT16 __ssat16
835#define __USAT16 __usat16
836#define __UXTB16 __uxtb16
837#define __UXTAB16 __uxtab16
838#define __SXTB16 __sxtb16
839#define __SXTAB16 __sxtab16
840#define __SMUAD __smuad
841#define __SMUADX __smuadx
842#define __SMLAD __smlad
843#define __SMLADX __smladx
844#define __SMLALD __smlald
845#define __SMLALDX __smlaldx
846#define __SMUSD __smusd
847#define __SMUSDX __smusdx
848#define __SMLSD __smlsd
849#define __SMLSDX __smlsdx
850#define __SMLSLD __smlsld
851#define __SMLSLDX __smlsldx
856#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
857 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
859#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
860 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
862#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
863 ((int64_t)(ARG3) << 32U) ) >> 32U))
__STATIC_INLINE void __set_CONTROL(uint32_t control)
Set Control Register.
Definition cmsis_armcc.h:146
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Set Main Stack Pointer.
Definition cmsis_armcc.h:230
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Set Process Stack Pointer.
Definition cmsis_armcc.h:206
#define __set_FPSCR(x)
Set FPSCR.
Definition cmsis_armclang.h:766
__STATIC_INLINE uint32_t __get_PRIMASK(void)
Get Priority Mask.
Definition cmsis_armcc.h:242
__STATIC_INLINE uint32_t __get_MSP(void)
Get Main Stack Pointer.
Definition cmsis_armcc.h:218
__STATIC_INLINE uint32_t __get_FPSCR(void)
Get FPSCR.
Definition cmsis_armcc.h:349
__STATIC_INLINE uint32_t __get_CONTROL(void)
Enable IRQ Interrupts.
Definition cmsis_armcc.h:134
__STATIC_INLINE uint32_t __get_PSP(void)
Get Process Stack Pointer.
Definition cmsis_armcc.h:194
__STATIC_INLINE uint32_t __get_xPSR(void)
Get xPSR Register.
Definition cmsis_armcc.h:182
__STATIC_INLINE uint32_t __get_APSR(void)
Get APSR Register.
Definition cmsis_armcc.h:170
__STATIC_INLINE uint32_t __get_IPSR(void)
Get IPSR Register.
Definition cmsis_armcc.h:158
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Set Priority Mask.
Definition cmsis_armcc.h:254
__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
Signed Saturate.
Definition cmsis_armclang.h:1139
__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
Unsigned Saturate.
Definition cmsis_armclang.h:1164
#define __RBIT
Reverse bit order of value.
Definition cmsis_armclang.h:905
#define __REV16(value)
Reverse byte order (16 bit).
Definition cmsis_armclang.h:859
#define __REVSH(value)
Reverse byte order (16 bit).
Definition cmsis_armclang.h:868
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
Reverse byte order (16 bit).
Definition cmsis_armcc.h:467