]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MB9B500_IAR_Keil/Fujitu_source/core_cm3.h
43be05e58ba9e97c967eed1e099bf34fbf6f7bba
[freertos] / FreeRTOS / Demo / CORTEX_MB9B500_IAR_Keil / Fujitu_source / 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  V1.40\r
5  * @date     16. February 2010\r
6  *\r
7  * @note\r
8  * Copyright (C) 2009-2010 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 \r
24 #ifndef __CORE_CM3_H__\r
25 #define __CORE_CM3_H__\r
26 \r
27 /** @addtogroup CMSIS_CM3_core_LintCinfiguration CMSIS CM3 Core Lint Configuration\r
28  *\r
29  * List of Lint messages which will be suppressed and not shown:\r
30  *   - not yet checked\r
31  * .\r
32  * Note:  To re-enable a Message, insert a space before 'lint' *\r
33  *\r
34  */\r
35 \r
36 \r
37 /** @addtogroup CMSIS_CM3_core_definitions CM3 Core Definitions\r
38   This file defines all structures and symbols for CMSIS core:\r
39     - CMSIS version number\r
40     - Cortex-M core registers and bitfields\r
41     - Cortex-M core peripheral base address\r
42   @{\r
43  */\r
44 \r
45 #ifdef __cplusplus\r
46  extern "C" {\r
47 #endif \r
48 \r
49 #define __CM3_CMSIS_VERSION_MAIN  (0x01)                                                       /*!< [31:16] CMSIS HAL main version */\r
50 #define __CM3_CMSIS_VERSION_SUB   (0x40)                                                       /*!< [15:0]  CMSIS HAL sub version  */\r
51 #define __CM3_CMSIS_VERSION       ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB) /*!< CMSIS HAL version number       */\r
52 \r
53 #define __CORTEX_M                (0x03)                                                       /*!< Cortex core                    */\r
54 \r
55 #ifndef __NVIC_PRIO_BITS\r
56   #define __NVIC_PRIO_BITS    4               /*!< standard definition for NVIC Priority Bits */\r
57 #endif\r
58 \r
59 \r
60 #include <stdint.h>                           /* Include standard types */\r
61 \r
62 \r
63 \r
64 /**\r
65  * IO definitions\r
66  *\r
67  * define access restrictions to peripheral registers\r
68  */\r
69 \r
70 #ifdef __cplusplus\r
71   #define     __I     volatile                /*!< defines 'read only' permissions      */\r
72 #else\r
73   #define     __I     volatile const          /*!< defines 'read only' permissions      */\r
74 #endif\r
75 #define     __O     volatile                  /*!< defines 'write only' permissions     */\r
76 #define     __IO    volatile                  /*!< defines 'read / write' permissions   */\r
77 \r
78 \r
79 \r
80 /*******************************************************************************\r
81  *                 Register Abstraction\r
82  ******************************************************************************/\r
83 /** @addtogroup CMSIS_CM3_core_register CMSIS CM3 Core Register\r
84  @{\r
85 */\r
86 \r
87 /** @addtogroup CMSIS_ARM_CORE CMSIS ARM Core\r
88   memory mapped structure for Nested Vectored Interrupt Controller (NVIC)\r
89   @{\r
90  */\r
91 typedef union\r
92 {\r
93   struct\r
94   {\r
95 #if (__CORTEX_M != 0x04)\r
96     uint32_t _reserved0:27;\r
97 #else\r
98     uint32_t _reserved0:16;\r
99     uint32_t GE:4;                             /*!< bit: 16..19  Greater than or Equal flags  */\r
100     uint32_t _reserved1:7;\r
101 #endif\r
102     uint32_t Q:1;                              /*!< bit:     27  Saturation condition flag    */\r
103     uint32_t V:1;                              /*!< bit:     28  Overflow condition code flag */\r
104     uint32_t C:1;                              /*!< bit:     29  Carry condition code flag    */\r
105     uint32_t Z:1;                              /*!< bit:     30  Zero condition code flag     */\r
106     uint32_t N:1;                              /*!< bit:     31  Negative condition code flag */\r
107   } b;\r
108   uint32_t w;\r
109 } APSR_Type;\r
110 \r
111 typedef union\r
112 {\r
113   struct\r
114   {\r
115     uint32_t ISR:9;                            /*!< bit: 00..08  Exception number             */\r
116     uint32_t _reserved0:23;\r
117   } b;\r
118   uint32_t w;\r
119 } IPSR_Type;\r
120 \r
121 typedef union\r
122 {\r
123   struct\r
124   {\r
125     uint32_t ISR:9;                            /*!< bit: 00..08  Exception number             */\r
126 #if (__CORTEX_M != 0x04)\r
127     uint32_t _reserved0:15;\r
128 #else\r
129     uint32_t _reserved0:7;\r
130     uint32_t GE:4;                             /*!< bit: 16..19  Greater than or Equal flags  */\r
131     uint32_t _reserved1:4;\r
132 #endif\r
133     uint32_t T:1;                              /*!< bit:     24  Thumb bit        (read 0)    */\r
134     uint32_t IT:2;                             /*!< bit: 25..26  saved IT state   (read 0)    */\r
135     uint32_t Q:1;                              /*!< bit:     27  Saturation condition flag    */\r
136     uint32_t V:1;                              /*!< bit:     28  Overflow condition code flag */\r
137     uint32_t C:1;                              /*!< bit:     29  Carry condition code flag    */\r
138     uint32_t Z:1;                              /*!< bit:     30  Zero condition code flag     */\r
139     uint32_t N:1;                              /*!< bit:     31  Negative condition code flag */\r
140   } b;\r
141   uint32_t w;\r
142 } xPSR_Type;\r
143 \r
144 typedef union\r
145 {\r
146   struct\r
147   {\r
148     uint32_t nPRIV:1;                         /*!< bit:     00  Execution privilege in Thread mode */\r
149     uint32_t SPSEL:1;                         /*!< bit:     01  Stack to be used                   */\r
150     uint32_t FPCA:1;                          /*!< bit:     02  FP extension active flag           */\r
151     uint32_t _reserved0:29;\r
152   } b;\r
153   uint32_t w;\r
154 } CONTROL_Type;\r
155 \r
156 /*@}*/ /* end of group CMSIS_ARM_CORE */\r
157 \r
158 \r
159 /** @addtogroup CMSIS_CM3_NVIC CMSIS CM3 NVIC\r
160   memory mapped structure for Nested Vectored Interrupt Controller (NVIC)\r
161   @{\r
162  */\r
163 typedef struct\r
164 {\r
165   __IO uint32_t ISER[8];                      /*!< Offset: 0x000  Interrupt Set Enable Register           */\r
166        uint32_t RESERVED0[24];                                   \r
167   __IO uint32_t ICER[8];                      /*!< Offset: 0x080  Interrupt Clear Enable Register         */\r
168        uint32_t RSERVED1[24];                                    \r
169   __IO uint32_t ISPR[8];                      /*!< Offset: 0x100  Interrupt Set Pending Register          */\r
170        uint32_t RESERVED2[24];                                   \r
171   __IO uint32_t ICPR[8];                      /*!< Offset: 0x180  Interrupt Clear Pending Register        */\r
172        uint32_t RESERVED3[24];                                   \r
173   __IO uint32_t IABR[8];                      /*!< Offset: 0x200  Interrupt Active bit Register           */\r
174        uint32_t RESERVED4[56];                                   \r
175   __IO uint8_t  IP[240];                      /*!< Offset: 0x300  Interrupt Priority Register (8Bit wide) */\r
176        uint32_t RESERVED5[644];                                  \r
177   __O  uint32_t STIR;                         /*!< Offset: 0xE00  Software Trigger Interrupt Register     */\r
178 }  NVIC_Type;                                               \r
179 /*@}*/ /* end of group CMSIS_CM3_NVIC */\r
180 \r
181 \r
182 /** @addtogroup CMSIS_CM3_SCB CMSIS CM3 SCB\r
183   memory mapped structure for System Control Block (SCB)\r
184   @{\r
185  */\r
186 typedef struct\r
187 {\r
188   __I  uint32_t CPUID;                        /*!< Offset: 0x00  CPU ID Base Register                                  */\r
189   __IO uint32_t ICSR;                         /*!< Offset: 0x04  Interrupt Control State Register                      */\r
190   __IO uint32_t VTOR;                         /*!< Offset: 0x08  Vector Table Offset Register                          */\r
191   __IO uint32_t AIRCR;                        /*!< Offset: 0x0C  Application Interrupt / Reset Control Register        */\r
192   __IO uint32_t SCR;                          /*!< Offset: 0x10  System Control Register                               */\r
193   __IO uint32_t CCR;                          /*!< Offset: 0x14  Configuration Control Register                        */\r
194   __IO uint8_t  SHP[12];                      /*!< Offset: 0x18  System Handlers Priority Registers (4-7, 8-11, 12-15) */\r
195   __IO uint32_t SHCSR;                        /*!< Offset: 0x24  System Handler Control and State Register             */\r
196   __IO uint32_t CFSR;                         /*!< Offset: 0x28  Configurable Fault Status Register                    */\r
197   __IO uint32_t HFSR;                         /*!< Offset: 0x2C  Hard Fault Status Register                            */\r
198   __IO uint32_t DFSR;                         /*!< Offset: 0x30  Debug Fault Status Register                           */\r
199   __IO uint32_t MMFAR;                        /*!< Offset: 0x34  Mem Manage Address Register                           */\r
200   __IO uint32_t BFAR;                         /*!< Offset: 0x38  Bus Fault Address Register                            */\r
201   __IO uint32_t AFSR;                         /*!< Offset: 0x3C  Auxiliary Fault Status Register                       */\r
202   __I  uint32_t PFR[2];                       /*!< Offset: 0x40  Processor Feature Register                            */\r
203   __I  uint32_t DFR;                          /*!< Offset: 0x48  Debug Feature Register                                */\r
204   __I  uint32_t ADR;                          /*!< Offset: 0x4C  Auxiliary Feature Register                            */\r
205   __I  uint32_t MMFR[4];                      /*!< Offset: 0x50  Memory Model Feature Register                         */\r
206   __I  uint32_t ISAR[5];                      /*!< Offset: 0x60  ISA Feature Register                                  */\r
207 } SCB_Type;                                                \r
208 \r
209 /* SCB CPUID Register Definitions */\r
210 #define SCB_CPUID_IMPLEMENTER_Pos          24                                             /*!< SCB CPUID: IMPLEMENTER Position */\r
211 #define SCB_CPUID_IMPLEMENTER_Msk          (0xFFul << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */\r
212 \r
213 #define SCB_CPUID_VARIANT_Pos              20                                             /*!< SCB CPUID: VARIANT Position */\r
214 #define SCB_CPUID_VARIANT_Msk              (0xFul << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */\r
215 \r
216 #define SCB_CPUID_PARTNO_Pos                4                                             /*!< SCB CPUID: PARTNO Position */\r
217 #define SCB_CPUID_PARTNO_Msk               (0xFFFul << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */\r
218 \r
219 #define SCB_CPUID_REVISION_Pos              0                                             /*!< SCB CPUID: REVISION Position */\r
220 #define SCB_CPUID_REVISION_Msk             (0xFul << SCB_CPUID_REVISION_Pos)              /*!< SCB CPUID: REVISION Mask */\r
221 \r
222 /* SCB Interrupt Control State Register Definitions */\r
223 #define SCB_ICSR_NMIPENDSET_Pos            31                                             /*!< SCB ICSR: NMIPENDSET Position */\r
224 #define SCB_ICSR_NMIPENDSET_Msk            (1ul << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */\r
225 \r
226 #define SCB_ICSR_PENDSVSET_Pos             28                                             /*!< SCB ICSR: PENDSVSET Position */\r
227 #define SCB_ICSR_PENDSVSET_Msk             (1ul << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */\r
228 \r
229 #define SCB_ICSR_PENDSVCLR_Pos             27                                             /*!< SCB ICSR: PENDSVCLR Position */\r
230 #define SCB_ICSR_PENDSVCLR_Msk             (1ul << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */\r
231 \r
232 #define SCB_ICSR_PENDSTSET_Pos             26                                             /*!< SCB ICSR: PENDSTSET Position */\r
233 #define SCB_ICSR_PENDSTSET_Msk             (1ul << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */\r
234 \r
235 #define SCB_ICSR_PENDSTCLR_Pos             25                                             /*!< SCB ICSR: PENDSTCLR Position */\r
236 #define SCB_ICSR_PENDSTCLR_Msk             (1ul << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */\r
237 \r
238 #define SCB_ICSR_ISRPREEMPT_Pos            23                                             /*!< SCB ICSR: ISRPREEMPT Position */\r
239 #define SCB_ICSR_ISRPREEMPT_Msk            (1ul << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */\r
240 \r
241 #define SCB_ICSR_ISRPENDING_Pos            22                                             /*!< SCB ICSR: ISRPENDING Position */\r
242 #define SCB_ICSR_ISRPENDING_Msk            (1ul << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */\r
243 \r
244 #define SCB_ICSR_VECTPENDING_Pos           12                                             /*!< SCB ICSR: VECTPENDING Position */\r
245 #define SCB_ICSR_VECTPENDING_Msk           (0x1FFul << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */\r
246 \r
247 #define SCB_ICSR_RETTOBASE_Pos             11                                             /*!< SCB ICSR: RETTOBASE Position */\r
248 #define SCB_ICSR_RETTOBASE_Msk             (1ul << SCB_ICSR_RETTOBASE_Pos)                /*!< SCB ICSR: RETTOBASE Mask */\r
249 \r
250 #define SCB_ICSR_VECTACTIVE_Pos             0                                             /*!< SCB ICSR: VECTACTIVE Position */\r
251 #define SCB_ICSR_VECTACTIVE_Msk            (0x1FFul << SCB_ICSR_VECTACTIVE_Pos)           /*!< SCB ICSR: VECTACTIVE Mask */\r
252 \r
253 /* SCB Interrupt Control State Register Definitions */\r
254 #define SCB_VTOR_TBLBASE_Pos               29                                             /*!< SCB VTOR: TBLBASE Position */\r
255 #define SCB_VTOR_TBLBASE_Msk               (0x1FFul << SCB_VTOR_TBLBASE_Pos)              /*!< SCB VTOR: TBLBASE Mask */\r
256 \r
257 #define SCB_VTOR_TBLOFF_Pos                 7                                             /*!< SCB VTOR: TBLOFF Position */\r
258 #define SCB_VTOR_TBLOFF_Msk                (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos)            /*!< SCB VTOR: TBLOFF Mask */\r
259 \r
260 /* SCB Application Interrupt and Reset Control Register Definitions */\r
261 #define SCB_AIRCR_VECTKEY_Pos              16                                             /*!< SCB AIRCR: VECTKEY Position */\r
262 #define SCB_AIRCR_VECTKEY_Msk              (0xFFFFul << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */\r
263 \r
264 #define SCB_AIRCR_VECTKEYSTAT_Pos          16                                             /*!< SCB AIRCR: VECTKEYSTAT Position */\r
265 #define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */\r
266 \r
267 #define SCB_AIRCR_ENDIANESS_Pos            15                                             /*!< SCB AIRCR: ENDIANESS Position */\r
268 #define SCB_AIRCR_ENDIANESS_Msk            (1ul << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */\r
269 \r
270 #define SCB_AIRCR_PRIGROUP_Pos              8                                             /*!< SCB AIRCR: PRIGROUP Position */\r
271 #define SCB_AIRCR_PRIGROUP_Msk             (7ul << SCB_AIRCR_PRIGROUP_Pos)                /*!< SCB AIRCR: PRIGROUP Mask */\r
272 \r
273 #define SCB_AIRCR_SYSRESETREQ_Pos           2                                             /*!< SCB AIRCR: SYSRESETREQ Position */\r
274 #define SCB_AIRCR_SYSRESETREQ_Msk          (1ul << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */\r
275 \r
276 #define SCB_AIRCR_VECTCLRACTIVE_Pos         1                                             /*!< SCB AIRCR: VECTCLRACTIVE Position */\r
277 #define SCB_AIRCR_VECTCLRACTIVE_Msk        (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */\r
278 \r
279 #define SCB_AIRCR_VECTRESET_Pos             0                                             /*!< SCB AIRCR: VECTRESET Position */\r
280 #define SCB_AIRCR_VECTRESET_Msk            (1ul << SCB_AIRCR_VECTRESET_Pos)               /*!< SCB AIRCR: VECTRESET Mask */\r
281 \r
282 /* SCB System Control Register Definitions */\r
283 #define SCB_SCR_SEVONPEND_Pos               4                                             /*!< SCB SCR: SEVONPEND Position */\r
284 #define SCB_SCR_SEVONPEND_Msk              (1ul << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */\r
285 \r
286 #define SCB_SCR_SLEEPDEEP_Pos               2                                             /*!< SCB SCR: SLEEPDEEP Position */\r
287 #define SCB_SCR_SLEEPDEEP_Msk              (1ul << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */\r
288 \r
289 #define SCB_SCR_SLEEPONEXIT_Pos             1                                             /*!< SCB SCR: SLEEPONEXIT Position */\r
290 #define SCB_SCR_SLEEPONEXIT_Msk            (1ul << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */\r
291 \r
292 /* SCB Configuration Control Register Definitions */\r
293 #define SCB_CCR_STKALIGN_Pos                9                                             /*!< SCB CCR: STKALIGN Position */\r
294 #define SCB_CCR_STKALIGN_Msk               (1ul << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */\r
295 \r
296 #define SCB_CCR_BFHFNMIGN_Pos               8                                             /*!< SCB CCR: BFHFNMIGN Position */\r
297 #define SCB_CCR_BFHFNMIGN_Msk              (1ul << SCB_CCR_BFHFNMIGN_Pos)                 /*!< SCB CCR: BFHFNMIGN Mask */\r
298 \r
299 #define SCB_CCR_DIV_0_TRP_Pos               4                                             /*!< SCB CCR: DIV_0_TRP Position */\r
300 #define SCB_CCR_DIV_0_TRP_Msk              (1ul << SCB_CCR_DIV_0_TRP_Pos)                 /*!< SCB CCR: DIV_0_TRP Mask */\r
301 \r
302 #define SCB_CCR_UNALIGN_TRP_Pos             3                                             /*!< SCB CCR: UNALIGN_TRP Position */\r
303 #define SCB_CCR_UNALIGN_TRP_Msk            (1ul << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */\r
304 \r
305 #define SCB_CCR_USERSETMPEND_Pos            1                                             /*!< SCB CCR: USERSETMPEND Position */\r
306 #define SCB_CCR_USERSETMPEND_Msk           (1ul << SCB_CCR_USERSETMPEND_Pos)              /*!< SCB CCR: USERSETMPEND Mask */\r
307 \r
308 #define SCB_CCR_NONBASETHRDENA_Pos          0                                             /*!< SCB CCR: NONBASETHRDENA Position */\r
309 #define SCB_CCR_NONBASETHRDENA_Msk         (1ul << SCB_CCR_NONBASETHRDENA_Pos)            /*!< SCB CCR: NONBASETHRDENA Mask */\r
310 \r
311 /* SCB System Handler Control and State Register Definitions */\r
312 #define SCB_SHCSR_USGFAULTENA_Pos          18                                             /*!< SCB SHCSR: USGFAULTENA Position */\r
313 #define SCB_SHCSR_USGFAULTENA_Msk          (1ul << SCB_SHCSR_USGFAULTENA_Pos)             /*!< SCB SHCSR: USGFAULTENA Mask */\r
314 \r
315 #define SCB_SHCSR_BUSFAULTENA_Pos          17                                             /*!< SCB SHCSR: BUSFAULTENA Position */\r
316 #define SCB_SHCSR_BUSFAULTENA_Msk          (1ul << SCB_SHCSR_BUSFAULTENA_Pos)             /*!< SCB SHCSR: BUSFAULTENA Mask */\r
317 \r
318 #define SCB_SHCSR_MEMFAULTENA_Pos          16                                             /*!< SCB SHCSR: MEMFAULTENA Position */\r
319 #define SCB_SHCSR_MEMFAULTENA_Msk          (1ul << SCB_SHCSR_MEMFAULTENA_Pos)             /*!< SCB SHCSR: MEMFAULTENA Mask */\r
320 \r
321 #define SCB_SHCSR_SVCALLPENDED_Pos         15                                             /*!< SCB SHCSR: SVCALLPENDED Position */\r
322 #define SCB_SHCSR_SVCALLPENDED_Msk         (1ul << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */\r
323 \r
324 #define SCB_SHCSR_BUSFAULTPENDED_Pos       14                                             /*!< SCB SHCSR: BUSFAULTPENDED Position */\r
325 #define SCB_SHCSR_BUSFAULTPENDED_Msk       (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos)          /*!< SCB SHCSR: BUSFAULTPENDED Mask */\r
326 \r
327 #define SCB_SHCSR_MEMFAULTPENDED_Pos       13                                             /*!< SCB SHCSR: MEMFAULTPENDED Position */\r
328 #define SCB_SHCSR_MEMFAULTPENDED_Msk       (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos)          /*!< SCB SHCSR: MEMFAULTPENDED Mask */\r
329 \r
330 #define SCB_SHCSR_USGFAULTPENDED_Pos       12                                             /*!< SCB SHCSR: USGFAULTPENDED Position */\r
331 #define SCB_SHCSR_USGFAULTPENDED_Msk       (1ul << SCB_SHCSR_USGFAULTPENDED_Pos)          /*!< SCB SHCSR: USGFAULTPENDED Mask */\r
332 \r
333 #define SCB_SHCSR_SYSTICKACT_Pos           11                                             /*!< SCB SHCSR: SYSTICKACT Position */\r
334 #define SCB_SHCSR_SYSTICKACT_Msk           (1ul << SCB_SHCSR_SYSTICKACT_Pos)              /*!< SCB SHCSR: SYSTICKACT Mask */\r
335 \r
336 #define SCB_SHCSR_PENDSVACT_Pos            10                                             /*!< SCB SHCSR: PENDSVACT Position */\r
337 #define SCB_SHCSR_PENDSVACT_Msk            (1ul << SCB_SHCSR_PENDSVACT_Pos)               /*!< SCB SHCSR: PENDSVACT Mask */\r
338 \r
339 #define SCB_SHCSR_MONITORACT_Pos            8                                             /*!< SCB SHCSR: MONITORACT Position */\r
340 #define SCB_SHCSR_MONITORACT_Msk           (1ul << SCB_SHCSR_MONITORACT_Pos)              /*!< SCB SHCSR: MONITORACT Mask */\r
341 \r
342 #define SCB_SHCSR_SVCALLACT_Pos             7                                             /*!< SCB SHCSR: SVCALLACT Position */\r
343 #define SCB_SHCSR_SVCALLACT_Msk            (1ul << SCB_SHCSR_SVCALLACT_Pos)               /*!< SCB SHCSR: SVCALLACT Mask */\r
344                                      \r
345 #define SCB_SHCSR_USGFAULTACT_Pos           3                                             /*!< SCB SHCSR: USGFAULTACT Position */\r
346 #define SCB_SHCSR_USGFAULTACT_Msk          (1ul << SCB_SHCSR_USGFAULTACT_Pos)             /*!< SCB SHCSR: USGFAULTACT Mask */\r
347 \r
348 #define SCB_SHCSR_BUSFAULTACT_Pos           1                                             /*!< SCB SHCSR: BUSFAULTACT Position */\r
349 #define SCB_SHCSR_BUSFAULTACT_Msk          (1ul << SCB_SHCSR_BUSFAULTACT_Pos)             /*!< SCB SHCSR: BUSFAULTACT Mask */\r
350 \r
351 #define SCB_SHCSR_MEMFAULTACT_Pos           0                                             /*!< SCB SHCSR: MEMFAULTACT Position */\r
352 #define SCB_SHCSR_MEMFAULTACT_Msk          (1ul << SCB_SHCSR_MEMFAULTACT_Pos)             /*!< SCB SHCSR: MEMFAULTACT Mask */\r
353 \r
354 /* SCB Configurable Fault Status Registers Definitions */\r
355 #define SCB_CFSR_USGFAULTSR_Pos            16                                             /*!< SCB CFSR: Usage Fault Status Register Position */\r
356 #define SCB_CFSR_USGFAULTSR_Msk            (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos)          /*!< SCB CFSR: Usage Fault Status Register Mask */\r
357 \r
358 #define SCB_CFSR_BUSFAULTSR_Pos             8                                             /*!< SCB CFSR: Bus Fault Status Register Position */\r
359 #define SCB_CFSR_BUSFAULTSR_Msk            (0xFFul << SCB_CFSR_BUSFAULTSR_Pos)            /*!< SCB CFSR: Bus Fault Status Register Mask */\r
360 \r
361 #define SCB_CFSR_MEMFAULTSR_Pos             0                                             /*!< SCB CFSR: Memory Manage Fault Status Register Position */\r
362 #define SCB_CFSR_MEMFAULTSR_Msk            (0xFFul << SCB_CFSR_MEMFAULTSR_Pos)            /*!< SCB CFSR: Memory Manage Fault Status Register Mask */\r
363 \r
364 /* SCB Hard Fault Status Registers Definitions */\r
365 #define SCB_HFSR_DEBUGEVT_Pos              31                                             /*!< SCB HFSR: DEBUGEVT Position */\r
366 #define SCB_HFSR_DEBUGEVT_Msk              (1ul << SCB_HFSR_DEBUGEVT_Pos)                 /*!< SCB HFSR: DEBUGEVT Mask */\r
367 \r
368 #define SCB_HFSR_FORCED_Pos                30                                             /*!< SCB HFSR: FORCED Position */\r
369 #define SCB_HFSR_FORCED_Msk                (1ul << SCB_HFSR_FORCED_Pos)                   /*!< SCB HFSR: FORCED Mask */\r
370 \r
371 #define SCB_HFSR_VECTTBL_Pos                1                                             /*!< SCB HFSR: VECTTBL Position */\r
372 #define SCB_HFSR_VECTTBL_Msk               (1ul << SCB_HFSR_VECTTBL_Pos)                  /*!< SCB HFSR: VECTTBL Mask */\r
373 \r
374 /* SCB Debug Fault Status Register Definitions */\r
375 #define SCB_DFSR_EXTERNAL_Pos               4                                             /*!< SCB DFSR: EXTERNAL Position */\r
376 #define SCB_DFSR_EXTERNAL_Msk              (1ul << SCB_DFSR_EXTERNAL_Pos)                 /*!< SCB DFSR: EXTERNAL Mask */\r
377 \r
378 #define SCB_DFSR_VCATCH_Pos                 3                                             /*!< SCB DFSR: VCATCH Position */\r
379 #define SCB_DFSR_VCATCH_Msk                (1ul << SCB_DFSR_VCATCH_Pos)                   /*!< SCB DFSR: VCATCH Mask */\r
380 \r
381 #define SCB_DFSR_DWTTRAP_Pos                2                                             /*!< SCB DFSR: DWTTRAP Position */\r
382 #define SCB_DFSR_DWTTRAP_Msk               (1ul << SCB_DFSR_DWTTRAP_Pos)                  /*!< SCB DFSR: DWTTRAP Mask */\r
383 \r
384 #define SCB_DFSR_BKPT_Pos                   1                                             /*!< SCB DFSR: BKPT Position */\r
385 #define SCB_DFSR_BKPT_Msk                  (1ul << SCB_DFSR_BKPT_Pos)                     /*!< SCB DFSR: BKPT Mask */\r
386 \r
387 #define SCB_DFSR_HALTED_Pos                 0                                             /*!< SCB DFSR: HALTED Position */\r
388 #define SCB_DFSR_HALTED_Msk                (1ul << SCB_DFSR_HALTED_Pos)                   /*!< SCB DFSR: HALTED Mask */\r
389 /*@}*/ /* end of group CMSIS_CM3_SCB */\r
390 \r
391 \r
392 /** @addtogroup CMSIS_CM3_SysTick CMSIS CM3 SysTick\r
393   memory mapped structure for SysTick\r
394   @{\r
395  */\r
396 typedef struct\r
397 {\r
398   __IO uint32_t CTRL;                         /*!< Offset: 0x00  SysTick Control and Status Register */\r
399   __IO uint32_t LOAD;                         /*!< Offset: 0x04  SysTick Reload Value Register       */\r
400   __IO uint32_t VAL;                          /*!< Offset: 0x08  SysTick Current Value Register      */\r
401   __I  uint32_t CALIB;                        /*!< Offset: 0x0C  SysTick Calibration Register        */\r
402 } SysTick_Type;\r
403 \r
404 /* SysTick Control / Status Register Definitions */\r
405 #define SysTick_CTRL_COUNTFLAG_Pos         16                                             /*!< SysTick CTRL: COUNTFLAG Position */\r
406 #define SysTick_CTRL_COUNTFLAG_Msk         (1ul << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */\r
407 \r
408 #define SysTick_CTRL_CLKSOURCE_Pos          2                                             /*!< SysTick CTRL: CLKSOURCE Position */\r
409 #define SysTick_CTRL_CLKSOURCE_Msk         (1ul << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */\r
410 \r
411 #define SysTick_CTRL_TICKINT_Pos            1                                             /*!< SysTick CTRL: TICKINT Position */\r
412 #define SysTick_CTRL_TICKINT_Msk           (1ul << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */\r
413 \r
414 #define SysTick_CTRL_ENABLE_Pos             0                                             /*!< SysTick CTRL: ENABLE Position */\r
415 #define SysTick_CTRL_ENABLE_Msk            (1ul << SysTick_CTRL_ENABLE_Pos)               /*!< SysTick CTRL: ENABLE Mask */\r
416 \r
417 /* SysTick Reload Register Definitions */\r
418 #define SysTick_LOAD_RELOAD_Pos             0                                             /*!< SysTick LOAD: RELOAD Position */\r
419 #define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos)        /*!< SysTick LOAD: RELOAD Mask */\r
420 \r
421 /* SysTick Current Register Definitions */\r
422 #define SysTick_VAL_CURRENT_Pos             0                                             /*!< SysTick VAL: CURRENT Position */\r
423 #define SysTick_VAL_CURRENT_Msk            (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)        /*!< SysTick VAL: CURRENT Mask */\r
424 \r
425 /* SysTick Calibration Register Definitions */\r
426 #define SysTick_CALIB_NOREF_Pos            31                                             /*!< SysTick CALIB: NOREF Position */\r
427 #define SysTick_CALIB_NOREF_Msk            (1ul << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */\r
428 \r
429 #define SysTick_CALIB_SKEW_Pos             30                                             /*!< SysTick CALIB: SKEW Position */\r
430 #define SysTick_CALIB_SKEW_Msk             (1ul << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */\r
431 \r
432 #define SysTick_CALIB_TENMS_Pos             0                                             /*!< SysTick CALIB: TENMS Position */\r
433 #define SysTick_CALIB_TENMS_Msk            (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)        /*!< SysTick CALIB: TENMS Mask */\r
434 /*@}*/ /* end of group CMSIS_CM3_SysTick */\r
435 \r
436 \r
437 /** @addtogroup CMSIS_CM3_ITM CMSIS CM3 ITM\r
438   memory mapped structure for Instrumentation Trace Macrocell (ITM)\r
439   @{\r
440  */\r
441 typedef struct\r
442 {\r
443   __O  union  \r
444   {\r
445     __O  uint8_t    u8;                       /*!< Offset:       ITM Stimulus Port 8-bit                   */\r
446     __O  uint16_t   u16;                      /*!< Offset:       ITM Stimulus Port 16-bit                  */\r
447     __O  uint32_t   u32;                      /*!< Offset:       ITM Stimulus Port 32-bit                  */\r
448   }  PORT [32];                               /*!< Offset: 0x00  ITM Stimulus Port Registers               */\r
449        uint32_t RESERVED0[864];                                 \r
450   __IO uint32_t TER;                          /*!< Offset:       ITM Trace Enable Register                 */\r
451        uint32_t RESERVED1[15];                                  \r
452   __IO uint32_t TPR;                          /*!< Offset:       ITM Trace Privilege Register              */\r
453        uint32_t RESERVED2[15];                                  \r
454   __IO uint32_t TCR;                          /*!< Offset:       ITM Trace Control Register                */\r
455        uint32_t RESERVED3[29];                                  \r
456   __IO uint32_t IWR;                          /*!< Offset:       ITM Integration Write Register            */\r
457   __IO uint32_t IRR;                          /*!< Offset:       ITM Integration Read Register             */\r
458   __IO uint32_t IMCR;                         /*!< Offset:       ITM Integration Mode Control Register     */\r
459        uint32_t RESERVED4[43];                                  \r
460   __IO uint32_t LAR;                          /*!< Offset:       ITM Lock Access Register                  */\r
461   __IO uint32_t LSR;                          /*!< Offset:       ITM Lock Status Register                  */\r
462        uint32_t RESERVED5[6];                                   \r
463   __I  uint32_t PID4;                         /*!< Offset:       ITM Peripheral Identification Register #4 */\r
464   __I  uint32_t PID5;                         /*!< Offset:       ITM Peripheral Identification Register #5 */\r
465   __I  uint32_t PID6;                         /*!< Offset:       ITM Peripheral Identification Register #6 */\r
466   __I  uint32_t PID7;                         /*!< Offset:       ITM Peripheral Identification Register #7 */\r
467   __I  uint32_t PID0;                         /*!< Offset:       ITM Peripheral Identification Register #0 */\r
468   __I  uint32_t PID1;                         /*!< Offset:       ITM Peripheral Identification Register #1 */\r
469   __I  uint32_t PID2;                         /*!< Offset:       ITM Peripheral Identification Register #2 */\r
470   __I  uint32_t PID3;                         /*!< Offset:       ITM Peripheral Identification Register #3 */\r
471   __I  uint32_t CID0;                         /*!< Offset:       ITM Component  Identification Register #0 */\r
472   __I  uint32_t CID1;                         /*!< Offset:       ITM Component  Identification Register #1 */\r
473   __I  uint32_t CID2;                         /*!< Offset:       ITM Component  Identification Register #2 */\r
474   __I  uint32_t CID3;                         /*!< Offset:       ITM Component  Identification Register #3 */\r
475 } ITM_Type;                                                \r
476 \r
477 /* ITM Trace Privilege Register Definitions */\r
478 #define ITM_TPR_PRIVMASK_Pos                0                                             /*!< ITM TPR: PRIVMASK Position */\r
479 #define ITM_TPR_PRIVMASK_Msk               (0xFul << ITM_TPR_PRIVMASK_Pos)                /*!< ITM TPR: PRIVMASK Mask */\r
480 \r
481 /* ITM Trace Control Register Definitions */\r
482 #define ITM_TCR_BUSY_Pos                   23                                             /*!< ITM TCR: BUSY Position */\r
483 #define ITM_TCR_BUSY_Msk                   (1ul << ITM_TCR_BUSY_Pos)                      /*!< ITM TCR: BUSY Mask */\r
484 \r
485 #define ITM_TCR_ATBID_Pos                  16                                             /*!< ITM TCR: ATBID Position */\r
486 #define ITM_TCR_ATBID_Msk                  (0x7Ful << ITM_TCR_ATBID_Pos)                  /*!< ITM TCR: ATBID Mask */\r
487 \r
488 #define ITM_TCR_TSPrescale_Pos              8                                             /*!< ITM TCR: TSPrescale Position */\r
489 #define ITM_TCR_TSPrescale_Msk             (3ul << ITM_TCR_TSPrescale_Pos)                /*!< ITM TCR: TSPrescale Mask */\r
490 \r
491 #define ITM_TCR_SWOENA_Pos                  4                                             /*!< ITM TCR: SWOENA Position */\r
492 #define ITM_TCR_SWOENA_Msk                 (1ul << ITM_TCR_SWOENA_Pos)                    /*!< ITM TCR: SWOENA Mask */\r
493 \r
494 #define ITM_TCR_DWTENA_Pos                  3                                             /*!< ITM TCR: DWTENA Position */\r
495 #define ITM_TCR_DWTENA_Msk                 (1ul << ITM_TCR_DWTENA_Pos)                    /*!< ITM TCR: DWTENA Mask */\r
496 \r
497 #define ITM_TCR_SYNCENA_Pos                 2                                             /*!< ITM TCR: SYNCENA Position */\r
498 #define ITM_TCR_SYNCENA_Msk                (1ul << ITM_TCR_SYNCENA_Pos)                   /*!< ITM TCR: SYNCENA Mask */\r
499 \r
500 #define ITM_TCR_TSENA_Pos                   1                                             /*!< ITM TCR: TSENA Position */\r
501 #define ITM_TCR_TSENA_Msk                  (1ul << ITM_TCR_TSENA_Pos)                     /*!< ITM TCR: TSENA Mask */\r
502 \r
503 #define ITM_TCR_ITMENA_Pos                  0                                             /*!< ITM TCR: ITM Enable bit Position */\r
504 #define ITM_TCR_ITMENA_Msk                 (1ul << ITM_TCR_ITMENA_Pos)                    /*!< ITM TCR: ITM Enable bit Mask */\r
505 \r
506 /* ITM Integration Write Register Definitions */\r
507 #define ITM_IWR_ATVALIDM_Pos                0                                             /*!< ITM IWR: ATVALIDM Position */\r
508 #define ITM_IWR_ATVALIDM_Msk               (1ul << ITM_IWR_ATVALIDM_Pos)                  /*!< ITM IWR: ATVALIDM Mask */\r
509 \r
510 /* ITM Integration Read Register Definitions */\r
511 #define ITM_IRR_ATREADYM_Pos                0                                             /*!< ITM IRR: ATREADYM Position */\r
512 #define ITM_IRR_ATREADYM_Msk               (1ul << ITM_IRR_ATREADYM_Pos)                  /*!< ITM IRR: ATREADYM Mask */\r
513 \r
514 /* ITM Integration Mode Control Register Definitions */\r
515 #define ITM_IMCR_INTEGRATION_Pos            0                                             /*!< ITM IMCR: INTEGRATION Position */\r
516 #define ITM_IMCR_INTEGRATION_Msk           (1ul << ITM_IMCR_INTEGRATION_Pos)              /*!< ITM IMCR: INTEGRATION Mask */\r
517 \r
518 /* ITM Lock Status Register Definitions */\r
519 #define ITM_LSR_ByteAcc_Pos                 2                                             /*!< ITM LSR: ByteAcc Position */\r
520 #define ITM_LSR_ByteAcc_Msk                (1ul << ITM_LSR_ByteAcc_Pos)                   /*!< ITM LSR: ByteAcc Mask */\r
521 \r
522 #define ITM_LSR_Access_Pos                  1                                             /*!< ITM LSR: Access Position */\r
523 #define ITM_LSR_Access_Msk                 (1ul << ITM_LSR_Access_Pos)                    /*!< ITM LSR: Access Mask */\r
524 \r
525 #define ITM_LSR_Present_Pos                 0                                             /*!< ITM LSR: Present Position */\r
526 #define ITM_LSR_Present_Msk                (1ul << ITM_LSR_Present_Pos)                   /*!< ITM LSR: Present Mask */\r
527 /*@}*/ /* end of group CMSIS_CM3_ITM */\r
528 \r
529 \r
530 /** @addtogroup CMSIS_CM3_InterruptType CMSIS CM3 Interrupt Type\r
531   memory mapped structure for Interrupt Type\r
532   @{\r
533  */\r
534 typedef struct\r
535 {\r
536        uint32_t RESERVED0;\r
537   __I  uint32_t ICTR;                         /*!< Offset: 0x04  Interrupt Control Type Register */\r
538   __IO uint32_t ACTLR;                        /*!< Offset: 0x08  Auxiliary Control Register      */\r
539 } InterruptType_Type;\r
540 \r
541 /* Interrupt Controller Type Register Definitions */\r
542 #define InterruptType_ICTR_INTLINESNUM_Pos  0                                             /*!< InterruptType ICTR: INTLINESNUM Position */\r
543 #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos) /*!< InterruptType ICTR: INTLINESNUM Mask */\r
544 \r
545 /* Auxiliary Control Register Definitions */\r
546 #define InterruptType_ACTLR_DISFOLD_Pos     2                                             /*!< InterruptType ACTLR: DISFOLD Position */\r
547 #define InterruptType_ACTLR_DISFOLD_Msk    (1ul << InterruptType_ACTLR_DISFOLD_Pos)       /*!< InterruptType ACTLR: DISFOLD Mask */\r
548 \r
549 #define InterruptType_ACTLR_DISDEFWBUF_Pos  1                                             /*!< InterruptType ACTLR: DISDEFWBUF Position */\r
550 #define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos)    /*!< InterruptType ACTLR: DISDEFWBUF Mask */\r
551 \r
552 #define InterruptType_ACTLR_DISMCYCINT_Pos  0                                             /*!< InterruptType ACTLR: DISMCYCINT Position */\r
553 #define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos)    /*!< InterruptType ACTLR: DISMCYCINT Mask */\r
554 /*@}*/ /* end of group CMSIS_CM3_InterruptType */\r
555 \r
556 \r
557 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)\r
558 /** @addtogroup CMSIS_CM3_MPU CMSIS CM3 MPU\r
559   memory mapped structure for Memory Protection Unit (MPU)\r
560   @{\r
561  */\r
562 typedef struct\r
563 {\r
564   __I  uint32_t TYPE;                         /*!< Offset: 0x00  MPU Type Register                              */\r
565   __IO uint32_t CTRL;                         /*!< Offset: 0x04  MPU Control Register                           */\r
566   __IO uint32_t RNR;                          /*!< Offset: 0x08  MPU Region RNRber Register                     */\r
567   __IO uint32_t RBAR;                         /*!< Offset: 0x0C  MPU Region Base Address Register               */\r
568   __IO uint32_t RASR;                         /*!< Offset: 0x10  MPU Region Attribute and Size Register         */\r
569   __IO uint32_t RBAR_A1;                      /*!< Offset: 0x14  MPU Alias 1 Region Base Address Register       */\r
570   __IO uint32_t RASR_A1;                      /*!< Offset: 0x18  MPU Alias 1 Region Attribute and Size Register */\r
571   __IO uint32_t RBAR_A2;                      /*!< Offset: 0x1C  MPU Alias 2 Region Base Address Register       */\r
572   __IO uint32_t RASR_A2;                      /*!< Offset: 0x20  MPU Alias 2 Region Attribute and Size Register */\r
573   __IO uint32_t RBAR_A3;                      /*!< Offset: 0x24  MPU Alias 3 Region Base Address Register       */\r
574   __IO uint32_t RASR_A3;                      /*!< Offset: 0x28  MPU Alias 3 Region Attribute and Size Register */\r
575 } MPU_Type;                                                \r
576 \r
577 /* MPU Type Register */\r
578 #define MPU_TYPE_IREGION_Pos               16                                             /*!< MPU TYPE: IREGION Position */\r
579 #define MPU_TYPE_IREGION_Msk               (0xFFul << MPU_TYPE_IREGION_Pos)               /*!< MPU TYPE: IREGION Mask */\r
580 \r
581 #define MPU_TYPE_DREGION_Pos                8                                             /*!< MPU TYPE: DREGION Position */\r
582 #define MPU_TYPE_DREGION_Msk               (0xFFul << MPU_TYPE_DREGION_Pos)               /*!< MPU TYPE: DREGION Mask */\r
583 \r
584 #define MPU_TYPE_SEPARATE_Pos               0                                             /*!< MPU TYPE: SEPARATE Position */\r
585 #define MPU_TYPE_SEPARATE_Msk              (1ul << MPU_TYPE_SEPARATE_Pos)                 /*!< MPU TYPE: SEPARATE Mask */\r
586 \r
587 /* MPU Control Register */\r
588 #define MPU_CTRL_PRIVDEFENA_Pos             2                                             /*!< MPU CTRL: PRIVDEFENA Position */\r
589 #define MPU_CTRL_PRIVDEFENA_Msk            (1ul << MPU_CTRL_PRIVDEFENA_Pos)               /*!< MPU CTRL: PRIVDEFENA Mask */\r
590 \r
591 #define MPU_CTRL_HFNMIENA_Pos               1                                             /*!< MPU CTRL: HFNMIENA Position */\r
592 #define MPU_CTRL_HFNMIENA_Msk              (1ul << MPU_CTRL_HFNMIENA_Pos)                 /*!< MPU CTRL: HFNMIENA Mask */\r
593 \r
594 #define MPU_CTRL_ENABLE_Pos                 0                                             /*!< MPU CTRL: ENABLE Position */\r
595 #define MPU_CTRL_ENABLE_Msk                (1ul << MPU_CTRL_ENABLE_Pos)                   /*!< MPU CTRL: ENABLE Mask */\r
596 \r
597 /* MPU Region Number Register */\r
598 #define MPU_RNR_REGION_Pos                  0                                             /*!< MPU RNR: REGION Position */\r
599 #define MPU_RNR_REGION_Msk                 (0xFFul << MPU_RNR_REGION_Pos)                 /*!< MPU RNR: REGION Mask */\r
600 \r
601 /* MPU Region Base Address Register */\r
602 #define MPU_RBAR_ADDR_Pos                   5                                             /*!< MPU RBAR: ADDR Position */\r
603 #define MPU_RBAR_ADDR_Msk                  (0x7FFFFFFul << MPU_RBAR_ADDR_Pos)             /*!< MPU RBAR: ADDR Mask */\r
604 \r
605 #define MPU_RBAR_VALID_Pos                  4                                             /*!< MPU RBAR: VALID Position */\r
606 #define MPU_RBAR_VALID_Msk                 (1ul << MPU_RBAR_VALID_Pos)                    /*!< MPU RBAR: VALID Mask */\r
607 \r
608 #define MPU_RBAR_REGION_Pos                 0                                             /*!< MPU RBAR: REGION Position */\r
609 #define MPU_RBAR_REGION_Msk                (0xFul << MPU_RBAR_REGION_Pos)                 /*!< MPU RBAR: REGION Mask */\r
610 \r
611 /* MPU Region Attribute and Size Register */\r
612 #define MPU_RASR_XN_Pos                    28                                             /*!< MPU RASR: XN Position */\r
613 #define MPU_RASR_XN_Msk                    (1ul << MPU_RASR_XN_Pos)                       /*!< MPU RASR: XN Mask */\r
614 \r
615 #define MPU_RASR_AP_Pos                    24                                             /*!< MPU RASR: AP Position */\r
616 #define MPU_RASR_AP_Msk                    (7ul << MPU_RASR_AP_Pos)                       /*!< MPU RASR: AP Mask */\r
617 \r
618 #define MPU_RASR_TEX_Pos                   19                                             /*!< MPU RASR: TEX Position */\r
619 #define MPU_RASR_TEX_Msk                   (7ul << MPU_RASR_TEX_Pos)                      /*!< MPU RASR: TEX Mask */\r
620 \r
621 #define MPU_RASR_S_Pos                     18                                             /*!< MPU RASR: Shareable bit Position */\r
622 #define MPU_RASR_S_Msk                     (1ul << MPU_RASR_S_Pos)                        /*!< MPU RASR: Shareable bit Mask */\r
623 \r
624 #define MPU_RASR_C_Pos                     17                                             /*!< MPU RASR: Cacheable bit Position */\r
625 #define MPU_RASR_C_Msk                     (1ul << MPU_RASR_C_Pos)                        /*!< MPU RASR: Cacheable bit Mask */\r
626 \r
627 #define MPU_RASR_B_Pos                     16                                             /*!< MPU RASR: Bufferable bit Position */\r
628 #define MPU_RASR_B_Msk                     (1ul << MPU_RASR_B_Pos)                        /*!< MPU RASR: Bufferable bit Mask */\r
629 \r
630 #define MPU_RASR_SRD_Pos                    8                                             /*!< MPU RASR: Sub-Region Disable Position */\r
631 #define MPU_RASR_SRD_Msk                   (0xFFul << MPU_RASR_SRD_Pos)                   /*!< MPU RASR: Sub-Region Disable Mask */\r
632 \r
633 #define MPU_RASR_SIZE_Pos                   1                                             /*!< MPU RASR: Region Size Field Position */\r
634 #define MPU_RASR_SIZE_Msk                  (0x1Ful << MPU_RASR_SIZE_Pos)                  /*!< MPU RASR: Region Size Field Mask */\r
635 \r
636 #define MPU_RASR_ENA_Pos                     0                                            /*!< MPU RASR: Region enable bit Position */\r
637 #define MPU_RASR_ENA_Msk                    (0x1Ful << MPU_RASR_ENA_Pos)                  /*!< MPU RASR: Region enable bit Disable Mask */\r
638 \r
639 /*@}*/ /* end of group CMSIS_CM3_MPU */\r
640 #endif\r
641 \r
642 \r
643 /** @addtogroup CMSIS_CM3_CoreDebug CMSIS CM3 Core Debug\r
644   memory mapped structure for Core Debug Register\r
645   @{\r
646  */\r
647 typedef struct\r
648 {\r
649   __IO uint32_t DHCSR;                        /*!< Offset: 0x00  Debug Halting Control and Status Register    */\r
650   __O  uint32_t DCRSR;                        /*!< Offset: 0x04  Debug Core Register Selector Register        */\r
651   __IO uint32_t DCRDR;                        /*!< Offset: 0x08  Debug Core Register Data Register            */\r
652   __IO uint32_t DEMCR;                        /*!< Offset: 0x0C  Debug Exception and Monitor Control Register */\r
653 } CoreDebug_Type;\r
654 \r
655 /* Debug Halting Control and Status Register */\r
656 #define CoreDebug_DHCSR_DBGKEY_Pos         16                                             /*!< CoreDebug DHCSR: DBGKEY Position */\r
657 #define CoreDebug_DHCSR_DBGKEY_Msk         (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos)       /*!< CoreDebug DHCSR: DBGKEY Mask */\r
658 \r
659 #define CoreDebug_DHCSR_S_RESET_ST_Pos     25                                             /*!< CoreDebug DHCSR: S_RESET_ST Position */\r
660 #define CoreDebug_DHCSR_S_RESET_ST_Msk     (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos)        /*!< CoreDebug DHCSR: S_RESET_ST Mask */\r
661 \r
662 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos    24                                             /*!< CoreDebug DHCSR: S_RETIRE_ST Position */\r
663 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk    (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos)       /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */\r
664 \r
665 #define CoreDebug_DHCSR_S_LOCKUP_Pos       19                                             /*!< CoreDebug DHCSR: S_LOCKUP Position */\r
666 #define CoreDebug_DHCSR_S_LOCKUP_Msk       (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos)          /*!< CoreDebug DHCSR: S_LOCKUP Mask */\r
667 \r
668 #define CoreDebug_DHCSR_S_SLEEP_Pos        18                                             /*!< CoreDebug DHCSR: S_SLEEP Position */\r
669 #define CoreDebug_DHCSR_S_SLEEP_Msk        (1ul << CoreDebug_DHCSR_S_SLEEP_Pos)           /*!< CoreDebug DHCSR: S_SLEEP Mask */\r
670 \r
671 #define CoreDebug_DHCSR_S_HALT_Pos         17                                             /*!< CoreDebug DHCSR: S_HALT Position */\r
672 #define CoreDebug_DHCSR_S_HALT_Msk         (1ul << CoreDebug_DHCSR_S_HALT_Pos)            /*!< CoreDebug DHCSR: S_HALT Mask */\r
673 \r
674 #define CoreDebug_DHCSR_S_REGRDY_Pos       16                                             /*!< CoreDebug DHCSR: S_REGRDY Position */\r
675 #define CoreDebug_DHCSR_S_REGRDY_Msk       (1ul << CoreDebug_DHCSR_S_REGRDY_Pos)          /*!< CoreDebug DHCSR: S_REGRDY Mask */\r
676 \r
677 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos     5                                             /*!< CoreDebug DHCSR: C_SNAPSTALL Position */\r
678 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk    (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos)       /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */\r
679 \r
680 #define CoreDebug_DHCSR_C_MASKINTS_Pos      3                                             /*!< CoreDebug DHCSR: C_MASKINTS Position */\r
681 #define CoreDebug_DHCSR_C_MASKINTS_Msk     (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos)        /*!< CoreDebug DHCSR: C_MASKINTS Mask */\r
682 \r
683 #define CoreDebug_DHCSR_C_STEP_Pos          2                                             /*!< CoreDebug DHCSR: C_STEP Position */\r
684 #define CoreDebug_DHCSR_C_STEP_Msk         (1ul << CoreDebug_DHCSR_C_STEP_Pos)            /*!< CoreDebug DHCSR: C_STEP Mask */\r
685 \r
686 #define CoreDebug_DHCSR_C_HALT_Pos          1                                             /*!< CoreDebug DHCSR: C_HALT Position */\r
687 #define CoreDebug_DHCSR_C_HALT_Msk         (1ul << CoreDebug_DHCSR_C_HALT_Pos)            /*!< CoreDebug DHCSR: C_HALT Mask */\r
688 \r
689 #define CoreDebug_DHCSR_C_DEBUGEN_Pos       0                                             /*!< CoreDebug DHCSR: C_DEBUGEN Position */\r
690 #define CoreDebug_DHCSR_C_DEBUGEN_Msk      (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos)         /*!< CoreDebug DHCSR: C_DEBUGEN Mask */\r
691 \r
692 /* Debug Core Register Selector Register */\r
693 #define CoreDebug_DCRSR_REGWnR_Pos         16                                             /*!< CoreDebug DCRSR: REGWnR Position */\r
694 #define CoreDebug_DCRSR_REGWnR_Msk         (1ul << CoreDebug_DCRSR_REGWnR_Pos)            /*!< CoreDebug DCRSR: REGWnR Mask */\r
695 \r
696 #define CoreDebug_DCRSR_REGSEL_Pos          0                                             /*!< CoreDebug DCRSR: REGSEL Position */\r
697 #define CoreDebug_DCRSR_REGSEL_Msk         (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos)         /*!< CoreDebug DCRSR: REGSEL Mask */\r
698 \r
699 /* Debug Exception and Monitor Control Register */\r
700 #define CoreDebug_DEMCR_TRCENA_Pos         24                                             /*!< CoreDebug DEMCR: TRCENA Position */\r
701 #define CoreDebug_DEMCR_TRCENA_Msk         (1ul << CoreDebug_DEMCR_TRCENA_Pos)            /*!< CoreDebug DEMCR: TRCENA Mask */\r
702 \r
703 #define CoreDebug_DEMCR_MON_REQ_Pos        19                                             /*!< CoreDebug DEMCR: MON_REQ Position */\r
704 #define CoreDebug_DEMCR_MON_REQ_Msk        (1ul << CoreDebug_DEMCR_MON_REQ_Pos)           /*!< CoreDebug DEMCR: MON_REQ Mask */\r
705 \r
706 #define CoreDebug_DEMCR_MON_STEP_Pos       18                                             /*!< CoreDebug DEMCR: MON_STEP Position */\r
707 #define CoreDebug_DEMCR_MON_STEP_Msk       (1ul << CoreDebug_DEMCR_MON_STEP_Pos)          /*!< CoreDebug DEMCR: MON_STEP Mask */\r
708 \r
709 #define CoreDebug_DEMCR_MON_PEND_Pos       17                                             /*!< CoreDebug DEMCR: MON_PEND Position */\r
710 #define CoreDebug_DEMCR_MON_PEND_Msk       (1ul << CoreDebug_DEMCR_MON_PEND_Pos)          /*!< CoreDebug DEMCR: MON_PEND Mask */\r
711 \r
712 #define CoreDebug_DEMCR_MON_EN_Pos         16                                             /*!< CoreDebug DEMCR: MON_EN Position */\r
713 #define CoreDebug_DEMCR_MON_EN_Msk         (1ul << CoreDebug_DEMCR_MON_EN_Pos)            /*!< CoreDebug DEMCR: MON_EN Mask */\r
714 \r
715 #define CoreDebug_DEMCR_VC_HARDERR_Pos     10                                             /*!< CoreDebug DEMCR: VC_HARDERR Position */\r
716 #define CoreDebug_DEMCR_VC_HARDERR_Msk     (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos)        /*!< CoreDebug DEMCR: VC_HARDERR Mask */\r
717 \r
718 #define CoreDebug_DEMCR_VC_INTERR_Pos       9                                             /*!< CoreDebug DEMCR: VC_INTERR Position */\r
719 #define CoreDebug_DEMCR_VC_INTERR_Msk      (1ul << CoreDebug_DEMCR_VC_INTERR_Pos)         /*!< CoreDebug DEMCR: VC_INTERR Mask */\r
720 \r
721 #define CoreDebug_DEMCR_VC_BUSERR_Pos       8                                             /*!< CoreDebug DEMCR: VC_BUSERR Position */\r
722 #define CoreDebug_DEMCR_VC_BUSERR_Msk      (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos)         /*!< CoreDebug DEMCR: VC_BUSERR Mask */\r
723 \r
724 #define CoreDebug_DEMCR_VC_STATERR_Pos      7                                             /*!< CoreDebug DEMCR: VC_STATERR Position */\r
725 #define CoreDebug_DEMCR_VC_STATERR_Msk     (1ul << CoreDebug_DEMCR_VC_STATERR_Pos)        /*!< CoreDebug DEMCR: VC_STATERR Mask */\r
726 \r
727 #define CoreDebug_DEMCR_VC_CHKERR_Pos       6                                             /*!< CoreDebug DEMCR: VC_CHKERR Position */\r
728 #define CoreDebug_DEMCR_VC_CHKERR_Msk      (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos)         /*!< CoreDebug DEMCR: VC_CHKERR Mask */\r
729 \r
730 #define CoreDebug_DEMCR_VC_NOCPERR_Pos      5                                             /*!< CoreDebug DEMCR: VC_NOCPERR Position */\r
731 #define CoreDebug_DEMCR_VC_NOCPERR_Msk     (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos)        /*!< CoreDebug DEMCR: VC_NOCPERR Mask */\r
732 \r
733 #define CoreDebug_DEMCR_VC_MMERR_Pos        4                                             /*!< CoreDebug DEMCR: VC_MMERR Position */\r
734 #define CoreDebug_DEMCR_VC_MMERR_Msk       (1ul << CoreDebug_DEMCR_VC_MMERR_Pos)          /*!< CoreDebug DEMCR: VC_MMERR Mask */\r
735 \r
736 #define CoreDebug_DEMCR_VC_CORERESET_Pos    0                                             /*!< CoreDebug DEMCR: VC_CORERESET Position */\r
737 #define CoreDebug_DEMCR_VC_CORERESET_Msk   (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos)      /*!< CoreDebug DEMCR: VC_CORERESET Mask */\r
738 /*@}*/ /* end of group CMSIS_CM3_CoreDebug */\r
739 \r
740 \r
741 /* Memory mapping of Cortex-M3 Hardware */\r
742 #define SCS_BASE            (0xE000E000)                              /*!< System Control Space Base Address */\r
743 #define ITM_BASE            (0xE0000000)                              /*!< ITM Base Address                  */\r
744 #define CoreDebug_BASE      (0xE000EDF0)                              /*!< Core Debug Base Address           */\r
745 #define SysTick_BASE        (SCS_BASE +  0x0010)                      /*!< SysTick Base Address              */\r
746 #define NVIC_BASE           (SCS_BASE +  0x0100)                      /*!< NVIC Base Address                 */\r
747 #define SCB_BASE            (SCS_BASE +  0x0D00)                      /*!< System Control Block Base Address */\r
748 \r
749 #define InterruptType       ((InterruptType_Type *) SCS_BASE)         /*!< Interrupt Type Register           */\r
750 #define SCB                 ((SCB_Type *)           SCB_BASE)         /*!< SCB configuration struct          */\r
751 #define SysTick             ((SysTick_Type *)       SysTick_BASE)     /*!< SysTick configuration struct      */\r
752 #define NVIC                ((NVIC_Type *)          NVIC_BASE)        /*!< NVIC configuration struct         */\r
753 #define ITM                 ((ITM_Type *)           ITM_BASE)         /*!< ITM configuration struct          */\r
754 #define CoreDebug           ((CoreDebug_Type *)     CoreDebug_BASE)   /*!< Core Debug configuration struct   */\r
755 \r
756 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)\r
757   #define MPU_BASE          (SCS_BASE +  0x0D90)                      /*!< Memory Protection Unit            */\r
758   #define MPU               ((MPU_Type*)            MPU_BASE)         /*!< Memory Protection Unit            */\r
759 #endif\r
760 \r
761 /*@}*/ /* end of group CMSIS_CM3_core_register */\r
762 \r
763 \r
764 /*******************************************************************************\r
765  *                Hardware Abstraction Layer\r
766  ******************************************************************************/\r
767 \r
768 #if defined ( __CC_ARM   )\r
769   #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler          */\r
770   #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler       */\r
771 \r
772 #elif defined ( __ICCARM__ )\r
773   #define __ASM           __asm                                       /*!< asm keyword for IAR Compiler          */\r
774   #define __INLINE        inline                                      /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */\r
775 \r
776 #elif defined   (  __GNUC__  )\r
777   #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler          */\r
778   #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler       */\r
779 \r
780 #elif defined   (  __TASKING__  )\r
781   #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler      */\r
782   #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler   */\r
783 \r
784 #endif\r
785 \r
786 /* ##########################  Core Instruction Access  ######################### */\r
787 #include "core_cmInstr.h"\r
788 \r
789 /* ###########################  Core Function Access  ########################### */\r
790 #include "core_cmFunc.h"\r
791 \r
792 \r
793 /** @addtogroup CMSIS_CM3_Core_FunctionInterface CMSIS CM3 Core Function Interface\r
794   Core  Function Interface containing:\r
795   - Core NVIC Functions\r
796   - Core SysTick Functions\r
797   - Core Reset Functions\r
798 */\r
799 /*@{*/\r
800 \r
801 /* ##########################   NVIC functions  #################################### */\r
802 \r
803 /**\r
804  * @brief  Set the Priority Grouping in NVIC Interrupt Controller\r
805  *\r
806  * @param  PriorityGroup is priority grouping field\r
807  *\r
808  * Set the priority grouping field using the required unlock sequence.\r
809  * The parameter priority_grouping is assigned to the field \r
810  * SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used.\r
811  * In case of a conflict between priority grouping and available\r
812  * priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.\r
813  */\r
814 static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)\r
815 {\r
816   uint32_t reg_value;\r
817   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);                         /* only values 0..7 are used          */\r
818   \r
819   reg_value  =  SCB->AIRCR;                                                   /* read old register configuration    */\r
820   reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk);             /* clear bits to change               */\r
821   reg_value  =  (reg_value                       |\r
822                 (0x5FA << SCB_AIRCR_VECTKEY_Pos) | \r
823                 (PriorityGroupTmp << 8));                                     /* Insert write key and priorty group */\r
824   SCB->AIRCR =  reg_value;\r
825 }\r
826 \r
827 /**\r
828  * @brief  Get the Priority Grouping from NVIC Interrupt Controller\r
829  *\r
830  * @return priority grouping field \r
831  *\r
832  * Get the priority grouping from NVIC Interrupt Controller.\r
833  * priority grouping is SCB->AIRCR [10:8] PRIGROUP field.\r
834  */\r
835 static __INLINE uint32_t NVIC_GetPriorityGrouping(void)\r
836 {\r
837   return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos);   /* read priority grouping field */\r
838 }\r
839 \r
840 /**\r
841  * @brief  Enable Interrupt in NVIC Interrupt Controller\r
842  *\r
843  * @param  IRQn   The positive number of the external interrupt to enable\r
844  *\r
845  * Enable a device specific interupt in the NVIC interrupt controller.\r
846  * The interrupt number cannot be a negative value.\r
847  */\r
848 static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)\r
849 {\r
850   NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */\r
851 }\r
852 \r
853 /**\r
854  * @brief  Disable the interrupt line for external interrupt specified\r
855  * \r
856  * @param  IRQn   The positive number of the external interrupt to disable\r
857  * \r
858  * Disable a device specific interupt in the NVIC interrupt controller.\r
859  * The interrupt number cannot be a negative value.\r
860  */\r
861 static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)\r
862 {\r
863   NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */\r
864 }\r
865 \r
866 /**\r
867  * @brief  Read the interrupt pending bit for a device specific interrupt source\r
868  * \r
869  * @param  IRQn    The number of the device specifc interrupt\r
870  * @return         1 = interrupt pending, 0 = interrupt not pending\r
871  *\r
872  * Read the pending register in NVIC and return 1 if its status is pending, \r
873  * otherwise it returns 0\r
874  */\r
875 static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)\r
876 {\r
877   return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */\r
878 }\r
879 \r
880 /**\r
881  * @brief  Set the pending bit for an external interrupt\r
882  * \r
883  * @param  IRQn    The number of the interrupt for set pending\r
884  *\r
885  * Set the pending bit for the specified interrupt.\r
886  * The interrupt number cannot be a negative value.\r
887  */\r
888 static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)\r
889 {\r
890   NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */\r
891 }\r
892 \r
893 /**\r
894  * @brief  Clear the pending bit for an external interrupt\r
895  *\r
896  * @param  IRQn    The number of the interrupt for clear pending\r
897  *\r
898  * Clear the pending bit for the specified interrupt. \r
899  * The interrupt number cannot be a negative value.\r
900  */\r
901 static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)\r
902 {\r
903   NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */\r
904 }\r
905 \r
906 /**\r
907  * @brief  Read the active bit for an external interrupt\r
908  *\r
909  * @param  IRQn    The number of the interrupt for read active bit\r
910  * @return         1 = interrupt active, 0 = interrupt not active\r
911  *\r
912  * Read the active register in NVIC and returns 1 if its status is active, \r
913  * otherwise it returns 0.\r
914  */\r
915 static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)\r
916 {\r
917   return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */\r
918 }\r
919 \r
920 /**\r
921  * @brief  Set the priority for an interrupt\r
922  *\r
923  * @param  IRQn      The number of the interrupt for set priority\r
924  * @param  priority  The priority to set\r
925  *\r
926  * Set the priority for the specified interrupt. The interrupt \r
927  * number can be positive to specify an external (device specific) \r
928  * interrupt, or negative to specify an internal (core) interrupt.\r
929  *\r
930  * Note: The priority cannot be set for every core interrupt.\r
931  */\r
932 static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)\r
933 {\r
934   if(IRQn < 0) {\r
935     SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */\r
936   else {\r
937     NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);    }        /* set Priority for device specific Interrupts  */\r
938 }\r
939 \r
940 /**\r
941  * @brief  Read the priority for an interrupt\r
942  *\r
943  * @param  IRQn      The number of the interrupt for get priority\r
944  * @return           The priority for the interrupt\r
945  *\r
946  * Read the priority for the specified interrupt. The interrupt \r
947  * number can be positive to specify an external (device specific) \r
948  * interrupt, or negative to specify an internal (core) interrupt.\r
949  *\r
950  * The returned priority value is automatically aligned to the implemented\r
951  * priority bits of the microcontroller.\r
952  *\r
953  * Note: The priority cannot be set for every core interrupt.\r
954  */\r
955 static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)\r
956 {\r
957 \r
958   if(IRQn < 0) {\r
959     return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for Cortex-M3 system interrupts */\r
960   else {\r
961     return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)]           >> (8 - __NVIC_PRIO_BITS)));  } /* get priority for device specific interrupts  */\r
962 }\r
963 \r
964 \r
965 /**\r
966  * @brief  Encode the priority for an interrupt\r
967  *\r
968  * @param  PriorityGroup    The used priority group\r
969  * @param  PreemptPriority  The preemptive priority value (starting from 0)\r
970  * @param  SubPriority      The sub priority value (starting from 0)\r
971  * @return                  The encoded priority for the interrupt\r
972  *\r
973  * Encode the priority for an interrupt with the given priority group,\r
974  * preemptive priority value and sub priority value.\r
975  * In case of a conflict between priority grouping and available\r
976  * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.\r
977  *\r
978  * The returned priority value can be used for NVIC_SetPriority(...) function\r
979  */\r
980 static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)\r
981 {\r
982   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */\r
983   uint32_t PreemptPriorityBits;\r
984   uint32_t SubPriorityBits;\r
985 \r
986   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;\r
987   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;\r
988  \r
989   return (\r
990            ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |\r
991            ((SubPriority     & ((1 << (SubPriorityBits    )) - 1)))\r
992          );\r
993 }\r
994 \r
995 \r
996 /**\r
997  * @brief  Decode the priority of an interrupt\r
998  *\r
999  * @param  Priority           The priority for the interrupt\r
1000  * @param  PriorityGroup      The used priority group\r
1001  * @param  pPreemptPriority   The preemptive priority value (starting from 0)\r
1002  * @param  pSubPriority       The sub priority value (starting from 0)\r
1003  *\r
1004  * Decode an interrupt priority value with the given priority group to \r
1005  * preemptive priority value and sub priority value.\r
1006  * In case of a conflict between priority grouping and available\r
1007  * priority bits (__NVIC_PRIO_BITS) the samllest possible priority group is set.\r
1008  *\r
1009  * The priority value can be retrieved with NVIC_GetPriority(...) function\r
1010  */\r
1011 static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)\r
1012 {\r
1013   uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);          /* only values 0..7 are used          */\r
1014   uint32_t PreemptPriorityBits;\r
1015   uint32_t SubPriorityBits;\r
1016 \r
1017   PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;\r
1018   SubPriorityBits     = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;\r
1019   \r
1020   *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);\r
1021   *pSubPriority     = (Priority                   ) & ((1 << (SubPriorityBits    )) - 1);\r
1022 }\r
1023 \r
1024 \r
1025 \r
1026 /* ##################################    SysTick function  ############################################ */\r
1027 \r
1028 #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)\r
1029 \r
1030 /**\r
1031  * @brief  Initialize and start the SysTick counter and its interrupt.\r
1032  *\r
1033  * @param   ticks   number of ticks between two interrupts\r
1034  * @return  1 = failed, 0 = successful\r
1035  *\r
1036  * Initialise the system tick timer and its interrupt and start the\r
1037  * system tick timer / counter in free running mode to generate \r
1038  * periodical interrupts.\r
1039  */\r
1040 static __INLINE uint32_t SysTick_Config(uint32_t ticks)\r
1041\r
1042   if (ticks > SysTick_LOAD_RELOAD_Msk)  return (1);            /* Reload value impossible */\r
1043                                                                \r
1044   SysTick->LOAD  = (ticks & SysTick_LOAD_RELOAD_Msk) - 1;      /* set reload register */\r
1045   NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);  /* set Priority for Cortex-M0 System Interrupts */\r
1046   SysTick->VAL   = 0;                                          /* Load the SysTick Counter Value */\r
1047   SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk | \r
1048                    SysTick_CTRL_TICKINT_Msk   | \r
1049                    SysTick_CTRL_ENABLE_Msk;                    /* Enable SysTick IRQ and SysTick Timer */\r
1050   return (0);                                                  /* Function successful */\r
1051 }\r
1052 \r
1053 #endif\r
1054 \r
1055 \r
1056 \r
1057 \r
1058 /* ##################################    Reset function  ############################################ */\r
1059 \r
1060 /**\r
1061  * @brief  Initiate a system reset request.\r
1062  *\r
1063  * Initiate a system reset request to reset the MCU\r
1064  */\r
1065 static __INLINE void NVIC_SystemReset(void)\r
1066 {\r
1067   __DSB();                                                     /* Ensure all outstanding memory accesses included\r
1068                                                                   buffered write are completed before reset */              \r
1069   SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      | \r
1070                  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | \r
1071                  SCB_AIRCR_SYSRESETREQ_Msk);                   /* Keep priority group unchanged */\r
1072   __DSB();                                                     /* Ensure completion of memory access */              \r
1073   while(1);                                                    /* wait until reset */\r
1074 }\r
1075 \r
1076 /*@}*/ /* end of group CMSIS_CM3_Core_FunctionInterface */\r
1077 \r
1078 \r
1079 \r
1080 /* ##################################### Debug In/Output function ########################################### */\r
1081 \r
1082 /** @addtogroup CMSIS_CM3_CoreDebugInterface CMSIS CM3 Core Debug Interface\r
1083   Core Debug Interface containing:\r
1084   - Core Debug Receive / Transmit Functions\r
1085   - Core Debug Defines\r
1086   - Core Debug Variables\r
1087 */\r
1088 /*@{*/\r
1089 \r
1090 extern volatile int ITM_RxBuffer;                    /*!< variable to receive characters                             */\r
1091 #define             ITM_RXBUFFER_EMPTY    0x5AA55AA5 /*!< value identifying ITM_RxBuffer is ready for next character */\r
1092 \r
1093 \r
1094 /**\r
1095  * @brief  Outputs a character via the ITM channel 0\r
1096  *\r
1097  * @param  ch   character to output\r
1098  * @return      character to output\r
1099  *\r
1100  * The function outputs a character via the ITM channel 0. \r
1101  * The function returns when no debugger is connected that has booked the output.  \r
1102  * It is blocking when a debugger is connected, but the previous character send is not transmitted. \r
1103  */\r
1104 static __INLINE uint32_t ITM_SendChar (uint32_t ch)\r
1105 {\r
1106   if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)  &&      /* Trace enabled */\r
1107       (ITM->TCR & ITM_TCR_ITMENA_Msk)                  &&      /* ITM enabled */\r
1108       (ITM->TER & (1ul << 0)        )                    )     /* ITM Port #0 enabled */\r
1109   {\r
1110     while (ITM->PORT[0].u32 == 0);\r
1111     ITM->PORT[0].u8 = (uint8_t) ch;\r
1112   }  \r
1113   return (ch);\r
1114 }\r
1115 \r
1116 \r
1117 /**\r
1118  * @brief  Inputs a character via variable ITM_RxBuffer\r
1119  *\r
1120  * @return      received character, -1 = no character received\r
1121  *\r
1122  * The function inputs a character via variable ITM_RxBuffer. \r
1123  * The function returns when no debugger is connected that has booked the output.  \r
1124  * It is blocking when a debugger is connected, but the previous character send is not transmitted. \r
1125  */\r
1126 static __INLINE int ITM_ReceiveChar (void) {\r
1127   int ch = -1;                               /* no character available */\r
1128 \r
1129   if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {\r
1130     ch = ITM_RxBuffer;\r
1131     ITM_RxBuffer = ITM_RXBUFFER_EMPTY;       /* ready for next character */\r
1132   }\r
1133   \r
1134   return (ch); \r
1135 }\r
1136 \r
1137 \r
1138 /**\r
1139  * @brief  Check if a character via variable ITM_RxBuffer is available\r
1140  *\r
1141  * @return      1 = character available, 0 = no character available\r
1142  *\r
1143  * The function checks  variable ITM_RxBuffer whether a character is available or not. \r
1144  * The function returns '1' if a character is available and '0' if no character is available. \r
1145  */\r
1146 static __INLINE int ITM_CheckChar (void) {\r
1147 \r
1148   if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {\r
1149     return (0);                                 /* no character available */\r
1150   } else {\r
1151     return (1);                                 /*    character available */\r
1152   }\r
1153 }\r
1154 \r
1155 /*@}*/ /* end of group CMSIS_CM3_core_DebugInterface */\r
1156 \r
1157 \r
1158 #ifdef __cplusplus\r
1159 }\r
1160 #endif\r
1161 \r
1162 /*@}*/ /* end of group CMSIS_CM3_core_definitions */\r
1163 \r
1164 #endif /* __CORE_CM3_H__ */\r
1165 \r
1166 /*lint -restore */\r