Skip to content

Commit fb69411

Browse files
Accept ErasedPin in AnyPin (#2072)
Co-authored-by: Jesse Braham <[email protected]>
1 parent e898e89 commit fb69411

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

esp-hal/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Changed
1616

1717
- `Delay::new()` is now a `const` function (#1999)
18+
- You can now create an `AnyPin` out of an `ErasedPin`. (#2072)
1819

1920
### Fixed
2021

esp-hal/src/gpio/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ macro_rules! gpio {
13771377
/// Pins available on this chip
13781378
pub struct Pins {
13791379
$(
1380-
/// GPIO pin number `$gpionum`.
1380+
#[doc = concat!("GPIO pin number ", $gpionum, ".")]
13811381
pub [< gpio $gpionum >] : GpioPin<$gpionum>,
13821382
)+
13831383
}
@@ -1394,7 +1394,19 @@ macro_rules! gpio {
13941394
match self {
13951395
$(
13961396
ErasedPin::[<Gpio $gpionum >](_) => {
1397-
$crate::gpio::ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
1397+
ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
1398+
}
1399+
)+
1400+
}
1401+
}
1402+
}
1403+
1404+
impl $crate::gpio::CreateErasedPin for ErasedPin {
1405+
fn erased_pin(&self, _: $crate::private::Internal) -> ErasedPin {
1406+
match self {
1407+
$(
1408+
ErasedPin::[<Gpio $gpionum >](_) => {
1409+
ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
13981410
}
13991411
)+
14001412
}

0 commit comments

Comments
 (0)