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>
impl<'lt> DedicatedGpioOutput<'lt>
Sourcepub fn new<CH>(channel: CH) -> Selfwhere
CH: OutputChannel + 'lt,
pub fn new<CH>(channel: CH) -> Selfwhere
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.
Sourcepub fn with_pin(self, pin: impl OutputDriver + 'lt) -> Self
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.
Sourcepub fn output_level(&self) -> Level
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.
impl Drop for DedicatedGpioOutput<'_>
unstable only.Source§impl ErrorType for DedicatedGpioOutput<'_>
Available on crate feature unstable only.
impl ErrorType for DedicatedGpioOutput<'_>
unstable only.Source§impl OutputPin for DedicatedGpioOutput<'_>
Available on crate feature unstable only.
impl OutputPin for DedicatedGpioOutput<'_>
unstable only.