1 /**************************************************************************//**
2 * @file cmsis_armclang.h
3 * @brief CMSIS Cortex-M Core Function/Instruction Header File
5 * @date 28. October 2016
6 ******************************************************************************/
8 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
25 #ifndef __CMSIS_ARMCLANG_H
26 #define __CMSIS_ARMCLANG_H
28 #ifndef __ARM_COMPAT_H
29 #include <arm_compat.h> /* Compatibility header for ARM Compiler 5 intrinsics */
32 /* CMSIS compiler specific defines */
37 #define __INLINE __inline
39 #ifndef __STATIC_INLINE
40 #define __STATIC_INLINE static __inline
43 #define __NO_RETURN __attribute__((noreturn))
46 #define __USED __attribute__((used))
49 #define __WEAK __attribute__((weak))
51 #ifndef __UNALIGNED_UINT32
52 #pragma clang diagnostic push
53 #pragma clang diagnostic ignored "-Wpacked"
54 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
55 #pragma clang diagnostic pop
56 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
59 #define __ALIGNED(x) __attribute__((aligned(x)))
62 #define __PACKED __attribute__((packed, aligned(1)))
66 /* ########################### Core Function Access ########################### */
67 /** \ingroup CMSIS_Core_FunctionInterface
68 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
73 \brief Enable IRQ Interrupts
74 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
75 Can only be executed in Privileged modes.
77 /* intrinsic void __enable_irq(); see arm_compat.h */
81 \brief Disable IRQ Interrupts
82 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
83 Can only be executed in Privileged modes.
85 /* intrinsic void __disable_irq(); see arm_compat.h */
89 \brief Get Control Register
90 \details Returns the content of the Control Register.
91 \return Control Register value
93 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
97 __ASM volatile ("MRS %0, control" : "=r" (result) );
102 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
104 \brief Get Control Register (non-secure)
105 \details Returns the content of the non-secure Control Register when in secure mode.
106 \return non-secure Control Register value
108 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
112 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
119 \brief Set Control Register
120 \details Writes the given value to the Control Register.
121 \param [in] control Control Register value to set
123 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
125 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
129 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
131 \brief Set Control Register (non-secure)
132 \details Writes the given value to the non-secure Control Register when in secure state.
133 \param [in] control Control Register value to set
135 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
137 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
143 \brief Get IPSR Register
144 \details Returns the content of the IPSR Register.
145 \return IPSR Register value
147 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
151 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
157 \brief Get APSR Register
158 \details Returns the content of the APSR Register.
159 \return APSR Register value
161 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
165 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
171 \brief Get xPSR Register
172 \details Returns the content of the xPSR Register.
173 \return xPSR Register value
175 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
179 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
185 \brief Get Process Stack Pointer
186 \details Returns the current value of the Process Stack Pointer (PSP).
187 \return PSP Register value
189 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
191 register uint32_t result;
193 __ASM volatile ("MRS %0, psp" : "=r" (result) );
198 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
200 \brief Get Process Stack Pointer (non-secure)
201 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
202 \return PSP Register value
204 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
206 register uint32_t result;
208 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
215 \brief Set Process Stack Pointer
216 \details Assigns the given value to the Process Stack Pointer (PSP).
217 \param [in] topOfProcStack Process Stack Pointer value to set
219 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
221 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : "sp");
225 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
227 \brief Set Process Stack Pointer (non-secure)
228 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
229 \param [in] topOfProcStack Process Stack Pointer value to set
231 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
233 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : "sp");
239 \brief Get Main Stack Pointer
240 \details Returns the current value of the Main Stack Pointer (MSP).
241 \return MSP Register value
243 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
245 register uint32_t result;
247 __ASM volatile ("MRS %0, msp" : "=r" (result) );
252 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
254 \brief Get Main Stack Pointer (non-secure)
255 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
256 \return MSP Register value
258 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
260 register uint32_t result;
262 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
269 \brief Set Main Stack Pointer
270 \details Assigns the given value to the Main Stack Pointer (MSP).
271 \param [in] topOfMainStack Main Stack Pointer value to set
273 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
275 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : "sp");
279 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
281 \brief Set Main Stack Pointer (non-secure)
282 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
283 \param [in] topOfMainStack Main Stack Pointer value to set
285 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
287 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : "sp");
293 \brief Get Priority Mask
294 \details Returns the current state of the priority mask bit from the Priority Mask Register.
295 \return Priority Mask value
297 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
301 __ASM volatile ("MRS %0, primask" : "=r" (result) );
306 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
308 \brief Get Priority Mask (non-secure)
309 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
310 \return Priority Mask value
312 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
316 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
323 \brief Set Priority Mask
324 \details Assigns the given value to the Priority Mask Register.
325 \param [in] priMask Priority Mask
327 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
329 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
333 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
335 \brief Set Priority Mask (non-secure)
336 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
337 \param [in] priMask Priority Mask
339 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
341 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
346 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
347 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
348 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
351 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
352 Can only be executed in Privileged modes.
354 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
359 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
360 Can only be executed in Privileged modes.
362 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
366 \brief Get Base Priority
367 \details Returns the current value of the Base Priority register.
368 \return Base Priority register value
370 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
374 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
379 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
381 \brief Get Base Priority (non-secure)
382 \details Returns the current value of the non-secure Base Priority register when in secure state.
383 \return Base Priority register value
385 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
389 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
396 \brief Set Base Priority
397 \details Assigns the given value to the Base Priority register.
398 \param [in] basePri Base Priority value to set
400 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
402 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
406 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
408 \brief Set Base Priority (non-secure)
409 \details Assigns the given value to the non-secure Base Priority register when in secure state.
410 \param [in] basePri Base Priority value to set
412 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
414 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
420 \brief Set Base Priority with condition
421 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
422 or the new value increases the BASEPRI priority level.
423 \param [in] basePri Base Priority value to set
425 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
427 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
432 \brief Get Fault Mask
433 \details Returns the current value of the Fault Mask register.
434 \return Fault Mask register value
436 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
440 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
445 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
447 \brief Get Fault Mask (non-secure)
448 \details Returns the current value of the non-secure Fault Mask register when in secure state.
449 \return Fault Mask register value
451 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
455 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
462 \brief Set Fault Mask
463 \details Assigns the given value to the Fault Mask register.
464 \param [in] faultMask Fault Mask value to set
466 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
468 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
472 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
474 \brief Set Fault Mask (non-secure)
475 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
476 \param [in] faultMask Fault Mask value to set
478 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
480 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
484 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
485 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
486 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
489 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
490 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
493 \brief Get Process Stack Pointer Limit
494 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
495 \return PSPLIM Register value
497 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
499 register uint32_t result;
501 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
506 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
507 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
509 \brief Get Process Stack Pointer Limit (non-secure)
510 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
511 \return PSPLIM Register value
513 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
515 register uint32_t result;
517 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
524 \brief Set Process Stack Pointer Limit
525 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
526 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
528 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
530 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
534 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
535 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
537 \brief Set Process Stack Pointer (non-secure)
538 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
539 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
541 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
543 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
549 \brief Get Main Stack Pointer Limit
550 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
551 \return MSPLIM Register value
553 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
555 register uint32_t result;
557 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
563 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
564 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
566 \brief Get Main Stack Pointer Limit (non-secure)
567 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
568 \return MSPLIM Register value
570 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
572 register uint32_t result;
574 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
581 \brief Set Main Stack Pointer Limit
582 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
583 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
585 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
587 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
591 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
592 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
594 \brief Set Main Stack Pointer Limit (non-secure)
595 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
596 \param [in] MainStackPtrLimit Main Stack Pointer value to set
598 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
600 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
604 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
605 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
608 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
609 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
613 \details Returns the current value of the Floating Point Status/Control register.
614 \return Floating Point Status/Control register value
616 /* #define __get_FPSCR __builtin_arm_get_fpscr */
617 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
619 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
620 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
623 __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */
624 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
635 \details Assigns the given value to the Floating Point Status/Control register.
636 \param [in] fpscr Floating Point Status/Control value to set
638 /* #define __set_FPSCR __builtin_arm_set_fpscr */
639 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
641 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
642 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
643 __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */
644 /* __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); */
645 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) :);
652 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
653 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
657 /*@} end of CMSIS_Core_RegAccFunctions */
660 /* ########################## Core Instruction Access ######################### */
661 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
662 Access to dedicated instructions
666 /* Define macros for porting to both thumb1 and thumb2.
667 * For thumb1, use low register (r0-r7), specified by constraint "l"
668 * Otherwise, use general registers, specified by constraint "r" */
669 #if defined (__thumb__) && !defined (__thumb2__)
670 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
671 #define __CMSIS_GCC_USE_REG(r) "l" (r)
673 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
674 #define __CMSIS_GCC_USE_REG(r) "r" (r)
679 \details No Operation does nothing. This instruction can be used for code alignment purposes.
681 #define __NOP __builtin_arm_nop
684 \brief Wait For Interrupt
685 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
687 #define __WFI __builtin_arm_wfi
691 \brief Wait For Event
692 \details Wait For Event is a hint instruction that permits the processor to enter
693 a low-power state until one of a number of events occurs.
695 #define __WFE __builtin_arm_wfe
700 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
702 #define __SEV __builtin_arm_sev
706 \brief Instruction Synchronization Barrier
707 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
708 so that all instructions following the ISB are fetched from cache or memory,
709 after the instruction has been completed.
711 #define __ISB() __builtin_arm_isb(0xF);
714 \brief Data Synchronization Barrier
715 \details Acts as a special kind of Data Memory Barrier.
716 It completes when all explicit memory accesses before this instruction complete.
718 #define __DSB() __builtin_arm_dsb(0xF);
722 \brief Data Memory Barrier
723 \details Ensures the apparent order of the explicit memory operations before
724 and after the instruction, without ensuring their completion.
726 #define __DMB() __builtin_arm_dmb(0xF);
730 \brief Reverse byte order (32 bit)
731 \details Reverses the byte order in integer value.
732 \param [in] value Value to reverse
733 \return Reversed value
735 #define __REV __builtin_bswap32
739 \brief Reverse byte order (16 bit)
740 \details Reverses the byte order in two unsigned short values.
741 \param [in] value Value to reverse
742 \return Reversed value
744 #define __REV16 __builtin_bswap16 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
746 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
750 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
757 \brief Reverse byte order in signed short value
758 \details Reverses the byte order in a signed short value with sign extension to integer.
759 \param [in] value Value to reverse
760 \return Reversed value
762 /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
763 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
767 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
773 \brief Rotate Right in unsigned value (32 bit)
774 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
775 \param [in] op1 Value to rotate
776 \param [in] op2 Number of Bits to rotate
777 \return Rotated value
779 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
781 return (op1 >> op2) | (op1 << (32U - op2));
787 \details Causes the processor to enter Debug state.
788 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
789 \param [in] value is ignored by the processor.
790 If required, a debugger can use it to store additional information about the breakpoint.
792 #define __BKPT(value) __ASM volatile ("bkpt "#value)
796 \brief Reverse bit order of value
797 \details Reverses the bit order of the given value.
798 \param [in] value Value to reverse
799 \return Reversed value
801 /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
802 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
806 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
807 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
808 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
809 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
811 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
813 result = value; /* r will be reversed bits of v; first get LSB of v */
814 for (value >>= 1U; value; value >>= 1U)
817 result |= value & 1U;
820 result <<= s; /* shift when v's highest bits are zero */
827 \brief Count leading zeros
828 \details Counts the number of leading zeros of a data value.
829 \param [in] value Value to count the leading zeros
830 \return number of leading zeros in value
832 #define __CLZ __builtin_clz
835 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
836 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
837 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
838 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
840 \brief LDR Exclusive (8 bit)
841 \details Executes a exclusive LDR instruction for 8 bit value.
842 \param [in] ptr Pointer to data
843 \return value of type uint8_t at (*ptr)
845 #define __LDREXB (uint8_t)__builtin_arm_ldrex
849 \brief LDR Exclusive (16 bit)
850 \details Executes a exclusive LDR instruction for 16 bit values.
851 \param [in] ptr Pointer to data
852 \return value of type uint16_t at (*ptr)
854 #define __LDREXH (uint16_t)__builtin_arm_ldrex
858 \brief LDR Exclusive (32 bit)
859 \details Executes a exclusive LDR instruction for 32 bit values.
860 \param [in] ptr Pointer to data
861 \return value of type uint32_t at (*ptr)
863 #define __LDREXW (uint32_t)__builtin_arm_ldrex
867 \brief STR Exclusive (8 bit)
868 \details Executes a exclusive STR instruction for 8 bit values.
869 \param [in] value Value to store
870 \param [in] ptr Pointer to location
871 \return 0 Function succeeded
872 \return 1 Function failed
874 #define __STREXB (uint32_t)__builtin_arm_strex
878 \brief STR Exclusive (16 bit)
879 \details Executes a exclusive STR instruction for 16 bit values.
880 \param [in] value Value to store
881 \param [in] ptr Pointer to location
882 \return 0 Function succeeded
883 \return 1 Function failed
885 #define __STREXH (uint32_t)__builtin_arm_strex
889 \brief STR Exclusive (32 bit)
890 \details Executes a exclusive STR instruction for 32 bit values.
891 \param [in] value Value to store
892 \param [in] ptr Pointer to location
893 \return 0 Function succeeded
894 \return 1 Function failed
896 #define __STREXW (uint32_t)__builtin_arm_strex
900 \brief Remove the exclusive lock
901 \details Removes the exclusive lock which is created by LDREX.
903 #define __CLREX __builtin_arm_clrex
905 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
906 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
907 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
908 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
911 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
912 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
913 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
915 \brief Signed Saturate
916 \details Saturates a signed value.
917 \param [in] value Value to be saturated
918 \param [in] sat Bit position to saturate to (1..32)
919 \return Saturated value
921 #define __SSAT __builtin_arm_ssat
925 \brief Unsigned Saturate
926 \details Saturates an unsigned value.
927 \param [in] value Value to be saturated
928 \param [in] sat Bit position to saturate to (0..31)
929 \return Saturated value
931 #define __USAT __builtin_arm_usat
935 \brief Rotate Right with Extend (32 bit)
936 \details Moves each bit of a bitstring right by one bit.
937 The carry input is shifted in at the left end of the bitstring.
938 \param [in] value Value to rotate
939 \return Rotated value
941 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
945 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
951 \brief LDRT Unprivileged (8 bit)
952 \details Executes a Unprivileged LDRT instruction for 8 bit value.
953 \param [in] ptr Pointer to data
954 \return value of type uint8_t at (*ptr)
956 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
960 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
961 return ((uint8_t) result); /* Add explicit type cast here */
966 \brief LDRT Unprivileged (16 bit)
967 \details Executes a Unprivileged LDRT instruction for 16 bit values.
968 \param [in] ptr Pointer to data
969 \return value of type uint16_t at (*ptr)
971 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
975 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
976 return ((uint16_t) result); /* Add explicit type cast here */
981 \brief LDRT Unprivileged (32 bit)
982 \details Executes a Unprivileged LDRT instruction for 32 bit values.
983 \param [in] ptr Pointer to data
984 \return value of type uint32_t at (*ptr)
986 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
990 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
996 \brief STRT Unprivileged (8 bit)
997 \details Executes a Unprivileged STRT instruction for 8 bit values.
998 \param [in] value Value to store
999 \param [in] ptr Pointer to location
1001 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1003 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1008 \brief STRT Unprivileged (16 bit)
1009 \details Executes a Unprivileged STRT instruction for 16 bit values.
1010 \param [in] value Value to store
1011 \param [in] ptr Pointer to location
1013 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1015 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1020 \brief STRT Unprivileged (32 bit)
1021 \details Executes a Unprivileged STRT instruction for 32 bit values.
1022 \param [in] value Value to store
1023 \param [in] ptr Pointer to location
1025 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1027 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1030 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1031 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1032 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1035 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1036 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1038 \brief Load-Acquire (8 bit)
1039 \details Executes a LDAB instruction for 8 bit value.
1040 \param [in] ptr Pointer to data
1041 \return value of type uint8_t at (*ptr)
1043 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1047 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1048 return ((uint8_t) result);
1053 \brief Load-Acquire (16 bit)
1054 \details Executes a LDAH instruction for 16 bit values.
1055 \param [in] ptr Pointer to data
1056 \return value of type uint16_t at (*ptr)
1058 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1062 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1063 return ((uint16_t) result);
1068 \brief Load-Acquire (32 bit)
1069 \details Executes a LDA instruction for 32 bit values.
1070 \param [in] ptr Pointer to data
1071 \return value of type uint32_t at (*ptr)
1073 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1077 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1083 \brief Store-Release (8 bit)
1084 \details Executes a STLB instruction for 8 bit values.
1085 \param [in] value Value to store
1086 \param [in] ptr Pointer to location
1088 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1090 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1095 \brief Store-Release (16 bit)
1096 \details Executes a STLH instruction for 16 bit values.
1097 \param [in] value Value to store
1098 \param [in] ptr Pointer to location
1100 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1102 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1107 \brief Store-Release (32 bit)
1108 \details Executes a STL instruction for 32 bit values.
1109 \param [in] value Value to store
1110 \param [in] ptr Pointer to location
1112 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1114 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1119 \brief Load-Acquire Exclusive (8 bit)
1120 \details Executes a LDAB exclusive instruction for 8 bit value.
1121 \param [in] ptr Pointer to data
1122 \return value of type uint8_t at (*ptr)
1124 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1128 \brief Load-Acquire Exclusive (16 bit)
1129 \details Executes a LDAH exclusive instruction for 16 bit values.
1130 \param [in] ptr Pointer to data
1131 \return value of type uint16_t at (*ptr)
1133 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1137 \brief Load-Acquire Exclusive (32 bit)
1138 \details Executes a LDA exclusive instruction for 32 bit values.
1139 \param [in] ptr Pointer to data
1140 \return value of type uint32_t at (*ptr)
1142 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1146 \brief Store-Release Exclusive (8 bit)
1147 \details Executes a STLB exclusive instruction for 8 bit values.
1148 \param [in] value Value to store
1149 \param [in] ptr Pointer to location
1150 \return 0 Function succeeded
1151 \return 1 Function failed
1153 #define __STLEXB (uint32_t)__builtin_arm_stlex
1157 \brief Store-Release Exclusive (16 bit)
1158 \details Executes a STLH exclusive instruction for 16 bit values.
1159 \param [in] value Value to store
1160 \param [in] ptr Pointer to location
1161 \return 0 Function succeeded
1162 \return 1 Function failed
1164 #define __STLEXH (uint32_t)__builtin_arm_stlex
1168 \brief Store-Release Exclusive (32 bit)
1169 \details Executes a STL exclusive instruction for 32 bit values.
1170 \param [in] value Value to store
1171 \param [in] ptr Pointer to location
1172 \return 0 Function succeeded
1173 \return 1 Function failed
1175 #define __STLEX (uint32_t)__builtin_arm_stlex
1177 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1178 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1180 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1183 /* ################### Compiler specific Intrinsics ########################### */
1184 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1185 Access to dedicated SIMD instructions
1189 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1191 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1195 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1199 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1203 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1207 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1211 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1215 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1219 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1223 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1227 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1231 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1235 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1240 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1244 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1248 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1252 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1256 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1260 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1264 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1268 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1272 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1276 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1280 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1284 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1289 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1293 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1297 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1301 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1305 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1309 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1313 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1317 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1321 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1325 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1329 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1333 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1337 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1341 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1345 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1349 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1353 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1357 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1361 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1365 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1369 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1373 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1377 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1381 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1385 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1389 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1393 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1397 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1401 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1405 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1409 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1413 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1417 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1421 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1425 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1429 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1433 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1437 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1445 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1449 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1453 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1457 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1461 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1465 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1469 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1473 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1477 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1481 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1485 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1489 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1493 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1497 #define __SSAT16(ARG1,ARG2) \
1499 int32_t __RES, __ARG1 = (ARG1); \
1500 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1504 #define __USAT16(ARG1,ARG2) \
1506 uint32_t __RES, __ARG1 = (ARG1); \
1507 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1511 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1515 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1519 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1523 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1527 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1531 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1535 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1539 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1543 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1547 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1551 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1555 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1559 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1563 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1567 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1571 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1575 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1583 #ifndef __ARMEB__ /* Little endian */
1584 __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]) );
1585 #else /* Big endian */
1586 __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]) );
1592 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1600 #ifndef __ARMEB__ /* Little endian */
1601 __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]) );
1602 #else /* Big endian */
1603 __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]) );
1609 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1613 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1617 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1621 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1625 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1629 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1633 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1637 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1641 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1649 #ifndef __ARMEB__ /* Little endian */
1650 __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]) );
1651 #else /* Big endian */
1652 __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]) );
1658 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1666 #ifndef __ARMEB__ /* Little endian */
1667 __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]) );
1668 #else /* Big endian */
1669 __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]) );
1675 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1679 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1683 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1687 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1691 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1695 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1700 #define __PKHBT(ARG1,ARG2,ARG3) \
1702 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1703 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1707 #define __PKHTB(ARG1,ARG2,ARG3) \
1709 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1711 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1713 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1718 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1719 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1721 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1722 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1724 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1728 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1732 #endif /* (__ARM_FEATURE_DSP == 1) */
1733 /*@} end of group CMSIS_SIMD_intrinsics */
1736 #endif /* __CMSIS_ARMCLANG_H */