24 #ifndef __CM3_CORE_H__
25 #define __CM3_CORE_H__
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)
92 #if defined (__ICCARM__)
93 #include <intrinsics.h>
97 #ifndef __NVIC_PRIO_BITS
98 #define __NVIC_PRIO_BITS 4
113 #define __I volatile const
116 #define __IO volatile
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
387 #define SysTick_LOAD_RELOAD_Pos 0
388 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFul << SysTick_LOAD_RELOAD_Pos)
391 #define SysTick_VAL_CURRENT_Pos 0
392 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFul << SysTick_VAL_CURRENT_Pos)
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)
447 #define ITM_TPR_PRIVMASK_Pos 0
448 #define ITM_TPR_PRIVMASK_Msk (0xFul << ITM_TPR_PRIVMASK_Pos)
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)
476 #define ITM_IWR_ATVALIDM_Pos 0
477 #define ITM_IWR_ATVALIDM_Msk (1ul << ITM_IWR_ATVALIDM_Pos)
480 #define ITM_IRR_ATREADYM_Pos 0
481 #define ITM_IRR_ATREADYM_Msk (1ul << ITM_IRR_ATREADYM_Pos)
484 #define ITM_IMCR_INTEGRATION_Pos 0
485 #define ITM_IMCR_INTEGRATION_Msk (1ul << ITM_IMCR_INTEGRATION_Pos)
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)
507 #if ((defined __CM3_REV) && (__CM3_REV >= 0x200))
515 #define InterruptType_ICTR_INTLINESNUM_Pos 0
516 #define InterruptType_ICTR_INTLINESNUM_Msk (0x1Ful << InterruptType_ICTR_INTLINESNUM_Pos)
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)
530 #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
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)
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)
571 #define MPU_RNR_REGION_Pos 0
572 #define MPU_RNR_REGION_Msk (0xFFul << MPU_RNR_REGION_Pos)
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)
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)
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)
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)
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)
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)
741 #if defined ( __CC_ARM )
743 #define __INLINE __inline
745 #elif defined ( __ICCARM__ )
747 #define __INLINE inline
749 #elif defined ( __GNUC__ )
751 #define __INLINE inline
753 #elif defined ( __TASKING__ )
755 #define __INLINE inline
762 #if defined ( __CC_ARM )
765 #define __enable_fault_irq __enable_fiq
766 #define __disable_fault_irq __disable_fiq
772 #define __ISB() __isb(0)
773 #define __DSB() __dsb(0)
774 #define __DMB() __dmb(0)
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)
808 extern void __set_PSP(
uint32_t topOfProcStack);
828 extern void __set_MSP(
uint32_t topOfMainStack);
851 #if (__ARMCC_VERSION < 400000)
858 extern void __CLREX(
void);
867 extern uint32_t __get_BASEPRI(
void);
876 extern void __set_BASEPRI(
uint32_t basePri);
885 extern uint32_t __get_PRIMASK(
void);
894 extern void __set_PRIMASK(
uint32_t priMask);
903 extern uint32_t __get_FAULTMASK(
void);
912 extern void __set_FAULTMASK(
uint32_t faultMask);
921 extern uint32_t __get_CONTROL(
void);
930 extern void __set_CONTROL(
uint32_t control);
939 #define __CLREX __clrex
948 static __INLINE
uint32_t __get_BASEPRI(
void)
950 register uint32_t __regBasePri __ASM(
"basepri");
951 return(__regBasePri);
961 static __INLINE
void __set_BASEPRI(
uint32_t basePri)
963 register uint32_t __regBasePri __ASM(
"basepri");
964 __regBasePri = (basePri & 0xff);
974 static __INLINE
uint32_t __get_PRIMASK(
void)
976 register uint32_t __regPriMask __ASM(
"primask");
977 return(__regPriMask);
987 static __INLINE
void __set_PRIMASK(
uint32_t priMask)
989 register uint32_t __regPriMask __ASM(
"primask");
990 __regPriMask = (priMask);
1000 static __INLINE
uint32_t __get_FAULTMASK(
void)
1002 register uint32_t __regFaultMask __ASM(
"faultmask");
1003 return(__regFaultMask);
1013 static __INLINE
void __set_FAULTMASK(
uint32_t faultMask)
1015 register uint32_t __regFaultMask __ASM(
"faultmask");
1016 __regFaultMask = (faultMask & 1);
1026 static __INLINE
uint32_t __get_CONTROL(
void)
1028 register uint32_t __regControl __ASM(
"control");
1029 return(__regControl);
1039 static __INLINE
void __set_CONTROL(
uint32_t control)
1041 register uint32_t __regControl __ASM(
"control");
1042 __regControl = control;
1049 #elif (defined (__ICCARM__))
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"); }
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"); }
1094 extern void __set_PSP(
uint32_t topOfProcStack);
1114 extern void __set_MSP(
uint32_t topOfMainStack);
1201 #elif (defined (__GNUC__))
1204 static __INLINE
void __enable_irq() { __ASM
volatile (
"cpsie i"); }
1205 static __INLINE
void __disable_irq() { __ASM
volatile (
"cpsid i"); }
1207 static __INLINE
void __enable_fault_irq() { __ASM
volatile (
"cpsie f"); }
1208 static __INLINE
void __disable_fault_irq() { __ASM
volatile (
"cpsid f"); }
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"); }
1237 extern void __set_PSP(
uint32_t topOfProcStack);
1257 extern void __set_MSP(
uint32_t topOfMainStack);
1266 extern uint32_t __get_BASEPRI(
void);
1275 extern void __set_BASEPRI(
uint32_t basePri);
1284 extern uint32_t __get_PRIMASK(
void);
1293 extern void __set_PRIMASK(
uint32_t priMask);
1302 extern uint32_t __get_FAULTMASK(
void);
1311 extern void __set_FAULTMASK(
uint32_t faultMask);
1320 extern uint32_t __get_CONTROL(
void);
1329 extern void __set_CONTROL(
uint32_t control);
1435 #elif (defined (__TASKING__))
1468 static __INLINE
void NVIC_SetPriorityGrouping(
uint32_t PriorityGroup)
1471 uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);
1473 reg_value =
SCB->AIRCR;
1475 reg_value = (reg_value |
1477 (PriorityGroupTmp << 8));
1478 SCB->AIRCR = reg_value;
1489 static __INLINE
uint32_t NVIC_GetPriorityGrouping(
void)
1502 static __INLINE
void NVIC_EnableIRQ(IRQn_Type IRQn)
1515 static __INLINE
void NVIC_DisableIRQ(IRQn_Type IRQn)
1529 static __INLINE
uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
1542 static __INLINE
void NVIC_SetPendingIRQ(IRQn_Type IRQn)
1555 static __INLINE
void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1569 static __INLINE
uint32_t NVIC_GetActive(IRQn_Type IRQn)
1586 static __INLINE
void NVIC_SetPriority(IRQn_Type IRQn,
uint32_t priority)
1609 static __INLINE
uint32_t NVIC_GetPriority(IRQn_Type IRQn)
1636 uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);
1644 ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) |
1645 ((SubPriority & ((1 << (SubPriorityBits )) - 1)))
1667 uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);
1671 PreemptPriorityBits = ((7 - PriorityGroupTmp) > __NVIC_PRIO_BITS) ? __NVIC_PRIO_BITS : 7 - PriorityGroupTmp;
1674 *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1);
1675 *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1);
1682 #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
1699 NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
1719 static __INLINE
void NVIC_SystemReset(
void)
1743 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5
1756 static __INLINE uint32_t ITM_SendChar (uint32_t ch)
1760 (
ITM->TER & (1ul << 0) ) )
1762 while (
ITM->PORT[0].u32 == 0);
1778 static __INLINE
int ITM_ReceiveChar (
void) {
1798 static __INLINE
int ITM_CheckChar (
void) {
#define SysTick_CTRL_CLKSOURCE_Msk
#define SysTick_CTRL_TICKINT_Msk
#define CoreDebug_DEMCR_TRCENA_Msk
#define SCB_AIRCR_PRIGROUP_Pos
volatile int ITM_RxBuffer
#define SCB_AIRCR_VECTKEY_Pos
#define SysTick_LOAD_RELOAD_Msk
#define SysTick_CTRL_ENABLE_Msk
#define ITM_TCR_ITMENA_Msk
unsigned short int uint16_t
#define SCB_AIRCR_PRIGROUP_Msk
#define ITM_RXBUFFER_EMPTY
#define SCB_AIRCR_VECTKEY_Msk
#define SCB_AIRCR_SYSRESETREQ_Msk