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::{
asynch::AtomicWaker,
interrupt::{InterruptHandler, Priority},
peripherals::{GPIO, IO_MUX, Interrupt, io_mux_reg},
peripherals::{GPIO, IO_MUX, Interrupt},
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.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
@ -2132,24 +1968,59 @@ impl Pin for AnyPin<'_> {
&self,
private: private::Internal,
) -> &'static [(AlternateFunction, OutputSignal)] {
impl_for_pin_type!(self, target, Output, {
Pin::output_signals(&target, private)
})
for_each_gpio! {
(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(
&self,
private: private::Internal,
) -> &'static [(AlternateFunction, InputSignal)] {
impl_for_pin_type!(self, target, Input, {
Pin::input_signals(&target, private)
})
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 Pin::input_signals(&inner, private);
}
)?)*
other => panic!("Pin {} is not an InputPin", other)
}
};
}
}
}
impl InputPin for AnyPin<'_> {
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<'_> {}
@ -2203,6 +2074,99 @@ impl AnyPin<'_> {
{
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]
@ -2238,13 +2202,18 @@ macro_rules! for_each_rtcio_pin {
macro_rules! for_each_rtcio_output_pin {
(@impl $ident:ident, $target:ident, $gpio:ident, $code:tt, $kind:literal) => {
if $ident.number() == $crate::peripherals::$gpio::NUMBER {
if_pin_is_type!($gpio, Output, {
for_each_gpio! {
// If the pin is an output pin, generate $code
($n:tt, $gpio $in_afs:tt $out_afs:tt ($input:tt [Output])) => {
#[allow(unused_mut)]
let mut $target = unsafe { $crate::peripherals::$gpio::steal() };
return $code;
} else {
};
// 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 {
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! {
// Define stable peripheral singletons
($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) {
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));
}
}

View File

@ -416,7 +416,7 @@ macro_rules! for_each_peripheral {
///
/// Syntax: `($n:literal, $gpio:ident ($($digital_input_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:
///
@ -429,95 +429,100 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code: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)
(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 =>
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!((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))); _for_each_inner!((5, GPIO5(_1 => VSPICS0 _3 => HS1_DATA6 _5 =>
EMAC_RX_CLK) (_1 => VSPICS0 _3 => HS1_DATA6) (Input Output)));
_for_each_inner!((6, GPIO6(_1 => SPICLK _4 => U1CTS) (_0 => SD_CLK _1 => SPICLK
_3 => HS1_CLK) (Input Output))); _for_each_inner!((7, GPIO7(_0 => SD_DATA0 _1 =>
SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0 _4 => U2RTS)
(Input Output))); _for_each_inner!((8, GPIO8(_0 => SD_DATA1 _1 => SPID _3 =>
HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1) (Input
Output))); _for_each_inner!((9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2
_4 => U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2) (Input Output)));
_for_each_inner!((10, GPIO10(_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3) (_0 =>
SD_DATA3 _1 => SPIWP _3 => HS1_DATA3 _4 => U1TXD) (Input Output)));
_for_each_inner!((11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 => SD_CMD _1 =>
SPICS0 _3 => HS1_CMD _4 => U1RTS) (Input Output))); _for_each_inner!((12,
([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 =>
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!((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]))); _for_each_inner!((5, GPIO5(_1 => VSPICS0 _3 =>
HS1_DATA6 _5 => EMAC_RX_CLK) (_1 => VSPICS0 _3 => HS1_DATA6) ([Input]
[Output]))); _for_each_inner!((6, GPIO6(_1 => SPICLK _4 => U1CTS) (_0 => SD_CLK
_1 => SPICLK _3 => HS1_CLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_0
=> SD_DATA0 _1 => SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 =>
HS1_DATA0 _4 => U2RTS) ([Input] [Output]))); _for_each_inner!((8, GPIO8(_0 =>
SD_DATA1 _1 => SPID _3 => HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 =>
HS1_DATA1) ([Input] [Output]))); _for_each_inner!((9, GPIO9(_0 => SD_DATA2 _1 =>
SPIHD _3 => HS1_DATA2 _4 => U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2)
([Input] [Output]))); _for_each_inner!((10, GPIO10(_0 => SD_DATA3 _1 => SPIWP _3
=> HS1_DATA3) (_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3 _4 => U1TXD) ([Input]
[Output]))); _for_each_inner!((11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 =>
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 =>
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 =>
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))));
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.
@ -696,423 +701,9 @@ macro_rules! for_each_lp_function {
RTC_GPIOn, 3), GPIO39)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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 =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))`
/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
///
/// Macro fragments:
///
@ -366,45 +366,49 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() ()
(Input Output))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input
Output))); _for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4,
GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input Output)));
_for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input
Output))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK)
(Input Output))); _for_each_inner!((7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
FSPID) (Input Output))); _for_each_inner!((8, GPIO8() () (Input Output)));
_for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((10, GPIO10()
() (Input Output))); _for_each_inner!((11, GPIO11(_0 => SPIHD) (_0 => SPIHD)
(Input Output))); _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) (Input
Output))); _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) (Input
Output))); _for_each_inner!((14, GPIO14() (_0 => SPICS0) (Input Output)));
_for_each_inner!((15, GPIO15() (_0 => SPICLK) (Input Output)));
_for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output)));
_for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) (Input Output)));
_for_each_inner!((18, GPIO18() () (Input Output))); _for_each_inner!((19,
GPIO19(_0 => U0RXD) () (Input Output))); _for_each_inner!((20, GPIO20() (_0 =>
U0TXD) (Input Output))); _for_each_inner!((all(0, GPIO0() () (Input Output)), (1,
GPIO1() () (Input Output)), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input Output)),
(3, GPIO3() () (Input Output)), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
(Input Output)), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input
Output)), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) (Input Output)),
(7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) (Input Output)), (8, GPIO8() ()
(Input Output)), (9, GPIO9() () (Input Output)), (10, GPIO10() () (Input
Output)), (11, GPIO11(_0 => SPIHD) (_0 => SPIHD) (Input Output)), (12, GPIO12(_0
=> SPIHD) (_0 => SPIHD) (Input Output)), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP)
(Input Output)), (14, GPIO14() (_0 => SPICS0) (Input Output)), (15, GPIO15() (_0
=> SPICLK) (Input Output)), (16, GPIO16(_0 => SPID) (_0 => SPID) (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))));
_for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
[Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
[Output]))); _for_each_inner!((10, GPIO10() () ([Input] [Output])));
_for_each_inner!((11, GPIO11(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
_for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
_for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
_for_each_inner!((14, GPIO14() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((15, GPIO15() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
_for_each_inner!((18, GPIO18() () ([Input] [Output]))); _for_each_inner!((19,
GPIO19(_0 => U0RXD) () ([Input] [Output]))); _for_each_inner!((20, GPIO20() (_0
=> U0TXD) ([Input] [Output]))); _for_each_inner!((all(0, GPIO0() () ([Input]
[Output])), (1, GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 =>
FSPIQ) ([Input] [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 =>
MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 =>
FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK)
(_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
FSPID) ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() ()
([Input] [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11(_0 =>
SPIHD) (_0 => SPIHD) ([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD)
([Input] [Output])), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])),
(14, GPIO14() (_0 => SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK)
([Input] [Output])), (16, GPIO16(_0 => SPID) (_0 => SPID) ([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.
@ -500,273 +504,9 @@ macro_rules! for_each_lp_function {
RTC_GPIOn, 5), GPIO5)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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 =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))`
/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
///
/// Macro fragments:
///
@ -391,46 +391,50 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() ()
(Input Output))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input
Output))); _for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4,
GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input Output)));
_for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input
Output))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK)
(Input Output))); _for_each_inner!((7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
FSPID) (Input Output))); _for_each_inner!((8, GPIO8() () (Input Output)));
_for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((10, GPIO10(_2
=> FSPICS0) (_2 => FSPICS0) (Input Output))); _for_each_inner!((11, GPIO11() ()
(Input Output))); _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) (Input
Output))); _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) (Input
Output))); _for_each_inner!((14, GPIO14() (_0 => SPICS0) (Input Output)));
_for_each_inner!((15, GPIO15() (_0 => SPICLK) (Input Output)));
_for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output)));
_for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) (Input Output)));
_for_each_inner!((18, GPIO18() () (Input Output))); _for_each_inner!((19,
GPIO19() () (Input Output))); _for_each_inner!((20, GPIO20(_0 => U0RXD) () (Input
Output))); _for_each_inner!((21, GPIO21() (_0 => U0TXD) (Input Output)));
_for_each_inner!((all(0, GPIO0() () (Input Output)), (1, GPIO1() () (Input
Output)), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input Output)), (3, GPIO3() ()
(Input Output)), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input
Output)), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input Output)), (6,
GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) (Input Output)), (7, GPIO7(_2 =>
FSPID) (_0 => MTDO _2 => FSPID) (Input Output)), (8, GPIO8() () (Input Output)),
(9, GPIO9() () (Input Output)), (10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) (Input
Output)), (11, GPIO11() () (Input Output)), (12, GPIO12(_0 => SPIHD) (_0 =>
SPIHD) (Input Output)), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) (Input Output)),
(14, GPIO14() (_0 => SPICS0) (Input Output)), (15, GPIO15() (_0 => SPICLK) (Input
Output)), (16, GPIO16(_0 => SPID) (_0 => SPID) (Input Output)), (17, GPIO17(_0 =>
SPIQ) (_0 => SPIQ) (Input Output)), (18, GPIO18() () (Input Output)), (19,
GPIO19() () (Input Output)), (20, GPIO20(_0 => U0RXD) () (Input Output)), (21,
GPIO21() (_0 => U0TXD) (Input Output))));
_for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
[Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
[Output]))); _for_each_inner!((10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
[Output]))); _for_each_inner!((11, GPIO11() () ([Input] [Output])));
_for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
_for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
_for_each_inner!((14, GPIO14() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((15, GPIO15() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
_for_each_inner!((18, GPIO18() () ([Input] [Output]))); _for_each_inner!((19,
GPIO19() () ([Input] [Output]))); _for_each_inner!((20, GPIO20(_0 => U0RXD) ()
([Input] [Output]))); _for_each_inner!((21, GPIO21() (_0 => U0TXD) ([Input]
[Output]))); _for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1()
() ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
(3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 =>
FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP)
([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
[Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
(8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10,
GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (11, GPIO11() ()
([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
(13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (14, GPIO14() (_0 =>
SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK) ([Input] [Output])),
(16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])), (17, GPIO17(_0 => SPIQ)
(_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.
@ -530,285 +534,9 @@ macro_rules! for_each_lp_function {
RTC_GPIOn, 5), GPIO5)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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 =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))`
/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
///
/// Macro fragments:
///
@ -446,63 +446,68 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() ()
(Input Output))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) (Input
Output))); _for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4,
GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) (Input Output)));
_for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) (Input
Output))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK)
(Input Output))); _for_each_inner!((7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
FSPID) (Input Output))); _for_each_inner!((8, GPIO8() () (Input Output)));
_for_each_inner!((9, GPIO9() () (Input Output))); _for_each_inner!((10, GPIO10()
() (Input Output))); _for_each_inner!((11, GPIO11() () (Input Output)));
_for_each_inner!((12, GPIO12() () (Input Output))); _for_each_inner!((13,
GPIO13() () (Input Output))); _for_each_inner!((14, GPIO14() () (Input Output)));
_for_each_inner!((15, GPIO15() () (Input Output))); _for_each_inner!((16,
GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) (Input Output)));
_for_each_inner!((17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) (Input Output)));
_for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
[Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
[Output]))); _for_each_inner!((10, GPIO10() () ([Input] [Output])));
_for_each_inner!((11, GPIO11() () ([Input] [Output]))); _for_each_inner!((12,
GPIO12() () ([Input] [Output]))); _for_each_inner!((13, GPIO13() () ([Input]
[Output]))); _for_each_inner!((14, GPIO14() () ([Input] [Output])));
_for_each_inner!((15, GPIO15() () ([Input] [Output]))); _for_each_inner!((16,
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)
(Input Output))); _for_each_inner!((19, GPIO19() (_0 => SDIO_CLK _2 => 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_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) (Input Output)));
_for_each_inner!((22, GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) (Input
Output))); _for_each_inner!((23, GPIO23(_0 => SDIO_DATA3) (_0 => SDIO_DATA3)
(Input Output))); _for_each_inner!((24, GPIO24() (_0 => SPICS0) (Input Output)));
_for_each_inner!((25, GPIO25(_0 => SPIQ) (_0 => SPIQ) (Input Output)));
_for_each_inner!((26, GPIO26(_0 => SPIWP) (_0 => SPIWP) (Input Output)));
_for_each_inner!((27, GPIO27() () (Input Output))); _for_each_inner!((28,
GPIO28(_0 => SPIHD) (_0 => SPIHD) (Input Output))); _for_each_inner!((29,
GPIO29() (_0 => SPICLK) (Input Output))); _for_each_inner!((30, GPIO30(_0 =>
SPID) (_0 => SPID) (Input Output))); _for_each_inner!((all(0, GPIO0() () (Input
Output)), (1, GPIO1() () (Input Output)), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ)
(Input Output)), (3, GPIO3() () (Input Output)), (4, GPIO4(_0 => MTMS _2 =>
FSPIHD) (_2 => FSPIHD) (Input Output)), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
FSPIWP) (Input Output)), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK)
(Input Output)), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) (Input Output)),
(8, GPIO8() () (Input Output)), (9, GPIO9() () (Input Output)), (10, GPIO10() ()
(Input Output)), (11, GPIO11() () (Input Output)), (12, GPIO12() () (Input
Output)), (13, GPIO13() () (Input Output)), (14, GPIO14() () (Input Output)),
(15, GPIO15() () (Input Output)), (16, GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 =>
FSPICS0) (Input Output)), (17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) (Input
Output)), (18, GPIO18(_0 => SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) (Input
Output)), (19, GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) (Input Output)), (20,
GPIO20(_0 => SDIO_DATA0) (_0 => SDIO_DATA0 _2 => FSPICS4) (Input Output)), (21,
GPIO21(_0 => SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) (Input Output)), (22,
GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) (Input Output)), (23, GPIO23(_0 =>
SDIO_DATA3) (_0 => SDIO_DATA3) (Input Output)), (24, GPIO24() (_0 => SPICS0)
(Input Output)), (25, GPIO25(_0 => SPIQ) (_0 => SPIQ) (Input Output)), (26,
GPIO26(_0 => SPIWP) (_0 => SPIWP) (Input Output)), (27, GPIO27() () (Input
Output)), (28, GPIO28(_0 => SPIHD) (_0 => SPIHD) (Input Output)), (29, GPIO29()
(_0 => SPICLK) (Input Output)), (30, GPIO30(_0 => SPID) (_0 => SPID) (Input
Output))));
([Input] [Output]))); _for_each_inner!((19, GPIO19() (_0 => SDIO_CLK _2 =>
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_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])));
_for_each_inner!((22, GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) ([Input]
[Output]))); _for_each_inner!((23, GPIO23(_0 => SDIO_DATA3) (_0 => SDIO_DATA3)
([Input] [Output]))); _for_each_inner!((24, GPIO24() (_0 => SPICS0) ([Input]
[Output]))); _for_each_inner!((25, GPIO25(_0 => SPIQ) (_0 => SPIQ) ([Input]
[Output]))); _for_each_inner!((26, GPIO26(_0 => SPIWP) (_0 => SPIWP) ([Input]
[Output]))); _for_each_inner!((27, GPIO27() () ([Input] [Output])));
_for_each_inner!((28, GPIO28(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
_for_each_inner!((29, GPIO29() (_0 => SPICLK) ([Input] [Output])));
_for_each_inner!((30, GPIO30(_0 => SPID) (_0 => SPID) ([Input] [Output])));
_for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() () ([Input]
[Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])), (3, GPIO3()
() ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) ([Input]
[Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
[Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
(8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10,
GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input] [Output])), (12,
GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14,
GPIO14() () ([Input] [Output])), (15, GPIO15() () ([Input] [Output])), (16,
GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) ([Input] [Output])), (17,
GPIO17(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (18, GPIO18(_0 =>
SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) ([Input] [Output])), (19, GPIO19() (_0
=> SDIO_CLK _2 => FSPICS3) ([Input] [Output])), (20, GPIO20(_0 => SDIO_DATA0) (_0
=> SDIO_DATA0 _2 => FSPICS4) ([Input] [Output])), (21, GPIO21(_0 => SDIO_DATA1)
(_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])), (22, GPIO22(_0 =>
SDIO_DATA2) (_0 => SDIO_DATA2) ([Input] [Output])), (23, GPIO23(_0 => SDIO_DATA3)
(_0 => SDIO_DATA3) ([Input] [Output])), (24, GPIO24() (_0 => SPICS0) ([Input]
[Output])), (25, GPIO25(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (26,
GPIO26(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (27, GPIO27() () ([Input]
[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.
@ -612,393 +617,9 @@ macro_rules! for_each_lp_function {
((LP_GPIO6, LP_GPIOn, 6), GPIO6), ((LP_GPIO7, LP_GPIOn, 7), GPIO7)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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 =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))`
/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
///
/// Macro fragments:
///
@ -427,44 +427,48 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_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!((2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) (Input
Output))); _for_each_inner!((3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD)
(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
=> FSPID) (Input Output))); _for_each_inner!((6, GPIO6() () (Input Output)));
_for_each_inner!((7, GPIO7() () (Input Output))); _for_each_inner!((8, GPIO8() ()
(Input Output))); _for_each_inner!((9, GPIO9() () (Input Output)));
_for_each_inner!((10, GPIO10() () (Input Output))); _for_each_inner!((11,
GPIO11() () (Input Output))); _for_each_inner!((12, GPIO12() () (Input Output)));
_for_each_inner!((13, GPIO13() () (Input Output))); _for_each_inner!((14,
GPIO14() () (Input Output))); _for_each_inner!((22, GPIO22() () (Input Output)));
_for_each_inner!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) (Input Output)));
_for_each_inner!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2) (Input Output)));
_for_each_inner!((25, GPIO25() (_2 => FSPICS3) (Input Output)));
_for_each_inner!((26, GPIO26() (_2 => FSPICS4) (Input Output)));
_for_each_inner!((27, GPIO27() (_2 => FSPICS5) (Input Output)));
_for_each_inner!((all(0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) (Input Output)), (1,
GPIO1(_2 => FSPICS0) (_2 => FSPICS0) (Input Output)), (2, GPIO2(_0 => MTMS _2 =>
FSPIWP) (_2 => FSPIWP) (Input Output)), (3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 =>
FSPIHD) (Input Output)), (4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK)
(Input Output)), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) (Input Output)),
(6, GPIO6() () (Input Output)), (7, GPIO7() () (Input Output)), (8, GPIO8() ()
(Input Output)), (9, GPIO9() () (Input Output)), (10, GPIO10() () (Input
Output)), (11, GPIO11() () (Input Output)), (12, GPIO12() () (Input Output)),
(13, GPIO13() () (Input Output)), (14, GPIO14() () (Input Output)), (22, GPIO22()
() (Input Output)), (23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) (Input Output)),
(24, 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))));
_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!((2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input]
[Output]))); _for_each_inner!((3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD)
([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 => FSPID) ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
[Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
_for_each_inner!((8, GPIO8() () ([Input] [Output]))); _for_each_inner!((9,
GPIO9() () ([Input] [Output]))); _for_each_inner!((10, GPIO10() () ([Input]
[Output]))); _for_each_inner!((11, GPIO11() () ([Input] [Output])));
_for_each_inner!((12, GPIO12() () ([Input] [Output]))); _for_each_inner!((13,
GPIO13() () ([Input] [Output]))); _for_each_inner!((14, GPIO14() () ([Input]
[Output]))); _for_each_inner!((22, GPIO22() () ([Input] [Output])));
_for_each_inner!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])));
_for_each_inner!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2) ([Input] [Output])));
_for_each_inner!((25, GPIO25() (_2 => FSPICS3) ([Input] [Output])));
_for_each_inner!((26, GPIO26() (_2 => FSPICS4) ([Input] [Output])));
_for_each_inner!((27, GPIO27() (_2 => FSPICS5) ([Input] [Output])));
_for_each_inner!((all(0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
(1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (2, GPIO2(_0 =>
MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (3, GPIO3(_0 => MTDI _2 =>
FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (4, GPIO4(_0 => MTCK _2 => FSPICLK)
(_2 => FSPICLK) ([Input] [Output])), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 =>
FSPID) ([Input] [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() ()
([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input]
[Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input]
[Output])), (12, GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input]
[Output])), (14, GPIO14() () ([Input] [Output])), (22, GPIO22() () ([Input]
[Output])), (23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (24,
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.
@ -552,273 +556,9 @@ macro_rules! for_each_lp_function {
_for_each_inner!((all)); _for_each_inner!((all_expanded));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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 =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))`
/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
///
/// Macro fragments:
///
@ -429,90 +429,97 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() ()
(Input Output))); _for_each_inner!((2, GPIO2() () (Input Output)));
_for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, GPIO4() ()
(Input Output))); _for_each_inner!((5, GPIO5() () (Input Output)));
_for_each_inner!((6, GPIO6() () (Input Output))); _for_each_inner!((7, GPIO7() ()
(Input Output))); _for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) (Input
Output))); _for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 =>
SUBSPIHD _4 => FSPIHD) (Input Output))); _for_each_inner!((10, GPIO10(_2 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input
Output))); _for_each_inner!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID)
(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (Input Output))); _for_each_inner!((12,
_for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2() () ([Input]
[Output]))); _for_each_inner!((3, GPIO3() () ([Input] [Output])));
_for_each_inner!((4, GPIO4() () ([Input] [Output]))); _for_each_inner!((5,
GPIO5() () ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
[Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
_for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])));
_for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 =>
FSPIHD) ([Input] [Output]))); _for_each_inner!((10, GPIO10(_2 => FSPIIO4 _4 =>
FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) ([Input] [Output])));
_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)
(Input Output))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 =>
FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (Input Output)));
([Input] [Output]))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4
=> FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) ([Input] [Output])));
_for_each_inner!((14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 =>
SUBSPIWP _4 => FSPIWP) (Input Output))); _for_each_inner!((15, GPIO15() (_2 =>
U0RTS) (Input Output))); _for_each_inner!((16, GPIO16(_2 => U0CTS) () (Input
Output))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) (Input Output)));
_for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input Output)));
_for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output)));
_for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output)));
_for_each_inner!((21, GPIO21() () (Input Output))); _for_each_inner!((26,
GPIO26() (_0 => SPICS1) (Input Output))); _for_each_inner!((27, GPIO27(_0 =>
SPIHD) (_0 => SPIHD) (Input Output))); _for_each_inner!((28, GPIO28(_0 => SPIWP)
(_0 => SPIWP) (Input Output))); _for_each_inner!((29, GPIO29() (_0 => SPICS0)
(Input Output))); _for_each_inner!((30, GPIO30() (_0 => SPICLK) (Input Output)));
_for_each_inner!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output)));
_for_each_inner!((32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output)));
SUBSPIWP _4 => FSPIWP) ([Input] [Output]))); _for_each_inner!((15, GPIO15() (_2
=> U0RTS) ([Input] [Output]))); _for_each_inner!((16, GPIO16(_2 => U0CTS) ()
([Input] [Output]))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) ([Input]
[Output]))); _for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) ([Input]
[Output]))); _for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) ([Input]
[Output]))); _for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
[Output]))); _for_each_inner!((21, GPIO21() () ([Input] [Output])));
_for_each_inner!((26, GPIO26() (_0 => SPICS1) ([Input] [Output])));
_for_each_inner!((27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
_for_each_inner!((28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
_for_each_inner!((29, GPIO29() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((30, GPIO30() (_0 => SPICLK) ([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 =>
SUBSPIHD) (Input Output))); _for_each_inner!((34, GPIO34(_2 => FSPICS0) (_2 =>
FSPICS0 _3 => SUBSPICS0) (Input Output))); _for_each_inner!((35, GPIO35(_2 =>
FSPID _3 => SUBSPID) (_2 => FSPID _3 => SUBSPID) (Input Output)));
SUBSPIHD) ([Input] [Output]))); _for_each_inner!((34, GPIO34(_2 => FSPICS0) (_2
=> FSPICS0 _3 => SUBSPICS0) ([Input] [Output]))); _for_each_inner!((35, GPIO35(_2
=> FSPID _3 => SUBSPID) (_2 => FSPID _3 => SUBSPID) ([Input] [Output])));
_for_each_inner!((36, GPIO36(_2 => FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK)
(Input Output))); _for_each_inner!((37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 =>
SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (Input Output)));
([Input] [Output]))); _for_each_inner!((37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4
=> SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) ([Input] [Output])));
_for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 =>
SUBSPIWP) (Input Output))); _for_each_inner!((39, GPIO39(_0 => MTCK) (_2 =>
CLK_OUT3 _3 => SUBSPICS1) (Input Output))); _for_each_inner!((40, GPIO40() (_0 =>
MTDO _2 => CLK_OUT2) (Input Output))); _for_each_inner!((41, GPIO41(_0 => MTDI)
(_2 => CLK_OUT1) (Input Output))); _for_each_inner!((42, GPIO42(_0 => MTMS) ()
(Input Output))); _for_each_inner!((43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1)
(Input Output))); _for_each_inner!((44, GPIO44(_0 => U0RXD) (_2 => CLK_OUT2)
(Input Output))); _for_each_inner!((45, GPIO45() () (Input Output)));
_for_each_inner!((46, GPIO46() () (Input Output))); _for_each_inner!((all(0,
GPIO0() () (Input Output)), (1, GPIO1() () (Input Output)), (2, GPIO2() () (Input
Output)), (3, GPIO3() () (Input Output)), (4, GPIO4() () (Input Output)), (5,
GPIO5() () (Input Output)), (6, GPIO6() () (Input Output)), (7, GPIO7() () (Input
Output)), (8, GPIO8() (_3 => SUBSPICS1) (Input Output)), (9, GPIO9(_3 => SUBSPIHD
_4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) (Input Output)), (10, GPIO10(_2 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input
Output)), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 => FSPIIO5 _3
=> SUBSPID _4 => FSPID) (Input Output)), (12, GPIO12(_2 => FSPIIO6 _4 => FSPICLK)
(_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) (Input Output)), (13, GPIO13(_2 =>
FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ)
(Input Output)), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 =>
SUBSPIWP _4 => FSPIWP) (Input Output)), (15, GPIO15() (_2 => U0RTS) (Input
Output)), (16, GPIO16(_2 => U0CTS) () (Input Output)), (17, GPIO17() (_2 =>
U1TXD) (Input Output)), (18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input
Output)), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output)), (20,
GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output)), (21, GPIO21() () (Input
Output)), (26, GPIO26() (_0 => SPICS1) (Input Output)), (27, GPIO27(_0 => SPIHD)
(_0 => SPIHD) (Input Output)), (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) (Input
Output)), (29, GPIO29() (_0 => SPICS0) (Input Output)), (30, GPIO30() (_0 =>
SPICLK) (Input Output)), (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output)),
(32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output)), (33, GPIO33(_2 => FSPIHD _3
=> SUBSPIHD) (_2 => FSPIHD _3 => SUBSPIHD) (Input Output)), (34, GPIO34(_2 =>
FSPICS0) (_2 => FSPICS0 _3 => SUBSPICS0) (Input Output)), (35, GPIO35(_2 => FSPID
_3 => SUBSPID) (_2 => FSPID _3 => SUBSPID) (Input Output)), (36, GPIO36(_2 =>
FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) (Input Output)), (37, GPIO37(_2 => FSPIQ
_3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (Input
Output)), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 => SUBSPIWP)
(Input Output)), (39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 => SUBSPICS1) (Input
Output)), (40, GPIO40() (_0 => MTDO _2 => CLK_OUT2) (Input Output)), (41,
GPIO41(_0 => MTDI) (_2 => CLK_OUT1) (Input 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))));
SUBSPIWP) ([Input] [Output]))); _for_each_inner!((39, GPIO39(_0 => MTCK) (_2 =>
CLK_OUT3 _3 => SUBSPICS1) ([Input] [Output]))); _for_each_inner!((40, GPIO40()
(_0 => MTDO _2 => CLK_OUT2) ([Input] [Output]))); _for_each_inner!((41, GPIO41(_0
=> MTDI) (_2 => CLK_OUT1) ([Input] [Output]))); _for_each_inner!((42, GPIO42(_0
=> MTMS) () ([Input] [Output]))); _for_each_inner!((43, GPIO43() (_0 => U0TXD _2
=> CLK_OUT1) ([Input] [Output]))); _for_each_inner!((44, GPIO44(_0 => U0RXD) (_2
=> CLK_OUT2) ([Input] [Output]))); _for_each_inner!((45, GPIO45() () ([Input]
[Output]))); _for_each_inner!((46, GPIO46() () ([Input] [Output])));
_for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() () ([Input]
[Output])), (2, GPIO2() () ([Input] [Output])), (3, GPIO3() () ([Input]
[Output])), (4, GPIO4() () ([Input] [Output])), (5, GPIO5() () ([Input]
[Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input]
[Output])), (8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])), (9, GPIO9(_3 =>
SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) ([Input] [Output])), (10,
GPIO10(_2 => FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0)
([Input] [Output])), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])), (12, GPIO12(_2 => FSPIIO6
_4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) ([Input] [Output])),
(13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ
_4 => FSPIQ) ([Input] [Output])), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 =>
FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])), (15, GPIO15() (_2 =>
U0RTS) ([Input] [Output])), (16, GPIO16(_2 => U0CTS) () ([Input] [Output])), (17,
GPIO17() (_2 => U1TXD) ([Input] [Output])), (18, GPIO18(_2 => U1RXD) (_3 =>
CLK_OUT3) ([Input] [Output])), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
([Input] [Output])), (20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
[Output])), (21, GPIO21() () ([Input] [Output])), (26, GPIO26() (_0 => SPICS1)
([Input] [Output])), (27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
(28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (29, GPIO29() (_0 =>
SPICS0) ([Input] [Output])), (30, GPIO30() (_0 => SPICLK) ([Input] [Output])),
(31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (32, GPIO32(_0 => SPID)
(_0 => SPID) ([Input] [Output])), (33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2 =>
FSPIHD _3 => SUBSPIHD) ([Input] [Output])), (34, GPIO34(_2 => FSPICS0) (_2 =>
FSPICS0 _3 => SUBSPICS0) ([Input] [Output])), (35, GPIO35(_2 => FSPID _3 =>
SUBSPID) (_2 => FSPID _3 => SUBSPID) ([Input] [Output])), (36, GPIO36(_2 =>
FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) ([Input] [Output])), (37, GPIO37(_2 =>
FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS)
([Input] [Output])), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 =>
SUBSPIWP) ([Input] [Output])), (39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 =>
SUBSPICS1) ([Input] [Output])), (40, GPIO40() (_0 => MTDO _2 => CLK_OUT2)
([Input] [Output])), (41, GPIO41(_0 => MTDI) (_2 => CLK_OUT1) ([Input]
[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.
@ -705,537 +712,9 @@ macro_rules! for_each_lp_function {
((RTC_GPIO21, RTC_GPIOn, 21), GPIO21)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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 =>
/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
/// $digital_output_signal:ident)*) ($($pin_attribute:ident)*))`
/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
///
/// Macro fragments:
///
@ -447,96 +447,103 @@ macro_rules! for_each_peripheral {
/// function 0 this is `_0`).
/// - `$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.
/// 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]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((0, GPIO0() () (Input Output))); _for_each_inner!((1, GPIO1() ()
(Input Output))); _for_each_inner!((2, GPIO2() () (Input Output)));
_for_each_inner!((3, GPIO3() () (Input Output))); _for_each_inner!((4, GPIO4() ()
(Input Output))); _for_each_inner!((5, GPIO5() () (Input Output)));
_for_each_inner!((6, GPIO6() () (Input Output))); _for_each_inner!((7, GPIO7() ()
(Input Output))); _for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) (Input
Output))); _for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 =>
SUBSPIHD _4 => FSPIHD) (Input Output))); _for_each_inner!((10, GPIO10(_2 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input
Output))); _for_each_inner!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID)
(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (Input Output))); _for_each_inner!((12,
_for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2() () ([Input]
[Output]))); _for_each_inner!((3, GPIO3() () ([Input] [Output])));
_for_each_inner!((4, GPIO4() () ([Input] [Output]))); _for_each_inner!((5,
GPIO5() () ([Input] [Output]))); _for_each_inner!((6, GPIO6() () ([Input]
[Output]))); _for_each_inner!((7, GPIO7() () ([Input] [Output])));
_for_each_inner!((8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])));
_for_each_inner!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 =>
FSPIHD) ([Input] [Output]))); _for_each_inner!((10, GPIO10(_2 => FSPIIO4 _4 =>
FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) ([Input] [Output])));
_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)
(Input Output))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 =>
FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (Input Output)));
([Input] [Output]))); _for_each_inner!((13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4
=> FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) ([Input] [Output])));
_for_each_inner!((14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 =>
SUBSPIWP _4 => FSPIWP) (Input Output))); _for_each_inner!((15, GPIO15() (_2 =>
U0RTS) (Input Output))); _for_each_inner!((16, GPIO16(_2 => U0CTS) () (Input
Output))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) (Input Output)));
_for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input Output)));
_for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output)));
_for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output)));
_for_each_inner!((21, GPIO21() () (Input Output))); _for_each_inner!((26,
GPIO26() (_0 => SPICS1) (Input Output))); _for_each_inner!((27, GPIO27(_0 =>
SPIHD) (_0 => SPIHD) (Input Output))); _for_each_inner!((28, GPIO28(_0 => SPIWP)
(_0 => SPIWP) (Input Output))); _for_each_inner!((29, GPIO29() (_0 => SPICS0)
(Input Output))); _for_each_inner!((30, GPIO30() (_0 => SPICLK) (Input Output)));
_for_each_inner!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output)));
_for_each_inner!((32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output)));
SUBSPIWP _4 => FSPIWP) ([Input] [Output]))); _for_each_inner!((15, GPIO15() (_2
=> U0RTS) ([Input] [Output]))); _for_each_inner!((16, GPIO16(_2 => U0CTS) ()
([Input] [Output]))); _for_each_inner!((17, GPIO17() (_2 => U1TXD) ([Input]
[Output]))); _for_each_inner!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) ([Input]
[Output]))); _for_each_inner!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) ([Input]
[Output]))); _for_each_inner!((20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
[Output]))); _for_each_inner!((21, GPIO21() () ([Input] [Output])));
_for_each_inner!((26, GPIO26() (_0 => SPICS1) ([Input] [Output])));
_for_each_inner!((27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
_for_each_inner!((28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
_for_each_inner!((29, GPIO29() (_0 => SPICS0) ([Input] [Output])));
_for_each_inner!((30, GPIO30() (_0 => SPICLK) ([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 =>
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)
(Input Output))); _for_each_inner!((35, GPIO35(_2 => FSPID _3 => SUBSPID _4 =>
SPIIO6) (_2 => FSPID _3 => SUBSPID _4 => SPIIO6) (Input Output)));
([Input] [Output]))); _for_each_inner!((35, GPIO35(_2 => FSPID _3 => SUBSPID _4
=> SPIIO6) (_2 => FSPID _3 => SUBSPID _4 => SPIIO6) ([Input] [Output])));
_for_each_inner!((36, GPIO36(_2 => FSPICLK _4 => SPIIO7) (_2 => FSPICLK _3 =>
SUBSPICLK _4 => SPIIO7) (Input Output))); _for_each_inner!((37, GPIO37(_2 =>
FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (Input
Output))); _for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 =>
FSPIWP _3 => SUBSPIWP) (Input Output))); _for_each_inner!((39, GPIO39() (_2 =>
CLK_OUT3 _3 => SUBSPICS1) (Input Output))); _for_each_inner!((40, GPIO40() (_2 =>
CLK_OUT2) (Input Output))); _for_each_inner!((41, GPIO41() (_2 => CLK_OUT1)
(Input Output))); _for_each_inner!((42, GPIO42() () (Input Output)));
_for_each_inner!((43, GPIO43() (_0 => U0TXD _2 => CLK_OUT1) (Input Output)));
_for_each_inner!((44, GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) (Input Output)));
_for_each_inner!((45, GPIO45() () (Input Output))); _for_each_inner!((46,
GPIO46() () (Input Output))); _for_each_inner!((47, GPIO47() (_0 => SPICLK_P_DIFF
_2 => SUBSPICLK_P_DIFF) (Input Output))); _for_each_inner!((48, GPIO48() (_0 =>
SPICLK_N_DIFF _2 => SUBSPICLK_N_DIFF) (Input Output))); _for_each_inner!((all(0,
GPIO0() () (Input Output)), (1, GPIO1() () (Input Output)), (2, GPIO2() () (Input
Output)), (3, GPIO3() () (Input Output)), (4, GPIO4() () (Input Output)), (5,
GPIO5() () (Input Output)), (6, GPIO6() () (Input Output)), (7, GPIO7() () (Input
Output)), (8, GPIO8() (_3 => SUBSPICS1) (Input Output)), (9, GPIO9(_3 => SUBSPIHD
_4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) (Input Output)), (10, GPIO10(_2 =>
FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) (Input
Output)), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 => FSPIIO5 _3
=> SUBSPID _4 => FSPID) (Input Output)), (12, GPIO12(_2 => FSPIIO6 _4 => FSPICLK)
(_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) (Input Output)), (13, GPIO13(_2 =>
FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ)
(Input Output)), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 => FSPIDQS _3 =>
SUBSPIWP _4 => FSPIWP) (Input Output)), (15, GPIO15() (_2 => U0RTS) (Input
Output)), (16, GPIO16(_2 => U0CTS) () (Input Output)), (17, GPIO17() (_2 =>
U1TXD) (Input Output)), (18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) (Input
Output)), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2) (Input Output)), (20,
GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) (Input Output)), (21, GPIO21() () (Input
Output)), (26, GPIO26() (_0 => SPICS1) (Input Output)), (27, GPIO27(_0 => SPIHD)
(_0 => SPIHD) (Input Output)), (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) (Input
Output)), (29, GPIO29() (_0 => SPICS0) (Input Output)), (30, GPIO30() (_0 =>
SPICLK) (Input Output)), (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) (Input Output)),
(32, GPIO32(_0 => SPID) (_0 => SPID) (Input Output)), (33, GPIO33(_2 => FSPIHD _3
=> SUBSPIHD _4 => SPIIO4) (_2 => FSPIHD _3 => SUBSPIHD _4 => SPIIO4) (Input
Output)), (34, GPIO34(_2 => FSPICS0 _4 => SPIIO5) (_2 => FSPICS0 _3 => SUBSPICS0
_4 => SPIIO5) (Input Output)), (35, GPIO35(_2 => FSPID _3 => SUBSPID _4 =>
SPIIO6) (_2 => FSPID _3 => SUBSPID _4 => SPIIO6) (Input Output)), (36, GPIO36(_2
=> FSPICLK _4 => SPIIO7) (_2 => FSPICLK _3 => SUBSPICLK _4 => SPIIO7) (Input
Output)), (37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 =>
SUBSPIQ _4 => SPIDQS) (Input Output)), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP)
(_2 => FSPIWP _3 => SUBSPIWP) (Input Output)), (39, GPIO39() (_2 => CLK_OUT3 _3
=> SUBSPICS1) (Input Output)), (40, GPIO40() (_2 => CLK_OUT2) (Input Output)),
(41, GPIO41() (_2 => CLK_OUT1) (Input Output)), (42, GPIO42() () (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)), (47, GPIO47() (_0 => SPICLK_P_DIFF _2 =>
SUBSPICLK_P_DIFF) (Input Output)), (48, GPIO48() (_0 => SPICLK_N_DIFF _2 =>
SUBSPICLK_N_DIFF) (Input Output))));
SUBSPICLK _4 => SPIIO7) ([Input] [Output]))); _for_each_inner!((37, GPIO37(_2 =>
FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS)
([Input] [Output]))); _for_each_inner!((38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP)
(_2 => FSPIWP _3 => SUBSPIWP) ([Input] [Output]))); _for_each_inner!((39,
GPIO39() (_2 => CLK_OUT3 _3 => SUBSPICS1) ([Input] [Output])));
_for_each_inner!((40, GPIO40() (_2 => CLK_OUT2) ([Input] [Output])));
_for_each_inner!((41, GPIO41() (_2 => CLK_OUT1) ([Input] [Output])));
_for_each_inner!((42, GPIO42() () ([Input] [Output]))); _for_each_inner!((43,
GPIO43() (_0 => U0TXD _2 => CLK_OUT1) ([Input] [Output]))); _for_each_inner!((44,
GPIO44(_0 => U0RXD) (_2 => CLK_OUT2) ([Input] [Output]))); _for_each_inner!((45,
GPIO45() () ([Input] [Output]))); _for_each_inner!((46, GPIO46() () ([Input]
[Output]))); _for_each_inner!((47, GPIO47() (_0 => SPICLK_P_DIFF _2 =>
SUBSPICLK_P_DIFF) ([Input] [Output]))); _for_each_inner!((48, GPIO48() (_0 =>
SPICLK_N_DIFF _2 => SUBSPICLK_N_DIFF) ([Input] [Output])));
_for_each_inner!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() () ([Input]
[Output])), (2, GPIO2() () ([Input] [Output])), (3, GPIO3() () ([Input]
[Output])), (4, GPIO4() () ([Input] [Output])), (5, GPIO5() () ([Input]
[Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input]
[Output])), (8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])), (9, GPIO9(_3 =>
SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) ([Input] [Output])), (10,
GPIO10(_2 => FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0)
([Input] [Output])), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])), (12, GPIO12(_2 => FSPIIO6
_4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) ([Input] [Output])),
(13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ
_4 => FSPIQ) ([Input] [Output])), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 =>
FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])), (15, GPIO15() (_2 =>
U0RTS) ([Input] [Output])), (16, GPIO16(_2 => U0CTS) () ([Input] [Output])), (17,
GPIO17() (_2 => U1TXD) ([Input] [Output])), (18, GPIO18(_2 => U1RXD) (_3 =>
CLK_OUT3) ([Input] [Output])), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
([Input] [Output])), (20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
[Output])), (21, GPIO21() () ([Input] [Output])), (26, GPIO26() (_0 => SPICS1)
([Input] [Output])), (27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
(28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (29, GPIO29() (_0 =>
SPICS0) ([Input] [Output])), (30, GPIO30() (_0 => SPICLK) ([Input] [Output])),
(31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (32, GPIO32(_0 => SPID)
(_0 => SPID) ([Input] [Output])), (33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD _4 =>
SPIIO4) (_2 => FSPIHD _3 => SUBSPIHD _4 => SPIIO4) ([Input] [Output])), (34,
GPIO34(_2 => FSPICS0 _4 => SPIIO5) (_2 => FSPICS0 _3 => SUBSPICS0 _4 => SPIIO5)
([Input] [Output])), (35, GPIO35(_2 => FSPID _3 => SUBSPID _4 => SPIIO6) (_2 =>
FSPID _3 => SUBSPID _4 => SPIIO6) ([Input] [Output])), (36, GPIO36(_2 => FSPICLK
_4 => SPIIO7) (_2 => FSPICLK _3 => SUBSPICLK _4 => SPIIO7) ([Input] [Output])),
(37, GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4
=> SPIDQS) ([Input] [Output])), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 =>
FSPIWP _3 => SUBSPIWP) ([Input] [Output])), (39, GPIO39() (_2 => CLK_OUT3 _3 =>
SUBSPICS1) ([Input] [Output])), (40, GPIO40() (_2 => CLK_OUT2) ([Input]
[Output])), (41, GPIO41() (_2 => CLK_OUT1) ([Input] [Output])), (42, GPIO42() ()
([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])), (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.
@ -736,561 +743,9 @@ macro_rules! for_each_lp_function {
((RTC_GPIO21, RTC_GPIOn, 21), GPIO21)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! if_pin_is_type {
(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") })
};
}
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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.
//!
//! > 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
//!
//! 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
//! 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 */ };
//!
//! // 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
.iter()
.map(|pin| {
// Input must come first
if pin.input_only {
vec![quote! { Input }]
vec![quote! { Input }, quote! {}]
} else {
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![];
for (((n, p), af), attrs) in pin_numbers
.iter()
@ -478,7 +414,7 @@ pub(crate) fn generate_gpios(gpio: &super::GpioProperties) -> TokenStream {
.zip(pin_attrs.iter())
{
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:
///
/// 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:
///
@ -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_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.
/// - `$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
/// 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.
#for_each_lp
#if_pin_is_type
#impl_for_pin_type
/// Defines the `InputSignal` and `OutputSignal` enums.
///
/// This macro is intended to be called in esp-hal only.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
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]
#[expect(clippy::crate_in_macro_def)]
#[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.
//!
//! > 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
//!
//! 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
//! 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 */ };
//!
//! // You can create matchers with data filled in. This example will specifically match GPIO2