diff --git a/build.zig b/build.zig index c95adc3a..23a8a2a5 100644 --- a/build.zig +++ b/build.zig @@ -463,7 +463,7 @@ pub fn MicroBuild(port_select: PortSelect) type { .linkage = .static, .root_source_file = mb.core_dep.path("src/start.zig"), .strip = options.strip, - .unwind_tables = true, + .unwind_tables = .sync, }), .app_mod = app_mod, .target = target, diff --git a/drivers/stepper/stepper.zig b/drivers/stepper/stepper.zig index 7025e82e..d77bfc5d 100644 --- a/drivers/stepper/stepper.zig +++ b/drivers/stepper/stepper.zig @@ -233,7 +233,7 @@ pub fn Stepper(comptime Driver: type) type { .constant_speed => { self.steps_to_cruise = 0; self.steps_to_brake = 0; - self.cruise_step_pulse = step_pulse(self.motor_steps, self.microsteps, self.rpm); + self.cruise_step_pulse = get_step_pulse(self.motor_steps, self.microsteps, self.rpm); self.step_pulse = self.cruise_step_pulse; if (@intFromEnum(time) > self.steps_remaining * @intFromEnum(self.step_pulse)) { self.step_pulse = mdf.time.Duration.from_us(@intFromFloat(@as(f64, @floatFromInt(time.to_us())) / @@ -243,7 +243,7 @@ pub fn Stepper(comptime Driver: type) type { } } - inline fn step_pulse(steps: i32, microsteps: u8, rpm: f64) mdf.time.Duration { + inline fn get_step_pulse(steps: i32, microsteps: u8, rpm: f64) mdf.time.Duration { return @enumFromInt(@as(u64, @intFromFloat(60.0 * 1000000 / @as(f64, @floatFromInt(steps)) / @as(f64, @floatFromInt(microsteps)) / rpm))); diff --git a/port/raspberrypi/rp2xxx/build.zig b/port/raspberrypi/rp2xxx/build.zig index 4d4f0103..cfe3d50d 100644 --- a/port/raspberrypi/rp2xxx/build.zig +++ b/port/raspberrypi/rp2xxx/build.zig @@ -69,7 +69,7 @@ pub fn init(dep: *std.Build.Dependency) Self { .{ .kind = .flash, .offset = 0x10000000, .length = 2048 * 1024 }, .{ .kind = .ram, .offset = 0x20000000, .length = 256 * 1024 }, }, - .patches = @import("patches/rp2350_arm.zig").patches, + .patches = @import("patches/rp2350.zig").patches, }, .hal = hal, .linker_script = b.path("rp2350_arm.ld"), @@ -105,7 +105,14 @@ pub fn init(dep: *std.Build.Dependency) Self { .{ .kind = .flash, .offset = 0x10000000, .length = 256 }, .{ .kind = .ram, .offset = 0x20000000, .length = 256 * 1024 }, }, - .patches = @import("patches/rp2350_riscv.zig").patches, + .patches = @import("patches/rp2350.zig").patches ++ [_]microzig.Patch{ + .{ + .override_arch = .{ + .device_name = "RP2350", + .arch = .hazard3, + }, + }, + }, }, .hal = hal, .linker_script = b.path("rp2350_riscv.ld"), diff --git a/port/raspberrypi/rp2xxx/patches/rp2350_arm.zig b/port/raspberrypi/rp2xxx/patches/rp2350.zig similarity index 98% rename from port/raspberrypi/rp2xxx/patches/rp2350_arm.zig rename to port/raspberrypi/rp2xxx/patches/rp2350.zig index 51319659..8cd6efe8 100644 --- a/port/raspberrypi/rp2xxx/patches/rp2350_arm.zig +++ b/port/raspberrypi/rp2xxx/patches/rp2350.zig @@ -1,4 +1,7 @@ -pub const patches = &.{ +const microzig = @import("microzig/build-internals"); +const Patch = microzig.Patch; + +pub const patches: []const Patch = &.{ .{ .add_enum = .{ .parent = "types.peripherals.USB_DPRAM", .@"enum" = .{ diff --git a/port/raspberrypi/rp2xxx/patches/rp2350_riscv.zig b/port/raspberrypi/rp2xxx/patches/rp2350_riscv.zig deleted file mode 100644 index 1424339c..00000000 --- a/port/raspberrypi/rp2xxx/patches/rp2350_riscv.zig +++ /dev/null @@ -1,95 +0,0 @@ -pub const patches = &.{ - .{ .override_arch = .{ - .device_name = "RP2350", - .arch = .hazard3, - } }, - .{ .add_enum = .{ - .parent = "types.peripherals.USB_DPRAM", - .@"enum" = .{ - .name = "EndpointType", - .bitsize = 2, - .fields = &.{ - .{ .value = 0x0, .name = "control" }, - .{ .value = 0x1, .name = "isochronous" }, - .{ .value = 0x2, .name = "bulk" }, - .{ .value = 0x3, .name = "interrupt" }, - }, - }, - } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP1_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP1_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP2_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP2_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP3_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP3_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP4_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP4_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP5_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP5_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP6_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP6_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP7_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP7_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP8_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP8_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP9_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP9_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP10_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP10_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP11_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP11_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP12_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP12_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP13_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP13_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP14_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP14_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP15_IN_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .set_enum_type = .{ .of = "types.peripherals.USB_DPRAM.EP15_OUT_CONTROL.ENDPOINT_TYPE", .to = "types.peripherals.USB_DPRAM.EndpointType" } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 40, - .name = "PROC0_IRQ_CTI", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 41, - .name = "PROC1_IRQ_CTI", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 46, - .name = "SPAREIRQ_IRQ_0", - .description = "Spare interrupt 0 (triggered only by software)", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 47, - .name = "SPAREIRQ_IRQ_1", - .description = "Spare interrupt 1 (triggered only by software)", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 48, - .name = "SPAREIRQ_IRQ_2", - .description = "Spare interrupt 2 (triggered only by software)", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 49, - .name = "SPAREIRQ_IRQ_3", - .description = "Spare interrupt 3 (triggered only by software)", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 50, - .name = "SPAREIRQ_IRQ_4", - .description = "Spare interrupt 4 (triggered only by software)", - } }, - .{ .add_interrupt = .{ - .device_name = "RP2350", - .idx = 51, - .name = "SPAREIRQ_IRQ_5", - .description = "Spare interrupt 5 (triggered only by software)", - } }, -};