Skip to content

Commit

Permalink
Remove panicking match from Flex::set_level
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 20, 2024
1 parent d66e153 commit 42054d5
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ macro_rules! gpio {
)*

impl $crate::gpio::Pin for $crate::gpio::GpioPin<$gpionum> {
#[inline(always)]
fn number(&self) -> u8 {
$gpionum
}
Expand Down Expand Up @@ -2037,8 +2038,8 @@ where
/// Toggle pin output
#[inline]
pub fn toggle(&mut self) {
let level = !self.output_level();
self.set_level(level);
let level = self.output_level();
self.set_level(!level);
}

/// Configure the [DriveStrength] of the pin
Expand Down Expand Up @@ -2124,6 +2125,7 @@ pub(crate) mod internal {
}

impl Pin for AnyPin {
#[inline(always)]
fn number(&self) -> u8 {
handle_gpio_input!(&self.0, target, { Pin::number(target) })
}
Expand Down Expand Up @@ -2191,11 +2193,8 @@ pub(crate) mod internal {
})
}

fn set_output_high(&mut self, high: bool, _: private::Internal) {
handle_gpio_output!(&mut self.0, target, {
OutputPin::set_output_high(target, high, private::Internal)
})
}
// We use the default `set_output_high` implementation to avoid matching on pin
// type. We check the pin type to enable output functionality anyway.

fn set_drive_strength(&mut self, strength: DriveStrength, _: private::Internal) {
handle_gpio_output!(&mut self.0, target, {
Expand All @@ -2220,12 +2219,6 @@ pub(crate) mod internal {
OutputPin::internal_pull_down_in_sleep_mode(target, on, private::Internal)
})
}

fn is_set_high(&self, _: private::Internal) -> bool {
handle_gpio_output!(&self.0, target, {
OutputPin::is_set_high(target, private::Internal)
})
}
}

#[cfg(any(xtensa, esp32c2, esp32c3, esp32c6))]
Expand Down

0 comments on commit 42054d5

Please sign in to comment.