-
Notifications
You must be signed in to change notification settings - Fork 651
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
Proposal changes to the ClockInterface trait #3671
Comments
We have a |
https://www.ewsn.org/file-repository/ewsn2021/Article13.pdf This is the paper discussed on the call. This comment, #3333 (comment), from Leon's old PR also likely relevant |
I don't think it makes sense to have a clock with a frequency of |
Hmm... Returning 0 when a clock is disabled can lead to divisions by 0. I think an even better signature for
Using |
I don't understand what a Every call to |
A disabled clock is still a clock. The method's comment indicates that |
I guess we need to establish what we want to be able to do with this interface. Currently it seems to be designed for optimizing power by enabling clocks only when they are needed. Then there is configuring peripherals based on the actual frequency of the clock. There is also configuring peripherals based on a clock where the frequency can change dynamically at runtime. Finally, it seems like there is getting runtime status of the clock (ie its current frequency, which could be 0 if it is not running). Those are related but not identical goals. Returning |
Hmm... If I remember correctly the discussion around this issue, the problem was about peripheral initialization for static clock configuration. For instance, when I was working on the Ethernet, I enabled a higher system clock required by PHY. However, the UART configuration was hard coded as for the default system configuration. With Again, if I remember correctly, dynamic clock configuration was not consired because currently Tock lacks that infrastructure. |
Is the solution simply to make the function We already have the Every clock has a frequency it's configured to run at [based on its configured clock source and divider in the clock's status registers] at all times, regardless of current on/off state, which eliminates the need for |
Currently, the
ClockInterface
trait insidekernel/src/platform/chip.rs
allows enabling/disabling a clock and querying whether the clock is enabled or not. However, there are situations when one needs to retrieve the frequency of the clock. For instance, the UART peripheral requires knowledge of the input clock in order to configure itself for a certain baud rate. This issue proposes the following solution:The associated function returns
None
if the clock is stopped orSome(frequency)
. The frequency is expressed in Hertz. The actual frequency might vary depending on the source clock quality.Currently,
sam4l
,stm32f303xc
,stm32f4xx
andimxrt10xx
crates rely on this trait. The addition doesn't break any current implementation.The text was updated successfully, but these errors were encountered: