stm32f3xx-hal
stm32f3xx-hal copied to clipboard
Implement GPIO temporary mode closures
This should be similar to https://github.com/stm32-rs/stm32l0xx-hal/pull/74
The other approach already merged to embedded-hal: https://github.com/rust-embedded/embedded-hal/issues/29
Yeah, IoPin
has also to be implemented for this HAL. Thanks for the reminder :)
But this solves a slightly different issue. This is a particular API to solve the "Option
-dance", too please the rust borrow checker. Because changing the pins mode, changes its pin type state / type signature, which rustc is not happy about, if the pin it is not owned (which always is the case, when it is static mut
). To solve this, you either have to use the "Option
-dance", a pattern I've been using in the testsuite
quite heavily, or introduce an API suggested in the linked issue.