Skip to content

Conversation

@Grazfather
Copy link
Collaborator

A lot of this functionality was informed by https://github.com/robinjanssens/WCH-Toolchain

switch (sws) {
0 => {
// HSI used as system clock
sysclk = HSI_VALUE;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use cpu.cpu_frequency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hold off on standardizing globals like that. Maybe have a scoped global for the clock HAL. So something like hal.clocks.get_sysclk_hz()

},
1 => {
// HSE used as system clock
sysclk = HSE_VALUE;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use board.cpu_frequency, but only if some flag indicates that there is an external clock?

const regs = i2c.get_regs();
const star1 = regs.STAR1.read();

if (star1.AF == 1) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could more than one error be set? Do we want to clear all of them?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible if they're sticky. I would provide an option to the caller, assume you want the below behaviour by default -- this one destroys less information, but they get the option of clearing all of them when one error is fetched.

microzig.board.init();

// Enable peripheral clocks for USART2 and GPIOA
RCC.APB2PCENR.modify(.{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should usart apply take the pins and do this stuff as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff like the clock of another peripheral shouldn't be the responsibility of the USART HAL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to test, but last few commits try to tuck it away in the hal, and the hal makes calls to the clock hal

Copy link
Contributor

@mattnite mattnite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides weighing in, looks good to me, pull the trigger when you're ready.

Damn that multi-second delay when typing comments.

microzig.board.init();

// Enable peripheral clocks for USART2 and GPIOA
RCC.APB2PCENR.modify(.{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff like the clock of another peripheral shouldn't be the responsibility of the USART HAL.

switch (sws) {
0 => {
// HSI used as system clock
sysclk = HSI_VALUE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hold off on standardizing globals like that. Maybe have a scoped global for the clock HAL. So something like hal.clocks.get_sysclk_hz()

const regs = i2c.get_regs();
const star1 = regs.STAR1.read();

if (star1.AF == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible if they're sticky. I would provide an option to the caller, assume you want the below behaviour by default -- this one destroys less information, but they get the option of clearing all of them when one error is fetched.

@Grazfather
Copy link
Collaborator Author

Let me fix this up. Don't merge yet please

@Grazfather
Copy link
Collaborator Author

I bricked my board (doing something else). I have to wait for a new one to arrive to properly test everything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants