interrupt driver
parent
69c9c4a84d
commit
c539462ef7
@ -0,0 +1,40 @@
|
||||
var vector_table: [256] *const fn () void = undefined;
|
||||
var vtor: *u32 = @ptrFromInt(0xE000ED08);
|
||||
|
||||
pub const vector = enum(u8) {
|
||||
NMI = 2,
|
||||
HardFault,
|
||||
MemManage,
|
||||
BusFault,
|
||||
UsageFault,
|
||||
rsvd7,
|
||||
rsvd8,
|
||||
rsvd9,
|
||||
rsvd10,
|
||||
SVCall,
|
||||
DebugMonitor,
|
||||
rsvd13,
|
||||
PendSV,
|
||||
SysTick,
|
||||
};
|
||||
|
||||
pub fn initialize() void {
|
||||
register(.NMI, nmi);
|
||||
register(.HardFault, hardfault);
|
||||
register(.MemManage, memmanage);
|
||||
register(.BusFault, busfault);
|
||||
register(.UsageFault, usagefault);
|
||||
|
||||
vtor.* = @as(u32, @intFromPtr(&vector_table));
|
||||
}
|
||||
|
||||
pub fn register(index: vector, handler: *const fn () void) void {
|
||||
vector_table[@intFromEnum(index)] = handler;
|
||||
}
|
||||
|
||||
fn nmi() void { while (true) {} }
|
||||
fn hardfault() void { while (true) {} }
|
||||
fn memmanage() void { while (true) {} }
|
||||
fn busfault() void { while (true) {} }
|
||||
fn usagefault() void { while (true) {} }
|
||||
|
Loading…
Reference in New Issue