Skip to main content

DedicatedGpioOutput

Struct DedicatedGpioOutput 

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

A dedicated GPIO output driver.

Due to how the hardware works, DedicatedGpioOutput can drive any number of GPIO pins. To create a driver, you can use the DedicatedGpioOutput::new method, then DedicatedGpioOutput::with_pin to add output drivers.

The method output_level is currently not available on ESP32-S3 due to an LLVM bug. See https://github.com/espressif/llvm-project/issues/120 for details.
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::{
    Level,
    Output,
    OutputConfig,
    dedicated::{DedicatedGpio, DedicatedGpioOutput},
};

// Create a dedicated GPIO driver:
let channels = DedicatedGpio::new(peripherals.GPIO_DEDICATED);
let dedicated_output = DedicatedGpioOutput::new(channels.channel0);

// Add any number of output pin drivers:
let output = Output::new(peripherals.GPIO0, Level::Low, OutputConfig::default());
let mut dedicated_output = dedicated_output.with_pin(output);

// Now you can use the pin.
dedicated_output.set_level(Level::High);

Implementations§

Source§

impl<'lt> DedicatedGpioOutput<'lt>

Source

pub fn new<CH>(channel: CH) -> Self
where CH: OutputChannel + 'lt,

Creates a new dedicated GPIO output driver.

This function returns an empty driver. You will need to add output drivers to it using the Self::with_pin method.

Source

pub fn with_pin(self, pin: impl OutputDriver + 'lt) -> Self

Adds a new output driver to the GPIO pins.

A dedicated GPIO output driver can control any number of GPIO pins. The pins will be released when the driver is dropped. This function does not change the state of the newly added GPIO pin.

Source

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

Changes the current state of the GPIO pins.

Trait Implementations§

Source§

impl Drop for DedicatedGpioOutput<'_>

Available on crate feature unstable only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ErrorType for DedicatedGpioOutput<'_>

Available on crate feature unstable only.
Source§

type Error = Infallible

Error type
Source§

impl OutputPin for DedicatedGpioOutput<'_>

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

§

impl<'lt> Freeze for DedicatedGpioOutput<'lt>

§

impl<'lt> RefUnwindSafe for DedicatedGpioOutput<'lt>

§

impl<'lt> Send for DedicatedGpioOutput<'lt>

§

impl<'lt> Sync for DedicatedGpioOutput<'lt>

§

impl<'lt> Unpin for DedicatedGpioOutput<'lt>

§

impl<'lt> UnsafeUnpin for DedicatedGpioOutput<'lt>

§

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