Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix set_low() and set_high() implementation for OutputPin #807

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions rp2040-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,8 @@ mod eh1 {
use embedded_hal::digital::{ErrorType, InputPin, OutputPin, StatefulOutputPin};

use super::{
func, AnyPin, AsInputPin, Error, FunctionSio, InOutPin, Pin, PinId, PullType, SioConfig,
SioInput, SioOutput,
func, AnyPin, AsInputPin, Error, FunctionSio, InOutPin, OutputEnableOverride, Pin, PinId,
PullType, SioConfig, SioInput, SioOutput,
};

impl<I, P, S> ErrorType for Pin<I, FunctionSio<S>, P>
Expand Down Expand Up @@ -1558,12 +1558,17 @@ mod eh1 {
I: AnyPin,
{
fn set_low(&mut self) -> Result<(), Self::Error> {
self.inner._set_low();
// The pin is already set to output low but this is inhibited by the override.
self.inner
.set_output_enable_override(OutputEnableOverride::Enable);
Ok(())
}

fn set_high(&mut self) -> Result<(), Self::Error> {
self.inner._set_high();
// To set the open-drain pin to high, just disable the output driver by configuring the
// output override. That way, the DHT11 can still pull the data line down to send its response.
self.inner
.set_output_enable_override(OutputEnableOverride::Disable);
Ok(())
}
}
Expand Down
Loading