]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_gcc.h
5.0.1-dev1: http:// removed. PACK schema relaxed
[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     28. October 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  * 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 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1002            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1003            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1004            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1005
1006
1007 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1008      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1009      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
1010 /**
1011   \brief   Signed Saturate
1012   \details Saturates a signed value.
1013   \param [in]  value  Value to be saturated
1014   \param [in]    sat  Bit position to saturate to (1..32)
1015   \return             Saturated value
1016  */
1017 #define __SSAT(ARG1,ARG2) \
1018 ({                          \
1019   int32_t __RES, __ARG1 = (ARG1); \
1020   __ASM ("ssat %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1021   __RES; \
1022  })
1023
1024
1025 /**
1026   \brief   Unsigned Saturate
1027   \details Saturates an unsigned value.
1028   \param [in]  value  Value to be saturated
1029   \param [in]    sat  Bit position to saturate to (0..31)
1030   \return             Saturated value
1031  */
1032 #define __USAT(ARG1,ARG2) \
1033 ({                          \
1034   uint32_t __RES, __ARG1 = (ARG1); \
1035   __ASM ("usat %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1036   __RES; \
1037  })
1038
1039
1040 /**
1041   \brief   Rotate Right with Extend (32 bit)
1042   \details Moves each bit of a bitstring right by one bit.
1043            The carry input is shifted in at the left end of the bitstring.
1044   \param [in]    value  Value to rotate
1045   \return               Rotated value
1046  */
1047 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1048 {
1049   uint32_t result;
1050
1051   __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1052   return(result);
1053 }
1054
1055
1056 /**
1057   \brief   LDRT Unprivileged (8 bit)
1058   \details Executes a Unprivileged LDRT instruction for 8 bit value.
1059   \param [in]    ptr  Pointer to data
1060   \return             value of type uint8_t at (*ptr)
1061  */
1062 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1063 {
1064     uint32_t result;
1065
1066 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1067    __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1068 #else
1069     /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1070        accepted by assembler. So has to use following less efficient pattern.
1071     */
1072    __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1073 #endif
1074    return ((uint8_t) result);    /* Add explicit type cast here */
1075 }
1076
1077
1078 /**
1079   \brief   LDRT Unprivileged (16 bit)
1080   \details Executes a Unprivileged LDRT instruction for 16 bit values.
1081   \param [in]    ptr  Pointer to data
1082   \return        value of type uint16_t at (*ptr)
1083  */
1084 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1085 {
1086     uint32_t result;
1087
1088 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1089    __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1090 #else
1091     /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1092        accepted by assembler. So has to use following less efficient pattern.
1093     */
1094    __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1095 #endif
1096    return ((uint16_t) result);    /* Add explicit type cast here */
1097 }
1098
1099
1100 /**
1101   \brief   LDRT Unprivileged (32 bit)
1102   \details Executes a Unprivileged LDRT instruction for 32 bit values.
1103   \param [in]    ptr  Pointer to data
1104   \return        value of type uint32_t at (*ptr)
1105  */
1106 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1107 {
1108     uint32_t result;
1109
1110    __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1111    return(result);
1112 }
1113
1114
1115 /**
1116   \brief   STRT Unprivileged (8 bit)
1117   \details Executes a Unprivileged STRT instruction for 8 bit values.
1118   \param [in]  value  Value to store
1119   \param [in]    ptr  Pointer to location
1120  */
1121 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1122 {
1123    __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1124 }
1125
1126
1127 /**
1128   \brief   STRT Unprivileged (16 bit)
1129   \details Executes a Unprivileged STRT instruction for 16 bit values.
1130   \param [in]  value  Value to store
1131   \param [in]    ptr  Pointer to location
1132  */
1133 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1134 {
1135    __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1136 }
1137
1138
1139 /**
1140   \brief   STRT Unprivileged (32 bit)
1141   \details Executes a Unprivileged STRT instruction for 32 bit values.
1142   \param [in]  value  Value to store
1143   \param [in]    ptr  Pointer to location
1144  */
1145 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1146 {
1147    __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1148 }
1149
1150 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1151            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1152            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
1153
1154
1155 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1156      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
1157 /**
1158   \brief   Load-Acquire (8 bit)
1159   \details Executes a LDAB instruction for 8 bit value.
1160   \param [in]    ptr  Pointer to data
1161   \return             value of type uint8_t at (*ptr)
1162  */
1163 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1164 {
1165     uint32_t result;
1166
1167    __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1168    return ((uint8_t) result);
1169 }
1170
1171
1172 /**
1173   \brief   Load-Acquire (16 bit)
1174   \details Executes a LDAH instruction for 16 bit values.
1175   \param [in]    ptr  Pointer to data
1176   \return        value of type uint16_t at (*ptr)
1177  */
1178 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1179 {
1180     uint32_t result;
1181
1182    __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1183    return ((uint16_t) result);
1184 }
1185
1186
1187 /**
1188   \brief   Load-Acquire (32 bit)
1189   \details Executes a LDA instruction for 32 bit values.
1190   \param [in]    ptr  Pointer to data
1191   \return        value of type uint32_t at (*ptr)
1192  */
1193 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1194 {
1195     uint32_t result;
1196
1197    __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1198    return(result);
1199 }
1200
1201
1202 /**
1203   \brief   Store-Release (8 bit)
1204   \details Executes a STLB instruction for 8 bit values.
1205   \param [in]  value  Value to store
1206   \param [in]    ptr  Pointer to location
1207  */
1208 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1209 {
1210    __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1211 }
1212
1213
1214 /**
1215   \brief   Store-Release (16 bit)
1216   \details Executes a STLH instruction for 16 bit values.
1217   \param [in]  value  Value to store
1218   \param [in]    ptr  Pointer to location
1219  */
1220 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1221 {
1222    __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1223 }
1224
1225
1226 /**
1227   \brief   Store-Release (32 bit)
1228   \details Executes a STL instruction for 32 bit values.
1229   \param [in]  value  Value to store
1230   \param [in]    ptr  Pointer to location
1231  */
1232 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1233 {
1234    __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1235 }
1236
1237
1238 /**
1239   \brief   Load-Acquire Exclusive (8 bit)
1240   \details Executes a LDAB exclusive instruction for 8 bit value.
1241   \param [in]    ptr  Pointer to data
1242   \return             value of type uint8_t at (*ptr)
1243  */
1244 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1245 {
1246     uint32_t result;
1247
1248    __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1249    return ((uint8_t) result);
1250 }
1251
1252
1253 /**
1254   \brief   Load-Acquire Exclusive (16 bit)
1255   \details Executes a LDAH exclusive instruction for 16 bit values.
1256   \param [in]    ptr  Pointer to data
1257   \return        value of type uint16_t at (*ptr)
1258  */
1259 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1260 {
1261     uint32_t result;
1262
1263    __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1264    return ((uint16_t) result);
1265 }
1266
1267
1268 /**
1269   \brief   Load-Acquire Exclusive (32 bit)
1270   \details Executes a LDA exclusive instruction for 32 bit values.
1271   \param [in]    ptr  Pointer to data
1272   \return        value of type uint32_t at (*ptr)
1273  */
1274 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1275 {
1276     uint32_t result;
1277
1278    __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1279    return(result);
1280 }
1281
1282
1283 /**
1284   \brief   Store-Release Exclusive (8 bit)
1285   \details Executes a STLB exclusive instruction for 8 bit values.
1286   \param [in]  value  Value to store
1287   \param [in]    ptr  Pointer to location
1288   \return          0  Function succeeded
1289   \return          1  Function failed
1290  */
1291 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1292 {
1293    uint32_t result;
1294
1295    __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1296    return(result);
1297 }
1298
1299
1300 /**
1301   \brief   Store-Release Exclusive (16 bit)
1302   \details Executes a STLH exclusive instruction for 16 bit values.
1303   \param [in]  value  Value to store
1304   \param [in]    ptr  Pointer to location
1305   \return          0  Function succeeded
1306   \return          1  Function failed
1307  */
1308 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1309 {
1310    uint32_t result;
1311
1312    __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1313    return(result);
1314 }
1315
1316
1317 /**
1318   \brief   Store-Release Exclusive (32 bit)
1319   \details Executes a STL exclusive instruction for 32 bit values.
1320   \param [in]  value  Value to store
1321   \param [in]    ptr  Pointer to location
1322   \return          0  Function succeeded
1323   \return          1  Function failed
1324  */
1325 __attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1326 {
1327    uint32_t result;
1328
1329    __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1330    return(result);
1331 }
1332
1333 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1334            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1335
1336 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1337
1338
1339 /* ###################  Compiler specific Intrinsics  ########################### */
1340 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1341   Access to dedicated SIMD instructions
1342   @{
1343 */
1344
1345 #if (__ARM_FEATURE_DSP == 1)                             /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1346
1347 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1348 {
1349   uint32_t result;
1350
1351   __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1352   return(result);
1353 }
1354
1355 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1356 {
1357   uint32_t result;
1358
1359   __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1360   return(result);
1361 }
1362
1363 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1364 {
1365   uint32_t result;
1366
1367   __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1368   return(result);
1369 }
1370
1371 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1372 {
1373   uint32_t result;
1374
1375   __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1376   return(result);
1377 }
1378
1379 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1380 {
1381   uint32_t result;
1382
1383   __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1384   return(result);
1385 }
1386
1387 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1388 {
1389   uint32_t result;
1390
1391   __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1392   return(result);
1393 }
1394
1395
1396 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1397 {
1398   uint32_t result;
1399
1400   __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1401   return(result);
1402 }
1403
1404 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1405 {
1406   uint32_t result;
1407
1408   __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1409   return(result);
1410 }
1411
1412 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1413 {
1414   uint32_t result;
1415
1416   __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1417   return(result);
1418 }
1419
1420 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1421 {
1422   uint32_t result;
1423
1424   __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1425   return(result);
1426 }
1427
1428 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1429 {
1430   uint32_t result;
1431
1432   __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1433   return(result);
1434 }
1435
1436 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1437 {
1438   uint32_t result;
1439
1440   __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1441   return(result);
1442 }
1443
1444
1445 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1446 {
1447   uint32_t result;
1448
1449   __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1450   return(result);
1451 }
1452
1453 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1454 {
1455   uint32_t result;
1456
1457   __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1458   return(result);
1459 }
1460
1461 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1462 {
1463   uint32_t result;
1464
1465   __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1466   return(result);
1467 }
1468
1469 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1470 {
1471   uint32_t result;
1472
1473   __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1474   return(result);
1475 }
1476
1477 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1478 {
1479   uint32_t result;
1480
1481   __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1482   return(result);
1483 }
1484
1485 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1486 {
1487   uint32_t result;
1488
1489   __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1490   return(result);
1491 }
1492
1493 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1494 {
1495   uint32_t result;
1496
1497   __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1498   return(result);
1499 }
1500
1501 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1502 {
1503   uint32_t result;
1504
1505   __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1506   return(result);
1507 }
1508
1509 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1510 {
1511   uint32_t result;
1512
1513   __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1514   return(result);
1515 }
1516
1517 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1518 {
1519   uint32_t result;
1520
1521   __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1522   return(result);
1523 }
1524
1525 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1526 {
1527   uint32_t result;
1528
1529   __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1530   return(result);
1531 }
1532
1533 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1534 {
1535   uint32_t result;
1536
1537   __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1538   return(result);
1539 }
1540
1541 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1542 {
1543   uint32_t result;
1544
1545   __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1546   return(result);
1547 }
1548
1549 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1550 {
1551   uint32_t result;
1552
1553   __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1554   return(result);
1555 }
1556
1557 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1558 {
1559   uint32_t result;
1560
1561   __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1562   return(result);
1563 }
1564
1565 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1566 {
1567   uint32_t result;
1568
1569   __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1570   return(result);
1571 }
1572
1573 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1574 {
1575   uint32_t result;
1576
1577   __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1578   return(result);
1579 }
1580
1581 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1582 {
1583   uint32_t result;
1584
1585   __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1586   return(result);
1587 }
1588
1589 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1590 {
1591   uint32_t result;
1592
1593   __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1594   return(result);
1595 }
1596
1597 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1598 {
1599   uint32_t result;
1600
1601   __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1602   return(result);
1603 }
1604
1605 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1606 {
1607   uint32_t result;
1608
1609   __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1610   return(result);
1611 }
1612
1613 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1614 {
1615   uint32_t result;
1616
1617   __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1618   return(result);
1619 }
1620
1621 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1622 {
1623   uint32_t result;
1624
1625   __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1626   return(result);
1627 }
1628
1629 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1630 {
1631   uint32_t result;
1632
1633   __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1634   return(result);
1635 }
1636
1637 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1638 {
1639   uint32_t result;
1640
1641   __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1642   return(result);
1643 }
1644
1645 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1646 {
1647   uint32_t result;
1648
1649   __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1650   return(result);
1651 }
1652
1653 #define __SSAT16(ARG1,ARG2) \
1654 ({                          \
1655   int32_t __RES, __ARG1 = (ARG1); \
1656   __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1657   __RES; \
1658  })
1659
1660 #define __USAT16(ARG1,ARG2) \
1661 ({                          \
1662   uint32_t __RES, __ARG1 = (ARG1); \
1663   __ASM ("usat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1664   __RES; \
1665  })
1666
1667 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1668 {
1669   uint32_t result;
1670
1671   __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1672   return(result);
1673 }
1674
1675 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1676 {
1677   uint32_t result;
1678
1679   __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1680   return(result);
1681 }
1682
1683 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1684 {
1685   uint32_t result;
1686
1687   __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1688   return(result);
1689 }
1690
1691 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1692 {
1693   uint32_t result;
1694
1695   __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1696   return(result);
1697 }
1698
1699 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD  (uint32_t op1, uint32_t op2)
1700 {
1701   uint32_t result;
1702
1703   __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1704   return(result);
1705 }
1706
1707 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1708 {
1709   uint32_t result;
1710
1711   __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1712   return(result);
1713 }
1714
1715 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1716 {
1717   uint32_t result;
1718
1719   __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1720   return(result);
1721 }
1722
1723 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1724 {
1725   uint32_t result;
1726
1727   __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1728   return(result);
1729 }
1730
1731 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1732 {
1733   union llreg_u{
1734     uint32_t w32[2];
1735     uint64_t w64;
1736   } llr;
1737   llr.w64 = acc;
1738
1739 #ifndef __ARMEB__   /* Little endian */
1740   __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]) );
1741 #else               /* Big endian */
1742   __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]) );
1743 #endif
1744
1745   return(llr.w64);
1746 }
1747
1748 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1749 {
1750   union llreg_u{
1751     uint32_t w32[2];
1752     uint64_t w64;
1753   } llr;
1754   llr.w64 = acc;
1755
1756 #ifndef __ARMEB__   /* Little endian */
1757   __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]) );
1758 #else               /* Big endian */
1759   __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]) );
1760 #endif
1761
1762   return(llr.w64);
1763 }
1764
1765 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD  (uint32_t op1, uint32_t op2)
1766 {
1767   uint32_t result;
1768
1769   __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1770   return(result);
1771 }
1772
1773 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1774 {
1775   uint32_t result;
1776
1777   __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1778   return(result);
1779 }
1780
1781 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1782 {
1783   uint32_t result;
1784
1785   __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1786   return(result);
1787 }
1788
1789 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1790 {
1791   uint32_t result;
1792
1793   __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1794   return(result);
1795 }
1796
1797 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1798 {
1799   union llreg_u{
1800     uint32_t w32[2];
1801     uint64_t w64;
1802   } llr;
1803   llr.w64 = acc;
1804
1805 #ifndef __ARMEB__   /* Little endian */
1806   __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]) );
1807 #else               /* Big endian */
1808   __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]) );
1809 #endif
1810
1811   return(llr.w64);
1812 }
1813
1814 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1815 {
1816   union llreg_u{
1817     uint32_t w32[2];
1818     uint64_t w64;
1819   } llr;
1820   llr.w64 = acc;
1821
1822 #ifndef __ARMEB__   /* Little endian */
1823   __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]) );
1824 #else               /* Big endian */
1825   __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]) );
1826 #endif
1827
1828   return(llr.w64);
1829 }
1830
1831 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL  (uint32_t op1, uint32_t op2)
1832 {
1833   uint32_t result;
1834
1835   __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1836   return(result);
1837 }
1838
1839 __attribute__((always_inline)) __STATIC_INLINE  int32_t __QADD( int32_t op1,  int32_t op2)
1840 {
1841   int32_t result;
1842
1843   __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1844   return(result);
1845 }
1846
1847 __attribute__((always_inline)) __STATIC_INLINE  int32_t __QSUB( int32_t op1,  int32_t op2)
1848 {
1849   int32_t result;
1850
1851   __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1852   return(result);
1853 }
1854
1855 #if 0
1856 #define __PKHBT(ARG1,ARG2,ARG3) \
1857 ({                          \
1858   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1859   __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1860   __RES; \
1861  })
1862
1863 #define __PKHTB(ARG1,ARG2,ARG3) \
1864 ({                          \
1865   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1866   if (ARG3 == 0) \
1867     __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2)  ); \
1868   else \
1869     __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1870   __RES; \
1871  })
1872 #endif
1873
1874 #define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \
1875                                            ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )
1876
1877 #define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \
1878                                            ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )
1879
1880 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1881 {
1882  int32_t result;
1883
1884  __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r"  (op1), "r" (op2), "r" (op3) );
1885  return(result);
1886 }
1887
1888 #endif /* (__ARM_FEATURE_DSP == 1) */
1889 /*@} end of group CMSIS_SIMD_intrinsics */
1890
1891
1892 #pragma GCC diagnostic pop
1893
1894 #endif /* __CMSIS_GCC_H */