1 /**************************************************************************//**
2 * @file cmsis_armclang.h
3 * @brief CMSIS compiler ARMCLANG (ARM compiler V6) header file
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 //lint -esym(9058, IRQn) disable MISRA 2012 Rule 2.4 for IRQn
27 #ifndef __CMSIS_ARMCLANG_H
28 #define __CMSIS_ARMCLANG_H
30 #ifndef __ARM_COMPAT_H
31 #include <arm_compat.h> /* Compatibility header for ARM Compiler 5 intrinsics */
34 /* CMSIS compiler specific defines */
39 #define __INLINE __inline
41 #ifndef __STATIC_INLINE
42 #define __STATIC_INLINE static __inline
45 #define __NO_RETURN __attribute__((noreturn))
48 #define __USED __attribute__((used))
51 #define __WEAK __attribute__((weak))
54 #define __PACKED __attribute__((packed, aligned(1)))
56 #ifndef __PACKED_STRUCT
57 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
59 #ifndef __PACKED_UNION
60 #define __PACKED_UNION union __attribute__((packed, aligned(1)))
62 #ifndef __UNALIGNED_UINT32 /* deprecated */
63 #pragma clang diagnostic push
64 #pragma clang diagnostic ignored "-Wpacked"
65 //lint -esym(9058, T_UINT32) disable MISRA 2012 Rule 2.4 for T_UINT32
66 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
67 #pragma clang diagnostic pop
68 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
70 #ifndef __UNALIGNED_UINT16_WRITE
71 #pragma clang diagnostic push
72 #pragma clang diagnostic ignored "-Wpacked"
73 //lint -esym(9058, T_UINT16_WRITE) disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE
74 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
75 #pragma clang diagnostic pop
76 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
78 #ifndef __UNALIGNED_UINT16_READ
79 #pragma clang diagnostic push
80 #pragma clang diagnostic ignored "-Wpacked"
81 //lint -esym(9058, T_UINT16_READ) disable MISRA 2012 Rule 2.4 for T_UINT16_READ
82 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
83 #pragma clang diagnostic pop
84 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
86 #ifndef __UNALIGNED_UINT32_WRITE
87 #pragma clang diagnostic push
88 #pragma clang diagnostic ignored "-Wpacked"
89 //lint -esym(9058, T_UINT32_WRITE) disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE
90 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
91 #pragma clang diagnostic pop
92 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
94 #ifndef __UNALIGNED_UINT32_READ
95 #pragma clang diagnostic push
96 #pragma clang diagnostic ignored "-Wpacked"
97 //lint -esym(9058, T_UINT32_READ) disable MISRA 2012 Rule 2.4 for T_UINT32_READ
98 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
99 #pragma clang diagnostic pop
100 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
103 #define __ALIGNED(x) __attribute__((aligned(x)))
107 /* ########################### Core Function Access ########################### */
108 /** \ingroup CMSIS_Core_FunctionInterface
109 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
114 \brief Enable IRQ Interrupts
115 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
116 Can only be executed in Privileged modes.
118 /* intrinsic void __enable_irq(); see arm_compat.h */
122 \brief Disable IRQ Interrupts
123 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
124 Can only be executed in Privileged modes.
126 /* intrinsic void __disable_irq(); see arm_compat.h */
130 \brief Get Control Register
131 \details Returns the content of the Control Register.
132 \return Control Register value
134 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
138 __ASM volatile ("MRS %0, control" : "=r" (result) );
143 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
145 \brief Get Control Register (non-secure)
146 \details Returns the content of the non-secure Control Register when in secure mode.
147 \return non-secure Control Register value
149 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
153 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
160 \brief Set Control Register
161 \details Writes the given value to the Control Register.
162 \param [in] control Control Register value to set
164 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
166 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
170 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
172 \brief Set Control Register (non-secure)
173 \details Writes the given value to the non-secure Control Register when in secure state.
174 \param [in] control Control Register value to set
176 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
178 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
184 \brief Get IPSR Register
185 \details Returns the content of the IPSR Register.
186 \return IPSR Register value
188 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
192 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
198 \brief Get APSR Register
199 \details Returns the content of the APSR Register.
200 \return APSR Register value
202 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
206 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
212 \brief Get xPSR Register
213 \details Returns the content of the xPSR Register.
214 \return xPSR Register value
216 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
220 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
226 \brief Get Process Stack Pointer
227 \details Returns the current value of the Process Stack Pointer (PSP).
228 \return PSP Register value
230 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
232 register uint32_t result;
234 __ASM volatile ("MRS %0, psp" : "=r" (result) );
239 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
241 \brief Get Process Stack Pointer (non-secure)
242 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
243 \return PSP Register value
245 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
247 register uint32_t result;
249 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
256 \brief Set Process Stack Pointer
257 \details Assigns the given value to the Process Stack Pointer (PSP).
258 \param [in] topOfProcStack Process Stack Pointer value to set
260 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
262 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
266 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
268 \brief Set Process Stack Pointer (non-secure)
269 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
270 \param [in] topOfProcStack Process Stack Pointer value to set
272 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
274 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
280 \brief Get Main Stack Pointer
281 \details Returns the current value of the Main Stack Pointer (MSP).
282 \return MSP Register value
284 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
286 register uint32_t result;
288 __ASM volatile ("MRS %0, msp" : "=r" (result) );
293 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
295 \brief Get Main Stack Pointer (non-secure)
296 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
297 \return MSP Register value
299 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
301 register uint32_t result;
303 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
310 \brief Set Main Stack Pointer
311 \details Assigns the given value to the Main Stack Pointer (MSP).
312 \param [in] topOfMainStack Main Stack Pointer value to set
314 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
316 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
320 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
322 \brief Set Main Stack Pointer (non-secure)
323 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
324 \param [in] topOfMainStack Main Stack Pointer value to set
326 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
328 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
333 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
335 \brief Get Stack Pointer (non-secure)
336 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
337 \return SP Register value
339 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_SP_NS(void)
341 register uint32_t result;
343 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
349 \brief Set Stack Pointer (non-secure)
350 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
351 \param [in] topOfStack Stack Pointer value to set
353 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_SP_NS(uint32_t topOfStack)
355 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
361 \brief Get Priority Mask
362 \details Returns the current state of the priority mask bit from the Priority Mask Register.
363 \return Priority Mask value
365 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
369 __ASM volatile ("MRS %0, primask" : "=r" (result) );
374 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
376 \brief Get Priority Mask (non-secure)
377 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
378 \return Priority Mask value
380 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
384 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
391 \brief Set Priority Mask
392 \details Assigns the given value to the Priority Mask Register.
393 \param [in] priMask Priority Mask
395 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
397 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
401 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
403 \brief Set Priority Mask (non-secure)
404 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
405 \param [in] priMask Priority Mask
407 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
409 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
414 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
415 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
416 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
419 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
420 Can only be executed in Privileged modes.
422 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
427 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
428 Can only be executed in Privileged modes.
430 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
434 \brief Get Base Priority
435 \details Returns the current value of the Base Priority register.
436 \return Base Priority register value
438 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
442 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
447 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
449 \brief Get Base Priority (non-secure)
450 \details Returns the current value of the non-secure Base Priority register when in secure state.
451 \return Base Priority register value
453 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
457 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
464 \brief Set Base Priority
465 \details Assigns the given value to the Base Priority register.
466 \param [in] basePri Base Priority value to set
468 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
470 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
474 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
476 \brief Set Base Priority (non-secure)
477 \details Assigns the given value to the non-secure Base Priority register when in secure state.
478 \param [in] basePri Base Priority value to set
480 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
482 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
488 \brief Set Base Priority with condition
489 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
490 or the new value increases the BASEPRI priority level.
491 \param [in] basePri Base Priority value to set
493 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
495 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
500 \brief Get Fault Mask
501 \details Returns the current value of the Fault Mask register.
502 \return Fault Mask register value
504 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
508 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
513 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
515 \brief Get Fault Mask (non-secure)
516 \details Returns the current value of the non-secure Fault Mask register when in secure state.
517 \return Fault Mask register value
519 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
523 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
530 \brief Set Fault Mask
531 \details Assigns the given value to the Fault Mask register.
532 \param [in] faultMask Fault Mask value to set
534 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
536 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
540 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
542 \brief Set Fault Mask (non-secure)
543 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
544 \param [in] faultMask Fault Mask value to set
546 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
548 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
552 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
553 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
554 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
557 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
558 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
561 \brief Get Process Stack Pointer Limit
562 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
563 \return PSPLIM Register value
565 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
567 register uint32_t result;
569 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
574 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
575 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
577 \brief Get Process Stack Pointer Limit (non-secure)
578 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
579 \return PSPLIM Register value
581 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
583 register uint32_t result;
585 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
592 \brief Set Process Stack Pointer Limit
593 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
594 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
596 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
598 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
602 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
603 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
605 \brief Set Process Stack Pointer (non-secure)
606 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
607 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
609 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
611 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
617 \brief Get Main Stack Pointer Limit
618 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
619 \return MSPLIM Register value
621 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
623 register uint32_t result;
625 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
631 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
632 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
634 \brief Get Main Stack Pointer Limit (non-secure)
635 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
636 \return MSPLIM Register value
638 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
640 register uint32_t result;
642 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
649 \brief Set Main Stack Pointer Limit
650 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
651 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
653 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
655 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
659 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
660 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
662 \brief Set Main Stack Pointer Limit (non-secure)
663 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
664 \param [in] MainStackPtrLimit Main Stack Pointer value to set
666 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
668 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
672 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
673 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
676 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
677 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
681 \details Returns the current value of the Floating Point Status/Control register.
682 \return Floating Point Status/Control register value
684 /* #define __get_FPSCR __builtin_arm_get_fpscr */
685 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
687 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
688 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
691 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
701 \details Assigns the given value to the Floating Point Status/Control register.
702 \param [in] fpscr Floating Point Status/Control value to set
704 /* #define __set_FPSCR __builtin_arm_set_fpscr */
705 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
707 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
708 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
709 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
715 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
716 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
720 /*@} end of CMSIS_Core_RegAccFunctions */
723 /* ########################## Core Instruction Access ######################### */
724 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
725 Access to dedicated instructions
729 /* Define macros for porting to both thumb1 and thumb2.
730 * For thumb1, use low register (r0-r7), specified by constraint "l"
731 * Otherwise, use general registers, specified by constraint "r" */
732 #if defined (__thumb__) && !defined (__thumb2__)
733 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
734 #define __CMSIS_GCC_USE_REG(r) "l" (r)
736 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
737 #define __CMSIS_GCC_USE_REG(r) "r" (r)
742 \details No Operation does nothing. This instruction can be used for code alignment purposes.
744 #define __NOP __builtin_arm_nop
747 \brief Wait For Interrupt
748 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
750 #define __WFI __builtin_arm_wfi
754 \brief Wait For Event
755 \details Wait For Event is a hint instruction that permits the processor to enter
756 a low-power state until one of a number of events occurs.
758 #define __WFE __builtin_arm_wfe
763 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
765 #define __SEV __builtin_arm_sev
769 \brief Instruction Synchronization Barrier
770 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
771 so that all instructions following the ISB are fetched from cache or memory,
772 after the instruction has been completed.
774 #define __ISB() __builtin_arm_isb(0xF);
777 \brief Data Synchronization Barrier
778 \details Acts as a special kind of Data Memory Barrier.
779 It completes when all explicit memory accesses before this instruction complete.
781 #define __DSB() __builtin_arm_dsb(0xF);
785 \brief Data Memory Barrier
786 \details Ensures the apparent order of the explicit memory operations before
787 and after the instruction, without ensuring their completion.
789 #define __DMB() __builtin_arm_dmb(0xF);
793 \brief Reverse byte order (32 bit)
794 \details Reverses the byte order in integer value.
795 \param [in] value Value to reverse
796 \return Reversed value
798 #define __REV __builtin_bswap32
802 \brief Reverse byte order (16 bit)
803 \details Reverses the byte order in two unsigned short values.
804 \param [in] value Value to reverse
805 \return Reversed value
807 #define __REV16 __builtin_bswap16 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
809 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
813 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
820 \brief Reverse byte order in signed short value
821 \details Reverses the byte order in a signed short value with sign extension to integer.
822 \param [in] value Value to reverse
823 \return Reversed value
825 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
826 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
830 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
836 \brief Rotate Right in unsigned value (32 bit)
837 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
838 \param [in] op1 Value to rotate
839 \param [in] op2 Number of Bits to rotate
840 \return Rotated value
842 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
844 return (op1 >> op2) | (op1 << (32U - op2));
850 \details Causes the processor to enter Debug state.
851 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
852 \param [in] value is ignored by the processor.
853 If required, a debugger can use it to store additional information about the breakpoint.
855 #define __BKPT(value) __ASM volatile ("bkpt "#value)
859 \brief Reverse bit order of value
860 \details Reverses the bit order of the given value.
861 \param [in] value Value to reverse
862 \return Reversed value
864 /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
865 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
869 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
870 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
871 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
872 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
874 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
876 result = value; /* r will be reversed bits of v; first get LSB of v */
877 for (value >>= 1U; value; value >>= 1U)
880 result |= value & 1U;
883 result <<= s; /* shift when v's highest bits are zero */
890 \brief Count leading zeros
891 \details Counts the number of leading zeros of a data value.
892 \param [in] value Value to count the leading zeros
893 \return number of leading zeros in value
895 #define __CLZ __builtin_clz
898 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
899 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
900 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
901 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
903 \brief LDR Exclusive (8 bit)
904 \details Executes a exclusive LDR instruction for 8 bit value.
905 \param [in] ptr Pointer to data
906 \return value of type uint8_t at (*ptr)
908 #define __LDREXB (uint8_t)__builtin_arm_ldrex
912 \brief LDR Exclusive (16 bit)
913 \details Executes a exclusive LDR instruction for 16 bit values.
914 \param [in] ptr Pointer to data
915 \return value of type uint16_t at (*ptr)
917 #define __LDREXH (uint16_t)__builtin_arm_ldrex
921 \brief LDR Exclusive (32 bit)
922 \details Executes a exclusive LDR instruction for 32 bit values.
923 \param [in] ptr Pointer to data
924 \return value of type uint32_t at (*ptr)
926 #define __LDREXW (uint32_t)__builtin_arm_ldrex
930 \brief STR Exclusive (8 bit)
931 \details Executes a exclusive STR instruction for 8 bit values.
932 \param [in] value Value to store
933 \param [in] ptr Pointer to location
934 \return 0 Function succeeded
935 \return 1 Function failed
937 #define __STREXB (uint32_t)__builtin_arm_strex
941 \brief STR Exclusive (16 bit)
942 \details Executes a exclusive STR instruction for 16 bit values.
943 \param [in] value Value to store
944 \param [in] ptr Pointer to location
945 \return 0 Function succeeded
946 \return 1 Function failed
948 #define __STREXH (uint32_t)__builtin_arm_strex
952 \brief STR Exclusive (32 bit)
953 \details Executes a exclusive STR instruction for 32 bit values.
954 \param [in] value Value to store
955 \param [in] ptr Pointer to location
956 \return 0 Function succeeded
957 \return 1 Function failed
959 #define __STREXW (uint32_t)__builtin_arm_strex
963 \brief Remove the exclusive lock
964 \details Removes the exclusive lock which is created by LDREX.
966 #define __CLREX __builtin_arm_clrex
968 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
969 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
970 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
971 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
974 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
975 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
976 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
978 \brief Signed Saturate
979 \details Saturates a signed value.
980 \param [in] value Value to be saturated
981 \param [in] sat Bit position to saturate to (1..32)
982 \return Saturated value
984 #define __SSAT __builtin_arm_ssat
988 \brief Unsigned Saturate
989 \details Saturates an unsigned value.
990 \param [in] value Value to be saturated
991 \param [in] sat Bit position to saturate to (0..31)
992 \return Saturated value
994 #define __USAT __builtin_arm_usat
998 \brief Rotate Right with Extend (32 bit)
999 \details Moves each bit of a bitstring right by one bit.
1000 The carry input is shifted in at the left end of the bitstring.
1001 \param [in] value Value to rotate
1002 \return Rotated value
1004 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1008 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1014 \brief LDRT Unprivileged (8 bit)
1015 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1016 \param [in] ptr Pointer to data
1017 \return value of type uint8_t at (*ptr)
1019 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1023 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1024 return ((uint8_t) result); /* Add explicit type cast here */
1029 \brief LDRT Unprivileged (16 bit)
1030 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1031 \param [in] ptr Pointer to data
1032 \return value of type uint16_t at (*ptr)
1034 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1038 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1039 return ((uint16_t) result); /* Add explicit type cast here */
1044 \brief LDRT Unprivileged (32 bit)
1045 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1046 \param [in] ptr Pointer to data
1047 \return value of type uint32_t at (*ptr)
1049 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1053 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1059 \brief STRT Unprivileged (8 bit)
1060 \details Executes a Unprivileged STRT instruction for 8 bit values.
1061 \param [in] value Value to store
1062 \param [in] ptr Pointer to location
1064 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1066 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1071 \brief STRT Unprivileged (16 bit)
1072 \details Executes a Unprivileged STRT instruction for 16 bit values.
1073 \param [in] value Value to store
1074 \param [in] ptr Pointer to location
1076 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1078 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1083 \brief STRT Unprivileged (32 bit)
1084 \details Executes a Unprivileged STRT instruction for 32 bit values.
1085 \param [in] value Value to store
1086 \param [in] ptr Pointer to location
1088 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1090 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1093 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1094 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1095 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1098 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1099 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1101 \brief Load-Acquire (8 bit)
1102 \details Executes a LDAB instruction for 8 bit value.
1103 \param [in] ptr Pointer to data
1104 \return value of type uint8_t at (*ptr)
1106 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1110 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1111 return ((uint8_t) result);
1116 \brief Load-Acquire (16 bit)
1117 \details Executes a LDAH instruction for 16 bit values.
1118 \param [in] ptr Pointer to data
1119 \return value of type uint16_t at (*ptr)
1121 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1125 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1126 return ((uint16_t) result);
1131 \brief Load-Acquire (32 bit)
1132 \details Executes a LDA instruction for 32 bit values.
1133 \param [in] ptr Pointer to data
1134 \return value of type uint32_t at (*ptr)
1136 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1140 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1146 \brief Store-Release (8 bit)
1147 \details Executes a STLB instruction for 8 bit values.
1148 \param [in] value Value to store
1149 \param [in] ptr Pointer to location
1151 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1153 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1158 \brief Store-Release (16 bit)
1159 \details Executes a STLH instruction for 16 bit values.
1160 \param [in] value Value to store
1161 \param [in] ptr Pointer to location
1163 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1165 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1170 \brief Store-Release (32 bit)
1171 \details Executes a STL instruction for 32 bit values.
1172 \param [in] value Value to store
1173 \param [in] ptr Pointer to location
1175 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1177 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1182 \brief Load-Acquire Exclusive (8 bit)
1183 \details Executes a LDAB exclusive instruction for 8 bit value.
1184 \param [in] ptr Pointer to data
1185 \return value of type uint8_t at (*ptr)
1187 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1191 \brief Load-Acquire Exclusive (16 bit)
1192 \details Executes a LDAH exclusive instruction for 16 bit values.
1193 \param [in] ptr Pointer to data
1194 \return value of type uint16_t at (*ptr)
1196 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1200 \brief Load-Acquire Exclusive (32 bit)
1201 \details Executes a LDA exclusive instruction for 32 bit values.
1202 \param [in] ptr Pointer to data
1203 \return value of type uint32_t at (*ptr)
1205 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1209 \brief Store-Release Exclusive (8 bit)
1210 \details Executes a STLB exclusive instruction for 8 bit values.
1211 \param [in] value Value to store
1212 \param [in] ptr Pointer to location
1213 \return 0 Function succeeded
1214 \return 1 Function failed
1216 #define __STLEXB (uint32_t)__builtin_arm_stlex
1220 \brief Store-Release Exclusive (16 bit)
1221 \details Executes a STLH exclusive instruction for 16 bit values.
1222 \param [in] value Value to store
1223 \param [in] ptr Pointer to location
1224 \return 0 Function succeeded
1225 \return 1 Function failed
1227 #define __STLEXH (uint32_t)__builtin_arm_stlex
1231 \brief Store-Release Exclusive (32 bit)
1232 \details Executes a STL exclusive instruction for 32 bit values.
1233 \param [in] value Value to store
1234 \param [in] ptr Pointer to location
1235 \return 0 Function succeeded
1236 \return 1 Function failed
1238 #define __STLEX (uint32_t)__builtin_arm_stlex
1240 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1241 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1243 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1246 /* ################### Compiler specific Intrinsics ########################### */
1247 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1248 Access to dedicated SIMD instructions
1252 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1254 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1258 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1262 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1266 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1270 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1274 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1278 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1282 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1286 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1290 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1294 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1298 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1303 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1307 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1311 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1315 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1319 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1323 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1327 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1331 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1335 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1339 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1343 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1347 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1352 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1356 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1360 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1364 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1368 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1372 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1376 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1380 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1384 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1388 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1396 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1400 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1404 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1408 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1412 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1416 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1420 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1424 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1428 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1432 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1436 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1440 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1444 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1448 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1452 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1456 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1460 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1464 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1468 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1472 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1476 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1480 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1484 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1488 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1492 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1496 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1500 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1504 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1508 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1512 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1516 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1520 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1524 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1528 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1532 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1536 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1540 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1544 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1548 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1552 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1556 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1560 #define __SSAT16(ARG1,ARG2) \
1562 int32_t __RES, __ARG1 = (ARG1); \
1563 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1567 #define __USAT16(ARG1,ARG2) \
1569 uint32_t __RES, __ARG1 = (ARG1); \
1570 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1574 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1578 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1582 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1586 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1590 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1594 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1598 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1602 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1606 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1610 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1614 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1618 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1622 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1626 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1630 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1634 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1638 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1646 #ifndef __ARMEB__ /* Little endian */
1647 __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]) );
1648 #else /* Big endian */
1649 __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]) );
1655 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1663 #ifndef __ARMEB__ /* Little endian */
1664 __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]) );
1665 #else /* Big endian */
1666 __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]) );
1672 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1676 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1680 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1684 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1688 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1692 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1696 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1700 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1704 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1712 #ifndef __ARMEB__ /* Little endian */
1713 __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]) );
1714 #else /* Big endian */
1715 __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]) );
1721 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1729 #ifndef __ARMEB__ /* Little endian */
1730 __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]) );
1731 #else /* Big endian */
1732 __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]) );
1738 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1742 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1746 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1750 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1754 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1758 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1763 #define __PKHBT(ARG1,ARG2,ARG3) \
1765 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1766 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1770 #define __PKHTB(ARG1,ARG2,ARG3) \
1772 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1774 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1776 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1781 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1782 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1784 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1785 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1787 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1791 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1795 #endif /* (__ARM_FEATURE_DSP == 1) */
1796 /*@} end of group CMSIS_SIMD_intrinsics */
1799 #endif /* __CMSIS_ARMCLANG_H */