How to convert from esp_hal::Gpio::Pin to embedded_hal::digital::OutputPin

I'm trying to construct an mipidsi::interface::spi::SpiInterface struct. The constructor takes in a type embedded_hal::digital::OutputPin.

My code so far is:

let config = esp_hal::Config::default();
let peripherals = esp_hal::init(config);
let dc = peripherals.GPIO11;

SpiInterface::new(exlusive_spi, dc, &mut buffer) // <-- error here

dc is of type esp_hal::gpio::GpioPin<11> which implements esp_hal::Gpio::Pin (not sure if that's relevant).

If I try to pass this into SpiInterface::new, I get an error:

the trait bound `GpioPin<11>: embedded_hal::digital::OutputPin` is not satisfied

I think I somehow need to convert the GpioPin into something that implements OutputPin, but I can't seem to figure out how to do that

okay, something like this seemed to work:

let dcc = Output::new(
    dc,
    esp_hal::gpio::Level::Low,
    OutputConfig::default().with_drive_mode(esp_hal::gpio::DriveMode::PushPull),
);
1 Like