Open
Description
Clocks are an important part of all microcontrollers that I know of, and I believe this is a topic that should be covered in embedded-hal. I don't have a good enough overview over the topic to know everything that's required, but I have encountered some use cases that gave me a few ideas.
I've implemented a rough proposal as part of LPC82x HAL. This is not quite ready for inclusion into embedded-hal, but I've decided to open this issue to garner some feedback, and give others the opportunity to mention other use cases that I haven't covered.
Here's the API that I'd like to submit (eventually):
- Overview: lpc82x_hal::clock
- A trait that returns a clock's frequency: clock::Frequency
- A marker trait for enabled clocks: clock::Enabled
- A struct to represent durations: clock::Ticks
Use cases for the API:
- Implementations of the traits: LowPowerClock, IrcDerivedClock
- Sleep code that depends on various bits: Sleep
- I also have an unrelease time library that depends on this infrastructure. I haven't had time to polish and release it yet, but I'll happily send the code to anyone who wants to take a look.
As I said, this is still a bit rough. lpc-rs/lpc8xx-hal#4 has some
ideas for improvement. I'd love to hear what everyone thinks!