См. документацию.
23 #if defined ( __ICCARM__ )
24 #pragma system_include
31 #ifndef __CORE_CM0PLUS_H_GENERIC
32 #define __CORE_CM0PLUS_H_GENERIC
56 #define __CM0PLUS_CMSIS_VERSION_MAIN (0x03)
57 #define __CM0PLUS_CMSIS_VERSION_SUB (0x01)
58 #define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16) | \
59 __CM0PLUS_CMSIS_VERSION_SUB)
61 #define __CORTEX_M (0x00)
64 #if defined ( __CC_ARM )
66 #define __INLINE __inline
67 #define __STATIC_INLINE static __inline
69 #elif defined ( __ICCARM__ )
71 #define __INLINE inline
72 #define __STATIC_INLINE static inline
74 #elif defined ( __GNUC__ )
76 #define __INLINE inline
77 #define __STATIC_INLINE static inline
79 #elif defined ( __TASKING__ )
81 #define __INLINE inline
82 #define __STATIC_INLINE static inline
90 #if defined ( __CC_ARM )
91 #if defined __TARGET_FPU_VFP
92 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
95 #elif defined ( __ICCARM__ )
96 #if defined __ARMVFP__
97 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
100 #elif defined ( __GNUC__ )
101 #if defined (__VFP_FP__) && !defined(__SOFTFP__)
102 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
105 #elif defined ( __TASKING__ )
106 #if defined __FPU_VFP__
107 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
117 #ifndef __CMSIS_GENERIC
119 #ifndef __CORE_CM0PLUS_H_DEPENDANT
120 #define __CORE_CM0PLUS_H_DEPENDANT
123 #if defined __CHECK_DEVICE_DEFINES
124 #ifndef __CM0PLUS_REV
125 #define __CM0PLUS_REV 0x0000
126 #warning "__CM0PLUS_REV not defined in device header file; using default!"
129 #ifndef __MPU_PRESENT
130 #define __MPU_PRESENT 0
131 #warning "__MPU_PRESENT not defined in device header file; using default!"
134 #ifndef __VTOR_PRESENT
135 #define __VTOR_PRESENT 0
136 #warning "__VTOR_PRESENT not defined in device header file; using default!"
139 #ifndef __NVIC_PRIO_BITS
140 #define __NVIC_PRIO_BITS 2
141 #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
144 #ifndef __Vendor_SysTickConfig
145 #define __Vendor_SysTickConfig 0
146 #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
161 #define __I volatile const
164 #define __IO volatile
195 #if (__CORTEX_M != 0x04)
232 #if (__CORTEX_M != 0x04)
305 #if (__VTOR_PRESENT == 1)
319 #define SCB_CPUID_IMPLEMENTER_Pos 24
320 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)
322 #define SCB_CPUID_VARIANT_Pos 20
323 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos)
325 #define SCB_CPUID_ARCHITECTURE_Pos 16
326 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)
328 #define SCB_CPUID_PARTNO_Pos 4
329 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos)
331 #define SCB_CPUID_REVISION_Pos 0
332 #define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos)
335 #define SCB_ICSR_NMIPENDSET_Pos 31
336 #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos)
338 #define SCB_ICSR_PENDSVSET_Pos 28
339 #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos)
341 #define SCB_ICSR_PENDSVCLR_Pos 27
342 #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos)
344 #define SCB_ICSR_PENDSTSET_Pos 26
345 #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos)
347 #define SCB_ICSR_PENDSTCLR_Pos 25
348 #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos)
350 #define SCB_ICSR_ISRPREEMPT_Pos 23
351 #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos)
353 #define SCB_ICSR_ISRPENDING_Pos 22
354 #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos)
356 #define SCB_ICSR_VECTPENDING_Pos 12
357 #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)
359 #define SCB_ICSR_VECTACTIVE_Pos 0
360 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos)
362 #if (__VTOR_PRESENT == 1)
364 #define SCB_VTOR_TBLOFF_Pos 7
365 #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos)
369 #define SCB_AIRCR_VECTKEY_Pos 16
370 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)
372 #define SCB_AIRCR_VECTKEYSTAT_Pos 16
373 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)
375 #define SCB_AIRCR_ENDIANESS_Pos 15
376 #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos)
378 #define SCB_AIRCR_SYSRESETREQ_Pos 2
379 #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos)
381 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1
382 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)
385 #define SCB_SCR_SEVONPEND_Pos 4
386 #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos)
388 #define SCB_SCR_SLEEPDEEP_Pos 2
389 #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos)
391 #define SCB_SCR_SLEEPONEXIT_Pos 1
392 #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos)
395 #define SCB_CCR_STKALIGN_Pos 9
396 #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos)
398 #define SCB_CCR_UNALIGN_TRP_Pos 3
399 #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos)
402 #define SCB_SHCSR_SVCALLPENDED_Pos 15
403 #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos)
425 #define SysTick_CTRL_COUNTFLAG_Pos 16
426 #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos)
428 #define SysTick_CTRL_CLKSOURCE_Pos 2
429 #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos)
431 #define SysTick_CTRL_TICKINT_Pos 1
432 #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos)
434 #define SysTick_CTRL_ENABLE_Pos 0
435 #define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos)
438 #define SysTick_LOAD_RELOAD_Pos 0
439 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos)
442 #define SysTick_VAL_CURRENT_Pos 0
443 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)
446 #define SysTick_CALIB_NOREF_Pos 31
447 #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos)
449 #define SysTick_CALIB_SKEW_Pos 30
450 #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos)
452 #define SysTick_CALIB_TENMS_Pos 0
453 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos)
457 #if (__MPU_PRESENT == 1)
476 #define MPU_TYPE_IREGION_Pos 16
477 #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos)
479 #define MPU_TYPE_DREGION_Pos 8
480 #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos)
482 #define MPU_TYPE_SEPARATE_Pos 0
483 #define MPU_TYPE_SEPARATE_Msk (1UL << MPU_TYPE_SEPARATE_Pos)
486 #define MPU_CTRL_PRIVDEFENA_Pos 2
487 #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos)
489 #define MPU_CTRL_HFNMIENA_Pos 1
490 #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos)
492 #define MPU_CTRL_ENABLE_Pos 0
493 #define MPU_CTRL_ENABLE_Msk (1UL << MPU_CTRL_ENABLE_Pos)
496 #define MPU_RNR_REGION_Pos 0
497 #define MPU_RNR_REGION_Msk (0xFFUL << MPU_RNR_REGION_Pos)
500 #define MPU_RBAR_ADDR_Pos 8
501 #define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos)
503 #define MPU_RBAR_VALID_Pos 4
504 #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos)
506 #define MPU_RBAR_REGION_Pos 0
507 #define MPU_RBAR_REGION_Msk (0xFUL << MPU_RBAR_REGION_Pos)
510 #define MPU_RASR_ATTRS_Pos 16
511 #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos)
513 #define MPU_RASR_XN_Pos 28
514 #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos)
516 #define MPU_RASR_AP_Pos 24
517 #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos)
519 #define MPU_RASR_TEX_Pos 19
520 #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos)
522 #define MPU_RASR_S_Pos 18
523 #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos)
525 #define MPU_RASR_C_Pos 17
526 #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos)
528 #define MPU_RASR_B_Pos 16
529 #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos)
531 #define MPU_RASR_SRD_Pos 8
532 #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos)
534 #define MPU_RASR_SIZE_Pos 1
535 #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos)
537 #define MPU_RASR_ENABLE_Pos 0
538 #define MPU_RASR_ENABLE_Msk (1UL << MPU_RASR_ENABLE_Pos)
561 #define SCS_BASE (0xE000E000UL)
562 #define SysTick_BASE (SCS_BASE + 0x0010UL)
563 #define NVIC_BASE (SCS_BASE + 0x0100UL)
564 #define SCB_BASE (SCS_BASE + 0x0D00UL)
566 #define SCB ((SCB_Type *) SCB_BASE )
567 #define SysTick ((SysTick_Type *) SysTick_BASE )
568 #define NVIC ((NVIC_Type *) NVIC_BASE )
570 #if (__MPU_PRESENT == 1)
571 #define MPU_BASE (SCS_BASE + 0x0D90UL)
572 #define MPU ((MPU_Type *) MPU_BASE )
600 #define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 )
601 #define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) )
602 #define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) )
735 #if (__Vendor_SysTickConfig == 0)