]> begriffs open source - cmsis/blob - CMSIS/Core/Include/m-profile/cmsis_armclang_m.h
Core: Unify __NO_INIT macro across toolchains
[cmsis] / CMSIS / Core / Include / m-profile / cmsis_armclang_m.h
1 /**************************************************************************//**
2  * @file     cmsis_armclang_m.h
3  * @brief    CMSIS compiler armclang (Arm Compiler 6) header file
4  * @version  V6.0.0
5  * @date     23. November 2023
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2009-2023 Arm Limited. All rights reserved.
9  *
10  * SPDX-License-Identifier: Apache-2.0
11  *
12  * Licensed under the Apache License, Version 2.0 (the License); you may
13  * not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24
25 #ifndef __CMSIS_ARMCLANG_M_H
26 #define __CMSIS_ARMCLANG_M_H
27
28 #pragma clang system_header   /* treat file as system include file */
29
30 #if (__ARM_ACLE >= 200)
31   #include <arm_acle.h>
32 #else
33   #error Compiler must support ACLE V2.0
34 #endif /* (__ARM_ACLE >= 200) */
35
36 /* CMSIS compiler specific defines */
37 #ifndef   __ASM
38   #define __ASM                                  __asm
39 #endif
40 #ifndef   __INLINE
41   #define __INLINE                               __inline
42 #endif
43 #ifndef   __STATIC_INLINE
44   #define __STATIC_INLINE                        static __inline
45 #endif
46 #ifndef   __STATIC_FORCEINLINE
47   #define __STATIC_FORCEINLINE                   __attribute__((always_inline)) static __inline
48 #endif
49 #ifndef   __NO_RETURN
50   #define __NO_RETURN                            __attribute__((__noreturn__))
51 #endif
52 #ifndef   __USED
53   #define __USED                                 __attribute__((used))
54 #endif
55 #ifndef   __WEAK
56   #define __WEAK                                 __attribute__((weak))
57 #endif
58 #ifndef   __PACKED
59   #define __PACKED                               __attribute__((packed, aligned(1)))
60 #endif
61 #ifndef   __PACKED_STRUCT
62   #define __PACKED_STRUCT                        struct __attribute__((packed, aligned(1)))
63 #endif
64 #ifndef   __PACKED_UNION
65   #define __PACKED_UNION                         union __attribute__((packed, aligned(1)))
66 #endif
67 #ifndef   __UNALIGNED_UINT16_WRITE
68   #pragma clang diagnostic push
69   #pragma clang diagnostic ignored "-Wpacked"
70   __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
71   #pragma clang diagnostic pop
72   #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
73 #endif
74 #ifndef   __UNALIGNED_UINT16_READ
75   #pragma clang diagnostic push
76   #pragma clang diagnostic ignored "-Wpacked"
77   __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
78   #pragma clang diagnostic pop
79   #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
80 #endif
81 #ifndef   __UNALIGNED_UINT32_WRITE
82   #pragma clang diagnostic push
83   #pragma clang diagnostic ignored "-Wpacked"
84   __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
85   #pragma clang diagnostic pop
86   #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
87 #endif
88 #ifndef   __UNALIGNED_UINT32_READ
89   #pragma clang diagnostic push
90   #pragma clang diagnostic ignored "-Wpacked"
91   __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
92   #pragma clang diagnostic pop
93   #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
94 #endif
95 #ifndef   __ALIGNED
96   #define __ALIGNED(x)                           __attribute__((aligned(x)))
97 #endif
98 #ifndef   __RESTRICT
99   #define __RESTRICT                             __restrict
100 #endif
101 #ifndef   __COMPILER_BARRIER
102   #define __COMPILER_BARRIER()                   __ASM volatile("":::"memory")
103 #endif
104 #ifndef __NO_INIT
105   #define __NO_INIT                              __attribute__ ((section (".noinit")))
106 #endif
107 #ifndef __ALIAS
108   #define __ALIAS(x)                             __attribute__ ((alias(x)))
109 #endif
110
111 /* #########################  Startup and Lowlevel Init  ######################## */
112 #ifndef __PROGRAM_START
113 #define __PROGRAM_START           __main
114 #endif
115
116 #ifndef __INITIAL_SP
117 #define __INITIAL_SP              Image$$ARM_LIB_STACK$$ZI$$Limit
118 #endif
119
120 #ifndef __STACK_LIMIT
121 #define __STACK_LIMIT             Image$$ARM_LIB_STACK$$ZI$$Base
122 #endif
123
124 #ifndef __VECTOR_TABLE
125 #define __VECTOR_TABLE            __Vectors
126 #endif
127
128 #ifndef __VECTOR_TABLE_ATTRIBUTE
129 #define __VECTOR_TABLE_ATTRIBUTE  __attribute__((used, section("RESET")))
130 #endif
131
132 #if (__ARM_FEATURE_CMSE == 3)
133 #ifndef __STACK_SEAL
134 #define __STACK_SEAL              Image$$STACKSEAL$$ZI$$Base
135 #endif
136
137 #ifndef __TZ_STACK_SEAL_SIZE
138 #define __TZ_STACK_SEAL_SIZE      8U
139 #endif
140
141 #ifndef __TZ_STACK_SEAL_VALUE
142 #define __TZ_STACK_SEAL_VALUE     0xFEF5EDA5FEF5EDA5ULL
143 #endif
144
145
146 __STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
147   *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE;
148 }
149 #endif
150
151
152 /* ##########################  Core Instruction Access  ######################### */
153 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
154   Access to dedicated instructions
155   @{
156 */
157
158 /* Define macros for porting to both thumb1 and thumb2.
159  * For thumb1, use low register (r0-r7), specified by constraint "l"
160  * Otherwise, use general registers, specified by constraint "r" */
161 #if defined (__thumb__) && !defined (__thumb2__)
162 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
163 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
164 #define __CMSIS_GCC_USE_REG(r) "l" (r)
165 #else
166 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
167 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
168 #define __CMSIS_GCC_USE_REG(r) "r" (r)
169 #endif
170
171 /**
172   \brief   No Operation
173   \details No Operation does nothing. This instruction can be used for code alignment purposes.
174  */
175 #define __NOP()         __nop()
176
177
178 /**
179   \brief   Wait For Interrupt
180   \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
181  */
182 #define __WFI()         __wfi()
183
184
185 /**
186   \brief   Wait For Event
187   \details Wait For Event is a hint instruction that permits the processor to enter
188            a low-power state until one of a number of events occurs.
189  */
190 #define __WFE()         __wfe()
191
192
193 /**
194   \brief   Send Event
195   \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
196  */
197 #define __SEV()         __sev()
198
199
200 /**
201   \brief   Instruction Synchronization Barrier
202   \details Instruction Synchronization Barrier flushes the pipeline in the processor,
203            so that all instructions following the ISB are fetched from cache or memory,
204            after the instruction has been completed.
205  */
206 #define __ISB()         __isb(0xF)
207
208
209 /**
210   \brief   Data Synchronization Barrier
211   \details Acts as a special kind of Data Memory Barrier.
212            It completes when all explicit memory accesses before this instruction complete.
213  */
214 #define __DSB()         __dsb(0xF)
215
216
217 /**
218   \brief   Data Memory Barrier
219   \details Ensures the apparent order of the explicit memory operations before
220            and after the instruction, without ensuring their completion.
221  */
222 #define __DMB()         __dmb(0xF)
223
224
225 /**
226   \brief   Reverse byte order (32 bit)
227   \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
228   \param [in]    value  Value to reverse
229   \return               Reversed value
230  */
231 #define __REV(value)    __rev(value)
232
233
234 /**
235   \brief   Reverse byte order (16 bit)
236   \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
237   \param [in]    value  Value to reverse
238   \return               Reversed value
239  */
240 #define __REV16(value)  __rev16(value)
241
242
243 /**
244   \brief   Reverse byte order (16 bit)
245   \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
246   \param [in]    value  Value to reverse
247   \return               Reversed value
248  */
249 #define __REVSH(value)  __revsh(value)
250
251
252 /**
253   \brief   Rotate Right in unsigned value (32 bit)
254   \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
255   \param [in]    op1  Value to rotate
256   \param [in]    op2  Number of Bits to rotate
257   \return               Rotated value
258  */
259 #define __ROR(op1, op2) __ror(op1, op2)
260
261
262 /**
263   \brief   Breakpoint
264   \details Causes the processor to enter Debug state.
265            Debug tools can use this to investigate system state when the instruction at a particular address is reached.
266   \param [in]    value  is ignored by the processor.
267                  If required, a debugger can use it to store additional information about the breakpoint.
268  */
269 #define __BKPT(value)   __ASM volatile ("bkpt "#value)
270
271
272 /**
273   \brief   Reverse bit order of value
274   \details Reverses the bit order of the given value.
275   \param [in]    value  Value to reverse
276   \return               Reversed value
277  */
278 #define __RBIT(value)   __rbit(value)
279
280
281 /**
282   \brief   Count leading zeros
283   \details Counts the number of leading zeros of a data value.
284   \param [in]  value  Value to count the leading zeros
285   \return             number of leading zeros in value
286  */
287 #define __CLZ(value)    __clz(value)
288
289
290 #if ((__ARM_FEATURE_SAT    >= 1) && \
291      (__ARM_ARCH_ISA_THUMB >= 2)    )
292 /* __ARM_FEATURE_SAT is wrong for Armv8-M Baseline devices */
293 /**
294   \brief   Signed Saturate
295   \details Saturates a signed value.
296   \param [in]  value  Value to be saturated
297   \param [in]    sat  Bit position to saturate to (1..32)
298   \return             Saturated value
299  */
300 #define __SSAT(value, sat) __ssat(value, sat)
301
302
303 /**
304   \brief   Unsigned Saturate
305   \details Saturates an unsigned value.
306   \param [in]  value  Value to be saturated
307   \param [in]    sat  Bit position to saturate to (0..31)
308   \return             Saturated value
309  */
310 #define __USAT(value, sat) __usat(value, sat)
311
312 #else /* (__ARM_FEATURE_SAT >= 1) */
313 /**
314   \brief   Signed Saturate
315   \details Saturates a signed value.
316   \param [in]  value  Value to be saturated
317   \param [in]    sat  Bit position to saturate to (1..32)
318   \return             Saturated value
319  */
320 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
321 {
322   if ((sat >= 1U) && (sat <= 32U))
323   {
324     const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
325     const int32_t min = -1 - max ;
326     if (val > max)
327     {
328       return (max);
329     }
330     else if (val < min)
331     {
332       return (min);
333     }
334   }
335   return (val);
336 }
337
338
339 /**
340   \brief   Unsigned Saturate
341   \details Saturates an unsigned value.
342   \param [in]  value  Value to be saturated
343   \param [in]    sat  Bit position to saturate to (0..31)
344   \return             Saturated value
345  */
346 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
347 {
348   if (sat <= 31U)
349   {
350     const uint32_t max = ((1U << sat) - 1U);
351     if (val > (int32_t)max)
352     {
353       return (max);
354     }
355     else if (val < 0)
356     {
357       return (0U);
358     }
359   }
360   return ((uint32_t)val);
361 }
362 #endif /* (__ARM_FEATURE_SAT >= 1) */
363
364
365 #if (__ARM_FEATURE_LDREX >= 1)
366 /**
367   \brief   Remove the exclusive lock
368   \details Removes the exclusive lock which is created by LDREX.
369  */
370 #define __CLREX             __builtin_arm_clrex
371
372
373 /**
374   \brief   LDR Exclusive (8 bit)
375   \details Executes a exclusive LDR instruction for 8 bit value.
376   \param [in]    ptr  Pointer to data
377   \return             value of type uint8_t at (*ptr)
378  */
379 #define __LDREXB        (uint8_t)__builtin_arm_ldrex
380
381
382 /**
383   \brief   STR Exclusive (8 bit)
384   \details Executes a exclusive STR instruction for 8 bit values.
385   \param [in]  value  Value to store
386   \param [in]    ptr  Pointer to location
387   \return          0  Function succeeded
388   \return          1  Function failed
389  */
390 #define __STREXB        (uint32_t)__builtin_arm_strex
391 #endif /* (__ARM_FEATURE_LDREX >= 1) */
392
393
394 #if (__ARM_FEATURE_LDREX >= 2)
395 /**
396   \brief   LDR Exclusive (16 bit)
397   \details Executes a exclusive LDR instruction for 16 bit values.
398   \param [in]    ptr  Pointer to data
399   \return        value of type uint16_t at (*ptr)
400  */
401 #define __LDREXH        (uint16_t)__builtin_arm_ldrex
402
403
404 /**
405   \brief   STR Exclusive (16 bit)
406   \details Executes a exclusive STR instruction for 16 bit values.
407   \param [in]  value  Value to store
408   \param [in]    ptr  Pointer to location
409   \return          0  Function succeeded
410   \return          1  Function failed
411  */
412 #define __STREXH        (uint32_t)__builtin_arm_strex
413 #endif /* (__ARM_FEATURE_LDREX >= 2) */
414
415
416 #if (__ARM_FEATURE_LDREX >= 4)
417 /**
418   \brief   LDR Exclusive (32 bit)
419   \details Executes a exclusive LDR instruction for 32 bit values.
420   \param [in]    ptr  Pointer to data
421   \return        value of type uint32_t at (*ptr)
422  */
423 #define __LDREXW        (uint32_t)__builtin_arm_ldrex
424
425
426 /**
427   \brief   STR Exclusive (32 bit)
428   \details Executes a exclusive STR instruction for 32 bit values.
429   \param [in]  value  Value to store
430   \param [in]    ptr  Pointer to location
431   \return          0  Function succeeded
432   \return          1  Function failed
433  */
434 #define __STREXW        (uint32_t)__builtin_arm_strex
435 #endif /* (__ARM_FEATURE_LDREX >= 4) */
436
437
438 #if (__ARM_ARCH_ISA_THUMB >= 2)
439 /**
440   \brief   Rotate Right with Extend (32 bit)
441   \details Moves each bit of a bitstring right by one bit.
442            The carry input is shifted in at the left end of the bitstring.
443   \param [in]    value  Value to rotate
444   \return               Rotated value
445  */
446 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
447 {
448   uint32_t result;
449
450   __ASM volatile ("rrx %0, %1" : "=r" (result) : "r" (value));
451   return (result);
452 }
453
454
455 /**
456   \brief   LDRT Unprivileged (8 bit)
457   \details Executes a Unprivileged LDRT instruction for 8 bit value.
458   \param [in]    ptr  Pointer to data
459   \return             value of type uint8_t at (*ptr)
460  */
461 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
462 {
463   uint32_t result;
464
465   __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
466   return ((uint8_t)result);    /* Add explicit type cast here */
467 }
468
469
470 /**
471   \brief   LDRT Unprivileged (16 bit)
472   \details Executes a Unprivileged LDRT instruction for 16 bit values.
473   \param [in]    ptr  Pointer to data
474   \return        value of type uint16_t at (*ptr)
475  */
476 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
477 {
478   uint32_t result;
479
480   __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
481   return ((uint16_t)result);    /* Add explicit type cast here */
482 }
483
484
485 /**
486   \brief   LDRT Unprivileged (32 bit)
487   \details Executes a Unprivileged LDRT instruction for 32 bit values.
488   \param [in]    ptr  Pointer to data
489   \return        value of type uint32_t at (*ptr)
490  */
491 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
492 {
493   uint32_t result;
494
495   __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
496   return (result);
497 }
498
499
500 /**
501   \brief   STRT Unprivileged (8 bit)
502   \details Executes a Unprivileged STRT instruction for 8 bit values.
503   \param [in]  value  Value to store
504   \param [in]    ptr  Pointer to location
505  */
506 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
507 {
508   __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
509 }
510
511
512 /**
513   \brief   STRT Unprivileged (16 bit)
514   \details Executes a Unprivileged STRT instruction for 16 bit values.
515   \param [in]  value  Value to store
516   \param [in]    ptr  Pointer to location
517  */
518 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
519 {
520   __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
521 }
522
523
524 /**
525   \brief   STRT Unprivileged (32 bit)
526   \details Executes a Unprivileged STRT instruction for 32 bit values.
527   \param [in]  value  Value to store
528   \param [in]    ptr  Pointer to location
529  */
530 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
531 {
532   __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
533 }
534 #endif /* (__ARM_ARCH_ISA_THUMB >= 2) */
535
536
537 #if (__ARM_ARCH >= 8)
538 /**
539   \brief   Load-Acquire (8 bit)
540   \details Executes a LDAB instruction for 8 bit value.
541   \param [in]    ptr  Pointer to data
542   \return             value of type uint8_t at (*ptr)
543  */
544 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
545 {
546   uint32_t result;
547
548   __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
549   return ((uint8_t)result);    /* Add explicit type cast here */
550 }
551
552
553 /**
554   \brief   Load-Acquire (16 bit)
555   \details Executes a LDAH instruction for 16 bit values.
556   \param [in]    ptr  Pointer to data
557   \return        value of type uint16_t at (*ptr)
558  */
559 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
560 {
561   uint32_t result;
562
563   __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
564   return ((uint16_t)result);    /* Add explicit type cast here */
565 }
566
567
568 /**
569   \brief   Load-Acquire (32 bit)
570   \details Executes a LDA instruction for 32 bit values.
571   \param [in]    ptr  Pointer to data
572   \return        value of type uint32_t at (*ptr)
573  */
574 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
575 {
576   uint32_t result;
577
578   __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
579   return (result);
580 }
581
582
583 /**
584   \brief   Store-Release (8 bit)
585   \details Executes a STLB instruction for 8 bit values.
586   \param [in]  value  Value to store
587   \param [in]    ptr  Pointer to location
588  */
589 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
590 {
591   __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
592 }
593
594
595 /**
596   \brief   Store-Release (16 bit)
597   \details Executes a STLH instruction for 16 bit values.
598   \param [in]  value  Value to store
599   \param [in]    ptr  Pointer to location
600  */
601 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
602 {
603   __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
604 }
605
606
607 /**
608   \brief   Store-Release (32 bit)
609   \details Executes a STL instruction for 32 bit values.
610   \param [in]  value  Value to store
611   \param [in]    ptr  Pointer to location
612  */
613 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
614 {
615   __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
616 }
617
618
619 /**
620   \brief   Load-Acquire Exclusive (8 bit)
621   \details Executes a LDAB exclusive instruction for 8 bit value.
622   \param [in]    ptr  Pointer to data
623   \return             value of type uint8_t at (*ptr)
624  */
625 #define __LDAEXB                 (uint8_t)__builtin_arm_ldaex
626
627
628 /**
629   \brief   Load-Acquire Exclusive (16 bit)
630   \details Executes a LDAH exclusive instruction for 16 bit values.
631   \param [in]    ptr  Pointer to data
632   \return        value of type uint16_t at (*ptr)
633  */
634 #define __LDAEXH                 (uint16_t)__builtin_arm_ldaex
635
636
637 /**
638   \brief   Load-Acquire Exclusive (32 bit)
639   \details Executes a LDA exclusive instruction for 32 bit values.
640   \param [in]    ptr  Pointer to data
641   \return        value of type uint32_t at (*ptr)
642  */
643 #define __LDAEX                  (uint32_t)__builtin_arm_ldaex
644
645
646 /**
647   \brief   Store-Release Exclusive (8 bit)
648   \details Executes a STLB exclusive instruction for 8 bit values.
649   \param [in]  value  Value to store
650   \param [in]    ptr  Pointer to location
651   \return          0  Function succeeded
652   \return          1  Function failed
653  */
654 #define __STLEXB                 (uint32_t)__builtin_arm_stlex
655
656
657 /**
658   \brief   Store-Release Exclusive (16 bit)
659   \details Executes a STLH exclusive instruction for 16 bit values.
660   \param [in]  value  Value to store
661   \param [in]    ptr  Pointer to location
662   \return          0  Function succeeded
663   \return          1  Function failed
664  */
665 #define __STLEXH                 (uint32_t)__builtin_arm_stlex
666
667
668 /**
669   \brief   Store-Release Exclusive (32 bit)
670   \details Executes a STL exclusive instruction for 32 bit values.
671   \param [in]  value  Value to store
672   \param [in]    ptr  Pointer to location
673   \return          0  Function succeeded
674   \return          1  Function failed
675  */
676 #define __STLEX                  (uint32_t)__builtin_arm_stlex
677
678 #endif /* (__ARM_ARCH >= 8) */
679
680 /** @}*/ /* end of group CMSIS_Core_InstructionInterface */
681
682
683 /* ###########################  Core Function Access  ########################### */
684 /** \ingroup  CMSIS_Core_FunctionInterface
685     \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
686   @{
687  */
688
689 /**
690   \brief   Enable IRQ Interrupts
691   \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
692            Can only be executed in Privileged modes.
693  */
694 #ifndef __ARM_COMPAT_H
695 __STATIC_FORCEINLINE void __enable_irq(void)
696 {
697   __ASM volatile ("cpsie i" : : : "memory");
698 }
699 #endif
700
701
702 /**
703   \brief   Disable IRQ Interrupts
704   \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
705            Can only be executed in Privileged modes.
706  */
707 #ifndef __ARM_COMPAT_H
708 __STATIC_FORCEINLINE void __disable_irq(void)
709 {
710   __ASM volatile ("cpsid i" : : : "memory");
711 }
712 #endif
713
714
715 /**
716   \brief   Get Control Register
717   \details Returns the content of the Control Register.
718   \return               Control Register value
719  */
720 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
721 {
722   uint32_t result;
723
724   __ASM volatile ("MRS %0, control" : "=r" (result) );
725   return (result);
726 }
727
728
729 #if (__ARM_FEATURE_CMSE == 3)
730 /**
731   \brief   Get Control Register (non-secure)
732   \details Returns the content of the non-secure Control Register when in secure mode.
733   \return               non-secure Control Register value
734  */
735 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
736 {
737   uint32_t result;
738
739   __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
740   return (result);
741 }
742 #endif
743
744
745 /**
746   \brief   Set Control Register
747   \details Writes the given value to the Control Register.
748   \param [in]    control  Control Register value to set
749  */
750 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
751 {
752   __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
753   __ISB();
754 }
755
756
757 #if (__ARM_FEATURE_CMSE == 3)
758 /**
759   \brief   Set Control Register (non-secure)
760   \details Writes the given value to the non-secure Control Register when in secure state.
761   \param [in]    control  Control Register value to set
762  */
763 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
764 {
765   __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
766   __ISB();
767 }
768 #endif
769
770
771 /**
772   \brief   Get IPSR Register
773   \details Returns the content of the IPSR Register.
774   \return               IPSR Register value
775  */
776 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
777 {
778   uint32_t result;
779
780   __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
781   return (result);
782 }
783
784
785 /**
786   \brief   Get APSR Register
787   \details Returns the content of the APSR Register.
788   \return               APSR Register value
789  */
790 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
791 {
792   uint32_t result;
793
794   __ASM volatile ("MRS %0, apsr" : "=r" (result) );
795   return (result);
796 }
797
798
799 /**
800   \brief   Get xPSR Register
801   \details Returns the content of the xPSR Register.
802   \return               xPSR Register value
803  */
804 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
805 {
806   uint32_t result;
807
808   __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
809   return (result);
810 }
811
812
813 /**
814   \brief   Get Process Stack Pointer
815   \details Returns the current value of the Process Stack Pointer (PSP).
816   \return               PSP Register value
817  */
818 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
819 {
820   uint32_t result;
821
822   __ASM volatile ("MRS %0, psp"  : "=r" (result) );
823   return (result);
824 }
825
826
827 #if (__ARM_FEATURE_CMSE == 3)
828 /**
829   \brief   Get Process Stack Pointer (non-secure)
830   \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
831   \return               PSP Register value
832  */
833 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
834 {
835   uint32_t result;
836
837   __ASM volatile ("MRS %0, psp_ns"  : "=r" (result) );
838   return (result);
839 }
840 #endif
841
842
843 /**
844   \brief   Set Process Stack Pointer
845   \details Assigns the given value to the Process Stack Pointer (PSP).
846   \param [in]    topOfProcStack  Process Stack Pointer value to set
847  */
848 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
849 {
850   __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
851 }
852
853
854 #if (__ARM_FEATURE_CMSE == 3)
855 /**
856   \brief   Set Process Stack Pointer (non-secure)
857   \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
858   \param [in]    topOfProcStack  Process Stack Pointer value to set
859  */
860 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
861 {
862   __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
863 }
864 #endif
865
866
867 /**
868   \brief   Get Main Stack Pointer
869   \details Returns the current value of the Main Stack Pointer (MSP).
870   \return               MSP Register value
871  */
872 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
873 {
874   uint32_t result;
875
876   __ASM volatile ("MRS %0, msp" : "=r" (result) );
877   return (result);
878 }
879
880
881 #if (__ARM_FEATURE_CMSE == 3)
882 /**
883   \brief   Get Main Stack Pointer (non-secure)
884   \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
885   \return               MSP Register value
886  */
887 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
888 {
889   uint32_t result;
890
891   __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
892   return (result);
893 }
894 #endif
895
896
897 /**
898   \brief   Set Main Stack Pointer
899   \details Assigns the given value to the Main Stack Pointer (MSP).
900   \param [in]    topOfMainStack  Main Stack Pointer value to set
901  */
902 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
903 {
904   __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
905 }
906
907
908 #if (__ARM_FEATURE_CMSE == 3)
909 /**
910   \brief   Set Main Stack Pointer (non-secure)
911   \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
912   \param [in]    topOfMainStack  Main Stack Pointer value to set
913  */
914 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
915 {
916   __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
917 }
918 #endif
919
920
921 #if (__ARM_FEATURE_CMSE == 3)
922 /**
923   \brief   Get Stack Pointer (non-secure)
924   \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
925   \return               SP Register value
926  */
927 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
928 {
929   uint32_t result;
930
931   __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
932   return (result);
933 }
934
935
936 /**
937   \brief   Set Stack Pointer (non-secure)
938   \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
939   \param [in]    topOfStack  Stack Pointer value to set
940  */
941 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
942 {
943   __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
944 }
945 #endif
946
947
948 /**
949   \brief   Get Priority Mask
950   \details Returns the current state of the priority mask bit from the Priority Mask Register.
951   \return               Priority Mask value
952  */
953 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
954 {
955   uint32_t result;
956
957   __ASM volatile ("MRS %0, primask" : "=r" (result) );
958   return (result);
959 }
960
961
962 #if (__ARM_FEATURE_CMSE == 3)
963 /**
964   \brief   Get Priority Mask (non-secure)
965   \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
966   \return               Priority Mask value
967  */
968 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
969 {
970   uint32_t result;
971
972   __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
973   return (result);
974 }
975 #endif
976
977
978 /**
979   \brief   Set Priority Mask
980   \details Assigns the given value to the Priority Mask Register.
981   \param [in]    priMask  Priority Mask
982  */
983 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
984 {
985   __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
986 }
987
988
989 #if (__ARM_FEATURE_CMSE == 3)
990 /**
991   \brief   Set Priority Mask (non-secure)
992   \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
993   \param [in]    priMask  Priority Mask
994  */
995 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
996 {
997   __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
998 }
999 #endif
1000
1001
1002 #if (__ARM_ARCH_ISA_THUMB >= 2)
1003 /**
1004   \brief   Enable FIQ
1005   \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
1006            Can only be executed in Privileged modes.
1007  */
1008 __STATIC_FORCEINLINE void __enable_fault_irq(void)
1009 {
1010   __ASM volatile ("cpsie f" : : : "memory");
1011 }
1012
1013
1014 /**
1015   \brief   Disable FIQ
1016   \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
1017            Can only be executed in Privileged modes.
1018  */
1019 __STATIC_FORCEINLINE void __disable_fault_irq(void)
1020 {
1021   __ASM volatile ("cpsid f" : : : "memory");
1022 }
1023
1024
1025 /**
1026   \brief   Get Base Priority
1027   \details Returns the current value of the Base Priority register.
1028   \return               Base Priority register value
1029  */
1030 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
1031 {
1032   uint32_t result;
1033
1034   __ASM volatile ("MRS %0, basepri" : "=r" (result) );
1035   return (result);
1036 }
1037
1038
1039 #if (__ARM_FEATURE_CMSE == 3)
1040 /**
1041   \brief   Get Base Priority (non-secure)
1042   \details Returns the current value of the non-secure Base Priority register when in secure state.
1043   \return               Base Priority register value
1044  */
1045 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
1046 {
1047   uint32_t result;
1048
1049   __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
1050   return (result);
1051 }
1052 #endif
1053
1054
1055 /**
1056   \brief   Set Base Priority
1057   \details Assigns the given value to the Base Priority register.
1058   \param [in]    basePri  Base Priority value to set
1059  */
1060 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
1061 {
1062   __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
1063 }
1064
1065
1066 #if (__ARM_FEATURE_CMSE == 3)
1067 /**
1068   \brief   Set Base Priority (non-secure)
1069   \details Assigns the given value to the non-secure Base Priority register when in secure state.
1070   \param [in]    basePri  Base Priority value to set
1071  */
1072 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
1073 {
1074   __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
1075 }
1076 #endif
1077
1078
1079 /**
1080   \brief   Set Base Priority with condition
1081   \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
1082            or the new value increases the BASEPRI priority level.
1083   \param [in]    basePri  Base Priority value to set
1084  */
1085 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
1086 {
1087   __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
1088 }
1089
1090
1091 /**
1092   \brief   Get Fault Mask
1093   \details Returns the current value of the Fault Mask register.
1094   \return               Fault Mask register value
1095  */
1096 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
1097 {
1098   uint32_t result;
1099
1100   __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
1101   return (result);
1102 }
1103
1104
1105 #if (__ARM_FEATURE_CMSE == 3)
1106 /**
1107   \brief   Get Fault Mask (non-secure)
1108   \details Returns the current value of the non-secure Fault Mask register when in secure state.
1109   \return               Fault Mask register value
1110  */
1111 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
1112 {
1113   uint32_t result;
1114
1115   __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
1116   return (result);
1117 }
1118 #endif
1119
1120
1121 /**
1122   \brief   Set Fault Mask
1123   \details Assigns the given value to the Fault Mask register.
1124   \param [in]    faultMask  Fault Mask value to set
1125  */
1126 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
1127 {
1128   __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
1129 }
1130
1131
1132 #if (__ARM_FEATURE_CMSE == 3)
1133 /**
1134   \brief   Set Fault Mask (non-secure)
1135   \details Assigns the given value to the non-secure Fault Mask register when in secure state.
1136   \param [in]    faultMask  Fault Mask value to set
1137  */
1138 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
1139 {
1140   __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
1141 }
1142 #endif
1143
1144 #endif /* (__ARM_ARCH_ISA_THUMB >= 2) */
1145
1146
1147 #if (__ARM_ARCH >= 8)
1148 /**
1149   \brief   Get Process Stack Pointer Limit
1150   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1151   Stack Pointer Limit register hence zero is returned always in non-secure
1152   mode.
1153
1154   \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
1155   \return               PSPLIM Register value
1156  */
1157 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
1158 {
1159 #if (((__ARM_ARCH_8M_MAIN__   < 1) && \
1160       (__ARM_ARCH_8_1M_MAIN__ < 1)    ) && \
1161          (__ARM_FEATURE_CMSE < 3)              )
1162   /* without main extensions, the non-secure PSPLIM is RAZ/WI */
1163   return (0U);
1164 #else
1165   uint32_t result;
1166   __ASM volatile ("MRS %0, psplim"  : "=r" (result) );
1167   return (result);
1168 #endif
1169 }
1170
1171 #if (__ARM_FEATURE_CMSE == 3)
1172 /**
1173   \brief   Get Process Stack Pointer Limit (non-secure)
1174   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1175   Stack Pointer Limit register hence zero is returned always.
1176
1177   \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
1178   \return               PSPLIM Register value
1179  */
1180 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
1181 {
1182 #if ((__ARM_ARCH_8M_MAIN__   < 1) && \
1183      (__ARM_ARCH_8_1M_MAIN__ < 1)    )
1184   /* without main extensions, the non-secure PSPLIM is RAZ/WI */
1185   return (0U);
1186 #else
1187   uint32_t result;
1188   __ASM volatile ("MRS %0, psplim_ns"  : "=r" (result) );
1189   return (result);
1190 #endif
1191 }
1192 #endif
1193
1194
1195 /**
1196   \brief   Set Process Stack Pointer Limit
1197   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1198   Stack Pointer Limit register hence the write is silently ignored in non-secure
1199   mode.
1200
1201   \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
1202   \param [in]    ProcStackPtrLimit  Process Stack Pointer Limit value to set
1203  */
1204 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
1205 {
1206 #if (((__ARM_ARCH_8M_MAIN__   < 1) && \
1207       (__ARM_ARCH_8_1M_MAIN__ < 1)    ) && \
1208          (__ARM_FEATURE_CMSE < 3)              )
1209   /* without main extensions, the non-secure PSPLIM is RAZ/WI */
1210   (void)ProcStackPtrLimit;
1211 #else
1212   __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
1213 #endif
1214 }
1215
1216
1217 #if (__ARM_FEATURE_CMSE == 3)
1218 /**
1219   \brief   Set Process Stack Pointer (non-secure)
1220   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1221   Stack Pointer Limit register hence the write is silently ignored.
1222
1223   \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
1224   \param [in]    ProcStackPtrLimit  Process Stack Pointer Limit value to set
1225  */
1226 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
1227 {
1228 #if ((__ARM_ARCH_8M_MAIN__   < 1) && \
1229      (__ARM_ARCH_8_1M_MAIN__ < 1)    )
1230   /* without main extensions, the non-secure PSPLIM is RAZ/WI */
1231   (void)ProcStackPtrLimit;
1232 #else
1233   __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
1234 #endif
1235 }
1236 #endif
1237
1238
1239 /**
1240   \brief   Get Main Stack Pointer Limit
1241   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1242   Stack Pointer Limit register hence zero is returned always.
1243
1244   \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
1245   \return               MSPLIM Register value
1246  */
1247 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
1248 {
1249 #if (((__ARM_ARCH_8M_MAIN__   < 1) && \
1250       (__ARM_ARCH_8_1M_MAIN__ < 1)    ) && \
1251          (__ARM_FEATURE_CMSE < 3)              )
1252   /* without main extensions, the non-secure MSPLIM is RAZ/WI */
1253   return (0U);
1254 #else
1255   uint32_t result;
1256   __ASM volatile ("MRS %0, msplim" : "=r" (result) );
1257   return (result);
1258 #endif
1259 }
1260
1261
1262 #if (__ARM_FEATURE_CMSE == 3)
1263 /**
1264   \brief   Get Main Stack Pointer Limit (non-secure)
1265   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1266   Stack Pointer Limit register hence zero is returned always.
1267
1268   \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
1269   \return               MSPLIM Register value
1270  */
1271 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
1272 {
1273 #if ((__ARM_ARCH_8M_MAIN__   < 1) && \
1274      (__ARM_ARCH_8_1M_MAIN__ < 1)    )
1275   /* without main extensions, the non-secure MSPLIM is RAZ/WI */
1276   return (0U);
1277 #else
1278   uint32_t result;
1279   __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
1280   return (result);
1281 #endif
1282 }
1283 #endif
1284
1285
1286 /**
1287   \brief   Set Main Stack Pointer Limit
1288   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1289   Stack Pointer Limit register hence the write is silently ignored.
1290
1291   \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
1292   \param [in]    MainStackPtrLimit  Main Stack Pointer Limit value to set
1293  */
1294 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
1295 {
1296 #if (((__ARM_ARCH_8M_MAIN__   < 1) && \
1297       (__ARM_ARCH_8_1M_MAIN__ < 1)    ) && \
1298          (__ARM_FEATURE_CMSE < 3)              )
1299   /* without main extensions, the non-secure MSPLIM is RAZ/WI */
1300   (void)MainStackPtrLimit;
1301 #else
1302   __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
1303 #endif
1304 }
1305
1306
1307 #if (__ARM_FEATURE_CMSE == 3)
1308 /**
1309   \brief   Set Main Stack Pointer Limit (non-secure)
1310   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
1311   Stack Pointer Limit register hence the write is silently ignored.
1312
1313   \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
1314   \param [in]    MainStackPtrLimit  Main Stack Pointer value to set
1315  */
1316 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
1317 {
1318 #if ((__ARM_ARCH_8M_MAIN__   < 1) && \
1319      (__ARM_ARCH_8_1M_MAIN__ < 1)    )
1320   /* without main extensions, the non-secure MSPLIM is RAZ/WI */
1321   (void)MainStackPtrLimit;
1322 #else
1323   __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
1324 #endif
1325 }
1326 #endif
1327
1328 #endif /* (__ARM_ARCH >= 8) */
1329
1330
1331 /**
1332   \brief   Get FPSCR
1333   \details Returns the current value of the Floating Point Status/Control register.
1334   \return               Floating Point Status/Control register value
1335  */
1336 __STATIC_FORCEINLINE uint32_t __get_FPSCR(void)
1337 {
1338 #if (__ARM_FP >= 1)
1339   return (__builtin_arm_get_fpscr());
1340 #else
1341   return (0U);
1342 #endif
1343 }
1344
1345
1346 /**
1347   \brief   Set FPSCR
1348   \details Assigns the given value to the Floating Point Status/Control register.
1349   \param [in]    fpscr  Floating Point Status/Control value to set
1350  */
1351 __STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr)
1352 {
1353 #if (__ARM_FP >= 1)
1354   __builtin_arm_set_fpscr(fpscr);
1355 #else
1356   (void)fpscr;
1357 #endif
1358 }
1359
1360
1361 /** @} end of CMSIS_Core_RegAccFunctions */
1362
1363
1364 /* ###################  Compiler specific Intrinsics  ########################### */
1365 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1366   Access to dedicated SIMD instructions
1367   @{
1368 */
1369
1370 #if (__ARM_FEATURE_DSP == 1)
1371 #define     __SADD8                 __sadd8
1372 #define     __QADD8                 __qadd8
1373 #define     __SHADD8                __shadd8
1374 #define     __UADD8                 __uadd8
1375 #define     __UQADD8                __uqadd8
1376 #define     __UHADD8                __uhadd8
1377 #define     __SSUB8                 __ssub8
1378 #define     __QSUB8                 __qsub8
1379 #define     __SHSUB8                __shsub8
1380 #define     __USUB8                 __usub8
1381 #define     __UQSUB8                __uqsub8
1382 #define     __UHSUB8                __uhsub8
1383 #define     __SADD16                __sadd16
1384 #define     __QADD16                __qadd16
1385 #define     __SHADD16               __shadd16
1386 #define     __UADD16                __uadd16
1387 #define     __UQADD16               __uqadd16
1388 #define     __UHADD16               __uhadd16
1389 #define     __SSUB16                __ssub16
1390 #define     __QSUB16                __qsub16
1391 #define     __SHSUB16               __shsub16
1392 #define     __USUB16                __usub16
1393 #define     __UQSUB16               __uqsub16
1394 #define     __UHSUB16               __uhsub16
1395 #define     __SASX                  __sasx
1396 #define     __QASX                  __qasx
1397 #define     __SHASX                 __shasx
1398 #define     __UASX                  __uasx
1399 #define     __UQASX                 __uqasx
1400 #define     __UHASX                 __uhasx
1401 #define     __SSAX                  __ssax
1402 #define     __QSAX                  __qsax
1403 #define     __SHSAX                 __shsax
1404 #define     __USAX                  __usax
1405 #define     __UQSAX                 __uqsax
1406 #define     __UHSAX                 __uhsax
1407 #define     __USAD8                 __usad8
1408 #define     __USADA8                __usada8
1409 #define     __SSAT16                __ssat16
1410 #define     __USAT16                __usat16
1411 #define     __UXTB16                __uxtb16
1412 #define     __UXTAB16               __uxtab16
1413 #define     __SXTB16                __sxtb16
1414 #define     __SXTAB16               __sxtab16
1415 #define     __SMUAD                 __smuad
1416 #define     __SMUADX                __smuadx
1417 #define     __SMLAD                 __smlad
1418 #define     __SMLADX                __smladx
1419 #define     __SMLALD                __smlald
1420 #define     __SMLALDX               __smlaldx
1421 #define     __SMUSD                 __smusd
1422 #define     __SMUSDX                __smusdx
1423 #define     __SMLSD                 __smlsd
1424 #define     __SMLSDX                __smlsdx
1425 #define     __SMLSLD                __smlsld
1426 #define     __SMLSLDX               __smlsldx
1427 #define     __SEL                   __sel
1428 #define     __QADD                  __qadd
1429 #define     __QSUB                  __qsub
1430
1431 #define __PKHBT(ARG1,ARG2,ARG3) \
1432 __extension__ \
1433 ({                          \
1434   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1435   __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1436   __RES; \
1437  })
1438
1439 #define __PKHTB(ARG1,ARG2,ARG3) \
1440 __extension__ \
1441 ({                          \
1442   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1443   if (ARG3 == 0) \
1444     __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2)  ); \
1445   else \
1446     __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1447   __RES; \
1448  })
1449
1450 #define __SXTB16_RORn(ARG1, ARG2)        __SXTB16(__ROR(ARG1, ARG2))
1451
1452 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1453
1454 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1455 {
1456   int32_t result;
1457
1458   __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r"  (op1), "r" (op2), "r" (op3) );
1459   return (result);
1460 }
1461
1462 #endif /* (__ARM_FEATURE_DSP == 1) */
1463 /** @} end of group CMSIS_SIMD_intrinsics */
1464
1465
1466 #endif /* __CMSIS_ARMCLANG_M_H */