1 /**************************************************************************//**
3 * @brief CMSIS compiler GCC header file
5 * @date 13. 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))
54 #define __PACKED __attribute__((packed, aligned(1)))
56 #ifndef __PACKED_STRUCT
57 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
59 #ifndef __UNALIGNED_UINT32 /* deprecated */
60 #pragma GCC diagnostic push
61 #pragma GCC diagnostic ignored "-Wpacked"
62 #pragma GCC diagnostic ignored "-Wattributes"
63 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
64 #pragma GCC diagnostic pop
65 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
67 #ifndef __UNALIGNED_UINT16_WRITE
68 #pragma GCC diagnostic push
69 #pragma GCC diagnostic ignored "-Wpacked"
70 #pragma GCC diagnostic ignored "-Wattributes"
71 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
72 #pragma GCC diagnostic pop
73 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
75 #ifndef __UNALIGNED_UINT16_READ
76 #pragma GCC diagnostic push
77 #pragma GCC diagnostic ignored "-Wpacked"
78 #pragma GCC diagnostic ignored "-Wattributes"
79 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
80 #pragma GCC diagnostic pop
81 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
83 #ifndef __UNALIGNED_UINT32_WRITE
84 #pragma GCC diagnostic push
85 #pragma GCC diagnostic ignored "-Wpacked"
86 #pragma GCC diagnostic ignored "-Wattributes"
87 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
88 #pragma GCC diagnostic pop
89 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
91 #ifndef __UNALIGNED_UINT32_READ
92 #pragma GCC diagnostic push
93 #pragma GCC diagnostic ignored "-Wpacked"
94 #pragma GCC diagnostic ignored "-Wattributes"
95 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
96 #pragma GCC diagnostic pop
97 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
100 #define __ALIGNED(x) __attribute__((aligned(x)))
104 /* ########################### Core Function Access ########################### */
105 /** \ingroup CMSIS_Core_FunctionInterface
106 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
111 \brief Enable IRQ Interrupts
112 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
113 Can only be executed in Privileged modes.
115 __attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void)
117 __ASM volatile ("cpsie i" : : : "memory");
122 \brief Disable IRQ Interrupts
123 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
124 Can only be executed in Privileged modes.
126 __attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void)
128 __ASM volatile ("cpsid i" : : : "memory");
133 \brief Get Control Register
134 \details Returns the content of the Control Register.
135 \return Control Register value
137 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
141 __ASM volatile ("MRS %0, control" : "=r" (result) );
146 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
148 \brief Get Control Register (non-secure)
149 \details Returns the content of the non-secure Control Register when in secure mode.
150 \return non-secure Control Register value
152 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
156 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
163 \brief Set Control Register
164 \details Writes the given value to the Control Register.
165 \param [in] control Control Register value to set
167 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
169 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
173 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
175 \brief Set Control Register (non-secure)
176 \details Writes the given value to the non-secure Control Register when in secure state.
177 \param [in] control Control Register value to set
179 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
181 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
187 \brief Get IPSR Register
188 \details Returns the content of the IPSR Register.
189 \return IPSR Register value
191 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
195 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
201 \brief Get APSR Register
202 \details Returns the content of the APSR Register.
203 \return APSR Register value
205 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
209 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
215 \brief Get xPSR Register
216 \details Returns the content of the xPSR Register.
217 \return xPSR Register value
219 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
223 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
229 \brief Get Process Stack Pointer
230 \details Returns the current value of the Process Stack Pointer (PSP).
231 \return PSP Register value
233 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
235 register uint32_t result;
237 __ASM volatile ("MRS %0, psp" : "=r" (result) );
242 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
244 \brief Get Process Stack Pointer (non-secure)
245 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
246 \return PSP Register value
248 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
250 register uint32_t result;
252 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
259 \brief Set Process Stack Pointer
260 \details Assigns the given value to the Process Stack Pointer (PSP).
261 \param [in] topOfProcStack Process Stack Pointer value to set
263 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
265 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
269 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
271 \brief Set Process Stack Pointer (non-secure)
272 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
273 \param [in] topOfProcStack Process Stack Pointer value to set
275 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
277 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
283 \brief Get Main Stack Pointer
284 \details Returns the current value of the Main Stack Pointer (MSP).
285 \return MSP Register value
287 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
289 register uint32_t result;
291 __ASM volatile ("MRS %0, msp" : "=r" (result) );
296 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
298 \brief Get Main Stack Pointer (non-secure)
299 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
300 \return MSP Register value
302 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
304 register uint32_t result;
306 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
313 \brief Set Main Stack Pointer
314 \details Assigns the given value to the Main Stack Pointer (MSP).
315 \param [in] topOfMainStack Main Stack Pointer value to set
317 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
319 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
323 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
325 \brief Set Main Stack Pointer (non-secure)
326 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
327 \param [in] topOfMainStack Main Stack Pointer value to set
329 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
331 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
337 \brief Get Priority Mask
338 \details Returns the current state of the priority mask bit from the Priority Mask Register.
339 \return Priority Mask value
341 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
345 __ASM volatile ("MRS %0, primask" : "=r" (result) );
350 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
352 \brief Get Priority Mask (non-secure)
353 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
354 \return Priority Mask value
356 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
360 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
367 \brief Set Priority Mask
368 \details Assigns the given value to the Priority Mask Register.
369 \param [in] priMask Priority Mask
371 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
373 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
377 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
379 \brief Set Priority Mask (non-secure)
380 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
381 \param [in] priMask Priority Mask
383 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
385 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
390 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
391 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
392 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
395 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
396 Can only be executed in Privileged modes.
398 __attribute__((always_inline)) __STATIC_INLINE void __enable_fault_irq(void)
400 __ASM volatile ("cpsie f" : : : "memory");
406 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
407 Can only be executed in Privileged modes.
409 __attribute__((always_inline)) __STATIC_INLINE void __disable_fault_irq(void)
411 __ASM volatile ("cpsid f" : : : "memory");
416 \brief Get Base Priority
417 \details Returns the current value of the Base Priority register.
418 \return Base Priority register value
420 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
424 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
429 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
431 \brief Get Base Priority (non-secure)
432 \details Returns the current value of the non-secure Base Priority register when in secure state.
433 \return Base Priority register value
435 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
439 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
446 \brief Set Base Priority
447 \details Assigns the given value to the Base Priority register.
448 \param [in] basePri Base Priority value to set
450 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
452 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
456 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
458 \brief Set Base Priority (non-secure)
459 \details Assigns the given value to the non-secure Base Priority register when in secure state.
460 \param [in] basePri Base Priority value to set
462 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
464 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
470 \brief Set Base Priority with condition
471 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
472 or the new value increases the BASEPRI priority level.
473 \param [in] basePri Base Priority value to set
475 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
477 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
482 \brief Get Fault Mask
483 \details Returns the current value of the Fault Mask register.
484 \return Fault Mask register value
486 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
490 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
495 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
497 \brief Get Fault Mask (non-secure)
498 \details Returns the current value of the non-secure Fault Mask register when in secure state.
499 \return Fault Mask register value
501 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
505 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
512 \brief Set Fault Mask
513 \details Assigns the given value to the Fault Mask register.
514 \param [in] faultMask Fault Mask value to set
516 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
518 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
522 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
524 \brief Set Fault Mask (non-secure)
525 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
526 \param [in] faultMask Fault Mask value to set
528 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
530 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
534 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
535 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
536 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
539 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
540 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
543 \brief Get Process Stack Pointer Limit
544 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
545 \return PSPLIM Register value
547 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
549 register uint32_t result;
551 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
556 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
557 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
559 \brief Get Process Stack Pointer Limit (non-secure)
560 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
561 \return PSPLIM Register value
563 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
565 register uint32_t result;
567 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
574 \brief Set Process Stack Pointer Limit
575 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
576 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
578 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
580 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
584 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
585 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
587 \brief Set Process Stack Pointer (non-secure)
588 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
589 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
591 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
593 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
599 \brief Get Main Stack Pointer Limit
600 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
601 \return MSPLIM Register value
603 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
605 register uint32_t result;
607 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
613 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
614 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
616 \brief Get Main Stack Pointer Limit (non-secure)
617 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
618 \return MSPLIM Register value
620 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
622 register uint32_t result;
624 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
631 \brief Set Main Stack Pointer Limit
632 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
633 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
635 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
637 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
641 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
642 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
644 \brief Set Main Stack Pointer Limit (non-secure)
645 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
646 \param [in] MainStackPtrLimit Main Stack Pointer value to set
648 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
650 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
654 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
655 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
658 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
659 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
663 \details Returns the current value of the Floating Point Status/Control register.
664 \return Floating Point Status/Control register value
666 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
668 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
669 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
672 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
682 \details Assigns the given value to the Floating Point Status/Control register.
683 \param [in] fpscr Floating Point Status/Control value to set
685 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
687 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
688 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
689 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory");
695 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
696 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
700 /*@} end of CMSIS_Core_RegAccFunctions */
703 /* ########################## Core Instruction Access ######################### */
704 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
705 Access to dedicated instructions
709 /* Define macros for porting to both thumb1 and thumb2.
710 * For thumb1, use low register (r0-r7), specified by constraint "l"
711 * Otherwise, use general registers, specified by constraint "r" */
712 #if defined (__thumb__) && !defined (__thumb2__)
713 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
714 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
715 #define __CMSIS_GCC_USE_REG(r) "l" (r)
717 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
718 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
719 #define __CMSIS_GCC_USE_REG(r) "r" (r)
724 \details No Operation does nothing. This instruction can be used for code alignment purposes.
726 //__attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
728 // __ASM volatile ("nop");
730 #define __NOP() __ASM volatile ("nop") /* This implementation generates debug information */
733 \brief Wait For Interrupt
734 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
736 //__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
738 // __ASM volatile ("wfi");
740 #define __WFI() __ASM volatile ("wfi") /* This implementation generates debug information */
744 \brief Wait For Event
745 \details Wait For Event is a hint instruction that permits the processor to enter
746 a low-power state until one of a number of events occurs.
748 //__attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
750 // __ASM volatile ("wfe");
752 #define __WFE() __ASM volatile ("wfe") /* This implementation generates debug information */
757 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
759 //__attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
761 // __ASM volatile ("sev");
763 #define __SEV() __ASM volatile ("sev") /* This implementation generates debug information */
767 \brief Instruction Synchronization Barrier
768 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
769 so that all instructions following the ISB are fetched from cache or memory,
770 after the instruction has been completed.
772 __attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
774 __ASM volatile ("isb 0xF":::"memory");
779 \brief Data Synchronization Barrier
780 \details Acts as a special kind of Data Memory Barrier.
781 It completes when all explicit memory accesses before this instruction complete.
783 __attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
785 __ASM volatile ("dsb 0xF":::"memory");
790 \brief Data Memory Barrier
791 \details Ensures the apparent order of the explicit memory operations before
792 and after the instruction, without ensuring their completion.
794 __attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
796 __ASM volatile ("dmb 0xF":::"memory");
801 \brief Reverse byte order (32 bit)
802 \details Reverses the byte order in integer value.
803 \param [in] value Value to reverse
804 \return Reversed value
806 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
808 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
809 return __builtin_bswap32(value);
813 __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
820 \brief Reverse byte order (16 bit)
821 \details Reverses the byte order in two unsigned short values.
822 \param [in] value Value to reverse
823 \return Reversed value
825 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
829 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
835 \brief Reverse byte order in signed short value
836 \details Reverses the byte order in a signed short value with sign extension to integer.
837 \param [in] value Value to reverse
838 \return Reversed value
840 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
842 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
843 return (short)__builtin_bswap16(value);
847 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
854 \brief Rotate Right in unsigned value (32 bit)
855 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
856 \param [in] op1 Value to rotate
857 \param [in] op2 Number of Bits to rotate
858 \return Rotated value
860 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
862 return (op1 >> op2) | (op1 << (32U - op2));
868 \details Causes the processor to enter Debug state.
869 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
870 \param [in] value is ignored by the processor.
871 If required, a debugger can use it to store additional information about the breakpoint.
873 #define __BKPT(value) __ASM volatile ("bkpt "#value)
877 \brief Reverse bit order of value
878 \details Reverses the bit order of the given value.
879 \param [in] value Value to reverse
880 \return Reversed value
882 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
886 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
887 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
888 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
889 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
891 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
893 result = value; /* r will be reversed bits of v; first get LSB of v */
894 for (value >>= 1U; value; value >>= 1U)
897 result |= value & 1U;
900 result <<= s; /* shift when v's highest bits are zero */
907 \brief Count leading zeros
908 \details Counts the number of leading zeros of a data value.
909 \param [in] value Value to count the leading zeros
910 \return number of leading zeros in value
912 #define __CLZ __builtin_clz
915 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
916 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
917 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
918 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
920 \brief LDR Exclusive (8 bit)
921 \details Executes a exclusive LDR instruction for 8 bit value.
922 \param [in] ptr Pointer to data
923 \return value of type uint8_t at (*ptr)
925 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
929 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
930 __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
932 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
933 accepted by assembler. So has to use following less efficient pattern.
935 __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
937 return ((uint8_t) result); /* Add explicit type cast here */
942 \brief LDR Exclusive (16 bit)
943 \details Executes a exclusive LDR instruction for 16 bit values.
944 \param [in] ptr Pointer to data
945 \return value of type uint16_t at (*ptr)
947 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
951 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
952 __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
954 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
955 accepted by assembler. So has to use following less efficient pattern.
957 __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
959 return ((uint16_t) result); /* Add explicit type cast here */
964 \brief LDR Exclusive (32 bit)
965 \details Executes a exclusive LDR instruction for 32 bit values.
966 \param [in] ptr Pointer to data
967 \return value of type uint32_t at (*ptr)
969 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
973 __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
979 \brief STR Exclusive (8 bit)
980 \details Executes a exclusive STR instruction for 8 bit values.
981 \param [in] value Value to store
982 \param [in] ptr Pointer to location
983 \return 0 Function succeeded
984 \return 1 Function failed
986 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
990 __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
996 \brief STR Exclusive (16 bit)
997 \details Executes a exclusive STR instruction for 16 bit values.
998 \param [in] value Value to store
999 \param [in] ptr Pointer to location
1000 \return 0 Function succeeded
1001 \return 1 Function failed
1003 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
1007 __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
1013 \brief STR Exclusive (32 bit)
1014 \details Executes a exclusive STR instruction for 32 bit values.
1015 \param [in] value Value to store
1016 \param [in] ptr Pointer to location
1017 \return 0 Function succeeded
1018 \return 1 Function failed
1020 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
1024 __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
1030 \brief Remove the exclusive lock
1031 \details Removes the exclusive lock which is created by LDREX.
1033 __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
1035 __ASM volatile ("clrex" ::: "memory");
1038 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1039 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1040 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1041 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1044 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1045 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1046 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1048 \brief Signed Saturate
1049 \details Saturates a signed value.
1050 \param [in] value Value to be saturated
1051 \param [in] sat Bit position to saturate to (1..32)
1052 \return Saturated value
1054 #define __SSAT(ARG1,ARG2) \
1056 int32_t __RES, __ARG1 = (ARG1); \
1057 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1063 \brief Unsigned Saturate
1064 \details Saturates an unsigned value.
1065 \param [in] value Value to be saturated
1066 \param [in] sat Bit position to saturate to (0..31)
1067 \return Saturated value
1069 #define __USAT(ARG1,ARG2) \
1071 uint32_t __RES, __ARG1 = (ARG1); \
1072 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1078 \brief Rotate Right with Extend (32 bit)
1079 \details Moves each bit of a bitstring right by one bit.
1080 The carry input is shifted in at the left end of the bitstring.
1081 \param [in] value Value to rotate
1082 \return Rotated value
1084 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1088 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1094 \brief LDRT Unprivileged (8 bit)
1095 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1096 \param [in] ptr Pointer to data
1097 \return value of type uint8_t at (*ptr)
1099 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1103 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1104 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1106 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1107 accepted by assembler. So has to use following less efficient pattern.
1109 __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1111 return ((uint8_t) result); /* Add explicit type cast here */
1116 \brief LDRT Unprivileged (16 bit)
1117 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1118 \param [in] ptr Pointer to data
1119 \return value of type uint16_t at (*ptr)
1121 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1125 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1126 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1128 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1129 accepted by assembler. So has to use following less efficient pattern.
1131 __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1133 return ((uint16_t) result); /* Add explicit type cast here */
1138 \brief LDRT Unprivileged (32 bit)
1139 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1140 \param [in] ptr Pointer to data
1141 \return value of type uint32_t at (*ptr)
1143 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1147 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1153 \brief STRT Unprivileged (8 bit)
1154 \details Executes a Unprivileged STRT instruction for 8 bit values.
1155 \param [in] value Value to store
1156 \param [in] ptr Pointer to location
1158 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1160 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1165 \brief STRT Unprivileged (16 bit)
1166 \details Executes a Unprivileged STRT instruction for 16 bit values.
1167 \param [in] value Value to store
1168 \param [in] ptr Pointer to location
1170 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1172 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1177 \brief STRT Unprivileged (32 bit)
1178 \details Executes a Unprivileged STRT instruction for 32 bit values.
1179 \param [in] value Value to store
1180 \param [in] ptr Pointer to location
1182 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1184 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1187 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1188 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1189 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1192 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1193 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1195 \brief Load-Acquire (8 bit)
1196 \details Executes a LDAB instruction for 8 bit value.
1197 \param [in] ptr Pointer to data
1198 \return value of type uint8_t at (*ptr)
1200 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1204 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1205 return ((uint8_t) result);
1210 \brief Load-Acquire (16 bit)
1211 \details Executes a LDAH instruction for 16 bit values.
1212 \param [in] ptr Pointer to data
1213 \return value of type uint16_t at (*ptr)
1215 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1219 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1220 return ((uint16_t) result);
1225 \brief Load-Acquire (32 bit)
1226 \details Executes a LDA instruction for 32 bit values.
1227 \param [in] ptr Pointer to data
1228 \return value of type uint32_t at (*ptr)
1230 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1234 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1240 \brief Store-Release (8 bit)
1241 \details Executes a STLB instruction for 8 bit values.
1242 \param [in] value Value to store
1243 \param [in] ptr Pointer to location
1245 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1247 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1252 \brief Store-Release (16 bit)
1253 \details Executes a STLH instruction for 16 bit values.
1254 \param [in] value Value to store
1255 \param [in] ptr Pointer to location
1257 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1259 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1264 \brief Store-Release (32 bit)
1265 \details Executes a STL instruction for 32 bit values.
1266 \param [in] value Value to store
1267 \param [in] ptr Pointer to location
1269 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1271 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1276 \brief Load-Acquire Exclusive (8 bit)
1277 \details Executes a LDAB exclusive instruction for 8 bit value.
1278 \param [in] ptr Pointer to data
1279 \return value of type uint8_t at (*ptr)
1281 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1285 __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1286 return ((uint8_t) result);
1291 \brief Load-Acquire Exclusive (16 bit)
1292 \details Executes a LDAH exclusive instruction for 16 bit values.
1293 \param [in] ptr Pointer to data
1294 \return value of type uint16_t at (*ptr)
1296 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1300 __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1301 return ((uint16_t) result);
1306 \brief Load-Acquire Exclusive (32 bit)
1307 \details Executes a LDA exclusive instruction for 32 bit values.
1308 \param [in] ptr Pointer to data
1309 \return value of type uint32_t at (*ptr)
1311 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1315 __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1321 \brief Store-Release Exclusive (8 bit)
1322 \details Executes a STLB exclusive instruction for 8 bit values.
1323 \param [in] value Value to store
1324 \param [in] ptr Pointer to location
1325 \return 0 Function succeeded
1326 \return 1 Function failed
1328 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1332 __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1338 \brief Store-Release Exclusive (16 bit)
1339 \details Executes a STLH exclusive instruction for 16 bit values.
1340 \param [in] value Value to store
1341 \param [in] ptr Pointer to location
1342 \return 0 Function succeeded
1343 \return 1 Function failed
1345 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1349 __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1355 \brief Store-Release Exclusive (32 bit)
1356 \details Executes a STL exclusive instruction for 32 bit values.
1357 \param [in] value Value to store
1358 \param [in] ptr Pointer to location
1359 \return 0 Function succeeded
1360 \return 1 Function failed
1362 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1366 __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1370 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1371 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1373 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1376 /* ################### Compiler specific Intrinsics ########################### */
1377 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1378 Access to dedicated SIMD instructions
1382 #if (__ARM_FEATURE_DSP == 1) /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1384 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1388 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1396 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1400 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1404 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1408 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1412 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1416 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1420 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1424 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1428 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1433 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1437 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1445 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1449 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1453 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1457 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1461 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1465 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1469 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1473 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1477 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1482 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1486 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1490 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1494 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1498 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1502 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1506 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1510 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1514 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1518 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1522 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1526 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1530 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1534 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1538 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1542 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1546 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1550 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1554 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1558 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1562 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1566 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1570 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1574 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1578 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1582 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1586 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1590 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1594 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1598 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1602 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1606 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1610 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1614 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1618 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1622 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1626 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1630 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1634 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1638 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1642 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1646 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1650 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1654 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1658 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1662 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1666 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1670 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1674 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1678 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1682 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1686 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1690 #define __SSAT16(ARG1,ARG2) \
1692 int32_t __RES, __ARG1 = (ARG1); \
1693 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1697 #define __USAT16(ARG1,ARG2) \
1699 uint32_t __RES, __ARG1 = (ARG1); \
1700 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1704 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1708 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1712 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1716 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1720 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1724 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1728 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1732 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1736 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1740 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1744 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1748 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1752 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1756 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1760 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1764 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1768 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1776 #ifndef __ARMEB__ /* Little endian */
1777 __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]) );
1778 #else /* Big endian */
1779 __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]) );
1785 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1793 #ifndef __ARMEB__ /* Little endian */
1794 __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]) );
1795 #else /* Big endian */
1796 __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]) );
1802 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1806 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1810 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1814 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1818 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1822 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1826 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1830 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1834 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1842 #ifndef __ARMEB__ /* Little endian */
1843 __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]) );
1844 #else /* Big endian */
1845 __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]) );
1851 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1859 #ifndef __ARMEB__ /* Little endian */
1860 __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]) );
1861 #else /* Big endian */
1862 __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]) );
1868 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1872 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1876 __attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1880 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1884 __attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1888 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1893 #define __PKHBT(ARG1,ARG2,ARG3) \
1895 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1896 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1900 #define __PKHTB(ARG1,ARG2,ARG3) \
1902 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1904 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1906 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1911 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1912 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1914 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1915 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1917 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1921 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1925 #endif /* (__ARM_FEATURE_DSP == 1) */
1926 /*@} end of group CMSIS_SIMD_intrinsics */
1929 #pragma GCC diagnostic pop
1931 #endif /* __CMSIS_GCC_H */