Update microzig (#26)

* update microzig

* update to new api

---------

Co-authored-by: mattnite <mattnite@users.noreply.github.com>
wch-ch32v003
Matt Knight 2 years ago committed by GitHub
parent 58d73abc08
commit 3b129e1ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,11 +2,12 @@ const std = @import("std");
const Builder = std.build.Builder; const Builder = std.build.Builder;
const Pkg = std.build.Pkg; const Pkg = std.build.Pkg;
const comptimePrint = std.fmt.comptimePrint; const comptimePrint = std.fmt.comptimePrint;
const FileSource = std.build.FileSource;
pub const microzig = @import("deps/microzig/build.zig"); pub const microzig = @import("deps/microzig/build.zig");
const chips = @import("src/chips.zig"); pub const chips = @import("src/chips.zig");
const boards = @import("src/boards.zig"); pub const boards = @import("src/boards.zig");
const linkerscript_path = root() ++ "rp2040.ld"; const linkerscript_path = root() ++ "rp2040.ld";
@ -14,24 +15,23 @@ pub const BuildOptions = struct {
optimize: std.builtin.OptimizeMode, optimize: std.builtin.OptimizeMode,
}; };
pub const PicoExecutableOptions = struct {
name: []const u8,
source_file: FileSource,
optimize: std.builtin.OptimizeMode = .Debug,
};
pub fn addPiPicoExecutable( pub fn addPiPicoExecutable(
builder: *Builder, builder: *Builder,
name: []const u8, opts: PicoExecutableOptions,
source: []const u8,
options: BuildOptions,
) *microzig.EmbeddedExecutable { ) *microzig.EmbeddedExecutable {
const ret = microzig.addEmbeddedExecutable( return microzig.addEmbeddedExecutable(builder, .{
builder, .name = opts.name,
name, .source_file = opts.source_file,
source, .backing = .{ .board = boards.raspberry_pi_pico },
.{ .board = boards.raspberry_pi_pico }, .optimize = opts.optimize,
.{ .linkerscript_source_file = .{ .path = linkerscript_path },
.optimize = options.optimize, });
},
);
ret.inner.setLinkerScriptPath(.{ .path = linkerscript_path });
return ret;
} }
// this build script is mostly for testing and verification of this // this build script is mostly for testing and verification of this
@ -61,12 +61,11 @@ pub const Examples = struct {
inline for (@typeInfo(Examples).Struct.fields) |field| { inline for (@typeInfo(Examples).Struct.fields) |field| {
const path = comptime root() ++ "examples/" ++ field.name ++ ".zig"; const path = comptime root() ++ "examples/" ++ field.name ++ ".zig";
@field(ret, field.name) = addPiPicoExecutable( @field(ret, field.name) = addPiPicoExecutable(b, .{
b, .name = field.name,
field.name, .source_file = .{ .path = path },
path, .optimize = optimize,
.{ .optimize = optimize }, });
);
} }
return ret; return ret;

2
deps/microzig vendored

@ -1 +1 @@
Subproject commit 11214ed8ba05e380a516beef3f3f594571a1c732 Subproject commit b6fc3abbf7a91cb0cdafc7843ac7e6c26042ff84

@ -12,7 +12,9 @@ const baud_rate = 115200;
const uart_tx_pin = 0; const uart_tx_pin = 0;
const uart_rx_pin = 1; const uart_rx_pin = 1;
pub const log = rp2040.uart.log; pub const std_options = struct {
pub const logFn = rp2040.uart.log;
};
pub fn init() void { pub fn init() void {
rp2040.clock_config.apply(); rp2040.clock_config.apply();

@ -18,8 +18,10 @@ pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noretu
while (true) {} while (true) {}
} }
pub const log_level = .debug; pub const std_options = struct {
pub const log = rp2040.uart.log; pub const log_level = .debug;
pub const logFn = rp2040.uart.log;
};
pub fn main() !void { pub fn main() !void {
gpio.reset(); gpio.reset();

Loading…
Cancel
Save