RT-AICHIP-sample
core_cm3.h
[詳解]
1 /**************************************************************************/
24 #ifndef __CM3_CORE_H__
25 #define __CM3_CORE_H__
26 
62 /*lint -save */
63 /*lint -e10 */
64 /*lint -e530 */
65 /*lint -e550 */
66 /*lint -e754 */
67 /*lint -e750 */
68 /*lint -e528 */
69 /*lint -e751 */
70 
71 
80 #ifdef __cplusplus
81  extern "C" {
82 #endif
83 
84 #define __CM3_CMSIS_VERSION_MAIN (0x01)
85 #define __CM3_CMSIS_VERSION_SUB (0x30)
86 #define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB)
88 #define __CORTEX_M (0x03)
90 #include <stdint.h> /* Include standard types */
91 
92 #if defined (__ICCARM__)
93  #include <intrinsics.h> /* IAR Intrinsics */
94 #endif
95 
96 
97 #ifndef __NVIC_PRIO_BITS
98  #define __NVIC_PRIO_BITS 4
99 #endif
100 
101 
102 
103 
110 #ifdef __cplusplus
111  #define __I volatile
112 #else
113  #define __I volatile const
114 #endif
115 #define __O volatile
116 #define __IO volatile
120 /*******************************************************************************
121  * Register Abstraction
122  ******************************************************************************/
123 
132 typedef struct
133 {
134  __IO uint32_t ISER[8];
135  uint32_t RESERVED0[24];
136  __IO uint32_t ICER[8];
137  uint32_t RSERVED1[24];
138  __IO uint32_t ISPR[8];
139  uint32_t RESERVED2[24];
140  __IO uint32_t ICPR[8];
141  uint32_t RESERVED3[24];
142  __IO uint32_t IABR[8];
143  uint32_t RESERVED4[56];
144  __IO uint8_t IP[240];
145  uint32_t RESERVED5[644];
147 } NVIC_Type; /* end of group CMSIS_CM3_NVIC */
149 
150 
155 typedef struct
156 {
163  __IO uint8_t SHP[12];
171  __I uint32_t PFR[2];
174  __I uint32_t MMFR[4];
175  __I uint32_t ISAR[5];
176 } SCB_Type;
177 
178 /* SCB CPUID Register Definitions */
179 #define SCB_CPUID_IMPLEMENTER_Pos 24
180 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFul << SCB_CPUID_IMPLEMENTER_Pos)
182 #define SCB_CPUID_VARIANT_Pos 20
183 #define SCB_CPUID_VARIANT_Msk (0xFul << SCB_CPUID_VARIANT_Pos)
185 #define SCB_CPUID_PARTNO_Pos 4
186 #define SCB_CPUID_PARTNO_Msk (0xFFFul << SCB_CPUID_PARTNO_Pos)
188 #define SCB_CPUID_REVISION_Pos 0
189 #define SCB_CPUID_REVISION_Msk (0xFul << SCB_CPUID_REVISION_Pos)
191 /* SCB Interrupt Control State Register Definitions */
192 #define SCB_ICSR_NMIPENDSET_Pos 31
193 #define SCB_ICSR_NMIPENDSET_Msk (1ul << SCB_ICSR_NMIPENDSET_Pos)
195 #define SCB_ICSR_PENDSVSET_Pos 28
196 #define SCB_ICSR_PENDSVSET_Msk (1ul << SCB_ICSR_PENDSVSET_Pos)
198 #define SCB_ICSR_PENDSVCLR_Pos 27
199 #define SCB_ICSR_PENDSVCLR_Msk (1ul << SCB_ICSR_PENDSVCLR_Pos)
201 #define SCB_ICSR_PENDSTSET_Pos 26
202 #define SCB_ICSR_PENDSTSET_Msk (1ul << SCB_ICSR_PENDSTSET_Pos)
204 #define SCB_ICSR_PENDSTCLR_Pos 25
205 #define SCB_ICSR_PENDSTCLR_Msk (1ul << SCB_ICSR_PENDSTCLR_Pos)
207 #define SCB_ICSR_ISRPREEMPT_Pos 23
208 #define SCB_ICSR_ISRPREEMPT_Msk (1ul << SCB_ICSR_ISRPREEMPT_Pos)
210 #define SCB_ICSR_ISRPENDING_Pos 22
211 #define SCB_ICSR_ISRPENDING_Msk (1ul << SCB_ICSR_ISRPENDING_Pos)
213 #define SCB_ICSR_VECTPENDING_Pos 12
214 #define SCB_ICSR_VECTPENDING_Msk (0x1FFul << SCB_ICSR_VECTPENDING_Pos)
216 #define SCB_ICSR_RETTOBASE_Pos 11
217 #define SCB_ICSR_RETTOBASE_Msk (1ul << SCB_ICSR_RETTOBASE_Pos)
219 #define SCB_ICSR_VECTACTIVE_Pos 0
220 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFul << SCB_ICSR_VECTACTIVE_Pos)
222 /* SCB Interrupt Control State Register Definitions */
223 #define SCB_VTOR_TBLBASE_Pos 29
224 #define SCB_VTOR_TBLBASE_Msk (0x1FFul << SCB_VTOR_TBLBASE_Pos)
226 #define SCB_VTOR_TBLOFF_Pos 7
227 #define SCB_VTOR_TBLOFF_Msk (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos)
229 /* SCB Application Interrupt and Reset Control Register Definitions */
230 #define SCB_AIRCR_VECTKEY_Pos 16
231 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFul << SCB_AIRCR_VECTKEY_Pos)
233 #define SCB_AIRCR_VECTKEYSTAT_Pos 16
234 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos)
236 #define SCB_AIRCR_ENDIANESS_Pos 15
237 #define SCB_AIRCR_ENDIANESS_Msk (1ul << SCB_AIRCR_ENDIANESS_Pos)
239 #define SCB_AIRCR_PRIGROUP_Pos 8
240 #define SCB_AIRCR_PRIGROUP_Msk (7ul << SCB_AIRCR_PRIGROUP_Pos)
242 #define SCB_AIRCR_SYSRESETREQ_Pos 2
243 #define SCB_AIRCR_SYSRESETREQ_Msk (1ul << SCB_AIRCR_SYSRESETREQ_Pos)
245 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1
246 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos)
248 #define SCB_AIRCR_VECTRESET_Pos 0
249 #define SCB_AIRCR_VECTRESET_Msk (1ul << SCB_AIRCR_VECTRESET_Pos)
251 /* SCB System Control Register Definitions */
252 #define SCB_SCR_SEVONPEND_Pos 4
253 #define SCB_SCR_SEVONPEND_Msk (1ul << SCB_SCR_SEVONPEND_Pos)
255 #define SCB_SCR_SLEEPDEEP_Pos 2
256 #define SCB_SCR_SLEEPDEEP_Msk (1ul << SCB_SCR_SLEEPDEEP_Pos)
258 #define SCB_SCR_SLEEPONEXIT_Pos 1
259 #define SCB_SCR_SLEEPONEXIT_Msk (1ul << SCB_SCR_SLEEPONEXIT_Pos)
261 /* SCB Configuration Control Register Definitions */
262 #define SCB_CCR_STKALIGN_Pos 9
263 #define SCB_CCR_STKALIGN_Msk (1ul << SCB_CCR_STKALIGN_Pos)
265 #define SCB_CCR_BFHFNMIGN_Pos 8
266 #define SCB_CCR_BFHFNMIGN_Msk (1ul << SCB_CCR_BFHFNMIGN_Pos)
268 #define SCB_CCR_DIV_0_TRP_Pos 4
269 #define SCB_CCR_DIV_0_TRP_Msk (1ul << SCB_CCR_DIV_0_TRP_Pos)
271 #define SCB_CCR_UNALIGN_TRP_Pos 3
272 #define SCB_CCR_UNALIGN_TRP_Msk (1ul << SCB_CCR_UNALIGN_TRP_Pos)
274 #define SCB_CCR_USERSETMPEND_Pos 1
275 #define SCB_CCR_USERSETMPEND_Msk (1ul << SCB_CCR_USERSETMPEND_Pos)
277 #define SCB_CCR_NONBASETHRDENA_Pos 0
278 #define SCB_CCR_NONBASETHRDENA_Msk (1ul << SCB_CCR_NONBASETHRDENA_Pos)
280 /* SCB System Handler Control and State Register Definitions */
281 #define SCB_SHCSR_USGFAULTENA_Pos 18
282 #define SCB_SHCSR_USGFAULTENA_Msk (1ul << SCB_SHCSR_USGFAULTENA_Pos)
284 #define SCB_SHCSR_BUSFAULTENA_Pos 17
285 #define SCB_SHCSR_BUSFAULTENA_Msk (1ul << SCB_SHCSR_BUSFAULTENA_Pos)
287 #define SCB_SHCSR_MEMFAULTENA_Pos 16
288 #define SCB_SHCSR_MEMFAULTENA_Msk (1ul << SCB_SHCSR_MEMFAULTENA_Pos)
290 #define SCB_SHCSR_SVCALLPENDED_Pos 15
291 #define SCB_SHCSR_SVCALLPENDED_Msk (1ul << SCB_SHCSR_SVCALLPENDED_Pos)
293 #define SCB_SHCSR_BUSFAULTPENDED_Pos 14
294 #define SCB_SHCSR_BUSFAULTPENDED_Msk (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos)
296 #define SCB_SHCSR_MEMFAULTPENDED_Pos 13
297 #define SCB_SHCSR_MEMFAULTPENDED_Msk (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos)
299 #define SCB_SHCSR_USGFAULTPENDED_Pos 12
300 #define SCB_SHCSR_USGFAULTPENDED_Msk (1ul << SCB_SHCSR_USGFAULTPENDED_Pos)
302 #define SCB_SHCSR_SYSTICKACT_Pos 11
303 #define SCB_SHCSR_SYSTICKACT_Msk (1ul << SCB_SHCSR_SYSTICKACT_Pos)
305 #define SCB_SHCSR_PENDSVACT_Pos 10
306 #define SCB_SHCSR_PENDSVACT_Msk (1ul << SCB_SHCSR_PENDSVACT_Pos)
308 #define SCB_SHCSR_MONITORACT_Pos 8
309 #define SCB_SHCSR_MONITORACT_Msk (1ul << SCB_SHCSR_MONITORACT_Pos)
311 #define SCB_SHCSR_SVCALLACT_Pos 7
312 #define SCB_SHCSR_SVCALLACT_Msk (1ul << SCB_SHCSR_SVCALLACT_Pos)
314 #define SCB_SHCSR_USGFAULTACT_Pos 3
315 #define SCB_SHCSR_USGFAULTACT_Msk (1ul << SCB_SHCSR_USGFAULTACT_Pos)
317 #define SCB_SHCSR_BUSFAULTACT_Pos 1
318 #define SCB_SHCSR_BUSFAULTACT_Msk (1ul << SCB_SHCSR_BUSFAULTACT_Pos)
320 #define SCB_SHCSR_MEMFAULTACT_Pos 0
321 #define SCB_SHCSR_MEMFAULTACT_Msk (1ul << SCB_SHCSR_MEMFAULTACT_Pos)
323 /* SCB Configurable Fault Status Registers Definitions */
324 #define SCB_CFSR_USGFAULTSR_Pos 16
325 #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos)
327 #define SCB_CFSR_BUSFAULTSR_Pos 8
328 #define SCB_CFSR_BUSFAULTSR_Msk (0xFFul << SCB_CFSR_BUSFAULTSR_Pos)
330 #define SCB_CFSR_MEMFAULTSR_Pos 0
331 #define SCB_CFSR_MEMFAULTSR_Msk (0xFFul << SCB_CFSR_MEMFAULTSR_Pos)
333 /* SCB Hard Fault Status Registers Definitions */
334 #define SCB_HFSR_DEBUGEVT_Pos 31
335 #define SCB_HFSR_DEBUGEVT_Msk (1ul << SCB_HFSR_DEBUGEVT_Pos)
337 #define SCB_HFSR_FORCED_Pos 30
338 #define SCB_HFSR_FORCED_Msk (1ul << SCB_HFSR_FORCED_Pos)
340 #define SCB_HFSR_VECTTBL_Pos 1
341 #define SCB_HFSR_VECTTBL_Msk (1ul << SCB_HFSR_VECTTBL_Pos)
343 /* SCB Debug Fault Status Register Definitions */
344 #define SCB_DFSR_EXTERNAL_Pos 4
345 #define SCB_DFSR_EXTERNAL_Msk (1ul << SCB_DFSR_EXTERNAL_Pos)
347 #define SCB_DFSR_VCATCH_Pos 3
348 #define SCB_DFSR_VCATCH_Msk (1ul << SCB_DFSR_VCATCH_Pos)
350 #define SCB_DFSR_DWTTRAP_Pos 2
351 #define SCB_DFSR_DWTTRAP_Msk (1ul << SCB_DFSR_DWTTRAP_Pos)
353 #define SCB_DFSR_BKPT_Pos 1
354 #define SCB_DFSR_BKPT_Msk (1ul << SCB_DFSR_BKPT_Pos)
356 #define SCB_DFSR_HALTED_Pos 0
357 #define SCB_DFSR_HALTED_Msk (1ul << SCB_DFSR_HALTED_Pos)
358  /* end of group CMSIS_CM3_SCB */
359 
360 
365 typedef struct
366 {
371 } SysTick_Type;
372 
373 /* SysTick Control / Status Register Definitions */
374 #define SysTick_CTRL_COUNTFLAG_Pos 16
375 #define SysTick_CTRL_COUNTFLAG_Msk (1ul << SysTick_CTRL_COUNTFLAG_Pos)
377 #define SysTick_CTRL_CLKSOURCE_Pos 2
378 #define SysTick_CTRL_CLKSOURCE_Msk (1ul << SysTick_CTRL_CLKSOURCE_Pos)
380 #define SysTick_CTRL_TICKINT_Pos 1
381 #define SysTick_CTRL_TICKINT_Msk (1ul << SysTick_CTRL_TICKINT_Pos)
383 #define SysTick_CTRL_ENABLE_Pos 0
384 #define SysTick_CTRL_ENABLE_Msk (1ul << SysTick_CTRL_ENABLE_Pos)
386 /* SysTick Reload Register Definitions */
387 #define SysTick_LOAD_RELOAD_Pos 0
388 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos)
390 /* SysTick Current Register Definitions */
391 #define SysTick_VAL_CURRENT_Pos 0
392 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)
394 /* SysTick Calibration Register Definitions */
395 #define SysTick_CALIB_NOREF_Pos 31
396 #define SysTick_CALIB_NOREF_Msk (1ul << SysTick_CALIB_NOREF_Pos)
398 #define SysTick_CALIB_SKEW_Pos 30
399 #define SysTick_CALIB_SKEW_Msk (1ul << SysTick_CALIB_SKEW_Pos)
401 #define SysTick_CALIB_TENMS_Pos 0
402 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)
403  /* end of group CMSIS_CM3_SysTick */
404 
405 
410 typedef struct
411 {
412  __O union
413  {
417  } PORT [32];
418  uint32_t RESERVED0[864];
420  uint32_t RESERVED1[15];
422  uint32_t RESERVED2[15];
424  uint32_t RESERVED3[29];
428  uint32_t RESERVED4[43];
431  uint32_t RESERVED5[6];
444 } ITM_Type;
445 
446 /* ITM Trace Privilege Register Definitions */
447 #define ITM_TPR_PRIVMASK_Pos 0
448 #define ITM_TPR_PRIVMASK_Msk (0xFul << ITM_TPR_PRIVMASK_Pos)
450 /* ITM Trace Control Register Definitions */
451 #define ITM_TCR_BUSY_Pos 23
452 #define ITM_TCR_BUSY_Msk (1ul << ITM_TCR_BUSY_Pos)
454 #define ITM_TCR_ATBID_Pos 16
455 #define ITM_TCR_ATBID_Msk (0x7Ful << ITM_TCR_ATBID_Pos)
457 #define ITM_TCR_TSPrescale_Pos 8
458 #define ITM_TCR_TSPrescale_Msk (3ul << ITM_TCR_TSPrescale_Pos)
460 #define ITM_TCR_SWOENA_Pos 4
461 #define ITM_TCR_SWOENA_Msk (1ul << ITM_TCR_SWOENA_Pos)
463 #define ITM_TCR_DWTENA_Pos 3
464 #define ITM_TCR_DWTENA_Msk (1ul << ITM_TCR_DWTENA_Pos)
466 #define ITM_TCR_SYNCENA_Pos 2
467 #define ITM_TCR_SYNCENA_Msk (1ul << ITM_TCR_SYNCENA_Pos)
469 #define ITM_TCR_TSENA_Pos 1
470 #define ITM_TCR_TSENA_Msk (1ul << ITM_TCR_TSENA_Pos)
472 #define ITM_TCR_ITMENA_Pos 0
473 #define ITM_TCR_ITMENA_Msk (1ul << ITM_TCR_ITMENA_Pos)
475 /* ITM Integration Write Register Definitions */
476 #define ITM_IWR_ATVALIDM_Pos 0
477 #define ITM_IWR_ATVALIDM_Msk (1ul << ITM_IWR_ATVALIDM_Pos)
479 /* ITM Integration Read Register Definitions */
480 #define ITM_IRR_ATREADYM_Pos 0
481 #define ITM_IRR_ATREADYM_Msk (1ul << ITM_IRR_ATREADYM_Pos)
483 /* ITM Integration Mode Control Register Definitions */
484 #define ITM_IMCR_INTEGRATION_Pos 0
485 #define ITM_IMCR_INTEGRATION_Msk (1ul << ITM_IMCR_INTEGRATION_Pos)
487 /* ITM Lock Status Register Definitions */
488 #define ITM_LSR_ByteAcc_Pos 2
489 #define ITM_LSR_ByteAcc_Msk (1ul << ITM_LSR_ByteAcc_Pos)
491 #define ITM_LSR_Access_Pos 1
492 #define ITM_LSR_Access_Msk (1ul << ITM_LSR_Access_Pos)
494 #define ITM_LSR_Present_Pos 0
495 #define ITM_LSR_Present_Msk (1ul << ITM_LSR_Present_Pos)
496  /* end of group CMSIS_CM3_ITM */
497 
498 
503 typedef struct
504 {
507 #if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
508  __IO uint32_t ACTLR;
509 #else
511 #endif
513 
514 /* Interrupt Controller Type Register Definitions */
515 #define InterruptType_ICTR_INTLINESNUM_Pos 0
516 #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos)
518 /* Auxiliary Control Register Definitions */
519 #define InterruptType_ACTLR_DISFOLD_Pos 2
520 #define InterruptType_ACTLR_DISFOLD_Msk (1ul << InterruptType_ACTLR_DISFOLD_Pos)
522 #define InterruptType_ACTLR_DISDEFWBUF_Pos 1
523 #define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos)
525 #define InterruptType_ACTLR_DISMCYCINT_Pos 0
526 #define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos)
527  /* end of group CMSIS_CM3_InterruptType */
528 
529 
530 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
531 
535 typedef struct
536 {
537  __I uint32_t TYPE;
538  __IO uint32_t CTRL;
539  __IO uint32_t RNR;
540  __IO uint32_t RBAR;
541  __IO uint32_t RASR;
542  __IO uint32_t RBAR_A1;
543  __IO uint32_t RASR_A1;
544  __IO uint32_t RBAR_A2;
545  __IO uint32_t RASR_A2;
546  __IO uint32_t RBAR_A3;
547  __IO uint32_t RASR_A3;
548 } MPU_Type;
549 
550 /* MPU Type Register */
551 #define MPU_TYPE_IREGION_Pos 16
552 #define MPU_TYPE_IREGION_Msk (0xFFul << MPU_TYPE_IREGION_Pos)
554 #define MPU_TYPE_DREGION_Pos 8
555 #define MPU_TYPE_DREGION_Msk (0xFFul << MPU_TYPE_DREGION_Pos)
557 #define MPU_TYPE_SEPARATE_Pos 0
558 #define MPU_TYPE_SEPARATE_Msk (1ul << MPU_TYPE_SEPARATE_Pos)
560 /* MPU Control Register */
561 #define MPU_CTRL_PRIVDEFENA_Pos 2
562 #define MPU_CTRL_PRIVDEFENA_Msk (1ul << MPU_CTRL_PRIVDEFENA_Pos)
564 #define MPU_CTRL_HFNMIENA_Pos 1
565 #define MPU_CTRL_HFNMIENA_Msk (1ul << MPU_CTRL_HFNMIENA_Pos)
567 #define MPU_CTRL_ENABLE_Pos 0
568 #define MPU_CTRL_ENABLE_Msk (1ul << MPU_CTRL_ENABLE_Pos)
570 /* MPU Region Number Register */
571 #define MPU_RNR_REGION_Pos 0
572 #define MPU_RNR_REGION_Msk (0xFFul << MPU_RNR_REGION_Pos)
574 /* MPU Region Base Address Register */
575 #define MPU_RBAR_ADDR_Pos 5
576 #define MPU_RBAR_ADDR_Msk (0x7FFFFFFul << MPU_RBAR_ADDR_Pos)
578 #define MPU_RBAR_VALID_Pos 4
579 #define MPU_RBAR_VALID_Msk (1ul << MPU_RBAR_VALID_Pos)
581 #define MPU_RBAR_REGION_Pos 0
582 #define MPU_RBAR_REGION_Msk (0xFul << MPU_RBAR_REGION_Pos)
584 /* MPU Region Attribute and Size Register */
585 #define MPU_RASR_XN_Pos 28
586 #define MPU_RASR_XN_Msk (1ul << MPU_RASR_XN_Pos)
588 #define MPU_RASR_AP_Pos 24
589 #define MPU_RASR_AP_Msk (7ul << MPU_RASR_AP_Pos)
591 #define MPU_RASR_TEX_Pos 19
592 #define MPU_RASR_TEX_Msk (7ul << MPU_RASR_TEX_Pos)
594 #define MPU_RASR_S_Pos 18
595 #define MPU_RASR_S_Msk (1ul << MPU_RASR_S_Pos)
597 #define MPU_RASR_C_Pos 17
598 #define MPU_RASR_C_Msk (1ul << MPU_RASR_C_Pos)
600 #define MPU_RASR_B_Pos 16
601 #define MPU_RASR_B_Msk (1ul << MPU_RASR_B_Pos)
603 #define MPU_RASR_SRD_Pos 8
604 #define MPU_RASR_SRD_Msk (0xFFul << MPU_RASR_SRD_Pos)
606 #define MPU_RASR_SIZE_Pos 1
607 #define MPU_RASR_SIZE_Msk (0x1Ful << MPU_RASR_SIZE_Pos)
609 #define MPU_RASR_ENA_Pos 0
610 #define MPU_RASR_ENA_Msk (0x1Ful << MPU_RASR_ENA_Pos)
612  /* end of group CMSIS_CM3_MPU */
613 #endif
614 
615 
620 typedef struct
621 {
627 
628 /* Debug Halting Control and Status Register */
629 #define CoreDebug_DHCSR_DBGKEY_Pos 16
630 #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos)
632 #define CoreDebug_DHCSR_S_RESET_ST_Pos 25
633 #define CoreDebug_DHCSR_S_RESET_ST_Msk (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos)
635 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24
636 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos)
638 #define CoreDebug_DHCSR_S_LOCKUP_Pos 19
639 #define CoreDebug_DHCSR_S_LOCKUP_Msk (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos)
641 #define CoreDebug_DHCSR_S_SLEEP_Pos 18
642 #define CoreDebug_DHCSR_S_SLEEP_Msk (1ul << CoreDebug_DHCSR_S_SLEEP_Pos)
644 #define CoreDebug_DHCSR_S_HALT_Pos 17
645 #define CoreDebug_DHCSR_S_HALT_Msk (1ul << CoreDebug_DHCSR_S_HALT_Pos)
647 #define CoreDebug_DHCSR_S_REGRDY_Pos 16
648 #define CoreDebug_DHCSR_S_REGRDY_Msk (1ul << CoreDebug_DHCSR_S_REGRDY_Pos)
650 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5
651 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos)
653 #define CoreDebug_DHCSR_C_MASKINTS_Pos 3
654 #define CoreDebug_DHCSR_C_MASKINTS_Msk (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos)
656 #define CoreDebug_DHCSR_C_STEP_Pos 2
657 #define CoreDebug_DHCSR_C_STEP_Msk (1ul << CoreDebug_DHCSR_C_STEP_Pos)
659 #define CoreDebug_DHCSR_C_HALT_Pos 1
660 #define CoreDebug_DHCSR_C_HALT_Msk (1ul << CoreDebug_DHCSR_C_HALT_Pos)
662 #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0
663 #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos)
665 /* Debug Core Register Selector Register */
666 #define CoreDebug_DCRSR_REGWnR_Pos 16
667 #define CoreDebug_DCRSR_REGWnR_Msk (1ul << CoreDebug_DCRSR_REGWnR_Pos)
669 #define CoreDebug_DCRSR_REGSEL_Pos 0
670 #define CoreDebug_DCRSR_REGSEL_Msk (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos)
672 /* Debug Exception and Monitor Control Register */
673 #define CoreDebug_DEMCR_TRCENA_Pos 24
674 #define CoreDebug_DEMCR_TRCENA_Msk (1ul << CoreDebug_DEMCR_TRCENA_Pos)
676 #define CoreDebug_DEMCR_MON_REQ_Pos 19
677 #define CoreDebug_DEMCR_MON_REQ_Msk (1ul << CoreDebug_DEMCR_MON_REQ_Pos)
679 #define CoreDebug_DEMCR_MON_STEP_Pos 18
680 #define CoreDebug_DEMCR_MON_STEP_Msk (1ul << CoreDebug_DEMCR_MON_STEP_Pos)
682 #define CoreDebug_DEMCR_MON_PEND_Pos 17
683 #define CoreDebug_DEMCR_MON_PEND_Msk (1ul << CoreDebug_DEMCR_MON_PEND_Pos)
685 #define CoreDebug_DEMCR_MON_EN_Pos 16
686 #define CoreDebug_DEMCR_MON_EN_Msk (1ul << CoreDebug_DEMCR_MON_EN_Pos)
688 #define CoreDebug_DEMCR_VC_HARDERR_Pos 10
689 #define CoreDebug_DEMCR_VC_HARDERR_Msk (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos)
691 #define CoreDebug_DEMCR_VC_INTERR_Pos 9
692 #define CoreDebug_DEMCR_VC_INTERR_Msk (1ul << CoreDebug_DEMCR_VC_INTERR_Pos)
694 #define CoreDebug_DEMCR_VC_BUSERR_Pos 8
695 #define CoreDebug_DEMCR_VC_BUSERR_Msk (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos)
697 #define CoreDebug_DEMCR_VC_STATERR_Pos 7
698 #define CoreDebug_DEMCR_VC_STATERR_Msk (1ul << CoreDebug_DEMCR_VC_STATERR_Pos)
700 #define CoreDebug_DEMCR_VC_CHKERR_Pos 6
701 #define CoreDebug_DEMCR_VC_CHKERR_Msk (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos)
703 #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5
704 #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos)
706 #define CoreDebug_DEMCR_VC_MMERR_Pos 4
707 #define CoreDebug_DEMCR_VC_MMERR_Msk (1ul << CoreDebug_DEMCR_VC_MMERR_Pos)
709 #define CoreDebug_DEMCR_VC_CORERESET_Pos 0
710 #define CoreDebug_DEMCR_VC_CORERESET_Msk (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos)
711  /* end of group CMSIS_CM3_CoreDebug */
712 
713 
714 /* Memory mapping of Cortex-M3 Hardware */
715 #define SCS_BASE (0xE000E000)
716 #define ITM_BASE (0xE0000000)
717 #define CoreDebug_BASE (0xE000EDF0)
718 #define SysTick_BASE (SCS_BASE + 0x0010)
719 #define NVIC_BASE (SCS_BASE + 0x0100)
720 #define SCB_BASE (SCS_BASE + 0x0D00)
722 #define InterruptType ((InterruptType_Type *) SCS_BASE)
723 #define SCB ((SCB_Type *) SCB_BASE)
724 #define SysTick ((SysTick_Type *) SysTick_BASE)
725 #define NVIC ((NVIC_Type *) NVIC_BASE)
726 #define ITM ((ITM_Type *) ITM_BASE)
727 #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE)
729 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
730  #define MPU_BASE (SCS_BASE + 0x0D90)
731  #define MPU ((MPU_Type*) MPU_BASE)
732 #endif
733  /* end of group CMSIS_CM3_core_register */
735 
736 
737 /*******************************************************************************
738  * Hardware Abstraction Layer
739  ******************************************************************************/
740 
741 #if defined ( __CC_ARM )
742  #define __ASM __asm
743  #define __INLINE __inline
745 #elif defined ( __ICCARM__ )
746  #define __ASM __asm
747  #define __INLINE inline
749 #elif defined ( __GNUC__ )
750  #define __ASM __asm
751  #define __INLINE inline
753 #elif defined ( __TASKING__ )
754  #define __ASM __asm
755  #define __INLINE inline
757 #endif
758 
759 
760 /* ################### Compiler specific Intrinsics ########################### */
761 
762 #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
763 /* ARM armcc specific functions */
764 
765 #define __enable_fault_irq __enable_fiq
766 #define __disable_fault_irq __disable_fiq
767 
768 #define __NOP __nop
769 #define __WFI __wfi
770 #define __WFE __wfe
771 #define __SEV __sev
772 #define __ISB() __isb(0)
773 #define __DSB() __dsb(0)
774 #define __DMB() __dmb(0)
775 #define __REV __rev
776 #define __RBIT __rbit
777 #define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr))
778 #define __LDREXH(ptr) ((unsigned short) __ldrex(ptr))
779 #define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr))
780 #define __STREXB(value, ptr) __strex(value, ptr)
781 #define __STREXH(value, ptr) __strex(value, ptr)
782 #define __STREXW(value, ptr) __strex(value, ptr)
783 
784 
785 /* intrinsic unsigned long long __ldrexd(volatile void *ptr) */
786 /* intrinsic int __strexd(unsigned long long val, volatile void *ptr) */
787 /* intrinsic void __enable_irq(); */
788 /* intrinsic void __disable_irq(); */
789 
790 
798 extern uint32_t __get_PSP(void);
799 
808 extern void __set_PSP(uint32_t topOfProcStack);
809 
818 extern uint32_t __get_MSP(void);
819 
828 extern void __set_MSP(uint32_t topOfMainStack);
829 
838 extern uint32_t __REV16(uint16_t value);
839 
848 extern int32_t __REVSH(int16_t value);
849 
850 
851 #if (__ARMCC_VERSION < 400000)
852 
858 extern void __CLREX(void);
859 
867 extern uint32_t __get_BASEPRI(void);
868 
876 extern void __set_BASEPRI(uint32_t basePri);
877 
885 extern uint32_t __get_PRIMASK(void);
886 
894 extern void __set_PRIMASK(uint32_t priMask);
895 
903 extern uint32_t __get_FAULTMASK(void);
904 
912 extern void __set_FAULTMASK(uint32_t faultMask);
913 
921 extern uint32_t __get_CONTROL(void);
922 
930 extern void __set_CONTROL(uint32_t control);
931 
932 #else /* (__ARMCC_VERSION >= 400000) */
933 
939 #define __CLREX __clrex
940 
948 static __INLINE uint32_t __get_BASEPRI(void)
949 {
950  register uint32_t __regBasePri __ASM("basepri");
951  return(__regBasePri);
952 }
953 
961 static __INLINE void __set_BASEPRI(uint32_t basePri)
962 {
963  register uint32_t __regBasePri __ASM("basepri");
964  __regBasePri = (basePri & 0xff);
965 }
966 
974 static __INLINE uint32_t __get_PRIMASK(void)
975 {
976  register uint32_t __regPriMask __ASM("primask");
977  return(__regPriMask);
978 }
979 
987 static __INLINE void __set_PRIMASK(uint32_t priMask)
988 {
989  register uint32_t __regPriMask __ASM("primask");
990  __regPriMask = (priMask);
991 }
992 
1000 static __INLINE uint32_t __get_FAULTMASK(void)
1001 {
1002  register uint32_t __regFaultMask __ASM("faultmask");
1003  return(__regFaultMask);
1004 }
1005 
1013 static __INLINE void __set_FAULTMASK(uint32_t faultMask)
1014 {
1015  register uint32_t __regFaultMask __ASM("faultmask");
1016  __regFaultMask = (faultMask & 1);
1017 }
1018 
1026 static __INLINE uint32_t __get_CONTROL(void)
1027 {
1028  register uint32_t __regControl __ASM("control");
1029  return(__regControl);
1030 }
1031 
1039 static __INLINE void __set_CONTROL(uint32_t control)
1040 {
1041  register uint32_t __regControl __ASM("control");
1042  __regControl = control;
1043 }
1044 
1045 #endif /* __ARMCC_VERSION */
1046 
1047 
1048 
1049 #elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/
1050 /* IAR iccarm specific functions */
1051 
1052 #define __enable_irq __enable_interrupt
1053 #define __disable_irq __disable_interrupt
1055 static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); }
1056 static __INLINE void __disable_fault_irq() { __ASM ("cpsid f"); }
1057 
1058 #define __NOP __no_operation
1059 static __INLINE void __WFI() { __ASM ("wfi"); }
1060 static __INLINE void __WFE() { __ASM ("wfe"); }
1061 static __INLINE void __SEV() { __ASM ("sev"); }
1062 static __INLINE void __CLREX() { __ASM ("clrex"); }
1063 
1064 /* intrinsic void __ISB(void) */
1065 /* intrinsic void __DSB(void) */
1066 /* intrinsic void __DMB(void) */
1067 /* intrinsic void __set_PRIMASK(); */
1068 /* intrinsic void __get_PRIMASK(); */
1069 /* intrinsic void __set_FAULTMASK(); */
1070 /* intrinsic void __get_FAULTMASK(); */
1071 /* intrinsic uint32_t __REV(uint32_t value); */
1072 /* intrinsic uint32_t __REVSH(uint32_t value); */
1073 /* intrinsic unsigned long __STREX(unsigned long, unsigned long); */
1074 /* intrinsic unsigned long __LDREX(unsigned long *); */
1075 
1076 
1084 extern uint32_t __get_PSP(void);
1085 
1094 extern void __set_PSP(uint32_t topOfProcStack);
1095 
1104 extern uint32_t __get_MSP(void);
1105 
1114 extern void __set_MSP(uint32_t topOfMainStack);
1115 
1124 extern uint32_t __REV16(uint16_t value);
1125 
1134 extern uint32_t __RBIT(uint32_t value);
1135 
1144 extern uint8_t __LDREXB(uint8_t *addr);
1145 
1154 extern uint16_t __LDREXH(uint16_t *addr);
1155 
1164 extern uint32_t __LDREXW(uint32_t *addr);
1165 
1175 extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
1176 
1186 extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
1187 
1197 extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
1198 
1199 
1200 
1201 #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/
1202 /* GNU gcc specific functions */
1203 
1204 static __INLINE void __enable_irq() { __ASM volatile ("cpsie i"); }
1205 static __INLINE void __disable_irq() { __ASM volatile ("cpsid i"); }
1206 
1207 static __INLINE void __enable_fault_irq() { __ASM volatile ("cpsie f"); }
1208 static __INLINE void __disable_fault_irq() { __ASM volatile ("cpsid f"); }
1209 
1210 static __INLINE void __NOP() { __ASM volatile ("nop"); }
1211 static __INLINE void __WFI() { __ASM volatile ("wfi"); }
1212 static __INLINE void __WFE() { __ASM volatile ("wfe"); }
1213 static __INLINE void __SEV() { __ASM volatile ("sev"); }
1214 static __INLINE void __ISB() { __ASM volatile ("isb"); }
1215 static __INLINE void __DSB() { __ASM volatile ("dsb"); }
1216 static __INLINE void __DMB() { __ASM volatile ("dmb"); }
1217 static __INLINE void __CLREX() { __ASM volatile ("clrex"); }
1218 
1219 
1227 extern uint32_t __get_PSP(void);
1228 
1237 extern void __set_PSP(uint32_t topOfProcStack);
1238 
1247 extern uint32_t __get_MSP(void);
1248 
1257 extern void __set_MSP(uint32_t topOfMainStack);
1258 
1266 extern uint32_t __get_BASEPRI(void);
1267 
1275 extern void __set_BASEPRI(uint32_t basePri);
1276 
1284 extern uint32_t __get_PRIMASK(void);
1285 
1293 extern void __set_PRIMASK(uint32_t priMask);
1294 
1302 extern uint32_t __get_FAULTMASK(void);
1303 
1311 extern void __set_FAULTMASK(uint32_t faultMask);
1312 
1320 extern uint32_t __get_CONTROL(void);
1321 
1329 extern void __set_CONTROL(uint32_t control);
1330 
1339 extern uint32_t __REV(uint32_t value);
1340 
1349 extern uint32_t __REV16(uint16_t value);
1350 
1359 extern int32_t __REVSH(int16_t value);
1360 
1369 extern uint32_t __RBIT(uint32_t value);
1370 
1379 extern uint8_t __LDREXB(uint8_t *addr);
1380 
1389 extern uint16_t __LDREXH(uint16_t *addr);
1390 
1399 extern uint32_t __LDREXW(uint32_t *addr);
1400 
1410 extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
1411 
1421 extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
1422 
1432 extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
1433 
1434 
1435 #elif (defined (__TASKING__)) /*------------------ TASKING Compiler ---------------------*/
1436 /* TASKING carm specific functions */
1437 
1438 /*
1439  * The CMSIS functions have been implemented as intrinsics in the compiler.
1440  * Please use "carm -?i" to get an up to date list of all instrinsics,
1441  * Including the CMSIS ones.
1442  */
1443 
1444 #endif
1445 
1446 
1454 
1455 /* ########################## NVIC functions #################################### */
1456 
1468 static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1469 {
1470  uint32_t reg_value;
1471  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1472 
1473  reg_value = SCB->AIRCR; /* read old register configuration */
1474  reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
1475  reg_value = (reg_value |
1476  (0x5FA << SCB_AIRCR_VECTKEY_Pos) |
1477  (PriorityGroupTmp << 8)); /* Insert write key and priorty group */
1478  SCB->AIRCR = reg_value;
1479 }
1480 
1489 static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
1490 {
1491  return ((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos); /* read priority grouping field */
1492 }
1493 
1502 static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
1503 {
1504  NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
1505 }
1506 
1515 static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
1516 {
1517  NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* disable interrupt */
1518 }
1519 
1529 static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
1530 {
1531  return((uint32_t) ((NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if pending else 0 */
1532 }
1533 
1542 static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
1543 {
1544  NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* set interrupt pending */
1545 }
1546 
1555 static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1556 {
1557  NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* Clear pending interrupt */
1558 }
1559 
1569 static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
1570 {
1571  return((uint32_t)((NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0)); /* Return 1 if active else 0 */
1572 }
1573 
1586 static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
1587 {
1588  if(IRQn < 0) {
1589  SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
1590  else {
1591  NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
1592 }
1593 
1609 static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
1610 {
1611 
1612  if(IRQn < 0) {
1613  return((uint32_t)(SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for Cortex-M3 system interrupts */
1614  else {
1615  return((uint32_t)(NVIC->IP[(uint32_t)(IRQn)] >> (8 - __NVIC_PRIO_BITS))); } /* get priority for device specific interrupts */
1616 }
1617 
1618 
1634 static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
1635 {
1636  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1637  uint32_t PreemptPriorityBits;
1638  uint32_t SubPriorityBits;
1639 
1640  PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1641  SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
1642 
1643  return (
1644  ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
1645  ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
1646  );
1647 }
1648 
1649 
1665 static __INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
1666 {
1667  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
1668  uint32_t PreemptPriorityBits;
1669  uint32_t SubPriorityBits;
1670 
1671  PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1672  SubPriorityBits = ((PriorityGroupTmp + __NVIC_PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + __NVIC_PRIO_BITS;
1673 
1674  *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
1675  *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
1676 }
1677 
1678 
1679 
1680 /* ################################## SysTick function ############################################ */
1681 
1682 #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
1683 
1694 static __INLINE uint32_t SysTick_Config(uint32_t ticks)
1695 {
1696  if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */
1697 
1698  SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
1699  NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
1700  SysTick->VAL = 0; /* Load the SysTick Counter Value */
1703  SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
1704  return (0); /* Function successful */
1705 }
1706 
1707 #endif
1708 
1709 
1710 
1711 
1712 /* ################################## Reset function ############################################ */
1713 
1719 static __INLINE void NVIC_SystemReset(void)
1720 {
1721  SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
1722  (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
1723  SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
1724  __DSB(); /* Ensure completion of memory access */
1725  while(1); /* wait until reset */
1726 }
1727  /* end of group CMSIS_CM3_Core_FunctionInterface */
1729 
1730 
1731 
1732 /* ##################################### Debug In/Output function ########################################### */
1733 
1741 
1742 extern volatile int ITM_RxBuffer;
1743 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5
1756 static __INLINE uint32_t ITM_SendChar (uint32_t ch)
1757 {
1758  if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk) && /* Trace enabled */
1759  (ITM->TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
1760  (ITM->TER & (1ul << 0) ) ) /* ITM Port #0 enabled */
1761  {
1762  while (ITM->PORT[0].u32 == 0);
1763  ITM->PORT[0].u8 = (uint8_t) ch;
1764  }
1765  return (ch);
1766 }
1767 
1768 
1778 static __INLINE int ITM_ReceiveChar (void) {
1779  int ch = -1; /* no character available */
1780 
1781  if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
1782  ch = ITM_RxBuffer;
1783  ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
1784  }
1785 
1786  return (ch);
1787 }
1788 
1789 
1798 static __INLINE int ITM_CheckChar (void) {
1799 
1800  if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
1801  return (0); /* no character available */
1802  } else {
1803  return (1); /* character available */
1804  }
1805 }
1806  /* end of group CMSIS_CM3_core_DebugInterface */
1808 
1809 
1810 #ifdef __cplusplus
1811 }
1812 #endif
1813  /* end of group CMSIS_CM3_core_definitions */
1815 
1816 #endif /* __CM3_CORE_H__ */
1817 
1818 /*lint -restore */
__IO uint32_t ICSR
Definition: core_cm3.h:158
__IO uint32_t CFSR
Definition: core_cm3.h:165
#define SysTick_CTRL_CLKSOURCE_Msk
Definition: core_cm3.h:378
__I uint32_t PID4
Definition: core_cm3.h:432
#define SCB
Definition: core_cm3.h:723
__IO uint32_t LOAD
Definition: core_cm3.h:368
__IO uint32_t IRR
Definition: core_cm3.h:426
__O uint32_t u32
Definition: core_cm3.h:416
__IO uint32_t DCRDR
Definition: core_cm3.h:624
__I uint32_t CALIB
Definition: core_cm3.h:370
__O uint8_t u8
Definition: core_cm3.h:414
__O uint16_t u16
Definition: core_cm3.h:415
__IO uint32_t MMFAR
Definition: core_cm3.h:168
#define __NVIC_PRIO_BITS
Definition: core_cm3.h:98
__IO uint32_t DHCSR
Definition: core_cm3.h:622
#define SysTick_CTRL_TICKINT_Msk
Definition: core_cm3.h:381
signed int int32_t
Definition: type.h:23
__IO uint32_t DFSR
Definition: core_cm3.h:167
#define CoreDebug_DEMCR_TRCENA_Msk
Definition: core_cm3.h:674
#define __IO
Definition: core_cm3.h:116
__O uint32_t STIR
Definition: core_cm3.h:146
__O uint32_t DCRSR
Definition: core_cm3.h:623
__I uint32_t PID5
Definition: core_cm3.h:433
__IO uint32_t CCR
Definition: core_cm3.h:162
__IO uint32_t VTOR
Definition: core_cm3.h:159
__I uint32_t ICTR
Definition: core_cm3.h:506
__IO uint32_t IMCR
Definition: core_cm3.h:427
__I uint32_t DFR
Definition: core_cm3.h:172
__IO uint32_t HFSR
Definition: core_cm3.h:166
__IO uint32_t DEMCR
Definition: core_cm3.h:625
#define SCB_AIRCR_PRIGROUP_Pos
Definition: core_cm3.h:239
unsigned char uint8_t
Definition: type.h:27
__I uint32_t PID7
Definition: core_cm3.h:435
__IO uint32_t LAR
Definition: core_cm3.h:429
__I uint32_t CID0
Definition: core_cm3.h:440
__I uint32_t ADR
Definition: core_cm3.h:173
__IO uint32_t VAL
Definition: core_cm3.h:369
volatile int ITM_RxBuffer
#define SysTick
Definition: core_cm3.h:724
#define ITM
Definition: core_cm3.h:726
__IO uint32_t LSR
Definition: core_cm3.h:430
__I uint32_t CID1
Definition: core_cm3.h:441
__I uint32_t CPUID
Definition: core_cm3.h:157
__I uint32_t PID6
Definition: core_cm3.h:434
#define SCB_AIRCR_VECTKEY_Pos
Definition: core_cm3.h:230
__IO uint32_t IWR
Definition: core_cm3.h:425
__IO uint32_t CTRL
Definition: core_cm3.h:367
#define SysTick_LOAD_RELOAD_Msk
Definition: core_cm3.h:388
__IO uint32_t SHCSR
Definition: core_cm3.h:164
__IO uint32_t TER
Definition: core_cm3.h:419
#define SysTick_CTRL_ENABLE_Msk
Definition: core_cm3.h:384
__IO uint32_t SCR
Definition: core_cm3.h:161
uint32_t RESERVED1
Definition: core_cm3.h:510
#define ITM_TCR_ITMENA_Msk
Definition: core_cm3.h:473
__I uint32_t CID3
Definition: core_cm3.h:443
__IO uint32_t TCR
Definition: core_cm3.h:423
#define CoreDebug
Definition: core_cm3.h:727
signed short int int16_t
Definition: type.h:22
unsigned short int uint16_t
Definition: type.h:28
__IO uint32_t TPR
Definition: core_cm3.h:421
__I uint32_t PID1
Definition: core_cm3.h:437
__I uint32_t PID2
Definition: core_cm3.h:438
#define SCB_AIRCR_PRIGROUP_Msk
Definition: core_cm3.h:240
#define __O
Definition: core_cm3.h:115
uint32_t RESERVED0
Definition: core_cm3.h:505
#define ITM_RXBUFFER_EMPTY
Definition: core_cm3.h:1743
#define SCB_AIRCR_VECTKEY_Msk
Definition: core_cm3.h:231
__I uint32_t PID3
Definition: core_cm3.h:439
#define __I
Definition: core_cm3.h:113
__IO uint32_t AFSR
Definition: core_cm3.h:170
__IO uint32_t AIRCR
Definition: core_cm3.h:160
__I uint32_t CID2
Definition: core_cm3.h:442
__I uint32_t PID0
Definition: core_cm3.h:436
#define NVIC
Definition: core_cm3.h:725
__IO uint32_t BFAR
Definition: core_cm3.h:169
#define SCB_AIRCR_SYSRESETREQ_Msk
Definition: core_cm3.h:243
unsigned int uint32_t
Definition: type.h:29