Skip to main content

DedicatedGpioFlex

Struct DedicatedGpioFlex 

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

A dedicated GPIO input and output driver.

On ESP32-S2 and ESP32-S3, the GPIO’s output is always enabled.

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::{
    Flex,
    Input,
    Level,
    dedicated::{DedicatedGpio, DedicatedGpioFlex},
};

// Create a pin driver:
let flex = Flex::new(peripherals.GPIO0);

// Create a dedicated GPIO driver:
let channels = DedicatedGpio::new(peripherals.GPIO_DEDICATED);
let mut dedicated_io = DedicatedGpioFlex::new(channels.channel0, flex);

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

Implementations§

Source§

impl<'lt> DedicatedGpioFlex<'lt>

Source

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

Creates a new dedicated GPIO input/output driver.

Source

pub fn set_level(&mut self, level: Level)

Change the current state of the GPIO pin.

Source

pub fn level(&self) -> Level

Read the current state of the GPIO pins.

Trait Implementations§

Source§

impl Drop for DedicatedGpioFlex<'_>

Available on crate feature unstable only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'lt> Freeze for DedicatedGpioFlex<'lt>

§

impl<'lt> RefUnwindSafe for DedicatedGpioFlex<'lt>

§

impl<'lt> Send for DedicatedGpioFlex<'lt>

§

impl<'lt> Sync for DedicatedGpioFlex<'lt>

§

impl<'lt> Unpin for DedicatedGpioFlex<'lt>

§

impl<'lt> UnsafeUnpin for DedicatedGpioFlex<'lt>

§

impl<'lt> !UnwindSafe for DedicatedGpioFlex<'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.