xref: /btstack/port/stm32-wb55xx-nucleo-freertos/Drivers/CMSIS/Include/cmsis_armcc.h (revision 0561b2d8d5dba972c7daa57d5e677f7a1327edfd)
1*0561b2d8STREFOU Felix /**************************************************************************//**
2*0561b2d8STREFOU Felix  * @file     cmsis_armcc.h
3*0561b2d8STREFOU Felix  * @brief    CMSIS compiler ARMCC (Arm Compiler 5) header file
4*0561b2d8STREFOU Felix  * @version  V5.0.4
5*0561b2d8STREFOU Felix  * @date     10. January 2018
6*0561b2d8STREFOU Felix  ******************************************************************************/
7*0561b2d8STREFOU Felix /*
8*0561b2d8STREFOU Felix  * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
9*0561b2d8STREFOU Felix  *
10*0561b2d8STREFOU Felix  * SPDX-License-Identifier: Apache-2.0
11*0561b2d8STREFOU Felix  *
12*0561b2d8STREFOU Felix  * Licensed under the Apache License, Version 2.0 (the License); you may
13*0561b2d8STREFOU Felix  * not use this file except in compliance with the License.
14*0561b2d8STREFOU Felix  * You may obtain a copy of the License at
15*0561b2d8STREFOU Felix  *
16*0561b2d8STREFOU Felix  * www.apache.org/licenses/LICENSE-2.0
17*0561b2d8STREFOU Felix  *
18*0561b2d8STREFOU Felix  * Unless required by applicable law or agreed to in writing, software
19*0561b2d8STREFOU Felix  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20*0561b2d8STREFOU Felix  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21*0561b2d8STREFOU Felix  * See the License for the specific language governing permissions and
22*0561b2d8STREFOU Felix  * limitations under the License.
23*0561b2d8STREFOU Felix  */
24*0561b2d8STREFOU Felix 
25*0561b2d8STREFOU Felix #ifndef __CMSIS_ARMCC_H
26*0561b2d8STREFOU Felix #define __CMSIS_ARMCC_H
27*0561b2d8STREFOU Felix 
28*0561b2d8STREFOU Felix 
29*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
30*0561b2d8STREFOU Felix   #error "Please use Arm Compiler Toolchain V4.0.677 or later!"
31*0561b2d8STREFOU Felix #endif
32*0561b2d8STREFOU Felix 
33*0561b2d8STREFOU Felix /* CMSIS compiler control architecture macros */
34*0561b2d8STREFOU Felix #if ((defined (__TARGET_ARCH_6_M  ) && (__TARGET_ARCH_6_M   == 1)) || \
35*0561b2d8STREFOU Felix      (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M  == 1))   )
36*0561b2d8STREFOU Felix   #define __ARM_ARCH_6M__           1
37*0561b2d8STREFOU Felix #endif
38*0561b2d8STREFOU Felix 
39*0561b2d8STREFOU Felix #if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M  == 1))
40*0561b2d8STREFOU Felix   #define __ARM_ARCH_7M__           1
41*0561b2d8STREFOU Felix #endif
42*0561b2d8STREFOU Felix 
43*0561b2d8STREFOU Felix #if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
44*0561b2d8STREFOU Felix   #define __ARM_ARCH_7EM__          1
45*0561b2d8STREFOU Felix #endif
46*0561b2d8STREFOU Felix 
47*0561b2d8STREFOU Felix   /* __ARM_ARCH_8M_BASE__  not applicable */
48*0561b2d8STREFOU Felix   /* __ARM_ARCH_8M_MAIN__  not applicable */
49*0561b2d8STREFOU Felix 
50*0561b2d8STREFOU Felix 
51*0561b2d8STREFOU Felix /* CMSIS compiler specific defines */
52*0561b2d8STREFOU Felix #ifndef   __ASM
53*0561b2d8STREFOU Felix   #define __ASM                                  __asm
54*0561b2d8STREFOU Felix #endif
55*0561b2d8STREFOU Felix #ifndef   __INLINE
56*0561b2d8STREFOU Felix   #define __INLINE                               __inline
57*0561b2d8STREFOU Felix #endif
58*0561b2d8STREFOU Felix #ifndef   __STATIC_INLINE
59*0561b2d8STREFOU Felix   #define __STATIC_INLINE                        static __inline
60*0561b2d8STREFOU Felix #endif
61*0561b2d8STREFOU Felix #ifndef   __STATIC_FORCEINLINE
62*0561b2d8STREFOU Felix   #define __STATIC_FORCEINLINE                   static __forceinline
63*0561b2d8STREFOU Felix #endif
64*0561b2d8STREFOU Felix #ifndef   __NO_RETURN
65*0561b2d8STREFOU Felix   #define __NO_RETURN                            __declspec(noreturn)
66*0561b2d8STREFOU Felix #endif
67*0561b2d8STREFOU Felix #ifndef   __USED
68*0561b2d8STREFOU Felix   #define __USED                                 __attribute__((used))
69*0561b2d8STREFOU Felix #endif
70*0561b2d8STREFOU Felix #ifndef   __WEAK
71*0561b2d8STREFOU Felix   #define __WEAK                                 __attribute__((weak))
72*0561b2d8STREFOU Felix #endif
73*0561b2d8STREFOU Felix #ifndef   __PACKED
74*0561b2d8STREFOU Felix   #define __PACKED                               __attribute__((packed))
75*0561b2d8STREFOU Felix #endif
76*0561b2d8STREFOU Felix #ifndef   __PACKED_STRUCT
77*0561b2d8STREFOU Felix   #define __PACKED_STRUCT                        __packed struct
78*0561b2d8STREFOU Felix #endif
79*0561b2d8STREFOU Felix #ifndef   __PACKED_UNION
80*0561b2d8STREFOU Felix   #define __PACKED_UNION                         __packed union
81*0561b2d8STREFOU Felix #endif
82*0561b2d8STREFOU Felix #ifndef   __UNALIGNED_UINT32        /* deprecated */
83*0561b2d8STREFOU Felix   #define __UNALIGNED_UINT32(x)                  (*((__packed uint32_t *)(x)))
84*0561b2d8STREFOU Felix #endif
85*0561b2d8STREFOU Felix #ifndef   __UNALIGNED_UINT16_WRITE
86*0561b2d8STREFOU Felix   #define __UNALIGNED_UINT16_WRITE(addr, val)    ((*((__packed uint16_t *)(addr))) = (val))
87*0561b2d8STREFOU Felix #endif
88*0561b2d8STREFOU Felix #ifndef   __UNALIGNED_UINT16_READ
89*0561b2d8STREFOU Felix   #define __UNALIGNED_UINT16_READ(addr)          (*((const __packed uint16_t *)(addr)))
90*0561b2d8STREFOU Felix #endif
91*0561b2d8STREFOU Felix #ifndef   __UNALIGNED_UINT32_WRITE
92*0561b2d8STREFOU Felix   #define __UNALIGNED_UINT32_WRITE(addr, val)    ((*((__packed uint32_t *)(addr))) = (val))
93*0561b2d8STREFOU Felix #endif
94*0561b2d8STREFOU Felix #ifndef   __UNALIGNED_UINT32_READ
95*0561b2d8STREFOU Felix   #define __UNALIGNED_UINT32_READ(addr)          (*((const __packed uint32_t *)(addr)))
96*0561b2d8STREFOU Felix #endif
97*0561b2d8STREFOU Felix #ifndef   __ALIGNED
98*0561b2d8STREFOU Felix   #define __ALIGNED(x)                           __attribute__((aligned(x)))
99*0561b2d8STREFOU Felix #endif
100*0561b2d8STREFOU Felix #ifndef   __RESTRICT
101*0561b2d8STREFOU Felix   #define __RESTRICT                             __restrict
102*0561b2d8STREFOU Felix #endif
103*0561b2d8STREFOU Felix 
104*0561b2d8STREFOU Felix /* ###########################  Core Function Access  ########################### */
105*0561b2d8STREFOU Felix /** \ingroup  CMSIS_Core_FunctionInterface
106*0561b2d8STREFOU Felix     \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
107*0561b2d8STREFOU Felix   @{
108*0561b2d8STREFOU Felix  */
109*0561b2d8STREFOU Felix 
110*0561b2d8STREFOU Felix /**
111*0561b2d8STREFOU Felix   \brief   Enable IRQ Interrupts
112*0561b2d8STREFOU Felix   \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
113*0561b2d8STREFOU Felix            Can only be executed in Privileged modes.
114*0561b2d8STREFOU Felix  */
115*0561b2d8STREFOU Felix /* intrinsic void __enable_irq();     */
116*0561b2d8STREFOU Felix 
117*0561b2d8STREFOU Felix 
118*0561b2d8STREFOU Felix /**
119*0561b2d8STREFOU Felix   \brief   Disable IRQ Interrupts
120*0561b2d8STREFOU Felix   \details Disables IRQ interrupts by setting the I-bit in the CPSR.
121*0561b2d8STREFOU Felix            Can only be executed in Privileged modes.
122*0561b2d8STREFOU Felix  */
123*0561b2d8STREFOU Felix /* intrinsic void __disable_irq();    */
124*0561b2d8STREFOU Felix 
125*0561b2d8STREFOU Felix /**
126*0561b2d8STREFOU Felix   \brief   Get Control Register
127*0561b2d8STREFOU Felix   \details Returns the content of the Control Register.
128*0561b2d8STREFOU Felix   \return               Control Register value
129*0561b2d8STREFOU Felix  */
__get_CONTROL(void)130*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_CONTROL(void)
131*0561b2d8STREFOU Felix {
132*0561b2d8STREFOU Felix   register uint32_t __regControl         __ASM("control");
133*0561b2d8STREFOU Felix   return(__regControl);
134*0561b2d8STREFOU Felix }
135*0561b2d8STREFOU Felix 
136*0561b2d8STREFOU Felix 
137*0561b2d8STREFOU Felix /**
138*0561b2d8STREFOU Felix   \brief   Set Control Register
139*0561b2d8STREFOU Felix   \details Writes the given value to the Control Register.
140*0561b2d8STREFOU Felix   \param [in]    control  Control Register value to set
141*0561b2d8STREFOU Felix  */
__set_CONTROL(uint32_t control)142*0561b2d8STREFOU Felix __STATIC_INLINE void __set_CONTROL(uint32_t control)
143*0561b2d8STREFOU Felix {
144*0561b2d8STREFOU Felix   register uint32_t __regControl         __ASM("control");
145*0561b2d8STREFOU Felix   __regControl = control;
146*0561b2d8STREFOU Felix }
147*0561b2d8STREFOU Felix 
148*0561b2d8STREFOU Felix 
149*0561b2d8STREFOU Felix /**
150*0561b2d8STREFOU Felix   \brief   Get IPSR Register
151*0561b2d8STREFOU Felix   \details Returns the content of the IPSR Register.
152*0561b2d8STREFOU Felix   \return               IPSR Register value
153*0561b2d8STREFOU Felix  */
__get_IPSR(void)154*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_IPSR(void)
155*0561b2d8STREFOU Felix {
156*0561b2d8STREFOU Felix   register uint32_t __regIPSR          __ASM("ipsr");
157*0561b2d8STREFOU Felix   return(__regIPSR);
158*0561b2d8STREFOU Felix }
159*0561b2d8STREFOU Felix 
160*0561b2d8STREFOU Felix 
161*0561b2d8STREFOU Felix /**
162*0561b2d8STREFOU Felix   \brief   Get APSR Register
163*0561b2d8STREFOU Felix   \details Returns the content of the APSR Register.
164*0561b2d8STREFOU Felix   \return               APSR Register value
165*0561b2d8STREFOU Felix  */
__get_APSR(void)166*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_APSR(void)
167*0561b2d8STREFOU Felix {
168*0561b2d8STREFOU Felix   register uint32_t __regAPSR          __ASM("apsr");
169*0561b2d8STREFOU Felix   return(__regAPSR);
170*0561b2d8STREFOU Felix }
171*0561b2d8STREFOU Felix 
172*0561b2d8STREFOU Felix 
173*0561b2d8STREFOU Felix /**
174*0561b2d8STREFOU Felix   \brief   Get xPSR Register
175*0561b2d8STREFOU Felix   \details Returns the content of the xPSR Register.
176*0561b2d8STREFOU Felix   \return               xPSR Register value
177*0561b2d8STREFOU Felix  */
__get_xPSR(void)178*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_xPSR(void)
179*0561b2d8STREFOU Felix {
180*0561b2d8STREFOU Felix   register uint32_t __regXPSR          __ASM("xpsr");
181*0561b2d8STREFOU Felix   return(__regXPSR);
182*0561b2d8STREFOU Felix }
183*0561b2d8STREFOU Felix 
184*0561b2d8STREFOU Felix 
185*0561b2d8STREFOU Felix /**
186*0561b2d8STREFOU Felix   \brief   Get Process Stack Pointer
187*0561b2d8STREFOU Felix   \details Returns the current value of the Process Stack Pointer (PSP).
188*0561b2d8STREFOU Felix   \return               PSP Register value
189*0561b2d8STREFOU Felix  */
__get_PSP(void)190*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_PSP(void)
191*0561b2d8STREFOU Felix {
192*0561b2d8STREFOU Felix   register uint32_t __regProcessStackPointer  __ASM("psp");
193*0561b2d8STREFOU Felix   return(__regProcessStackPointer);
194*0561b2d8STREFOU Felix }
195*0561b2d8STREFOU Felix 
196*0561b2d8STREFOU Felix 
197*0561b2d8STREFOU Felix /**
198*0561b2d8STREFOU Felix   \brief   Set Process Stack Pointer
199*0561b2d8STREFOU Felix   \details Assigns the given value to the Process Stack Pointer (PSP).
200*0561b2d8STREFOU Felix   \param [in]    topOfProcStack  Process Stack Pointer value to set
201*0561b2d8STREFOU Felix  */
__set_PSP(uint32_t topOfProcStack)202*0561b2d8STREFOU Felix __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
203*0561b2d8STREFOU Felix {
204*0561b2d8STREFOU Felix   register uint32_t __regProcessStackPointer  __ASM("psp");
205*0561b2d8STREFOU Felix   __regProcessStackPointer = topOfProcStack;
206*0561b2d8STREFOU Felix }
207*0561b2d8STREFOU Felix 
208*0561b2d8STREFOU Felix 
209*0561b2d8STREFOU Felix /**
210*0561b2d8STREFOU Felix   \brief   Get Main Stack Pointer
211*0561b2d8STREFOU Felix   \details Returns the current value of the Main Stack Pointer (MSP).
212*0561b2d8STREFOU Felix   \return               MSP Register value
213*0561b2d8STREFOU Felix  */
__get_MSP(void)214*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_MSP(void)
215*0561b2d8STREFOU Felix {
216*0561b2d8STREFOU Felix   register uint32_t __regMainStackPointer     __ASM("msp");
217*0561b2d8STREFOU Felix   return(__regMainStackPointer);
218*0561b2d8STREFOU Felix }
219*0561b2d8STREFOU Felix 
220*0561b2d8STREFOU Felix 
221*0561b2d8STREFOU Felix /**
222*0561b2d8STREFOU Felix   \brief   Set Main Stack Pointer
223*0561b2d8STREFOU Felix   \details Assigns the given value to the Main Stack Pointer (MSP).
224*0561b2d8STREFOU Felix   \param [in]    topOfMainStack  Main Stack Pointer value to set
225*0561b2d8STREFOU Felix  */
__set_MSP(uint32_t topOfMainStack)226*0561b2d8STREFOU Felix __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
227*0561b2d8STREFOU Felix {
228*0561b2d8STREFOU Felix   register uint32_t __regMainStackPointer     __ASM("msp");
229*0561b2d8STREFOU Felix   __regMainStackPointer = topOfMainStack;
230*0561b2d8STREFOU Felix }
231*0561b2d8STREFOU Felix 
232*0561b2d8STREFOU Felix 
233*0561b2d8STREFOU Felix /**
234*0561b2d8STREFOU Felix   \brief   Get Priority Mask
235*0561b2d8STREFOU Felix   \details Returns the current state of the priority mask bit from the Priority Mask Register.
236*0561b2d8STREFOU Felix   \return               Priority Mask value
237*0561b2d8STREFOU Felix  */
__get_PRIMASK(void)238*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_PRIMASK(void)
239*0561b2d8STREFOU Felix {
240*0561b2d8STREFOU Felix   register uint32_t __regPriMask         __ASM("primask");
241*0561b2d8STREFOU Felix   return(__regPriMask);
242*0561b2d8STREFOU Felix }
243*0561b2d8STREFOU Felix 
244*0561b2d8STREFOU Felix 
245*0561b2d8STREFOU Felix /**
246*0561b2d8STREFOU Felix   \brief   Set Priority Mask
247*0561b2d8STREFOU Felix   \details Assigns the given value to the Priority Mask Register.
248*0561b2d8STREFOU Felix   \param [in]    priMask  Priority Mask
249*0561b2d8STREFOU Felix  */
__set_PRIMASK(uint32_t priMask)250*0561b2d8STREFOU Felix __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
251*0561b2d8STREFOU Felix {
252*0561b2d8STREFOU Felix   register uint32_t __regPriMask         __ASM("primask");
253*0561b2d8STREFOU Felix   __regPriMask = (priMask);
254*0561b2d8STREFOU Felix }
255*0561b2d8STREFOU Felix 
256*0561b2d8STREFOU Felix 
257*0561b2d8STREFOU Felix #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__  == 1)) || \
258*0561b2d8STREFOU Felix      (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     )
259*0561b2d8STREFOU Felix 
260*0561b2d8STREFOU Felix /**
261*0561b2d8STREFOU Felix   \brief   Enable FIQ
262*0561b2d8STREFOU Felix   \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
263*0561b2d8STREFOU Felix            Can only be executed in Privileged modes.
264*0561b2d8STREFOU Felix  */
265*0561b2d8STREFOU Felix #define __enable_fault_irq                __enable_fiq
266*0561b2d8STREFOU Felix 
267*0561b2d8STREFOU Felix 
268*0561b2d8STREFOU Felix /**
269*0561b2d8STREFOU Felix   \brief   Disable FIQ
270*0561b2d8STREFOU Felix   \details Disables FIQ interrupts by setting the F-bit in the CPSR.
271*0561b2d8STREFOU Felix            Can only be executed in Privileged modes.
272*0561b2d8STREFOU Felix  */
273*0561b2d8STREFOU Felix #define __disable_fault_irq               __disable_fiq
274*0561b2d8STREFOU Felix 
275*0561b2d8STREFOU Felix 
276*0561b2d8STREFOU Felix /**
277*0561b2d8STREFOU Felix   \brief   Get Base Priority
278*0561b2d8STREFOU Felix   \details Returns the current value of the Base Priority register.
279*0561b2d8STREFOU Felix   \return               Base Priority register value
280*0561b2d8STREFOU Felix  */
__get_BASEPRI(void)281*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t  __get_BASEPRI(void)
282*0561b2d8STREFOU Felix {
283*0561b2d8STREFOU Felix   register uint32_t __regBasePri         __ASM("basepri");
284*0561b2d8STREFOU Felix   return(__regBasePri);
285*0561b2d8STREFOU Felix }
286*0561b2d8STREFOU Felix 
287*0561b2d8STREFOU Felix 
288*0561b2d8STREFOU Felix /**
289*0561b2d8STREFOU Felix   \brief   Set Base Priority
290*0561b2d8STREFOU Felix   \details Assigns the given value to the Base Priority register.
291*0561b2d8STREFOU Felix   \param [in]    basePri  Base Priority value to set
292*0561b2d8STREFOU Felix  */
__set_BASEPRI(uint32_t basePri)293*0561b2d8STREFOU Felix __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
294*0561b2d8STREFOU Felix {
295*0561b2d8STREFOU Felix   register uint32_t __regBasePri         __ASM("basepri");
296*0561b2d8STREFOU Felix   __regBasePri = (basePri & 0xFFU);
297*0561b2d8STREFOU Felix }
298*0561b2d8STREFOU Felix 
299*0561b2d8STREFOU Felix 
300*0561b2d8STREFOU Felix /**
301*0561b2d8STREFOU Felix   \brief   Set Base Priority with condition
302*0561b2d8STREFOU Felix   \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
303*0561b2d8STREFOU Felix            or the new value increases the BASEPRI priority level.
304*0561b2d8STREFOU Felix   \param [in]    basePri  Base Priority value to set
305*0561b2d8STREFOU Felix  */
__set_BASEPRI_MAX(uint32_t basePri)306*0561b2d8STREFOU Felix __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
307*0561b2d8STREFOU Felix {
308*0561b2d8STREFOU Felix   register uint32_t __regBasePriMax      __ASM("basepri_max");
309*0561b2d8STREFOU Felix   __regBasePriMax = (basePri & 0xFFU);
310*0561b2d8STREFOU Felix }
311*0561b2d8STREFOU Felix 
312*0561b2d8STREFOU Felix 
313*0561b2d8STREFOU Felix /**
314*0561b2d8STREFOU Felix   \brief   Get Fault Mask
315*0561b2d8STREFOU Felix   \details Returns the current value of the Fault Mask register.
316*0561b2d8STREFOU Felix   \return               Fault Mask register value
317*0561b2d8STREFOU Felix  */
__get_FAULTMASK(void)318*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_FAULTMASK(void)
319*0561b2d8STREFOU Felix {
320*0561b2d8STREFOU Felix   register uint32_t __regFaultMask       __ASM("faultmask");
321*0561b2d8STREFOU Felix   return(__regFaultMask);
322*0561b2d8STREFOU Felix }
323*0561b2d8STREFOU Felix 
324*0561b2d8STREFOU Felix 
325*0561b2d8STREFOU Felix /**
326*0561b2d8STREFOU Felix   \brief   Set Fault Mask
327*0561b2d8STREFOU Felix   \details Assigns the given value to the Fault Mask register.
328*0561b2d8STREFOU Felix   \param [in]    faultMask  Fault Mask value to set
329*0561b2d8STREFOU Felix  */
__set_FAULTMASK(uint32_t faultMask)330*0561b2d8STREFOU Felix __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
331*0561b2d8STREFOU Felix {
332*0561b2d8STREFOU Felix   register uint32_t __regFaultMask       __ASM("faultmask");
333*0561b2d8STREFOU Felix   __regFaultMask = (faultMask & (uint32_t)1U);
334*0561b2d8STREFOU Felix }
335*0561b2d8STREFOU Felix 
336*0561b2d8STREFOU Felix #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__  == 1)) || \
337*0561b2d8STREFOU Felix            (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     ) */
338*0561b2d8STREFOU Felix 
339*0561b2d8STREFOU Felix 
340*0561b2d8STREFOU Felix /**
341*0561b2d8STREFOU Felix   \brief   Get FPSCR
342*0561b2d8STREFOU Felix   \details Returns the current value of the Floating Point Status/Control register.
343*0561b2d8STREFOU Felix   \return               Floating Point Status/Control register value
344*0561b2d8STREFOU Felix  */
__get_FPSCR(void)345*0561b2d8STREFOU Felix __STATIC_INLINE uint32_t __get_FPSCR(void)
346*0561b2d8STREFOU Felix {
347*0561b2d8STREFOU Felix #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
348*0561b2d8STREFOU Felix      (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
349*0561b2d8STREFOU Felix   register uint32_t __regfpscr         __ASM("fpscr");
350*0561b2d8STREFOU Felix   return(__regfpscr);
351*0561b2d8STREFOU Felix #else
352*0561b2d8STREFOU Felix    return(0U);
353*0561b2d8STREFOU Felix #endif
354*0561b2d8STREFOU Felix }
355*0561b2d8STREFOU Felix 
356*0561b2d8STREFOU Felix 
357*0561b2d8STREFOU Felix /**
358*0561b2d8STREFOU Felix   \brief   Set FPSCR
359*0561b2d8STREFOU Felix   \details Assigns the given value to the Floating Point Status/Control register.
360*0561b2d8STREFOU Felix   \param [in]    fpscr  Floating Point Status/Control value to set
361*0561b2d8STREFOU Felix  */
__set_FPSCR(uint32_t fpscr)362*0561b2d8STREFOU Felix __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
363*0561b2d8STREFOU Felix {
364*0561b2d8STREFOU Felix #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
365*0561b2d8STREFOU Felix      (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
366*0561b2d8STREFOU Felix   register uint32_t __regfpscr         __ASM("fpscr");
367*0561b2d8STREFOU Felix   __regfpscr = (fpscr);
368*0561b2d8STREFOU Felix #else
369*0561b2d8STREFOU Felix   (void)fpscr;
370*0561b2d8STREFOU Felix #endif
371*0561b2d8STREFOU Felix }
372*0561b2d8STREFOU Felix 
373*0561b2d8STREFOU Felix 
374*0561b2d8STREFOU Felix /*@} end of CMSIS_Core_RegAccFunctions */
375*0561b2d8STREFOU Felix 
376*0561b2d8STREFOU Felix 
377*0561b2d8STREFOU Felix /* ##########################  Core Instruction Access  ######################### */
378*0561b2d8STREFOU Felix /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
379*0561b2d8STREFOU Felix   Access to dedicated instructions
380*0561b2d8STREFOU Felix   @{
381*0561b2d8STREFOU Felix */
382*0561b2d8STREFOU Felix 
383*0561b2d8STREFOU Felix /**
384*0561b2d8STREFOU Felix   \brief   No Operation
385*0561b2d8STREFOU Felix   \details No Operation does nothing. This instruction can be used for code alignment purposes.
386*0561b2d8STREFOU Felix  */
387*0561b2d8STREFOU Felix #define __NOP                             __nop
388*0561b2d8STREFOU Felix 
389*0561b2d8STREFOU Felix 
390*0561b2d8STREFOU Felix /**
391*0561b2d8STREFOU Felix   \brief   Wait For Interrupt
392*0561b2d8STREFOU Felix   \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
393*0561b2d8STREFOU Felix  */
394*0561b2d8STREFOU Felix #define __WFI                             __wfi
395*0561b2d8STREFOU Felix 
396*0561b2d8STREFOU Felix 
397*0561b2d8STREFOU Felix /**
398*0561b2d8STREFOU Felix   \brief   Wait For Event
399*0561b2d8STREFOU Felix   \details Wait For Event is a hint instruction that permits the processor to enter
400*0561b2d8STREFOU Felix            a low-power state until one of a number of events occurs.
401*0561b2d8STREFOU Felix  */
402*0561b2d8STREFOU Felix #define __WFE                             __wfe
403*0561b2d8STREFOU Felix 
404*0561b2d8STREFOU Felix 
405*0561b2d8STREFOU Felix /**
406*0561b2d8STREFOU Felix   \brief   Send Event
407*0561b2d8STREFOU Felix   \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
408*0561b2d8STREFOU Felix  */
409*0561b2d8STREFOU Felix #define __SEV                             __sev
410*0561b2d8STREFOU Felix 
411*0561b2d8STREFOU Felix 
412*0561b2d8STREFOU Felix /**
413*0561b2d8STREFOU Felix   \brief   Instruction Synchronization Barrier
414*0561b2d8STREFOU Felix   \details Instruction Synchronization Barrier flushes the pipeline in the processor,
415*0561b2d8STREFOU Felix            so that all instructions following the ISB are fetched from cache or memory,
416*0561b2d8STREFOU Felix            after the instruction has been completed.
417*0561b2d8STREFOU Felix  */
418*0561b2d8STREFOU Felix #define __ISB() do {\
419*0561b2d8STREFOU Felix                    __schedule_barrier();\
420*0561b2d8STREFOU Felix                    __isb(0xF);\
421*0561b2d8STREFOU Felix                    __schedule_barrier();\
422*0561b2d8STREFOU Felix                 } while (0U)
423*0561b2d8STREFOU Felix 
424*0561b2d8STREFOU Felix /**
425*0561b2d8STREFOU Felix   \brief   Data Synchronization Barrier
426*0561b2d8STREFOU Felix   \details Acts as a special kind of Data Memory Barrier.
427*0561b2d8STREFOU Felix            It completes when all explicit memory accesses before this instruction complete.
428*0561b2d8STREFOU Felix  */
429*0561b2d8STREFOU Felix #define __DSB() do {\
430*0561b2d8STREFOU Felix                    __schedule_barrier();\
431*0561b2d8STREFOU Felix                    __dsb(0xF);\
432*0561b2d8STREFOU Felix                    __schedule_barrier();\
433*0561b2d8STREFOU Felix                 } while (0U)
434*0561b2d8STREFOU Felix 
435*0561b2d8STREFOU Felix /**
436*0561b2d8STREFOU Felix   \brief   Data Memory Barrier
437*0561b2d8STREFOU Felix   \details Ensures the apparent order of the explicit memory operations before
438*0561b2d8STREFOU Felix            and after the instruction, without ensuring their completion.
439*0561b2d8STREFOU Felix  */
440*0561b2d8STREFOU Felix #define __DMB() do {\
441*0561b2d8STREFOU Felix                    __schedule_barrier();\
442*0561b2d8STREFOU Felix                    __dmb(0xF);\
443*0561b2d8STREFOU Felix                    __schedule_barrier();\
444*0561b2d8STREFOU Felix                 } while (0U)
445*0561b2d8STREFOU Felix 
446*0561b2d8STREFOU Felix 
447*0561b2d8STREFOU Felix /**
448*0561b2d8STREFOU Felix   \brief   Reverse byte order (32 bit)
449*0561b2d8STREFOU Felix   \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
450*0561b2d8STREFOU Felix   \param [in]    value  Value to reverse
451*0561b2d8STREFOU Felix   \return               Reversed value
452*0561b2d8STREFOU Felix  */
453*0561b2d8STREFOU Felix #define __REV                             __rev
454*0561b2d8STREFOU Felix 
455*0561b2d8STREFOU Felix 
456*0561b2d8STREFOU Felix /**
457*0561b2d8STREFOU Felix   \brief   Reverse byte order (16 bit)
458*0561b2d8STREFOU Felix   \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
459*0561b2d8STREFOU Felix   \param [in]    value  Value to reverse
460*0561b2d8STREFOU Felix   \return               Reversed value
461*0561b2d8STREFOU Felix  */
462*0561b2d8STREFOU Felix #ifndef __NO_EMBEDDED_ASM
__REV16(uint32_t value)463*0561b2d8STREFOU Felix __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
464*0561b2d8STREFOU Felix {
465*0561b2d8STREFOU Felix   rev16 r0, r0
466*0561b2d8STREFOU Felix   bx lr
467*0561b2d8STREFOU Felix }
468*0561b2d8STREFOU Felix #endif
469*0561b2d8STREFOU Felix 
470*0561b2d8STREFOU Felix 
471*0561b2d8STREFOU Felix /**
472*0561b2d8STREFOU Felix   \brief   Reverse byte order (16 bit)
473*0561b2d8STREFOU Felix   \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
474*0561b2d8STREFOU Felix   \param [in]    value  Value to reverse
475*0561b2d8STREFOU Felix   \return               Reversed value
476*0561b2d8STREFOU Felix  */
477*0561b2d8STREFOU Felix #ifndef __NO_EMBEDDED_ASM
__REVSH(int16_t value)478*0561b2d8STREFOU Felix __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
479*0561b2d8STREFOU Felix {
480*0561b2d8STREFOU Felix   revsh r0, r0
481*0561b2d8STREFOU Felix   bx lr
482*0561b2d8STREFOU Felix }
483*0561b2d8STREFOU Felix #endif
484*0561b2d8STREFOU Felix 
485*0561b2d8STREFOU Felix 
486*0561b2d8STREFOU Felix /**
487*0561b2d8STREFOU Felix   \brief   Rotate Right in unsigned value (32 bit)
488*0561b2d8STREFOU Felix   \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
489*0561b2d8STREFOU Felix   \param [in]    op1  Value to rotate
490*0561b2d8STREFOU Felix   \param [in]    op2  Number of Bits to rotate
491*0561b2d8STREFOU Felix   \return               Rotated value
492*0561b2d8STREFOU Felix  */
493*0561b2d8STREFOU Felix #define __ROR                             __ror
494*0561b2d8STREFOU Felix 
495*0561b2d8STREFOU Felix 
496*0561b2d8STREFOU Felix /**
497*0561b2d8STREFOU Felix   \brief   Breakpoint
498*0561b2d8STREFOU Felix   \details Causes the processor to enter Debug state.
499*0561b2d8STREFOU Felix            Debug tools can use this to investigate system state when the instruction at a particular address is reached.
500*0561b2d8STREFOU Felix   \param [in]    value  is ignored by the processor.
501*0561b2d8STREFOU Felix                  If required, a debugger can use it to store additional information about the breakpoint.
502*0561b2d8STREFOU Felix  */
503*0561b2d8STREFOU Felix #define __BKPT(value)                       __breakpoint(value)
504*0561b2d8STREFOU Felix 
505*0561b2d8STREFOU Felix 
506*0561b2d8STREFOU Felix /**
507*0561b2d8STREFOU Felix   \brief   Reverse bit order of value
508*0561b2d8STREFOU Felix   \details Reverses the bit order of the given value.
509*0561b2d8STREFOU Felix   \param [in]    value  Value to reverse
510*0561b2d8STREFOU Felix   \return               Reversed value
511*0561b2d8STREFOU Felix  */
512*0561b2d8STREFOU Felix #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__  == 1)) || \
513*0561b2d8STREFOU Felix      (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     )
514*0561b2d8STREFOU Felix   #define __RBIT                          __rbit
515*0561b2d8STREFOU Felix #else
__RBIT(uint32_t value)516*0561b2d8STREFOU Felix __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
517*0561b2d8STREFOU Felix {
518*0561b2d8STREFOU Felix   uint32_t result;
519*0561b2d8STREFOU Felix   uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
520*0561b2d8STREFOU Felix 
521*0561b2d8STREFOU Felix   result = value;                      /* r will be reversed bits of v; first get LSB of v */
522*0561b2d8STREFOU Felix   for (value >>= 1U; value != 0U; value >>= 1U)
523*0561b2d8STREFOU Felix   {
524*0561b2d8STREFOU Felix     result <<= 1U;
525*0561b2d8STREFOU Felix     result |= value & 1U;
526*0561b2d8STREFOU Felix     s--;
527*0561b2d8STREFOU Felix   }
528*0561b2d8STREFOU Felix   result <<= s;                        /* shift when v's highest bits are zero */
529*0561b2d8STREFOU Felix   return result;
530*0561b2d8STREFOU Felix }
531*0561b2d8STREFOU Felix #endif
532*0561b2d8STREFOU Felix 
533*0561b2d8STREFOU Felix 
534*0561b2d8STREFOU Felix /**
535*0561b2d8STREFOU Felix   \brief   Count leading zeros
536*0561b2d8STREFOU Felix   \details Counts the number of leading zeros of a data value.
537*0561b2d8STREFOU Felix   \param [in]  value  Value to count the leading zeros
538*0561b2d8STREFOU Felix   \return             number of leading zeros in value
539*0561b2d8STREFOU Felix  */
540*0561b2d8STREFOU Felix #define __CLZ                             __clz
541*0561b2d8STREFOU Felix 
542*0561b2d8STREFOU Felix 
543*0561b2d8STREFOU Felix #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__  == 1)) || \
544*0561b2d8STREFOU Felix      (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     )
545*0561b2d8STREFOU Felix 
546*0561b2d8STREFOU Felix /**
547*0561b2d8STREFOU Felix   \brief   LDR Exclusive (8 bit)
548*0561b2d8STREFOU Felix   \details Executes a exclusive LDR instruction for 8 bit value.
549*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to data
550*0561b2d8STREFOU Felix   \return             value of type uint8_t at (*ptr)
551*0561b2d8STREFOU Felix  */
552*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
553*0561b2d8STREFOU Felix   #define __LDREXB(ptr)                                                        ((uint8_t ) __ldrex(ptr))
554*0561b2d8STREFOU Felix #else
555*0561b2d8STREFOU Felix   #define __LDREXB(ptr)          _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr))  _Pragma("pop")
556*0561b2d8STREFOU Felix #endif
557*0561b2d8STREFOU Felix 
558*0561b2d8STREFOU Felix 
559*0561b2d8STREFOU Felix /**
560*0561b2d8STREFOU Felix   \brief   LDR Exclusive (16 bit)
561*0561b2d8STREFOU Felix   \details Executes a exclusive LDR instruction for 16 bit values.
562*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to data
563*0561b2d8STREFOU Felix   \return        value of type uint16_t at (*ptr)
564*0561b2d8STREFOU Felix  */
565*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
566*0561b2d8STREFOU Felix   #define __LDREXH(ptr)                                                        ((uint16_t) __ldrex(ptr))
567*0561b2d8STREFOU Felix #else
568*0561b2d8STREFOU Felix   #define __LDREXH(ptr)          _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr))  _Pragma("pop")
569*0561b2d8STREFOU Felix #endif
570*0561b2d8STREFOU Felix 
571*0561b2d8STREFOU Felix 
572*0561b2d8STREFOU Felix /**
573*0561b2d8STREFOU Felix   \brief   LDR Exclusive (32 bit)
574*0561b2d8STREFOU Felix   \details Executes a exclusive LDR instruction for 32 bit values.
575*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to data
576*0561b2d8STREFOU Felix   \return        value of type uint32_t at (*ptr)
577*0561b2d8STREFOU Felix  */
578*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
579*0561b2d8STREFOU Felix   #define __LDREXW(ptr)                                                        ((uint32_t ) __ldrex(ptr))
580*0561b2d8STREFOU Felix #else
581*0561b2d8STREFOU Felix   #define __LDREXW(ptr)          _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr))  _Pragma("pop")
582*0561b2d8STREFOU Felix #endif
583*0561b2d8STREFOU Felix 
584*0561b2d8STREFOU Felix 
585*0561b2d8STREFOU Felix /**
586*0561b2d8STREFOU Felix   \brief   STR Exclusive (8 bit)
587*0561b2d8STREFOU Felix   \details Executes a exclusive STR instruction for 8 bit values.
588*0561b2d8STREFOU Felix   \param [in]  value  Value to store
589*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to location
590*0561b2d8STREFOU Felix   \return          0  Function succeeded
591*0561b2d8STREFOU Felix   \return          1  Function failed
592*0561b2d8STREFOU Felix  */
593*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
594*0561b2d8STREFOU Felix   #define __STREXB(value, ptr)                                                 __strex(value, ptr)
595*0561b2d8STREFOU Felix #else
596*0561b2d8STREFOU Felix   #define __STREXB(value, ptr)   _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr)        _Pragma("pop")
597*0561b2d8STREFOU Felix #endif
598*0561b2d8STREFOU Felix 
599*0561b2d8STREFOU Felix 
600*0561b2d8STREFOU Felix /**
601*0561b2d8STREFOU Felix   \brief   STR Exclusive (16 bit)
602*0561b2d8STREFOU Felix   \details Executes a exclusive STR instruction for 16 bit values.
603*0561b2d8STREFOU Felix   \param [in]  value  Value to store
604*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to location
605*0561b2d8STREFOU Felix   \return          0  Function succeeded
606*0561b2d8STREFOU Felix   \return          1  Function failed
607*0561b2d8STREFOU Felix  */
608*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
609*0561b2d8STREFOU Felix   #define __STREXH(value, ptr)                                                 __strex(value, ptr)
610*0561b2d8STREFOU Felix #else
611*0561b2d8STREFOU Felix   #define __STREXH(value, ptr)   _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr)        _Pragma("pop")
612*0561b2d8STREFOU Felix #endif
613*0561b2d8STREFOU Felix 
614*0561b2d8STREFOU Felix 
615*0561b2d8STREFOU Felix /**
616*0561b2d8STREFOU Felix   \brief   STR Exclusive (32 bit)
617*0561b2d8STREFOU Felix   \details Executes a exclusive STR instruction for 32 bit values.
618*0561b2d8STREFOU Felix   \param [in]  value  Value to store
619*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to location
620*0561b2d8STREFOU Felix   \return          0  Function succeeded
621*0561b2d8STREFOU Felix   \return          1  Function failed
622*0561b2d8STREFOU Felix  */
623*0561b2d8STREFOU Felix #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
624*0561b2d8STREFOU Felix   #define __STREXW(value, ptr)                                                 __strex(value, ptr)
625*0561b2d8STREFOU Felix #else
626*0561b2d8STREFOU Felix   #define __STREXW(value, ptr)   _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr)        _Pragma("pop")
627*0561b2d8STREFOU Felix #endif
628*0561b2d8STREFOU Felix 
629*0561b2d8STREFOU Felix 
630*0561b2d8STREFOU Felix /**
631*0561b2d8STREFOU Felix   \brief   Remove the exclusive lock
632*0561b2d8STREFOU Felix   \details Removes the exclusive lock which is created by LDREX.
633*0561b2d8STREFOU Felix  */
634*0561b2d8STREFOU Felix #define __CLREX                           __clrex
635*0561b2d8STREFOU Felix 
636*0561b2d8STREFOU Felix 
637*0561b2d8STREFOU Felix /**
638*0561b2d8STREFOU Felix   \brief   Signed Saturate
639*0561b2d8STREFOU Felix   \details Saturates a signed value.
640*0561b2d8STREFOU Felix   \param [in]  value  Value to be saturated
641*0561b2d8STREFOU Felix   \param [in]    sat  Bit position to saturate to (1..32)
642*0561b2d8STREFOU Felix   \return             Saturated value
643*0561b2d8STREFOU Felix  */
644*0561b2d8STREFOU Felix #define __SSAT                            __ssat
645*0561b2d8STREFOU Felix 
646*0561b2d8STREFOU Felix 
647*0561b2d8STREFOU Felix /**
648*0561b2d8STREFOU Felix   \brief   Unsigned Saturate
649*0561b2d8STREFOU Felix   \details Saturates an unsigned value.
650*0561b2d8STREFOU Felix   \param [in]  value  Value to be saturated
651*0561b2d8STREFOU Felix   \param [in]    sat  Bit position to saturate to (0..31)
652*0561b2d8STREFOU Felix   \return             Saturated value
653*0561b2d8STREFOU Felix  */
654*0561b2d8STREFOU Felix #define __USAT                            __usat
655*0561b2d8STREFOU Felix 
656*0561b2d8STREFOU Felix 
657*0561b2d8STREFOU Felix /**
658*0561b2d8STREFOU Felix   \brief   Rotate Right with Extend (32 bit)
659*0561b2d8STREFOU Felix   \details Moves each bit of a bitstring right by one bit.
660*0561b2d8STREFOU Felix            The carry input is shifted in at the left end of the bitstring.
661*0561b2d8STREFOU Felix   \param [in]    value  Value to rotate
662*0561b2d8STREFOU Felix   \return               Rotated value
663*0561b2d8STREFOU Felix  */
664*0561b2d8STREFOU Felix #ifndef __NO_EMBEDDED_ASM
__RRX(uint32_t value)665*0561b2d8STREFOU Felix __attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
666*0561b2d8STREFOU Felix {
667*0561b2d8STREFOU Felix   rrx r0, r0
668*0561b2d8STREFOU Felix   bx lr
669*0561b2d8STREFOU Felix }
670*0561b2d8STREFOU Felix #endif
671*0561b2d8STREFOU Felix 
672*0561b2d8STREFOU Felix 
673*0561b2d8STREFOU Felix /**
674*0561b2d8STREFOU Felix   \brief   LDRT Unprivileged (8 bit)
675*0561b2d8STREFOU Felix   \details Executes a Unprivileged LDRT instruction for 8 bit value.
676*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to data
677*0561b2d8STREFOU Felix   \return             value of type uint8_t at (*ptr)
678*0561b2d8STREFOU Felix  */
679*0561b2d8STREFOU Felix #define __LDRBT(ptr)                      ((uint8_t )  __ldrt(ptr))
680*0561b2d8STREFOU Felix 
681*0561b2d8STREFOU Felix 
682*0561b2d8STREFOU Felix /**
683*0561b2d8STREFOU Felix   \brief   LDRT Unprivileged (16 bit)
684*0561b2d8STREFOU Felix   \details Executes a Unprivileged LDRT instruction for 16 bit values.
685*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to data
686*0561b2d8STREFOU Felix   \return        value of type uint16_t at (*ptr)
687*0561b2d8STREFOU Felix  */
688*0561b2d8STREFOU Felix #define __LDRHT(ptr)                      ((uint16_t)  __ldrt(ptr))
689*0561b2d8STREFOU Felix 
690*0561b2d8STREFOU Felix 
691*0561b2d8STREFOU Felix /**
692*0561b2d8STREFOU Felix   \brief   LDRT Unprivileged (32 bit)
693*0561b2d8STREFOU Felix   \details Executes a Unprivileged LDRT instruction for 32 bit values.
694*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to data
695*0561b2d8STREFOU Felix   \return        value of type uint32_t at (*ptr)
696*0561b2d8STREFOU Felix  */
697*0561b2d8STREFOU Felix #define __LDRT(ptr)                       ((uint32_t ) __ldrt(ptr))
698*0561b2d8STREFOU Felix 
699*0561b2d8STREFOU Felix 
700*0561b2d8STREFOU Felix /**
701*0561b2d8STREFOU Felix   \brief   STRT Unprivileged (8 bit)
702*0561b2d8STREFOU Felix   \details Executes a Unprivileged STRT instruction for 8 bit values.
703*0561b2d8STREFOU Felix   \param [in]  value  Value to store
704*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to location
705*0561b2d8STREFOU Felix  */
706*0561b2d8STREFOU Felix #define __STRBT(value, ptr)               __strt(value, ptr)
707*0561b2d8STREFOU Felix 
708*0561b2d8STREFOU Felix 
709*0561b2d8STREFOU Felix /**
710*0561b2d8STREFOU Felix   \brief   STRT Unprivileged (16 bit)
711*0561b2d8STREFOU Felix   \details Executes a Unprivileged STRT instruction for 16 bit values.
712*0561b2d8STREFOU Felix   \param [in]  value  Value to store
713*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to location
714*0561b2d8STREFOU Felix  */
715*0561b2d8STREFOU Felix #define __STRHT(value, ptr)               __strt(value, ptr)
716*0561b2d8STREFOU Felix 
717*0561b2d8STREFOU Felix 
718*0561b2d8STREFOU Felix /**
719*0561b2d8STREFOU Felix   \brief   STRT Unprivileged (32 bit)
720*0561b2d8STREFOU Felix   \details Executes a Unprivileged STRT instruction for 32 bit values.
721*0561b2d8STREFOU Felix   \param [in]  value  Value to store
722*0561b2d8STREFOU Felix   \param [in]    ptr  Pointer to location
723*0561b2d8STREFOU Felix  */
724*0561b2d8STREFOU Felix #define __STRT(value, ptr)                __strt(value, ptr)
725*0561b2d8STREFOU Felix 
726*0561b2d8STREFOU Felix #else  /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__  == 1)) || \
727*0561b2d8STREFOU Felix            (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     ) */
728*0561b2d8STREFOU Felix 
729*0561b2d8STREFOU Felix /**
730*0561b2d8STREFOU Felix   \brief   Signed Saturate
731*0561b2d8STREFOU Felix   \details Saturates a signed value.
732*0561b2d8STREFOU Felix   \param [in]  value  Value to be saturated
733*0561b2d8STREFOU Felix   \param [in]    sat  Bit position to saturate to (1..32)
734*0561b2d8STREFOU Felix   \return             Saturated value
735*0561b2d8STREFOU Felix  */
__SSAT(int32_t val,uint32_t sat)736*0561b2d8STREFOU Felix __attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
737*0561b2d8STREFOU Felix {
738*0561b2d8STREFOU Felix   if ((sat >= 1U) && (sat <= 32U))
739*0561b2d8STREFOU Felix   {
740*0561b2d8STREFOU Felix     const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
741*0561b2d8STREFOU Felix     const int32_t min = -1 - max ;
742*0561b2d8STREFOU Felix     if (val > max)
743*0561b2d8STREFOU Felix     {
744*0561b2d8STREFOU Felix       return max;
745*0561b2d8STREFOU Felix     }
746*0561b2d8STREFOU Felix     else if (val < min)
747*0561b2d8STREFOU Felix     {
748*0561b2d8STREFOU Felix       return min;
749*0561b2d8STREFOU Felix     }
750*0561b2d8STREFOU Felix   }
751*0561b2d8STREFOU Felix   return val;
752*0561b2d8STREFOU Felix }
753*0561b2d8STREFOU Felix 
754*0561b2d8STREFOU Felix /**
755*0561b2d8STREFOU Felix   \brief   Unsigned Saturate
756*0561b2d8STREFOU Felix   \details Saturates an unsigned value.
757*0561b2d8STREFOU Felix   \param [in]  value  Value to be saturated
758*0561b2d8STREFOU Felix   \param [in]    sat  Bit position to saturate to (0..31)
759*0561b2d8STREFOU Felix   \return             Saturated value
760*0561b2d8STREFOU Felix  */
__USAT(int32_t val,uint32_t sat)761*0561b2d8STREFOU Felix __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
762*0561b2d8STREFOU Felix {
763*0561b2d8STREFOU Felix   if (sat <= 31U)
764*0561b2d8STREFOU Felix   {
765*0561b2d8STREFOU Felix     const uint32_t max = ((1U << sat) - 1U);
766*0561b2d8STREFOU Felix     if (val > (int32_t)max)
767*0561b2d8STREFOU Felix     {
768*0561b2d8STREFOU Felix       return max;
769*0561b2d8STREFOU Felix     }
770*0561b2d8STREFOU Felix     else if (val < 0)
771*0561b2d8STREFOU Felix     {
772*0561b2d8STREFOU Felix       return 0U;
773*0561b2d8STREFOU Felix     }
774*0561b2d8STREFOU Felix   }
775*0561b2d8STREFOU Felix   return (uint32_t)val;
776*0561b2d8STREFOU Felix }
777*0561b2d8STREFOU Felix 
778*0561b2d8STREFOU Felix #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__  == 1)) || \
779*0561b2d8STREFOU Felix            (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     ) */
780*0561b2d8STREFOU Felix 
781*0561b2d8STREFOU Felix /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
782*0561b2d8STREFOU Felix 
783*0561b2d8STREFOU Felix 
784*0561b2d8STREFOU Felix /* ###################  Compiler specific Intrinsics  ########################### */
785*0561b2d8STREFOU Felix /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
786*0561b2d8STREFOU Felix   Access to dedicated SIMD instructions
787*0561b2d8STREFOU Felix   @{
788*0561b2d8STREFOU Felix */
789*0561b2d8STREFOU Felix 
790*0561b2d8STREFOU Felix #if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     )
791*0561b2d8STREFOU Felix 
792*0561b2d8STREFOU Felix #define __SADD8                           __sadd8
793*0561b2d8STREFOU Felix #define __QADD8                           __qadd8
794*0561b2d8STREFOU Felix #define __SHADD8                          __shadd8
795*0561b2d8STREFOU Felix #define __UADD8                           __uadd8
796*0561b2d8STREFOU Felix #define __UQADD8                          __uqadd8
797*0561b2d8STREFOU Felix #define __UHADD8                          __uhadd8
798*0561b2d8STREFOU Felix #define __SSUB8                           __ssub8
799*0561b2d8STREFOU Felix #define __QSUB8                           __qsub8
800*0561b2d8STREFOU Felix #define __SHSUB8                          __shsub8
801*0561b2d8STREFOU Felix #define __USUB8                           __usub8
802*0561b2d8STREFOU Felix #define __UQSUB8                          __uqsub8
803*0561b2d8STREFOU Felix #define __UHSUB8                          __uhsub8
804*0561b2d8STREFOU Felix #define __SADD16                          __sadd16
805*0561b2d8STREFOU Felix #define __QADD16                          __qadd16
806*0561b2d8STREFOU Felix #define __SHADD16                         __shadd16
807*0561b2d8STREFOU Felix #define __UADD16                          __uadd16
808*0561b2d8STREFOU Felix #define __UQADD16                         __uqadd16
809*0561b2d8STREFOU Felix #define __UHADD16                         __uhadd16
810*0561b2d8STREFOU Felix #define __SSUB16                          __ssub16
811*0561b2d8STREFOU Felix #define __QSUB16                          __qsub16
812*0561b2d8STREFOU Felix #define __SHSUB16                         __shsub16
813*0561b2d8STREFOU Felix #define __USUB16                          __usub16
814*0561b2d8STREFOU Felix #define __UQSUB16                         __uqsub16
815*0561b2d8STREFOU Felix #define __UHSUB16                         __uhsub16
816*0561b2d8STREFOU Felix #define __SASX                            __sasx
817*0561b2d8STREFOU Felix #define __QASX                            __qasx
818*0561b2d8STREFOU Felix #define __SHASX                           __shasx
819*0561b2d8STREFOU Felix #define __UASX                            __uasx
820*0561b2d8STREFOU Felix #define __UQASX                           __uqasx
821*0561b2d8STREFOU Felix #define __UHASX                           __uhasx
822*0561b2d8STREFOU Felix #define __SSAX                            __ssax
823*0561b2d8STREFOU Felix #define __QSAX                            __qsax
824*0561b2d8STREFOU Felix #define __SHSAX                           __shsax
825*0561b2d8STREFOU Felix #define __USAX                            __usax
826*0561b2d8STREFOU Felix #define __UQSAX                           __uqsax
827*0561b2d8STREFOU Felix #define __UHSAX                           __uhsax
828*0561b2d8STREFOU Felix #define __USAD8                           __usad8
829*0561b2d8STREFOU Felix #define __USADA8                          __usada8
830*0561b2d8STREFOU Felix #define __SSAT16                          __ssat16
831*0561b2d8STREFOU Felix #define __USAT16                          __usat16
832*0561b2d8STREFOU Felix #define __UXTB16                          __uxtb16
833*0561b2d8STREFOU Felix #define __UXTAB16                         __uxtab16
834*0561b2d8STREFOU Felix #define __SXTB16                          __sxtb16
835*0561b2d8STREFOU Felix #define __SXTAB16                         __sxtab16
836*0561b2d8STREFOU Felix #define __SMUAD                           __smuad
837*0561b2d8STREFOU Felix #define __SMUADX                          __smuadx
838*0561b2d8STREFOU Felix #define __SMLAD                           __smlad
839*0561b2d8STREFOU Felix #define __SMLADX                          __smladx
840*0561b2d8STREFOU Felix #define __SMLALD                          __smlald
841*0561b2d8STREFOU Felix #define __SMLALDX                         __smlaldx
842*0561b2d8STREFOU Felix #define __SMUSD                           __smusd
843*0561b2d8STREFOU Felix #define __SMUSDX                          __smusdx
844*0561b2d8STREFOU Felix #define __SMLSD                           __smlsd
845*0561b2d8STREFOU Felix #define __SMLSDX                          __smlsdx
846*0561b2d8STREFOU Felix #define __SMLSLD                          __smlsld
847*0561b2d8STREFOU Felix #define __SMLSLDX                         __smlsldx
848*0561b2d8STREFOU Felix #define __SEL                             __sel
849*0561b2d8STREFOU Felix #define __QADD                            __qadd
850*0561b2d8STREFOU Felix #define __QSUB                            __qsub
851*0561b2d8STREFOU Felix 
852*0561b2d8STREFOU Felix #define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \
853*0561b2d8STREFOU Felix                                            ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )
854*0561b2d8STREFOU Felix 
855*0561b2d8STREFOU Felix #define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \
856*0561b2d8STREFOU Felix                                            ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )
857*0561b2d8STREFOU Felix 
858*0561b2d8STREFOU Felix #define __SMMLA(ARG1,ARG2,ARG3)          ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
859*0561b2d8STREFOU Felix                                                       ((int64_t)(ARG3) << 32U)     ) >> 32U))
860*0561b2d8STREFOU Felix 
861*0561b2d8STREFOU Felix #endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))     ) */
862*0561b2d8STREFOU Felix /*@} end of group CMSIS_SIMD_intrinsics */
863*0561b2d8STREFOU Felix 
864*0561b2d8STREFOU Felix 
865*0561b2d8STREFOU Felix #endif /* __CMSIS_ARMCC_H */
866