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