1 /**************************************************************************//**
2 * @file cmsis_armclang.h
3 * @brief CMSIS compiler armclang (Arm Compiler 6) header file
6 ******************************************************************************/
8 * Copyright (c) 2009-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)) || \
471 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
474 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
475 Can only be executed in Privileged modes.
477 __STATIC_FORCEINLINE void __enable_fault_irq(void)
479 __ASM volatile ("cpsie f" : : : "memory");
485 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
486 Can only be executed in Privileged modes.
488 __STATIC_FORCEINLINE void __disable_fault_irq(void)
490 __ASM volatile ("cpsid f" : : : "memory");
495 \brief Get Base Priority
496 \details Returns the current value of the Base Priority register.
497 \return Base Priority register value
499 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
503 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
508 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
510 \brief Get Base Priority (non-secure)
511 \details Returns the current value of the non-secure Base Priority register when in secure state.
512 \return Base Priority register value
514 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
518 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
525 \brief Set Base Priority
526 \details Assigns the given value to the Base Priority register.
527 \param [in] basePri Base Priority value to set
529 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
531 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
535 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
537 \brief Set Base Priority (non-secure)
538 \details Assigns the given value to the non-secure Base Priority register when in secure state.
539 \param [in] basePri Base Priority value to set
541 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
543 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
549 \brief Set Base Priority with condition
550 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
551 or the new value increases the BASEPRI priority level.
552 \param [in] basePri Base Priority value to set
554 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
556 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
561 \brief Get Fault Mask
562 \details Returns the current value of the Fault Mask register.
563 \return Fault Mask register value
565 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
569 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
574 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
576 \brief Get Fault Mask (non-secure)
577 \details Returns the current value of the non-secure Fault Mask register when in secure state.
578 \return Fault Mask register value
580 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
584 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
591 \brief Set Fault Mask
592 \details Assigns the given value to the Fault Mask register.
593 \param [in] faultMask Fault Mask value to set
595 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
597 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
601 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
603 \brief Set Fault Mask (non-secure)
604 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
605 \param [in] faultMask Fault Mask value to set
607 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
609 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
613 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
614 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
615 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
616 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
619 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
620 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
621 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
624 \brief Get Process Stack Pointer Limit
625 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
626 Stack Pointer Limit register hence zero is returned always in non-secure
629 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
630 \return PSPLIM Register value
632 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
634 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
635 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
636 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
637 // without main extensions, the non-secure PSPLIM is RAZ/WI
641 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
646 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
648 \brief Get Process Stack Pointer Limit (non-secure)
649 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
650 Stack Pointer Limit register hence zero is returned always in non-secure
653 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
654 \return PSPLIM Register value
656 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
658 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
659 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
660 // without main extensions, the non-secure PSPLIM is RAZ/WI
664 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
672 \brief Set Process Stack Pointer Limit
673 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
674 Stack Pointer Limit register hence the write is silently ignored in non-secure
677 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
678 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
680 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
682 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
683 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
684 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
685 // without main extensions, the non-secure PSPLIM is RAZ/WI
686 (void)ProcStackPtrLimit;
688 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
693 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
695 \brief Set Process Stack Pointer (non-secure)
696 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
697 Stack Pointer Limit register hence the write is silently ignored in non-secure
700 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
701 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
703 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
705 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
706 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
707 // without main extensions, the non-secure PSPLIM is RAZ/WI
708 (void)ProcStackPtrLimit;
710 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
717 \brief Get Main Stack Pointer Limit
718 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
719 Stack Pointer Limit register hence zero is returned always.
721 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
722 \return MSPLIM Register value
724 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
726 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
727 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
728 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
729 // without main extensions, the non-secure MSPLIM is RAZ/WI
733 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
739 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
741 \brief Get Main Stack Pointer Limit (non-secure)
742 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
743 Stack Pointer Limit register hence zero is returned always.
745 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
746 \return MSPLIM Register value
748 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
750 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
751 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
752 // without main extensions, the non-secure MSPLIM is RAZ/WI
756 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
764 \brief Set Main Stack Pointer Limit
765 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
766 Stack Pointer Limit register hence the write is silently ignored.
768 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
769 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
771 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
773 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
774 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
775 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
776 // without main extensions, the non-secure MSPLIM is RAZ/WI
777 (void)MainStackPtrLimit;
779 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
784 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
786 \brief Set Main Stack Pointer Limit (non-secure)
787 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
788 Stack Pointer Limit register hence the write is silently ignored.
790 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
791 \param [in] MainStackPtrLimit Main Stack Pointer value to set
793 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
795 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
796 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
797 // without main extensions, the non-secure MSPLIM is RAZ/WI
798 (void)MainStackPtrLimit;
800 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
805 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
806 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
807 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
811 \details Returns the current value of the Floating Point Status/Control register.
812 \return Floating Point Status/Control register value
814 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
815 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
816 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
818 #define __get_FPSCR() ((uint32_t)0U)
823 \details Assigns the given value to the Floating Point Status/Control register.
824 \param [in] fpscr Floating Point Status/Control value to set
826 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
827 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
828 #define __set_FPSCR __builtin_arm_set_fpscr
830 #define __set_FPSCR(x) ((void)(x))
834 /*@} end of CMSIS_Core_RegAccFunctions */
837 /* ########################## Core Instruction Access ######################### */
838 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
839 Access to dedicated instructions
843 /* Define macros for porting to both thumb1 and thumb2.
844 * For thumb1, use low register (r0-r7), specified by constraint "l"
845 * Otherwise, use general registers, specified by constraint "r" */
846 #if defined (__thumb__) && !defined (__thumb2__)
847 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
848 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
849 #define __CMSIS_GCC_USE_REG(r) "l" (r)
851 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
852 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
853 #define __CMSIS_GCC_USE_REG(r) "r" (r)
858 \details No Operation does nothing. This instruction can be used for code alignment purposes.
860 #define __NOP __builtin_arm_nop
863 \brief Wait For Interrupt
864 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
866 #define __WFI __builtin_arm_wfi
870 \brief Wait For Event
871 \details Wait For Event is a hint instruction that permits the processor to enter
872 a low-power state until one of a number of events occurs.
874 #define __WFE __builtin_arm_wfe
879 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
881 #define __SEV __builtin_arm_sev
885 \brief Instruction Synchronization Barrier
886 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
887 so that all instructions following the ISB are fetched from cache or memory,
888 after the instruction has been completed.
890 #define __ISB() __builtin_arm_isb(0xF)
893 \brief Data Synchronization Barrier
894 \details Acts as a special kind of Data Memory Barrier.
895 It completes when all explicit memory accesses before this instruction complete.
897 #define __DSB() __builtin_arm_dsb(0xF)
901 \brief Data Memory Barrier
902 \details Ensures the apparent order of the explicit memory operations before
903 and after the instruction, without ensuring their completion.
905 #define __DMB() __builtin_arm_dmb(0xF)
909 \brief Reverse byte order (32 bit)
910 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
911 \param [in] value Value to reverse
912 \return Reversed value
914 #define __REV(value) __builtin_bswap32(value)
918 \brief Reverse byte order (16 bit)
919 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
920 \param [in] value Value to reverse
921 \return Reversed value
923 #define __REV16(value) __ROR(__REV(value), 16)
927 \brief Reverse byte order (16 bit)
928 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
929 \param [in] value Value to reverse
930 \return Reversed value
932 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
936 \brief Rotate Right in unsigned value (32 bit)
937 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
938 \param [in] op1 Value to rotate
939 \param [in] op2 Number of Bits to rotate
940 \return Rotated value
942 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
949 return (op1 >> op2) | (op1 << (32U - op2));
955 \details Causes the processor to enter Debug state.
956 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
957 \param [in] value is ignored by the processor.
958 If required, a debugger can use it to store additional information about the breakpoint.
960 #define __BKPT(value) __ASM volatile ("bkpt "#value)
964 \brief Reverse bit order of value
965 \details Reverses the bit order of the given value.
966 \param [in] value Value to reverse
967 \return Reversed value
969 #define __RBIT __builtin_arm_rbit
972 \brief Count leading zeros
973 \details Counts the number of leading zeros of a data value.
974 \param [in] value Value to count the leading zeros
975 \return number of leading zeros in value
977 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
979 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
980 __builtin_clz(0) is undefined behaviour, so handle this case specially.
981 This guarantees ARM-compatible results if happening to compile on a non-ARM
982 target, and ensures the compiler doesn't decide to activate any
983 optimisations using the logic "value was passed to __builtin_clz, so it
985 ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
986 single CLZ instruction.
992 return __builtin_clz(value);
996 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
997 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
998 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
999 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1000 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1003 \brief LDR Exclusive (8 bit)
1004 \details Executes a exclusive LDR instruction for 8 bit value.
1005 \param [in] ptr Pointer to data
1006 \return value of type uint8_t at (*ptr)
1008 #define __LDREXB (uint8_t)__builtin_arm_ldrex
1012 \brief LDR Exclusive (16 bit)
1013 \details Executes a exclusive LDR instruction for 16 bit values.
1014 \param [in] ptr Pointer to data
1015 \return value of type uint16_t at (*ptr)
1017 #define __LDREXH (uint16_t)__builtin_arm_ldrex
1021 \brief LDR Exclusive (32 bit)
1022 \details Executes a exclusive LDR instruction for 32 bit values.
1023 \param [in] ptr Pointer to data
1024 \return value of type uint32_t at (*ptr)
1026 #define __LDREXW (uint32_t)__builtin_arm_ldrex
1030 \brief STR Exclusive (8 bit)
1031 \details Executes a exclusive STR instruction for 8 bit values.
1032 \param [in] value Value to store
1033 \param [in] ptr Pointer to location
1034 \return 0 Function succeeded
1035 \return 1 Function failed
1037 #define __STREXB (uint32_t)__builtin_arm_strex
1041 \brief STR Exclusive (16 bit)
1042 \details Executes a exclusive STR instruction for 16 bit values.
1043 \param [in] value Value to store
1044 \param [in] ptr Pointer to location
1045 \return 0 Function succeeded
1046 \return 1 Function failed
1048 #define __STREXH (uint32_t)__builtin_arm_strex
1052 \brief STR Exclusive (32 bit)
1053 \details Executes a exclusive STR instruction for 32 bit values.
1054 \param [in] value Value to store
1055 \param [in] ptr Pointer to location
1056 \return 0 Function succeeded
1057 \return 1 Function failed
1059 #define __STREXW (uint32_t)__builtin_arm_strex
1063 \brief Remove the exclusive lock
1064 \details Removes the exclusive lock which is created by LDREX.
1066 #define __CLREX __builtin_arm_clrex
1068 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1069 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1070 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1071 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1072 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1075 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1076 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1077 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1078 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1081 \brief Signed Saturate
1082 \details Saturates a signed value.
1083 \param [in] value Value to be saturated
1084 \param [in] sat Bit position to saturate to (1..32)
1085 \return Saturated value
1087 #define __SSAT __builtin_arm_ssat
1091 \brief Unsigned Saturate
1092 \details Saturates an unsigned value.
1093 \param [in] value Value to be saturated
1094 \param [in] sat Bit position to saturate to (0..31)
1095 \return Saturated value
1097 #define __USAT __builtin_arm_usat
1101 \brief Rotate Right with Extend (32 bit)
1102 \details Moves each bit of a bitstring right by one bit.
1103 The carry input is shifted in at the left end of the bitstring.
1104 \param [in] value Value to rotate
1105 \return Rotated value
1107 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
1111 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1117 \brief LDRT Unprivileged (8 bit)
1118 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1119 \param [in] ptr Pointer to data
1120 \return value of type uint8_t at (*ptr)
1122 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1126 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1127 return ((uint8_t) result); /* Add explicit type cast here */
1132 \brief LDRT Unprivileged (16 bit)
1133 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1134 \param [in] ptr Pointer to data
1135 \return value of type uint16_t at (*ptr)
1137 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1141 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1142 return ((uint16_t) result); /* Add explicit type cast here */
1147 \brief LDRT Unprivileged (32 bit)
1148 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1149 \param [in] ptr Pointer to data
1150 \return value of type uint32_t at (*ptr)
1152 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1156 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1162 \brief STRT Unprivileged (8 bit)
1163 \details Executes a Unprivileged STRT instruction for 8 bit values.
1164 \param [in] value Value to store
1165 \param [in] ptr Pointer to location
1167 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1169 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1174 \brief STRT Unprivileged (16 bit)
1175 \details Executes a Unprivileged STRT instruction for 16 bit values.
1176 \param [in] value Value to store
1177 \param [in] ptr Pointer to location
1179 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1181 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1186 \brief STRT Unprivileged (32 bit)
1187 \details Executes a Unprivileged STRT instruction for 32 bit values.
1188 \param [in] value Value to store
1189 \param [in] ptr Pointer to location
1191 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1193 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1196 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1197 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1198 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1199 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1202 \brief Signed Saturate
1203 \details Saturates a signed value.
1204 \param [in] value Value to be saturated
1205 \param [in] sat Bit position to saturate to (1..32)
1206 \return Saturated value
1208 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1210 if ((sat >= 1U) && (sat <= 32U))
1212 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1213 const int32_t min = -1 - max ;
1227 \brief Unsigned Saturate
1228 \details Saturates an unsigned value.
1229 \param [in] value Value to be saturated
1230 \param [in] sat Bit position to saturate to (0..31)
1231 \return Saturated value
1233 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1237 const uint32_t max = ((1U << sat) - 1U);
1238 if (val > (int32_t)max)
1247 return (uint32_t)val;
1250 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1251 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1252 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1253 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1256 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1257 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1258 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1261 \brief Load-Acquire (8 bit)
1262 \details Executes a LDAB instruction for 8 bit value.
1263 \param [in] ptr Pointer to data
1264 \return value of type uint8_t at (*ptr)
1266 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1270 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1271 return ((uint8_t) result);
1276 \brief Load-Acquire (16 bit)
1277 \details Executes a LDAH instruction for 16 bit values.
1278 \param [in] ptr Pointer to data
1279 \return value of type uint16_t at (*ptr)
1281 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1285 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1286 return ((uint16_t) result);
1291 \brief Load-Acquire (32 bit)
1292 \details Executes a LDA instruction for 32 bit values.
1293 \param [in] ptr Pointer to data
1294 \return value of type uint32_t at (*ptr)
1296 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1300 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1306 \brief Store-Release (8 bit)
1307 \details Executes a STLB instruction for 8 bit values.
1308 \param [in] value Value to store
1309 \param [in] ptr Pointer to location
1311 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1313 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1318 \brief Store-Release (16 bit)
1319 \details Executes a STLH instruction for 16 bit values.
1320 \param [in] value Value to store
1321 \param [in] ptr Pointer to location
1323 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1325 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1330 \brief Store-Release (32 bit)
1331 \details Executes a STL instruction for 32 bit values.
1332 \param [in] value Value to store
1333 \param [in] ptr Pointer to location
1335 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1337 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1342 \brief Load-Acquire Exclusive (8 bit)
1343 \details Executes a LDAB exclusive instruction for 8 bit value.
1344 \param [in] ptr Pointer to data
1345 \return value of type uint8_t at (*ptr)
1347 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1351 \brief Load-Acquire Exclusive (16 bit)
1352 \details Executes a LDAH exclusive instruction for 16 bit values.
1353 \param [in] ptr Pointer to data
1354 \return value of type uint16_t at (*ptr)
1356 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1360 \brief Load-Acquire Exclusive (32 bit)
1361 \details Executes a LDA exclusive instruction for 32 bit values.
1362 \param [in] ptr Pointer to data
1363 \return value of type uint32_t at (*ptr)
1365 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1369 \brief Store-Release Exclusive (8 bit)
1370 \details Executes a STLB exclusive instruction for 8 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 __STLEXB (uint32_t)__builtin_arm_stlex
1380 \brief Store-Release Exclusive (16 bit)
1381 \details Executes a STLH exclusive instruction for 16 bit values.
1382 \param [in] value Value to store
1383 \param [in] ptr Pointer to location
1384 \return 0 Function succeeded
1385 \return 1 Function failed
1387 #define __STLEXH (uint32_t)__builtin_arm_stlex
1391 \brief Store-Release Exclusive (32 bit)
1392 \details Executes a STL exclusive instruction for 32 bit values.
1393 \param [in] value Value to store
1394 \param [in] ptr Pointer to location
1395 \return 0 Function succeeded
1396 \return 1 Function failed
1398 #define __STLEX (uint32_t)__builtin_arm_stlex
1400 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1401 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1402 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1404 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1407 /* ################### Compiler specific Intrinsics ########################### */
1408 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1409 Access to dedicated SIMD instructions
1413 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1415 #define __SADD8 __builtin_arm_sadd8
1416 #define __QADD8 __builtin_arm_qadd8
1417 #define __SHADD8 __builtin_arm_shadd8
1418 #define __UADD8 __builtin_arm_uadd8
1419 #define __UQADD8 __builtin_arm_uqadd8
1420 #define __UHADD8 __builtin_arm_uhadd8
1421 #define __SSUB8 __builtin_arm_ssub8
1422 #define __QSUB8 __builtin_arm_qsub8
1423 #define __SHSUB8 __builtin_arm_shsub8
1424 #define __USUB8 __builtin_arm_usub8
1425 #define __UQSUB8 __builtin_arm_uqsub8
1426 #define __UHSUB8 __builtin_arm_uhsub8
1427 #define __SADD16 __builtin_arm_sadd16
1428 #define __QADD16 __builtin_arm_qadd16
1429 #define __SHADD16 __builtin_arm_shadd16
1430 #define __UADD16 __builtin_arm_uadd16
1431 #define __UQADD16 __builtin_arm_uqadd16
1432 #define __UHADD16 __builtin_arm_uhadd16
1433 #define __SSUB16 __builtin_arm_ssub16
1434 #define __QSUB16 __builtin_arm_qsub16
1435 #define __SHSUB16 __builtin_arm_shsub16
1436 #define __USUB16 __builtin_arm_usub16
1437 #define __UQSUB16 __builtin_arm_uqsub16
1438 #define __UHSUB16 __builtin_arm_uhsub16
1439 #define __SASX __builtin_arm_sasx
1440 #define __QASX __builtin_arm_qasx
1441 #define __SHASX __builtin_arm_shasx
1442 #define __UASX __builtin_arm_uasx
1443 #define __UQASX __builtin_arm_uqasx
1444 #define __UHASX __builtin_arm_uhasx
1445 #define __SSAX __builtin_arm_ssax
1446 #define __QSAX __builtin_arm_qsax
1447 #define __SHSAX __builtin_arm_shsax
1448 #define __USAX __builtin_arm_usax
1449 #define __UQSAX __builtin_arm_uqsax
1450 #define __UHSAX __builtin_arm_uhsax
1451 #define __USAD8 __builtin_arm_usad8
1452 #define __USADA8 __builtin_arm_usada8
1453 #define __SSAT16 __builtin_arm_ssat16
1454 #define __USAT16 __builtin_arm_usat16
1455 #define __UXTB16 __builtin_arm_uxtb16
1456 #define __UXTAB16 __builtin_arm_uxtab16
1457 #define __SXTB16 __builtin_arm_sxtb16
1458 #define __SXTAB16 __builtin_arm_sxtab16
1459 #define __SMUAD __builtin_arm_smuad
1460 #define __SMUADX __builtin_arm_smuadx
1461 #define __SMLAD __builtin_arm_smlad
1462 #define __SMLADX __builtin_arm_smladx
1463 #define __SMLALD __builtin_arm_smlald
1464 #define __SMLALDX __builtin_arm_smlaldx
1465 #define __SMUSD __builtin_arm_smusd
1466 #define __SMUSDX __builtin_arm_smusdx
1467 #define __SMLSD __builtin_arm_smlsd
1468 #define __SMLSDX __builtin_arm_smlsdx
1469 #define __SMLSLD __builtin_arm_smlsld
1470 #define __SMLSLDX __builtin_arm_smlsldx
1471 #define __SEL __builtin_arm_sel
1472 #define __QADD __builtin_arm_qadd
1473 #define __QSUB __builtin_arm_qsub
1475 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1476 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1478 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1479 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1481 #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
1483 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1485 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1489 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1493 #endif /* (__ARM_FEATURE_DSP == 1) */
1494 /*@} end of group CMSIS_SIMD_intrinsics */
1497 #endif /* __CMSIS_ARMCLANG_H */