38 #ifndef __CORE_CMINSTR_H 39 #define __CORE_CMINSTR_H 48 #if defined ( __CC_ARM ) 51 #if (__ARMCC_VERSION < 400677) 52 #error "Please use ARM Compiler Toolchain V4.0.677 or later!" 92 #define __ISB() __isb(0xF) 100 #define __DSB() __dsb(0xF) 108 #define __DMB() __dmb(0xF) 128 #ifndef __NO_EMBEDDED_ASM 129 __attribute__((section(
".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t
value)
143 #ifndef __NO_EMBEDDED_ASM 144 __attribute__((section(
".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t
value)
171 #define __BKPT(value) __breakpoint(value) 174 #if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) 183 #define __RBIT __rbit 193 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) 203 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) 213 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) 225 #define __STREXB(value, ptr) __strex(value, ptr) 237 #define __STREXH(value, ptr) __strex(value, ptr) 249 #define __STREXW(value, ptr) __strex(value, ptr) 257 #define __CLREX __clrex 268 #define __SSAT __ssat 279 #define __USAT __usat 299 #ifndef __NO_EMBEDDED_ASM 300 __attribute__((section(
".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t
value)
315 #define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) 325 #define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) 335 #define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) 345 #define __STRBT(value, ptr) __strt(value, ptr) 355 #define __STRHT(value, ptr) __strt(value, ptr) 365 #define __STRT(value, ptr) __strt(value, ptr) 370 #elif defined ( __GNUC__ ) 376 #if defined (__thumb__) && !defined (__thumb2__) 377 #define __CMSIS_GCC_OUT_REG(r) "=l" (r) 378 #define __CMSIS_GCC_USE_REG(r) "l" (r) 380 #define __CMSIS_GCC_OUT_REG(r) "=r" (r) 381 #define __CMSIS_GCC_USE_REG(r) "r" (r) 388 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __NOP(
void)
390 __ASM
volatile (
"nop");
399 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __WFI(
void)
401 __ASM
volatile (
"wfi");
410 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __WFE(
void)
412 __ASM
volatile (
"wfe");
420 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __SEV(
void)
422 __ASM
volatile (
"sev");
432 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __ISB(
void)
434 __ASM
volatile (
"isb");
443 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __DSB(
void)
445 __ASM
volatile (
"dsb");
454 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __DMB(
void)
456 __ASM
volatile (
"dmb");
469 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) 470 return __builtin_bswap32(value);
474 __ASM
volatile (
"rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
487 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
491 __ASM
volatile (
"rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
503 __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
505 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) 506 return (
short)__builtin_bswap16(value);
510 __ASM
volatile (
"revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
524 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
526 return (op1 >> op2) | (op1 << (32 - op2));
538 #define __BKPT(value) __ASM volatile ("bkpt "#value) 541 #if (__CORTEX_M >= 0x03) || ((defined(__CORTEX_SC)) && (__CORTEX_SC >= 300)) 550 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
554 __ASM
volatile (
"rbit %0, %1" :
"=r" (result) :
"r" (value) );
566 __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(
volatile uint8_t *addr)
570 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) 571 __ASM
volatile (
"ldrexb %0, %1" :
"=r" (result) :
"Q" (*addr) );
576 __ASM
volatile (
"ldrexb %0, [%1]" :
"=r" (result) :
"r" (addr) :
"memory" );
578 return ((uint8_t) result);
589 __attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(
volatile uint16_t *addr)
593 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) 594 __ASM
volatile (
"ldrexh %0, %1" :
"=r" (result) :
"Q" (*addr) );
599 __ASM
volatile (
"ldrexh %0, [%1]" :
"=r" (result) :
"r" (addr) :
"memory" );
601 return ((uint16_t) result);
612 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(
volatile uint32_t *addr)
616 __ASM
volatile (
"ldrex %0, %1" :
"=r" (result) :
"Q" (*addr) );
630 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value,
volatile uint8_t *addr)
634 __ASM
volatile (
"strexb %0, %2, %1" :
"=&r" (result),
"=Q" (*addr) :
"r" ((uint32_t)value) );
648 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value,
volatile uint16_t *addr)
652 __ASM
volatile (
"strexh %0, %2, %1" :
"=&r" (result),
"=Q" (*addr) :
"r" ((uint32_t)value) );
666 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value,
volatile uint32_t *addr)
670 __ASM
volatile (
"strex %0, %2, %1" :
"=&r" (result),
"=Q" (*addr) :
"r" (
value) );
680 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __CLREX(
void)
682 __ASM
volatile (
"clrex" :::
"memory");
694 #define __SSAT(ARG1,ARG2) \ 696 uint32_t __RES, __ARG1 = (ARG1); \ 697 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ 710 #define __USAT(ARG1,ARG2) \ 712 uint32_t __RES, __ARG1 = (ARG1); \ 713 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ 725 __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
729 __ASM
volatile (
"clz %0, %1" :
"=r" (result) :
"r" (value) );
730 return ((uint8_t) result);
741 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RRX(uint32_t value)
745 __ASM
volatile (
"rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
757 __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDRBT(
volatile uint8_t *addr)
761 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) 762 __ASM
volatile (
"ldrbt %0, %1" :
"=r" (result) :
"Q" (*addr) );
767 __ASM
volatile (
"ldrbt %0, [%1]" :
"=r" (result) :
"r" (addr) :
"memory" );
769 return ((uint8_t) result);
780 __attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDRHT(
volatile uint16_t *addr)
784 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) 785 __ASM
volatile (
"ldrht %0, %1" :
"=r" (result) :
"Q" (*addr) );
790 __ASM
volatile (
"ldrht %0, [%1]" :
"=r" (result) :
"r" (addr) :
"memory" );
792 return ((uint16_t) result);
803 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDRT(
volatile uint32_t *addr)
807 __ASM
volatile (
"ldrt %0, %1" :
"=r" (result) :
"Q" (*addr) );
819 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __STRBT(uint8_t value,
volatile uint8_t *addr)
821 __ASM
volatile (
"strbt %1, %0" :
"=Q" (*addr) :
"r" ((uint32_t)value) );
832 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __STRHT(uint16_t value,
volatile uint16_t *addr)
834 __ASM
volatile (
"strht %1, %0" :
"=Q" (*addr) :
"r" ((uint32_t)value) );
845 __attribute__( ( always_inline ) ) __STATIC_INLINE
void __STRT(uint32_t value,
volatile uint32_t *addr)
847 __ASM
volatile (
"strt %1, %0" :
"=Q" (*addr) :
"r" (
value) );
853 #elif defined ( __ICCARM__ ) 855 #include <cmsis_iar.h> 858 #elif defined ( __TMS470__ ) 860 #include <cmsis_ccs.h> 863 #elif defined ( __TASKING__ ) 872 #elif defined ( __CSMC__ ) 874 #include <cmsis_csm.h> GeneratorWrapper< T > value(T &&value)
typedef __attribute__
USB Device LPM Descriptor structure.