Skip to content
Open
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
5 changes: 3 additions & 2 deletions examples/stmicro/stm32/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ pub fn build(b: *std.Build) void {
const available_examples = [_]Example{
.{ .target = stm32.boards.stm32f3discovery, .name = "stm32f3discovery", .file = "src/blinky.zig" },
// TODO: stm32.pins.GlobalConfiguration is not available on those targets
// .{ .target = stm32.chips.stm32f303vc, .name = "stm32f303vc", .file = "src/blinky.zig" },
// .{ .target = stm32.chips.stm32f407vg, .name = "stm32f407vg", .file = "src/blinky.zig" },
// .{ .target = stm32.chips.stm32f429zit6u, .name = "stm32f429zit6u", .file = "src/blinky.zig" },
// .{ .target = stm32.boards.stm32f4discovery, .name = "stm32f4discovery", .file = "src/blinky.zig" },
// .{ .target = stm32.boards.stm3240geval, .name = "stm3240geval", .file = "src/blinky.zig" },
// .{ .target = stm32.boards.stm32f429idiscovery, .name = "stm32f429idiscovery", .file = "src/blinky.zig" },
.{ .target = stm32.boards.stm32f3discovery, .name = "STM32F303_HTS221", .file = "src/stm32f303/hts221.zig" },
.{ .target = stm32.boards.stm32f3discovery, .name = "STM32F303_HTS221", .file = "src/hts221.zig" },
.{ .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_HTS211", .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
43 changes: 21 additions & 22 deletions examples/stmicro/stm32/src/blinky.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const std = @import("std");
const microzig = @import("microzig");
const stm32 = microzig.hal;
const hal = microzig.hal;
const board = microzig.board;

fn delay() void {
var i: u32 = 0;
Expand All @@ -13,35 +14,33 @@ fn delay() void {
pub fn main() !void {
const pins, const all_leds = res: {
if (comptime std.mem.eql(u8, microzig.config.chip_name, "STM32F103C8")) {
const pins = (stm32.pins.GlobalConfiguration{ .GPIOC = .{
const pins = (hal.pins.GlobalConfiguration{ .GPIOC = .{
.PIN13 = .{ .name = "led", .mode = .{ .output = .general_purpose_push_pull } },
} }).apply();
const all_leds = .{
pins.led,
};
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 = (stm32.pins.GlobalConfiguration{
.GPIOE = .{
.PIN8 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN9 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN10 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN11 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN12 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN13 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN14 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
.PIN15 = .{ .mode = .{ .output = .{ .resistor = .Floating, .o_type = .PushPull } } },
},
}).apply();
const pins = board.leds_config.apply();
const all_leds = .{
pins.LD3,
pins.LD4,
pins.LD5,
pins.LD6,
pins.LD7,
pins.LD8,
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.PE8,
pins.PE9,
pins.PE10,
pins.PE11,
pins.PE12,
pins.PE13,
pins.PE14,
pins.PE15,
pins.LD4,
pins.LD5,
};

break :res .{ pins, all_leds };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const std = @import("std");
const microzig = @import("microzig");
const stm32 = microzig.hal;
const board = microzig.board;
const HTS221 = microzig.drivers.sensor.HTS221;

fn delay() void {
var i: u32 = 0;
while (i < 8_000_000) {
while (i < 800_000) {
microzig.cpu.nop();
i += 1;
}
Expand All @@ -16,24 +17,12 @@ pub const microzig_options: microzig.Options = .{
};

pub fn init() void {
microzig.board.init();
microzig.board.init_log();
board.init();
board.init_log();
}

pub fn main() !void {
_ = (stm32.pins.GlobalConfiguration{
.GPIOB = .{
// I2C
.PIN6 = .{ .mode = .{ .alternate_function = .{
.afr = .AF4,
} } },
.PIN7 = .{ .mode = .{ .alternate_function = .{
.afr = .AF4,
} } },
},
}).apply();

var i2c1 = stm32.i2c.I2C_Device.init(.I2C1);
var i2c1 = board.i2c1();
try i2c1.apply();
var device = i2c1.i2c_device();

Expand Down
58 changes: 29 additions & 29 deletions port/stmicro/stm32/src/Chips.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4560,7 +4560,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4585,7 +4585,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4610,7 +4610,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4635,7 +4635,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4660,7 +4660,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4685,7 +4685,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4710,7 +4710,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4735,7 +4735,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4760,7 +4760,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4785,7 +4785,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4810,7 +4810,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4836,7 +4836,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4862,7 +4862,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4887,7 +4887,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4912,7 +4912,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4937,7 +4937,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4962,7 +4962,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -4987,7 +4987,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5012,7 +5012,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5037,7 +5037,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5062,7 +5062,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5087,7 +5087,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5113,7 +5113,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5139,7 +5139,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5164,7 +5164,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5189,7 +5189,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5214,7 +5214,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5240,7 +5240,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand All @@ -5266,7 +5266,7 @@ pub fn init(dep: *std.Build.Dependency) Self {
},
},
.hal = .{
.root_source_file = b.path("src/hals/STM32F103/hal.zig"),
.root_source_file = b.path("src/hals/STM32F103.zig"),
},
};

Expand Down
Loading