Struct CdevPin

Source
pub struct CdevPin(pub LineHandle, _);
Expand description

Cdev pin re-export Newtype around gpio_cdev::LineHandle that implements the embedded-hal traits

Tuple Fields§

§0: LineHandle

Implementations§

Source§

impl CdevPin

Source

pub fn new(handle: LineHandle) -> Result<Self, Error>

See gpio_cdev::Line::request for details.

Source

pub fn into_input_pin(self) -> Result<CdevPin, Error>

Set this pin to input mode

Source

pub fn into_output_pin(self, state: PinState) -> Result<CdevPin, Error>

Set this pin to output mode

Methods from Deref<Target = LineHandle>§

Source

pub fn get_value(&self) -> Result<u8, Error>

Request the current state of this Line from the kernel

This call is expected to succeed for both input and output lines. It should be noted, however, that some drivers may not be able to give any useful information when the value is requested for an output line.

This value should be 0 or 1 which a “1” representing that the line is active. Usually this means that the line is at logic-level high but it could mean the opposite if the line has been marked as being ACTIVE_LOW.

Source

pub fn set_value(&self, value: u8) -> Result<(), Error>

Request that the line be driven to the specified value

The value should be 0 or 1 with 1 representing a request to make the line “active”. Usually “active” means logic level high unless the line has been marked as ACTIVE_LOW.

Calling set_value on a line that is not an output will likely result in an error (from the kernel).

Source

pub fn line(&self) -> &Line

Get the Line information associated with this handle.

Source

pub fn flags(&self) -> LineRequestFlags

Get the flags with which this handle was created

Trait Implementations§

Source§

impl Deref for CdevPin

Source§

type Target = LineHandle

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for CdevPin

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl ErrorType for CdevPin

Source§

type Error = CdevPinError

Error type
Source§

impl InputPin for CdevPin

Source§

fn is_high(&mut self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&mut self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl OutputPin for CdevPin

Source§

fn set_low(&mut self) -> Result<(), Self::Error>

Drives the pin low. Read more
Source§

fn set_high(&mut self) -> Result<(), Self::Error>

Drives the pin high. Read more
Source§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.