Go to the documentation of this file.
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
83 #ifndef __PACKED_UNION
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
107 #ifndef __COMPILER_BARRIER
108 #define __COMPILER_BARRIER() __memory_changed()
113 #ifndef __PROGRAM_START
114 #define __PROGRAM_START __main
118 #define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
121 #ifndef __STACK_LIMIT
122 #define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
125 #ifndef __VECTOR_TABLE
126 #define __VECTOR_TABLE __Vectors
129 #ifndef __VECTOR_TABLE_ATTRIBUTE
130 #define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section("RESET")))
161 register uint32_t __regControl
__ASM(
"control");
162 return(__regControl);
173 register uint32_t __regControl
__ASM(
"control");
174 __regControl = control;
185 register uint32_t __regIPSR
__ASM(
"ipsr");
197 register uint32_t __regAPSR
__ASM(
"apsr");
209 register uint32_t __regXPSR
__ASM(
"xpsr");
221 register uint32_t __regProcessStackPointer
__ASM(
"psp");
222 return(__regProcessStackPointer);
233 register uint32_t __regProcessStackPointer
__ASM(
"psp");
234 __regProcessStackPointer = topOfProcStack;
245 register uint32_t __regMainStackPointer
__ASM(
"msp");
246 return(__regMainStackPointer);
257 register uint32_t __regMainStackPointer
__ASM(
"msp");
258 __regMainStackPointer = topOfMainStack;
269 register uint32_t __regPriMask
__ASM(
"primask");
270 return(__regPriMask);
281 register uint32_t __regPriMask
__ASM(
"primask");
282 __regPriMask = (priMask);
286 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
287 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
294 #define __enable_fault_irq __enable_fiq
302 #define __disable_fault_irq __disable_fiq
312 register uint32_t __regBasePri
__ASM(
"basepri");
313 return(__regBasePri);
324 register uint32_t __regBasePri
__ASM(
"basepri");
325 __regBasePri = (basePri & 0xFFU);
337 register uint32_t __regBasePriMax
__ASM(
"basepri_max");
338 __regBasePriMax = (basePri & 0xFFU);
349 register uint32_t __regFaultMask
__ASM(
"faultmask");
350 return(__regFaultMask);
361 register uint32_t __regFaultMask
__ASM(
"faultmask");
362 __regFaultMask = (faultMask & (uint32_t)1U);
376 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
377 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
378 register uint32_t __regfpscr
__ASM(
"fpscr");
393 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
394 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
395 register uint32_t __regfpscr
__ASM(
"fpscr");
396 __regfpscr = (fpscr);
447 #define __ISB() do {\
448 __schedule_barrier();\
450 __schedule_barrier();\
458 #define __DSB() do {\
459 __schedule_barrier();\
461 __schedule_barrier();\
469 #define __DMB() do {\
470 __schedule_barrier();\
472 __schedule_barrier();\
491 #ifndef __NO_EMBEDDED_ASM
506 #ifndef __NO_EMBEDDED_ASM
532 #define __BKPT(value) __breakpoint(value)
541 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
542 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
543 #define __RBIT __rbit
548 uint32_t
s = (4U * 8U) - 1U;
551 for (value >>= 1U; value != 0U; value >>= 1U)
554 result |= value & 1U;
572 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
573 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
581 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
582 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
584 #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
594 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
595 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
597 #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
607 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
608 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
610 #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
622 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
623 #define __STREXB(value, ptr) __strex(value, ptr)
625 #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
637 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
638 #define __STREXH(value, ptr) __strex(value, ptr)
640 #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
652 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
653 #define __STREXW(value, ptr) __strex(value, ptr)
655 #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
663 #define __CLREX __clrex
673 #define __SSAT __ssat
683 #define __USAT __usat
693 #ifndef __NO_EMBEDDED_ASM
708 #define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
717 #define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
726 #define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
735 #define __STRBT(value, ptr) __strt(value, ptr)
744 #define __STRHT(value, ptr) __strt(value, ptr)
753 #define __STRT(value, ptr) __strt(value, ptr)
767 if ((
sat >= 1U) && (
sat <= 32U))
769 const int32_t max = (int32_t)((1U << (
sat - 1U)) - 1U);
770 const int32_t
min = -1 - max ;
794 const uint32_t max = ((1U <<
sat) - 1U);
795 if (val > (int32_t)max)
804 return (uint32_t)val;
819 #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
821 #define __SADD8 __sadd8
822 #define __QADD8 __qadd8
823 #define __SHADD8 __shadd8
824 #define __UADD8 __uadd8
825 #define __UQADD8 __uqadd8
826 #define __UHADD8 __uhadd8
827 #define __SSUB8 __ssub8
828 #define __QSUB8 __qsub8
829 #define __SHSUB8 __shsub8
830 #define __USUB8 __usub8
831 #define __UQSUB8 __uqsub8
832 #define __UHSUB8 __uhsub8
833 #define __SADD16 __sadd16
834 #define __QADD16 __qadd16
835 #define __SHADD16 __shadd16
836 #define __UADD16 __uadd16
837 #define __UQADD16 __uqadd16
838 #define __UHADD16 __uhadd16
839 #define __SSUB16 __ssub16
840 #define __QSUB16 __qsub16
841 #define __SHSUB16 __shsub16
842 #define __USUB16 __usub16
843 #define __UQSUB16 __uqsub16
844 #define __UHSUB16 __uhsub16
845 #define __SASX __sasx
846 #define __QASX __qasx
847 #define __SHASX __shasx
848 #define __UASX __uasx
849 #define __UQASX __uqasx
850 #define __UHASX __uhasx
851 #define __SSAX __ssax
852 #define __QSAX __qsax
853 #define __SHSAX __shsax
854 #define __USAX __usax
855 #define __UQSAX __uqsax
856 #define __UHSAX __uhsax
857 #define __USAD8 __usad8
858 #define __USADA8 __usada8
859 #define __SSAT16 __ssat16
860 #define __USAT16 __usat16
861 #define __UXTB16 __uxtb16
862 #define __UXTAB16 __uxtab16
863 #define __SXTB16 __sxtb16
864 #define __SXTAB16 __sxtab16
865 #define __SMUAD __smuad
866 #define __SMUADX __smuadx
867 #define __SMLAD __smlad
868 #define __SMLADX __smladx
869 #define __SMLALD __smlald
870 #define __SMLALDX __smlaldx
871 #define __SMUSD __smusd
872 #define __SMUSDX __smusdx
873 #define __SMLSD __smlsd
874 #define __SMLSDX __smlsdx
875 #define __SMLSLD __smlsld
876 #define __SMLSLDX __smlsldx
878 #define __QADD __qadd
879 #define __QSUB __qsub
881 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
882 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
884 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
885 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
887 #define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
888 ((int64_t)(ARG3) << 32U) ) >> 32U))
__STATIC_INLINE uint32_t __get_CONTROL(void)
Enable IRQ Interrupts.
__STATIC_INLINE uint32_t __get_PRIMASK(void)
Get Priority Mask.
__STATIC_FORCEINLINE int16_t __REVSH(int16_t value)
Reverse byte order (16 bit)
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Set Priority Mask.
__STATIC_INLINE uint32_t __get_MSP(void)
Get Main Stack Pointer.
__STATIC_INLINE uint32_t __get_xPSR(void)
Get xPSR Register.
__STATIC_INLINE uint32_t __get_FPSCR(void)
Get FPSCR.
__STATIC_INLINE void __set_CONTROL(uint32_t control)
Set Control Register.
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Set Main Stack Pointer.
__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value)
Reverse bit order of value.
__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value)
Reverse byte order (16 bit)
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Set FPSCR.
__STATIC_INLINE uint32_t __get_PSP(void)
Get Process Stack Pointer.
__STATIC_INLINE uint32_t __get_IPSR(void)
Get IPSR Register.
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
Reverse byte order (16 bit)
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Set Process Stack Pointer.
__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
Signed Saturate.
__STATIC_INLINE uint32_t __get_APSR(void)
Get APSR Register.
__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
Unsigned Saturate.