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