More touching up of generated code (#3791)

* Document remaining macros, update gpio syntax

* Update if_pin_is_type syntax, simplify impl

* Remove impl_for_pin_type

* Remove if_pin_is_type

* Remove the gpio macro
This commit is contained in:
Dániel Buga 2025-07-14 15:05:27 +02:00 committed by GitHub
parent 40fc4f2c6c
commit 496aeb864b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 791 additions and 3379 deletions

View File

@ -80,7 +80,7 @@ use strum::EnumCount;
use crate::{ use crate::{
asynch::AtomicWaker, asynch::AtomicWaker,
interrupt::{InterruptHandler, Priority}, interrupt::{InterruptHandler, Priority},
peripherals::{GPIO, IO_MUX, Interrupt, io_mux_reg}, peripherals::{GPIO, IO_MUX, Interrupt},
private::{self, Sealed}, private::{self, Sealed},
}; };
@ -695,170 +695,6 @@ for_each_analog_function! {
}; };
} }
/// This macro is called from code generated by `esp-metadata`. It defines the
/// GPIOn singletons and varios AnyPin methods.
#[doc(hidden)]
#[macro_export]
macro_rules! gpio {
(
$(
(
$gpionum:literal, $peri:ident
( $( $af_input_num:ident => $af_input_signal:ident )* )
( $( $af_output_num:ident => $af_output_signal:ident )* )
)
)+
) => {
$(
impl<'d> $peri<'d> {
#[allow(unused)]
pub(crate) const NUMBER: u8 = $gpionum;
/// Split the pin into an input and output signal.
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
///
/// # Safety
///
/// The caller must ensure that peripheral drivers don't configure the same
/// GPIO at the same time in multiple places. This includes clones of the
/// `InputSignal` struct, as well as the `OutputSignal` struct.
///
/// ```rust, no_run
#[doc = $crate::before_snippet!()]
/// let (rx, tx) = unsafe { peripherals.GPIO2.split() };
/// // rx and tx can then be passed to different peripherals to connect them.
/// # Ok(())
/// # }
/// ```
#[instability::unstable]
pub unsafe fn split(self) -> ($crate::gpio::interconnect::InputSignal<'d>, $crate::gpio::interconnect::OutputSignal<'d>) {
use $crate::gpio::Pin;
// FIXME: we should implement this in the gpio macro for output pins, but we
// should also have an input-only alternative for pins that can't be used as
// outputs.
// This goes through AnyPin which calls `init_gpio` as needed.
unsafe { self.degrade().split() }
}
}
impl $crate::gpio::Pin for $peri<'_> {
#[inline(always)]
fn number(&self) -> u8 {
$gpionum
}
fn output_signals(&self, _: $crate::private::Internal) -> &'static [($crate::gpio::AlternateFunction, $crate::gpio::OutputSignal)] {
&[
$(
(
$crate::gpio::AlternateFunction::$af_output_num,
$crate::gpio::OutputSignal::$af_output_signal
),
)*
]
}
fn input_signals(&self, _: $crate::private::Internal) -> &'static [($crate::gpio::AlternateFunction, $crate::gpio::InputSignal)] {
&[
$(
(
$crate::gpio::AlternateFunction::$af_input_num,
$crate::gpio::InputSignal::$af_input_signal
),
)*
]
}
}
impl<'lt> From<$peri<'lt>> for $crate::gpio::AnyPin<'lt> {
fn from(pin: $peri<'lt>) -> Self {
$crate::gpio::Pin::degrade(pin)
}
}
)+
impl $crate::gpio::AnyPin<'_> {
/// Conjure a new GPIO pin out of thin air.
///
/// # Safety
///
/// The caller must ensure that only one instance of a pin is in use at one time.
///
/// # Panics
///
/// Panics if the pin with the given number does not exist.
///
/// ## Example
///
/// ```rust, no_run
#[doc = $crate::before_snippet!()]
/// use esp_hal::gpio::AnyPin;
/// let pin = unsafe { AnyPin::steal(1) };
/// # Ok(())
/// # }
/// ```
pub unsafe fn steal(pin: u8) -> Self {
const PINS: &[u8] = &[$($gpionum),*];
assert!(PINS.contains(&pin), "Pin {} does not exist", pin);
Self { pin, _lifetime: core::marker::PhantomData }
}
/// Unsafely clone the pin.
///
/// # Safety
///
/// Ensure that only one instance of a pin is in use at one time.
///
/// ## Example
///
/// ```rust, no_run
#[doc = $crate::before_snippet!()]
/// use esp_hal::gpio::{AnyPin, Pin};
/// let pin = peripherals.GPIO1.degrade();
/// let pin_cloned = unsafe { pin.clone_unchecked() };
/// # Ok(())
/// # }
/// ```
pub unsafe fn clone_unchecked(&self) -> Self {
Self {
pin: self.pin,
_lifetime: core::marker::PhantomData,
}
}
/// Create a new AnyPin object that is limited to the lifetime of the
/// passed reference.
///
/// ## Example
///
/// ```rust, no_run
#[doc = $crate::before_snippet!()]
/// use esp_hal::gpio::{AnyPin, Pin};
/// let mut pin = peripherals.GPIO1.degrade();
/// let pin_reborrowed = pin.reborrow();
/// # Ok(())
/// # }
/// ```
pub fn reborrow(&mut self) -> $crate::gpio::AnyPin<'_> {
unsafe { self.clone_unchecked() }
}
pub(crate) fn is_output(&self) -> bool {
match self.pin {
$(
$gpionum => if_pin_is_type!($peri, Output, { true } else { false }),
)+
_ => false,
}
}
}
};
}
/// The drive mode of the output pin. /// The drive mode of the output pin.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
@ -2132,24 +1968,59 @@ impl Pin for AnyPin<'_> {
&self, &self,
private: private::Internal, private: private::Internal,
) -> &'static [(AlternateFunction, OutputSignal)] { ) -> &'static [(AlternateFunction, OutputSignal)] {
impl_for_pin_type!(self, target, Output, { for_each_gpio! {
Pin::output_signals(&target, private) (all $( ($n:literal, $gpio:ident $in_afs:tt $out_afs:tt ($input:tt [$($is_output:ident)?]) ) ),* ) => {
}) match self.number() {
$($(
$n => {
crate::ignore!($is_output);
let inner = unsafe { crate::peripherals::$gpio::steal() };
return Pin::output_signals(&inner, private);
}
)?)*
other => panic!("Pin {} is not an OutputPin", other)
}
};
}
} }
fn input_signals( fn input_signals(
&self, &self,
private: private::Internal, private: private::Internal,
) -> &'static [(AlternateFunction, InputSignal)] { ) -> &'static [(AlternateFunction, InputSignal)] {
impl_for_pin_type!(self, target, Input, { for_each_gpio! {
Pin::input_signals(&target, private) (all $( ($n:literal, $gpio:ident $in_afs:tt $out_afs:tt ([$($is_input:ident)?] $output:tt) ) ),* ) => {
}) match self.number() {
$($(
$n => {
crate::ignore!($is_input);
let inner = unsafe { crate::peripherals::$gpio::steal() };
return Pin::input_signals(&inner, private);
}
)?)*
other => panic!("Pin {} is not an InputPin", other)
}
};
}
} }
} }
impl InputPin for AnyPin<'_> { impl InputPin for AnyPin<'_> {
fn waker(&self) -> &'static AtomicWaker { fn waker(&self) -> &'static AtomicWaker {
impl_for_pin_type!(self, target, Input, { InputPin::waker(&target) }) for_each_gpio! {
(all $( ($n:literal, $gpio:ident $in_afs:tt $out_afs:tt ([$($is_input:ident)?] $output:tt) ) ),* ) => {
match self.number() {
$($(
$n => {
crate::ignore!($is_input);
let inner = unsafe { crate::peripherals::$gpio::steal() };
return InputPin::waker(&inner);
}
)?)*
other => panic!("Pin {} is not an InputPin", other)
}
};
}
} }
} }
impl OutputPin for AnyPin<'_> {} impl OutputPin for AnyPin<'_> {}
@ -2203,6 +2074,99 @@ impl AnyPin<'_> {
{ {
self.try_into() self.try_into()
} }
#[procmacros::doc_replace]
/// Conjure a new GPIO pin out of thin air.
///
/// # Safety
///
/// The caller must ensure that only one instance of a pin is in use at one time.
///
/// # Panics
///
/// Panics if the pin with the given number does not exist.
///
/// ## Example
///
/// ```rust, no_run
/// # {before_snippet}
/// #
/// use esp_hal::gpio::AnyPin;
/// let pin = unsafe { AnyPin::steal(1) };
/// #
/// # {after_snippet}
/// ```
pub unsafe fn steal(pin: u8) -> Self {
for_each_gpio! {
(all $( ($n:literal $($any:tt)*) ),*) => { const PINS: &[u8] = &[ $($n),* ]; };
};
assert!(PINS.contains(&pin), "Pin {} does not exist", pin);
Self {
pin,
_lifetime: core::marker::PhantomData,
}
}
#[procmacros::doc_replace]
/// Unsafely clone the pin.
///
/// # Safety
///
/// Ensure that only one instance of a pin is in use at one time.
///
/// ## Example
///
/// ```rust, no_run
/// # {before_snippet}
/// #
/// use esp_hal::gpio::{AnyPin, Pin};
/// let pin = peripherals.GPIO1.degrade();
/// let pin_cloned = unsafe { pin.clone_unchecked() };
/// #
/// # {after_snippet}
/// ```
pub unsafe fn clone_unchecked(&self) -> Self {
Self {
pin: self.pin,
_lifetime: core::marker::PhantomData,
}
}
#[procmacros::doc_replace]
/// Create a new AnyPin object that is limited to the lifetime of the
/// passed reference.
///
/// ## Example
///
/// ```rust, no_run
/// # {before_snippet}
/// #
/// use esp_hal::gpio::{AnyPin, Pin};
/// let mut pin = peripherals.GPIO1.degrade();
/// let pin_reborrowed = pin.reborrow();
/// #
/// # {after_snippet}
/// ```
pub fn reborrow(&mut self) -> AnyPin<'_> {
unsafe { self.clone_unchecked() }
}
pub(crate) fn is_output(&self) -> bool {
for_each_gpio! {
(all $( ($n:literal, $gpio:ident $in_afs:tt $out_afs:tt ($input:tt [$($is_output:ident)?]) ) ),* ) => {
return match self.number() {
$($(
// This code is generated if the Output attribute is present
$n => {
crate::ignore!($is_output);
true
}
)?)*
other => false,
};
};
}
}
} }
#[cold] #[cold]
@ -2238,13 +2202,18 @@ macro_rules! for_each_rtcio_pin {
macro_rules! for_each_rtcio_output_pin { macro_rules! for_each_rtcio_output_pin {
(@impl $ident:ident, $target:ident, $gpio:ident, $code:tt, $kind:literal) => { (@impl $ident:ident, $target:ident, $gpio:ident, $code:tt, $kind:literal) => {
if $ident.number() == $crate::peripherals::$gpio::NUMBER { if $ident.number() == $crate::peripherals::$gpio::NUMBER {
if_pin_is_type!($gpio, Output, { for_each_gpio! {
#[allow(unused_mut)] // If the pin is an output pin, generate $code
let mut $target = unsafe { $crate::peripherals::$gpio::steal() }; ($n:tt, $gpio $in_afs:tt $out_afs:tt ($input:tt [Output])) => {
return $code; #[allow(unused_mut)]
} else { let mut $target = unsafe { $crate::peripherals::$gpio::steal() };
pin_does_not_support_function($crate::peripherals::$gpio::NUMBER, $kind) return $code;
}) };
// If the pin is not an output pin, generate a panic
($n:tt, $gpio $in_afs:tt $out_afs:tt ($input:tt [])) => {
pin_does_not_support_function($crate::peripherals::$gpio::NUMBER, $kind)
};
}
} }
}; };
@ -2325,3 +2294,86 @@ fn set_int_enable(gpio_num: u8, int_ena: Option<u8>, int_type: u8, wake_up_from_
fn is_int_enabled(gpio_num: u8) -> bool { fn is_int_enabled(gpio_num: u8) -> bool {
GPIO::regs().pin(gpio_num as usize).read().int_ena().bits() != 0 GPIO::regs().pin(gpio_num as usize).read().int_ena().bits() != 0
} }
for_each_gpio! {
($n:literal, $gpio:ident $af_ins:tt $af_outs:tt ([Input] $output:tt)) => {
impl InputPin for crate::peripherals::$gpio<'_> {
#[doc(hidden)]
#[inline]
fn waker(&self) -> &'static $crate::asynch::AtomicWaker {
static WAKER: $crate::asynch::AtomicWaker = $crate::asynch::AtomicWaker::new();
&WAKER
}
}
};
}
for_each_gpio! {
($n:literal, $gpio:ident $af_ins:tt $af_outs:tt ($input:tt [Output])) => {
impl OutputPin for crate::peripherals::$gpio<'_> {}
};
}
for_each_gpio! {
($n:literal, $gpio:ident ($( $af_input_num:ident => $af_input_signal:ident )*) ($( $af_output_num:ident => $af_output_signal:ident )*) $attrs:tt) => {
impl<'d> crate::peripherals::$gpio<'d> {
#[allow(unused)]
pub(crate) const NUMBER: u8 = $n;
#[procmacros::doc_replace]
/// Split the pin into an input and output signal.
///
/// Peripheral signals allow connecting peripherals together without using
/// external hardware.
///
/// # Safety
///
/// The caller must ensure that peripheral drivers don't configure the same
/// GPIO at the same time in multiple places. This includes clones of the
/// `InputSignal` struct, as well as the `OutputSignal` struct.
///
/// ```rust, no_run
/// # {before_snippet}
/// #
/// let (rx, tx) = unsafe { peripherals.GPIO2.split() };
/// // rx and tx can then be passed to different peripherals to connect them.
/// #
/// # {after_snippet}
/// ```
#[instability::unstable]
pub unsafe fn split(self) -> (interconnect::InputSignal<'d>, interconnect::OutputSignal<'d>) {
// FIXME: we should implement this in the gpio macro for output pins, but we
// should also have an input-only alternative for pins that can't be used as
// outputs.
// This goes through AnyPin which calls `init_gpio` as needed.
unsafe { self.degrade().split() }
}
}
impl Pin for crate::peripherals::$gpio<'_> {
#[inline(always)]
fn number(&self) -> u8 {
$n
}
fn output_signals(&self, _: crate::private::Internal) -> &'static [(AlternateFunction, OutputSignal)] {
&[$(
(AlternateFunction::$af_output_num, OutputSignal::$af_output_signal),
)*]
}
fn input_signals(&self, _: crate::private::Internal) -> &'static [(AlternateFunction, InputSignal)] {
&[$(
(AlternateFunction::$af_input_num, InputSignal::$af_input_signal),
)*]
}
}
impl<'lt> From<crate::peripherals::$gpio<'lt>> for AnyPin<'lt> {
fn from(pin: crate::peripherals::$gpio<'lt>) -> Self {
Pin::degrade(pin)
}
}
};
}
define_io_mux_reg!();

