1 /**************************************************************************//**
3 * @brief CMSIS compiler GCC header file
5 * @date 02. February 2017
6 ******************************************************************************/
8 * Copyright (c) 2009-2017 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.
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 #pragma GCC diagnostic push
55 #pragma GCC diagnostic ignored "-Wpacked"
56 #pragma GCC diagnostic ignored "-Wattributes"
57 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
58 #pragma GCC diagnostic pop
59 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
62 #define __ALIGNED(x) __attribute__((aligned(x)))
65 #define __PACKED __attribute__((packed, aligned(1)))
67 #ifndef __PACKED_STRUCT
68 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
72 /* ########################### Core Function Access ########################### */
73 /** \ingroup CMSIS_Core_FunctionInterface
74 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
79 \brief Enable IRQ Interrupts
80 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
81 Can only be executed in Privileged modes.
83 __attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void)
85 __ASM volatile ("cpsie i" : : : "memory");
90 \brief Disable IRQ Interrupts
91 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
92 Can only be executed in Privileged modes.
94 __attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void)
96 __ASM volatile ("cpsid i" : : : "memory");
101 \brief Get Control Register
102 \details Returns the content of the Control Register.
103 \return Control Register value
105 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
109 __ASM volatile ("MRS %0, control" : "=r" (result) );
114 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
116 \brief Get Control Register (non-secure)
117 \details Returns the content of the non-secure Control Register when in secure mode.
118 \return non-secure Control Register value
120 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
124 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
131 \brief Set Control Register
132 \details Writes the given value to the Control Register.
133 \param [in] control Control Register value to set
135 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
137 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
141 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
143 \brief Set Control Register (non-secure)
144 \details Writes the given value to the non-secure Control Register when in secure state.
145 \param [in] control Control Register value to set
147 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
149 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
155 \brief Get IPSR Register
156 \details Returns the content of the IPSR Register.
157 \return IPSR Register value
159 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
163 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
169 \brief Get APSR Register
170 \details Returns the content of the APSR Register.
171 \return APSR Register value
173 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
177 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
183 \brief Get xPSR Register
184 \details Returns the content of the xPSR Register.
185 \return xPSR Register value
187 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
191 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
197 \brief Get Process Stack Pointer
198 \details Returns the current value of the Process Stack Pointer (PSP).
199 \return PSP Register value
201 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
203 register uint32_t result;
205 __ASM volatile ("MRS %0, psp" : "=r" (result) );
210 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
212 \brief Get Process Stack Pointer (non-secure)
213 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
214 \return PSP Register value
216 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
218 register uint32_t result;
220 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
227 \brief Set Process Stack Pointer
228 \details Assigns the given value to the Process Stack Pointer (PSP).
229 \param [in] topOfProcStack Process Stack Pointer value to set
231 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
233 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
237 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
239 \brief Set Process Stack Pointer (non-secure)
240 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
241 \param [in] topOfProcStack Process Stack Pointer value to set
243 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
245 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
251 \brief Get Main Stack Pointer
252 \details Returns the current value of the Main Stack Pointer (MSP).
253 \return MSP Register value
255 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
257 register uint32_t result;
259 __ASM volatile ("MRS %0, msp" : "=r" (result) );
264 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
266 \brief Get Main Stack Pointer (non-secure)
267 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
268 \return MSP Register value
270 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
272 register uint32_t result;
274 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
281 \brief Set Main Stack Pointer
282 \details Assigns the given value to the Main Stack Pointer (MSP).
283 \param [in] topOfMainStack Main Stack Pointer value to set
285 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
287 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
291 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
293 \brief Set Main Stack Pointer (non-secure)
294 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
295 \param [in] topOfMainStack Main Stack Pointer value to set
297 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
299 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
305 \brief Get Priority Mask
306 \details Returns the current state of the priority mask bit from the Priority Mask Register.
307 \return Priority Mask value
309 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
313 __ASM volatile ("MRS %0, primask" : "=r" (result) );
318 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
320 \brief Get Priority Mask (non-secure)
321 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
322 \return Priority Mask value
324 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
328 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
335 \brief Set Priority Mask
336 \details Assigns the given value to the Priority Mask Register.
337 \param [in] priMask Priority Mask
339 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
341 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
345 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
347 \brief Set Priority Mask (non-secure)
348 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
349 \param [in] priMask Priority Mask
351 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
353 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
358 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
359 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
360 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
363 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
364 Can only be executed in Privileged modes.
366 __attribute__((always_inline)) __STATIC_INLINE void __enable_fault_irq(void)
368 __ASM volatile ("cpsie f" : : : "memory");
374 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
375 Can only be executed in Privileged modes.
377 __attribute__((always_inline)) __STATIC_INLINE void __disable_fault_irq(void)
379 __ASM volatile ("cpsid f" : : : "memory");
384 \brief Get Base Priority
385 \details Returns the current value of the Base Priority register.
386 \return Base Priority register value
388 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
392 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
397 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
399 \brief Get Base Priority (non-secure)
400 \details Returns the current value of the non-secure Base Priority register when in secure state.
401 \return Base Priority register value
403 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
407 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
414 \brief Set Base Priority
415 \details Assigns the given value to the Base Priority register.
416 \param [in] basePri Base Priority value to set
418 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
420 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
424 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
426 \brief Set Base Priority (non-secure)
427 \details Assigns the given value to the non-secure Base Priority register when in secure state.
428 \param [in] basePri Base Priority value to set
430 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
432 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
438 \brief Set Base Priority with condition
439 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
440 or the new value increases the BASEPRI priority level.
441 \param [in] basePri Base Priority value to set
443 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
445 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
450 \brief Get Fault Mask
451 \details Returns the current value of the Fault Mask register.
452 \return Fault Mask register value
454 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
458 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
463 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
465 \brief Get Fault Mask (non-secure)
466 \details Returns the current value of the non-secure Fault Mask register when in secure state.
467 \return Fault Mask register value
469 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
473 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
480 \brief Set Fault Mask
481 \details Assigns the given value to the Fault Mask register.
482 \param [in] faultMask Fault Mask value to set
484 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
486 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
490 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
492 \brief Set Fault Mask (non-secure)
493 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
494 \param [in] faultMask Fault Mask value to set
496 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
498 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
502 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
503 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
504 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
507 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
508 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
511 \brief Get Process Stack Pointer Limit
512 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
513 \return PSPLIM Register value
515 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
517 register uint32_t result;
519 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
524 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
525 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
527 \brief Get Process Stack Pointer Limit (non-secure)
528 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
529 \return PSPLIM Register value
531 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
533 register uint32_t result;
535 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
542 \brief Set Process Stack Pointer Limit
543 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
544 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
546 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
548 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
552 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
553 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
555 \brief Set Process Stack Pointer (non-secure)
556 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
557 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
559 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
561 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
567 \brief Get Main Stack Pointer Limit
568 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
569 \return MSPLIM Register value
571 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
573 register uint32_t result;
575 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
581 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
582 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
584 \brief Get Main Stack Pointer Limit (non-secure)
585 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
586 \return MSPLIM Register value
588 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
590 register uint32_t result;
592 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
599 \brief Set Main Stack Pointer Limit
600 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
601 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
603 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
605 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
609 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
610 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
612 \brief Set Main Stack Pointer Limit (non-secure)
613 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
614 \param [in] MainStackPtrLimit Main Stack Pointer value to set
616 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
618 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
622 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
623 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
626 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
627 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
631 \details Returns the current value of the Floating Point Status/Control register.
632 \return Floating Point Status/Control register value
634 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
636 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
637 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
640 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
650 \details Assigns the given value to the Floating Point Status/Control register.
651 \param [in] fpscr Floating Point Status/Control value to set
653 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
655 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
656 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
657 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory");
663 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
664 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
668 /*@} end of CMSIS_Core_RegAccFunctions */
671 /* ########################## Core Instruction Access ######################### */
672 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
673 Access to dedicated instructions
677 /* Define macros for porting to both thumb1 and thumb2.
678 * For thumb1, use low register (r0-r7), specified by constraint "l"
679 * Otherwise, use general registers, specified by constraint "r" */
680 #if defined (__thumb__) && !defined (__thumb2__)
681 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
682 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
683 #define __CMSIS_GCC_USE_REG(r) "l" (r)
685 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
686 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
687 #define __CMSIS_GCC_USE_REG(r) "r" (r)
692 \details No Operation does nothing. This instruction can be used for code alignment purposes.
694 //__attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
696 // __ASM volatile ("nop");
698 #define __NOP() __ASM volatile ("nop") /* This implementation generates debug information */
701 \brief Wait For Interrupt
702 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
704 //__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
706 // __ASM volatile ("wfi");
708 #define __WFI() __ASM volatile ("wfi") /* This implementation generates debug information */
712 \brief Wait For Event
713 \details Wait For Event is a hint instruction that permits the processor to enter
714 a low-power state until one of a number of events occurs.
716 //__attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
718 // __ASM volatile ("wfe");
720 #define __WFE() __ASM volatile ("wfe") /* This implementation generates debug information */
725 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
727 //__attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
729 // __ASM volatile ("sev");
731 #define __SEV() __ASM volatile ("sev") /* This implementation generates debug information */
735 \brief Instruction Synchronization Barrier
736 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
737 so that all instructions following the ISB are fetched from cache or memory,
738 after the instruction has been completed.
740 __attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
742 __ASM volatile ("isb 0xF":::"memory");
747 \brief Data Synchronization Barrier
748 \details Acts as a special kind of Data Memory Barrier.
749 It completes when all explicit memory accesses before this instruction complete.
751 __attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
753 __ASM volatile ("dsb 0xF":::"memory");
758 \brief Data Memory Barrier
759 \details Ensures the apparent order of the explicit memory operations before
760 and after the instruction, without ensuring their completion.
762 __attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
764 __ASM volatile ("dmb 0xF":::"memory");
769 \brief Reverse byte order (32 bit)
770 \details Reverses the byte order in integer value.
771 \param [in] value Value to reverse
772 \return Reversed value
774 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
776 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
777 return __builtin_bswap32(value);
781 __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
788 \brief Reverse byte order (16 bit)
789 \details Reverses the byte order in two unsigned short values.
790 \param [in] value Value to reverse
791 \return Reversed value
793 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
797 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
803 \brief Reverse byte order in signed short value
804 \details Reverses the byte order in a signed short value with sign extension to integer.
805 \param [in] value Value to reverse
806 \return Reversed value
808 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
810 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
811 return (short)__builtin_bswap16(value);
815 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
822 \brief Rotate Right in unsigned value (32 bit)
823 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
824 \param [in] op1 Value to rotate
825 \param [in] op2 Number of Bits to rotate
826 \return Rotated value
828 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
830 return (op1 >> op2) | (op1 << (32U - op2));
836 \details Causes the processor to enter Debug state.
837 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
838 \param [in] value is ignored by the processor.
839 If required, a debugger can use it to store additional information about the breakpoint.
841 #define __BKPT(value) __ASM volatile ("bkpt "#value)
845 \brief Reverse bit order of value
846 \details Reverses the bit order of the given value.
847 \param [in] value Value to reverse
848 \return Reversed value
850 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
854 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
855 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
856 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
857 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
859 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
861 result = value; /* r will be reversed bits of v; first get LSB of v */
862 for (value >>= 1U; value; value >>= 1U)
865 result |= value & 1U;
868 result <<= s; /* shift when v's highest bits are zero */
875 \brief Count leading zeros
876 \details Counts the number of leading zeros of a data value.
877 \param [in] value Value to count the leading zeros
878 \return number of leading zeros in value
880 #define __CLZ __builtin_clz
883 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
884 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
885 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
886 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
888 \brief LDR Exclusive (8 bit)
889 \details Executes a exclusive LDR instruction for 8 bit value.
890 \param [in] ptr Pointer to data
891 \return value of type uint8_t at (*ptr)
893 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
897 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
898 __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
900 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
901 accepted by assembler. So has to use following less efficient pattern.
903 __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
905 return ((uint8_t) result); /* Add explicit type cast here */
910 \brief LDR Exclusive (16 bit)
911 \details Executes a exclusive LDR instruction for 16 bit values.
912 \param [in] ptr Pointer to data
913 \return value of type uint16_t at (*ptr)
915 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
919 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
920 __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
922 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
923 accepted by assembler. So has to use following less efficient pattern.
925 __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
927 return ((uint16_t) result); /* Add explicit type cast here */
932 \brief LDR Exclusive (32 bit)
933 \details Executes a exclusive LDR instruction for 32 bit values.
934 \param [in] ptr Pointer to data
935 \return value of type uint32_t at (*ptr)
937 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
941 __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
947 \brief STR Exclusive (8 bit)
948 \details Executes a exclusive STR instruction for 8 bit values.
949 \param [in] value Value to store
950 \param [in] ptr Pointer to location
951 \return 0 Function succeeded
952 \return 1 Function failed
954 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
958 __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
964 \brief STR Exclusive (16 bit)
965 \details Executes a exclusive STR instruction for 16 bit values.
966 \param [in] value Value to store
967 \param [in] ptr Pointer to location
968 \return 0 Function succeeded
969 \return 1 Function failed
971 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
975 __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
981 \brief STR Exclusive (32 bit)
982 \details Executes a exclusive STR instruction for 32 bit values.
983 \param [in] value Value to store
984 \param [in] ptr Pointer to location
985 \return 0 Function succeeded
986 \return 1 Function failed
988 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
992 __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
998 \brief Remove the exclusive lock
999 \details Removes the exclusive lock which is created by LDREX.
1001 __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
1003 __ASM volatile ("clrex" ::: "memory");
1006 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1007 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1008 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1009 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1012 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1013 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1014 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1016 \brief Signed Saturate
1017 \details Saturates a signed value.
1018 \param [in] value Value to be saturated
1019 \param [in] sat Bit position to saturate to (1..32)
1020 \return Saturated value
1022 #define __SSAT(ARG1,ARG2) \
1024 int32_t __RES, __ARG1 = (ARG1); \
1025 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1031 \brief Unsigned Saturate
1032 \details Saturates an unsigned value.
1033 \param [in] value Value to be saturated
1034 \param [in] sat Bit position to saturate to (0..31)
1035 \return Saturated value
1037 #define __USAT(ARG1,ARG2) \
1039 uint32_t __RES, __ARG1 = (ARG1); \
1040 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1046 \brief Rotate Right with Extend (32 bit)
1047 \details Moves each bit of a bitstring right by one bit.
1048 The carry input is shifted in at the left end of the bitstring.
1049 \param [in] value Value to rotate
1050 \return Rotated value
1052 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1056 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1062 \brief LDRT Unprivileged (8 bit)
1063 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1064 \param [in] ptr Pointer to data
1065 \return value of type uint8_t at (*ptr)
1067 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1071 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1072 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1074 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1075 accepted by assembler. So has to use following less efficient pattern.
1077 __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1079 return ((uint8_t) result); /* Add explicit type cast here */
1084 \brief LDRT Unprivileged (16 bit)
1085 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1086 \param [in] ptr Pointer to data
1087 \return value of type uint16_t at (*ptr)
1089 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1093 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1094 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1096 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1097 accepted by assembler. So has to use following less efficient pattern.
1099 __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1101 return ((uint16_t) result); /* Add explicit type cast here */
1106 \brief LDRT Unprivileged (32 bit)
1107 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1108 \param [in] ptr Pointer to data
1109 \return value of type uint32_t at (*ptr)
1111 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1115 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1121 \brief STRT Unprivileged (8 bit)
1122 \details Executes a Unprivileged STRT instruction for 8 bit values.
1123 \param [in] value Value to store
1124 \param [in] ptr Pointer to location
1126 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1128 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1133 \brief STRT Unprivileged (16 bit)
1134 \details Executes a Unprivileged STRT instruction for 16 bit values.
1135 \param [in] value Value to store
1136 \param [in] ptr Pointer to location
1138 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1140 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1145 \brief STRT Unprivileged (32 bit)
1146 \details Executes a Unprivileged STRT instruction for 32 bit values.
1147 \param [in] value Value to store
1148 \param [in] ptr Pointer to location
1150 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1152 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1155 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1156 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1157 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1160 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1161 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1163 \brief Load-Acquire (8 bit)
1164 \details Executes a LDAB instruction for 8 bit value.
1165 \param [in] ptr Pointer to data
1166 \return value of type uint8_t at (*ptr)
1168 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1172 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1173 return ((uint8_t) result);
1178 \brief Load-Acquire (16 bit)
1179 \details Executes a LDAH instruction for 16 bit values.
1180 \param [in] ptr Pointer to data
1181 \return value of type uint16_t at (*ptr)
1183 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1187 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1188 return ((uint16_t) result);
1193 \brief Load-Acquire (32 bit)
1194 \details Executes a LDA instruction for 32 bit values.
1195 \param [in] ptr Pointer to data
1196 \return value of type uint32_t at (*ptr)
1198 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1202 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1208 \brief Store-Release (8 bit)
1209 \details Executes a STLB instruction for 8 bit values.
1210 \param [in] value Value to store
1211 \param [in] ptr Pointer to location
1213 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1215 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1220 \brief Store-Release (16 bit)
1221 \details Executes a STLH instruction for 16 bit values.
1222 \param [in] value Value to store
1223 \param [in] ptr Pointer to location
1225 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1227 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1232 \brief Store-Release (32 bit)
1233 \details Executes a STL instruction for 32 bit values.
1234 \param [in] value Value to store
1235 \param [in] ptr Pointer to location
1237 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1239 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1244 \brief Load-Acquire Exclusive (8 bit)
1245 \details Executes a LDAB exclusive instruction for 8 bit value.
1246 \param [in] ptr Pointer to data
1247 \return value of type uint8_t at (*ptr)
1249 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1253 __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1254 return ((uint8_t) result);
1259 \brief Load-Acquire Exclusive (16 bit)
1260 \details Executes a LDAH exclusive instruction for 16 bit values.
1261 \param [in] ptr Pointer to data
1262 \return value of type uint16_t at (*ptr)
1264 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1268 __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1269 return ((uint16_t) result);
1274 \brief Load-Acquire Exclusive (32 bit)
1275 \details Executes a LDA exclusive instruction for 32 bit values.
1276 \param [in] ptr Pointer to data
1277 \return value of type uint32_t at (*ptr)
1279 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1283 __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1289 \brief Store-Release Exclusive (8 bit)
1290 \details Executes a STLB exclusive instruction for 8 bit values.
1291 \param [in] value Value to store
1292 \param [in] ptr Pointer to location
1293 \return 0 Function succeeded
1294 \return 1 Function failed
1296 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1300 __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1306 \brief Store-Release Exclusive (16 bit)
1307 \details Executes a STLH exclusive instruction for 16 bit values.
1308 \param [in] value Value to store
1309 \param [in] ptr Pointer to location
1310 \return 0 Function succeeded
1311 \return 1 Function failed
1313 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1317 __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1323 \brief Store-Release Exclusive (32 bit)
1324 \details Executes a STL exclusive instruction for 32 bit values.
1325 \param [in] value Value to store
1326 \param [in] ptr Pointer to location
1327 \return 0 Function succeeded
1328 \return 1 Function failed
1330 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1334 __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1338 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1339 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1341 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1344 /* ################### Compiler specific Intrinsics ########################### */
1345 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1346 Access to dedicated SIMD instructions
1350 #if (__ARM_FEATURE_DSP == 1) /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1352 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1356 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1360 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1364 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1368 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1372 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1376 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1380 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1384 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1388 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1396 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1401 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1405 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1409 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1413 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1417 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1421 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1425 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1429 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1433 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1437 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1445 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1450 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1454 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1458 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1462 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1466 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1470 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1474 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1478 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1482 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1486 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1490 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1494 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1498 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1502 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1506 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1510 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1514 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1518 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1522 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1526 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1530 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1534 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1538 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1542 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1546 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1550 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1554 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1558 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1562 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1566 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1570 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1574 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1578 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1582 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1586 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1590 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1594 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1598 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1602 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1606 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1610 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1614 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1618 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1622 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1626 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1630 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1634 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1638 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1642 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1646 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1650 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1654 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1658 #define __SSAT16(ARG1,ARG2) \
1660 int32_t __RES, __ARG1 = (ARG1); \
1661 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1665 #define __USAT16(ARG1,ARG2) \
1667 uint32_t __RES, __ARG1 = (ARG1); \
1668 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1672 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1676 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1680 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1684 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1688 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1692 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1696 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1700 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1704 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1708 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1712 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1716 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1720 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1724 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1728 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1732 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1736 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1744 #ifndef __ARMEB__ /* Little endian */
1745 __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]) );
1746 #else /* Big endian */
1747 __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]) );
1753 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1761 #ifndef __ARMEB__ /* Little endian */
1762 __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]) );
1763 #else /* Big endian */
1764 __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]) );
1770 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1774 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1778 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1782 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1786 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1790 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1794 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1798 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1802 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1810 #ifndef __ARMEB__ /* Little endian */
1811 __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]) );
1812 #else /* Big endian */
1813 __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]) );
1819 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1827 #ifndef __ARMEB__ /* Little endian */
1828 __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]) );
1829 #else /* Big endian */
1830 __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]) );
1836 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1840 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1844 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1848 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1852 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1856 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1861 #define __PKHBT(ARG1,ARG2,ARG3) \
1863 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1864 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1868 #define __PKHTB(ARG1,ARG2,ARG3) \
1870 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1872 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1874 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1879 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1880 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1882 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1883 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1885 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1889 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1893 #endif /* (__ARM_FEATURE_DSP == 1) */
1894 /*@} end of group CMSIS_SIMD_intrinsics */
1897 #pragma GCC diagnostic pop
1899 #endif /* __CMSIS_GCC_H */