Skip to content

Commit

Permalink
Remove unnecessary enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Sep 3, 2024
1 parent 464d40e commit e9b3578
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions esp-hal/src/gpio/any_pin.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
use super::*;

#[derive(Clone, Copy)]
enum Inverted {
NonInverted,
Inverted,
}

impl Inverted {
fn is_inverted(&self) -> bool {
match self {
Inverted::NonInverted => false,
Inverted::Inverted => true,
}
}
}

/// A type-erased GPIO pin, with additional configuration options.
///
/// Note that accessing unsupported pin functions (e.g. trying to use an
/// input-only pin as output) will panic.
pub struct AnyPin<'d> {
pin: ErasedPin,
inverted: Inverted,
inverted: bool,
_phantom: PhantomData<&'d ()>,
}

Expand All @@ -34,7 +19,7 @@ impl<'d> AnyPin<'d> {

Self {
pin,
inverted: Inverted::NonInverted,
inverted: false,
_phantom: PhantomData,
}
}
Expand All @@ -50,7 +35,7 @@ impl<'d> AnyPin<'d> {

Self {
pin,
inverted: Inverted::Inverted,
inverted: true,
_phantom: PhantomData,
}
}
Expand Down Expand Up @@ -115,10 +100,10 @@ impl<'d> OutputPin for AnyPin<'d> {
fn connect_peripheral_to_output(&mut self, signal: OutputSignal, _internal: private::Internal) {
self.pin.connect_peripheral_to_output_with_options(
signal,
self.inverted.is_inverted(),
self.inverted,
false,
false,
self.inverted.is_inverted(),
self.inverted,
private::Internal,
);
}
Expand All @@ -132,7 +117,7 @@ impl<'d> OutputPin for AnyPin<'d> {
force_via_gpio_mux: bool,
_internal: private::Internal,
) {
if self.inverted.is_inverted() {
if self.inverted {
self.pin.connect_peripheral_to_output_with_options(
signal,
true,
Expand Down Expand Up @@ -169,8 +154,8 @@ impl<'d> InputPin for AnyPin<'d> {
fn connect_input_to_peripheral(&mut self, signal: InputSignal, _internal: private::Internal) {
self.pin.connect_input_to_peripheral_with_options(
signal,
self.inverted.is_inverted(),
self.inverted.is_inverted(),
self.inverted,
self.inverted,
private::Internal,
);
}
Expand All @@ -182,7 +167,7 @@ impl<'d> InputPin for AnyPin<'d> {
force_via_gpio_mux: bool,
_internal: private::Internal,
) {
if self.inverted.is_inverted() {
if self.inverted {
self.pin.connect_input_to_peripheral_with_options(
signal,
true,
Expand Down

0 comments on commit e9b3578

Please sign in to comment.