]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/CMSIS/cmsis_armclang.h
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso / NXP_Code / CMSIS / cmsis_armclang.h
1 /**************************************************************************//**\r
2  * @file     cmsis_armclang.h\r
3  * @brief    CMSIS compiler armclang (Arm Compiler 6) header file\r
4  * @version  V5.1.0\r
5  * @date     14. March 2019\r
6  ******************************************************************************/\r
7 /*\r
8  * Copyright (c) 2009-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_RW_REG(r) "+l" (r)\r
785 #define __CMSIS_GCC_USE_REG(r) "l" (r)\r
786 #else\r
787 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)\r
788 #define __CMSIS_GCC_RW_REG(r) "+r" (r)\r
789 #define __CMSIS_GCC_USE_REG(r) "r" (r)\r
790 #endif\r
791 \r
792 /**\r
793   \brief   No Operation\r
794   \details No Operation does nothing. This instruction can be used for code alignment purposes.\r
795  */\r
796 #define __NOP          __builtin_arm_nop\r
797 \r
798 /**\r
799   \brief   Wait For Interrupt\r
800   \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.\r
801  */\r
802 #define __WFI          __builtin_arm_wfi\r
803 \r
804 \r
805 /**\r
806   \brief   Wait For Event\r
807   \details Wait For Event is a hint instruction that permits the processor to enter\r
808            a low-power state until one of a number of events occurs.\r
809  */\r
810 #define __WFE          __builtin_arm_wfe\r
811 \r
812 \r
813 /**\r
814   \brief   Send Event\r
815   \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.\r
816  */\r
817 #define __SEV          __builtin_arm_sev\r
818 \r
819 \r
820 /**\r
821   \brief   Instruction Synchronization Barrier\r
822   \details Instruction Synchronization Barrier flushes the pipeline in the processor,\r
823            so that all instructions following the ISB are fetched from cache or memory,\r
824            after the instruction has been completed.\r
825  */\r
826 #define __ISB()        __builtin_arm_isb(0xF)\r
827 \r
828 /**\r
829   \brief   Data Synchronization Barrier\r
830   \details Acts as a special kind of Data Memory Barrier.\r
831            It completes when all explicit memory accesses before this instruction complete.\r
832  */\r
833 #define __DSB()        __builtin_arm_dsb(0xF)\r
834 \r
835 \r
836 /**\r
837   \brief   Data Memory Barrier\r
838   \details Ensures the apparent order of the explicit memory operations before\r
839            and after the instruction, without ensuring their completion.\r
840  */\r
841 #define __DMB()        __builtin_arm_dmb(0xF)\r
842 \r
843 \r
844 /**\r
845   \brief   Reverse byte order (32 bit)\r
846   \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.\r
847   \param [in]    value  Value to reverse\r
848   \return               Reversed value\r
849  */\r
850 #define __REV(value)   __builtin_bswap32(value)\r
851 \r
852 \r
853 /**\r
854   \brief   Reverse byte order (16 bit)\r
855   \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.\r
856   \param [in]    value  Value to reverse\r
857   \return               Reversed value\r
858  */\r
859 #define __REV16(value) __ROR(__REV(value), 16)\r
860 \r
861 \r
862 /**\r
863   \brief   Reverse byte order (16 bit)\r
864   \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.\r
865   \param [in]    value  Value to reverse\r
866   \return               Reversed value\r
867  */\r
868 #define __REVSH(value) (int16_t)__builtin_bswap16(value)\r
869 \r
870 \r
871 /**\r
872   \brief   Rotate Right in unsigned value (32 bit)\r
873   \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.\r
874   \param [in]    op1  Value to rotate\r
875   \param [in]    op2  Number of Bits to rotate\r
876   \return               Rotated value\r
877  */\r
878 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)\r
879 {\r
880   op2 %= 32U;\r
881   if (op2 == 0U)\r
882   {\r
883     return op1;\r
884   }\r
885   return (op1 >> op2) | (op1 << (32U - op2));\r
886 }\r
887 \r
888 \r
889 /**\r
890   \brief   Breakpoint\r
891   \details Causes the processor to enter Debug state.\r
892            Debug tools can use this to investigate system state when the instruction at a particular address is reached.\r
893   \param [in]    value  is ignored by the processor.\r
894                  If required, a debugger can use it to store additional information about the breakpoint.\r
895  */\r
896 #define __BKPT(value)     __ASM volatile ("bkpt "#value)\r
897 \r
898 \r
899 /**\r
900   \brief   Reverse bit order of value\r
901   \details Reverses the bit order of the given value.\r
902   \param [in]    value  Value to reverse\r
903   \return               Reversed value\r
904  */\r
905 #define __RBIT            __builtin_arm_rbit\r
906 \r
907 /**\r
908   \brief   Count leading zeros\r
909   \details Counts the number of leading zeros of a data value.\r
910   \param [in]  value  Value to count the leading zeros\r
911   \return             number of leading zeros in value\r
912  */\r
913 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)\r
914 {\r
915   /* Even though __builtin_clz produces a CLZ instruction on ARM, formally\r
916      __builtin_clz(0) is undefined behaviour, so handle this case specially.\r
917      This guarantees ARM-compatible results if happening to compile on a non-ARM\r
918      target, and ensures the compiler doesn't decide to activate any\r
919      optimisations using the logic "value was passed to __builtin_clz, so it\r
920      is non-zero".\r
921      ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a\r
922      single CLZ instruction.\r
923    */\r
924   if (value == 0U)\r
925   {\r
926     return 32U;\r
927   }\r
928   return __builtin_clz(value);\r
929 }\r
930 \r
931 \r
932 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \\r
933      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \\r
934      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \\r
935      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )\r
936 /**\r
937   \brief   LDR Exclusive (8 bit)\r
938   \details Executes a exclusive LDR instruction for 8 bit value.\r
939   \param [in]    ptr  Pointer to data\r
940   \return             value of type uint8_t at (*ptr)\r
941  */\r
942 #define __LDREXB        (uint8_t)__builtin_arm_ldrex\r
943 \r
944 \r
945 /**\r
946   \brief   LDR Exclusive (16 bit)\r
947   \details Executes a exclusive LDR instruction for 16 bit values.\r
948   \param [in]    ptr  Pointer to data\r
949   \return        value of type uint16_t at (*ptr)\r
950  */\r
951 #define __LDREXH        (uint16_t)__builtin_arm_ldrex\r
952 \r
953 \r
954 /**\r
955   \brief   LDR Exclusive (32 bit)\r
956   \details Executes a exclusive LDR instruction for 32 bit values.\r
957   \param [in]    ptr  Pointer to data\r
958   \return        value of type uint32_t at (*ptr)\r
959  */\r
960 #define __LDREXW        (uint32_t)__builtin_arm_ldrex\r
961 \r
962 \r
963 /**\r
964   \brief   STR Exclusive (8 bit)\r
965   \details Executes a exclusive STR instruction for 8 bit values.\r
966   \param [in]  value  Value to store\r
967   \param [in]    ptr  Pointer to location\r
968   \return          0  Function succeeded\r
969   \return          1  Function failed\r
970  */\r
971 #define __STREXB        (uint32_t)__builtin_arm_strex\r
972 \r
973 \r
974 /**\r
975   \brief   STR Exclusive (16 bit)\r
976   \details Executes a exclusive STR instruction for 16 bit values.\r
977   \param [in]  value  Value to store\r
978   \param [in]    ptr  Pointer to location\r
979   \return          0  Function succeeded\r
980   \return          1  Function failed\r
981  */\r
982 #define __STREXH        (uint32_t)__builtin_arm_strex\r
983 \r
984 \r
985 /**\r
986   \brief   STR Exclusive (32 bit)\r
987   \details Executes a exclusive STR instruction for 32 bit values.\r
988   \param [in]  value  Value to store\r
989   \param [in]    ptr  Pointer to location\r
990   \return          0  Function succeeded\r
991   \return          1  Function failed\r
992  */\r
993 #define __STREXW        (uint32_t)__builtin_arm_strex\r
994 \r
995 \r
996 /**\r
997   \brief   Remove the exclusive lock\r
998   \details Removes the exclusive lock which is created by LDREX.\r
999  */\r
1000 #define __CLREX             __builtin_arm_clrex\r
1001 \r
1002 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \\r
1003            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \\r
1004            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \\r
1005            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */\r
1006 \r
1007 \r
1008 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \\r
1009      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \\r
1010      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )\r
1011 \r
1012 /**\r
1013   \brief   Signed Saturate\r
1014   \details Saturates a signed value.\r
1015   \param [in]  value  Value to be saturated\r
1016   \param [in]    sat  Bit position to saturate to (1..32)\r
1017   \return             Saturated value\r
1018  */\r
1019 #define __SSAT             __builtin_arm_ssat\r
1020 \r
1021 \r
1022 /**\r
1023   \brief   Unsigned Saturate\r
1024   \details Saturates an unsigned value.\r
1025   \param [in]  value  Value to be saturated\r
1026   \param [in]    sat  Bit position to saturate to (0..31)\r
1027   \return             Saturated value\r
1028  */\r
1029 #define __USAT             __builtin_arm_usat\r
1030 \r
1031 \r
1032 /**\r
1033   \brief   Rotate Right with Extend (32 bit)\r
1034   \details Moves each bit of a bitstring right by one bit.\r
1035            The carry input is shifted in at the left end of the bitstring.\r
1036   \param [in]    value  Value to rotate\r
1037   \return               Rotated value\r
1038  */\r
1039 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)\r
1040 {\r
1041   uint32_t result;\r
1042 \r
1043   __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );\r
1044   return(result);\r
1045 }\r
1046 \r
1047 \r
1048 /**\r
1049   \brief   LDRT Unprivileged (8 bit)\r
1050   \details Executes a Unprivileged LDRT instruction for 8 bit value.\r
1051   \param [in]    ptr  Pointer to data\r
1052   \return             value of type uint8_t at (*ptr)\r
1053  */\r
1054 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)\r
1055 {\r
1056   uint32_t result;\r
1057 \r
1058   __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );\r
1059   return ((uint8_t) result);    /* Add explicit type cast here */\r
1060 }\r
1061 \r
1062 \r
1063 /**\r
1064   \brief   LDRT Unprivileged (16 bit)\r
1065   \details Executes a Unprivileged LDRT instruction for 16 bit values.\r
1066   \param [in]    ptr  Pointer to data\r
1067   \return        value of type uint16_t at (*ptr)\r
1068  */\r
1069 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)\r
1070 {\r
1071   uint32_t result;\r
1072 \r
1073   __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );\r
1074   return ((uint16_t) result);    /* Add explicit type cast here */\r
1075 }\r
1076 \r
1077 \r
1078 /**\r
1079   \brief   LDRT Unprivileged (32 bit)\r
1080   \details Executes a Unprivileged LDRT instruction for 32 bit values.\r
1081   \param [in]    ptr  Pointer to data\r
1082   \return        value of type uint32_t at (*ptr)\r
1083  */\r
1084 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)\r
1085 {\r
1086   uint32_t result;\r
1087 \r
1088   __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );\r
1089   return(result);\r
1090 }\r
1091 \r
1092 \r
1093 /**\r
1094   \brief   STRT Unprivileged (8 bit)\r
1095   \details Executes a Unprivileged STRT instruction for 8 bit values.\r
1096   \param [in]  value  Value to store\r
1097   \param [in]    ptr  Pointer to location\r
1098  */\r
1099 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)\r
1100 {\r
1101   __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );\r
1102 }\r
1103 \r
1104 \r
1105 /**\r
1106   \brief   STRT Unprivileged (16 bit)\r
1107   \details Executes a Unprivileged STRT instruction for 16 bit values.\r
1108   \param [in]  value  Value to store\r
1109   \param [in]    ptr  Pointer to location\r
1110  */\r
1111 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)\r
1112 {\r
1113   __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );\r
1114 }\r
1115 \r
1116 \r
1117 /**\r
1118   \brief   STRT Unprivileged (32 bit)\r
1119   \details Executes a Unprivileged STRT instruction for 32 bit values.\r
1120   \param [in]  value  Value to store\r
1121   \param [in]    ptr  Pointer to location\r
1122  */\r
1123 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)\r
1124 {\r
1125   __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );\r
1126 }\r
1127 \r
1128 #else  /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \\r
1129            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \\r
1130            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */\r
1131 \r
1132 /**\r
1133   \brief   Signed Saturate\r
1134   \details Saturates a signed value.\r
1135   \param [in]  value  Value to be saturated\r
1136   \param [in]    sat  Bit position to saturate to (1..32)\r
1137   \return             Saturated value\r
1138  */\r
1139 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)\r
1140 {\r
1141   if ((sat >= 1U) && (sat <= 32U))\r
1142   {\r
1143     const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);\r
1144     const int32_t min = -1 - max ;\r
1145     if (val > max)\r
1146     {\r
1147       return max;\r
1148     }\r
1149     else if (val < min)\r
1150     {\r
1151       return min;\r
1152     }\r
1153   }\r
1154   return val;\r
1155 }\r
1156 \r
1157 /**\r
1158   \brief   Unsigned Saturate\r
1159   \details Saturates an unsigned value.\r
1160   \param [in]  value  Value to be saturated\r
1161   \param [in]    sat  Bit position to saturate to (0..31)\r
1162   \return             Saturated value\r
1163  */\r
1164 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)\r
1165 {\r
1166   if (sat <= 31U)\r
1167   {\r
1168     const uint32_t max = ((1U << sat) - 1U);\r
1169     if (val > (int32_t)max)\r
1170     {\r
1171       return max;\r
1172     }\r
1173     else if (val < 0)\r
1174     {\r
1175       return 0U;\r
1176     }\r
1177   }\r
1178   return (uint32_t)val;\r
1179 }\r
1180 \r
1181 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \\r
1182            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \\r
1183            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */\r
1184 \r
1185 \r
1186 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \\r
1187      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )\r
1188 /**\r
1189   \brief   Load-Acquire (8 bit)\r
1190   \details Executes a LDAB instruction for 8 bit value.\r
1191   \param [in]    ptr  Pointer to data\r
1192   \return             value of type uint8_t at (*ptr)\r
1193  */\r
1194 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)\r
1195 {\r
1196   uint32_t result;\r
1197 \r
1198   __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );\r
1199   return ((uint8_t) result);\r
1200 }\r
1201 \r
1202 \r
1203 /**\r
1204   \brief   Load-Acquire (16 bit)\r
1205   \details Executes a LDAH instruction for 16 bit values.\r
1206   \param [in]    ptr  Pointer to data\r
1207   \return        value of type uint16_t at (*ptr)\r
1208  */\r
1209 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)\r
1210 {\r
1211   uint32_t result;\r
1212 \r
1213   __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );\r
1214   return ((uint16_t) result);\r
1215 }\r
1216 \r
1217 \r
1218 /**\r
1219   \brief   Load-Acquire (32 bit)\r
1220   \details Executes a LDA instruction for 32 bit values.\r
1221   \param [in]    ptr  Pointer to data\r
1222   \return        value of type uint32_t at (*ptr)\r
1223  */\r
1224 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)\r
1225 {\r
1226   uint32_t result;\r
1227 \r
1228   __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );\r
1229   return(result);\r
1230 }\r
1231 \r
1232 \r
1233 /**\r
1234   \brief   Store-Release (8 bit)\r
1235   \details Executes a STLB instruction for 8 bit values.\r
1236   \param [in]  value  Value to store\r
1237   \param [in]    ptr  Pointer to location\r
1238  */\r
1239 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)\r
1240 {\r
1241   __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );\r
1242 }\r
1243 \r
1244 \r
1245 /**\r
1246   \brief   Store-Release (16 bit)\r
1247   \details Executes a STLH instruction for 16 bit values.\r
1248   \param [in]  value  Value to store\r
1249   \param [in]    ptr  Pointer to location\r
1250  */\r
1251 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)\r
1252 {\r
1253   __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );\r
1254 }\r
1255 \r
1256 \r
1257 /**\r
1258   \brief   Store-Release (32 bit)\r
1259   \details Executes a STL instruction for 32 bit values.\r
1260   \param [in]  value  Value to store\r
1261   \param [in]    ptr  Pointer to location\r
1262  */\r
1263 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)\r
1264 {\r
1265   __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );\r
1266 }\r
1267 \r
1268 \r
1269 /**\r
1270   \brief   Load-Acquire Exclusive (8 bit)\r
1271   \details Executes a LDAB exclusive instruction for 8 bit value.\r
1272   \param [in]    ptr  Pointer to data\r
1273   \return             value of type uint8_t at (*ptr)\r
1274  */\r
1275 #define     __LDAEXB                 (uint8_t)__builtin_arm_ldaex\r
1276 \r
1277 \r
1278 /**\r
1279   \brief   Load-Acquire Exclusive (16 bit)\r
1280   \details Executes a LDAH exclusive instruction for 16 bit values.\r
1281   \param [in]    ptr  Pointer to data\r
1282   \return        value of type uint16_t at (*ptr)\r
1283  */\r
1284 #define     __LDAEXH                 (uint16_t)__builtin_arm_ldaex\r
1285 \r
1286 \r
1287 /**\r
1288   \brief   Load-Acquire Exclusive (32 bit)\r
1289   \details Executes a LDA exclusive instruction for 32 bit values.\r
1290   \param [in]    ptr  Pointer to data\r
1291   \return        value of type uint32_t at (*ptr)\r
1292  */\r
1293 #define     __LDAEX                  (uint32_t)__builtin_arm_ldaex\r
1294 \r
1295 \r
1296 /**\r
1297   \brief   Store-Release Exclusive (8 bit)\r
1298   \details Executes a STLB exclusive instruction for 8 bit values.\r
1299   \param [in]  value  Value to store\r
1300   \param [in]    ptr  Pointer to location\r
1301   \return          0  Function succeeded\r
1302   \return          1  Function failed\r
1303  */\r
1304 #define     __STLEXB                 (uint32_t)__builtin_arm_stlex\r
1305 \r
1306 \r
1307 /**\r
1308   \brief   Store-Release Exclusive (16 bit)\r
1309   \details Executes a STLH exclusive instruction for 16 bit values.\r
1310   \param [in]  value  Value to store\r
1311   \param [in]    ptr  Pointer to location\r
1312   \return          0  Function succeeded\r
1313   \return          1  Function failed\r
1314  */\r
1315 #define     __STLEXH                 (uint32_t)__builtin_arm_stlex\r
1316 \r
1317 \r
1318 /**\r
1319   \brief   Store-Release Exclusive (32 bit)\r
1320   \details Executes a STL exclusive instruction for 32 bit values.\r
1321   \param [in]  value  Value to store\r
1322   \param [in]    ptr  Pointer to location\r
1323   \return          0  Function succeeded\r
1324   \return          1  Function failed\r
1325  */\r
1326 #define     __STLEX                  (uint32_t)__builtin_arm_stlex\r
1327 \r
1328 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \\r
1329            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */\r
1330 \r
1331 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */\r
1332 \r
1333 \r
1334 /* ###################  Compiler specific Intrinsics  ########################### */\r
1335 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics\r
1336   Access to dedicated SIMD instructions\r
1337   @{\r
1338 */\r
1339 \r
1340 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))\r
1341 \r
1342 #define     __SADD8                 __builtin_arm_sadd8\r
1343 #define     __QADD8                 __builtin_arm_qadd8\r
1344 #define     __SHADD8                __builtin_arm_shadd8\r
1345 #define     __UADD8                 __builtin_arm_uadd8\r
1346 #define     __UQADD8                __builtin_arm_uqadd8\r
1347 #define     __UHADD8                __builtin_arm_uhadd8\r
1348 #define     __SSUB8                 __builtin_arm_ssub8\r
1349 #define     __QSUB8                 __builtin_arm_qsub8\r
1350 #define     __SHSUB8                __builtin_arm_shsub8\r
1351 #define     __USUB8                 __builtin_arm_usub8\r
1352 #define     __UQSUB8                __builtin_arm_uqsub8\r
1353 #define     __UHSUB8                __builtin_arm_uhsub8\r
1354 #define     __SADD16                __builtin_arm_sadd16\r
1355 #define     __QADD16                __builtin_arm_qadd16\r
1356 #define     __SHADD16               __builtin_arm_shadd16\r
1357 #define     __UADD16                __builtin_arm_uadd16\r
1358 #define     __UQADD16               __builtin_arm_uqadd16\r
1359 #define     __UHADD16               __builtin_arm_uhadd16\r
1360 #define     __SSUB16                __builtin_arm_ssub16\r
1361 #define     __QSUB16                __builtin_arm_qsub16\r
1362 #define     __SHSUB16               __builtin_arm_shsub16\r
1363 #define     __USUB16                __builtin_arm_usub16\r
1364 #define     __UQSUB16               __builtin_arm_uqsub16\r
1365 #define     __UHSUB16               __builtin_arm_uhsub16\r
1366 #define     __SASX                  __builtin_arm_sasx\r
1367 #define     __QASX                  __builtin_arm_qasx\r
1368 #define     __SHASX                 __builtin_arm_shasx\r
1369 #define     __UASX                  __builtin_arm_uasx\r
1370 #define     __UQASX                 __builtin_arm_uqasx\r
1371 #define     __UHASX                 __builtin_arm_uhasx\r
1372 #define     __SSAX                  __builtin_arm_ssax\r
1373 #define     __QSAX                  __builtin_arm_qsax\r
1374 #define     __SHSAX                 __builtin_arm_shsax\r
1375 #define     __USAX                  __builtin_arm_usax\r
1376 #define     __UQSAX                 __builtin_arm_uqsax\r
1377 #define     __UHSAX                 __builtin_arm_uhsax\r
1378 #define     __USAD8                 __builtin_arm_usad8\r
1379 #define     __USADA8                __builtin_arm_usada8\r
1380 #define     __SSAT16                __builtin_arm_ssat16\r
1381 #define     __USAT16                __builtin_arm_usat16\r
1382 #define     __UXTB16                __builtin_arm_uxtb16\r
1383 #define     __UXTAB16               __builtin_arm_uxtab16\r
1384 #define     __SXTB16                __builtin_arm_sxtb16\r
1385 #define     __SXTAB16               __builtin_arm_sxtab16\r
1386 #define     __SMUAD                 __builtin_arm_smuad\r
1387 #define     __SMUADX                __builtin_arm_smuadx\r
1388 #define     __SMLAD                 __builtin_arm_smlad\r
1389 #define     __SMLADX                __builtin_arm_smladx\r
1390 #define     __SMLALD                __builtin_arm_smlald\r
1391 #define     __SMLALDX               __builtin_arm_smlaldx\r
1392 #define     __SMUSD                 __builtin_arm_smusd\r
1393 #define     __SMUSDX                __builtin_arm_smusdx\r
1394 #define     __SMLSD                 __builtin_arm_smlsd\r
1395 #define     __SMLSDX                __builtin_arm_smlsdx\r
1396 #define     __SMLSLD                __builtin_arm_smlsld\r
1397 #define     __SMLSLDX               __builtin_arm_smlsldx\r
1398 #define     __SEL                   __builtin_arm_sel\r
1399 #define     __QADD                  __builtin_arm_qadd\r
1400 #define     __QSUB                  __builtin_arm_qsub\r
1401 \r
1402 #define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \\r
1403                                            ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )\r
1404 \r
1405 #define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \\r
1406                                            ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )\r
1407 \r
1408 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)\r
1409 {\r
1410   int32_t result;\r
1411 \r
1412   __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r"  (op1), "r" (op2), "r" (op3) );\r
1413   return(result);\r
1414 }\r
1415 \r
1416 #endif /* (__ARM_FEATURE_DSP == 1) */\r
1417 /*@} end of group CMSIS_SIMD_intrinsics */\r
1418 \r
1419 \r
1420 #endif /* __CMSIS_ARMCLANG_H */\r