linux-embedded-hal icon indicating copy to clipboard operation
linux-embedded-hal copied to clipboard

impl embedded_hal::digital::Error for linux_embedded_hal::gpio_cdev::Error

Open SpieringsAE opened this issue 1 year ago • 2 comments

I'm trying to write an initialisation function for a driver, but the fact that the pin initialisation functions don't give me an embedded-hal Error trait is being a bit of a pain in the behind for me. I can't properly incorperate the errors that arise when setting up gpios in my drivers error enum.

My situation is an SPI device that has two additional gpios, a reset and an interrupt pin. This is a very hardware specific driver so the pins and spidev are created in the driver::new() function.

The linux_embedded_hal::spi::SPIError does implement embedded_hal::spi::Error so that one is fine I think.

Is this a workable idea?

SpieringsAE avatar Feb 09 '24 23:02 SpieringsAE

Would the implementation in https://github.com/rust-embedded/linux-embedded-hal/pull/110 solve your issue as well?

In there, the CdevPin::new method returns a CdevPinError defined in this crate instead of needing to construct the CdevPin from the external type as is currently the case.

reitermarkus avatar Feb 10 '24 12:02 reitermarkus

I think yes that could very much do that. I also think my request isn't possible, as the gpio_cdev::Error Is just a re-export so this crate doesn't influence it. So yeah it seems like there needs to be a linux-embedded-hal way to create a pin without having to deal with gpio-cdev errors.

SpieringsAE avatar Feb 10 '24 14:02 SpieringsAE