24 #ifndef __CM3_CORE_H__
25 #define __CM3_CORE_H__
88 #define __CM3_CMSIS_VERSION_MAIN (0x01)
89 #define __CM3_CMSIS_VERSION_SUB (0x30)
90 #define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16) | __CM3_CMSIS_VERSION_SUB)
92 #define __CORTEX_M (0x03)
96 #if defined (__ICCARM__)
97 #include <intrinsics.h>
101 #ifndef __NVIC_PRIO_BITS
102 #define __NVIC_PRIO_BITS 4
117 #define __I volatile const
120 #define __IO volatile
140 uint32_t RESERVED0[24];
142 uint32_t RSERVED1[24];
144 uint32_t RESERVED2[24];
146 uint32_t RESERVED3[24];
148 uint32_t RESERVED4[56];
150 uint32_t RESERVED5[644];
185 #define SCB_CPUID_IMPLEMENTER_Pos 24
186 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFul << SCB_CPUID_IMPLEMENTER_Pos)
188 #define SCB_CPUID_VARIANT_Pos 20
189 #define SCB_CPUID_VARIANT_Msk (0xFul << SCB_CPUID_VARIANT_Pos)
191 #define SCB_CPUID_PARTNO_Pos 4
192 #define SCB_CPUID_PARTNO_Msk (0xFFFul << SCB_CPUID_PARTNO_Pos)
194 #define SCB_CPUID_REVISION_Pos 0
195 #define SCB_CPUID_REVISION_Msk (0xFul << SCB_CPUID_REVISION_Pos)
198 #define SCB_ICSR_NMIPENDSET_Pos 31
199 #define SCB_ICSR_NMIPENDSET_Msk (1ul << SCB_ICSR_NMIPENDSET_Pos)
201 #define SCB_ICSR_PENDSVSET_Pos 28
202 #define SCB_ICSR_PENDSVSET_Msk (1ul << SCB_ICSR_PENDSVSET_Pos)
204 #define SCB_ICSR_PENDSVCLR_Pos 27
205 #define SCB_ICSR_PENDSVCLR_Msk (1ul << SCB_ICSR_PENDSVCLR_Pos)
207 #define SCB_ICSR_PENDSTSET_Pos 26
208 #define SCB_ICSR_PENDSTSET_Msk (1ul << SCB_ICSR_PENDSTSET_Pos)
210 #define SCB_ICSR_PENDSTCLR_Pos 25
211 #define SCB_ICSR_PENDSTCLR_Msk (1ul << SCB_ICSR_PENDSTCLR_Pos)
213 #define SCB_ICSR_ISRPREEMPT_Pos 23
214 #define SCB_ICSR_ISRPREEMPT_Msk (1ul << SCB_ICSR_ISRPREEMPT_Pos)
216 #define SCB_ICSR_ISRPENDING_Pos 22
217 #define SCB_ICSR_ISRPENDING_Msk (1ul << SCB_ICSR_ISRPENDING_Pos)
219 #define SCB_ICSR_VECTPENDING_Pos 12
220 #define SCB_ICSR_VECTPENDING_Msk (0x1FFul << SCB_ICSR_VECTPENDING_Pos)
222 #define SCB_ICSR_RETTOBASE_Pos 11
223 #define SCB_ICSR_RETTOBASE_Msk (1ul << SCB_ICSR_RETTOBASE_Pos)
225 #define SCB_ICSR_VECTACTIVE_Pos 0
226 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFul << SCB_ICSR_VECTACTIVE_Pos)
229 #define SCB_VTOR_TBLBASE_Pos 29
230 #define SCB_VTOR_TBLBASE_Msk (0x1FFul << SCB_VTOR_TBLBASE_Pos)
232 #define SCB_VTOR_TBLOFF_Pos 7
233 #define SCB_VTOR_TBLOFF_Msk (0x3FFFFFul << SCB_VTOR_TBLOFF_Pos)
236 #define SCB_AIRCR_VECTKEY_Pos 16
237 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFul << SCB_AIRCR_VECTKEY_Pos)
239 #define SCB_AIRCR_VECTKEYSTAT_Pos 16
240 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFul << SCB_AIRCR_VECTKEYSTAT_Pos)
242 #define SCB_AIRCR_ENDIANESS_Pos 15
243 #define SCB_AIRCR_ENDIANESS_Msk (1ul << SCB_AIRCR_ENDIANESS_Pos)
245 #define SCB_AIRCR_PRIGROUP_Pos 8
246 #define SCB_AIRCR_PRIGROUP_Msk (7ul << SCB_AIRCR_PRIGROUP_Pos)
248 #define SCB_AIRCR_SYSRESETREQ_Pos 2
249 #define SCB_AIRCR_SYSRESETREQ_Msk (1ul << SCB_AIRCR_SYSRESETREQ_Pos)
251 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1
252 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1ul << SCB_AIRCR_VECTCLRACTIVE_Pos)
254 #define SCB_AIRCR_VECTRESET_Pos 0
255 #define SCB_AIRCR_VECTRESET_Msk (1ul << SCB_AIRCR_VECTRESET_Pos)
258 #define SCB_SCR_SEVONPEND_Pos 4
259 #define SCB_SCR_SEVONPEND_Msk (1ul << SCB_SCR_SEVONPEND_Pos)
261 #define SCB_SCR_SLEEPDEEP_Pos 2
262 #define SCB_SCR_SLEEPDEEP_Msk (1ul << SCB_SCR_SLEEPDEEP_Pos)
264 #define SCB_SCR_SLEEPONEXIT_Pos 1
265 #define SCB_SCR_SLEEPONEXIT_Msk (1ul << SCB_SCR_SLEEPONEXIT_Pos)
268 #define SCB_CCR_STKALIGN_Pos 9
269 #define SCB_CCR_STKALIGN_Msk (1ul << SCB_CCR_STKALIGN_Pos)
271 #define SCB_CCR_BFHFNMIGN_Pos 8
272 #define SCB_CCR_BFHFNMIGN_Msk (1ul << SCB_CCR_BFHFNMIGN_Pos)
274 #define SCB_CCR_DIV_0_TRP_Pos 4
275 #define SCB_CCR_DIV_0_TRP_Msk (1ul << SCB_CCR_DIV_0_TRP_Pos)
277 #define SCB_CCR_UNALIGN_TRP_Pos 3
278 #define SCB_CCR_UNALIGN_TRP_Msk (1ul << SCB_CCR_UNALIGN_TRP_Pos)
280 #define SCB_CCR_USERSETMPEND_Pos 1
281 #define SCB_CCR_USERSETMPEND_Msk (1ul << SCB_CCR_USERSETMPEND_Pos)
283 #define SCB_CCR_NONBASETHRDENA_Pos 0
284 #define SCB_CCR_NONBASETHRDENA_Msk (1ul << SCB_CCR_NONBASETHRDENA_Pos)
287 #define SCB_SHCSR_USGFAULTENA_Pos 18
288 #define SCB_SHCSR_USGFAULTENA_Msk (1ul << SCB_SHCSR_USGFAULTENA_Pos)
290 #define SCB_SHCSR_BUSFAULTENA_Pos 17
291 #define SCB_SHCSR_BUSFAULTENA_Msk (1ul << SCB_SHCSR_BUSFAULTENA_Pos)
293 #define SCB_SHCSR_MEMFAULTENA_Pos 16
294 #define SCB_SHCSR_MEMFAULTENA_Msk (1ul << SCB_SHCSR_MEMFAULTENA_Pos)
296 #define SCB_SHCSR_SVCALLPENDED_Pos 15
297 #define SCB_SHCSR_SVCALLPENDED_Msk (1ul << SCB_SHCSR_SVCALLPENDED_Pos)
299 #define SCB_SHCSR_BUSFAULTPENDED_Pos 14
300 #define SCB_SHCSR_BUSFAULTPENDED_Msk (1ul << SCB_SHCSR_BUSFAULTPENDED_Pos)
302 #define SCB_SHCSR_MEMFAULTPENDED_Pos 13
303 #define SCB_SHCSR_MEMFAULTPENDED_Msk (1ul << SCB_SHCSR_MEMFAULTPENDED_Pos)
305 #define SCB_SHCSR_USGFAULTPENDED_Pos 12
306 #define SCB_SHCSR_USGFAULTPENDED_Msk (1ul << SCB_SHCSR_USGFAULTPENDED_Pos)
308 #define SCB_SHCSR_SYSTICKACT_Pos 11
309 #define SCB_SHCSR_SYSTICKACT_Msk (1ul << SCB_SHCSR_SYSTICKACT_Pos)
311 #define SCB_SHCSR_PENDSVACT_Pos 10
312 #define SCB_SHCSR_PENDSVACT_Msk (1ul << SCB_SHCSR_PENDSVACT_Pos)
314 #define SCB_SHCSR_MONITORACT_Pos 8
315 #define SCB_SHCSR_MONITORACT_Msk (1ul << SCB_SHCSR_MONITORACT_Pos)
317 #define SCB_SHCSR_SVCALLACT_Pos 7
318 #define SCB_SHCSR_SVCALLACT_Msk (1ul << SCB_SHCSR_SVCALLACT_Pos)
320 #define SCB_SHCSR_USGFAULTACT_Pos 3
321 #define SCB_SHCSR_USGFAULTACT_Msk (1ul << SCB_SHCSR_USGFAULTACT_Pos)
323 #define SCB_SHCSR_BUSFAULTACT_Pos 1
324 #define SCB_SHCSR_BUSFAULTACT_Msk (1ul << SCB_SHCSR_BUSFAULTACT_Pos)
326 #define SCB_SHCSR_MEMFAULTACT_Pos 0
327 #define SCB_SHCSR_MEMFAULTACT_Msk (1ul << SCB_SHCSR_MEMFAULTACT_Pos)
330 #define SCB_CFSR_USGFAULTSR_Pos 16
331 #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFul << SCB_CFSR_USGFAULTSR_Pos)
333 #define SCB_CFSR_BUSFAULTSR_Pos 8
334 #define SCB_CFSR_BUSFAULTSR_Msk (0xFFul << SCB_CFSR_BUSFAULTSR_Pos)
336 #define SCB_CFSR_MEMFAULTSR_Pos 0
337 #define SCB_CFSR_MEMFAULTSR_Msk (0xFFul << SCB_CFSR_MEMFAULTSR_Pos)
340 #define SCB_HFSR_DEBUGEVT_Pos 31
341 #define SCB_HFSR_DEBUGEVT_Msk (1ul << SCB_HFSR_DEBUGEVT_Pos)
343 #define SCB_HFSR_FORCED_Pos 30
344 #define SCB_HFSR_FORCED_Msk (1ul << SCB_HFSR_FORCED_Pos)
346 #define SCB_HFSR_VECTTBL_Pos 1
347 #define SCB_HFSR_VECTTBL_Msk (1ul << SCB_HFSR_VECTTBL_Pos)
350 #define SCB_DFSR_EXTERNAL_Pos 4
351 #define SCB_DFSR_EXTERNAL_Msk (1ul << SCB_DFSR_EXTERNAL_Pos)
353 #define SCB_DFSR_VCATCH_Pos 3
354 #define SCB_DFSR_VCATCH_Msk (1ul << SCB_DFSR_VCATCH_Pos)
356 #define SCB_DFSR_DWTTRAP_Pos 2
357 #define SCB_DFSR_DWTTRAP_Msk (1ul << SCB_DFSR_DWTTRAP_Pos)
359 #define SCB_DFSR_BKPT_Pos 1
360 #define SCB_DFSR_BKPT_Msk (1ul << SCB_DFSR_BKPT_Pos)
362 #define SCB_DFSR_HALTED_Pos 0
363 #define SCB_DFSR_HALTED_Msk (1ul << SCB_DFSR_HALTED_Pos)
381 #define SysTick_CTRL_COUNTFLAG_Pos 16
382 #define SysTick_CTRL_COUNTFLAG_Msk (1ul << SysTick_CTRL_COUNTFLAG_Pos)
384 #define SysTick_CTRL_CLKSOURCE_Pos 2
385 #define SysTick_CTRL_CLKSOURCE_Msk (1ul << SysTick_CTRL_CLKSOURCE_Pos)
387 #define SysTick_CTRL_TICKINT_Pos 1
388 #define SysTick_CTRL_TICKINT_Msk (1ul << SysTick_CTRL_TICKINT_Pos)
390 #define SysTick_CTRL_ENABLE_Pos 0
391 #define SysTick_CTRL_ENABLE_Msk (1ul << SysTick_CTRL_ENABLE_Pos)
394 #define SysTick_LOAD_RELOAD_Pos 0
395 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos)
398 #define SysTick_VAL_CURRENT_Pos 0
399 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)
402 #define SysTick_CALIB_NOREF_Pos 31
403 #define SysTick_CALIB_NOREF_Msk (1ul << SysTick_CALIB_NOREF_Pos)
405 #define SysTick_CALIB_SKEW_Pos 30
406 #define SysTick_CALIB_SKEW_Msk (1ul << SysTick_CALIB_SKEW_Pos)
408 #define SysTick_CALIB_TENMS_Pos 0
409 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)
426 uint32_t RESERVED0[864];
428 uint32_t RESERVED1[15];
430 uint32_t RESERVED2[15];
432 uint32_t RESERVED3[29];
436 uint32_t RESERVED4[43];
439 uint32_t RESERVED5[6];
455 #define ITM_TPR_PRIVMASK_Pos 0
456 #define ITM_TPR_PRIVMASK_Msk (0xFul << ITM_TPR_PRIVMASK_Pos)
459 #define ITM_TCR_BUSY_Pos 23
460 #define ITM_TCR_BUSY_Msk (1ul << ITM_TCR_BUSY_Pos)
462 #define ITM_TCR_ATBID_Pos 16
463 #define ITM_TCR_ATBID_Msk (0x7Ful << ITM_TCR_ATBID_Pos)
465 #define ITM_TCR_TSPrescale_Pos 8
466 #define ITM_TCR_TSPrescale_Msk (3ul << ITM_TCR_TSPrescale_Pos)
468 #define ITM_TCR_SWOENA_Pos 4
469 #define ITM_TCR_SWOENA_Msk (1ul << ITM_TCR_SWOENA_Pos)
471 #define ITM_TCR_DWTENA_Pos 3
472 #define ITM_TCR_DWTENA_Msk (1ul << ITM_TCR_DWTENA_Pos)
474 #define ITM_TCR_SYNCENA_Pos 2
475 #define ITM_TCR_SYNCENA_Msk (1ul << ITM_TCR_SYNCENA_Pos)
477 #define ITM_TCR_TSENA_Pos 1
478 #define ITM_TCR_TSENA_Msk (1ul << ITM_TCR_TSENA_Pos)
480 #define ITM_TCR_ITMENA_Pos 0
481 #define ITM_TCR_ITMENA_Msk (1ul << ITM_TCR_ITMENA_Pos)
484 #define ITM_IWR_ATVALIDM_Pos 0
485 #define ITM_IWR_ATVALIDM_Msk (1ul << ITM_IWR_ATVALIDM_Pos)
488 #define ITM_IRR_ATREADYM_Pos 0
489 #define ITM_IRR_ATREADYM_Msk (1ul << ITM_IRR_ATREADYM_Pos)
492 #define ITM_IMCR_INTEGRATION_Pos 0
493 #define ITM_IMCR_INTEGRATION_Msk (1ul << ITM_IMCR_INTEGRATION_Pos)
496 #define ITM_LSR_ByteAcc_Pos 2
497 #define ITM_LSR_ByteAcc_Msk (1ul << ITM_LSR_ByteAcc_Pos)
499 #define ITM_LSR_Access_Pos 1
500 #define ITM_LSR_Access_Msk (1ul << ITM_LSR_Access_Pos)
502 #define ITM_LSR_Present_Pos 0
503 #define ITM_LSR_Present_Msk (1ul << ITM_LSR_Present_Pos)
516 #if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
524 #define InterruptType_ICTR_INTLINESNUM_Pos 0
525 #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos)
528 #define InterruptType_ACTLR_DISFOLD_Pos 2
529 #define InterruptType_ACTLR_DISFOLD_Msk (1ul << InterruptType_ACTLR_DISFOLD_Pos)
531 #define InterruptType_ACTLR_DISDEFWBUF_Pos 1
532 #define InterruptType_ACTLR_DISDEFWBUF_Msk (1ul << InterruptType_ACTLR_DISDEFWBUF_Pos)
534 #define InterruptType_ACTLR_DISMCYCINT_Pos 0
535 #define InterruptType_ACTLR_DISMCYCINT_Msk (1ul << InterruptType_ACTLR_DISMCYCINT_Pos)
539 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
552 __IO uint32_t RBAR_A1;
553 __IO uint32_t RASR_A1;
554 __IO uint32_t RBAR_A2;
555 __IO uint32_t RASR_A2;
556 __IO uint32_t RBAR_A3;
557 __IO uint32_t RASR_A3;
561 #define MPU_TYPE_IREGION_Pos 16
562 #define MPU_TYPE_IREGION_Msk (0xFFul << MPU_TYPE_IREGION_Pos)
564 #define MPU_TYPE_DREGION_Pos 8
565 #define MPU_TYPE_DREGION_Msk (0xFFul << MPU_TYPE_DREGION_Pos)
567 #define MPU_TYPE_SEPARATE_Pos 0
568 #define MPU_TYPE_SEPARATE_Msk (1ul << MPU_TYPE_SEPARATE_Pos)
571 #define MPU_CTRL_PRIVDEFENA_Pos 2
572 #define MPU_CTRL_PRIVDEFENA_Msk (1ul << MPU_CTRL_PRIVDEFENA_Pos)
574 #define MPU_CTRL_HFNMIENA_Pos 1
575 #define MPU_CTRL_HFNMIENA_Msk (1ul << MPU_CTRL_HFNMIENA_Pos)
577 #define MPU_CTRL_ENABLE_Pos 0
578 #define MPU_CTRL_ENABLE_Msk (1ul << MPU_CTRL_ENABLE_Pos)
581 #define MPU_RNR_REGION_Pos 0
582 #define MPU_RNR_REGION_Msk (0xFFul << MPU_RNR_REGION_Pos)
585 #define MPU_RBAR_ADDR_Pos 5
586 #define MPU_RBAR_ADDR_Msk (0x7FFFFFFul << MPU_RBAR_ADDR_Pos)
588 #define MPU_RBAR_VALID_Pos 4
589 #define MPU_RBAR_VALID_Msk (1ul << MPU_RBAR_VALID_Pos)
591 #define MPU_RBAR_REGION_Pos 0
592 #define MPU_RBAR_REGION_Msk (0xFul << MPU_RBAR_REGION_Pos)
595 #define MPU_RASR_XN_Pos 28
596 #define MPU_RASR_XN_Msk (1ul << MPU_RASR_XN_Pos)
598 #define MPU_RASR_AP_Pos 24
599 #define MPU_RASR_AP_Msk (7ul << MPU_RASR_AP_Pos)
601 #define MPU_RASR_TEX_Pos 19
602 #define MPU_RASR_TEX_Msk (7ul << MPU_RASR_TEX_Pos)
604 #define MPU_RASR_S_Pos 18
605 #define MPU_RASR_S_Msk (1ul << MPU_RASR_S_Pos)
607 #define MPU_RASR_C_Pos 17
608 #define MPU_RASR_C_Msk (1ul << MPU_RASR_C_Pos)
610 #define MPU_RASR_B_Pos 16
611 #define MPU_RASR_B_Msk (1ul << MPU_RASR_B_Pos)
613 #define MPU_RASR_SRD_Pos 8
614 #define MPU_RASR_SRD_Msk (0xFFul << MPU_RASR_SRD_Pos)
616 #define MPU_RASR_SIZE_Pos 1
617 #define MPU_RASR_SIZE_Msk (0x1Ful << MPU_RASR_SIZE_Pos)
619 #define MPU_RASR_ENA_Pos 0
620 #define MPU_RASR_ENA_Msk (0x1Ful << MPU_RASR_ENA_Pos)
640 #define CoreDebug_DHCSR_DBGKEY_Pos 16
641 #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFul << CoreDebug_DHCSR_DBGKEY_Pos)
643 #define CoreDebug_DHCSR_S_RESET_ST_Pos 25
644 #define CoreDebug_DHCSR_S_RESET_ST_Msk (1ul << CoreDebug_DHCSR_S_RESET_ST_Pos)
646 #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24
647 #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1ul << CoreDebug_DHCSR_S_RETIRE_ST_Pos)
649 #define CoreDebug_DHCSR_S_LOCKUP_Pos 19
650 #define CoreDebug_DHCSR_S_LOCKUP_Msk (1ul << CoreDebug_DHCSR_S_LOCKUP_Pos)
652 #define CoreDebug_DHCSR_S_SLEEP_Pos 18
653 #define CoreDebug_DHCSR_S_SLEEP_Msk (1ul << CoreDebug_DHCSR_S_SLEEP_Pos)
655 #define CoreDebug_DHCSR_S_HALT_Pos 17
656 #define CoreDebug_DHCSR_S_HALT_Msk (1ul << CoreDebug_DHCSR_S_HALT_Pos)
658 #define CoreDebug_DHCSR_S_REGRDY_Pos 16
659 #define CoreDebug_DHCSR_S_REGRDY_Msk (1ul << CoreDebug_DHCSR_S_REGRDY_Pos)
661 #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5
662 #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1ul << CoreDebug_DHCSR_C_SNAPSTALL_Pos)
664 #define CoreDebug_DHCSR_C_MASKINTS_Pos 3
665 #define CoreDebug_DHCSR_C_MASKINTS_Msk (1ul << CoreDebug_DHCSR_C_MASKINTS_Pos)
667 #define CoreDebug_DHCSR_C_STEP_Pos 2
668 #define CoreDebug_DHCSR_C_STEP_Msk (1ul << CoreDebug_DHCSR_C_STEP_Pos)
670 #define CoreDebug_DHCSR_C_HALT_Pos 1
671 #define CoreDebug_DHCSR_C_HALT_Msk (1ul << CoreDebug_DHCSR_C_HALT_Pos)
673 #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0
674 #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1ul << CoreDebug_DHCSR_C_DEBUGEN_Pos)
677 #define CoreDebug_DCRSR_REGWnR_Pos 16
678 #define CoreDebug_DCRSR_REGWnR_Msk (1ul << CoreDebug_DCRSR_REGWnR_Pos)
680 #define CoreDebug_DCRSR_REGSEL_Pos 0
681 #define CoreDebug_DCRSR_REGSEL_Msk (0x1Ful << CoreDebug_DCRSR_REGSEL_Pos)
684 #define CoreDebug_DEMCR_TRCENA_Pos 24
685 #define CoreDebug_DEMCR_TRCENA_Msk (1ul << CoreDebug_DEMCR_TRCENA_Pos)
687 #define CoreDebug_DEMCR_MON_REQ_Pos 19
688 #define CoreDebug_DEMCR_MON_REQ_Msk (1ul << CoreDebug_DEMCR_MON_REQ_Pos)
690 #define CoreDebug_DEMCR_MON_STEP_Pos 18
691 #define CoreDebug_DEMCR_MON_STEP_Msk (1ul << CoreDebug_DEMCR_MON_STEP_Pos)
693 #define CoreDebug_DEMCR_MON_PEND_Pos 17
694 #define CoreDebug_DEMCR_MON_PEND_Msk (1ul << CoreDebug_DEMCR_MON_PEND_Pos)
696 #define CoreDebug_DEMCR_MON_EN_Pos 16
697 #define CoreDebug_DEMCR_MON_EN_Msk (1ul << CoreDebug_DEMCR_MON_EN_Pos)
699 #define CoreDebug_DEMCR_VC_HARDERR_Pos 10
700 #define CoreDebug_DEMCR_VC_HARDERR_Msk (1ul << CoreDebug_DEMCR_VC_HARDERR_Pos)
702 #define CoreDebug_DEMCR_VC_INTERR_Pos 9
703 #define CoreDebug_DEMCR_VC_INTERR_Msk (1ul << CoreDebug_DEMCR_VC_INTERR_Pos)
705 #define CoreDebug_DEMCR_VC_BUSERR_Pos 8
706 #define CoreDebug_DEMCR_VC_BUSERR_Msk (1ul << CoreDebug_DEMCR_VC_BUSERR_Pos)
708 #define CoreDebug_DEMCR_VC_STATERR_Pos 7
709 #define CoreDebug_DEMCR_VC_STATERR_Msk (1ul << CoreDebug_DEMCR_VC_STATERR_Pos)
711 #define CoreDebug_DEMCR_VC_CHKERR_Pos 6
712 #define CoreDebug_DEMCR_VC_CHKERR_Msk (1ul << CoreDebug_DEMCR_VC_CHKERR_Pos)
714 #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5
715 #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1ul << CoreDebug_DEMCR_VC_NOCPERR_Pos)
717 #define CoreDebug_DEMCR_VC_MMERR_Pos 4
718 #define CoreDebug_DEMCR_VC_MMERR_Msk (1ul << CoreDebug_DEMCR_VC_MMERR_Pos)
720 #define CoreDebug_DEMCR_VC_CORERESET_Pos 0
721 #define CoreDebug_DEMCR_VC_CORERESET_Msk (1ul << CoreDebug_DEMCR_VC_CORERESET_Pos)
726 #define SCS_BASE (0xE000E000)
727 #define ITM_BASE (0xE0000000)
728 #define CoreDebug_BASE (0xE000EDF0)
729 #define SysTick_BASE (SCS_BASE + 0x0010)
730 #define NVIC_BASE (SCS_BASE + 0x0100)
731 #define SCB_BASE (SCS_BASE + 0x0D00)
733 #define InterruptType ((InterruptType_Type *) SCS_BASE)
734 #define SCB ((SCB_Type *) SCB_BASE)
735 #define SysTick ((SysTick_Type *) SysTick_BASE)
736 #define NVIC ((NVIC_Type *) NVIC_BASE)
737 #define ITM ((ITM_Type *) ITM_BASE)
738 #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE)
740 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
741 #define MPU_BASE (SCS_BASE + 0x0D90)
742 #define MPU ((MPU_Type*) MPU_BASE)
752 #if defined ( __CC_ARM )
754 #define __INLINE __inline
756 #elif defined ( __ICCARM__ )
758 #define __INLINE inline
760 #elif defined ( __GNUC__ )
762 #define __INLINE inline
764 #elif defined ( __TASKING__ )
766 #define __INLINE inline
773 #if defined ( __CC_ARM )
776 #define __enable_fault_irq __enable_fiq
777 #define __disable_fault_irq __disable_fiq
783 #define __ISB() __isb(0)
784 #define __DSB() __dsb(0)
785 #define __DMB() __dmb(0)
787 #define __RBIT __rbit
788 #define __LDREXB(ptr) ((unsigned char ) __ldrex(ptr))
789 #define __LDREXH(ptr) ((unsigned short) __ldrex(ptr))
790 #define __LDREXW(ptr) ((unsigned int ) __ldrex(ptr))
791 #define __STREXB(value, ptr) __strex(value, ptr)
792 #define __STREXH(value, ptr) __strex(value, ptr)
793 #define __STREXW(value, ptr) __strex(value, ptr)
809 extern uint32_t __get_PSP(
void);
819 extern void __set_PSP(uint32_t topOfProcStack);
829 extern uint32_t __get_MSP(
void);
839 extern void __set_MSP(uint32_t topOfMainStack);
849 extern uint32_t __REV16(uint16_t value);
859 extern int32_t __REVSH(int16_t value);
862 #if (__ARMCC_VERSION < 400000)
869 extern void __CLREX(
void);
878 extern uint32_t __get_BASEPRI(
void);
887 extern void __set_BASEPRI(uint32_t basePri);
896 extern uint32_t __get_PRIMASK(
void);
905 extern void __set_PRIMASK(uint32_t priMask);
914 extern uint32_t __get_FAULTMASK(
void);
923 extern void __set_FAULTMASK(uint32_t faultMask);
932 extern uint32_t __get_CONTROL(
void);
941 extern void __set_CONTROL(uint32_t control);
950 #define __CLREX __clrex
959 static __INLINE uint32_t __get_BASEPRI(
void)
961 register uint32_t __regBasePri __ASM(
"basepri");
962 return(__regBasePri);
972 static __INLINE
void __set_BASEPRI(uint32_t basePri)
974 register uint32_t __regBasePri __ASM(
"basepri");
975 __regBasePri = (basePri & 0xff);
985 static __INLINE uint32_t __get_PRIMASK(
void)
987 register uint32_t __regPriMask __ASM(
"primask");
988 return(__regPriMask);
998 static __INLINE
void __set_PRIMASK(uint32_t priMask)
1000 register uint32_t __regPriMask __ASM(
"primask");
1001 __regPriMask = (priMask);
1011 static __INLINE uint32_t __get_FAULTMASK(
void)
1013 register uint32_t __regFaultMask __ASM(
"faultmask");
1014 return(__regFaultMask);
1024 static __INLINE
void __set_FAULTMASK(uint32_t faultMask)
1026 register uint32_t __regFaultMask __ASM(
"faultmask");
1027 __regFaultMask = (faultMask & 1);
1037 static __INLINE uint32_t __get_CONTROL(
void)
1039 register uint32_t __regControl __ASM(
"control");
1040 return(__regControl);
1050 static __INLINE
void __set_CONTROL(uint32_t control)
1052 register uint32_t __regControl __ASM(
"control");
1053 __regControl = control;
1060 #elif (defined (__ICCARM__))
1063 #define __enable_irq __enable_interrupt
1064 #define __disable_irq __disable_interrupt
1066 static __INLINE void __enable_fault_irq() { __ASM ("cpsie f"); }
1067 static __INLINE
void __disable_fault_irq() { __ASM (
"cpsid f"); }
1069 #define __NOP __no_operation
1070 static __INLINE void __WFI() { __ASM ("wfi"); }
1071 static __INLINE
void __WFE() { __ASM (
"wfe"); }
1072 static __INLINE
void __SEV() { __ASM (
"sev"); }
1073 static __INLINE
void __CLREX() { __ASM (
"clrex"); }
1095 extern uint32_t __get_PSP(
void);
1105 extern void __set_PSP(uint32_t topOfProcStack);
1115 extern uint32_t __get_MSP(
void);
1125 extern void __set_MSP(uint32_t topOfMainStack);
1135 extern uint32_t __REV16(uint16_t value);
1145 extern uint32_t __RBIT(uint32_t value);
1155 extern uint8_t __LDREXB(uint8_t *addr);
1165 extern uint16_t __LDREXH(uint16_t *addr);
1175 extern uint32_t __LDREXW(uint32_t *addr);
1186 extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
1197 extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
1208 extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
1212 #elif (defined (__GNUC__))
1215 static __INLINE
void __enable_irq() { __ASM
volatile (
"cpsie i"); }
1216 static __INLINE
void __disable_irq() { __ASM
volatile (
"cpsid i"); }
1218 static __INLINE
void __enable_fault_irq() { __ASM
volatile (
"cpsie f"); }
1219 static __INLINE
void __disable_fault_irq() { __ASM
volatile (
"cpsid f"); }
1221 static __INLINE
void __NOP() { __ASM
volatile (
"nop"); }
1222 static __INLINE
void __WFI() { __ASM
volatile (
"wfi"); }
1223 static __INLINE
void __WFE() { __ASM
volatile (
"wfe"); }
1224 static __INLINE
void __SEV() { __ASM
volatile (
"sev"); }
1225 static __INLINE
void __ISB() { __ASM
volatile (
"isb"); }
1226 static __INLINE
void __DSB() { __ASM
volatile (
"dsb"); }
1227 static __INLINE
void __DMB() { __ASM
volatile (
"dmb"); }
1228 static __INLINE
void __CLREX() { __ASM
volatile (
"clrex"); }
1238 extern uint32_t __get_PSP(
void);
1248 extern void __set_PSP(uint32_t topOfProcStack);
1258 extern uint32_t __get_MSP(
void);
1268 extern void __set_MSP(uint32_t topOfMainStack);
1277 extern uint32_t __get_BASEPRI(
void);
1286 extern void __set_BASEPRI(uint32_t basePri);
1295 extern uint32_t __get_PRIMASK(
void);
1304 extern void __set_PRIMASK(uint32_t priMask);
1313 extern uint32_t __get_FAULTMASK(
void);
1322 extern void __set_FAULTMASK(uint32_t faultMask);
1331 extern uint32_t __get_CONTROL(
void);
1340 extern void __set_CONTROL(uint32_t control);
1350 extern uint32_t __REV(uint32_t value);
1360 extern uint32_t __REV16(uint16_t value);
1370 extern int32_t __REVSH(int16_t value);
1380 extern uint32_t __RBIT(uint32_t value);
1390 extern uint8_t __LDREXB(uint8_t *addr);
1400 extern uint16_t __LDREXH(uint16_t *addr);
1410 extern uint32_t __LDREXW(uint32_t *addr);
1421 extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
1432 extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
1443 extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
1446 #elif (defined (__TASKING__))
1480 static __INLINE
void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1483 uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);
1485 reg_value =
SCB->AIRCR;
1487 reg_value = (reg_value |
1489 (PriorityGroupTmp << 8));
1490 SCB->AIRCR = reg_value;
1501 static __INLINE uint32_t NVIC_GetPriorityGrouping(
void)
1516 NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(
IRQn) & 0x1F));
1527 static __INLINE
void NVIC_DisableIRQ(
IRQn_Type IRQn)
1529 NVIC->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(
IRQn) & 0x1F));
1541 static __INLINE uint32_t NVIC_GetPendingIRQ(
IRQn_Type IRQn)
1543 return((uint32_t) ((
NVIC->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
1554 static __INLINE
void NVIC_SetPendingIRQ(
IRQn_Type IRQn)
1556 NVIC->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(
IRQn) & 0x1F));
1567 static __INLINE
void NVIC_ClearPendingIRQ(
IRQn_Type IRQn)
1569 NVIC->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(
IRQn) & 0x1F));
1581 static __INLINE uint32_t NVIC_GetActive(
IRQn_Type IRQn)
1583 return((uint32_t)((
NVIC->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
1598 static __INLINE
void NVIC_SetPriority(
IRQn_Type IRQn, uint32_t priority)
1621 static __INLINE uint32_t NVIC_GetPriority(
IRQn_Type IRQn)
1646 static __INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
1648 uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);
1649 uint32_t PreemptPriorityBits;
1650 uint32_t SubPriorityBits;
1656 ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
1657 ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
1677 static __INLINE
void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority)
1679 uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);
1680 uint32_t PreemptPriorityBits;
1681 uint32_t SubPriorityBits;
1683 PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1686 *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
1687 *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
1694 #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
1706 static __INLINE uint32_t SysTick_Config(uint32_t ticks)
1711 NVIC_SetPriority (
SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
1731 static __INLINE
void NVIC_SystemReset(
void)
1755 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5
1768 static __INLINE uint32_t ITM_SendChar (uint32_t ch)
1772 (
ITM->TER & (1ul << 0) ) )
1774 while (
ITM->PORT[0].u32 == 0);
1775 ITM->PORT[0].u8 = (uint8_t) ch;
1790 static __INLINE
int ITM_ReceiveChar (
void) {
1810 static __INLINE
int ITM_CheckChar (
void) {