1 /**************************************************************************//**
2 * @file cmsis_armclang_ltm.h
3 * @brief CMSIS compiler armclang (Arm Compiler 6) header file
6 ******************************************************************************/
8 * Copyright (c) 2018-2021 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
113 #ifndef __COMPILER_BARRIER
114 #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
117 /* ######################### Startup and Lowlevel Init ######################## */
119 #ifndef __PROGRAM_START
120 #define __PROGRAM_START __main
124 #define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
127 #ifndef __STACK_LIMIT
128 #define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
131 #ifndef __VECTOR_TABLE
132 #define __VECTOR_TABLE __Vectors
135 #ifndef __VECTOR_TABLE_ATTRIBUTE
136 #define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
139 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
141 #define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base
144 #ifndef __TZ_STACK_SEAL_SIZE
145 #define __TZ_STACK_SEAL_SIZE 8U
148 #ifndef __TZ_STACK_SEAL_VALUE
149 #define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL
153 __STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
154 *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE;
159 /* ########################### Core Function Access ########################### */
160 /** \ingroup CMSIS_Core_FunctionInterface
161 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
166 \brief Enable IRQ Interrupts
167 \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
168 Can only be executed in Privileged modes.
170 /* intrinsic void __enable_irq(); see arm_compat.h */
174 \brief Disable IRQ Interrupts
175 \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
176 Can only be executed in Privileged modes.
178 /* intrinsic void __disable_irq(); see arm_compat.h */
182 \brief Get Control Register
183 \details Returns the content of the Control Register.
184 \return Control Register value
186 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
190 __ASM volatile ("MRS %0, control" : "=r" (result) );
195 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
197 \brief Get Control Register (non-secure)
198 \details Returns the content of the non-secure Control Register when in secure mode.
199 \return non-secure Control Register value
201 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
205 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
212 \brief Set Control Register
213 \details Writes the given value to the Control Register.
214 \param [in] control Control Register value to set
216 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
218 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
222 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
224 \brief Set Control Register (non-secure)
225 \details Writes the given value to the non-secure Control Register when in secure state.
226 \param [in] control Control Register value to set
228 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
230 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
236 \brief Get IPSR Register
237 \details Returns the content of the IPSR Register.
238 \return IPSR Register value
240 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
244 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
250 \brief Get APSR Register
251 \details Returns the content of the APSR Register.
252 \return APSR Register value
254 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
258 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
264 \brief Get xPSR Register
265 \details Returns the content of the xPSR Register.
266 \return xPSR Register value
268 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
272 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
278 \brief Get Process Stack Pointer
279 \details Returns the current value of the Process Stack Pointer (PSP).
280 \return PSP Register value
282 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
286 __ASM volatile ("MRS %0, psp" : "=r" (result) );
291 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
293 \brief Get Process Stack Pointer (non-secure)
294 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
295 \return PSP Register value
297 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
301 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
308 \brief Set Process Stack Pointer
309 \details Assigns the given value to the Process Stack Pointer (PSP).
310 \param [in] topOfProcStack Process Stack Pointer value to set
312 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
314 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
318 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
320 \brief Set Process Stack Pointer (non-secure)
321 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
322 \param [in] topOfProcStack Process Stack Pointer value to set
324 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
326 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
332 \brief Get Main Stack Pointer
333 \details Returns the current value of the Main Stack Pointer (MSP).
334 \return MSP Register value
336 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
340 __ASM volatile ("MRS %0, msp" : "=r" (result) );
345 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
347 \brief Get Main Stack Pointer (non-secure)
348 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
349 \return MSP Register value
351 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
355 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
362 \brief Set Main Stack Pointer
363 \details Assigns the given value to the Main Stack Pointer (MSP).
364 \param [in] topOfMainStack Main Stack Pointer value to set
366 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
368 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
372 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
374 \brief Set Main Stack Pointer (non-secure)
375 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
376 \param [in] topOfMainStack Main Stack Pointer value to set
378 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
380 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
385 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
387 \brief Get Stack Pointer (non-secure)
388 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
389 \return SP Register value
391 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
395 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
401 \brief Set Stack Pointer (non-secure)
402 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
403 \param [in] topOfStack Stack Pointer value to set
405 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
407 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
413 \brief Get Priority Mask
414 \details Returns the current state of the priority mask bit from the Priority Mask Register.
415 \return Priority Mask value
417 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
421 __ASM volatile ("MRS %0, primask" : "=r" (result) );
426 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
428 \brief Get Priority Mask (non-secure)
429 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
430 \return Priority Mask value
432 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
436 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
443 \brief Set Priority Mask
444 \details Assigns the given value to the Priority Mask Register.
445 \param [in] priMask Priority Mask
447 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
449 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
453 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
455 \brief Set Priority Mask (non-secure)
456 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
457 \param [in] priMask Priority Mask
459 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
461 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
466 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
467 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
468 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
471 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
472 Can only be executed in Privileged modes.
474 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
479 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
480 Can only be executed in Privileged modes.
482 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
486 \brief Get Base Priority
487 \details Returns the current value of the Base Priority register.
488 \return Base Priority register value
490 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
494 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
499 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
501 \brief Get Base Priority (non-secure)
502 \details Returns the current value of the non-secure Base Priority register when in secure state.
503 \return Base Priority register value
505 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
509 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
516 \brief Set Base Priority
517 \details Assigns the given value to the Base Priority register.
518 \param [in] basePri Base Priority value to set
520 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
522 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
526 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
528 \brief Set Base Priority (non-secure)
529 \details Assigns the given value to the non-secure Base Priority register when in secure state.
530 \param [in] basePri Base Priority value to set
532 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
534 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
540 \brief Set Base Priority with condition
541 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
542 or the new value increases the BASEPRI priority level.
543 \param [in] basePri Base Priority value to set
545 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
547 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
552 \brief Get Fault Mask
553 \details Returns the current value of the Fault Mask register.
554 \return Fault Mask register value
556 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
560 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
565 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
567 \brief Get Fault Mask (non-secure)
568 \details Returns the current value of the non-secure Fault Mask register when in secure state.
569 \return Fault Mask register value
571 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
575 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
582 \brief Set Fault Mask
583 \details Assigns the given value to the Fault Mask register.
584 \param [in] faultMask Fault Mask value to set
586 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
588 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
592 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
594 \brief Set Fault Mask (non-secure)
595 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
596 \param [in] faultMask Fault Mask value to set
598 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
600 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
604 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
605 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
606 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
609 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
610 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
613 \brief Get Process Stack Pointer Limit
614 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
615 Stack Pointer Limit register hence zero is returned always in non-secure
618 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
619 \return PSPLIM Register value
621 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
623 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
624 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
625 // without main extensions, the non-secure PSPLIM is RAZ/WI
629 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
634 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
636 \brief Get Process Stack Pointer Limit (non-secure)
637 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
638 Stack Pointer Limit register hence zero is returned always in non-secure
641 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
642 \return PSPLIM Register value
644 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
646 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
647 // without main extensions, the non-secure PSPLIM is RAZ/WI
651 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
659 \brief Set Process Stack Pointer Limit
660 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
661 Stack Pointer Limit register hence the write is silently ignored in non-secure
664 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
665 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
667 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
669 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
670 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
671 // without main extensions, the non-secure PSPLIM is RAZ/WI
672 (void)ProcStackPtrLimit;
674 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
679 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
681 \brief Set Process Stack Pointer (non-secure)
682 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
683 Stack Pointer Limit register hence the write is silently ignored in non-secure
686 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
687 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
689 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
691 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
692 // without main extensions, the non-secure PSPLIM is RAZ/WI
693 (void)ProcStackPtrLimit;
695 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
702 \brief Get Main Stack Pointer Limit
703 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
704 Stack Pointer Limit register hence zero is returned always.
706 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
707 \return MSPLIM Register value
709 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
711 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
712 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
713 // without main extensions, the non-secure MSPLIM is RAZ/WI
717 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
723 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
725 \brief Get Main Stack Pointer Limit (non-secure)
726 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
727 Stack Pointer Limit register hence zero is returned always.
729 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
730 \return MSPLIM Register value
732 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
734 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
735 // without main extensions, the non-secure MSPLIM is RAZ/WI
739 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
747 \brief Set Main Stack Pointer Limit
748 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
749 Stack Pointer Limit register hence the write is silently ignored.
751 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
752 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
754 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
756 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
757 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
758 // without main extensions, the non-secure MSPLIM is RAZ/WI
759 (void)MainStackPtrLimit;
761 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
766 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
768 \brief Set Main Stack Pointer Limit (non-secure)
769 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
770 Stack Pointer Limit register hence the write is silently ignored.
772 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
773 \param [in] MainStackPtrLimit Main Stack Pointer value to set
775 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
777 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
778 // without main extensions, the non-secure MSPLIM is RAZ/WI
779 (void)MainStackPtrLimit;
781 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
786 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
787 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
791 \details Returns the current value of the Floating Point Status/Control register.
792 \return Floating Point Status/Control register value
794 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
795 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
796 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
798 #define __get_FPSCR() ((uint32_t)0U)
803 \details Assigns the given value to the Floating Point Status/Control register.
804 \param [in] fpscr Floating Point Status/Control value to set
806 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
807 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
808 #define __set_FPSCR __builtin_arm_set_fpscr
810 #define __set_FPSCR(x) ((void)(x))
814 /*@} end of CMSIS_Core_RegAccFunctions */
817 /* ########################## Core Instruction Access ######################### */
818 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
819 Access to dedicated instructions
823 /* Define macros for porting to both thumb1 and thumb2.
824 * For thumb1, use low register (r0-r7), specified by constraint "l"
825 * Otherwise, use general registers, specified by constraint "r" */
826 #if defined (__thumb__) && !defined (__thumb2__)
827 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
828 #define __CMSIS_GCC_USE_REG(r) "l" (r)
830 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
831 #define __CMSIS_GCC_USE_REG(r) "r" (r)
836 \details No Operation does nothing. This instruction can be used for code alignment purposes.
838 #define __NOP __builtin_arm_nop
841 \brief Wait For Interrupt
842 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
844 #define __WFI __builtin_arm_wfi
848 \brief Wait For Event
849 \details Wait For Event is a hint instruction that permits the processor to enter
850 a low-power state until one of a number of events occurs.
852 #define __WFE __builtin_arm_wfe
857 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
859 #define __SEV __builtin_arm_sev
863 \brief Instruction Synchronization Barrier
864 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
865 so that all instructions following the ISB are fetched from cache or memory,
866 after the instruction has been completed.
868 #define __ISB() __builtin_arm_isb(0xF)
871 \brief Data Synchronization Barrier
872 \details Acts as a special kind of Data Memory Barrier.
873 It completes when all explicit memory accesses before this instruction complete.
875 #define __DSB() __builtin_arm_dsb(0xF)
879 \brief Data Memory Barrier
880 \details Ensures the apparent order of the explicit memory operations before
881 and after the instruction, without ensuring their completion.
883 #define __DMB() __builtin_arm_dmb(0xF)
887 \brief Reverse byte order (32 bit)
888 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
889 \param [in] value Value to reverse
890 \return Reversed value
892 #define __REV(value) __builtin_bswap32(value)
896 \brief Reverse byte order (16 bit)
897 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
898 \param [in] value Value to reverse
899 \return Reversed value
901 #define __REV16(value) __ROR(__REV(value), 16)
905 \brief Reverse byte order (16 bit)
906 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
907 \param [in] value Value to reverse
908 \return Reversed value
910 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
914 \brief Rotate Right in unsigned value (32 bit)
915 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
916 \param [in] op1 Value to rotate
917 \param [in] op2 Number of Bits to rotate
918 \return Rotated value
920 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
927 return (op1 >> op2) | (op1 << (32U - op2));
933 \details Causes the processor to enter Debug state.
934 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
935 \param [in] value is ignored by the processor.
936 If required, a debugger can use it to store additional information about the breakpoint.
938 #define __BKPT(value) __ASM volatile ("bkpt "#value)
942 \brief Reverse bit order of value
943 \details Reverses the bit order of the given value.
944 \param [in] value Value to reverse
945 \return Reversed value
947 #define __RBIT __builtin_arm_rbit
950 \brief Count leading zeros
951 \details Counts the number of leading zeros of a data value.
952 \param [in] value Value to count the leading zeros
953 \return number of leading zeros in value
955 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
957 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
958 __builtin_clz(0) is undefined behaviour, so handle this case specially.
959 This guarantees ARM-compatible results if happening to compile on a non-ARM
960 target, and ensures the compiler doesn't decide to activate any
961 optimisations using the logic "value was passed to __builtin_clz, so it
963 ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
964 single CLZ instruction.
970 return __builtin_clz(value);
974 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
975 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
976 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
977 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
979 \brief LDR Exclusive (8 bit)
980 \details Executes a exclusive LDR instruction for 8 bit value.
981 \param [in] ptr Pointer to data
982 \return value of type uint8_t at (*ptr)
984 #define __LDREXB (uint8_t)__builtin_arm_ldrex
988 \brief LDR Exclusive (16 bit)
989 \details Executes a exclusive LDR instruction for 16 bit values.
990 \param [in] ptr Pointer to data
991 \return value of type uint16_t at (*ptr)
993 #define __LDREXH (uint16_t)__builtin_arm_ldrex
997 \brief LDR Exclusive (32 bit)
998 \details Executes a exclusive LDR instruction for 32 bit values.
999 \param [in] ptr Pointer to data
1000 \return value of type uint32_t at (*ptr)
1002 #define __LDREXW (uint32_t)__builtin_arm_ldrex
1006 \brief STR Exclusive (8 bit)
1007 \details Executes a exclusive STR instruction for 8 bit values.
1008 \param [in] value Value to store
1009 \param [in] ptr Pointer to location
1010 \return 0 Function succeeded
1011 \return 1 Function failed
1013 #define __STREXB (uint32_t)__builtin_arm_strex
1017 \brief STR Exclusive (16 bit)
1018 \details Executes a exclusive STR instruction for 16 bit values.
1019 \param [in] value Value to store
1020 \param [in] ptr Pointer to location
1021 \return 0 Function succeeded
1022 \return 1 Function failed
1024 #define __STREXH (uint32_t)__builtin_arm_strex
1028 \brief STR Exclusive (32 bit)
1029 \details Executes a exclusive STR instruction for 32 bit values.
1030 \param [in] value Value to store
1031 \param [in] ptr Pointer to location
1032 \return 0 Function succeeded
1033 \return 1 Function failed
1035 #define __STREXW (uint32_t)__builtin_arm_strex
1039 \brief Remove the exclusive lock
1040 \details Removes the exclusive lock which is created by LDREX.
1042 #define __CLREX __builtin_arm_clrex
1044 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1045 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1046 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1047 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1050 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1051 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1052 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1055 \brief Signed Saturate
1056 \details Saturates a signed value.
1057 \param [in] value Value to be saturated
1058 \param [in] sat Bit position to saturate to (1..32)
1059 \return Saturated value
1061 #define __SSAT __builtin_arm_ssat
1065 \brief Unsigned Saturate
1066 \details Saturates an unsigned value.
1067 \param [in] value Value to be saturated
1068 \param [in] sat Bit position to saturate to (0..31)
1069 \return Saturated value
1071 #define __USAT __builtin_arm_usat
1075 \brief Rotate Right with Extend (32 bit)
1076 \details Moves each bit of a bitstring right by one bit.
1077 The carry input is shifted in at the left end of the bitstring.
1078 \param [in] value Value to rotate
1079 \return Rotated value
1081 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
1085 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1091 \brief LDRT Unprivileged (8 bit)
1092 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1093 \param [in] ptr Pointer to data
1094 \return value of type uint8_t at (*ptr)
1096 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1100 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1101 return ((uint8_t) result); /* Add explicit type cast here */
1106 \brief LDRT Unprivileged (16 bit)
1107 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1108 \param [in] ptr Pointer to data
1109 \return value of type uint16_t at (*ptr)
1111 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1115 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1116 return ((uint16_t) result); /* Add explicit type cast here */
1121 \brief LDRT Unprivileged (32 bit)
1122 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1123 \param [in] ptr Pointer to data
1124 \return value of type uint32_t at (*ptr)
1126 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1130 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1136 \brief STRT Unprivileged (8 bit)
1137 \details Executes a Unprivileged STRT instruction for 8 bit values.
1138 \param [in] value Value to store
1139 \param [in] ptr Pointer to location
1141 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1143 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1148 \brief STRT Unprivileged (16 bit)
1149 \details Executes a Unprivileged STRT instruction for 16 bit values.
1150 \param [in] value Value to store
1151 \param [in] ptr Pointer to location
1153 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1155 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1160 \brief STRT Unprivileged (32 bit)
1161 \details Executes a Unprivileged STRT instruction for 32 bit values.
1162 \param [in] value Value to store
1163 \param [in] ptr Pointer to location
1165 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1167 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1170 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1171 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1172 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1175 \brief Signed Saturate
1176 \details Saturates a signed value.
1177 \param [in] value Value to be saturated
1178 \param [in] sat Bit position to saturate to (1..32)
1179 \return Saturated value
1181 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1183 if ((sat >= 1U) && (sat <= 32U))
1185 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1186 const int32_t min = -1 - max ;
1200 \brief Unsigned Saturate
1201 \details Saturates an unsigned value.
1202 \param [in] value Value to be saturated
1203 \param [in] sat Bit position to saturate to (0..31)
1204 \return Saturated value
1206 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1210 const uint32_t max = ((1U << sat) - 1U);
1211 if (val > (int32_t)max)
1220 return (uint32_t)val;
1223 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1224 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1225 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1228 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1229 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1231 \brief Load-Acquire (8 bit)
1232 \details Executes a LDAB instruction for 8 bit value.
1233 \param [in] ptr Pointer to data
1234 \return value of type uint8_t at (*ptr)
1236 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1240 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1241 return ((uint8_t) result);
1246 \brief Load-Acquire (16 bit)
1247 \details Executes a LDAH instruction for 16 bit values.
1248 \param [in] ptr Pointer to data
1249 \return value of type uint16_t at (*ptr)
1251 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1255 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1256 return ((uint16_t) result);
1261 \brief Load-Acquire (32 bit)
1262 \details Executes a LDA instruction for 32 bit values.
1263 \param [in] ptr Pointer to data
1264 \return value of type uint32_t at (*ptr)
1266 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1270 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1276 \brief Store-Release (8 bit)
1277 \details Executes a STLB instruction for 8 bit values.
1278 \param [in] value Value to store
1279 \param [in] ptr Pointer to location
1281 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1283 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1288 \brief Store-Release (16 bit)
1289 \details Executes a STLH instruction for 16 bit values.
1290 \param [in] value Value to store
1291 \param [in] ptr Pointer to location
1293 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1295 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1300 \brief Store-Release (32 bit)
1301 \details Executes a STL instruction for 32 bit values.
1302 \param [in] value Value to store
1303 \param [in] ptr Pointer to location
1305 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1307 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1312 \brief Load-Acquire Exclusive (8 bit)
1313 \details Executes a LDAB exclusive instruction for 8 bit value.
1314 \param [in] ptr Pointer to data
1315 \return value of type uint8_t at (*ptr)
1317 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1321 \brief Load-Acquire Exclusive (16 bit)
1322 \details Executes a LDAH exclusive instruction for 16 bit values.
1323 \param [in] ptr Pointer to data
1324 \return value of type uint16_t at (*ptr)
1326 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1330 \brief Load-Acquire Exclusive (32 bit)
1331 \details Executes a LDA exclusive instruction for 32 bit values.
1332 \param [in] ptr Pointer to data
1333 \return value of type uint32_t at (*ptr)
1335 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1339 \brief Store-Release Exclusive (8 bit)
1340 \details Executes a STLB exclusive instruction for 8 bit values.
1341 \param [in] value Value to store
1342 \param [in] ptr Pointer to location
1343 \return 0 Function succeeded
1344 \return 1 Function failed
1346 #define __STLEXB (uint32_t)__builtin_arm_stlex
1350 \brief Store-Release Exclusive (16 bit)
1351 \details Executes a STLH exclusive instruction for 16 bit values.
1352 \param [in] value Value to store
1353 \param [in] ptr Pointer to location
1354 \return 0 Function succeeded
1355 \return 1 Function failed
1357 #define __STLEXH (uint32_t)__builtin_arm_stlex
1361 \brief Store-Release Exclusive (32 bit)
1362 \details Executes a STL exclusive instruction for 32 bit values.
1363 \param [in] value Value to store
1364 \param [in] ptr Pointer to location
1365 \return 0 Function succeeded
1366 \return 1 Function failed
1368 #define __STLEX (uint32_t)__builtin_arm_stlex
1370 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1371 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1373 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1376 /* ################### Compiler specific Intrinsics ########################### */
1377 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1378 Access to dedicated SIMD instructions
1382 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1384 __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1388 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392 __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1396 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1400 __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1404 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1408 __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1412 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1416 __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1420 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1424 __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1428 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1433 __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1437 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441 __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1445 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1449 __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1453 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1457 __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1461 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1465 __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1469 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1473 __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1477 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1482 __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1486 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1490 __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1494 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1498 __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1502 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1506 __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1510 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1514 __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1518 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1522 __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1526 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1530 __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1534 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1538 __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1542 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1546 __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1550 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1554 __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1558 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1562 __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1566 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1570 __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1574 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1578 __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1582 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1586 __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1590 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1594 __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1598 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1602 __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1606 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1610 __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1614 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1618 __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1622 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1626 __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1630 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1634 __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1638 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1642 __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1646 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1650 __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1654 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1658 __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1662 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1666 __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1670 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1674 __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1678 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1682 __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1686 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1690 #define __SSAT16(ARG1,ARG2) \
1692 int32_t __RES, __ARG1 = (ARG1); \
1693 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1697 #define __USAT16(ARG1,ARG2) \
1699 uint32_t __RES, __ARG1 = (ARG1); \
1700 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1704 __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1)
1708 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1712 __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1716 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1720 __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1)
1724 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1728 __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1732 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1736 __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1740 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1744 __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1748 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1752 __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1756 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1760 __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1764 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1768 __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1776 #ifndef __ARMEB__ /* Little endian */
1777 __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]) );
1778 #else /* Big endian */
1779 __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]) );
1785 __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1793 #ifndef __ARMEB__ /* Little endian */
1794 __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]) );
1795 #else /* Big endian */
1796 __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]) );
1802 __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1806 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1810 __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1814 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1818 __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1822 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1826 __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1830 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1834 __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1842 #ifndef __ARMEB__ /* Little endian */
1843 __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]) );
1844 #else /* Big endian */
1845 __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]) );
1851 __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1859 #ifndef __ARMEB__ /* Little endian */
1860 __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]) );
1861 #else /* Big endian */
1862 __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]) );
1868 __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1872 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1876 __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2)
1880 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1884 __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2)
1888 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1892 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1893 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1895 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1896 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1898 #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
1900 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1902 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1906 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1910 #endif /* (__ARM_FEATURE_DSP == 1) */
1911 /*@} end of group CMSIS_SIMD_intrinsics */
1914 #endif /* __CMSIS_ARMCLANG_H */