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. Use DedicatedGpioOutput::new to create a driver, then DedicatedGpioOutput::with_pin to add output drivers.

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

Returns an empty driver. Output drivers must be added with the Self::with_pin method.

Source

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

Adds a GPIO output pin to this dedicated GPIO output.

A dedicated GPIO output can drive any number of GPIO pins. The driver releases the pins when it is dropped.

The GPIO matrix routes the current output of the dedicated GPIO channel to the pin. The pin follows the channel level immediately. The GPIO output register of the pin does not change.

Source

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

Changes the current state of the GPIO pins.

Source

pub fn output_level(&self) -> Level

Returns the current output state of the GPIO pins.

Returns Level::High if any of the GPIO pins are set high, otherwise Level::Low.

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§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl ErrorType for DedicatedGpioOutput<'_>

Available on crate feature unstable only.
Source§

type Error = !

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

§

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>

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.