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