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 __UNALIGNED_UINT32 /* deprecated */
60 #pragma clang diagnostic push
61 #pragma clang diagnostic ignored "-Wpacked"
62 //lint -esym(9058, T_UINT32) disable MISRA 2012 Rule 2.4 for T_UINT32
63 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
64 #pragma clang diagnostic pop
65 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
67 #ifndef __UNALIGNED_UINT16_WRITE
68 #pragma clang diagnostic push
69 #pragma clang diagnostic ignored "-Wpacked"
70 //lint -esym(9058, T_UINT16_WRITE) disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE
71 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
72 #pragma clang diagnostic pop
73 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
75 #ifndef __UNALIGNED_UINT16_READ
76 #pragma clang diagnostic push
77 #pragma clang diagnostic ignored "-Wpacked"
78 //lint -esym(9058, T_UINT16_READ) disable MISRA 2012 Rule 2.4 for T_UINT16_READ
79 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
80 #pragma clang diagnostic pop
81 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
83 #ifndef __UNALIGNED_UINT32_WRITE
84 #pragma clang diagnostic push
85 #pragma clang diagnostic ignored "-Wpacked"
86 //lint -esym(9058, T_UINT32_WRITE) disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE
87 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
88 #pragma clang diagnostic pop
89 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
91 #ifndef __UNALIGNED_UINT32_READ
92 #pragma clang diagnostic push
93 #pragma clang diagnostic ignored "-Wpacked"
94 //lint -esym(9058, T_UINT32_READ) disable MISRA 2012 Rule 2.4 for T_UINT32_READ
95 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
96 #pragma clang diagnostic pop
97 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
100 #define __ALIGNED(x) __attribute__((aligned(x)))
104 /* ########################### Core Function Access ########################### */
105 /** \ingroup CMSIS_Core_FunctionInterface
106 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
111 \brief Enable IRQ Interrupts
112 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
113 Can only be executed in Privileged modes.
115 /* intrinsic void __enable_irq(); see arm_compat.h */
119 \brief Disable IRQ Interrupts
120 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
121 Can only be executed in Privileged modes.
123 /* intrinsic void __disable_irq(); see arm_compat.h */
127 \brief Get Control Register
128 \details Returns the content of the Control Register.
129 \return Control Register value
131 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
135 __ASM volatile ("MRS %0, control" : "=r" (result) );
140 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
142 \brief Get Control Register (non-secure)
143 \details Returns the content of the non-secure Control Register when in secure mode.
144 \return non-secure Control Register value
146 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
150 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
157 \brief Set Control Register
158 \details Writes the given value to the Control Register.
159 \param [in] control Control Register value to set
161 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
163 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
167 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
169 \brief Set Control Register (non-secure)
170 \details Writes the given value to the non-secure Control Register when in secure state.
171 \param [in] control Control Register value to set
173 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
175 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
181 \brief Get IPSR Register
182 \details Returns the content of the IPSR Register.
183 \return IPSR Register value
185 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
189 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
195 \brief Get APSR Register
196 \details Returns the content of the APSR Register.
197 \return APSR Register value
199 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
203 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
209 \brief Get xPSR Register
210 \details Returns the content of the xPSR Register.
211 \return xPSR Register value
213 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
217 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
223 \brief Get Process Stack Pointer
224 \details Returns the current value of the Process Stack Pointer (PSP).
225 \return PSP Register value
227 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
229 register uint32_t result;
231 __ASM volatile ("MRS %0, psp" : "=r" (result) );
236 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
238 \brief Get Process Stack Pointer (non-secure)
239 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
240 \return PSP Register value
242 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
244 register uint32_t result;
246 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
253 \brief Set Process Stack Pointer
254 \details Assigns the given value to the Process Stack Pointer (PSP).
255 \param [in] topOfProcStack Process Stack Pointer value to set
257 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
259 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
263 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
265 \brief Set Process Stack Pointer (non-secure)
266 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
267 \param [in] topOfProcStack Process Stack Pointer value to set
269 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
271 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
277 \brief Get Main Stack Pointer
278 \details Returns the current value of the Main Stack Pointer (MSP).
279 \return MSP Register value
281 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
283 register uint32_t result;
285 __ASM volatile ("MRS %0, msp" : "=r" (result) );
290 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
292 \brief Get Main Stack Pointer (non-secure)
293 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
294 \return MSP Register value
296 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
298 register uint32_t result;
300 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
307 \brief Set Main Stack Pointer
308 \details Assigns the given value to the Main Stack Pointer (MSP).
309 \param [in] topOfMainStack Main Stack Pointer value to set
311 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
313 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
317 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
319 \brief Set Main Stack Pointer (non-secure)
320 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
321 \param [in] topOfMainStack Main Stack Pointer value to set
323 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
325 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
330 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
332 \brief Get Stack Pointer (non-secure)
333 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
334 \return SP Register value
336 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_SP_NS(void)
338 register uint32_t result;
340 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
346 \brief Set Stack Pointer (non-secure)
347 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
348 \param [in] topOfStack Stack Pointer value to set
350 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_SP_NS(uint32_t topOfStack)
352 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
358 \brief Get Priority Mask
359 \details Returns the current state of the priority mask bit from the Priority Mask Register.
360 \return Priority Mask value
362 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
366 __ASM volatile ("MRS %0, primask" : "=r" (result) );
371 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
373 \brief Get Priority Mask (non-secure)
374 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
375 \return Priority Mask value
377 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
381 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
388 \brief Set Priority Mask
389 \details Assigns the given value to the Priority Mask Register.
390 \param [in] priMask Priority Mask
392 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
394 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
398 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
400 \brief Set Priority Mask (non-secure)
401 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
402 \param [in] priMask Priority Mask
404 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
406 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
411 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
412 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
413 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
416 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
417 Can only be executed in Privileged modes.
419 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
424 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
425 Can only be executed in Privileged modes.
427 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
431 \brief Get Base Priority
432 \details Returns the current value of the Base Priority register.
433 \return Base Priority register value
435 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
439 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
444 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
446 \brief Get Base Priority (non-secure)
447 \details Returns the current value of the non-secure Base Priority register when in secure state.
448 \return Base Priority register value
450 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
454 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
461 \brief Set Base Priority
462 \details Assigns the given value to the Base Priority register.
463 \param [in] basePri Base Priority value to set
465 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
467 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
471 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
473 \brief Set Base Priority (non-secure)
474 \details Assigns the given value to the non-secure Base Priority register when in secure state.
475 \param [in] basePri Base Priority value to set
477 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
479 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
485 \brief Set Base Priority with condition
486 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
487 or the new value increases the BASEPRI priority level.
488 \param [in] basePri Base Priority value to set
490 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
492 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
497 \brief Get Fault Mask
498 \details Returns the current value of the Fault Mask register.
499 \return Fault Mask register value
501 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
505 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
510 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
512 \brief Get Fault Mask (non-secure)
513 \details Returns the current value of the non-secure Fault Mask register when in secure state.
514 \return Fault Mask register value
516 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
520 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
527 \brief Set Fault Mask
528 \details Assigns the given value to the Fault Mask register.
529 \param [in] faultMask Fault Mask value to set
531 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
533 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
537 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
539 \brief Set Fault Mask (non-secure)
540 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
541 \param [in] faultMask Fault Mask value to set
543 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
545 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
549 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
550 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
551 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
554 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
555 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
558 \brief Get Process Stack Pointer Limit
559 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
560 \return PSPLIM Register value
562 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
564 register uint32_t result;
566 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
571 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
572 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
574 \brief Get Process Stack Pointer Limit (non-secure)
575 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
576 \return PSPLIM Register value
578 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
580 register uint32_t result;
582 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
589 \brief Set Process Stack Pointer Limit
590 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
591 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
593 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
595 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
599 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
600 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
602 \brief Set Process Stack Pointer (non-secure)
603 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
604 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
606 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
608 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
614 \brief Get Main Stack Pointer Limit
615 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
616 \return MSPLIM Register value
618 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
620 register uint32_t result;
622 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
628 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
629 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
631 \brief Get Main Stack Pointer Limit (non-secure)
632 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
633 \return MSPLIM Register value
635 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
637 register uint32_t result;
639 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
646 \brief Set Main Stack Pointer Limit
647 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
648 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
650 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
652 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
656 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
657 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
659 \brief Set Main Stack Pointer Limit (non-secure)
660 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
661 \param [in] MainStackPtrLimit Main Stack Pointer value to set
663 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
665 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
669 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
670 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
673 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
674 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
678 \details Returns the current value of the Floating Point Status/Control register.
679 \return Floating Point Status/Control register value
681 /* #define __get_FPSCR __builtin_arm_get_fpscr */
682 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
684 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
685 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
688 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
698 \details Assigns the given value to the Floating Point Status/Control register.
699 \param [in] fpscr Floating Point Status/Control value to set
701 /* #define __set_FPSCR __builtin_arm_set_fpscr */
702 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
704 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
705 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
706 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
712 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
713 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
717 /*@} end of CMSIS_Core_RegAccFunctions */
720 /* ########################## Core Instruction Access ######################### */
721 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
722 Access to dedicated instructions
726 /* Define macros for porting to both thumb1 and thumb2.
727 * For thumb1, use low register (r0-r7), specified by constraint "l"
728 * Otherwise, use general registers, specified by constraint "r" */
729 #if defined (__thumb__) && !defined (__thumb2__)
730 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
731 #define __CMSIS_GCC_USE_REG(r) "l" (r)
733 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
734 #define __CMSIS_GCC_USE_REG(r) "r" (r)
739 \details No Operation does nothing. This instruction can be used for code alignment purposes.
741 #define __NOP __builtin_arm_nop
744 \brief Wait For Interrupt
745 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
747 #define __WFI __builtin_arm_wfi
751 \brief Wait For Event
752 \details Wait For Event is a hint instruction that permits the processor to enter
753 a low-power state until one of a number of events occurs.
755 #define __WFE __builtin_arm_wfe
760 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
762 #define __SEV __builtin_arm_sev
766 \brief Instruction Synchronization Barrier
767 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
768 so that all instructions following the ISB are fetched from cache or memory,
769 after the instruction has been completed.
771 #define __ISB() __builtin_arm_isb(0xF);
774 \brief Data Synchronization Barrier
775 \details Acts as a special kind of Data Memory Barrier.
776 It completes when all explicit memory accesses before this instruction complete.
778 #define __DSB() __builtin_arm_dsb(0xF);
782 \brief Data Memory Barrier
783 \details Ensures the apparent order of the explicit memory operations before
784 and after the instruction, without ensuring their completion.
786 #define __DMB() __builtin_arm_dmb(0xF);
790 \brief Reverse byte order (32 bit)
791 \details Reverses the byte order in integer value.
792 \param [in] value Value to reverse
793 \return Reversed value
795 #define __REV __builtin_bswap32
799 \brief Reverse byte order (16 bit)
800 \details Reverses the byte order in two unsigned short values.
801 \param [in] value Value to reverse
802 \return Reversed value
804 #define __REV16 __builtin_bswap16 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
806 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
810 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
817 \brief Reverse byte order in signed short value
818 \details Reverses the byte order in a signed short value with sign extension to integer.
819 \param [in] value Value to reverse
820 \return Reversed value
822 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
823 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
827 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
833 \brief Rotate Right in unsigned value (32 bit)
834 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
835 \param [in] op1 Value to rotate
836 \param [in] op2 Number of Bits to rotate
837 \return Rotated value
839 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
841 return (op1 >> op2) | (op1 << (32U - op2));
847 \details Causes the processor to enter Debug state.
848 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
849 \param [in] value is ignored by the processor.
850 If required, a debugger can use it to store additional information about the breakpoint.
852 #define __BKPT(value) __ASM volatile ("bkpt "#value)
856 \brief Reverse bit order of value
857 \details Reverses the bit order of the given value.
858 \param [in] value Value to reverse
859 \return Reversed value
861 /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
862 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
866 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
867 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
868 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
869 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
871 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
873 result = value; /* r will be reversed bits of v; first get LSB of v */
874 for (value >>= 1U; value; value >>= 1U)
877 result |= value & 1U;
880 result <<= s; /* shift when v's highest bits are zero */
887 \brief Count leading zeros
888 \details Counts the number of leading zeros of a data value.
889 \param [in] value Value to count the leading zeros
890 \return number of leading zeros in value
892 #define __CLZ __builtin_clz
895 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
896 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
897 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
898 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
900 \brief LDR Exclusive (8 bit)
901 \details Executes a exclusive LDR instruction for 8 bit value.
902 \param [in] ptr Pointer to data
903 \return value of type uint8_t at (*ptr)
905 #define __LDREXB (uint8_t)__builtin_arm_ldrex
909 \brief LDR Exclusive (16 bit)
910 \details Executes a exclusive LDR instruction for 16 bit values.
911 \param [in] ptr Pointer to data
912 \return value of type uint16_t at (*ptr)
914 #define __LDREXH (uint16_t)__builtin_arm_ldrex
918 \brief LDR Exclusive (32 bit)
919 \details Executes a exclusive LDR instruction for 32 bit values.
920 \param [in] ptr Pointer to data
921 \return value of type uint32_t at (*ptr)
923 #define __LDREXW (uint32_t)__builtin_arm_ldrex
927 \brief STR Exclusive (8 bit)
928 \details Executes a exclusive STR instruction for 8 bit values.
929 \param [in] value Value to store
930 \param [in] ptr Pointer to location
931 \return 0 Function succeeded
932 \return 1 Function failed
934 #define __STREXB (uint32_t)__builtin_arm_strex
938 \brief STR Exclusive (16 bit)
939 \details Executes a exclusive STR instruction for 16 bit values.
940 \param [in] value Value to store
941 \param [in] ptr Pointer to location
942 \return 0 Function succeeded
943 \return 1 Function failed
945 #define __STREXH (uint32_t)__builtin_arm_strex
949 \brief STR Exclusive (32 bit)
950 \details Executes a exclusive STR instruction for 32 bit values.
951 \param [in] value Value to store
952 \param [in] ptr Pointer to location
953 \return 0 Function succeeded
954 \return 1 Function failed
956 #define __STREXW (uint32_t)__builtin_arm_strex
960 \brief Remove the exclusive lock
961 \details Removes the exclusive lock which is created by LDREX.
963 #define __CLREX __builtin_arm_clrex
965 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
966 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
967 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
968 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
971 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
972 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
973 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
975 \brief Signed Saturate
976 \details Saturates a signed value.
977 \param [in] value Value to be saturated
978 \param [in] sat Bit position to saturate to (1..32)
979 \return Saturated value
981 #define __SSAT __builtin_arm_ssat
985 \brief Unsigned Saturate
986 \details Saturates an unsigned value.
987 \param [in] value Value to be saturated
988 \param [in] sat Bit position to saturate to (0..31)
989 \return Saturated value
991 #define __USAT __builtin_arm_usat
995 \brief Rotate Right with Extend (32 bit)
996 \details Moves each bit of a bitstring right by one bit.
997 The carry input is shifted in at the left end of the bitstring.
998 \param [in] value Value to rotate
999 \return Rotated value
1001 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1005 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1011 \brief LDRT Unprivileged (8 bit)
1012 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1013 \param [in] ptr Pointer to data
1014 \return value of type uint8_t at (*ptr)
1016 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1020 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1021 return ((uint8_t) result); /* Add explicit type cast here */
1026 \brief LDRT Unprivileged (16 bit)
1027 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1028 \param [in] ptr Pointer to data
1029 \return value of type uint16_t at (*ptr)
1031 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1035 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1036 return ((uint16_t) result); /* Add explicit type cast here */
1041 \brief LDRT Unprivileged (32 bit)
1042 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1043 \param [in] ptr Pointer to data
1044 \return value of type uint32_t at (*ptr)
1046 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1050 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1056 \brief STRT Unprivileged (8 bit)
1057 \details Executes a Unprivileged STRT instruction for 8 bit values.
1058 \param [in] value Value to store
1059 \param [in] ptr Pointer to location
1061 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1063 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1068 \brief STRT Unprivileged (16 bit)
1069 \details Executes a Unprivileged STRT instruction for 16 bit values.
1070 \param [in] value Value to store
1071 \param [in] ptr Pointer to location
1073 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1075 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1080 \brief STRT Unprivileged (32 bit)
1081 \details Executes a Unprivileged STRT instruction for 32 bit values.
1082 \param [in] value Value to store
1083 \param [in] ptr Pointer to location
1085 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1087 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1090 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1091 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1092 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1095 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1096 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1098 \brief Load-Acquire (8 bit)
1099 \details Executes a LDAB instruction for 8 bit value.
1100 \param [in] ptr Pointer to data
1101 \return value of type uint8_t at (*ptr)
1103 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1107 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1108 return ((uint8_t) result);
1113 \brief Load-Acquire (16 bit)
1114 \details Executes a LDAH instruction for 16 bit values.
1115 \param [in] ptr Pointer to data
1116 \return value of type uint16_t at (*ptr)
1118 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1122 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1123 return ((uint16_t) result);
1128 \brief Load-Acquire (32 bit)
1129 \details Executes a LDA instruction for 32 bit values.
1130 \param [in] ptr Pointer to data
1131 \return value of type uint32_t at (*ptr)
1133 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1137 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1143 \brief Store-Release (8 bit)
1144 \details Executes a STLB instruction for 8 bit values.
1145 \param [in] value Value to store
1146 \param [in] ptr Pointer to location
1148 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1150 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1155 \brief Store-Release (16 bit)
1156 \details Executes a STLH instruction for 16 bit values.
1157 \param [in] value Value to store
1158 \param [in] ptr Pointer to location
1160 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1162 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1167 \brief Store-Release (32 bit)
1168 \details Executes a STL instruction for 32 bit values.
1169 \param [in] value Value to store
1170 \param [in] ptr Pointer to location
1172 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1174 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1179 \brief Load-Acquire Exclusive (8 bit)
1180 \details Executes a LDAB exclusive instruction for 8 bit value.
1181 \param [in] ptr Pointer to data
1182 \return value of type uint8_t at (*ptr)
1184 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1188 \brief Load-Acquire Exclusive (16 bit)
1189 \details Executes a LDAH exclusive instruction for 16 bit values.
1190 \param [in] ptr Pointer to data
1191 \return value of type uint16_t at (*ptr)
1193 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1197 \brief Load-Acquire Exclusive (32 bit)
1198 \details Executes a LDA exclusive instruction for 32 bit values.
1199 \param [in] ptr Pointer to data
1200 \return value of type uint32_t at (*ptr)
1202 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1206 \brief Store-Release Exclusive (8 bit)
1207 \details Executes a STLB exclusive instruction for 8 bit values.
1208 \param [in] value Value to store
1209 \param [in] ptr Pointer to location
1210 \return 0 Function succeeded
1211 \return 1 Function failed
1213 #define __STLEXB (uint32_t)__builtin_arm_stlex
1217 \brief Store-Release Exclusive (16 bit)
1218 \details Executes a STLH exclusive instruction for 16 bit values.
1219 \param [in] value Value to store
1220 \param [in] ptr Pointer to location
1221 \return 0 Function succeeded
1222 \return 1 Function failed
1224 #define __STLEXH (uint32_t)__builtin_arm_stlex
1228 \brief Store-Release Exclusive (32 bit)
1229 \details Executes a STL exclusive instruction for 32 bit values.
1230 \param [in] value Value to store
1231 \param [in] ptr Pointer to location
1232 \return 0 Function succeeded
1233 \return 1 Function failed
1235 #define __STLEX (uint32_t)__builtin_arm_stlex
1237 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1238 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1240 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1243 /* ################### Compiler specific Intrinsics ########################### */
1244 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1245 Access to dedicated SIMD instructions
1249 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1251 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1255 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1259 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1263 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1267 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1271 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1275 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1279 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1283 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1287 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1291 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1295 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1300 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1304 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1308 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1312 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1316 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1320 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1324 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1328 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1332 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1336 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1340 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1344 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1349 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1353 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1357 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1361 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1365 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1369 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1373 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1377 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1381 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1385 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1389 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1393 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1397 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1401 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1405 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1409 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1413 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1417 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1421 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1425 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1429 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1433 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1437 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1441 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1445 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1449 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1453 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1457 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1461 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1465 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1469 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1473 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1477 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1481 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1485 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1489 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1493 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1497 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1501 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1505 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1509 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1513 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1517 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1521 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1525 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1529 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1533 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1537 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1541 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1545 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1549 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1553 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1557 #define __SSAT16(ARG1,ARG2) \
1559 int32_t __RES, __ARG1 = (ARG1); \
1560 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1564 #define __USAT16(ARG1,ARG2) \
1566 uint32_t __RES, __ARG1 = (ARG1); \
1567 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1571 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1575 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1579 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1583 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1587 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1591 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1595 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1599 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1603 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1607 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1611 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1615 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1619 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1623 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1627 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1631 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1635 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1643 #ifndef __ARMEB__ /* Little endian */
1644 __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]) );
1645 #else /* Big endian */
1646 __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]) );
1652 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1660 #ifndef __ARMEB__ /* Little endian */
1661 __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]) );
1662 #else /* Big endian */
1663 __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]) );
1669 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1673 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1677 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1681 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1685 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1689 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1693 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1697 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1701 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1709 #ifndef __ARMEB__ /* Little endian */
1710 __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]) );
1711 #else /* Big endian */
1712 __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]) );
1718 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1726 #ifndef __ARMEB__ /* Little endian */
1727 __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]) );
1728 #else /* Big endian */
1729 __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]) );
1735 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1739 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1743 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1747 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1751 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1755 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1760 #define __PKHBT(ARG1,ARG2,ARG3) \
1762 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1763 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1767 #define __PKHTB(ARG1,ARG2,ARG3) \
1769 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1771 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1773 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1778 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1779 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1781 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1782 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1784 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1788 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1792 #endif /* (__ARM_FEATURE_DSP == 1) */
1793 /*@} end of group CMSIS_SIMD_intrinsics */
1796 #endif /* __CMSIS_ARMCLANG_H */