You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
my project features two groups of six TM1637 displays, for whom I need to read a logical state of open-drain pins. Hence, I would like to group those pins in arrays, and I need them all to have the same type.
But I found out that InputPin trait is no longer satisfied after downgrade:
fn test<INPUT>(i: &mut INPUT) where INPUT: InputPin {}
[...]
let mut p1 = gpioc.pc8.into_open_drain_output(&mut gpioc.crh);
let mut p2 = gpioc.pc9.into_open_drain_output(&mut gpioc.crh).downgrade();
test(&mut p1); //OK
test(&mut p2); //Error
In gpio.rs I can see the implementation for generic OD pins and this would be enough for me (I can move all such pins to gpioc), but Generic is private:
impl InputPin for Generic<Output<OpenDrain>> {
type Error = Infallible;
fn is_high(&self) -> Result<bool, Self::Error> {
self.is_low().map(|b| !b)
}
fn is_low(&self) -> Result<bool, Self::Error> {
// NOTE(unsafe) atomic read with no side effects
Ok(unsafe { (*$GPIOX::ptr()).idr.read().bits() & (1 << self.i) == 0 })
}
}
Is there a technical reason behind loosing InputPin for downgraded OD pin? If so, how should I approach this? I don't want two functions doing the same thing, each taking 6 similar arguments.
Cheers,
~CS
The text was updated successfully, but these errors were encountered:
Hello,
my project features two groups of six TM1637 displays, for whom I need to read a logical state of open-drain pins. Hence, I would like to group those pins in arrays, and I need them all to have the same type.
But I found out that InputPin trait is no longer satisfied after downgrade:
In gpio.rs I can see the implementation for generic OD pins and this would be enough for me (I can move all such pins to gpioc), but Generic is private:
Is there a technical reason behind loosing InputPin for downgraded OD pin? If so, how should I approach this? I don't want two functions doing the same thing, each taking 6 similar arguments.
Cheers,
~CS
The text was updated successfully, but these errors were encountered: