Hide Info,State,Instance (#2856)

* Hide Info,State,Instance

* Fix lp_gpio macro

* Fix visibility
This commit is contained in:
Björn Quentin 2024-12-23 14:57:31 +01:00 committed by GitHub
parent c2de8a1859
commit 36095e447e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 40 additions and 5 deletions

View File

@ -42,6 +42,7 @@ pub struct LowPowerOutput<'d, const PIN: u8> {
impl<'d, const PIN: u8> LowPowerOutput<'d, PIN> { impl<'d, const PIN: u8> LowPowerOutput<'d, PIN> {
/// Create a new output pin for use by the low-power core /// Create a new output pin for use by the low-power core
#[instability::unstable]
pub fn new<P>(_pin: impl Peripheral<P = P> + 'd) -> Self pub fn new<P>(_pin: impl Peripheral<P = P> + 'd) -> Self
where where
P: OutputPin + RtcPin, P: OutputPin + RtcPin,
@ -77,6 +78,7 @@ pub struct LowPowerInput<'d, const PIN: u8> {
impl<'d, const PIN: u8> LowPowerInput<'d, PIN> { impl<'d, const PIN: u8> LowPowerInput<'d, PIN> {
/// Create a new input pin for use by the low-power core /// Create a new input pin for use by the low-power core
#[instability::unstable]
pub fn new<P>(_pin: impl Peripheral<P = P> + 'd) -> Self pub fn new<P>(_pin: impl Peripheral<P = P> + 'd) -> Self
where where
P: InputPin + RtcPin, P: InputPin + RtcPin,
@ -121,6 +123,7 @@ pub struct LowPowerOutputOpenDrain<'d, const PIN: u8> {
impl<'d, const PIN: u8> LowPowerOutputOpenDrain<'d, PIN> { impl<'d, const PIN: u8> LowPowerOutputOpenDrain<'d, PIN> {
/// Create a new output pin for use by the low-power core /// Create a new output pin for use by the low-power core
#[instability::unstable]
pub fn new<P>(_pin: impl Peripheral<P = P> + 'd) -> Self pub fn new<P>(_pin: impl Peripheral<P = P> + 'd) -> Self
where where
P: InputPin + OutputPin + RtcPin, P: InputPin + OutputPin + RtcPin,
@ -191,7 +194,6 @@ pub(crate) fn init_low_power_pin(pin: u8) {
} }
#[doc(hidden)] #[doc(hidden)]
#[macro_export]
macro_rules! lp_gpio { macro_rules! lp_gpio {
( (
$($gpionum:literal)+ $($gpionum:literal)+
@ -262,3 +264,5 @@ macro_rules! lp_gpio {
)+ )+
} }
} }
pub(crate) use lp_gpio;

View File

@ -86,11 +86,19 @@ mod placeholder;
pub use placeholder::NoPin; pub use placeholder::NoPin;
#[cfg(soc_etm)] #[cfg(soc_etm)]
pub mod etm; crate::unstable_module! {
pub mod etm;
}
#[cfg(lp_io)] #[cfg(lp_io)]
pub mod lp_io; crate::unstable_module! {
pub mod lp_io;
}
#[cfg(all(rtc_io, not(esp32)))] #[cfg(all(rtc_io, not(esp32)))]
pub mod rtc_io; crate::unstable_module! {
pub mod rtc_io;
}
/// Convenience constant for `Option::None` pin /// Convenience constant for `Option::None` pin
static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::new(); static USER_INTERRUPT_HANDLER: CFnPtr = CFnPtr::new();
@ -139,6 +147,7 @@ impl From<WakeEvent> for Event {
} }
/// Event used to wake up from light sleep. /// Event used to wake up from light sleep.
#[instability::unstable]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum WakeEvent { pub enum WakeEvent {
@ -233,6 +242,7 @@ pub enum DriveStrength {
/// ///
/// The different variants correspond to different functionality depending on /// The different variants correspond to different functionality depending on
/// the chip and the specific pin. For more information, refer to your chip's /// the chip and the specific pin. For more information, refer to your chip's
#[doc(hidden)]
#[doc = crate::trm_markdown_link!("iomuxgpio")] #[doc = crate::trm_markdown_link!("iomuxgpio")]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
@ -268,6 +278,7 @@ impl TryFrom<usize> for AlternateFunction {
} }
/// RTC function /// RTC function
#[instability::unstable]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RtcFunction { pub enum RtcFunction {
@ -278,6 +289,7 @@ pub enum RtcFunction {
} }
/// Trait implemented by RTC pins /// Trait implemented by RTC pins
#[instability::unstable]
pub trait RtcPin: Pin { pub trait RtcPin: Pin {
/// RTC number of the pin /// RTC number of the pin
#[cfg(xtensa)] #[cfg(xtensa)]
@ -300,6 +312,7 @@ pub trait RtcPin: Pin {
/// Trait implemented by RTC pins which supporting internal pull-up / pull-down /// Trait implemented by RTC pins which supporting internal pull-up / pull-down
/// resistors. /// resistors.
#[instability::unstable]
pub trait RtcPinWithResistors: RtcPin { pub trait RtcPinWithResistors: RtcPin {
/// Enable/disable the internal pull-up resistor /// Enable/disable the internal pull-up resistor
fn rtcio_pullup(&mut self, enable: bool); fn rtcio_pullup(&mut self, enable: bool);
@ -516,6 +529,7 @@ pub trait OutputPin: Pin + Into<AnyPin> + 'static {
} }
/// Trait implemented by pins which can be used as analog pins /// Trait implemented by pins which can be used as analog pins
#[instability::unstable]
pub trait AnalogPin: Pin { pub trait AnalogPin: Pin {
/// Configure the pin for analog operation /// Configure the pin for analog operation
#[doc(hidden)] #[doc(hidden)]
@ -523,6 +537,8 @@ pub trait AnalogPin: Pin {
} }
/// Trait implemented by pins which can be used as Touchpad pins /// Trait implemented by pins which can be used as Touchpad pins
#[cfg(touch)]
#[instability::unstable]
pub trait TouchPin: Pin { pub trait TouchPin: Pin {
/// Configure the pin for analog operation /// Configure the pin for analog operation
#[doc(hidden)] #[doc(hidden)]
@ -1583,6 +1599,7 @@ where
/// Enable as a wake-up source. /// Enable as a wake-up source.
/// ///
/// This will unlisten for interrupts /// This will unlisten for interrupts
#[instability::unstable]
#[inline] #[inline]
pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent) { pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent) {
self.pin.wakeup_enable(enable, event); self.pin.wakeup_enable(enable, event);
@ -1982,6 +1999,7 @@ where
/// Enable as a wake-up source. /// Enable as a wake-up source.
/// ///
/// This will unlisten for interrupts /// This will unlisten for interrupts
#[instability::unstable]
#[inline] #[inline]
pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent) { pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent) {
self.listen_with_options(event.into(), false, false, enable); self.listen_with_options(event.into(), false, false, enable);

View File

@ -985,6 +985,7 @@ fn configure_clock(
} }
/// Peripheral data describing a particular I2C instance. /// Peripheral data describing a particular I2C instance.
#[doc(hidden)]
#[derive(Debug)] #[derive(Debug)]
#[non_exhaustive] #[non_exhaustive]
pub struct Info { pub struct Info {
@ -2188,6 +2189,7 @@ impl Driver<'_> {
} }
/// Peripheral state for an I2C instance. /// Peripheral state for an I2C instance.
#[doc(hidden)]
#[non_exhaustive] #[non_exhaustive]
pub struct State { pub struct State {
/// Waker for the asynchronous operations. /// Waker for the asynchronous operations.
@ -2195,6 +2197,7 @@ pub struct State {
} }
/// I2C Peripheral Instance /// I2C Peripheral Instance
#[doc(hidden)]
pub trait Instance: Peripheral<P = Self> + Into<AnyI2c> + 'static { pub trait Instance: Peripheral<P = Self> + Into<AnyI2c> + 'static {
/// Returns the peripheral data and state describing this instance. /// Returns the peripheral data and state describing this instance.
fn parts(&self) -> (&Info, &State); fn parts(&self) -> (&Info, &State);

View File

@ -287,7 +287,7 @@ pub enum OutputSignal {
GPIO = 128, GPIO = 128,
} }
crate::lp_gpio! { crate::gpio::lp_io::lp_gpio! {
0 0
1 1
2 2

View File

@ -2362,15 +2362,18 @@ mod ehal1 {
} }
/// SPI peripheral instance. /// SPI peripheral instance.
#[doc(hidden)]
pub trait PeripheralInstance: private::Sealed + Into<AnySpi> + DmaEligible + 'static { pub trait PeripheralInstance: private::Sealed + Into<AnySpi> + DmaEligible + 'static {
/// Returns the peripheral data describing this SPI instance. /// Returns the peripheral data describing this SPI instance.
fn info(&self) -> &'static Info; fn info(&self) -> &'static Info;
} }
/// Marker trait for QSPI-capable SPI peripherals. /// Marker trait for QSPI-capable SPI peripherals.
#[doc(hidden)]
pub trait QspiInstance: PeripheralInstance {} pub trait QspiInstance: PeripheralInstance {}
/// Peripheral data describing a particular SPI instance. /// Peripheral data describing a particular SPI instance.
#[doc(hidden)]
#[non_exhaustive] #[non_exhaustive]
pub struct Info { pub struct Info {
/// Pointer to the register block for this SPI instance. /// Pointer to the register block for this SPI instance.

View File

@ -602,6 +602,7 @@ impl InstanceDma for crate::peripherals::SPI2 {}
impl InstanceDma for crate::peripherals::SPI3 {} impl InstanceDma for crate::peripherals::SPI3 {}
/// Peripheral data describing a particular SPI instance. /// Peripheral data describing a particular SPI instance.
#[doc(hidden)]
#[non_exhaustive] #[non_exhaustive]
#[doc(hidden)] #[doc(hidden)]
pub struct Info { pub struct Info {

View File

@ -207,6 +207,7 @@ where
} }
/// Trace peripheral instance /// Trace peripheral instance
#[doc(hidden)]
pub trait Instance: crate::private::Sealed { pub trait Instance: crate::private::Sealed {
/// Get a reference to the peripheral's underlying register block /// Get a reference to the peripheral's underlying register block
fn register_block(&self) -> &RegisterBlock; fn register_block(&self) -> &RegisterBlock;

View File

@ -1360,6 +1360,7 @@ where
} }
/// TWAI peripheral instance. /// TWAI peripheral instance.
#[doc(hidden)]
pub trait Instance: Peripheral<P = Self> + Into<AnyTwai> + 'static { pub trait Instance: Peripheral<P = Self> + Into<AnyTwai> + 'static {
/// The identifier number for this TWAI instance. /// The identifier number for this TWAI instance.
fn number(&self) -> usize; fn number(&self) -> usize;

View File

@ -2221,6 +2221,7 @@ pub mod lp_uart {
} }
/// UART Peripheral Instance /// UART Peripheral Instance
#[doc(hidden)]
pub trait Instance: Peripheral<P = Self> + Into<AnyUart> + 'static { pub trait Instance: Peripheral<P = Self> + Into<AnyUart> + 'static {
/// Returns the peripheral data and state describing this UART instance. /// Returns the peripheral data and state describing this UART instance.
fn parts(&self) -> (&'static Info, &'static State); fn parts(&self) -> (&'static Info, &'static State);
@ -2239,6 +2240,7 @@ pub trait Instance: Peripheral<P = Self> + Into<AnyUart> + 'static {
} }
/// Peripheral data describing a particular UART instance. /// Peripheral data describing a particular UART instance.
#[doc(hidden)]
#[non_exhaustive] #[non_exhaustive]
pub struct Info { pub struct Info {
/// Pointer to the register block for this UART instance. /// Pointer to the register block for this UART instance.
@ -2269,6 +2271,7 @@ pub struct Info {
} }
/// Peripheral state for a UART instance. /// Peripheral state for a UART instance.
#[doc(hidden)]
#[non_exhaustive] #[non_exhaustive]
pub struct State { pub struct State {
/// Waker for the asynchronous RX operations. /// Waker for the asynchronous RX operations.

View File

@ -450,6 +450,7 @@ where
} }
/// USB Serial/JTAG peripheral instance /// USB Serial/JTAG peripheral instance
#[doc(hidden)]
pub trait Instance: crate::private::Sealed { pub trait Instance: crate::private::Sealed {
/// Get a reference to the peripheral's underlying register block /// Get a reference to the peripheral's underlying register block
fn register_block() -> &'static RegisterBlock; fn register_block() -> &'static RegisterBlock;