123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- #ifndef __CMSIS_ARMCC_H
- #define __CMSIS_ARMCC_H
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
- #error "Please use Arm Compiler Toolchain V4.0.677 or later!"
- #endif
- #if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
- (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
- #define __ARM_ARCH_6M__ 1
- #endif
- #if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
- #define __ARM_ARCH_7M__ 1
- #endif
- #if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
- #define __ARM_ARCH_7EM__ 1
- #endif
-
-
- #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
- #define __ARM_FEATURE_DSP 1
- #endif
- #ifndef __ASM
- #define __ASM __asm
- #endif
- #ifndef __INLINE
- #define __INLINE __inline
- #endif
- #ifndef __STATIC_INLINE
- #define __STATIC_INLINE static __inline
- #endif
- #ifndef __STATIC_FORCEINLINE
- #define __STATIC_FORCEINLINE static __forceinline
- #endif
- #ifndef __NO_RETURN
- #define __NO_RETURN __declspec(noreturn)
- #endif
- #ifndef __USED
- #define __USED __attribute__((used))
- #endif
- #ifndef __WEAK
- #define __WEAK __attribute__((weak))
- #endif
- #ifndef __PACKED
- #define __PACKED __attribute__((packed))
- #endif
- #ifndef __PACKED_STRUCT
- #define __PACKED_STRUCT __packed struct
- #endif
- #ifndef __PACKED_UNION
- #define __PACKED_UNION __packed union
- #endif
- #ifndef __UNALIGNED_UINT32
- #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
- #endif
- #ifndef __UNALIGNED_UINT16_WRITE
- #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
- #endif
- #ifndef __UNALIGNED_UINT16_READ
- #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
- #endif
- #ifndef __UNALIGNED_UINT32_WRITE
- #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
- #endif
- #ifndef __UNALIGNED_UINT32_READ
- #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
- #endif
- #ifndef __ALIGNED
- #define __ALIGNED(x) __attribute__((aligned(x)))
- #endif
- #ifndef __RESTRICT
- #define __RESTRICT __restrict
- #endif
- #ifndef __COMPILER_BARRIER
- #define __COMPILER_BARRIER() __memory_changed()
- #endif
- #ifndef __PROGRAM_START
- #define __PROGRAM_START __main
- #endif
- #ifndef __INITIAL_SP
- #define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
- #endif
- #ifndef __STACK_LIMIT
- #define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
- #endif
- #ifndef __VECTOR_TABLE
- #define __VECTOR_TABLE __Vectors
- #endif
- #ifndef __VECTOR_TABLE_ATTRIBUTE
- #define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section("RESET")))
- #endif
- __STATIC_INLINE uint32_t __get_CONTROL(void)
- {
- register uint32_t __regControl __ASM("control");
- return(__regControl);
- }
- __STATIC_INLINE void __set_CONTROL(uint32_t control)
- {
- register uint32_t __regControl __ASM("control");
- __regControl = control;
- }
- __STATIC_INLINE uint32_t __get_IPSR(void)
- {
- register uint32_t __regIPSR __ASM("ipsr");
- return(__regIPSR);
- }
- __STATIC_INLINE uint32_t __get_APSR(void)
- {
- register uint32_t __regAPSR __ASM("apsr");
- return(__regAPSR);
- }
- __STATIC_INLINE uint32_t __get_xPSR(void)
- {
- register uint32_t __regXPSR __ASM("xpsr");
- return(__regXPSR);
- }
- __STATIC_INLINE uint32_t __get_PSP(void)
- {
- register uint32_t __regProcessStackPointer __ASM("psp");
- return(__regProcessStackPointer);
- }
- __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
- {
- register uint32_t __regProcessStackPointer __ASM("psp");
- __regProcessStackPointer = topOfProcStack;
- }
- __STATIC_INLINE uint32_t __get_MSP(void)
- {
- register uint32_t __regMainStackPointer __ASM("msp");
- return(__regMainStackPointer);
- }
- __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
- {
- register uint32_t __regMainStackPointer __ASM("msp");
- __regMainStackPointer = topOfMainStack;
- }
- __STATIC_INLINE uint32_t __get_PRIMASK(void)
- {
- register uint32_t __regPriMask __ASM("primask");
- return(__regPriMask);
- }
- __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
- {
- register uint32_t __regPriMask __ASM("primask");
- __regPriMask = (priMask);
- }
- #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
- (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
- #define __enable_fault_irq __enable_fiq
- #define __disable_fault_irq __disable_fiq
- __STATIC_INLINE uint32_t __get_BASEPRI(void)
- {
- register uint32_t __regBasePri __ASM("basepri");
- return(__regBasePri);
- }
- __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
- {
- register uint32_t __regBasePri __ASM("basepri");
- __regBasePri = (basePri & 0xFFU);
- }
- __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
- {
- register uint32_t __regBasePriMax __ASM("basepri_max");
- __regBasePriMax = (basePri & 0xFFU);
- }
- __STATIC_INLINE uint32_t __get_FAULTMASK(void)
- {
- register uint32_t __regFaultMask __ASM("faultmask");
- return(__regFaultMask);
- }
- __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
- {
- register uint32_t __regFaultMask __ASM("faultmask");
- __regFaultMask = (faultMask & (uint32_t)1U);
- }
- #endif
- __STATIC_INLINE uint32_t __get_FPSCR(void)
- {
- #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
- (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
- register uint32_t __regfpscr __ASM("fpscr");
- return(__regfpscr);
- #else
- return(0U);
- #endif
- }
- __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
- {
- #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
- (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
- register uint32_t __regfpscr __ASM("fpscr");
- __regfpscr = (fpscr);
- #else
- (void)fpscr;
- #endif
- }
- #define __NOP __nop
- #define __WFI __wfi
- #define __WFE __wfe
- #define __SEV __sev
- #define __ISB() do {\
- __schedule_barrier();\
- __isb(0xF);\
- __schedule_barrier();\
- } while (0U)
- #define __DSB() do {\
- __schedule_barrier();\
- __dsb(0xF);\
- __schedule_barrier();\
- } while (0U)
- #define __DMB() do {\
- __schedule_barrier();\
- __dmb(0xF);\
- __schedule_barrier();\
- } while (0U)
-
- #define __REV __rev
- #ifndef __NO_EMBEDDED_ASM
- __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
- {
- rev16 r0, r0
- bx lr
- }
- #endif
- #ifndef __NO_EMBEDDED_ASM
- __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
- {
- revsh r0, r0
- bx lr
- }
- #endif
- #define __ROR __ror
- #define __BKPT(value) __breakpoint(value)
- #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
- (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
- #define __RBIT __rbit
- #else
- __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
- {
- uint32_t result;
- uint32_t s = (4U * 8U) - 1U;
- result = value;
- for (value >>= 1U; value != 0U; value >>= 1U)
- {
- result <<= 1U;
- result |= value & 1U;
- s--;
- }
- result <<= s;
- return result;
- }
- #endif
- #define __CLZ __clz
- #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
- (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
- #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
- #else
- #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
- #endif
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
- #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
- #else
- #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
- #endif
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
- #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
- #else
- #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
- #endif
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
- #define __STREXB(value, ptr) __strex(value, ptr)
- #else
- #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
- #endif
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
- #define __STREXH(value, ptr) __strex(value, ptr)
- #else
- #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
- #endif
- #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
- #define __STREXW(value, ptr) __strex(value, ptr)
- #else
- #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
- #endif
- #define __CLREX __clrex
- #define __SSAT __ssat
- #define __USAT __usat
- #ifndef __NO_EMBEDDED_ASM
- __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
- {
- rrx r0, r0
- bx lr
- }
- #endif
- #define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
- #define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
- #define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
- #define __STRBT(value, ptr) __strt(value, ptr)
- #define __STRHT(value, ptr) __strt(value, ptr)
- #define __STRT(value, ptr) __strt(value, ptr)
- #else
- __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
- {
- if ((sat >= 1U) && (sat <= 32U))
- {
- const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
- const int32_t min = -1 - max ;
- if (val > max)
- {
- return max;
- }
- else if (val < min)
- {
- return min;
- }
- }
- return val;
- }
- __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
- {
- if (sat <= 31U)
- {
- const uint32_t max = ((1U << sat) - 1U);
- if (val > (int32_t)max)
- {
- return max;
- }
- else if (val < 0)
- {
- return 0U;
- }
- }
- return (uint32_t)val;
- }
- #endif
-
- #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
- #define __SADD8 __sadd8
- #define __QADD8 __qadd8
- #define __SHADD8 __shadd8
- #define __UADD8 __uadd8
- #define __UQADD8 __uqadd8
- #define __UHADD8 __uhadd8
- #define __SSUB8 __ssub8
- #define __QSUB8 __qsub8
- #define __SHSUB8 __shsub8
- #define __USUB8 __usub8
- #define __UQSUB8 __uqsub8
- #define __UHSUB8 __uhsub8
- #define __SADD16 __sadd16
- #define __QADD16 __qadd16
- #define __SHADD16 __shadd16
- #define __UADD16 __uadd16
- #define __UQADD16 __uqadd16
- #define __UHADD16 __uhadd16
- #define __SSUB16 __ssub16
- #define __QSUB16 __qsub16
- #define __SHSUB16 __shsub16
- #define __USUB16 __usub16
- #define __UQSUB16 __uqsub16
- #define __UHSUB16 __uhsub16
- #define __SASX __sasx
- #define __QASX __qasx
- #define __SHASX __shasx
- #define __UASX __uasx
- #define __UQASX __uqasx
- #define __UHASX __uhasx
- #define __SSAX __ssax
- #define __QSAX __qsax
- #define __SHSAX __shsax
- #define __USAX __usax
- #define __UQSAX __uqsax
- #define __UHSAX __uhsax
- #define __USAD8 __usad8
- #define __USADA8 __usada8
- #define __SSAT16 __ssat16
- #define __USAT16 __usat16
- #define __UXTB16 __uxtb16
- #define __UXTAB16 __uxtab16
- #define __SXTB16 __sxtb16
- #define __SXTAB16 __sxtab16
- #define __SMUAD __smuad
- #define __SMUADX __smuadx
- #define __SMLAD __smlad
- #define __SMLADX __smladx
- #define __SMLALD __smlald
- #define __SMLALDX __smlaldx
- #define __SMUSD __smusd
- #define __SMUSDX __smusdx
- #define __SMLSD __smlsd
- #define __SMLSDX __smlsdx
- #define __SMLSLD __smlsld
- #define __SMLSLDX __smlsldx
- #define __SEL __sel
- #define __QADD __qadd
- #define __QSUB __qsub
- #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
- ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
- #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
- ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
- #define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
- ((int64_t)(ARG3) << 32U) ) >> 32U))
- #endif
- #endif
|