Skip to content

Commit c1def48

Browse files
committed
add better fault identification for Cortex-M3/M33/M4/M7 hardfault handlers, add fault description registers to SCB_Type
1 parent 24d3e25 commit c1def48

File tree

4 files changed

+463
-70
lines changed

4 files changed

+463
-70
lines changed

src/device/arm/arm.go

-35
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,8 @@ const (
7676
SCS_BASE = 0xE000E000
7777
SYST_BASE = SCS_BASE + 0x0010
7878
NVIC_BASE = SCS_BASE + 0x0100
79-
SCB_BASE = SCS_BASE + 0x0D00
8079
)
8180

82-
const (
83-
SCB_AIRCR_VECTKEY_Pos = 16
84-
SCB_AIRCR_SYSRESETREQ_Pos = 2
85-
SCB_AIRCR_SYSRESETREQ_Msk = 1 << SCB_AIRCR_SYSRESETREQ_Pos
86-
)
87-
88-
// System Control Block (SCB)
89-
//
90-
// SCB_Type provides the definitions for the System Control Block Registers.
91-
type SCB_Type struct {
92-
CPUID volatile.Register32 // CPUID Base Register
93-
ICSR volatile.Register32 // Interrupt Control and State Register
94-
VTOR volatile.Register32 // Vector Table Offset Register
95-
AIRCR volatile.Register32 // Application Interrupt and Reset Control Register
96-
SCR volatile.Register32 // System Control Register
97-
CCR volatile.Register32 // Configuration Control Register
98-
_ volatile.Register32 // RESERVED1;
99-
SHP [2]volatile.Register32 // System Handlers Priority Registers. [0] is RESERVED
100-
SHCSR volatile.Register32 // System Handler Control and State Register
101-
}
102-
103-
var SCB = (*SCB_Type)(unsafe.Pointer(uintptr(SCB_BASE)))
104-
10581
// Nested Vectored Interrupt Controller (NVIC).
10682
//
10783
// Source:
@@ -213,17 +189,6 @@ func EnableInterrupts(mask uintptr) {
213189
})
214190
}
215191

216-
// SystemReset performs a hard system reset.
217-
func SystemReset() {
218-
// SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
219-
// SCB_AIRCR_SYSRESETREQ_Msk);
220-
SCB.AIRCR.Set((0x5FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk)
221-
222-
for {
223-
Asm("wfi")
224-
}
225-
}
226-
227192
// Set up the system timer to generate periodic tick events.
228193
// This will cause SysTick_Handler to fire once per tick.
229194
// The cyclecount parameter is a counter value which can range from 0 to

0 commit comments

Comments
 (0)