Skip to content

4th digital::IoPin proposal from #29 #73

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

Closed
wants to merge 2 commits into from
Closed
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
24 changes: 24 additions & 0 deletions src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,27 @@ pub trait InputPin {
/// Is the input pin low?
fn is_low(&self) -> bool;
}

/// Pins that can switch between input and output modes at runtime
#[cfg(feature = "unproven")]
pub trait IoPin {
/// Used by [`into_input()`](#tymethod.into_input)
///
/// In addition to being an [`InputPin`](trait.InputPin.html), the
/// target type must implement `IoPin` so that the mode can be
/// changed again.
type Input: InputPin + IoPin<Input = Self::Input, Output = Self::Output>;

/// Used by [`into_output()`](#tymethod.into_output)
///
/// In addition to being an [`OutputPin`](trait.OutputPin.html),
/// the target type must implement `IoPin` so that the mode can be
/// changed again.
type Output: OutputPin + IoPin<Input = Self::Input, Output = Self::Output>;

/// Configure as [`InputPin`](trait.InputPin.html)
fn into_input(self) -> Self::Input;

/// Configure as [`OutputPin`](trait.OutputPin.html)
fn into_output(self) -> Self::Output;
}