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

Cache bus clock register and support clock source #2897

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Jan 6, 2025

Rough draft of my idea to resolve (eventually) #1666 and #1668

The main idea is to handle clock source and clock frequency as a unit, instead of separate values. This allows us to calculate and store the register value to save time when reapplying the same configuration.

The idea relies on peripherals having the same possible set of clock sources. I think that's generally okay, as we don't aim to support LP peripherals with the same drivers, for example.

I've chosen to update right before applying, so that writing the fields is trivial. This means Config is no longer Copy, which is a pretty unfortunate side-effect. We can, instead, update on each field update, which makes things a bit more expensive. We can also provide a chain updater that uses Drop trickery to update when the user is done touching the struct. This is more of an implementation detail than a substantial part of the design at this point.

The BuilderLite change is supposed to provide a semblance of backwards compatibility, especially since SPI really only supports PLL clock source in half of the chips and selecting Xtal also feels pretty rare in those that support it.

@bugadani bugadani force-pushed the clk_source branch 3 times, most recently from 1865e79 to d60ae6c Compare January 7, 2025 17:20
@bugadani bugadani marked this pull request as ready for review January 8, 2025 16:34
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.

1 participant