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 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_USE_REG(r) "l" (r)
168 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
169 #define __CMSIS_GCC_USE_REG(r) "r" (r)
174 \details No Operation does nothing. This instruction can be used for code alignment purposes.
176 #define __NOP __builtin_arm_nop
179 \brief Wait For Interrupt
180 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
182 #define __WFI __builtin_arm_wfi
186 \brief Wait For Event
187 \details Wait For Event is a hint instruction that permits the processor to enter
188 a low-power state until one of a number of events occurs.
190 #define __WFE __builtin_arm_wfe
195 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
197 #define __SEV __builtin_arm_sev
201 \brief Instruction Synchronization Barrier
202 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
203 so that all instructions following the ISB are fetched from cache or memory,
204 after the instruction has been completed.
206 #define __ISB() __builtin_arm_isb(0xF)
209 \brief Data Synchronization Barrier
210 \details Acts as a special kind of Data Memory Barrier.
211 It completes when all explicit memory accesses before this instruction complete.
213 #define __DSB() __builtin_arm_dsb(0xF)
217 \brief Data Memory Barrier
218 \details Ensures the apparent order of the explicit memory operations before
219 and after the instruction, without ensuring their completion.
221 #define __DMB() __builtin_arm_dmb(0xF)
225 \brief Reverse byte order (32 bit)
226 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
227 \param [in] value Value to reverse
228 \return Reversed value
230 #define __REV(value) __builtin_bswap32(value)
234 \brief Reverse byte order (16 bit)
235 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
236 \param [in] value Value to reverse
237 \return Reversed value
239 #define __REV16(value) __ROR(__REV(value), 16)
243 \brief Reverse byte order (16 bit)
244 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
245 \param [in] value Value to reverse
246 \return Reversed value
248 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
252 \brief Rotate Right in unsigned value (32 bit)
253 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
254 \param [in] op1 Value to rotate
255 \param [in] op2 Number of Bits to rotate
256 \return Rotated value
258 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
265 return (op1 >> op2) | (op1 << (32U - op2));
271 \details Causes the processor to enter Debug state.
272 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
273 \param [in] value is ignored by the processor.
274 If required, a debugger can use it to store additional information about the breakpoint.
276 #define __BKPT(value) __ASM volatile ("bkpt "#value)
280 \brief Reverse bit order of value
281 \details Reverses the bit order of the given value.
282 \param [in] value Value to reverse
283 \return Reversed value
285 #define __RBIT __builtin_arm_rbit
288 \brief Count leading zeros
289 \details Counts the number of leading zeros of a data value.
290 \param [in] value Value to count the leading zeros
291 \return number of leading zeros in value
293 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
295 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
296 __builtin_clz(0) is undefined behaviour, so handle this case specially.
297 This guarantees ARM-compatible results if happening to compile on a non-ARM
298 target, and ensures the compiler doesn't decide to activate any
299 optimisations using the logic "value was passed to __builtin_clz, so it
301 ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
302 single CLZ instruction.
308 return __builtin_clz(value);
312 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
313 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
314 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
315 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
317 \brief LDR Exclusive (8 bit)
318 \details Executes a exclusive LDR instruction for 8 bit value.
319 \param [in] ptr Pointer to data
320 \return value of type uint8_t at (*ptr)
322 #define __LDREXB (uint8_t)__builtin_arm_ldrex
326 \brief LDR Exclusive (16 bit)
327 \details Executes a exclusive LDR instruction for 16 bit values.
328 \param [in] ptr Pointer to data
329 \return value of type uint16_t at (*ptr)
331 #define __LDREXH (uint16_t)__builtin_arm_ldrex
335 \brief LDR Exclusive (32 bit)
336 \details Executes a exclusive LDR instruction for 32 bit values.
337 \param [in] ptr Pointer to data
338 \return value of type uint32_t at (*ptr)
340 #define __LDREXW (uint32_t)__builtin_arm_ldrex
344 \brief STR Exclusive (8 bit)
345 \details Executes a exclusive STR instruction for 8 bit values.
346 \param [in] value Value to store
347 \param [in] ptr Pointer to location
348 \return 0 Function succeeded
349 \return 1 Function failed
351 #define __STREXB (uint32_t)__builtin_arm_strex
355 \brief STR Exclusive (16 bit)
356 \details Executes a exclusive STR instruction for 16 bit values.
357 \param [in] value Value to store
358 \param [in] ptr Pointer to location
359 \return 0 Function succeeded
360 \return 1 Function failed
362 #define __STREXH (uint32_t)__builtin_arm_strex
366 \brief STR Exclusive (32 bit)
367 \details Executes a exclusive STR instruction for 32 bit values.
368 \param [in] value Value to store
369 \param [in] ptr Pointer to location
370 \return 0 Function succeeded
371 \return 1 Function failed
373 #define __STREXW (uint32_t)__builtin_arm_strex
377 \brief Remove the exclusive lock
378 \details Removes the exclusive lock which is created by LDREX.
380 #define __CLREX __builtin_arm_clrex
382 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
383 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
384 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
385 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
388 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
389 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
390 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
393 \brief Signed Saturate
394 \details Saturates a signed value.
395 \param [in] value Value to be saturated
396 \param [in] sat Bit position to saturate to (1..32)
397 \return Saturated value
399 #define __SSAT __builtin_arm_ssat
403 \brief Unsigned Saturate
404 \details Saturates an unsigned value.
405 \param [in] value Value to be saturated
406 \param [in] sat Bit position to saturate to (0..31)
407 \return Saturated value
409 #define __USAT __builtin_arm_usat
413 \brief Rotate Right with Extend (32 bit)
414 \details Moves each bit of a bitstring right by one bit.
415 The carry input is shifted in at the left end of the bitstring.
416 \param [in] value Value to rotate
417 \return Rotated value
419 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
423 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
429 \brief LDRT Unprivileged (8 bit)
430 \details Executes a Unprivileged LDRT instruction for 8 bit value.
431 \param [in] ptr Pointer to data
432 \return value of type uint8_t at (*ptr)
434 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
438 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
439 return ((uint8_t) result); /* Add explicit type cast here */
444 \brief LDRT Unprivileged (16 bit)
445 \details Executes a Unprivileged LDRT instruction for 16 bit values.
446 \param [in] ptr Pointer to data
447 \return value of type uint16_t at (*ptr)
449 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
453 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
454 return ((uint16_t) result); /* Add explicit type cast here */
459 \brief LDRT Unprivileged (32 bit)
460 \details Executes a Unprivileged LDRT instruction for 32 bit values.
461 \param [in] ptr Pointer to data
462 \return value of type uint32_t at (*ptr)
464 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
468 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
474 \brief STRT Unprivileged (8 bit)
475 \details Executes a Unprivileged STRT instruction for 8 bit values.
476 \param [in] value Value to store
477 \param [in] ptr Pointer to location
479 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
481 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
486 \brief STRT Unprivileged (16 bit)
487 \details Executes a Unprivileged STRT instruction for 16 bit values.
488 \param [in] value Value to store
489 \param [in] ptr Pointer to location
491 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
493 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
498 \brief STRT Unprivileged (32 bit)
499 \details Executes a Unprivileged STRT instruction for 32 bit values.
500 \param [in] value Value to store
501 \param [in] ptr Pointer to location
503 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
505 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
508 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
509 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
510 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
513 \brief Signed Saturate
514 \details Saturates a signed value.
515 \param [in] value Value to be saturated
516 \param [in] sat Bit position to saturate to (1..32)
517 \return Saturated value
519 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
521 if ((sat >= 1U) && (sat <= 32U))
523 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
524 const int32_t min = -1 - max ;
538 \brief Unsigned Saturate
539 \details Saturates an unsigned value.
540 \param [in] value Value to be saturated
541 \param [in] sat Bit position to saturate to (0..31)
542 \return Saturated value
544 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
548 const uint32_t max = ((1U << sat) - 1U);
549 if (val > (int32_t)max)
558 return (uint32_t)val;
561 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
562 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
563 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
566 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
567 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
569 \brief Load-Acquire (8 bit)
570 \details Executes a LDAB instruction for 8 bit value.
571 \param [in] ptr Pointer to data
572 \return value of type uint8_t at (*ptr)
574 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
578 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
579 return ((uint8_t) result);
584 \brief Load-Acquire (16 bit)
585 \details Executes a LDAH instruction for 16 bit values.
586 \param [in] ptr Pointer to data
587 \return value of type uint16_t at (*ptr)
589 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
593 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
594 return ((uint16_t) result);
599 \brief Load-Acquire (32 bit)
600 \details Executes a LDA instruction for 32 bit values.
601 \param [in] ptr Pointer to data
602 \return value of type uint32_t at (*ptr)
604 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
608 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
614 \brief Store-Release (8 bit)
615 \details Executes a STLB instruction for 8 bit values.
616 \param [in] value Value to store
617 \param [in] ptr Pointer to location
619 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
621 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
626 \brief Store-Release (16 bit)
627 \details Executes a STLH instruction for 16 bit values.
628 \param [in] value Value to store
629 \param [in] ptr Pointer to location
631 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
633 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
638 \brief Store-Release (32 bit)
639 \details Executes a STL instruction for 32 bit values.
640 \param [in] value Value to store
641 \param [in] ptr Pointer to location
643 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
645 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
650 \brief Load-Acquire Exclusive (8 bit)
651 \details Executes a LDAB exclusive instruction for 8 bit value.
652 \param [in] ptr Pointer to data
653 \return value of type uint8_t at (*ptr)
655 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
659 \brief Load-Acquire Exclusive (16 bit)
660 \details Executes a LDAH exclusive instruction for 16 bit values.
661 \param [in] ptr Pointer to data
662 \return value of type uint16_t at (*ptr)
664 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
668 \brief Load-Acquire Exclusive (32 bit)
669 \details Executes a LDA exclusive instruction for 32 bit values.
670 \param [in] ptr Pointer to data
671 \return value of type uint32_t at (*ptr)
673 #define __LDAEX (uint32_t)__builtin_arm_ldaex
677 \brief Store-Release Exclusive (8 bit)
678 \details Executes a STLB exclusive instruction for 8 bit values.
679 \param [in] value Value to store
680 \param [in] ptr Pointer to location
681 \return 0 Function succeeded
682 \return 1 Function failed
684 #define __STLEXB (uint32_t)__builtin_arm_stlex
688 \brief Store-Release Exclusive (16 bit)
689 \details Executes a STLH exclusive instruction for 16 bit values.
690 \param [in] value Value to store
691 \param [in] ptr Pointer to location
692 \return 0 Function succeeded
693 \return 1 Function failed
695 #define __STLEXH (uint32_t)__builtin_arm_stlex
699 \brief Store-Release Exclusive (32 bit)
700 \details Executes a STL exclusive instruction for 32 bit values.
701 \param [in] value Value to store
702 \param [in] ptr Pointer to location
703 \return 0 Function succeeded
704 \return 1 Function failed
706 #define __STLEX (uint32_t)__builtin_arm_stlex
708 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
709 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
711 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
714 /* ########################### Core Function Access ########################### */
715 /** \ingroup CMSIS_Core_FunctionInterface
716 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
721 \brief Enable IRQ Interrupts
722 \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
723 Can only be executed in Privileged modes.
725 #ifndef __ARM_COMPAT_H
726 __STATIC_FORCEINLINE void __enable_irq(void)
728 __ASM volatile ("cpsie i" : : : "memory");
734 \brief Disable IRQ Interrupts
735 \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
736 Can only be executed in Privileged modes.
738 #ifndef __ARM_COMPAT_H
739 __STATIC_FORCEINLINE void __disable_irq(void)
741 __ASM volatile ("cpsid i" : : : "memory");
747 \brief Get Control Register
748 \details Returns the content of the Control Register.
749 \return Control Register value
751 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
755 __ASM volatile ("MRS %0, control" : "=r" (result) );
760 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
762 \brief Get Control Register (non-secure)
763 \details Returns the content of the non-secure Control Register when in secure mode.
764 \return non-secure Control Register value
766 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
770 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
777 \brief Set Control Register
778 \details Writes the given value to the Control Register.
779 \param [in] control Control Register value to set
781 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
783 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
788 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
790 \brief Set Control Register (non-secure)
791 \details Writes the given value to the non-secure Control Register when in secure state.
792 \param [in] control Control Register value to set
794 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
796 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
803 \brief Get IPSR Register
804 \details Returns the content of the IPSR Register.
805 \return IPSR Register value
807 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
811 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
817 \brief Get APSR Register
818 \details Returns the content of the APSR Register.
819 \return APSR Register value
821 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
825 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
831 \brief Get xPSR Register
832 \details Returns the content of the xPSR Register.
833 \return xPSR Register value
835 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
839 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
845 \brief Get Process Stack Pointer
846 \details Returns the current value of the Process Stack Pointer (PSP).
847 \return PSP Register value
849 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
853 __ASM volatile ("MRS %0, psp" : "=r" (result) );
858 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
860 \brief Get Process Stack Pointer (non-secure)
861 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
862 \return PSP Register value
864 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
868 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
875 \brief Set Process Stack Pointer
876 \details Assigns the given value to the Process Stack Pointer (PSP).
877 \param [in] topOfProcStack Process Stack Pointer value to set
879 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
881 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
885 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
887 \brief Set Process Stack Pointer (non-secure)
888 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
889 \param [in] topOfProcStack Process Stack Pointer value to set
891 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
893 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
899 \brief Get Main Stack Pointer
900 \details Returns the current value of the Main Stack Pointer (MSP).
901 \return MSP Register value
903 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
907 __ASM volatile ("MRS %0, msp" : "=r" (result) );
912 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
914 \brief Get Main Stack Pointer (non-secure)
915 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
916 \return MSP Register value
918 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
922 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
929 \brief Set Main Stack Pointer
930 \details Assigns the given value to the Main Stack Pointer (MSP).
931 \param [in] topOfMainStack Main Stack Pointer value to set
933 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
935 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
939 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
941 \brief Set Main Stack Pointer (non-secure)
942 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
943 \param [in] topOfMainStack Main Stack Pointer value to set
945 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
947 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
952 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
954 \brief Get Stack Pointer (non-secure)
955 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
956 \return SP Register value
958 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
962 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
968 \brief Set Stack Pointer (non-secure)
969 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
970 \param [in] topOfStack Stack Pointer value to set
972 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
974 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
980 \brief Get Priority Mask
981 \details Returns the current state of the priority mask bit from the Priority Mask Register.
982 \return Priority Mask value
984 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
988 __ASM volatile ("MRS %0, primask" : "=r" (result) );
993 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
995 \brief Get Priority Mask (non-secure)
996 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
997 \return Priority Mask value
999 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
1003 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
1010 \brief Set Priority Mask
1011 \details Assigns the given value to the Priority Mask Register.
1012 \param [in] priMask Priority Mask
1014 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
1016 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
1020 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1022 \brief Set Priority Mask (non-secure)
1023 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
1024 \param [in] priMask Priority Mask
1026 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
1028 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
1033 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1034 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1035 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1038 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
1039 Can only be executed in Privileged modes.
1041 __STATIC_FORCEINLINE void __enable_fault_irq(void)
1043 __ASM volatile ("cpsie f" : : : "memory");
1049 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
1050 Can only be executed in Privileged modes.
1052 __STATIC_FORCEINLINE void __disable_fault_irq(void)
1054 __ASM volatile ("cpsid f" : : : "memory");
1059 \brief Get Base Priority
1060 \details Returns the current value of the Base Priority register.
1061 \return Base Priority register value
1063 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
1067 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
1072 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1074 \brief Get Base Priority (non-secure)
1075 \details Returns the current value of the non-secure Base Priority register when in secure state.
1076 \return Base Priority register value
1078 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
1082 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
1089 \brief Set Base Priority
1090 \details Assigns the given value to the Base Priority register.
1091 \param [in] basePri Base Priority value to set
1093 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
1095 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
1099 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1101 \brief Set Base Priority (non-secure)
1102 \details Assigns the given value to the non-secure Base Priority register when in secure state.
1103 \param [in] basePri Base Priority value to set
1105 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
1107 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
1113 \brief Set Base Priority with condition
1114 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
1115 or the new value increases the BASEPRI priority level.
1116 \param [in] basePri Base Priority value to set
1118 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
1120 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
1125 \brief Get Fault Mask
1126 \details Returns the current value of the Fault Mask register.
1127 \return Fault Mask register value
1129 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
1133 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
1138 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1140 \brief Get Fault Mask (non-secure)
1141 \details Returns the current value of the non-secure Fault Mask register when in secure state.
1142 \return Fault Mask register value
1144 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
1148 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
1155 \brief Set Fault Mask
1156 \details Assigns the given value to the Fault Mask register.
1157 \param [in] faultMask Fault Mask value to set
1159 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
1161 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
1165 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1167 \brief Set Fault Mask (non-secure)
1168 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
1169 \param [in] faultMask Fault Mask value to set
1171 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
1173 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
1177 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1178 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1179 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1182 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1183 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1186 \brief Get Process Stack Pointer Limit
1187 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1188 Stack Pointer Limit register hence zero is returned always in non-secure
1191 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
1192 \return PSPLIM Register value
1194 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
1196 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
1197 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1198 // without main extensions, the non-secure PSPLIM is RAZ/WI
1202 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
1207 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
1209 \brief Get Process Stack Pointer Limit (non-secure)
1210 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1211 Stack Pointer Limit register hence zero is returned always in non-secure
1214 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
1215 \return PSPLIM Register value
1217 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
1219 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
1220 // without main extensions, the non-secure PSPLIM is RAZ/WI
1224 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
1232 \brief Set Process Stack Pointer Limit
1233 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1234 Stack Pointer Limit register hence the write is silently ignored in non-secure
1237 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
1238 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
1240 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
1242 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
1243 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1244 // without main extensions, the non-secure PSPLIM is RAZ/WI
1245 (void)ProcStackPtrLimit;
1247 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
1252 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1254 \brief Set Process Stack Pointer (non-secure)
1255 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1256 Stack Pointer Limit register hence the write is silently ignored in non-secure
1259 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
1260 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
1262 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
1264 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
1265 // without main extensions, the non-secure PSPLIM is RAZ/WI
1266 (void)ProcStackPtrLimit;
1268 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
1275 \brief Get Main Stack Pointer Limit
1276 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1277 Stack Pointer Limit register hence zero is returned always.
1279 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
1280 \return MSPLIM Register value
1282 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
1284 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
1285 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1286 // without main extensions, the non-secure MSPLIM is RAZ/WI
1290 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
1296 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1298 \brief Get Main Stack Pointer Limit (non-secure)
1299 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1300 Stack Pointer Limit register hence zero is returned always.
1302 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
1303 \return MSPLIM Register value
1305 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
1307 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
1308 // without main extensions, the non-secure MSPLIM is RAZ/WI
1312 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
1320 \brief Set Main Stack Pointer Limit
1321 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1322 Stack Pointer Limit register hence the write is silently ignored.
1324 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
1325 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
1327 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
1329 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
1330 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
1331 // without main extensions, the non-secure MSPLIM is RAZ/WI
1332 (void)MainStackPtrLimit;
1334 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
1339 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
1341 \brief Set Main Stack Pointer Limit (non-secure)
1342 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1343 Stack Pointer Limit register hence the write is silently ignored.
1345 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
1346 \param [in] MainStackPtrLimit Main Stack Pointer value to set
1348 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
1350 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
1351 // without main extensions, the non-secure MSPLIM is RAZ/WI
1352 (void)MainStackPtrLimit;
1354 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
1359 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1360 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1364 \details Returns the current value of the Floating Point Status/Control register.
1365 \return Floating Point Status/Control register value
1367 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
1368 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
1369 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
1371 #define __get_FPSCR() ((uint32_t)0U)
1376 \details Assigns the given value to the Floating Point Status/Control register.
1377 \param [in] fpscr Floating Point Status/Control value to set
1379 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
1380 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
1381 #define __set_FPSCR __builtin_arm_set_fpscr
1383 #define __set_FPSCR(x) ((void)(x))
1387 /*@} end of CMSIS_Core_RegAccFunctions */
1390 /* ################### Compiler specific Intrinsics ########################### */
1391 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1392 Access to dedicated SIMD instructions
1396 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1398 __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1402 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1406 __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1410 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1414 __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1418 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1422 __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1426 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1430 __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1434 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1438 __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1442 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1447 __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1451 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1455 __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1459 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1463 __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1467 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1471 __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1475 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1479 __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1483 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1487 __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1491 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1496 __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1500 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1504 __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1508 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1512 __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1516 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1520 __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1524 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1528 __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1532 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1536 __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1540 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1544 __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1548 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1552 __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1556 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1560 __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1564 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1568 __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1572 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1576 __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1580 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1584 __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1588 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1592 __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1596 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1600 __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1604 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1608 __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1612 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1616 __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1620 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1624 __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1628 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1632 __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1636 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1640 __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1644 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1648 __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1652 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1656 __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1660 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1664 __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1668 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1672 __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1676 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1680 __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1684 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1688 __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1692 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1696 __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1700 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1704 #define __SSAT16(ARG1,ARG2) \
1706 int32_t __RES, __ARG1 = (ARG1); \
1707 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1711 #define __USAT16(ARG1,ARG2) \
1713 uint32_t __RES, __ARG1 = (ARG1); \
1714 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1718 __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1)
1722 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1726 __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1730 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1734 __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1)
1738 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1742 __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1746 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1750 __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1754 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1758 __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1762 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1766 __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1770 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1774 __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1778 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1782 __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1790 #ifndef __ARMEB__ /* Little endian */
1791 __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]) );
1792 #else /* Big endian */
1793 __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]) );
1799 __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1807 #ifndef __ARMEB__ /* Little endian */
1808 __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]) );
1809 #else /* Big endian */
1810 __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]) );
1816 __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1820 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1824 __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1828 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1832 __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1836 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1840 __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1844 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1848 __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1856 #ifndef __ARMEB__ /* Little endian */
1857 __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]) );
1858 #else /* Big endian */
1859 __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]) );
1865 __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1873 #ifndef __ARMEB__ /* Little endian */
1874 __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]) );
1875 #else /* Big endian */
1876 __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]) );
1882 __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1886 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1890 __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2)
1894 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1898 __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2)
1902 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1906 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1907 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1909 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1910 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1912 #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
1914 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1916 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1920 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1924 #endif /* (__ARM_FEATURE_DSP == 1) */
1925 /*@} end of group CMSIS_SIMD_intrinsics */
1928 #endif /* __CMSIS_ARMCLANG_H */