embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
5.31k stars 732 forks source link

stm32/timer: Remove generics and introduce type-safe timer taxonomy #3123

Open honzasp opened 3 months ago

honzasp commented 3 months ago

This PR is a refactor of the timer functionality in embassy-stm32 that attempts to address two problems with the current implementation:

The approach that I took is described in the doc comment for the timer module. The foundation for type-safe timers is the timer::raw::RawTimer driver, which provides access only to the timer registers and their fields that are supported by the given timer.

honzasp commented 3 months ago

Marked as draft because I need to rebase and do more thorough testing before I'm comfortable merging this.

honzasp commented 3 months ago

The CI passes and I confirmed that the timer examples work on my STM32H743ZI Nucleo board, so this should be ready for review. (But we need to wait for https://github.com/embassy-rs/stm32-data/pull/495 to land first.)

honzasp commented 2 months ago

@Dirbaio, do you think you will have time to look at this PR? :)