1 /**************************************************************************//**
3 * @brief CMSIS compiler GCC header file
6 ******************************************************************************/
8 * Copyright (c) 2009-2023 Arm Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
28 #pragma GCC system_header /* treat file as system include file */
32 /* Fallback for __has_builtin */
34 #define __has_builtin(x) (0)
37 /* CMSIS compiler specific defines */
42 #define __INLINE inline
44 #ifndef __STATIC_INLINE
45 #define __STATIC_INLINE static inline
47 #ifndef __STATIC_FORCEINLINE
48 #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
51 #define __NO_RETURN __attribute__((__noreturn__))
53 #ifndef CMSIS_DEPRECATED
54 #define CMSIS_DEPRECATED __attribute__((deprecated))
57 #define __USED __attribute__((used))
60 #define __WEAK __attribute__((weak))
63 #define __PACKED __attribute__((packed, aligned(1)))
65 #ifndef __PACKED_STRUCT
66 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
68 #ifndef __PACKED_UNION
69 #define __PACKED_UNION union __attribute__((packed, aligned(1)))
71 #ifndef __UNALIGNED_UINT16_WRITE
72 #pragma GCC diagnostic push
73 #pragma GCC diagnostic ignored "-Wpacked"
74 #pragma GCC diagnostic ignored "-Wattributes"
75 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
76 #pragma GCC diagnostic pop
77 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
79 #ifndef __UNALIGNED_UINT16_READ
80 #pragma GCC diagnostic push
81 #pragma GCC diagnostic ignored "-Wpacked"
82 #pragma GCC diagnostic ignored "-Wattributes"
83 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
84 #pragma GCC diagnostic pop
85 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
87 #ifndef __UNALIGNED_UINT32_WRITE
88 #pragma GCC diagnostic push
89 #pragma GCC diagnostic ignored "-Wpacked"
90 #pragma GCC diagnostic ignored "-Wattributes"
91 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
92 #pragma GCC diagnostic pop
93 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
95 #ifndef __UNALIGNED_UINT32_READ
96 #pragma GCC diagnostic push
97 #pragma GCC diagnostic ignored "-Wpacked"
98 #pragma GCC diagnostic ignored "-Wattributes"
99 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
100 #pragma GCC diagnostic pop
101 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
104 #define __ALIGNED(x) __attribute__((aligned(x)))
107 #define __RESTRICT __restrict
109 #ifndef __COMPILER_BARRIER
110 #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
113 #define __NO_INIT __attribute__ ((section (".noinit")))
116 #define __ALIAS(x) __attribute__ ((alias(x)))
119 /* ########################## Core Instruction Access ######################### */
120 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
121 Access to dedicated instructions
125 /* Define macros for porting to both thumb1 and thumb2.
126 * For thumb1, use low register (r0-r7), specified by constraint "l"
127 * Otherwise, use general registers, specified by constraint "r" */
128 #if defined (__thumb__) && !defined (__thumb2__)
129 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
130 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
131 #define __CMSIS_GCC_USE_REG(r) "l" (r)
133 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
134 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
135 #define __CMSIS_GCC_USE_REG(r) "r" (r)
140 \details No Operation does nothing. This instruction can be used for code alignment purposes.
142 #define __NOP() __ASM volatile ("nop")
146 \brief Wait For Interrupt
147 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
149 #define __WFI() __ASM volatile ("wfi":::"memory")
153 \brief Wait For Event
154 \details Wait For Event is a hint instruction that permits the processor to enter
155 a low-power state until one of a number of events occurs.
157 #define __WFE() __ASM volatile ("wfe":::"memory")
162 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
164 #define __SEV() __ASM volatile ("sev")
168 \brief Instruction Synchronization Barrier
169 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
170 so that all instructions following the ISB are fetched from cache or memory,
171 after the instruction has been completed.
173 __STATIC_FORCEINLINE void __ISB(void)
175 __ASM volatile ("isb 0xF":::"memory");
180 \brief Data Synchronization Barrier
181 \details Acts as a special kind of Data Memory Barrier.
182 It completes when all explicit memory accesses before this instruction complete.
184 __STATIC_FORCEINLINE void __DSB(void)
186 __ASM volatile ("dsb 0xF":::"memory");
191 \brief Data Memory Barrier
192 \details Ensures the apparent order of the explicit memory operations before
193 and after the instruction, without ensuring their completion.
195 __STATIC_FORCEINLINE void __DMB(void)
197 __ASM volatile ("dmb 0xF":::"memory");
202 \brief Reverse byte order (32 bit)
203 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
204 \param [in] value Value to reverse
205 \return Reversed value
207 __STATIC_FORCEINLINE uint32_t __REV(uint32_t value)
209 return __builtin_bswap32(value);
214 \brief Reverse byte order (16 bit)
215 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
216 \param [in] value Value to reverse
217 \return Reversed value
219 __STATIC_FORCEINLINE uint32_t __REV16(uint32_t value)
223 __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
229 \brief Reverse byte order (16 bit)
230 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
231 \param [in] value Value to reverse
232 \return Reversed value
234 __STATIC_FORCEINLINE int16_t __REVSH(int16_t value)
236 return (int16_t)__builtin_bswap16(value);
241 \brief Rotate Right in unsigned value (32 bit)
242 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
243 \param [in] op1 Value to rotate
244 \param [in] op2 Number of Bits to rotate
245 \return Rotated value
247 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
254 return (op1 >> op2) | (op1 << (32U - op2));
260 \details Causes the processor to enter Debug state.
261 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
262 \param [in] value is ignored by the processor.
263 If required, a debugger can use it to store additional information about the breakpoint.
265 #define __BKPT(value) __ASM volatile ("bkpt "#value)
269 \brief Reverse bit order of value
270 \details Reverses the bit order of the given value.
271 \param [in] value Value to reverse
272 \return Reversed value
274 __STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value)
278 #if (__ARM_ARCH_ISA_THUMB >= 2)
279 __ASM ("rbit %0, %1" : "=r" (result) : "r" (value) );
281 uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
283 result = value; /* r will be reversed bits of v; first get LSB of v */
284 for (value >>= 1U; value != 0U; value >>= 1U)
287 result |= value & 1U;
290 result <<= s; /* shift when v's highest bits are zero */
297 \brief Count leading zeros
298 \details Counts the number of leading zeros of a data value.
299 \param [in] value Value to count the leading zeros
300 \return number of leading zeros in value
302 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
304 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
305 __builtin_clz(0) is undefined behaviour, so handle this case specially.
306 This guarantees ARM-compatible results if happening to compile on a non-ARM
307 target, and ensures the compiler doesn't decide to activate any
308 optimisations using the logic "value was passed to __builtin_clz, so it
310 ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a
311 single CLZ instruction.
317 return __builtin_clz(value);
321 #if (__ARM_FEATURE_SAT >= 1)
323 \brief Signed Saturate
324 \details Saturates a signed value.
325 \param [in] value Value to be saturated
326 \param [in] sat Bit position to saturate to (1..32)
327 \return Saturated value
329 #define __SSAT(value, sat) __ssat(value, sat)
333 \brief Unsigned Saturate
334 \details Saturates an unsigned value.
335 \param [in] value Value to be saturated
336 \param [in] sat Bit position to saturate to (0..31)
337 \return Saturated value
339 #define __USAT(value, sat) __usat(value, sat)
341 #else /* (__ARM_FEATURE_SAT >= 1) */
343 \brief Signed Saturate
344 \details Saturates a signed value.
345 \param [in] value Value to be saturated
346 \param [in] sat Bit position to saturate to (1..32)
347 \return Saturated value
349 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
351 if ((sat >= 1U) && (sat <= 32U))
353 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
354 const int32_t min = -1 - max ;
369 \brief Unsigned Saturate
370 \details Saturates an unsigned value.
371 \param [in] value Value to be saturated
372 \param [in] sat Bit position to saturate to (0..31)
373 \return Saturated value
375 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
379 const uint32_t max = ((1U << sat) - 1U);
380 if (val > (int32_t)max)
389 return ((uint32_t)val);
391 #endif /* (__ARM_FEATURE_SAT >= 1) */
394 #if (__ARM_FEATURE_LDREX >= 1)
396 \brief Remove the exclusive lock
397 \details Removes the exclusive lock which is created by LDREX.
399 __STATIC_FORCEINLINE void __CLREX(void)
401 __ASM volatile ("clrex" ::: "memory");
406 \brief LDR Exclusive (8 bit)
407 \details Executes a exclusive LDR instruction for 8 bit value.
408 \param [in] ptr Pointer to data
409 \return value of type uint8_t at (*ptr)
411 __STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr)
415 __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
416 return ((uint8_t) result); /* Add explicit type cast here */
421 \brief STR Exclusive (8 bit)
422 \details Executes a exclusive STR instruction for 8 bit values.
423 \param [in] value Value to store
424 \param [in] ptr Pointer to location
425 \return 0 Function succeeded
426 \return 1 Function failed
428 __STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
432 __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
435 #endif /* (__ARM_FEATURE_LDREX >= 1) */
438 #if (__ARM_FEATURE_LDREX >= 2)
440 \brief LDR Exclusive (16 bit)
441 \details Executes a exclusive LDR instruction for 16 bit values.
442 \param [in] ptr Pointer to data
443 \return value of type uint16_t at (*ptr)
445 __STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr)
449 __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
450 return ((uint16_t)result); /* Add explicit type cast here */
455 \brief STR Exclusive (16 bit)
456 \details Executes a exclusive STR instruction for 16 bit values.
457 \param [in] value Value to store
458 \param [in] ptr Pointer to location
459 \return 0 Function succeeded
460 \return 1 Function failed
462 __STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
466 __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
469 #endif /* (__ARM_FEATURE_LDREX >= 2) */
472 #if (__ARM_FEATURE_LDREX >= 4)
474 \brief LDR Exclusive (32 bit)
475 \details Executes a exclusive LDR instruction for 32 bit values.
476 \param [in] ptr Pointer to data
477 \return value of type uint32_t at (*ptr)
479 __STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr)
483 __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
489 \brief STR Exclusive (32 bit)
490 \details Executes a exclusive STR instruction for 32 bit values.
491 \param [in] value Value to store
492 \param [in] ptr Pointer to location
493 \return 0 Function succeeded
494 \return 1 Function failed
496 __STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
500 __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
503 #endif /* (__ARM_FEATURE_LDREX >= 4) */
506 #if (__ARM_ARCH_ISA_THUMB >= 2)
508 \brief Rotate Right with Extend (32 bit)
509 \details Moves each bit of a bitstring right by one bit.
510 The carry input is shifted in at the left end of the bitstring.
511 \param [in] value Value to rotate
512 \return Rotated value
514 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
518 __ASM volatile ("rrx %0, %1" : "=r" (result) : "r" (value));
524 \brief LDRT Unprivileged (8 bit)
525 \details Executes a Unprivileged LDRT instruction for 8 bit value.
526 \param [in] ptr Pointer to data
527 \return value of type uint8_t at (*ptr)
529 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
533 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
534 return ((uint8_t)result); /* Add explicit type cast here */
539 \brief LDRT Unprivileged (16 bit)
540 \details Executes a Unprivileged LDRT instruction for 16 bit values.
541 \param [in] ptr Pointer to data
542 \return value of type uint16_t at (*ptr)
544 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
548 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
549 return ((uint16_t)result); /* Add explicit type cast here */
554 \brief LDRT Unprivileged (32 bit)
555 \details Executes a Unprivileged LDRT instruction for 32 bit values.
556 \param [in] ptr Pointer to data
557 \return value of type uint32_t at (*ptr)
559 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
563 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
569 \brief STRT Unprivileged (8 bit)
570 \details Executes a Unprivileged STRT instruction for 8 bit values.
571 \param [in] value Value to store
572 \param [in] ptr Pointer to location
574 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
576 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
581 \brief STRT Unprivileged (16 bit)
582 \details Executes a Unprivileged STRT instruction for 16 bit values.
583 \param [in] value Value to store
584 \param [in] ptr Pointer to location
586 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
588 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
593 \brief STRT Unprivileged (32 bit)
594 \details Executes a Unprivileged STRT instruction for 32 bit values.
595 \param [in] value Value to store
596 \param [in] ptr Pointer to location
598 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
600 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
602 #endif /* (__ARM_ARCH_ISA_THUMB >= 2) */
605 #if (__ARM_ARCH >= 8)
607 \brief Load-Acquire (8 bit)
608 \details Executes a LDAB instruction for 8 bit value.
609 \param [in] ptr Pointer to data
610 \return value of type uint8_t at (*ptr)
612 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
616 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
617 return ((uint8_t)result); /* Add explicit type cast here */
622 \brief Load-Acquire (16 bit)
623 \details Executes a LDAH instruction for 16 bit values.
624 \param [in] ptr Pointer to data
625 \return value of type uint16_t at (*ptr)
627 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
631 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
632 return ((uint16_t)result); /* Add explicit type cast here */
637 \brief Load-Acquire (32 bit)
638 \details Executes a LDA instruction for 32 bit values.
639 \param [in] ptr Pointer to data
640 \return value of type uint32_t at (*ptr)
642 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
646 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
652 \brief Store-Release (8 bit)
653 \details Executes a STLB instruction for 8 bit values.
654 \param [in] value Value to store
655 \param [in] ptr Pointer to location
657 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
659 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
664 \brief Store-Release (16 bit)
665 \details Executes a STLH instruction for 16 bit values.
666 \param [in] value Value to store
667 \param [in] ptr Pointer to location
669 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
671 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
676 \brief Store-Release (32 bit)
677 \details Executes a STL instruction for 32 bit values.
678 \param [in] value Value to store
679 \param [in] ptr Pointer to location
681 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
683 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
688 \brief Load-Acquire Exclusive (8 bit)
689 \details Executes a LDAB exclusive instruction for 8 bit value.
690 \param [in] ptr Pointer to data
691 \return value of type uint8_t at (*ptr)
693 __STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
697 __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
698 return ((uint8_t)result); /* Add explicit type cast here */
703 \brief Load-Acquire Exclusive (16 bit)
704 \details Executes a LDAH exclusive instruction for 16 bit values.
705 \param [in] ptr Pointer to data
706 \return value of type uint16_t at (*ptr)
708 __STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
712 __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
713 return ((uint16_t)result); /* Add explicit type cast here */
718 \brief Load-Acquire Exclusive (32 bit)
719 \details Executes a LDA exclusive instruction for 32 bit values.
720 \param [in] ptr Pointer to data
721 \return value of type uint32_t at (*ptr)
723 __STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr)
727 __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
733 \brief Store-Release Exclusive (8 bit)
734 \details Executes a STLB exclusive instruction for 8 bit values.
735 \param [in] value Value to store
736 \param [in] ptr Pointer to location
737 \return 0 Function succeeded
738 \return 1 Function failed
740 __STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
744 __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
750 \brief Store-Release Exclusive (16 bit)
751 \details Executes a STLH exclusive instruction for 16 bit values.
752 \param [in] value Value to store
753 \param [in] ptr Pointer to location
754 \return 0 Function succeeded
755 \return 1 Function failed
757 __STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
761 __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
767 \brief Store-Release Exclusive (32 bit)
768 \details Executes a STL exclusive instruction for 32 bit values.
769 \param [in] value Value to store
770 \param [in] ptr Pointer to location
771 \return 0 Function succeeded
772 \return 1 Function failed
774 __STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
778 __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
782 #endif /* (__ARM_ARCH >= 8) */
784 /** @}*/ /* end of group CMSIS_Core_InstructionInterface */
787 /* ########################### Core Function Access ########################### */
788 /** \ingroup CMSIS_Core_FunctionInterface
789 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
794 \brief Enable IRQ Interrupts
795 \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
796 Can only be executed in Privileged modes.
798 __STATIC_FORCEINLINE void __enable_irq(void)
800 __ASM volatile ("cpsie i" : : : "memory");
805 \brief Disable IRQ Interrupts
806 \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
807 Can only be executed in Privileged modes.
809 __STATIC_FORCEINLINE void __disable_irq(void)
811 __ASM volatile ("cpsid i" : : : "memory");
814 #if (__ARM_ARCH_ISA_THUMB >= 2)
817 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
818 Can only be executed in Privileged modes.
820 __STATIC_FORCEINLINE void __enable_fault_irq(void)
822 __ASM volatile ("cpsie f" : : : "memory");
828 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
829 Can only be executed in Privileged modes.
831 __STATIC_FORCEINLINE void __disable_fault_irq(void)
833 __ASM volatile ("cpsid f" : : : "memory");
840 \details Returns the current value of the Floating Point Status/Control register.
841 \return Floating Point Status/Control register value
843 __STATIC_FORCEINLINE uint32_t __get_FPSCR(void)
845 #if (defined(__ARM_FP) && (__ARM_FP >= 1))
846 return (__builtin_arm_get_fpscr());
855 \details Assigns the given value to the Floating Point Status/Control register.
856 \param [in] fpscr Floating Point Status/Control value to set
858 __STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr)
860 #if (defined(__ARM_FP) && (__ARM_FP >= 1))
861 __builtin_arm_set_fpscr(fpscr);
868 /** @} end of CMSIS_Core_RegAccFunctions */
871 /* ################### Compiler specific Intrinsics ########################### */
872 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
873 Access to dedicated SIMD instructions
877 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
878 #define __SADD8 __sadd8
879 #define __QADD8 __qadd8
880 #define __SHADD8 __shadd8
881 #define __UADD8 __uadd8
882 #define __UQADD8 __uqadd8
883 #define __UHADD8 __uhadd8
884 #define __SSUB8 __ssub8
885 #define __QSUB8 __qsub8
886 #define __SHSUB8 __shsub8
887 #define __USUB8 __usub8
888 #define __UQSUB8 __uqsub8
889 #define __UHSUB8 __uhsub8
890 #define __SADD16 __sadd16
891 #define __QADD16 __qadd16
892 #define __SHADD16 __shadd16
893 #define __UADD16 __uadd16
894 #define __UQADD16 __uqadd16
895 #define __UHADD16 __uhadd16
896 #define __SSUB16 __ssub16
897 #define __QSUB16 __qsub16
898 #define __SHSUB16 __shsub16
899 #define __USUB16 __usub16
900 #define __UQSUB16 __uqsub16
901 #define __UHSUB16 __uhsub16
902 #define __SASX __sasx
903 #define __QASX __qasx
904 #define __SHASX __shasx
905 #define __UASX __uasx
906 #define __UQASX __uqasx
907 #define __UHASX __uhasx
908 #define __SSAX __ssax
909 #define __QSAX __qsax
910 #define __SHSAX __shsax
911 #define __USAX __usax
912 #define __UQSAX __uqsax
913 #define __UHSAX __uhsax
914 #define __USAD8 __usad8
915 #define __USADA8 __usada8
916 #define __SSAT16 __ssat16
917 #define __USAT16 __usat16
918 #define __UXTB16 __uxtb16
919 #define __UXTAB16 __uxtab16
920 #define __SXTB16 __sxtb16
921 #define __SXTAB16 __sxtab16
922 #define __SMUAD __smuad
923 #define __SMUADX __smuadx
924 #define __SMLAD __smlad
925 #define __SMLADX __smladx
926 #define __SMLALD __smlald
927 #define __SMLALDX __smlaldx
928 #define __SMUSD __smusd
929 #define __SMUSDX __smusdx
930 #define __SMLSD __smlsd
931 #define __SMLSDX __smlsdx
932 #define __SMLSLD __smlsld
933 #define __SMLSLDX __smlsldx
935 #define __QADD __qadd
936 #define __QSUB __qsub
938 #define __PKHBT(ARG1,ARG2,ARG3) \
941 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
942 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
946 #define __PKHTB(ARG1,ARG2,ARG3) \
949 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
951 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
953 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
957 __STATIC_FORCEINLINE uint32_t __SXTB16_RORn(uint32_t op1, uint32_t rotate)
960 if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U)))
962 __ASM volatile("sxtb16 %0, %1, ROR %2" : "=r"(result) : "r"(op1), "i"(rotate));
966 result = __SXTB16(__ROR(op1, rotate));
971 __STATIC_FORCEINLINE uint32_t __SXTAB16_RORn(uint32_t op1, uint32_t op2, uint32_t rotate)
974 if (__builtin_constant_p(rotate) && ((rotate == 8U) || (rotate == 16U) || (rotate == 24U)))
976 __ASM volatile("sxtab16 %0, %1, %2, ROR %3" : "=r"(result) : "r"(op1), "r"(op2), "i"(rotate));
980 result = __SXTAB16(op1, __ROR(op2, rotate));
985 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
989 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
992 #endif /* (__ARM_FEATURE_DSP == 1) */
993 /** @} end of group CMSIS_SIMD_intrinsics */
995 // Include the profile specific settings:
996 #if __ARM_ARCH_PROFILE == 'A'
997 #include "a-profile/cmsis_gcc_a.h"
998 #elif __ARM_ARCH_PROFILE == 'R'
999 #include "r-profile/cmsis_gcc_r.h"
1000 #elif __ARM_ARCH_PROFILE == 'M'
1001 #include "m-profile/cmsis_gcc_m.h"
1003 #error "Unknown Arm architecture profile"
1006 #endif /* __CMSIS_GCC_H */