Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c4d83b9
update RCC to use clockhelper 2.0 data
RecursiveError Nov 26, 2025
162a932
Add rcc flags to Config_Output
RecursiveError Dec 1, 2025
2c6107c
Merge branch 'ZigEmbeddedGroup:main' into new_rcc
RecursiveError Dec 1, 2025
164af24
Refactor rcc.apply()
RecursiveError Dec 3, 2025
86e5345
fork clockhelper into a HAL module and update generate.zig
RecursiveError Dec 5, 2025
f4cd64f
Merge branch 'main' of https://github.com/ZigEmbeddedGroup/microzig i…
RecursiveError Dec 5, 2025
f4ef89a
Fix bugs on STM32L436 and add test
RecursiveError Dec 8, 2025
0cac811
add unhandled signals as extra outputs and fix L476 test
RecursiveError Dec 9, 2025
ec33df6
remove comptime from F303 test
RecursiveError Dec 9, 2025
4d0a176
apply bug fixes from ClockHelper and add STM32H723 test
RecursiveError Dec 10, 2025
2e2826f
Fix missing State flags as config
RecursiveError Dec 11, 2025
dd77b73
-fix STM32U75 clocktree
RecursiveError Dec 17, 2025
117cdc0
add stm32f777 unit test
RecursiveError Dec 18, 2025
e083400
fmt Chips.zig
RecursiveError Dec 19, 2025
db53db1
Merge branch 'main' into new_rcc
RecursiveError Dec 19, 2025
3bae72d
The flags in TreeOutput.config have been converted from optional to b…
RecursiveError Dec 22, 2025
cc601a4
Merge branch 'new_rcc' of github.com:RecursiveError/microzig into new…
RecursiveError Dec 22, 2025
3526d99
update porting example
RecursiveError Dec 22, 2025
00b8feb
fix typo
RecursiveError Dec 23, 2025
58b9b36
fix typo
RecursiveError Dec 23, 2025
c60b7cd
Converted remaining optional flags to boolean and added CSS flags.
RecursiveError Dec 23, 2025
e2eabb1
Merge branch 'main' of https://github.com/ZigEmbeddedGroup/microzig i…
RecursiveError Dec 23, 2025
d941189
fix merge
RecursiveError Dec 23, 2025
24a6c14
fix generate.zig fmt
RecursiveError Dec 24, 2025
33d8bbc
move clocktree
RecursiveError Dec 28, 2025
776e41b
remove unused files
RecursiveError Dec 28, 2025
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
7 changes: 6 additions & 1 deletion examples/stmicro/stm32/src/stm32f1xx/advanced_adc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ fn adc_to_temp(val: usize) f32 {
}

