1 /**************************************************************************//**
\r
2 * @file cmsis_iccarm.h
\r
3 * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file
\r
5 * @date 19. June 2018
\r
6 ******************************************************************************/
\r
8 //------------------------------------------------------------------------------
\r
10 // Copyright (c) 2017-2018 IAR Systems
\r
12 // Licensed under the Apache License, Version 2.0 (the "License")
\r
13 // you may not use this file except in compliance with the License.
\r
14 // You may obtain a copy of the License at
\r
15 // http://www.apache.org/licenses/LICENSE-2.0
\r
17 // Unless required by applicable law or agreed to in writing, software
\r
18 // distributed under the License is distributed on an "AS IS" BASIS,
\r
19 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
20 // See the License for the specific language governing permissions and
\r
21 // limitations under the License.
\r
23 //------------------------------------------------------------------------------
\r
26 #ifndef __CMSIS_ICCARM_H__
\r
27 #define __CMSIS_ICCARM_H__
\r
30 #error This file should only be compiled by ICCARM
\r
33 #pragma system_include
\r
35 #define __IAR_FT _Pragma("inline=forced") __intrinsic
\r
37 #if (__VER__ >= 8000000)
\r
38 #define __ICCARM_V8 1
\r
40 #define __ICCARM_V8 0
\r
45 #define __ALIGNED(x) __attribute__((aligned(x)))
\r
46 #elif (__VER__ >= 7080000)
\r
47 /* Needs IAR language extensions */
\r
48 #define __ALIGNED(x) __attribute__((aligned(x)))
\r
50 #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored.
\r
51 #define __ALIGNED(x)
\r
56 /* Define compiler macros for CPU architecture, used in CMSIS 5.
\r
58 #if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__
\r
59 /* Macros already defined */
\r
61 #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__)
\r
62 #define __ARM_ARCH_8M_MAIN__ 1
\r
63 #elif defined(__ARM8M_BASELINE__)
\r
64 #define __ARM_ARCH_8M_BASE__ 1
\r
65 #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M'
\r
67 #define __ARM_ARCH_6M__ 1
\r
68 #elif __ARM_ARCH == 7
\r
69 #if __ARM_FEATURE_DSP
\r
70 #define __ARM_ARCH_7EM__ 1
\r
72 #define __ARM_ARCH_7M__ 1
\r
74 #endif /* __ARM_ARCH */
\r
75 #endif /* __ARM_ARCH_PROFILE == 'M' */
\r
78 /* Alternativ core deduction for older ICCARM's */
\r
79 #if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \
\r
80 !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__)
\r
81 #if defined(__ARM6M__) && (__CORE__ == __ARM6M__)
\r
82 #define __ARM_ARCH_6M__ 1
\r
83 #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__)
\r
84 #define __ARM_ARCH_7M__ 1
\r
85 #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__)
\r
86 #define __ARM_ARCH_7EM__ 1
\r
87 #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__)
\r
88 #define __ARM_ARCH_8M_BASE__ 1
\r
89 #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__)
\r
90 #define __ARM_ARCH_8M_MAIN__ 1
\r
91 #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__)
\r
92 #define __ARM_ARCH_8M_MAIN__ 1
\r
94 #error "Unknown target."
\r
100 #if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1
\r
101 #define __IAR_M0_FAMILY 1
\r
102 #elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1
\r
103 #define __IAR_M0_FAMILY 1
\r
105 #define __IAR_M0_FAMILY 0
\r
110 #define __ASM __asm
\r
114 #define __INLINE inline
\r
117 #ifndef __NO_RETURN
\r
119 #define __NO_RETURN __attribute__((__noreturn__))
\r
121 #define __NO_RETURN _Pragma("object_attribute=__noreturn")
\r
127 #define __PACKED __attribute__((packed, aligned(1)))
\r
129 /* Needs IAR language extensions */
\r
130 #define __PACKED __packed
\r
134 #ifndef __PACKED_STRUCT
\r
136 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
\r
138 /* Needs IAR language extensions */
\r
139 #define __PACKED_STRUCT __packed struct
\r
143 #ifndef __PACKED_UNION
\r
145 #define __PACKED_UNION union __attribute__((packed, aligned(1)))
\r
147 /* Needs IAR language extensions */
\r
148 #define __PACKED_UNION __packed union
\r
153 #define __RESTRICT __restrict
\r
156 #ifndef __STATIC_INLINE
\r
157 #define __STATIC_INLINE static inline
\r
160 #ifndef __FORCEINLINE
\r
161 #define __FORCEINLINE _Pragma("inline=forced")
\r
164 #ifndef __STATIC_FORCEINLINE
\r
165 #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE
\r
168 #ifndef __UNALIGNED_UINT16_READ
\r
169 #pragma language=save
\r
170 #pragma language=extended
\r
171 __IAR_FT uint16_t __iar_uint16_read(void const *ptr)
\r
173 return *(__packed uint16_t*)(ptr);
\r
175 #pragma language=restore
\r
176 #define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR)
\r
180 #ifndef __UNALIGNED_UINT16_WRITE
\r
181 #pragma language=save
\r
182 #pragma language=extended
\r
183 __IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
\r
185 *(__packed uint16_t*)(ptr) = val;;
\r
187 #pragma language=restore
\r
188 #define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
\r
191 #ifndef __UNALIGNED_UINT32_READ
\r
192 #pragma language=save
\r
193 #pragma language=extended
\r
194 __IAR_FT uint32_t __iar_uint32_read(void const *ptr)
\r
196 return *(__packed uint32_t*)(ptr);
\r
198 #pragma language=restore
\r
199 #define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR)
\r
202 #ifndef __UNALIGNED_UINT32_WRITE
\r
203 #pragma language=save
\r
204 #pragma language=extended
\r
205 __IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
\r
207 *(__packed uint32_t*)(ptr) = val;;
\r
209 #pragma language=restore
\r
210 #define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
\r
213 #ifndef __UNALIGNED_UINT32 /* deprecated */
\r
214 #pragma language=save
\r
215 #pragma language=extended
\r
216 __packed struct __iar_u32 { uint32_t v; };
\r
217 #pragma language=restore
\r
218 #define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
\r
223 #define __USED __attribute__((used))
\r
225 #define __USED _Pragma("__root")
\r
231 #define __WEAK __attribute__((weak))
\r
233 #define __WEAK _Pragma("__weak")
\r
238 #ifndef __ICCARM_INTRINSICS_VERSION__
\r
239 #define __ICCARM_INTRINSICS_VERSION__ 0
\r
242 #if __ICCARM_INTRINSICS_VERSION__ == 2
\r
247 #if defined(__REVSH)
\r
250 #if defined(__RBIT)
\r
253 #if defined(__SSAT)
\r
256 #if defined(__USAT)
\r
260 #include "iccarm_builtin.h"
\r
262 #define __disable_fault_irq __iar_builtin_disable_fiq
\r
263 #define __disable_irq __iar_builtin_disable_interrupt
\r
264 #define __enable_fault_irq __iar_builtin_enable_fiq
\r
265 #define __enable_irq __iar_builtin_enable_interrupt
\r
266 #define __arm_rsr __iar_builtin_rsr
\r
267 #define __arm_wsr __iar_builtin_wsr
\r
270 #define __get_APSR() (__arm_rsr("APSR"))
\r
271 #define __get_BASEPRI() (__arm_rsr("BASEPRI"))
\r
272 #define __get_CONTROL() (__arm_rsr("CONTROL"))
\r
273 #define __get_FAULTMASK() (__arm_rsr("FAULTMASK"))
\r
275 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
\r
276 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
\r
277 #define __get_FPSCR() (__arm_rsr("FPSCR"))
\r
278 #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE)))
\r
280 #define __get_FPSCR() ( 0 )
\r
281 #define __set_FPSCR(VALUE) ((void)VALUE)
\r
284 #define __get_IPSR() (__arm_rsr("IPSR"))
\r
285 #define __get_MSP() (__arm_rsr("MSP"))
\r
286 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
287 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
\r
288 // without main extensions, the non-secure MSPLIM is RAZ/WI
\r
289 #define __get_MSPLIM() (0U)
\r
291 #define __get_MSPLIM() (__arm_rsr("MSPLIM"))
\r
293 #define __get_PRIMASK() (__arm_rsr("PRIMASK"))
\r
294 #define __get_PSP() (__arm_rsr("PSP"))
\r
296 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
297 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
\r
298 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
299 #define __get_PSPLIM() (0U)
\r
301 #define __get_PSPLIM() (__arm_rsr("PSPLIM"))
\r
304 #define __get_xPSR() (__arm_rsr("xPSR"))
\r
306 #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE)))
\r
307 #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE)))
\r
308 #define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE)))
\r
309 #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE)))
\r
310 #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE)))
\r
312 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
313 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
\r
314 // without main extensions, the non-secure MSPLIM is RAZ/WI
\r
315 #define __set_MSPLIM(VALUE) ((void)(VALUE))
\r
317 #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE)))
\r
319 #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE)))
\r
320 #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE)))
\r
321 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
322 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
\r
323 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
324 #define __set_PSPLIM(VALUE) ((void)(VALUE))
\r
326 #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE)))
\r
329 #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS"))
\r
330 #define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE)))
\r
331 #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS"))
\r
332 #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE)))
\r
333 #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS"))
\r
334 #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE)))
\r
335 #define __TZ_get_SP_NS() (__arm_rsr("SP_NS"))
\r
336 #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE)))
\r
337 #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS"))
\r
338 #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE)))
\r
339 #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS"))
\r
340 #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE)))
\r
341 #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS"))
\r
342 #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE)))
\r
344 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
345 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
\r
346 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
347 #define __TZ_get_PSPLIM_NS() (0U)
\r
348 #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE))
\r
350 #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS"))
\r
351 #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE)))
\r
354 #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS"))
\r
355 #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE)))
\r
357 #define __NOP __iar_builtin_no_operation
\r
359 #define __CLZ __iar_builtin_CLZ
\r
360 #define __CLREX __iar_builtin_CLREX
\r
362 #define __DMB __iar_builtin_DMB
\r
363 #define __DSB __iar_builtin_DSB
\r
364 #define __ISB __iar_builtin_ISB
\r
366 #define __LDREXB __iar_builtin_LDREXB
\r
367 #define __LDREXH __iar_builtin_LDREXH
\r
368 #define __LDREXW __iar_builtin_LDREX
\r
370 #define __RBIT __iar_builtin_RBIT
\r
371 #define __REV __iar_builtin_REV
\r
372 #define __REV16 __iar_builtin_REV16
\r
374 __IAR_FT int16_t __REVSH(int16_t val)
\r
376 return (int16_t) __iar_builtin_REVSH(val);
\r
379 #define __ROR __iar_builtin_ROR
\r
380 #define __RRX __iar_builtin_RRX
\r
382 #define __SEV __iar_builtin_SEV
\r
384 #if !__IAR_M0_FAMILY
\r
385 #define __SSAT __iar_builtin_SSAT
\r
388 #define __STREXB __iar_builtin_STREXB
\r
389 #define __STREXH __iar_builtin_STREXH
\r
390 #define __STREXW __iar_builtin_STREX
\r
392 #if !__IAR_M0_FAMILY
\r
393 #define __USAT __iar_builtin_USAT
\r
396 #define __WFE __iar_builtin_WFE
\r
397 #define __WFI __iar_builtin_WFI
\r
400 #define __SADD8 __iar_builtin_SADD8
\r
401 #define __QADD8 __iar_builtin_QADD8
\r
402 #define __SHADD8 __iar_builtin_SHADD8
\r
403 #define __UADD8 __iar_builtin_UADD8
\r
404 #define __UQADD8 __iar_builtin_UQADD8
\r
405 #define __UHADD8 __iar_builtin_UHADD8
\r
406 #define __SSUB8 __iar_builtin_SSUB8
\r
407 #define __QSUB8 __iar_builtin_QSUB8
\r
408 #define __SHSUB8 __iar_builtin_SHSUB8
\r
409 #define __USUB8 __iar_builtin_USUB8
\r
410 #define __UQSUB8 __iar_builtin_UQSUB8
\r
411 #define __UHSUB8 __iar_builtin_UHSUB8
\r
412 #define __SADD16 __iar_builtin_SADD16
\r
413 #define __QADD16 __iar_builtin_QADD16
\r
414 #define __SHADD16 __iar_builtin_SHADD16
\r
415 #define __UADD16 __iar_builtin_UADD16
\r
416 #define __UQADD16 __iar_builtin_UQADD16
\r
417 #define __UHADD16 __iar_builtin_UHADD16
\r
418 #define __SSUB16 __iar_builtin_SSUB16
\r
419 #define __QSUB16 __iar_builtin_QSUB16
\r
420 #define __SHSUB16 __iar_builtin_SHSUB16
\r
421 #define __USUB16 __iar_builtin_USUB16
\r
422 #define __UQSUB16 __iar_builtin_UQSUB16
\r
423 #define __UHSUB16 __iar_builtin_UHSUB16
\r
424 #define __SASX __iar_builtin_SASX
\r
425 #define __QASX __iar_builtin_QASX
\r
426 #define __SHASX __iar_builtin_SHASX
\r
427 #define __UASX __iar_builtin_UASX
\r
428 #define __UQASX __iar_builtin_UQASX
\r
429 #define __UHASX __iar_builtin_UHASX
\r
430 #define __SSAX __iar_builtin_SSAX
\r
431 #define __QSAX __iar_builtin_QSAX
\r
432 #define __SHSAX __iar_builtin_SHSAX
\r
433 #define __USAX __iar_builtin_USAX
\r
434 #define __UQSAX __iar_builtin_UQSAX
\r
435 #define __UHSAX __iar_builtin_UHSAX
\r
436 #define __USAD8 __iar_builtin_USAD8
\r
437 #define __USADA8 __iar_builtin_USADA8
\r
438 #define __SSAT16 __iar_builtin_SSAT16
\r
439 #define __USAT16 __iar_builtin_USAT16
\r
440 #define __UXTB16 __iar_builtin_UXTB16
\r
441 #define __UXTAB16 __iar_builtin_UXTAB16
\r
442 #define __SXTB16 __iar_builtin_SXTB16
\r
443 #define __SXTAB16 __iar_builtin_SXTAB16
\r
444 #define __SMUAD __iar_builtin_SMUAD
\r
445 #define __SMUADX __iar_builtin_SMUADX
\r
446 #define __SMMLA __iar_builtin_SMMLA
\r
447 #define __SMLAD __iar_builtin_SMLAD
\r
448 #define __SMLADX __iar_builtin_SMLADX
\r
449 #define __SMLALD __iar_builtin_SMLALD
\r
450 #define __SMLALDX __iar_builtin_SMLALDX
\r
451 #define __SMUSD __iar_builtin_SMUSD
\r
452 #define __SMUSDX __iar_builtin_SMUSDX
\r
453 #define __SMLSD __iar_builtin_SMLSD
\r
454 #define __SMLSDX __iar_builtin_SMLSDX
\r
455 #define __SMLSLD __iar_builtin_SMLSLD
\r
456 #define __SMLSLDX __iar_builtin_SMLSLDX
\r
457 #define __SEL __iar_builtin_SEL
\r
458 #define __QADD __iar_builtin_QADD
\r
459 #define __QSUB __iar_builtin_QSUB
\r
460 #define __PKHBT __iar_builtin_PKHBT
\r
461 #define __PKHTB __iar_builtin_PKHTB
\r
464 #else /* __ICCARM_INTRINSICS_VERSION__ == 2 */
\r
466 #if __IAR_M0_FAMILY
\r
467 /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
\r
468 #define __CLZ __cmsis_iar_clz_not_active
\r
469 #define __SSAT __cmsis_iar_ssat_not_active
\r
470 #define __USAT __cmsis_iar_usat_not_active
\r
471 #define __RBIT __cmsis_iar_rbit_not_active
\r
472 #define __get_APSR __cmsis_iar_get_APSR_not_active
\r
476 #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
\r
477 (defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
\r
478 #define __get_FPSCR __cmsis_iar_get_FPSR_not_active
\r
479 #define __set_FPSCR __cmsis_iar_set_FPSR_not_active
\r
482 #ifdef __INTRINSICS_INCLUDED
\r
483 #error intrinsics.h is already included previously!
\r
486 #include <intrinsics.h>
\r
488 #if __IAR_M0_FAMILY
\r
489 /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
\r
496 __STATIC_INLINE uint8_t __CLZ(uint32_t data)
\r
498 if (data == 0U) { return 32U; }
\r
500 uint32_t count = 0U;
\r
501 uint32_t mask = 0x80000000U;
\r
503 while ((data & mask) == 0U)
\r
511 __STATIC_INLINE uint32_t __RBIT(uint32_t v)
\r
515 for (v >>= 1U; v; v >>= 1U)
\r
524 __STATIC_INLINE uint32_t __get_APSR(void)
\r
527 __asm("MRS %0,APSR" : "=r" (res));
\r
533 #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
\r
534 (defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
\r
537 #define __get_FPSCR() (0)
\r
538 #define __set_FPSCR(VALUE) ((void)VALUE)
\r
541 #pragma diag_suppress=Pe940
\r
542 #pragma diag_suppress=Pe177
\r
544 #define __enable_irq __enable_interrupt
\r
545 #define __disable_irq __disable_interrupt
\r
546 #define __NOP __no_operation
\r
548 #define __get_xPSR __get_PSR
\r
550 #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0)
\r
552 __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr)
\r
554 return __LDREX((unsigned long *)ptr);
\r
557 __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr)
\r
559 return __STREX(value, (unsigned long *)ptr);
\r
564 /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
\r
565 #if (__CORTEX_M >= 0x03)
\r
567 __IAR_FT uint32_t __RRX(uint32_t value)
\r
570 __ASM("RRX %0, %1" : "=r"(result) : "r" (value) : "cc");
\r
574 __IAR_FT void __set_BASEPRI_MAX(uint32_t value)
\r
576 __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value));
\r
580 #define __enable_fault_irq __enable_fiq
\r
581 #define __disable_fault_irq __disable_fiq
\r
584 #endif /* (__CORTEX_M >= 0x03) */
\r
586 __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2)
\r
588 return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2));
\r
591 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
\r
592 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
\r
594 __IAR_FT uint32_t __get_MSPLIM(void)
\r
597 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
598 (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
\r
599 // without main extensions, the non-secure MSPLIM is RAZ/WI
\r
602 __asm volatile("MRS %0,MSPLIM" : "=r" (res));
\r
607 __IAR_FT void __set_MSPLIM(uint32_t value)
\r
609 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
610 (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
\r
611 // without main extensions, the non-secure MSPLIM is RAZ/WI
\r
614 __asm volatile("MSR MSPLIM,%0" :: "r" (value));
\r
618 __IAR_FT uint32_t __get_PSPLIM(void)
\r
621 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
622 (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
\r
623 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
626 __asm volatile("MRS %0,PSPLIM" : "=r" (res));
\r
631 __IAR_FT void __set_PSPLIM(uint32_t value)
\r
633 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
634 (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
\r
635 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
638 __asm volatile("MSR PSPLIM,%0" :: "r" (value));
\r
642 __IAR_FT uint32_t __TZ_get_CONTROL_NS(void)
\r
645 __asm volatile("MRS %0,CONTROL_NS" : "=r" (res));
\r
649 __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value)
\r
651 __asm volatile("MSR CONTROL_NS,%0" :: "r" (value));
\r
654 __IAR_FT uint32_t __TZ_get_PSP_NS(void)
\r
657 __asm volatile("MRS %0,PSP_NS" : "=r" (res));
\r
661 __IAR_FT void __TZ_set_PSP_NS(uint32_t value)
\r
663 __asm volatile("MSR PSP_NS,%0" :: "r" (value));
\r
666 __IAR_FT uint32_t __TZ_get_MSP_NS(void)
\r
669 __asm volatile("MRS %0,MSP_NS" : "=r" (res));
\r
673 __IAR_FT void __TZ_set_MSP_NS(uint32_t value)
\r
675 __asm volatile("MSR MSP_NS,%0" :: "r" (value));
\r
678 __IAR_FT uint32_t __TZ_get_SP_NS(void)
\r
681 __asm volatile("MRS %0,SP_NS" : "=r" (res));
\r
684 __IAR_FT void __TZ_set_SP_NS(uint32_t value)
\r
686 __asm volatile("MSR SP_NS,%0" :: "r" (value));
\r
689 __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void)
\r
692 __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res));
\r
696 __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value)
\r
698 __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value));
\r
701 __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void)
\r
704 __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res));
\r
708 __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value)
\r
710 __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value));
\r
713 __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void)
\r
716 __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res));
\r
720 __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value)
\r
722 __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value));
\r
725 __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void)
\r
728 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
729 (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
\r
730 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
733 __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res));
\r
738 __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value)
\r
740 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
\r
741 (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
\r
742 // without main extensions, the non-secure PSPLIM is RAZ/WI
\r
745 __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value));
\r
749 __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void)
\r
752 __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res));
\r
756 __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value)
\r
758 __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value));
\r
761 #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
\r
763 #endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */
\r
765 #define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value))
\r
767 #if __IAR_M0_FAMILY
\r
768 __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
\r
770 if ((sat >= 1U) && (sat <= 32U))
\r
772 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
\r
773 const int32_t min = -1 - max ;
\r
778 else if (val < min)
\r
786 __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
\r
790 const uint32_t max = ((1U << sat) - 1U);
\r
791 if (val > (int32_t)max)
\r
800 return (uint32_t)val;
\r
804 #if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
\r
806 __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr)
\r
809 __ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
\r
810 return ((uint8_t)res);
\r
813 __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr)
\r
816 __ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
\r
817 return ((uint16_t)res);
\r
820 __IAR_FT uint32_t __LDRT(volatile uint32_t *addr)
\r
823 __ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
\r
827 __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr)
\r
829 __ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
\r
832 __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr)
\r
834 __ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
\r
837 __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr)
\r
839 __ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory");
\r
842 #endif /* (__CORTEX_M >= 0x03) */
\r
844 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
\r
845 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
\r
848 __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr)
\r
851 __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
\r
852 return ((uint8_t)res);
\r
855 __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr)
\r
858 __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
\r
859 return ((uint16_t)res);
\r
862 __IAR_FT uint32_t __LDA(volatile uint32_t *ptr)
\r
865 __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
\r
869 __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr)
\r
871 __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
\r
874 __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr)
\r
876 __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
\r
879 __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr)
\r
881 __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
\r
884 __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr)
\r
887 __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
\r
888 return ((uint8_t)res);
\r
891 __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr)
\r
894 __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
\r
895 return ((uint16_t)res);
\r
898 __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr)
\r
901 __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
\r
905 __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
\r
908 __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
\r
912 __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
\r
915 __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
\r
919 __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
\r
922 __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
\r
926 #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
\r
929 #undef __IAR_M0_FAMILY
\r
932 #pragma diag_default=Pe940
\r
933 #pragma diag_default=Pe177
\r
935 #endif /* __CMSIS_ICCARM_H__ */
\r