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