Skip to content

Commit

Permalink
Accept ErasedPin in AnyPin
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 4, 2024
1 parent 9bec6a1 commit 70d75be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MODE, ", $gpionum, ">")]
#[doc = concat!("Alias for GpioPin<", $gpionum, ">")]
pub type [<Gpio $gpionum >] = GpioPin<$gpionum>;
)+

Expand All @@ -1435,7 +1435,19 @@ macro_rules! gpio {
match self {
$(
ErasedPin::[<Gpio $gpionum >](_) => {
$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::[<Gpio $gpionum >](_) => {
ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
}
)+
}
Expand Down

0 comments on commit 70d75be

Please sign in to comment.