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
52#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
53 #define __ARM_FEATURE_DSP 1
61 #define __INLINE __inline
63#ifndef __STATIC_INLINE
64 #define __STATIC_INLINE static __inline
66#ifndef __STATIC_FORCEINLINE
67 #define __STATIC_FORCEINLINE static __forceinline
70 #define __NO_RETURN __declspec(noreturn)
73 #define __USED __attribute__((used))
76 #define __WEAK __attribute__((weak))
79 #define __PACKED __attribute__((packed))
81#ifndef __PACKED_STRUCT
82 #define __PACKED_STRUCT __packed struct
85 #define __PACKED_UNION __packed union
87#ifndef __UNALIGNED_UINT32
88 #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
90#ifndef __UNALIGNED_UINT16_WRITE
91 #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
93#ifndef __UNALIGNED_UINT16_READ
94 #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
96#ifndef __UNALIGNED_UINT32_WRITE
97 #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
99#ifndef __UNALIGNED_UINT32_READ
100 #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
103 #define __ALIGNED(x) __attribute__((aligned(x)))
106 #define __RESTRICT __restrict
108#ifndef __COMPILER_BARRIER
109 #define __COMPILER_BARRIER() __memory_changed()
114#ifndef __PROGRAM_START
115#define __PROGRAM_START __main
119#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
123#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
126#ifndef __VECTOR_TABLE
127#define __VECTOR_TABLE __Vectors
130#ifndef __VECTOR_TABLE_ATTRIBUTE
131#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
175#define __ISB() __isb(0xF)
182#define __DSB() __dsb(0xF)
189#define __DMB() __dmb(0xF)
207#ifndef __NO_EMBEDDED_ASM
222#ifndef __NO_EMBEDDED_ASM
248#define __BKPT(value) __breakpoint(value)
257#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
258 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
259 #define __RBIT __rbit
264 uint32_t s = (4U * 8U) - 1U;
288#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
289 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
297#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
298 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
300 #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
310#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
311 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
313 #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
323#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
324 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
326 #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
338#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
339 #define __STREXB(value, ptr) __strex(value, ptr)
341 #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
353#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
354 #define __STREXH(value, ptr) __strex(value, ptr)
356 #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
368#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
369 #define __STREXW(value, ptr) __strex(value, ptr)
371 #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
379#define __CLREX __clrex
409#ifndef __NO_EMBEDDED_ASM
424#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
433#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
442#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
451#define __STRBT(value, ptr) __strt(value, ptr)
460#define __STRHT(value, ptr) __strt(value, ptr)
469#define __STRT(value, ptr) __strt(value, ptr)
483 if ((
sat >= 1U) && (
sat <= 32U))
485 const int32_t
max = (int32_t)((1U << (
sat - 1U)) - 1U);
486 const int32_t
min = -1 -
max ;
510 const uint32_t
max = ((1U <<
sat) - 1U);
511 if (val > (int32_t)
max)
520 return (uint32_t)val;
557 register uint32_t __regControl
__ASM(
"control");
558 return(__regControl);
569 register uint32_t __regControl
__ASM(
"control");
570 __regControl = control;
582 register uint32_t __regIPSR
__ASM(
"ipsr");
594 register uint32_t __regAPSR
__ASM(
"apsr");
606 register uint32_t __regXPSR
__ASM(
"xpsr");
618 register uint32_t __regProcessStackPointer
__ASM(
"psp");
619 return(__regProcessStackPointer);
630 register uint32_t __regProcessStackPointer
__ASM(
"psp");
631 __regProcessStackPointer = topOfProcStack;
642 register uint32_t __regMainStackPointer
__ASM(
"msp");
643 return(__regMainStackPointer);
654 register uint32_t __regMainStackPointer
__ASM(
"msp");
655 __regMainStackPointer = topOfMainStack;
666 register uint32_t __regPriMask
__ASM(
"primask");
667 return(__regPriMask);
678 register uint32_t __regPriMask
__ASM(
"primask");
679 __regPriMask = (priMask);
683#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
684 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
691#define __enable_fault_irq __enable_fiq
699#define __disable_fault_irq __disable_fiq
709 register uint32_t __regBasePri
__ASM(
"basepri");
710 return(__regBasePri);
721 register uint32_t __regBasePri
__ASM(
"basepri");
722 __regBasePri = (basePri & 0xFFU);
734 register uint32_t __regBasePriMax
__ASM(
"basepri_max");
735 __regBasePriMax = (basePri & 0xFFU);
746 register uint32_t __regFaultMask
__ASM(
"faultmask");
747 return(__regFaultMask);
758 register uint32_t __regFaultMask
__ASM(
"faultmask");
759 __regFaultMask = (faultMask & (uint32_t)1U);
773#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
774 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
775 register uint32_t __regfpscr
__ASM(
"fpscr");
790#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
791 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
792 register uint32_t __regfpscr
__ASM(
"fpscr");
793 __regfpscr = (fpscr);
809#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
811#define __SADD8 __sadd8
812#define __QADD8 __qadd8
813#define __SHADD8 __shadd8
814#define __UADD8 __uadd8
815#define __UQADD8 __uqadd8
816#define __UHADD8 __uhadd8
817#define __SSUB8 __ssub8
818#define __QSUB8 __qsub8
819#define __SHSUB8 __shsub8
820#define __USUB8 __usub8
821#define __UQSUB8 __uqsub8
822#define __UHSUB8 __uhsub8
823#define __SADD16 __sadd16
824#define __QADD16 __qadd16
825#define __SHADD16 __shadd16
826#define __UADD16 __uadd16
827#define __UQADD16 __uqadd16
828#define __UHADD16 __uhadd16
829#define __SSUB16 __ssub16
830#define __QSUB16 __qsub16
831#define __SHSUB16 __shsub16
832#define __USUB16 __usub16
833#define __UQSUB16 __uqsub16
834#define __UHSUB16 __uhsub16
837#define __SHASX __shasx
839#define __UQASX __uqasx
840#define __UHASX __uhasx
843#define __SHSAX __shsax
845#define __UQSAX __uqsax
846#define __UHSAX __uhsax
847#define __USAD8 __usad8
848#define __USADA8 __usada8
849#define __SSAT16 __ssat16
850#define __USAT16 __usat16
851#define __UXTB16 __uxtb16
852#define __UXTAB16 __uxtab16
853#define __SXTB16 __sxtb16
854#define __SXTAB16 __sxtab16
855#define __SMUAD __smuad
856#define __SMUADX __smuadx
857#define __SMLAD __smlad
858#define __SMLADX __smladx
859#define __SMLALD __smlald
860#define __SMLALDX __smlaldx
861#define __SMUSD __smusd
862#define __SMUSDX __smusdx
863#define __SMLSD __smlsd
864#define __SMLSDX __smlsdx
865#define __SMLSLD __smlsld
866#define __SMLSLDX __smlsldx
871#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
872 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
874#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
875 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
877#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
878 ((int64_t)(ARG3) << 32U) ) >> 32U))
880#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
882#define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
Signed Saturate.
__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
Unsigned Saturate.
#define __ISB()
Instruction Synchronization Barrier.
#define __RBIT
Reverse bit order of value.
#define __REV16(value)
Reverse byte order (16 bit).
#define __REVSH(value)
Reverse byte order (16 bit).
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
Reverse byte order (16 bit).
__STATIC_INLINE void __set_CONTROL(uint32_t control)
Set Control Register.
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Set Main Stack Pointer.
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Set Process Stack Pointer.
#define __set_FPSCR(x)
Set FPSCR.
__STATIC_INLINE uint32_t __get_PRIMASK(void)
Get Priority Mask.
__STATIC_INLINE uint32_t __get_MSP(void)
Get Main Stack Pointer.
__STATIC_INLINE uint32_t __get_FPSCR(void)
Get FPSCR.
__STATIC_INLINE uint32_t __get_CONTROL(void)
Enable IRQ Interrupts.
__STATIC_INLINE uint32_t __get_PSP(void)
Get Process Stack Pointer.
__STATIC_INLINE uint32_t __get_xPSR(void)
Get xPSR Register.
__STATIC_INLINE uint32_t __get_APSR(void)
Get APSR Register.
__STATIC_INLINE uint32_t __get_IPSR(void)
Get IPSR Register.
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Set Priority Mask.