stm32-rs / stm32l0xx-hal

A hardware abstraction layer (HAL) for the STM32L0 series microcontrollers written in Rust
BSD Zero Clause License
96 stars 60 forks source link

Add MCO support #143

Closed jamwaffles closed 3 years ago

jamwaffles commented 3 years ago

I've added MCO (Microcontroller Clock Output) support in a hopefully sensible and typesafe way.

I'm reasonably happy with the impl, but will happily take any improvements. I tested the example with my L053 Nucleo using HSI16 as the clock reference. I can get PA8 and/or PA9 to show a nice steady 2MHz, so the code seems to be working as expected.

MCO consumes the output pin, which I think the API reflects. I'm also assuming MCO is available on all variants, so nothing is feature gated in this PR.

jamwaffles commented 3 years ago

I've rebased as #144 is merged. Would appreciate another look from @dbrgn or @hannobraun!

Aside: Nightly has started passing in Travis :thinking:

hannobraun commented 3 years ago

Thank you, @jamwaffles!

I'm not familiar with this feature, but the code looks good to me. And it's a new feature anyway, so unlikely to break existing use cases. Merging.

jamwaffles commented 3 years ago

Awesome! Thank you :blush: