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 #pragma clang system_header /* treat file as system include file */
32 #ifndef __ARM_COMPAT_H
33 #include <arm_compat.h> /* Compatibility header for ARM Compiler 5 intrinsics */
36 /* CMSIS compiler specific defines */
41 #define __INLINE __inline
43 #ifndef __STATIC_INLINE
44 #define __STATIC_INLINE static __inline
46 #ifndef __STATIC_FORCEINLINE
47 #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline
50 #define __NO_RETURN __attribute__((__noreturn__))
53 #define __USED __attribute__((used))
56 #define __WEAK __attribute__((weak))
59 #define __PACKED __attribute__((packed, aligned(1)))
61 #ifndef __PACKED_STRUCT
62 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
64 #ifndef __PACKED_UNION
65 #define __PACKED_UNION union __attribute__((packed, aligned(1)))
67 #ifndef __UNALIGNED_UINT32 /* deprecated */
68 #pragma clang diagnostic push
69 #pragma clang diagnostic ignored "-Wpacked"
70 /*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */
71 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
72 #pragma clang diagnostic pop
73 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
75 #ifndef __UNALIGNED_UINT16_WRITE
76 #pragma clang diagnostic push
77 #pragma clang diagnostic ignored "-Wpacked"
78 /*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */
79 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
80 #pragma clang diagnostic pop
81 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
83 #ifndef __UNALIGNED_UINT16_READ
84 #pragma clang diagnostic push
85 #pragma clang diagnostic ignored "-Wpacked"
86 /*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */
87 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
88 #pragma clang diagnostic pop
89 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
91 #ifndef __UNALIGNED_UINT32_WRITE
92 #pragma clang diagnostic push
93 #pragma clang diagnostic ignored "-Wpacked"
94 /*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */
95 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
96 #pragma clang diagnostic pop
97 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
99 #ifndef __UNALIGNED_UINT32_READ
100 #pragma clang diagnostic push
101 #pragma clang diagnostic ignored "-Wpacked"
102 /*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */
103 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
104 #pragma clang diagnostic pop
105 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
108 #define __ALIGNED(x) __attribute__((aligned(x)))
111 #define __RESTRICT __restrict
115 /* ########################### Core Function Access ########################### */
116 /** \ingroup CMSIS_Core_FunctionInterface
117 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
122 \brief Enable IRQ Interrupts
123 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
124 Can only be executed in Privileged modes.
126 /* intrinsic void __enable_irq(); see arm_compat.h */
130 \brief Disable IRQ Interrupts
131 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
132 Can only be executed in Privileged modes.
134 /* intrinsic void __disable_irq(); see arm_compat.h */
138 \brief Get Control Register
139 \details Returns the content of the Control Register.
140 \return Control Register value
142 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
146 __ASM volatile ("MRS %0, control" : "=r" (result) );
151 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
153 \brief Get Control Register (non-secure)
154 \details Returns the content of the non-secure Control Register when in secure mode.
155 \return non-secure Control Register value
157 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
161 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
168 \brief Set Control Register
169 \details Writes the given value to the Control Register.
170 \param [in] control Control Register value to set
172 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
174 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
178 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
180 \brief Set Control Register (non-secure)
181 \details Writes the given value to the non-secure Control Register when in secure state.
182 \param [in] control Control Register value to set
184 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
186 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
192 \brief Get IPSR Register
193 \details Returns the content of the IPSR Register.
194 \return IPSR Register value
196 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
200 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
206 \brief Get APSR Register
207 \details Returns the content of the APSR Register.
208 \return APSR Register value
210 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
214 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
220 \brief Get xPSR Register
221 \details Returns the content of the xPSR Register.
222 \return xPSR Register value
224 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
228 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
234 \brief Get Process Stack Pointer
235 \details Returns the current value of the Process Stack Pointer (PSP).
236 \return PSP Register value
238 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
240 register uint32_t result;
242 __ASM volatile ("MRS %0, psp" : "=r" (result) );
247 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
249 \brief Get Process Stack Pointer (non-secure)
250 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
251 \return PSP Register value
253 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
255 register uint32_t result;
257 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
264 \brief Set Process Stack Pointer
265 \details Assigns the given value to the Process Stack Pointer (PSP).
266 \param [in] topOfProcStack Process Stack Pointer value to set
268 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
270 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
274 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
276 \brief Set Process Stack Pointer (non-secure)
277 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
278 \param [in] topOfProcStack Process Stack Pointer value to set
280 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
282 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
288 \brief Get Main Stack Pointer
289 \details Returns the current value of the Main Stack Pointer (MSP).
290 \return MSP Register value
292 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
294 register uint32_t result;
296 __ASM volatile ("MRS %0, msp" : "=r" (result) );
301 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
303 \brief Get Main Stack Pointer (non-secure)
304 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
305 \return MSP Register value
307 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
309 register uint32_t result;
311 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
318 \brief Set Main Stack Pointer
319 \details Assigns the given value to the Main Stack Pointer (MSP).
320 \param [in] topOfMainStack Main Stack Pointer value to set
322 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
324 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
328 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
330 \brief Set Main Stack Pointer (non-secure)
331 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
332 \param [in] topOfMainStack Main Stack Pointer value to set
334 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
336 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
341 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
343 \brief Get Stack Pointer (non-secure)
344 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
345 \return SP Register value
347 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
349 register uint32_t result;
351 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
357 \brief Set Stack Pointer (non-secure)
358 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
359 \param [in] topOfStack Stack Pointer value to set
361 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
363 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
369 \brief Get Priority Mask
370 \details Returns the current state of the priority mask bit from the Priority Mask Register.
371 \return Priority Mask value
373 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
377 __ASM volatile ("MRS %0, primask" : "=r" (result) );
382 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
384 \brief Get Priority Mask (non-secure)
385 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
386 \return Priority Mask value
388 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
392 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
399 \brief Set Priority Mask
400 \details Assigns the given value to the Priority Mask Register.
401 \param [in] priMask Priority Mask
403 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
405 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
409 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
411 \brief Set Priority Mask (non-secure)
412 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
413 \param [in] priMask Priority Mask
415 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
417 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
422 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
423 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
424 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
427 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
428 Can only be executed in Privileged modes.
430 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
435 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
436 Can only be executed in Privileged modes.
438 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
442 \brief Get Base Priority
443 \details Returns the current value of the Base Priority register.
444 \return Base Priority register value
446 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
450 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
455 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
457 \brief Get Base Priority (non-secure)
458 \details Returns the current value of the non-secure Base Priority register when in secure state.
459 \return Base Priority register value
461 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
465 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
472 \brief Set Base Priority
473 \details Assigns the given value to the Base Priority register.
474 \param [in] basePri Base Priority value to set
476 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
478 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
482 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
484 \brief Set Base Priority (non-secure)
485 \details Assigns the given value to the non-secure Base Priority register when in secure state.
486 \param [in] basePri Base Priority value to set
488 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
490 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
496 \brief Set Base Priority with condition
497 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
498 or the new value increases the BASEPRI priority level.
499 \param [in] basePri Base Priority value to set
501 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
503 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
508 \brief Get Fault Mask
509 \details Returns the current value of the Fault Mask register.
510 \return Fault Mask register value
512 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
516 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
521 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
523 \brief Get Fault Mask (non-secure)
524 \details Returns the current value of the non-secure Fault Mask register when in secure state.
525 \return Fault Mask register value
527 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
531 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
538 \brief Set Fault Mask
539 \details Assigns the given value to the Fault Mask register.
540 \param [in] faultMask Fault Mask value to set
542 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
544 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
548 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
550 \brief Set Fault Mask (non-secure)
551 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
552 \param [in] faultMask Fault Mask value to set
554 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
556 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
560 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
561 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
562 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
565 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
566 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
569 \brief Get Process Stack Pointer Limit
570 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
571 \return PSPLIM Register value
573 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
575 register uint32_t result;
577 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
582 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
583 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
585 \brief Get Process Stack Pointer Limit (non-secure)
586 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
587 \return PSPLIM Register value
589 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
591 register uint32_t result;
593 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
600 \brief Set Process Stack Pointer Limit
601 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
602 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
604 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
606 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
610 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
611 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
613 \brief Set Process Stack Pointer (non-secure)
614 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
615 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
617 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
619 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
625 \brief Get Main Stack Pointer Limit
626 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
627 \return MSPLIM Register value
629 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
631 register uint32_t result;
633 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
639 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
640 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
642 \brief Get Main Stack Pointer Limit (non-secure)
643 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
644 \return MSPLIM Register value
646 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
648 register uint32_t result;
650 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
657 \brief Set Main Stack Pointer Limit
658 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
659 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
661 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
663 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
667 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
668 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
670 \brief Set Main Stack Pointer Limit (non-secure)
671 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
672 \param [in] MainStackPtrLimit Main Stack Pointer value to set
674 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
676 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
680 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
681 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
684 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
685 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
689 \details Returns the current value of the Floating Point Status/Control register.
690 \return Floating Point Status/Control register value
692 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
693 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
694 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
696 #define __get_FPSCR() ((uint32_t)0U)
701 \details Assigns the given value to the Floating Point Status/Control register.
702 \param [in] fpscr Floating Point Status/Control value to set
704 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
705 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
706 #define __set_FPSCR __builtin_arm_set_fpscr
708 #define __set_FPSCR(x) ((void)(x))
711 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
712 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
716 /*@} end of CMSIS_Core_RegAccFunctions */
719 /* ########################## Core Instruction Access ######################### */
720 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
721 Access to dedicated instructions
725 /* Define macros for porting to both thumb1 and thumb2.
726 * For thumb1, use low register (r0-r7), specified by constraint "l"
727 * Otherwise, use general registers, specified by constraint "r" */
728 #if defined (__thumb__) && !defined (__thumb2__)
729 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
730 #define __CMSIS_GCC_USE_REG(r) "l" (r)
732 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
733 #define __CMSIS_GCC_USE_REG(r) "r" (r)
738 \details No Operation does nothing. This instruction can be used for code alignment purposes.
740 #define __NOP __builtin_arm_nop
743 \brief Wait For Interrupt
744 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
746 #define __WFI __builtin_arm_wfi
750 \brief Wait For Event
751 \details Wait For Event is a hint instruction that permits the processor to enter
752 a low-power state until one of a number of events occurs.
754 #define __WFE __builtin_arm_wfe
759 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
761 #define __SEV __builtin_arm_sev
765 \brief Instruction Synchronization Barrier
766 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
767 so that all instructions following the ISB are fetched from cache or memory,
768 after the instruction has been completed.
770 #define __ISB() __builtin_arm_isb(0xF);
773 \brief Data Synchronization Barrier
774 \details Acts as a special kind of Data Memory Barrier.
775 It completes when all explicit memory accesses before this instruction complete.
777 #define __DSB() __builtin_arm_dsb(0xF);
781 \brief Data Memory Barrier
782 \details Ensures the apparent order of the explicit memory operations before
783 and after the instruction, without ensuring their completion.
785 #define __DMB() __builtin_arm_dmb(0xF);
789 \brief Reverse byte order (32 bit)
790 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
791 \param [in] value Value to reverse
792 \return Reversed value
794 #define __REV(value) __builtin_bswap32(value)
798 \brief Reverse byte order (16 bit)
799 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
800 \param [in] value Value to reverse
801 \return Reversed value
803 #define __REV16(value) __ROR(__REV(value), 16)
807 \brief Reverse byte order (16 bit)
808 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
809 \param [in] value Value to reverse
810 \return Reversed value
812 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
816 \brief Rotate Right in unsigned value (32 bit)
817 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
818 \param [in] op1 Value to rotate
819 \param [in] op2 Number of Bits to rotate
820 \return Rotated value
822 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
829 return (op1 >> op2) | (op1 << (32U - op2));
835 \details Causes the processor to enter Debug state.
836 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
837 \param [in] value is ignored by the processor.
838 If required, a debugger can use it to store additional information about the breakpoint.
840 #define __BKPT(value) __ASM volatile ("bkpt "#value)
844 \brief Reverse bit order of value
845 \details Reverses the bit order of the given value.
846 \param [in] value Value to reverse
847 \return Reversed value
849 #define __RBIT __builtin_arm_rbit
852 \brief Count leading zeros
853 \details Counts the number of leading zeros of a data value.
854 \param [in] value Value to count the leading zeros
855 \return number of leading zeros in value
857 #define __CLZ (uint8_t)__builtin_clz
860 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
861 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
862 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
863 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
865 \brief LDR Exclusive (8 bit)
866 \details Executes a exclusive LDR instruction for 8 bit value.
867 \param [in] ptr Pointer to data
868 \return value of type uint8_t at (*ptr)
870 #define __LDREXB (uint8_t)__builtin_arm_ldrex
874 \brief LDR Exclusive (16 bit)
875 \details Executes a exclusive LDR instruction for 16 bit values.
876 \param [in] ptr Pointer to data
877 \return value of type uint16_t at (*ptr)
879 #define __LDREXH (uint16_t)__builtin_arm_ldrex
883 \brief LDR Exclusive (32 bit)
884 \details Executes a exclusive LDR instruction for 32 bit values.
885 \param [in] ptr Pointer to data
886 \return value of type uint32_t at (*ptr)
888 #define __LDREXW (uint32_t)__builtin_arm_ldrex
892 \brief STR Exclusive (8 bit)
893 \details Executes a exclusive STR instruction for 8 bit values.
894 \param [in] value Value to store
895 \param [in] ptr Pointer to location
896 \return 0 Function succeeded
897 \return 1 Function failed
899 #define __STREXB (uint32_t)__builtin_arm_strex
903 \brief STR Exclusive (16 bit)
904 \details Executes a exclusive STR instruction for 16 bit values.
905 \param [in] value Value to store
906 \param [in] ptr Pointer to location
907 \return 0 Function succeeded
908 \return 1 Function failed
910 #define __STREXH (uint32_t)__builtin_arm_strex
914 \brief STR Exclusive (32 bit)
915 \details Executes a exclusive STR instruction for 32 bit values.
916 \param [in] value Value to store
917 \param [in] ptr Pointer to location
918 \return 0 Function succeeded
919 \return 1 Function failed
921 #define __STREXW (uint32_t)__builtin_arm_strex
925 \brief Remove the exclusive lock
926 \details Removes the exclusive lock which is created by LDREX.
928 #define __CLREX __builtin_arm_clrex
930 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
931 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
932 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
933 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
936 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
937 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
938 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
941 \brief Signed Saturate
942 \details Saturates a signed value.
943 \param [in] value Value to be saturated
944 \param [in] sat Bit position to saturate to (1..32)
945 \return Saturated value
947 #define __SSAT __builtin_arm_ssat
951 \brief Unsigned Saturate
952 \details Saturates an unsigned value.
953 \param [in] value Value to be saturated
954 \param [in] sat Bit position to saturate to (0..31)
955 \return Saturated value
957 #define __USAT __builtin_arm_usat
961 \brief Rotate Right with Extend (32 bit)
962 \details Moves each bit of a bitstring right by one bit.
963 The carry input is shifted in at the left end of the bitstring.
964 \param [in] value Value to rotate
965 \return Rotated value
967 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
971 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
977 \brief LDRT Unprivileged (8 bit)
978 \details Executes a Unprivileged LDRT instruction for 8 bit value.
979 \param [in] ptr Pointer to data
980 \return value of type uint8_t at (*ptr)
982 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
986 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
987 return ((uint8_t) result); /* Add explicit type cast here */
992 \brief LDRT Unprivileged (16 bit)
993 \details Executes a Unprivileged LDRT instruction for 16 bit values.
994 \param [in] ptr Pointer to data
995 \return value of type uint16_t at (*ptr)
997 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1001 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1002 return ((uint16_t) result); /* Add explicit type cast here */
1007 \brief LDRT Unprivileged (32 bit)
1008 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1009 \param [in] ptr Pointer to data
1010 \return value of type uint32_t at (*ptr)
1012 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1016 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1022 \brief STRT Unprivileged (8 bit)
1023 \details Executes a Unprivileged STRT instruction for 8 bit values.
1024 \param [in] value Value to store
1025 \param [in] ptr Pointer to location
1027 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1029 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1034 \brief STRT Unprivileged (16 bit)
1035 \details Executes a Unprivileged STRT instruction for 16 bit values.
1036 \param [in] value Value to store
1037 \param [in] ptr Pointer to location
1039 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1041 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1046 \brief STRT Unprivileged (32 bit)
1047 \details Executes a Unprivileged STRT instruction for 32 bit values.
1048 \param [in] value Value to store
1049 \param [in] ptr Pointer to location
1051 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1053 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1056 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1057 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1058 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1061 \brief Signed Saturate
1062 \details Saturates a signed value.
1063 \param [in] value Value to be saturated
1064 \param [in] sat Bit position to saturate to (1..32)
1065 \return Saturated value
1067 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1069 if ((sat >= 1U) && (sat <= 32U))
1071 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1072 const int32_t min = -1 - max ;
1086 \brief Unsigned Saturate
1087 \details Saturates an unsigned value.
1088 \param [in] value Value to be saturated
1089 \param [in] sat Bit position to saturate to (0..31)
1090 \return Saturated value
1092 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1096 const uint32_t max = ((1U << sat) - 1U);
1097 if (val > (int32_t)max)
1106 return (uint32_t)val;
1109 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1110 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1111 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1114 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1115 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1117 \brief Load-Acquire (8 bit)
1118 \details Executes a LDAB instruction for 8 bit value.
1119 \param [in] ptr Pointer to data
1120 \return value of type uint8_t at (*ptr)
1122 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1126 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1127 return ((uint8_t) result);
1132 \brief Load-Acquire (16 bit)
1133 \details Executes a LDAH instruction for 16 bit values.
1134 \param [in] ptr Pointer to data
1135 \return value of type uint16_t at (*ptr)
1137 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1141 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1142 return ((uint16_t) result);
1147 \brief Load-Acquire (32 bit)
1148 \details Executes a LDA instruction for 32 bit values.
1149 \param [in] ptr Pointer to data
1150 \return value of type uint32_t at (*ptr)
1152 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1156 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1162 \brief Store-Release (8 bit)
1163 \details Executes a STLB instruction for 8 bit values.
1164 \param [in] value Value to store
1165 \param [in] ptr Pointer to location
1167 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1169 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1174 \brief Store-Release (16 bit)
1175 \details Executes a STLH instruction for 16 bit values.
1176 \param [in] value Value to store
1177 \param [in] ptr Pointer to location
1179 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1181 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1186 \brief Store-Release (32 bit)
1187 \details Executes a STL instruction for 32 bit values.
1188 \param [in] value Value to store
1189 \param [in] ptr Pointer to location
1191 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1193 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1198 \brief Load-Acquire Exclusive (8 bit)
1199 \details Executes a LDAB exclusive instruction for 8 bit value.
1200 \param [in] ptr Pointer to data
1201 \return value of type uint8_t at (*ptr)
1203 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1207 \brief Load-Acquire Exclusive (16 bit)
1208 \details Executes a LDAH exclusive instruction for 16 bit values.
1209 \param [in] ptr Pointer to data
1210 \return value of type uint16_t at (*ptr)
1212 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1216 \brief Load-Acquire Exclusive (32 bit)
1217 \details Executes a LDA exclusive instruction for 32 bit values.
1218 \param [in] ptr Pointer to data
1219 \return value of type uint32_t at (*ptr)
1221 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1225 \brief Store-Release Exclusive (8 bit)
1226 \details Executes a STLB exclusive instruction for 8 bit values.
1227 \param [in] value Value to store
1228 \param [in] ptr Pointer to location
1229 \return 0 Function succeeded
1230 \return 1 Function failed
1232 #define __STLEXB (uint32_t)__builtin_arm_stlex
1236 \brief Store-Release Exclusive (16 bit)
1237 \details Executes a STLH exclusive instruction for 16 bit values.
1238 \param [in] value Value to store
1239 \param [in] ptr Pointer to location
1240 \return 0 Function succeeded
1241 \return 1 Function failed
1243 #define __STLEXH (uint32_t)__builtin_arm_stlex
1247 \brief Store-Release Exclusive (32 bit)
1248 \details Executes a STL exclusive instruction for 32 bit values.
1249 \param [in] value Value to store
1250 \param [in] ptr Pointer to location
1251 \return 0 Function succeeded
1252 \return 1 Function failed
1254 #define __STLEX (uint32_t)__builtin_arm_stlex
1256 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1257 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1259 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1262 /* ################### Compiler specific Intrinsics ########################### */
1263 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1264 Access to dedicated SIMD instructions
1268 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1270 __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1274 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1278 __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1282 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1286 __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1290 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1294 __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1298 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1302 __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1306 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1310 __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1314 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1319 __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1323 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1327 __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1331 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1335 __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1339 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1343 __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1347 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1351 __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1355 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1359 __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1363 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1368 __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1372 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1376 __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1380 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1384 __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1388 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392 __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1396 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1400 __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1404 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1408 __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1412 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1416 __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1420 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1424 __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1428 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1432 __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1436 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1440 __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1444 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1448 __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1452 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1456 __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1460 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1464 __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1468 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1472 __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1476 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1480 __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1484 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1488 __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1492 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1496 __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1500 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1504 __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1508 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1512 __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1516 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1520 __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1524 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1528 __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1532 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1536 __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1540 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1544 __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1548 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1552 __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1556 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1560 __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1564 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1568 __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1572 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1576 #define __SSAT16(ARG1,ARG2) \
1578 int32_t __RES, __ARG1 = (ARG1); \
1579 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1583 #define __USAT16(ARG1,ARG2) \
1585 uint32_t __RES, __ARG1 = (ARG1); \
1586 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1590 __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1)
1594 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1598 __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1602 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1606 __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1)
1610 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1614 __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1618 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1622 __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1626 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1630 __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1634 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1638 __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1642 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1646 __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1650 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1654 __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1662 #ifndef __ARMEB__ /* Little endian */
1663 __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]) );
1664 #else /* Big endian */
1665 __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]) );
1671 __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1679 #ifndef __ARMEB__ /* Little endian */
1680 __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]) );
1681 #else /* Big endian */
1682 __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]) );
1688 __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1692 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1696 __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1700 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1704 __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1708 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1712 __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1716 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1720 __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1728 #ifndef __ARMEB__ /* Little endian */
1729 __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]) );
1730 #else /* Big endian */
1731 __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]) );
1737 __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1745 #ifndef __ARMEB__ /* Little endian */
1746 __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]) );
1747 #else /* Big endian */
1748 __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]) );
1754 __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1758 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1762 __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2)
1766 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1770 __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2)
1774 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1779 #define __PKHBT(ARG1,ARG2,ARG3) \
1781 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1782 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1786 #define __PKHTB(ARG1,ARG2,ARG3) \
1788 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1790 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1792 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1797 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1798 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1800 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1801 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1803 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1807 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1811 #endif /* (__ARM_FEATURE_DSP == 1) */
1812 /*@} end of group CMSIS_SIMD_intrinsics */
1815 #endif /* __CMSIS_ARMCLANG_H */