MCCI Trusted Bootloader
Simple trusted bootloader and tools for small embedded systems
mcci_arm_cm7.h
Go to the documentation of this file.
1/*
2
3Module: mcci_arm_cm7.h
4
5Function:
6 ARM cm7 definitions without CMSIS overhead.
7
8Copyright and License:
9 This file copyright (C) 2021 by
10
11 MCCI Corporation
12 3520 Krums Corners Road
13 Ithaca, NY 14850
14
15 See accompanying LICENSE file for copyright and license information.
16
17Author:
18 ChaeHee Won, MCCI Corporation June 2021
19
20*/
21
22#ifndef _mcci_arm_cm7_h_
23#define _mcci_arm_cm7_h_ /* prevent multiple includes */
24
25#pragma once
26
27#ifndef _mcci_bootloader_bits_h_
28# include "mcci_bootloader_bits.h"
29#endif
30
31#include <stdint.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/****************************************************************************\
38|
39| Special function register values
40|
41\****************************************************************************/
42
43/// \name CPU Special function registers
44/// @{
45#define MCCI_CM7_SYSM_APSR UINT32_C(0x00) ///< Flags from previous instructions
46#define MCCI_CM7_SYSM_IAPSR UINT32_C(0x01) ///< Composite of IPSR and APSR
47#define MCCI_CM7_SYSM_EAPSR UINT32_C(0x02) ///< Composite of EPSR and APSR
48#define MCCI_CM7_SYSM_XPSR UINT32_C(0x03) ///< Composite of EPSR, IPSR and APSR
49#define MCCI_CM7_SYSM_IPSR UINT32_C(0x05) ///< Interrupt status register
50#define MCCI_CM7_SYSM_EPSR UINT32_C(0x06) ///< Exception status register
51#define MCCI_CM7_SYSM_IEPSR UINT32_C(0x07) ///< Composite of IPSR and EPSR
52#define MCCI_CM7_SYSM_MSP UINT32_C(0x08) ///< Main stack pointer
53#define MCCI_CM7_SYSM_PSP UINT32_C(0x09) ///< Process stack pointer
54#define MCCI_CM7_SYSM_PRIMASK UINT32_C(0x10) ///< priority mask register
55#define MCCI_CM7_SYSM_BASEPRI UINT32_C(0x11) ///< base priority register
56#define MCCI_CM7_SYSM_BASEPRI_MAX UINT32_C(0x12) ///< base priority max register
57#define MCCI_CM7_SYSM_FAULTMASK UINT32_C(0x13) ///< register to raise priority to the HardFault level
58#define MCCI_CM7_SYSM_CONTROL UINT32_C(0x14) ///< control register
59
60/// \name PRIMASK special register fields
61/// @{
62#define MCCI_CM7_SR_PRIMASK_DISABLE (UINT32_C(1) << 0) ///< the bit to disable interrupts
63/// @}
64
65/// \name BASEPRI special register fields
66/// @{
67#define MCCI_CM7_SR_BASEPRI_MASK (UINT32_C(0xFF) << 0) ///< the base priority mask
68#define MCCI_CM7_SR_BASEPRI_VAL(n) ((n) << 0) ///< the base priority value
69/// @}
70
71/// \name FAULTMASK special register fields
72/// @{
73#define MCCI_CM7_SR_FAULTMASK_FM (UINT32_C(1) << 0) ///< the fault mask
74/// @}
75
76/* end of special-function registers */
77/// @}
78
79/****************************************************************************\
80|
81| Register addresses
82|
83\****************************************************************************/
84
85#define MCCI_CM7_SCS_BASE UINT32_C(0xE000E000)
86
87/// \name SCnSCB (System Controls not in SCB) registers
88/// @{
89#define MCCI_CM7_ICTR UINT32_C(0xE000E004)
90#define MCCI_CM7_ACTLR UINT32_C(0xE000E008)
91/// @}
92
93/// \name SYSTICK registers
94/// @{
95#define MCCI_CM7_SYSTICK UINT32_C(0xE000E010)
96#define MCCI_CM7_SYSTICK_CSR (MCCI_CM7_SYSTICK + 0x0)
97#define MCCI_CM7_SYSTICK_RVR (MCCI_CM7_SYSTICK + 0x4)
98#define MCCI_CM7_SYSTICK_CVR (MCCI_CM7_SYSTICK + 0x8)
99#define MCCI_CM7_SYSTICK_CALIB (MCCI_CM7_SYSTICK + 0xC)
100/// @}
101
102/// \name NVIC registers
103/// @{
104#define MCCI_CM7_NVIC UINT32_C(0xE000E100)
105#define MCCI_CM7_NVIC_ISER (MCCI_CM7_NVIC + 0x000)
106#define MCCI_CM7_NVIC_ISER0 (MCCI_CM7_NVIC + 0x000)
107#define MCCI_CM7_NVIC_ISER1 (MCCI_CM7_NVIC + 0x004)
108#define MCCI_CM7_NVIC_ISER2 (MCCI_CM7_NVIC + 0x008)
109#define MCCI_CM7_NVIC_ISER3 (MCCI_CM7_NVIC + 0x00C)
110#define MCCI_CM7_NVIC_ISER4 (MCCI_CM7_NVIC + 0x010)
111#define MCCI_CM7_NVIC_ISER5 (MCCI_CM7_NVIC + 0x014)
112#define MCCI_CM7_NVIC_ISER6 (MCCI_CM7_NVIC + 0x018)
113#define MCCI_CM7_NVIC_ISER7 (MCCI_CM7_NVIC + 0x01C)
114#define MCCI_CM7_NVIC_ICER (MCCI_CM7_NVIC + 0x080)
115#define MCCI_CM7_NVIC_ICER0 (MCCI_CM7_NVIC + 0x080)
116#define MCCI_CM7_NVIC_ICER1 (MCCI_CM7_NVIC + 0x084)
117#define MCCI_CM7_NVIC_ICER2 (MCCI_CM7_NVIC + 0x088)
118#define MCCI_CM7_NVIC_ICER3 (MCCI_CM7_NVIC + 0x08C)
119#define MCCI_CM7_NVIC_ICER4 (MCCI_CM7_NVIC + 0x090)
120#define MCCI_CM7_NVIC_ICER5 (MCCI_CM7_NVIC + 0x094)
121#define MCCI_CM7_NVIC_ICER6 (MCCI_CM7_NVIC + 0x098)
122#define MCCI_CM7_NVIC_ICER7 (MCCI_CM7_NVIC + 0x09C)
123#define MCCI_CM7_NVIC_ISPR (MCCI_CM7_NVIC + 0x100)
124#define MCCI_CM7_NVIC_ISPR0 (MCCI_CM7_NVIC + 0x100)
125#define MCCI_CM7_NVIC_ISPR1 (MCCI_CM7_NVIC + 0x104)
126#define MCCI_CM7_NVIC_ISPR2 (MCCI_CM7_NVIC + 0x108)
127#define MCCI_CM7_NVIC_ISPR3 (MCCI_CM7_NVIC + 0x10C)
128#define MCCI_CM7_NVIC_ISPR4 (MCCI_CM7_NVIC + 0x110)
129#define MCCI_CM7_NVIC_ISPR5 (MCCI_CM7_NVIC + 0x114)
130#define MCCI_CM7_NVIC_ISPR6 (MCCI_CM7_NVIC + 0x118)
131#define MCCI_CM7_NVIC_ISPR7 (MCCI_CM7_NVIC + 0x11C)
132#define MCCI_CM7_NVIC_ICPR (MCCI_CM7_NVIC + 0x180)
133#define MCCI_CM7_NVIC_ICPR0 (MCCI_CM7_NVIC + 0x180)
134#define MCCI_CM7_NVIC_ICPR1 (MCCI_CM7_NVIC + 0x184)
135#define MCCI_CM7_NVIC_ICPR2 (MCCI_CM7_NVIC + 0x188)
136#define MCCI_CM7_NVIC_ICPR3 (MCCI_CM7_NVIC + 0x18C)
137#define MCCI_CM7_NVIC_ICPR4 (MCCI_CM7_NVIC + 0x190)
138#define MCCI_CM7_NVIC_ICPR5 (MCCI_CM7_NVIC + 0x194)
139#define MCCI_CM7_NVIC_ICPR6 (MCCI_CM7_NVIC + 0x198)
140#define MCCI_CM7_NVIC_ICPR7 (MCCI_CM7_NVIC + 0x19C)
141#define MCCI_CM7_NVIC_IABR (MCCI_CM7_NVIC + 0x200)
142#define MCCI_CM7_NVIC_IABR0 (MCCI_CM7_NVIC + 0x200)
143#define MCCI_CM7_NVIC_IABR1 (MCCI_CM7_NVIC + 0x204)
144#define MCCI_CM7_NVIC_IABR2 (MCCI_CM7_NVIC + 0x208)
145#define MCCI_CM7_NVIC_IABR3 (MCCI_CM7_NVIC + 0x20C)
146#define MCCI_CM7_NVIC_IABR4 (MCCI_CM7_NVIC + 0x210)
147#define MCCI_CM7_NVIC_IABR5 (MCCI_CM7_NVIC + 0x214)
148#define MCCI_CM7_NVIC_IABR6 (MCCI_CM7_NVIC + 0x218)
149#define MCCI_CM7_NVIC_IABR7 (MCCI_CM7_NVIC + 0x21C)
150#define MCCI_CM7_NVIC_IPR (MCCI_CM7_NVIC + 0x300)
151#define MCCI_CM7_NVIC_IPR0 (MCCI_CM7_NVIC + 0x300)
152#define MCCI_CM7_NVIC_IPR1 (MCCI_CM7_NVIC + 0x304)
153#define MCCI_CM7_NVIC_IPR2 (MCCI_CM7_NVIC + 0x308)
154#define MCCI_CM7_NVIC_IPR3 (MCCI_CM7_NVIC + 0x30C)
155#define MCCI_CM7_NVIC_IPR4 (MCCI_CM7_NVIC + 0x310)
156#define MCCI_CM7_NVIC_IPR5 (MCCI_CM7_NVIC + 0x314)
157#define MCCI_CM7_NVIC_IPR6 (MCCI_CM7_NVIC + 0x318)
158#define MCCI_CM7_NVIC_IPR7 (MCCI_CM7_NVIC + 0x31C)
159#define MCCI_CM7_NVIC_IPR8 (MCCI_CM7_NVIC + 0x320)
160#define MCCI_CM7_NVIC_IPR9 (MCCI_CM7_NVIC + 0x324)
161#define MCCI_CM7_NVIC_IPR10 (MCCI_CM7_NVIC + 0x328)
162#define MCCI_CM7_NVIC_IPR11 (MCCI_CM7_NVIC + 0x32C)
163#define MCCI_CM7_NVIC_IPR12 (MCCI_CM7_NVIC + 0x330)
164#define MCCI_CM7_NVIC_IPR13 (MCCI_CM7_NVIC + 0x334)
165#define MCCI_CM7_NVIC_IPR14 (MCCI_CM7_NVIC + 0x338)
166#define MCCI_CM7_NVIC_IPR15 (MCCI_CM7_NVIC + 0x33C)
167#define MCCI_CM7_NVIC_IPR16 (MCCI_CM7_NVIC + 0x340)
168#define MCCI_CM7_NVIC_IPR17 (MCCI_CM7_NVIC + 0x344)
169#define MCCI_CM7_NVIC_IPR18 (MCCI_CM7_NVIC + 0x348)
170#define MCCI_CM7_NVIC_IPR19 (MCCI_CM7_NVIC + 0x34C)
171#define MCCI_CM7_NVIC_IPR20 (MCCI_CM7_NVIC + 0x350)
172#define MCCI_CM7_NVIC_IPR21 (MCCI_CM7_NVIC + 0x354)
173#define MCCI_CM7_NVIC_IPR22 (MCCI_CM7_NVIC + 0x358)
174#define MCCI_CM7_NVIC_IPR23 (MCCI_CM7_NVIC + 0x35C)
175#define MCCI_CM7_NVIC_IPR24 (MCCI_CM7_NVIC + 0x360)
176#define MCCI_CM7_NVIC_IPR25 (MCCI_CM7_NVIC + 0x364)
177#define MCCI_CM7_NVIC_IPR26 (MCCI_CM7_NVIC + 0x368)
178#define MCCI_CM7_NVIC_IPR27 (MCCI_CM7_NVIC + 0x36C)
179#define MCCI_CM7_NVIC_IPR28 (MCCI_CM7_NVIC + 0x370)
180#define MCCI_CM7_NVIC_IPR29 (MCCI_CM7_NVIC + 0x374)
181#define MCCI_CM7_NVIC_IPR30 (MCCI_CM7_NVIC + 0x378)
182#define MCCI_CM7_NVIC_IPR31 (MCCI_CM7_NVIC + 0x37C)
183#define MCCI_CM7_NVIC_IPR32 (MCCI_CM7_NVIC + 0x380)
184#define MCCI_CM7_NVIC_IPR33 (MCCI_CM7_NVIC + 0x384)
185#define MCCI_CM7_NVIC_IPR34 (MCCI_CM7_NVIC + 0x388)
186#define MCCI_CM7_NVIC_IPR35 (MCCI_CM7_NVIC + 0x38C)
187#define MCCI_CM7_NVIC_IPR36 (MCCI_CM7_NVIC + 0x390)
188#define MCCI_CM7_NVIC_IPR37 (MCCI_CM7_NVIC + 0x394)
189#define MCCI_CM7_NVIC_IPR38 (MCCI_CM7_NVIC + 0x398)
190#define MCCI_CM7_NVIC_IPR39 (MCCI_CM7_NVIC + 0x39C)
191#define MCCI_CM7_NVIC_IPR40 (MCCI_CM7_NVIC + 0x3A0)
192#define MCCI_CM7_NVIC_IPR41 (MCCI_CM7_NVIC + 0x3A4)
193#define MCCI_CM7_NVIC_IPR42 (MCCI_CM7_NVIC + 0x3A8)
194#define MCCI_CM7_NVIC_IPR43 (MCCI_CM7_NVIC + 0x3AC)
195#define MCCI_CM7_NVIC_IPR44 (MCCI_CM7_NVIC + 0x3B0)
196#define MCCI_CM7_NVIC_IPR45 (MCCI_CM7_NVIC + 0x3B4)
197#define MCCI_CM7_NVIC_IPR46 (MCCI_CM7_NVIC + 0x3B8)
198#define MCCI_CM7_NVIC_IPR47 (MCCI_CM7_NVIC + 0x3BC)
199#define MCCI_CM7_NVIC_IPR48 (MCCI_CM7_NVIC + 0x3C0)
200#define MCCI_CM7_NVIC_IPR49 (MCCI_CM7_NVIC + 0x3C4)
201#define MCCI_CM7_NVIC_IPR50 (MCCI_CM7_NVIC + 0x3C8)
202#define MCCI_CM7_NVIC_IPR51 (MCCI_CM7_NVIC + 0x3CC)
203#define MCCI_CM7_NVIC_IPR52 (MCCI_CM7_NVIC + 0x3D0)
204#define MCCI_CM7_NVIC_IPR53 (MCCI_CM7_NVIC + 0x3D4)
205#define MCCI_CM7_NVIC_IPR54 (MCCI_CM7_NVIC + 0x3D8)
206#define MCCI_CM7_NVIC_IPR55 (MCCI_CM7_NVIC + 0x3DC)
207#define MCCI_CM7_NVIC_IPR56 (MCCI_CM7_NVIC + 0x3E0)
208#define MCCI_CM7_NVIC_IPR57 (MCCI_CM7_NVIC + 0x3E4)
209#define MCCI_CM7_NVIC_IPR58 (MCCI_CM7_NVIC + 0x3E8)
210#define MCCI_CM7_NVIC_IPR59 (MCCI_CM7_NVIC + 0x3EC)
211/// @}
212
213/// \name SCB registers
214/// @{
215#define MCCI_CM7_SCB UINT32_C(0xE000ED00)
216#define MCCI_CM7_SCB_CPUID (MCCI_CM7_SCB + 0x00)
217#define MCCI_CM7_SCB_ICSR (MCCI_CM7_SCB + 0x04)
218#define MCCI_CM7_SCB_VTOR (MCCI_CM7_SCB + 0x08)
219#define MCCI_CM7_SCB_AIRCR (MCCI_CM7_SCB + 0x0C)
220#define MCCI_CM7_SCB_SCR (MCCI_CM7_SCB + 0x10)
221#define MCCI_CM7_SCB_CCR (MCCI_CM7_SCB + 0x14)
222#define MCCI_CM7_SCB_SHPR1 (MCCI_CM7_SCB + 0x18)
223#define MCCI_CM7_SCB_SHPR2 (MCCI_CM7_SCB + 0x1C)
224#define MCCI_CM7_SCB_SHPR3 (MCCI_CM7_SCB + 0x20)
225#define MCCI_CM7_SCB_SHCSR (MCCI_CM7_SCB + 0x24)
226#define MCCI_CM7_SCB_CFSR (MCCI_CM7_SCB + 0x28)
227#define MCCI_CM7_SCB_HFSR (MCCI_CM7_SCB + 0x2C)
228#define MCCI_CM7_SCB_DFSR (MCCI_CM7_SCB + 0x30)
229#define MCCI_CM7_SCB_MMFAR (MCCI_CM7_SCB + 0x34)
230#define MCCI_CM7_SCB_BFAR (MCCI_CM7_SCB + 0x38)
231#define MCCI_CM7_SCB_ID_PFR0 (MCCI_CM7_SCB + 0x40)
232#define MCCI_CM7_SCB_ID_PFR1 (MCCI_CM7_SCB + 0x44)
233#define MCCI_CM7_SCB_ID_DFR0 (MCCI_CM7_SCB + 0x48)
234#define MCCI_CM7_SCB_ID_AFR0 (MCCI_CM7_SCB + 0x4C)
235#define MCCI_CM7_SCB_ID_MMFR0 (MCCI_CM7_SCB + 0x50)
236#define MCCI_CM7_SCB_ID_MMFR1 (MCCI_CM7_SCB + 0x54)
237#define MCCI_CM7_SCB_ID_MMFR2 (MCCI_CM7_SCB + 0x58)
238#define MCCI_CM7_SCB_ID_MMFR3 (MCCI_CM7_SCB + 0x5C)
239#define MCCI_CM7_SCB_ID_ISAR0 (MCCI_CM7_SCB + 0x60)
240#define MCCI_CM7_SCB_ID_ISAR1 (MCCI_CM7_SCB + 0x64)
241#define MCCI_CM7_SCB_ID_ISAR2 (MCCI_CM7_SCB + 0x68)
242#define MCCI_CM7_SCB_ID_ISAR3 (MCCI_CM7_SCB + 0x6C)
243#define MCCI_CM7_SCB_ID_ISAR4 (MCCI_CM7_SCB + 0x70)
244#define MCCI_CM7_SCB_CLIDR (MCCI_CM7_SCB + 0x78)
245#define MCCI_CM7_SCB_CTR (MCCI_CM7_SCB + 0x7C)
246#define MCCI_CM7_SCB_CCSIDR (MCCI_CM7_SCB + 0x80)
247#define MCCI_CM7_SCB_CSSELR (MCCI_CM7_SCB + 0x84)
248#define MCCI_CM7_SCB_CPACR (MCCI_CM7_SCB + 0x88)
249#define MCCI_CM7_SCB_STIR (MCCI_CM7_SCB + 0x200)
250#define MCCI_CM7_SCB_ICIALLU (MCCI_CM7_SCB + 0x250)
251#define MCCI_CM7_SCB_ICIMVAU (MCCI_CM7_SCB + 0x258)
252#define MCCI_CM7_SCB_DCIMVAC (MCCI_CM7_SCB + 0x25C)
253#define MCCI_CM7_SCB_DCISW (MCCI_CM7_SCB + 0x260)
254#define MCCI_CM7_SCB_DCCMVAU (MCCI_CM7_SCB + 0x264)
255#define MCCI_CM7_SCB_DCCMVAC (MCCI_CM7_SCB + 0x268)
256#define MCCI_CM7_SCB_DCCSW (MCCI_CM7_SCB + 0x26C)
257#define MCCI_CM7_SCB_DCCIMVAC (MCCI_CM7_SCB + 0x270)
258#define MCCI_CM7_SCB_DCCISW (MCCI_CM7_SCB + 0x274)
259#define MCCI_CM7_SCB_BPIALL (MCCI_CM7_SCB + 0x278)
260#define MCCI_CM7_SCB_ITCMCR (MCCI_CM7_SCB + 0x290)
261#define MCCI_CM7_SCB_DTCMCR (MCCI_CM7_SCB + 0x294)
262#define MCCI_CM7_SCB_AHBPCR (MCCI_CM7_SCB + 0x298)
263#define MCCI_CM7_SCB_CACR (MCCI_CM7_SCB + 0x29C)
264#define MCCI_CM7_SCB_AHBSCR (MCCI_CM7_SCB + 0x2A0)
265#define MCCI_CM7_SCB_ABFSR (MCCI_CM7_SCB + 0x2A8)
266#define MCCI_CM7_SCB_IEBR0 (MCCI_CM7_SCB + 0x2B0)
267#define MCCI_CM7_SCB_IEBR1 (MCCI_CM7_SCB + 0x2B4)
268#define MCCI_CM7_SCB_DEBR0 (MCCI_CM7_SCB + 0x2B8)
269#define MCCI_CM7_SCB_DEBR1 (MCCI_CM7_SCB + 0x2BC)
270#define MCCI_CM7_SCB_PID4 (MCCI_CM7_SCB + 0x2D0)
271#define MCCI_CM7_SCB_PID5 (MCCI_CM7_SCB + 0x2D4)
272#define MCCI_CM7_SCB_PID6 (MCCI_CM7_SCB + 0x2D8)
273#define MCCI_CM7_SCB_PID7 (MCCI_CM7_SCB + 0x2DC)
274#define MCCI_CM7_SCB_PID0 (MCCI_CM7_SCB + 0x2E0)
275#define MCCI_CM7_SCB_PID1 (MCCI_CM7_SCB + 0x2E4)
276#define MCCI_CM7_SCB_PID2 (MCCI_CM7_SCB + 0x2E8)
277#define MCCI_CM7_SCB_PID3 (MCCI_CM7_SCB + 0x2EC)
278#define MCCI_CM7_SCB_CID0 (MCCI_CM7_SCB + 0x2F0)
279#define MCCI_CM7_SCB_CID1 (MCCI_CM7_SCB + 0x2F4)
280#define MCCI_CM7_SCB_CID2 (MCCI_CM7_SCB + 0x2F8)
281#define MCCI_CM7_SCB_CID3 (MCCI_CM7_SCB + 0x2FC)
282/// @}
283
284/// \name FPU registers
285/// @{
286#define MCCI_CM7_FPU UINT32_C(0xE000EF30)
287#define MCCI_CM7_FPU_FPCCR (MCCI_CM7_FPU + 0x04) ///<
288#define MCCI_CM7_FPU_FPCAR (MCCI_CM7_FPU + 0x08) ///<
289#define MCCI_CM7_FPU_FPDSCR (MCCI_CM7_FPU + 0x0C) ///<
290#define MCCI_CM7_FPU_MVFR0 (MCCI_CM7_FPU + 0x10) ///<
291#define MCCI_CM7_FPU_MVFR1 (MCCI_CM7_FPU + 0x14) ///<
292#define MCCI_CM7_FPU_MVFR2 (MCCI_CM7_FPU + 0x18) ///<
293/// @}
294
295/****************************************************************************\
296|
297| Register bits
298|
299\****************************************************************************/
300
301/// \name SYSTICK CSR bits
302/// @{
303#define MCCI_CM7_SYSTICK_CSR_RSV17 UINT32_C(0xFFFE0000) ///< reserved
304#define MCCI_CM7_SYSTICK_CSR_COUNTFLAG (UINT32_C(1) << 16) ///< timer has counted to zero
305#define MCCI_CM7_SYSTICK_CSR_RSV3 UINT32_C(0x0000FFF8) ///< reserved
306#define MCCI_CM7_SYSTICK_CSR_CLKSOURCE (UINT32_C(1) << 2) ///< use processor (not external) clock
307#define MCCI_CM7_SYSTICK_CSR_TICKINT (UINT32_C(1) << 1) ///< enable tick exception
308#define MCCI_CM7_SYSTICK_CSR_ENABLE (UINT32_C(1) << 0) ///< enable counter
309/// @}
310
311/// \name SYSTICK RVR bits
312/// @{
313#define MCCI_CM7_SYSTICK_RVR_RSV24 UINT32_C(0xFF000000) ///< reserved, zero
314#define MCCI_CM7_SYSTICK_RVR_RELOAD UINT32_C(0x00FFFFFF) ///< reload value
315/// @}
316
317/// \name SYSTICK CVR bits
318/// @{
319#define MCCI_CM7_SYSTICK_CVR_RSV24 UINT32_C(0xFF000000) ///< reserved, read as zero
320#define MCCI_CM7_SYSTICK_CVR_CURRENT UINT32_C(0x00FFFFFF) ///< current value
321/// @}
322
323/// \name SYSTICK CALIB bits
324/// @{
325#define MCCI_CM7_SYSTICK_CALIB_NOREF (UINT32_C(1) << 31) ///< reference clock is not implemented
326#define MCCI_CM7_SYSTICK_CALIB_SKEW (UINT32_C(1) << 30) ///< 10ms cal value is inexact
327#define MCCI_CM7_SYSTICK_CALIB_RSV24 (UINT32_C(0x3F) << 24) ///< reserved, zero
328#define MCCI_CM7_SYSTICK_CALIB_TENMS UINT32_C(0x00FFFFFF) ///< if non-zero, use this as reload value for 10ms ticks
329/// @}
330
331/// \name SCB CPUID fields
332/// @{
333#define MCCI_CM7_SCB_CPUID_IMPLEMENTER (UINT32_C(0xFF) << 24) ///< Implementer code
334#define MCCI_CM7_SCB_CPUID_VARIANT (UINT32_C(0xF) << 20) ///< Variant code
335#define MCCI_CM7_SCB_CPUID_ARCHITECTURE (UINT32_C(0xF) << 16) ///< Architecture code
336#define MCCI_CM7_SCB_CPUID_PARTNO (UINT32_C(0xFFF) << 4) ///< Part number
337#define MCCI_CM7_SCB_CPUID_REVISION (UINT32_C(0xF) << 0) ///< Revision
338/// @}
339
340/// \name SCB ICSR fields
341/// @{
342#define MCCI_CM7_SCB_ICSR_NMIPENDSET (UINT32_C(1) << 31) ///<
343#define MCCI_CM7_SCB_ICSR_RSV29 (UINT32_C(3) << 29) ///<
344#define MCCI_CM7_SCB_ICSR_PENDSVSET (UINT32_C(1) << 28) ///<
345#define MCCI_CM7_SCB_ICSR_PENDSVCLR (UINT32_C(1) << 27) ///<
346#define MCCI_CM7_SCB_ICSR_PENDSTSET (UINT32_C(1) << 26) ///<
347#define MCCI_CM7_SCB_ICSR_PENDSTCLR (UINT32_C(1) << 25) ///<
348#define MCCI_CM7_SCB_ICSR_RSV24 (UINT32_C(1) << 24) ///<
349#define MCCI_CM7_SCB_ICSR_ISRPREEMPT (UINT32_C(1) << 23) ///<
350#define MCCI_CM7_SCB_ICSR_ISRPENDING (UINT32_C(1) << 22) ///<
351#define MCCI_CM7_SCB_ICSR_VECTPENDING (UINT32_C(0x1FF) << 12) ///<
352#define MCCI_CM7_SCB_ICSR_RETTOBASE (UINT32_C(1) << 11) ///<
353#define MCCI_CM7_SCB_ICSR_VECTACTIVE (UINT32_C(0x1FF) << 0) ///<
354/// @}
355
356/// \name SCB VTOR fields
357/// @{
358#define MCCI_CM7_SCB_VTOR_TBLOFF UINT32_C(0xFFFFFF80) ///<
359/// @}
360
361/// \name SCB AIRCR fields (Application Interrupt and Reset Control)
362/// @{
363#define MCCI_CM7_SCB_AIRCR_VECTKEY (UINT32_C(0xFFFF) << 16) ///< Vector key
364#define MCCI_CM7_SCB_AIRCR_VECTKEY_VALUE (UINT32_C(0x05FA) << 16) ///< Value to write to unlock register.
365#define MCCI_CM7_SCB_AIRCR_ENDIANNESS (UINT32_C(1) << 15) ///< 0=little, 1=big endian
366#define MCCI_CM7_SCB_AIRCR_PRIGROUP (UINT32_C(7) << 8) ///< Priority grouping position
367#define MCCI_CM7_SCB_AIRCR_PRIGROUP_N(n) ((n) << 8) ///<
368#define MCCI_CM7_SCB_AIRCR_SYSRESETREQ (UINT32_C(1) << 2) ///< System reset request
369#define MCCI_CM7_SCB_AIRCR_VECTCLRACTIVE (UINT32_C(1) << 1) ///<
370#define MCCI_CM7_SCB_AIRCR_VECTRESET (UINT32_C(1) << 0) ///<
371/// @}
372
373/// \name SCB SCR fields
374/// @{
375#define MCCI_CM7_SCB_SCR_SEVONPEND (UINT32_C(1) << 4) ///<
376#define MCCI_CM7_SCB_SCR_SLEEPDEEP (UINT32_C(1) << 2) ///<
377#define MCCI_CM7_SCB_SCR_SLEEPONEXIT (UINT32_C(1) << 1) ///<
378/// @}
379
380/// \name SCB Configuration Control Register bits
381/// @{
382#define MCCI_CM7_SCB_CCR_BP (UINT32_C(1) << 18) ///<
383#define MCCI_CM7_SCB_CCR_IC (UINT32_C(1) << 17) ///<
384#define MCCI_CM7_SCB_CCR_DC (UINT32_C(1) << 16) ///<
385#define MCCI_CM7_SCB_CCR_STKALIGN (UINT32_C(1) << 9) ///<
386#define MCCI_CM7_SCB_CCR_BFHFNMIGN (UINT32_C(1) << 8) ///<
387#define MCCI_CM7_SCB_CCR_DIV_0_TRP (UINT32_C(1) << 4) ///<
388#define MCCI_CM7_SCB_CCR_UNALIGN_TRP (UINT32_C(1) << 3) ///<
389#define MCCI_CM7_SCB_CCR_USERSETMPEND (UINT32_C(1) << 1) ///<
390#define MCCI_CM7_SCB_CCR_NONBASETHRDENA (UINT32_C(1) << 0) ///<
391/// @}
392
393/// \name SCB SHPR access
394/// @{
395#define MCCI_CM7_SCB_SHPR_PRI (UINT32_C(7) << 5) ///< priority bits within a byte
396
397#define MCCI_CM7_PRI_INDEX_MEM_MANAGE UINT32_C(4) ///< priority of MemManage
398#define MCCI_CM7_PRI_INDEX_BUS_FAULT UINT32_C(5) ///< priority of BusFault
399#define MCCI_CM7_PRI_INDEX_USAGE_FAULT UINT32_C(6) ///< priority of UsageFault
400#define MCCI_CM7_PRI_INDEX_SVC UINT32_C(11) ///< priority of SVCall
401#define MCCI_CM7_PRI_INDEX_DEBUG_MONITOR UINT32_C(12) ///< priority of DebugMonitor
402#define MCCI_CM7_PRI_INDEX_PENDSV UINT32_C(14) ///< priority of PendSV
403#define MCCI_CM7_PRI_INDEX_SYSTICK UINT32_C(15) ///< priority of systick
404
405/// \brief return register for a given handler index
406static inline uint32_t
408 uint32_t handlerIndex
409 )
410 {
411 return handlerIndex < 8
413 : handlerIndex < 12 ? MCCI_CM7_SCB_SHPR2 : MCCI_CM7_SCB_SHPR3;
414 }
415
416/// \brief return byte mask for a given handler index
417static inline uint32_t
419 uint32_t handlerIndex
420 )
421 {
422 // compute and return the mask for a given bit
423 return UINT32_C(0xE0) << (8 * (handlerIndex & 3));
424 }
425/// @}
426
427/// \name SCB System Handler Control and State Register bits
428/// @{
429#define MCCI_CM7_SCB_SHCSR_USGFAULTENA (UINT32_C(1) << 18) ///<
430#define MCCI_CM7_SCB_SHCSR_BUSFAULTENA (UINT32_C(1) << 17) ///<
431#define MCCI_CM7_SCB_SHCSR_MEMFAULTENA (UINT32_C(1) << 16) ///<
432#define MCCI_CM7_SCB_SHCSR_SVCALLPENDED (UINT32_C(1) << 15) ///<
433#define MCCI_CM7_SCB_SHCSR_BUSFAULTPENDED (UINT32_C(1) << 14) ///<
434#define MCCI_CM7_SCB_SHCSR_MEMFAULTPENDED (UINT32_C(1) << 13) ///<
435#define MCCI_CM7_SCB_SHCSR_USGFAULTPENDED (UINT32_C(1) << 12) ///<
436#define MCCI_CM7_SCB_SHCSR_SYSTICKACT (UINT32_C(1) << 11) ///<
437#define MCCI_CM7_SCB_SHCSR_PENDSVACT (UINT32_C(1) << 10) ///<
438#define MCCI_CM7_SCB_SHCSR_MONITORACT (UINT32_C(1) << 8) ///<
439#define MCCI_CM7_SCB_SHCSR_SVCALLACT (UINT32_C(1) << 7) ///<
440#define MCCI_CM7_SCB_SHCSR_USGFAULTACT (UINT32_C(1) << 3) ///<
441#define MCCI_CM7_SCB_SHCSR_BUSFAULTACT (UINT32_C(1) << 1) ///<
442#define MCCI_CM7_SCB_SHCSR_MEMFAULTACT (UINT32_C(1) << 0) ///<
443/// @}
444
445/****************************************************************************\
446|
447| Interrupt Number Definition
448|
449\****************************************************************************/
450
451/// \name Cortex-M Processor Exceptions Numbers
452/// @{
453#define MCCI_CM7_IRQ_BASE UINT32_C(256) ///< Cortex-M Processor Exception Number Base
454#define MCCI_CM7_IRQ_NonMaskableInt (MCCI_CM7_IRQ_BASE + UINT32_C(2)) ///< Non Maskable Interrupt
455#define MCCI_CM7_IRQ_HardFault (MCCI_CM7_IRQ_BASE + UINT32_C(3)) ///< Cortex-M Hard Fault
456#define MCCI_CM7_IRQ_MemoryManagement (MCCI_CM7_IRQ_BASE + UINT32_C(4)) ///< Cortex-M Memory Management Interrupt
457#define MCCI_CM7_IRQ_BusFault (MCCI_CM7_IRQ_BASE + UINT32_C(5)) ///< Cortex-M Bus Fault Interrupt
458#define MCCI_CM7_IRQ_UsageFault (MCCI_CM7_IRQ_BASE + UINT32_C(6)) ///< Cortex-M Usage Fault Interrupt
459#define MCCI_CM7_IRQ_SVCall (MCCI_CM7_IRQ_BASE + UINT32_C(11)) ///< Cortex-M SV Call Interrupt
460#define MCCI_CM7_IRQ_DebugMonitor (MCCI_CM7_IRQ_BASE + UINT32_C(12)) ///< Cortex-M Debug Monitor Interrupt
461#define MCCI_CM7_IRQ_PendSV (MCCI_CM7_IRQ_BASE + UINT32_C(14)) ///< Cortex-M Pend SV Interrupt
462#define MCCI_CM7_IRQ_SysTick (MCCI_CM7_IRQ_BASE + UINT32_C(15)) ///< Cortex-M System Tick Interrupt
463/// @}
464
465/****************************************************************************\
466|
467| Register access primitives
468|
469\****************************************************************************/
470
471/// \brief write a 32-bit value to a cm7 register
472__attribute__((__always_inline__))
473static inline uint32_t
474McciArm_putReg(uint32_t reg, uint32_t val)
475 {
476 *(volatile uint32_t *)reg = val;
477 return val;
478 }
479
480/// \brief read a 32-bit value from a cm7 register
481__attribute__((__always_inline__))
482static inline uint32_t
483McciArm_getReg(uint32_t reg)
484 {
485 return *(volatile uint32_t *)reg;
486 }
487
488/// \brief and/or 32-bit values to a cm7 register
489__attribute__((__always_inline__))
490static inline uint32_t
491McciArm_putRegAndOr(uint32_t reg, uint32_t andVal, uint32_t orVal)
492 {
493 uint32_t const rValue = McciArm_getReg(reg);
494
495 return McciArm_putReg(
496 reg,
497 (rValue & andVal) | orVal
498 );
499 }
500
501/// \brief or 32-bit values to a cm7 register
502__attribute__((__always_inline__))
503static inline uint32_t
504McciArm_putRegOr(uint32_t reg, uint32_t orVal)
505 {
506 uint32_t const rValue = McciArm_getReg(reg);
507
508 return McciArm_putReg(
509 reg,
510 rValue | orVal
511 );
512 }
513
514/// \brief clear out 32-bit values to a cm7 register
515__attribute__((__always_inline__))
516static inline uint32_t
517McciArm_putRegClear(uint32_t reg, uint32_t clearVal)
518 {
519 uint32_t const rValue = McciArm_getReg(reg);
520
521 return McciArm_putReg(
522 reg,
523 rValue & ~clearVal
524 );
525 }
526
527///
528/// \brief clear and set 32-bit values to a cm7 register
529///
530/// \param [in] reg register to be modified
531/// \param [in] clearVal mask of bits to be cleared (1 in mask clears bit in reg)
532/// \param [in] setVal mask of bits to be set
533///
534/// \note this is subtly different than \ref McciArm_putRegMasked,
535/// in that \p setVal is not modified by \p clearVal. Any bits
536/// set in \p setVal are unconditionally set in \p reg, whereas
537/// \ref McciArm_putRegMasked only changes bits that are set
538/// in its \c maskVal parameter.
539///
540/// \see McciArm_putRegMasked
541///
542__attribute__((__always_inline__))
543static inline uint32_t
544McciArm_putRegClearSet(uint32_t reg, uint32_t clearVal, uint32_t setVal)
545 {
546 uint32_t const rValue = McciArm_getReg(reg);
547
548 return McciArm_putReg(
549 reg,
550 (rValue & ~clearVal) | setVal
551 );
552 }
553
554///
555/// \brief store to cm7 register under mask
556///
557/// \param [in] reg register to be modified
558/// \param [in] maskVal mask of bits to be modified
559/// \param [in] modVal where \p maskVal is 1, provides values of bits
560///
561/// \note this is subtly different than \ref McciArm_putRegClearSet,
562/// in that any bits in \b ~maskVal are not changed, regardless of
563/// corresponding bits in \p modVal.
564///
565/// \see McciArm_putRegClearSet
566/// \see https://graphics.stanford.edu/~seander/bithacks.html#MaskedMerge
567///
568__attribute__((__always_inline__))
569static inline uint32_t
570McciArm_putRegMasked(uint32_t reg, uint32_t maskVal, uint32_t modVal)
571 {
572 uint32_t const rValue = McciArm_getReg(reg);
573
574 return McciArm_putReg(
575 reg,
576 rValue ^ ((rValue ^ modVal) & maskVal)
577 /* same as (rValue & ~maskVal) | (modVal & maskVal) */
578 );
579 }
580
581/****************************************************************************\
582|
583| ARM intrinsics (some of then)
584|
585\****************************************************************************/
586
587#if defined(__GNUC__) // GCC or clang, likely
588
589///
590/// \brief set main stack pointer
591///
592/// \param[in] stack new stack pointer value.
593///
594/// \note This always must be inline because once stack pointer changes,
595/// maybe hard to return!
596///
597__attribute__((__always_inline__)) static inline
598void
599McciArm_setMSP(
600 uint32_t stack
601 )
602 {
603 __asm volatile ("MSR msp,%0\n" :: "r"(stack): );
604 }
605
606///
607/// \brief get priority mask
608///
609/// \return current value of PRIMASK register
610///
611/// \note only bit 0 is implemented on CM7 CPUs. If cleared, it enables
612/// interrupts; if set it disables interrupts.
613///
614__attribute__((__always_inline__)) static inline
615uint32_t
616McciArm_getPRIMASK(
617 void
618 )
619 {
620 uint32_t primask;
621
622 __asm volatile ("MRS %0,primask" : "=r"(primask));
623 return primask;
624 }
625
626///
627/// \brief set priority mask
628///
629/// \param [in] primask new value of PRIMASK register
630///
631/// \note only bit 0 is implemented on CM7 CPUs. If cleared, it enables
632/// interrupts; if set it disables interrupts.
633///
634__attribute__((__always_inline__)) static inline
635void
636McciArm_setPRIMASK(
637 uint32_t primask
638 )
639 {
640 __asm volatile ("MSR primask,%0" :: "r"(primask) : "memory");
641 }
642
643///
644/// \brief Disable interrupts and return previous state
645///
646/// \return previous value of PRIMASK register.
647///
648__attribute__((__always_inline__)) static inline
649uint32_t
650McciArm_disableInterrupts(
651 void
652 )
653 {
654 uint32_t const primask = McciArm_getPRIMASK();
655 __asm volatile ("cpsid i" ::: "memory");
656 return primask;
657 }
658
659///
660/// \brief insert a instruction synchronization barrier
661///
662/// \details
663/// Force flush the pipeline in the processor, so that all instructions
664/// following the ISB are fetched from cache or memory, after the
665/// instruction has been completed.
666///
667__attribute__((always_inline)) static inline
668void McciArm_InstructionSynchBarrier(
669 void
670 )
671 {
672 __asm volatile ("isb 0xF" ::: "memory");
673 }
674
675///
676/// \brief insert a data synchronization barrier
677///
678/// \details
679/// Force all pending memory operations to complete before
680/// continuing.
681///
682__attribute__((always_inline)) static inline
683void McciArm_DataSynchBarrier(
684 void
685 )
686 {
687 __asm volatile ("dsb 0xF" ::: "memory");
688 }
689
690///
691/// \brief enable NVIC interrupt
692///
693/// \details
694/// Enable NVIC interrupt
695///
696/// \param [in] interruptNumber device specific interrupt number
697///
698__attribute__((always_inline)) static inline
699void McciArm_NvicEnableIrq(
700 uint32_t interruptNumber
701 )
702 {
703 if (interruptNumber < MCCI_CM7_IRQ_BASE)
704 {
705 __asm volatile ("" ::: "memory");
707 MCCI_CM7_NVIC_ISER + (interruptNumber >> 5) * 4,
708 (1u << (interruptNumber & 31u))
709 );
710 __asm volatile ("" ::: "memory");
711 }
712 }
713
714///
715/// \brief disable NVIC interrupt
716///
717/// \details
718/// Disable NVIC interrupt
719///
720/// \param [in] interruptNumber device specific interrupt number
721///
722__attribute__((always_inline)) static inline
723void McciArm_NvicDisableIrq(
724 uint32_t interruptNumber
725 )
726 {
727 if (interruptNumber < MCCI_CM7_IRQ_BASE)
728 {
730 MCCI_CM7_NVIC_ICER + (interruptNumber >> 5) * 4,
731 (1u << (interruptNumber & 31u))
732 );
733 __asm volatile ("dsb 0xF" ::: "memory");
734 __asm volatile ("isb 0xF" ::: "memory");
735 }
736 }
737
738///
739/// \brief get NVIC interrupt enable state
740///
741/// \details
742/// Get NVIC interrupt enable state
743///
744/// \param [in] interruptNumber device specific interrupt number
745///
746/// \return interrupt enable state
747///
748__attribute__((always_inline)) static inline
749int McciArm_NvicGetEnableIrq(
750 uint32_t interruptNumber
751 )
752 {
753 if (interruptNumber < MCCI_CM7_IRQ_BASE)
754 {
755 return McciArm_getReg(
756 MCCI_CM7_NVIC_ISER + (interruptNumber >> 5) * 4
757 ) & (1u << (interruptNumber & 31u)) ? 1 : 0;
758 }
759 else
760 {
761 return 0;
762 }
763 }
764
765///
766/// \brief get NVIC interrupt pending state
767///
768/// \details
769/// Get NVIC interrupt pending state
770///
771/// \param [in] interruptNumber device specific interrupt number
772///
773/// \return interrupt pending state. 1 is interrupt pending.
774///
775__attribute__((always_inline)) static inline
776int McciArm_NvicGetPendingIrq(
777 uint32_t interruptNumber
778 )
779 {
780 if (interruptNumber < MCCI_CM7_IRQ_BASE)
781 {
782 return McciArm_getReg(
783 MCCI_CM7_NVIC_ISPR + (interruptNumber >> 5) * 4
784 ) & (1u << (interruptNumber & 31u)) ? 1 : 0;
785 }
786 else
787 {
788 return 0;
789 }
790 }
791
792///
793/// \brief set NVIC interrupt pending state
794///
795/// \details
796/// Set NVIC interrupt pending state
797///
798/// \param [in] interruptNumber device specific interrupt number
799///
800__attribute__((always_inline)) static inline
801void McciArm_NvicSetPendingIrq(
802 uint32_t interruptNumber
803 )
804 {
805 if (interruptNumber < MCCI_CM7_IRQ_BASE)
806 {
808 MCCI_CM7_NVIC_ISPR + (interruptNumber >> 5) * 4,
809 (1u << (interruptNumber & 31u))
810 );
811 }
812 }
813
814///
815/// \brief clear NVIC interrupt pending state
816///
817/// \details
818/// Clear NVIC interrupt pending state
819///
820/// \param [in] interruptNumber device specific interrupt number
821///
822__attribute__((always_inline)) static inline
823void McciArm_NvicClearPendingIrq(
824 uint32_t interruptNumber
825 )
826 {
827 if (interruptNumber < MCCI_CM7_IRQ_BASE)
828 {
830 MCCI_CM7_NVIC_ICPR + (interruptNumber >> 5) * 4,
831 (1u << (interruptNumber & 31u))
832 );
833 }
834 }
835
836///
837/// \brief set NVIC priority group
838///
839/// \details
840/// Set NVIC priority group
841///
842/// \param [in] priorityGroup priority grouping field
843///
844__attribute__((always_inline)) static inline
845void McciArm_NvicSetPriorityGroup(
846 uint32_t priorityGroup
847 )
848 {
853 );
854 }
855
856///
857/// \brief get NVIC priority group
858///
859/// \details
860/// Get NVIC priority group
861///
862/// \return priority grouping field
863///
864__attribute__((always_inline)) static inline
865uint32_t McciArm_NvicGetPriorityGroup(
866 void
867 )
868 {
872 );
873 }
874
875///
876/// \brief set NVIC interrupt priority
877///
878/// \details
879/// Set NVIC interrupt priority
880///
881/// \param [in] interruptNumber Specific interrupt number
882/// \param [in] priority Priority to set
883///
884__attribute__((always_inline)) static inline
885void McciArm_NvicSetPriority(
886 uint32_t interruptNumber,
887 uint32_t priority
888 )
889 {
890 if (interruptNumber < MCCI_CM7_IRQ_BASE)
891 {
892 *(volatile uint8_t *)(MCCI_CM7_NVIC_IPR + interruptNumber) =
893 (uint8_t)(priority << 4);
894 }
895 else if (interruptNumber >= MCCI_CM7_IRQ_MemoryManagement)
896 {
897 *(volatile uint8_t *)(MCCI_CM7_SCB_SHPR1 + interruptNumber - MCCI_CM7_IRQ_MemoryManagement) =
898 (uint8_t)(priority << 4);
899 }
900 }
901
902///
903/// \brief get NVIC interrupt priority
904///
905/// \details
906/// Get NVIC interrupt priority
907///
908/// \param [in] interruptNumber Specific interrupt number
909///
910/// \return interrupt priority
911///
912__attribute__((always_inline)) static inline
913uint32_t McciArm_NvicGetPriority(
914 uint32_t interruptNumber
915 )
916 {
917 if (interruptNumber < MCCI_CM7_IRQ_BASE)
918 {
919 return *(volatile uint8_t *)(MCCI_CM7_NVIC_IPR + interruptNumber) >> 4;
920 }
921 else if (interruptNumber >= MCCI_CM7_IRQ_MemoryManagement)
922 {
923 return *(volatile uint8_t *)(MCCI_CM7_SCB_SHPR1 + interruptNumber - MCCI_CM7_IRQ_MemoryManagement) >> 4;
924 }
925 else
926 {
927 return 0;
928 }
929 }
930
931///
932/// \brief system reset
933///
934/// \details
935/// Initiate a system reset request to reset the MCU.
936///
937__attribute__((__noreturn__)) __attribute__((always_inline)) static inline
938void McciArm_NvicSystemReset(
939 void
940 )
941 {
942 __asm volatile ("dsb 0xF" ::: "memory");
947 );
948 __asm volatile ("dsb 0xF" ::: "memory");
949 for (;;)
950 {
951 __asm volatile ("nop");
952 }
953 }
954
955#else
956# error "Compiler not supported"
957#endif
958
959/****************************************************************************\
960|
961| Vectors and so forth
962|
963\****************************************************************************/
964
965///
966/// \brief application entry contents
967///
968/// Every Cortex M7 application begins with two DWORDs. The first is
969/// the stack pointer; the second is the program counter.
970///
971/// We use MCCI Russian Doll structure nesting; this is the root
972/// of the hierarchy that forms the page zero vectors.
973///
974typedef struct Mcci_CortexAppEntryContents_s
975 {
976 uint32_t stack; //< Initial stack pointer must be multiple of 4
977 uint32_t entry; //< Initial entry point; must be odd.
979
980///
981/// \brief application entry object
982///
983/// This union wraps the app entry contents, so that we can always reference
984/// with a consistent name (`AppEntry.stack` etc.), regardless of how general
985/// or specific the pointer is.
986///
987typedef union Mcci_CortexAppEntry_u
988 {
989 Mcci_CortexAppEntryContents_t CortexAppEntry; //< reference name for application entry view.
991
992///
993/// \brief Cortex M7 interrupt vectors (low level view)
994///
995/// This structure represents the vectors page as an array of 256 32-bit vectors.
996/// It's used mostly for initialization and for building up larger structures.
997///
998typedef struct Mcci_CortexM7VectorsContents_s
999 {
1000 uint32_t vectors[256];
1002
1003///
1004/// \brief Cortex M7 interrupt vector object
1005///
1006/// This union wraps the interrupt vector contents, both so we can always
1007/// reference fields with consistent names (`AppEntry.stack` etc.), and to allow
1008/// us to view the vectors as either an AppEntry description or a table of
1009/// vectors.
1010///
1011typedef union Mcci_CortexM7Vectors_u
1012 {
1013 Mcci_CortexAppEntryContents_t CortexAppEntry; //< View instance as a CortexM7 AppEntry.
1014 Mcci_CortexAppEntry_t CortexAppEntryCast; //< Downcast to an AppEntry without explicit casting
1015 Mcci_CortexM7VectorsContents_t CortexVectors; //< View instance as vectors.
1017
1018/****************************************************************************\
1019|
1020| End of file
1021|
1022\****************************************************************************/
1023
1024#ifdef __cplusplus
1025}
1026#endif
1027
1028#endif /* _mcci_arm_cm7_h_ */
static uint32_t McciArm_putRegOr(uint32_t reg, uint32_t orVal)
or 32-bit values to a cm7 register
static uint32_t McciArm_getReg(uint32_t reg)
read a 32-bit value from a cm7 register
#define MCCI_CM7_NVIC_ISER
#define MCCI_CM7_IRQ_BASE
Cortex-M Processor Exception Number Base.
static uint32_t McciArm_putReg(uint32_t reg, uint32_t val)
write a 32-bit value to a cm7 register
#define MCCI_CM7_NVIC_ISPR
#define MCCI_CM7_SCB_SHPR3
#define MCCI_CM7_SCB_AIRCR_SYSRESETREQ
System reset request.
#define MCCI_CM7_SCB_AIRCR_VECTKEY
Vector key.
#define MCCI_CM7_SCB_AIRCR
static uint32_t McciArm_putRegClear(uint32_t reg, uint32_t clearVal)
clear out 32-bit values to a cm7 register
#define MCCI_CM7_SCB_SHPR1
#define MCCI_CM7_SCB_SHPR2
#define MCCI_CM7_NVIC_ICPR
static uint32_t McciCm7_SCB_SHPR_getRegister(uint32_t handlerIndex)
return register for a given handler index
#define MCCI_CM7_NVIC_ICER
static uint32_t McciArm_putRegClearSet(uint32_t reg, uint32_t clearVal, uint32_t setVal)
clear and set 32-bit values to a cm7 register
#define MCCI_CM7_NVIC_IPR
#define MCCI_CM7_SCB_AIRCR_VECTKEY_VALUE
Value to write to unlock register.
#define MCCI_CM7_SCB_AIRCR_PRIGROUP_N(n)
static uint32_t McciArm_putRegMasked(uint32_t reg, uint32_t maskVal, uint32_t modVal)
store to cm7 register under mask
static uint32_t McciCm7_SCB_SHPR_getMask(uint32_t handlerIndex)
return byte mask for a given handler index
static uint32_t McciArm_putRegAndOr(uint32_t reg, uint32_t andVal, uint32_t orVal)
and/or 32-bit values to a cm7 register
#define MCCI_CM7_IRQ_MemoryManagement
Cortex-M Memory Management Interrupt.
#define MCCI_CM7_SCB_AIRCR_PRIGROUP
Priority grouping position.
#define MCCI_BOOTLOADER_VALUE_GET_FIELD(val, fmask)
application entry contents
Cortex M7 interrupt vectors (low level view)
application entry object
Cortex M7 interrupt vector object.
Mcci_CortexAppEntry_t CortexAppEntryCast
Mcci_CortexAppEntryContents_t CortexAppEntry
Mcci_CortexM7VectorsContents_t CortexVectors