Skip to content

Commit

Permalink
Hide interconnect types
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Jan 9, 2025
1 parent bb614eb commit 0fe5b9b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions esp-hal/src/gpio/interconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn disconnect_peripheral_output_from_pin(pin: &mut AnyPin, signal: gpio::OutputS
/// A configurable input signal between a peripheral and a GPIO pin.
///
/// Multiple input signals can be connected to one pin.
#[instability::unstable]
pub struct InputSignal {
pin: AnyPin,
is_inverted: bool,
Expand Down Expand Up @@ -350,6 +351,7 @@ impl DirectInputSignal {
/// A configurable output signal between a peripheral and a GPIO pin.
///
/// Multiple pins can be connected to one output signal.
#[instability::unstable]
pub struct OutputSignal {
pin: AnyPin,
is_inverted: bool,
Expand Down Expand Up @@ -512,6 +514,7 @@ enum InputConnectionInner {
/// This is mainly intended for internal use, but it can be used to connect
/// peripherals within the MCU without external hardware.
#[derive(Clone)]
#[doc(hidden)] // FIXME: replace with `#[unstable]` when we can mark delegated methods https://github.com/Kobzol/rust-delegate/issues/77
pub struct InputConnection(InputConnectionInner);

impl Peripheral for InputConnection {
Expand Down Expand Up @@ -623,6 +626,7 @@ enum OutputConnectionInner {
///
/// This is mainly intended for internal use, but it can be used to connect
/// peripherals within the MCU without external hardware.
#[doc(hidden)] // FIXME: replace with `#[unstable]` when we can mark delegated methods https://github.com/Kobzol/rust-delegate/issues/77
pub struct OutputConnection(OutputConnectionInner);

impl Sealed for OutputConnection {}
Expand Down
18 changes: 18 additions & 0 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
(
interconnect::InputSignal::new(self.degrade_pin(private::Internal)),
Expand Down Expand Up @@ -1300,6 +1301,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.split()
}
Expand All @@ -1309,6 +1312,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.peripheral_input()
}
Expand All @@ -1319,6 +1323,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.pin.into_peripheral_output()
}
Expand Down Expand Up @@ -1496,6 +1501,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.peripheral_input()
}
Expand Down Expand Up @@ -1627,6 +1633,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.split()
}
Expand All @@ -1637,6 +1645,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.pin.into_peripheral_output()
}
Expand Down Expand Up @@ -1762,6 +1771,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.split()
}
Expand All @@ -1771,6 +1782,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.peripheral_input()
}
Expand All @@ -1781,6 +1793,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.pin.into_peripheral_output()
}
Expand Down Expand Up @@ -1917,6 +1930,7 @@ where
///
/// The input signal can be passed to peripherals in place of an input pin.
#[inline]
#[instability::unstable]
pub fn peripheral_input(&self) -> interconnect::InputSignal {
self.pin.degrade_pin(private::Internal).split().0
}
Expand Down Expand Up @@ -2089,6 +2103,8 @@ where
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
#[inline]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
self.pin.degrade_pin(private::Internal).split()
}
Expand All @@ -2099,6 +2115,7 @@ where
/// The output signal can be passed to peripherals in place of an output
/// pin.
#[inline]
#[instability::unstable]
pub fn into_peripheral_output(self) -> interconnect::OutputSignal {
self.split().1
}
Expand Down Expand Up @@ -2151,6 +2168,7 @@ pub(crate) mod internal {
/// using external hardware.
#[inline]
#[allow(unused_braces, reason = "False positive")]
#[instability::unstable]
pub fn split(self) -> (interconnect::InputSignal, interconnect::OutputSignal) {
handle_gpio_input!(self, target, { target.split() })
}
Expand Down

0 comments on commit 0fe5b9b

Please sign in to comment.