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