]> begriffs open source - cmsis/blob - CMSIS/Core/Include/core_cm0plus.h
Merge remote-tracking branch 'refs/remotes/ARM-software/master'
[cmsis] / CMSIS / Core / Include / core_cm0plus.h
1 /**************************************************************************//**\r
2  * @file     core_cm0plus.h\r
3  * @brief    CMSIS Cortex-M0+ Core Peripheral Access Layer Header File\r
4  * @version  V5.00\r
5  * @date     02. March 2016\r
6  ******************************************************************************/\r
7 /*\r
8  * Copyright (c) 2009-2016 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  * http://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 #if   defined ( __ICCARM__ )\r
26  #pragma system_include         /* treat file as system include file for MISRA check */\r
27 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)\r
28   #pragma clang system_header   /* treat file as system include file */\r
29 #endif\r
30 \r
31 #ifndef __CORE_CM0PLUS_H_GENERIC\r
32 #define __CORE_CM0PLUS_H_GENERIC\r
33 \r
34 #include <stdint.h>\r
35 \r
36 #ifdef __cplusplus\r
37  extern "C" {\r
38 #endif\r
39 \r
40 /**\r
41   \page CMSIS_MISRA_Exceptions  MISRA-C:2004 Compliance Exceptions\r
42   CMSIS violates the following MISRA-C:2004 rules:\r
43 \r
44    \li Required Rule 8.5, object/function definition in header file.<br>\r
45      Function definitions in header files are used to allow 'inlining'.\r
46 \r
47    \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>\r
48      Unions are used for effective representation of core registers.\r
49 \r
50    \li Advisory Rule 19.7, Function-like macro defined.<br>\r
51      Function-like macros are used to allow more efficient code.\r
52  */\r
53 \r
54 \r
55 /*******************************************************************************\r
56  *                 CMSIS definitions\r
57  ******************************************************************************/\r
58 /**\r
59   \ingroup Cortex-M0+\r
60   @{\r
61  */\r
62 \r
63 /*  CMSIS CM0+ definitions */\r
64 #define __CM0PLUS_CMSIS_VERSION_MAIN ( 5U)                                      /*!< [31:16] CMSIS HAL main version */\r
65 #define __CM0PLUS_CMSIS_VERSION_SUB  ( 0U)                                      /*!< [15:0]  CMSIS HAL sub version */\r
66 #define __CM0PLUS_CMSIS_VERSION      ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \\r
67                                        __CM0PLUS_CMSIS_VERSION_SUB           )  /*!< CMSIS HAL version number */\r
68 \r
69 #define __CORTEX_M                   (0U)                                       /*!< Cortex-M Core */\r
70 \r
71 /* Common defines in core_*.h files\r
72   - #define __ASM               Compiler keyword for asm\r
73   - #define __INLINE            Compiler keyword for inline\r
74   - #define __STATIC_INLINE     Compiler keyword for static inline\r
75   - #define __NO_RETURN         function that never returns\r
76   - #define __USED              function or variable that is not optimized away\r
77   - #define __WEAK              weak function or variable\r
78   - #define __UNALIGNED_UINT32  pointer to unaligned uint32_t variable\r
79  */\r
80 #if   defined ( __CC_ARM )                                            /* ARM Compiler 4/5 */\r
81   #define __ASM                     __asm\r
82   #define __INLINE                  __inline\r
83   #define __STATIC_INLINE           static __inline\r
84   #define __NO_RETURN               __declspec(noreturn)\r
85   #define __USED                    __attribute__((used))\r
86   #define __WEAK                    __attribute__((weak))\r
87   #define __UNALIGNED_UINT32(x)     (*((__packed uint32_t *)(x)))\r
88 \r
89 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)       /* ARM Compiler 6 */\r
90   #define __ASM                     __asm\r
91   #define __INLINE                  __inline\r
92   #define __STATIC_INLINE           static __inline\r
93   #define __NO_RETURN               __attribute__((noreturn))\r
94   #define __USED                    __attribute__((used))\r
95   #define __WEAK                    __attribute__((weak))\r
96   #pragma clang diagnostic push\r
97   #pragma clang diagnostic ignored "-Wpacked"\r
98   struct __attribute__((packed)) T_UINT32 { uint32_t v; };\r
99   #pragma clang diagnostic pop\r
100   #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)\r
101 \r
102 #elif defined ( __GNUC__ )                                            /* GNU Compiler */\r
103   #define __ASM                     __asm\r
104   #define __INLINE                  inline\r
105   #define __STATIC_INLINE           static inline\r
106   #define __NO_RETURN               __attribute__((noreturn))\r
107   #define __USED                    __attribute__((used))\r
108   #define __WEAK                    __attribute__((weak))\r
109   struct __attribute__((packed)) T_UINT32 { uint32_t v; };\r
110   #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)\r
111 \r
112 #elif defined ( __ICCARM__ )                                          /* IAR Compiler */\r
113   #define __ASM                     __asm\r
114   #define __INLINE                  inline\r
115   #define __STATIC_INLINE           static inline\r
116   #define __NO_RETURN               __noreturn\r
117   #define __USED\r
118   #define __WEAK                    __weak\r
119   struct __packed T_UINT32 { uint32_t v; };\r
120   #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)\r
121 \r
122 #elif defined ( __TI_ARM__ )                                          /* TI ARM Compiler */\r
123   #define __ASM                     __asm\r
124   #define __INLINE                  inline\r
125   #define __STATIC_INLINE           static inline\r
126   #define __NO_RETURN               __attribute__((noreturn))\r
127   #define __USED                    __attribute__((used))\r
128   #define __WEAK                    __attribute__((weak))\r
129   struct __attribute__((packed)) T_UINT32 { uint32_t v; };\r
130   #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)\r
131 \r
132 #elif defined ( __TASKING__ )                                         /* TASKING Compiler */\r
133   #define __ASM                     __asm\r
134   #define __INLINE                  inline\r
135   #define __STATIC_INLINE           static inline\r
136   #define __NO_RETURN               __attribute__((noreturn))\r
137   #define __USED                    __attribute__((used))\r
138   #define __WEAK                    __attribute__((weak))\r
139   struct __packed__ T_UINT32 { uint32_t v; };\r
140   #define __UNALIGNED_UINT32(x)     (((struct T_UINT32 *)(x))->v)\r
141 \r
142 #elif defined ( __CSMC__ )                                            /* COSMIC Compiler */\r
143   #define __packed\r
144   #define __ASM                     _asm\r
145   #define __INLINE                  inline\r
146   #define __STATIC_INLINE           static inline\r
147   #define __NO_RETURN\r
148   #define __USED\r
149   #define __WEAK\r
150   #define __UNALIGNED_UINT32(x)     (*x)\r
151 \r
152 #else\r
153   #error Unknown compiler\r
154 #endif\r
155 \r
156 /** __FPU_USED indicates whether an FPU is used or not.\r
157     This core does not support an FPU at all\r
158 */\r
159 #define __FPU_USED       0U\r
160 \r
161 #if defined ( __CC_ARM )\r
162   #if defined __TARGET_FPU_VFP\r
163     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
164   #endif\r
165 \r
166 #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)\r
167   #if defined __ARM_PCS_VFP\r
168     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
169   #endif\r
170 \r
171 #elif defined ( __GNUC__ )\r
172   #if defined (__VFP_FP__) && !defined(__SOFTFP__)\r
173     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
174   #endif\r
175 \r
176 #elif defined ( __ICCARM__ )\r
177   #if defined __ARMVFP__\r
178     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
179   #endif\r
180 \r
181 #elif defined ( __TI_ARM__ )\r
182   #if defined __TI_VFP_SUPPORT__\r
183     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
184   #endif\r
185 \r
186 #elif defined ( __TASKING__ )\r
187   #if defined __FPU_VFP__\r
188     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
189   #endif\r
190 \r
191 #elif defined ( __CSMC__ )\r
192   #if ( __CSMC__ & 0x400U)\r
193     #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
194   #endif\r
195 \r
196 #endif\r
197 \r
198 #include "core_cminstr.h"                /* Core Instruction Access */\r
199 #include "core_cmfunc.h"                 /* Core Function Access */\r
200 \r
201 #ifdef __cplusplus\r
202 }\r
203 #endif\r
204 \r
205 #endif /* __CORE_CM0PLUS_H_GENERIC */\r
206 \r
207 #ifndef __CMSIS_GENERIC\r
208 \r
209 #ifndef __CORE_CM0PLUS_H_DEPENDANT\r
210 #define __CORE_CM0PLUS_H_DEPENDANT\r
211 \r
212 #ifdef __cplusplus\r
213  extern "C" {\r
214 #endif\r
215 \r
216 /* check device defines and use defaults */\r
217 #if defined __CHECK_DEVICE_DEFINES\r
218   #ifndef __CM0PLUS_REV\r
219     #define __CM0PLUS_REV             0x0000U\r
220     #warning "__CM0PLUS_REV not defined in device header file; using default!"\r
221   #endif\r
222 \r
223   #ifndef __MPU_PRESENT\r
224     #define __MPU_PRESENT             0U\r
225     #warning "__MPU_PRESENT not defined in device header file; using default!"\r
226   #endif\r
227 \r
228   #ifndef __VTOR_PRESENT\r
229     #define __VTOR_PRESENT            0U\r
230     #warning "__VTOR_PRESENT not defined in device header file; using default!"\r
231   #endif\r
232 \r
233   #ifndef __NVIC_PRIO_BITS\r
234     #define __NVIC_PRIO_BITS          2U\r
235     #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"\r
236   #endif\r
237 \r
238   #ifndef __Vendor_SysTickConfig\r
239     #define __Vendor_SysTickConfig    0U\r
240     #warning "__Vendor_SysTickConfig not defined in device header file; using default!"\r
241   #endif\r
242 #endif\r
243 \r
244 /* IO definitions (access restrictions to peripheral registers) */\r
245 /**\r
246     \defgroup CMSIS_glob_defs CMSIS Global Defines\r
247 \r
248     <strong>IO Type Qualifiers</strong> are used\r
249     \li to specify the access to peripheral variables.\r
250     \li for automatic generation of peripheral register debug information.\r
251 */\r
252 #ifdef __cplusplus\r
253   #define   __I     volatile             /*!< Defines 'read only' permissions */\r
254 #else\r
255   #define   __I     volatile const       /*!< Defines 'read only' permissions */\r
256 #endif\r
257 #define     __O     volatile             /*!< Defines 'write only' permissions */\r
258 #define     __IO    volatile             /*!< Defines 'read / write' permissions */\r
259 \r
260 /* following defines should be used for structure members */\r
261 #define     __IM     volatile const      /*! Defines 'read only' structure member permissions */\r
262 #define     __OM     volatile            /*! Defines 'write only' structure member permissions */\r
263 #define     __IOM    volatile            /*! Defines 'read / write' structure member permissions */\r
264 \r
265 /*@} end of group Cortex-M0+ */\r
266 \r
267 \r
268 \r
269 /*******************************************************************************\r
270  *                 Register Abstraction\r
271   Core Register contain:\r
272   - Core Register\r
273   - Core NVIC Register\r
274   - Core SCB Register\r
275   - Core SysTick Register\r
276   - Core MPU Register\r
277  ******************************************************************************/\r
278 /**\r
279   \defgroup CMSIS_core_register Defines and Type Definitions\r
280   \brief Type definitions and defines for Cortex-M processor based devices.\r
281 */\r
282 \r
283 /**\r
284   \ingroup    CMSIS_core_register\r
285   \defgroup   CMSIS_CORE  Status and Control Registers\r
286   \brief      Core Register type definitions.\r
287   @{\r
288  */\r
289 \r
290 /**\r
291   \brief  Union type to access the Application Program Status Register (APSR).\r
292  */\r
293 typedef union\r
294 {\r
295   struct\r
296   {\r
297     uint32_t _reserved0:28;              /*!< bit:  0..27  Reserved */\r
298     uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */\r
299     uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */\r
300     uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */\r
301     uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */\r
302   } b;                                   /*!< Structure used for bit  access */\r
303   uint32_t w;                            /*!< Type      used for word access */\r
304 } APSR_Type;\r
305 \r
306 /* APSR Register Definitions */\r
307 #define APSR_N_Pos                         31U                                            /*!< APSR: N Position */\r
308 #define APSR_N_Msk                         (1UL << APSR_N_Pos)                            /*!< APSR: N Mask */\r
309 \r
310 #define APSR_Z_Pos                         30U                                            /*!< APSR: Z Position */\r
311 #define APSR_Z_Msk                         (1UL << APSR_Z_Pos)                            /*!< APSR: Z Mask */\r
312 \r
313 #define APSR_C_Pos                         29U                                            /*!< APSR: C Position */\r
314 #define APSR_C_Msk                         (1UL << APSR_C_Pos)                            /*!< APSR: C Mask */\r
315 \r
316 #define APSR_V_Pos                         28U                                            /*!< APSR: V Position */\r
317 #define APSR_V_Msk                         (1UL << APSR_V_Pos)                            /*!< APSR: V Mask */\r
318 \r
319 \r
320 /**\r
321   \brief  Union type to access the Interrupt Program Status Register (IPSR).\r
322  */\r
323 typedef union\r
324 {\r
325   struct\r
326   {\r
327     uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */\r
328     uint32_t _reserved0:23;              /*!< bit:  9..31  Reserved */\r
329   } b;                                   /*!< Structure used for bit  access */\r
330   uint32_t w;                            /*!< Type      used for word access */\r
331 } IPSR_Type;\r
332 \r
333 /* IPSR Register Definitions */\r
334 #define IPSR_ISR_Pos                        0U                                            /*!< IPSR: ISR Position */\r
335 #define IPSR_ISR_Msk                       (0x1FFUL /*<< IPSR_ISR_Pos*/)                  /*!< IPSR: ISR Mask */\r
336 \r
337 \r
338 /**\r
339   \brief  Union type to access the Special-Purpose Program Status Registers (xPSR).\r
340  */\r
341 typedef union\r
342 {\r
343   struct\r
344   {\r
345     uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */\r
346     uint32_t _reserved0:15;              /*!< bit:  9..23  Reserved */\r
347     uint32_t T:1;                        /*!< bit:     24  Thumb bit        (read 0) */\r
348     uint32_t _reserved1:3;               /*!< bit: 25..27  Reserved */\r
349     uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */\r
350     uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */\r
351     uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */\r
352     uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */\r
353   } b;                                   /*!< Structure used for bit  access */\r
354   uint32_t w;                            /*!< Type      used for word access */\r
355 } xPSR_Type;\r
356 \r
357 /* xPSR Register Definitions */\r
358 #define xPSR_N_Pos                         31U                                            /*!< xPSR: N Position */\r
359 #define xPSR_N_Msk                         (1UL << xPSR_N_Pos)                            /*!< xPSR: N Mask */\r
360 \r
361 #define xPSR_Z_Pos                         30U                                            /*!< xPSR: Z Position */\r
362 #define xPSR_Z_Msk                         (1UL << xPSR_Z_Pos)                            /*!< xPSR: Z Mask */\r
363 \r
364 #define xPSR_C_Pos                         29U                                            /*!< xPSR: C Position */\r
365 #define xPSR_C_Msk                         (1UL << xPSR_C_Pos)                            /*!< xPSR: C Mask */\r
366 \r
367 #define xPSR_V_Pos                         28U                                            /*!< xPSR: V Position */\r
368 #define xPSR_V_Msk                         (1UL << xPSR_V_Pos)                            /*!< xPSR: V Mask */\r
369 \r
370 #define xPSR_T_Pos                         24U                                            /*!< xPSR: T Position */\r
371 #define xPSR_T_Msk                         (1UL << xPSR_T_Pos)                            /*!< xPSR: T Mask */\r
372 \r
373 #define xPSR_ISR_Pos                        0U                                            /*!< xPSR: ISR Position */\r
374 #define xPSR_ISR_Msk                       (0x1FFUL /*<< xPSR_ISR_Pos*/)                  /*!< xPSR: ISR Mask */\r
375 \r
376 \r
377 /**\r
378   \brief  Union type to access the Control Registers (CONTROL).\r
379  */\r
380 typedef union\r
381 {\r
382   struct\r
383   {\r
384     uint32_t nPRIV:1;                    /*!< bit:      0  Execution privilege in Thread mode */\r
385     uint32_t SPSEL:1;                    /*!< bit:      1  Stack to be used */\r
386     uint32_t _reserved1:30;              /*!< bit:  2..31  Reserved */\r
387   } b;                                   /*!< Structure used for bit  access */\r
388   uint32_t w;                            /*!< Type      used for word access */\r
389 } CONTROL_Type;\r
390 \r
391 /* CONTROL Register Definitions */\r
392 #define CONTROL_SPSEL_Pos                   1U                                            /*!< CONTROL: SPSEL Position */\r
393 #define CONTROL_SPSEL_Msk                  (1UL << CONTROL_SPSEL_Pos)                     /*!< CONTROL: SPSEL Mask */\r
394 \r
395 #define CONTROL_nPRIV_Pos                   0U                                            /*!< CONTROL: nPRIV Position */\r
396 #define CONTROL_nPRIV_Msk                  (1UL /*<< CONTROL_nPRIV_Pos*/)                 /*!< CONTROL: nPRIV Mask */\r
397 \r
398 /*@} end of group CMSIS_CORE */\r
399 \r
400 \r
401 /**\r
402   \ingroup    CMSIS_core_register\r
403   \defgroup   CMSIS_NVIC  Nested Vectored Interrupt Controller (NVIC)\r
404   \brief      Type definitions for the NVIC Registers\r
405   @{\r
406  */\r
407 \r
408 /**\r
409   \brief  Structure type to access the Nested Vectored Interrupt Controller (NVIC).\r
410  */\r
411 typedef struct\r
412 {\r
413   __IOM uint32_t ISER[1U];               /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register */\r
414         uint32_t RESERVED0[31U];\r
415   __IOM uint32_t ICER[1U];               /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register */\r
416         uint32_t RSERVED1[31U];\r
417   __IOM uint32_t ISPR[1U];               /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register */\r
418         uint32_t RESERVED2[31U];\r
419   __IOM uint32_t ICPR[1U];               /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register */\r
420         uint32_t RESERVED3[31U];\r
421         uint32_t RESERVED4[64U];\r
422   __IOM uint32_t IP[8U];                 /*!< Offset: 0x300 (R/W)  Interrupt Priority Register */\r
423 }  NVIC_Type;\r
424 \r
425 /*@} end of group CMSIS_NVIC */\r
426 \r
427 \r
428 /**\r
429   \ingroup  CMSIS_core_register\r
430   \defgroup CMSIS_SCB     System Control Block (SCB)\r
431   \brief    Type definitions for the System Control Block Registers\r
432   @{\r
433  */\r
434 \r
435 /**\r
436   \brief  Structure type to access the System Control Block (SCB).\r
437  */\r
438 typedef struct\r
439 {\r
440   __IM  uint32_t CPUID;                  /*!< Offset: 0x000 (R/ )  CPUID Base Register */\r
441   __IOM uint32_t ICSR;                   /*!< Offset: 0x004 (R/W)  Interrupt Control and State Register */\r
442 #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)\r
443   __IOM uint32_t VTOR;                   /*!< Offset: 0x008 (R/W)  Vector Table Offset Register */\r
444 #else\r
445         uint32_t RESERVED0;\r
446 #endif\r
447   __IOM uint32_t AIRCR;                  /*!< Offset: 0x00C (R/W)  Application Interrupt and Reset Control Register */\r
448   __IOM uint32_t SCR;                    /*!< Offset: 0x010 (R/W)  System Control Register */\r
449   __IOM uint32_t CCR;                    /*!< Offset: 0x014 (R/W)  Configuration Control Register */\r
450         uint32_t RESERVED1;\r
451   __IOM uint32_t SHP[2U];                /*!< Offset: 0x01C (R/W)  System Handlers Priority Registers. [0] is RESERVED */\r
452   __IOM uint32_t SHCSR;                  /*!< Offset: 0x024 (R/W)  System Handler Control and State Register */\r
453 } SCB_Type;\r
454 \r
455 /* SCB CPUID Register Definitions */\r
456 #define SCB_CPUID_IMPLEMENTER_Pos          24U                                            /*!< SCB CPUID: IMPLEMENTER Position */\r
457 #define SCB_CPUID_IMPLEMENTER_Msk          (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */\r
458 \r
459 #define SCB_CPUID_VARIANT_Pos              20U                                            /*!< SCB CPUID: VARIANT Position */\r
460 #define SCB_CPUID_VARIANT_Msk              (0xFUL << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */\r
461 \r
462 #define SCB_CPUID_ARCHITECTURE_Pos         16U                                            /*!< SCB CPUID: ARCHITECTURE Position */\r
463 #define SCB_CPUID_ARCHITECTURE_Msk         (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)          /*!< SCB CPUID: ARCHITECTURE Mask */\r
464 \r
465 #define SCB_CPUID_PARTNO_Pos                4U                                            /*!< SCB CPUID: PARTNO Position */\r
466 #define SCB_CPUID_PARTNO_Msk               (0xFFFUL << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */\r
467 \r
468 #define SCB_CPUID_REVISION_Pos              0U                                            /*!< SCB CPUID: REVISION Position */\r
469 #define SCB_CPUID_REVISION_Msk             (0xFUL /*<< SCB_CPUID_REVISION_Pos*/)          /*!< SCB CPUID: REVISION Mask */\r
470 \r
471 /* SCB Interrupt Control State Register Definitions */\r
472 #define SCB_ICSR_NMIPENDSET_Pos            31U                                            /*!< SCB ICSR: NMIPENDSET Position */\r
473 #define SCB_ICSR_NMIPENDSET_Msk            (1UL << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */\r
474 \r
475 #define SCB_ICSR_PENDSVSET_Pos             28U                                            /*!< SCB ICSR: PENDSVSET Position */\r
476 #define SCB_ICSR_PENDSVSET_Msk             (1UL << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */\r
477 \r
478 #define SCB_ICSR_PENDSVCLR_Pos             27U                                            /*!< SCB ICSR: PENDSVCLR Position */\r
479 #define SCB_ICSR_PENDSVCLR_Msk             (1UL << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */\r
480 \r
481 #define SCB_ICSR_PENDSTSET_Pos             26U                                            /*!< SCB ICSR: PENDSTSET Position */\r
482 #define SCB_ICSR_PENDSTSET_Msk             (1UL << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */\r
483 \r
484 #define SCB_ICSR_PENDSTCLR_Pos             25U                                            /*!< SCB ICSR: PENDSTCLR Position */\r
485 #define SCB_ICSR_PENDSTCLR_Msk             (1UL << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */\r
486 \r
487 #define SCB_ICSR_ISRPREEMPT_Pos            23U                                            /*!< SCB ICSR: ISRPREEMPT Position */\r
488 #define SCB_ICSR_ISRPREEMPT_Msk            (1UL << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */\r
489 \r
490 #define SCB_ICSR_ISRPENDING_Pos            22U                                            /*!< SCB ICSR: ISRPENDING Position */\r
491 #define SCB_ICSR_ISRPENDING_Msk            (1UL << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */\r
492 \r
493 #define SCB_ICSR_VECTPENDING_Pos           12U                                            /*!< SCB ICSR: VECTPENDING Position */\r
494 #define SCB_ICSR_VECTPENDING_Msk           (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */\r
495 \r
496 #define SCB_ICSR_VECTACTIVE_Pos             0U                                            /*!< SCB ICSR: VECTACTIVE Position */\r
497 #define SCB_ICSR_VECTACTIVE_Msk            (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/)       /*!< SCB ICSR: VECTACTIVE Mask */\r
498 \r
499 #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)\r
500 /* SCB Interrupt Control State Register Definitions */\r
501 #define SCB_VTOR_TBLOFF_Pos                 8U                                            /*!< SCB VTOR: TBLOFF Position */\r
502 #define SCB_VTOR_TBLOFF_Msk                (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos)            /*!< SCB VTOR: TBLOFF Mask */\r
503 #endif\r
504 \r
505 /* SCB Application Interrupt and Reset Control Register Definitions */\r
506 #define SCB_AIRCR_VECTKEY_Pos              16U                                            /*!< SCB AIRCR: VECTKEY Position */\r
507 #define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */\r
508 \r
509 #define SCB_AIRCR_VECTKEYSTAT_Pos          16U                                            /*!< SCB AIRCR: VECTKEYSTAT Position */\r
510 #define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */\r
511 \r
512 #define SCB_AIRCR_ENDIANESS_Pos            15U                                            /*!< SCB AIRCR: ENDIANESS Position */\r
513 #define SCB_AIRCR_ENDIANESS_Msk            (1UL << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */\r
514 \r
515 #define SCB_AIRCR_SYSRESETREQ_Pos           2U                                            /*!< SCB AIRCR: SYSRESETREQ Position */\r
516 #define SCB_AIRCR_SYSRESETREQ_Msk          (1UL << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */\r
517 \r
518 #define SCB_AIRCR_VECTCLRACTIVE_Pos         1U                                            /*!< SCB AIRCR: VECTCLRACTIVE Position */\r
519 #define SCB_AIRCR_VECTCLRACTIVE_Msk        (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */\r
520 \r
521 /* SCB System Control Register Definitions */\r
522 #define SCB_SCR_SEVONPEND_Pos               4U                                            /*!< SCB SCR: SEVONPEND Position */\r
523 #define SCB_SCR_SEVONPEND_Msk              (1UL << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */\r
524 \r
525 #define SCB_SCR_SLEEPDEEP_Pos               2U                                            /*!< SCB SCR: SLEEPDEEP Position */\r
526 #define SCB_SCR_SLEEPDEEP_Msk              (1UL << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */\r
527 \r
528 #define SCB_SCR_SLEEPONEXIT_Pos             1U                                            /*!< SCB SCR: SLEEPONEXIT Position */\r
529 #define SCB_SCR_SLEEPONEXIT_Msk            (1UL << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */\r
530 \r
531 /* SCB Configuration Control Register Definitions */\r
532 #define SCB_CCR_STKALIGN_Pos                9U                                            /*!< SCB CCR: STKALIGN Position */\r
533 #define SCB_CCR_STKALIGN_Msk               (1UL << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */\r
534 \r
535 #define SCB_CCR_UNALIGN_TRP_Pos             3U                                            /*!< SCB CCR: UNALIGN_TRP Position */\r
536 #define SCB_CCR_UNALIGN_TRP_Msk            (1UL << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */\r
537 \r
538 /* SCB System Handler Control and State Register Definitions */\r
539 #define SCB_SHCSR_SVCALLPENDED_Pos         15U                                            /*!< SCB SHCSR: SVCALLPENDED Position */\r
540 #define SCB_SHCSR_SVCALLPENDED_Msk         (1UL << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */\r
541 \r
542 /*@} end of group CMSIS_SCB */\r
543 \r
544 \r
545 /**\r
546   \ingroup  CMSIS_core_register\r
547   \defgroup CMSIS_SysTick     System Tick Timer (SysTick)\r
548   \brief    Type definitions for the System Timer Registers.\r
549   @{\r
550  */\r
551 \r
552 /**\r
553   \brief  Structure type to access the System Timer (SysTick).\r
554  */\r
555 typedef struct\r
556 {\r
557   __IOM uint32_t CTRL;                   /*!< Offset: 0x000 (R/W)  SysTick Control and Status Register */\r
558   __IOM uint32_t LOAD;                   /*!< Offset: 0x004 (R/W)  SysTick Reload Value Register */\r
559   __IOM uint32_t VAL;                    /*!< Offset: 0x008 (R/W)  SysTick Current Value Register */\r
560   __IM  uint32_t CALIB;                  /*!< Offset: 0x00C (R/ )  SysTick Calibration Register */\r
561 } SysTick_Type;\r
562 \r
563 /* SysTick Control / Status Register Definitions */\r
564 #define SysTick_CTRL_COUNTFLAG_Pos         16U                                            /*!< SysTick CTRL: COUNTFLAG Position */\r
565 #define SysTick_CTRL_COUNTFLAG_Msk         (1UL << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */\r
566 \r
567 #define SysTick_CTRL_CLKSOURCE_Pos          2U                                            /*!< SysTick CTRL: CLKSOURCE Position */\r
568 #define SysTick_CTRL_CLKSOURCE_Msk         (1UL << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */\r
569 \r
570 #define SysTick_CTRL_TICKINT_Pos            1U                                            /*!< SysTick CTRL: TICKINT Position */\r
571 #define SysTick_CTRL_TICKINT_Msk           (1UL << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */\r
572 \r
573 #define SysTick_CTRL_ENABLE_Pos             0U                                            /*!< SysTick CTRL: ENABLE Position */\r
574 #define SysTick_CTRL_ENABLE_Msk            (1UL /*<< SysTick_CTRL_ENABLE_Pos*/)           /*!< SysTick CTRL: ENABLE Mask */\r
575 \r
576 /* SysTick Reload Register Definitions */\r
577 #define SysTick_LOAD_RELOAD_Pos             0U                                            /*!< SysTick LOAD: RELOAD Position */\r
578 #define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/)    /*!< SysTick LOAD: RELOAD Mask */\r
579 \r
580 /* SysTick Current Register Definitions */\r
581 #define SysTick_VAL_CURRENT_Pos             0U                                            /*!< SysTick VAL: CURRENT Position */\r
582 #define SysTick_VAL_CURRENT_Msk            (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/)    /*!< SysTick VAL: CURRENT Mask */\r
583 \r
584 /* SysTick Calibration Register Definitions */\r
585 #define SysTick_CALIB_NOREF_Pos            31U                                            /*!< SysTick CALIB: NOREF Position */\r
586 #define SysTick_CALIB_NOREF_Msk            (1UL << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */\r
587 \r
588 #define SysTick_CALIB_SKEW_Pos             30U                                            /*!< SysTick CALIB: SKEW Position */\r
589 #define SysTick_CALIB_SKEW_Msk             (1UL << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */\r
590 \r
591 #define SysTick_CALIB_TENMS_Pos             0U                                            /*!< SysTick CALIB: TENMS Position */\r
592 #define SysTick_CALIB_TENMS_Msk            (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/)    /*!< SysTick CALIB: TENMS Mask */\r
593 \r
594 /*@} end of group CMSIS_SysTick */\r
595 \r
596 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)\r
597 /**\r
598   \ingroup  CMSIS_core_register\r
599   \defgroup CMSIS_MPU     Memory Protection Unit (MPU)\r
600   \brief    Type definitions for the Memory Protection Unit (MPU)\r
601   @{\r
602  */\r
603 \r
604 /**\r
605   \brief  Structure type to access the Memory Protection Unit (MPU).\r
606  */\r
607 typedef struct\r
608 {\r
609   __IM  uint32_t TYPE;                   /*!< Offset: 0x000 (R/ )  MPU Type Register */\r
610   __IOM uint32_t CTRL;                   /*!< Offset: 0x004 (R/W)  MPU Control Register */\r
611   __IOM uint32_t RNR;                    /*!< Offset: 0x008 (R/W)  MPU Region RNRber Register */\r
612   __IOM uint32_t RBAR;                   /*!< Offset: 0x00C (R/W)  MPU Region Base Address Register */\r
613   __IOM uint32_t RASR;                   /*!< Offset: 0x010 (R/W)  MPU Region Attribute and Size Register */\r
614 } MPU_Type;\r
615 \r
616 /* MPU Type Register Definitions */\r
617 #define MPU_TYPE_IREGION_Pos               16U                                            /*!< MPU TYPE: IREGION Position */\r
618 #define MPU_TYPE_IREGION_Msk               (0xFFUL << MPU_TYPE_IREGION_Pos)               /*!< MPU TYPE: IREGION Mask */\r
619 \r
620 #define MPU_TYPE_DREGION_Pos                8U                                            /*!< MPU TYPE: DREGION Position */\r
621 #define MPU_TYPE_DREGION_Msk               (0xFFUL << MPU_TYPE_DREGION_Pos)               /*!< MPU TYPE: DREGION Mask */\r
622 \r
623 #define MPU_TYPE_SEPARATE_Pos               0U                                            /*!< MPU TYPE: SEPARATE Position */\r
624 #define MPU_TYPE_SEPARATE_Msk              (1UL /*<< MPU_TYPE_SEPARATE_Pos*/)             /*!< MPU TYPE: SEPARATE Mask */\r
625 \r
626 /* MPU Control Register Definitions */\r
627 #define MPU_CTRL_PRIVDEFENA_Pos             2U                                            /*!< MPU CTRL: PRIVDEFENA Position */\r
628 #define MPU_CTRL_PRIVDEFENA_Msk            (1UL << MPU_CTRL_PRIVDEFENA_Pos)               /*!< MPU CTRL: PRIVDEFENA Mask */\r
629 \r
630 #define MPU_CTRL_HFNMIENA_Pos               1U                                            /*!< MPU CTRL: HFNMIENA Position */\r
631 #define MPU_CTRL_HFNMIENA_Msk              (1UL << MPU_CTRL_HFNMIENA_Pos)                 /*!< MPU CTRL: HFNMIENA Mask */\r
632 \r
633 #define MPU_CTRL_ENABLE_Pos                 0U                                            /*!< MPU CTRL: ENABLE Position */\r
634 #define MPU_CTRL_ENABLE_Msk                (1UL /*<< MPU_CTRL_ENABLE_Pos*/)               /*!< MPU CTRL: ENABLE Mask */\r
635 \r
636 /* MPU Region Number Register Definitions */\r
637 #define MPU_RNR_REGION_Pos                  0U                                            /*!< MPU RNR: REGION Position */\r
638 #define MPU_RNR_REGION_Msk                 (0xFFUL /*<< MPU_RNR_REGION_Pos*/)             /*!< MPU RNR: REGION Mask */\r
639 \r
640 /* MPU Region Base Address Register Definitions */\r
641 #define MPU_RBAR_ADDR_Pos                   8U                                            /*!< MPU RBAR: ADDR Position */\r
642 #define MPU_RBAR_ADDR_Msk                  (0xFFFFFFUL << MPU_RBAR_ADDR_Pos)              /*!< MPU RBAR: ADDR Mask */\r
643 \r
644 #define MPU_RBAR_VALID_Pos                  4U                                            /*!< MPU RBAR: VALID Position */\r
645 #define MPU_RBAR_VALID_Msk                 (1UL << MPU_RBAR_VALID_Pos)                    /*!< MPU RBAR: VALID Mask */\r
646 \r
647 #define MPU_RBAR_REGION_Pos                 0U                                            /*!< MPU RBAR: REGION Position */\r
648 #define MPU_RBAR_REGION_Msk                (0xFUL /*<< MPU_RBAR_REGION_Pos*/)             /*!< MPU RBAR: REGION Mask */\r
649 \r
650 /* MPU Region Attribute and Size Register Definitions */\r
651 #define MPU_RASR_ATTRS_Pos                 16U                                            /*!< MPU RASR: MPU Region Attribute field Position */\r
652 #define MPU_RASR_ATTRS_Msk                 (0xFFFFUL << MPU_RASR_ATTRS_Pos)               /*!< MPU RASR: MPU Region Attribute field Mask */\r
653 \r
654 #define MPU_RASR_XN_Pos                    28U                                            /*!< MPU RASR: ATTRS.XN Position */\r
655 #define MPU_RASR_XN_Msk                    (1UL << MPU_RASR_XN_Pos)                       /*!< MPU RASR: ATTRS.XN Mask */\r
656 \r
657 #define MPU_RASR_AP_Pos                    24U                                            /*!< MPU RASR: ATTRS.AP Position */\r
658 #define MPU_RASR_AP_Msk                    (0x7UL << MPU_RASR_AP_Pos)                     /*!< MPU RASR: ATTRS.AP Mask */\r
659 \r
660 #define MPU_RASR_TEX_Pos                   19U                                            /*!< MPU RASR: ATTRS.TEX Position */\r
661 #define MPU_RASR_TEX_Msk                   (0x7UL << MPU_RASR_TEX_Pos)                    /*!< MPU RASR: ATTRS.TEX Mask */\r
662 \r
663 #define MPU_RASR_S_Pos                     18U                                            /*!< MPU RASR: ATTRS.S Position */\r
664 #define MPU_RASR_S_Msk                     (1UL << MPU_RASR_S_Pos)                        /*!< MPU RASR: ATTRS.S Mask */\r
665 \r
666 #define MPU_RASR_C_Pos                     17U                                            /*!< MPU RASR: ATTRS.C Position */\r
667 #define MPU_RASR_C_Msk                     (1UL << MPU_RASR_C_Pos)                        /*!< MPU RASR: ATTRS.C Mask */\r
668 \r
669 #define MPU_RASR_B_Pos                     16U                                            /*!< MPU RASR: ATTRS.B Position */\r
670 #define MPU_RASR_B_Msk                     (1UL << MPU_RASR_B_Pos)                        /*!< MPU RASR: ATTRS.B Mask */\r
671 \r
672 #define MPU_RASR_SRD_Pos                    8U                                            /*!< MPU RASR: Sub-Region Disable Position */\r
673 #define MPU_RASR_SRD_Msk                   (0xFFUL << MPU_RASR_SRD_Pos)                   /*!< MPU RASR: Sub-Region Disable Mask */\r
674 \r
675 #define MPU_RASR_SIZE_Pos                   1U                                            /*!< MPU RASR: Region Size Field Position */\r
676 #define MPU_RASR_SIZE_Msk                  (0x1FUL << MPU_RASR_SIZE_Pos)                  /*!< MPU RASR: Region Size Field Mask */\r
677 \r
678 #define MPU_RASR_ENABLE_Pos                 0U                                            /*!< MPU RASR: Region enable bit Position */\r
679 #define MPU_RASR_ENABLE_Msk                (1UL /*<< MPU_RASR_ENABLE_Pos*/)               /*!< MPU RASR: Region enable bit Disable Mask */\r
680 \r
681 /*@} end of group CMSIS_MPU */\r
682 #endif\r
683 \r
684 \r
685 /**\r
686   \ingroup  CMSIS_core_register\r
687   \defgroup CMSIS_CoreDebug       Core Debug Registers (CoreDebug)\r
688   \brief    Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.\r
689             Therefore they are not covered by the Cortex-M0+ header file.\r
690   @{\r
691  */\r
692 /*@} end of group CMSIS_CoreDebug */\r
693 \r
694 \r
695 /**\r
696   \ingroup    CMSIS_core_register\r
697   \defgroup   CMSIS_core_bitfield     Core register bit field macros\r
698   \brief      Macros for use with bit field definitions (xxx_Pos, xxx_Msk).\r
699   @{\r
700  */\r
701 \r
702 /**\r
703   \brief   Mask and shift a bit field value for use in a register bit range.\r
704   \param[in] field  Name of the register bit field.\r
705   \param[in] value  Value of the bit field. This parameter is interpreted as an uint32_t type.\r
706   \return           Masked and shifted value.\r
707 */\r
708 #define _VAL2FLD(field, value)    (((uint32_t)(value) << field ## _Pos) & field ## _Msk)\r
709 \r
710 /**\r
711   \brief     Mask and shift a register value to extract a bit filed value.\r
712   \param[in] field  Name of the register bit field.\r
713   \param[in] value  Value of register. This parameter is interpreted as an uint32_t type.\r
714   \return           Masked and shifted bit field value.\r
715 */\r
716 #define _FLD2VAL(field, value)    (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)\r
717 \r
718 /*@} end of group CMSIS_core_bitfield */\r
719 \r
720 \r
721 /**\r
722   \ingroup    CMSIS_core_register\r
723   \defgroup   CMSIS_core_base     Core Definitions\r
724   \brief      Definitions for base addresses, unions, and structures.\r
725   @{\r
726  */\r
727 \r
728 /* Memory mapping of Cortex-M0+ Hardware */\r
729 #define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */\r
730 #define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */\r
731 #define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */\r
732 #define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */\r
733 \r
734 #define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */\r
735 #define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */\r
736 #define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */\r
737 \r
738 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)\r
739   #define MPU_BASE          (SCS_BASE +  0x0D90UL)                    /*!< Memory Protection Unit */\r
740   #define MPU               ((MPU_Type       *)     MPU_BASE      )   /*!< Memory Protection Unit */\r
741 #endif\r
742 \r
743 /*@} */\r
744 \r
745 \r
746 \r
747 /*******************************************************************************\r
748  *                Hardware Abstraction Layer\r
749   Core Function Interface contains:\r
750   - Core NVIC Functions\r
751   - Core SysTick Functions\r
752   - Core Register Access Functions\r
753  ******************************************************************************/\r
754 /**\r
755   \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference\r
756 */\r
757 \r
758 \r
759 \r
760 /* ##########################   NVIC functions  #################################### */\r
761 /**\r
762   \ingroup  CMSIS_Core_FunctionInterface\r
763   \defgroup CMSIS_Core_NVICFunctions NVIC Functions\r
764   \brief    Functions that manage interrupts and exceptions via the NVIC.\r
765   @{\r
766  */\r
767 \r
768 /* Interrupt Priorities are WORD accessible only under ARMv6M                   */\r
769 /* The following MACROS handle generation of the register offset and byte masks */\r
770 #define _BIT_SHIFT(IRQn)         (  ((((uint32_t)(int32_t)(IRQn))         )      &  0x03UL) * 8UL)\r
771 #define _SHP_IDX(IRQn)           ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >>    2UL)      )\r
772 #define _IP_IDX(IRQn)            (   (((uint32_t)(int32_t)(IRQn))                >>    2UL)      )\r
773 \r
774 \r
775 /**\r
776   \brief   Enable External Interrupt\r
777   \details Enables a device-specific interrupt in the NVIC interrupt controller.\r
778   \param [in]      IRQn  External interrupt number. Value cannot be negative.\r
779  */\r
780 __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)\r
781 {\r
782   NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));\r
783 }\r
784 \r
785 \r
786 /**\r
787   \brief   Disable External Interrupt\r
788   \details Disables a device-specific interrupt in the NVIC interrupt controller.\r
789   \param [in]      IRQn  External interrupt number. Value cannot be negative.\r
790  */\r
791 __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)\r
792 {\r
793   NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));\r
794 }\r
795 \r
796 \r
797 /**\r
798   \brief   Get Pending Interrupt\r
799   \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.\r
800   \param [in]      IRQn  Interrupt number.\r
801   \return             0  Interrupt status is not pending.\r
802   \return             1  Interrupt status is pending.\r
803  */\r
804 __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)\r
805 {\r
806   return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));\r
807 }\r
808 \r
809 \r
810 /**\r
811   \brief   Set Pending Interrupt\r
812   \details Sets the pending bit of an external interrupt.\r
813   \param [in]      IRQn  Interrupt number. Value cannot be negative.\r
814  */\r
815 __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)\r
816 {\r
817   NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));\r
818 }\r
819 \r
820 \r
821 /**\r
822   \brief   Clear Pending Interrupt\r
823   \details Clears the pending bit of an external interrupt.\r
824   \param [in]      IRQn  External interrupt number. Value cannot be negative.\r
825  */\r
826 __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)\r
827 {\r
828   NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));\r
829 }\r
830 \r
831 \r
832 /**\r
833   \brief   Set Interrupt Priority\r
834   \details Sets the priority of an interrupt.\r
835   \note    The priority cannot be set for every core interrupt.\r
836   \param [in]      IRQn  Interrupt number.\r
837   \param [in]  priority  Priority to set.\r
838  */\r
839 __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)\r
840 {\r
841   if ((int32_t)(IRQn) < 0)\r
842   {\r
843     SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |\r
844        (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));\r
845   }\r
846   else\r
847   {\r
848     NVIC->IP[_IP_IDX(IRQn)]  = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)]  & ~(0xFFUL << _BIT_SHIFT(IRQn))) |\r
849        (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));\r
850   }\r
851 }\r
852 \r
853 \r
854 /**\r
855   \brief   Get Interrupt Priority\r
856   \details Reads the priority of an interrupt.\r
857            The interrupt number can be positive to specify an external (device specific) interrupt,\r
858            or negative to specify an internal (core) interrupt.\r
859   \param [in]   IRQn  Interrupt number.\r
860   \return             Interrupt Priority.\r
861                       Value is aligned automatically to the implemented priority bits of the microcontroller.\r
862  */\r
863 __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)\r
864 {\r
865 \r
866   if ((int32_t)(IRQn) < 0)\r
867   {\r
868     return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));\r
869   }\r
870   else\r
871   {\r
872     return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));\r
873   }\r
874 }\r
875 \r
876 \r
877 /**\r
878   \brief   System Reset\r
879   \details Initiates a system reset request to reset the MCU.\r
880  */\r
881 __STATIC_INLINE void NVIC_SystemReset(void)\r
882 {\r
883   __DSB();                                                          /* Ensure all outstanding memory accesses included\r
884                                                                        buffered write are completed before reset */\r
885   SCB->AIRCR  = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |\r
886                  SCB_AIRCR_SYSRESETREQ_Msk);\r
887   __DSB();                                                          /* Ensure completion of memory access */\r
888 \r
889   for(;;)                                                           /* wait until reset */\r
890   {\r
891     __NOP();\r
892   }\r
893 }\r
894 \r
895 /*@} end of CMSIS_Core_NVICFunctions */\r
896 \r
897 \r
898 /* ##########################  FPU functions  #################################### */\r
899 /**\r
900   \ingroup  CMSIS_Core_FunctionInterface\r
901   \defgroup CMSIS_Core_FpuFunctions FPU Functions\r
902   \brief    Function that provides FPU type.\r
903   @{\r
904  */\r
905 \r
906 /**\r
907   \brief   get FPU type\r
908   \details returns the FPU type\r
909   \returns\r
910    - \b  0: No FPU\r
911    - \b  1: Single precision FPU\r
912    - \b  2: Double + Single precision FPU\r
913  */\r
914 __STATIC_INLINE uint32_t SCB_GetFPUType(void)\r
915 {\r
916     return 0U;           /* No FPU */\r
917 }\r
918 \r
919 \r
920 /*@} end of CMSIS_Core_FpuFunctions */\r
921 \r
922 \r
923 \r
924 /* ##################################    SysTick function  ############################################ */\r
925 /**\r
926   \ingroup  CMSIS_Core_FunctionInterface\r
927   \defgroup CMSIS_Core_SysTickFunctions SysTick Functions\r
928   \brief    Functions that configure the System.\r
929   @{\r
930  */\r
931 \r
932 #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)\r
933 \r
934 /**\r
935   \brief   System Tick Configuration\r
936   \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.\r
937            Counter is in free running mode to generate periodic interrupts.\r
938   \param [in]  ticks  Number of ticks between two interrupts.\r
939   \return          0  Function succeeded.\r
940   \return          1  Function failed.\r
941   \note    When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the\r
942            function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>\r
943            must contain a vendor-specific implementation of this function.\r
944  */\r
945 __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)\r
946 {\r
947   if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)\r
948   {\r
949     return (1UL);                                                   /* Reload value impossible */\r
950   }\r
951 \r
952   SysTick->LOAD  = (uint32_t)(ticks - 1UL);                         /* set reload register */\r
953   NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */\r
954   SysTick->VAL   = 0UL;                                             /* Load the SysTick Counter Value */\r
955   SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |\r
956                    SysTick_CTRL_TICKINT_Msk   |\r
957                    SysTick_CTRL_ENABLE_Msk;                         /* Enable SysTick IRQ and SysTick Timer */\r
958   return (0UL);                                                     /* Function successful */\r
959 }\r
960 \r
961 #endif\r
962 \r
963 /*@} end of CMSIS_Core_SysTickFunctions */\r
964 \r
965 \r
966 \r
967 \r
968 #ifdef __cplusplus\r
969 }\r
970 #endif\r
971 \r
972 #endif /* __CORE_CM0PLUS_H_DEPENDANT */\r
973 \r
974 #endif /* __CMSIS_GENERIC */\r