]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_armclang_ltm.h
RTX5: fix mutex priority inversion (#1202)
[cmsis] / CMSIS / Core / Include / cmsis_armclang_ltm.h
1 /**************************************************************************//**
2  * @file     cmsis_armclang_ltm.h
3  * @brief    CMSIS compiler armclang (Arm Compiler 6) header file
4  * @version  V1.5.2
5  * @date     05. May 2021
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2018-2021 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 /*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */
26
27 #ifndef __CMSIS_ARMCLANG_H
28 #define __CMSIS_ARMCLANG_H
29
30 #pragma clang system_header   /* treat file as system include file */
31
32 /* CMSIS compiler specific defines */
33 #ifndef   __ASM
34   #define __ASM                                  __asm
35 #endif
36 #ifndef   __INLINE
37   #define __INLINE                               __inline
38 #endif
39 #ifndef   __STATIC_INLINE
40   #define __STATIC_INLINE                        static __inline
41 #endif
42 #ifndef   __STATIC_FORCEINLINE
43   #define __STATIC_FORCEINLINE                   __attribute__((always_inline)) static __inline
44 #endif
45 #ifndef   __NO_RETURN
46   #define __NO_RETURN                            __attribute__((__noreturn__))
47 #endif
48 #ifndef   __USED
49   #define __USED                                 __attribute__((used))
50 #endif
51 #ifndef   __WEAK
52   #define __WEAK                                 __attribute__((weak))
53 #endif
54 #ifndef   __PACKED
55   #define __PACKED                               __attribute__((packed, aligned(1)))
56 #endif
57 #ifndef   __PACKED_STRUCT
58   #define __PACKED_STRUCT                        struct __attribute__((packed, aligned(1)))
59 #endif
60 #ifndef   __PACKED_UNION
61   #define __PACKED_UNION                         union __attribute__((packed, aligned(1)))
62 #endif
63 #ifndef   __UNALIGNED_UINT32        /* deprecated */
64   #pragma clang diagnostic push
65   #pragma clang diagnostic ignored "-Wpacked"
66 /*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */
67   struct __attribute__((packed)) T_UINT32 { uint32_t v; };
68   #pragma clang diagnostic pop
69   #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
70 #endif
71 #ifndef   __UNALIGNED_UINT16_WRITE
72   #pragma clang diagnostic push
73   #pragma clang diagnostic ignored "-Wpacked"
74 /*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */
75   __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
76   #pragma clang diagnostic pop
77   #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
78 #endif
79 #ifndef   __UNALIGNED_UINT16_READ
80   #pragma clang diagnostic push
81   #pragma clang diagnostic ignored "-Wpacked"
82 /*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */
83   __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
84   #pragma clang diagnostic pop
85   #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
86 #endif
87 #ifndef   __UNALIGNED_UINT32_WRITE
88   #pragma clang diagnostic push
89   #pragma clang diagnostic ignored "-Wpacked"
90 /*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */
91   __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
92   #pragma clang diagnostic pop
93   #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
94 #endif
95 #ifndef   __UNALIGNED_UINT32_READ
96   #pragma clang diagnostic push
97   #pragma clang diagnostic ignored "-Wpacked"
98 /*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */
99   __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
100   #pragma clang diagnostic pop
101   #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
102 #endif
103 #ifndef   __ALIGNED
104   #define __ALIGNED(x)                           __attribute__((aligned(x)))
105 #endif
106 #ifndef   __RESTRICT
107   #define __RESTRICT                             __restrict
108 #endif
109 #ifndef   __COMPILER_BARRIER
110   #define __COMPILER_BARRIER()                   __ASM volatile("":::"memory")
111 #endif
112
113 /* #########################  Startup and Lowlevel Init  ######################## */
114
115 #ifndef __PROGRAM_START
116 #define __PROGRAM_START           __main
117 #endif
118
119 #ifndef __INITIAL_SP
120 #define __INITIAL_SP              Image$$ARM_LIB_STACK$$ZI$$Limit
121 #endif
122
123 #ifndef __STACK_LIMIT
124 #define __STACK_LIMIT             Image$$ARM_LIB_STACK$$ZI$$Base
125 #endif
126
127 #ifndef __VECTOR_TABLE
128 #define __VECTOR_TABLE            __Vectors
129 #endif
130
131 #ifndef __VECTOR_TABLE_ATTRIBUTE
132 #define __VECTOR_TABLE_ATTRIBUTE  __attribute__((used, section("RESET")))
133 #endif
134
135 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
136 #ifndef __STACK_SEAL
137 #define __STACK_SEAL              Image$$STACKSEAL$$ZI$$Base
138 #endif
139
140 #ifndef __TZ_STACK_SEAL_SIZE
141 #define __TZ_STACK_SEAL_SIZE      8U
142 #endif
143
144 #ifndef __TZ_STACK_SEAL_VALUE
145 #define __TZ_STACK_SEAL_VALUE     0xFEF5EDA5FEF5EDA5ULL
146 #endif
147
148
149 __STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
150   *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE;
151 }
152 #endif
153
154
155 /* ###########################  Core Function Access  ########################### */
156 /** \ingroup  CMSIS_Core_FunctionInterface
157     \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
158   @{
159  */
160
161 /**
162   \brief   Enable IRQ Interrupts
163   \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
164            Can only be executed in Privileged modes.
165  */
166 __STATIC_FORCEINLINE void __enable_irq(void)
167 {
168   __ASM volatile ("cpsie i" : : : "memory");
169 }
170
171
172 /**
173   \brief   Disable IRQ Interrupts
174   \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
175            Can only be executed in Privileged modes.
176  */
177 __STATIC_FORCEINLINE void __disable_irq(void)
178 {
179   __ASM volatile ("cpsid i" : : : "memory");
180 }
181
182
183 /**
184   \brief   Get Control Register
185   \details Returns the content of the Control Register.
186   \return               Control Register value
187  */
188 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
189 {
190   uint32_t result;
191
192   __ASM volatile ("MRS %0, control" : "=r" (result) );
193   return(result);
194 }
195
196
197 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
198 /**
199   \brief   Get Control Register (non-secure)
200   \details Returns the content of the non-secure Control Register when in secure mode.
201   \return               non-secure Control Register value
202  */
203 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
204 {
205   uint32_t result;
206
207   __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
208   return(result);
209 }
210 #endif
211
212
213 /**
214   \brief   Set Control Register
215   \details Writes the given value to the Control Register.
216   \param [in]    control  Control Register value to set
217  */
218 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
219 {
220   __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
221 }
222
223
224 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
225 /**
226   \brief   Set Control Register (non-secure)
227   \details Writes the given value to the non-secure Control Register when in secure state.
228   \param [in]    control  Control Register value to set
229  */
230 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
231 {
232   __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
233 }
234 #endif
235
236
237 /**
238   \brief   Get IPSR Register
239   \details Returns the content of the IPSR Register.
240   \return               IPSR Register value
241  */
242 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
243 {
244   uint32_t result;
245
246   __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
247   return(result);
248 }
249
250
251 /**
252   \brief   Get APSR Register
253   \details Returns the content of the APSR Register.
254   \return               APSR Register value
255  */
256 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
257 {
258   uint32_t result;
259
260   __ASM volatile ("MRS %0, apsr" : "=r" (result) );
261   return(result);
262 }
263
264
265 /**
266   \brief   Get xPSR Register
267   \details Returns the content of the xPSR Register.
268   \return               xPSR Register value
269  */
270 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
271 {
272   uint32_t result;
273
274   __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
275   return(result);
276 }
277
278
279 /**
280   \brief   Get Process Stack Pointer
281   \details Returns the current value of the Process Stack Pointer (PSP).
282   \return               PSP Register value
283  */
284 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
285 {
286   uint32_t result;
287
288   __ASM volatile ("MRS %0, psp"  : "=r" (result) );
289   return(result);
290 }
291
292
293 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
294 /**
295   \brief   Get Process Stack Pointer (non-secure)
296   \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
297   \return               PSP Register value
298  */
299 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
300 {
301   uint32_t result;
302
303   __ASM volatile ("MRS %0, psp_ns"  : "=r" (result) );
304   return(result);
305 }
306 #endif
307
308
309 /**
310   \brief   Set Process Stack Pointer
311   \details Assigns the given value to the Process Stack Pointer (PSP).
312   \param [in]    topOfProcStack  Process Stack Pointer value to set
313  */
314 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
315 {
316   __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
317 }
318
319
320 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
321 /**
322   \brief   Set Process Stack Pointer (non-secure)
323   \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
324   \param [in]    topOfProcStack  Process Stack Pointer value to set
325  */
326 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
327 {
328   __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
329 }
330 #endif
331
332
333 /**
334   \brief   Get Main Stack Pointer
335   \details Returns the current value of the Main Stack Pointer (MSP).
336   \return               MSP Register value
337  */
338 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
339 {
340   uint32_t result;
341
342   __ASM volatile ("MRS %0, msp" : "=r" (result) );
343   return(result);
344 }
345
346
347 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
348 /**
349   \brief   Get Main Stack Pointer (non-secure)
350   \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
351   \return               MSP Register value
352  */
353 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
354 {
355   uint32_t result;
356
357   __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
358   return(result);
359 }
360 #endif
361
362
363 /**
364   \brief   Set Main Stack Pointer
365   \details Assigns the given value to the Main Stack Pointer (MSP).
366   \param [in]    topOfMainStack  Main Stack Pointer value to set
367  */
368 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
369 {
370   __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
371 }
372
373
374 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
375 /**
376   \brief   Set Main Stack Pointer (non-secure)
377   \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
378   \param [in]    topOfMainStack  Main Stack Pointer value to set
379  */
380 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
381 {
382   __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
383 }
384 #endif
385
386
387 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
388 /**
389   \brief   Get Stack Pointer (non-secure)
390   \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
391   \return               SP Register value
392  */
393 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
394 {
395   uint32_t result;
396
397   __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
398   return(result);
399 }
400
401
402 /**
403   \brief   Set Stack Pointer (non-secure)
404   \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
405   \param [in]    topOfStack  Stack Pointer value to set
406  */
407 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
408 {
409   __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
410 }
411 #endif
412
413
414 /**
415   \brief   Get Priority Mask
416   \details Returns the current state of the priority mask bit from the Priority Mask Register.
417   \return               Priority Mask value
418  */
419 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
420 {
421   uint32_t result;
422
423   __ASM volatile ("MRS %0, primask" : "=r" (result) );
424   return(result);
425 }
426
427
428 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
429 /**
430   \brief   Get Priority Mask (non-secure)
431   \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
432   \return               Priority Mask value
433  */
434 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
435 {
436   uint32_t result;
437
438   __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
439   return(result);
440 }
441 #endif
442
443
444 /**
445   \brief   Set Priority Mask
446   \details Assigns the given value to the Priority Mask Register.
447   \param [in]    priMask  Priority Mask
448  */
449 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
450 {
451   __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
452 }
453
454
455 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
456 /**
457   \brief   Set Priority Mask (non-secure)
458   \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
459   \param [in]    priMask  Priority Mask
460  */
461 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
462 {
463   __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
464 }
465 #endif
466
467
468 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
469      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
470      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
471 /**
472   \brief   Enable FIQ
473   \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
474            Can only be executed in Privileged modes.
475  */
476 __STATIC_FORCEINLINE void __enable_fault_irq(void)
477 {
478   __ASM volatile ("cpsie f" : : : "memory");
479 }
480
481
482 /**
483   \brief   Disable FIQ
484   \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
485            Can only be executed in Privileged modes.
486  */
487 __STATIC_FORCEINLINE void __disable_fault_irq(void)
488 {
489   __ASM volatile ("cpsid f" : : : "memory");
490 }
491
492
493 /**
494   \brief   Get Base Priority
495   \details Returns the current value of the Base Priority register.
496   \return               Base Priority register value
497  */
498 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
499 {
500   uint32_t result;
501
502   __ASM volatile ("MRS %0, basepri" : "=r" (result) );
503   return(result);
504 }
505
506
507 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
508 /**
509   \brief   Get Base Priority (non-secure)
510   \details Returns the current value of the non-secure Base Priority register when in secure state.
511   \return               Base Priority register value
512  */
513 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
514 {
515   uint32_t result;
516
517   __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
518   return(result);
519 }
520 #endif
521
522
523 /**
524   \brief   Set Base Priority
525   \details Assigns the given value to the Base Priority register.
526   \param [in]    basePri  Base Priority value to set
527  */
528 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
529 {
530   __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
531 }
532
533
534 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
535 /**
536   \brief   Set Base Priority (non-secure)
537   \details Assigns the given value to the non-secure Base Priority register when in secure state.
538   \param [in]    basePri  Base Priority value to set
539  */
540 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
541 {
542   __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
543 }
544 #endif
545
546
547 /**
548   \brief   Set Base Priority with condition
549   \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
550            or the new value increases the BASEPRI priority level.
551   \param [in]    basePri  Base Priority value to set
552  */
553 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
554 {
555   __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
556 }
557
558
559 /**
560   \brief   Get Fault Mask
561   \details Returns the current value of the Fault Mask register.
562   \return               Fault Mask register value
563  */
564 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
565 {
566   uint32_t result;
567
568   __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
569   return(result);
570 }
571
572
573 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
574 /**
575   \brief   Get Fault Mask (non-secure)
576   \details Returns the current value of the non-secure Fault Mask register when in secure state.
577   \return               Fault Mask register value
578  */
579 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
580 {
581   uint32_t result;
582
583   __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
584   return(result);
585 }
586 #endif
587
588
589 /**
590   \brief   Set Fault Mask
591   \details Assigns the given value to the Fault Mask register.
592   \param [in]    faultMask  Fault Mask value to set
593  */
594 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
595 {
596   __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
597 }
598
599
600 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
601 /**
602   \brief   Set Fault Mask (non-secure)
603   \details Assigns the given value to the non-secure Fault Mask register when in secure state.
604   \param [in]    faultMask  Fault Mask value to set
605  */
606 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
607 {
608   __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
609 }
610 #endif
611
612 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
613            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
614            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
615
616
617 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
618      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
619
620 /**
621   \brief   Get Process Stack Pointer Limit
622   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
623   Stack Pointer Limit register hence zero is returned always in non-secure
624   mode.
625
626   \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
627   \return               PSPLIM Register value
628  */
629 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
630 {
631 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
632     (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
633     // without main extensions, the non-secure PSPLIM is RAZ/WI
634   return 0U;
635 #else
636   uint32_t result;
637   __ASM volatile ("MRS %0, psplim"  : "=r" (result) );
638   return result;
639 #endif
640 }
641
642 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
643 /**
644   \brief   Get Process Stack Pointer Limit (non-secure)
645   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
646   Stack Pointer Limit register hence zero is returned always in non-secure
647   mode.
648
649   \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
650   \return               PSPLIM Register value
651  */
652 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
653 {
654 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
655   // without main extensions, the non-secure PSPLIM is RAZ/WI
656   return 0U;
657 #else
658   uint32_t result;
659   __ASM volatile ("MRS %0, psplim_ns"  : "=r" (result) );
660   return result;
661 #endif
662 }
663 #endif
664
665
666 /**
667   \brief   Set Process Stack Pointer Limit
668   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
669   Stack Pointer Limit register hence the write is silently ignored in non-secure
670   mode.
671
672   \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
673   \param [in]    ProcStackPtrLimit  Process Stack Pointer Limit value to set
674  */
675 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
676 {
677 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
678     (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
679   // without main extensions, the non-secure PSPLIM is RAZ/WI
680   (void)ProcStackPtrLimit;
681 #else
682   __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
683 #endif
684 }
685
686
687 #if (defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3))
688 /**
689   \brief   Set Process Stack Pointer (non-secure)
690   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
691   Stack Pointer Limit register hence the write is silently ignored in non-secure
692   mode.
693
694   \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
695   \param [in]    ProcStackPtrLimit  Process Stack Pointer Limit value to set
696  */
697 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
698 {
699 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
700   // without main extensions, the non-secure PSPLIM is RAZ/WI
701   (void)ProcStackPtrLimit;
702 #else
703   __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
704 #endif
705 }
706 #endif
707
708
709 /**
710   \brief   Get Main Stack Pointer Limit
711   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
712   Stack Pointer Limit register hence zero is returned always.
713
714   \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
715   \return               MSPLIM Register value
716  */
717 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
718 {
719 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
720     (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
721   // without main extensions, the non-secure MSPLIM is RAZ/WI
722   return 0U;
723 #else
724   uint32_t result;
725   __ASM volatile ("MRS %0, msplim" : "=r" (result) );
726   return result;
727 #endif
728 }
729
730
731 #if (defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3))
732 /**
733   \brief   Get Main Stack Pointer Limit (non-secure)
734   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
735   Stack Pointer Limit register hence zero is returned always.
736
737   \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
738   \return               MSPLIM Register value
739  */
740 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
741 {
742 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
743   // without main extensions, the non-secure MSPLIM is RAZ/WI
744   return 0U;
745 #else
746   uint32_t result;
747   __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
748   return result;
749 #endif
750 }
751 #endif
752
753
754 /**
755   \brief   Set Main Stack Pointer Limit
756   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
757   Stack Pointer Limit register hence the write is silently ignored.
758
759   \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
760   \param [in]    MainStackPtrLimit  Main Stack Pointer Limit value to set
761  */
762 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
763 {
764 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
765     (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
766   // without main extensions, the non-secure MSPLIM is RAZ/WI
767   (void)MainStackPtrLimit;
768 #else
769   __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
770 #endif
771 }
772
773
774 #if (defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3))
775 /**
776   \brief   Set Main Stack Pointer Limit (non-secure)
777   Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
778   Stack Pointer Limit register hence the write is silently ignored.
779
780   \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
781   \param [in]    MainStackPtrLimit  Main Stack Pointer value to set
782  */
783 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
784 {
785 #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)))
786   // without main extensions, the non-secure MSPLIM is RAZ/WI
787   (void)MainStackPtrLimit;
788 #else
789   __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
790 #endif
791 }
792 #endif
793
794 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
795            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
796
797 /**
798   \brief   Get FPSCR
799   \details Returns the current value of the Floating Point Status/Control register.
800   \return               Floating Point Status/Control register value
801  */
802 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
803      (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
804 #define __get_FPSCR      (uint32_t)__builtin_arm_get_fpscr
805 #else
806 #define __get_FPSCR()      ((uint32_t)0U)
807 #endif
808
809 /**
810   \brief   Set FPSCR
811   \details Assigns the given value to the Floating Point Status/Control register.
812   \param [in]    fpscr  Floating Point Status/Control value to set
813  */
814 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
815      (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
816 #define __set_FPSCR      __builtin_arm_set_fpscr
817 #else
818 #define __set_FPSCR(x)      ((void)(x))
819 #endif
820
821
822 /*@} end of CMSIS_Core_RegAccFunctions */
823
824
825 /* ##########################  Core Instruction Access  ######################### */
826 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
827   Access to dedicated instructions
828   @{
829 */
830
831 /* Define macros for porting to both thumb1 and thumb2.
832  * For thumb1, use low register (r0-r7), specified by constraint "l"
833  * Otherwise, use general registers, specified by constraint "r" */
834 #if defined (__thumb__) && !defined (__thumb2__)
835 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
836 #define __CMSIS_GCC_USE_REG(r) "l" (r)
837 #else
838 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
839 #define __CMSIS_GCC_USE_REG(r) "r" (r)
840 #endif
841
842 /**
843   \brief   No Operation
844   \details No Operation does nothing. This instruction can be used for code alignment purposes.
845  */
846 #define __NOP          __builtin_arm_nop
847
848 /**
849   \brief   Wait For Interrupt
850   \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
851  */
852 #define __WFI          __builtin_arm_wfi
853
854
855 /**
856   \brief   Wait For Event
857   \details Wait For Event is a hint instruction that permits the processor to enter
858            a low-power state until one of a number of events occurs.
859  */
860 #define __WFE          __builtin_arm_wfe
861
862
863 /**
864   \brief   Send Event
865   \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
866  */
867 #define __SEV          __builtin_arm_sev
868
869
870 /**
871   \brief   Instruction Synchronization Barrier
872   \details Instruction Synchronization Barrier flushes the pipeline in the processor,
873            so that all instructions following the ISB are fetched from cache or memory,
874            after the instruction has been completed.
875  */
876 #define __ISB()        __builtin_arm_isb(0xF)
877
878 /**
879   \brief   Data Synchronization Barrier
880   \details Acts as a special kind of Data Memory Barrier.
881            It completes when all explicit memory accesses before this instruction complete.
882  */
883 #define __DSB()        __builtin_arm_dsb(0xF)
884
885
886 /**
887   \brief   Data Memory Barrier
888   \details Ensures the apparent order of the explicit memory operations before
889            and after the instruction, without ensuring their completion.
890  */
891 #define __DMB()        __builtin_arm_dmb(0xF)
892
893
894 /**
895   \brief   Reverse byte order (32 bit)
896   \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
897   \param [in]    value  Value to reverse
898   \return               Reversed value
899  */
900 #define __REV(value)   __builtin_bswap32(value)
901
902
903 /**
904   \brief   Reverse byte order (16 bit)
905   \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
906   \param [in]    value  Value to reverse
907   \return               Reversed value
908  */
909 #define __REV16(value) __ROR(__REV(value), 16)
910
911
912 /**
913   \brief   Reverse byte order (16 bit)
914   \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
915   \param [in]    value  Value to reverse
916   \return               Reversed value
917  */
918 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
919
920
921 /**
922   \brief   Rotate Right in unsigned value (32 bit)
923   \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
924   \param [in]    op1  Value to rotate
925   \param [in]    op2  Number of Bits to rotate
926   \return               Rotated value
927  */
928 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
929 {
930   op2 %= 32U;
931   if (op2 == 0U)
932   {
933     return op1;
934   }
935   return (op1 >> op2) | (op1 << (32U - op2));
936 }
937
938
939 /**
940   \brief   Breakpoint
941   \details Causes the processor to enter Debug state.
942            Debug tools can use this to investigate system state when the instruction at a particular address is reached.
943   \param [in]    value  is ignored by the processor.
944                  If required, a debugger can use it to store additional information about the breakpoint.
945  */
946 #define __BKPT(value)     __ASM volatile ("bkpt "#value)
947
948
949 /**
950   \brief   Reverse bit order of value
951   \details Reverses the bit order of the given value.
952   \param [in]    value  Value to reverse
953   \return               Reversed value
954  */
955 #define __RBIT            __builtin_arm_rbit
956
957 /**
958   \brief   Count leading zeros
959   \details Counts the number of leading zeros of a data value.
960   \param [in]  value  Value to count the leading zeros
961   \return             number of leading zeros in value
962  */
963 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
964 {
965   /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
966      __builtin_clz(0) is undefined behaviour, so handle this case specially.
967      This guarantees ARM-compatible results if happening to compile on a non-ARM
968      target, and ensures the compiler doesn't decide to activate any
969      optimisations using the logic "value was passed to __builtin_clz, so it
970      is non-zero".
971      ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
972      single CLZ instruction.
973    */
974   if (value == 0U)
975   {
976     return 32U;
977   }
978   return __builtin_clz(value);
979 }
980
981
982 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
983      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
984      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
985      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
986 /**
987   \brief   LDR Exclusive (8 bit)
988   \details Executes a exclusive LDR instruction for 8 bit value.
989   \param [in]    ptr  Pointer to data
990   \return             value of type uint8_t at (*ptr)
991  */
992 #define __LDREXB        (uint8_t)__builtin_arm_ldrex
993
994
995 /**
996   \brief   LDR Exclusive (16 bit)
997   \details Executes a exclusive LDR instruction for 16 bit values.
998   \param [in]    ptr  Pointer to data
999   \return        value of type uint16_t at (*ptr)
1000  */
1001 #define __LDREXH        (uint16_t)__builtin_arm_ldrex
1002
1003
1004 /**
1005   \brief   LDR Exclusive (32 bit)
1006   \details Executes a exclusive LDR instruction for 32 bit values.
1007   \param [in]    ptr  Pointer to data
1008   \return        value of type uint32_t at (*ptr)
1009  */
1010 #define __LDREXW        (uint32_t)__builtin_arm_ldrex
1011
1012
1013 /**
1014   \brief   STR Exclusive (8 bit)
1015   \details Executes a exclusive STR instruction for 8 bit values.
1016   \param [in]  value  Value to store
1017   \param [in]    ptr  Pointer to location
1018   \return          0  Function succeeded
1019   \return          1  Function failed
1020  */
1021 #define __STREXB        (uint32_t)__builtin_arm_strex
1022
1023
1024 /**
1025   \brief   STR Exclusive (16 bit)
1026   \details Executes a exclusive STR instruction for 16 bit values.
1027   \param [in]  value  Value to store
1028   \param [in]    ptr  Pointer to location
1029   \return          0  Function succeeded
1030   \return          1  Function failed
1031  */
1032 #define __STREXH        (uint32_t)__builtin_arm_strex
1033
1034
1035 /**
1036   \brief   STR Exclusive (32 bit)
1037   \details Executes a exclusive STR instruction for 32 bit values.
1038   \param [in]  value  Value to store
1039   \param [in]    ptr  Pointer to location
1040   \return          0  Function succeeded
1041   \return          1  Function failed
1042  */
1043 #define __STREXW        (uint32_t)__builtin_arm_strex
1044
1045
1046 /**
1047   \brief   Remove the exclusive lock
1048   \details Removes the exclusive lock which is created by LDREX.
1049  */
1050 #define __CLREX             __builtin_arm_clrex
1051
1052 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1053            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1054            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1055            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1056
1057
1058 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1059      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1060      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
1061
1062 /**
1063   \brief   Signed Saturate
1064   \details Saturates a signed value.
1065   \param [in]  value  Value to be saturated
1066   \param [in]    sat  Bit position to saturate to (1..32)
1067   \return             Saturated value
1068  */
1069 #define __SSAT             __builtin_arm_ssat
1070
1071
1072 /**
1073   \brief   Unsigned Saturate
1074   \details Saturates an unsigned value.
1075   \param [in]  value  Value to be saturated
1076   \param [in]    sat  Bit position to saturate to (0..31)
1077   \return             Saturated value
1078  */
1079 #define __USAT             __builtin_arm_usat
1080
1081
1082 /**
1083   \brief   Rotate Right with Extend (32 bit)
1084   \details Moves each bit of a bitstring right by one bit.
1085            The carry input is shifted in at the left end of the bitstring.
1086   \param [in]    value  Value to rotate
1087   \return               Rotated value
1088  */
1089 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
1090 {
1091   uint32_t result;
1092
1093   __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1094   return(result);
1095 }
1096
1097
1098 /**
1099   \brief   LDRT Unprivileged (8 bit)
1100   \details Executes a Unprivileged LDRT instruction for 8 bit value.
1101   \param [in]    ptr  Pointer to data
1102   \return             value of type uint8_t at (*ptr)
1103  */
1104 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1105 {
1106   uint32_t result;
1107
1108   __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1109   return ((uint8_t) result);    /* Add explicit type cast here */
1110 }
1111
1112
1113 /**
1114   \brief   LDRT Unprivileged (16 bit)
1115   \details Executes a Unprivileged LDRT instruction for 16 bit values.
1116   \param [in]    ptr  Pointer to data
1117   \return        value of type uint16_t at (*ptr)
1118  */
1119 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1120 {
1121   uint32_t result;
1122
1123   __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1124   return ((uint16_t) result);    /* Add explicit type cast here */
1125 }
1126
1127
1128 /**
1129   \brief   LDRT Unprivileged (32 bit)
1130   \details Executes a Unprivileged LDRT instruction for 32 bit values.
1131   \param [in]    ptr  Pointer to data
1132   \return        value of type uint32_t at (*ptr)
1133  */
1134 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1135 {
1136   uint32_t result;
1137
1138   __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1139   return(result);
1140 }
1141
1142
1143 /**
1144   \brief   STRT Unprivileged (8 bit)
1145   \details Executes a Unprivileged STRT instruction for 8 bit values.
1146   \param [in]  value  Value to store
1147   \param [in]    ptr  Pointer to location
1148  */
1149 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1150 {
1151   __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1152 }
1153
1154
1155 /**
1156   \brief   STRT Unprivileged (16 bit)
1157   \details Executes a Unprivileged STRT instruction for 16 bit values.
1158   \param [in]  value  Value to store
1159   \param [in]    ptr  Pointer to location
1160  */
1161 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1162 {
1163   __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1164 }
1165
1166
1167 /**
1168   \brief   STRT Unprivileged (32 bit)
1169   \details Executes a Unprivileged STRT instruction for 32 bit values.
1170   \param [in]  value  Value to store
1171   \param [in]    ptr  Pointer to location
1172  */
1173 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1174 {
1175   __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1176 }
1177
1178 #else  /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1179            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1180            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
1181
1182 /**
1183   \brief   Signed Saturate
1184   \details Saturates a signed value.
1185   \param [in]  value  Value to be saturated
1186   \param [in]    sat  Bit position to saturate to (1..32)
1187   \return             Saturated value
1188  */
1189 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1190 {
1191   if ((sat >= 1U) && (sat <= 32U))
1192   {
1193     const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1194     const int32_t min = -1 - max ;
1195     if (val > max)
1196     {
1197       return max;
1198     }
1199     else if (val < min)
1200     {
1201       return min;
1202     }
1203   }
1204   return val;
1205 }
1206
1207 /**
1208   \brief   Unsigned Saturate
1209   \details Saturates an unsigned value.
1210   \param [in]  value  Value to be saturated
1211   \param [in]    sat  Bit position to saturate to (0..31)
1212   \return             Saturated value
1213  */
1214 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1215 {
1216   if (sat <= 31U)
1217   {
1218     const uint32_t max = ((1U << sat) - 1U);
1219     if (val > (int32_t)max)
1220     {
1221       return max;
1222     }
1223     else if (val < 0)
1224     {
1225       return 0U;
1226     }
1227   }
1228   return (uint32_t)val;
1229 }
1230
1231 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1232            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1233            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
1234
1235
1236 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1237      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
1238 /**
1239   \brief   Load-Acquire (8 bit)
1240   \details Executes a LDAB instruction for 8 bit value.
1241   \param [in]    ptr  Pointer to data
1242   \return             value of type uint8_t at (*ptr)
1243  */
1244 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1245 {
1246   uint32_t result;
1247
1248   __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1249   return ((uint8_t) result);
1250 }
1251
1252
1253 /**
1254   \brief   Load-Acquire (16 bit)
1255   \details Executes a LDAH instruction for 16 bit values.
1256   \param [in]    ptr  Pointer to data
1257   \return        value of type uint16_t at (*ptr)
1258  */
1259 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1260 {
1261   uint32_t result;
1262
1263   __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1264   return ((uint16_t) result);
1265 }
1266
1267
1268 /**
1269   \brief   Load-Acquire (32 bit)
1270   \details Executes a LDA instruction for 32 bit values.
1271   \param [in]    ptr  Pointer to data
1272   \return        value of type uint32_t at (*ptr)
1273  */
1274 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1275 {
1276   uint32_t result;
1277
1278   __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1279   return(result);
1280 }
1281
1282
1283 /**
1284   \brief   Store-Release (8 bit)
1285   \details Executes a STLB instruction for 8 bit values.
1286   \param [in]  value  Value to store
1287   \param [in]    ptr  Pointer to location
1288  */
1289 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1290 {
1291   __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1292 }
1293
1294
1295 /**
1296   \brief   Store-Release (16 bit)
1297   \details Executes a STLH instruction for 16 bit values.
1298   \param [in]  value  Value to store
1299   \param [in]    ptr  Pointer to location
1300  */
1301 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1302 {
1303   __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1304 }
1305
1306
1307 /**
1308   \brief   Store-Release (32 bit)
1309   \details Executes a STL instruction for 32 bit values.
1310   \param [in]  value  Value to store
1311   \param [in]    ptr  Pointer to location
1312  */
1313 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1314 {
1315   __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1316 }
1317
1318
1319 /**
1320   \brief   Load-Acquire Exclusive (8 bit)
1321   \details Executes a LDAB exclusive instruction for 8 bit value.
1322   \param [in]    ptr  Pointer to data
1323   \return             value of type uint8_t at (*ptr)
1324  */
1325 #define     __LDAEXB                 (uint8_t)__builtin_arm_ldaex
1326
1327
1328 /**
1329   \brief   Load-Acquire Exclusive (16 bit)
1330   \details Executes a LDAH exclusive instruction for 16 bit values.
1331   \param [in]    ptr  Pointer to data
1332   \return        value of type uint16_t at (*ptr)
1333  */
1334 #define     __LDAEXH                 (uint16_t)__builtin_arm_ldaex
1335
1336
1337 /**
1338   \brief   Load-Acquire Exclusive (32 bit)
1339   \details Executes a LDA exclusive instruction for 32 bit values.
1340   \param [in]    ptr  Pointer to data
1341   \return        value of type uint32_t at (*ptr)
1342  */
1343 #define     __LDAEX                  (uint32_t)__builtin_arm_ldaex
1344
1345
1346 /**
1347   \brief   Store-Release Exclusive (8 bit)
1348   \details Executes a STLB exclusive instruction for 8 bit values.
1349   \param [in]  value  Value to store
1350   \param [in]    ptr  Pointer to location
1351   \return          0  Function succeeded
1352   \return          1  Function failed
1353  */
1354 #define     __STLEXB                 (uint32_t)__builtin_arm_stlex
1355
1356
1357 /**
1358   \brief   Store-Release Exclusive (16 bit)
1359   \details Executes a STLH exclusive instruction for 16 bit values.
1360   \param [in]  value  Value to store
1361   \param [in]    ptr  Pointer to location
1362   \return          0  Function succeeded
1363   \return          1  Function failed
1364  */
1365 #define     __STLEXH                 (uint32_t)__builtin_arm_stlex
1366
1367
1368 /**
1369   \brief   Store-Release Exclusive (32 bit)
1370   \details Executes a STL exclusive instruction for 32 bit values.
1371   \param [in]  value  Value to store
1372   \param [in]    ptr  Pointer to location
1373   \return          0  Function succeeded
1374   \return          1  Function failed
1375  */
1376 #define     __STLEX                  (uint32_t)__builtin_arm_stlex
1377
1378 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1379            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1380
1381 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1382
1383
1384 /* ###################  Compiler specific Intrinsics  ########################### */
1385 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1386   Access to dedicated SIMD instructions
1387   @{
1388 */
1389
1390 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1391
1392 __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1393 {
1394   uint32_t result;
1395
1396   __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1397   return(result);
1398 }
1399
1400 __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1401 {
1402   uint32_t result;
1403
1404   __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1405   return(result);
1406 }
1407
1408 __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1409 {
1410   uint32_t result;
1411
1412   __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1413   return(result);
1414 }
1415
1416 __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1417 {
1418   uint32_t result;
1419
1420   __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1421   return(result);
1422 }
1423
1424 __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1425 {
1426   uint32_t result;
1427
1428   __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1429   return(result);
1430 }
1431
1432 __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1433 {
1434   uint32_t result;
1435
1436   __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1437   return(result);
1438 }
1439
1440
1441 __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1442 {
1443   uint32_t result;
1444
1445   __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1446   return(result);
1447 }
1448
1449 __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1450 {
1451   uint32_t result;
1452
1453   __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1454   return(result);
1455 }
1456
1457 __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1458 {
1459   uint32_t result;
1460
1461   __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1462   return(result);
1463 }
1464
1465 __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1466 {
1467   uint32_t result;
1468
1469   __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1470   return(result);
1471 }
1472
1473 __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1474 {
1475   uint32_t result;
1476
1477   __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1478   return(result);
1479 }
1480
1481 __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1482 {
1483   uint32_t result;
1484
1485   __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1486   return(result);
1487 }
1488
1489
1490 __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1491 {
1492   uint32_t result;
1493
1494   __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1495   return(result);
1496 }
1497
1498 __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1499 {
1500   uint32_t result;
1501
1502   __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1503   return(result);
1504 }
1505
1506 __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1507 {
1508   uint32_t result;
1509
1510   __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1511   return(result);
1512 }
1513
1514 __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1515 {
1516   uint32_t result;
1517
1518   __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1519   return(result);
1520 }
1521
1522 __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1523 {
1524   uint32_t result;
1525
1526   __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1527   return(result);
1528 }
1529
1530 __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1531 {
1532   uint32_t result;
1533
1534   __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1535   return(result);
1536 }
1537
1538 __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1539 {
1540   uint32_t result;
1541
1542   __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1543   return(result);
1544 }
1545
1546 __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1547 {
1548   uint32_t result;
1549
1550   __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1551   return(result);
1552 }
1553
1554 __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1555 {
1556   uint32_t result;
1557
1558   __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1559   return(result);
1560 }
1561
1562 __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1563 {
1564   uint32_t result;
1565
1566   __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1567   return(result);
1568 }
1569
1570 __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1571 {
1572   uint32_t result;
1573
1574   __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1575   return(result);
1576 }
1577
1578 __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1579 {
1580   uint32_t result;
1581
1582   __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1583   return(result);
1584 }
1585
1586 __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1587 {
1588   uint32_t result;
1589
1590   __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1591   return(result);
1592 }
1593
1594 __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1595 {
1596   uint32_t result;
1597
1598   __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1599   return(result);
1600 }
1601
1602 __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1603 {
1604   uint32_t result;
1605
1606   __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1607   return(result);
1608 }
1609
1610 __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1611 {
1612   uint32_t result;
1613
1614   __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1615   return(result);
1616 }
1617
1618 __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1619 {
1620   uint32_t result;
1621
1622   __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1623   return(result);
1624 }
1625
1626 __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1627 {
1628   uint32_t result;
1629
1630   __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1631   return(result);
1632 }
1633
1634 __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1635 {
1636   uint32_t result;
1637
1638   __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1639   return(result);
1640 }
1641
1642 __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1643 {
1644   uint32_t result;
1645
1646   __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1647   return(result);
1648 }
1649
1650 __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1651 {
1652   uint32_t result;
1653
1654   __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1655   return(result);
1656 }
1657
1658 __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1659 {
1660   uint32_t result;
1661
1662   __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1663   return(result);
1664 }
1665
1666 __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1667 {
1668   uint32_t result;
1669
1670   __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1671   return(result);
1672 }
1673
1674 __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1675 {
1676   uint32_t result;
1677
1678   __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1679   return(result);
1680 }
1681
1682 __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1683 {
1684   uint32_t result;
1685
1686   __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1687   return(result);
1688 }
1689
1690 __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1691 {
1692   uint32_t result;
1693
1694   __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1695   return(result);
1696 }
1697
1698 #define __SSAT16(ARG1,ARG2) \
1699 ({                          \
1700   int32_t __RES, __ARG1 = (ARG1); \
1701   __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1702   __RES; \
1703  })
1704
1705 #define __USAT16(ARG1,ARG2) \
1706 ({                          \
1707   uint32_t __RES, __ARG1 = (ARG1); \
1708   __ASM ("usat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1709   __RES; \
1710  })
1711
1712 __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1)
1713 {
1714   uint32_t result;
1715
1716   __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1717   return(result);
1718 }
1719
1720 __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1721 {
1722   uint32_t result;
1723
1724   __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1725   return(result);
1726 }
1727
1728 __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1)
1729 {
1730   uint32_t result;
1731
1732   __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1733   return(result);
1734 }
1735
1736 __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1737 {
1738   uint32_t result;
1739
1740   __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1741   return(result);
1742 }
1743
1744 __STATIC_FORCEINLINE uint32_t __SMUAD  (uint32_t op1, uint32_t op2)
1745 {
1746   uint32_t result;
1747
1748   __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1749   return(result);
1750 }
1751
1752 __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1753 {
1754   uint32_t result;
1755
1756   __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1757   return(result);
1758 }
1759
1760 __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1761 {
1762   uint32_t result;
1763
1764   __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1765   return(result);
1766 }
1767
1768 __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1769 {
1770   uint32_t result;
1771
1772   __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1773   return(result);
1774 }
1775
1776 __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1777 {
1778   union llreg_u{
1779     uint32_t w32[2];
1780     uint64_t w64;
1781   } llr;
1782   llr.w64 = acc;
1783
1784 #ifndef __ARMEB__   /* Little endian */
1785   __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1786 #else               /* Big endian */
1787   __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1788 #endif
1789
1790   return(llr.w64);
1791 }
1792
1793 __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1794 {
1795   union llreg_u{
1796     uint32_t w32[2];
1797     uint64_t w64;
1798   } llr;
1799   llr.w64 = acc;
1800
1801 #ifndef __ARMEB__   /* Little endian */
1802   __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1803 #else               /* Big endian */
1804   __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1805 #endif
1806
1807   return(llr.w64);
1808 }
1809
1810 __STATIC_FORCEINLINE uint32_t __SMUSD  (uint32_t op1, uint32_t op2)
1811 {
1812   uint32_t result;
1813
1814   __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1815   return(result);
1816 }
1817
1818 __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1819 {
1820   uint32_t result;
1821
1822   __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1823   return(result);
1824 }
1825
1826 __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1827 {
1828   uint32_t result;
1829
1830   __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1831   return(result);
1832 }
1833
1834 __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1835 {
1836   uint32_t result;
1837
1838   __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1839   return(result);
1840 }
1841
1842 __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1843 {
1844   union llreg_u{
1845     uint32_t w32[2];
1846     uint64_t w64;
1847   } llr;
1848   llr.w64 = acc;
1849
1850 #ifndef __ARMEB__   /* Little endian */
1851   __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1852 #else               /* Big endian */
1853   __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1854 #endif
1855
1856   return(llr.w64);
1857 }
1858
1859 __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1860 {
1861   union llreg_u{
1862     uint32_t w32[2];
1863     uint64_t w64;
1864   } llr;
1865   llr.w64 = acc;
1866
1867 #ifndef __ARMEB__   /* Little endian */
1868   __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1869 #else               /* Big endian */
1870   __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1871 #endif
1872
1873   return(llr.w64);
1874 }
1875
1876 __STATIC_FORCEINLINE uint32_t __SEL  (uint32_t op1, uint32_t op2)
1877 {
1878   uint32_t result;
1879
1880   __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1881   return(result);
1882 }
1883
1884 __STATIC_FORCEINLINE  int32_t __QADD( int32_t op1,  int32_t op2)
1885 {
1886   int32_t result;
1887
1888   __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1889   return(result);
1890 }
1891
1892 __STATIC_FORCEINLINE  int32_t __QSUB( int32_t op1,  int32_t op2)
1893 {
1894   int32_t result;
1895
1896   __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1897   return(result);
1898 }
1899
1900 #define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \
1901                                            ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )
1902
1903 #define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \
1904                                            ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )
1905
1906 #define __SXTB16_RORn(ARG1, ARG2)        __SXTB16(__ROR(ARG1, ARG2))
1907
1908 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1909
1910 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1911 {
1912   int32_t result;
1913
1914   __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r"  (op1), "r" (op2), "r" (op3) );
1915   return(result);
1916 }
1917
1918 #endif /* (__ARM_FEATURE_DSP == 1) */
1919 /*@} end of group CMSIS_SIMD_intrinsics */
1920
1921
1922 #endif /* __CMSIS_ARMCLANG_H */