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