Skip to main content

DedicatedGpioInput

Struct DedicatedGpioInput 

Source
pub struct DedicatedGpioInput<'lt> { /* private fields */ }
Expand description

A dedicated GPIO input driver.

Note that the driver must only be used on the core that has created it. Do not send the driver to another core, either directly, or indirectly via a thread that is not pinned to a core.

§Examples

use esp_hal::gpio::{
    Input,
    InputConfig,
    Level,
    dedicated::{DedicatedGpio, DedicatedGpioInput},
};

// Create an input pin driver:
let input = Input::new(peripherals.GPIO0, InputConfig::default());

// Create a dedicated GPIO driver:
let channels = DedicatedGpio::new(peripherals.GPIO_DEDICATED);
let mut dedicated_input = DedicatedGpioInput::new(channels.channel0, input);

// Now you can use the pin:
let level = dedicated_input.level();

Implementations§

Source§

impl<'lt> DedicatedGpioInput<'lt>

Source

pub fn new<CH, P>(channel: CH, pin: P) -> Self
where CH: InputChannel + 'lt, P: InputDriver + 'lt,

Creates a new dedicated GPIO input driver.

Source

pub fn level(&self) -> Level

Read the current state of the GPIO pins.

Trait Implementations§

Source§

impl ErrorType for DedicatedGpioInput<'_>

Available on crate feature unstable only.
Source§

type Error = Infallible

Error type
Source§

impl InputPin for DedicatedGpioInput<'_>

Available on crate feature unstable only.
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?

Auto Trait Implementations§

§

impl<'lt> Freeze for DedicatedGpioInput<'lt>

§

impl<'lt> RefUnwindSafe for DedicatedGpioInput<'lt>

§

impl<'lt> Send for DedicatedGpioInput<'lt>

§

impl<'lt> Sync for DedicatedGpioInput<'lt>

§

impl<'lt> Unpin for DedicatedGpioInput<'lt>

§

impl<'lt> UnsafeUnpin for DedicatedGpioInput<'lt>

§

impl<'lt> !UnwindSafe for DedicatedGpioInput<'lt>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.