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