]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_gcc.h
Merge branch 'develop' of https://github.com/ARM-software/CMSIS_5 into develop
[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_USE_REG(r) "l" (r)
678 #else
679 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
680 #define __CMSIS_GCC_USE_REG(r) "r" (r)
681 #endif
682
683 /**
684   \brief   No Operation
685   \details No Operation does nothing. This instruction can be used for code alignment purposes.
686  */
687 //__attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
688 //{
689 //  __ASM volatile ("nop");
690 //}
691 #define __NOP()                             __ASM volatile ("nop")       /* This implementation generates debug information */
692
693 /**
694   \brief   Wait For Interrupt
695   \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
696  */
697 //__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
698 //{
699 //  __ASM volatile ("wfi");
700 //}
701 #define __WFI()                             __ASM volatile ("wfi")       /* This implementation generates debug information */
702
703
704 /**
705   \brief   Wait For Event
706   \details Wait For Event is a hint instruction that permits the processor to enter
707            a low-power state until one of a number of events occurs.
708  */
709 //__attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
710 //{
711 //  __ASM volatile ("wfe");
712 //}
713 #define __WFE()                             __ASM volatile ("wfe")       /* This implementation generates debug information */
714
715
716 /**
717   \brief   Send Event
718   \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
719  */
720 //__attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
721 //{
722 //  __ASM volatile ("sev");
723 //}
724 #define __SEV()                             __ASM volatile ("sev")       /* This implementation generates debug information */
725
726
727 /**
728   \brief   Instruction Synchronization Barrier
729   \details Instruction Synchronization Barrier flushes the pipeline in the processor,
730            so that all instructions following the ISB are fetched from cache or memory,
731            after the instruction has been completed.
732  */
733 __attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
734 {
735   __ASM volatile ("isb 0xF":::"memory");
736 }
737
738
739 /**
740   \brief   Data Synchronization Barrier
741   \details Acts as a special kind of Data Memory Barrier.
742            It completes when all explicit memory accesses before this instruction complete.
743  */
744 __attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
745 {
746   __ASM volatile ("dsb 0xF":::"memory");
747 }
748
749
750 /**
751   \brief   Data Memory Barrier
752   \details Ensures the apparent order of the explicit memory operations before
753            and after the instruction, without ensuring their completion.
754  */
755 __attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
756 {
757   __ASM volatile ("dmb 0xF":::"memory");
758 }
759
760
761 /**
762   \brief   Reverse byte order (32 bit)
763   \details Reverses the byte order in integer value.
764   \param [in]    value  Value to reverse
765   \return               Reversed value
766  */
767 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
768 {
769 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
770   return __builtin_bswap32(value);
771 #else
772   uint32_t result;
773
774   __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
775   return(result);
776 #endif
777 }
778
779
780 /**
781   \brief   Reverse byte order (16 bit)
782   \details Reverses the byte order in two unsigned short values.
783   \param [in]    value  Value to reverse
784   \return               Reversed value
785  */
786 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
787 {
788   uint32_t result;
789
790   __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
791   return(result);
792 }
793
794
795 /**
796   \brief   Reverse byte order in signed short value
797   \details Reverses the byte order in a signed short value with sign extension to integer.
798   \param [in]    value  Value to reverse
799   \return               Reversed value
800  */
801 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
802 {
803 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
804   return (short)__builtin_bswap16(value);
805 #else
806   int32_t result;
807
808   __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
809   return(result);
810 #endif
811 }
812
813
814 /**
815   \brief   Rotate Right in unsigned value (32 bit)
816   \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
817   \param [in]    op1  Value to rotate
818   \param [in]    op2  Number of Bits to rotate
819   \return               Rotated value
820  */
821 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
822 {
823   return (op1 >> op2) | (op1 << (32U - op2));
824 }
825
826
827 /**
828   \brief   Breakpoint
829   \details Causes the processor to enter Debug state.
830            Debug tools can use this to investigate system state when the instruction at a particular address is reached.
831   \param [in]    value  is ignored by the processor.
832                  If required, a debugger can use it to store additional information about the breakpoint.
833  */
834 #define __BKPT(value)                       __ASM volatile ("bkpt "#value)
835
836
837 /**
838   \brief   Reverse bit order of value
839   \details Reverses the bit order of the given value.
840   \param [in]    value  Value to reverse
841   \return               Reversed value
842  */
843 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
844 {
845   uint32_t result;
846
847 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
848      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
849      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
850    __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
851 #else
852   int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
853
854   result = value;                      /* r will be reversed bits of v; first get LSB of v */
855   for (value >>= 1U; value; value >>= 1U)
856   {
857     result <<= 1U;
858     result |= value & 1U;
859     s--;
860   }
861   result <<= s;                        /* shift when v's highest bits are zero */
862 #endif
863   return(result);
864 }
865
866
867 /**
868   \brief   Count leading zeros
869   \details Counts the number of leading zeros of a data value.
870   \param [in]  value  Value to count the leading zeros
871   \return             number of leading zeros in value
872  */
873 #define __CLZ             __builtin_clz
874
875
876 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
877      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
878      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
879      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
880 /**
881   \brief   LDR Exclusive (8 bit)
882   \details Executes a exclusive LDR instruction for 8 bit value.
883   \param [in]    ptr  Pointer to data
884   \return             value of type uint8_t at (*ptr)
885  */
886 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
887 {
888     uint32_t result;
889
890 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
891    __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
892 #else
893     /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
894        accepted by assembler. So has to use following less efficient pattern.
895     */
896    __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
897 #endif
898    return ((uint8_t) result);    /* Add explicit type cast here */
899 }
900
901
902 /**
903   \brief   LDR Exclusive (16 bit)
904   \details Executes a exclusive LDR instruction for 16 bit values.
905   \param [in]    ptr  Pointer to data
906   \return        value of type uint16_t at (*ptr)
907  */
908 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
909 {
910     uint32_t result;
911
912 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
913    __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
914 #else
915     /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
916        accepted by assembler. So has to use following less efficient pattern.
917     */
918    __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
919 #endif
920    return ((uint16_t) result);    /* Add explicit type cast here */
921 }
922
923
924 /**
925   \brief   LDR Exclusive (32 bit)
926   \details Executes a exclusive LDR instruction for 32 bit values.
927   \param [in]    ptr  Pointer to data
928   \return        value of type uint32_t at (*ptr)
929  */
930 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
931 {
932     uint32_t result;
933
934    __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
935    return(result);
936 }
937
938
939 /**
940   \brief   STR Exclusive (8 bit)
941   \details Executes a exclusive STR instruction for 8 bit values.
942   \param [in]  value  Value to store
943   \param [in]    ptr  Pointer to location
944   \return          0  Function succeeded
945   \return          1  Function failed
946  */
947 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
948 {
949    uint32_t result;
950
951    __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
952    return(result);
953 }
954
955
956 /**
957   \brief   STR Exclusive (16 bit)
958   \details Executes a exclusive STR instruction for 16 bit values.
959   \param [in]  value  Value to store
960   \param [in]    ptr  Pointer to location
961   \return          0  Function succeeded
962   \return          1  Function failed
963  */
964 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
965 {
966    uint32_t result;
967
968    __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
969    return(result);
970 }
971
972
973 /**
974   \brief   STR Exclusive (32 bit)
975   \details Executes a exclusive STR instruction for 32 bit values.
976   \param [in]  value  Value to store
977   \param [in]    ptr  Pointer to location
978   \return          0  Function succeeded
979   \return          1  Function failed
980  */
981 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
982 {
983    uint32_t result;
984
985    __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
986    return(result);
987 }
988
989
990 /**
991   \brief   Remove the exclusive lock
992   \details Removes the exclusive lock which is created by LDREX.
993  */
994 __attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
995 {
996   __ASM volatile ("clrex" ::: "memory");
997 }
998
999
1000 /**
1001   \brief   Signed Saturate
1002   \details Saturates a signed value.
1003   \param [in]  value  Value to be saturated
1004   \param [in]    sat  Bit position to saturate to (1..32)
1005   \return             Saturated value
1006  */
1007 #define __SSAT(ARG1,ARG2) \
1008 ({                          \
1009   int32_t __RES, __ARG1 = (ARG1); \
1010   __ASM ("ssat %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1011   __RES; \
1012  })
1013
1014
1015 /**
1016   \brief   Unsigned Saturate
1017   \details Saturates an unsigned value.
1018   \param [in]  value  Value to be saturated
1019   \param [in]    sat  Bit position to saturate to (0..31)
1020   \return             Saturated value
1021  */
1022 #define __USAT(ARG1,ARG2) \
1023 ({                          \
1024   uint32_t __RES, __ARG1 = (ARG1); \
1025   __ASM ("usat %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1026   __RES; \
1027  })
1028
1029
1030 /**
1031   \brief   Rotate Right with Extend (32 bit)
1032   \details Moves each bit of a bitstring right by one bit.
1033            The carry input is shifted in at the left end of the bitstring.
1034   \param [in]    value  Value to rotate
1035   \return               Rotated value
1036  */
1037 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1038 {
1039   uint32_t result;
1040
1041   __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1042   return(result);
1043 }
1044
1045
1046 /**
1047   \brief   LDRT Unprivileged (8 bit)
1048   \details Executes a Unprivileged LDRT instruction for 8 bit value.
1049   \param [in]    ptr  Pointer to data
1050   \return             value of type uint8_t at (*ptr)
1051  */
1052 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1053 {
1054     uint32_t result;
1055
1056 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1057    __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1058 #else
1059     /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1060        accepted by assembler. So has to use following less efficient pattern.
1061     */
1062    __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1063 #endif
1064    return ((uint8_t) result);    /* Add explicit type cast here */
1065 }
1066
1067
1068 /**
1069   \brief   LDRT Unprivileged (16 bit)
1070   \details Executes a Unprivileged LDRT instruction for 16 bit values.
1071   \param [in]    ptr  Pointer to data
1072   \return        value of type uint16_t at (*ptr)
1073  */
1074 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1075 {
1076     uint32_t result;
1077
1078 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1079    __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1080 #else
1081     /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1082        accepted by assembler. So has to use following less efficient pattern.
1083     */
1084    __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1085 #endif
1086    return ((uint16_t) result);    /* Add explicit type cast here */
1087 }
1088
1089
1090 /**
1091   \brief   LDRT Unprivileged (32 bit)
1092   \details Executes a Unprivileged LDRT instruction for 32 bit values.
1093   \param [in]    ptr  Pointer to data
1094   \return        value of type uint32_t at (*ptr)
1095  */
1096 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1097 {
1098     uint32_t result;
1099
1100    __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1101    return(result);
1102 }
1103
1104
1105 /**
1106   \brief   STRT Unprivileged (8 bit)
1107   \details Executes a Unprivileged STRT instruction for 8 bit values.
1108   \param [in]  value  Value to store
1109   \param [in]    ptr  Pointer to location
1110  */
1111 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1112 {
1113    __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1114 }
1115
1116
1117 /**
1118   \brief   STRT Unprivileged (16 bit)
1119   \details Executes a Unprivileged STRT instruction for 16 bit values.
1120   \param [in]  value  Value to store
1121   \param [in]    ptr  Pointer to location
1122  */
1123 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1124 {
1125    __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1126 }
1127
1128
1129 /**
1130   \brief   STRT Unprivileged (32 bit)
1131   \details Executes a Unprivileged STRT instruction for 32 bit values.
1132   \param [in]  value  Value to store
1133   \param [in]    ptr  Pointer to location
1134  */
1135 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1136 {
1137    __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1138 }
1139
1140 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1141            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1142            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1143            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1144
1145
1146 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1147      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
1148 /**
1149   \brief   Load-Acquire (8 bit)
1150   \details Executes a LDAB instruction for 8 bit value.
1151   \param [in]    ptr  Pointer to data
1152   \return             value of type uint8_t at (*ptr)
1153  */
1154 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1155 {
1156     uint32_t result;
1157
1158    __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1159    return ((uint8_t) result);
1160 }
1161
1162
1163 /**
1164   \brief   Load-Acquire (16 bit)
1165   \details Executes a LDAH instruction for 16 bit values.
1166   \param [in]    ptr  Pointer to data
1167   \return        value of type uint16_t at (*ptr)
1168  */
1169 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1170 {
1171     uint32_t result;
1172
1173    __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1174    return ((uint16_t) result);
1175 }
1176
1177
1178 /**
1179   \brief   Load-Acquire (32 bit)
1180   \details Executes a LDA instruction for 32 bit values.
1181   \param [in]    ptr  Pointer to data
1182   \return        value of type uint32_t at (*ptr)
1183  */
1184 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1185 {
1186     uint32_t result;
1187
1188    __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1189    return(result);
1190 }
1191
1192
1193 /**
1194   \brief   Store-Release (8 bit)
1195   \details Executes a STLB instruction for 8 bit values.
1196   \param [in]  value  Value to store
1197   \param [in]    ptr  Pointer to location
1198  */
1199 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1200 {
1201    __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1202 }
1203
1204
1205 /**
1206   \brief   Store-Release (16 bit)
1207   \details Executes a STLH instruction for 16 bit values.
1208   \param [in]  value  Value to store
1209   \param [in]    ptr  Pointer to location
1210  */
1211 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1212 {
1213    __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1214 }
1215
1216
1217 /**
1218   \brief   Store-Release (32 bit)
1219   \details Executes a STL instruction for 32 bit values.
1220   \param [in]  value  Value to store
1221   \param [in]    ptr  Pointer to location
1222  */
1223 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1224 {
1225    __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1226 }
1227
1228
1229 /**
1230   \brief   Load-Acquire Exclusive (8 bit)
1231   \details Executes a LDAB exclusive instruction for 8 bit value.
1232   \param [in]    ptr  Pointer to data
1233   \return             value of type uint8_t at (*ptr)
1234  */
1235 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1236 {
1237     uint32_t result;
1238
1239    __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1240    return ((uint8_t) result);
1241 }
1242
1243
1244 /**
1245   \brief   Load-Acquire Exclusive (16 bit)
1246   \details Executes a LDAH exclusive instruction for 16 bit values.
1247   \param [in]    ptr  Pointer to data
1248   \return        value of type uint16_t at (*ptr)
1249  */
1250 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1251 {
1252     uint32_t result;
1253
1254    __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1255    return ((uint16_t) result);
1256 }
1257
1258
1259 /**
1260   \brief   Load-Acquire Exclusive (32 bit)
1261   \details Executes a LDA exclusive instruction for 32 bit values.
1262   \param [in]    ptr  Pointer to data
1263   \return        value of type uint32_t at (*ptr)
1264  */
1265 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1266 {
1267     uint32_t result;
1268
1269    __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1270    return(result);
1271 }
1272
1273
1274 /**
1275   \brief   Store-Release Exclusive (8 bit)
1276   \details Executes a STLB exclusive instruction for 8 bit values.
1277   \param [in]  value  Value to store
1278   \param [in]    ptr  Pointer to location
1279   \return          0  Function succeeded
1280   \return          1  Function failed
1281  */
1282 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1283 {
1284    uint32_t result;
1285
1286    __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1287    return(result);
1288 }
1289
1290
1291 /**
1292   \brief   Store-Release Exclusive (16 bit)
1293   \details Executes a STLH exclusive instruction for 16 bit values.
1294   \param [in]  value  Value to store
1295   \param [in]    ptr  Pointer to location
1296   \return          0  Function succeeded
1297   \return          1  Function failed
1298  */
1299 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1300 {
1301    uint32_t result;
1302
1303    __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1304    return(result);
1305 }
1306
1307
1308 /**
1309   \brief   Store-Release Exclusive (32 bit)
1310   \details Executes a STL exclusive instruction for 32 bit values.
1311   \param [in]  value  Value to store
1312   \param [in]    ptr  Pointer to location
1313   \return          0  Function succeeded
1314   \return          1  Function failed
1315  */
1316 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1317 {
1318    uint32_t result;
1319
1320    __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1321    return(result);
1322 }
1323
1324 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1325            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1326
1327 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1328
1329
1330 /* ###################  Compiler specific Intrinsics  ########################### */
1331 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1332   Access to dedicated SIMD instructions
1333   @{
1334 */
1335
1336 #if (__ARM_FEATURE_DSP == 1)                             /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1337
1338 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1339 {
1340   uint32_t result;
1341
1342   __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1343   return(result);
1344 }
1345
1346 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1347 {
1348   uint32_t result;
1349
1350   __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1351   return(result);
1352 }
1353
1354 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1355 {
1356   uint32_t result;
1357
1358   __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1359   return(result);
1360 }
1361
1362 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1363 {
1364   uint32_t result;
1365
1366   __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1367   return(result);
1368 }
1369
1370 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1371 {
1372   uint32_t result;
1373
1374   __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1375   return(result);
1376 }
1377
1378 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1379 {
1380   uint32_t result;
1381
1382   __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1383   return(result);
1384 }
1385
1386
1387 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1388 {
1389   uint32_t result;
1390
1391   __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392   return(result);
1393 }
1394
1395 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1396 {
1397   uint32_t result;
1398
1399   __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1400   return(result);
1401 }
1402
1403 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1404 {
1405   uint32_t result;
1406
1407   __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1408   return(result);
1409 }
1410
1411 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1412 {
1413   uint32_t result;
1414
1415   __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1416   return(result);
1417 }
1418
1419 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1420 {
1421   uint32_t result;
1422
1423   __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1424   return(result);
1425 }
1426
1427 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1428 {
1429   uint32_t result;
1430
1431   __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1432   return(result);
1433 }
1434
1435
1436 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1437 {
1438   uint32_t result;
1439
1440   __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441   return(result);
1442 }
1443
1444 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1445 {
1446   uint32_t result;
1447
1448   __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1449   return(result);
1450 }
1451
1452 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1453 {
1454   uint32_t result;
1455
1456   __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1457   return(result);
1458 }
1459
1460 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1461 {
1462   uint32_t result;
1463
1464   __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1465   return(result);
1466 }
1467
1468 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1469 {
1470   uint32_t result;
1471
1472   __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1473   return(result);
1474 }
1475
1476 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1477 {
1478   uint32_t result;
1479
1480   __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1481   return(result);
1482 }
1483
1484 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1485 {
1486   uint32_t result;
1487
1488   __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1489   return(result);
1490 }
1491
1492 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1493 {
1494   uint32_t result;
1495
1496   __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1497   return(result);
1498 }
1499
1500 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1501 {
1502   uint32_t result;
1503
1504   __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1505   return(result);
1506 }
1507
1508 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1509 {
1510   uint32_t result;
1511
1512   __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1513   return(result);
1514 }
1515
1516 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1517 {
1518   uint32_t result;
1519
1520   __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1521   return(result);
1522 }
1523
1524 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1525 {
1526   uint32_t result;
1527
1528   __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1529   return(result);
1530 }
1531
1532 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1533 {
1534   uint32_t result;
1535
1536   __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1537   return(result);
1538 }
1539
1540 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1541 {
1542   uint32_t result;
1543
1544   __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1545   return(result);
1546 }
1547
1548 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1549 {
1550   uint32_t result;
1551
1552   __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1553   return(result);
1554 }
1555
1556 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1557 {
1558   uint32_t result;
1559
1560   __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1561   return(result);
1562 }
1563
1564 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1565 {
1566   uint32_t result;
1567
1568   __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1569   return(result);
1570 }
1571
1572 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1573 {
1574   uint32_t result;
1575
1576   __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1577   return(result);
1578 }
1579
1580 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1581 {
1582   uint32_t result;
1583
1584   __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1585   return(result);
1586 }
1587
1588 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1589 {
1590   uint32_t result;
1591
1592   __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1593   return(result);
1594 }
1595
1596 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1597 {
1598   uint32_t result;
1599
1600   __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1601   return(result);
1602 }
1603
1604 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1605 {
1606   uint32_t result;
1607
1608   __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1609   return(result);
1610 }
1611
1612 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1613 {
1614   uint32_t result;
1615
1616   __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1617   return(result);
1618 }
1619
1620 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1621 {
1622   uint32_t result;
1623
1624   __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1625   return(result);
1626 }
1627
1628 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1629 {
1630   uint32_t result;
1631
1632   __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1633   return(result);
1634 }
1635
1636 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1637 {
1638   uint32_t result;
1639
1640   __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1641   return(result);
1642 }
1643
1644 #define __SSAT16(ARG1,ARG2) \
1645 ({                          \
1646   int32_t __RES, __ARG1 = (ARG1); \
1647   __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1648   __RES; \
1649  })
1650
1651 #define __USAT16(ARG1,ARG2) \
1652 ({                          \
1653   uint32_t __RES, __ARG1 = (ARG1); \
1654   __ASM ("usat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1655   __RES; \
1656  })
1657
1658 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1659 {
1660   uint32_t result;
1661
1662   __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1663   return(result);
1664 }
1665
1666 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1667 {
1668   uint32_t result;
1669
1670   __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1671   return(result);
1672 }
1673
1674 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1675 {
1676   uint32_t result;
1677
1678   __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1679   return(result);
1680 }
1681
1682 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1683 {
1684   uint32_t result;
1685
1686   __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1687   return(result);
1688 }
1689
1690 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD  (uint32_t op1, uint32_t op2)
1691 {
1692   uint32_t result;
1693
1694   __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1695   return(result);
1696 }
1697
1698 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1699 {
1700   uint32_t result;
1701
1702   __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1703   return(result);
1704 }
1705
1706 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1707 {
1708   uint32_t result;
1709
1710   __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1711   return(result);
1712 }
1713
1714 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1715 {
1716   uint32_t result;
1717
1718   __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1719   return(result);
1720 }
1721
1722 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1723 {
1724   union llreg_u{
1725     uint32_t w32[2];
1726     uint64_t w64;
1727   } llr;
1728   llr.w64 = acc;
1729
1730 #ifndef __ARMEB__   /* Little endian */
1731   __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]) );
1732 #else               /* Big endian */
1733   __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]) );
1734 #endif
1735
1736   return(llr.w64);
1737 }
1738
1739 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1740 {
1741   union llreg_u{
1742     uint32_t w32[2];
1743     uint64_t w64;
1744   } llr;
1745   llr.w64 = acc;
1746
1747 #ifndef __ARMEB__   /* Little endian */
1748   __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]) );
1749 #else               /* Big endian */
1750   __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]) );
1751 #endif
1752
1753   return(llr.w64);
1754 }
1755
1756 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD  (uint32_t op1, uint32_t op2)
1757 {
1758   uint32_t result;
1759
1760   __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1761   return(result);
1762 }
1763
1764 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1765 {
1766   uint32_t result;
1767
1768   __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1769   return(result);
1770 }
1771
1772 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1773 {
1774   uint32_t result;
1775
1776   __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1777   return(result);
1778 }
1779
1780 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1781 {
1782   uint32_t result;
1783
1784   __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1785   return(result);
1786 }
1787
1788 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1789 {
1790   union llreg_u{
1791     uint32_t w32[2];
1792     uint64_t w64;
1793   } llr;
1794   llr.w64 = acc;
1795
1796 #ifndef __ARMEB__   /* Little endian */
1797   __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]) );
1798 #else               /* Big endian */
1799   __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]) );
1800 #endif
1801
1802   return(llr.w64);
1803 }
1804
1805 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1806 {
1807   union llreg_u{
1808     uint32_t w32[2];
1809     uint64_t w64;
1810   } llr;
1811   llr.w64 = acc;
1812
1813 #ifndef __ARMEB__   /* Little endian */
1814   __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]) );
1815 #else               /* Big endian */
1816   __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]) );
1817 #endif
1818
1819   return(llr.w64);
1820 }
1821
1822 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL  (uint32_t op1, uint32_t op2)
1823 {
1824   uint32_t result;
1825
1826   __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1827   return(result);
1828 }
1829
1830 __attribute__((always_inline)) __STATIC_INLINE  int32_t __QADD( int32_t op1,  int32_t op2)
1831 {
1832   int32_t result;
1833
1834   __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1835   return(result);
1836 }
1837
1838 __attribute__((always_inline)) __STATIC_INLINE  int32_t __QSUB( int32_t op1,  int32_t op2)
1839 {
1840   int32_t result;
1841
1842   __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1843   return(result);
1844 }
1845
1846 #if 0
1847 #define __PKHBT(ARG1,ARG2,ARG3) \
1848 ({                          \
1849   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1850   __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1851   __RES; \
1852  })
1853
1854 #define __PKHTB(ARG1,ARG2,ARG3) \
1855 ({                          \
1856   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1857   if (ARG3 == 0) \
1858     __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2)  ); \
1859   else \
1860     __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1861   __RES; \
1862  })
1863 #endif
1864
1865 #define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \
1866                                            ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )
1867
1868 #define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \
1869                                            ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )
1870
1871 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1872 {
1873  int32_t result;
1874
1875  __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r"  (op1), "r" (op2), "r" (op3) );
1876  return(result);
1877 }
1878
1879 #endif /* (__ARM_FEATURE_DSP == 1) */
1880 /*@} end of group CMSIS_SIMD_intrinsics */
1881
1882
1883 #pragma GCC diagnostic pop
1884
1885 #endif /* __CMSIS_GCC_H */