Move handler from main to rp2040
This commit is contained in:
parent
75943973c9
commit
ab7adcbc97
20
src/main.zig
20
src/main.zig
|
@ -5,30 +5,12 @@ const map = @import("map.zig");
|
|||
|
||||
const core = @import("microzig");
|
||||
|
||||
// pub const microzig_options = robot.microzig_options;
|
||||
|
||||
// microzig.Options
|
||||
// microzig.core.Options
|
||||
// type
|
||||
// .
|
||||
// @import("start.zig").Options
|
||||
// microzig.start.Options
|
||||
//
|
||||
|
||||
// const pins = robot.pins;
|
||||
fn gpio_handler () callconv(.C) void {
|
||||
robot.pins.led_1.put(1);
|
||||
}
|
||||
|
||||
pub const microzig_options = .{
|
||||
.interrupts = .{
|
||||
.IO_IRQ_BANK0 = core.interrupt.Handler {
|
||||
.C = &gpio_handler
|
||||
.C = robot.gpio_handler
|
||||
}
|
||||
|
||||
// .IO_IRQ_BANK0 = &gpio_handler,
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
pub fn main() !noreturn {
|
||||
|
|
|
@ -207,28 +207,22 @@ const pin_config = hal.pins.GlobalConfiguration {
|
|||
},
|
||||
};
|
||||
|
||||
fn gpio_handler () void {
|
||||
pub fn gpio_handler () callconv(.C) void {
|
||||
pins.led_1.put(1);
|
||||
// Acknowledge
|
||||
// Write to INTR reg
|
||||
// Again
|
||||
// * INTR0 is 0-7,
|
||||
// * INTR1 is 8-15,
|
||||
// * INTR2 is 16-23,
|
||||
// * INTR2 is 16-23, (we want this one, for pin 18 again)
|
||||
// * INTR3 is 24-31,
|
||||
const INTR2: *volatile u32 = @ptrFromInt(0x40014000 + 0x0f8);
|
||||
const IOBANK0 = 0x40014000;
|
||||
const INTR2: *volatile u32 = @ptrFromInt(IOBANK0 + 0x0f8);
|
||||
// Again, we only care about setting bit 10, GPIO2_EDGE_LOW
|
||||
// But might as well clear all of them
|
||||
INTR2.* = 0;
|
||||
|
||||
}
|
||||
|
||||
pub const microzig_options = microzig.Options{
|
||||
.interrupts = .{
|
||||
.IO_IRQ_BANK0 = gpio_handler
|
||||
},
|
||||
};
|
||||
|
||||
pub var pins: hal.pins.Pins(pin_config) = undefined;
|
||||
|
||||
pub fn pin_error(error_code: u6) noreturn {
|
||||
|
|
Loading…
Reference in New Issue