Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept ErasedPin in AnyPin #2072

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

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

### Fixed

Expand Down
16 changes: 14 additions & 2 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ 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>,
)+
}
Expand All @@ -1430,7 +1430,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