|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
-
-
- #ifndef __CORE_CMINSTR_H
- #define __CORE_CMINSTR_H
-
-
-
-
-
-
- #if defined ( __GNUC__ )
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
- {
- __ASM volatile ("nop");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void)
- {
- __ASM volatile ("wfi");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void)
- {
- __ASM volatile ("wfe");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void)
- {
- __ASM volatile ("sev");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void)
- {
- __ASM volatile ("isb");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void)
- {
- __ASM volatile ("dsb");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
- {
- __ASM volatile ("dmb");
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
- {
- uint32_t result;
-
- __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
- {
- uint32_t result;
-
- __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
- {
- uint32_t result;
-
- __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
- {
-
- __ASM volatile ("ror %0, %0, %1" : "+r" (op1) : "r" (op2) );
- return(op1);
- }
-
-
- #if (__CORTEX_M >= 0x03)
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
- {
- uint32_t result;
-
- __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
- {
- uint8_t result;
-
- __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
- {
- uint16_t result;
-
- __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
- {
- uint32_t result;
-
- __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
- {
- uint32_t result;
-
- __ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
- {
- uint32_t result;
-
- __ASM volatile ("strexh %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
- {
- uint32_t result;
-
- __ASM volatile ("strex %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
- return(result);
- }
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
- {
- __ASM volatile ("clrex");
- }
-
-
-
- #define __SSAT(ARG1,ARG2) \
- ({ \
- uint32_t __RES, __ARG1 = (ARG1); \
- __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
- __RES; \
- })
-
-
-
- #define __USAT(ARG1,ARG2) \
- ({ \
- uint32_t __RES, __ARG1 = (ARG1); \
- __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
- __RES; \
- })
-
-
-
- __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
- {
- uint8_t result;
-
- __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
- return(result);
- }
-
- #endif
-
-
-
-
- #elif defined ( __TASKING__ )
-
-
-
-
- #endif
-
-
-
- #endif
|