Skip to main content

CdevPin

Struct CdevPin 

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

Newtype around gpio_cdev::LineHandle that implements the embedded-hal traits

Tuple Fields§

§0: LineHandle

Implementations§

§

impl CdevPin

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

See gpio_cdev::Line::request for details.

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

Set this pin to input mode

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

Set this pin to output mode

Methods from Deref<Target = LineHandle>§

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.

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).

pub fn line(&self) -> &Line

Get the Line information associated with this handle.

pub fn flags(&self) -> LineRequestFlags

Get the flags with which this handle was created

Trait Implementations§

§

impl Deref for CdevPin

§

type Target = LineHandle

The resulting type after dereferencing.
§

fn deref(&self) -> &<CdevPin as Deref>::Target

Dereferences the value.
§

impl DerefMut for CdevPin

§

fn deref_mut(&mut self) -> &mut <CdevPin as Deref>::Target

Mutably dereferences the value.
§

impl ErrorType for CdevPin

§

type Error = CdevPinError

Error type
§

impl InputPin for CdevPin

§

fn is_high(&mut self) -> Result<bool, <CdevPin as ErrorType>::Error>

Is the input pin high?
§

fn is_low(&mut self) -> Result<bool, <CdevPin as ErrorType>::Error>

Is the input pin low?
§

impl OutputPin for CdevPin

§

fn set_low(&mut self) -> Result<(), <CdevPin as ErrorType>::Error>

Drives the pin low. Read more
§

fn set_high(&mut self) -> Result<(), <CdevPin as ErrorType>::Error>

Drives the pin high. Read more
§

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.