Skip to content

Commit f1a094b

Browse files
committed
Accept ErasedPin in AnyPin
1 parent 647e34f commit f1a094b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

esp-hal/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Changed
1616

17+
- You can now create an `AnyPin` out of an `ErasedPin`. (#2072)
18+
1719
### Fixed
1820

1921
- Fixed an issue with DMA transfers potentially not waking up the correct async task (#2065)

esp-hal/src/gpio/mod.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,13 +1414,13 @@ macro_rules! gpio {
14141414
/// Pins available on this chip
14151415
pub struct Pins {
14161416
$(
1417-
/// GPIO pin number `$gpionum`.
1417+
#[doc = concat!("GPIO pin number ", $gpionum, ".")]
14181418
pub [< gpio $gpionum >] : GpioPin<$gpionum>,
14191419
)+
14201420
}
14211421

14221422
$(
1423-
#[doc = concat!("Alias for GpioPin<MODE, ", $gpionum, ">")]
1423+
#[doc = concat!("Alias for GpioPin<", $gpionum, ">")]
14241424
pub type [<Gpio $gpionum >] = GpioPin<$gpionum>;
14251425
)+
14261426

@@ -1436,7 +1436,19 @@ macro_rules! gpio {
14361436
match self {
14371437
$(
14381438
ErasedPin::[<Gpio $gpionum >](_) => {
1439-
$crate::gpio::ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
1439+
ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
1440+
}
1441+
)+
1442+
}
1443+
}
1444+
}
1445+
1446+
impl $crate::gpio::CreateErasedPin for ErasedPin {
1447+
fn erased_pin(&self, _: $crate::private::Internal) -> ErasedPin {
1448+
match self {
1449+
$(
1450+
ErasedPin::[<Gpio $gpionum >](_) => {
1451+
ErasedPin::[< Gpio $gpionum >](unsafe { GpioPin::steal() })
14401452
}
14411453
)+
14421454
}

0 commit comments

Comments
 (0)