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

Hide Info,State,Instance #2856

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
24 changes: 18 additions & 6 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ mod placeholder;

pub use placeholder::NoPin;

#[cfg(soc_etm)]
pub mod etm;
#[cfg(lp_io)]
pub mod lp_io;
#[cfg(all(rtc_io, not(esp32)))]
pub mod rtc_io;
crate::unstable_module! {
#[cfg(soc_etm)]
pub mod etm;
#[cfg(lp_io)]
pub mod lp_io;
#[cfg(all(rtc_io, not(esp32)))]
pub mod rtc_io;
}

/// Convenience constant for `Option::None` pin
static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::new();
Expand Down Expand Up @@ -139,6 +141,7 @@ impl From<WakeEvent> for Event {
}

/// Event used to wake up from light sleep.
#[instability::unstable]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum WakeEvent {
Expand Down Expand Up @@ -233,6 +236,7 @@ pub enum DriveStrength {
///
/// The different variants correspond to different functionality depending on
/// the chip and the specific pin. For more information, refer to your chip's
#[doc(hidden)]
#[doc = crate::trm_markdown_link!("iomuxgpio")]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
Expand Down Expand Up @@ -268,6 +272,7 @@ impl TryFrom<usize> for AlternateFunction {
}

/// RTC function
#[instability::unstable]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RtcFunction {
Expand All @@ -278,6 +283,7 @@ pub enum RtcFunction {
}

/// Trait implemented by RTC pins
#[instability::unstable]
pub trait RtcPin: Pin {
/// RTC number of the pin
#[cfg(xtensa)]
Expand All @@ -300,6 +306,7 @@ pub trait RtcPin: Pin {

/// Trait implemented by RTC pins which supporting internal pull-up / pull-down
/// resistors.
#[instability::unstable]
pub trait RtcPinWithResistors: RtcPin {
/// Enable/disable the internal pull-up resistor
fn rtcio_pullup(&mut self, enable: bool);
Expand Down Expand Up @@ -516,13 +523,16 @@ pub trait OutputPin: Pin + Into<AnyPin> + 'static {
}

/// Trait implemented by pins which can be used as analog pins
#[instability::unstable]
pub trait AnalogPin: Pin {
/// Configure the pin for analog operation
#[doc(hidden)]
fn set_analog(&self, _: private::Internal);
}

/// Trait implemented by pins which can be used as Touchpad pins
#[cfg(touch)]
#[instability::unstable]
pub trait TouchPin: Pin {
/// Configure the pin for analog operation
#[doc(hidden)]
Expand Down Expand Up @@ -1583,6 +1593,7 @@ where
/// Enable as a wake-up source.
///
/// This will unlisten for interrupts
#[instability::unstable]
#[inline]
pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent) {
self.pin.wakeup_enable(enable, event);
Expand Down Expand Up @@ -1982,6 +1993,7 @@ where
/// Enable as a wake-up source.
///
/// This will unlisten for interrupts
#[instability::unstable]
#[inline]
pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent) {
self.listen_with_options(event.into(), false, false, enable);
Expand Down
3 changes: 3 additions & 0 deletions esp-hal/src/i2c/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ fn configure_clock(
}

/// Peripheral data describing a particular I2C instance.
#[doc(hidden)]
#[derive(Debug)]
#[non_exhaustive]
pub struct Info {
Expand Down Expand Up @@ -2188,13 +2189,15 @@ impl Driver<'_> {
}

/// Peripheral state for an I2C instance.
#[doc(hidden)]
#[non_exhaustive]
pub struct State {
/// Waker for the asynchronous operations.
pub waker: AtomicWaker,
}

/// I2C Peripheral Instance
#[doc(hidden)]
pub trait Instance: Peripheral<P = Self> + Into<AnyI2c> + 'static {
/// Returns the peripheral data and state describing this instance.
fn parts(&self) -> (&Info, &State);
Expand Down
3 changes: 3 additions & 0 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,15 +2362,18 @@ mod ehal1 {
}

/// SPI peripheral instance.
#[doc(hidden)]
pub trait PeripheralInstance: private::Sealed + Into<AnySpi> + DmaEligible + 'static {
/// Returns the peripheral data describing this SPI instance.
fn info(&self) -> &'static Info;
}

/// Marker trait for QSPI-capable SPI peripherals.
#[doc(hidden)]
pub trait QspiInstance: PeripheralInstance {}

/// Peripheral data describing a particular SPI instance.
#[doc(hidden)]
#[non_exhaustive]
pub struct Info {
/// Pointer to the register block for this SPI instance.
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/spi/slave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ impl InstanceDma for crate::peripherals::SPI2 {}
impl InstanceDma for crate::peripherals::SPI3 {}

/// Peripheral data describing a particular SPI instance.
#[doc(hidden)]
#[non_exhaustive]
#[doc(hidden)]
pub struct Info {
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ where
}

/// Trace peripheral instance
#[doc(hidden)]
pub trait Instance: crate::private::Sealed {
/// Get a reference to the peripheral's underlying register block
fn register_block(&self) -> &RegisterBlock;
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/twai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ where
}

/// TWAI peripheral instance.
#[doc(hidden)]
pub trait Instance: Peripheral<P = Self> + Into<AnyTwai> + 'static {
/// The identifier number for this TWAI instance.
fn number(&self) -> usize;
Expand Down
3 changes: 3 additions & 0 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,7 @@ pub mod lp_uart {
}

/// UART Peripheral Instance
#[doc(hidden)]
pub trait Instance: Peripheral<P = Self> + Into<AnyUart> + 'static {
/// Returns the peripheral data and state describing this UART instance.
fn parts(&self) -> (&'static Info, &'static State);
Expand All @@ -2239,6 +2240,7 @@ pub trait Instance: Peripheral<P = Self> + Into<AnyUart> + 'static {
}

/// Peripheral data describing a particular UART instance.
#[doc(hidden)]
#[non_exhaustive]
pub struct Info {
/// Pointer to the register block for this UART instance.
Expand Down Expand Up @@ -2269,6 +2271,7 @@ pub struct Info {
}

/// Peripheral state for a UART instance.
#[doc(hidden)]
#[non_exhaustive]
pub struct State {
/// Waker for the asynchronous RX operations.
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/usb_serial_jtag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ where
}

/// USB Serial/JTAG peripheral instance
#[doc(hidden)]
pub trait Instance: crate::private::Sealed {
/// Get a reference to the peripheral's underlying register block
fn register_block() -> &'static RegisterBlock;
Expand Down
Loading