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)))
106 #define __RESTRICT __restrict
110 /* ########################### Core Function Access ########################### */
111 /** \ingroup CMSIS_Core_FunctionInterface
112 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
117 \brief Enable IRQ Interrupts
118 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
119 Can only be executed in Privileged modes.
121 /* intrinsic void __enable_irq(); see arm_compat.h */
125 \brief Disable IRQ Interrupts
126 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
127 Can only be executed in Privileged modes.
129 /* intrinsic void __disable_irq(); see arm_compat.h */
133 \brief Get Control Register
134 \details Returns the content of the Control Register.
135 \return Control Register value
137 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
141 __ASM volatile ("MRS %0, control" : "=r" (result) );
146 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
148 \brief Get Control Register (non-secure)
149 \details Returns the content of the non-secure Control Register when in secure mode.
150 \return non-secure Control Register value
152 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
156 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
163 \brief Set Control Register
164 \details Writes the given value to the Control Register.
165 \param [in] control Control Register value to set
167 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
169 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
173 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
175 \brief Set Control Register (non-secure)
176 \details Writes the given value to the non-secure Control Register when in secure state.
177 \param [in] control Control Register value to set
179 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
181 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
187 \brief Get IPSR Register
188 \details Returns the content of the IPSR Register.
189 \return IPSR Register value
191 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
195 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
201 \brief Get APSR Register
202 \details Returns the content of the APSR Register.
203 \return APSR Register value
205 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
209 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
215 \brief Get xPSR Register
216 \details Returns the content of the xPSR Register.
217 \return xPSR Register value
219 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
223 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
229 \brief Get Process Stack Pointer
230 \details Returns the current value of the Process Stack Pointer (PSP).
231 \return PSP Register value
233 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
235 register uint32_t result;
237 __ASM volatile ("MRS %0, psp" : "=r" (result) );
242 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
244 \brief Get Process Stack Pointer (non-secure)
245 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
246 \return PSP Register value
248 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
250 register uint32_t result;
252 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
259 \brief Set Process Stack Pointer
260 \details Assigns the given value to the Process Stack Pointer (PSP).
261 \param [in] topOfProcStack Process Stack Pointer value to set
263 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
265 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
269 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
271 \brief Set Process Stack Pointer (non-secure)
272 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
273 \param [in] topOfProcStack Process Stack Pointer value to set
275 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
277 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
283 \brief Get Main Stack Pointer
284 \details Returns the current value of the Main Stack Pointer (MSP).
285 \return MSP Register value
287 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
289 register uint32_t result;
291 __ASM volatile ("MRS %0, msp" : "=r" (result) );
296 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
298 \brief Get Main Stack Pointer (non-secure)
299 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
300 \return MSP Register value
302 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
304 register uint32_t result;
306 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
313 \brief Set Main Stack Pointer
314 \details Assigns the given value to the Main Stack Pointer (MSP).
315 \param [in] topOfMainStack Main Stack Pointer value to set
317 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
319 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
323 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
325 \brief Set Main Stack Pointer (non-secure)
326 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
327 \param [in] topOfMainStack Main Stack Pointer value to set
329 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
331 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
336 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
338 \brief Get Stack Pointer (non-secure)
339 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
340 \return SP Register value
342 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_SP_NS(void)
344 register uint32_t result;
346 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
352 \brief Set Stack Pointer (non-secure)
353 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
354 \param [in] topOfStack Stack Pointer value to set
356 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_SP_NS(uint32_t topOfStack)
358 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
364 \brief Get Priority Mask
365 \details Returns the current state of the priority mask bit from the Priority Mask Register.
366 \return Priority Mask value
368 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
372 __ASM volatile ("MRS %0, primask" : "=r" (result) );
377 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
379 \brief Get Priority Mask (non-secure)
380 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
381 \return Priority Mask value
383 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
387 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
394 \brief Set Priority Mask
395 \details Assigns the given value to the Priority Mask Register.
396 \param [in] priMask Priority Mask
398 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
400 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
404 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
406 \brief Set Priority Mask (non-secure)
407 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
408 \param [in] priMask Priority Mask
410 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
412 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
417 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
418 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
419 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
422 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
423 Can only be executed in Privileged modes.
425 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
430 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
431 Can only be executed in Privileged modes.
433 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
437 \brief Get Base Priority
438 \details Returns the current value of the Base Priority register.
439 \return Base Priority register value
441 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
445 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
450 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
452 \brief Get Base Priority (non-secure)
453 \details Returns the current value of the non-secure Base Priority register when in secure state.
454 \return Base Priority register value
456 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
460 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
467 \brief Set Base Priority
468 \details Assigns the given value to the Base Priority register.
469 \param [in] basePri Base Priority value to set
471 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
473 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
477 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
479 \brief Set Base Priority (non-secure)
480 \details Assigns the given value to the non-secure Base Priority register when in secure state.
481 \param [in] basePri Base Priority value to set
483 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
485 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
491 \brief Set Base Priority with condition
492 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
493 or the new value increases the BASEPRI priority level.
494 \param [in] basePri Base Priority value to set
496 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
498 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
503 \brief Get Fault Mask
504 \details Returns the current value of the Fault Mask register.
505 \return Fault Mask register value
507 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
511 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
516 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
518 \brief Get Fault Mask (non-secure)
519 \details Returns the current value of the non-secure Fault Mask register when in secure state.
520 \return Fault Mask register value
522 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
526 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
533 \brief Set Fault Mask
534 \details Assigns the given value to the Fault Mask register.
535 \param [in] faultMask Fault Mask value to set
537 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
539 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
543 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
545 \brief Set Fault Mask (non-secure)
546 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
547 \param [in] faultMask Fault Mask value to set
549 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
551 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
555 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
556 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
557 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
560 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
561 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
564 \brief Get Process Stack Pointer Limit
565 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
566 \return PSPLIM Register value
568 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
570 register uint32_t result;
572 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
577 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
578 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
580 \brief Get Process Stack Pointer Limit (non-secure)
581 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
582 \return PSPLIM Register value
584 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
586 register uint32_t result;
588 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
595 \brief Set Process Stack Pointer Limit
596 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
597 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
599 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
601 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
605 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
606 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
608 \brief Set Process Stack Pointer (non-secure)
609 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
610 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
612 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
614 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
620 \brief Get Main Stack Pointer Limit
621 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
622 \return MSPLIM Register value
624 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
626 register uint32_t result;
628 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
634 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
635 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
637 \brief Get Main Stack Pointer Limit (non-secure)
638 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
639 \return MSPLIM Register value
641 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
643 register uint32_t result;
645 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
652 \brief Set Main Stack Pointer Limit
653 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
654 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
656 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
658 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
662 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
663 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
665 \brief Set Main Stack Pointer Limit (non-secure)
666 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
667 \param [in] MainStackPtrLimit Main Stack Pointer value to set
669 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
671 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
675 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
676 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
679 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
680 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
684 \details Returns the current value of the Floating Point Status/Control register.
685 \return Floating Point Status/Control register value
687 /* #define __get_FPSCR __builtin_arm_get_fpscr */
688 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
690 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
691 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
694 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
704 \details Assigns the given value to the Floating Point Status/Control register.
705 \param [in] fpscr Floating Point Status/Control value to set
707 /* #define __set_FPSCR __builtin_arm_set_fpscr */
708 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
710 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
711 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
712 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
718 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
719 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
723 /*@} end of CMSIS_Core_RegAccFunctions */
726 /* ########################## Core Instruction Access ######################### */
727 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
728 Access to dedicated instructions
732 /* Define macros for porting to both thumb1 and thumb2.
733 * For thumb1, use low register (r0-r7), specified by constraint "l"
734 * Otherwise, use general registers, specified by constraint "r" */
735 #if defined (__thumb__) && !defined (__thumb2__)
736 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
737 #define __CMSIS_GCC_USE_REG(r) "l" (r)
739 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
740 #define __CMSIS_GCC_USE_REG(r) "r" (r)
745 \details No Operation does nothing. This instruction can be used for code alignment purposes.
747 #define __NOP __builtin_arm_nop
750 \brief Wait For Interrupt
751 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
753 #define __WFI __builtin_arm_wfi
757 \brief Wait For Event
758 \details Wait For Event is a hint instruction that permits the processor to enter
759 a low-power state until one of a number of events occurs.
761 #define __WFE __builtin_arm_wfe
766 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
768 #define __SEV __builtin_arm_sev
772 \brief Instruction Synchronization Barrier
773 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
774 so that all instructions following the ISB are fetched from cache or memory,
775 after the instruction has been completed.
777 #define __ISB() __builtin_arm_isb(0xF);
780 \brief Data Synchronization Barrier
781 \details Acts as a special kind of Data Memory Barrier.
782 It completes when all explicit memory accesses before this instruction complete.
784 #define __DSB() __builtin_arm_dsb(0xF);
788 \brief Data Memory Barrier
789 \details Ensures the apparent order of the explicit memory operations before
790 and after the instruction, without ensuring their completion.
792 #define __DMB() __builtin_arm_dmb(0xF);
796 \brief Reverse byte order (32 bit)
797 \details Reverses the byte order in integer value.
798 \param [in] value Value to reverse
799 \return Reversed value
801 #define __REV __builtin_bswap32
805 \brief Reverse byte order (16 bit)
806 \details Reverses the byte order in two unsigned short values.
807 \param [in] value Value to reverse
808 \return Reversed value
810 #define __REV16 __builtin_bswap16
814 \brief Reverse byte order in signed short value
815 \details Reverses the byte order in a signed short value with sign extension to integer.
816 \param [in] value Value to reverse
817 \return Reversed value
819 __attribute__((always_inline)) __STATIC_INLINE int16_t __REVSH(int16_t value)
823 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
830 \brief Rotate Right in unsigned value (32 bit)
831 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
832 \param [in] op1 Value to rotate
833 \param [in] op2 Number of Bits to rotate
834 \return Rotated value
836 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
838 return (op1 >> op2) | (op1 << (32U - op2));
844 \details Causes the processor to enter Debug state.
845 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
846 \param [in] value is ignored by the processor.
847 If required, a debugger can use it to store additional information about the breakpoint.
849 #define __BKPT(value) __ASM volatile ("bkpt "#value)
853 \brief Reverse bit order of value
854 \details Reverses the bit order of the given value.
855 \param [in] value Value to reverse
856 \return Reversed value
858 #define __RBIT __builtin_arm_rbit
861 \brief Count leading zeros
862 \details Counts the number of leading zeros of a data value.
863 \param [in] value Value to count the leading zeros
864 \return number of leading zeros in value
866 #define __CLZ __builtin_clz
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 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
874 \brief LDR Exclusive (8 bit)
875 \details Executes a exclusive LDR instruction for 8 bit value.
876 \param [in] ptr Pointer to data
877 \return value of type uint8_t at (*ptr)
879 #define __LDREXB (uint8_t)__builtin_arm_ldrex
883 \brief LDR Exclusive (16 bit)
884 \details Executes a exclusive LDR instruction for 16 bit values.
885 \param [in] ptr Pointer to data
886 \return value of type uint16_t at (*ptr)
888 #define __LDREXH (uint16_t)__builtin_arm_ldrex
892 \brief LDR Exclusive (32 bit)
893 \details Executes a exclusive LDR instruction for 32 bit values.
894 \param [in] ptr Pointer to data
895 \return value of type uint32_t at (*ptr)
897 #define __LDREXW (uint32_t)__builtin_arm_ldrex
901 \brief STR Exclusive (8 bit)
902 \details Executes a exclusive STR instruction for 8 bit values.
903 \param [in] value Value to store
904 \param [in] ptr Pointer to location
905 \return 0 Function succeeded
906 \return 1 Function failed
908 #define __STREXB (uint32_t)__builtin_arm_strex
912 \brief STR Exclusive (16 bit)
913 \details Executes a exclusive STR instruction for 16 bit values.
914 \param [in] value Value to store
915 \param [in] ptr Pointer to location
916 \return 0 Function succeeded
917 \return 1 Function failed
919 #define __STREXH (uint32_t)__builtin_arm_strex
923 \brief STR Exclusive (32 bit)
924 \details Executes a exclusive STR instruction for 32 bit values.
925 \param [in] value Value to store
926 \param [in] ptr Pointer to location
927 \return 0 Function succeeded
928 \return 1 Function failed
930 #define __STREXW (uint32_t)__builtin_arm_strex
934 \brief Remove the exclusive lock
935 \details Removes the exclusive lock which is created by LDREX.
937 #define __CLREX __builtin_arm_clrex
939 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
940 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
941 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
942 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
945 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
946 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
947 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
950 \brief Signed Saturate
951 \details Saturates a signed value.
952 \param [in] value Value to be saturated
953 \param [in] sat Bit position to saturate to (1..32)
954 \return Saturated value
956 #define __SSAT __builtin_arm_ssat
960 \brief Unsigned Saturate
961 \details Saturates an unsigned value.
962 \param [in] value Value to be saturated
963 \param [in] sat Bit position to saturate to (0..31)
964 \return Saturated value
966 #define __USAT __builtin_arm_usat
970 \brief Rotate Right with Extend (32 bit)
971 \details Moves each bit of a bitstring right by one bit.
972 The carry input is shifted in at the left end of the bitstring.
973 \param [in] value Value to rotate
974 \return Rotated value
976 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
980 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
986 \brief LDRT Unprivileged (8 bit)
987 \details Executes a Unprivileged LDRT instruction for 8 bit value.
988 \param [in] ptr Pointer to data
989 \return value of type uint8_t at (*ptr)
991 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
995 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
996 return ((uint8_t) result); /* Add explicit type cast here */
1001 \brief LDRT Unprivileged (16 bit)
1002 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1003 \param [in] ptr Pointer to data
1004 \return value of type uint16_t at (*ptr)
1006 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1010 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1011 return ((uint16_t) result); /* Add explicit type cast here */
1016 \brief LDRT Unprivileged (32 bit)
1017 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1018 \param [in] ptr Pointer to data
1019 \return value of type uint32_t at (*ptr)
1021 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1025 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1031 \brief STRT Unprivileged (8 bit)
1032 \details Executes a Unprivileged STRT instruction for 8 bit values.
1033 \param [in] value Value to store
1034 \param [in] ptr Pointer to location
1036 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1038 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1043 \brief STRT Unprivileged (16 bit)
1044 \details Executes a Unprivileged STRT instruction for 16 bit values.
1045 \param [in] value Value to store
1046 \param [in] ptr Pointer to location
1048 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1050 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1055 \brief STRT Unprivileged (32 bit)
1056 \details Executes a Unprivileged STRT instruction for 32 bit values.
1057 \param [in] value Value to store
1058 \param [in] ptr Pointer to location
1060 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1062 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1065 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1066 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1067 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1070 \brief Signed Saturate
1071 \details Saturates a signed value.
1072 \param [in] value Value to be saturated
1073 \param [in] sat Bit position to saturate to (1..32)
1074 \return Saturated value
1076 __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) {
1077 if ((sat >= 1U) && (sat <= 32U)) {
1078 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1079 const int32_t min = -1 - max ;
1082 } else if (val < min) {
1090 \brief Unsigned Saturate
1091 \details Saturates an unsigned value.
1092 \param [in] value Value to be saturated
1093 \param [in] sat Bit position to saturate to (0..31)
1094 \return Saturated value
1096 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(uint32_t val, uint32_t sat) {
1098 const uint32_t max = (UINT32_MAX >> (32U - sat));
1106 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1107 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1108 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1111 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1112 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1114 \brief Load-Acquire (8 bit)
1115 \details Executes a LDAB instruction for 8 bit value.
1116 \param [in] ptr Pointer to data
1117 \return value of type uint8_t at (*ptr)
1119 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1123 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1124 return ((uint8_t) result);
1129 \brief Load-Acquire (16 bit)
1130 \details Executes a LDAH instruction for 16 bit values.
1131 \param [in] ptr Pointer to data
1132 \return value of type uint16_t at (*ptr)
1134 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1138 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1139 return ((uint16_t) result);
1144 \brief Load-Acquire (32 bit)
1145 \details Executes a LDA instruction for 32 bit values.
1146 \param [in] ptr Pointer to data
1147 \return value of type uint32_t at (*ptr)
1149 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1153 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1159 \brief Store-Release (8 bit)
1160 \details Executes a STLB instruction for 8 bit values.
1161 \param [in] value Value to store
1162 \param [in] ptr Pointer to location
1164 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1166 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1171 \brief Store-Release (16 bit)
1172 \details Executes a STLH instruction for 16 bit values.
1173 \param [in] value Value to store
1174 \param [in] ptr Pointer to location
1176 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1178 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1183 \brief Store-Release (32 bit)
1184 \details Executes a STL instruction for 32 bit values.
1185 \param [in] value Value to store
1186 \param [in] ptr Pointer to location
1188 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1190 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1195 \brief Load-Acquire Exclusive (8 bit)
1196 \details Executes a LDAB exclusive instruction for 8 bit value.
1197 \param [in] ptr Pointer to data
1198 \return value of type uint8_t at (*ptr)
1200 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1204 \brief Load-Acquire Exclusive (16 bit)
1205 \details Executes a LDAH exclusive instruction for 16 bit values.
1206 \param [in] ptr Pointer to data
1207 \return value of type uint16_t at (*ptr)
1209 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1213 \brief Load-Acquire Exclusive (32 bit)
1214 \details Executes a LDA exclusive instruction for 32 bit values.
1215 \param [in] ptr Pointer to data
1216 \return value of type uint32_t at (*ptr)
1218 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1222 \brief Store-Release Exclusive (8 bit)
1223 \details Executes a STLB exclusive instruction for 8 bit values.
1224 \param [in] value Value to store
1225 \param [in] ptr Pointer to location
1226 \return 0 Function succeeded
1227 \return 1 Function failed
1229 #define __STLEXB (uint32_t)__builtin_arm_stlex
1233 \brief Store-Release Exclusive (16 bit)
1234 \details Executes a STLH exclusive instruction for 16 bit values.
1235 \param [in] value Value to store
1236 \param [in] ptr Pointer to location
1237 \return 0 Function succeeded
1238 \return 1 Function failed
1240 #define __STLEXH (uint32_t)__builtin_arm_stlex
1244 \brief Store-Release Exclusive (32 bit)
1245 \details Executes a STL exclusive instruction for 32 bit values.
1246 \param [in] value Value to store
1247 \param [in] ptr Pointer to location
1248 \return 0 Function succeeded
1249 \return 1 Function failed
1251 #define __STLEX (uint32_t)__builtin_arm_stlex
1253 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1254 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1256 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1259 /* ################### Compiler specific Intrinsics ########################### */
1260 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1261 Access to dedicated SIMD instructions
1265 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1267 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1271 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1275 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1279 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1283 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1287 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1291 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1295 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1299 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1303 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1307 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1311 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1316 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1320 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1324 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1328 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1332 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1336 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1340 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1344 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1348 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1352 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1356 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1360 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1365 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1369 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1373 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1377 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1381 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1385 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1389 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1393 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1397 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1401 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1405 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1409 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1413 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1417 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1421 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1425 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1429 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1433 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1437 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1441 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1445 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1449 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1453 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1457 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1461 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1465 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1469 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1473 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1477 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1481 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1485 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1489 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1493 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1497 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1501 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1505 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1509 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1513 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1517 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1521 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1525 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1529 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1533 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1537 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1541 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1545 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1549 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1553 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1557 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1561 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1565 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1569 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1573 #define __SSAT16(ARG1,ARG2) \
1575 int32_t __RES, __ARG1 = (ARG1); \
1576 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1580 #define __USAT16(ARG1,ARG2) \
1582 uint32_t __RES, __ARG1 = (ARG1); \
1583 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1587 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1591 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1595 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1599 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1603 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1607 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1611 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1615 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1619 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1623 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1627 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1631 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1635 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1639 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1643 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1647 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1651 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1659 #ifndef __ARMEB__ /* Little endian */
1660 __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]) );
1661 #else /* Big endian */
1662 __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]) );
1668 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1676 #ifndef __ARMEB__ /* Little endian */
1677 __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]) );
1678 #else /* Big endian */
1679 __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]) );
1685 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1689 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1693 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1697 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1701 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1705 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1709 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1713 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1717 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1725 #ifndef __ARMEB__ /* Little endian */
1726 __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]) );
1727 #else /* Big endian */
1728 __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]) );
1734 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1742 #ifndef __ARMEB__ /* Little endian */
1743 __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]) );
1744 #else /* Big endian */
1745 __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]) );
1751 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1755 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1759 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1763 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1767 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1771 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1776 #define __PKHBT(ARG1,ARG2,ARG3) \
1778 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1779 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1783 #define __PKHTB(ARG1,ARG2,ARG3) \
1785 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1787 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1789 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1794 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1795 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1797 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1798 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1800 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1804 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1808 #endif /* (__ARM_FEATURE_DSP == 1) */
1809 /*@} end of group CMSIS_SIMD_intrinsics */
1812 #endif /* __CMSIS_ARMCLANG_H */