22#ifndef _mcci_arm_cm0plus_h_
23#define _mcci_arm_cm0plus_h_
27#ifndef _mcci_bootloader_bits_h_
45#define MCCI_CM0PLUS_SYSM_APSR UINT32_C(0x00)
46#define MCCI_CM0PLUS_SYSM_IAPSR UINT32_C(0x01)
47#define MCCI_CM0PLUS_SYSM_EAPSR UINT32_C(0x02)
48#define MCCI_CM0PLUS_SYSM_XPSR UINT32_C(0x03)
49#define MCCI_CM0PLUS_SYSM_IPSR UINT32_C(0x05)
50#define MCCI_CM0PLUS_SYSM_EPSR UINT32_C(0x06)
51#define MCCI_CM0PLUS_SYSM_IEPSR UINT32_C(0x07)
52#define MCCI_CM0PLUS_SYSM_MSP UINT32_C(0x08)
53#define MCCI_CM0PLUS_SYSM_PSP UINT32_C(0x09)
54#define MCCI_CM0PLUS_SYSM_PRIMASK UINT32_C(0x10)
55#define MCCI_CM0PLUS_SYSM_CONTROL UINT32_C(0x14)
59#define MCCI_CM0PLUS_SR_PRIMASK_DISABLE (UINT32_C(1) << 0)
71#define MCCI_CM0PLUS_SCS_BASE UINT32_C(0xE000E000)
75#define MCCI_CM0PLUS_SYSTICK UINT32_C(0xE000E010)
76#define MCCI_CM0PLUS_SYSTICK_CSR (MCCI_CM0PLUS_SYSTICK + 0x0)
77#define MCCI_CM0PLUS_SYSTICK_RVR (MCCI_CM0PLUS_SYSTICK + 0x4)
78#define MCCI_CM0PLUS_SYSTICK_CVR (MCCI_CM0PLUS_SYSTICK + 0x8)
79#define MCCI_CM0PLUS_SYSTICK_CALIB (MCCI_CM0PLUS_SYSTICK + 0xC)
84#define MCCI_CM0PLUS_NVIC UINT32_C(0xE000E100)
85#define MCCI_CM0PLUS_NVIC_ISER (MCCI_CM0PLUS_NVIC + 0x000)
86#define MCCI_CM0PLUS_NVIC_ICER (MCCI_CM0PLUS_NVIC + 0x080)
87#define MCCI_CM0PLUS_NVIC_ISPR (MCCI_CM0PLUS_NVIC + 0x100)
88#define MCCI_CM0PLUS_NVIC_ICPR (MCCI_CM0PLUS_NVIC + 0x180)
89#define MCCI_CM0PLUS_NVIC_IP0 (MCCI_CM0PLUS_NVIC + 0x300)
90#define MCCI_CM0PLUS_NVIC_IP1 (MCCI_CM0PLUS_NVIC + 0x304)
91#define MCCI_CM0PLUS_NVIC_IP2 (MCCI_CM0PLUS_NVIC + 0x308)
92#define MCCI_CM0PLUS_NVIC_IP3 (MCCI_CM0PLUS_NVIC + 0x30C)
93#define MCCI_CM0PLUS_NVIC_IP4 (MCCI_CM0PLUS_NVIC + 0x310)
94#define MCCI_CM0PLUS_NVIC_IP5 (MCCI_CM0PLUS_NVIC + 0x314)
95#define MCCI_CM0PLUS_NVIC_IP6 (MCCI_CM0PLUS_NVIC + 0x318)
96#define MCCI_CM0PLUS_NVIC_IP7 (MCCI_CM0PLUS_NVIC + 0x31C)
101#define MCCI_CM0PLUS_SCB UINT32_C(0xE000ED00)
102#define MCCI_CM0PLUS_SCB_CPUID (MCCI_CM0PLUS_SCB + 0x00)
103#define MCCI_CM0PLUS_SCB_ICSR (MCCI_CM0PLUS_SCB + 0x04)
104#define MCCI_CM0PLUS_SCB_VTOR (MCCI_CM0PLUS_SCB + 0x08)
105#define MCCI_CM0PLUS_SCB_AIRCR (MCCI_CM0PLUS_SCB + 0x0C)
106#define MCCI_CM0PLUS_SCB_SCR (MCCI_CM0PLUS_SCB + 0x10)
107#define MCCI_CM0PLUS_SCB_CCR (MCCI_CM0PLUS_SCB + 0x14)
108#define MCCI_CM0PLUS_SCB_SHPR2 (MCCI_CM0PLUS_SCB + 0x1C)
109#define MCCI_CM0PLUS_SCB_SHPR3 (MCCI_CM0PLUS_SCB + 0x20)
110#define MCCI_CM0PLUS_SCB_SHCSR (MCCI_CM0PLUS_SCB + 0x24)
111#define MCCI_CM0PLUS_SCB_DFSR (MCCI_CM0PLUS_SCB + 0x30)
116#define MCCI_CM0PLUS_MPU UINT32_C(0xE000ED90)
117#define MCCI_CM0PLUS_MPU_TYPE (MCCI_CM0PLUS_MPU + 0x00)
118#define MCCI_CM0PLUS_MPU_CTRL (MCCI_CM0PLUS_MPU + 0x04)
119#define MCCI_CM0PLUS_MPU_RNR (MCCI_CM0PLUS_MPU + 0x08)
120#define MCCI_CM0PLUS_MPU_RBAR (MCCI_CM0PLUS_MPU + 0x0C)
121#define MCCI_CM0PLUS_MPU_RASR (MCCI_CM0PLUS_MPU + 0x10)
132#define MCCI_CM0PLUS_SYSTICK_CSR_RSV17 UINT32_C(0xFFFE0000)
133#define MCCI_CM0PLUS_SYSTICK_CSR_COUNTFLAG (UINT32_C(1) << 16)
134#define MCCI_CM0PLUS_SYSTICK_CSR_RSV3 UINT32_C(0x0000FFF8)
135#define MCCI_CM0PLUS_SYSTICK_CSR_CLKSOURCE (UINT32_C(1) << 2)
136#define MCCI_CM0PLUS_SYSTICK_CSR_TICKINT (UINT32_C(1) << 1)
137#define MCCI_CM0PLUS_SYSTICK_CSR_ENABLE (UINT32_C(1) << 0)
142#define MCCI_CM0PLUS_SYSTICK_RVR_RSV24 UINT32_C(0xFF000000)
143#define MCCI_CM0PLUS_SYSTICK_RVR_RELOAD UINT32_C(0x00FFFFFF)
148#define MCCI_CM0PLUS_SYSTICK_CVR_RSV24 UINT32_C(0xFF000000)
149#define MCCI_CM0PLUS_SYSTICK_CVR_CURRENT UINT32_C(0x00FFFFFF)
154#define MCCI_CM0PLUS_SYSTICK_CALIB_NOREF (UINT32_C(1) << 31)
155#define MCCI_CM0PLUS_SYSTICK_CALIB_SKEW (UINT32_C(1) << 30)
156#define MCCI_CM0PLUS_SYSTICK_CALIB_RSV24 (UINT32_C(0x3F) << 24)
157#define MCCI_CM0PLUS_SYSTICK_CALIB_TENMS UINT32_C(0x00FFFFFF)
164#define MCCI_CM0PLUS_SCB_CPUID_IMPLEMENTER (UINT32_C(0xFF) << 24)
165#define MCCI_CM0PLUS_SCB_CPUID_VARIANT (UINT32_C(0xF) << 20)
166#define MCCI_CM0PLUS_SCB_CPUID_ARCHITECTURE (UINT32_C(0xF) << 16)
167#define MCCI_CM0PLUS_SCB_CPUID_PARTNO (UINT32_C(0xFFF) << 4)
168#define MCCI_CM0PLUS_SCB_CPUID_REVISION (UINT32_C(0xF) << 0)
173#define MCCI_CM0PLUS_SCB_ICSR_NMIPENDSET (UINT32_C(1) << 31)
174#define MCCI_CM0PLUS_SCB_ICSR_RSV29 (UINT32_C(3) << 29)
175#define MCCI_CM0PLUS_SCB_ICSR_PENDSVSET (UINT32_C(1) << 28)
176#define MCCI_CM0PLUS_SCB_ICSR_PENDSVCLR (UINT32_C(1) << 27)
177#define MCCI_CM0PLUS_SCB_ICSR_PENDSTSET (UINT32_C(1) << 26)
178#define MCCI_CM0PLUS_SCB_ICSR_PENDSTCLR (UINT32_C(1) << 26)
179#define MCCI_CM0PLUS_SCB_ICSR_RSV24 (UINT32_C(1) << 24)
180#define MCCI_CM0PLUS_SCB_ICSR_ISRPREEMPT (UINT32_C(1) << 23)
181#define MCCI_CM0PLUS_SCB_ICSR_ISRPENDING (UINT32_C(1) << 22)
182#define MCCI_CM0PLUS_SCB_ICSR_VECTPENDING (UINT32_C(0x1FF) << 12)
183#define MCCI_CM0PLUS_SCB_ICSR_VECTACTIVE (UINT32_C(0x1FF) << 0)
188#define MCCI_CM0PLUS_SCB_VTOR_TBLOFF UINT32_C(0xFFFFFF00)
193#define MCCI_CM0PLUS_SCB_AIRCR_VECTKEY (UINT32_C(0xFFFF) << 16)
194#define MCCI_CM0PLUS_SCB_AIRCR_VECTKEY_VALUE (UINT32_C(0x05FA) << 16)
195#define MCCI_CM0PLUS_SCB_AIRCR_ENDIANNESS (UINT32_C(1) << 15)
196#define MCCI_CM0PLUS_SCB_AIRCR_SYSRESETREQ (UINT32_C(1) << 2)
197#define MCCI_CM0PLUS_SCB_AIRCR_VECTCLRACTIVE (UINT32_C(1) << 1)
202#define MCCI_CM0PLUS_SCB_SCR_SEVONPEND (UINT32_C(1) << 4)
203#define MCCI_CM0PLUS_SCB_SCR_SLEEPDEEP (UINT32_C(1) << 2)
204#define MCCI_CM0PLUS_SCB_SCR_SLEEPONEXIT (UINT32_C(1) << 1)
209#define MCCI_CM0PLUS_SCB_CCR_STKALIGN (UINT32_C(1) << 9)
210#define MCCI_CM0PLUS_SCB_CCR_UNALIGNED (UINT32_C(1) << 3)
215#define MCCI_CM0PLUS_SCB_SHPR_PRI (UINT32_C(3) << 6)
217#define MCCI_CM0PLUS_PRI_INDEX_SVC UINT32_C(11)
218#define MCCI_CM0PLUS_PRI_INDEX_PENDSV UINT32_C(14)
219#define MCCI_CM0PLUS_PRI_INDEX_SYSTICK UINT32_C(15)
222static inline uint32_t
224 uint32_t handlerIndex
232static inline uint32_t
234 uint32_t handlerIndex
238 return UINT32_C(0xE0) << (8 * (handlerIndex & 3));
244#define MCCI_CM0PLUS_SCB_SHCSR_SVCALLPENDED (UINT32_C(1) << 15)
254__attribute__((__always_inline__))
255static inline uint32_t
258 *(
volatile uint32_t *)reg = val;
263__attribute__((__always_inline__))
264static inline uint32_t
267 return *(
volatile uint32_t *)reg;
271__attribute__((__always_inline__))
272static inline uint32_t
279 (rValue & andVal) | orVal
284__attribute__((__always_inline__))
285static inline uint32_t
297__attribute__((__always_inline__))
298static inline uint32_t
324__attribute__((__always_inline__))
325static inline uint32_t
332 (rValue & ~clearVal) | setVal
350__attribute__((__always_inline__))
351static inline uint32_t
358 rValue ^ ((rValue ^ modVal) & maskVal)
379__attribute__((__always_inline__))
static inline
385 __asm
volatile (
"MSR msp,%0\n" ::
"r"(stack): );
396__attribute__((__always_inline__))
static inline
404 __asm
volatile (
"MRS %0,primask" :
"=r"(primask));
416__attribute__((__always_inline__))
static inline
422 __asm
volatile (
"MSR primask,%0" ::
"r"(primask) :
"memory");
430__attribute__((__always_inline__))
static inline
432McciArm_disableInterrupts(
436 uint32_t
const primask = McciArm_getPRIMASK();
437 __asm
volatile (
"cpsid i" :::
"memory");
448__attribute__((always_inline))
static inline
449void McciArm_DataSynchBarrier(
453 __asm
volatile (
"dsb 0xF" :::
"memory");
457# error "Compiler not supported"
475typedef struct Mcci_CortexAppEntryContents_s
488typedef union Mcci_CortexAppEntry_u
499typedef struct Mcci_CortexVectorsContents_s
501 uint32_t vectors[192/4];
512typedef union Mcci_CortexVectors_u
static uint32_t McciArm_putRegOr(uint32_t reg, uint32_t orVal)
or 32-bit values to a cm0plus register
static uint32_t McciArm_getReg(uint32_t reg)
read a 32-bit value from a cm0plus register
static uint32_t McciArm_putReg(uint32_t reg, uint32_t val)
write a 32-bit value to a cm0plus register
#define MCCI_CM0PLUS_SCB_SHPR2
static uint32_t McciArm_putRegClear(uint32_t reg, uint32_t clearVal)
clear out 32-bit values to a cm0plus register
static uint32_t McciArm_putRegClearSet(uint32_t reg, uint32_t clearVal, uint32_t setVal)
clear and set 32-bit values to a cm0plus register
static uint32_t McciCm0Plus_SCB_SHPR_getRegister(uint32_t handlerIndex)
return register for a given handler index
static uint32_t McciArm_putRegMasked(uint32_t reg, uint32_t maskVal, uint32_t modVal)
store to cm0plus register under mask
static uint32_t McciArm_putRegAndOr(uint32_t reg, uint32_t andVal, uint32_t orVal)
and/or 32-bit values to a cm0plus register
static uint32_t McciCm0Plus_SCB_SHPR_getMask(uint32_t handlerIndex)
return byte mask for a given handler index
application entry contents
Cortex M0 interrupt vectors (low level view)
Mcci_CortexAppEntryContents_t CortexAppEntry
Cortex M0 interrupt vector object.
Mcci_CortexAppEntry_t CortexAppEntryCast
Mcci_CortexVectorsContents_t CortexVectors
Mcci_CortexAppEntryContents_t CortexAppEntry