discoverpixy
core_cm4.h
Go to the documentation of this file.
1 /**************************************************************************/
10 /* Copyright (c) 2009 - 2013 ARM LIMITED
11 
12  All rights reserved.
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  - Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  - Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  - Neither the name of ARM nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23  *
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ---------------------------------------------------------------------------*/
36 
37 
38 #if defined ( __ICCARM__ )
39  #pragma system_include /* treat file as system include file for MISRA check */
40 #endif
41 
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45 
46 #ifndef __CORE_CM4_H_GENERIC
47 #define __CORE_CM4_H_GENERIC
48 
63 /*******************************************************************************
64  * CMSIS definitions
65  ******************************************************************************/
70 /* CMSIS CM4 definitions */
71 #define __CM4_CMSIS_VERSION_MAIN (0x03)
72 #define __CM4_CMSIS_VERSION_SUB (0x20)
73 #define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16) | \
74  __CM4_CMSIS_VERSION_SUB )
76 #define __CORTEX_M (0x04)
79 #if defined ( __CC_ARM )
80  #define __ASM __asm
81  #define __INLINE __inline
82  #define __STATIC_INLINE static __inline
83 
84 #elif defined ( __ICCARM__ )
85  #define __ASM __asm
86  #define __INLINE inline
87  #define __STATIC_INLINE static inline
88 
89 #elif defined ( __TMS470__ )
90  #define __ASM __asm
91  #define __STATIC_INLINE static inline
92 
93 #elif defined ( __GNUC__ )
94  #define __ASM __asm
95  #define __INLINE inline
96  #define __STATIC_INLINE static inline
97 
98 #elif defined ( __TASKING__ )
99  #define __ASM __asm
100  #define __INLINE inline
101  #define __STATIC_INLINE static inline
102 
103 #endif
104 
107 #if defined ( __CC_ARM )
108  #if defined __TARGET_FPU_VFP
109  #if (__FPU_PRESENT == 1)
110  #define __FPU_USED 1
111  #else
112  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
113  #define __FPU_USED 0
114  #endif
115  #else
116  #define __FPU_USED 0
117  #endif
118 
119 #elif defined ( __ICCARM__ )
120  #if defined __ARMVFP__
121  #if (__FPU_PRESENT == 1)
122  #define __FPU_USED 1
123  #else
124  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
125  #define __FPU_USED 0
126  #endif
127  #else
128  #define __FPU_USED 0
129  #endif
130 
131 #elif defined ( __TMS470__ )
132  #if defined __TI_VFP_SUPPORT__
133  #if (__FPU_PRESENT == 1)
134  #define __FPU_USED 1
135  #else
136  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
137  #define __FPU_USED 0
138  #endif
139  #else
140  #define __FPU_USED 0
141  #endif
142 
143 #elif defined ( __GNUC__ )
144  #if defined (__VFP_FP__) && !defined(__SOFTFP__)
145  #if (__FPU_PRESENT == 1)
146  #define __FPU_USED 1
147  #else
148  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
149  #define __FPU_USED 0
150  #endif
151  #else
152  #define __FPU_USED 0
153  #endif
154 
155 #elif defined ( __TASKING__ )
156  #if defined __FPU_VFP__
157  #if (__FPU_PRESENT == 1)
158  #define __FPU_USED 1
159  #else
160  #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
161  #define __FPU_USED 0
162  #endif
163  #else
164  #define __FPU_USED 0
165  #endif
166 #endif
167 
168 #include <stdint.h> /* standard types definitions */
169 #include <core_cmInstr.h> /* Core Instruction Access */
170 #include <core_cmFunc.h> /* Core Function Access */
171 #include <core_cm4_simd.h> /* Compiler specific SIMD Intrinsics */
172 
173 #endif /* __CORE_CM4_H_GENERIC */
174 
175 #ifndef __CMSIS_GENERIC
176 
177 #ifndef __CORE_CM4_H_DEPENDANT
178 #define __CORE_CM4_H_DEPENDANT
179 
180 /* check device defines and use defaults */
181 #if defined __CHECK_DEVICE_DEFINES
182  #ifndef __CM4_REV
183  #define __CM4_REV 0x0000
184  #warning "__CM4_REV not defined in device header file; using default!"
185  #endif
186 
187  #ifndef __FPU_PRESENT
188  #define __FPU_PRESENT 0
189  #warning "__FPU_PRESENT not defined in device header file; using default!"
190  #endif
191 
192  #ifndef __MPU_PRESENT
193  #define __MPU_PRESENT 0
194  #warning "__MPU_PRESENT not defined in device header file; using default!"
195  #endif
196 
197  #ifndef __NVIC_PRIO_BITS
198  #define __NVIC_PRIO_BITS 4
199  #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
200  #endif
201 
202  #ifndef __Vendor_SysTickConfig
203  #define __Vendor_SysTickConfig 0
204  #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
205  #endif
206 #endif
207 
208 /* IO definitions (access restrictions to peripheral registers) */
216 #ifdef __cplusplus
217  #define __I volatile
218 #else
219  #define __I volatile const
220 #endif
221 #define __O volatile
222 #define __IO volatile
224 
228 /*******************************************************************************
229  * Register Abstraction
230  Core Register contain:
231  - Core Register
232  - Core NVIC Register
233  - Core SCB Register
234  - Core SysTick Register
235  - Core Debug Register
236  - Core MPU Register
237  - Core FPU Register
238  ******************************************************************************/
239 
251 typedef union
252 {
253  struct
254  {
255 #if (__CORTEX_M != 0x04)
256  uint32_t _reserved0:27;
257 #else
258  uint32_t _reserved0:16;
259  uint32_t GE:4;
260  uint32_t _reserved1:7;
261 #endif
262  uint32_t Q:1;
263  uint32_t V:1;
264  uint32_t C:1;
265  uint32_t Z:1;
266  uint32_t N:1;
267  } b;
268  uint32_t w;
269 } APSR_Type;
270 
271 
274 typedef union
275 {
276  struct
277  {
278  uint32_t ISR:9;
279  uint32_t _reserved0:23;
280  } b;
281  uint32_t w;
282 } IPSR_Type;
283 
284 
287 typedef union
288 {
289  struct
290  {
291  uint32_t ISR:9;
292 #if (__CORTEX_M != 0x04)
293  uint32_t _reserved0:15;
294 #else
295  uint32_t _reserved0:7;
296  uint32_t GE:4;
297  uint32_t _reserved1:4;
298 #endif
299  uint32_t T:1;
300  uint32_t IT:2;
301  uint32_t Q:1;
302  uint32_t V:1;
303  uint32_t C:1;
304  uint32_t Z:1;
305  uint32_t N:1;
306  } b;
307  uint32_t w;
308 } xPSR_Type;
309 
310 
313 typedef union
314 {
315  struct
316  {
317  uint32_t nPRIV:1;
318  uint32_t SPSEL:1;
319  uint32_t FPCA:1;
320  uint32_t _reserved0:29;
321  } b;
322  uint32_t w;
323 } CONTROL_Type;
324 
336 typedef struct
337 {
338  __IO uint32_t ISER[8];
339  uint32_t RESERVED0[24];
340  __IO uint32_t ICER[8];
341  uint32_t RSERVED1[24];
342  __IO uint32_t ISPR[8];
343  uint32_t RESERVED2[24];
344  __IO uint32_t ICPR[8];
345  uint32_t RESERVED3[24];
346  __IO uint32_t IABR[8];
347  uint32_t RESERVED4[56];
348  __IO uint8_t IP[240];
349  uint32_t RESERVED5[644];
350  __O uint32_t STIR;
351 } NVIC_Type;
352 
353 /* Software Triggered Interrupt Register Definitions */
354 #define NVIC_STIR_INTID_Pos 0
355 #define NVIC_STIR_INTID_Msk (0x1FFUL << NVIC_STIR_INTID_Pos)
357 
368 typedef struct
369 {
370  __I uint32_t CPUID;
371  __IO uint32_t ICSR;
372  __IO uint32_t VTOR;
373  __IO uint32_t AIRCR;
374  __IO uint32_t SCR;
375  __IO uint32_t CCR;
376  __IO uint8_t SHP[12];
377  __IO uint32_t SHCSR;
378  __IO uint32_t CFSR;
379  __IO uint32_t HFSR;
380  __IO uint32_t DFSR;
381  __IO uint32_t MMFAR;
382  __IO uint32_t BFAR;
383  __IO uint32_t AFSR;
384  __I uint32_t PFR[2];
385  __I uint32_t DFR;
386  __I uint32_t ADR;
387  __I uint32_t MMFR[4];
388  __I uint32_t ISAR[5];
389  uint32_t RESERVED0[5];
390  __IO uint32_t CPACR;
391 } SCB_Type;
392 
393 /* SCB CPUID Register Definitions */
394 #define SCB_CPUID_IMPLEMENTER_Pos 24
395 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)
397 #define SCB_CPUID_VARIANT_Pos 20
398 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos)
400 #define SCB_CPUID_ARCHITECTURE_Pos 16
401 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)
403 #define SCB_CPUID_PARTNO_Pos 4
404 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos)
406 #define SCB_CPUID_REVISION_Pos 0
407 #define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos)
409 /* SCB Interrupt Control State Register Definitions */
410 #define SCB_ICSR_NMIPENDSET_Pos 31
411 #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos)
413 #define SCB_ICSR_PENDSVSET_Pos 28
414 #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos)
416 #define SCB_ICSR_PENDSVCLR_Pos 27
417 #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos)
419 #define SCB_ICSR_PENDSTSET_Pos 26
420 #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos)
422 #define SCB_ICSR_PENDSTCLR_Pos 25
423 #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos)
425 #define SCB_ICSR_ISRPREEMPT_Pos 23
426 #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos)
428 #define SCB_ICSR_ISRPENDING_Pos 22
429 #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos)
431 #define SCB_ICSR_VECTPENDING_Pos 12
432 #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)
434 #define SCB_ICSR_RETTOBASE_Pos 11
435 #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos)
437 #define SCB_ICSR_VECTACTIVE_Pos 0
438 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos)
440 /* SCB Vector Table Offset Register Definitions */
441 #define SCB_VTOR_TBLOFF_Pos 7
442 #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos)
444 /* SCB Application Interrupt and Reset Control Register Definitions */
445 #define SCB_AIRCR_VECTKEY_Pos 16
446 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)
448 #define SCB_AIRCR_VECTKEYSTAT_Pos 16
449 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)
451 #define SCB_AIRCR_ENDIANESS_Pos 15
452 #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos)
454 #define SCB_AIRCR_PRIGROUP_Pos 8
455 #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos)
457 #define SCB_AIRCR_SYSRESETREQ_Pos 2
458 #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos)
460 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1
461 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)
463 #define SCB_AIRCR_VECTRESET_Pos 0
464 #define SCB_AIRCR_VECTRESET_Msk (1UL << SCB_AIRCR_VECTRESET_Pos)
466 /* SCB System Control Register Definitions */
467 #define SCB_SCR_SEVONPEND_Pos 4
468 #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos)
470 #define SCB_SCR_SLEEPDEEP_Pos 2
471 #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos)
473 #define SCB_SCR_SLEEPONEXIT_Pos 1
474 #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos)
476 /* SCB Configuration Control Register Definitions */
477 #define SCB_CCR_STKALIGN_Pos 9
478 #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos)
480 #define SCB_CCR_BFHFNMIGN_Pos 8
481 #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos)
483 #define SCB_CCR_DIV_0_TRP_Pos 4
484 #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos)
486 #define SCB_CCR_UNALIGN_TRP_Pos 3
487 #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos)
489 #define SCB_CCR_USERSETMPEND_Pos 1
490 #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos)
492 #define SCB_CCR_NONBASETHRDENA_Pos 0
493 #define SCB_CCR_NONBASETHRDENA_Msk (1UL << SCB_CCR_NONBASETHRDENA_Pos)
495 /* SCB System Handler Control and State Register Definitions */
496 #define SCB_SHCSR_USGFAULTENA_Pos 18
497 #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos)
499 #define SCB_SHCSR_BUSFAULTENA_Pos 17
500 #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos)
502 #define SCB_SHCSR_MEMFAULTENA_Pos 16
503 #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos)
505 #define SCB_SHCSR_SVCALLPENDED_Pos 15
506 #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos)
508 #define SCB_SHCSR_BUSFAULTPENDED_Pos 14
509 #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos)
511 #define SCB_SHCSR_MEMFAULTPENDED_Pos 13
512 #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos)
514 #define SCB_SHCSR_USGFAULTPENDED_Pos 12
515 #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos)
517 #define SCB_SHCSR_SYSTICKACT_Pos 11
518 #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos)
520 #define SCB_SHCSR_PENDSVACT_Pos 10
521 #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos)
523 #define SCB_SHCSR_MONITORACT_Pos 8
524 #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos)
526 #define SCB_SHCSR_SVCALLACT_Pos 7
527 #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos)
529 #define SCB_SHCSR_USGFAULTACT_Pos 3
530 #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos)
532 #define SCB_SHCSR_BUSFAULTACT_Pos 1
533 #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos)
535 #define SCB_SHCSR_MEMFAULTACT_Pos 0
536 #define SCB_SHCSR_MEMFAULTACT_Msk (1UL << SCB_SHCSR_MEMFAULTACT_Pos)
538 /* SCB Configurable Fault Status Registers Definitions */
539 #define SCB_CFSR_USGFAULTSR_Pos 16
540 #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos)
542 #define SCB_CFSR_BUSFAULTSR_Pos 8
543 #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos)
545 #define SCB_CFSR_MEMFAULTSR_Pos 0
546 #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL << SCB_CFSR_MEMFAULTSR_Pos)
548 /* SCB Hard Fault Status Registers Definitions */
549 #define SCB_HFSR_DEBUGEVT_Pos 31
550 #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos)
552 #define SCB_HFSR_FORCED_Pos 30
553 #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos)
555 #define SCB_HFSR_VECTTBL_Pos 1
556 #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos)
558 /* SCB Debug Fault Status Register Definitions */
559 #define SCB_DFSR_EXTERNAL_Pos 4
560 #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos)
562 #define SCB_DFSR_VCATCH_Pos 3
563 #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos)
565 #define SCB_DFSR_DWTTRAP_Pos 2
566 #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos)
568 #define SCB_DFSR_BKPT_Pos 1
569 #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos)
571 #define SCB_DFSR_HALTED_Pos 0
572 #define SCB_DFSR_HALTED_Msk (1UL << SCB_DFSR_HALTED_Pos)
574 
585 typedef struct
586 {
587  uint32_t RESERVED0[1];
588  __I uint32_t ICTR;
589  __IO uint32_t ACTLR;
590 } SCnSCB_Type;
591 
592 /* Interrupt Controller Type Register Definitions */
593 #define SCnSCB_ICTR_INTLINESNUM_Pos 0
594 #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL << SCnSCB_ICTR_INTLINESNUM_Pos)
596 /* Auxiliary Control Register Definitions */
597 #define SCnSCB_ACTLR_DISOOFP_Pos 9
598 #define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos)
600 #define SCnSCB_ACTLR_DISFPCA_Pos 8
601 #define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos)
603 #define SCnSCB_ACTLR_DISFOLD_Pos 2
604 #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos)
606 #define SCnSCB_ACTLR_DISDEFWBUF_Pos 1
607 #define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos)
609 #define SCnSCB_ACTLR_DISMCYCINT_Pos 0
610 #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL << SCnSCB_ACTLR_DISMCYCINT_Pos)
612 
623 typedef struct
624 {
625  __IO uint32_t CTRL;
626  __IO uint32_t LOAD;
627  __IO uint32_t VAL;
628  __I uint32_t CALIB;
629 } SysTick_Type;
630 
631 /* SysTick Control / Status Register Definitions */
632 #define SysTick_CTRL_COUNTFLAG_Pos 16
633 #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos)
635 #define SysTick_CTRL_CLKSOURCE_Pos 2
636 #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos)
638 #define SysTick_CTRL_TICKINT_Pos 1
639 #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos)
641 #define SysTick_CTRL_ENABLE_Pos 0
642 #define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos)
644 /* SysTick Reload Register Definitions */
645 #define SysTick_LOAD_RELOAD_Pos 0
646 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos)
648 /* SysTick Current Register Definitions */
649 #define SysTick_VAL_CURRENT_Pos 0
650 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)
652 /* SysTick Calibration Register Definitions */
653 #define SysTick_CALIB_NOREF_Pos 31
654 #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos)
656 #define SysTick_CALIB_SKEW_Pos 30
657 #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos)
659 #define SysTick_CALIB_TENMS_Pos 0
660 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)
662 
673 typedef struct
674 {
675  __O union
676  {
677  __O uint8_t u8;
678  __O uint16_t u16;
679  __O uint32_t u32;
680  } PORT [32];
681  uint32_t RESERVED0[864];
682  __IO uint32_t TER;
683  uint32_t RESERVED1[15];
684  __IO uint32_t TPR;
685  uint32_t RESERVED2[15];
686  __IO uint32_t TCR;
687  uint32_t RESERVED3[29];
688  __O uint32_t IWR;
689  __I uint32_t IRR;
690  __IO uint32_t IMCR;
691  uint32_t RESERVED4[43];
692  __O uint32_t LAR;
693  __I uint32_t LSR;
694  uint32_t RESERVED5[6];
695  __I uint32_t PID4;
696  __I uint32_t PID5;
697  __I uint32_t PID6;
698  __I uint32_t PID7;
699  __I uint32_t PID0;
700  __I uint32_t PID1;
701  __I uint32_t PID2;
702  __I uint32_t PID3;
703  __I uint32_t CID0;
704  __I uint32_t CID1;
705  __I uint32_t CID2;
706  __I uint32_t CID3;
707 } ITM_Type;
708 
709 /* ITM Trace Privilege Register Definitions */
710 #define ITM_TPR_PRIVMASK_Pos 0
711 #define ITM_TPR_PRIVMASK_Msk (0xFUL << ITM_TPR_PRIVMASK_Pos)
713 /* ITM Trace Control Register Definitions */
714 #define ITM_TCR_BUSY_Pos 23
715 #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos)
717 #define ITM_TCR_TraceBusID_Pos 16
718 #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos)
720 #define ITM_TCR_GTSFREQ_Pos 10
721 #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos)
723 #define ITM_TCR_TSPrescale_Pos 8
724 #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos)
726 #define ITM_TCR_SWOENA_Pos 4
727 #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos)
729 #define ITM_TCR_DWTENA_Pos 3
730 #define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos)
732 #define ITM_TCR_SYNCENA_Pos 2
733 #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos)
735 #define ITM_TCR_TSENA_Pos 1
736 #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos)
738 #define ITM_TCR_ITMENA_Pos 0
739 #define ITM_TCR_ITMENA_Msk (1UL << ITM_TCR_ITMENA_Pos)
741 /* ITM Integration Write Register Definitions */
742 #define ITM_IWR_ATVALIDM_Pos 0
743 #define ITM_IWR_ATVALIDM_Msk (1UL << ITM_IWR_ATVALIDM_Pos)
745 /* ITM Integration Read Register Definitions */
746 #define ITM_IRR_ATREADYM_Pos 0
747 #define ITM_IRR_ATREADYM_Msk (1UL << ITM_IRR_ATREADYM_Pos)
749 /* ITM Integration Mode Control Register Definitions */
750 #define ITM_IMCR_INTEGRATION_Pos 0
751 #define ITM_IMCR_INTEGRATION_Msk (1UL << ITM_IMCR_INTEGRATION_Pos)
753 /* ITM Lock Status Register Definitions */
754 #define ITM_LSR_ByteAcc_Pos 2
755 #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos)
757 #define ITM_LSR_Access_Pos 1
758 #define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos)
760 #define ITM_LSR_Present_Pos 0
761 #define ITM_LSR_Present_Msk (1UL << ITM_LSR_Present_Pos)
763  /* end of group CMSIS_ITM */
764 
765 
774 typedef struct
775 {
776  __IO uint32_t CTRL;
777  __IO uint32_t CYCCNT;
778  __IO uint32_t CPICNT;
779  __IO uint32_t EXCCNT;
780  __IO uint32_t SLEEPCNT;
781  __IO uint32_t LSUCNT;
782  __IO uint32_t FOLDCNT;
783  __I uint32_t PCSR;
784  __IO uint32_t COMP0;
785  __IO uint32_t MASK0;
786  __IO uint32_t FUNCTION0;
787  uint32_t RESERVED0[1];
788  __IO uint32_t COMP1;
789  __IO uint32_t MASK1;
790  __IO uint32_t FUNCTION1;
791  uint32_t RESERVED1[1];
792  __IO uint32_t COMP2;
793  __IO uint32_t MASK2;
794  __IO uint32_t FUNCTION2;
795  uint32_t RESERVED2[1];
796  __IO uint32_t COMP3;
797  __IO uint32_t MASK3;
798  __IO uint32_t FUNCTION3;
799 } DWT_Type;
800 
801 /* DWT Control Register Definitions */
802 #define DWT_CTRL_NUMCOMP_Pos 28
803 #define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos)
805 #define DWT_CTRL_NOTRCPKT_Pos 27
806 #define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos)
808 #define DWT_CTRL_NOEXTTRIG_Pos 26
809 #define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos)
811 #define DWT_CTRL_NOCYCCNT_Pos 25
812 #define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos)
814 #define DWT_CTRL_NOPRFCNT_Pos 24
815 #define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos)
817 #define DWT_CTRL_CYCEVTENA_Pos 22
818 #define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos)
820 #define DWT_CTRL_FOLDEVTENA_Pos 21
821 #define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos)
823 #define DWT_CTRL_LSUEVTENA_Pos 20
824 #define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos)
826 #define DWT_CTRL_SLEEPEVTENA_Pos 19
827 #define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos)
829 #define DWT_CTRL_EXCEVTENA_Pos 18
830 #define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos)
832 #define DWT_CTRL_CPIEVTENA_Pos 17
833 #define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos)
835 #define DWT_CTRL_EXCTRCENA_Pos 16
836 #define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos)
838 #define DWT_CTRL_PCSAMPLENA_Pos 12
839 #define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos)
841 #define DWT_CTRL_SYNCTAP_Pos 10
842 #define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos)
844 #define DWT_CTRL_CYCTAP_Pos 9
845 #define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos)
847 #define DWT_CTRL_POSTINIT_Pos 5
848 #define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos)
850 #define DWT_CTRL_POSTPRESET_Pos 1
851 #define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos)
853 #define DWT_CTRL_CYCCNTENA_Pos 0
854 #define DWT_CTRL_CYCCNTENA_Msk (0x1UL << DWT_CTRL_CYCCNTENA_Pos)
856 /* DWT CPI Count Register Definitions */
857 #define DWT_CPICNT_CPICNT_Pos 0
858 #define DWT_CPICNT_CPICNT_Msk (0xFFUL << DWT_CPICNT_CPICNT_Pos)
860 /* DWT Exception Overhead Count Register Definitions */
861 #define DWT_EXCCNT_EXCCNT_Pos 0
862 #define DWT_EXCCNT_EXCCNT_Msk (0xFFUL << DWT_EXCCNT_EXCCNT_Pos)
864 /* DWT Sleep Count Register Definitions */
865 #define DWT_SLEEPCNT_SLEEPCNT_Pos 0
866 #define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL << DWT_SLEEPCNT_SLEEPCNT_Pos)
868 /* DWT LSU Count Register Definitions */
869 #define DWT_LSUCNT_LSUCNT_Pos 0
870 #define DWT_LSUCNT_LSUCNT_Msk (0xFFUL << DWT_LSUCNT_LSUCNT_Pos)
872 /* DWT Folded-instruction Count Register Definitions */
873 #define DWT_FOLDCNT_FOLDCNT_Pos 0
874 #define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL << DWT_FOLDCNT_FOLDCNT_Pos)
876 /* DWT Comparator Mask Register Definitions */
877 #define DWT_MASK_MASK_Pos 0
878 #define DWT_MASK_MASK_Msk (0x1FUL << DWT_MASK_MASK_Pos)
880 /* DWT Comparator Function Register Definitions */
881 #define DWT_FUNCTION_MATCHED_Pos 24
882 #define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos)
884 #define DWT_FUNCTION_DATAVADDR1_Pos 16
885 #define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos)
887 #define DWT_FUNCTION_DATAVADDR0_Pos 12
888 #define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos)
890 #define DWT_FUNCTION_DATAVSIZE_Pos 10
891 #define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos)
893 #define DWT_FUNCTION_LNK1ENA_Pos 9
894 #define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos)
896 #define DWT_FUNCTION_DATAVMATCH_Pos 8
897 #define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos)
899 #define DWT_FUNCTION_CYCMATCH_Pos 7
900 #define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos)
902 #define DWT_FUNCTION_EMITRANGE_Pos 5
903 #define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos)
905 #define DWT_FUNCTION_FUNCTION_Pos 0
906 #define DWT_FUNCTION_FUNCTION_Msk (0xFUL << DWT_FUNCTION_FUNCTION_Pos)
908  /* end of group CMSIS_DWT */
909 
910 
919 typedef struct
920 {
921  __IO uint32_t SSPSR;
922  __IO uint32_t CSPSR;
923  uint32_t RESERVED0[2];
924  __IO uint32_t ACPR;
925  uint32_t RESERVED1[55];
926  __IO uint32_t SPPR;
927  uint32_t RESERVED2[131];
928  __I uint32_t FFSR;
929  __IO uint32_t FFCR;
930  __I uint32_t FSCR;
931  uint32_t RESERVED3[759];
932  __I uint32_t TRIGGER;
933  __I uint32_t FIFO0;
934  __I uint32_t ITATBCTR2;
935  uint32_t RESERVED4[1];
936  __I uint32_t ITATBCTR0;
937  __I uint32_t FIFO1;
938  __IO uint32_t ITCTRL;
939  uint32_t RESERVED5[39];
940  __IO uint32_t CLAIMSET;
941  __IO uint32_t CLAIMCLR;
942  uint32_t RESERVED7[8];
943  __I uint32_t DEVID;
944  __I uint32_t DEVTYPE;
945 } TPI_Type;
946 
947 /* TPI Asynchronous Clock Prescaler Register Definitions */
948 #define TPI_ACPR_PRESCALER_Pos 0
949 #define TPI_ACPR_PRESCALER_Msk (0x1FFFUL << TPI_ACPR_PRESCALER_Pos)
951 /* TPI Selected Pin Protocol Register Definitions */
952 #define TPI_SPPR_TXMODE_Pos 0
953 #define TPI_SPPR_TXMODE_Msk (0x3UL << TPI_SPPR_TXMODE_Pos)
955 /* TPI Formatter and Flush Status Register Definitions */
956 #define TPI_FFSR_FtNonStop_Pos 3
957 #define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos)
959 #define TPI_FFSR_TCPresent_Pos 2
960 #define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos)
962 #define TPI_FFSR_FtStopped_Pos 1
963 #define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos)
965 #define TPI_FFSR_FlInProg_Pos 0
966 #define TPI_FFSR_FlInProg_Msk (0x1UL << TPI_FFSR_FlInProg_Pos)
968 /* TPI Formatter and Flush Control Register Definitions */
969 #define TPI_FFCR_TrigIn_Pos 8
970 #define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos)
972 #define TPI_FFCR_EnFCont_Pos 1
973 #define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos)
975 /* TPI TRIGGER Register Definitions */
976 #define TPI_TRIGGER_TRIGGER_Pos 0
977 #define TPI_TRIGGER_TRIGGER_Msk (0x1UL << TPI_TRIGGER_TRIGGER_Pos)
979 /* TPI Integration ETM Data Register Definitions (FIFO0) */
980 #define TPI_FIFO0_ITM_ATVALID_Pos 29
981 #define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos)
983 #define TPI_FIFO0_ITM_bytecount_Pos 27
984 #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos)
986 #define TPI_FIFO0_ETM_ATVALID_Pos 26
987 #define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos)
989 #define TPI_FIFO0_ETM_bytecount_Pos 24
990 #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos)
992 #define TPI_FIFO0_ETM2_Pos 16
993 #define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos)
995 #define TPI_FIFO0_ETM1_Pos 8
996 #define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos)
998 #define TPI_FIFO0_ETM0_Pos 0
999 #define TPI_FIFO0_ETM0_Msk (0xFFUL << TPI_FIFO0_ETM0_Pos)
1001 /* TPI ITATBCTR2 Register Definitions */
1002 #define TPI_ITATBCTR2_ATREADY_Pos 0
1003 #define TPI_ITATBCTR2_ATREADY_Msk (0x1UL << TPI_ITATBCTR2_ATREADY_Pos)
1005 /* TPI Integration ITM Data Register Definitions (FIFO1) */
1006 #define TPI_FIFO1_ITM_ATVALID_Pos 29
1007 #define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos)
1009 #define TPI_FIFO1_ITM_bytecount_Pos 27
1010 #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos)
1012 #define TPI_FIFO1_ETM_ATVALID_Pos 26
1013 #define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos)
1015 #define TPI_FIFO1_ETM_bytecount_Pos 24
1016 #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos)
1018 #define TPI_FIFO1_ITM2_Pos 16
1019 #define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos)
1021 #define TPI_FIFO1_ITM1_Pos 8
1022 #define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos)
1024 #define TPI_FIFO1_ITM0_Pos 0
1025 #define TPI_FIFO1_ITM0_Msk (0xFFUL << TPI_FIFO1_ITM0_Pos)
1027 /* TPI ITATBCTR0 Register Definitions */
1028 #define TPI_ITATBCTR0_ATREADY_Pos 0
1029 #define TPI_ITATBCTR0_ATREADY_Msk (0x1UL << TPI_ITATBCTR0_ATREADY_Pos)
1031 /* TPI Integration Mode Control Register Definitions */
1032 #define TPI_ITCTRL_Mode_Pos 0
1033 #define TPI_ITCTRL_Mode_Msk (0x1UL << TPI_ITCTRL_Mode_Pos)
1035 /* TPI DEVID Register Definitions */
1036 #define TPI_DEVID_NRZVALID_Pos 11
1037 #define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos)
1039 #define TPI_DEVID_MANCVALID_Pos 10
1040 #define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos)
1042 #define TPI_DEVID_PTINVALID_Pos 9
1043 #define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos)
1045 #define TPI_DEVID_MinBufSz_Pos 6
1046 #define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos)
1048 #define TPI_DEVID_AsynClkIn_Pos 5
1049 #define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos)
1051 #define TPI_DEVID_NrTraceInput_Pos 0
1052 #define TPI_DEVID_NrTraceInput_Msk (0x1FUL << TPI_DEVID_NrTraceInput_Pos)
1054 /* TPI DEVTYPE Register Definitions */
1055 #define TPI_DEVTYPE_SubType_Pos 0
1056 #define TPI_DEVTYPE_SubType_Msk (0xFUL << TPI_DEVTYPE_SubType_Pos)
1058 #define TPI_DEVTYPE_MajorType_Pos 4
1059 #define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos)
1061  /* end of group CMSIS_TPI */
1062 
1063 
1064 #if (__MPU_PRESENT == 1)
1065 
1073 typedef struct
1074 {
1075  __I uint32_t TYPE;
1076  __IO uint32_t CTRL;
1077  __IO uint32_t RNR;
1078  __IO uint32_t RBAR;
1079  __IO uint32_t RASR;
1080  __IO uint32_t RBAR_A1;
1081  __IO uint32_t RASR_A1;
1082  __IO uint32_t RBAR_A2;
1083  __IO uint32_t RASR_A2;
1084  __IO uint32_t RBAR_A3;
1085  __IO uint32_t RASR_A3;
1086 } MPU_Type;
1087 
1088 /* MPU Type Register */
1089 #define MPU_TYPE_IREGION_Pos 16
1090 #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos)
1092 #define MPU_TYPE_DREGION_Pos 8
1093 #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos)
1095 #define MPU_TYPE_SEPARATE_Pos 0
1096 #define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos)
1098 /* MPU Control Register */
1099 #define MPU_CTRL_PRIVDEFENA_Pos 2
1100 #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos)
1102 #define MPU_CTRL_HFNMIENA_Pos 1
1103 #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos)
1105 #define MPU_CTRL_ENABLE_Pos 0
1106 #define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos)
1108 /* MPU Region Number Register */
1109 #define MPU_RNR_REGION_Pos 0
1110 #define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos)
1112 /* MPU Region Base Address Register */
1113 #define MPU_RBAR_ADDR_Pos 5
1114 #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos)
1116 #define MPU_RBAR_VALID_Pos 4
1117 #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos)
1119 #define MPU_RBAR_REGION_Pos 0
1120 #define MPU_RBAR_REGION_Msk (0xFUL << MPU_RBAR_REGION_Pos)
1122 /* MPU Region Attribute and Size Register */
1123 #define MPU_RASR_ATTRS_Pos 16
1124 #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos)
1126 #define MPU_RASR_XN_Pos 28
1127 #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos)
1129 #define MPU_RASR_AP_Pos 24
1130 #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos)
1132 #define MPU_RASR_TEX_Pos 19
1133 #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos)
1135 #define MPU_RASR_S_Pos 18
1136 #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos)
1138 #define MPU_RASR_C_Pos 17
1139 #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos)
1141 #define MPU_RASR_B_Pos 16
1142 #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos)
1144 #define MPU_RASR_SRD_Pos 8
1145 #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos)
1147 #define MPU_RASR_SIZE_Pos 1
1148 #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos)
1150 #define MPU_RASR_ENABLE_Pos 0
1151 #define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos)
1153 
1154 #endif
1155 
1156 
1157 #if (__FPU_PRESENT == 1)
1158 
1166 typedef struct
1167 {
1168  uint32_t RESERVED0[1];
1169  __IO uint32_t FPCCR;
1170  __IO uint32_t FPCAR;
1171  __IO uint32_t FPDSCR;
1172  __I uint32_t MVFR0;
1173  __I uint32_t MVFR1;
1174 } FPU_Type;
1175 
1176 /* Floating-Point Context Control Register */
1177 #define FPU_FPCCR_ASPEN_Pos 31
1178 #define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos)
1180 #define FPU_FPCCR_LSPEN_Pos 30
1181 #define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos)
1183 #define FPU_FPCCR_MONRDY_Pos 8
1184 #define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos)
1186 #define FPU_FPCCR_BFRDY_Pos 6
1187 #define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos)
1189 #define FPU_FPCCR_MMRDY_Pos 5
1190 #define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos)
1192 #define FPU_FPCCR_HFRDY_Pos 4
1193 #define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos)
1195 #define FPU_FPCCR_THREAD_Pos 3
1196 #define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos)
1198 #define FPU_FPCCR_USER_Pos 1
1199 #define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos)
1201 #define FPU_FPCCR_LSPACT_Pos 0
1202 #define FPU_FPCCR_LSPACT_Msk (1UL << FPU_FPCCR_LSPACT_Pos)
1204 /* Floating-Point Context Address Register */
1205 #define FPU_FPCAR_ADDRESS_Pos 3
1206 #define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos)
1208 /* Floating-Point Default Status Control Register */
1209 #define FPU_FPDSCR_AHP_Pos 26
1210 #define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos)
1212 #define FPU_FPDSCR_DN_Pos 25
1213 #define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos)
1215 #define FPU_FPDSCR_FZ_Pos 24
1216 #define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos)
1218 #define FPU_FPDSCR_RMode_Pos 22
1219 #define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos)
1221 /* Media and FP Feature Register 0 */
1222 #define FPU_MVFR0_FP_rounding_modes_Pos 28
1223 #define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos)
1225 #define FPU_MVFR0_Short_vectors_Pos 24
1226 #define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos)
1228 #define FPU_MVFR0_Square_root_Pos 20
1229 #define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos)
1231 #define FPU_MVFR0_Divide_Pos 16
1232 #define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos)
1234 #define FPU_MVFR0_FP_excep_trapping_Pos 12
1235 #define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos)
1237 #define FPU_MVFR0_Double_precision_Pos 8
1238 #define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos)
1240 #define FPU_MVFR0_Single_precision_Pos 4
1241 #define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos)
1243 #define FPU_MVFR0_A_SIMD_registers_Pos 0
1244 #define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL << FPU_MVFR0_A_SIMD_registers_Pos)
1246 /* Media and FP Feature Register 1 */
1247 #define FPU_MVFR1_FP_fused_MAC_Pos 28
1248 #define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos)
1250 #define FPU_MVFR1_FP_HPFP_Pos 24
1251 #define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos)
1253 #define FPU_MVFR1_D_NaN_mode_Pos 4
1254 #define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos)
1256 #define FPU_MVFR1_FtZ_mode_Pos 0
1257 #define FPU_MVFR1_FtZ_mode_Msk (0xFUL << FPU_MVFR1_FtZ_mode_Pos)
1259 
1260 #endif
1261 
1262 
1271 typedef struct
1272 {
1273  __IO uint32_t DHCSR;
1274  __O uint32_t DCRSR;
1275  __IO uint32_t DCRDR;
1276  __IO uint32_t DEMCR;
1277 } CoreDebug_Type;
1278 
1279 /* Debug Halting Control and Status Register */
1280 #define CoreDebug_DHCSR_DBGKEY_Pos 16
1281 #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos)
1283 #define CoreDebug_DHCSR_S_RESET_ST_Pos 25
1284 #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos)
1286 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24
1287 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos)
1289 #define CoreDebug_DHCSR_S_LOCKUP_Pos 19
1290 #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos)
1292 #define CoreDebug_DHCSR_S_SLEEP_Pos 18
1293 #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos)
1295 #define CoreDebug_DHCSR_S_HALT_Pos 17
1296 #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos)
1298 #define CoreDebug_DHCSR_S_REGRDY_Pos 16
1299 #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos)
1301 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5
1302 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos)
1304 #define CoreDebug_DHCSR_C_MASKINTS_Pos 3
1305 #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos)
1307 #define CoreDebug_DHCSR_C_STEP_Pos 2
1308 #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos)
1310 #define CoreDebug_DHCSR_C_HALT_Pos 1
1311 #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos)
1313 #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0
1314 #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL << CoreDebug_DHCSR_C_DEBUGEN_Pos)
1316 /* Debug Core Register Selector Register */
1317 #define CoreDebug_DCRSR_REGWnR_Pos 16
1318 #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos)
1320 #define CoreDebug_DCRSR_REGSEL_Pos 0
1321 #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL << CoreDebug_DCRSR_REGSEL_Pos)
1323 /* Debug Exception and Monitor Control Register */
1324 #define CoreDebug_DEMCR_TRCENA_Pos 24
1325 #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos)
1327 #define CoreDebug_DEMCR_MON_REQ_Pos 19
1328 #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos)
1330 #define CoreDebug_DEMCR_MON_STEP_Pos 18
1331 #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos)
1333 #define CoreDebug_DEMCR_MON_PEND_Pos 17
1334 #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos)
1336 #define CoreDebug_DEMCR_MON_EN_Pos 16
1337 #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos)
1339 #define CoreDebug_DEMCR_VC_HARDERR_Pos 10
1340 #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos)
1342 #define CoreDebug_DEMCR_VC_INTERR_Pos 9
1343 #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos)
1345 #define CoreDebug_DEMCR_VC_BUSERR_Pos 8
1346 #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos)
1348 #define CoreDebug_DEMCR_VC_STATERR_Pos 7
1349 #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos)
1351 #define CoreDebug_DEMCR_VC_CHKERR_Pos 6
1352 #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos)
1354 #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5
1355 #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos)
1357 #define CoreDebug_DEMCR_VC_MMERR_Pos 4
1358 #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos)
1360 #define CoreDebug_DEMCR_VC_CORERESET_Pos 0
1361 #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL << CoreDebug_DEMCR_VC_CORERESET_Pos)
1363 
1372 /* Memory mapping of Cortex-M4 Hardware */
1373 #define SCS_BASE (0xE000E000UL)
1374 #define ITM_BASE (0xE0000000UL)
1375 #define DWT_BASE (0xE0001000UL)
1376 #define TPI_BASE (0xE0040000UL)
1377 #define CoreDebug_BASE (0xE000EDF0UL)
1378 #define SysTick_BASE (SCS_BASE + 0x0010UL)
1379 #define NVIC_BASE (SCS_BASE + 0x0100UL)
1380 #define SCB_BASE (SCS_BASE + 0x0D00UL)
1382 #define SCnSCB ((SCnSCB_Type *) SCS_BASE )
1383 #define SCB ((SCB_Type *) SCB_BASE )
1384 #define SysTick ((SysTick_Type *) SysTick_BASE )
1385 #define NVIC ((NVIC_Type *) NVIC_BASE )
1386 #define ITM ((ITM_Type *) ITM_BASE )
1387 #define DWT ((DWT_Type *) DWT_BASE )
1388 #define TPI ((TPI_Type *) TPI_BASE )
1389 #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE)
1391 #if (__MPU_PRESENT == 1)
1392  #define MPU_BASE (SCS_BASE + 0x0D90UL)
1393  #define MPU ((MPU_Type *) MPU_BASE )
1394 #endif
1395 
1396 #if (__FPU_PRESENT == 1)
1397  #define FPU_BASE (SCS_BASE + 0x0F30UL)
1398  #define FPU ((FPU_Type *) FPU_BASE )
1399 #endif
1400 
1405 /*******************************************************************************
1406  * Hardware Abstraction Layer
1407  Core Function Interface contains:
1408  - Core NVIC Functions
1409  - Core SysTick Functions
1410  - Core Debug Functions
1411  - Core Register Access Functions
1412  ******************************************************************************/
1418 /* ########################## NVIC functions #################################### */
1435 __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1436 {
1437  uint32_t reg_value;
1438  uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
1439 
1440  reg_value = SCB->AIRCR; /* read old register configuration */
1441  reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
1442  reg_value = (reg_value |
1443  ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) |
1444  (PriorityGroupTmp << 8)); /* Insert write key and priorty group */
1445  SCB->AIRCR = reg_value;
1446 }
1447 
1448 
1455 __STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void)
1456 {
1457  return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */
1458 }
1459 
1460 
1467 __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
1468 {
1469 /* NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); enable interrupt */
1470  NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5] = (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F)); /* enable interrupt */
1471 }
1472 
1473 
1480 __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
1481 {
1482  NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
1483 }
1484 
1485 
1496 __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
1497 {
1498  return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
1499 }
1500 
1501 
1508 __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
1509 {
1510  NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
1511 }
1512 
1513 
1520 __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1521 {
1522  NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
1523 }
1524 
1525 
1535 __STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
1536 {
1537  return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
1538 }
1539 
1540 
1550 __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
1551 {
1552  if(IRQn < 0) {
1553  SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M System Interrupts */
1554  else {
1555  NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
1556 }
1557 
1558 
1570 __STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
1571 {
1572 
1573  if(IRQn < 0) {
1574  return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M system interrupts */
1575  else {
1576  return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
1577 }
1578 
1579 
1592 __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
1593 {
1594  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1595  uint32_t PreemptPriorityBits;
1596  uint32_t SubPriorityBits;
1597 
1598  PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1599  SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
1600 
1601  return (
1602  ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
1603  ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
1604  );
1605 }
1606 
1607 
1620 __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
1621 {
1622  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1623  uint32_t PreemptPriorityBits;
1624  uint32_t SubPriorityBits;
1625 
1626  PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1627  SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
1628 
1629  *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
1630  *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
1631 }
1632 
1633 
1638 __STATIC_INLINE void NVIC_SystemReset(void)
1639 {
1640  __DSB(); /* Ensure all outstanding memory accesses included
1641  buffered write are completed before reset */
1642  SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
1643  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
1644  SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
1645  __DSB(); /* Ensure completion of memory access */
1646  while(1); /* wait until reset */
1647 }
1648 
1653 /* ################################## SysTick function ############################################ */
1660 #if (__Vendor_SysTickConfig == 0)
1661 
1677 __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
1678 {
1679  if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
1680 
1681  SysTick->LOAD = ticks - 1; /* set reload register */
1682  NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Systick Interrupt */
1683  SysTick->VAL = 0; /* Load the SysTick Counter Value */
1686  SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
1687  return (0); /* Function successful */
1688 }
1689 
1690 #endif
1691 
1696 /* ##################################### Debug In/Output function ########################################### */
1703 extern volatile int32_t ITM_RxBuffer;
1704 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5
1717 __STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
1718 {
1719  if ((ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
1720  (ITM->TER & (1UL << 0) ) ) /* ITM Port #0 enabled */
1721  {
1722  while (ITM->PORT[0].u32 == 0);
1723  ITM->PORT[0].u8 = (uint8_t) ch;
1724  }
1725  return (ch);
1726 }
1727 
1728 
1736 __STATIC_INLINE int32_t ITM_ReceiveChar (void) {
1737  int32_t ch = -1; /* no character available */
1738 
1739  if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
1740  ch = ITM_RxBuffer;
1741  ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
1742  }
1743 
1744  return (ch);
1745 }
1746 
1747 
1755 __STATIC_INLINE int32_t ITM_CheckChar (void) {
1756 
1757  if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
1758  return (0); /* no character available */
1759  } else {
1760  return (1); /* character available */
1761  }
1762 }
1763 
1766 #endif /* __CORE_CM4_H_DEPENDANT */
1767 
1768 #endif /* __CMSIS_GENERIC */
1769 
1770 #ifdef __cplusplus
1771 }
1772 #endif
__IO uint32_t VAL
Definition: core_cm4.h:627
#define ITM
Definition: core_cm4.h:1386
CMSIS Cortex-M Core Function Access Header File.
Structure type to access the Data Watchpoint and Trace Register (DWT).
Definition: core_cm4.h:774
#define __NVIC_PRIO_BITS
Definition: stm32f4xx.h:166
#define SCB_AIRCR_PRIGROUP_Msk
Definition: core_cm4.h:455
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
Get Pending Interrupt.
Definition: core_cm4.h:1496
__IO uint32_t CLAIMCLR
Definition: core_cm4.h:941
__O uint8_t u8
Definition: core_cm4.h:677
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
Set Pending Interrupt.
Definition: core_cm4.h:1508
__IO uint32_t CPACR
Definition: core_cm4.h:390
__IO uint32_t CFSR
Definition: core_cm4.h:378
__I uint32_t FSCR
Definition: core_cm4.h:930
__I uint32_t IRR
Definition: core_cm4.h:689
__I uint32_t DEVID
Definition: core_cm4.h:943
__I uint32_t CID0
Definition: core_cm4.h:703
__I uint32_t PID4
Definition: core_cm4.h:695
__I uint32_t FIFO0
Definition: core_cm4.h:933
#define __I
Definition: core_cm4.h:219
__IO uint32_t DFSR
Definition: core_cm4.h:380
__IO uint32_t MMFAR
Definition: core_cm4.h:381
__IO uint32_t TER
Definition: core_cm4.h:682
__I uint32_t CPUID
Definition: core_cm4.h:370
__IO uint32_t BFAR
Definition: core_cm4.h:382
__IO uint32_t COMP1
Definition: core_cm4.h:788
__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void)
Get Priority Grouping.
Definition: core_cm4.h:1455
#define SCB_AIRCR_VECTKEY_Msk
Definition: core_cm4.h:446
__IO uint32_t COMP0
Definition: core_cm4.h:784
__IO uint32_t COMP2
Definition: core_cm4.h:792
__I uint32_t CID2
Definition: core_cm4.h:705
__IO uint32_t HFSR
Definition: core_cm4.h:379
#define SysTick
Definition: core_cm4.h:1384
#define ITM_RXBUFFER_EMPTY
Definition: core_cm4.h:1704
__IO uint32_t FFCR
Definition: core_cm4.h:929
__I uint32_t CID3
Definition: core_cm4.h:706
IRQn
STM32F4XX Interrupt Number Definition, according to the selected device in Library_configuration_sect...
Definition: stm32f4xx.h:174
#define __IO
Definition: core_cm4.h:222
__IO uint32_t LSUCNT
Definition: core_cm4.h:781
__IO uint32_t ACPR
Definition: core_cm4.h:924
__IO uint32_t TCR
Definition: core_cm4.h:686
__IO uint32_t SHCSR
Definition: core_cm4.h:377
__IO uint32_t CLAIMSET
Definition: core_cm4.h:940
#define __O
Definition: core_cm4.h:221
volatile int32_t ITM_RxBuffer
__STATIC_INLINE int32_t ITM_ReceiveChar(void)
ITM Receive Character.
Definition: core_cm4.h:1736
__O uint16_t u16
Definition: core_cm4.h:678
__O uint32_t u32
Definition: core_cm4.h:679
__IO uint32_t MASK0
Definition: core_cm4.h:785
__IO uint32_t FUNCTION3
Definition: core_cm4.h:798
Union type to access the Interrupt Program Status Register (IPSR).
Definition: core_cm4.h:274
__I uint32_t PID0
Definition: core_cm4.h:699
uint32_t w
Definition: core_cm4.h:322
Structure type to access the Trace Port Interface Register (TPI).
Definition: core_cm4.h:919
__I uint32_t ICTR
Definition: core_cm4.h:588
__IO uint32_t SPPR
Definition: core_cm4.h:926
__I uint32_t FFSR
Definition: core_cm4.h:928
__STATIC_INLINE int32_t ITM_CheckChar(void)
ITM Check Character.
Definition: core_cm4.h:1755
__IO uint32_t FUNCTION2
Definition: core_cm4.h:794
__I uint32_t PID5
Definition: core_cm4.h:696
__IO uint32_t AFSR
Definition: core_cm4.h:383
__IO uint32_t SSPSR
Definition: core_cm4.h:921
__I uint32_t PID2
Definition: core_cm4.h:701
__IO uint32_t DEMCR
Definition: core_cm4.h:1276
__IO uint32_t EXCCNT
Definition: core_cm4.h:779
__IO uint32_t COMP3
Definition: core_cm4.h:796
#define NVIC
Definition: core_cm4.h:1385
__IO uint32_t LOAD
Definition: core_cm4.h:626
__IO uint32_t VTOR
Definition: core_cm4.h:372
__I uint32_t PID3
Definition: core_cm4.h:702
__IO uint32_t CTRL
Definition: core_cm4.h:625
uint32_t w
Definition: core_cm4.h:307
__IO uint32_t ITCTRL
Definition: core_cm4.h:938
__O uint32_t IWR
Definition: core_cm4.h:688
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
Enable External Interrupt.
Definition: core_cm4.h:1467
__I uint32_t PCSR
Definition: core_cm4.h:783
CMSIS Cortex-M4 SIMD Header File.
Structure type to access the Core Debug Register (CoreDebug).
Definition: core_cm4.h:1271
Structure type to access the System Control Block (SCB).
Definition: core_cm4.h:368
#define ITM_TCR_ITMENA_Msk
Definition: core_cm4.h:739
__I uint32_t DFR
Definition: core_cm4.h:385
#define SCB
Definition: core_cm4.h:1383
Structure type to access the Instrumentation Trace Macrocell Register (ITM).
Definition: core_cm4.h:673
uint32_t w
Definition: core_cm4.h:281
enum IRQn IRQn_Type
STM32F4XX Interrupt Number Definition, according to the selected device in Library_configuration_sect...
__O uint32_t DCRSR
Definition: core_cm4.h:1274
__O uint32_t LAR
Definition: core_cm4.h:692
__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
Set Priority Grouping.
Definition: core_cm4.h:1435
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
System Tick Configuration.
Definition: core_cm4.h:1677
__I uint32_t LSR
Definition: core_cm4.h:693
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
Get Interrupt Priority.
Definition: core_cm4.h:1570
__IO uint32_t SCR
Definition: core_cm4.h:374
uint32_t w
Definition: core_cm4.h:268
__IO uint32_t FUNCTION1
Definition: core_cm4.h:790
__IO uint32_t CYCCNT
Definition: core_cm4.h:777
#define SCB_AIRCR_PRIGROUP_Pos
Definition: core_cm4.h:454
__I uint32_t CALIB
Definition: core_cm4.h:628
Structure type to access the System Control and ID Register not in the SCB.
Definition: core_cm4.h:585
__I uint32_t CID1
Definition: core_cm4.h:704
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
Set Interrupt Priority.
Definition: core_cm4.h:1550
Structure type to access the Nested Vectored Interrupt Controller (NVIC).
Definition: core_cm4.h:336
Structure type to access the System Timer (SysTick).
Definition: core_cm4.h:623
__I uint32_t PID1
Definition: core_cm4.h:700
#define SCB_AIRCR_VECTKEY_Pos
Definition: core_cm4.h:445
__I uint32_t TRIGGER
Definition: core_cm4.h:932
__STATIC_INLINE void NVIC_SystemReset(void)
System Reset.
Definition: core_cm4.h:1638
__IO uint32_t AIRCR
Definition: core_cm4.h:373
__IO uint32_t DCRDR
Definition: core_cm4.h:1275
__I uint32_t DEVTYPE
Definition: core_cm4.h:944
__O uint32_t STIR
Definition: core_cm4.h:350
#define SCB_AIRCR_SYSRESETREQ_Msk
Definition: core_cm4.h:458
Union type to access the Application Program Status Register (APSR).
Definition: core_cm4.h:251
__STATIC_INLINE void NVIC_DecodePriority(uint32_t Priority, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority)
Decode Priority.
Definition: core_cm4.h:1620
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
Disable External Interrupt.
Definition: core_cm4.h:1480
#define SysTick_LOAD_RELOAD_Msk
Definition: core_cm4.h:646
__IO uint32_t MASK3
Definition: core_cm4.h:797
__IO uint32_t MASK2
Definition: core_cm4.h:793
__I uint32_t ITATBCTR0
Definition: core_cm4.h:936
__I uint32_t FIFO1
Definition: core_cm4.h:937
__IO uint32_t ACTLR
Definition: core_cm4.h:589
__IO uint32_t CTRL
Definition: core_cm4.h:776
Union type to access the Control Registers (CONTROL).
Definition: core_cm4.h:313
#define SysTick_CTRL_CLKSOURCE_Msk
Definition: core_cm4.h:636
#define SysTick_CTRL_ENABLE_Msk
Definition: core_cm4.h:642
__IO uint32_t MASK1
Definition: core_cm4.h:789
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
Clear Pending Interrupt.
Definition: core_cm4.h:1520
__IO uint32_t FOLDCNT
Definition: core_cm4.h:782
__STATIC_INLINE uint32_t NVIC_EncodePriority(uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
Encode Priority.
Definition: core_cm4.h:1592
__IO uint32_t CCR
Definition: core_cm4.h:375
CMSIS Cortex-M Core Instruction Access Header File.
__IO uint32_t DHCSR
Definition: core_cm4.h:1273
__IO uint32_t FUNCTION0
Definition: core_cm4.h:786
__IO uint32_t CSPSR
Definition: core_cm4.h:922
__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
Get Active Interrupt.
Definition: core_cm4.h:1535
__IO uint32_t CPICNT
Definition: core_cm4.h:778
Union type to access the Special-Purpose Program Status Registers (xPSR).
Definition: core_cm4.h:287
__IO uint32_t TPR
Definition: core_cm4.h:684
__IO uint32_t ICSR
Definition: core_cm4.h:371
__IO uint32_t IMCR
Definition: core_cm4.h:690
__I uint32_t PID7
Definition: core_cm4.h:698
__IO uint32_t SLEEPCNT
Definition: core_cm4.h:780
#define SysTick_CTRL_TICKINT_Msk
Definition: core_cm4.h:639
__I uint32_t ITATBCTR2
Definition: core_cm4.h:934
__I uint32_t PID6
Definition: core_cm4.h:697
__I uint32_t ADR
Definition: core_cm4.h:386
Definition: stm32f4xx.h:184