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 Instruction Access ######################### */
156 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
157 Access to dedicated instructions
161 /* Define macros for porting to both thumb1 and thumb2.
162 * For thumb1, use low register (r0-r7), specified by constraint "l"
163 * Otherwise, use general registers, specified by constraint "r" */
164 #if defined (__thumb__) && !defined (__thumb2__)
165 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
166 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
167 #define __CMSIS_GCC_USE_REG(r) "l" (r)
169 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
170 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
171 #define __CMSIS_GCC_USE_REG(r) "r" (r)
176 \details No Operation does nothing. This instruction can be used for code alignment purposes.
178 #define __NOP __builtin_arm_nop
181 \brief Wait For Interrupt
182 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
184 #define __WFI __builtin_arm_wfi
188 \brief Wait For Event
189 \details Wait For Event is a hint instruction that permits the processor to enter
190 a low-power state until one of a number of events occurs.
192 #define __WFE __builtin_arm_wfe
197 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
199 #define __SEV __builtin_arm_sev
203 \brief Instruction Synchronization Barrier
204 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
205 so that all instructions following the ISB are fetched from cache or memory,
206 after the instruction has been completed.
208 #define __ISB() __builtin_arm_isb(0xF)
211 \brief Data Synchronization Barrier
212 \details Acts as a special kind of Data Memory Barrier.
213 It completes when all explicit memory accesses before this instruction complete.
215 #define __DSB() __builtin_arm_dsb(0xF)
219 \brief Data Memory Barrier
220 \details Ensures the apparent order of the explicit memory operations before
221 and after the instruction, without ensuring their completion.
223 #define __DMB() __builtin_arm_dmb(0xF)
227 \brief Reverse byte order (32 bit)
228 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
229 \param [in] value Value to reverse
230 \return Reversed value
232 #define __REV(value) __builtin_bswap32(value)
236 \brief Reverse byte order (16 bit)
237 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
238 \param [in] value Value to reverse
239 \return Reversed value
241 #define __REV16(value) __ROR(__REV(value), 16)
245 \brief Reverse byte order (16 bit)
246 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
247 \param [in] value Value to reverse
248 \return Reversed value
250 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
254 \brief Rotate Right in unsigned value (32 bit)
255 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
256 \param [in] op1 Value to rotate
257 \param [in] op2 Number of Bits to rotate
258 \return Rotated value
260 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
267 return (op1 >> op2) | (op1 << (32U - op2));
273 \details Causes the processor to enter Debug state.
274 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
275 \param [in] value is ignored by the processor.
276 If required, a debugger can use it to store additional information about the breakpoint.
278 #define __BKPT(value) __ASM volatile ("bkpt "#value)
282 \brief Reverse bit order of value
283 \details Reverses the bit order of the given value.
284 \param [in] value Value to reverse
285 \return Reversed value
287 #define __RBIT __builtin_arm_rbit
290 \brief Count leading zeros
291 \details Counts the number of leading zeros of a data value.
292 \param [in] value Value to count the leading zeros
293 \return number of leading zeros in value
295 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
297 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
298 __builtin_clz(0) is undefined behaviour, so handle this case specially.
299 This guarantees ARM-compatible results if happening to compile on a non-ARM
300 target, and ensures the compiler doesn't decide to activate any
301 optimisations using the logic "value was passed to __builtin_clz, so it
303 ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
304 single CLZ instruction.
310 return __builtin_clz(value);
314 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
315 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
316 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
317 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
318 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
321 \brief LDR Exclusive (8 bit)
322 \details Executes a exclusive LDR instruction for 8 bit value.
323 \param [in] ptr Pointer to data
324 \return value of type uint8_t at (*ptr)
326 #define __LDREXB (uint8_t)__builtin_arm_ldrex
330 \brief LDR Exclusive (16 bit)
331 \details Executes a exclusive LDR instruction for 16 bit values.
332 \param [in] ptr Pointer to data
333 \return value of type uint16_t at (*ptr)
335 #define __LDREXH (uint16_t)__builtin_arm_ldrex
339 \brief LDR Exclusive (32 bit)
340 \details Executes a exclusive LDR instruction for 32 bit values.
341 \param [in] ptr Pointer to data
342 \return value of type uint32_t at (*ptr)
344 #define __LDREXW (uint32_t)__builtin_arm_ldrex
348 \brief STR Exclusive (8 bit)
349 \details Executes a exclusive STR instruction for 8 bit values.
350 \param [in] value Value to store
351 \param [in] ptr Pointer to location
352 \return 0 Function succeeded
353 \return 1 Function failed
355 #define __STREXB (uint32_t)__builtin_arm_strex
359 \brief STR Exclusive (16 bit)
360 \details Executes a exclusive STR instruction for 16 bit values.
361 \param [in] value Value to store
362 \param [in] ptr Pointer to location
363 \return 0 Function succeeded
364 \return 1 Function failed
366 #define __STREXH (uint32_t)__builtin_arm_strex
370 \brief STR Exclusive (32 bit)
371 \details Executes a exclusive STR instruction for 32 bit values.
372 \param [in] value Value to store
373 \param [in] ptr Pointer to location
374 \return 0 Function succeeded
375 \return 1 Function failed
377 #define __STREXW (uint32_t)__builtin_arm_strex
381 \brief Remove the exclusive lock
382 \details Removes the exclusive lock which is created by LDREX.
384 #define __CLREX __builtin_arm_clrex
386 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
387 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
388 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
389 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
390 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
393 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
394 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
395 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
396 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
399 \brief Signed Saturate
400 \details Saturates a signed value.
401 \param [in] value Value to be saturated
402 \param [in] sat Bit position to saturate to (1..32)
403 \return Saturated value
405 #define __SSAT __builtin_arm_ssat
409 \brief Unsigned Saturate
410 \details Saturates an unsigned value.
411 \param [in] value Value to be saturated
412 \param [in] sat Bit position to saturate to (0..31)
413 \return Saturated value
415 #define __USAT __builtin_arm_usat
419 \brief Rotate Right with Extend (32 bit)
420 \details Moves each bit of a bitstring right by one bit.
421 The carry input is shifted in at the left end of the bitstring.
422 \param [in] value Value to rotate
423 \return Rotated value
425 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
429 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
435 \brief LDRT Unprivileged (8 bit)
436 \details Executes a Unprivileged LDRT instruction for 8 bit value.
437 \param [in] ptr Pointer to data
438 \return value of type uint8_t at (*ptr)
440 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
444 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
445 return ((uint8_t) result); /* Add explicit type cast here */
450 \brief LDRT Unprivileged (16 bit)
451 \details Executes a Unprivileged LDRT instruction for 16 bit values.
452 \param [in] ptr Pointer to data
453 \return value of type uint16_t at (*ptr)
455 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
459 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
460 return ((uint16_t) result); /* Add explicit type cast here */
465 \brief LDRT Unprivileged (32 bit)
466 \details Executes a Unprivileged LDRT instruction for 32 bit values.
467 \param [in] ptr Pointer to data
468 \return value of type uint32_t at (*ptr)
470 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
474 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
480 \brief STRT Unprivileged (8 bit)
481 \details Executes a Unprivileged STRT instruction for 8 bit values.
482 \param [in] value Value to store
483 \param [in] ptr Pointer to location
485 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
487 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
492 \brief STRT Unprivileged (16 bit)
493 \details Executes a Unprivileged STRT instruction for 16 bit values.
494 \param [in] value Value to store
495 \param [in] ptr Pointer to location
497 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
499 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
504 \brief STRT Unprivileged (32 bit)
505 \details Executes a Unprivileged STRT instruction for 32 bit values.
506 \param [in] value Value to store
507 \param [in] ptr Pointer to location
509 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
511 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
514 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
515 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
516 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
517 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
520 \brief Signed Saturate
521 \details Saturates a signed value.
522 \param [in] value Value to be saturated
523 \param [in] sat Bit position to saturate to (1..32)
524 \return Saturated value
526 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
528 if ((sat >= 1U) && (sat <= 32U))
530 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
531 const int32_t min = -1 - max ;
545 \brief Unsigned Saturate
546 \details Saturates an unsigned value.
547 \param [in] value Value to be saturated
548 \param [in] sat Bit position to saturate to (0..31)
549 \return Saturated value
551 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
555 const uint32_t max = ((1U << sat) - 1U);
556 if (val > (int32_t)max)
565 return (uint32_t)val;
568 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
569 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
570 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
571 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
574 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
575 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
576 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
579 \brief Load-Acquire (8 bit)
580 \details Executes a LDAB instruction for 8 bit value.
581 \param [in] ptr Pointer to data
582 \return value of type uint8_t at (*ptr)
584 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
588 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
589 return ((uint8_t) result);
594 \brief Load-Acquire (16 bit)
595 \details Executes a LDAH instruction for 16 bit values.
596 \param [in] ptr Pointer to data
597 \return value of type uint16_t at (*ptr)
599 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
603 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
604 return ((uint16_t) result);
609 \brief Load-Acquire (32 bit)
610 \details Executes a LDA instruction for 32 bit values.
611 \param [in] ptr Pointer to data
612 \return value of type uint32_t at (*ptr)
614 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
618 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
624 \brief Store-Release (8 bit)
625 \details Executes a STLB instruction for 8 bit values.
626 \param [in] value Value to store
627 \param [in] ptr Pointer to location
629 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
631 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
636 \brief Store-Release (16 bit)
637 \details Executes a STLH instruction for 16 bit values.
638 \param [in] value Value to store
639 \param [in] ptr Pointer to location
641 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
643 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
648 \brief Store-Release (32 bit)
649 \details Executes a STL instruction for 32 bit values.
650 \param [in] value Value to store
651 \param [in] ptr Pointer to location
653 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
655 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
660 \brief Load-Acquire Exclusive (8 bit)
661 \details Executes a LDAB exclusive instruction for 8 bit value.
662 \param [in] ptr Pointer to data
663 \return value of type uint8_t at (*ptr)
665 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
669 \brief Load-Acquire Exclusive (16 bit)
670 \details Executes a LDAH exclusive instruction for 16 bit values.
671 \param [in] ptr Pointer to data
672 \return value of type uint16_t at (*ptr)
674 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
678 \brief Load-Acquire Exclusive (32 bit)
679 \details Executes a LDA exclusive instruction for 32 bit values.
680 \param [in] ptr Pointer to data
681 \return value of type uint32_t at (*ptr)
683 #define __LDAEX (uint32_t)__builtin_arm_ldaex
687 \brief Store-Release Exclusive (8 bit)
688 \details Executes a STLB exclusive instruction for 8 bit values.
689 \param [in] value Value to store
690 \param [in] ptr Pointer to location
691 \return 0 Function succeeded
692 \return 1 Function failed
694 #define __STLEXB (uint32_t)__builtin_arm_stlex
698 \brief Store-Release Exclusive (16 bit)
699 \details Executes a STLH exclusive instruction for 16 bit values.
700 \param [in] value Value to store
701 \param [in] ptr Pointer to location
702 \return 0 Function succeeded
703 \return 1 Function failed
705 #define __STLEXH (uint32_t)__builtin_arm_stlex
709 \brief Store-Release Exclusive (32 bit)
710 \details Executes a STL exclusive instruction for 32 bit values.
711 \param [in] value Value to store
712 \param [in] ptr Pointer to location
713 \return 0 Function succeeded
714 \return 1 Function failed
716 #define __STLEX (uint32_t)__builtin_arm_stlex
718 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
719 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
720 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
722 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
725 /* ########################### Core Function Access ########################### */
726 /** \ingroup CMSIS_Core_FunctionInterface
727 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
732 \brief Enable IRQ Interrupts
733 \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
734 Can only be executed in Privileged modes.
736 __STATIC_FORCEINLINE void __enable_irq(void)
738 __ASM volatile ("cpsie i" : : : "memory");
743 \brief Disable IRQ Interrupts
744 \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
745 Can only be executed in Privileged modes.
747 __STATIC_FORCEINLINE void __disable_irq(void)
749 __ASM volatile ("cpsid i" : : : "memory");
754 \brief Get Control Register
755 \details Returns the content of the Control Register.
756 \return Control Register value
758 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
762 __ASM volatile ("MRS %0, control" : "=r" (result) );
767 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
769 \brief Get Control Register (non-secure)
770 \details Returns the content of the non-secure Control Register when in secure mode.
771 \return non-secure Control Register value
773 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
777 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
784 \brief Set Control Register
785 \details Writes the given value to the Control Register.
786 \param [in] control Control Register value to set
788 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
790 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
795 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
797 \brief Set Control Register (non-secure)
798 \details Writes the given value to the non-secure Control Register when in secure state.
799 \param [in] control Control Register value to set
801 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
803 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
810 \brief Get IPSR Register
811 \details Returns the content of the IPSR Register.
812 \return IPSR Register value
814 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
818 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
824 \brief Get APSR Register
825 \details Returns the content of the APSR Register.
826 \return APSR Register value
828 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
832 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
838 \brief Get xPSR Register
839 \details Returns the content of the xPSR Register.
840 \return xPSR Register value
842 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
846 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
852 \brief Get Process Stack Pointer
853 \details Returns the current value of the Process Stack Pointer (PSP).
854 \return PSP Register value
856 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
860 __ASM volatile ("MRS %0, psp" : "=r" (result) );
865 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
867 \brief Get Process Stack Pointer (non-secure)
868 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
869 \return PSP Register value
871 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
875 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
882 \brief Set Process Stack Pointer
883 \details Assigns the given value to the Process Stack Pointer (PSP).
884 \param [in] topOfProcStack Process Stack Pointer value to set
886 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
888 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
892 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
894 \brief Set Process Stack Pointer (non-secure)
895 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
896 \param [in] topOfProcStack Process Stack Pointer value to set
898 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
900 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
906 \brief Get Main Stack Pointer
907 \details Returns the current value of the Main Stack Pointer (MSP).
908 \return MSP Register value
910 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
914 __ASM volatile ("MRS %0, msp" : "=r" (result) );
919 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
921 \brief Get Main Stack Pointer (non-secure)
922 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
923 \return MSP Register value
925 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
929 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
936 \brief Set Main Stack Pointer
937 \details Assigns the given value to the Main Stack Pointer (MSP).
938 \param [in] topOfMainStack Main Stack Pointer value to set
940 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
942 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
946 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
948 \brief Set Main Stack Pointer (non-secure)
949 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
950 \param [in] topOfMainStack Main Stack Pointer value to set
952 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
954 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
959 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
961 \brief Get Stack Pointer (non-secure)
962 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
963 \return SP Register value
965 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
969 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
975 \brief Set Stack Pointer (non-secure)
976 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
977 \param [in] topOfStack Stack Pointer value to set
979 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
981 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
987 \brief Get Priority Mask
988 \details Returns the current state of the priority mask bit from the Priority Mask Register.
989 \return Priority Mask value
991 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
995 __ASM volatile ("MRS %0, primask" : "=r" (result) );
1000 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1002 \brief Get Priority Mask (non-secure)
1003 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
1004 \return Priority Mask value
1006 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
1010 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
1017 \brief Set Priority Mask
1018 \details Assigns the given value to the Priority Mask Register.
1019 \param [in] priMask Priority Mask
1021 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
1023 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
1027 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1029 \brief Set Priority Mask (non-secure)
1030 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
1031 \param [in] priMask Priority Mask
1033 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
1035 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
1040 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1041 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1042 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1043 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1046 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
1047 Can only be executed in Privileged modes.
1049 __STATIC_FORCEINLINE void __enable_fault_irq(void)
1051 __ASM volatile ("cpsie f" : : : "memory");
1057 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
1058 Can only be executed in Privileged modes.
1060 __STATIC_FORCEINLINE void __disable_fault_irq(void)
1062 __ASM volatile ("cpsid f" : : : "memory");
1067 \brief Get Base Priority
1068 \details Returns the current value of the Base Priority register.
1069 \return Base Priority register value
1071 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
1075 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
1080 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1082 \brief Get Base Priority (non-secure)
1083 \details Returns the current value of the non-secure Base Priority register when in secure state.
1084 \return Base Priority register value
1086 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
1090 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
1097 \brief Set Base Priority
1098 \details Assigns the given value to the Base Priority register.
1099 \param [in] basePri Base Priority value to set
1101 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
1103 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
1107 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1109 \brief Set Base Priority (non-secure)
1110 \details Assigns the given value to the non-secure Base Priority register when in secure state.
1111 \param [in] basePri Base Priority value to set
1113 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
1115 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
1121 \brief Set Base Priority with condition
1122 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
1123 or the new value increases the BASEPRI priority level.
1124 \param [in] basePri Base Priority value to set
1126 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
1128 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
1133 \brief Get Fault Mask
1134 \details Returns the current value of the Fault Mask register.
1135 \return Fault Mask register value
1137 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
1141 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
1146 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1148 \brief Get Fault Mask (non-secure)
1149 \details Returns the current value of the non-secure Fault Mask register when in secure state.
1150 \return Fault Mask register value
1152 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
1156 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
1163 \brief Set Fault Mask
1164 \details Assigns the given value to the Fault Mask register.
1165 \param [in] faultMask Fault Mask value to set
1167 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
1169 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
1173 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1175 \brief Set Fault Mask (non-secure)
1176 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
1177 \param [in] faultMask Fault Mask value to set
1179 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
1181 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
1185 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1186 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1187 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1188 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1191 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1192 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1193 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1196 \brief Get Process Stack Pointer Limit
1197 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1198 Stack Pointer Limit register hence zero is returned always in non-secure
1201 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
1202 \return PSPLIM Register value
1204 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
1206 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1207 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
1208 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1209 // without main extensions, the non-secure PSPLIM is RAZ/WI
1213 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
1218 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
1220 \brief Get Process Stack Pointer Limit (non-secure)
1221 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1222 Stack Pointer Limit register hence zero is returned always in non-secure
1225 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
1226 \return PSPLIM Register value
1228 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
1230 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1231 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
1232 // without main extensions, the non-secure PSPLIM is RAZ/WI
1236 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
1244 \brief Set Process Stack Pointer Limit
1245 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1246 Stack Pointer Limit register hence the write is silently ignored in non-secure
1249 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
1250 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
1252 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
1254 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1255 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
1256 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1257 // without main extensions, the non-secure PSPLIM is RAZ/WI
1258 (void)ProcStackPtrLimit;
1260 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
1265 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1267 \brief Set Process Stack Pointer (non-secure)
1268 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1269 Stack Pointer Limit register hence the write is silently ignored in non-secure
1272 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
1273 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
1275 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
1277 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1278 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
1279 // without main extensions, the non-secure PSPLIM is RAZ/WI
1280 (void)ProcStackPtrLimit;
1282 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
1289 \brief Get Main Stack Pointer Limit
1290 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1291 Stack Pointer Limit register hence zero is returned always.
1293 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
1294 \return MSPLIM Register value
1296 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
1298 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1299 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
1300 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1301 // without main extensions, the non-secure MSPLIM is RAZ/WI
1305 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
1311 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1313 \brief Get Main Stack Pointer Limit (non-secure)
1314 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1315 Stack Pointer Limit register hence zero is returned always.
1317 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
1318 \return MSPLIM Register value
1320 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
1322 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1323 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
1324 // without main extensions, the non-secure MSPLIM is RAZ/WI
1328 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
1336 \brief Set Main Stack Pointer Limit
1337 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1338 Stack Pointer Limit register hence the write is silently ignored.
1340 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
1341 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
1343 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
1345 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1346 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
1347 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1348 // without main extensions, the non-secure MSPLIM is RAZ/WI
1349 (void)MainStackPtrLimit;
1351 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
1356 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1358 \brief Set Main Stack Pointer Limit (non-secure)
1359 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1360 Stack Pointer Limit register hence the write is silently ignored.
1362 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
1363 \param [in] MainStackPtrLimit Main Stack Pointer value to set
1365 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
1367 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1368 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
1369 // without main extensions, the non-secure MSPLIM is RAZ/WI
1370 (void)MainStackPtrLimit;
1372 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
1377 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1378 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1379 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1383 \details Returns the current value of the Floating Point Status/Control register.
1384 \return Floating Point Status/Control register value
1386 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
1387 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
1388 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
1390 #define __get_FPSCR() ((uint32_t)0U)
1395 \details Assigns the given value to the Floating Point Status/Control register.
1396 \param [in] fpscr Floating Point Status/Control value to set
1398 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
1399 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
1400 #define __set_FPSCR __builtin_arm_set_fpscr
1402 #define __set_FPSCR(x) ((void)(x))
1406 /*@} end of CMSIS_Core_RegAccFunctions */
1409 /* ################### Compiler specific Intrinsics ########################### */
1410 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1411 Access to dedicated SIMD instructions
1415 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1417 #define __SADD8 __builtin_arm_sadd8
1418 #define __QADD8 __builtin_arm_qadd8
1419 #define __SHADD8 __builtin_arm_shadd8
1420 #define __UADD8 __builtin_arm_uadd8
1421 #define __UQADD8 __builtin_arm_uqadd8
1422 #define __UHADD8 __builtin_arm_uhadd8
1423 #define __SSUB8 __builtin_arm_ssub8
1424 #define __QSUB8 __builtin_arm_qsub8
1425 #define __SHSUB8 __builtin_arm_shsub8
1426 #define __USUB8 __builtin_arm_usub8
1427 #define __UQSUB8 __builtin_arm_uqsub8
1428 #define __UHSUB8 __builtin_arm_uhsub8
1429 #define __SADD16 __builtin_arm_sadd16
1430 #define __QADD16 __builtin_arm_qadd16
1431 #define __SHADD16 __builtin_arm_shadd16
1432 #define __UADD16 __builtin_arm_uadd16
1433 #define __UQADD16 __builtin_arm_uqadd16
1434 #define __UHADD16 __builtin_arm_uhadd16
1435 #define __SSUB16 __builtin_arm_ssub16
1436 #define __QSUB16 __builtin_arm_qsub16
1437 #define __SHSUB16 __builtin_arm_shsub16
1438 #define __USUB16 __builtin_arm_usub16
1439 #define __UQSUB16 __builtin_arm_uqsub16
1440 #define __UHSUB16 __builtin_arm_uhsub16
1441 #define __SASX __builtin_arm_sasx
1442 #define __QASX __builtin_arm_qasx
1443 #define __SHASX __builtin_arm_shasx
1444 #define __UASX __builtin_arm_uasx
1445 #define __UQASX __builtin_arm_uqasx
1446 #define __UHASX __builtin_arm_uhasx
1447 #define __SSAX __builtin_arm_ssax
1448 #define __QSAX __builtin_arm_qsax
1449 #define __SHSAX __builtin_arm_shsax
1450 #define __USAX __builtin_arm_usax
1451 #define __UQSAX __builtin_arm_uqsax
1452 #define __UHSAX __builtin_arm_uhsax
1453 #define __USAD8 __builtin_arm_usad8
1454 #define __USADA8 __builtin_arm_usada8
1455 #define __SSAT16 __builtin_arm_ssat16
1456 #define __USAT16 __builtin_arm_usat16
1457 #define __UXTB16 __builtin_arm_uxtb16
1458 #define __UXTAB16 __builtin_arm_uxtab16
1459 #define __SXTB16 __builtin_arm_sxtb16
1460 #define __SXTAB16 __builtin_arm_sxtab16
1461 #define __SMUAD __builtin_arm_smuad
1462 #define __SMUADX __builtin_arm_smuadx
1463 #define __SMLAD __builtin_arm_smlad
1464 #define __SMLADX __builtin_arm_smladx
1465 #define __SMLALD __builtin_arm_smlald
1466 #define __SMLALDX __builtin_arm_smlaldx
1467 #define __SMUSD __builtin_arm_smusd
1468 #define __SMUSDX __builtin_arm_smusdx
1469 #define __SMLSD __builtin_arm_smlsd
1470 #define __SMLSDX __builtin_arm_smlsdx
1471 #define __SMLSLD __builtin_arm_smlsld
1472 #define __SMLSLDX __builtin_arm_smlsldx
1473 #define __SEL __builtin_arm_sel
1474 #define __QADD __builtin_arm_qadd
1475 #define __QSUB __builtin_arm_qsub
1477 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1478 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1480 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1481 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1483 #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
1485 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1487 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1491 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1495 #endif /* (__ARM_FEATURE_DSP == 1) */
1496 /*@} end of group CMSIS_SIMD_intrinsics */
1499 #endif /* __CMSIS_ARMCLANG_H */