]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_ATSAM3S-EK2_Atmel_Studio/src/asf/thirdparty/CMSIS/Include/core_cm3.h
Add demo for SAM3S-EK2.
[freertos] / FreeRTOS / Demo / CORTEX_ATSAM3S-EK2_Atmel_Studio / src / asf / thirdparty / CMSIS / Include / core_cm3.h
1 /**************************************************************************//**\r
2  * @file     core_cm3.h\r
3  * @brief    CMSIS Cortex-M3 Core Peripheral Access Layer Header File\r
4  * @version  V2.11\r
5  * @date     08. September 2011\r
6  *\r
7  * @note\r
8  * Copyright (C) 2009-2011 ARM Limited. All rights reserved.\r
9  *\r
10  * @par\r
11  * ARM Limited (ARM) is supplying this software for use with Cortex-M\r
12  * processor based microcontrollers.  This file can be freely distributed\r
13  * within development tools that are supporting such ARM based processors.\r
14  *\r
15  * @par\r
16  * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED\r
17  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\r
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.\r
19  * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR\r
20  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.\r
21  *\r
22  ******************************************************************************/\r
23 #if defined ( __ICCARM__ )\r
24  #pragma system_include  /* treat file as system include file for MISRA check */\r
25 #endif\r
26 \r
27 #ifdef __cplusplus\r
28  extern "C" {\r
29 #endif\r
30 \r
31 #ifndef __CORE_CM3_H_GENERIC\r
32 #define __CORE_CM3_H_GENERIC\r
33 \r
34 \r
35 /** \mainpage CMSIS Cortex-M3\r
36 \r
37   This documentation describes the CMSIS Cortex-M Core Peripheral Access Layer.\r
38   It consists of:\r
39 \r
40      - Cortex-M Core Register Definitions\r
41      - Cortex-M functions\r
42      - Cortex-M instructions\r
43 \r
44   The CMSIS Cortex-M3 Core Peripheral Access Layer contains C and assembly functions that ease\r
45   access to the Cortex-M Core\r
46  */\r
47 \r
48 /** \defgroup CMSIS_MISRA_Exceptions  CMSIS MISRA-C:2004 Compliance Exceptions\r
49   CMSIS violates following MISRA-C2004 Rules:\r
50   \r
51    - Violates MISRA 2004 Required Rule 8.5, object/function definition in header file.<br>\r
52      Function definitions in header files are used to allow 'inlining'. \r
53 \r
54    - Violates MISRA 2004 Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>\r
55      Unions are used for effective representation of core registers.\r
56    \r
57    - Violates MISRA 2004 Advisory Rule 19.7, Function-like macro defined.<br>\r
58      Function-like macros are used to allow more efficient code. \r
59 \r
60  */\r
61 \r
62 \r
63 /*******************************************************************************\r
64  *                 CMSIS definitions\r
65  ******************************************************************************/\r
66 /** \defgroup CMSIS_core_definitions CMSIS Core Definitions\r
67   This file defines all structures and symbols for CMSIS core:\r
68    - CMSIS version number\r
69    - Cortex-M core\r
70    - Cortex-M core Revision Number\r
71   @{\r
72  */\r
73 \r
74 /*  CMSIS CM3 definitions */\r
75 #define __CM3_CMSIS_VERSION_MAIN  (0x02)                                                       /*!< [31:16] CMSIS HAL main version */\r
76 #define __CM3_CMSIS_VERSION_SUB   (0x10)                                                       /*!< [15:0]  CMSIS HAL sub version  */\r
77 #define __CM3_CMSIS_VERSION       ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number       */\r
78 \r
79 #define __CORTEX_M                (0x03)                                                       /*!< Cortex core                    */\r
80 \r
81 \r
82 #if   defined ( __CC_ARM )\r
83   #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler          */\r
84   #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler       */\r
85 \r
86 #elif defined ( __ICCARM__ )\r
87   #define __ASM           __asm                                       /*!< asm keyword for IAR Compiler          */\r
88   #define __INLINE        inline                                      /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */\r
89 \r
90 #elif defined ( __GNUC__ )\r
91   #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler          */\r
92   #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler       */\r
93 \r
94 #elif defined ( __TASKING__ )\r
95   #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler      */\r
96   #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler   */\r
97 \r
98 #endif\r
99 \r
100 \r
101 #define __FPU_USED       0 /*!< __FPU_USED to be checked prior to making use of FPU specific registers and functions */\r
102 \r
103 #if defined ( __CC_ARM )\r
104   #if defined __TARGET_FPU_VFP\r
105     #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
106   #endif\r
107 #elif defined ( __ICCARM__ )\r
108   #if defined __ARMVFP__\r
109     #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
110   #endif\r
111 \r
112 #elif defined ( __GNUC__ )\r
113   #if defined (__VFP_FP__) && !defined(__SOFTFP__)\r
114     #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"\r
115   #endif\r
116 \r
117 #elif defined ( __TASKING__ )\r
118     /* add preprocessor checks */\r
119 #endif\r
120 \r
121 #include <stdint.h>                      /*!< standard types definitions                      */\r
122 #include "core_cmInstr.h"                /*!< Core Instruction Access                         */\r
123 #include "core_cmFunc.h"                 /*!< Core Function Access                            */\r
124 \r
125 #endif /* __CORE_CM3_H_GENERIC */\r
126 \r
127 #ifndef __CMSIS_GENERIC\r
128 \r
129 #ifndef __CORE_CM3_H_DEPENDANT\r
130 #define __CORE_CM3_H_DEPENDANT\r
131 \r
132 /* check device defines and use defaults */\r
133 #if defined __CHECK_DEVICE_DEFINES\r
134   #ifndef __CM3_REV\r
135     #define __CM3_REV               0x0200\r
136     #warning "__CM3_REV not defined in device header file; using default!"\r
137   #endif\r
138 \r
139   #ifndef __MPU_PRESENT\r
140     #define __MPU_PRESENT             0\r
141     #warning "__MPU_PRESENT not defined in device header file; using default!"\r
142   #endif\r
143 \r
144   #ifndef __NVIC_PRIO_BITS\r
145     #define __NVIC_PRIO_BITS          4\r
146     #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"\r
147   #endif\r
148 \r
149   #ifndef __Vendor_SysTickConfig\r
150     #define __Vendor_SysTickConfig    0\r
151     #warning "__Vendor_SysTickConfig not defined in device header file; using default!"\r
152   #endif\r
153 #endif\r
154 \r
155 /* IO definitions (access restrictions to peripheral registers) */\r
156 #ifdef __cplusplus\r
157   #define   __I     volatile             /*!< defines 'read only' permissions                 */\r
158 #else\r
159   #define   __I     volatile const       /*!< defines 'read only' permissions                 */\r
160 #endif\r
161 #define     __O     volatile             /*!< defines 'write only' permissions                */\r
162 #define     __IO    volatile             /*!< defines 'read / write' permissions              */\r
163 \r
164 /*@} end of group CMSIS_core_definitions */\r
165 \r
166 \r
167 \r
168 /*******************************************************************************\r
169  *                 Register Abstraction\r
170  ******************************************************************************/\r
171 /** \defgroup CMSIS_core_register CMSIS Core Register\r
172   Core Register contain:\r
173   - Core Register\r
174   - Core NVIC Register\r
175   - Core SCB Register\r
176   - Core SysTick Register\r
177   - Core Debug Register\r
178   - Core MPU Register\r
179 */\r
180 \r
181 /** \ingroup  CMSIS_core_register\r
182     \defgroup CMSIS_CORE CMSIS Core\r
183   Type definitions for the Cortex-M Core Registers\r
184   @{\r
185  */\r
186 \r
187 /** \brief  Union type to access the Application Program Status Register (APSR).\r
188  */\r
189 typedef union\r
190 {\r
191   struct\r
192   {\r
193 #if (__CORTEX_M != 0x04)\r
194     uint32_t _reserved0:27;              /*!< bit:  0..26  Reserved                           */\r
195 #else\r
196     uint32_t _reserved0:16;              /*!< bit:  0..15  Reserved                           */\r
197     uint32_t GE:4;                       /*!< bit: 16..19  Greater than or Equal flags        */\r
198     uint32_t _reserved1:7;               /*!< bit: 20..26  Reserved                           */\r
199 #endif\r
200     uint32_t Q:1;                        /*!< bit:     27  Saturation condition flag          */\r
201     uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag       */\r
202     uint32_t C:1;                        /*!< bit:     29  Carry condition code flag          */\r
203     uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag           */\r
204     uint32_t N:1;                        /*!< bit:     31  Negative condition code flag       */\r
205   } b;                                   /*!< Structure used for bit  access                  */\r
206   uint32_t w;                            /*!< Type      used for word access                  */\r
207 } APSR_Type;\r
208 \r
209 \r
210 /** \brief  Union type to access the Interrupt Program Status Register (IPSR).\r
211  */\r
212 typedef union\r
213 {\r
214   struct\r
215   {\r
216     uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number                   */\r
217     uint32_t _reserved0:23;              /*!< bit:  9..31  Reserved                           */\r
218   } b;                                   /*!< Structure used for bit  access                  */\r
219   uint32_t w;                            /*!< Type      used for word access                  */\r
220 } IPSR_Type;\r
221 \r
222 \r
223 /** \brief  Union type to access the Special-Purpose Program Status Registers (xPSR).\r
224  */\r
225 typedef union\r
226 {\r
227   struct\r
228   {\r
229     uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number                   */\r
230 #if (__CORTEX_M != 0x04)\r
231     uint32_t _reserved0:15;              /*!< bit:  9..23  Reserved                           */\r
232 #else\r
233     uint32_t _reserved0:7;               /*!< bit:  9..15  Reserved                           */\r
234     uint32_t GE:4;                       /*!< bit: 16..19  Greater than or Equal flags        */\r
235     uint32_t _reserved1:4;               /*!< bit: 20..23  Reserved                           */\r
236 #endif\r
237     uint32_t T:1;                        /*!< bit:     24  Thumb bit        (read 0)          */\r
238     uint32_t IT:2;                       /*!< bit: 25..26  saved IT state   (read 0)          */\r
239     uint32_t Q:1;                        /*!< bit:     27  Saturation condition flag          */\r
240     uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag       */\r
241     uint32_t C:1;                        /*!< bit:     29  Carry condition code flag          */\r
242     uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag           */\r
243     uint32_t N:1;                        /*!< bit:     31  Negative condition code flag       */\r
244   } b;                                   /*!< Structure used for bit  access                  */\r
245   uint32_t w;                            /*!< Type      used for word access                  */\r
246 } xPSR_Type;\r
247 \r
248 \r
249 /** \brief  Union type to access the Control Registers (CONTROL).\r
250  */\r
251 typedef union\r
252 {\r
253   struct\r
254   {\r
255     uint32_t nPRIV:1;                    /*!< bit:      0  Execution privilege in Thread mode */\r
256     uint32_t SPSEL:1;                    /*!< bit:      1  Stack to be used                   */\r
257     uint32_t FPCA:1;                     /*!< bit:      2  FP extension active flag           */\r
258     uint32_t _reserved0:29;              /*!< bit:  3..31  Reserved                           */\r
259   } b;                                   /*!< Structure used for bit  access                  */\r
260   uint32_t w;                            /*!< Type      used for word access                  */\r
261 } CONTROL_Type;\r
262 \r
263 /*@} end of group CMSIS_CORE */\r
264 \r
265 \r
266 /** \ingroup  CMSIS_core_register\r
267     \defgroup CMSIS_NVIC CMSIS NVIC\r
268   Type definitions for the Cortex-M NVIC Registers\r
269   @{\r
270  */\r
271 \r
272 /** \brief  Structure type to access the Nested Vectored Interrupt Controller (NVIC).\r
273  */\r
274 typedef struct\r
275 {\r
276   __IO uint32_t ISER[8];                 /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register           */\r
277        uint32_t RESERVED0[24];\r
278   __IO uint32_t ICER[8];                 /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register         */\r
279        uint32_t RSERVED1[24];\r
280   __IO uint32_t ISPR[8];                 /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register          */\r
281        uint32_t RESERVED2[24];\r
282   __IO uint32_t ICPR[8];                 /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register        */\r
283        uint32_t RESERVED3[24];\r
284   __IO uint32_t IABR[8];                 /*!< Offset: 0x200 (R/W)  Interrupt Active bit Register           */\r
285        uint32_t RESERVED4[56];\r
286   __IO uint8_t  IP[240];                 /*!< Offset: 0x300 (R/W)  Interrupt Priority Register (8Bit wide) */\r
287        uint32_t RESERVED5[644];\r
288   __O  uint32_t STIR;                    /*!< Offset: 0xE00 ( /W)  Software Trigger Interrupt Register     */\r
289 }  NVIC_Type;\r
290 \r
291 /* Software Triggered Interrupt Register Definitions */\r
292 #define NVIC_STIR_INTID_Pos                 0                                          /*!< STIR: INTLINESNUM Position */\r
293 #define NVIC_STIR_INTID_Msk                (0x1FFUL << NVIC_STIR_INTID_Pos)            /*!< STIR: INTLINESNUM Mask */\r
294 \r
295 /*@} end of group CMSIS_NVIC */\r
296 \r
297 \r
298 /** \ingroup  CMSIS_core_register\r
299     \defgroup CMSIS_SCB CMSIS SCB\r
300   Type definitions for the Cortex-M System Control Block Registers\r
301   @{\r
302  */\r
303 \r
304 /** \brief  Structure type to access the System Control Block (SCB).\r
305  */\r
306 typedef struct\r
307 {\r
308   __I  uint32_t CPUID;                   /*!< Offset: 0x000 (R/ )  CPUID Base Register                                   */\r
309   __IO uint32_t ICSR;                    /*!< Offset: 0x004 (R/W)  Interrupt Control and State Register                  */\r
310   __IO uint32_t VTOR;                    /*!< Offset: 0x008 (R/W)  Vector Table Offset Register                          */\r
311   __IO uint32_t AIRCR;                   /*!< Offset: 0x00C (R/W)  Application Interrupt and Reset Control Register      */\r
312   __IO uint32_t SCR;                     /*!< Offset: 0x010 (R/W)  System Control Register                               */\r
313   __IO uint32_t CCR;                     /*!< Offset: 0x014 (R/W)  Configuration Control Register                        */\r
314   __IO uint8_t  SHP[12];                 /*!< Offset: 0x018 (R/W)  System Handlers Priority Registers (4-7, 8-11, 12-15) */\r
315   __IO uint32_t SHCSR;                   /*!< Offset: 0x024 (R/W)  System Handler Control and State Register             */\r
316   __IO uint32_t CFSR;                    /*!< Offset: 0x028 (R/W)  Configurable Fault Status Register                    */\r
317   __IO uint32_t HFSR;                    /*!< Offset: 0x02C (R/W)  HardFault Status Register                             */\r
318   __IO uint32_t DFSR;                    /*!< Offset: 0x030 (R/W)  Debug Fault Status Register                           */\r
319   __IO uint32_t MMFAR;                   /*!< Offset: 0x034 (R/W)  MemManage Fault Address Register                      */\r
320   __IO uint32_t BFAR;                    /*!< Offset: 0x038 (R/W)  BusFault Address Register                             */\r
321   __IO uint32_t AFSR;                    /*!< Offset: 0x03C (R/W)  Auxiliary Fault Status Register                       */\r
322   __I  uint32_t PFR[2];                  /*!< Offset: 0x040 (R/ )  Processor Feature Register                            */\r
323   __I  uint32_t DFR;                     /*!< Offset: 0x048 (R/ )  Debug Feature Register                                */\r
324   __I  uint32_t ADR;                     /*!< Offset: 0x04C (R/ )  Auxiliary Feature Register                            */\r
325   __I  uint32_t MMFR[4];                 /*!< Offset: 0x050 (R/ )  Memory Model Feature Register                         */\r
326   __I  uint32_t ISAR[5];                 /*!< Offset: 0x060 (R/ )  Instruction Set Attributes Register                   */\r
327        uint32_t RESERVED0[5];\r
328   __IO uint32_t CPACR;                   /*!< Offset: 0x088 (R/W)  Coprocessor Access Control Register                   */\r
329 } SCB_Type;\r
330 \r
331 /* SCB CPUID Register Definitions */\r
332 #define SCB_CPUID_IMPLEMENTER_Pos          24                                             /*!< SCB CPUID: IMPLEMENTER Position */\r
333 #define SCB_CPUID_IMPLEMENTER_Msk          (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */\r
334 \r
335 #define SCB_CPUID_VARIANT_Pos              20                                             /*!< SCB CPUID: VARIANT Position */\r
336 #define SCB_CPUID_VARIANT_Msk              (0xFUL << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */\r
337 \r
338 #define SCB_CPUID_ARCHITECTURE_Pos         16                                             /*!< SCB CPUID: ARCHITECTURE Position */\r
339 #define SCB_CPUID_ARCHITECTURE_Msk         (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)          /*!< SCB CPUID: ARCHITECTURE Mask */\r
340 \r
341 #define SCB_CPUID_PARTNO_Pos                4                                             /*!< SCB CPUID: PARTNO Position */\r
342 #define SCB_CPUID_PARTNO_Msk               (0xFFFUL << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */\r
343 \r
344 #define SCB_CPUID_REVISION_Pos              0                                             /*!< SCB CPUID: REVISION Position */\r
345 #define SCB_CPUID_REVISION_Msk             (0xFUL << SCB_CPUID_REVISION_Pos)              /*!< SCB CPUID: REVISION Mask */\r
346 \r
347 /* SCB Interrupt Control State Register Definitions */\r
348 #define SCB_ICSR_NMIPENDSET_Pos            31                                             /*!< SCB ICSR: NMIPENDSET Position */\r
349 #define SCB_ICSR_NMIPENDSET_Msk            (1UL << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */\r
350 \r
351 #define SCB_ICSR_PENDSVSET_Pos             28                                             /*!< SCB ICSR: PENDSVSET Position */\r
352 #define SCB_ICSR_PENDSVSET_Msk             (1UL << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */\r
353 \r
354 #define SCB_ICSR_PENDSVCLR_Pos             27                                             /*!< SCB ICSR: PENDSVCLR Position */\r
355 #define SCB_ICSR_PENDSVCLR_Msk             (1UL << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */\r
356 \r
357 #define SCB_ICSR_PENDSTSET_Pos             26                                             /*!< SCB ICSR: PENDSTSET Position */\r
358 #define SCB_ICSR_PENDSTSET_Msk             (1UL << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */\r
359 \r
360 #define SCB_ICSR_PENDSTCLR_Pos             25                                             /*!< SCB ICSR: PENDSTCLR Position */\r
361 #define SCB_ICSR_PENDSTCLR_Msk             (1UL << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */\r
362 \r
363 #define SCB_ICSR_ISRPREEMPT_Pos            23                                             /*!< SCB ICSR: ISRPREEMPT Position */\r
364 #define SCB_ICSR_ISRPREEMPT_Msk            (1UL << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */\r
365 \r
366 #define SCB_ICSR_ISRPENDING_Pos            22                                             /*!< SCB ICSR: ISRPENDING Position */\r
367 #define SCB_ICSR_ISRPENDING_Msk            (1UL << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */\r
368 \r
369 #define SCB_ICSR_VECTPENDING_Pos           12                                             /*!< SCB ICSR: VECTPENDING Position */\r
370 #define SCB_ICSR_VECTPENDING_Msk           (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */\r
371 \r
372 #define SCB_ICSR_RETTOBASE_Pos             11                                             /*!< SCB ICSR: RETTOBASE Position */\r
373 #define SCB_ICSR_RETTOBASE_Msk             (1UL << SCB_ICSR_RETTOBASE_Pos)                /*!< SCB ICSR: RETTOBASE Mask */\r
374 \r
375 #define SCB_ICSR_VECTACTIVE_Pos             0                                             /*!< SCB ICSR: VECTACTIVE Position */\r
376 #define SCB_ICSR_VECTACTIVE_Msk            (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos)           /*!< SCB ICSR: VECTACTIVE Mask */\r
377 \r
378 /* SCB Vector Table Offset Register Definitions */\r
379 #if (__CM3_REV < 0x0201)                   /* core r2p1 */\r
380 #define SCB_VTOR_TBLBASE_Pos               29                                             /*!< SCB VTOR: TBLBASE Position */\r
381 #define SCB_VTOR_TBLBASE_Msk               (1UL << SCB_VTOR_TBLBASE_Pos)                  /*!< SCB VTOR: TBLBASE Mask */\r
382 \r
383 #define SCB_VTOR_TBLOFF_Pos                 7                                             /*!< SCB VTOR: TBLOFF Position */\r
384 #define SCB_VTOR_TBLOFF_Msk                (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos)            /*!< SCB VTOR: TBLOFF Mask */\r
385 #else\r
386 #define SCB_VTOR_TBLOFF_Pos                 7                                             /*!< SCB VTOR: TBLOFF Position */\r
387 #define SCB_VTOR_TBLOFF_Msk                (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos)           /*!< SCB VTOR: TBLOFF Mask */\r
388 #endif\r
389 \r
390 /* SCB Application Interrupt and Reset Control Register Definitions */\r
391 #define SCB_AIRCR_VECTKEY_Pos              16                                             /*!< SCB AIRCR: VECTKEY Position */\r
392 #define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */\r
393 \r
394 #define SCB_AIRCR_VECTKEYSTAT_Pos          16                                             /*!< SCB AIRCR: VECTKEYSTAT Position */\r
395 #define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */\r
396 \r
397 #define SCB_AIRCR_ENDIANESS_Pos            15                                             /*!< SCB AIRCR: ENDIANESS Position */\r
398 #define SCB_AIRCR_ENDIANESS_Msk            (1UL << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */\r
399 \r
400 #define SCB_AIRCR_PRIGROUP_Pos              8                                             /*!< SCB AIRCR: PRIGROUP Position */\r
401 #define SCB_AIRCR_PRIGROUP_Msk             (7UL << SCB_AIRCR_PRIGROUP_Pos)                /*!< SCB AIRCR: PRIGROUP Mask */\r
402 \r
403 #define SCB_AIRCR_SYSRESETREQ_Pos           2                                             /*!< SCB AIRCR: SYSRESETREQ Position */\r
404 #define SCB_AIRCR_SYSRESETREQ_Msk          (1UL << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */\r
405 \r
406 #define SCB_AIRCR_VECTCLRACTIVE_Pos         1                                             /*!< SCB AIRCR: VECTCLRACTIVE Position */\r
407 #define SCB_AIRCR_VECTCLRACTIVE_Msk        (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */\r
408 \r
409 #define SCB_AIRCR_VECTRESET_Pos             0                                             /*!< SCB AIRCR: VECTRESET Position */\r
410 #define SCB_AIRCR_VECTRESET_Msk            (1UL << SCB_AIRCR_VECTRESET_Pos)               /*!< SCB AIRCR: VECTRESET Mask */\r
411 \r
412 /* SCB System Control Register Definitions */\r
413 #define SCB_SCR_SEVONPEND_Pos               4                                             /*!< SCB SCR: SEVONPEND Position */\r
414 #define SCB_SCR_SEVONPEND_Msk              (1UL << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */\r
415 \r
416 #define SCB_SCR_SLEEPDEEP_Pos               2                                             /*!< SCB SCR: SLEEPDEEP Position */\r
417 #define SCB_SCR_SLEEPDEEP_Msk              (1UL << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */\r
418 \r
419 #define SCB_SCR_SLEEPONEXIT_Pos             1                                             /*!< SCB SCR: SLEEPONEXIT Position */\r
420 #define SCB_SCR_SLEEPONEXIT_Msk            (1UL << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */\r
421 \r
422 /* SCB Configuration Control Register Definitions */\r
423 #define SCB_CCR_STKALIGN_Pos                9                                             /*!< SCB CCR: STKALIGN Position */\r
424 #define SCB_CCR_STKALIGN_Msk               (1UL << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */\r
425 \r
426 #define SCB_CCR_BFHFNMIGN_Pos               8                                             /*!< SCB CCR: BFHFNMIGN Position */\r
427 #define SCB_CCR_BFHFNMIGN_Msk              (1UL << SCB_CCR_BFHFNMIGN_Pos)                 /*!< SCB CCR: BFHFNMIGN Mask */\r
428 \r
429 #define SCB_CCR_DIV_0_TRP_Pos               4                                             /*!< SCB CCR: DIV_0_TRP Position */\r
430 #define SCB_CCR_DIV_0_TRP_Msk              (1UL << SCB_CCR_DIV_0_TRP_Pos)                 /*!< SCB CCR: DIV_0_TRP Mask */\r
431 \r
432 #define SCB_CCR_UNALIGN_TRP_Pos             3                                             /*!< SCB CCR: UNALIGN_TRP Position */\r
433 #define SCB_CCR_UNALIGN_TRP_Msk            (1UL << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */\r
434 \r
435 #define SCB_CCR_USERSETMPEND_Pos            1                                             /*!< SCB CCR: USERSETMPEND Position */\r
436 #define SCB_CCR_USERSETMPEND_Msk           (1UL << SCB_CCR_USERSETMPEND_Pos)              /*!< SCB CCR: USERSETMPEND Mask */\r
437 \r
438 #define SCB_CCR_NONBASETHRDENA_Pos          0                                             /*!< SCB CCR: NONBASETHRDENA Position */\r
439 #define SCB_CCR_NONBASETHRDENA_Msk         (1UL << SCB_CCR_NONBASETHRDENA_Pos)            /*!< SCB CCR: NONBASETHRDENA Mask */\r
440 \r
441 /* SCB System Handler Control and State Register Definitions */\r
442 #define SCB_SHCSR_USGFAULTENA_Pos          18                                             /*!< SCB SHCSR: USGFAULTENA Position */\r
443 #define SCB_SHCSR_USGFAULTENA_Msk          (1UL << SCB_SHCSR_USGFAULTENA_Pos)             /*!< SCB SHCSR: USGFAULTENA Mask */\r
444 \r
445 #define SCB_SHCSR_BUSFAULTENA_Pos          17                                             /*!< SCB SHCSR: BUSFAULTENA Position */\r
446 #define SCB_SHCSR_BUSFAULTENA_Msk          (1UL << SCB_SHCSR_BUSFAULTENA_Pos)             /*!< SCB SHCSR: BUSFAULTENA Mask */\r
447 \r
448 #define SCB_SHCSR_MEMFAULTENA_Pos          16                                             /*!< SCB SHCSR: MEMFAULTENA Position */\r
449 #define SCB_SHCSR_MEMFAULTENA_Msk          (1UL << SCB_SHCSR_MEMFAULTENA_Pos)             /*!< SCB SHCSR: MEMFAULTENA Mask */\r
450 \r
451 #define SCB_SHCSR_SVCALLPENDED_Pos         15                                             /*!< SCB SHCSR: SVCALLPENDED Position */\r
452 #define SCB_SHCSR_SVCALLPENDED_Msk         (1UL << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */\r
453 \r
454 #define SCB_SHCSR_BUSFAULTPENDED_Pos       14                                             /*!< SCB SHCSR: BUSFAULTPENDED Position */\r
455 #define SCB_SHCSR_BUSFAULTPENDED_Msk       (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos)          /*!< SCB SHCSR: BUSFAULTPENDED Mask */\r
456 \r
457 #define SCB_SHCSR_MEMFAULTPENDED_Pos       13                                             /*!< SCB SHCSR: MEMFAULTPENDED Position */\r
458 #define SCB_SHCSR_MEMFAULTPENDED_Msk       (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos)          /*!< SCB SHCSR: MEMFAULTPENDED Mask */\r
459 \r
460 #define SCB_SHCSR_USGFAULTPENDED_Pos       12                                             /*!< SCB SHCSR: USGFAULTPENDED Position */\r
461 #define SCB_SHCSR_USGFAULTPENDED_Msk       (1UL << SCB_SHCSR_USGFAULTPENDED_Pos)          /*!< SCB SHCSR: USGFAULTPENDED Mask */\r
462 \r
463 #define SCB_SHCSR_SYSTICKACT_Pos           11                                             /*!< SCB SHCSR: SYSTICKACT Position */\r
464 #define SCB_SHCSR_SYSTICKACT_Msk           (1UL << SCB_SHCSR_SYSTICKACT_Pos)              /*!< SCB SHCSR: SYSTICKACT Mask */\r
465 \r
466 #define SCB_SHCSR_PENDSVACT_Pos            10                                             /*!< SCB SHCSR: PENDSVACT Position */\r
467 #define SCB_SHCSR_PENDSVACT_Msk            (1UL << SCB_SHCSR_PENDSVACT_Pos)               /*!< SCB SHCSR: PENDSVACT Mask */\r
468 \r
469 #define SCB_SHCSR_MONITORACT_Pos            8                                             /*!< SCB SHCSR: MONITORACT Position */\r
470 #define SCB_SHCSR_MONITORACT_Msk           (1UL << SCB_SHCSR_MONITORACT_Pos)              /*!< SCB SHCSR: MONITORACT Mask */\r
471 \r
472 #define SCB_SHCSR_SVCALLACT_Pos             7                                             /*!< SCB SHCSR: SVCALLACT Position */\r
473 #define SCB_SHCSR_SVCALLACT_Msk            (1UL << SCB_SHCSR_SVCALLACT_Pos)               /*!< SCB SHCSR: SVCALLACT Mask */\r
474 \r
475 #define SCB_SHCSR_USGFAULTACT_Pos           3                                             /*!< SCB SHCSR: USGFAULTACT Position */\r
476 #define SCB_SHCSR_USGFAULTACT_Msk          (1UL << SCB_SHCSR_USGFAULTACT_Pos)             /*!< SCB SHCSR: USGFAULTACT Mask */\r
477 \r
478 #define SCB_SHCSR_BUSFAULTACT_Pos           1                                             /*!< SCB SHCSR: BUSFAULTACT Position */\r
479 #define SCB_SHCSR_BUSFAULTACT_Msk          (1UL << SCB_SHCSR_BUSFAULTACT_Pos)             /*!< SCB SHCSR: BUSFAULTACT Mask */\r
480 \r
481 #define SCB_SHCSR_MEMFAULTACT_Pos           0                                             /*!< SCB SHCSR: MEMFAULTACT Position */\r
482 #define SCB_SHCSR_MEMFAULTACT_Msk          (1UL << SCB_SHCSR_MEMFAULTACT_Pos)             /*!< SCB SHCSR: MEMFAULTACT Mask */\r
483 \r
484 /* SCB Configurable Fault Status Registers Definitions */\r
485 #define SCB_CFSR_USGFAULTSR_Pos            16                                             /*!< SCB CFSR: Usage Fault Status Register Position */\r
486 #define SCB_CFSR_USGFAULTSR_Msk            (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos)          /*!< SCB CFSR: Usage Fault Status Register Mask */\r
487 \r
488 #define SCB_CFSR_BUSFAULTSR_Pos             8                                             /*!< SCB CFSR: Bus Fault Status Register Position */\r
489 #define SCB_CFSR_BUSFAULTSR_Msk            (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos)            /*!< SCB CFSR: Bus Fault Status Register Mask */\r
490 \r
491 #define SCB_CFSR_MEMFAULTSR_Pos             0                                             /*!< SCB CFSR: Memory Manage Fault Status Register Position */\r
492 #define SCB_CFSR_MEMFAULTSR_Msk            (0xFFUL << SCB_CFSR_MEMFAULTSR_Pos)            /*!< SCB CFSR: Memory Manage Fault Status Register Mask */\r
493 \r
494 /* SCB Hard Fault Status Registers Definitions */\r
495 #define SCB_HFSR_DEBUGEVT_Pos              31                                             /*!< SCB HFSR: DEBUGEVT Position */\r
496 #define SCB_HFSR_DEBUGEVT_Msk              (1UL << SCB_HFSR_DEBUGEVT_Pos)                 /*!< SCB HFSR: DEBUGEVT Mask */\r
497 \r
498 #define SCB_HFSR_FORCED_Pos                30                                             /*!< SCB HFSR: FORCED Position */\r
499 #define SCB_HFSR_FORCED_Msk                (1UL << SCB_HFSR_FORCED_Pos)                   /*!< SCB HFSR: FORCED Mask */\r
500 \r
501 #define SCB_HFSR_VECTTBL_Pos                1                                             /*!< SCB HFSR: VECTTBL Position */\r
502 #define SCB_HFSR_VECTTBL_Msk               (1UL << SCB_HFSR_VECTTBL_Pos)                  /*!< SCB HFSR: VECTTBL Mask */\r
503 \r
504 /* SCB Debug Fault Status Register Definitions */\r
505 #define SCB_DFSR_EXTERNAL_Pos               4                                             /*!< SCB DFSR: EXTERNAL Position */\r
506 #define SCB_DFSR_EXTERNAL_Msk              (1UL << SCB_DFSR_EXTERNAL_Pos)                 /*!< SCB DFSR: EXTERNAL Mask */\r
507 \r
508 #define SCB_DFSR_VCATCH_Pos                 3                                             /*!< SCB DFSR: VCATCH Position */\r
509 #define SCB_DFSR_VCATCH_Msk                (1UL << SCB_DFSR_VCATCH_Pos)                   /*!< SCB DFSR: VCATCH Mask */\r
510 \r
511 #define SCB_DFSR_DWTTRAP_Pos                2                                             /*!< SCB DFSR: DWTTRAP Position */\r
512 #define SCB_DFSR_DWTTRAP_Msk               (1UL << SCB_DFSR_DWTTRAP_Pos)                  /*!< SCB DFSR: DWTTRAP Mask */\r
513 \r
514 #define SCB_DFSR_BKPT_Pos                   1                                             /*!< SCB DFSR: BKPT Position */\r
515 #define SCB_DFSR_BKPT_Msk                  (1UL << SCB_DFSR_BKPT_Pos)                     /*!< SCB DFSR: BKPT Mask */\r
516 \r
517 #define SCB_DFSR_HALTED_Pos                 0                                             /*!< SCB DFSR: HALTED Position */\r
518 #define SCB_DFSR_HALTED_Msk                (1UL << SCB_DFSR_HALTED_Pos)                   /*!< SCB DFSR: HALTED Mask */\r
519 \r
520 /*@} end of group CMSIS_SCB */\r
521 \r
522 \r
523 /** \ingroup  CMSIS_core_register\r
524     \defgroup CMSIS_SCnSCB CMSIS System Control and ID Register not in the SCB\r
525   Type definitions for the Cortex-M System Control and ID Register not in the SCB\r
526   @{\r
527  */\r
528 \r
529 /** \brief  Structure type to access the System Control and ID Register not in the SCB.\r
530  */\r
531 typedef struct\r
532 {\r
533        uint32_t RESERVED0[1];\r
534   __I  uint32_t ICTR;                    /*!< Offset: 0x004 (R/ )  Interrupt Controller Type Register      */\r
535 #if ((defined __CM3_REV) && (__CM3_REV >= 0x200))\r
536   __IO uint32_t ACTLR;                   /*!< Offset: 0x008 (R/W)  Auxiliary Control Register      */\r
537 #else\r
538        uint32_t RESERVED1[1];\r
539 #endif\r
540 } SCnSCB_Type;\r
541 \r
542 /* Interrupt Controller Type Register Definitions */\r
543 #define SCnSCB_ICTR_INTLINESNUM_Pos         0                                          /*!< ICTR: INTLINESNUM Position */\r
544 #define SCnSCB_ICTR_INTLINESNUM_Msk        (0xFUL << SCnSCB_ICTR_INTLINESNUM_Pos)      /*!< ICTR: INTLINESNUM Mask */\r
545 \r
546 /* Auxiliary Control Register Definitions */\r
547 \r
548 #define SCnSCB_ACTLR_DISFOLD_Pos            2                                          /*!< ACTLR: DISFOLD Position */\r
549 #define SCnSCB_ACTLR_DISFOLD_Msk           (1UL << SCnSCB_ACTLR_DISFOLD_Pos)           /*!< ACTLR: DISFOLD Mask */\r
550 \r
551 #define SCnSCB_ACTLR_DISDEFWBUF_Pos         1                                          /*!< ACTLR: DISDEFWBUF Position */\r
552 #define SCnSCB_ACTLR_DISDEFWBUF_Msk        (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos)        /*!< ACTLR: DISDEFWBUF Mask */\r
553 \r
554 #define SCnSCB_ACTLR_DISMCYCINT_Pos         0                                          /*!< ACTLR: DISMCYCINT Position */\r
555 #define SCnSCB_ACTLR_DISMCYCINT_Msk        (1UL << SCnSCB_ACTLR_DISMCYCINT_Pos)        /*!< ACTLR: DISMCYCINT Mask */\r
556 \r
557 /*@} end of group CMSIS_SCnotSCB */\r
558 \r
559 \r
560 /** \ingroup  CMSIS_core_register\r
561     \defgroup CMSIS_SysTick CMSIS SysTick\r
562   Type definitions for the Cortex-M System Timer Registers\r
563   @{\r
564  */\r
565 \r
566 /** \brief  Structure type to access the System Timer (SysTick).\r
567  */\r
568 typedef struct\r
569 {\r
570   __IO uint32_t CTRL;                    /*!< Offset: 0x000 (R/W)  SysTick Control and Status Register */\r
571   __IO uint32_t LOAD;                    /*!< Offset: 0x004 (R/W)  SysTick Reload Value Register       */\r
572   __IO uint32_t VAL;                     /*!< Offset: 0x008 (R/W)  SysTick Current Value Register      */\r
573   __I  uint32_t CALIB;                   /*!< Offset: 0x00C (R/ )  SysTick Calibration Register        */\r
574 } SysTick_Type;\r
575 \r
576 /* SysTick Control / Status Register Definitions */\r
577 #define SysTick_CTRL_COUNTFLAG_Pos         16                                             /*!< SysTick CTRL: COUNTFLAG Position */\r
578 #define SysTick_CTRL_COUNTFLAG_Msk         (1UL << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */\r
579 \r
580 #define SysTick_CTRL_CLKSOURCE_Pos          2                                             /*!< SysTick CTRL: CLKSOURCE Position */\r
581 #define SysTick_CTRL_CLKSOURCE_Msk         (1UL << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */\r
582 \r
583 #define SysTick_CTRL_TICKINT_Pos            1                                             /*!< SysTick CTRL: TICKINT Position */\r
584 #define SysTick_CTRL_TICKINT_Msk           (1UL << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */\r
585 \r
586 #define SysTick_CTRL_ENABLE_Pos             0                                             /*!< SysTick CTRL: ENABLE Position */\r
587 #define SysTick_CTRL_ENABLE_Msk            (1UL << SysTick_CTRL_ENABLE_Pos)               /*!< SysTick CTRL: ENABLE Mask */\r
588 \r
589 /* SysTick Reload Register Definitions */\r
590 #define SysTick_LOAD_RELOAD_Pos             0                                             /*!< SysTick LOAD: RELOAD Position */\r
591 #define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos)        /*!< SysTick LOAD: RELOAD Mask */\r
592 \r
593 /* SysTick Current Register Definitions */\r
594 #define SysTick_VAL_CURRENT_Pos             0                                             /*!< SysTick VAL: CURRENT Position */\r
595 #define SysTick_VAL_CURRENT_Msk            (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)        /*!< SysTick VAL: CURRENT Mask */\r
596 \r
597 /* SysTick Calibration Register Definitions */\r
598 #define SysTick_CALIB_NOREF_Pos            31                                             /*!< SysTick CALIB: NOREF Position */\r
599 #define SysTick_CALIB_NOREF_Msk            (1UL << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */\r
600 \r
601 #define SysTick_CALIB_SKEW_Pos             30                                             /*!< SysTick CALIB: SKEW Position */\r
602 #define SysTick_CALIB_SKEW_Msk             (1UL << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */\r
603 \r
604 #define SysTick_CALIB_TENMS_Pos             0                                             /*!< SysTick CALIB: TENMS Position */\r
605 #define SysTick_CALIB_TENMS_Msk            (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)        /*!< SysTick CALIB: TENMS Mask */\r
606 \r
607 /*@} end of group CMSIS_SysTick */\r
608 \r
609 \r
610 /** \ingroup  CMSIS_core_register\r
611     \defgroup CMSIS_ITM CMSIS ITM\r
612   Type definitions for the Cortex-M Instrumentation Trace Macrocell (ITM)\r
613   @{\r
614  */\r
615 \r
616 /** \brief  Structure type to access the Instrumentation Trace Macrocell Register (ITM).\r
617  */\r
618 typedef struct\r
619 {\r
620   __O  union\r
621   {\r
622     __O  uint8_t    u8;                  /*!< Offset: 0x000 ( /W)  ITM Stimulus Port 8-bit                   */\r
623     __O  uint16_t   u16;                 /*!< Offset: 0x000 ( /W)  ITM Stimulus Port 16-bit                  */\r
624     __O  uint32_t   u32;                 /*!< Offset: 0x000 ( /W)  ITM Stimulus Port 32-bit                  */\r
625   }  PORT [32];                          /*!< Offset: 0x000 ( /W)  ITM Stimulus Port Registers               */\r
626        uint32_t RESERVED0[864];\r
627   __IO uint32_t TER;                     /*!< Offset: 0xE00 (R/W)  ITM Trace Enable Register                 */\r
628        uint32_t RESERVED1[15];\r
629   __IO uint32_t TPR;                     /*!< Offset: 0xE40 (R/W)  ITM Trace Privilege Register              */\r
630        uint32_t RESERVED2[15];\r
631   __IO uint32_t TCR;                     /*!< Offset: 0xE80 (R/W)  ITM Trace Control Register                */\r
632 } ITM_Type;\r
633 \r
634 /* ITM Trace Privilege Register Definitions */\r
635 #define ITM_TPR_PRIVMASK_Pos                0                                          /*!< ITM TPR: PRIVMASK Position */\r
636 #define ITM_TPR_PRIVMASK_Msk               (0xFUL << ITM_TPR_PRIVMASK_Pos)             /*!< ITM TPR: PRIVMASK Mask */\r
637 \r
638 /* ITM Trace Control Register Definitions */\r
639 #define ITM_TCR_BUSY_Pos                   23                                          /*!< ITM TCR: BUSY Position */\r
640 #define ITM_TCR_BUSY_Msk                   (1UL << ITM_TCR_BUSY_Pos)                   /*!< ITM TCR: BUSY Mask */\r
641 \r
642 #define ITM_TCR_TraceBusID_Pos             16                                          /*!< ITM TCR: ATBID Position */\r
643 #define ITM_TCR_TraceBusID_Msk             (0x7FUL << ITM_TCR_TraceBusID_Pos)          /*!< ITM TCR: ATBID Mask */\r
644 \r
645 #define ITM_TCR_GTSFREQ_Pos                10                                          /*!< ITM TCR: Global timestamp frequency Position */\r
646 #define ITM_TCR_GTSFREQ_Msk                (3UL << ITM_TCR_GTSFREQ_Pos)                /*!< ITM TCR: Global timestamp frequency Mask */\r
647 \r
648 #define ITM_TCR_TSPrescale_Pos              8                                          /*!< ITM TCR: TSPrescale Position */\r
649 #define ITM_TCR_TSPrescale_Msk             (3UL << ITM_TCR_TSPrescale_Pos)             /*!< ITM TCR: TSPrescale Mask */\r
650 \r
651 #define ITM_TCR_SWOENA_Pos                  4                                          /*!< ITM TCR: SWOENA Position */\r
652 #define ITM_TCR_SWOENA_Msk                 (1UL << ITM_TCR_SWOENA_Pos)                 /*!< ITM TCR: SWOENA Mask */\r
653 \r
654 #define ITM_TCR_TXENA_Pos                   3                                          /*!< ITM TCR: TXENA Position */\r
655 #define ITM_TCR_TXENA_Msk                  (1UL << ITM_TCR_TXENA_Pos)                  /*!< ITM TCR: TXENA Mask */\r
656 \r
657 #define ITM_TCR_SYNCENA_Pos                 2                                          /*!< ITM TCR: SYNCENA Position */\r
658 #define ITM_TCR_SYNCENA_Msk                (1UL << ITM_TCR_SYNCENA_Pos)                /*!< ITM TCR: SYNCENA Mask */\r
659 \r
660 #define ITM_TCR_TSENA_Pos                   1                                          /*!< ITM TCR: TSENA Position */\r
661 #define ITM_TCR_TSENA_Msk                  (1UL << ITM_TCR_TSENA_Pos)                  /*!< ITM TCR: TSENA Mask */\r
662 \r
663 #define ITM_TCR_ITMENA_Pos                  0                                          /*!< ITM TCR: ITM Enable bit Position */\r
664 #define ITM_TCR_ITMENA_Msk                 (1UL << ITM_TCR_ITMENA_Pos)                 /*!< ITM TCR: ITM Enable bit Mask */\r
665 \r
666 /*@}*/ /* end of group CMSIS_ITM */\r
667 \r
668 \r
669 #if (__MPU_PRESENT == 1)\r
670 /** \ingroup  CMSIS_core_register\r
671     \defgroup CMSIS_MPU CMSIS MPU\r
672   Type definitions for the Cortex-M Memory Protection Unit (MPU)\r
673   @{\r
674  */\r
675 \r
676 /** \brief  Structure type to access the Memory Protection Unit (MPU).\r
677  */\r
678 typedef struct\r
679 {\r
680   __I  uint32_t TYPE;                    /*!< Offset: 0x000 (R/ )  MPU Type Register                              */\r
681   __IO uint32_t CTRL;                    /*!< Offset: 0x004 (R/W)  MPU Control Register                           */\r
682   __IO uint32_t RNR;                     /*!< Offset: 0x008 (R/W)  MPU Region RNRber Register                     */\r
683   __IO uint32_t RBAR;                    /*!< Offset: 0x00C (R/W)  MPU Region Base Address Register               */\r
684   __IO uint32_t RASR;                    /*!< Offset: 0x010 (R/W)  MPU Region Attribute and Size Register         */\r
685   __IO uint32_t RBAR_A1;                 /*!< Offset: 0x014 (R/W)  MPU Alias 1 Region Base Address Register       */\r
686   __IO uint32_t RASR_A1;                 /*!< Offset: 0x018 (R/W)  MPU Alias 1 Region Attribute and Size Register */\r
687   __IO uint32_t RBAR_A2;                 /*!< Offset: 0x01C (R/W)  MPU Alias 2 Region Base Address Register       */\r
688   __IO uint32_t RASR_A2;                 /*!< Offset: 0x020 (R/W)  MPU Alias 2 Region Attribute and Size Register */\r
689   __IO uint32_t RBAR_A3;                 /*!< Offset: 0x024 (R/W)  MPU Alias 3 Region Base Address Register       */\r
690   __IO uint32_t RASR_A3;                 /*!< Offset: 0x028 (R/W)  MPU Alias 3 Region Attribute and Size Register */\r
691 } MPU_Type;\r
692 \r
693 /* MPU Type Register */\r
694 #define MPU_TYPE_IREGION_Pos               16                                             /*!< MPU TYPE: IREGION Position */\r
695 #define MPU_TYPE_IREGION_Msk               (0xFFUL << MPU_TYPE_IREGION_Pos)               /*!< MPU TYPE: IREGION Mask */\r
696 \r
697 #define MPU_TYPE_DREGION_Pos                8                                             /*!< MPU TYPE: DREGION Position */\r
698 #define MPU_TYPE_DREGION_Msk               (0xFFUL << MPU_TYPE_DREGION_Pos)               /*!< MPU TYPE: DREGION Mask */\r
699 \r
700 #define MPU_TYPE_SEPARATE_Pos               0                                             /*!< MPU TYPE: SEPARATE Position */\r
701 #define MPU_TYPE_SEPARATE_Msk              (1UL << MPU_TYPE_SEPARATE_Pos)                 /*!< MPU TYPE: SEPARATE Mask */\r
702 \r
703 /* MPU Control Register */\r
704 #define MPU_CTRL_PRIVDEFENA_Pos             2                                             /*!< MPU CTRL: PRIVDEFENA Position */\r
705 #define MPU_CTRL_PRIVDEFENA_Msk            (1UL << MPU_CTRL_PRIVDEFENA_Pos)               /*!< MPU CTRL: PRIVDEFENA Mask */\r
706 \r
707 #define MPU_CTRL_HFNMIENA_Pos               1                                             /*!< MPU CTRL: HFNMIENA Position */\r
708 #define MPU_CTRL_HFNMIENA_Msk              (1UL << MPU_CTRL_HFNMIENA_Pos)                 /*!< MPU CTRL: HFNMIENA Mask */\r
709 \r
710 #define MPU_CTRL_ENABLE_Pos                 0                                             /*!< MPU CTRL: ENABLE Position */\r
711 #define MPU_CTRL_ENABLE_Msk                (1UL << MPU_CTRL_ENABLE_Pos)                   /*!< MPU CTRL: ENABLE Mask */\r
712 \r
713 /* MPU Region Number Register */\r
714 #define MPU_RNR_REGION_Pos                  0                                             /*!< MPU RNR: REGION Position */\r
715 #define MPU_RNR_REGION_Msk                 (0xFFUL << MPU_RNR_REGION_Pos)                 /*!< MPU RNR: REGION Mask */\r
716 \r
717 /* MPU Region Base Address Register */\r
718 #define MPU_RBAR_ADDR_Pos                   5                                             /*!< MPU RBAR: ADDR Position */\r
719 #define MPU_RBAR_ADDR_Msk                  (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos)             /*!< MPU RBAR: ADDR Mask */\r
720 \r
721 #define MPU_RBAR_VALID_Pos                  4                                             /*!< MPU RBAR: VALID Position */\r
722 #define MPU_RBAR_VALID_Msk                 (1UL << MPU_RBAR_VALID_Pos)                    /*!< MPU RBAR: VALID Mask */\r
723 \r
724 #define MPU_RBAR_REGION_Pos                 0                                             /*!< MPU RBAR: REGION Position */\r
725 #define MPU_RBAR_REGION_Msk                (0xFUL << MPU_RBAR_REGION_Pos)                 /*!< MPU RBAR: REGION Mask */\r
726 \r
727 /* MPU Region Attribute and Size Register */\r
728 #define MPU_RASR_ATTRS_Pos                 16                                             /*!< MPU RASR: MPU Region Attribute field Position */\r
729 #define MPU_RASR_ATTRS_Msk                 (0xFFFFUL << MPU_RASR_ATTRS_Pos)               /*!< MPU RASR: MPU Region Attribute field Mask */\r
730 \r
731 #define MPU_RASR_SRD_Pos                    8                                             /*!< MPU RASR: Sub-Region Disable Position */\r
732 #define MPU_RASR_SRD_Msk                   (0xFFUL << MPU_RASR_SRD_Pos)                   /*!< MPU RASR: Sub-Region Disable Mask */\r
733 \r
734 #define MPU_RASR_SIZE_Pos                   1                                             /*!< MPU RASR: Region Size Field Position */\r
735 #define MPU_RASR_SIZE_Msk                  (0x1FUL << MPU_RASR_SIZE_Pos)                  /*!< MPU RASR: Region Size Field Mask */\r
736 \r
737 #define MPU_RASR_ENABLE_Pos                 0                                             /*!< MPU RASR: Region enable bit Position */\r
738 #define MPU_RASR_ENABLE_Msk                (1UL << MPU_RASR_ENABLE_Pos)                   /*!< MPU RASR: Region enable bit Disable Mask */\r
739 \r
740 /*@} end of group CMSIS_MPU */\r
741 #endif\r
742 \r
743 \r
744 /** \ingroup  CMSIS_core_register\r
745     \defgroup CMSIS_CoreDebug CMSIS Core Debug\r
746   Type definitions for the Cortex-M Core Debug Registers\r
747   @{\r
748  */\r
749 \r
750 /** \brief  Structure type to access the Core Debug Register (CoreDebug).\r
751  */\r
752 typedef struct\r
753 {\r
754   __IO uint32_t DHCSR;                   /*!< Offset: 0x000 (R/W)  Debug Halting Control and Status Register    */\r
755   __O  uint32_t DCRSR;                   /*!< Offset: 0x004 ( /W)  Debug Core Register Selector Register        */\r
756   __IO uint32_t DCRDR;                   /*!< Offset: 0x008 (R/W)  Debug Core Register Data Register            */\r
757   __IO uint32_t DEMCR;                   /*!< Offset: 0x00C (R/W)  Debug Exception and Monitor Control Register */\r
758 } CoreDebug_Type;\r
759 \r
760 /* Debug Halting Control and Status Register */\r
761 #define CoreDebug_DHCSR_DBGKEY_Pos         16                                             /*!< CoreDebug DHCSR: DBGKEY Position */\r
762 #define CoreDebug_DHCSR_DBGKEY_Msk         (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos)       /*!< CoreDebug DHCSR: DBGKEY Mask */\r
763 \r
764 #define CoreDebug_DHCSR_S_RESET_ST_Pos     25                                             /*!< CoreDebug DHCSR: S_RESET_ST Position */\r
765 #define CoreDebug_DHCSR_S_RESET_ST_Msk     (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos)        /*!< CoreDebug DHCSR: S_RESET_ST Mask */\r
766 \r
767 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos    24                                             /*!< CoreDebug DHCSR: S_RETIRE_ST Position */\r
768 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk    (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos)       /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */\r
769 \r
770 #define CoreDebug_DHCSR_S_LOCKUP_Pos       19                                             /*!< CoreDebug DHCSR: S_LOCKUP Position */\r
771 #define CoreDebug_DHCSR_S_LOCKUP_Msk       (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos)          /*!< CoreDebug DHCSR: S_LOCKUP Mask */\r
772 \r
773 #define CoreDebug_DHCSR_S_SLEEP_Pos        18                                             /*!< CoreDebug DHCSR: S_SLEEP Position */\r
774 #define CoreDebug_DHCSR_S_SLEEP_Msk        (1UL << CoreDebug_DHCSR_S_SLEEP_Pos)           /*!< CoreDebug DHCSR: S_SLEEP Mask */\r
775 \r
776 #define CoreDebug_DHCSR_S_HALT_Pos         17                                             /*!< CoreDebug DHCSR: S_HALT Position */\r
777 #define CoreDebug_DHCSR_S_HALT_Msk         (1UL << CoreDebug_DHCSR_S_HALT_Pos)            /*!< CoreDebug DHCSR: S_HALT Mask */\r
778 \r
779 #define CoreDebug_DHCSR_S_REGRDY_Pos       16                                             /*!< CoreDebug DHCSR: S_REGRDY Position */\r
780 #define CoreDebug_DHCSR_S_REGRDY_Msk       (1UL << CoreDebug_DHCSR_S_REGRDY_Pos)          /*!< CoreDebug DHCSR: S_REGRDY Mask */\r
781 \r
782 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos     5                                             /*!< CoreDebug DHCSR: C_SNAPSTALL Position */\r
783 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk    (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos)       /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */\r
784 \r
785 #define CoreDebug_DHCSR_C_MASKINTS_Pos      3                                             /*!< CoreDebug DHCSR: C_MASKINTS Position */\r
786 #define CoreDebug_DHCSR_C_MASKINTS_Msk     (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos)        /*!< CoreDebug DHCSR: C_MASKINTS Mask */\r
787 \r
788 #define CoreDebug_DHCSR_C_STEP_Pos          2                                             /*!< CoreDebug DHCSR: C_STEP Position */\r
789 #define CoreDebug_DHCSR_C_STEP_Msk         (1UL << CoreDebug_DHCSR_C_STEP_Pos)            /*!< CoreDebug DHCSR: C_STEP Mask */\r
790 \r
791 #define CoreDebug_DHCSR_C_HALT_Pos          1                                             /*!< CoreDebug DHCSR: C_HALT Position */\r
792 #define CoreDebug_DHCSR_C_HALT_Msk         (1UL << CoreDebug_DHCSR_C_HALT_Pos)            /*!< CoreDebug DHCSR: C_HALT Mask */\r
793 \r
794 #define CoreDebug_DHCSR_C_DEBUGEN_Pos       0                                             /*!< CoreDebug DHCSR: C_DEBUGEN Position */\r
795 #define CoreDebug_DHCSR_C_DEBUGEN_Msk      (1UL << CoreDebug_DHCSR_C_DEBUGEN_Pos)         /*!< CoreDebug DHCSR: C_DEBUGEN Mask */\r
796 \r
797 /* Debug Core Register Selector Register */\r
798 #define CoreDebug_DCRSR_REGWnR_Pos         16                                             /*!< CoreDebug DCRSR: REGWnR Position */\r
799 #define CoreDebug_DCRSR_REGWnR_Msk         (1UL << CoreDebug_DCRSR_REGWnR_Pos)            /*!< CoreDebug DCRSR: REGWnR Mask */\r
800 \r
801 #define CoreDebug_DCRSR_REGSEL_Pos          0                                             /*!< CoreDebug DCRSR: REGSEL Position */\r
802 #define CoreDebug_DCRSR_REGSEL_Msk         (0x1FUL << CoreDebug_DCRSR_REGSEL_Pos)         /*!< CoreDebug DCRSR: REGSEL Mask */\r
803 \r
804 /* Debug Exception and Monitor Control Register */\r
805 #define CoreDebug_DEMCR_TRCENA_Pos         24                                             /*!< CoreDebug DEMCR: TRCENA Position */\r
806 #define CoreDebug_DEMCR_TRCENA_Msk         (1UL << CoreDebug_DEMCR_TRCENA_Pos)            /*!< CoreDebug DEMCR: TRCENA Mask */\r
807 \r
808 #define CoreDebug_DEMCR_MON_REQ_Pos        19                                             /*!< CoreDebug DEMCR: MON_REQ Position */\r
809 #define CoreDebug_DEMCR_MON_REQ_Msk        (1UL << CoreDebug_DEMCR_MON_REQ_Pos)           /*!< CoreDebug DEMCR: MON_REQ Mask */\r
810 \r
811 #define CoreDebug_DEMCR_MON_STEP_Pos       18                                             /*!< CoreDebug DEMCR: MON_STEP Position */\r
812 #define CoreDebug_DEMCR_MON_STEP_Msk       (1UL << CoreDebug_DEMCR_MON_STEP_Pos)          /*!< CoreDebug DEMCR: MON_STEP Mask */\r
813 \r
814 #define CoreDebug_DEMCR_MON_PEND_Pos       17                                             /*!< CoreDebug DEMCR: MON_PEND Position */\r
815 #define CoreDebug_DEMCR_MON_PEND_Msk       (1UL << CoreDebug_DEMCR_MON_PEND_Pos)          /*!< CoreDebug DEMCR: MON_PEND Mask */\r
816 \r
817 #define CoreDebug_DEMCR_MON_EN_Pos         16                                             /*!< CoreDebug DEMCR: MON_EN Position */\r
818 #define CoreDebug_DEMCR_MON_EN_Msk         (1UL << CoreDebug_DEMCR_MON_EN_Pos)            /*!< CoreDebug DEMCR: MON_EN Mask */\r
819 \r
820 #define CoreDebug_DEMCR_VC_HARDERR_Pos     10                                             /*!< CoreDebug DEMCR: VC_HARDERR Position */\r
821 #define CoreDebug_DEMCR_VC_HARDERR_Msk     (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos)        /*!< CoreDebug DEMCR: VC_HARDERR Mask */\r
822 \r
823 #define CoreDebug_DEMCR_VC_INTERR_Pos       9                                             /*!< CoreDebug DEMCR: VC_INTERR Position */\r
824 #define CoreDebug_DEMCR_VC_INTERR_Msk      (1UL << CoreDebug_DEMCR_VC_INTERR_Pos)         /*!< CoreDebug DEMCR: VC_INTERR Mask */\r
825 \r
826 #define CoreDebug_DEMCR_VC_BUSERR_Pos       8                                             /*!< CoreDebug DEMCR: VC_BUSERR Position */\r
827 #define CoreDebug_DEMCR_VC_BUSERR_Msk      (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos)         /*!< CoreDebug DEMCR: VC_BUSERR Mask */\r
828 \r
829 #define CoreDebug_DEMCR_VC_STATERR_Pos      7                                             /*!< CoreDebug DEMCR: VC_STATERR Position */\r
830 #define CoreDebug_DEMCR_VC_STATERR_Msk     (1UL << CoreDebug_DEMCR_VC_STATERR_Pos)        /*!< CoreDebug DEMCR: VC_STATERR Mask */\r
831 \r
832 #define CoreDebug_DEMCR_VC_CHKERR_Pos       6                                             /*!< CoreDebug DEMCR: VC_CHKERR Position */\r
833 #define CoreDebug_DEMCR_VC_CHKERR_Msk      (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos)         /*!< CoreDebug DEMCR: VC_CHKERR Mask */\r
834 \r
835 #define CoreDebug_DEMCR_VC_NOCPERR_Pos      5                                             /*!< CoreDebug DEMCR: VC_NOCPERR Position */\r
836 #define CoreDebug_DEMCR_VC_NOCPERR_Msk     (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos)        /*!< CoreDebug DEMCR: VC_NOCPERR Mask */\r
837 \r
838 #define CoreDebug_DEMCR_VC_MMERR_Pos        4                                             /*!< CoreDebug DEMCR: VC_MMERR Position */\r
839 #define CoreDebug_DEMCR_VC_MMERR_Msk       (1UL << CoreDebug_DEMCR_VC_MMERR_Pos)          /*!< CoreDebug DEMCR: VC_MMERR Mask */\r
840 \r
841 #define CoreDebug_DEMCR_VC_CORERESET_Pos    0                                             /*!< CoreDebug DEMCR: VC_CORERESET Position */\r
842 #define CoreDebug_DEMCR_VC_CORERESET_Msk   (1UL << CoreDebug_DEMCR_VC_CORERESET_Pos)      /*!< CoreDebug DEMCR: VC_CORERESET Mask */\r
843 \r
844 /*@} end of group CMSIS_CoreDebug */\r
845 \r
846 \r
847 /** \ingroup  CMSIS_core_register\r
848   @{\r
849  */\r
850 \r
851 /* Memory mapping of Cortex-M3 Hardware */\r
852 #define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address  */\r
853 #define ITM_BASE            (0xE0000000UL)                            /*!< ITM Base Address                   */\r
854 #define CoreDebug_BASE      (0xE000EDF0UL)                            /*!< Core Debug Base Address            */\r
855 #define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address               */\r
856 #define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address                  */\r
857 #define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address  */\r
858 \r
859 #define SCnSCB              ((SCnSCB_Type    *)     SCS_BASE      )   /*!< System control Register not in SCB */\r
860 #define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct           */\r
861 #define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct       */\r
862 #define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct          */\r
863 #define ITM                 ((ITM_Type       *)     ITM_BASE      )   /*!< ITM configuration struct           */\r
864 #define CoreDebug           ((CoreDebug_Type *)     CoreDebug_BASE)   /*!< Core Debug configuration struct    */\r
865 \r
866 #if (__MPU_PRESENT == 1)\r
867   #define MPU_BASE          (SCS_BASE +  0x0D90UL)                    /*!< Memory Protection Unit             */\r
868   #define MPU               ((MPU_Type       *)     MPU_BASE      )   /*!< Memory Protection Unit             */\r
869 #endif\r
870 \r
871 /*@} */\r
872 \r
873 \r
874 \r
875 /*******************************************************************************\r
876  *                Hardware Abstraction Layer\r
877  ******************************************************************************/\r
878 /** \defgroup CMSIS_Core_FunctionInterface CMSIS Core Function Interface\r
879   Core Function Interface contains:\r
880   - Core NVIC Functions\r
881   - Core SysTick Functions\r
882   - Core Debug Functions\r
883   - Core Register Access Functions\r
884 */\r
885 \r
886 \r
887 \r
888 /* ##########################   NVIC functions  #################################### */\r
889 /** \ingroup  CMSIS_Core_FunctionInterface\r
890     \defgroup CMSIS_Core_NVICFunctions CMSIS Core NVIC Functions\r
891   @{\r
892  */\r
893 \r
894 /** \brief  Set Priority Grouping\r
895 \r
896   This function sets the priority grouping field using the required unlock sequence.\r
897   The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field.\r
898   Only values from 0..7 are used.\r
899   In case of a conflict between priority grouping and available\r
900   priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.\r
901 \r
902     \param [in]      PriorityGroup  Priority grouping field\r
903  */\r
904 static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)\r
905 {\r
906   uint32_t reg_value;\r
907   uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07);               /* only values 0..7 are used          */\r
908 \r
909   reg_value  =  SCB->AIRCR;                                                   /* read old register configuration    */\r
910   reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk);             /* clear bits to change               */\r
911   reg_value  =  (reg_value                                 |\r
912                 ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) |\r
913                 (PriorityGroupTmp << 8));                                     /* Insert write key and priorty group */\r
914   SCB->AIRCR =  reg_value;\r
915 }\r
916 \r
917 \r
918 /** \brief  Get Priority Grouping\r
919 \r
920   This function gets the priority grouping from NVIC Interrupt Controller.\r
921   Priority grouping is SCB->AIRCR [10:8] PRIGROUP field.\r
922 \r
923     \return                Priority grouping field\r
924  */\r
925 static __INLINE uint32_t NVIC_GetPriorityGrouping(void)\r
926 {\r
927   return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos);   /* read priority grouping field */\r
928 }\r
929 \r
930 \r
931 /** \brief  Enable External Interrupt\r
932 \r
933     This function enables a device specific interrupt in the NVIC interrupt controller.\r
934     The interrupt number cannot be a negative value.\r
935 \r
936     \param [in]      IRQn  Number of the external interrupt to enable\r
937  */\r
938 static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)\r
939 {\r
940   NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */\r
941 }\r
942 \r
943 \r
944 /** \brief  Disable External Interrupt\r
945 \r
946     This function disables a device specific interrupt in the NVIC interrupt controller.\r
947     The interrupt number cannot be a negative value.\r
948 \r
949     \param [in]      IRQn  Number of the external interrupt to disable\r
950  */\r
951 static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)\r
952 {\r
953   NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */\r
954 }\r
955 \r
956 \r
957 /** \brief  Get Pending Interrupt\r
958 \r
959     This function reads the pending register in the NVIC and returns the pending bit\r
960     for the specified interrupt.\r
961 \r
962     \param [in]      IRQn  Number of the interrupt for get pending\r
963     \return             0  Interrupt status is not pending\r
964     \return             1  Interrupt status is pending\r
965  */\r
966 static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)\r
967 {\r
968   return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */\r
969 }\r
970 \r
971 \r
972 /** \brief  Set Pending Interrupt\r
973 \r
974     This function sets the pending bit for the specified interrupt.\r
975     The interrupt number cannot be a negative value.\r
976 \r
977     \param [in]      IRQn  Number of the interrupt for set pending\r
978  */\r
979 static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)\r
980 {\r
981   NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */\r
982 }\r
983 \r
984 \r
985 /** \brief  Clear Pending Interrupt\r
986 \r
987     This function clears the pending bit for the specified interrupt.\r
988     The interrupt number cannot be a negative value.\r
989 \r
990     \param [in]      IRQn  Number of the interrupt for clear pending\r
991  */\r
992 static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)\r
993 {\r
994   NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */\r
995 }\r
996 \r
997 \r
998 /** \brief  Get Active Interrupt\r
999 \r
1000     This function reads the active register in NVIC and returns the active bit.\r
1001     \param [in]      IRQn  Number of the interrupt for get active\r
1002     \return             0  Interrupt status is not active\r
1003     \return             1  Interrupt status is active\r
1004  */\r
1005 static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)\r
1006 {\r
1007   return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */\r
1008 }\r
1009 \r
1010 \r
1011 /** \brief  Set Interrupt Priority\r
1012 \r
1013     This function sets the priority for the specified interrupt. The interrupt\r
1014     number can be positive to specify an external (device specific)\r
1015     interrupt, or negative to specify an internal (core) interrupt.\r
1016 \r
1017     Note: The priority cannot be set for every core interrupt.\r
1018 \r
1019     \param [in]      IRQn  Number of the interrupt for set priority\r
1020     \param [in]  priority  Priority to set\r
1021  */\r
1022 static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)\r
1023 {\r
1024   if(IRQn < 0) {\r
1025     SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M  System Interrupts */\r
1026   else {\r
1027     NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);    }        /* set Priority for device specific Interrupts  */\r
1028 }\r
1029 \r
1030 \r
1031 /** \brief  Get Interrupt Priority\r
1032 \r
1033     This function reads the priority for the specified interrupt. The interrupt\r
1034     number can be positive to specify an external (device specific)\r
1035     interrupt, or negative to specify an internal (core) interrupt.\r
1036 \r
1037     The returned priority value is automatically aligned to the implemented\r
1038     priority bits of the microcontroller.\r
1039 \r
1040     \param [in]   IRQn  Number of the interrupt for get priority\r
1041     \return             Interrupt Priority\r
1042  */\r
1043 static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)\r
1044 {\r
1045 \r
1046   if(IRQn < 0) {\r
1047     return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for Cortex-M  system interrupts */\r
1048   else {\r
1049     return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)]           >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for device specific interrupts  */\r
1050 }\r
1051 \r
1052 \r
1053 /** \brief  Encode Priority\r
1054 \r
1055     This function encodes the priority for an interrupt with the given priority group,\r
1056     preemptive priority value and sub priority value.\r
1057     In case of a conflict between priority grouping and available\r
1058     priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.\r
1059 \r
1060     The returned priority value can be used for NVIC_SetPriority(...) function\r
1061 \r
1062     \param [in]     PriorityGroup  Used priority group\r
1063     \param [in]   PreemptPriority  Preemptive priority value (starting from 0)\r
1064     \param [in]       SubPriority  Sub priority value (starting from 0)\r
1065     \return                        Encoded priority for the interrupt\r
1066  */\r
1067 static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)\r
1068 {\r
1069   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */\r
1070   uint32_t PreemptPriorityBits;\r
1071   uint32_t SubPriorityBits;\r
1072 \r
1073   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;\r
1074   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;\r
1075 \r
1076   return (\r
1077            ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |\r
1078            ((SubPriority     & ((1 << (SubPriorityBits    )) - 1)))\r
1079          );\r
1080 }\r
1081 \r
1082 \r
1083 /** \brief  Decode Priority\r
1084 \r
1085     This function decodes an interrupt priority value with the given priority group to\r
1086     preemptive priority value and sub priority value.\r
1087     In case of a conflict between priority grouping and available\r
1088     priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.\r
1089 \r
1090     The priority value can be retrieved with NVIC_GetPriority(...) function\r
1091 \r
1092     \param [in]         Priority   Priority value\r
1093     \param [in]     PriorityGroup  Used priority group\r
1094     \param [out] pPreemptPriority  Preemptive priority value (starting from 0)\r
1095     \param [out]     pSubPriority  Sub priority value (starting from 0)\r
1096  */\r
1097 static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)\r
1098 {\r
1099   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */\r
1100   uint32_t PreemptPriorityBits;\r
1101   uint32_t SubPriorityBits;\r
1102 \r
1103   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;\r
1104   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;\r
1105 \r
1106   *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);\r
1107   *pSubPriority     = (Priority                   ) & ((1 << (SubPriorityBits    )) - 1);\r
1108 }\r
1109 \r
1110 \r
1111 /** \brief  System Reset\r
1112 \r
1113     This function initiate a system reset request to reset the MCU.\r
1114  */\r
1115 static __INLINE void NVIC_SystemReset(void)\r
1116 {\r
1117   __DSB();                                                     /* Ensure all outstanding memory accesses included\r
1118                                                                   buffered write are completed before reset */\r
1119   SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      |\r
1120                  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |\r
1121                  SCB_AIRCR_SYSRESETREQ_Msk);                   /* Keep priority group unchanged */\r
1122   __DSB();                                                     /* Ensure completion of memory access */\r
1123   while(1);                                                    /* wait until reset */\r
1124 }\r
1125 \r
1126 /*@} end of CMSIS_Core_NVICFunctions */\r
1127 \r
1128 \r
1129 \r
1130 /* ##################################    SysTick function  ############################################ */\r
1131 /** \ingroup  CMSIS_Core_FunctionInterface\r
1132     \defgroup CMSIS_Core_SysTickFunctions CMSIS Core SysTick Functions\r
1133   @{\r
1134  */\r
1135 \r
1136 #if (__Vendor_SysTickConfig == 0)\r
1137 \r
1138 /** \brief  System Tick Configuration\r
1139 \r
1140     This function initialises the system tick timer and its interrupt and start the system tick timer.\r
1141     Counter is in free running mode to generate periodical interrupts.\r
1142 \r
1143     \param [in]  ticks  Number of ticks between two interrupts\r
1144     \return          0  Function succeeded\r
1145     \return          1  Function failed\r
1146  */\r
1147 static __INLINE uint32_t SysTick_Config(uint32_t ticks)\r
1148 {\r
1149   if (ticks > SysTick_LOAD_RELOAD_Msk)  return (1);            /* Reload value impossible */\r
1150 \r
1151   SysTick->LOAD  = (ticks & SysTick_LOAD_RELOAD_Msk) - 1;      /* set reload register */\r
1152   NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);  /* set Priority for Cortex-M0 System Interrupts */\r
1153   SysTick->VAL   = 0;                                          /* Load the SysTick Counter Value */\r
1154   SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |\r
1155                    SysTick_CTRL_TICKINT_Msk   |\r
1156                    SysTick_CTRL_ENABLE_Msk;                    /* Enable SysTick IRQ and SysTick Timer */\r
1157   return (0);                                                  /* Function successful */\r
1158 }\r
1159 \r
1160 #endif\r
1161 \r
1162 /*@} end of CMSIS_Core_SysTickFunctions */\r
1163 \r
1164 \r
1165 \r
1166 /* ##################################### Debug In/Output function ########################################### */\r
1167 /** \ingroup  CMSIS_Core_FunctionInterface\r
1168     \defgroup CMSIS_core_DebugFunctions CMSIS Core Debug Functions\r
1169   @{\r
1170  */\r
1171 \r
1172 extern volatile int32_t ITM_RxBuffer;                    /*!< external variable to receive characters                    */\r
1173 #define                 ITM_RXBUFFER_EMPTY    0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */\r
1174 \r
1175 \r
1176 /** \brief  ITM Send Character\r
1177 \r
1178     This function transmits a character via the ITM channel 0.\r
1179     It just returns when no debugger is connected that has booked the output.\r
1180     It is blocking when a debugger is connected, but the previous character send is not transmitted.\r
1181 \r
1182     \param [in]     ch  Character to transmit\r
1183     \return             Character to transmit\r
1184  */\r
1185 static __INLINE uint32_t ITM_SendChar (uint32_t ch)\r
1186 {\r
1187   if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)  &&      /* Trace enabled */\r
1188       (ITM->TCR & ITM_TCR_ITMENA_Msk)                  &&      /* ITM enabled */\r
1189       (ITM->TER & (1UL << 0)        )                    )     /* ITM Port #0 enabled */\r
1190   {\r
1191     while (ITM->PORT[0].u32 == 0);\r
1192     ITM->PORT[0].u8 = (uint8_t) ch;\r
1193   }\r
1194   return (ch);\r
1195 }\r
1196 \r
1197 \r
1198 /** \brief  ITM Receive Character\r
1199 \r
1200     This function inputs a character via external variable ITM_RxBuffer.\r
1201     It just returns when no debugger is connected that has booked the output.\r
1202     It is blocking when a debugger is connected, but the previous character send is not transmitted.\r
1203 \r
1204     \return             Received character\r
1205     \return         -1  No character received\r
1206  */\r
1207 static __INLINE int32_t ITM_ReceiveChar (void) {\r
1208   int32_t ch = -1;                           /* no character available */\r
1209 \r
1210   if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {\r
1211     ch = ITM_RxBuffer;\r
1212     ITM_RxBuffer = ITM_RXBUFFER_EMPTY;       /* ready for next character */\r
1213   }\r
1214 \r
1215   return (ch);\r
1216 }\r
1217 \r
1218 \r
1219 /** \brief  ITM Check Character\r
1220 \r
1221     This function checks external variable ITM_RxBuffer whether a character is available or not.\r
1222     It returns '1' if a character is available and '0' if no character is available.\r
1223 \r
1224     \return          0  No character available\r
1225     \return          1  Character available\r
1226  */\r
1227 static __INLINE int32_t ITM_CheckChar (void) {\r
1228 \r
1229   if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {\r
1230     return (0);                                 /* no character available */\r
1231   } else {\r
1232     return (1);                                 /*    character available */\r
1233   }\r
1234 }\r
1235 \r
1236 /*@} end of CMSIS_core_DebugFunctions */\r
1237 \r
1238 #endif /* __CORE_CM3_H_DEPENDANT */\r
1239 \r
1240 #endif /* __CMSIS_GENERIC */\r
1241 \r
1242 #ifdef __cplusplus\r
1243 }\r
1244 #endif\r