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

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

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

Conversation

honzasp
Copy link
Contributor

@honzasp honzasp commented Jun 26, 2024

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

  • Remove the peripheral types from timer drivers (similar to what we did for UART of I2C)
  • Introduce type-safe taxonomy of timers that works with type-erased drivers. This makes sure that drivers (and users) don't attempt to use features that are not supported by the underlying timer peripheral. (Currently, Embassy just gives up on this, pretending that all timers are general-purpose 4-channel timers...).

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
Copy link
Contributor Author

honzasp commented Jun 26, 2024

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

@honzasp
Copy link
Contributor Author

honzasp commented Jun 29, 2024

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 embassy-rs/stm32-data#495 to land first.)

@honzasp honzasp marked this pull request as ready for review June 29, 2024 15:33
@honzasp
Copy link
Contributor Author

honzasp commented Jul 16, 2024

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

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