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 /* CMSIS compiler specific defines */
37 #define __INLINE __inline
39 #ifndef __STATIC_INLINE
40 #define __STATIC_INLINE static __inline
42 #ifndef __STATIC_FORCEINLINE
43 #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline
46 #define __NO_RETURN __attribute__((__noreturn__))
49 #define __USED __attribute__((used))
52 #define __WEAK __attribute__((weak))
55 #define __PACKED __attribute__((packed, aligned(1)))
57 #ifndef __PACKED_STRUCT
58 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
60 #ifndef __PACKED_UNION
61 #define __PACKED_UNION union __attribute__((packed, aligned(1)))
63 #ifndef __UNALIGNED_UINT32 /* deprecated */
64 #pragma clang diagnostic push
65 #pragma clang diagnostic ignored "-Wpacked"
66 /*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */
67 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
68 #pragma clang diagnostic pop
69 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
71 #ifndef __UNALIGNED_UINT16_WRITE
72 #pragma clang diagnostic push
73 #pragma clang diagnostic ignored "-Wpacked"
74 /*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */
75 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
76 #pragma clang diagnostic pop
77 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
79 #ifndef __UNALIGNED_UINT16_READ
80 #pragma clang diagnostic push
81 #pragma clang diagnostic ignored "-Wpacked"
82 /*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */
83 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
84 #pragma clang diagnostic pop
85 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
87 #ifndef __UNALIGNED_UINT32_WRITE
88 #pragma clang diagnostic push
89 #pragma clang diagnostic ignored "-Wpacked"
90 /*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */
91 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
92 #pragma clang diagnostic pop
93 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
95 #ifndef __UNALIGNED_UINT32_READ
96 #pragma clang diagnostic push
97 #pragma clang diagnostic ignored "-Wpacked"
98 /*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */
99 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
100 #pragma clang diagnostic pop
101 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
104 #define __ALIGNED(x) __attribute__((aligned(x)))
107 #define __RESTRICT __restrict
109 #ifndef __COMPILER_BARRIER
110 #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
113 /* ######################### Startup and Lowlevel Init ######################## */
115 #ifndef __PROGRAM_START
116 #define __PROGRAM_START __main
120 #define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
123 #ifndef __STACK_LIMIT
124 #define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
127 #ifndef __VECTOR_TABLE
128 #define __VECTOR_TABLE __Vectors
131 #ifndef __VECTOR_TABLE_ATTRIBUTE
132 #define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
135 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
137 #define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base
140 #ifndef __TZ_STACK_SEAL_SIZE
141 #define __TZ_STACK_SEAL_SIZE 8U
144 #ifndef __TZ_STACK_SEAL_VALUE
145 #define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL
149 __STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
150 *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE;
155 /* ########################### Core Function Access ########################### */
156 /** \ingroup CMSIS_Core_FunctionInterface
157 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
162 \brief Enable IRQ Interrupts
163 \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
164 Can only be executed in Privileged modes.
166 __STATIC_FORCEINLINE void __enable_irq(void)
168 __ASM volatile ("cpsie i" : : : "memory");
173 \brief Disable IRQ Interrupts
174 \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
175 Can only be executed in Privileged modes.
177 __STATIC_FORCEINLINE void __disable_irq(void)
179 __ASM volatile ("cpsid i" : : : "memory");
184 \brief Get Control Register
185 \details Returns the content of the Control Register.
186 \return Control Register value
188 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
192 __ASM volatile ("MRS %0, control" : "=r" (result) );
197 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
199 \brief Get Control Register (non-secure)
200 \details Returns the content of the non-secure Control Register when in secure mode.
201 \return non-secure Control Register value
203 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
207 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
214 \brief Set Control Register
215 \details Writes the given value to the Control Register.
216 \param [in] control Control Register value to set
218 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
220 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
224 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
226 \brief Set Control Register (non-secure)
227 \details Writes the given value to the non-secure Control Register when in secure state.
228 \param [in] control Control Register value to set
230 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
232 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
238 \brief Get IPSR Register
239 \details Returns the content of the IPSR Register.
240 \return IPSR Register value
242 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
246 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
252 \brief Get APSR Register
253 \details Returns the content of the APSR Register.
254 \return APSR Register value
256 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
260 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
266 \brief Get xPSR Register
267 \details Returns the content of the xPSR Register.
268 \return xPSR Register value
270 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
274 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
280 \brief Get Process Stack Pointer
281 \details Returns the current value of the Process Stack Pointer (PSP).
282 \return PSP Register value
284 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
288 __ASM volatile ("MRS %0, psp" : "=r" (result) );
293 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
295 \brief Get Process Stack Pointer (non-secure)
296 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
297 \return PSP Register value
299 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
303 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
310 \brief Set Process Stack Pointer
311 \details Assigns the given value to the Process Stack Pointer (PSP).
312 \param [in] topOfProcStack Process Stack Pointer value to set
314 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
316 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
320 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
322 \brief Set Process Stack Pointer (non-secure)
323 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
324 \param [in] topOfProcStack Process Stack Pointer value to set
326 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
328 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
334 \brief Get Main Stack Pointer
335 \details Returns the current value of the Main Stack Pointer (MSP).
336 \return MSP Register value
338 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
342 __ASM volatile ("MRS %0, msp" : "=r" (result) );
347 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
349 \brief Get Main Stack Pointer (non-secure)
350 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
351 \return MSP Register value
353 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
357 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
364 \brief Set Main Stack Pointer
365 \details Assigns the given value to the Main Stack Pointer (MSP).
366 \param [in] topOfMainStack Main Stack Pointer value to set
368 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
370 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
374 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
376 \brief Set Main Stack Pointer (non-secure)
377 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
378 \param [in] topOfMainStack Main Stack Pointer value to set
380 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
382 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
387 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
389 \brief Get Stack Pointer (non-secure)
390 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
391 \return SP Register value
393 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
397 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
403 \brief Set Stack Pointer (non-secure)
404 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
405 \param [in] topOfStack Stack Pointer value to set
407 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
409 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
415 \brief Get Priority Mask
416 \details Returns the current state of the priority mask bit from the Priority Mask Register.
417 \return Priority Mask value
419 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
423 __ASM volatile ("MRS %0, primask" : "=r" (result) );
428 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
430 \brief Get Priority Mask (non-secure)
431 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
432 \return Priority Mask value
434 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
438 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
445 \brief Set Priority Mask
446 \details Assigns the given value to the Priority Mask Register.
447 \param [in] priMask Priority Mask
449 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
451 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
455 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
457 \brief Set Priority Mask (non-secure)
458 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
459 \param [in] priMask Priority Mask
461 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
463 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
468 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
469 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
470 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
473 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
474 Can only be executed in Privileged modes.
476 __STATIC_FORCEINLINE void __enable_fault_irq(void)
478 __ASM volatile ("cpsie f" : : : "memory");
484 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
485 Can only be executed in Privileged modes.
487 __STATIC_FORCEINLINE void __disable_fault_irq(void)
489 __ASM volatile ("cpsid f" : : : "memory");
494 \brief Get Base Priority
495 \details Returns the current value of the Base Priority register.
496 \return Base Priority register value
498 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
502 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
507 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
509 \brief Get Base Priority (non-secure)
510 \details Returns the current value of the non-secure Base Priority register when in secure state.
511 \return Base Priority register value
513 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
517 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
524 \brief Set Base Priority
525 \details Assigns the given value to the Base Priority register.
526 \param [in] basePri Base Priority value to set
528 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
530 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
534 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
536 \brief Set Base Priority (non-secure)
537 \details Assigns the given value to the non-secure Base Priority register when in secure state.
538 \param [in] basePri Base Priority value to set
540 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
542 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
548 \brief Set Base Priority with condition
549 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
550 or the new value increases the BASEPRI priority level.
551 \param [in] basePri Base Priority value to set
553 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
555 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
560 \brief Get Fault Mask
561 \details Returns the current value of the Fault Mask register.
562 \return Fault Mask register value
564 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
568 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
573 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
575 \brief Get Fault Mask (non-secure)
576 \details Returns the current value of the non-secure Fault Mask register when in secure state.
577 \return Fault Mask register value
579 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
583 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
590 \brief Set Fault Mask
591 \details Assigns the given value to the Fault Mask register.
592 \param [in] faultMask Fault Mask value to set
594 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
596 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
600 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
602 \brief Set Fault Mask (non-secure)
603 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
604 \param [in] faultMask Fault Mask value to set
606 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
608 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
612 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
613 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
614 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
617 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
618 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
621 \brief Get Process Stack Pointer Limit
622 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
623 Stack Pointer Limit register hence zero is returned always in non-secure
626 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
627 \return PSPLIM Register value
629 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
631 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
632 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
633 // without main extensions, the non-secure PSPLIM is RAZ/WI
637 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
642 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
644 \brief Get Process Stack Pointer Limit (non-secure)
645 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
646 Stack Pointer Limit register hence zero is returned always in non-secure
649 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
650 \return PSPLIM Register value
652 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
654 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
655 // without main extensions, the non-secure PSPLIM is RAZ/WI
659 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
667 \brief Set Process Stack Pointer Limit
668 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
669 Stack Pointer Limit register hence the write is silently ignored in non-secure
672 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
673 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
675 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
677 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
678 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
679 // without main extensions, the non-secure PSPLIM is RAZ/WI
680 (void)ProcStackPtrLimit;
682 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
687 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
689 \brief Set Process Stack Pointer (non-secure)
690 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
691 Stack Pointer Limit register hence the write is silently ignored in non-secure
694 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
695 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
697 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
699 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
700 // without main extensions, the non-secure PSPLIM is RAZ/WI
701 (void)ProcStackPtrLimit;
703 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
710 \brief Get Main Stack Pointer Limit
711 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
712 Stack Pointer Limit register hence zero is returned always.
714 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
715 \return MSPLIM Register value
717 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
719 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
720 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
721 // without main extensions, the non-secure MSPLIM is RAZ/WI
725 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
731 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
733 \brief Get Main Stack Pointer Limit (non-secure)
734 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
735 Stack Pointer Limit register hence zero is returned always.
737 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
738 \return MSPLIM Register value
740 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
742 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
743 // without main extensions, the non-secure MSPLIM is RAZ/WI
747 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
755 \brief Set Main Stack Pointer Limit
756 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
757 Stack Pointer Limit register hence the write is silently ignored.
759 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
760 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
762 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
764 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
765 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
766 // without main extensions, the non-secure MSPLIM is RAZ/WI
767 (void)MainStackPtrLimit;
769 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
774 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
776 \brief Set Main Stack Pointer Limit (non-secure)
777 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
778 Stack Pointer Limit register hence the write is silently ignored.
780 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
781 \param [in] MainStackPtrLimit Main Stack Pointer value to set
783 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
785 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
786 // without main extensions, the non-secure MSPLIM is RAZ/WI
787 (void)MainStackPtrLimit;
789 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
794 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
795 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
799 \details Returns the current value of the Floating Point Status/Control register.
800 \return Floating Point Status/Control register value
802 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
803 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
804 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
806 #define __get_FPSCR() ((uint32_t)0U)
811 \details Assigns the given value to the Floating Point Status/Control register.
812 \param [in] fpscr Floating Point Status/Control value to set
814 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
815 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
816 #define __set_FPSCR __builtin_arm_set_fpscr
818 #define __set_FPSCR(x) ((void)(x))
822 /*@} end of CMSIS_Core_RegAccFunctions */
825 /* ########################## Core Instruction Access ######################### */
826 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
827 Access to dedicated instructions
831 /* Define macros for porting to both thumb1 and thumb2.
832 * For thumb1, use low register (r0-r7), specified by constraint "l"
833 * Otherwise, use general registers, specified by constraint "r" */
834 #if defined (__thumb__) && !defined (__thumb2__)
835 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
836 #define __CMSIS_GCC_USE_REG(r) "l" (r)
838 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
839 #define __CMSIS_GCC_USE_REG(r) "r" (r)
844 \details No Operation does nothing. This instruction can be used for code alignment purposes.
846 #define __NOP __builtin_arm_nop
849 \brief Wait For Interrupt
850 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
852 #define __WFI __builtin_arm_wfi
856 \brief Wait For Event
857 \details Wait For Event is a hint instruction that permits the processor to enter
858 a low-power state until one of a number of events occurs.
860 #define __WFE __builtin_arm_wfe
865 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
867 #define __SEV __builtin_arm_sev
871 \brief Instruction Synchronization Barrier
872 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
873 so that all instructions following the ISB are fetched from cache or memory,
874 after the instruction has been completed.
876 #define __ISB() __builtin_arm_isb(0xF)
879 \brief Data Synchronization Barrier
880 \details Acts as a special kind of Data Memory Barrier.
881 It completes when all explicit memory accesses before this instruction complete.
883 #define __DSB() __builtin_arm_dsb(0xF)
887 \brief Data Memory Barrier
888 \details Ensures the apparent order of the explicit memory operations before
889 and after the instruction, without ensuring their completion.
891 #define __DMB() __builtin_arm_dmb(0xF)
895 \brief Reverse byte order (32 bit)
896 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
897 \param [in] value Value to reverse
898 \return Reversed value
900 #define __REV(value) __builtin_bswap32(value)
904 \brief Reverse byte order (16 bit)
905 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
906 \param [in] value Value to reverse
907 \return Reversed value
909 #define __REV16(value) __ROR(__REV(value), 16)
913 \brief Reverse byte order (16 bit)
914 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
915 \param [in] value Value to reverse
916 \return Reversed value
918 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
922 \brief Rotate Right in unsigned value (32 bit)
923 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
924 \param [in] op1 Value to rotate
925 \param [in] op2 Number of Bits to rotate
926 \return Rotated value
928 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
935 return (op1 >> op2) | (op1 << (32U - op2));
941 \details Causes the processor to enter Debug state.
942 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
943 \param [in] value is ignored by the processor.
944 If required, a debugger can use it to store additional information about the breakpoint.
946 #define __BKPT(value) __ASM volatile ("bkpt "#value)
950 \brief Reverse bit order of value
951 \details Reverses the bit order of the given value.
952 \param [in] value Value to reverse
953 \return Reversed value
955 #define __RBIT __builtin_arm_rbit
958 \brief Count leading zeros
959 \details Counts the number of leading zeros of a data value.
960 \param [in] value Value to count the leading zeros
961 \return number of leading zeros in value
963 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
965 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
966 __builtin_clz(0) is undefined behaviour, so handle this case specially.
967 This guarantees ARM-compatible results if happening to compile on a non-ARM
968 target, and ensures the compiler doesn't decide to activate any
969 optimisations using the logic "value was passed to __builtin_clz, so it
971 ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
972 single CLZ instruction.
978 return __builtin_clz(value);
982 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
983 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
984 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
985 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
987 \brief LDR Exclusive (8 bit)
988 \details Executes a exclusive LDR instruction for 8 bit value.
989 \param [in] ptr Pointer to data
990 \return value of type uint8_t at (*ptr)
992 #define __LDREXB (uint8_t)__builtin_arm_ldrex
996 \brief LDR Exclusive (16 bit)
997 \details Executes a exclusive LDR instruction for 16 bit values.
998 \param [in] ptr Pointer to data
999 \return value of type uint16_t at (*ptr)
1001 #define __LDREXH (uint16_t)__builtin_arm_ldrex
1005 \brief LDR Exclusive (32 bit)
1006 \details Executes a exclusive LDR instruction for 32 bit values.
1007 \param [in] ptr Pointer to data
1008 \return value of type uint32_t at (*ptr)
1010 #define __LDREXW (uint32_t)__builtin_arm_ldrex
1014 \brief STR Exclusive (8 bit)
1015 \details Executes a exclusive STR instruction for 8 bit values.
1016 \param [in] value Value to store
1017 \param [in] ptr Pointer to location
1018 \return 0 Function succeeded
1019 \return 1 Function failed
1021 #define __STREXB (uint32_t)__builtin_arm_strex
1025 \brief STR Exclusive (16 bit)
1026 \details Executes a exclusive STR instruction for 16 bit values.
1027 \param [in] value Value to store
1028 \param [in] ptr Pointer to location
1029 \return 0 Function succeeded
1030 \return 1 Function failed
1032 #define __STREXH (uint32_t)__builtin_arm_strex
1036 \brief STR Exclusive (32 bit)
1037 \details Executes a exclusive STR instruction for 32 bit values.
1038 \param [in] value Value to store
1039 \param [in] ptr Pointer to location
1040 \return 0 Function succeeded
1041 \return 1 Function failed
1043 #define __STREXW (uint32_t)__builtin_arm_strex
1047 \brief Remove the exclusive lock
1048 \details Removes the exclusive lock which is created by LDREX.
1050 #define __CLREX __builtin_arm_clrex
1052 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1053 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1054 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1055 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1058 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1059 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1060 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1063 \brief Signed Saturate
1064 \details Saturates a signed value.
1065 \param [in] value Value to be saturated
1066 \param [in] sat Bit position to saturate to (1..32)
1067 \return Saturated value
1069 #define __SSAT __builtin_arm_ssat
1073 \brief Unsigned Saturate
1074 \details Saturates an unsigned value.
1075 \param [in] value Value to be saturated
1076 \param [in] sat Bit position to saturate to (0..31)
1077 \return Saturated value
1079 #define __USAT __builtin_arm_usat
1083 \brief Rotate Right with Extend (32 bit)
1084 \details Moves each bit of a bitstring right by one bit.
1085 The carry input is shifted in at the left end of the bitstring.
1086 \param [in] value Value to rotate
1087 \return Rotated value
1089 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
1093 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1099 \brief LDRT Unprivileged (8 bit)
1100 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1101 \param [in] ptr Pointer to data
1102 \return value of type uint8_t at (*ptr)
1104 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1108 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1109 return ((uint8_t) result); /* Add explicit type cast here */
1114 \brief LDRT Unprivileged (16 bit)
1115 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1116 \param [in] ptr Pointer to data
1117 \return value of type uint16_t at (*ptr)
1119 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1123 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1124 return ((uint16_t) result); /* Add explicit type cast here */
1129 \brief LDRT Unprivileged (32 bit)
1130 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1131 \param [in] ptr Pointer to data
1132 \return value of type uint32_t at (*ptr)
1134 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1138 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1144 \brief STRT Unprivileged (8 bit)
1145 \details Executes a Unprivileged STRT instruction for 8 bit values.
1146 \param [in] value Value to store
1147 \param [in] ptr Pointer to location
1149 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1151 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1156 \brief STRT Unprivileged (16 bit)
1157 \details Executes a Unprivileged STRT instruction for 16 bit values.
1158 \param [in] value Value to store
1159 \param [in] ptr Pointer to location
1161 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1163 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1168 \brief STRT Unprivileged (32 bit)
1169 \details Executes a Unprivileged STRT instruction for 32 bit values.
1170 \param [in] value Value to store
1171 \param [in] ptr Pointer to location
1173 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1175 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1178 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1179 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1180 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1183 \brief Signed Saturate
1184 \details Saturates a signed value.
1185 \param [in] value Value to be saturated
1186 \param [in] sat Bit position to saturate to (1..32)
1187 \return Saturated value
1189 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1191 if ((sat >= 1U) && (sat <= 32U))
1193 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1194 const int32_t min = -1 - max ;
1208 \brief Unsigned Saturate
1209 \details Saturates an unsigned value.
1210 \param [in] value Value to be saturated
1211 \param [in] sat Bit position to saturate to (0..31)
1212 \return Saturated value
1214 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1218 const uint32_t max = ((1U << sat) - 1U);
1219 if (val > (int32_t)max)
1228 return (uint32_t)val;
1231 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1232 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1233 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1236 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1237 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1239 \brief Load-Acquire (8 bit)
1240 \details Executes a LDAB instruction for 8 bit value.
1241 \param [in] ptr Pointer to data
1242 \return value of type uint8_t at (*ptr)
1244 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1248 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1249 return ((uint8_t) result);
1254 \brief Load-Acquire (16 bit)
1255 \details Executes a LDAH instruction for 16 bit values.
1256 \param [in] ptr Pointer to data
1257 \return value of type uint16_t at (*ptr)
1259 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1263 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1264 return ((uint16_t) result);
1269 \brief Load-Acquire (32 bit)
1270 \details Executes a LDA instruction for 32 bit values.
1271 \param [in] ptr Pointer to data
1272 \return value of type uint32_t at (*ptr)
1274 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1278 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1284 \brief Store-Release (8 bit)
1285 \details Executes a STLB instruction for 8 bit values.
1286 \param [in] value Value to store
1287 \param [in] ptr Pointer to location
1289 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1291 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1296 \brief Store-Release (16 bit)
1297 \details Executes a STLH instruction for 16 bit values.
1298 \param [in] value Value to store
1299 \param [in] ptr Pointer to location
1301 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1303 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1308 \brief Store-Release (32 bit)
1309 \details Executes a STL instruction for 32 bit values.
1310 \param [in] value Value to store
1311 \param [in] ptr Pointer to location
1313 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1315 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1320 \brief Load-Acquire Exclusive (8 bit)
1321 \details Executes a LDAB exclusive instruction for 8 bit value.
1322 \param [in] ptr Pointer to data
1323 \return value of type uint8_t at (*ptr)
1325 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1329 \brief Load-Acquire Exclusive (16 bit)
1330 \details Executes a LDAH exclusive instruction for 16 bit values.
1331 \param [in] ptr Pointer to data
1332 \return value of type uint16_t at (*ptr)
1334 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1338 \brief Load-Acquire Exclusive (32 bit)
1339 \details Executes a LDA exclusive instruction for 32 bit values.
1340 \param [in] ptr Pointer to data
1341 \return value of type uint32_t at (*ptr)
1343 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1347 \brief Store-Release Exclusive (8 bit)
1348 \details Executes a STLB exclusive instruction for 8 bit values.
1349 \param [in] value Value to store
1350 \param [in] ptr Pointer to location
1351 \return 0 Function succeeded
1352 \return 1 Function failed
1354 #define __STLEXB (uint32_t)__builtin_arm_stlex
1358 \brief Store-Release Exclusive (16 bit)
1359 \details Executes a STLH exclusive instruction for 16 bit values.
1360 \param [in] value Value to store
1361 \param [in] ptr Pointer to location
1362 \return 0 Function succeeded
1363 \return 1 Function failed
1365 #define __STLEXH (uint32_t)__builtin_arm_stlex
1369 \brief Store-Release Exclusive (32 bit)
1370 \details Executes a STL exclusive instruction for 32 bit values.
1371 \param [in] value Value to store
1372 \param [in] ptr Pointer to location
1373 \return 0 Function succeeded
1374 \return 1 Function failed
1376 #define __STLEX (uint32_t)__builtin_arm_stlex
1378 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1379 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1381 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1384 /* ################### Compiler specific Intrinsics ########################### */
1385 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1386 Access to dedicated SIMD instructions
1390 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1392 __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1396 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1400 __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1404 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1408 __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1412 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1416 __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1420 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1424 __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1428 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1432 __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1436 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441 __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1445 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1449 __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1453 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1457 __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1461 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1465 __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1469 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1473 __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1477 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1481 __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1485 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1490 __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1494 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1498 __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1502 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1506 __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1510 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1514 __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1518 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1522 __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1526 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1530 __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1534 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1538 __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1542 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1546 __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1550 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1554 __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1558 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1562 __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1566 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1570 __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1574 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1578 __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1582 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1586 __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1590 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1594 __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1598 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1602 __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1606 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1610 __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1614 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1618 __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1622 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1626 __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1630 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1634 __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1638 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1642 __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1646 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1650 __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1654 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1658 __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1662 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1666 __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1670 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1674 __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1678 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1682 __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1686 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1690 __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1694 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1698 #define __SSAT16(ARG1,ARG2) \
1700 int32_t __RES, __ARG1 = (ARG1); \
1701 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1705 #define __USAT16(ARG1,ARG2) \
1707 uint32_t __RES, __ARG1 = (ARG1); \
1708 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1712 __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1)
1716 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1720 __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1724 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1728 __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1)
1732 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1736 __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1740 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1744 __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1748 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1752 __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1756 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1760 __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1764 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1768 __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1772 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1776 __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1784 #ifndef __ARMEB__ /* Little endian */
1785 __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]) );
1786 #else /* Big endian */
1787 __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]) );
1793 __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1801 #ifndef __ARMEB__ /* Little endian */
1802 __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]) );
1803 #else /* Big endian */
1804 __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]) );
1810 __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1814 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1818 __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1822 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1826 __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1830 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1834 __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1838 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1842 __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1850 #ifndef __ARMEB__ /* Little endian */
1851 __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]) );
1852 #else /* Big endian */
1853 __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]) );
1859 __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1867 #ifndef __ARMEB__ /* Little endian */
1868 __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]) );
1869 #else /* Big endian */
1870 __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]) );
1876 __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1880 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1884 __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2)
1888 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1892 __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2)
1896 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1900 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1901 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1903 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1904 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1906 #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
1908 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1910 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1914 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1918 #endif /* (__ARM_FEATURE_DSP == 1) */
1919 /*@} end of group CMSIS_SIMD_intrinsics */
1922 #endif /* __CMSIS_ARMCLANG_H */