View File

@ -119,38 +119,6 @@ macro_rules! create_peripheral {
}; };
} }
macro_rules! io_type {
(Input, $peri:ident) => {
impl $crate::gpio::InputPin for $peri<'_> {
#[doc(hidden)]
#[inline]
fn waker(&self) -> &'static $crate::asynch::AtomicWaker {
static WAKER: $crate::asynch::AtomicWaker = $crate::asynch::AtomicWaker::new();
&WAKER
}
}
};
(Output, $peri:ident) => {
impl $crate::gpio::OutputPin for $peri<'_> {}
};
}
for_each_gpio! {
($n:literal, $pin_peri:ident $af_ins:tt $af_outs:tt ($($attr:ident)*)) => {
$(
io_type!($attr, $pin_peri);
)*
};
(all $( ($n:literal, $pin_peri:ident $af_ins:tt $af_outs:tt $attrs:tt) ),*) => {
crate::gpio! {
$( ($n, $pin_peri $af_ins $af_outs) )*
}
};
}
define_io_mux_reg!();
for_each_peripheral! { for_each_peripheral! {
// Define stable peripheral singletons // Define stable peripheral singletons
($name:ident <= $from_pac:tt $interrupts:tt) => { ($name:ident <= $from_pac:tt $interrupts:tt) => {

View File

@ -1029,7 +1029,7 @@ pub(crate) mod utils {
fn configure_gpio(gpio: u8, field: Field, bits: u8) { fn configure_gpio(gpio: u8, field: Field, bits: u8) {
unsafe { unsafe {
let ptr = crate::peripherals::io_mux_reg(gpio); let ptr = crate::gpio::io_mux_reg(gpio);
ptr.modify(|_, w| apply_to_field!(w, field, bits)); ptr.modify(|_, w| apply_to_field!(w, field, bits));
} }
} }

View File

@ -416,7 +416,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -429,95 +429,100 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0(_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) _for_each_inner!((0, GPIO0(_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK)
(Input Output))); _for_each_inner!((1, GPIO1(_5 => EMAC_RXD2) (_0 => U0TXD _1 => ([Input] [Output]))); _for_each_inner!((1, GPIO1(_5 => EMAC_RXD2) (_0 => U0TXD _1
CLK_OUT3) (Input Output))); _for_each_inner!((2, GPIO2(_1 => HSPIWP _3 => => CLK_OUT3) ([Input] [Output]))); _for_each_inner!((2, GPIO2(_1 => HSPIWP _3 =>
HS2_DATA0 _4 => SD_DATA0) (_1 => HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) (Input HS2_DATA0 _4 => SD_DATA0) (_1 => HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) ([Input]
Output))); _for_each_inner!((3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) (Input [Output]))); _for_each_inner!((3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) ([Input]
Output))); _for_each_inner!((4, GPIO4(_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 [Output]))); _for_each_inner!((4, GPIO4(_1 => HSPIHD _3 => HS2_DATA1 _4 =>
_5 => EMAC_TX_ER) (_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 => EMAC_TX_ER) SD_DATA1 _5 => EMAC_TX_ER) (_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 =>
(Input Output))); _for_each_inner!((5, GPIO5(_1 => VSPICS0 _3 => HS1_DATA6 _5 => EMAC_TX_ER) ([Input] [Output]))); _for_each_inner!((5, GPIO5(_1 => VSPICS0 _3 =>
EMAC_RX_CLK) (_1 => VSPICS0 _3 => HS1_DATA6) (Input Output))); HS1_DATA6 _5 => EMAC_RX_CLK) (_1 => VSPICS0 _3 => HS1_DATA6) ([Input]
_for_each_inner!((6, GPIO6(_1 => SPICLK _4 => U1CTS) (_0 => SD_CLK _1 => SPICLK [Output]))); _for_each_inner!((6, GPIO6(_1 => SPICLK _4 => U1CTS) (_0 => SD_CLK
_3 => HS1_CLK) (Input Output))); _for_each_inner!((7, GPIO7(_0 => SD_DATA0 _1 => _1 => SPICLK _3 => HS1_CLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_0
SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0 _4 => U2RTS) => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 =>
(Input Output))); _for_each_inner!((8, GPIO8(_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA0 _4 => U2RTS) ([Input] [Output]))); _for_each_inner!((8, GPIO8(_0 =>
HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1) (Input SD_DATA1 _1 => SPID _3 => HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 =>
Output))); _for_each_inner!((9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2 HS1_DATA1) ([Input] [Output]))); _for_each_inner!((9, GPIO9(_0 => SD_DATA2 _1 =>
_4 => U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2) (Input Output))); SPIHD _3 => HS1_DATA2 _4 => U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2)
_for_each_inner!((10, GPIO10(_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3) (_0 => ([Input] [Output]))); _for_each_inner!((10, GPIO10(_0 => SD_DATA3 _1 => SPIWP _3
SD_DATA3 _1 => SPIWP _3 => HS1_DATA3 _4 => U1TXD) (Input Output))); => HS1_DATA3) (_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3 _4 => U1TXD) ([Input]
_for_each_inner!((11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 => SD_CMD _1 => [Output]))); _for_each_inner!((11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 =>
SPICS0 _3 => HS1_CMD _4 => U1RTS) (Input Output))); _for_each_inner!((12, SD_CMD _1 => SPICS0 _3 => HS1_CMD _4 => U1RTS) ([Input] [Output])));
_for_each_inner!((12, GPIO12(_0 => MTDI _1 => HSPIQ _3 => HS2_DATA2 _4 =>
SD_DATA2) (_1 => HSPIQ _3 => HS2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) ([Input]
[Output]))); _for_each_inner!((13, GPIO13(_0 => MTCK _1 => HSPID _3 => HS2_DATA3
_4 => SD_DATA3 _5 => EMAC_RX_ER) (_1 => HSPID _3 => HS2_DATA3 _4 => SD_DATA3 _5
=> EMAC_RX_ER) ([Input] [Output]))); _for_each_inner!((14, GPIO14(_0 => MTMS _1
=> HSPICLK) (_1 => HSPICLK _3 => HS2_CLK _4 => SD_CLK _5 => EMAC_TXD2) ([Input]
[Output]))); _for_each_inner!((15, GPIO15(_1 => HSPICS0 _4 => SD_CMD _5 =>
EMAC_RXD3) (_0 => MTDO _1 => HSPICS0 _3 => HS2_CMD _4 => SD_CMD) ([Input]
[Output]))); _for_each_inner!((16, GPIO16(_3 => HS1_DATA4 _4 => U2RXD) (_3 =>
HS1_DATA4 _5 => EMAC_CLK_OUT) ([Input] [Output]))); _for_each_inner!((17,
GPIO17(_3 => HS1_DATA5) (_3 => HS1_DATA5 _4 => U2TXD _5 => EMAC_CLK_180) ([Input]
[Output]))); _for_each_inner!((18, GPIO18(_1 => VSPICLK _3 => HS1_DATA7) (_1 =>
VSPICLK _3 => HS1_DATA7) ([Input] [Output]))); _for_each_inner!((19, GPIO19(_1 =>
VSPIQ _3 => U0CTS) (_1 => VSPIQ _5 => EMAC_TXD0) ([Input] [Output])));
_for_each_inner!((20, GPIO20() () ([Input] [Output]))); _for_each_inner!((21,
GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 => EMAC_TX_EN) ([Input] [Output])));
_for_each_inner!((22, GPIO22(_1 => VSPIWP) (_1 => VSPIWP _3 => U0RTS _5 =>
EMAC_TXD1) ([Input] [Output]))); _for_each_inner!((23, GPIO23(_1 => VSPID) (_1 =>
VSPID _3 => HS1_STROBE) ([Input] [Output]))); _for_each_inner!((25, GPIO25(_5 =>
EMAC_RXD0) () ([Input] [Output]))); _for_each_inner!((26, GPIO26(_5 => EMAC_RXD1)
() ([Input] [Output]))); _for_each_inner!((27, GPIO27(_5 => EMAC_RX_DV) ()
([Input] [Output]))); _for_each_inner!((32, GPIO32() () ([Input] [Output])));
_for_each_inner!((33, GPIO33() () ([Input] [Output]))); _for_each_inner!((34,
GPIO34() () ([Input] []))); _for_each_inner!((35, GPIO35() () ([Input] [])));
_for_each_inner!((36, GPIO36() () ([Input] []))); _for_each_inner!((37, GPIO37()
() ([Input] []))); _for_each_inner!((38, GPIO38() () ([Input] [])));
_for_each_inner!((39, GPIO39() () ([Input] []))); _for_each_inner!((all(0,
GPIO0(_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output])),
(1, GPIO1(_5 => EMAC_RXD2) (_0 => U0TXD _1 => CLK_OUT3) ([Input] [Output])), (2,
GPIO2(_1 => HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) (_1 => HSPIWP _3 => HS2_DATA0
_4 => SD_DATA0) ([Input] [Output])), (3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2)
([Input] [Output])), (4, GPIO4(_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 =>
EMAC_TX_ER) (_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 => EMAC_TX_ER)
([Input] [Output])), (5, GPIO5(_1 => VSPICS0 _3 => HS1_DATA6 _5 => EMAC_RX_CLK)
(_1 => VSPICS0 _3 => HS1_DATA6) ([Input] [Output])), (6, GPIO6(_1 => SPICLK _4 =>
U1CTS) (_0 => SD_CLK _1 => SPICLK _3 => HS1_CLK) ([Input] [Output])), (7,
GPIO7(_0 => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 =>
HS1_DATA0 _4 => U2RTS) ([Input] [Output])), (8, GPIO8(_0 => SD_DATA1 _1 => SPID
_3 => HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1) ([Input]
[Output])), (9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2 _4 => U1RXD) (_0
=> SD_DATA2 _1 => SPIHD _3 => HS1_DATA2) ([Input] [Output])), (10, GPIO10(_0 =>
SD_DATA3 _1 => SPIWP _3 => HS1_DATA3) (_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3
_4 => U1TXD) ([Input] [Output])), (11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 =>
SD_CMD _1 => SPICS0 _3 => HS1_CMD _4 => U1RTS) ([Input] [Output])), (12,
GPIO12(_0 => MTDI _1 => HSPIQ _3 => HS2_DATA2 _4 => SD_DATA2) (_1 => HSPIQ _3 => GPIO12(_0 => MTDI _1 => HSPIQ _3 => HS2_DATA2 _4 => SD_DATA2) (_1 => HSPIQ _3 =>
HS2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) (Input Output))); _for_each_inner!((13, HS2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) ([Input] [Output])), (13, GPIO13(_0 =>
GPIO13(_0 => MTCK _1 => HSPID _3 => HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) MTCK _1 => HSPID _3 => HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) (_1 => HSPID _3
(_1 => HSPID _3 => HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) (Input Output))); => HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) ([Input] [Output])), (14, GPIO14(_0
_for_each_inner!((14, GPIO14(_0 => MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => => MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => HS2_CLK _4 => SD_CLK _5 => EMAC_TXD2)
HS2_CLK _4 => SD_CLK _5 => EMAC_TXD2) (Input Output))); _for_each_inner!((15, ([Input] [Output])), (15, GPIO15(_1 => HSPICS0 _4 => SD_CMD _5 => EMAC_RXD3) (_0
GPIO15(_1 => HSPICS0 _4 => SD_CMD _5 => EMAC_RXD3) (_0 => MTDO _1 => HSPICS0 _3 => MTDO _1 => HSPICS0 _3 => HS2_CMD _4 => SD_CMD) ([Input] [Output])), (16,
=> HS2_CMD _4 => SD_CMD) (Input Output))); _for_each_inner!((16, GPIO16(_3 => GPIO16(_3 => HS1_DATA4 _4 => U2RXD) (_3 => HS1_DATA4 _5 => EMAC_CLK_OUT) ([Input]
HS1_DATA4 _4 => U2RXD) (_3 => HS1_DATA4 _5 => EMAC_CLK_OUT) (Input Output))); [Output])), (17, GPIO17(_3 => HS1_DATA5) (_3 => HS1_DATA5 _4 => U2TXD _5 =>
_for_each_inner!((17, GPIO17(_3 => HS1_DATA5) (_3 => HS1_DATA5 _4 => U2TXD _5 => EMAC_CLK_180) ([Input] [Output])), (18, GPIO18(_1 => VSPICLK _3 => HS1_DATA7) (_1
EMAC_CLK_180) (Input Output))); _for_each_inner!((18, GPIO18(_1 => VSPICLK _3 => => VSPICLK _3 => HS1_DATA7) ([Input] [Output])), (19, GPIO19(_1 => VSPIQ _3 =>
HS1_DATA7) (_1 => VSPICLK _3 => HS1_DATA7) (Input Output))); U0CTS) (_1 => VSPIQ _5 => EMAC_TXD0) ([Input] [Output])), (20, GPIO20() ()
_for_each_inner!((19, GPIO19(_1 => VSPIQ _3 => U0CTS) (_1 => VSPIQ _5 => ([Input] [Output])), (21, GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 => EMAC_TX_EN)
EMAC_TXD0) (Input Output))); _for_each_inner!((20, GPIO20() () (Input Output))); ([Input] [Output])), (22, GPIO22(_1 => VSPIWP) (_1 => VSPIWP _3 => U0RTS _5 =>
_for_each_inner!((21, GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 => EMAC_TX_EN) (Input EMAC_TXD1) ([Input] [Output])), (23, GPIO23(_1 => VSPID) (_1 => VSPID _3 =>
Output))); _for_each_inner!((22, GPIO22(_1 => VSPIWP) (_1 => VSPIWP _3 => U0RTS HS1_STROBE) ([Input] [Output])), (25, GPIO25(_5 => EMAC_RXD0) () ([Input]
_5 => EMAC_TXD1) (Input Output))); _for_each_inner!((23, GPIO23(_1 => VSPID) (_1 [Output])), (26, GPIO26(_5 => EMAC_RXD1) () ([Input] [Output])), (27, GPIO27(_5
=> VSPID _3 => HS1_STROBE) (Input Output))); _for_each_inner!((25, GPIO25(_5 => => EMAC_RX_DV) () ([Input] [Output])), (32, GPIO32() () ([Input] [Output])), (33,
EMAC_RXD0) () (Input Output))); _for_each_inner!((26, GPIO26(_5 => EMAC_RXD1) () GPIO33() () ([Input] [Output])), (34, GPIO34() () ([Input] [])), (35, GPIO35() ()
(Input Output))); _for_each_inner!((27, GPIO27(_5 => EMAC_RX_DV) () (Input ([Input] [])), (36, GPIO36() () ([Input] [])), (37, GPIO37() () ([Input] [])),
Output))); _for_each_inner!((32, GPIO32() () (Input Output))); (38, GPIO38() () ([Input] [])), (39, GPIO39() () ([Input] []))));
_for_each_inner!((33, GPIO33() () (Input Output))); _for_each_inner!((34,
GPIO34() () (Input))); _for_each_inner!((35, GPIO35() () (Input)));
_for_each_inner!((36, GPIO36() () (Input))); _for_each_inner!((37, GPIO37() ()
(Input))); _for_each_inner!((38, GPIO38() () (Input))); _for_each_inner!((39,
GPIO39() () (Input))); _for_each_inner!((all(0, GPIO0(_5 => EMAC_TX_CLK) (_1 =>
CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output)), (1, GPIO1(_5 => EMAC_RXD2) (_0 =>
U0TXD _1 => CLK_OUT3) (Input Output)), (2, GPIO2(_1 => HSPIWP _3 => HS2_DATA0 _4
=> SD_DATA0) (_1 => HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) (Input Output)), (3,
GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) (Input Output)), (4, GPIO4(_1 => HSPIHD _3 =>
HS2_DATA1 _4 => SD_DATA1 _5 => EMAC_TX_ER) (_1 => HSPIHD _3 => HS2_DATA1 _4 =>
SD_DATA1 _5 => EMAC_TX_ER) (Input Output)), (5, GPIO5(_1 => VSPICS0 _3 =>
HS1_DATA6 _5 => EMAC_RX_CLK) (_1 => VSPICS0 _3 => HS1_DATA6) (Input Output)), (6,
GPIO6(_1 => SPICLK _4 => U1CTS) (_0 => SD_CLK _1 => SPICLK _3 => HS1_CLK) (Input
Output)), (7, GPIO7(_0 => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1
=> SPIQ _3 => HS1_DATA0 _4 => U2RTS) (Input Output)), (8, GPIO8(_0 => SD_DATA1 _1
=> SPID _3 => HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1)
(Input Output)), (9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2 _4 =>
U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2) (Input Output)), (10,
GPIO10(_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3) (_0 => SD_DATA3 _1 => SPIWP _3
=> HS1_DATA3 _4 => U1TXD) (Input Output)), (11, GPIO11(_0 => SD_CMD _1 => SPICS0)
(_0 => SD_CMD _1 => SPICS0 _3 => HS1_CMD _4 => U1RTS) (Input Output)), (12,
GPIO12(_0 => MTDI _1 => HSPIQ _3 => HS2_DATA2 _4 => SD_DATA2) (_1 => HSPIQ _3 =>
HS2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) (Input Output)), (13, GPIO13(_0 => MTCK
_1 => HSPID _3 => HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) (_1 => HSPID _3 =>
HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) (Input Output)), (14, GPIO14(_0 =>
MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => HS2_CLK _4 => SD_CLK _5 => EMAC_TXD2)
(Input Output)), (15, GPIO15(_1 => HSPICS0 _4 => SD_CMD _5 => EMAC_RXD3) (_0 =>
MTDO _1 => HSPICS0 _3 => HS2_CMD _4 => SD_CMD) (Input Output)), (16, GPIO16(_3 =>
HS1_DATA4 _4 => U2RXD) (_3 => HS1_DATA4 _5 => EMAC_CLK_OUT) (Input Output)), (17,
GPIO17(_3 => HS1_DATA5) (_3 => HS1_DATA5 _4 => U2TXD _5 => EMAC_CLK_180) (Input
Output)), (18, GPIO18(_1 => VSPICLK _3 => HS1_DATA7) (_1 => VSPICLK _3 =>
HS1_DATA7) (Input Output)), (19, GPIO19(_1 => VSPIQ _3 => U0CTS) (_1 => VSPIQ _5
=> EMAC_TXD0) (Input Output)), (20, GPIO20() () (Input Output)), (21, GPIO21(_1
=> VSPIHD) (_1 => VSPIHD _5 => EMAC_TX_EN) (Input Output)), (22, GPIO22(_1 =>
VSPIWP) (_1 => VSPIWP _3 => U0RTS _5 => EMAC_TXD1) (Input Output)), (23,
GPIO23(_1 => VSPID) (_1 => VSPID _3 => HS1_STROBE) (Input Output)), (25,
GPIO25(_5 => EMAC_RXD0) () (Input Output)), (26, GPIO26(_5 => EMAC_RXD1) ()
(Input Output)), (27, GPIO27(_5 => EMAC_RX_DV) () (Input Output)), (32, GPIO32()
() (Input Output)), (33, GPIO33() () (Input Output)), (34, GPIO34() () (Input)),
(35, GPIO35() () (Input)), (36, GPIO36() () (Input)), (37, GPIO37() () (Input)),
(38, GPIO38() () (Input)), (39, GPIO39() () (Input))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -696,423 +701,9 @@ macro_rules! for_each_lp_function {
RTC_GPIOn, 3), GPIO39))); RTC_GPIOn, 3), GPIO39)));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO15, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO16, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO17, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO18, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO19, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO20, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO21, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO22, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO22, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO22, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO23, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO23, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO23, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO25, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO25, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO25, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO26, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO27, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO32, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO32, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO32, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO33, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO33, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO33, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO34, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO34, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO35, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO35, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO36, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO36, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO37, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO37, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO38, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO38, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO39, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO39, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 15 =>
if_pin_is_type!(GPIO15, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO15::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 16 =>
if_pin_is_type!(GPIO16, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO16::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 17 =>
if_pin_is_type!(GPIO17, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO17::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 18 =>
if_pin_is_type!(GPIO18, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO18::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 19 =>
if_pin_is_type!(GPIO19, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO19::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 20 =>
if_pin_is_type!(GPIO20, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO20::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 21 =>
if_pin_is_type!(GPIO21, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO21::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 22 =>
if_pin_is_type!(GPIO22, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO22::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 23 =>
if_pin_is_type!(GPIO23, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO23::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 25 =>
if_pin_is_type!(GPIO25, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO25::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 26 =>
if_pin_is_type!(GPIO26, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO26::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 27 =>
if_pin_is_type!(GPIO27, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO27::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 32 =>
if_pin_is_type!(GPIO32, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO32::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 33 =>
if_pin_is_type!(GPIO33, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO33::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 34 =>
if_pin_is_type!(GPIO34, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO34::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 35 =>
if_pin_is_type!(GPIO35, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO35::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 36 =>
if_pin_is_type!(GPIO36, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO36::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 37 =>
if_pin_is_type!(GPIO37, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO37::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 38 =>
if_pin_is_type!(GPIO38, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO38::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 39 =>
if_pin_is_type!(GPIO39, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO39::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -1522,6 +1113,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -353,7 +353,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -366,45 +366,49 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() () _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
(Input Output))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
Output))); _for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input Output))); [Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
_for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input ([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
Output))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
(Input Output))); _for_each_inner!((7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
FSPID) (Input Output))); _for_each_inner!((8, GPIO8() () (Input Output))); FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
_for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((10, GPIO10() GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
() (Input Output))); _for_each_inner!((11, GPIO11(_0 => SPIHD) (_0 => SPIHD) [Output]))); _for_each_inner!((10, GPIO10() () ([Input] [Output])));
(Input Output))); _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) (Input _for_each_inner!((11, GPIO11(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
Output))); _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) (Input _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
Output))); _for_each_inner!((14, GPIO14() (_0 => SPICS0) (Input Output))); _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
_for_each_inner!((15, GPIO15() (_0 => SPICLK) (Input Output))); _for_each_inner!((14, GPIO14() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output))); _for_each_inner!((15, GPIO15() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) (Input Output))); _for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((18, GPIO18() () (Input Output))); _for_each_inner!((19, _for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
GPIO19(_0 => U0RXD) () (Input Output))); _for_each_inner!((20, GPIO20() (_0 => _for_each_inner!((18, GPIO18() () ([Input] [Output]))); _for_each_inner!((19,
U0TXD) (Input Output))); _for_each_inner!((all(0, GPIO0() () (Input Output)), (1, GPIO19(_0 => U0RXD) () ([Input] [Output]))); _for_each_inner!((20, GPIO20() (_0
GPIO1() () (Input Output)), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input Output)), => U0TXD) ([Input] [Output]))); _for_each_inner!((all(0, GPIO0() () ([Input]
(3, GPIO3() () (Input Output)), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) [Output])), (1, GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 =>
(Input Output)), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input FSPIQ) ([Input] [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 =>
Output)), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) (Input Output)), MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 =>
(7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) (Input Output)), (8, GPIO8() () FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK)
(Input Output)), (9, GPIO9() () (Input Output)), (10, GPIO10() () (Input (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
Output)), (11, GPIO11(_0 => SPIHD) (_0 => SPIHD) (Input Output)), (12, GPIO12(_0 FSPID) ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() ()
=> SPIHD) (_0 => SPIHD) (Input Output)), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11(_0 =>
(Input Output)), (14, GPIO14() (_0 => SPICS0) (Input Output)), (15, GPIO15() (_0 SPIHD) (_0 => SPIHD) ([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD)
=> SPICLK) (Input Output)), (16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output)), ([Input] [Output])), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])),
(17, GPIO17(_0 => SPIQ) (_0 => SPIQ) (Input Output)), (18, GPIO18() () (Input (14, GPIO14() (_0 => SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK)
Output)), (19, GPIO19(_0 => U0RXD) () (Input Output)), (20, GPIO20() (_0 => ([Input] [Output])), (16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])),
U0TXD) (Input Output)))); (17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (18, GPIO18() ()
([Input] [Output])), (19, GPIO19(_0 => U0RXD) () ([Input] [Output])), (20,
GPIO20() (_0 => U0TXD) ([Input] [Output]))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -500,273 +504,9 @@ macro_rules! for_each_lp_function {
RTC_GPIOn, 5), GPIO5))); RTC_GPIOn, 5), GPIO5)));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO15, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO16, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO17, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO18, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO19, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO20, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 15 =>
if_pin_is_type!(GPIO15, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO15::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 16 =>
if_pin_is_type!(GPIO16, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO16::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 17 =>
if_pin_is_type!(GPIO17, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO17::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 18 =>
if_pin_is_type!(GPIO18, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO18::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 19 =>
if_pin_is_type!(GPIO19, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO19::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 20 =>
if_pin_is_type!(GPIO20, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO20::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -884,6 +624,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -378,7 +378,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -391,46 +391,50 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() () _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
(Input Output))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
Output))); _for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input Output))); [Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
_for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input ([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
Output))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
(Input Output))); _for_each_inner!((7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
FSPID) (Input Output))); _for_each_inner!((8, GPIO8() () (Input Output))); FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
_for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((10, GPIO10(_2 GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
=> FSPICS0) (_2 => FSPICS0) (Input Output))); _for_each_inner!((11, GPIO11() () [Output]))); _for_each_inner!((10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
(Input Output))); _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) (Input [Output]))); _for_each_inner!((11, GPIO11() () ([Input] [Output])));
Output))); _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) (Input _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
Output))); _for_each_inner!((14, GPIO14() (_0 => SPICS0) (Input Output))); _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
_for_each_inner!((15, GPIO15() (_0 => SPICLK) (Input Output))); _for_each_inner!((14, GPIO14() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output))); _for_each_inner!((15, GPIO15() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) (Input Output))); _for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((18, GPIO18() () (Input Output))); _for_each_inner!((19, _for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
GPIO19() () (Input Output))); _for_each_inner!((20, GPIO20(_0 => U0RXD) () (Input _for_each_inner!((18, GPIO18() () ([Input] [Output]))); _for_each_inner!((19,
Output))); _for_each_inner!((21, GPIO21() (_0 => U0TXD) (Input Output))); GPIO19() () ([Input] [Output]))); _for_each_inner!((20, GPIO20(_0 => U0RXD) ()
_for_each_inner!((all(0, GPIO0() () (Input Output)), (1, GPIO1() () (Input ([Input] [Output]))); _for_each_inner!((21, GPIO21() (_0 => U0TXD) ([Input]
Output)), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input Output)), (3, GPIO3() () [Output]))); _for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1()
(Input Output)), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
Output)), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input Output)), (6, (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 =>
GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) (Input Output)), (7, GPIO7(_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP)
FSPID) (_0 => MTDO _2 => FSPID) (Input Output)), (8, GPIO8() () (Input Output)), ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
(9, GPIO9() () (Input Output)), (10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) (Input [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
Output)), (11, GPIO11() () (Input Output)), (12, GPIO12(_0 => SPIHD) (_0 => (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10,
SPIHD) (Input Output)), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) (Input Output)), GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (11, GPIO11() ()
(14, GPIO14() (_0 => SPICS0) (Input Output)), (15, GPIO15() (_0 => SPICLK) (Input ([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
Output)), (16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output)), (17, GPIO17(_0 => (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (14, GPIO14() (_0 =>
SPIQ) (_0 => SPIQ) (Input Output)), (18, GPIO18() () (Input Output)), (19, SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK) ([Input] [Output])),
GPIO19() () (Input Output)), (20, GPIO20(_0 => U0RXD) () (Input Output)), (21, (16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])), (17, GPIO17(_0 => SPIQ)
GPIO21() (_0 => U0TXD) (Input Output)))); (_0 => SPIQ) ([Input] [Output])), (18, GPIO18() () ([Input] [Output])), (19,
GPIO19() () ([Input] [Output])), (20, GPIO20(_0 => U0RXD) () ([Input] [Output])),
(21, GPIO21() (_0 => U0TXD) ([Input] [Output]))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -530,285 +534,9 @@ macro_rules! for_each_lp_function {
RTC_GPIOn, 5), GPIO5))); RTC_GPIOn, 5), GPIO5)));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO15, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO16, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO17, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO18, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO19, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO20, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO21, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 15 =>
if_pin_is_type!(GPIO15, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO15::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 16 =>
if_pin_is_type!(GPIO16, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO16::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 17 =>
if_pin_is_type!(GPIO17, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO17::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 18 =>
if_pin_is_type!(GPIO18, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO18::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 19 =>
if_pin_is_type!(GPIO19, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO19::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 20 =>
if_pin_is_type!(GPIO20, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO20::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 21 =>
if_pin_is_type!(GPIO21, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO21::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -952,6 +680,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -433,7 +433,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -446,63 +446,68 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() () _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
(Input Output))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
Output))); _for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input Output))); [Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
_for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input ([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
Output))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
(Input Output))); _for_each_inner!((7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
FSPID) (Input Output))); _for_each_inner!((8, GPIO8() () (Input Output))); FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
_for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((10, GPIO10() GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
() (Input Output))); _for_each_inner!((11, GPIO11() () (Input Output))); [Output]))); _for_each_inner!((10, GPIO10() () ([Input] [Output])));
_for_each_inner!((12, GPIO12() () (Input Output))); _for_each_inner!((13, _for_each_inner!((11, GPIO11() () ([Input] [Output]))); _for_each_inner!((12,
GPIO13() () (Input Output))); _for_each_inner!((14, GPIO14() () (Input Output))); GPIO12() () ([Input] [Output]))); _for_each_inner!((13, GPIO13() () ([Input]
_for_each_inner!((15, GPIO15() () (Input Output))); _for_each_inner!((16, [Output]))); _for_each_inner!((14, GPIO14() () ([Input] [Output])));
GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) (Input Output))); _for_each_inner!((15, GPIO15() () ([Input] [Output]))); _for_each_inner!((16,
_for_each_inner!((17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) (Input Output))); GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) ([Input] [Output])));
_for_each_inner!((17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])));
_for_each_inner!((18, GPIO18(_0 => SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) _for_each_inner!((18, GPIO18(_0 => SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2)
(Input Output))); _for_each_inner!((19, GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) ([Input] [Output]))); _for_each_inner!((19, GPIO19() (_0 => SDIO_CLK _2 =>
(Input Output))); _for_each_inner!((20, GPIO20(_0 => SDIO_DATA0) (_0 => FSPICS3) ([Input] [Output]))); _for_each_inner!((20, GPIO20(_0 => SDIO_DATA0) (_0
SDIO_DATA0 _2 => FSPICS4) (Input Output))); _for_each_inner!((21, GPIO21(_0 => => SDIO_DATA0 _2 => FSPICS4) ([Input] [Output]))); _for_each_inner!((21,
SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) (Input Output))); GPIO21(_0 => SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])));
_for_each_inner!((22, GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) (Input _for_each_inner!((22, GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) ([Input]
Output))); _for_each_inner!((23, GPIO23(_0 => SDIO_DATA3) (_0 => SDIO_DATA3) [Output]))); _for_each_inner!((23, GPIO23(_0 => SDIO_DATA3) (_0 => SDIO_DATA3)
(Input Output))); _for_each_inner!((24, GPIO24() (_0 => SPICS0) (Input Output))); ([Input] [Output]))); _for_each_inner!((24, GPIO24() (_0 => SPICS0) ([Input]
_for_each_inner!((25, GPIO25(_0 => SPIQ) (_0 => SPIQ) (Input Output))); [Output]))); _for_each_inner!((25, GPIO25(_0 => SPIQ) (_0 => SPIQ) ([Input]
_for_each_inner!((26, GPIO26(_0 => SPIWP) (_0 => SPIWP) (Input Output))); [Output]))); _for_each_inner!((26, GPIO26(_0 => SPIWP) (_0 => SPIWP) ([Input]
_for_each_inner!((27, GPIO27() () (Input Output))); _for_each_inner!((28, [Output]))); _for_each_inner!((27, GPIO27() () ([Input] [Output])));
GPIO28(_0 => SPIHD) (_0 => SPIHD) (Input Output))); _for_each_inner!((29, _for_each_inner!((28, GPIO28(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
GPIO29() (_0 => SPICLK) (Input Output))); _for_each_inner!((30, GPIO30(_0 => _for_each_inner!((29, GPIO29() (_0 => SPICLK) ([Input] [Output])));
SPID) (_0 => SPID) (Input Output))); _for_each_inner!((all(0, GPIO0() () (Input _for_each_inner!((30, GPIO30(_0 => SPID) (_0 => SPID) ([Input] [Output])));
Output)), (1, GPIO1() () (Input Output)), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) _for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() () ([Input]
(Input Output)), (3, GPIO3() () (Input Output)), (4, GPIO4(_0 => MTMS _2 => [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])), (3, GPIO3()
FSPIHD) (_2 => FSPIHD) (Input Output)), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
FSPIWP) (Input Output)), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) ([Input]
(Input Output)), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) (Input Output)), [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
(8, GPIO8() () (Input Output)), (9, GPIO9() () (Input Output)), (10, GPIO10() () [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
(Input Output)), (11, GPIO11() () (Input Output)), (12, GPIO12() () (Input (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10,
Output)), (13, GPIO13() () (Input Output)), (14, GPIO14() () (Input Output)), GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input] [Output])), (12,
(15, GPIO15() () (Input Output)), (16, GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14,
FSPICS0) (Input Output)), (17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) (Input GPIO14() () ([Input] [Output])), (15, GPIO15() () ([Input] [Output])), (16,
Output)), (18, GPIO18(_0 => SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) (Input GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) ([Input] [Output])), (17,
Output)), (19, GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) (Input Output)), (20, GPIO17(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (18, GPIO18(_0 =>
GPIO20(_0 => SDIO_DATA0) (_0 => SDIO_DATA0 _2 => FSPICS4) (Input Output)), (21, SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) ([Input] [Output])), (19, GPIO19() (_0
GPIO21(_0 => SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) (Input Output)), (22, => SDIO_CLK _2 => FSPICS3) ([Input] [Output])), (20, GPIO20(_0 => SDIO_DATA0) (_0
GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) (Input Output)), (23, GPIO23(_0 => => SDIO_DATA0 _2 => FSPICS4) ([Input] [Output])), (21, GPIO21(_0 => SDIO_DATA1)
SDIO_DATA3) (_0 => SDIO_DATA3) (Input Output)), (24, GPIO24() (_0 => SPICS0) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])), (22, GPIO22(_0 =>
(Input Output)), (25, GPIO25(_0 => SPIQ) (_0 => SPIQ) (Input Output)), (26, SDIO_DATA2) (_0 => SDIO_DATA2) ([Input] [Output])), (23, GPIO23(_0 => SDIO_DATA3)
GPIO26(_0 => SPIWP) (_0 => SPIWP) (Input Output)), (27, GPIO27() () (Input (_0 => SDIO_DATA3) ([Input] [Output])), (24, GPIO24() (_0 => SPICS0) ([Input]
Output)), (28, GPIO28(_0 => SPIHD) (_0 => SPIHD) (Input Output)), (29, GPIO29() [Output])), (25, GPIO25(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (26,
(_0 => SPICLK) (Input Output)), (30, GPIO30(_0 => SPID) (_0 => SPID) (Input GPIO26(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (27, GPIO27() () ([Input]
Output)))); [Output])), (28, GPIO28(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])), (29,
GPIO29() (_0 => SPICLK) ([Input] [Output])), (30, GPIO30(_0 => SPID) (_0 => SPID)
([Input] [Output]))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -612,393 +617,9 @@ macro_rules! for_each_lp_function {
((LP_GPIO6, LP_GPIOn, 6), GPIO6), ((LP_GPIO7, LP_GPIOn, 7), GPIO7))); ((LP_GPIO6, LP_GPIOn, 6), GPIO6), ((LP_GPIO7, LP_GPIOn, 7), GPIO7)));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO15, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO16, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO17, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO18, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO19, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO20, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO21, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO22, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO22, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO22, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO23, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO23, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO23, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO24, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO24, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO24, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO25, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO25, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO25, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO26, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO27, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO28, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO28, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO28, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO29, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO29, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO29, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO30, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO30, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO30, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 15 =>
if_pin_is_type!(GPIO15, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO15::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 16 =>
if_pin_is_type!(GPIO16, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO16::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 17 =>
if_pin_is_type!(GPIO17, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO17::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 18 =>
if_pin_is_type!(GPIO18, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO18::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 19 =>
if_pin_is_type!(GPIO19, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO19::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 20 =>
if_pin_is_type!(GPIO20, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO20::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 21 =>
if_pin_is_type!(GPIO21, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO21::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 22 =>
if_pin_is_type!(GPIO22, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO22::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 23 =>
if_pin_is_type!(GPIO23, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO23::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 24 =>
if_pin_is_type!(GPIO24, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO24::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 25 =>
if_pin_is_type!(GPIO25, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO25::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 26 =>
if_pin_is_type!(GPIO26, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO26::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 27 =>
if_pin_is_type!(GPIO27, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO27::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 28 =>
if_pin_is_type!(GPIO28, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO28::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 29 =>
if_pin_is_type!(GPIO29, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO29::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 30 =>
if_pin_is_type!(GPIO30, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO30::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -1239,6 +860,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -414,7 +414,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -427,44 +427,48 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) (Input Output))); _for_each_inner!((0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
_for_each_inner!((1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) (Input Output))); _for_each_inner!((1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])));
_for_each_inner!((2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) (Input _for_each_inner!((2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input]
Output))); _for_each_inner!((3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD) [Output]))); _for_each_inner!((3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD)
(Input Output))); _for_each_inner!((4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => ([Input] [Output]))); _for_each_inner!((4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 =>
FSPICLK) (Input Output))); _for_each_inner!((5, GPIO5(_2 => FSPID) (_0 => MTDO _2 FSPICLK) ([Input] [Output]))); _for_each_inner!((5, GPIO5(_2 => FSPID) (_0 =>
=> FSPID) (Input Output))); _for_each_inner!((6, GPIO6() () (Input Output))); MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
_for_each_inner!((7, GPIO7() () (Input Output))); _for_each_inner!((8, GPIO8() () [Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
(Input Output))); _for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((8, GPIO8() () ([Input] [Output]))); _for_each_inner!((9,
_for_each_inner!((10, GPIO10() () (Input Output))); _for_each_inner!((11, GPIO9() () ([Input] [Output]))); _for_each_inner!((10, GPIO10() () ([Input]
GPIO11() () (Input Output))); _for_each_inner!((12, GPIO12() () (Input Output))); [Output]))); _for_each_inner!((11, GPIO11() () ([Input] [Output])));
_for_each_inner!((13, GPIO13() () (Input Output))); _for_each_inner!((14, _for_each_inner!((12, GPIO12() () ([Input] [Output]))); _for_each_inner!((13,
GPIO14() () (Input Output))); _for_each_inner!((22, GPIO22() () (Input Output))); GPIO13() () ([Input] [Output]))); _for_each_inner!((14, GPIO14() () ([Input]
_for_each_inner!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) (Input Output))); [Output]))); _for_each_inner!((22, GPIO22() () ([Input] [Output])));
_for_each_inner!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2) (Input Output))); _for_each_inner!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])));
_for_each_inner!((25, GPIO25() (_2 => FSPICS3) (Input Output))); _for_each_inner!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2) ([Input] [Output])));
_for_each_inner!((26, GPIO26() (_2 => FSPICS4) (Input Output))); _for_each_inner!((25, GPIO25() (_2 => FSPICS3) ([Input] [Output])));
_for_each_inner!((27, GPIO27() (_2 => FSPICS5) (Input Output))); _for_each_inner!((26, GPIO26() (_2 => FSPICS4) ([Input] [Output])));
_for_each_inner!((all(0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) (Input Output)), (1, _for_each_inner!((27, GPIO27() (_2 => FSPICS5) ([Input] [Output])));
GPIO1(_2 => FSPICS0) (_2 => FSPICS0) (Input Output)), (2, GPIO2(_0 => MTMS _2 => _for_each_inner!((all(0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
FSPIWP) (_2 => FSPIWP) (Input Output)), (3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => (1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (2, GPIO2(_0 =>
FSPIHD) (Input Output)), (4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (3, GPIO3(_0 => MTDI _2 =>
(Input Output)), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) (Input Output)), FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (4, GPIO4(_0 => MTCK _2 => FSPICLK)
(6, GPIO6() () (Input Output)), (7, GPIO7() () (Input Output)), (8, GPIO8() () (_2 => FSPICLK) ([Input] [Output])), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 =>
(Input Output)), (9, GPIO9() () (Input Output)), (10, GPIO10() () (Input FSPID) ([Input] [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() ()
Output)), (11, GPIO11() () (Input Output)), (12, GPIO12() () (Input Output)), ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input]
(13, GPIO13() () (Input Output)), (14, GPIO14() () (Input Output)), (22, GPIO22() [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input]
() (Input Output)), (23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) (Input Output)), [Output])), (12, GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input]
(24, GPIO24() (_0 => U0TXD _2 => FSPICS2) (Input Output)), (25, GPIO25() (_2 => [Output])), (14, GPIO14() () ([Input] [Output])), (22, GPIO22() () ([Input]
FSPICS3) (Input Output)), (26, GPIO26() (_2 => FSPICS4) (Input Output)), (27, [Output])), (23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (24,
GPIO27() (_2 => FSPICS5) (Input Output)))); GPIO24() (_0 => U0TXD _2 => FSPICS2) ([Input] [Output])), (25, GPIO25() (_2 =>
FSPICS3) ([Input] [Output])), (26, GPIO26() (_2 => FSPICS4) ([Input] [Output])),
(27, GPIO27() (_2 => FSPICS5) ([Input] [Output]))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -552,273 +556,9 @@ macro_rules! for_each_lp_function {
_for_each_inner!((all)); _for_each_inner!((all_expanded)); _for_each_inner!((all)); _for_each_inner!((all_expanded));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO22, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO22, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO22, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO23, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO23, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO23, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO24, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO24, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO24, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO25, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO25, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO25, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO26, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO27, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 22 =>
if_pin_is_type!(GPIO22, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO22::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 23 =>
if_pin_is_type!(GPIO23, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO23::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 24 =>
if_pin_is_type!(GPIO24, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO24::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 25 =>
if_pin_is_type!(GPIO25, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO25::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 26 =>
if_pin_is_type!(GPIO26, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO26::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 27 =>
if_pin_is_type!(GPIO27, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO27::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -1012,6 +752,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -416,7 +416,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -429,90 +429,97 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() () _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
(Input Output))); _for_each_inner!((2, GPIO2() () (Input Output))); GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2() () ([Input]
_for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, GPIO4() () [Output]))); _for_each_inner!((3, GPIO3() () ([Input] [Output])));
(Input Output))); _for_each_inner!((5, GPIO5() () (Input Output))); _for_each_inner!((4, GPIO4() () ([Input] [Output]))); _for_each_inner!((5,
_for_each_inner!((6, GPIO6() () (Input Output))); _for_each_inner!((7, GPIO7() () GPIO5() () ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
(Input Output))); _for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) (Input [Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
Output))); _for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => _for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])));
SUBSPIHD _4 => FSPIHD) (Input Output))); _for_each_inner!((10, GPIO10(_2 => _for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input FSPIHD) ([Input] [Output]))); _for_each_inner!((10, GPIO10(_2 => FSPIIO4 _4 =>
Output))); _for_each_inner!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) ([Input] [Output])));
(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (Input Output))); _for_each_inner!((12, _for_each_inner!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output]))); _for_each_inner!((12,
GPIO12(_2 => FSPIIO6 _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) GPIO12(_2 => FSPIIO6 _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK)
(Input Output))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => ([Input] [Output]))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4
FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (Input Output))); => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) ([Input] [Output])));
_for_each_inner!((14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 => _for_each_inner!((14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 =>
SUBSPIWP _4 => FSPIWP) (Input Output))); _for_each_inner!((15, GPIO15() (_2 => SUBSPIWP _4 => FSPIWP) ([Input] [Output]))); _for_each_inner!((15, GPIO15() (_2
U0RTS) (Input Output))); _for_each_inner!((16, GPIO16(_2 => U0CTS) () (Input => U0RTS) ([Input] [Output]))); _for_each_inner!((16, GPIO16(_2 => U0CTS) ()
Output))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) (Input Output))); ([Input] [Output]))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) ([Input]
_for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input Output))); [Output]))); _for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) ([Input]
_for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output))); [Output]))); _for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) ([Input]
_for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output))); [Output]))); _for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
_for_each_inner!((21, GPIO21() () (Input Output))); _for_each_inner!((26, [Output]))); _for_each_inner!((21, GPIO21() () ([Input] [Output])));
GPIO26() (_0 => SPICS1) (Input Output))); _for_each_inner!((27, GPIO27(_0 => _for_each_inner!((26, GPIO26() (_0 => SPICS1) ([Input] [Output])));
SPIHD) (_0 => SPIHD) (Input Output))); _for_each_inner!((28, GPIO28(_0 => SPIWP) _for_each_inner!((27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
(_0 => SPIWP) (Input Output))); _for_each_inner!((29, GPIO29() (_0 => SPICS0) _for_each_inner!((28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
(Input Output))); _for_each_inner!((30, GPIO30() (_0 => SPICLK) (Input Output))); _for_each_inner!((29, GPIO29() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output))); _for_each_inner!((30, GPIO30() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output))); _for_each_inner!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
_for_each_inner!((32, GPIO32(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2 => FSPIHD _3 => _for_each_inner!((33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2 => FSPIHD _3 =>
SUBSPIHD) (Input Output))); _for_each_inner!((34, GPIO34(_2 => FSPICS0) (_2 => SUBSPIHD) ([Input] [Output]))); _for_each_inner!((34, GPIO34(_2 => FSPICS0) (_2
FSPICS0 _3 => SUBSPICS0) (Input Output))); _for_each_inner!((35, GPIO35(_2 => => FSPICS0 _3 => SUBSPICS0) ([Input] [Output]))); _for_each_inner!((35, GPIO35(_2
FSPID _3 => SUBSPID) (_2 => FSPID _3 => SUBSPID) (Input Output))); => FSPID _3 => SUBSPID) (_2 => FSPID _3 => SUBSPID) ([Input] [Output])));
_for_each_inner!((36, GPIO36(_2 => FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) _for_each_inner!((36, GPIO36(_2 => FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK)
(Input Output))); _for_each_inner!((37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => ([Input] [Output]))); _for_each_inner!((37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4
SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (Input Output))); => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) ([Input] [Output])));
_for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 => _for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 =>
SUBSPIWP) (Input Output))); _for_each_inner!((39, GPIO39(_0 => MTCK) (_2 => SUBSPIWP) ([Input] [Output]))); _for_each_inner!((39, GPIO39(_0 => MTCK) (_2 =>
CLK_OUT3 _3 => SUBSPICS1) (Input Output))); _for_each_inner!((40, GPIO40() (_0 => CLK_OUT3 _3 => SUBSPICS1) ([Input] [Output]))); _for_each_inner!((40, GPIO40()
MTDO _2 => CLK_OUT2) (Input Output))); _for_each_inner!((41, GPIO41(_0 => MTDI) (_0 => MTDO _2 => CLK_OUT2) ([Input] [Output]))); _for_each_inner!((41, GPIO41(_0
(_2 => CLK_OUT1) (Input Output))); _for_each_inner!((42, GPIO42(_0 => MTMS) () => MTDI) (_2 => CLK_OUT1) ([Input] [Output]))); _for_each_inner!((42, GPIO42(_0
(Input Output))); _for_each_inner!((43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1) => MTMS) () ([Input] [Output]))); _for_each_inner!((43, GPIO43() (_0 => U0TXD _2
(Input Output))); _for_each_inner!((44, GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) => CLK_OUT1) ([Input] [Output]))); _for_each_inner!((44, GPIO44(_0 => U0RXD) (_2
(Input Output))); _for_each_inner!((45, GPIO45() () (Input Output))); => CLK_OUT2) ([Input] [Output]))); _for_each_inner!((45, GPIO45() () ([Input]
_for_each_inner!((46, GPIO46() () (Input Output))); _for_each_inner!((all(0, [Output]))); _for_each_inner!((46, GPIO46() () ([Input] [Output])));
GPIO0() () (Input Output)), (1, GPIO1() () (Input Output)), (2, GPIO2() () (Input _for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() () ([Input]
Output)), (3, GPIO3() () (Input Output)), (4, GPIO4() () (Input Output)), (5, [Output])), (2, GPIO2() () ([Input] [Output])), (3, GPIO3() () ([Input]
GPIO5() () (Input Output)), (6, GPIO6() () (Input Output)), (7, GPIO7() () (Input [Output])), (4, GPIO4() () ([Input] [Output])), (5, GPIO5() () ([Input]
Output)), (8, GPIO8() (_3 => SUBSPICS1) (Input Output)), (9, GPIO9(_3 => SUBSPIHD [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input]
_4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) (Input Output)), (10, GPIO10(_2 => [Output])), (8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])), (9, GPIO9(_3 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) ([Input] [Output])), (10,
Output)), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 => FSPIIO5 _3 GPIO10(_2 => FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0)
=> SUBSPID _4 => FSPID) (Input Output)), (12, GPIO12(_2 => FSPIIO6 _4 => FSPICLK) ([Input] [Output])), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
(_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) (Input Output)), (13, GPIO13(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])), (12, GPIO12(_2 => FSPIIO6
FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) ([Input] [Output])),
(Input Output)), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 => (13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ
SUBSPIWP _4 => FSPIWP) (Input Output)), (15, GPIO15() (_2 => U0RTS) (Input _4 => FSPIQ) ([Input] [Output])), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 =>
Output)), (16, GPIO16(_2 => U0CTS) () (Input Output)), (17, GPIO17() (_2 => FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])), (15, GPIO15() (_2 =>
U1TXD) (Input Output)), (18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input U0RTS) ([Input] [Output])), (16, GPIO16(_2 => U0CTS) () ([Input] [Output])), (17,
Output)), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output)), (20, GPIO17() (_2 => U1TXD) ([Input] [Output])), (18, GPIO18(_2 => U1RXD) (_3 =>
GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output)), (21, GPIO21() () (Input CLK_OUT3) ([Input] [Output])), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
Output)), (26, GPIO26() (_0 => SPICS1) (Input Output)), (27, GPIO27(_0 => SPIHD) ([Input] [Output])), (20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
(_0 => SPIHD) (Input Output)), (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) (Input [Output])), (21, GPIO21() () ([Input] [Output])), (26, GPIO26() (_0 => SPICS1)
Output)), (29, GPIO29() (_0 => SPICS0) (Input Output)), (30, GPIO30() (_0 => ([Input] [Output])), (27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
SPICLK) (Input Output)), (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output)), (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (29, GPIO29() (_0 =>
(32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output)), (33, GPIO33(_2 => FSPIHD _3 SPICS0) ([Input] [Output])), (30, GPIO30() (_0 => SPICLK) ([Input] [Output])),
=> SUBSPIHD) (_2 => FSPIHD _3 => SUBSPIHD) (Input Output)), (34, GPIO34(_2 => (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (32, GPIO32(_0 => SPID)
FSPICS0) (_2 => FSPICS0 _3 => SUBSPICS0) (Input Output)), (35, GPIO35(_2 => FSPID (_0 => SPID) ([Input] [Output])), (33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2 =>
_3 => SUBSPID) (_2 => FSPID _3 => SUBSPID) (Input Output)), (36, GPIO36(_2 => FSPIHD _3 => SUBSPIHD) ([Input] [Output])), (34, GPIO34(_2 => FSPICS0) (_2 =>
FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) (Input Output)), (37, GPIO37(_2 => FSPIQ FSPICS0 _3 => SUBSPICS0) ([Input] [Output])), (35, GPIO35(_2 => FSPID _3 =>
_3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (Input SUBSPID) (_2 => FSPID _3 => SUBSPID) ([Input] [Output])), (36, GPIO36(_2 =>
Output)), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 => SUBSPIWP) FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) ([Input] [Output])), (37, GPIO37(_2 =>
(Input Output)), (39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 => SUBSPICS1) (Input FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS)
Output)), (40, GPIO40() (_0 => MTDO _2 => CLK_OUT2) (Input Output)), (41, ([Input] [Output])), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 =>
GPIO41(_0 => MTDI) (_2 => CLK_OUT1) (Input Output)), (42, GPIO42(_0 => MTMS) () SUBSPIWP) ([Input] [Output])), (39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 =>
(Input Output)), (43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1) (Input Output)), (44, SUBSPICS1) ([Input] [Output])), (40, GPIO40() (_0 => MTDO _2 => CLK_OUT2)
GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) (Input Output)), (45, GPIO45() () (Input ([Input] [Output])), (41, GPIO41(_0 => MTDI) (_2 => CLK_OUT1) ([Input]
Output)), (46, GPIO46() () (Input Output)))); [Output])), (42, GPIO42(_0 => MTMS) () ([Input] [Output])), (43, GPIO43() (_0 =>
U0TXD _2 => CLK_OUT1) ([Input] [Output])), (44, GPIO44(_0 => U0RXD) (_2 =>
CLK_OUT2) ([Input] [Output])), (45, GPIO45() () ([Input] [Output])), (46,
GPIO46() () ([Input] [Output]))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -705,537 +712,9 @@ macro_rules! for_each_lp_function {
((RTC_GPIO21, RTC_GPIOn, 21), GPIO21))); ((RTC_GPIO21, RTC_GPIOn, 21), GPIO21)));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO15, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO16, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO17, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO18, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO19, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO20, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO21, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO26, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO27, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO28, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO28, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO28, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO29, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO29, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO29, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO30, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO30, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO30, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO31, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO31, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO31, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO32, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO32, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO32, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO33, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO33, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO33, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO34, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO34, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO34, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO35, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO35, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO35, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO36, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO36, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO36, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO37, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO37, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO37, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO38, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO38, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO38, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO39, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO39, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO39, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO40, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO40, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO40, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO41, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO41, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO41, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO42, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO42, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO42, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO43, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO43, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO43, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO44, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO44, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO44, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO45, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO45, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO45, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO46, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO46, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO46, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 15 =>
if_pin_is_type!(GPIO15, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO15::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 16 =>
if_pin_is_type!(GPIO16, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO16::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 17 =>
if_pin_is_type!(GPIO17, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO17::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 18 =>
if_pin_is_type!(GPIO18, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO18::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 19 =>
if_pin_is_type!(GPIO19, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO19::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 20 =>
if_pin_is_type!(GPIO20, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO20::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 21 =>
if_pin_is_type!(GPIO21, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO21::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 26 =>
if_pin_is_type!(GPIO26, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO26::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 27 =>
if_pin_is_type!(GPIO27, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO27::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 28 =>
if_pin_is_type!(GPIO28, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO28::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 29 =>
if_pin_is_type!(GPIO29, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO29::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 30 =>
if_pin_is_type!(GPIO30, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO30::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 31 =>
if_pin_is_type!(GPIO31, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO31::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 32 =>
if_pin_is_type!(GPIO32, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO32::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 33 =>
if_pin_is_type!(GPIO33, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO33::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 34 =>
if_pin_is_type!(GPIO34, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO34::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 35 =>
if_pin_is_type!(GPIO35, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO35::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 36 =>
if_pin_is_type!(GPIO36, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO36::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 37 =>
if_pin_is_type!(GPIO37, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO37::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 38 =>
if_pin_is_type!(GPIO38, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO38::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 39 =>
if_pin_is_type!(GPIO39, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO39::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 40 =>
if_pin_is_type!(GPIO40, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO40::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 41 =>
if_pin_is_type!(GPIO41, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO41::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 42 =>
if_pin_is_type!(GPIO42, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO42::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 43 =>
if_pin_is_type!(GPIO43, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO43::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 44 =>
if_pin_is_type!(GPIO44, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO44::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 45 =>
if_pin_is_type!(GPIO45, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO45::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 46 =>
if_pin_is_type!(GPIO46, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO46::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -1453,6 +932,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -434,7 +434,7 @@ macro_rules! for_each_peripheral {
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident => /// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -447,96 +447,103 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`). /// function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
/// Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
/// [Output]))`
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio { macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => { ($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} } macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() () _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
(Input Output))); _for_each_inner!((2, GPIO2() () (Input Output))); GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2() () ([Input]
_for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, GPIO4() () [Output]))); _for_each_inner!((3, GPIO3() () ([Input] [Output])));
(Input Output))); _for_each_inner!((5, GPIO5() () (Input Output))); _for_each_inner!((4, GPIO4() () ([Input] [Output]))); _for_each_inner!((5,
_for_each_inner!((6, GPIO6() () (Input Output))); _for_each_inner!((7, GPIO7() () GPIO5() () ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
(Input Output))); _for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) (Input [Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
Output))); _for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => _for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])));
SUBSPIHD _4 => FSPIHD) (Input Output))); _for_each_inner!((10, GPIO10(_2 => _for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input FSPIHD) ([Input] [Output]))); _for_each_inner!((10, GPIO10(_2 => FSPIIO4 _4 =>
Output))); _for_each_inner!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) ([Input] [Output])));
(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (Input Output))); _for_each_inner!((12, _for_each_inner!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output]))); _for_each_inner!((12,
GPIO12(_2 => FSPIIO6 _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) GPIO12(_2 => FSPIIO6 _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK)
(Input Output))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => ([Input] [Output]))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4
FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (Input Output))); => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) ([Input] [Output])));
_for_each_inner!((14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 => _for_each_inner!((14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 =>
SUBSPIWP _4 => FSPIWP) (Input Output))); _for_each_inner!((15, GPIO15() (_2 => SUBSPIWP _4 => FSPIWP) ([Input] [Output]))); _for_each_inner!((15, GPIO15() (_2
U0RTS) (Input Output))); _for_each_inner!((16, GPIO16(_2 => U0CTS) () (Input => U0RTS) ([Input] [Output]))); _for_each_inner!((16, GPIO16(_2 => U0CTS) ()
Output))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) (Input Output))); ([Input] [Output]))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) ([Input]
_for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input Output))); [Output]))); _for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) ([Input]
_for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output))); [Output]))); _for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) ([Input]
_for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output))); [Output]))); _for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
_for_each_inner!((21, GPIO21() () (Input Output))); _for_each_inner!((26, [Output]))); _for_each_inner!((21, GPIO21() () ([Input] [Output])));
GPIO26() (_0 => SPICS1) (Input Output))); _for_each_inner!((27, GPIO27(_0 => _for_each_inner!((26, GPIO26() (_0 => SPICS1) ([Input] [Output])));
SPIHD) (_0 => SPIHD) (Input Output))); _for_each_inner!((28, GPIO28(_0 => SPIWP) _for_each_inner!((27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
(_0 => SPIWP) (Input Output))); _for_each_inner!((29, GPIO29() (_0 => SPICS0) _for_each_inner!((28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
(Input Output))); _for_each_inner!((30, GPIO30() (_0 => SPICLK) (Input Output))); _for_each_inner!((29, GPIO29() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output))); _for_each_inner!((30, GPIO30() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output))); _for_each_inner!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
_for_each_inner!((32, GPIO32(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD _4 => SPIIO4) (_2 => _for_each_inner!((33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD _4 => SPIIO4) (_2 =>
FSPIHD _3 => SUBSPIHD _4 => SPIIO4) (Input Output))); _for_each_inner!((34, FSPIHD _3 => SUBSPIHD _4 => SPIIO4) ([Input] [Output]))); _for_each_inner!((34,
GPIO34(_2 => FSPICS0 _4 => SPIIO5) (_2 => FSPICS0 _3 => SUBSPICS0 _4 => SPIIO5) GPIO34(_2 => FSPICS0 _4 => SPIIO5) (_2 => FSPICS0 _3 => SUBSPICS0 _4 => SPIIO5)
(Input Output))); _for_each_inner!((35, GPIO35(_2 => FSPID _3 => SUBSPID _4 => ([Input] [Output]))); _for_each_inner!((35, GPIO35(_2 => FSPID _3 => SUBSPID _4
SPIIO6) (_2 => FSPID _3 => SUBSPID _4 => SPIIO6) (Input Output))); => SPIIO6) (_2 => FSPID _3 => SUBSPID _4 => SPIIO6) ([Input] [Output])));
_for_each_inner!((36, GPIO36(_2 => FSPICLK _4 => SPIIO7) (_2 => FSPICLK _3 => _for_each_inner!((36, GPIO36(_2 => FSPICLK _4 => SPIIO7) (_2 => FSPICLK _3 =>
SUBSPICLK _4 => SPIIO7) (Input Output))); _for_each_inner!((37, GPIO37(_2 => SUBSPICLK _4 => SPIIO7) ([Input] [Output]))); _for_each_inner!((37, GPIO37(_2 =>
FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (Input FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS)
Output))); _for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => ([Input] [Output]))); _for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP)
FSPIWP _3 => SUBSPIWP) (Input Output))); _for_each_inner!((39, GPIO39() (_2 => (_2 => FSPIWP _3 => SUBSPIWP) ([Input] [Output]))); _for_each_inner!((39,
CLK_OUT3 _3 => SUBSPICS1) (Input Output))); _for_each_inner!((40, GPIO40() (_2 => GPIO39() (_2 => CLK_OUT3 _3 => SUBSPICS1) ([Input] [Output])));
CLK_OUT2) (Input Output))); _for_each_inner!((41, GPIO41() (_2 => CLK_OUT1) _for_each_inner!((40, GPIO40() (_2 => CLK_OUT2) ([Input] [Output])));
(Input Output))); _for_each_inner!((42, GPIO42() () (Input Output))); _for_each_inner!((41, GPIO41() (_2 => CLK_OUT1) ([Input] [Output])));
_for_each_inner!((43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1) (Input Output))); _for_each_inner!((42, GPIO42() () ([Input] [Output]))); _for_each_inner!((43,
_for_each_inner!((44, GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) (Input Output))); GPIO43() (_0 => U0TXD _2 => CLK_OUT1) ([Input] [Output]))); _for_each_inner!((44,
_for_each_inner!((45, GPIO45() () (Input Output))); _for_each_inner!((46, GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) ([Input] [Output]))); _for_each_inner!((45,
GPIO46() () (Input Output))); _for_each_inner!((47, GPIO47() (_0 => SPICLK_P_DIFF GPIO45() () ([Input] [Output]))); _for_each_inner!((46, GPIO46() () ([Input]
_2 => SUBSPICLK_P_DIFF) (Input Output))); _for_each_inner!((48, GPIO48() (_0 => [Output]))); _for_each_inner!((47, GPIO47() (_0 => SPICLK_P_DIFF _2 =>
SPICLK_N_DIFF _2 => SUBSPICLK_N_DIFF) (Input Output))); _for_each_inner!((all(0, SUBSPICLK_P_DIFF) ([Input] [Output]))); _for_each_inner!((48, GPIO48() (_0 =>
GPIO0() () (Input Output)), (1, GPIO1() () (Input Output)), (2, GPIO2() () (Input SPICLK_N_DIFF _2 => SUBSPICLK_N_DIFF) ([Input] [Output])));
Output)), (3, GPIO3() () (Input Output)), (4, GPIO4() () (Input Output)), (5, _for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() () ([Input]
GPIO5() () (Input Output)), (6, GPIO6() () (Input Output)), (7, GPIO7() () (Input [Output])), (2, GPIO2() () ([Input] [Output])), (3, GPIO3() () ([Input]
Output)), (8, GPIO8() (_3 => SUBSPICS1) (Input Output)), (9, GPIO9(_3 => SUBSPIHD [Output])), (4, GPIO4() () ([Input] [Output])), (5, GPIO5() () ([Input]
_4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) (Input Output)), (10, GPIO10(_2 => [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input]
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input [Output])), (8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])), (9, GPIO9(_3 =>
Output)), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 => FSPIIO5 _3 SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) ([Input] [Output])), (10,
=> SUBSPID _4 => FSPID) (Input Output)), (12, GPIO12(_2 => FSPIIO6 _4 => FSPICLK) GPIO10(_2 => FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0)
(_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) (Input Output)), (13, GPIO13(_2 => ([Input] [Output])), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])), (12, GPIO12(_2 => FSPIIO6
(Input Output)), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 => _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) ([Input] [Output])),
SUBSPIWP _4 => FSPIWP) (Input Output)), (15, GPIO15() (_2 => U0RTS) (Input (13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ
Output)), (16, GPIO16(_2 => U0CTS) () (Input Output)), (17, GPIO17() (_2 => _4 => FSPIQ) ([Input] [Output])), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 =>
U1TXD) (Input Output)), (18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])), (15, GPIO15() (_2 =>
Output)), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output)), (20, U0RTS) ([Input] [Output])), (16, GPIO16(_2 => U0CTS) () ([Input] [Output])), (17,
GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output)), (21, GPIO21() () (Input GPIO17() (_2 => U1TXD) ([Input] [Output])), (18, GPIO18(_2 => U1RXD) (_3 =>
Output)), (26, GPIO26() (_0 => SPICS1) (Input Output)), (27, GPIO27(_0 => SPIHD) CLK_OUT3) ([Input] [Output])), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
(_0 => SPIHD) (Input Output)), (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) (Input ([Input] [Output])), (20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
Output)), (29, GPIO29() (_0 => SPICS0) (Input Output)), (30, GPIO30() (_0 => [Output])), (21, GPIO21() () ([Input] [Output])), (26, GPIO26() (_0 => SPICS1)
SPICLK) (Input Output)), (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output)), ([Input] [Output])), (27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
(32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output)), (33, GPIO33(_2 => FSPIHD _3 (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (29, GPIO29() (_0 =>
=> SUBSPIHD _4 => SPIIO4) (_2 => FSPIHD _3 => SUBSPIHD _4 => SPIIO4) (Input SPICS0) ([Input] [Output])), (30, GPIO30() (_0 => SPICLK) ([Input] [Output])),
Output)), (34, GPIO34(_2 => FSPICS0 _4 => SPIIO5) (_2 => FSPICS0 _3 => SUBSPICS0 (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (32, GPIO32(_0 => SPID)
_4 => SPIIO5) (Input Output)), (35, GPIO35(_2 => FSPID _3 => SUBSPID _4 => (_0 => SPID) ([Input] [Output])), (33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD _4 =>
SPIIO6) (_2 => FSPID _3 => SUBSPID _4 => SPIIO6) (Input Output)), (36, GPIO36(_2 SPIIO4) (_2 => FSPIHD _3 => SUBSPIHD _4 => SPIIO4) ([Input] [Output])), (34,
=> FSPICLK _4 => SPIIO7) (_2 => FSPICLK _3 => SUBSPICLK _4 => SPIIO7) (Input GPIO34(_2 => FSPICS0 _4 => SPIIO5) (_2 => FSPICS0 _3 => SUBSPICS0 _4 => SPIIO5)
Output)), (37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => ([Input] [Output])), (35, GPIO35(_2 => FSPID _3 => SUBSPID _4 => SPIIO6) (_2 =>
SUBSPIQ _4 => SPIDQS) (Input Output)), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) FSPID _3 => SUBSPID _4 => SPIIO6) ([Input] [Output])), (36, GPIO36(_2 => FSPICLK
(_2 => FSPIWP _3 => SUBSPIWP) (Input Output)), (39, GPIO39() (_2 => CLK_OUT3 _3 _4 => SPIIO7) (_2 => FSPICLK _3 => SUBSPICLK _4 => SPIIO7) ([Input] [Output])),
=> SUBSPICS1) (Input Output)), (40, GPIO40() (_2 => CLK_OUT2) (Input Output)), (37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4
(41, GPIO41() (_2 => CLK_OUT1) (Input Output)), (42, GPIO42() () (Input Output)), => SPIDQS) ([Input] [Output])), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 =>
(43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1) (Input Output)), (44, GPIO44(_0 => FSPIWP _3 => SUBSPIWP) ([Input] [Output])), (39, GPIO39() (_2 => CLK_OUT3 _3 =>
U0RXD) (_2 => CLK_OUT2) (Input Output)), (45, GPIO45() () (Input Output)), (46, SUBSPICS1) ([Input] [Output])), (40, GPIO40() (_2 => CLK_OUT2) ([Input]
GPIO46() () (Input Output)), (47, GPIO47() (_0 => SPICLK_P_DIFF _2 => [Output])), (41, GPIO41() (_2 => CLK_OUT1) ([Input] [Output])), (42, GPIO42() ()
SUBSPICLK_P_DIFF) (Input Output)), (48, GPIO48() (_0 => SPICLK_N_DIFF _2 => ([Input] [Output])), (43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1) ([Input]
SUBSPICLK_N_DIFF) (Input Output)))); [Output])), (44, GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) ([Input] [Output])), (45,
GPIO45() () ([Input] [Output])), (46, GPIO46() () ([Input] [Output])), (47,
GPIO47() (_0 => SPICLK_P_DIFF _2 => SUBSPICLK_P_DIFF) ([Input] [Output])), (48,
GPIO48() (_0 => SPICLK_N_DIFF _2 => SUBSPICLK_N_DIFF) ([Input] [Output]))));
}; };
} }
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -736,561 +743,9 @@ macro_rules! for_each_lp_function {
((RTC_GPIO21, RTC_GPIOn, 21), GPIO21))); ((RTC_GPIO21, RTC_GPIOn, 21), GPIO21)));
}; };
} }
#[macro_export] /// Defines the `InputSignal` and `OutputSignal` enums.
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] ///
macro_rules! if_pin_is_type { /// This macro is intended to be called in esp-hal only.
(GPIO0, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO0, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO1, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO1, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO2, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO2, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO3, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO3, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO4, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO4, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO5, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO5, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO6, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO6, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO7, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO7, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO8, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO8, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO9, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO9, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO10, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO10, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO11, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO11, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO12, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO12, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO13, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO13, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO14, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO14, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO15, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO15, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO16, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO16, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO17, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO17, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO18, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO18, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO19, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO19, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO20, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO20, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO21, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO21, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO26, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO26, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO27, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO27, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO28, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO28, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO28, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO29, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO29, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO29, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO30, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO30, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO30, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO31, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO31, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO31, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO32, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO32, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO32, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO33, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO33, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO33, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO34, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO34, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO34, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO35, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO35, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO35, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO36, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO36, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO36, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO37, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO37, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO37, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO38, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO38, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO38, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO39, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO39, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO39, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO40, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO40, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO40, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO41, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO41, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO41, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO42, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO42, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO42, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO43, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO43, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO43, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO44, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO44, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO44, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO45, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO45, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO45, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO46, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO46, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO46, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO47, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO47, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO47, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
(GPIO48, Input, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO48, Output, $then_tt:tt else $else_tt:tt) => {
$then_tt
};
(GPIO48, $t:tt, $then_tt:tt else $else_tt:tt) => {
$else_tt
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin .number() { 0 => if_pin_is_type!(GPIO0, $on_type, { {
#[allow(unused_unsafe, unused_mut)] let mut $inner_ident = unsafe { crate
::peripherals::GPIO0::steal() }; #[allow(unused_braces)] $code } } else {
$otherwise }), 1 => if_pin_is_type!(GPIO1, $on_type, { { #[allow(unused_unsafe,
unused_mut)] let mut $inner_ident = unsafe { crate ::peripherals::GPIO1::steal()
}; #[allow(unused_braces)] $code } } else { $otherwise }), 2 =>
if_pin_is_type!(GPIO2, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO2::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 3 =>
if_pin_is_type!(GPIO3, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO3::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 4 =>
if_pin_is_type!(GPIO4, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO4::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 5 =>
if_pin_is_type!(GPIO5, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO5::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 6 =>
if_pin_is_type!(GPIO6, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO6::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 7 =>
if_pin_is_type!(GPIO7, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO7::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 8 =>
if_pin_is_type!(GPIO8, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO8::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 9 =>
if_pin_is_type!(GPIO9, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO9::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 10 =>
if_pin_is_type!(GPIO10, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO10::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 11 =>
if_pin_is_type!(GPIO11, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO11::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 12 =>
if_pin_is_type!(GPIO12, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO12::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 13 =>
if_pin_is_type!(GPIO13, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO13::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 14 =>
if_pin_is_type!(GPIO14, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO14::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 15 =>
if_pin_is_type!(GPIO15, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO15::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 16 =>
if_pin_is_type!(GPIO16, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO16::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 17 =>
if_pin_is_type!(GPIO17, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO17::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 18 =>
if_pin_is_type!(GPIO18, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO18::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 19 =>
if_pin_is_type!(GPIO19, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO19::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 20 =>
if_pin_is_type!(GPIO20, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO20::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 21 =>
if_pin_is_type!(GPIO21, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO21::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 26 =>
if_pin_is_type!(GPIO26, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO26::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 27 =>
if_pin_is_type!(GPIO27, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO27::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 28 =>
if_pin_is_type!(GPIO28, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO28::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 29 =>
if_pin_is_type!(GPIO29, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO29::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 30 =>
if_pin_is_type!(GPIO30, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO30::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 31 =>
if_pin_is_type!(GPIO31, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO31::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 32 =>
if_pin_is_type!(GPIO32, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO32::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 33 =>
if_pin_is_type!(GPIO33, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO33::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 34 =>
if_pin_is_type!(GPIO34, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO34::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 35 =>
if_pin_is_type!(GPIO35, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO35::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 36 =>
if_pin_is_type!(GPIO36, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO36::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 37 =>
if_pin_is_type!(GPIO37, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO37::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 38 =>
if_pin_is_type!(GPIO38, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO38::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 39 =>
if_pin_is_type!(GPIO39, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO39::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 40 =>
if_pin_is_type!(GPIO40, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO40::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 41 =>
if_pin_is_type!(GPIO41, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO41::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 42 =>
if_pin_is_type!(GPIO42, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO42::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 43 =>
if_pin_is_type!(GPIO43, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO43::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 44 =>
if_pin_is_type!(GPIO44, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO44::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 45 =>
if_pin_is_type!(GPIO45, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO45::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 46 =>
if_pin_is_type!(GPIO46, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO46::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 47 =>
if_pin_is_type!(GPIO47, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO47::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), 48 =>
if_pin_is_type!(GPIO48, $on_type, { { #[allow(unused_unsafe, unused_mut)] let mut
$inner_ident = unsafe { crate ::peripherals::GPIO48::steal() };
#[allow(unused_braces)] $code } } else { $otherwise }), _ => $otherwise, }
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else {
panic!("Unsupported") })
};
}
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -1667,6 +1122,18 @@ macro_rules! define_io_mux_signals {
} }
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -52,6 +52,9 @@
//! //!
//! You can specify any number of matchers in the same invocation. //! You can specify any number of matchers in the same invocation.
//! //!
//! > The way code is generated, you will need to use the full `return` syntax to return any
//! > values from code generated with these macros.
//!
//! ### Using the individual matcher //! ### Using the individual matcher
//! //!
//! In this use case, each item's data is individually passed through the macro. This can be used to //! In this use case, each item's data is individually passed through the macro. This can be used to
@ -59,7 +62,7 @@
//! //!
//! ```rust,no_run //! ```rust,no_run
//! for_each_gpio! { //! for_each_gpio! {
//! // Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` //! // Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output]))`
//! ($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($($pin_attribute:ident)*)) => { /* some code */ }; //! ($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($($pin_attribute:ident)*)) => { /* some code */ };
//! //!
//! // You can create matchers with data filled in. This example will specifically match GPIO2 //! // You can create matchers with data filled in. This example will specifically match GPIO2

View File

@ -224,8 +224,9 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
.pins .pins
.iter() .iter()
.map(|pin| { .map(|pin| {
// Input must come first
if pin.input_only { if pin.input_only {
vec![quote! { Input }] vec![quote! { Input }, quote! {}]
} else { } else {
vec![quote! { Input }, quote! { Output }] vec![quote! { Input }, quote! { Output }]
} }
@ -405,71 +406,6 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
} }
}; };
// Generates a macro that can select between a `then` and an `else` branch based
// on whether a pin implement a certain attribute.
//
// In essence this expands to (in case of pin = GPIO5, attr = Analog):
// `if typeof(GPIO5) == Analog { then_tokens } else { else_tokens }`
let if_pin_is_type = {
let mut branches = vec![];
for (pin, attr) in pin_peris.iter().zip(pin_attrs.iter()) {
branches.push(quote! {
#( (#pin, #attr, $then_tt:tt else $else_tt:tt ) => { $then_tt }; )*
});
branches.push(quote! {
(#pin, $t:tt, $then_tt:tt else $else_tt:tt ) => { $else_tt };
});
}
quote! {
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
#(#branches)*
}
}
};
// Delegates AnyPin functions to GPIOn functions when the pin implements a
// certain attribute.
//
// In essence this expands to (in case of attr = Analog):
// `if typeof(anypin's current value) == Analog { call $code } else { panic }`
let impl_for_pin_type = {
let mut impl_branches = vec![];
for (gpionum, peri) in pin_numbers.iter().zip(pin_peris.iter()) {
impl_branches.push(quote! {
#gpionum => if_pin_is_type!(#peri, $on_type, {{
#[allow(unused_unsafe, unused_mut)]
let mut $inner_ident = unsafe { crate::peripherals::#peri::steal() };
#[allow(unused_braces)]
$code
}} else {
$otherwise
}),
});
}
quote! {
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
#[expect(clippy::crate_in_macro_def)]
macro_rules! impl_for_pin_type {
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt else $otherwise:tt) => {
match $any_pin.number() {
#(#impl_branches)*
_ => $otherwise,
}
};
($any_pin:ident, $inner_ident:ident, $on_type:tt, $code:tt) => {
impl_for_pin_type!($any_pin, $inner_ident, $on_type, $code else { panic!("Unsupported") })
};
}
}
};
let mut branches = vec![]; let mut branches = vec![];
for (((n, p), af), attrs) in pin_numbers for (((n, p), af), attrs) in pin_numbers
.iter() .iter()
@ -478,7 +414,7 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
.zip(pin_attrs.iter()) .zip(pin_attrs.iter())
{ {
branches.push(quote! { branches.push(quote! {
#n, #p #af (#(#attrs)*) #n, #p #af (#([#attrs])*)
}) })
} }
@ -508,7 +444,7 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
/// ///
/// This macro has one option for its "Individual matcher" case: /// This macro has one option for its "Individual matcher" case:
/// ///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($($pin_attribute:ident)*))` /// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
/// ///
/// Macro fragments: /// Macro fragments:
/// ///
@ -518,9 +454,9 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
/// - `$digital_input_function`: the name of the digital function, as an identifier. /// - `$digital_input_function`: the name of the digital function, as an identifier.
/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for function 0 this is `_0`). /// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for function 0 this is `_0`).
/// - `$digital_output_function`: the name of the digital function, as an identifier. /// - `$digital_output_function`: the name of the digital function, as an identifier.
/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. /// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO. Bracketed so that they can also be matched as optional fragments. Order is always Input first.
/// ///
/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` /// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output]))`
#for_each_gpio #for_each_gpio
/// This macro can be used to generate code for each analog function of each GPIO. /// This macro can be used to generate code for each analog function of each GPIO.
@ -571,9 +507,9 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
/// The expanded syntax is only available when the signal has at least one numbered component. /// The expanded syntax is only available when the signal has at least one numbered component.
#for_each_lp #for_each_lp
#if_pin_is_type /// Defines the `InputSignal` and `OutputSignal` enums.
#impl_for_pin_type ///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals { macro_rules! define_io_mux_signals {
@ -583,6 +519,18 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
}; };
} }
/// Defines and implements the `io_mux_reg` function.
///
/// The generated function has the following signature:
///
/// ```rust,ignore
/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
/// // ...
/// # unimplemented!()
/// }
/// ```
///
/// This macro is intended to be called in esp-hal only.
#[macro_export] #[macro_export]
#[expect(clippy::crate_in_macro_def)] #[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))] #[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]

View File

@ -918,6 +918,9 @@ pub fn generate_lib_rs() -> TokenStream {
//! //!
//! You can specify any number of matchers in the same invocation. //! You can specify any number of matchers in the same invocation.
//! //!
//! > The way code is generated, you will need to use the full `return` syntax to return any
//! > values from code generated with these macros.
//!
//! ### Using the individual matcher //! ### Using the individual matcher
//! //!
//! In this use case, each item's data is individually passed through the macro. This can be used to //! In this use case, each item's data is individually passed through the macro. This can be used to
@ -925,7 +928,7 @@ pub fn generate_lib_rs() -> TokenStream {
//! //!
//! ```rust,no_run //! ```rust,no_run
//! for_each_gpio! { //! for_each_gpio! {
//! // Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) (Input Output))` //! // Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output]))`
//! ($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($($pin_attribute:ident)*)) => { /* some code */ }; //! ($n:literal, $gpio:ident ($($digital_input_function:ident => $digital_input_signal:ident)*) ($($digital_output_function:ident => $digital_output_signal:ident)*) ($($pin_attribute:ident)*)) => { /* some code */ };
//! //!
//! // You can create matchers with data filled in. This example will specifically match GPIO2 //! // You can create matchers with data filled in. This example will specifically match GPIO2