1 /**************************************************************************//**
2 * @file cmsis_armclang.h
3 * @brief CMSIS compiler ARMCLANG (ARM compiler V6) header file
5 * @date 13. February 2017
6 ******************************************************************************/
8 * Copyright (c) 2009-2017 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.
25 #ifndef __CMSIS_ARMCLANG_H
26 #define __CMSIS_ARMCLANG_H
28 #ifndef __ARM_COMPAT_H
29 #include <arm_compat.h> /* Compatibility header for ARM Compiler 5 intrinsics */
32 /* CMSIS compiler specific defines */
37 #define __INLINE __inline
39 #ifndef __STATIC_INLINE
40 #define __STATIC_INLINE static __inline
43 #define __NO_RETURN __attribute__((noreturn))
46 #define __USED __attribute__((used))
49 #define __WEAK __attribute__((weak))
52 #define __PACKED __attribute__((packed, aligned(1)))
54 #ifndef __PACKED_STRUCT
55 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
57 #ifndef __UNALIGNED_UINT32 /* deprecated */
58 #pragma clang diagnostic push
59 #pragma clang diagnostic ignored "-Wpacked"
60 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
61 #pragma clang diagnostic pop
62 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
64 #ifndef __UNALIGNED_UINT16_WRITE
65 #pragma clang diagnostic push
66 #pragma clang diagnostic ignored "-Wpacked"
67 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
68 #pragma clang diagnostic pop
69 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
71 #ifndef __UNALIGNED_UINT16_READ
72 #pragma clang diagnostic push
73 #pragma clang diagnostic ignored "-Wpacked"
74 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
75 #pragma clang diagnostic pop
76 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
78 #ifndef __UNALIGNED_UINT32_WRITE
79 #pragma clang diagnostic push
80 #pragma clang diagnostic ignored "-Wpacked"
81 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
82 #pragma clang diagnostic pop
83 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
85 #ifndef __UNALIGNED_UINT32_READ
86 #pragma clang diagnostic push
87 #pragma clang diagnostic ignored "-Wpacked"
88 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
89 #pragma clang diagnostic pop
90 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
93 #define __ALIGNED(x) __attribute__((aligned(x)))
97 /* ########################### Core Function Access ########################### */
98 /** \ingroup CMSIS_Core_FunctionInterface
99 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
104 \brief Enable IRQ Interrupts
105 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
106 Can only be executed in Privileged modes.
108 /* intrinsic void __enable_irq(); see arm_compat.h */
112 \brief Disable IRQ Interrupts
113 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
114 Can only be executed in Privileged modes.
116 /* intrinsic void __disable_irq(); see arm_compat.h */
120 \brief Get Control Register
121 \details Returns the content of the Control Register.
122 \return Control Register value
124 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
128 __ASM volatile ("MRS %0, control" : "=r" (result) );
133 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
135 \brief Get Control Register (non-secure)
136 \details Returns the content of the non-secure Control Register when in secure mode.
137 \return non-secure Control Register value
139 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
143 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
150 \brief Set Control Register
151 \details Writes the given value to the Control Register.
152 \param [in] control Control Register value to set
154 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
156 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
160 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
162 \brief Set Control Register (non-secure)
163 \details Writes the given value to the non-secure Control Register when in secure state.
164 \param [in] control Control Register value to set
166 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
168 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
174 \brief Get IPSR Register
175 \details Returns the content of the IPSR Register.
176 \return IPSR Register value
178 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
182 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
188 \brief Get APSR Register
189 \details Returns the content of the APSR Register.
190 \return APSR Register value
192 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
196 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
202 \brief Get xPSR Register
203 \details Returns the content of the xPSR Register.
204 \return xPSR Register value
206 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
210 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
216 \brief Get Process Stack Pointer
217 \details Returns the current value of the Process Stack Pointer (PSP).
218 \return PSP Register value
220 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
222 register uint32_t result;
224 __ASM volatile ("MRS %0, psp" : "=r" (result) );
229 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
231 \brief Get Process Stack Pointer (non-secure)
232 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
233 \return PSP Register value
235 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
237 register uint32_t result;
239 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
246 \brief Set Process Stack Pointer
247 \details Assigns the given value to the Process Stack Pointer (PSP).
248 \param [in] topOfProcStack Process Stack Pointer value to set
250 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
252 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
256 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
258 \brief Set Process Stack Pointer (non-secure)
259 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
260 \param [in] topOfProcStack Process Stack Pointer value to set
262 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
264 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
270 \brief Get Main Stack Pointer
271 \details Returns the current value of the Main Stack Pointer (MSP).
272 \return MSP Register value
274 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
276 register uint32_t result;
278 __ASM volatile ("MRS %0, msp" : "=r" (result) );
283 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
285 \brief Get Main Stack Pointer (non-secure)
286 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
287 \return MSP Register value
289 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
291 register uint32_t result;
293 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
300 \brief Set Main Stack Pointer
301 \details Assigns the given value to the Main Stack Pointer (MSP).
302 \param [in] topOfMainStack Main Stack Pointer value to set
304 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
306 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
310 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
312 \brief Set Main Stack Pointer (non-secure)
313 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
314 \param [in] topOfMainStack Main Stack Pointer value to set
316 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
318 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
323 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
325 \brief Get Stack Pointer (non-secure)
326 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
327 \return SP Register value
329 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_SP_NS(void)
331 register uint32_t result;
333 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
339 \brief Set Stack Pointer (non-secure)
340 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
341 \param [in] topOfStack Stack Pointer value to set
343 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_SP_NS(uint32_t topOfStack)
345 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
351 \brief Get Priority Mask
352 \details Returns the current state of the priority mask bit from the Priority Mask Register.
353 \return Priority Mask value
355 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
359 __ASM volatile ("MRS %0, primask" : "=r" (result) );
364 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
366 \brief Get Priority Mask (non-secure)
367 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
368 \return Priority Mask value
370 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
374 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
381 \brief Set Priority Mask
382 \details Assigns the given value to the Priority Mask Register.
383 \param [in] priMask Priority Mask
385 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
387 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
391 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
393 \brief Set Priority Mask (non-secure)
394 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
395 \param [in] priMask Priority Mask
397 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
399 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
404 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
405 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
406 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
409 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
410 Can only be executed in Privileged modes.
412 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
417 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
418 Can only be executed in Privileged modes.
420 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
424 \brief Get Base Priority
425 \details Returns the current value of the Base Priority register.
426 \return Base Priority register value
428 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
432 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
437 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
439 \brief Get Base Priority (non-secure)
440 \details Returns the current value of the non-secure Base Priority register when in secure state.
441 \return Base Priority register value
443 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
447 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
454 \brief Set Base Priority
455 \details Assigns the given value to the Base Priority register.
456 \param [in] basePri Base Priority value to set
458 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
460 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
464 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
466 \brief Set Base Priority (non-secure)
467 \details Assigns the given value to the non-secure Base Priority register when in secure state.
468 \param [in] basePri Base Priority value to set
470 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
472 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
478 \brief Set Base Priority with condition
479 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
480 or the new value increases the BASEPRI priority level.
481 \param [in] basePri Base Priority value to set
483 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
485 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
490 \brief Get Fault Mask
491 \details Returns the current value of the Fault Mask register.
492 \return Fault Mask register value
494 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
498 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
503 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
505 \brief Get Fault Mask (non-secure)
506 \details Returns the current value of the non-secure Fault Mask register when in secure state.
507 \return Fault Mask register value
509 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
513 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
520 \brief Set Fault Mask
521 \details Assigns the given value to the Fault Mask register.
522 \param [in] faultMask Fault Mask value to set
524 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
526 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
530 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
532 \brief Set Fault Mask (non-secure)
533 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
534 \param [in] faultMask Fault Mask value to set
536 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
538 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
542 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
543 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
544 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
547 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
548 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
551 \brief Get Process Stack Pointer Limit
552 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
553 \return PSPLIM Register value
555 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
557 register uint32_t result;
559 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
564 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
565 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
567 \brief Get Process Stack Pointer Limit (non-secure)
568 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
569 \return PSPLIM Register value
571 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
573 register uint32_t result;
575 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
582 \brief Set Process Stack Pointer Limit
583 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
584 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
586 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
588 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
592 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
593 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
595 \brief Set Process Stack Pointer (non-secure)
596 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
597 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
599 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
601 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
607 \brief Get Main Stack Pointer Limit
608 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
609 \return MSPLIM Register value
611 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
613 register uint32_t result;
615 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
621 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
622 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
624 \brief Get Main Stack Pointer Limit (non-secure)
625 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
626 \return MSPLIM Register value
628 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
630 register uint32_t result;
632 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
639 \brief Set Main Stack Pointer Limit
640 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
641 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
643 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
645 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
649 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
650 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
652 \brief Set Main Stack Pointer Limit (non-secure)
653 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
654 \param [in] MainStackPtrLimit Main Stack Pointer value to set
656 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
658 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
662 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
663 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
666 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
667 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
671 \details Returns the current value of the Floating Point Status/Control register.
672 \return Floating Point Status/Control register value
674 /* #define __get_FPSCR __builtin_arm_get_fpscr */
675 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
677 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
678 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
681 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
691 \details Assigns the given value to the Floating Point Status/Control register.
692 \param [in] fpscr Floating Point Status/Control value to set
694 /* #define __set_FPSCR __builtin_arm_set_fpscr */
695 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
697 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
698 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
699 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
705 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
706 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
710 /*@} end of CMSIS_Core_RegAccFunctions */
713 /* ########################## Core Instruction Access ######################### */
714 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
715 Access to dedicated instructions
719 /* Define macros for porting to both thumb1 and thumb2.
720 * For thumb1, use low register (r0-r7), specified by constraint "l"
721 * Otherwise, use general registers, specified by constraint "r" */
722 #if defined (__thumb__) && !defined (__thumb2__)
723 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
724 #define __CMSIS_GCC_USE_REG(r) "l" (r)
726 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
727 #define __CMSIS_GCC_USE_REG(r) "r" (r)
732 \details No Operation does nothing. This instruction can be used for code alignment purposes.
734 #define __NOP __builtin_arm_nop
737 \brief Wait For Interrupt
738 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
740 #define __WFI __builtin_arm_wfi
744 \brief Wait For Event
745 \details Wait For Event is a hint instruction that permits the processor to enter
746 a low-power state until one of a number of events occurs.
748 #define __WFE __builtin_arm_wfe
753 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
755 #define __SEV __builtin_arm_sev
759 \brief Instruction Synchronization Barrier
760 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
761 so that all instructions following the ISB are fetched from cache or memory,
762 after the instruction has been completed.
764 #define __ISB() __builtin_arm_isb(0xF);
767 \brief Data Synchronization Barrier
768 \details Acts as a special kind of Data Memory Barrier.
769 It completes when all explicit memory accesses before this instruction complete.
771 #define __DSB() __builtin_arm_dsb(0xF);
775 \brief Data Memory Barrier
776 \details Ensures the apparent order of the explicit memory operations before
777 and after the instruction, without ensuring their completion.
779 #define __DMB() __builtin_arm_dmb(0xF);
783 \brief Reverse byte order (32 bit)
784 \details Reverses the byte order in integer value.
785 \param [in] value Value to reverse
786 \return Reversed value
788 #define __REV __builtin_bswap32
792 \brief Reverse byte order (16 bit)
793 \details Reverses the byte order in two unsigned short values.
794 \param [in] value Value to reverse
795 \return Reversed value
797 #define __REV16 __builtin_bswap16 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
799 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
803 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
810 \brief Reverse byte order in signed short value
811 \details Reverses the byte order in a signed short value with sign extension to integer.
812 \param [in] value Value to reverse
813 \return Reversed value
815 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
816 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
820 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
826 \brief Rotate Right in unsigned value (32 bit)
827 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
828 \param [in] op1 Value to rotate
829 \param [in] op2 Number of Bits to rotate
830 \return Rotated value
832 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
834 return (op1 >> op2) | (op1 << (32U - op2));
840 \details Causes the processor to enter Debug state.
841 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
842 \param [in] value is ignored by the processor.
843 If required, a debugger can use it to store additional information about the breakpoint.
845 #define __BKPT(value) __ASM volatile ("bkpt "#value)
849 \brief Reverse bit order of value
850 \details Reverses the bit order of the given value.
851 \param [in] value Value to reverse
852 \return Reversed value
854 /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
855 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
859 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
860 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
861 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
862 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
864 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
866 result = value; /* r will be reversed bits of v; first get LSB of v */
867 for (value >>= 1U; value; value >>= 1U)
870 result |= value & 1U;
873 result <<= s; /* shift when v's highest bits are zero */
880 \brief Count leading zeros
881 \details Counts the number of leading zeros of a data value.
882 \param [in] value Value to count the leading zeros
883 \return number of leading zeros in value
885 #define __CLZ __builtin_clz
888 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
889 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
890 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
891 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
893 \brief LDR Exclusive (8 bit)
894 \details Executes a exclusive LDR instruction for 8 bit value.
895 \param [in] ptr Pointer to data
896 \return value of type uint8_t at (*ptr)
898 #define __LDREXB (uint8_t)__builtin_arm_ldrex
902 \brief LDR Exclusive (16 bit)
903 \details Executes a exclusive LDR instruction for 16 bit values.
904 \param [in] ptr Pointer to data
905 \return value of type uint16_t at (*ptr)
907 #define __LDREXH (uint16_t)__builtin_arm_ldrex
911 \brief LDR Exclusive (32 bit)
912 \details Executes a exclusive LDR instruction for 32 bit values.
913 \param [in] ptr Pointer to data
914 \return value of type uint32_t at (*ptr)
916 #define __LDREXW (uint32_t)__builtin_arm_ldrex
920 \brief STR Exclusive (8 bit)
921 \details Executes a exclusive STR instruction for 8 bit values.
922 \param [in] value Value to store
923 \param [in] ptr Pointer to location
924 \return 0 Function succeeded
925 \return 1 Function failed
927 #define __STREXB (uint32_t)__builtin_arm_strex
931 \brief STR Exclusive (16 bit)
932 \details Executes a exclusive STR instruction for 16 bit values.
933 \param [in] value Value to store
934 \param [in] ptr Pointer to location
935 \return 0 Function succeeded
936 \return 1 Function failed
938 #define __STREXH (uint32_t)__builtin_arm_strex
942 \brief STR Exclusive (32 bit)
943 \details Executes a exclusive STR instruction for 32 bit values.
944 \param [in] value Value to store
945 \param [in] ptr Pointer to location
946 \return 0 Function succeeded
947 \return 1 Function failed
949 #define __STREXW (uint32_t)__builtin_arm_strex
953 \brief Remove the exclusive lock
954 \details Removes the exclusive lock which is created by LDREX.
956 #define __CLREX __builtin_arm_clrex
958 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
959 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
960 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
961 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
964 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
965 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
966 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
968 \brief Signed Saturate
969 \details Saturates a signed value.
970 \param [in] value Value to be saturated
971 \param [in] sat Bit position to saturate to (1..32)
972 \return Saturated value
974 #define __SSAT __builtin_arm_ssat
978 \brief Unsigned Saturate
979 \details Saturates an unsigned value.
980 \param [in] value Value to be saturated
981 \param [in] sat Bit position to saturate to (0..31)
982 \return Saturated value
984 #define __USAT __builtin_arm_usat
988 \brief Rotate Right with Extend (32 bit)
989 \details Moves each bit of a bitstring right by one bit.
990 The carry input is shifted in at the left end of the bitstring.
991 \param [in] value Value to rotate
992 \return Rotated value
994 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
998 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1004 \brief LDRT Unprivileged (8 bit)
1005 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1006 \param [in] ptr Pointer to data
1007 \return value of type uint8_t at (*ptr)
1009 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1013 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1014 return ((uint8_t) result); /* Add explicit type cast here */
1019 \brief LDRT Unprivileged (16 bit)
1020 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1021 \param [in] ptr Pointer to data
1022 \return value of type uint16_t at (*ptr)
1024 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1028 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1029 return ((uint16_t) result); /* Add explicit type cast here */
1034 \brief LDRT Unprivileged (32 bit)
1035 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1036 \param [in] ptr Pointer to data
1037 \return value of type uint32_t at (*ptr)
1039 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1043 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1049 \brief STRT Unprivileged (8 bit)
1050 \details Executes a Unprivileged STRT instruction for 8 bit values.
1051 \param [in] value Value to store
1052 \param [in] ptr Pointer to location
1054 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1056 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1061 \brief STRT Unprivileged (16 bit)
1062 \details Executes a Unprivileged STRT instruction for 16 bit values.
1063 \param [in] value Value to store
1064 \param [in] ptr Pointer to location
1066 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1068 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1073 \brief STRT Unprivileged (32 bit)
1074 \details Executes a Unprivileged STRT instruction for 32 bit values.
1075 \param [in] value Value to store
1076 \param [in] ptr Pointer to location
1078 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1080 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1083 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1084 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1085 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1088 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1089 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1091 \brief Load-Acquire (8 bit)
1092 \details Executes a LDAB instruction for 8 bit value.
1093 \param [in] ptr Pointer to data
1094 \return value of type uint8_t at (*ptr)
1096 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1100 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1101 return ((uint8_t) result);
1106 \brief Load-Acquire (16 bit)
1107 \details Executes a LDAH instruction for 16 bit values.
1108 \param [in] ptr Pointer to data
1109 \return value of type uint16_t at (*ptr)
1111 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1115 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1116 return ((uint16_t) result);
1121 \brief Load-Acquire (32 bit)
1122 \details Executes a LDA instruction for 32 bit values.
1123 \param [in] ptr Pointer to data
1124 \return value of type uint32_t at (*ptr)
1126 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1130 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1136 \brief Store-Release (8 bit)
1137 \details Executes a STLB instruction for 8 bit values.
1138 \param [in] value Value to store
1139 \param [in] ptr Pointer to location
1141 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1143 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1148 \brief Store-Release (16 bit)
1149 \details Executes a STLH instruction for 16 bit values.
1150 \param [in] value Value to store
1151 \param [in] ptr Pointer to location
1153 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1155 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1160 \brief Store-Release (32 bit)
1161 \details Executes a STL instruction for 32 bit values.
1162 \param [in] value Value to store
1163 \param [in] ptr Pointer to location
1165 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1167 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1172 \brief Load-Acquire Exclusive (8 bit)
1173 \details Executes a LDAB exclusive instruction for 8 bit value.
1174 \param [in] ptr Pointer to data
1175 \return value of type uint8_t at (*ptr)
1177 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1181 \brief Load-Acquire Exclusive (16 bit)
1182 \details Executes a LDAH exclusive instruction for 16 bit values.
1183 \param [in] ptr Pointer to data
1184 \return value of type uint16_t at (*ptr)
1186 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1190 \brief Load-Acquire Exclusive (32 bit)
1191 \details Executes a LDA exclusive instruction for 32 bit values.
1192 \param [in] ptr Pointer to data
1193 \return value of type uint32_t at (*ptr)
1195 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1199 \brief Store-Release Exclusive (8 bit)
1200 \details Executes a STLB exclusive instruction for 8 bit values.
1201 \param [in] value Value to store
1202 \param [in] ptr Pointer to location
1203 \return 0 Function succeeded
1204 \return 1 Function failed
1206 #define __STLEXB (uint32_t)__builtin_arm_stlex
1210 \brief Store-Release Exclusive (16 bit)
1211 \details Executes a STLH exclusive instruction for 16 bit values.
1212 \param [in] value Value to store
1213 \param [in] ptr Pointer to location
1214 \return 0 Function succeeded
1215 \return 1 Function failed
1217 #define __STLEXH (uint32_t)__builtin_arm_stlex
1221 \brief Store-Release Exclusive (32 bit)
1222 \details Executes a STL exclusive instruction for 32 bit values.
1223 \param [in] value Value to store
1224 \param [in] ptr Pointer to location
1225 \return 0 Function succeeded
1226 \return 1 Function failed
1228 #define __STLEX (uint32_t)__builtin_arm_stlex
1230 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1231 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1233 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1236 /* ################### Compiler specific Intrinsics ########################### */
1237 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1238 Access to dedicated SIMD instructions
1242 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1244 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1248 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1252 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1256 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1260 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1264 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1268 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1272 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1276 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1280 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1284 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1288 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1293 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1297 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1301 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1305 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1309 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1313 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1317 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1321 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1325 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1329 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1333 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1337 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1342 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1346 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1350 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1354 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1358 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1362 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1366 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1370 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1374 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1378 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1382 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1386 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1390 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1394 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1398 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1402 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1406 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1410 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1414 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1418 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1422 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1426 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1430 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1434 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1438 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1442 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1446 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1450 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1454 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1458 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1462 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1466 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1470 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1474 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1478 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1482 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1486 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1490 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1494 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1498 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1502 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1506 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1510 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1514 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1518 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1522 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1526 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1530 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1534 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1538 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1542 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1546 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1550 #define __SSAT16(ARG1,ARG2) \
1552 int32_t __RES, __ARG1 = (ARG1); \
1553 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1557 #define __USAT16(ARG1,ARG2) \
1559 uint32_t __RES, __ARG1 = (ARG1); \
1560 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1564 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1568 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1572 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1576 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1580 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1584 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1588 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1592 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1596 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1600 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1604 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1608 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1612 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1616 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1620 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1624 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1628 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1636 #ifndef __ARMEB__ /* Little endian */
1637 __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1638 #else /* Big endian */
1639 __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1645 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1653 #ifndef __ARMEB__ /* Little endian */
1654 __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1655 #else /* Big endian */
1656 __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1662 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1666 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1670 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1674 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1678 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1682 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1686 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1690 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1694 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1702 #ifndef __ARMEB__ /* Little endian */
1703 __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1704 #else /* Big endian */
1705 __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1711 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1719 #ifndef __ARMEB__ /* Little endian */
1720 __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1721 #else /* Big endian */
1722 __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1728 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1732 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1736 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1740 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1744 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1748 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1753 #define __PKHBT(ARG1,ARG2,ARG3) \
1755 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1756 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1760 #define __PKHTB(ARG1,ARG2,ARG3) \
1762 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1764 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1766 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1771 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1772 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1774 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1775 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1777 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1781 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1785 #endif /* (__ARM_FEATURE_DSP == 1) */
1786 /*@} end of group CMSIS_SIMD_intrinsics */
1789 #endif /* __CMSIS_ARMCLANG_H */