Skip to content

Commit

Permalink
Remove RtcPin from H2
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 14, 2024
1 parent 416bfff commit a3d8d13
Showing 1 changed file with 46 additions and 40 deletions.
86 changes: 46 additions & 40 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ pub enum RtcFunction {
}

/// Trait implemented by RTC pins
#[cfg(any(lp_io, rtc_cntl))]
pub trait RtcPin: Pin {
/// RTC number of the pin
#[cfg(xtensa)]
Expand All @@ -287,6 +288,7 @@ pub trait RtcPin: Pin {

/// Trait implemented by RTC pins which supporting internal pull-up / pull-down
/// resistors.
#[cfg(any(lp_io, rtc_cntl))]
pub trait RtcPinWithResistors: RtcPin {
/// Enable/disable the internal pull-up resistor
fn rtcio_pullup(&mut self, enable: bool);
Expand Down Expand Up @@ -1075,50 +1077,54 @@ macro_rules! gpio {
}
}

#[doc(hidden)]
#[macro_export]
macro_rules! handle_rtcio {
($this:expr, $inner:ident, $code:tt) => {
match $this {
$(
AnyPinInner::[<Gpio $gpionum >]($inner) => $crate::if_rtcio_pin!($($type),* {
$code
} else {{
let _ = $inner;
panic!("Unsupported")
}}),
)+
pub(crate) use handle_gpio_output;
pub(crate) use handle_gpio_input;

cfg_if::cfg_if! {
if #[cfg(any(lp_io, rtc_cntl))] {
#[doc(hidden)]
#[macro_export]
macro_rules! handle_rtcio {
($this:expr, $inner:ident, $code:tt) => {
match $this {
$(
AnyPinInner::[<Gpio $gpionum >]($inner) => $crate::if_rtcio_pin!($($type),* {
$code
} else {{
let _ = $inner;
panic!("Unsupported")
}}),
)+
}
}
}
}
}

#[doc(hidden)]
#[macro_export]
macro_rules! handle_rtcio_with_resistors {
($this:expr, $inner:ident, $code:tt) => {
match $this {
$(
AnyPinInner::[<Gpio $gpionum >]($inner) => $crate::if_rtcio_pin!($($type),* {
$crate::if_output_pin!($($type),* {
$code
} else {{
let _ = $inner;
panic!("Unsupported")
}})
} else {{
let _ = $inner;
panic!("Unsupported")
}}),
)+
#[doc(hidden)]
#[macro_export]
macro_rules! handle_rtcio_with_resistors {
($this:expr, $inner:ident, $code:tt) => {
match $this {
$(
AnyPinInner::[<Gpio $gpionum >]($inner) => $crate::if_rtcio_pin!($($type),* {
$crate::if_output_pin!($($type),* {
$code
} else {{
let _ = $inner;
panic!("Unsupported")
}})
} else {{
let _ = $inner;
panic!("Unsupported")
}}),
)+
}
}
}

pub(crate) use handle_rtcio;
pub(crate) use handle_rtcio_with_resistors;
}
}

pub(crate) use handle_gpio_output;
pub(crate) use handle_gpio_input;

pub(crate) use handle_rtcio;
pub(crate) use handle_rtcio_with_resistors;
}
};
}
Expand Down Expand Up @@ -2136,7 +2142,7 @@ pub(crate) mod internal {
}
}

#[cfg(any(xtensa, esp32c2, esp32c3, esp32c6))]
#[cfg(any(lp_io, rtc_cntl))]
impl RtcPin for AnyPin {
#[cfg(xtensa)]
#[allow(unused_braces)] // False positive :/
Expand Down

0 comments on commit a3d8d13

Please sign in to comment.