From 70d75be531343ace224a7da48099f3c7c0e4abc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 3 Sep 2024 18:04:51 +0200 Subject: [PATCH] Accept ErasedPin in AnyPin --- esp-hal/CHANGELOG.md | 2 ++ esp-hal/src/gpio/mod.rs | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 8a9f8a01f82..afa0620225a 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- You can now create an `AnyPin` out of an `ErasedPin`. (#2072) + ### Fixed - Fixed an issue with DMA transfers potentially not waking up the correct async task (#2065) diff --git a/esp-hal/src/gpio/mod.rs b/esp-hal/src/gpio/mod.rs index fef1fe145f6..3d3545cd13a 100644 --- a/esp-hal/src/gpio/mod.rs +++ b/esp-hal/src/gpio/mod.rs @@ -1413,13 +1413,13 @@ macro_rules! gpio { /// Pins available on this chip pub struct Pins { $( - /// GPIO pin number `$gpionum`. + #[doc = concat!("GPIO pin number ", $gpionum, ".")] pub [< gpio $gpionum >] : GpioPin<$gpionum>, )+ } $( - #[doc = concat!("Alias for GpioPin")] + #[doc = concat!("Alias for GpioPin<", $gpionum, ">")] pub type [] = GpioPin<$gpionum>; )+ @@ -1435,7 +1435,19 @@ macro_rules! gpio { match self { $( ErasedPin::[](_) => { - $crate::gpio::ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() }) + ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() }) + } + )+ + } + } + } + + impl $crate::gpio::CreateErasedPin for ErasedPin { + fn erased_pin(&self, _: $crate::private::Internal) -> ErasedPin { + match self { + $( + ErasedPin::[](_) => { + ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() }) } )+ }