stm32-rs / stm32f0xx-hal

A Rust `embedded-hal` implementation for all MCUs in the STM32 F0 family
BSD Zero Clause License
134 stars 59 forks source link

PWM support #138

Closed jonfin closed 3 years ago

jonfin commented 3 years ago

Add PWM support based on the stm32f4xx_hal implementation. It is mostly a copy from stm32f4xx_hal with some modification. Only change to stm32f4xx_hal: it uses the recommended order for setting the register from DM00042534

I did some testing based on a stm32f030c8 chip.

fixes #26

therealprof commented 3 years ago

Thanks for the PR! I've tested it on a STM32F072 and it works a treat. If you could fix the CI issues and register the example with Cargo.toml I can merge this in.

jonfin commented 3 years ago

It should now work even on more devices. I missed the possibility that there could be other devices than the stm32f030 or stm32f070.

One thing is missing: the PWM implementation for TIM2 (32-bit). I skip it because I cannot test it after changing the calculation of the prescaler / Auto-reload value.

therealprof commented 3 years ago

Thanks, it's still missing the example registration in Cargo.toml. And if you could squash your PR a bit that'd be much appreciated.

jonfin commented 3 years ago

Is the example not automatic registered?

therealprof commented 3 years ago

Ah sorry, I missed that it's an example that works on all chips; not used to that. 😅

jonfin commented 3 years ago

Me neither ;) I squashed the commits.

bors[bot] commented 3 years ago

Build succeeded: