esp_metadata_generated/
_generated_esp32c2.rs

1// Do NOT edit this file directly. Make your changes to esp-metadata,
2// then run `cargo xtask update-metadata`.
3
4/// The name of the chip as `&str`
5///
6/// # Example
7///
8/// ```rust, no_run
9/// use esp_hal::chip;
10/// let chip_name = chip!();
11#[doc = concat!("assert_eq!(chip_name, ", chip!(), ")")]
12/// ```
13#[macro_export]
14#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
15macro_rules! chip {
16    () => {
17        "esp32c2"
18    };
19}
20/// The properties of this chip and its drivers.
21#[macro_export]
22#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
23macro_rules! property {
24    ("chip") => {
25        "esp32c2"
26    };
27    ("arch") => {
28        "riscv"
29    };
30    ("cores") => {
31        1
32    };
33    ("cores", str) => {
34        stringify!(1)
35    };
36    ("trm") => {
37        "https://www.espressif.com/sites/default/files/documentation/esp8684_technical_reference_manual_en.pdf"
38    };
39    ("assist_debug.has_sp_monitor") => {
40        true
41    };
42    ("assist_debug.has_region_monitor") => {
43        false
44    };
45    ("gpio.has_bank_1") => {
46        false
47    };
48    ("gpio.gpio_function") => {
49        1
50    };
51    ("gpio.gpio_function", str) => {
52        stringify!(1)
53    };
54    ("gpio.constant_0_input") => {
55        31
56    };
57    ("gpio.constant_0_input", str) => {
58        stringify!(31)
59    };
60    ("gpio.constant_1_input") => {
61        30
62    };
63    ("gpio.constant_1_input", str) => {
64        stringify!(30)
65    };
66    ("gpio.remap_iomux_pin_registers") => {
67        false
68    };
69    ("gpio.func_in_sel_offset") => {
70        0
71    };
72    ("gpio.func_in_sel_offset", str) => {
73        stringify!(0)
74    };
75    ("gpio.input_signal_max") => {
76        100
77    };
78    ("gpio.input_signal_max", str) => {
79        stringify!(100)
80    };
81    ("gpio.output_signal_max") => {
82        128
83    };
84    ("gpio.output_signal_max", str) => {
85        stringify!(128)
86    };
87    ("i2c_master.has_fsm_timeouts") => {
88        true
89    };
90    ("i2c_master.has_hw_bus_clear") => {
91        true
92    };
93    ("i2c_master.has_bus_timeout_enable") => {
94        true
95    };
96    ("i2c_master.separate_filter_config_registers") => {
97        false
98    };
99    ("i2c_master.can_estimate_nack_reason") => {
100        false
101    };
102    ("i2c_master.has_conf_update") => {
103        true
104    };
105    ("i2c_master.has_reliable_fsm_reset") => {
106        false
107    };
108    ("i2c_master.has_arbitration_en") => {
109        true
110    };
111    ("i2c_master.has_tx_fifo_watermark") => {
112        true
113    };
114    ("i2c_master.bus_timeout_is_exponential") => {
115        true
116    };
117    ("i2c_master.max_bus_timeout") => {
118        31
119    };
120    ("i2c_master.max_bus_timeout", str) => {
121        stringify!(31)
122    };
123    ("i2c_master.ll_intr_mask") => {
124        262143
125    };
126    ("i2c_master.ll_intr_mask", str) => {
127        stringify!(262143)
128    };
129    ("i2c_master.fifo_size") => {
130        16
131    };
132    ("i2c_master.fifo_size", str) => {
133        stringify!(16)
134    };
135    ("interrupts.status_registers") => {
136        2
137    };
138    ("interrupts.status_registers", str) => {
139        stringify!(2)
140    };
141    ("spi_master.has_octal") => {
142        false
143    };
144    ("timergroup.timg_has_timer1") => {
145        false
146    };
147    ("wifi.has_wifi6") => {
148        false
149    };
150}
151/// Macro to get the address range of the given memory region.
152#[macro_export]
153#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
154macro_rules! memory_range {
155    ("DRAM") => {
156        1070202880..1070465024
157    };
158}
159/// This macro can be used to generate code for each peripheral instance of the I2C master driver.
160///
161/// For an explanation on the general syntax, as well as usage of individual/repeated
162/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
163///
164/// This macro has one option for its "Individual matcher" case:
165///
166/// Syntax: `($instance:ident, $sys:ident, $scl:ident, $sda:ident)`
167///
168/// Macro fragments:
169///
170/// - `$instance`: the name of the I2C instance
171/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
172/// - `$scl`, `$sda`: peripheral signal names.
173///
174/// Example data: `(I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)`
175#[macro_export]
176#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
177macro_rules! for_each_i2c_master {
178    ($($pattern:tt => $code:tt;)*) => {
179        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
180        _for_each_inner!((I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA));
181        _for_each_inner!((all(I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)));
182    };
183}
184/// This macro can be used to generate code for each peripheral instance of the UART driver.
185///
186/// For an explanation on the general syntax, as well as usage of individual/repeated
187/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
188///
189/// This macro has one option for its "Individual matcher" case:
190///
191/// Syntax: `($instance:ident, $sys:ident, $rx:ident, $tx:ident, $cts:ident, $rts:ident)`
192///
193/// Macro fragments:
194///
195/// - `$instance`: the name of the UART instance
196/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
197/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
198///
199/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
200#[macro_export]
201#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
202macro_rules! for_each_uart {
203    ($($pattern:tt => $code:tt;)*) => {
204        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
205        _for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
206        _for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
207        _for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
208        U1RXD, U1TXD, U1CTS, U1RTS)));
209    };
210}
211/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
212///
213/// For an explanation on the general syntax, as well as usage of individual/repeated
214/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
215///
216/// This macro has one option for its "Individual matcher" case:
217///
218/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, [$($cs:ident),*] [$($sio:ident),*
219/// $($is_qspi:iteral)?])`
220///
221/// Macro fragments:
222///
223/// - `$instance`: the name of the SPI instance
224/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
225/// - `$cs`, `$sio`: chip select and SIO signal names.
226/// - `$is_qspi`: a `true` literal present if the SPI instance supports QSPI.
227///
228/// Example data:
229/// - `(SPI2, Spi2, FSPICLK [FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ,
230///   FSPIWP, FSPIHD, FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7], true)`
231/// - `(SPI3, Spi3, SPI3_CLK [SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q])`
232#[macro_export]
233#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
234macro_rules! for_each_spi_master {
235    ($($pattern:tt => $code:tt;)*) => {
236        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
237        _for_each_inner!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3,
238        FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true));
239        _for_each_inner!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3,
240        FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
241    };
242}
243/// This macro can be used to generate code for each peripheral instance of the SPI slave driver.
244///
245/// For an explanation on the general syntax, as well as usage of individual/repeated
246/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
247///
248/// This macro has one option for its "Individual matcher" case:
249///
250/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, $mosi:ident, $miso:ident, $cs:ident)`
251///
252/// Macro fragments:
253///
254/// - `$instance`: the name of the I2C instance
255/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
256/// - `$mosi`, `$miso`, `$cs`: signal names.
257///
258/// Example data: `(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)`
259#[macro_export]
260#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
261macro_rules! for_each_spi_slave {
262    ($($pattern:tt => $code:tt;)*) => {
263        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
264        _for_each_inner!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
265        _for_each_inner!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
266    };
267}
268#[macro_export]
269#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
270macro_rules! for_each_peripheral {
271    ($($pattern:tt => $code:tt;)*) => {
272        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
273        _for_each_inner!((GPIO0 <= virtual())); _for_each_inner!((GPIO1 <= virtual()));
274        _for_each_inner!((GPIO2 <= virtual())); _for_each_inner!((GPIO3 <= virtual()));
275        _for_each_inner!((GPIO4 <= virtual())); _for_each_inner!((GPIO5 <= virtual()));
276        _for_each_inner!((GPIO6 <= virtual())); _for_each_inner!((GPIO7 <= virtual()));
277        _for_each_inner!((GPIO8 <= virtual())); _for_each_inner!((GPIO9 <= virtual()));
278        _for_each_inner!((GPIO10 <= virtual())); _for_each_inner!((GPIO11 <= virtual()));
279        _for_each_inner!((GPIO12 <= virtual())); _for_each_inner!((GPIO13 <= virtual()));
280        _for_each_inner!((GPIO14 <= virtual())); _for_each_inner!((GPIO15 <= virtual()));
281        _for_each_inner!((GPIO16 <= virtual())); _for_each_inner!((GPIO17 <= virtual()));
282        _for_each_inner!((GPIO18 <= virtual())); _for_each_inner!((GPIO19 <= virtual()));
283        _for_each_inner!((GPIO20 <= virtual())); _for_each_inner!((APB_CTRL <= APB_CTRL()
284        (unstable))); _for_each_inner!((APB_SARADC <= APB_SARADC() (unstable)));
285        _for_each_inner!((BB <= BB() (unstable))); _for_each_inner!((ASSIST_DEBUG <=
286        ASSIST_DEBUG() (unstable))); _for_each_inner!((DMA <= DMA() (unstable)));
287        _for_each_inner!((ECC <= ECC() (unstable))); _for_each_inner!((EFUSE <= EFUSE()
288        (unstable))); _for_each_inner!((EXTMEM <= EXTMEM() (unstable)));
289        _for_each_inner!((GPIO <= GPIO() (unstable))); _for_each_inner!((I2C_ANA_MST <=
290        I2C_ANA_MST() (unstable))); _for_each_inner!((I2C0 <= I2C0(I2C_EXT0 : {
291        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })));
292        _for_each_inner!((INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)));
293        _for_each_inner!((IO_MUX <= IO_MUX() (unstable))); _for_each_inner!((LEDC <=
294        LEDC() (unstable))); _for_each_inner!((RNG <= RNG() (unstable)));
295        _for_each_inner!((LPWR <= RTC_CNTL() (unstable))); _for_each_inner!((MODEM_CLKRST
296        <= MODEM_CLKRST() (unstable))); _for_each_inner!((SENSITIVE <= SENSITIVE()
297        (unstable))); _for_each_inner!((SHA <= SHA() (unstable))); _for_each_inner!((SPI0
298        <= SPI0() (unstable))); _for_each_inner!((SPI1 <= SPI1() (unstable)));
299        _for_each_inner!((SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
300        enable_peri_interrupt, disable_peri_interrupt }))); _for_each_inner!((SYSTEM <=
301        SYSTEM() (unstable))); _for_each_inner!((SYSTIMER <= SYSTIMER() (unstable)));
302        _for_each_inner!((TIMG0 <= TIMG0() (unstable))); _for_each_inner!((UART0 <=
303        UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
304        disable_peri_interrupt }))); _for_each_inner!((UART1 <= UART1(UART1 : {
305        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })));
306        _for_each_inner!((XTS_AES <= XTS_AES() (unstable))); _for_each_inner!((DMA_CH0 <=
307        virtual() (unstable))); _for_each_inner!((ADC1 <= virtual() (unstable)));
308        _for_each_inner!((BT <= virtual() (unstable))); _for_each_inner!((SW_INTERRUPT <=
309        virtual() (unstable))); _for_each_inner!((WIFI <= virtual() (unstable)));
310        _for_each_inner!((MEM2MEM1 <= virtual() (unstable))); _for_each_inner!((MEM2MEM2
311        <= virtual() (unstable))); _for_each_inner!((MEM2MEM3 <= virtual() (unstable)));
312        _for_each_inner!((MEM2MEM4 <= virtual() (unstable))); _for_each_inner!((MEM2MEM5
313        <= virtual() (unstable))); _for_each_inner!((MEM2MEM6 <= virtual() (unstable)));
314        _for_each_inner!((MEM2MEM7 <= virtual() (unstable))); _for_each_inner!((MEM2MEM8
315        <= virtual() (unstable))); _for_each_inner!((all(GPIO0 <= virtual()), (GPIO1 <=
316        virtual()), (GPIO2 <= virtual()), (GPIO3 <= virtual()), (GPIO4 <= virtual()),
317        (GPIO5 <= virtual()), (GPIO6 <= virtual()), (GPIO7 <= virtual()), (GPIO8 <=
318        virtual()), (GPIO9 <= virtual()), (GPIO10 <= virtual()), (GPIO11 <= virtual()),
319        (GPIO12 <= virtual()), (GPIO13 <= virtual()), (GPIO14 <= virtual()), (GPIO15 <=
320        virtual()), (GPIO16 <= virtual()), (GPIO17 <= virtual()), (GPIO18 <= virtual()),
321        (GPIO19 <= virtual()), (GPIO20 <= virtual()), (APB_CTRL <= APB_CTRL()
322        (unstable)), (APB_SARADC <= APB_SARADC() (unstable)), (BB <= BB() (unstable)),
323        (ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)), (DMA <= DMA() (unstable)), (ECC <=
324        ECC() (unstable)), (EFUSE <= EFUSE() (unstable)), (EXTMEM <= EXTMEM()
325        (unstable)), (GPIO <= GPIO() (unstable)), (I2C_ANA_MST <= I2C_ANA_MST()
326        (unstable)), (I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
327        enable_peri_interrupt, disable_peri_interrupt })), (INTERRUPT_CORE0 <=
328        INTERRUPT_CORE0() (unstable)), (IO_MUX <= IO_MUX() (unstable)), (LEDC <= LEDC()
329        (unstable)), (RNG <= RNG() (unstable)), (LPWR <= RTC_CNTL() (unstable)),
330        (MODEM_CLKRST <= MODEM_CLKRST() (unstable)), (SENSITIVE <= SENSITIVE()
331        (unstable)), (SHA <= SHA() (unstable)), (SPI0 <= SPI0() (unstable)), (SPI1 <=
332        SPI1() (unstable)), (SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
333        enable_peri_interrupt, disable_peri_interrupt })), (SYSTEM <= SYSTEM()
334        (unstable)), (SYSTIMER <= SYSTIMER() (unstable)), (TIMG0 <= TIMG0() (unstable)),
335        (UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
336        disable_peri_interrupt })), (UART1 <= UART1(UART1 : { bind_peri_interrupt,
337        enable_peri_interrupt, disable_peri_interrupt })), (XTS_AES <= XTS_AES()
338        (unstable)), (DMA_CH0 <= virtual() (unstable)), (ADC1 <= virtual() (unstable)),
339        (BT <= virtual() (unstable)), (SW_INTERRUPT <= virtual() (unstable)), (WIFI <=
340        virtual() (unstable)), (MEM2MEM1 <= virtual() (unstable)), (MEM2MEM2 <= virtual()
341        (unstable)), (MEM2MEM3 <= virtual() (unstable)), (MEM2MEM4 <= virtual()
342        (unstable)), (MEM2MEM5 <= virtual() (unstable)), (MEM2MEM6 <= virtual()
343        (unstable)), (MEM2MEM7 <= virtual() (unstable)), (MEM2MEM8 <= virtual()
344        (unstable))));
345    };
346}
347/// This macro can be used to generate code for each `GPIOn` instance.
348///
349/// For an explanation on the general syntax, as well as usage of individual/repeated
350/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
351///
352/// This macro has one option for its "Individual matcher" case:
353///
354/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
355/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
356/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
357///
358/// Macro fragments:
359///
360/// - `$n`: the number of the GPIO. For `GPIO0`, `$n` is 0.
361/// - `$gpio`: the name of the GPIO.
362/// - `$digital_input_function`: the number of the digital function, as an identifier (i.e. for
363///   function 0 this is `_0`).
364/// - `$digital_input_function`: the name of the digital function, as an identifier.
365/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for
366///   function 0 this is `_0`).
367/// - `$digital_output_function`: the name of the digital function, as an identifier.
368/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
369///   Bracketed so that they can also be matched as optional fragments. Order is always Input first.
370///
371/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
372/// [Output]))`
373#[macro_export]
374#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
375macro_rules! for_each_gpio {
376    ($($pattern:tt => $code:tt;)*) => {
377        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
378        _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
379        GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
380        FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
381        [Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
382        ([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
383        FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
384        FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
385        FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
386        GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
387        [Output]))); _for_each_inner!((10, GPIO10() () ([Input] [Output])));
388        _for_each_inner!((11, GPIO11(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
389        _for_each_inner!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])));
390        _for_each_inner!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])));
391        _for_each_inner!((14, GPIO14() (_0 => SPICS0) ([Input] [Output])));
392        _for_each_inner!((15, GPIO15() (_0 => SPICLK) ([Input] [Output])));
393        _for_each_inner!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])));
394        _for_each_inner!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])));
395        _for_each_inner!((18, GPIO18() () ([Input] [Output]))); _for_each_inner!((19,
396        GPIO19(_0 => U0RXD) () ([Input] [Output]))); _for_each_inner!((20, GPIO20() (_0
397        => U0TXD) ([Input] [Output]))); _for_each_inner!((all(0, GPIO0() () ([Input]
398        [Output])), (1, GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 =>
399        FSPIQ) ([Input] [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 =>
400        MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 =>
401        FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK)
402        (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
403        FSPID) ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() ()
404        ([Input] [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11(_0 =>
405        SPIHD) (_0 => SPIHD) ([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD)
406        ([Input] [Output])), (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])),
407        (14, GPIO14() (_0 => SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK)
408        ([Input] [Output])), (16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])),
409        (17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (18, GPIO18() ()
410        ([Input] [Output])), (19, GPIO19(_0 => U0RXD) () ([Input] [Output])), (20,
411        GPIO20() (_0 => U0TXD) ([Input] [Output]))));
412    };
413}
414/// This macro can be used to generate code for each analog function of each GPIO.
415///
416/// For an explanation on the general syntax, as well as usage of individual/repeated
417/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
418///
419/// This macro has two options for its "Individual matcher" case:
420///
421/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
422/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
423///   expanded signal case, where you need the number(s) of a signal, or the general group to which
424///   the signal belongs. For example, in case of `ADC2_CH3` the expanded form looks like
425///   `(ADC2_CH3, ADCn_CHm, 2, 3)`.
426///
427/// Macro fragments:
428///
429/// - `$signal`: the name of the signal.
430/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
431///   is `ADCn_CHm`.
432/// - `$number`: the numbers extracted from `$signal`.
433/// - `$gpio`: the name of the GPIO.
434///
435/// Example data:
436/// - `(ADC2_CH5, GPIO12)`
437/// - `((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)`
438///
439/// The expanded syntax is only available when the signal has at least one numbered component.
440#[macro_export]
441#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
442macro_rules! for_each_analog_function {
443    ($($pattern:tt => $code:tt;)*) => {
444        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
445        _for_each_inner!((ADC1_CH0, GPIO0)); _for_each_inner!((ADC1_CH1, GPIO1));
446        _for_each_inner!((ADC1_CH2, GPIO2)); _for_each_inner!((ADC1_CH3, GPIO3));
447        _for_each_inner!((ADC1_CH4, GPIO4)); _for_each_inner!(((ADC1_CH0, ADCn_CHm, 1,
448        0), GPIO0)); _for_each_inner!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1));
449        _for_each_inner!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2));
450        _for_each_inner!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3));
451        _for_each_inner!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4));
452        _for_each_inner!((all(ADC1_CH0, GPIO0), (ADC1_CH1, GPIO1), (ADC1_CH2, GPIO2),
453        (ADC1_CH3, GPIO3), (ADC1_CH4, GPIO4))); _for_each_inner!((all_expanded((ADC1_CH0,
454        ADCn_CHm, 1, 0), GPIO0), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1), ((ADC1_CH2,
455        ADCn_CHm, 1, 2), GPIO2), ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3), ((ADC1_CH4,
456        ADCn_CHm, 1, 4), GPIO4)));
457    };
458}
459/// This macro can be used to generate code for each LP/RTC function of each GPIO.
460///
461/// For an explanation on the general syntax, as well as usage of individual/repeated
462/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
463///
464/// This macro has two options for its "Individual matcher" case:
465///
466/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
467/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
468///   expanded signal case, where you need the number(s) of a signal, or the general group to which
469///   the signal belongs. For example, in case of `SAR_I2C_SCL_1` the expanded form looks like
470///   `(SAR_I2C_SCL_1, SAR_I2C_SCL_n, 1)`.
471///
472/// Macro fragments:
473///
474/// - `$signal`: the name of the signal.
475/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
476///   is `ADCn_CHm`.
477/// - `$number`: the numbers extracted from `$signal`.
478/// - `$gpio`: the name of the GPIO.
479///
480/// Example data:
481/// - `(RTC_GPIO15, GPIO12)`
482/// - `((RTC_GPIO15, RTC_GPIOn, 15), GPIO12)`
483///
484/// The expanded syntax is only available when the signal has at least one numbered component.
485#[macro_export]
486#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
487macro_rules! for_each_lp_function {
488    ($($pattern:tt => $code:tt;)*) => {
489        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
490        _for_each_inner!((RTC_GPIO0, GPIO0)); _for_each_inner!((RTC_GPIO1, GPIO1));
491        _for_each_inner!((RTC_GPIO2, GPIO2)); _for_each_inner!((RTC_GPIO3, GPIO3));
492        _for_each_inner!((RTC_GPIO4, GPIO4)); _for_each_inner!((RTC_GPIO5, GPIO5));
493        _for_each_inner!(((RTC_GPIO0, RTC_GPIOn, 0), GPIO0));
494        _for_each_inner!(((RTC_GPIO1, RTC_GPIOn, 1), GPIO1));
495        _for_each_inner!(((RTC_GPIO2, RTC_GPIOn, 2), GPIO2));
496        _for_each_inner!(((RTC_GPIO3, RTC_GPIOn, 3), GPIO3));
497        _for_each_inner!(((RTC_GPIO4, RTC_GPIOn, 4), GPIO4));
498        _for_each_inner!(((RTC_GPIO5, RTC_GPIOn, 5), GPIO5));
499        _for_each_inner!((all(RTC_GPIO0, GPIO0), (RTC_GPIO1, GPIO1), (RTC_GPIO2, GPIO2),
500        (RTC_GPIO3, GPIO3), (RTC_GPIO4, GPIO4), (RTC_GPIO5, GPIO5)));
501        _for_each_inner!((all_expanded((RTC_GPIO0, RTC_GPIOn, 0), GPIO0), ((RTC_GPIO1,
502        RTC_GPIOn, 1), GPIO1), ((RTC_GPIO2, RTC_GPIOn, 2), GPIO2), ((RTC_GPIO3,
503        RTC_GPIOn, 3), GPIO3), ((RTC_GPIO4, RTC_GPIOn, 4), GPIO4), ((RTC_GPIO5,
504        RTC_GPIOn, 5), GPIO5)));
505    };
506}
507/// Defines the `InputSignal` and `OutputSignal` enums.
508///
509/// This macro is intended to be called in esp-hal only.
510#[macro_export]
511#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
512macro_rules! define_io_mux_signals {
513    () => {
514        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
515        #[derive(Debug, PartialEq, Copy, Clone)]
516        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
517        #[doc(hidden)]
518        pub enum InputSignal {
519            SPIQ          = 0,
520            SPID          = 1,
521            SPIHD         = 2,
522            SPIWP         = 3,
523            U0RXD         = 6,
524            U0CTS         = 7,
525            U0DSR         = 8,
526            U1RXD         = 9,
527            U1CTS         = 10,
528            U1DSR         = 11,
529            CPU_GPIO_0    = 28,
530            CPU_GPIO_1    = 29,
531            CPU_GPIO_2    = 30,
532            CPU_GPIO_3    = 31,
533            CPU_GPIO_4    = 32,
534            CPU_GPIO_5    = 33,
535            CPU_GPIO_6    = 34,
536            CPU_GPIO_7    = 35,
537            EXT_ADC_START = 45,
538            RMT_SIG_0     = 51,
539            RMT_SIG_1     = 52,
540            I2CEXT0_SCL   = 53,
541            I2CEXT0_SDA   = 54,
542            FSPICLK       = 63,
543            FSPIQ         = 64,
544            FSPID         = 65,
545            FSPIHD        = 66,
546            FSPIWP        = 67,
547            FSPICS0       = 68,
548            SIG_FUNC_97   = 97,
549            SIG_FUNC_98   = 98,
550            SIG_FUNC_99   = 99,
551            SIG_FUNC_100  = 100,
552            MTCK,
553            MTMS,
554            MTDI,
555        }
556        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
557        #[derive(Debug, PartialEq, Copy, Clone)]
558        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
559        #[doc(hidden)]
560        pub enum OutputSignal {
561            SPIQ          = 0,
562            SPID          = 1,
563            SPIHD         = 2,
564            SPIWP         = 3,
565            SPICLK        = 4,
566            SPICS0        = 5,
567            U0TXD         = 6,
568            U0RTS         = 7,
569            U0DTR         = 8,
570            U1TXD         = 9,
571            U1RTS         = 10,
572            U1DTR         = 11,
573            SPIQ_MONITOR  = 15,
574            SPID_MONITOR  = 16,
575            SPIHD_MONITOR = 17,
576            SPIWP_MONITOR = 18,
577            SPICS1        = 19,
578            CPU_GPIO_0    = 28,
579            CPU_GPIO_1    = 29,
580            CPU_GPIO_2    = 30,
581            CPU_GPIO_3    = 31,
582            CPU_GPIO_4    = 32,
583            CPU_GPIO_5    = 33,
584            CPU_GPIO_6    = 34,
585            CPU_GPIO_7    = 35,
586            LEDC_LS_SIG0  = 45,
587            LEDC_LS_SIG1  = 46,
588            LEDC_LS_SIG2  = 47,
589            LEDC_LS_SIG3  = 48,
590            LEDC_LS_SIG4  = 49,
591            LEDC_LS_SIG5  = 50,
592            RMT_SIG_0     = 51,
593            RMT_SIG_1     = 52,
594            I2CEXT0_SCL   = 53,
595            I2CEXT0_SDA   = 54,
596            FSPICLK       = 63,
597            FSPIQ         = 64,
598            FSPID         = 65,
599            FSPIHD        = 66,
600            FSPIWP        = 67,
601            FSPICS0       = 68,
602            FSPICS1       = 69,
603            FSPICS3       = 70,
604            FSPICS2       = 71,
605            FSPICS4       = 72,
606            FSPICS5       = 73,
607            ANT_SEL0      = 89,
608            ANT_SEL1      = 90,
609            ANT_SEL2      = 91,
610            ANT_SEL3      = 92,
611            ANT_SEL4      = 93,
612            ANT_SEL5      = 94,
613            ANT_SEL6      = 95,
614            ANT_SEL7      = 96,
615            SIG_FUNC_97   = 97,
616            SIG_FUNC_98   = 98,
617            SIG_FUNC_99   = 99,
618            SIG_FUNC_100  = 100,
619            CLK_OUT1      = 123,
620            CLK_OUT2      = 124,
621            CLK_OUT3      = 125,
622            GPIO          = 128,
623            MTDO,
624        }
625    };
626}
627/// Defines and implements the `io_mux_reg` function.
628///
629/// The generated function has the following signature:
630///
631/// ```rust,ignore
632/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
633///     // ...
634/// # unimplemented!()
635/// }
636/// ```
637///
638/// This macro is intended to be called in esp-hal only.
639#[macro_export]
640#[expect(clippy::crate_in_macro_def)]
641#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
642macro_rules! define_io_mux_reg {
643    () => {
644        pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
645            crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
646        }
647    };
648}