1 /**************************************************************************//**
3 * @brief CMSIS Cortex-M Core Function/Instruction Header File
5 * @date 13. September 2016
6 ******************************************************************************/
8 * Copyright (c) 2009-2016 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 * http://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.
28 /* ignore some GCC warnings */
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wsign-conversion"
31 #pragma GCC diagnostic ignored "-Wconversion"
32 #pragma GCC diagnostic ignored "-Wunused-parameter"
34 /* CMSIS compiler specific defines */
39 #define __INLINE inline
41 #ifndef __STATIC_INLINE
42 #define __STATIC_INLINE static inline
45 #define __NO_RETURN __attribute__((noreturn))
48 #define __USED __attribute__((used))
51 #define __WEAK __attribute__((weak))
53 #ifndef __UNALIGNED_UINT32
54 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
55 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
58 #define __ALIGNED(x) __attribute__((aligned(x)))
61 #define __PACKED __attribute__((packed, aligned(1)))
65 /* ########################### Core Function Access ########################### */
66 /** \ingroup CMSIS_Core_FunctionInterface
67 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
72 \brief Enable IRQ Interrupts
73 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
74 Can only be executed in Privileged modes.
76 __attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void)
78 __ASM volatile ("cpsie i" : : : "memory");
83 \brief Disable IRQ Interrupts
84 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
85 Can only be executed in Privileged modes.
87 __attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void)
89 __ASM volatile ("cpsid i" : : : "memory");
94 \brief Get Control Register
95 \details Returns the content of the Control Register.
96 \return Control Register value
98 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
102 __ASM volatile ("MRS %0, control" : "=r" (result) );
107 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
109 \brief Get Control Register (non-secure)
110 \details Returns the content of the non-secure Control Register when in secure mode.
111 \return non-secure Control Register value
113 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
117 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
124 \brief Set Control Register
125 \details Writes the given value to the Control Register.
126 \param [in] control Control Register value to set
128 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
130 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
134 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
136 \brief Set Control Register (non-secure)
137 \details Writes the given value to the non-secure Control Register when in secure state.
138 \param [in] control Control Register value to set
140 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
142 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
148 \brief Get IPSR Register
149 \details Returns the content of the IPSR Register.
150 \return IPSR Register value
152 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
156 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
162 \brief Get APSR Register
163 \details Returns the content of the APSR Register.
164 \return APSR Register value
166 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
170 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
176 \brief Get xPSR Register
177 \details Returns the content of the xPSR Register.
178 \return xPSR Register value
180 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
184 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
190 \brief Get Process Stack Pointer
191 \details Returns the current value of the Process Stack Pointer (PSP).
192 \return PSP Register value
194 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
196 register uint32_t result;
198 __ASM volatile ("MRS %0, psp" : "=r" (result) );
203 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
205 \brief Get Process Stack Pointer (non-secure)
206 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
207 \return PSP Register value
209 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
211 register uint32_t result;
213 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
220 \brief Set Process Stack Pointer
221 \details Assigns the given value to the Process Stack Pointer (PSP).
222 \param [in] topOfProcStack Process Stack Pointer value to set
224 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
226 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : "sp");
230 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
232 \brief Set Process Stack Pointer (non-secure)
233 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
234 \param [in] topOfProcStack Process Stack Pointer value to set
236 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
238 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : "sp");
244 \brief Get Main Stack Pointer
245 \details Returns the current value of the Main Stack Pointer (MSP).
246 \return MSP Register value
248 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
250 register uint32_t result;
252 __ASM volatile ("MRS %0, msp" : "=r" (result) );
257 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
259 \brief Get Main Stack Pointer (non-secure)
260 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
261 \return MSP Register value
263 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
265 register uint32_t result;
267 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
274 \brief Set Main Stack Pointer
275 \details Assigns the given value to the Main Stack Pointer (MSP).
276 \param [in] topOfMainStack Main Stack Pointer value to set
278 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
280 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : "sp");
284 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
286 \brief Set Main Stack Pointer (non-secure)
287 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
288 \param [in] topOfMainStack Main Stack Pointer value to set
290 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
292 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : "sp");
298 \brief Get Priority Mask
299 \details Returns the current state of the priority mask bit from the Priority Mask Register.
300 \return Priority Mask value
302 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
306 __ASM volatile ("MRS %0, primask" : "=r" (result) );
311 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
313 \brief Get Priority Mask (non-secure)
314 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
315 \return Priority Mask value
317 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
321 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
328 \brief Set Priority Mask
329 \details Assigns the given value to the Priority Mask Register.
330 \param [in] priMask Priority Mask
332 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
334 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
338 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
340 \brief Set Priority Mask (non-secure)
341 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
342 \param [in] priMask Priority Mask
344 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
346 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
351 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
352 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
353 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
356 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
357 Can only be executed in Privileged modes.
359 __attribute__((always_inline)) __STATIC_INLINE void __enable_fault_irq(void)
361 __ASM volatile ("cpsie f" : : : "memory");
367 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
368 Can only be executed in Privileged modes.
370 __attribute__((always_inline)) __STATIC_INLINE void __disable_fault_irq(void)
372 __ASM volatile ("cpsid f" : : : "memory");
377 \brief Get Base Priority
378 \details Returns the current value of the Base Priority register.
379 \return Base Priority register value
381 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
385 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
390 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
392 \brief Get Base Priority (non-secure)
393 \details Returns the current value of the non-secure Base Priority register when in secure state.
394 \return Base Priority register value
396 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
400 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
407 \brief Set Base Priority
408 \details Assigns the given value to the Base Priority register.
409 \param [in] basePri Base Priority value to set
411 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
413 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
417 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
419 \brief Set Base Priority (non-secure)
420 \details Assigns the given value to the non-secure Base Priority register when in secure state.
421 \param [in] basePri Base Priority value to set
423 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
425 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
431 \brief Set Base Priority with condition
432 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
433 or the new value increases the BASEPRI priority level.
434 \param [in] basePri Base Priority value to set
436 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
438 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
443 \brief Get Fault Mask
444 \details Returns the current value of the Fault Mask register.
445 \return Fault Mask register value
447 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
451 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
456 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
458 \brief Get Fault Mask (non-secure)
459 \details Returns the current value of the non-secure Fault Mask register when in secure state.
460 \return Fault Mask register value
462 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
466 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
473 \brief Set Fault Mask
474 \details Assigns the given value to the Fault Mask register.
475 \param [in] faultMask Fault Mask value to set
477 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
479 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
483 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
485 \brief Set Fault Mask (non-secure)
486 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
487 \param [in] faultMask Fault Mask value to set
489 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
491 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
495 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
496 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
497 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
500 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1U)) || \
501 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1U)) )
504 \brief Get Process Stack Pointer Limit
505 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
506 \return PSPLIM Register value
508 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
510 register uint32_t result;
512 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
517 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
518 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
520 \brief Get Process Stack Pointer Limit (non-secure)
521 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
522 \return PSPLIM Register value
524 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
526 register uint32_t result;
528 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
535 \brief Set Process Stack Pointer Limit
536 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
537 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
539 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
541 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
545 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
546 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
548 \brief Set Process Stack Pointer (non-secure)
549 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
550 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
552 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
554 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
560 \brief Get Main Stack Pointer Limit
561 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
562 \return MSPLIM Register value
564 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
566 register uint32_t result;
568 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
574 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
575 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
577 \brief Get Main Stack Pointer Limit (non-secure)
578 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
579 \return MSPLIM Register value
581 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
583 register uint32_t result;
585 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
592 \brief Set Main Stack Pointer Limit
593 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
594 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
596 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
598 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
602 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
603 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
605 \brief Set Main Stack Pointer Limit (non-secure)
606 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
607 \param [in] MainStackPtrLimit Main Stack Pointer value to set
609 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
611 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
615 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1U)) || \
616 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1U)) ) */
619 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
620 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
624 \details Returns the current value of the Floating Point Status/Control register.
625 \return Floating Point Status/Control register value
627 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
629 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
630 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
633 __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */
634 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
645 \details Assigns the given value to the Floating Point Status/Control register.
646 \param [in] fpscr Floating Point Status/Control value to set
648 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
650 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
651 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
652 __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */
653 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
658 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
659 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
663 /*@} end of CMSIS_Core_RegAccFunctions */
666 /* ########################## Core Instruction Access ######################### */
667 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
668 Access to dedicated instructions
672 /* Define macros for porting to both thumb1 and thumb2.
673 * For thumb1, use low register (r0-r7), specified by constraint "l"
674 * Otherwise, use general registers, specified by constraint "r" */
675 #if defined (__thumb__) && !defined (__thumb2__)
676 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
677 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
678 #define __CMSIS_GCC_USE_REG(r) "l" (r)
680 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
681 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
682 #define __CMSIS_GCC_USE_REG(r) "r" (r)
687 \details No Operation does nothing. This instruction can be used for code alignment purposes.
689 //__attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
691 // __ASM volatile ("nop");
693 #define __NOP() __ASM volatile ("nop") /* This implementation generates debug information */
696 \brief Wait For Interrupt
697 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
699 //__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
701 // __ASM volatile ("wfi");
703 #define __WFI() __ASM volatile ("wfi") /* This implementation generates debug information */
707 \brief Wait For Event
708 \details Wait For Event is a hint instruction that permits the processor to enter
709 a low-power state until one of a number of events occurs.
711 //__attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
713 // __ASM volatile ("wfe");
715 #define __WFE() __ASM volatile ("wfe") /* This implementation generates debug information */
720 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
722 //__attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
724 // __ASM volatile ("sev");
726 #define __SEV() __ASM volatile ("sev") /* This implementation generates debug information */
730 \brief Instruction Synchronization Barrier
731 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
732 so that all instructions following the ISB are fetched from cache or memory,
733 after the instruction has been completed.
735 __attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
737 __ASM volatile ("isb 0xF":::"memory");
742 \brief Data Synchronization Barrier
743 \details Acts as a special kind of Data Memory Barrier.
744 It completes when all explicit memory accesses before this instruction complete.
746 __attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
748 __ASM volatile ("dsb 0xF":::"memory");
753 \brief Data Memory Barrier
754 \details Ensures the apparent order of the explicit memory operations before
755 and after the instruction, without ensuring their completion.
757 __attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
759 __ASM volatile ("dmb 0xF":::"memory");
764 \brief Reverse byte order (32 bit)
765 \details Reverses the byte order in integer value.
766 \param [in] value Value to reverse
767 \return Reversed value
769 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
771 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
772 return __builtin_bswap32(value);
776 __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
783 \brief Reverse byte order (16 bit)
784 \details Reverses the byte order in two unsigned short values.
785 \param [in] value Value to reverse
786 \return Reversed value
788 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
792 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
798 \brief Reverse byte order in signed short value
799 \details Reverses the byte order in a signed short value with sign extension to integer.
800 \param [in] value Value to reverse
801 \return Reversed value
803 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
805 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
806 return (short)__builtin_bswap16(value);
810 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
817 \brief Rotate Right in unsigned value (32 bit)
818 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
819 \param [in] op1 Value to rotate
820 \param [in] op2 Number of Bits to rotate
821 \return Rotated value
823 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
825 return (op1 >> op2) | (op1 << (32U - op2));
831 \details Causes the processor to enter Debug state.
832 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
833 \param [in] value is ignored by the processor.
834 If required, a debugger can use it to store additional information about the breakpoint.
836 #define __BKPT(value) __ASM volatile ("bkpt "#value)
840 \brief Reverse bit order of value
841 \details Reverses the bit order of the given value.
842 \param [in] value Value to reverse
843 \return Reversed value
845 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
849 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
850 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
851 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
852 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
854 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
856 result = value; /* r will be reversed bits of v; first get LSB of v */
857 for (value >>= 1U; value; value >>= 1U)
860 result |= value & 1U;
863 result <<= s; /* shift when v's highest bits are zero */
870 \brief Count leading zeros
871 \details Counts the number of leading zeros of a data value.
872 \param [in] value Value to count the leading zeros
873 \return number of leading zeros in value
875 #define __CLZ __builtin_clz
878 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
879 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
880 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
881 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
883 \brief LDR Exclusive (8 bit)
884 \details Executes a exclusive LDR instruction for 8 bit value.
885 \param [in] ptr Pointer to data
886 \return value of type uint8_t at (*ptr)
888 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
892 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
893 __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
895 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
896 accepted by assembler. So has to use following less efficient pattern.
898 __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
900 return ((uint8_t) result); /* Add explicit type cast here */
905 \brief LDR Exclusive (16 bit)
906 \details Executes a exclusive LDR instruction for 16 bit values.
907 \param [in] ptr Pointer to data
908 \return value of type uint16_t at (*ptr)
910 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
914 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
915 __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
917 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
918 accepted by assembler. So has to use following less efficient pattern.
920 __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
922 return ((uint16_t) result); /* Add explicit type cast here */
927 \brief LDR Exclusive (32 bit)
928 \details Executes a exclusive LDR instruction for 32 bit values.
929 \param [in] ptr Pointer to data
930 \return value of type uint32_t at (*ptr)
932 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
936 __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
942 \brief STR Exclusive (8 bit)
943 \details Executes a exclusive STR instruction for 8 bit values.
944 \param [in] value Value to store
945 \param [in] ptr Pointer to location
946 \return 0 Function succeeded
947 \return 1 Function failed
949 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
953 __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
959 \brief STR Exclusive (16 bit)
960 \details Executes a exclusive STR instruction for 16 bit values.
961 \param [in] value Value to store
962 \param [in] ptr Pointer to location
963 \return 0 Function succeeded
964 \return 1 Function failed
966 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
970 __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
976 \brief STR Exclusive (32 bit)
977 \details Executes a exclusive STR instruction for 32 bit values.
978 \param [in] value Value to store
979 \param [in] ptr Pointer to location
980 \return 0 Function succeeded
981 \return 1 Function failed
983 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
987 __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
993 \brief Remove the exclusive lock
994 \details Removes the exclusive lock which is created by LDREX.
996 __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
998 __ASM volatile ("clrex" ::: "memory");
1003 \brief Signed Saturate
1004 \details Saturates a signed value.
1005 \param [in] value Value to be saturated
1006 \param [in] sat Bit position to saturate to (1..32)
1007 \return Saturated value
1009 #define __SSAT(ARG1,ARG2) \
1011 int32_t __RES, __ARG1 = (ARG1); \
1012 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1018 \brief Unsigned Saturate
1019 \details Saturates an unsigned value.
1020 \param [in] value Value to be saturated
1021 \param [in] sat Bit position to saturate to (0..31)
1022 \return Saturated value
1024 #define __USAT(ARG1,ARG2) \
1026 uint32_t __RES, __ARG1 = (ARG1); \
1027 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1033 \brief Rotate Right with Extend (32 bit)
1034 \details Moves each bit of a bitstring right by one bit.
1035 The carry input is shifted in at the left end of the bitstring.
1036 \param [in] value Value to rotate
1037 \return Rotated value
1039 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1043 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1049 \brief LDRT Unprivileged (8 bit)
1050 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1051 \param [in] ptr Pointer to data
1052 \return value of type uint8_t at (*ptr)
1054 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1058 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1059 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1061 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1062 accepted by assembler. So has to use following less efficient pattern.
1064 __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1066 return ((uint8_t) result); /* Add explicit type cast here */
1071 \brief LDRT Unprivileged (16 bit)
1072 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1073 \param [in] ptr Pointer to data
1074 \return value of type uint16_t at (*ptr)
1076 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1080 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1081 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1083 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1084 accepted by assembler. So has to use following less efficient pattern.
1086 __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1088 return ((uint16_t) result); /* Add explicit type cast here */
1093 \brief LDRT Unprivileged (32 bit)
1094 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1095 \param [in] ptr Pointer to data
1096 \return value of type uint32_t at (*ptr)
1098 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1102 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1108 \brief STRT Unprivileged (8 bit)
1109 \details Executes a Unprivileged STRT instruction for 8 bit values.
1110 \param [in] value Value to store
1111 \param [in] ptr Pointer to location
1113 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1115 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1120 \brief STRT Unprivileged (16 bit)
1121 \details Executes a Unprivileged STRT instruction for 16 bit values.
1122 \param [in] value Value to store
1123 \param [in] ptr Pointer to location
1125 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1127 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1132 \brief STRT Unprivileged (32 bit)
1133 \details Executes a Unprivileged STRT instruction for 32 bit values.
1134 \param [in] value Value to store
1135 \param [in] ptr Pointer to location
1137 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1139 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1142 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1143 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1144 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1145 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1148 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1149 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1151 \brief Load-Acquire (8 bit)
1152 \details Executes a LDAB instruction for 8 bit value.
1153 \param [in] ptr Pointer to data
1154 \return value of type uint8_t at (*ptr)
1156 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1160 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1161 return ((uint8_t) result);
1166 \brief Load-Acquire (16 bit)
1167 \details Executes a LDAH instruction for 16 bit values.
1168 \param [in] ptr Pointer to data
1169 \return value of type uint16_t at (*ptr)
1171 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1175 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1176 return ((uint16_t) result);
1181 \brief Load-Acquire (32 bit)
1182 \details Executes a LDA instruction for 32 bit values.
1183 \param [in] ptr Pointer to data
1184 \return value of type uint32_t at (*ptr)
1186 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1190 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1196 \brief Store-Release (8 bit)
1197 \details Executes a STLB instruction for 8 bit values.
1198 \param [in] value Value to store
1199 \param [in] ptr Pointer to location
1201 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1203 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1208 \brief Store-Release (16 bit)
1209 \details Executes a STLH instruction for 16 bit values.
1210 \param [in] value Value to store
1211 \param [in] ptr Pointer to location
1213 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1215 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1220 \brief Store-Release (32 bit)
1221 \details Executes a STL instruction for 32 bit values.
1222 \param [in] value Value to store
1223 \param [in] ptr Pointer to location
1225 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1227 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1232 \brief Load-Acquire Exclusive (8 bit)
1233 \details Executes a LDAB exclusive instruction for 8 bit value.
1234 \param [in] ptr Pointer to data
1235 \return value of type uint8_t at (*ptr)
1237 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1241 __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1242 return ((uint8_t) result);
1247 \brief Load-Acquire Exclusive (16 bit)
1248 \details Executes a LDAH exclusive instruction for 16 bit values.
1249 \param [in] ptr Pointer to data
1250 \return value of type uint16_t at (*ptr)
1252 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1256 __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1257 return ((uint16_t) result);
1262 \brief Load-Acquire Exclusive (32 bit)
1263 \details Executes a LDA exclusive instruction for 32 bit values.
1264 \param [in] ptr Pointer to data
1265 \return value of type uint32_t at (*ptr)
1267 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1271 __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1277 \brief Store-Release Exclusive (8 bit)
1278 \details Executes a STLB exclusive instruction for 8 bit values.
1279 \param [in] value Value to store
1280 \param [in] ptr Pointer to location
1281 \return 0 Function succeeded
1282 \return 1 Function failed
1284 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1288 __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1294 \brief Store-Release Exclusive (16 bit)
1295 \details Executes a STLH exclusive instruction for 16 bit values.
1296 \param [in] value Value to store
1297 \param [in] ptr Pointer to location
1298 \return 0 Function succeeded
1299 \return 1 Function failed
1301 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1305 __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1311 \brief Store-Release Exclusive (32 bit)
1312 \details Executes a STL exclusive instruction for 32 bit values.
1313 \param [in] value Value to store
1314 \param [in] ptr Pointer to location
1315 \return 0 Function succeeded
1316 \return 1 Function failed
1318 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1322 __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1326 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1327 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1329 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1332 /* ################### Compiler specific Intrinsics ########################### */
1333 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1334 Access to dedicated SIMD instructions
1338 #if (__ARM_FEATURE_DSP == 1) /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1340 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1344 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1348 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1352 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1356 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1360 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1364 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1368 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1372 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1376 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1380 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1384 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1389 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1393 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1397 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1401 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1405 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1409 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1413 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1417 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1421 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1425 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1429 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1433 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1438 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1442 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1446 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1450 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1454 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1458 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1462 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1466 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1470 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1474 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1478 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1482 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1486 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1490 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1494 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1498 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1502 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1506 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1510 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1514 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1518 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1522 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1526 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1530 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1534 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1538 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1542 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1546 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1550 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1554 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1558 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1562 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1566 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1570 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1574 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1578 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1582 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1586 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1590 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1594 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1598 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1602 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1606 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1610 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1614 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1618 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1622 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1626 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1630 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1634 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1638 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1642 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1646 #define __SSAT16(ARG1,ARG2) \
1648 int32_t __RES, __ARG1 = (ARG1); \
1649 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1653 #define __USAT16(ARG1,ARG2) \
1655 uint32_t __RES, __ARG1 = (ARG1); \
1656 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1660 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1664 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1668 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1672 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1676 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1680 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1684 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1688 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1692 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1696 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1700 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1704 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1708 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1712 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1716 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1720 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1724 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1732 #ifndef __ARMEB__ /* Little endian */
1733 __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]) );
1734 #else /* Big endian */
1735 __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]) );
1741 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1749 #ifndef __ARMEB__ /* Little endian */
1750 __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]) );
1751 #else /* Big endian */
1752 __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]) );
1758 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1762 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1766 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1770 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1774 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1778 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1782 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1786 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1790 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1798 #ifndef __ARMEB__ /* Little endian */
1799 __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]) );
1800 #else /* Big endian */
1801 __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]) );
1807 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1815 #ifndef __ARMEB__ /* Little endian */
1816 __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]) );
1817 #else /* Big endian */
1818 __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]) );
1824 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1828 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1832 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1836 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1840 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1844 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1849 #define __PKHBT(ARG1,ARG2,ARG3) \
1851 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1852 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1856 #define __PKHTB(ARG1,ARG2,ARG3) \
1858 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1860 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1862 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1867 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1868 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1870 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1871 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1873 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1877 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1881 #endif /* (__ARM_FEATURE_DSP == 1) */
1882 /*@} end of group CMSIS_SIMD_intrinsics */
1885 #pragma GCC diagnostic pop
1887 #endif /* __CMSIS_GCC_H */