| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #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 |
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| #define __NOP __nop |
|
|
|
|
| |
| |
| |
| |
| #define __WFI __wfi |
|
|
|
|
| |
| |
| |
| |
| |
| #define __WFE __wfe |
|
|
|
|
| |
| |
| |
| |
| #define __SEV __sev |
|
|
|
|
| |
| |
| |
| |
| |
| |
| #define __ISB() __isb(0xF) |
|
|
| |
| |
| |
| |
| |
| #define __DSB() __dsb(0xF) |
|
|
| |
| |
| |
| |
| |
| #define __DMB() __dmb(0xF) |
|
|
|
|
| |
| |
| |
| |
| |
| |
| #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 |
| |
|
|
| |
|
|
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| __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; |
| __ISB(); |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| __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 |
| } |
|
|
|
|
| |
|
|
|
|
| |
| |
| |
| |
| |
|
|
| #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)) |
|
|
| #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) |
|
|
| #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3)) |
|
|
| #endif |
| |
|
|
|
|
| #endif |
|
|