Skip to content

Commit ff45d4f

Browse files
authored
Specify device for stm32 (#889)
Instead of having to ingest and generate all the register information for all stm32 chips, give regz the ability to only generate for one. This has the added benefit that when you look at the generated code, you only see the peripheral types that are used by your device.
1 parent 617f65c commit ff45d4f

7 files changed

Lines changed: 5637 additions & 1410 deletions

File tree

build-internals/build.zig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,11 @@ pub const Chip = struct {
142142
/// Use the provided file directly as the chip file.
143143
zig: LazyPath,
144144

145-
/// Path to embassy stm32-data directory
146-
embassy: LazyPath,
145+
/// Path to embassy stm32-data directory with optional device filter
146+
embassy: struct {
147+
path: LazyPath,
148+
device: ?[]const u8 = null,
149+
},
147150

148151
/// Single device from TI targetdb
149152
targetdb: struct {

build.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub fn MicroBuild(port_select: PortSelect) type {
416416
regz_run.addFileArg(file);
417417
break :blk chips_dir.path(b, b.fmt("{s}.zig", .{target.chip.name}));
418418
},
419-
.embassy => |path| blk: {
419+
.embassy => |embassy| blk: {
420420
const regz_run = b.addRunArtifact(regz_exe);
421421

422422
regz_run.addArg("--format");
@@ -430,7 +430,12 @@ pub fn MicroBuild(port_select: PortSelect) type {
430430
regz_run.addFileArg(patch_file);
431431
}
432432

433-
regz_run.addDirectoryArg(path);
433+
if (embassy.device) |device| {
434+
regz_run.addArg("--device");
435+
regz_run.addArg(device);
436+
}
437+
438+
regz_run.addDirectoryArg(embassy.path);
434439
break :blk chips_dir.path(b, b.fmt("{s}.zig", .{target.chip.name}));
435440
},
436441
.targetdb => |targetdb| blk: {

0 commit comments

Comments
 (0)