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