Robobo
core_cm4.h
Go to the documentation of this file.
1 /**************************************************************************/
23 #if defined ( __ICCARM__ )
24  #pragma system_include /* treat file as system include file for MISRA check */
25 #endif
26 
27 #ifdef __cplusplus
28  extern "C" {
29 #endif
30 
31 #ifndef __CORE_CM4_H_GENERIC
32 #define __CORE_CM4_H_GENERIC
33 
34 
64 /*******************************************************************************
65  * CMSIS definitions
66  ******************************************************************************/
75 /* CMSIS CM4 definitions */
76 #define __CM4_CMSIS_VERSION_MAIN (0x02)
77 #define __CM4_CMSIS_VERSION_SUB (0x10)
78 #define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16) | __CM4_CMSIS_VERSION_SUB)
80 #define __CORTEX_M (0x04)
83 #if defined ( __CC_ARM )
84  #define __ASM __asm
85  #define __INLINE __inline
87 #elif defined ( __ICCARM__ )
88  #define __ASM __asm
89  #define __INLINE inline
91 #elif defined ( __GNUC__ )
92  #define __ASM __asm
93  #define __INLINE inline
95 #elif defined ( __TASKING__ )
96  #define __ASM __asm
97  #define __INLINE inline
99 #endif
100 
102 #if defined ( __CC_ARM )
103  #if defined __TARGET_FPU_VFP
104  #if (__FPU_PRESENT == 1)
105  #define __FPU_USED 1
106  #else
107  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
108  #define __FPU_USED 0
109  #endif
110  #else
111  #define __FPU_USED 0
112  #endif
113 
114 #elif defined ( __ICCARM__ )
115  #if defined __ARMVFP__
116  #if (__FPU_PRESENT == 1)
117  #define __FPU_USED 1
118  #else
119  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
120  #define __FPU_USED 0
121  #endif
122  #else
123  #define __FPU_USED 0
124  #endif
125 
126 #elif defined ( __GNUC__ )
127  #if defined (__VFP_FP__) && !defined(__SOFTFP__)
128  #if (__FPU_PRESENT == 1)
129  #define __FPU_USED 1
130  #else
131  #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
132  #define __FPU_USED 0
133  #endif
134  #else
135  #define __FPU_USED 0
136  #endif
137 
138 #elif defined ( __TASKING__ )
139  /* add preprocessor checks to define __FPU_USED */
140  #define __FPU_USED 0
141 #endif
142 
143 #include <stdint.h>
144 #include <core_cmInstr.h>
145 #include <core_cmFunc.h>
146 #include <core_cm4_simd.h>
148 #endif /* __CORE_CM4_H_GENERIC */
149 
150 #ifndef __CMSIS_GENERIC
151 
152 #ifndef __CORE_CM4_H_DEPENDANT
153 #define __CORE_CM4_H_DEPENDANT
154 
155 /* check device defines and use defaults */
156 #if defined __CHECK_DEVICE_DEFINES
157  #ifndef __CM4_REV
158  #define __CM4_REV 0x0000
159  #warning "__CM4_REV not defined in device header file; using default!"
160  #endif
161 
162  #ifndef __FPU_PRESENT
163  #define __FPU_PRESENT 0
164  #warning "__FPU_PRESENT not defined in device header file; using default!"
165  #endif
166 
167  #ifndef __MPU_PRESENT
168  #define __MPU_PRESENT 0
169  #warning "__MPU_PRESENT not defined in device header file; using default!"
170  #endif
171 
172  #ifndef __NVIC_PRIO_BITS
173  #define __NVIC_PRIO_BITS 4
174  #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
175  #endif
176 
177  #ifndef __Vendor_SysTickConfig
178  #define __Vendor_SysTickConfig 0
179  #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
180  #endif
181 #endif
182 
183 /* IO definitions (access restrictions to peripheral registers) */
184 #ifdef __cplusplus
185  #define __I volatile
186 #else
187  #define __I volatile const
188 #endif
189 #define __O volatile
190 #define __IO volatile
192 
196 /*******************************************************************************
197  * Register Abstraction
198  ******************************************************************************/
199 
218 typedef union
219 {
220  struct
221  {
222 #if (__CORTEX_M != 0x04)
223  uint32_t _reserved0:27;
224 #else
225  uint32_t _reserved0:16;
226  uint32_t GE:4;
227  uint32_t _reserved1:7;
228 #endif
229  uint32_t Q:1;
230  uint32_t V:1;
231  uint32_t C:1;
232  uint32_t Z:1;
233  uint32_t N:1;
234  } b;
235  uint32_t w;
236 } APSR_Type;
237 
238 
241 typedef union
242 {
243  struct
244  {
245  uint32_t ISR:9;
246  uint32_t _reserved0:23;
247  } b;
248  uint32_t w;
249 } IPSR_Type;
250 
251 
254 typedef union
255 {
256  struct
257  {
258  uint32_t ISR:9;
259 #if (__CORTEX_M != 0x04)
260  uint32_t _reserved0:15;
261 #else
262  uint32_t _reserved0:7;
263  uint32_t GE:4;
264  uint32_t _reserved1:4;
265 #endif
266  uint32_t T:1;
267  uint32_t IT:2;
268  uint32_t Q:1;
269  uint32_t V:1;
270  uint32_t C:1;
271  uint32_t Z:1;
272  uint32_t N:1;
273  } b;
274  uint32_t w;
275 } xPSR_Type;
276 
277 
280 typedef union
281 {
282  struct
283  {
284  uint32_t nPRIV:1;
285  uint32_t SPSEL:1;
286  uint32_t FPCA:1;
287  uint32_t _reserved0:29;
288  } b;
289  uint32_t w;
290 } CONTROL_Type;
291 
303 typedef struct
304 {
305  __IO uint32_t ISER[8];
306  uint32_t RESERVED0[24];
307  __IO uint32_t ICER[8];
308  uint32_t RSERVED1[24];
309  __IO uint32_t ISPR[8];
310  uint32_t RESERVED2[24];
311  __IO uint32_t ICPR[8];
312  uint32_t RESERVED3[24];
313  __IO uint32_t IABR[8];
314  uint32_t RESERVED4[56];
315  __IO uint8_t IP[240];
316  uint32_t RESERVED5[644];
317  __O uint32_t STIR;
318 } NVIC_Type;
319 
320 /* Software Triggered Interrupt Register Definitions */
321 #define NVIC_STIR_INTID_Pos 0
322 #define NVIC_STIR_INTID_Msk (0x1FFUL << NVIC_STIR_INTID_Pos)
324 
335 typedef struct
336 {
337  __I uint32_t CPUID;
338  __IO uint32_t ICSR;
339  __IO uint32_t VTOR;
340  __IO uint32_t AIRCR;
341  __IO uint32_t SCR;
342  __IO uint32_t CCR;
343  __IO uint8_t SHP[12];
344  __IO uint32_t SHCSR;
345  __IO uint32_t CFSR;
346  __IO uint32_t HFSR;
347  __IO uint32_t DFSR;
348  __IO uint32_t MMFAR;
349  __IO uint32_t BFAR;
350  __IO uint32_t AFSR;
351  __I uint32_t PFR[2];
352  __I uint32_t DFR;
353  __I uint32_t ADR;
354  __I uint32_t MMFR[4];
355  __I uint32_t ISAR[5];
356  uint32_t RESERVED0[5];
357  __IO uint32_t CPACR;
358 } SCB_Type;
359 
360 /* SCB CPUID Register Definitions */
361 #define SCB_CPUID_IMPLEMENTER_Pos 24
362 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)
364 #define SCB_CPUID_VARIANT_Pos 20
365 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos)
367 #define SCB_CPUID_ARCHITECTURE_Pos 16
368 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)
370 #define SCB_CPUID_PARTNO_Pos 4
371 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos)
373 #define SCB_CPUID_REVISION_Pos 0
374 #define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos)
376 /* SCB Interrupt Control State Register Definitions */
377 #define SCB_ICSR_NMIPENDSET_Pos 31
378 #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos)
380 #define SCB_ICSR_PENDSVSET_Pos 28
381 #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos)
383 #define SCB_ICSR_PENDSVCLR_Pos 27
384 #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos)
386 #define SCB_ICSR_PENDSTSET_Pos 26
387 #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos)
389 #define SCB_ICSR_PENDSTCLR_Pos 25
390 #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos)
392 #define SCB_ICSR_ISRPREEMPT_Pos 23
393 #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos)
395 #define SCB_ICSR_ISRPENDING_Pos 22
396 #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos)
398 #define SCB_ICSR_VECTPENDING_Pos 12
399 #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)
401 #define SCB_ICSR_RETTOBASE_Pos 11
402 #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos)
404 #define SCB_ICSR_VECTACTIVE_Pos 0
405 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos)
407 /* SCB Vector Table Offset Register Definitions */
408 #define SCB_VTOR_TBLOFF_Pos 7
409 #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos)
411 /* SCB Application Interrupt and Reset Control Register Definitions */
412 #define SCB_AIRCR_VECTKEY_Pos 16
413 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)
415 #define SCB_AIRCR_VECTKEYSTAT_Pos 16
416 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)
418 #define SCB_AIRCR_ENDIANESS_Pos 15
419 #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos)
421 #define SCB_AIRCR_PRIGROUP_Pos 8
422 #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos)
424 #define SCB_AIRCR_SYSRESETREQ_Pos 2
425 #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos)
427 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1
428 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)
430 #define SCB_AIRCR_VECTRESET_Pos 0
431 #define SCB_AIRCR_VECTRESET_Msk (1UL << SCB_AIRCR_VECTRESET_Pos)
433 /* SCB System Control Register Definitions */
434 #define SCB_SCR_SEVONPEND_Pos 4
435 #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos)
437 #define SCB_SCR_SLEEPDEEP_Pos 2
438 #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos)
440 #define SCB_SCR_SLEEPONEXIT_Pos 1
441 #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos)
443 /* SCB Configuration Control Register Definitions */
444 #define SCB_CCR_STKALIGN_Pos 9
445 #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos)
447 #define SCB_CCR_BFHFNMIGN_Pos 8
448 #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos)
450 #define SCB_CCR_DIV_0_TRP_Pos 4
451 #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos)
453 #define SCB_CCR_UNALIGN_TRP_Pos 3
454 #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos)
456 #define SCB_CCR_USERSETMPEND_Pos 1
457 #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos)
459 #define SCB_CCR_NONBASETHRDENA_Pos 0
460 #define SCB_CCR_NONBASETHRDENA_Msk (1UL << SCB_CCR_NONBASETHRDENA_Pos)
462 /* SCB System Handler Control and State Register Definitions */
463 #define SCB_SHCSR_USGFAULTENA_Pos 18
464 #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos)
466 #define SCB_SHCSR_BUSFAULTENA_Pos 17
467 #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos)
469 #define SCB_SHCSR_MEMFAULTENA_Pos 16
470 #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos)
472 #define SCB_SHCSR_SVCALLPENDED_Pos 15
473 #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos)
475 #define SCB_SHCSR_BUSFAULTPENDED_Pos 14
476 #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos)
478 #define SCB_SHCSR_MEMFAULTPENDED_Pos 13
479 #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos)
481 #define SCB_SHCSR_USGFAULTPENDED_Pos 12
482 #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos)
484 #define SCB_SHCSR_SYSTICKACT_Pos 11
485 #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos)
487 #define SCB_SHCSR_PENDSVACT_Pos 10
488 #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos)
490 #define SCB_SHCSR_MONITORACT_Pos 8
491 #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos)
493 #define SCB_SHCSR_SVCALLACT_Pos 7
494 #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos)
496 #define SCB_SHCSR_USGFAULTACT_Pos 3
497 #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos)
499 #define SCB_SHCSR_BUSFAULTACT_Pos 1
500 #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos)
502 #define SCB_SHCSR_MEMFAULTACT_Pos 0
503 #define SCB_SHCSR_MEMFAULTACT_Msk (1UL << SCB_SHCSR_MEMFAULTACT_Pos)
505 /* SCB Configurable Fault Status Registers Definitions */
506 #define SCB_CFSR_USGFAULTSR_Pos 16
507 #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos)
509 #define SCB_CFSR_BUSFAULTSR_Pos 8
510 #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos)
512 #define SCB_CFSR_MEMFAULTSR_Pos 0
513 #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL << SCB_CFSR_MEMFAULTSR_Pos)
515 /* SCB Hard Fault Status Registers Definitions */
516 #define SCB_HFSR_DEBUGEVT_Pos 31
517 #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos)
519 #define SCB_HFSR_FORCED_Pos 30
520 #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos)
522 #define SCB_HFSR_VECTTBL_Pos 1
523 #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos)
525 /* SCB Debug Fault Status Register Definitions */
526 #define SCB_DFSR_EXTERNAL_Pos 4
527 #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos)
529 #define SCB_DFSR_VCATCH_Pos 3
530 #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos)
532 #define SCB_DFSR_DWTTRAP_Pos 2
533 #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos)
535 #define SCB_DFSR_BKPT_Pos 1
536 #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos)
538 #define SCB_DFSR_HALTED_Pos 0
539 #define SCB_DFSR_HALTED_Msk (1UL << SCB_DFSR_HALTED_Pos)
541 
552 typedef struct
553 {
554  uint32_t RESERVED0[1];
555  __I uint32_t ICTR;
556  __IO uint32_t ACTLR;
557 } SCnSCB_Type;
558 
559 /* Interrupt Controller Type Register Definitions */
560 #define SCnSCB_ICTR_INTLINESNUM_Pos 0
561 #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL << SCnSCB_ICTR_INTLINESNUM_Pos)
563 /* Auxiliary Control Register Definitions */
564 #define SCnSCB_ACTLR_DISOOFP_Pos 9
565 #define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos)
567 #define SCnSCB_ACTLR_DISFPCA_Pos 8
568 #define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos)
570 #define SCnSCB_ACTLR_DISFOLD_Pos 2
571 #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos)
573 #define SCnSCB_ACTLR_DISDEFWBUF_Pos 1
574 #define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos)
576 #define SCnSCB_ACTLR_DISMCYCINT_Pos 0
577 #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL << SCnSCB_ACTLR_DISMCYCINT_Pos)
579 
590 typedef struct
591 {
592  __IO uint32_t CTRL;
593  __IO uint32_t LOAD;
594  __IO uint32_t VAL;
595  __I uint32_t CALIB;
596 } SysTick_Type;
597 
598 /* SysTick Control / Status Register Definitions */
599 #define SysTick_CTRL_COUNTFLAG_Pos 16
600 #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos)
602 #define SysTick_CTRL_CLKSOURCE_Pos 2
603 #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos)
605 #define SysTick_CTRL_TICKINT_Pos 1
606 #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos)
608 #define SysTick_CTRL_ENABLE_Pos 0
609 #define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos)
611 /* SysTick Reload Register Definitions */
612 #define SysTick_LOAD_RELOAD_Pos 0
613 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos)
615 /* SysTick Current Register Definitions */
616 #define SysTick_VAL_CURRENT_Pos 0
617 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)
619 /* SysTick Calibration Register Definitions */
620 #define SysTick_CALIB_NOREF_Pos 31
621 #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos)
623 #define SysTick_CALIB_SKEW_Pos 30
624 #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos)
626 #define SysTick_CALIB_TENMS_Pos 0
627 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)
629 
640 typedef struct
641 {
642  __O union
643  {
644  __O uint8_t u8;
645  __O uint16_t u16;
646  __O uint32_t u32;
647  } PORT [32];
648  uint32_t RESERVED0[864];
649  __IO uint32_t TER;
650  uint32_t RESERVED1[15];
651  __IO uint32_t TPR;
652  uint32_t RESERVED2[15];
653  __IO uint32_t TCR;
654 } ITM_Type;
655 
656 /* ITM Trace Privilege Register Definitions */
657 #define ITM_TPR_PRIVMASK_Pos 0
658 #define ITM_TPR_PRIVMASK_Msk (0xFUL << ITM_TPR_PRIVMASK_Pos)
660 /* ITM Trace Control Register Definitions */
661 #define ITM_TCR_BUSY_Pos 23
662 #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos)
664 #define ITM_TCR_TraceBusID_Pos 16
665 #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos)
667 #define ITM_TCR_GTSFREQ_Pos 10
668 #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos)
670 #define ITM_TCR_TSPrescale_Pos 8
671 #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos)
673 #define ITM_TCR_SWOENA_Pos 4
674 #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos)
676 #define ITM_TCR_TXENA_Pos 3
677 #define ITM_TCR_TXENA_Msk (1UL << ITM_TCR_TXENA_Pos)
679 #define ITM_TCR_SYNCENA_Pos 2
680 #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos)
682 #define ITM_TCR_TSENA_Pos 1
683 #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos)
685 #define ITM_TCR_ITMENA_Pos 0
686 #define ITM_TCR_ITMENA_Msk (1UL << ITM_TCR_ITMENA_Pos)
688  /* end of group CMSIS_ITM */
689 
690 
691 #if (__MPU_PRESENT == 1)
692 
700 typedef struct
701 {
702  __I uint32_t TYPE;
703  __IO uint32_t CTRL;
704  __IO uint32_t RNR;
705  __IO uint32_t RBAR;
706  __IO uint32_t RASR;
707  __IO uint32_t RBAR_A1;
708  __IO uint32_t RASR_A1;
709  __IO uint32_t RBAR_A2;
710  __IO uint32_t RASR_A2;
711  __IO uint32_t RBAR_A3;
712  __IO uint32_t RASR_A3;
713 } MPU_Type;
714 
715 /* MPU Type Register */
716 #define MPU_TYPE_IREGION_Pos 16
717 #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos)
719 #define MPU_TYPE_DREGION_Pos 8
720 #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos)
722 #define MPU_TYPE_SEPARATE_Pos 0
723 #define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos)
725 /* MPU Control Register */
726 #define MPU_CTRL_PRIVDEFENA_Pos 2
727 #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos)
729 #define MPU_CTRL_HFNMIENA_Pos 1
730 #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos)
732 #define MPU_CTRL_ENABLE_Pos 0
733 #define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos)
735 /* MPU Region Number Register */
736 #define MPU_RNR_REGION_Pos 0
737 #define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos)
739 /* MPU Region Base Address Register */
740 #define MPU_RBAR_ADDR_Pos 5
741 #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos)
743 #define MPU_RBAR_VALID_Pos 4
744 #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos)
746 #define MPU_RBAR_REGION_Pos 0
747 #define MPU_RBAR_REGION_Msk (0xFUL << MPU_RBAR_REGION_Pos)
749 /* MPU Region Attribute and Size Register */
750 #define MPU_RASR_ATTRS_Pos 16
751 #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos)
753 #define MPU_RASR_SRD_Pos 8
754 #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos)
756 #define MPU_RASR_SIZE_Pos 1
757 #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos)
759 #define MPU_RASR_ENABLE_Pos 0
760 #define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos)
762 
763 #endif
764 
765 
766 #if (__FPU_PRESENT == 1)
767 
775 typedef struct
776 {
777  uint32_t RESERVED0[1];
778  __IO uint32_t FPCCR;
779  __IO uint32_t FPCAR;
780  __IO uint32_t FPDSCR;
781  __I uint32_t MVFR0;
782  __I uint32_t MVFR1;
783 } FPU_Type;
784 
785 /* Floating-Point Context Control Register */
786 #define FPU_FPCCR_ASPEN_Pos 31
787 #define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos)
789 #define FPU_FPCCR_LSPEN_Pos 30
790 #define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos)
792 #define FPU_FPCCR_MONRDY_Pos 8
793 #define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos)
795 #define FPU_FPCCR_BFRDY_Pos 6
796 #define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos)
798 #define FPU_FPCCR_MMRDY_Pos 5
799 #define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos)
801 #define FPU_FPCCR_HFRDY_Pos 4
802 #define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos)
804 #define FPU_FPCCR_THREAD_Pos 3
805 #define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos)
807 #define FPU_FPCCR_USER_Pos 1
808 #define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos)
810 #define FPU_FPCCR_LSPACT_Pos 0
811 #define FPU_FPCCR_LSPACT_Msk (1UL << FPU_FPCCR_LSPACT_Pos)
813 /* Floating-Point Context Address Register */
814 #define FPU_FPCAR_ADDRESS_Pos 3
815 #define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos)
817 /* Floating-Point Default Status Control Register */
818 #define FPU_FPDSCR_AHP_Pos 26
819 #define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos)
821 #define FPU_FPDSCR_DN_Pos 25
822 #define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos)
824 #define FPU_FPDSCR_FZ_Pos 24
825 #define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos)
827 #define FPU_FPDSCR_RMode_Pos 22
828 #define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos)
830 /* Media and FP Feature Register 0 */
831 #define FPU_MVFR0_FP_rounding_modes_Pos 28
832 #define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos)
834 #define FPU_MVFR0_Short_vectors_Pos 24
835 #define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos)
837 #define FPU_MVFR0_Square_root_Pos 20
838 #define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos)
840 #define FPU_MVFR0_Divide_Pos 16
841 #define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos)
843 #define FPU_MVFR0_FP_excep_trapping_Pos 12
844 #define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos)
846 #define FPU_MVFR0_Double_precision_Pos 8
847 #define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos)
849 #define FPU_MVFR0_Single_precision_Pos 4
850 #define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos)
852 #define FPU_MVFR0_A_SIMD_registers_Pos 0
853 #define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL << FPU_MVFR0_A_SIMD_registers_Pos)
855 /* Media and FP Feature Register 1 */
856 #define FPU_MVFR1_FP_fused_MAC_Pos 28
857 #define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos)
859 #define FPU_MVFR1_FP_HPFP_Pos 24
860 #define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos)
862 #define FPU_MVFR1_D_NaN_mode_Pos 4
863 #define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos)
865 #define FPU_MVFR1_FtZ_mode_Pos 0
866 #define FPU_MVFR1_FtZ_mode_Msk (0xFUL << FPU_MVFR1_FtZ_mode_Pos)
868 
869 #endif
870 
871 
880 typedef struct
881 {
882  __IO uint32_t DHCSR;
883  __O uint32_t DCRSR;
884  __IO uint32_t DCRDR;
885  __IO uint32_t DEMCR;
887 
888 /* Debug Halting Control and Status Register */
889 #define CoreDebug_DHCSR_DBGKEY_Pos 16
890 #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos)
892 #define CoreDebug_DHCSR_S_RESET_ST_Pos 25
893 #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos)
895 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24
896 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos)
898 #define CoreDebug_DHCSR_S_LOCKUP_Pos 19
899 #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos)
901 #define CoreDebug_DHCSR_S_SLEEP_Pos 18
902 #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos)
904 #define CoreDebug_DHCSR_S_HALT_Pos 17
905 #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos)
907 #define CoreDebug_DHCSR_S_REGRDY_Pos 16
908 #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos)
910 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5
911 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos)
913 #define CoreDebug_DHCSR_C_MASKINTS_Pos 3
914 #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos)
916 #define CoreDebug_DHCSR_C_STEP_Pos 2
917 #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos)
919 #define CoreDebug_DHCSR_C_HALT_Pos 1
920 #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos)
922 #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0
923 #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL << CoreDebug_DHCSR_C_DEBUGEN_Pos)
925 /* Debug Core Register Selector Register */
926 #define CoreDebug_DCRSR_REGWnR_Pos 16
927 #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos)
929 #define CoreDebug_DCRSR_REGSEL_Pos 0
930 #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL << CoreDebug_DCRSR_REGSEL_Pos)
932 /* Debug Exception and Monitor Control Register */
933 #define CoreDebug_DEMCR_TRCENA_Pos 24
934 #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos)
936 #define CoreDebug_DEMCR_MON_REQ_Pos 19
937 #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos)
939 #define CoreDebug_DEMCR_MON_STEP_Pos 18
940 #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos)
942 #define CoreDebug_DEMCR_MON_PEND_Pos 17
943 #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos)
945 #define CoreDebug_DEMCR_MON_EN_Pos 16
946 #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos)
948 #define CoreDebug_DEMCR_VC_HARDERR_Pos 10
949 #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos)
951 #define CoreDebug_DEMCR_VC_INTERR_Pos 9
952 #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos)
954 #define CoreDebug_DEMCR_VC_BUSERR_Pos 8
955 #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos)
957 #define CoreDebug_DEMCR_VC_STATERR_Pos 7
958 #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos)
960 #define CoreDebug_DEMCR_VC_CHKERR_Pos 6
961 #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos)
963 #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5
964 #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos)
966 #define CoreDebug_DEMCR_VC_MMERR_Pos 4
967 #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos)
969 #define CoreDebug_DEMCR_VC_CORERESET_Pos 0
970 #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL << CoreDebug_DEMCR_VC_CORERESET_Pos)
972 
979 /* Memory mapping of Cortex-M4 Hardware */
980 #define SCS_BASE (0xE000E000UL)
981 #define ITM_BASE (0xE0000000UL)
982 #define CoreDebug_BASE (0xE000EDF0UL)
983 #define SysTick_BASE (SCS_BASE + 0x0010UL)
984 #define NVIC_BASE (SCS_BASE + 0x0100UL)
985 #define SCB_BASE (SCS_BASE + 0x0D00UL)
987 #define SCnSCB ((SCnSCB_Type *) SCS_BASE )
988 #define SCB ((SCB_Type *) SCB_BASE )
989 #define SysTick ((SysTick_Type *) SysTick_BASE )
990 #define NVIC ((NVIC_Type *) NVIC_BASE )
991 #define ITM ((ITM_Type *) ITM_BASE )
992 #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE)
994 #if (__MPU_PRESENT == 1)
995  #define MPU_BASE (SCS_BASE + 0x0D90UL)
996  #define MPU ((MPU_Type *) MPU_BASE )
997 #endif
998 
999 #if (__FPU_PRESENT == 1)
1000  #define FPU_BASE (SCS_BASE + 0x0F30UL)
1001  #define FPU ((FPU_Type *) FPU_BASE )
1002 #endif
1003 
1008 /*******************************************************************************
1009  * Hardware Abstraction Layer
1010  ******************************************************************************/
1021 /* ########################## NVIC functions #################################### */
1037 static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1038 {
1039  uint32_t reg_value;
1040  uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
1041 
1042  reg_value = SCB->AIRCR; /* read old register configuration */
1043  reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
1044  reg_value = (reg_value |
1045  ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) |
1046  (PriorityGroupTmp << 8)); /* Insert write key and priorty group */
1047  SCB->AIRCR = reg_value;
1048 }
1049 
1050 
1058 static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
1059 {
1060  return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */
1061 }
1062 
1063 
1071 static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
1072 {
1073 /* NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); enable interrupt */
1074  NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5] = (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F)); /* enable interrupt */
1075 }
1076 
1077 
1085 static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
1086 {
1087  NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
1088 }
1089 
1090 
1100 static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
1101 {
1102  return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
1103 }
1104 
1105 
1113 static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
1114 {
1115  NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
1116 }
1117 
1118 
1126 static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1127 {
1128  NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
1129 }
1130 
1131 
1139 static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
1140 {
1141  return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
1142 }
1143 
1144 
1156 static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
1157 {
1158  if(IRQn < 0) {
1159  SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M System Interrupts */
1160  else {
1161  NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
1162 }
1163 
1164 
1177 static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
1178 {
1179 
1180  if(IRQn < 0) {
1181  return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M system interrupts */
1182  else {
1183  return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
1184 }
1185 
1186 
1201 static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
1202 {
1203  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1204  uint32_t PreemptPriorityBits;
1205  uint32_t SubPriorityBits;
1206 
1207  PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1208  SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
1209 
1210  return (
1211  ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
1212  ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
1213  );
1214 }
1215 
1216 
1231 static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
1232 {
1233  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1234  uint32_t PreemptPriorityBits;
1235  uint32_t SubPriorityBits;
1236 
1237  PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1238  SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
1239 
1240  *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
1241  *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
1242 }
1243 
1244 
1249 static __INLINE void NVIC_SystemReset(void)
1250 {
1251  __DSB(); /* Ensure all outstanding memory accesses included
1252  buffered write are completed before reset */
1253  SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
1254  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
1255  SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
1256  __DSB(); /* Ensure completion of memory access */
1257  while(1); /* wait until reset */
1258 }
1259 
1264 /* ################################## SysTick function ############################################ */
1270 #if (__Vendor_SysTickConfig == 0)
1271 
1281 static __INLINE uint32_t SysTick_Config(uint32_t ticks)
1282 {
1283  if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
1284 
1285  SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
1286  NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
1287  SysTick->VAL = 0; /* Load the SysTick Counter Value */
1290  SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
1291  return (0); /* Function successful */
1292 }
1293 
1294 #endif
1295 
1300 /* ##################################### Debug In/Output function ########################################### */
1306 extern volatile int32_t ITM_RxBuffer;
1307 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5
1319 static __INLINE uint32_t ITM_SendChar (uint32_t ch)
1320 {
1321  if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && /* Trace enabled */
1322  (ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
1323  (ITM->TER & (1UL << 0) ) ) /* ITM Port #0 enabled */
1324  {
1325  while (ITM->PORT[0].u32 == 0);
1326  ITM->PORT[0].u8 = (uint8_t) ch;
1327  }
1328  return (ch);
1329 }
1330 
1331 
1341 static __INLINE int32_t ITM_ReceiveChar (void) {
1342  int32_t ch = -1; /* no character available */
1343 
1344  if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
1345  ch = ITM_RxBuffer;
1346  ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
1347  }
1348 
1349  return (ch);
1350 }
1351 
1352 
1361 static __INLINE int32_t ITM_CheckChar (void) {
1362 
1363  if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
1364  return (0); /* no character available */
1365  } else {
1366  return (1); /* character available */
1367  }
1368 }
1369 
1372 #endif /* __CORE_CM4_H_DEPENDANT */
1373 
1374 #endif /* __CMSIS_GENERIC */
1375 
1376 #ifdef __cplusplus
1377 }
1378 #endif
#define SCB_AIRCR_PRIGROUP_Msk
Definition: core_cm4.h:422
Structure type to access the System Control and ID Register not in the SCB.
Definition: core_cm3.h:531
#define ISR(func)
Define service routine.
Definition: interrupt_sam_nvic.h:65
#define SysTick_CTRL_TICKINT_Msk
Definition: core_cm4.h:606
__IO uint32_t ACTLR
Definition: core_cm4.h:556
Union type to access the Application Program Status Register (APSR).
Definition: core_cm0.h:182
IRQn
Definition: ARMCM0.h:35
Definition: ARMCM0.h:46
Structure type to access the System Timer (SysTick).
Definition: core_cm0.h:397
Structure type to access the Instrumentation Trace Macrocell Register (ITM).
Definition: core_cm3.h:618
#define NVIC
Definition: core_cm4.h:990
CMSIS Cortex-M4 SIMD Header File.
Structure type to access the System Control Block (SCB).
Definition: core_cm0.h:292
#define SysTick
Definition: core_cm4.h:989
#define SCB
Definition: core_cm4.h:988
#define ITM_TCR_ITMENA_Msk
Definition: core_cm4.h:686
#define ITM_RXBUFFER_EMPTY
Definition: core_cm4.h:1307
#define SCB_AIRCR_SYSRESETREQ_Msk
Definition: core_cm4.h:425
Union type to access the Control Registers (CONTROL).
Definition: core_cm0.h:244
volatile int32_t ITM_RxBuffer
#define SysTick_CTRL_ENABLE_Msk
Definition: core_cm4.h:609
#define SysTick_CTRL_CLKSOURCE_Msk
Definition: core_cm4.h:603
#define __IO
Definition: core_cm4.h:190
#define SCB_AIRCR_PRIGROUP_Pos
Definition: core_cm4.h:421
Union type to access the Interrupt Program Status Register (IPSR).
Definition: core_cm0.h:205
#define __O
Definition: core_cm4.h:189
#define __I
Definition: core_cm4.h:187
#define __NVIC_PRIO_BITS
Definition: ARMCM0.h:62
Structure type to access the Nested Vectored Interrupt Controller (NVIC).
Definition: core_cm0.h:267
Structure type to access the Core Debug Register (CoreDebug).
Definition: core_cm3.h:752
CMSIS Cortex-M Core Instruction Access Header File.
#define CoreDebug
Definition: core_cm4.h:992
#define SCB_AIRCR_VECTKEY_Pos
Definition: core_cm4.h:412
#define SysTick_LOAD_RELOAD_Msk
Definition: core_cm4.h:613
Union type to access the Special-Purpose Program Status Registers (xPSR).
Definition: core_cm0.h:218
#define SCB_AIRCR_VECTKEY_Msk
Definition: core_cm4.h:413
#define CoreDebug_DEMCR_TRCENA_Msk
Definition: core_cm4.h:934
CMSIS Cortex-M Core Function Access Header File.
#define ITM
Definition: core_cm4.h:991