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

Remove IoPin #393

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Fixed documentation for `wait_for_rising_edge`.

### Removed
- `digital::blocking::IoPin` traits.

## [v1.0.0-alpha.8] - 2022-04-15

*** This is (also) an alpha release with breaking changes (sorry) ***
Expand Down
46 changes: 0 additions & 46 deletions src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,50 +152,4 @@ pub mod blocking {
T::is_low(self)
}
}

/// Single pin that can switch from input to output mode, and vice-versa.
///
/// Example use (assumes the `Error` type is the same for the `IoPin`,
/// `InputPin`, and `OutputPin`):
///
/// ```
/// use core::time::Duration;
/// use embedded_hal::digital::blocking::{IoPin, InputPin, OutputPin};
///
/// pub fn ping_and_read<TInputPin, TOutputPin, TError: core::fmt::Debug>(
/// mut pin: TOutputPin, delay_fn: &dyn Fn(Duration) -> ()) -> Result<bool, TError>
/// where
/// TInputPin : InputPin<Error = TError> + IoPin<TInputPin, TOutputPin, Error = TError>,
/// TOutputPin : OutputPin<Error = TError> + IoPin<TInputPin, TOutputPin, Error = TError>,
/// {
/// // Ping
/// pin.set_low()?;
/// delay_fn(Duration::from_millis(10));
/// pin.set_high()?;
///
/// // Read
/// let pin = pin.into_input_pin()?;
/// delay_fn(Duration::from_millis(10));
/// pin.is_high()
/// }
/// ```
pub trait IoPin<TInput, TOutput>
where
TInput: InputPin + IoPin<TInput, TOutput>,
TOutput: OutputPin + IoPin<TInput, TOutput>,
{
/// Error type.
type Error: core::fmt::Debug;

/// Tries to convert this pin to input mode.
///
/// If the pin is already in input mode, this method should succeed.
fn into_input_pin(self) -> Result<TInput, Self::Error>;

/// Tries to convert this pin to output mode with the given initial state.
///
/// If the pin is already in the requested state, this method should
/// succeed.
fn into_output_pin(self, state: PinState) -> Result<TOutput, Self::Error>;
}
}