embassy-rs / embassy

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

stm32/hrtim: refactor to deduplicate code between channels. #2318

Open Dirbaio opened 8 months ago

Dirbaio commented 8 months ago

https://github.com/embassy-rs/embassy/blob/49534cd4056f20bdf5fa6058b0865afc5fcf38ee/embassy-stm32/src/hrtim/mod.rs#L35-L53

These should be changed into a single Ch<T: Instance, C: Channel>, where C is a series of marker types A, B, C... This will need deduplicating the Pin traits too.

See this PR which did a similar refactor to SAI for ideas: https://github.com/embassy-rs/embassy/pull/2310

usbalbin commented 8 months ago

Hi!

I am working on adding hrtim(v2) support to stm32g4xx-hal - messy work-in-progress PR. It is not yet very well thought out or consistent but I believe it does cover a lot of the features, still by no means all of them. Also I have no experiance with embassy so not sure if that would map well here. The API tries to be quite low level so that any converter topology(or other use case) can be implemented on top of it.

Anyways, feel free to have a look on the off chance that there may be anything useful. :)

Also, note that a lot of the examples have not be tested in quite a while so might be missing timer.start() or similar, but should otherwise be working.