23 #if defined ( __ICCARM__ ) 24 #pragma system_include 31 #ifndef __CORE_CM0_H_GENERIC 32 #define __CORE_CM0_H_GENERIC 75 #define __CM0_CMSIS_VERSION_MAIN (0x02) 76 #define __CM0_CMSIS_VERSION_SUB (0x10) 77 #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16) | __CM0_CMSIS_VERSION_SUB) 79 #define __CORTEX_M (0x00) 82 #if defined ( __CC_ARM ) 84 #define __INLINE __inline 86 #elif defined ( __ICCARM__ ) 88 #define __INLINE inline 90 #elif defined ( __GNUC__ ) 92 #define __INLINE inline 94 #elif defined ( __TASKING__ ) 96 #define __INLINE inline 103 #if defined ( __CC_ARM ) 104 #if defined __TARGET_FPU_VFP 105 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" 107 #elif defined ( __ICCARM__ ) 108 #if defined __ARMVFP__ 109 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" 112 #elif defined ( __GNUC__ ) 113 #if defined (__VFP_FP__) && !defined(__SOFTFP__) 114 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" 117 #elif defined ( __TASKING__ ) 127 #ifndef __CMSIS_GENERIC 129 #ifndef __CORE_CM0_H_DEPENDANT 130 #define __CORE_CM0_H_DEPENDANT 133 #if defined __CHECK_DEVICE_DEFINES 135 #define __CM0_REV 0x0000 136 #warning "__CM0_REV 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!" 154 #define __I volatile const 157 #define __IO volatile 186 #if (__CORTEX_M != 0x04) 187 uint32_t _reserved0:27;
189 uint32_t _reserved0:16;
191 uint32_t _reserved1:7;
210 uint32_t _reserved0:23;
223 #if (__CORTEX_M != 0x04) 224 uint32_t _reserved0:15;
226 uint32_t _reserved0:7;
228 uint32_t _reserved1:4;
251 uint32_t _reserved0:29;
270 uint32_t RESERVED0[31];
272 uint32_t RSERVED1[31];
274 uint32_t RESERVED2[31];
276 uint32_t RESERVED3[31];
277 uint32_t RESERVED4[64];
306 #define SCB_CPUID_IMPLEMENTER_Pos 24 307 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) 309 #define SCB_CPUID_VARIANT_Pos 20 310 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) 312 #define SCB_CPUID_ARCHITECTURE_Pos 16 313 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) 315 #define SCB_CPUID_PARTNO_Pos 4 316 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) 318 #define SCB_CPUID_REVISION_Pos 0 319 #define SCB_CPUID_REVISION_Msk (0xFUL << SCB_CPUID_REVISION_Pos) 322 #define SCB_ICSR_NMIPENDSET_Pos 31 323 #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) 325 #define SCB_ICSR_PENDSVSET_Pos 28 326 #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) 328 #define SCB_ICSR_PENDSVCLR_Pos 27 329 #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) 331 #define SCB_ICSR_PENDSTSET_Pos 26 332 #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) 334 #define SCB_ICSR_PENDSTCLR_Pos 25 335 #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) 337 #define SCB_ICSR_ISRPREEMPT_Pos 23 338 #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) 340 #define SCB_ICSR_ISRPENDING_Pos 22 341 #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) 343 #define SCB_ICSR_VECTPENDING_Pos 12 344 #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) 346 #define SCB_ICSR_VECTACTIVE_Pos 0 347 #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL << SCB_ICSR_VECTACTIVE_Pos) 350 #define SCB_AIRCR_VECTKEY_Pos 16 351 #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) 353 #define SCB_AIRCR_VECTKEYSTAT_Pos 16 354 #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) 356 #define SCB_AIRCR_ENDIANESS_Pos 15 357 #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) 359 #define SCB_AIRCR_SYSRESETREQ_Pos 2 360 #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) 362 #define SCB_AIRCR_VECTCLRACTIVE_Pos 1 363 #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) 366 #define SCB_SCR_SEVONPEND_Pos 4 367 #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) 369 #define SCB_SCR_SLEEPDEEP_Pos 2 370 #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) 372 #define SCB_SCR_SLEEPONEXIT_Pos 1 373 #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) 376 #define SCB_CCR_STKALIGN_Pos 9 377 #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) 379 #define SCB_CCR_UNALIGN_TRP_Pos 3 380 #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) 383 #define SCB_SHCSR_SVCALLPENDED_Pos 15 384 #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) 406 #define SysTick_CTRL_COUNTFLAG_Pos 16 407 #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) 409 #define SysTick_CTRL_CLKSOURCE_Pos 2 410 #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) 412 #define SysTick_CTRL_TICKINT_Pos 1 413 #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) 415 #define SysTick_CTRL_ENABLE_Pos 0 416 #define SysTick_CTRL_ENABLE_Msk (1UL << SysTick_CTRL_ENABLE_Pos) 419 #define SysTick_LOAD_RELOAD_Pos 0 420 #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL << SysTick_LOAD_RELOAD_Pos) 423 #define SysTick_VAL_CURRENT_Pos 0 424 #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) 427 #define SysTick_CALIB_NOREF_Pos 31 428 #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) 430 #define SysTick_CALIB_SKEW_Pos 30 431 #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) 433 #define SysTick_CALIB_TENMS_Pos 0 434 #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL << SysTick_VAL_CURRENT_Pos) 453 #define SCS_BASE (0xE000E000UL) 454 #define CoreDebug_BASE (0xE000EDF0UL) 455 #define SysTick_BASE (SCS_BASE + 0x0010UL) 456 #define NVIC_BASE (SCS_BASE + 0x0100UL) 457 #define SCB_BASE (SCS_BASE + 0x0D00UL) 459 #define SCB ((SCB_Type *) SCB_BASE ) 460 #define SysTick ((SysTick_Type *) SysTick_BASE ) 461 #define NVIC ((NVIC_Type *) NVIC_BASE ) 488 #define _BIT_SHIFT(IRQn) ( (((uint32_t)(IRQn) ) & 0x03) * 8 ) 489 #define _SHP_IDX(IRQn) ( ((((uint32_t)(IRQn) & 0x0F)-8) >> 2) ) 490 #define _IP_IDX(IRQn) ( ((uint32_t)(IRQn) >> 2) ) 500 static __INLINE
void NVIC_EnableIRQ(IRQn_Type
IRQn)
502 NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
513 static __INLINE
void NVIC_DisableIRQ(IRQn_Type
IRQn)
515 NVIC->ICER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
528 static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
530 return((uint32_t) ((
NVIC->ISPR[0] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));
541 static __INLINE
void NVIC_SetPendingIRQ(IRQn_Type IRQn)
543 NVIC->ISPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
554 static __INLINE
void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
556 NVIC->ICPR[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
571 static __INLINE
void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
574 SCB->SHP[_SHP_IDX(IRQn)] = (
SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
577 NVIC->IP[_IP_IDX(IRQn)] = (
NVIC->IP[_IP_IDX(IRQn)] & ~(0xFF << _BIT_SHIFT(IRQn))) |
594 static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
598 return((uint32_t)((
SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 -
__NVIC_PRIO_BITS))); }
600 return((uint32_t)((
NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) >> (8 -
__NVIC_PRIO_BITS))); }
608 static __INLINE
void NVIC_SystemReset(
void)
628 #if (__Vendor_SysTickConfig == 0) 639 static __INLINE uint32_t SysTick_Config(uint32_t ticks)
__I uint32_t CALIB
Definition: core_cm0.h:402
__IO uint32_t ICSR
Definition: core_cm0.h:295
#define ISR(func)
Define service routine.
Definition: interrupt_sam_nvic.h:65
#define SysTick_CTRL_TICKINT_Msk
Definition: core_cm0.h:413
Union type to access the Application Program Status Register (APSR).
Definition: core_cm0.h:182
IRQn
Definition: ARMCM0.h:35
uint32_t w
Definition: core_cm0.h:253
Structure type to access the System Timer (SysTick).
Definition: core_cm0.h:397
#define NVIC
Definition: core_cm0.h:461
__IO uint32_t AIRCR
Definition: core_cm0.h:297
Structure type to access the System Control Block (SCB).
Definition: core_cm0.h:292
#define SysTick
Definition: core_cm0.h:460
#define SCB
Definition: core_cm0.h:459
__IO uint32_t CTRL
Definition: core_cm0.h:399
uint32_t w
Definition: core_cm0.h:212
__IO uint32_t SCR
Definition: core_cm0.h:298
__IO uint32_t VAL
Definition: core_cm0.h:401
__IO uint32_t SHCSR
Definition: core_cm0.h:302
#define SCB_AIRCR_SYSRESETREQ_Msk
Definition: core_cm0.h:360
Union type to access the Control Registers (CONTROL).
Definition: core_cm0.h:244
#define SysTick_CTRL_ENABLE_Msk
Definition: core_cm0.h:416
__IO uint32_t LOAD
Definition: core_cm0.h:400
#define SysTick_CTRL_CLKSOURCE_Msk
Definition: core_cm0.h:410
#define __IO
Definition: core_cm0.h:157
Union type to access the Interrupt Program Status Register (IPSR).
Definition: core_cm0.h:205
#define __I
Definition: core_cm0.h:154
uint32_t w
Definition: core_cm0.h:199
__I uint32_t CPUID
Definition: core_cm0.h:294
#define __NVIC_PRIO_BITS
Definition: ARMCM0.h:62
Structure type to access the Nested Vectored Interrupt Controller (NVIC).
Definition: core_cm0.h:267
CMSIS Cortex-M Core Instruction Access Header File.
#define SCB_AIRCR_VECTKEY_Pos
Definition: core_cm0.h:350
#define SysTick_LOAD_RELOAD_Msk
Definition: core_cm0.h:420
Union type to access the Special-Purpose Program Status Registers (xPSR).
Definition: core_cm0.h:218
uint32_t w
Definition: core_cm0.h:238
CMSIS Cortex-M Core Function Access Header File.
__IO uint32_t CCR
Definition: core_cm0.h:299