Skip to content

Conversation

sw
Copy link
Contributor

@sw sw commented Jan 11, 2025

On the PY32F030, the RCC_ECSCR register has a field HSE_FREQ that needs to be set for the crystal oscillator to operate. That field is not present on the F072.

Being new to Rust, I'm not sure this is the right way to do it. I would like to use the Hertz type, but that doesn't seem to be possible in a range pattern. Feel free to suggest improvements or modify it yourself.

@sw
Copy link
Contributor Author

sw commented Jan 11, 2025

Is there a way to make the code depend on the presence of set_hse_freq instead of using #[cfg?

@decaday
Copy link
Member

decaday commented Jan 12, 2025

Thanks for the contribution! The current implementation looks good.

If you've tested this on PY32F030, would you mind adding an example to demonstrate and help with testing?
(I don't have any F030 Board with a HSE, but I have F072, F403 boards with it)

@decaday
Copy link
Member

decaday commented Jan 12, 2025

Is there a way to make the code depend on the presence of set_hse_freq instead of using #[cfg?

We keep all clock control operations in the py32_hal::init() function to prevent peripheral clock errors that could occur if RCC operations happen after peripheral initialization. The use of #[cfg] is appropriate here I think.

On the PY32F030, the RCC_ECSCR register has a field HSE_FREQ that
needs to be set for the crystal oscillator to operate. That field
is not present on the F072.
@sw
Copy link
Contributor Author

sw commented Jan 14, 2025

Rebased and added an example. I was planning to combine the MCO and HSE in an example, but you're right that it's probably best to keep the examples very simple.

@decaday
Copy link
Member

decaday commented Jan 14, 2025

Thanks!

@decaday decaday merged commit a547997 into py32-rs:main Jan 14, 2025
1 check passed
@sw sw deleted the f030-hse branch January 14, 2025 10:36
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.

2 participants