pub fn main() !void {
try rcc.apply_clock(.{ .ADCprescaler = .RCC_ADCPCLK2_DIV2 });
_ = try rcc.apply(.{
.ADCPresc = .RCC_ADCPCLK2_DIV2,
.flags = .{
.USE_ADC1 = true,
},
});

rcc.enable_clock(.DMA1);
rcc.enable_clock(.TIM2);
Expand Down
12 changes: 8 additions & 4 deletions examples/stmicro/stm32/src/stm32f1xx/gpio.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ const gpio = stm32.gpio;
const time = stm32.time;

pub fn main() !void {
try rcc.apply_clock(.{
.SysClkSource = .RCC_SYSCLKSOURCE_PLLCLK,
_ = try rcc.apply(.{
.SYSCLKSource = .RCC_SYSCLKSOURCE_PLLCLK,
.PLLSource = .RCC_PLLSOURCE_HSE,
.PLLMUL = .RCC_PLL_MUL9,
.APB1Prescaler = .RCC_HCLK_DIV2,
.RTCClkSource = .RCC_RTCCLKSOURCE_LSI,
.APB1CLKDivider = .RCC_HCLK_DIV2,
.RTCClockSelection = .RCC_RTCCLKSOURCE_LSI,
.flags = .{
.RTCUsed_ForRCC = true,
.HSEOscillator = true,
},
});
rcc.enable_clock(.GPIOC);

Expand Down
15 changes: 10 additions & 5 deletions examples/stmicro/stm32/src/stm32f1xx/rcc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ pub const microzig_options = microzig.Options{

const clk_config = rcc.Config{
.PLLSource = .RCC_PLLSOURCE_HSE,
.HSEDivPLL = .RCC_HSE_PREDIV_DIV2,
.HSEDivPLL = .RCC_HSE_PREDIV_DIV1,
.PLLMUL = .RCC_PLL_MUL2,
.SysClkSource = .RCC_SYSCLKSOURCE_PLLCLK,
.APB1Prescaler = .RCC_HCLK_DIV1,
.MCOMult = .RCC_MCO1SOURCE_SYSCLK,
.SYSCLKSource = .RCC_SYSCLKSOURCE_PLLCLK,
.APB1CLKDivider = .RCC_HCLK_DIV2,
.RCC_MCOSource = .RCC_MCO1SOURCE_SYSCLK,
.flags = .{
.HSEOscillator = true,
.MCOUsed_ForRCC = true,
.MCOConfig = true,
},
};

pub fn main() !void {
try rcc.apply_clock(clk_config);
_ = try rcc.apply(clk_config);
rcc.enable_clock(.GPIOA);
rcc.enable_clock(.AFIO);
rcc.enable_clock(.USART1);
Expand Down
8 changes: 6 additions & 2 deletions examples/stmicro/stm32/src/stm32f1xx/rtc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ pub fn main() !void {
//by the system reset, so we need to check if it is already running.
//If it is not running, we will configure it and enable it.
if (fresh_start()) {
try rcc.apply_clock(.{ .RTCClkSource = .RCC_RTCCLKSOURCE_LSE });
_ = try rcc.apply(.{
.RTCClockSelection = .RCC_RTCCLKSOURCE_LSE,
.flags = .{ .RTCUsed_ForRCC = true, .LSEOscillator = true },
});
rcc.enable_clock(.PWR);
rcc.enable_clock(.BKP);

Expand Down Expand Up @@ -66,9 +69,10 @@ pub fn main() !void {
}

fn fresh_start() bool {
const power_down: bool = hal.Reset_Reason == .POR_or_PDR;
rcc.enable_clock(.PWR);
rcc.enable_clock(.BKP);
const data: u32 = (@as(u32, bkp.BackupData1[1].data) << 16) | bkp.BackupData1[0].data;
rcc.disable_all_clocks();
return data != 0xDEADBEEF;
return (data != 0xDEADBEEF) or power_down;
}
9 changes: 8 additions & 1 deletion examples/stmicro/stm32/src/stm32f1xx/timer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const gpio = stm32.gpio;
const GPTimer = stm32.timer.GPTimer;
const time = stm32.time;

//pub const microzig_options: microzig.Options = .{
// .interrupts = .{ .TIM3 = .{ .c = time.TIM_handler } },
//};

//gpios
const ch1 = gpio.Pin.from_port(.A, 0);
const ch2 = gpio.Pin.from_port(.A, 1);
Expand All @@ -23,7 +27,10 @@ pub fn main() !void {
//first we need to enable the clocks for the GPIO and TIM peripherals

//use HSE as system clock source, more stable than HSI
try rcc.apply_clock(.{ .SysClkSource = .RCC_SYSCLKSOURCE_HSE });
_ = try rcc.apply(.{
.SYSCLKSource = .RCC_SYSCLKSOURCE_HSE,
.flags = .{ .HSEOscillator = true },
});

//enable GPIOA and TIM2, TIM3, AFIO clocks
//AFIO is needed for alternate function remapping, not used in this example but eneble for easy remapping
Expand Down
5 changes: 4 additions & 1 deletion examples/stmicro/stm32/src/stm32f1xx/timer_capture.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ pub fn main() !void {
//first we need to enable the clocks for the GPIO and TIM peripherals

//use HSE as system clock source, more stable than HSI
try rcc.apply_clock(.{ .SysClkSource = .RCC_SYSCLKSOURCE_HSE });
_ = try rcc.apply(.{
.SYSCLKSource = .RCC_SYSCLKSOURCE_HSE,
.flags = .{ .HSEOscillator = true },
});

//enable GPIOA and TIM2, TIM3, AFIO clocks
//AFIO is needed for alternate function remapping, not used in this example but eneble for easy remapping
Expand Down
10 changes: 7 additions & 3 deletions examples/stmicro/stm32/src/stm32f1xx/usb_cdc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,16 @@ fn CDC_read(buf: []u8, timeout: ?Duration) ![]const u8 {
}

pub fn main() !void {
try rcc.apply_clock(.{
_ = try rcc.apply(.{
.PLLSource = .RCC_PLLSOURCE_HSE,
.PLLMUL = .RCC_PLL_MUL9,
.SysClkSource = .RCC_SYSCLKSOURCE_PLLCLK,
.APB1Prescaler = .RCC_HCLK_DIV2,
.SYSCLKSource = .RCC_SYSCLKSOURCE_PLLCLK,
.APB1CLKDivider = .RCC_HCLK_DIV2,
.USBPrescaler = .RCC_USBCLKSOURCE_PLL_DIV1_5,
.flags = .{
.HSEOscillator = true,
.USBUsed_ForRCC = true,
},
});

rcc.enable_clock(.GPIOA);
Expand Down
7 changes: 4 additions & 3 deletions examples/stmicro/stm32/src/stm32f1xx/usb_hid.zig
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,13 @@ fn report(keys: []const u8) void {
}

pub fn main() !void {
try rcc.apply_clock(.{
_ = try rcc.apply(.{
.PLLSource = .RCC_PLLSOURCE_HSE,
.PLLMUL = .RCC_PLL_MUL9,
.SysClkSource = .RCC_SYSCLKSOURCE_PLLCLK,
.APB1Prescaler = .RCC_HCLK_DIV2,
.SYSCLKSource = .RCC_SYSCLKSOURCE_PLLCLK,
.APB1CLKDivider = .RCC_HCLK_DIV2,
.USBPrescaler = .RCC_USBCLKSOURCE_PLL_DIV1_5,
.flags = .{ .HSEOscillator = true, .USBUsed_ForRCC = true },
});

rcc.enable_clock(.GPIOA);
Expand Down
12 changes: 11 additions & 1 deletion port/stmicro/stm32/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ boards: struct {

pub fn init(dep: *std.Build.Dependency) Self {
const b = dep.builder;
const chips = Chips.init(dep);

const clockhelper_dep = b.dependency("ClockHelper", .{}).module("clockhelper");

const hal_imports: []std.Build.Module.Import = b.allocator.dupe(std.Build.Module.Import, &.{
.{
.name = "ClockTree",
.module = clockhelper_dep,
},
}) catch @panic("out of memory");

const chips = Chips.init(dep, hal_imports);

return .{
.chips = chips,
Expand Down
4 changes: 4 additions & 0 deletions port/stmicro/stm32/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.url = "git+https://github.com/embassy-rs/stm32-data-generated.git#5198a6e36b24f6d79c4ac91af5e61e8d54667d88",
.hash = "N-V-__8AAFi8WBlOh-NikHFVBjzQE0F1KixgKjVWYnlijPNm",
},
.ClockHelper = .{
.url = "git+https://github.com/ZigEmbeddedGroup/ClockHelper#7fd073b1be9544941c15f9a63032ed06149ddb70",
.hash = "ClockHelper-2.0.0-RcMaOSniGQHXH_qeoZbQDG64XThqpXTVPMfJ6P7LHpYY",
},
},
.paths = .{
"README.md",
Expand Down
Loading
Loading