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

⚓ rust    📅 2025-05-28    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 32 days ago. The information described in this article may have changed.

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

2 posts - 1 participant

Read full topic

🏷️ rust_feed