stm32f0xx-hal
stm32f0xx-hal copied to clipboard
Add filler types for unused pins in communication peripherals
For some communication peripherals it is typical that only partial functionality is used, e.g. only RX or TX for serial or only MOSI for SPI. For these situations we should have filler types which can be used in that case. https://github.com/stm32-rs/stm32f4xx-hal/ already has appropriate implementations which we should be able to reuse for our cause.
CC @david-sawatzke
I've already started #27, which takes a bit different, but similar approach. I personally prefer the approach with an universal Unused pin implementing all the AF traits, but both approaches are (mostly) equivalent. It's doesn't seem hard to modify it.
@david-sawatzke
I personally prefer the approach with an universal Unused pin implementing all the AF traits, but both approaches are (mostly) equivalent.
Uhm, that's not what your implementation does. I basically just defines an empty shell without any functionality (not even sure why you're using a PhantomData).
With AF traits i meant the traits that implement the link from af to peripheral, eg TxPin.
I used PhantomData because I wasn't sure if we maybe need to extend it in the future and without it it's constructable by user code (afaik).
I used PhantomData because I wasn't sure if we maybe need to extend it in the future
😲
and without it it's constructable by user code (afaik).
In that case you could use
pub struct Unused {
_0: (),
}
However it doesn't really matter since it's really just an empty shell and there's exactly none functionality attached to it (and true to the meaning never should be...).