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.
§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.
This function returns an empty driver. You will need to add output drivers to it using 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 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.
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.