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