Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/stmicro/stm32/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn build(b: *std.Build) void {
const stm32 = mb.ports.stm32;

const available_examples = [_]Example{
.{ .target = stm32.boards.stm32f303nucleo, .name = "stm32f303nucleo_Blinky", .file = "src/blinky.zig" },
.{ .target = stm32.boards.stm32f3discovery, .name = "stm32f3discovery", .file = "src/blinky.zig" },
// TODO: stm32.pins.GlobalConfiguration is not available on those targets
// .{ .target = stm32.chips.stm32f407vg, .name = "stm32f407vg", .file = "src/blinky.zig" },
Expand All @@ -25,7 +26,6 @@ pub fn build(b: *std.Build) void {
.{ .target = stm32.boards.stm32l476discovery, .name = "STM32L476Discovery_Lcd", .file = "src/stm32l476/lcd.zig" },
.{ .target = stm32.boards.stm32l476discovery, .name = "STM32L476Discovery_Blinky", .file = "src/blinky.zig" },
.{ .target = stm32.boards.stm32l476discovery, .name = "STM32L476Discovery_HTS221", .file = "src/hts221.zig" },

.{ .target = stm32.chips.STM32F103C8, .name = "STM32F1xx_blink", .file = "src/blinky.zig" },
.{ .target = stm32.chips.STM32F100RB, .name = "STM32F1xx_semihost", .file = "src/semihosting.zig" }, //QEMU target: stm32vldiscovery
.{ .target = stm32.chips.STM32F103C8, .name = "STM32F1xx_adc", .file = "src/stm32f1xx/adc.zig" },
Expand Down
9 changes: 6 additions & 3 deletions examples/stmicro/stm32/src/blinky.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pub fn main() !void {
pins.led,
};
break :res .{ pins, all_leds };
} else if (comptime microzig.config.board_name != null and std.mem.eql(u8, microzig.config.board_name.?, "STM32F303NUCLEO")) {
const pins = board.leds_config.apply();
const all_leds = .{
pins.LD2,
};
break :res .{ pins, all_leds };
} else if (comptime microzig.config.board_name != null and std.mem.eql(u8, microzig.config.board_name.?, "STM32F3DISCOVERY")) {
const pins = board.leds_config.apply();
const all_leds = .{
Expand All @@ -33,16 +39,13 @@ pub fn main() !void {
pins.LD9,
pins.LD10,
};

break :res .{ pins, all_leds };
} else if (comptime microzig.config.board_name != null and std.mem.eql(u8, microzig.config.board_name.?, "STM32L476DISCOVERY")) {
const pins = board.leds_config.apply();

const all_leds = .{
pins.LD4,
pins.LD5,
};

break :res .{ pins, all_leds };
} else {
@compileError("blinky is not (yet?) implemented for this target");
Expand Down
11 changes: 11 additions & 0 deletions port/stmicro/stm32/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ boards: struct {
stm32f4discovery: *const microzig.Target,
stm3240geval: *const microzig.Target,
stm32f429idiscovery: *const microzig.Target,
stm32f303nucleo: *const microzig.Target,
},

pub fn init(dep: *std.Build.Dependency) Self {
Expand All @@ -30,6 +31,16 @@ pub fn init(dep: *std.Build.Dependency) Self {
return .{
.chips = chips,
.boards = .{
.stm32f303nucleo = chips.STM32F303RE.derive(.{
.board = .{
.name = "STM32F303NUCLEO",
.root_source_file = b.path("src/boards/STM32F303NUCLEO.zig"),
},
.hal = microzig.HardwareAbstractionLayer{
.root_source_file = b.path("src/hals/STM32F303.zig"),
},
.stack = .{ .ram_region_name = "CCMRAM" },
}),
.stm32l476discovery = chips.STM32L476VG.derive(.{
.board = .{
.name = "STM32L476DISCOVERY",
Expand Down
11 changes: 11 additions & 0 deletions port/stmicro/stm32/src/boards/STM32F303NUCLEO.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const std = @import("std");

pub const microzig = @import("microzig");

pub const hal = microzig.hal;

pub const leds_config = (hal.pins.GlobalConfiguration{
.GPIOA = .{
.PIN5 = .{ .name = "LD2", .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
},
});
Loading