xref: /btstack/port/stm32-l476rg-nucleo-sx1280/Drivers/CMSIS/Include/cmsis_iccarm.h (revision 6b8177c56d8d42c688f52897394f8b5eac7ee972)
1*6b8177c5SMatthias Ringwald /**************************************************************************//**
2*6b8177c5SMatthias Ringwald  * @file     cmsis_iccarm.h
3*6b8177c5SMatthias Ringwald  * @brief    CMSIS compiler ICCARM (IAR Compiler for Arm) header file
4*6b8177c5SMatthias Ringwald  * @version  V5.1.0
5*6b8177c5SMatthias Ringwald  * @date     08. May 2019
6*6b8177c5SMatthias Ringwald  ******************************************************************************/
7*6b8177c5SMatthias Ringwald 
8*6b8177c5SMatthias Ringwald //------------------------------------------------------------------------------
9*6b8177c5SMatthias Ringwald //
10*6b8177c5SMatthias Ringwald // Copyright (c) 2017-2019 IAR Systems
11*6b8177c5SMatthias Ringwald // Copyright (c) 2017-2019 Arm Limited. All rights reserved.
12*6b8177c5SMatthias Ringwald //
13*6b8177c5SMatthias Ringwald // Licensed under the Apache License, Version 2.0 (the "License")
14*6b8177c5SMatthias Ringwald // you may not use this file except in compliance with the License.
15*6b8177c5SMatthias Ringwald // You may obtain a copy of the License at
16*6b8177c5SMatthias Ringwald //     http://www.apache.org/licenses/LICENSE-2.0
17*6b8177c5SMatthias Ringwald //
18*6b8177c5SMatthias Ringwald // Unless required by applicable law or agreed to in writing, software
19*6b8177c5SMatthias Ringwald // distributed under the License is distributed on an "AS IS" BASIS,
20*6b8177c5SMatthias Ringwald // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21*6b8177c5SMatthias Ringwald // See the License for the specific language governing permissions and
22*6b8177c5SMatthias Ringwald // limitations under the License.
23*6b8177c5SMatthias Ringwald //
24*6b8177c5SMatthias Ringwald //------------------------------------------------------------------------------
25*6b8177c5SMatthias Ringwald 
26*6b8177c5SMatthias Ringwald 
27*6b8177c5SMatthias Ringwald #ifndef __CMSIS_ICCARM_H__
28*6b8177c5SMatthias Ringwald #define __CMSIS_ICCARM_H__
29*6b8177c5SMatthias Ringwald 
30*6b8177c5SMatthias Ringwald #ifndef __ICCARM__
31*6b8177c5SMatthias Ringwald   #error This file should only be compiled by ICCARM
32*6b8177c5SMatthias Ringwald #endif
33*6b8177c5SMatthias Ringwald 
34*6b8177c5SMatthias Ringwald #pragma system_include
35*6b8177c5SMatthias Ringwald 
36*6b8177c5SMatthias Ringwald #define __IAR_FT _Pragma("inline=forced") __intrinsic
37*6b8177c5SMatthias Ringwald 
38*6b8177c5SMatthias Ringwald #if (__VER__ >= 8000000)
39*6b8177c5SMatthias Ringwald   #define __ICCARM_V8 1
40*6b8177c5SMatthias Ringwald #else
41*6b8177c5SMatthias Ringwald   #define __ICCARM_V8 0
42*6b8177c5SMatthias Ringwald #endif
43*6b8177c5SMatthias Ringwald 
44*6b8177c5SMatthias Ringwald #ifndef __ALIGNED
45*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
46*6b8177c5SMatthias Ringwald     #define __ALIGNED(x) __attribute__((aligned(x)))
47*6b8177c5SMatthias Ringwald   #elif (__VER__ >= 7080000)
48*6b8177c5SMatthias Ringwald     /* Needs IAR language extensions */
49*6b8177c5SMatthias Ringwald     #define __ALIGNED(x) __attribute__((aligned(x)))
50*6b8177c5SMatthias Ringwald   #else
51*6b8177c5SMatthias Ringwald     #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored.
52*6b8177c5SMatthias Ringwald     #define __ALIGNED(x)
53*6b8177c5SMatthias Ringwald   #endif
54*6b8177c5SMatthias Ringwald #endif
55*6b8177c5SMatthias Ringwald 
56*6b8177c5SMatthias Ringwald 
57*6b8177c5SMatthias Ringwald /* Define compiler macros for CPU architecture, used in CMSIS 5.
58*6b8177c5SMatthias Ringwald  */
59*6b8177c5SMatthias Ringwald #if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__
60*6b8177c5SMatthias Ringwald /* Macros already defined */
61*6b8177c5SMatthias Ringwald #else
62*6b8177c5SMatthias Ringwald   #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__)
63*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_8M_MAIN__ 1
64*6b8177c5SMatthias Ringwald   #elif defined(__ARM8M_BASELINE__)
65*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_8M_BASE__ 1
66*6b8177c5SMatthias Ringwald   #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M'
67*6b8177c5SMatthias Ringwald     #if __ARM_ARCH == 6
68*6b8177c5SMatthias Ringwald       #define __ARM_ARCH_6M__ 1
69*6b8177c5SMatthias Ringwald     #elif __ARM_ARCH == 7
70*6b8177c5SMatthias Ringwald       #if __ARM_FEATURE_DSP
71*6b8177c5SMatthias Ringwald         #define __ARM_ARCH_7EM__ 1
72*6b8177c5SMatthias Ringwald       #else
73*6b8177c5SMatthias Ringwald         #define __ARM_ARCH_7M__ 1
74*6b8177c5SMatthias Ringwald       #endif
75*6b8177c5SMatthias Ringwald     #endif /* __ARM_ARCH */
76*6b8177c5SMatthias Ringwald   #endif /* __ARM_ARCH_PROFILE == 'M' */
77*6b8177c5SMatthias Ringwald #endif
78*6b8177c5SMatthias Ringwald 
79*6b8177c5SMatthias Ringwald /* Alternativ core deduction for older ICCARM's */
80*6b8177c5SMatthias Ringwald #if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \
81*6b8177c5SMatthias Ringwald     !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__)
82*6b8177c5SMatthias Ringwald   #if defined(__ARM6M__) && (__CORE__ == __ARM6M__)
83*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_6M__ 1
84*6b8177c5SMatthias Ringwald   #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__)
85*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_7M__ 1
86*6b8177c5SMatthias Ringwald   #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__)
87*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_7EM__  1
88*6b8177c5SMatthias Ringwald   #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__)
89*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_8M_BASE__ 1
90*6b8177c5SMatthias Ringwald   #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__)
91*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_8M_MAIN__ 1
92*6b8177c5SMatthias Ringwald   #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__)
93*6b8177c5SMatthias Ringwald     #define __ARM_ARCH_8M_MAIN__ 1
94*6b8177c5SMatthias Ringwald   #else
95*6b8177c5SMatthias Ringwald     #error "Unknown target."
96*6b8177c5SMatthias Ringwald   #endif
97*6b8177c5SMatthias Ringwald #endif
98*6b8177c5SMatthias Ringwald 
99*6b8177c5SMatthias Ringwald 
100*6b8177c5SMatthias Ringwald 
101*6b8177c5SMatthias Ringwald #if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1
102*6b8177c5SMatthias Ringwald   #define __IAR_M0_FAMILY  1
103*6b8177c5SMatthias Ringwald #elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1
104*6b8177c5SMatthias Ringwald   #define __IAR_M0_FAMILY  1
105*6b8177c5SMatthias Ringwald #else
106*6b8177c5SMatthias Ringwald   #define __IAR_M0_FAMILY  0
107*6b8177c5SMatthias Ringwald #endif
108*6b8177c5SMatthias Ringwald 
109*6b8177c5SMatthias Ringwald 
110*6b8177c5SMatthias Ringwald #ifndef __ASM
111*6b8177c5SMatthias Ringwald   #define __ASM __asm
112*6b8177c5SMatthias Ringwald #endif
113*6b8177c5SMatthias Ringwald 
114*6b8177c5SMatthias Ringwald #ifndef   __COMPILER_BARRIER
115*6b8177c5SMatthias Ringwald   #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
116*6b8177c5SMatthias Ringwald #endif
117*6b8177c5SMatthias Ringwald 
118*6b8177c5SMatthias Ringwald #ifndef __INLINE
119*6b8177c5SMatthias Ringwald   #define __INLINE inline
120*6b8177c5SMatthias Ringwald #endif
121*6b8177c5SMatthias Ringwald 
122*6b8177c5SMatthias Ringwald #ifndef   __NO_RETURN
123*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
124*6b8177c5SMatthias Ringwald     #define __NO_RETURN __attribute__((__noreturn__))
125*6b8177c5SMatthias Ringwald   #else
126*6b8177c5SMatthias Ringwald     #define __NO_RETURN _Pragma("object_attribute=__noreturn")
127*6b8177c5SMatthias Ringwald   #endif
128*6b8177c5SMatthias Ringwald #endif
129*6b8177c5SMatthias Ringwald 
130*6b8177c5SMatthias Ringwald #ifndef   __PACKED
131*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
132*6b8177c5SMatthias Ringwald     #define __PACKED __attribute__((packed, aligned(1)))
133*6b8177c5SMatthias Ringwald   #else
134*6b8177c5SMatthias Ringwald     /* Needs IAR language extensions */
135*6b8177c5SMatthias Ringwald     #define __PACKED __packed
136*6b8177c5SMatthias Ringwald   #endif
137*6b8177c5SMatthias Ringwald #endif
138*6b8177c5SMatthias Ringwald 
139*6b8177c5SMatthias Ringwald #ifndef   __PACKED_STRUCT
140*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
141*6b8177c5SMatthias Ringwald     #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
142*6b8177c5SMatthias Ringwald   #else
143*6b8177c5SMatthias Ringwald     /* Needs IAR language extensions */
144*6b8177c5SMatthias Ringwald     #define __PACKED_STRUCT __packed struct
145*6b8177c5SMatthias Ringwald   #endif
146*6b8177c5SMatthias Ringwald #endif
147*6b8177c5SMatthias Ringwald 
148*6b8177c5SMatthias Ringwald #ifndef   __PACKED_UNION
149*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
150*6b8177c5SMatthias Ringwald     #define __PACKED_UNION union __attribute__((packed, aligned(1)))
151*6b8177c5SMatthias Ringwald   #else
152*6b8177c5SMatthias Ringwald     /* Needs IAR language extensions */
153*6b8177c5SMatthias Ringwald     #define __PACKED_UNION __packed union
154*6b8177c5SMatthias Ringwald   #endif
155*6b8177c5SMatthias Ringwald #endif
156*6b8177c5SMatthias Ringwald 
157*6b8177c5SMatthias Ringwald #ifndef   __RESTRICT
158*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
159*6b8177c5SMatthias Ringwald     #define __RESTRICT            __restrict
160*6b8177c5SMatthias Ringwald   #else
161*6b8177c5SMatthias Ringwald     /* Needs IAR language extensions */
162*6b8177c5SMatthias Ringwald     #define __RESTRICT            restrict
163*6b8177c5SMatthias Ringwald   #endif
164*6b8177c5SMatthias Ringwald #endif
165*6b8177c5SMatthias Ringwald 
166*6b8177c5SMatthias Ringwald #ifndef   __STATIC_INLINE
167*6b8177c5SMatthias Ringwald   #define __STATIC_INLINE       static inline
168*6b8177c5SMatthias Ringwald #endif
169*6b8177c5SMatthias Ringwald 
170*6b8177c5SMatthias Ringwald #ifndef   __FORCEINLINE
171*6b8177c5SMatthias Ringwald   #define __FORCEINLINE         _Pragma("inline=forced")
172*6b8177c5SMatthias Ringwald #endif
173*6b8177c5SMatthias Ringwald 
174*6b8177c5SMatthias Ringwald #ifndef   __STATIC_FORCEINLINE
175*6b8177c5SMatthias Ringwald   #define __STATIC_FORCEINLINE  __FORCEINLINE __STATIC_INLINE
176*6b8177c5SMatthias Ringwald #endif
177*6b8177c5SMatthias Ringwald 
178*6b8177c5SMatthias Ringwald #ifndef __UNALIGNED_UINT16_READ
179*6b8177c5SMatthias Ringwald #pragma language=save
180*6b8177c5SMatthias Ringwald #pragma language=extended
__iar_uint16_read(void const * ptr)181*6b8177c5SMatthias Ringwald __IAR_FT uint16_t __iar_uint16_read(void const *ptr)
182*6b8177c5SMatthias Ringwald {
183*6b8177c5SMatthias Ringwald   return *(__packed uint16_t*)(ptr);
184*6b8177c5SMatthias Ringwald }
185*6b8177c5SMatthias Ringwald #pragma language=restore
186*6b8177c5SMatthias Ringwald #define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR)
187*6b8177c5SMatthias Ringwald #endif
188*6b8177c5SMatthias Ringwald 
189*6b8177c5SMatthias Ringwald 
190*6b8177c5SMatthias Ringwald #ifndef __UNALIGNED_UINT16_WRITE
191*6b8177c5SMatthias Ringwald #pragma language=save
192*6b8177c5SMatthias Ringwald #pragma language=extended
__iar_uint16_write(void const * ptr,uint16_t val)193*6b8177c5SMatthias Ringwald __IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
194*6b8177c5SMatthias Ringwald {
195*6b8177c5SMatthias Ringwald   *(__packed uint16_t*)(ptr) = val;;
196*6b8177c5SMatthias Ringwald }
197*6b8177c5SMatthias Ringwald #pragma language=restore
198*6b8177c5SMatthias Ringwald #define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
199*6b8177c5SMatthias Ringwald #endif
200*6b8177c5SMatthias Ringwald 
201*6b8177c5SMatthias Ringwald #ifndef __UNALIGNED_UINT32_READ
202*6b8177c5SMatthias Ringwald #pragma language=save
203*6b8177c5SMatthias Ringwald #pragma language=extended
__iar_uint32_read(void const * ptr)204*6b8177c5SMatthias Ringwald __IAR_FT uint32_t __iar_uint32_read(void const *ptr)
205*6b8177c5SMatthias Ringwald {
206*6b8177c5SMatthias Ringwald   return *(__packed uint32_t*)(ptr);
207*6b8177c5SMatthias Ringwald }
208*6b8177c5SMatthias Ringwald #pragma language=restore
209*6b8177c5SMatthias Ringwald #define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR)
210*6b8177c5SMatthias Ringwald #endif
211*6b8177c5SMatthias Ringwald 
212*6b8177c5SMatthias Ringwald #ifndef __UNALIGNED_UINT32_WRITE
213*6b8177c5SMatthias Ringwald #pragma language=save
214*6b8177c5SMatthias Ringwald #pragma language=extended
__iar_uint32_write(void const * ptr,uint32_t val)215*6b8177c5SMatthias Ringwald __IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
216*6b8177c5SMatthias Ringwald {
217*6b8177c5SMatthias Ringwald   *(__packed uint32_t*)(ptr) = val;;
218*6b8177c5SMatthias Ringwald }
219*6b8177c5SMatthias Ringwald #pragma language=restore
220*6b8177c5SMatthias Ringwald #define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
221*6b8177c5SMatthias Ringwald #endif
222*6b8177c5SMatthias Ringwald 
223*6b8177c5SMatthias Ringwald #ifndef __UNALIGNED_UINT32   /* deprecated */
224*6b8177c5SMatthias Ringwald #pragma language=save
225*6b8177c5SMatthias Ringwald #pragma language=extended
226*6b8177c5SMatthias Ringwald __packed struct  __iar_u32 { uint32_t v; };
227*6b8177c5SMatthias Ringwald #pragma language=restore
228*6b8177c5SMatthias Ringwald #define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
229*6b8177c5SMatthias Ringwald #endif
230*6b8177c5SMatthias Ringwald 
231*6b8177c5SMatthias Ringwald #ifndef   __USED
232*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
233*6b8177c5SMatthias Ringwald     #define __USED __attribute__((used))
234*6b8177c5SMatthias Ringwald   #else
235*6b8177c5SMatthias Ringwald     #define __USED _Pragma("__root")
236*6b8177c5SMatthias Ringwald   #endif
237*6b8177c5SMatthias Ringwald #endif
238*6b8177c5SMatthias Ringwald 
239*6b8177c5SMatthias Ringwald #ifndef   __WEAK
240*6b8177c5SMatthias Ringwald   #if __ICCARM_V8
241*6b8177c5SMatthias Ringwald     #define __WEAK __attribute__((weak))
242*6b8177c5SMatthias Ringwald   #else
243*6b8177c5SMatthias Ringwald     #define __WEAK _Pragma("__weak")
244*6b8177c5SMatthias Ringwald   #endif
245*6b8177c5SMatthias Ringwald #endif
246*6b8177c5SMatthias Ringwald 
247*6b8177c5SMatthias Ringwald #ifndef __PROGRAM_START
248*6b8177c5SMatthias Ringwald #define __PROGRAM_START           __iar_program_start
249*6b8177c5SMatthias Ringwald #endif
250*6b8177c5SMatthias Ringwald 
251*6b8177c5SMatthias Ringwald #ifndef __INITIAL_SP
252*6b8177c5SMatthias Ringwald #define __INITIAL_SP              CSTACK$$Limit
253*6b8177c5SMatthias Ringwald #endif
254*6b8177c5SMatthias Ringwald 
255*6b8177c5SMatthias Ringwald #ifndef __STACK_LIMIT
256*6b8177c5SMatthias Ringwald #define __STACK_LIMIT             CSTACK$$Base
257*6b8177c5SMatthias Ringwald #endif
258*6b8177c5SMatthias Ringwald 
259*6b8177c5SMatthias Ringwald #ifndef __VECTOR_TABLE
260*6b8177c5SMatthias Ringwald #define __VECTOR_TABLE            __vector_table
261*6b8177c5SMatthias Ringwald #endif
262*6b8177c5SMatthias Ringwald 
263*6b8177c5SMatthias Ringwald #ifndef __VECTOR_TABLE_ATTRIBUTE
264*6b8177c5SMatthias Ringwald #define __VECTOR_TABLE_ATTRIBUTE  @".intvec"
265*6b8177c5SMatthias Ringwald #endif
266*6b8177c5SMatthias Ringwald 
267*6b8177c5SMatthias Ringwald #ifndef __ICCARM_INTRINSICS_VERSION__
268*6b8177c5SMatthias Ringwald   #define __ICCARM_INTRINSICS_VERSION__  0
269*6b8177c5SMatthias Ringwald #endif
270*6b8177c5SMatthias Ringwald 
271*6b8177c5SMatthias Ringwald #if __ICCARM_INTRINSICS_VERSION__ == 2
272*6b8177c5SMatthias Ringwald 
273*6b8177c5SMatthias Ringwald   #if defined(__CLZ)
274*6b8177c5SMatthias Ringwald     #undef __CLZ
275*6b8177c5SMatthias Ringwald   #endif
276*6b8177c5SMatthias Ringwald   #if defined(__REVSH)
277*6b8177c5SMatthias Ringwald     #undef __REVSH
278*6b8177c5SMatthias Ringwald   #endif
279*6b8177c5SMatthias Ringwald   #if defined(__RBIT)
280*6b8177c5SMatthias Ringwald     #undef __RBIT
281*6b8177c5SMatthias Ringwald   #endif
282*6b8177c5SMatthias Ringwald   #if defined(__SSAT)
283*6b8177c5SMatthias Ringwald     #undef __SSAT
284*6b8177c5SMatthias Ringwald   #endif
285*6b8177c5SMatthias Ringwald   #if defined(__USAT)
286*6b8177c5SMatthias Ringwald     #undef __USAT
287*6b8177c5SMatthias Ringwald   #endif
288*6b8177c5SMatthias Ringwald 
289*6b8177c5SMatthias Ringwald   #include "iccarm_builtin.h"
290*6b8177c5SMatthias Ringwald 
291*6b8177c5SMatthias Ringwald   #define __disable_fault_irq __iar_builtin_disable_fiq
292*6b8177c5SMatthias Ringwald   #define __disable_irq       __iar_builtin_disable_interrupt
293*6b8177c5SMatthias Ringwald   #define __enable_fault_irq  __iar_builtin_enable_fiq
294*6b8177c5SMatthias Ringwald   #define __enable_irq        __iar_builtin_enable_interrupt
295*6b8177c5SMatthias Ringwald   #define __arm_rsr           __iar_builtin_rsr
296*6b8177c5SMatthias Ringwald   #define __arm_wsr           __iar_builtin_wsr
297*6b8177c5SMatthias Ringwald 
298*6b8177c5SMatthias Ringwald 
299*6b8177c5SMatthias Ringwald   #define __get_APSR()                (__arm_rsr("APSR"))
300*6b8177c5SMatthias Ringwald   #define __get_BASEPRI()             (__arm_rsr("BASEPRI"))
301*6b8177c5SMatthias Ringwald   #define __get_CONTROL()             (__arm_rsr("CONTROL"))
302*6b8177c5SMatthias Ringwald   #define __get_FAULTMASK()           (__arm_rsr("FAULTMASK"))
303*6b8177c5SMatthias Ringwald 
304*6b8177c5SMatthias Ringwald   #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
305*6b8177c5SMatthias Ringwald        (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
306*6b8177c5SMatthias Ringwald     #define __get_FPSCR()             (__arm_rsr("FPSCR"))
307*6b8177c5SMatthias Ringwald     #define __set_FPSCR(VALUE)        (__arm_wsr("FPSCR", (VALUE)))
308*6b8177c5SMatthias Ringwald   #else
309*6b8177c5SMatthias Ringwald     #define __get_FPSCR()             ( 0 )
310*6b8177c5SMatthias Ringwald     #define __set_FPSCR(VALUE)        ((void)VALUE)
311*6b8177c5SMatthias Ringwald   #endif
312*6b8177c5SMatthias Ringwald 
313*6b8177c5SMatthias Ringwald   #define __get_IPSR()                (__arm_rsr("IPSR"))
314*6b8177c5SMatthias Ringwald   #define __get_MSP()                 (__arm_rsr("MSP"))
315*6b8177c5SMatthias Ringwald   #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
316*6b8177c5SMatthias Ringwald        (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
317*6b8177c5SMatthias Ringwald     // without main extensions, the non-secure MSPLIM is RAZ/WI
318*6b8177c5SMatthias Ringwald     #define __get_MSPLIM()            (0U)
319*6b8177c5SMatthias Ringwald   #else
320*6b8177c5SMatthias Ringwald     #define __get_MSPLIM()            (__arm_rsr("MSPLIM"))
321*6b8177c5SMatthias Ringwald   #endif
322*6b8177c5SMatthias Ringwald   #define __get_PRIMASK()             (__arm_rsr("PRIMASK"))
323*6b8177c5SMatthias Ringwald   #define __get_PSP()                 (__arm_rsr("PSP"))
324*6b8177c5SMatthias Ringwald 
325*6b8177c5SMatthias Ringwald   #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
326*6b8177c5SMatthias Ringwald        (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
327*6b8177c5SMatthias Ringwald     // without main extensions, the non-secure PSPLIM is RAZ/WI
328*6b8177c5SMatthias Ringwald     #define __get_PSPLIM()            (0U)
329*6b8177c5SMatthias Ringwald   #else
330*6b8177c5SMatthias Ringwald     #define __get_PSPLIM()            (__arm_rsr("PSPLIM"))
331*6b8177c5SMatthias Ringwald   #endif
332*6b8177c5SMatthias Ringwald 
333*6b8177c5SMatthias Ringwald   #define __get_xPSR()                (__arm_rsr("xPSR"))
334*6b8177c5SMatthias Ringwald 
335*6b8177c5SMatthias Ringwald   #define __set_BASEPRI(VALUE)        (__arm_wsr("BASEPRI", (VALUE)))
336*6b8177c5SMatthias Ringwald   #define __set_BASEPRI_MAX(VALUE)    (__arm_wsr("BASEPRI_MAX", (VALUE)))
337*6b8177c5SMatthias Ringwald   #define __set_CONTROL(VALUE)        (__arm_wsr("CONTROL", (VALUE)))
338*6b8177c5SMatthias Ringwald   #define __set_FAULTMASK(VALUE)      (__arm_wsr("FAULTMASK", (VALUE)))
339*6b8177c5SMatthias Ringwald   #define __set_MSP(VALUE)            (__arm_wsr("MSP", (VALUE)))
340*6b8177c5SMatthias Ringwald 
341*6b8177c5SMatthias Ringwald   #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
342*6b8177c5SMatthias Ringwald        (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
343*6b8177c5SMatthias Ringwald     // without main extensions, the non-secure MSPLIM is RAZ/WI
344*6b8177c5SMatthias Ringwald     #define __set_MSPLIM(VALUE)       ((void)(VALUE))
345*6b8177c5SMatthias Ringwald   #else
346*6b8177c5SMatthias Ringwald     #define __set_MSPLIM(VALUE)       (__arm_wsr("MSPLIM", (VALUE)))
347*6b8177c5SMatthias Ringwald   #endif
348*6b8177c5SMatthias Ringwald   #define __set_PRIMASK(VALUE)        (__arm_wsr("PRIMASK", (VALUE)))
349*6b8177c5SMatthias Ringwald   #define __set_PSP(VALUE)            (__arm_wsr("PSP", (VALUE)))
350*6b8177c5SMatthias Ringwald   #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
351*6b8177c5SMatthias Ringwald        (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
352*6b8177c5SMatthias Ringwald     // without main extensions, the non-secure PSPLIM is RAZ/WI
353*6b8177c5SMatthias Ringwald     #define __set_PSPLIM(VALUE)       ((void)(VALUE))
354*6b8177c5SMatthias Ringwald   #else
355*6b8177c5SMatthias Ringwald     #define __set_PSPLIM(VALUE)       (__arm_wsr("PSPLIM", (VALUE)))
356*6b8177c5SMatthias Ringwald   #endif
357*6b8177c5SMatthias Ringwald 
358*6b8177c5SMatthias Ringwald   #define __TZ_get_CONTROL_NS()       (__arm_rsr("CONTROL_NS"))
359*6b8177c5SMatthias Ringwald   #define __TZ_set_CONTROL_NS(VALUE)  (__arm_wsr("CONTROL_NS", (VALUE)))
360*6b8177c5SMatthias Ringwald   #define __TZ_get_PSP_NS()           (__arm_rsr("PSP_NS"))
361*6b8177c5SMatthias Ringwald   #define __TZ_set_PSP_NS(VALUE)      (__arm_wsr("PSP_NS", (VALUE)))
362*6b8177c5SMatthias Ringwald   #define __TZ_get_MSP_NS()           (__arm_rsr("MSP_NS"))
363*6b8177c5SMatthias Ringwald   #define __TZ_set_MSP_NS(VALUE)      (__arm_wsr("MSP_NS", (VALUE)))
364*6b8177c5SMatthias Ringwald   #define __TZ_get_SP_NS()            (__arm_rsr("SP_NS"))
365*6b8177c5SMatthias Ringwald   #define __TZ_set_SP_NS(VALUE)       (__arm_wsr("SP_NS", (VALUE)))
366*6b8177c5SMatthias Ringwald   #define __TZ_get_PRIMASK_NS()       (__arm_rsr("PRIMASK_NS"))
367*6b8177c5SMatthias Ringwald   #define __TZ_set_PRIMASK_NS(VALUE)  (__arm_wsr("PRIMASK_NS", (VALUE)))
368*6b8177c5SMatthias Ringwald   #define __TZ_get_BASEPRI_NS()       (__arm_rsr("BASEPRI_NS"))
369*6b8177c5SMatthias Ringwald   #define __TZ_set_BASEPRI_NS(VALUE)  (__arm_wsr("BASEPRI_NS", (VALUE)))
370*6b8177c5SMatthias Ringwald   #define __TZ_get_FAULTMASK_NS()     (__arm_rsr("FAULTMASK_NS"))
371*6b8177c5SMatthias Ringwald   #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE)))
372*6b8177c5SMatthias Ringwald 
373*6b8177c5SMatthias Ringwald   #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
374*6b8177c5SMatthias Ringwald        (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
375*6b8177c5SMatthias Ringwald     // without main extensions, the non-secure PSPLIM is RAZ/WI
376*6b8177c5SMatthias Ringwald     #define __TZ_get_PSPLIM_NS()      (0U)
377*6b8177c5SMatthias Ringwald     #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE))
378*6b8177c5SMatthias Ringwald   #else
379*6b8177c5SMatthias Ringwald     #define __TZ_get_PSPLIM_NS()      (__arm_rsr("PSPLIM_NS"))
380*6b8177c5SMatthias Ringwald     #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE)))
381*6b8177c5SMatthias Ringwald   #endif
382*6b8177c5SMatthias Ringwald 
383*6b8177c5SMatthias Ringwald   #define __TZ_get_MSPLIM_NS()        (__arm_rsr("MSPLIM_NS"))
384*6b8177c5SMatthias Ringwald   #define __TZ_set_MSPLIM_NS(VALUE)   (__arm_wsr("MSPLIM_NS", (VALUE)))
385*6b8177c5SMatthias Ringwald 
386*6b8177c5SMatthias Ringwald   #define __NOP     __iar_builtin_no_operation
387*6b8177c5SMatthias Ringwald 
388*6b8177c5SMatthias Ringwald   #define __CLZ     __iar_builtin_CLZ
389*6b8177c5SMatthias Ringwald   #define __CLREX   __iar_builtin_CLREX
390*6b8177c5SMatthias Ringwald 
391*6b8177c5SMatthias Ringwald   #define __DMB     __iar_builtin_DMB
392*6b8177c5SMatthias Ringwald   #define __DSB     __iar_builtin_DSB
393*6b8177c5SMatthias Ringwald   #define __ISB     __iar_builtin_ISB
394*6b8177c5SMatthias Ringwald 
395*6b8177c5SMatthias Ringwald   #define __LDREXB  __iar_builtin_LDREXB
396*6b8177c5SMatthias Ringwald   #define __LDREXH  __iar_builtin_LDREXH
397*6b8177c5SMatthias Ringwald   #define __LDREXW  __iar_builtin_LDREX
398*6b8177c5SMatthias Ringwald 
399*6b8177c5SMatthias Ringwald   #define __RBIT    __iar_builtin_RBIT
400*6b8177c5SMatthias Ringwald   #define __REV     __iar_builtin_REV
401*6b8177c5SMatthias Ringwald   #define __REV16   __iar_builtin_REV16
402*6b8177c5SMatthias Ringwald 
__REVSH(int16_t val)403*6b8177c5SMatthias Ringwald   __IAR_FT int16_t __REVSH(int16_t val)
404*6b8177c5SMatthias Ringwald   {
405*6b8177c5SMatthias Ringwald     return (int16_t) __iar_builtin_REVSH(val);
406*6b8177c5SMatthias Ringwald   }
407*6b8177c5SMatthias Ringwald 
408*6b8177c5SMatthias Ringwald   #define __ROR     __iar_builtin_ROR
409*6b8177c5SMatthias Ringwald   #define __RRX     __iar_builtin_RRX
410*6b8177c5SMatthias Ringwald 
411*6b8177c5SMatthias Ringwald   #define __SEV     __iar_builtin_SEV
412*6b8177c5SMatthias Ringwald 
413*6b8177c5SMatthias Ringwald   #if !__IAR_M0_FAMILY
414*6b8177c5SMatthias Ringwald     #define __SSAT    __iar_builtin_SSAT
415*6b8177c5SMatthias Ringwald   #endif
416*6b8177c5SMatthias Ringwald 
417*6b8177c5SMatthias Ringwald   #define __STREXB  __iar_builtin_STREXB
418*6b8177c5SMatthias Ringwald   #define __STREXH  __iar_builtin_STREXH
419*6b8177c5SMatthias Ringwald   #define __STREXW  __iar_builtin_STREX
420*6b8177c5SMatthias Ringwald 
421*6b8177c5SMatthias Ringwald   #if !__IAR_M0_FAMILY
422*6b8177c5SMatthias Ringwald     #define __USAT    __iar_builtin_USAT
423*6b8177c5SMatthias Ringwald   #endif
424*6b8177c5SMatthias Ringwald 
425*6b8177c5SMatthias Ringwald   #define __WFE     __iar_builtin_WFE
426*6b8177c5SMatthias Ringwald   #define __WFI     __iar_builtin_WFI
427*6b8177c5SMatthias Ringwald 
428*6b8177c5SMatthias Ringwald   #if __ARM_MEDIA__
429*6b8177c5SMatthias Ringwald     #define __SADD8   __iar_builtin_SADD8
430*6b8177c5SMatthias Ringwald     #define __QADD8   __iar_builtin_QADD8
431*6b8177c5SMatthias Ringwald     #define __SHADD8  __iar_builtin_SHADD8
432*6b8177c5SMatthias Ringwald     #define __UADD8   __iar_builtin_UADD8
433*6b8177c5SMatthias Ringwald     #define __UQADD8  __iar_builtin_UQADD8
434*6b8177c5SMatthias Ringwald     #define __UHADD8  __iar_builtin_UHADD8
435*6b8177c5SMatthias Ringwald     #define __SSUB8   __iar_builtin_SSUB8
436*6b8177c5SMatthias Ringwald     #define __QSUB8   __iar_builtin_QSUB8
437*6b8177c5SMatthias Ringwald     #define __SHSUB8  __iar_builtin_SHSUB8
438*6b8177c5SMatthias Ringwald     #define __USUB8   __iar_builtin_USUB8
439*6b8177c5SMatthias Ringwald     #define __UQSUB8  __iar_builtin_UQSUB8
440*6b8177c5SMatthias Ringwald     #define __UHSUB8  __iar_builtin_UHSUB8
441*6b8177c5SMatthias Ringwald     #define __SADD16  __iar_builtin_SADD16
442*6b8177c5SMatthias Ringwald     #define __QADD16  __iar_builtin_QADD16
443*6b8177c5SMatthias Ringwald     #define __SHADD16 __iar_builtin_SHADD16
444*6b8177c5SMatthias Ringwald     #define __UADD16  __iar_builtin_UADD16
445*6b8177c5SMatthias Ringwald     #define __UQADD16 __iar_builtin_UQADD16
446*6b8177c5SMatthias Ringwald     #define __UHADD16 __iar_builtin_UHADD16
447*6b8177c5SMatthias Ringwald     #define __SSUB16  __iar_builtin_SSUB16
448*6b8177c5SMatthias Ringwald     #define __QSUB16  __iar_builtin_QSUB16
449*6b8177c5SMatthias Ringwald     #define __SHSUB16 __iar_builtin_SHSUB16
450*6b8177c5SMatthias Ringwald     #define __USUB16  __iar_builtin_USUB16
451*6b8177c5SMatthias Ringwald     #define __UQSUB16 __iar_builtin_UQSUB16
452*6b8177c5SMatthias Ringwald     #define __UHSUB16 __iar_builtin_UHSUB16
453*6b8177c5SMatthias Ringwald     #define __SASX    __iar_builtin_SASX
454*6b8177c5SMatthias Ringwald     #define __QASX    __iar_builtin_QASX
455*6b8177c5SMatthias Ringwald     #define __SHASX   __iar_builtin_SHASX
456*6b8177c5SMatthias Ringwald     #define __UASX    __iar_builtin_UASX
457*6b8177c5SMatthias Ringwald     #define __UQASX   __iar_builtin_UQASX
458*6b8177c5SMatthias Ringwald     #define __UHASX   __iar_builtin_UHASX
459*6b8177c5SMatthias Ringwald     #define __SSAX    __iar_builtin_SSAX
460*6b8177c5SMatthias Ringwald     #define __QSAX    __iar_builtin_QSAX
461*6b8177c5SMatthias Ringwald     #define __SHSAX   __iar_builtin_SHSAX
462*6b8177c5SMatthias Ringwald     #define __USAX    __iar_builtin_USAX
463*6b8177c5SMatthias Ringwald     #define __UQSAX   __iar_builtin_UQSAX
464*6b8177c5SMatthias Ringwald     #define __UHSAX   __iar_builtin_UHSAX
465*6b8177c5SMatthias Ringwald     #define __USAD8   __iar_builtin_USAD8
466*6b8177c5SMatthias Ringwald     #define __USADA8  __iar_builtin_USADA8
467*6b8177c5SMatthias Ringwald     #define __SSAT16  __iar_builtin_SSAT16
468*6b8177c5SMatthias Ringwald     #define __USAT16  __iar_builtin_USAT16
469*6b8177c5SMatthias Ringwald     #define __UXTB16  __iar_builtin_UXTB16
470*6b8177c5SMatthias Ringwald     #define __UXTAB16 __iar_builtin_UXTAB16
471*6b8177c5SMatthias Ringwald     #define __SXTB16  __iar_builtin_SXTB16
472*6b8177c5SMatthias Ringwald     #define __SXTAB16 __iar_builtin_SXTAB16
473*6b8177c5SMatthias Ringwald     #define __SMUAD   __iar_builtin_SMUAD
474*6b8177c5SMatthias Ringwald     #define __SMUADX  __iar_builtin_SMUADX
475*6b8177c5SMatthias Ringwald     #define __SMMLA   __iar_builtin_SMMLA
476*6b8177c5SMatthias Ringwald     #define __SMLAD   __iar_builtin_SMLAD
477*6b8177c5SMatthias Ringwald     #define __SMLADX  __iar_builtin_SMLADX
478*6b8177c5SMatthias Ringwald     #define __SMLALD  __iar_builtin_SMLALD
479*6b8177c5SMatthias Ringwald     #define __SMLALDX __iar_builtin_SMLALDX
480*6b8177c5SMatthias Ringwald     #define __SMUSD   __iar_builtin_SMUSD
481*6b8177c5SMatthias Ringwald     #define __SMUSDX  __iar_builtin_SMUSDX
482*6b8177c5SMatthias Ringwald     #define __SMLSD   __iar_builtin_SMLSD
483*6b8177c5SMatthias Ringwald     #define __SMLSDX  __iar_builtin_SMLSDX
484*6b8177c5SMatthias Ringwald     #define __SMLSLD  __iar_builtin_SMLSLD
485*6b8177c5SMatthias Ringwald     #define __SMLSLDX __iar_builtin_SMLSLDX
486*6b8177c5SMatthias Ringwald     #define __SEL     __iar_builtin_SEL
487*6b8177c5SMatthias Ringwald     #define __QADD    __iar_builtin_QADD
488*6b8177c5SMatthias Ringwald     #define __QSUB    __iar_builtin_QSUB
489*6b8177c5SMatthias Ringwald     #define __PKHBT   __iar_builtin_PKHBT
490*6b8177c5SMatthias Ringwald     #define __PKHTB   __iar_builtin_PKHTB
491*6b8177c5SMatthias Ringwald   #endif
492*6b8177c5SMatthias Ringwald 
493*6b8177c5SMatthias Ringwald #else /* __ICCARM_INTRINSICS_VERSION__ == 2 */
494*6b8177c5SMatthias Ringwald 
495*6b8177c5SMatthias Ringwald   #if __IAR_M0_FAMILY
496*6b8177c5SMatthias Ringwald    /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
497*6b8177c5SMatthias Ringwald     #define __CLZ  __cmsis_iar_clz_not_active
498*6b8177c5SMatthias Ringwald     #define __SSAT __cmsis_iar_ssat_not_active
499*6b8177c5SMatthias Ringwald     #define __USAT __cmsis_iar_usat_not_active
500*6b8177c5SMatthias Ringwald     #define __RBIT __cmsis_iar_rbit_not_active
501*6b8177c5SMatthias Ringwald     #define __get_APSR  __cmsis_iar_get_APSR_not_active
502*6b8177c5SMatthias Ringwald   #endif
503*6b8177c5SMatthias Ringwald 
504*6b8177c5SMatthias Ringwald 
505*6b8177c5SMatthias Ringwald   #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
506*6b8177c5SMatthias Ringwald          (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     ))
507*6b8177c5SMatthias Ringwald     #define __get_FPSCR __cmsis_iar_get_FPSR_not_active
508*6b8177c5SMatthias Ringwald     #define __set_FPSCR __cmsis_iar_set_FPSR_not_active
509*6b8177c5SMatthias Ringwald   #endif
510*6b8177c5SMatthias Ringwald 
511*6b8177c5SMatthias Ringwald   #ifdef __INTRINSICS_INCLUDED
512*6b8177c5SMatthias Ringwald   #error intrinsics.h is already included previously!
513*6b8177c5SMatthias Ringwald   #endif
514*6b8177c5SMatthias Ringwald 
515*6b8177c5SMatthias Ringwald   #include <intrinsics.h>
516*6b8177c5SMatthias Ringwald 
517*6b8177c5SMatthias Ringwald   #if __IAR_M0_FAMILY
518*6b8177c5SMatthias Ringwald    /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
519*6b8177c5SMatthias Ringwald     #undef __CLZ
520*6b8177c5SMatthias Ringwald     #undef __SSAT
521*6b8177c5SMatthias Ringwald     #undef __USAT
522*6b8177c5SMatthias Ringwald     #undef __RBIT
523*6b8177c5SMatthias Ringwald     #undef __get_APSR
524*6b8177c5SMatthias Ringwald 
__CLZ(uint32_t data)525*6b8177c5SMatthias Ringwald     __STATIC_INLINE uint8_t __CLZ(uint32_t data)
526*6b8177c5SMatthias Ringwald     {
527*6b8177c5SMatthias Ringwald       if (data == 0U) { return 32U; }
528*6b8177c5SMatthias Ringwald 
529*6b8177c5SMatthias Ringwald       uint32_t count = 0U;
530*6b8177c5SMatthias Ringwald       uint32_t mask = 0x80000000U;
531*6b8177c5SMatthias Ringwald 
532*6b8177c5SMatthias Ringwald       while ((data & mask) == 0U)
533*6b8177c5SMatthias Ringwald       {
534*6b8177c5SMatthias Ringwald         count += 1U;
535*6b8177c5SMatthias Ringwald         mask = mask >> 1U;
536*6b8177c5SMatthias Ringwald       }
537*6b8177c5SMatthias Ringwald       return count;
538*6b8177c5SMatthias Ringwald     }
539*6b8177c5SMatthias Ringwald 
__RBIT(uint32_t v)540*6b8177c5SMatthias Ringwald     __STATIC_INLINE uint32_t __RBIT(uint32_t v)
541*6b8177c5SMatthias Ringwald     {
542*6b8177c5SMatthias Ringwald       uint8_t sc = 31U;
543*6b8177c5SMatthias Ringwald       uint32_t r = v;
544*6b8177c5SMatthias Ringwald       for (v >>= 1U; v; v >>= 1U)
545*6b8177c5SMatthias Ringwald       {
546*6b8177c5SMatthias Ringwald         r <<= 1U;
547*6b8177c5SMatthias Ringwald         r |= v & 1U;
548*6b8177c5SMatthias Ringwald         sc--;
549*6b8177c5SMatthias Ringwald       }
550*6b8177c5SMatthias Ringwald       return (r << sc);
551*6b8177c5SMatthias Ringwald     }
552*6b8177c5SMatthias Ringwald 
__get_APSR(void)553*6b8177c5SMatthias Ringwald     __STATIC_INLINE  uint32_t __get_APSR(void)
554*6b8177c5SMatthias Ringwald     {
555*6b8177c5SMatthias Ringwald       uint32_t res;
556*6b8177c5SMatthias Ringwald       __asm("MRS      %0,APSR" : "=r" (res));
557*6b8177c5SMatthias Ringwald       return res;
558*6b8177c5SMatthias Ringwald     }
559*6b8177c5SMatthias Ringwald 
560*6b8177c5SMatthias Ringwald   #endif
561*6b8177c5SMatthias Ringwald 
562*6b8177c5SMatthias Ringwald   #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
563*6b8177c5SMatthias Ringwald          (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     ))
564*6b8177c5SMatthias Ringwald     #undef __get_FPSCR
565*6b8177c5SMatthias Ringwald     #undef __set_FPSCR
566*6b8177c5SMatthias Ringwald     #define __get_FPSCR()       (0)
567*6b8177c5SMatthias Ringwald     #define __set_FPSCR(VALUE)  ((void)VALUE)
568*6b8177c5SMatthias Ringwald   #endif
569*6b8177c5SMatthias Ringwald 
570*6b8177c5SMatthias Ringwald   #pragma diag_suppress=Pe940
571*6b8177c5SMatthias Ringwald   #pragma diag_suppress=Pe177
572*6b8177c5SMatthias Ringwald 
573*6b8177c5SMatthias Ringwald   #define __enable_irq    __enable_interrupt
574*6b8177c5SMatthias Ringwald   #define __disable_irq   __disable_interrupt
575*6b8177c5SMatthias Ringwald   #define __NOP           __no_operation
576*6b8177c5SMatthias Ringwald 
577*6b8177c5SMatthias Ringwald   #define __get_xPSR      __get_PSR
578*6b8177c5SMatthias Ringwald 
579*6b8177c5SMatthias Ringwald   #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0)
580*6b8177c5SMatthias Ringwald 
__LDREXW(uint32_t volatile * ptr)581*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr)
582*6b8177c5SMatthias Ringwald     {
583*6b8177c5SMatthias Ringwald       return __LDREX((unsigned long *)ptr);
584*6b8177c5SMatthias Ringwald     }
585*6b8177c5SMatthias Ringwald 
__STREXW(uint32_t value,uint32_t volatile * ptr)586*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr)
587*6b8177c5SMatthias Ringwald     {
588*6b8177c5SMatthias Ringwald       return __STREX(value, (unsigned long *)ptr);
589*6b8177c5SMatthias Ringwald     }
590*6b8177c5SMatthias Ringwald   #endif
591*6b8177c5SMatthias Ringwald 
592*6b8177c5SMatthias Ringwald 
593*6b8177c5SMatthias Ringwald   /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
594*6b8177c5SMatthias Ringwald   #if (__CORTEX_M >= 0x03)
595*6b8177c5SMatthias Ringwald 
__RRX(uint32_t value)596*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t __RRX(uint32_t value)
597*6b8177c5SMatthias Ringwald     {
598*6b8177c5SMatthias Ringwald       uint32_t result;
599*6b8177c5SMatthias Ringwald       __ASM("RRX      %0, %1" : "=r"(result) : "r" (value) : "cc");
600*6b8177c5SMatthias Ringwald       return(result);
601*6b8177c5SMatthias Ringwald     }
602*6b8177c5SMatthias Ringwald 
__set_BASEPRI_MAX(uint32_t value)603*6b8177c5SMatthias Ringwald     __IAR_FT void __set_BASEPRI_MAX(uint32_t value)
604*6b8177c5SMatthias Ringwald     {
605*6b8177c5SMatthias Ringwald       __asm volatile("MSR      BASEPRI_MAX,%0"::"r" (value));
606*6b8177c5SMatthias Ringwald     }
607*6b8177c5SMatthias Ringwald 
608*6b8177c5SMatthias Ringwald 
609*6b8177c5SMatthias Ringwald     #define __enable_fault_irq  __enable_fiq
610*6b8177c5SMatthias Ringwald     #define __disable_fault_irq __disable_fiq
611*6b8177c5SMatthias Ringwald 
612*6b8177c5SMatthias Ringwald 
613*6b8177c5SMatthias Ringwald   #endif /* (__CORTEX_M >= 0x03) */
614*6b8177c5SMatthias Ringwald 
__ROR(uint32_t op1,uint32_t op2)615*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2)
616*6b8177c5SMatthias Ringwald   {
617*6b8177c5SMatthias Ringwald     return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2));
618*6b8177c5SMatthias Ringwald   }
619*6b8177c5SMatthias Ringwald 
620*6b8177c5SMatthias Ringwald   #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
621*6b8177c5SMatthias Ringwald        (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
622*6b8177c5SMatthias Ringwald 
__get_MSPLIM(void)623*6b8177c5SMatthias Ringwald    __IAR_FT uint32_t __get_MSPLIM(void)
624*6b8177c5SMatthias Ringwald     {
625*6b8177c5SMatthias Ringwald       uint32_t res;
626*6b8177c5SMatthias Ringwald     #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
627*6b8177c5SMatthias Ringwald          (!defined (__ARM_FEATURE_CMSE  ) || (__ARM_FEATURE_CMSE   < 3)))
628*6b8177c5SMatthias Ringwald       // without main extensions, the non-secure MSPLIM is RAZ/WI
629*6b8177c5SMatthias Ringwald       res = 0U;
630*6b8177c5SMatthias Ringwald     #else
631*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,MSPLIM" : "=r" (res));
632*6b8177c5SMatthias Ringwald     #endif
633*6b8177c5SMatthias Ringwald       return res;
634*6b8177c5SMatthias Ringwald     }
635*6b8177c5SMatthias Ringwald 
__set_MSPLIM(uint32_t value)636*6b8177c5SMatthias Ringwald     __IAR_FT void   __set_MSPLIM(uint32_t value)
637*6b8177c5SMatthias Ringwald     {
638*6b8177c5SMatthias Ringwald     #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
639*6b8177c5SMatthias Ringwald          (!defined (__ARM_FEATURE_CMSE  ) || (__ARM_FEATURE_CMSE   < 3)))
640*6b8177c5SMatthias Ringwald       // without main extensions, the non-secure MSPLIM is RAZ/WI
641*6b8177c5SMatthias Ringwald       (void)value;
642*6b8177c5SMatthias Ringwald     #else
643*6b8177c5SMatthias Ringwald       __asm volatile("MSR      MSPLIM,%0" :: "r" (value));
644*6b8177c5SMatthias Ringwald     #endif
645*6b8177c5SMatthias Ringwald     }
646*6b8177c5SMatthias Ringwald 
__get_PSPLIM(void)647*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t __get_PSPLIM(void)
648*6b8177c5SMatthias Ringwald     {
649*6b8177c5SMatthias Ringwald       uint32_t res;
650*6b8177c5SMatthias Ringwald     #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
651*6b8177c5SMatthias Ringwald          (!defined (__ARM_FEATURE_CMSE  ) || (__ARM_FEATURE_CMSE   < 3)))
652*6b8177c5SMatthias Ringwald       // without main extensions, the non-secure PSPLIM is RAZ/WI
653*6b8177c5SMatthias Ringwald       res = 0U;
654*6b8177c5SMatthias Ringwald     #else
655*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,PSPLIM" : "=r" (res));
656*6b8177c5SMatthias Ringwald     #endif
657*6b8177c5SMatthias Ringwald       return res;
658*6b8177c5SMatthias Ringwald     }
659*6b8177c5SMatthias Ringwald 
__set_PSPLIM(uint32_t value)660*6b8177c5SMatthias Ringwald     __IAR_FT void   __set_PSPLIM(uint32_t value)
661*6b8177c5SMatthias Ringwald     {
662*6b8177c5SMatthias Ringwald     #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
663*6b8177c5SMatthias Ringwald          (!defined (__ARM_FEATURE_CMSE  ) || (__ARM_FEATURE_CMSE   < 3)))
664*6b8177c5SMatthias Ringwald       // without main extensions, the non-secure PSPLIM is RAZ/WI
665*6b8177c5SMatthias Ringwald       (void)value;
666*6b8177c5SMatthias Ringwald     #else
667*6b8177c5SMatthias Ringwald       __asm volatile("MSR      PSPLIM,%0" :: "r" (value));
668*6b8177c5SMatthias Ringwald     #endif
669*6b8177c5SMatthias Ringwald     }
670*6b8177c5SMatthias Ringwald 
__TZ_get_CONTROL_NS(void)671*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t __TZ_get_CONTROL_NS(void)
672*6b8177c5SMatthias Ringwald     {
673*6b8177c5SMatthias Ringwald       uint32_t res;
674*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,CONTROL_NS" : "=r" (res));
675*6b8177c5SMatthias Ringwald       return res;
676*6b8177c5SMatthias Ringwald     }
677*6b8177c5SMatthias Ringwald 
__TZ_set_CONTROL_NS(uint32_t value)678*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_CONTROL_NS(uint32_t value)
679*6b8177c5SMatthias Ringwald     {
680*6b8177c5SMatthias Ringwald       __asm volatile("MSR      CONTROL_NS,%0" :: "r" (value));
681*6b8177c5SMatthias Ringwald     }
682*6b8177c5SMatthias Ringwald 
__TZ_get_PSP_NS(void)683*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_PSP_NS(void)
684*6b8177c5SMatthias Ringwald     {
685*6b8177c5SMatthias Ringwald       uint32_t res;
686*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,PSP_NS" : "=r" (res));
687*6b8177c5SMatthias Ringwald       return res;
688*6b8177c5SMatthias Ringwald     }
689*6b8177c5SMatthias Ringwald 
__TZ_set_PSP_NS(uint32_t value)690*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_PSP_NS(uint32_t value)
691*6b8177c5SMatthias Ringwald     {
692*6b8177c5SMatthias Ringwald       __asm volatile("MSR      PSP_NS,%0" :: "r" (value));
693*6b8177c5SMatthias Ringwald     }
694*6b8177c5SMatthias Ringwald 
__TZ_get_MSP_NS(void)695*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_MSP_NS(void)
696*6b8177c5SMatthias Ringwald     {
697*6b8177c5SMatthias Ringwald       uint32_t res;
698*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,MSP_NS" : "=r" (res));
699*6b8177c5SMatthias Ringwald       return res;
700*6b8177c5SMatthias Ringwald     }
701*6b8177c5SMatthias Ringwald 
__TZ_set_MSP_NS(uint32_t value)702*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_MSP_NS(uint32_t value)
703*6b8177c5SMatthias Ringwald     {
704*6b8177c5SMatthias Ringwald       __asm volatile("MSR      MSP_NS,%0" :: "r" (value));
705*6b8177c5SMatthias Ringwald     }
706*6b8177c5SMatthias Ringwald 
__TZ_get_SP_NS(void)707*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_SP_NS(void)
708*6b8177c5SMatthias Ringwald     {
709*6b8177c5SMatthias Ringwald       uint32_t res;
710*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,SP_NS" : "=r" (res));
711*6b8177c5SMatthias Ringwald       return res;
712*6b8177c5SMatthias Ringwald     }
__TZ_set_SP_NS(uint32_t value)713*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_SP_NS(uint32_t value)
714*6b8177c5SMatthias Ringwald     {
715*6b8177c5SMatthias Ringwald       __asm volatile("MSR      SP_NS,%0" :: "r" (value));
716*6b8177c5SMatthias Ringwald     }
717*6b8177c5SMatthias Ringwald 
__TZ_get_PRIMASK_NS(void)718*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_PRIMASK_NS(void)
719*6b8177c5SMatthias Ringwald     {
720*6b8177c5SMatthias Ringwald       uint32_t res;
721*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,PRIMASK_NS" : "=r" (res));
722*6b8177c5SMatthias Ringwald       return res;
723*6b8177c5SMatthias Ringwald     }
724*6b8177c5SMatthias Ringwald 
__TZ_set_PRIMASK_NS(uint32_t value)725*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_PRIMASK_NS(uint32_t value)
726*6b8177c5SMatthias Ringwald     {
727*6b8177c5SMatthias Ringwald       __asm volatile("MSR      PRIMASK_NS,%0" :: "r" (value));
728*6b8177c5SMatthias Ringwald     }
729*6b8177c5SMatthias Ringwald 
__TZ_get_BASEPRI_NS(void)730*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_BASEPRI_NS(void)
731*6b8177c5SMatthias Ringwald     {
732*6b8177c5SMatthias Ringwald       uint32_t res;
733*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,BASEPRI_NS" : "=r" (res));
734*6b8177c5SMatthias Ringwald       return res;
735*6b8177c5SMatthias Ringwald     }
736*6b8177c5SMatthias Ringwald 
__TZ_set_BASEPRI_NS(uint32_t value)737*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_BASEPRI_NS(uint32_t value)
738*6b8177c5SMatthias Ringwald     {
739*6b8177c5SMatthias Ringwald       __asm volatile("MSR      BASEPRI_NS,%0" :: "r" (value));
740*6b8177c5SMatthias Ringwald     }
741*6b8177c5SMatthias Ringwald 
__TZ_get_FAULTMASK_NS(void)742*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_FAULTMASK_NS(void)
743*6b8177c5SMatthias Ringwald     {
744*6b8177c5SMatthias Ringwald       uint32_t res;
745*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,FAULTMASK_NS" : "=r" (res));
746*6b8177c5SMatthias Ringwald       return res;
747*6b8177c5SMatthias Ringwald     }
748*6b8177c5SMatthias Ringwald 
__TZ_set_FAULTMASK_NS(uint32_t value)749*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_FAULTMASK_NS(uint32_t value)
750*6b8177c5SMatthias Ringwald     {
751*6b8177c5SMatthias Ringwald       __asm volatile("MSR      FAULTMASK_NS,%0" :: "r" (value));
752*6b8177c5SMatthias Ringwald     }
753*6b8177c5SMatthias Ringwald 
__TZ_get_PSPLIM_NS(void)754*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_PSPLIM_NS(void)
755*6b8177c5SMatthias Ringwald     {
756*6b8177c5SMatthias Ringwald       uint32_t res;
757*6b8177c5SMatthias Ringwald     #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
758*6b8177c5SMatthias Ringwald          (!defined (__ARM_FEATURE_CMSE  ) || (__ARM_FEATURE_CMSE   < 3)))
759*6b8177c5SMatthias Ringwald       // without main extensions, the non-secure PSPLIM is RAZ/WI
760*6b8177c5SMatthias Ringwald       res = 0U;
761*6b8177c5SMatthias Ringwald     #else
762*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,PSPLIM_NS" : "=r" (res));
763*6b8177c5SMatthias Ringwald     #endif
764*6b8177c5SMatthias Ringwald       return res;
765*6b8177c5SMatthias Ringwald     }
766*6b8177c5SMatthias Ringwald 
__TZ_set_PSPLIM_NS(uint32_t value)767*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_PSPLIM_NS(uint32_t value)
768*6b8177c5SMatthias Ringwald     {
769*6b8177c5SMatthias Ringwald     #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
770*6b8177c5SMatthias Ringwald          (!defined (__ARM_FEATURE_CMSE  ) || (__ARM_FEATURE_CMSE   < 3)))
771*6b8177c5SMatthias Ringwald       // without main extensions, the non-secure PSPLIM is RAZ/WI
772*6b8177c5SMatthias Ringwald       (void)value;
773*6b8177c5SMatthias Ringwald     #else
774*6b8177c5SMatthias Ringwald       __asm volatile("MSR      PSPLIM_NS,%0" :: "r" (value));
775*6b8177c5SMatthias Ringwald     #endif
776*6b8177c5SMatthias Ringwald     }
777*6b8177c5SMatthias Ringwald 
__TZ_get_MSPLIM_NS(void)778*6b8177c5SMatthias Ringwald     __IAR_FT uint32_t   __TZ_get_MSPLIM_NS(void)
779*6b8177c5SMatthias Ringwald     {
780*6b8177c5SMatthias Ringwald       uint32_t res;
781*6b8177c5SMatthias Ringwald       __asm volatile("MRS      %0,MSPLIM_NS" : "=r" (res));
782*6b8177c5SMatthias Ringwald       return res;
783*6b8177c5SMatthias Ringwald     }
784*6b8177c5SMatthias Ringwald 
__TZ_set_MSPLIM_NS(uint32_t value)785*6b8177c5SMatthias Ringwald     __IAR_FT void   __TZ_set_MSPLIM_NS(uint32_t value)
786*6b8177c5SMatthias Ringwald     {
787*6b8177c5SMatthias Ringwald       __asm volatile("MSR      MSPLIM_NS,%0" :: "r" (value));
788*6b8177c5SMatthias Ringwald     }
789*6b8177c5SMatthias Ringwald 
790*6b8177c5SMatthias Ringwald   #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
791*6b8177c5SMatthias Ringwald 
792*6b8177c5SMatthias Ringwald #endif   /* __ICCARM_INTRINSICS_VERSION__ == 2 */
793*6b8177c5SMatthias Ringwald 
794*6b8177c5SMatthias Ringwald #define __BKPT(value)    __asm volatile ("BKPT     %0" : : "i"(value))
795*6b8177c5SMatthias Ringwald 
796*6b8177c5SMatthias Ringwald #if __IAR_M0_FAMILY
__SSAT(int32_t val,uint32_t sat)797*6b8177c5SMatthias Ringwald   __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
798*6b8177c5SMatthias Ringwald   {
799*6b8177c5SMatthias Ringwald     if ((sat >= 1U) && (sat <= 32U))
800*6b8177c5SMatthias Ringwald     {
801*6b8177c5SMatthias Ringwald       const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
802*6b8177c5SMatthias Ringwald       const int32_t min = -1 - max ;
803*6b8177c5SMatthias Ringwald       if (val > max)
804*6b8177c5SMatthias Ringwald       {
805*6b8177c5SMatthias Ringwald         return max;
806*6b8177c5SMatthias Ringwald       }
807*6b8177c5SMatthias Ringwald       else if (val < min)
808*6b8177c5SMatthias Ringwald       {
809*6b8177c5SMatthias Ringwald         return min;
810*6b8177c5SMatthias Ringwald       }
811*6b8177c5SMatthias Ringwald     }
812*6b8177c5SMatthias Ringwald     return val;
813*6b8177c5SMatthias Ringwald   }
814*6b8177c5SMatthias Ringwald 
__USAT(int32_t val,uint32_t sat)815*6b8177c5SMatthias Ringwald   __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
816*6b8177c5SMatthias Ringwald   {
817*6b8177c5SMatthias Ringwald     if (sat <= 31U)
818*6b8177c5SMatthias Ringwald     {
819*6b8177c5SMatthias Ringwald       const uint32_t max = ((1U << sat) - 1U);
820*6b8177c5SMatthias Ringwald       if (val > (int32_t)max)
821*6b8177c5SMatthias Ringwald       {
822*6b8177c5SMatthias Ringwald         return max;
823*6b8177c5SMatthias Ringwald       }
824*6b8177c5SMatthias Ringwald       else if (val < 0)
825*6b8177c5SMatthias Ringwald       {
826*6b8177c5SMatthias Ringwald         return 0U;
827*6b8177c5SMatthias Ringwald       }
828*6b8177c5SMatthias Ringwald     }
829*6b8177c5SMatthias Ringwald     return (uint32_t)val;
830*6b8177c5SMatthias Ringwald   }
831*6b8177c5SMatthias Ringwald #endif
832*6b8177c5SMatthias Ringwald 
833*6b8177c5SMatthias Ringwald #if (__CORTEX_M >= 0x03)   /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
834*6b8177c5SMatthias Ringwald 
__LDRBT(volatile uint8_t * addr)835*6b8177c5SMatthias Ringwald   __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr)
836*6b8177c5SMatthias Ringwald   {
837*6b8177c5SMatthias Ringwald     uint32_t res;
838*6b8177c5SMatthias Ringwald     __ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
839*6b8177c5SMatthias Ringwald     return ((uint8_t)res);
840*6b8177c5SMatthias Ringwald   }
841*6b8177c5SMatthias Ringwald 
__LDRHT(volatile uint16_t * addr)842*6b8177c5SMatthias Ringwald   __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr)
843*6b8177c5SMatthias Ringwald   {
844*6b8177c5SMatthias Ringwald     uint32_t res;
845*6b8177c5SMatthias Ringwald     __ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
846*6b8177c5SMatthias Ringwald     return ((uint16_t)res);
847*6b8177c5SMatthias Ringwald   }
848*6b8177c5SMatthias Ringwald 
__LDRT(volatile uint32_t * addr)849*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __LDRT(volatile uint32_t *addr)
850*6b8177c5SMatthias Ringwald   {
851*6b8177c5SMatthias Ringwald     uint32_t res;
852*6b8177c5SMatthias Ringwald     __ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
853*6b8177c5SMatthias Ringwald     return res;
854*6b8177c5SMatthias Ringwald   }
855*6b8177c5SMatthias Ringwald 
__STRBT(uint8_t value,volatile uint8_t * addr)856*6b8177c5SMatthias Ringwald   __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr)
857*6b8177c5SMatthias Ringwald   {
858*6b8177c5SMatthias Ringwald     __ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
859*6b8177c5SMatthias Ringwald   }
860*6b8177c5SMatthias Ringwald 
__STRHT(uint16_t value,volatile uint16_t * addr)861*6b8177c5SMatthias Ringwald   __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr)
862*6b8177c5SMatthias Ringwald   {
863*6b8177c5SMatthias Ringwald     __ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
864*6b8177c5SMatthias Ringwald   }
865*6b8177c5SMatthias Ringwald 
__STRT(uint32_t value,volatile uint32_t * addr)866*6b8177c5SMatthias Ringwald   __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr)
867*6b8177c5SMatthias Ringwald   {
868*6b8177c5SMatthias Ringwald     __ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory");
869*6b8177c5SMatthias Ringwald   }
870*6b8177c5SMatthias Ringwald 
871*6b8177c5SMatthias Ringwald #endif /* (__CORTEX_M >= 0x03) */
872*6b8177c5SMatthias Ringwald 
873*6b8177c5SMatthias Ringwald #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
874*6b8177c5SMatthias Ringwald      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
875*6b8177c5SMatthias Ringwald 
876*6b8177c5SMatthias Ringwald 
__LDAB(volatile uint8_t * ptr)877*6b8177c5SMatthias Ringwald   __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr)
878*6b8177c5SMatthias Ringwald   {
879*6b8177c5SMatthias Ringwald     uint32_t res;
880*6b8177c5SMatthias Ringwald     __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
881*6b8177c5SMatthias Ringwald     return ((uint8_t)res);
882*6b8177c5SMatthias Ringwald   }
883*6b8177c5SMatthias Ringwald 
__LDAH(volatile uint16_t * ptr)884*6b8177c5SMatthias Ringwald   __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr)
885*6b8177c5SMatthias Ringwald   {
886*6b8177c5SMatthias Ringwald     uint32_t res;
887*6b8177c5SMatthias Ringwald     __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
888*6b8177c5SMatthias Ringwald     return ((uint16_t)res);
889*6b8177c5SMatthias Ringwald   }
890*6b8177c5SMatthias Ringwald 
__LDA(volatile uint32_t * ptr)891*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __LDA(volatile uint32_t *ptr)
892*6b8177c5SMatthias Ringwald   {
893*6b8177c5SMatthias Ringwald     uint32_t res;
894*6b8177c5SMatthias Ringwald     __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
895*6b8177c5SMatthias Ringwald     return res;
896*6b8177c5SMatthias Ringwald   }
897*6b8177c5SMatthias Ringwald 
__STLB(uint8_t value,volatile uint8_t * ptr)898*6b8177c5SMatthias Ringwald   __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr)
899*6b8177c5SMatthias Ringwald   {
900*6b8177c5SMatthias Ringwald     __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
901*6b8177c5SMatthias Ringwald   }
902*6b8177c5SMatthias Ringwald 
__STLH(uint16_t value,volatile uint16_t * ptr)903*6b8177c5SMatthias Ringwald   __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr)
904*6b8177c5SMatthias Ringwald   {
905*6b8177c5SMatthias Ringwald     __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
906*6b8177c5SMatthias Ringwald   }
907*6b8177c5SMatthias Ringwald 
__STL(uint32_t value,volatile uint32_t * ptr)908*6b8177c5SMatthias Ringwald   __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr)
909*6b8177c5SMatthias Ringwald   {
910*6b8177c5SMatthias Ringwald     __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
911*6b8177c5SMatthias Ringwald   }
912*6b8177c5SMatthias Ringwald 
__LDAEXB(volatile uint8_t * ptr)913*6b8177c5SMatthias Ringwald   __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr)
914*6b8177c5SMatthias Ringwald   {
915*6b8177c5SMatthias Ringwald     uint32_t res;
916*6b8177c5SMatthias Ringwald     __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
917*6b8177c5SMatthias Ringwald     return ((uint8_t)res);
918*6b8177c5SMatthias Ringwald   }
919*6b8177c5SMatthias Ringwald 
__LDAEXH(volatile uint16_t * ptr)920*6b8177c5SMatthias Ringwald   __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr)
921*6b8177c5SMatthias Ringwald   {
922*6b8177c5SMatthias Ringwald     uint32_t res;
923*6b8177c5SMatthias Ringwald     __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
924*6b8177c5SMatthias Ringwald     return ((uint16_t)res);
925*6b8177c5SMatthias Ringwald   }
926*6b8177c5SMatthias Ringwald 
__LDAEX(volatile uint32_t * ptr)927*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr)
928*6b8177c5SMatthias Ringwald   {
929*6b8177c5SMatthias Ringwald     uint32_t res;
930*6b8177c5SMatthias Ringwald     __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
931*6b8177c5SMatthias Ringwald     return res;
932*6b8177c5SMatthias Ringwald   }
933*6b8177c5SMatthias Ringwald 
__STLEXB(uint8_t value,volatile uint8_t * ptr)934*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
935*6b8177c5SMatthias Ringwald   {
936*6b8177c5SMatthias Ringwald     uint32_t res;
937*6b8177c5SMatthias Ringwald     __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
938*6b8177c5SMatthias Ringwald     return res;
939*6b8177c5SMatthias Ringwald   }
940*6b8177c5SMatthias Ringwald 
__STLEXH(uint16_t value,volatile uint16_t * ptr)941*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
942*6b8177c5SMatthias Ringwald   {
943*6b8177c5SMatthias Ringwald     uint32_t res;
944*6b8177c5SMatthias Ringwald     __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
945*6b8177c5SMatthias Ringwald     return res;
946*6b8177c5SMatthias Ringwald   }
947*6b8177c5SMatthias Ringwald 
__STLEX(uint32_t value,volatile uint32_t * ptr)948*6b8177c5SMatthias Ringwald   __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
949*6b8177c5SMatthias Ringwald   {
950*6b8177c5SMatthias Ringwald     uint32_t res;
951*6b8177c5SMatthias Ringwald     __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
952*6b8177c5SMatthias Ringwald     return res;
953*6b8177c5SMatthias Ringwald   }
954*6b8177c5SMatthias Ringwald 
955*6b8177c5SMatthias Ringwald #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
956*6b8177c5SMatthias Ringwald 
957*6b8177c5SMatthias Ringwald #undef __IAR_FT
958*6b8177c5SMatthias Ringwald #undef __IAR_M0_FAMILY
959*6b8177c5SMatthias Ringwald #undef __ICCARM_V8
960*6b8177c5SMatthias Ringwald 
961*6b8177c5SMatthias Ringwald #pragma diag_default=Pe940
962*6b8177c5SMatthias Ringwald #pragma diag_default=Pe177
963*6b8177c5SMatthias Ringwald 
964*6b8177c5SMatthias Ringwald #endif /* __CMSIS_ICCARM_H__ */
965