-
Notifications
You must be signed in to change notification settings - Fork 164
STM32:Use ClockTree helper for STM32F3 #869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Lint Results
Found 7 issues on changed lines in 1 file:
- port/stmicro/stm32/src/hals/STM32F303/rcc.zig: 7 issues
| .SPI1 => current_clock.p2_clk, | ||
| .SPI2, .SPI3 => current_clock.p1_clk, | ||
| // TODO: Patch for ClockTree | ||
| fn usart1Selection(src: anytype) USART1SW { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to usart1_selection, in MicroZig we use snake case for function names.
| if (comptime std.mem.eql(u8, microzig.config.chip_name, "STM32L476VG")) { | ||
| board.init(); | ||
| } else { | ||
| board.init(&board.rcc_medium_speed) catch @panic("Board init fail"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you just have each board have its own speed configuration? Does this example need a specific speed? I don't like the examples having this chip stuff hardcoded.
#830 will have this function be called automatically, so we can't do this.
Maybe we can expose some option that has board.init select which config to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap option could be a good choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clock speed I was thinking that this could be a user choice depending on the usage. (low power mode...) The idea is to be able to have comptime value for each ClockTree and that could be used for each peripheral at comptime too for different config computation.
| if (std.mem.eql(u8, "TIMINGR", field.name)) { | ||
| break :blk field.type; | ||
| } | ||
| } else @panic("No TIMINGR register"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a compileError.
ba9e5e4 to
b1266cd
Compare
Updating with new lint results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Lint Results
Found 7 issues on changed lines in 1 file:
- port/stmicro/stm32/src/hals/STM32F303/rcc.zig: 7 issues
| /// In the future we can switch on chip name to address | ||
| /// this limitation. | ||
| const microzig = @import("microzig"); | ||
| const Clock_Device = microzig.drivers.base.Clock_Device; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Rename Clock_Device to ClockDevice, it should be more in line with our style guidelines. This automation is not perfect so take it with a grain of salt.
| .SPI1 => current_clock.p2_clk, | ||
| .SPI2, .SPI3 => current_clock.p1_clk, | ||
| // TODO: Patch for ClockTree | ||
| fn usart1Selection(src: anytype) USART1SW { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to usart1_selection, in MicroZig we use snake case for function names.
| } else { | ||
| FLASH.ACR.modify(.{ .LATENCY = .WS2, .PRFTBE = 1 }); | ||
| // TODO: Patch for ClockTree | ||
| fn usart2Selection(src: anytype) USARTSW { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to usart2_selection, in MicroZig we use snake case for function names.
| } | ||
|
|
||
| // TODO: Patch for ClockTree | ||
| fn usart3Selection(src: anytype) USARTSW { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to usart3_selection, in MicroZig we use snake case for function names.
| } | ||
|
|
||
| // TODO: Patch for ClockTree | ||
| fn uart4Selection(src: anytype) USARTSW { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to uart4_selection, in MicroZig we use snake case for function names.
| .RCC_UART4CLKSOURCE_PCLK1 => .PCLK1, | ||
| }; | ||
| } // TODO: Patch for ClockTree | ||
| fn uart5Selection(src: anytype) USARTSW { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to uart5_selection, in MicroZig we use snake case for function names.
| } | ||
|
|
||
| // TODO: Patch for ClockTree | ||
| fn i2sSelection(src: anytype) ISSRC { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to i2s_selection, in MicroZig we use snake case for function names.
No description provided.