Skip to content
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

fix clock usage in timer driver for idf 5 #441

Merged
merged 9 commits into from
Jun 20, 2024

Conversation

Vollbrecht
Copy link
Collaborator

Newer esp's (c2/h2/c6) don't use the apb clock as a default clock for the timer. They use different variants of the pll clock. Furthermore the general assumption that the xtal clock is always 40Mhz is not correct. This PR includes fixes for the TimeDriver in this respect.

closes #426

@Vollbrecht Vollbrecht requested a review from ivmarkov June 19, 2024 01:16

#[cfg(not(esp_idf_version_major = "4"))]
#[allow(clippy::upper_case_acronyms)]
pub(crate) enum ClockSource {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: why pub(crate)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tbh i dont like our current clocktree api design, or lag of it. So this is more of a stopgab solution, till we have a general better api for that sort of stuff. Thats why i didn't want to expose it into public api.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant why is it with a crate visibility and not private, but then again - just a nit.

src/timer.rs Outdated
}

#[cfg(not(esp_idf_version_major = "4"))]
impl Default for ClockSource {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: you can replace all of this with just #[default] above, because for each MCU you end up with exactly two members of the enum, where the XTAL member should always be the non-default one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@ivmarkov
Copy link
Collaborator

Just two nits. I think you can merge without addressing these either, as they are nits.

@Vollbrecht Vollbrecht merged commit 7a30598 into esp-rs:master Jun 20, 2024
8 checks passed
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.

esp32c2 generated bindgen doesn't include APB_CLK_FREQ correctly
2 participants