1 /**************************************************************************//**
\r
2 * @file cmsis_armcc.h
\r
3 * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
\r
5 * @date 10. January 2018
\r
6 ******************************************************************************/
\r
8 * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
\r
10 * SPDX-License-Identifier: Apache-2.0
\r
12 * Licensed under the Apache License, Version 2.0 (the License); you may
\r
13 * not use this file except in compliance with the License.
\r
14 * You may obtain a copy of the License at
\r
16 * www.apache.org/licenses/LICENSE-2.0
\r
18 * Unless required by applicable law or agreed to in writing, software
\r
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
\r
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
21 * See the License for the specific language governing permissions and
\r
22 * limitations under the License.
\r
25 #ifndef __CMSIS_ARMCC_H
\r
26 #define __CMSIS_ARMCC_H
\r
29 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
\r
30 #error "Please use Arm Compiler Toolchain V4.0.677 or later!"
\r
33 /* CMSIS compiler control architecture macros */
\r
34 #if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
\r
35 (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
\r
36 #define __ARM_ARCH_6M__ 1
\r
39 #if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
\r
40 #define __ARM_ARCH_7M__ 1
\r
43 #if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
\r
44 #define __ARM_ARCH_7EM__ 1
\r
47 /* __ARM_ARCH_8M_BASE__ not applicable */
\r
48 /* __ARM_ARCH_8M_MAIN__ not applicable */
\r
51 /* CMSIS compiler specific defines */
\r
56 #define __INLINE __inline
\r
58 #ifndef __STATIC_INLINE
\r
59 #define __STATIC_INLINE static __inline
\r
61 #ifndef __STATIC_FORCEINLINE
\r
62 #define __STATIC_FORCEINLINE static __forceinline
\r
65 #define __NO_RETURN __declspec(noreturn)
\r
68 #define __USED __attribute__((used))
\r
71 #define __WEAK __attribute__((weak))
\r
74 #define __PACKED __attribute__((packed))
\r
76 #ifndef __PACKED_STRUCT
\r
77 #define __PACKED_STRUCT __packed struct
\r
79 #ifndef __PACKED_UNION
\r
80 #define __PACKED_UNION __packed union
\r
82 #ifndef __UNALIGNED_UINT32 /* deprecated */
\r
83 #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
\r
85 #ifndef __UNALIGNED_UINT16_WRITE
\r
86 #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
\r
88 #ifndef __UNALIGNED_UINT16_READ
\r
89 #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
\r
91 #ifndef __UNALIGNED_UINT32_WRITE
\r
92 #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
\r
94 #ifndef __UNALIGNED_UINT32_READ
\r
95 #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
\r
98 #define __ALIGNED(x) __attribute__((aligned(x)))
\r
101 #define __RESTRICT __restrict
\r
104 /* ########################### Core Function Access ########################### */
\r
105 /** \ingroup CMSIS_Core_FunctionInterface
\r
106 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
\r
111 \brief Enable IRQ Interrupts
\r
112 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
\r
113 Can only be executed in Privileged modes.
\r
115 /* intrinsic void __enable_irq(); */
\r
119 \brief Disable IRQ Interrupts
\r
120 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
\r
121 Can only be executed in Privileged modes.
\r
123 /* intrinsic void __disable_irq(); */
\r
126 \brief Get Control Register
\r
127 \details Returns the content of the Control Register.
\r
128 \return Control Register value
\r
130 __STATIC_INLINE uint32_t __get_CONTROL(void)
\r
132 register uint32_t __regControl __ASM("control");
\r
133 return(__regControl);
\r
138 \brief Set Control Register
\r
139 \details Writes the given value to the Control Register.
\r
140 \param [in] control Control Register value to set
\r
142 __STATIC_INLINE void __set_CONTROL(uint32_t control)
\r
144 register uint32_t __regControl __ASM("control");
\r
145 __regControl = control;
\r
150 \brief Get IPSR Register
\r
151 \details Returns the content of the IPSR Register.
\r
152 \return IPSR Register value
\r
154 __STATIC_INLINE uint32_t __get_IPSR(void)
\r
156 register uint32_t __regIPSR __ASM("ipsr");
\r
162 \brief Get APSR Register
\r
163 \details Returns the content of the APSR Register.
\r
164 \return APSR Register value
\r
166 __STATIC_INLINE uint32_t __get_APSR(void)
\r
168 register uint32_t __regAPSR __ASM("apsr");
\r
174 \brief Get xPSR Register
\r
175 \details Returns the content of the xPSR Register.
\r
176 \return xPSR Register value
\r
178 __STATIC_INLINE uint32_t __get_xPSR(void)
\r
180 register uint32_t __regXPSR __ASM("xpsr");
\r
186 \brief Get Process Stack Pointer
\r
187 \details Returns the current value of the Process Stack Pointer (PSP).
\r
188 \return PSP Register value
\r
190 __STATIC_INLINE uint32_t __get_PSP(void)
\r
192 register uint32_t __regProcessStackPointer __ASM("psp");
\r
193 return(__regProcessStackPointer);
\r
198 \brief Set Process Stack Pointer
\r
199 \details Assigns the given value to the Process Stack Pointer (PSP).
\r
200 \param [in] topOfProcStack Process Stack Pointer value to set
\r
202 __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
\r
204 register uint32_t __regProcessStackPointer __ASM("psp");
\r
205 __regProcessStackPointer = topOfProcStack;
\r
210 \brief Get Main Stack Pointer
\r
211 \details Returns the current value of the Main Stack Pointer (MSP).
\r
212 \return MSP Register value
\r
214 __STATIC_INLINE uint32_t __get_MSP(void)
\r
216 register uint32_t __regMainStackPointer __ASM("msp");
\r
217 return(__regMainStackPointer);
\r
222 \brief Set Main Stack Pointer
\r
223 \details Assigns the given value to the Main Stack Pointer (MSP).
\r
224 \param [in] topOfMainStack Main Stack Pointer value to set
\r
226 __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
\r
228 register uint32_t __regMainStackPointer __ASM("msp");
\r
229 __regMainStackPointer = topOfMainStack;
\r
234 \brief Get Priority Mask
\r
235 \details Returns the current state of the priority mask bit from the Priority Mask Register.
\r
236 \return Priority Mask value
\r
238 __STATIC_INLINE uint32_t __get_PRIMASK(void)
\r
240 register uint32_t __regPriMask __ASM("primask");
\r
241 return(__regPriMask);
\r
246 \brief Set Priority Mask
\r
247 \details Assigns the given value to the Priority Mask Register.
\r
248 \param [in] priMask Priority Mask
\r
250 __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
\r
252 register uint32_t __regPriMask __ASM("primask");
\r
253 __regPriMask = (priMask);
\r
257 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
\r
258 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
\r
262 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
\r
263 Can only be executed in Privileged modes.
\r
265 #define __enable_fault_irq __enable_fiq
\r
270 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
\r
271 Can only be executed in Privileged modes.
\r
273 #define __disable_fault_irq __disable_fiq
\r
277 \brief Get Base Priority
\r
278 \details Returns the current value of the Base Priority register.
\r
279 \return Base Priority register value
\r
281 __STATIC_INLINE uint32_t __get_BASEPRI(void)
\r
283 register uint32_t __regBasePri __ASM("basepri");
\r
284 return(__regBasePri);
\r
289 \brief Set Base Priority
\r
290 \details Assigns the given value to the Base Priority register.
\r
291 \param [in] basePri Base Priority value to set
\r
293 __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
\r
295 register uint32_t __regBasePri __ASM("basepri");
\r
296 __regBasePri = (basePri & 0xFFU);
\r
301 \brief Set Base Priority with condition
\r
302 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
\r
303 or the new value increases the BASEPRI priority level.
\r
304 \param [in] basePri Base Priority value to set
\r
306 __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
\r
308 register uint32_t __regBasePriMax __ASM("basepri_max");
\r
309 __regBasePriMax = (basePri & 0xFFU);
\r
314 \brief Get Fault Mask
\r
315 \details Returns the current value of the Fault Mask register.
\r
316 \return Fault Mask register value
\r
318 __STATIC_INLINE uint32_t __get_FAULTMASK(void)
\r
320 register uint32_t __regFaultMask __ASM("faultmask");
\r
321 return(__regFaultMask);
\r
326 \brief Set Fault Mask
\r
327 \details Assigns the given value to the Fault Mask register.
\r
328 \param [in] faultMask Fault Mask value to set
\r
330 __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
\r
332 register uint32_t __regFaultMask __ASM("faultmask");
\r
333 __regFaultMask = (faultMask & (uint32_t)1U);
\r
336 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
\r
337 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
\r
342 \details Returns the current value of the Floating Point Status/Control register.
\r
343 \return Floating Point Status/Control register value
\r
345 __STATIC_INLINE uint32_t __get_FPSCR(void)
\r
347 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
\r
348 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
\r
349 register uint32_t __regfpscr __ASM("fpscr");
\r
350 return(__regfpscr);
\r
359 \details Assigns the given value to the Floating Point Status/Control register.
\r
360 \param [in] fpscr Floating Point Status/Control value to set
\r
362 __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
\r
364 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
\r
365 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
\r
366 register uint32_t __regfpscr __ASM("fpscr");
\r
367 __regfpscr = (fpscr);
\r
374 /*@} end of CMSIS_Core_RegAccFunctions */
\r
377 /* ########################## Core Instruction Access ######################### */
\r
378 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
\r
379 Access to dedicated instructions
\r
384 \brief No Operation
\r
385 \details No Operation does nothing. This instruction can be used for code alignment purposes.
\r
387 #define __NOP __nop
\r
391 \brief Wait For Interrupt
\r
392 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
\r
394 #define __WFI __wfi
\r
398 \brief Wait For Event
\r
399 \details Wait For Event is a hint instruction that permits the processor to enter
\r
400 a low-power state until one of a number of events occurs.
\r
402 #define __WFE __wfe
\r
407 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
\r
409 #define __SEV __sev
\r
413 \brief Instruction Synchronization Barrier
\r
414 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
\r
415 so that all instructions following the ISB are fetched from cache or memory,
\r
416 after the instruction has been completed.
\r
418 #define __ISB() do {\
\r
419 __schedule_barrier();\
\r
421 __schedule_barrier();\
\r
425 \brief Data Synchronization Barrier
\r
426 \details Acts as a special kind of Data Memory Barrier.
\r
427 It completes when all explicit memory accesses before this instruction complete.
\r
429 #define __DSB() do {\
\r
430 __schedule_barrier();\
\r
432 __schedule_barrier();\
\r
436 \brief Data Memory Barrier
\r
437 \details Ensures the apparent order of the explicit memory operations before
\r
438 and after the instruction, without ensuring their completion.
\r
440 #define __DMB() do {\
\r
441 __schedule_barrier();\
\r
443 __schedule_barrier();\
\r
448 \brief Reverse byte order (32 bit)
\r
449 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
\r
450 \param [in] value Value to reverse
\r
451 \return Reversed value
\r
453 #define __REV __rev
\r
457 \brief Reverse byte order (16 bit)
\r
458 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
\r
459 \param [in] value Value to reverse
\r
460 \return Reversed value
\r
462 #ifndef __NO_EMBEDDED_ASM
\r
463 __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
\r
472 \brief Reverse byte order (16 bit)
\r
473 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
\r
474 \param [in] value Value to reverse
\r
475 \return Reversed value
\r
477 #ifndef __NO_EMBEDDED_ASM
\r
478 __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
\r
487 \brief Rotate Right in unsigned value (32 bit)
\r
488 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
\r
489 \param [in] op1 Value to rotate
\r
490 \param [in] op2 Number of Bits to rotate
\r
491 \return Rotated value
\r
493 #define __ROR __ror
\r
498 \details Causes the processor to enter Debug state.
\r
499 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
\r
500 \param [in] value is ignored by the processor.
\r
501 If required, a debugger can use it to store additional information about the breakpoint.
\r
503 #define __BKPT(value) __breakpoint(value)
\r
507 \brief Reverse bit order of value
\r
508 \details Reverses the bit order of the given value.
\r
509 \param [in] value Value to reverse
\r
510 \return Reversed value
\r
512 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
\r
513 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
\r
514 #define __RBIT __rbit
\r
516 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
\r
519 uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
\r
521 result = value; /* r will be reversed bits of v; first get LSB of v */
\r
522 for (value >>= 1U; value != 0U; value >>= 1U)
\r
525 result |= value & 1U;
\r
528 result <<= s; /* shift when v's highest bits are zero */
\r
535 \brief Count leading zeros
\r
536 \details Counts the number of leading zeros of a data value.
\r
537 \param [in] value Value to count the leading zeros
\r
538 \return number of leading zeros in value
\r
540 #define __CLZ __clz
\r
543 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
\r
544 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
\r
547 \brief LDR Exclusive (8 bit)
\r
548 \details Executes a exclusive LDR instruction for 8 bit value.
\r
549 \param [in] ptr Pointer to data
\r
550 \return value of type uint8_t at (*ptr)
\r
552 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
\r
553 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
\r
555 #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
\r
560 \brief LDR Exclusive (16 bit)
\r
561 \details Executes a exclusive LDR instruction for 16 bit values.
\r
562 \param [in] ptr Pointer to data
\r
563 \return value of type uint16_t at (*ptr)
\r
565 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
\r
566 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
\r
568 #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
\r
573 \brief LDR Exclusive (32 bit)
\r
574 \details Executes a exclusive LDR instruction for 32 bit values.
\r
575 \param [in] ptr Pointer to data
\r
576 \return value of type uint32_t at (*ptr)
\r
578 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
\r
579 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
\r
581 #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
\r
586 \brief STR Exclusive (8 bit)
\r
587 \details Executes a exclusive STR instruction for 8 bit values.
\r
588 \param [in] value Value to store
\r
589 \param [in] ptr Pointer to location
\r
590 \return 0 Function succeeded
\r
591 \return 1 Function failed
\r
593 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
\r
594 #define __STREXB(value, ptr) __strex(value, ptr)
\r
596 #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
\r
601 \brief STR Exclusive (16 bit)
\r
602 \details Executes a exclusive STR instruction for 16 bit values.
\r
603 \param [in] value Value to store
\r
604 \param [in] ptr Pointer to location
\r
605 \return 0 Function succeeded
\r
606 \return 1 Function failed
\r
608 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
\r
609 #define __STREXH(value, ptr) __strex(value, ptr)
\r
611 #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
\r
616 \brief STR Exclusive (32 bit)
\r
617 \details Executes a exclusive STR instruction for 32 bit values.
\r
618 \param [in] value Value to store
\r
619 \param [in] ptr Pointer to location
\r
620 \return 0 Function succeeded
\r
621 \return 1 Function failed
\r
623 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
\r
624 #define __STREXW(value, ptr) __strex(value, ptr)
\r
626 #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
\r
631 \brief Remove the exclusive lock
\r
632 \details Removes the exclusive lock which is created by LDREX.
\r
634 #define __CLREX __clrex
\r
638 \brief Signed Saturate
\r
639 \details Saturates a signed value.
\r
640 \param [in] value Value to be saturated
\r
641 \param [in] sat Bit position to saturate to (1..32)
\r
642 \return Saturated value
\r
644 #define __SSAT __ssat
\r
648 \brief Unsigned Saturate
\r
649 \details Saturates an unsigned value.
\r
650 \param [in] value Value to be saturated
\r
651 \param [in] sat Bit position to saturate to (0..31)
\r
652 \return Saturated value
\r
654 #define __USAT __usat
\r
658 \brief Rotate Right with Extend (32 bit)
\r
659 \details Moves each bit of a bitstring right by one bit.
\r
660 The carry input is shifted in at the left end of the bitstring.
\r
661 \param [in] value Value to rotate
\r
662 \return Rotated value
\r
664 #ifndef __NO_EMBEDDED_ASM
\r
665 __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
\r
674 \brief LDRT Unprivileged (8 bit)
\r
675 \details Executes a Unprivileged LDRT instruction for 8 bit value.
\r
676 \param [in] ptr Pointer to data
\r
677 \return value of type uint8_t at (*ptr)
\r
679 #define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
\r
683 \brief LDRT Unprivileged (16 bit)
\r
684 \details Executes a Unprivileged LDRT instruction for 16 bit values.
\r
685 \param [in] ptr Pointer to data
\r
686 \return value of type uint16_t at (*ptr)
\r
688 #define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
\r
692 \brief LDRT Unprivileged (32 bit)
\r
693 \details Executes a Unprivileged LDRT instruction for 32 bit values.
\r
694 \param [in] ptr Pointer to data
\r
695 \return value of type uint32_t at (*ptr)
\r
697 #define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
\r
701 \brief STRT Unprivileged (8 bit)
\r
702 \details Executes a Unprivileged STRT instruction for 8 bit values.
\r
703 \param [in] value Value to store
\r
704 \param [in] ptr Pointer to location
\r
706 #define __STRBT(value, ptr) __strt(value, ptr)
\r
710 \brief STRT Unprivileged (16 bit)
\r
711 \details Executes a Unprivileged STRT instruction for 16 bit values.
\r
712 \param [in] value Value to store
\r
713 \param [in] ptr Pointer to location
\r
715 #define __STRHT(value, ptr) __strt(value, ptr)
\r
719 \brief STRT Unprivileged (32 bit)
\r
720 \details Executes a Unprivileged STRT instruction for 32 bit values.
\r
721 \param [in] value Value to store
\r
722 \param [in] ptr Pointer to location
\r
724 #define __STRT(value, ptr) __strt(value, ptr)
\r
726 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
\r
727 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
\r
730 \brief Signed Saturate
\r
731 \details Saturates a signed value.
\r
732 \param [in] value Value to be saturated
\r
733 \param [in] sat Bit position to saturate to (1..32)
\r
734 \return Saturated value
\r
736 __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
\r
738 if ((sat >= 1U) && (sat <= 32U))
\r
740 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
\r
741 const int32_t min = -1 - max ;
\r
746 else if (val < min)
\r
755 \brief Unsigned Saturate
\r
756 \details Saturates an unsigned value.
\r
757 \param [in] value Value to be saturated
\r
758 \param [in] sat Bit position to saturate to (0..31)
\r
759 \return Saturated value
\r
761 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
\r
765 const uint32_t max = ((1U << sat) - 1U);
\r
766 if (val > (int32_t)max)
\r
775 return (uint32_t)val;
\r
778 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
\r
779 (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
\r
781 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
\r
784 /* ################### Compiler specific Intrinsics ########################### */
\r
785 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
\r
786 Access to dedicated SIMD instructions
\r
790 #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
\r
792 #define __SADD8 __sadd8
\r
793 #define __QADD8 __qadd8
\r
794 #define __SHADD8 __shadd8
\r
795 #define __UADD8 __uadd8
\r
796 #define __UQADD8 __uqadd8
\r
797 #define __UHADD8 __uhadd8
\r
798 #define __SSUB8 __ssub8
\r
799 #define __QSUB8 __qsub8
\r
800 #define __SHSUB8 __shsub8
\r
801 #define __USUB8 __usub8
\r
802 #define __UQSUB8 __uqsub8
\r
803 #define __UHSUB8 __uhsub8
\r
804 #define __SADD16 __sadd16
\r
805 #define __QADD16 __qadd16
\r
806 #define __SHADD16 __shadd16
\r
807 #define __UADD16 __uadd16
\r
808 #define __UQADD16 __uqadd16
\r
809 #define __UHADD16 __uhadd16
\r
810 #define __SSUB16 __ssub16
\r
811 #define __QSUB16 __qsub16
\r
812 #define __SHSUB16 __shsub16
\r
813 #define __USUB16 __usub16
\r
814 #define __UQSUB16 __uqsub16
\r
815 #define __UHSUB16 __uhsub16
\r
816 #define __SASX __sasx
\r
817 #define __QASX __qasx
\r
818 #define __SHASX __shasx
\r
819 #define __UASX __uasx
\r
820 #define __UQASX __uqasx
\r
821 #define __UHASX __uhasx
\r
822 #define __SSAX __ssax
\r
823 #define __QSAX __qsax
\r
824 #define __SHSAX __shsax
\r
825 #define __USAX __usax
\r
826 #define __UQSAX __uqsax
\r
827 #define __UHSAX __uhsax
\r
828 #define __USAD8 __usad8
\r
829 #define __USADA8 __usada8
\r
830 #define __SSAT16 __ssat16
\r
831 #define __USAT16 __usat16
\r
832 #define __UXTB16 __uxtb16
\r
833 #define __UXTAB16 __uxtab16
\r
834 #define __SXTB16 __sxtb16
\r
835 #define __SXTAB16 __sxtab16
\r
836 #define __SMUAD __smuad
\r
837 #define __SMUADX __smuadx
\r
838 #define __SMLAD __smlad
\r
839 #define __SMLADX __smladx
\r
840 #define __SMLALD __smlald
\r
841 #define __SMLALDX __smlaldx
\r
842 #define __SMUSD __smusd
\r
843 #define __SMUSDX __smusdx
\r
844 #define __SMLSD __smlsd
\r
845 #define __SMLSDX __smlsdx
\r
846 #define __SMLSLD __smlsld
\r
847 #define __SMLSLDX __smlsldx
\r
848 #define __SEL __sel
\r
849 #define __QADD __qadd
\r
850 #define __QSUB __qsub
\r
852 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
\r
853 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
\r
855 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
\r
856 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
\r
858 #define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
\r
859 ((int64_t)(ARG3) << 32U) ) >> 32U))
\r
861 #endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
\r
862 /*@} end of group CMSIS_SIMD_intrinsics */
\r
865 #endif /* __CMSIS_ARMCC_H */
\r