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    ("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.xtal_frequency") => {
58        40
59    };
60    ("soc.xtal_frequency", str) => {
61        stringify!(40)
62    };
63    ("aes.dma") => {
64        true
65    };
66    ("aes.has_split_text_registers") => {
67        true
68    };
69    ("aes.endianness_configurable") => {
70        false
71    };
72    ("assist_debug.has_sp_monitor") => {
73        true
74    };
75    ("assist_debug.has_region_monitor") => {
76        true
77    };
78    ("gpio.has_bank_1") => {
79        false
80    };
81    ("gpio.gpio_function") => {
82        1
83    };
84    ("gpio.gpio_function", str) => {
85        stringify!(1)
86    };
87    ("gpio.constant_0_input") => {
88        31
89    };
90    ("gpio.constant_0_input", str) => {
91        stringify!(31)
92    };
93    ("gpio.constant_1_input") => {
94        30
95    };
96    ("gpio.constant_1_input", str) => {
97        stringify!(30)
98    };
99    ("gpio.remap_iomux_pin_registers") => {
100        false
101    };
102    ("gpio.func_in_sel_offset") => {
103        0
104    };
105    ("gpio.func_in_sel_offset", str) => {
106        stringify!(0)
107    };
108    ("gpio.input_signal_max") => {
109        100
110    };
111    ("gpio.input_signal_max", str) => {
112        stringify!(100)
113    };
114    ("gpio.output_signal_max") => {
115        128
116    };
117    ("gpio.output_signal_max", str) => {
118        stringify!(128)
119    };
120    ("i2c_master.has_fsm_timeouts") => {
121        true
122    };
123    ("i2c_master.has_hw_bus_clear") => {
124        true
125    };
126    ("i2c_master.has_bus_timeout_enable") => {
127        true
128    };
129    ("i2c_master.separate_filter_config_registers") => {
130        false
131    };
132    ("i2c_master.can_estimate_nack_reason") => {
133        false
134    };
135    ("i2c_master.has_conf_update") => {
136        true
137    };
138    ("i2c_master.has_reliable_fsm_reset") => {
139        false
140    };
141    ("i2c_master.has_arbitration_en") => {
142        true
143    };
144    ("i2c_master.has_tx_fifo_watermark") => {
145        true
146    };
147    ("i2c_master.bus_timeout_is_exponential") => {
148        true
149    };
150    ("i2c_master.max_bus_timeout") => {
151        31
152    };
153    ("i2c_master.max_bus_timeout", str) => {
154        stringify!(31)
155    };
156    ("i2c_master.ll_intr_mask") => {
157        262143
158    };
159    ("i2c_master.ll_intr_mask", str) => {
160        stringify!(262143)
161    };
162    ("i2c_master.fifo_size") => {
163        32
164    };
165    ("i2c_master.fifo_size", str) => {
166        stringify!(32)
167    };
168    ("interrupts.status_registers") => {
169        2
170    };
171    ("interrupts.status_registers", str) => {
172        stringify!(2)
173    };
174    ("rmt.ram_start") => {
175        1610703872
176    };
177    ("rmt.ram_start", str) => {
178        stringify!(1610703872)
179    };
180    ("rmt.channel_ram_size") => {
181        48
182    };
183    ("rmt.channel_ram_size", str) => {
184        stringify!(48)
185    };
186    ("rmt.has_tx_immediate_stop") => {
187        true
188    };
189    ("rmt.has_tx_loop_count") => {
190        true
191    };
192    ("rmt.has_tx_loop_auto_stop") => {
193        false
194    };
195    ("rmt.has_tx_carrier_data_only") => {
196        true
197    };
198    ("rmt.has_tx_sync") => {
199        true
200    };
201    ("rmt.has_rx_wrap") => {
202        true
203    };
204    ("rmt.has_rx_demodulation") => {
205        true
206    };
207    ("rmt.has_dma") => {
208        false
209    };
210    ("rmt.has_per_channel_clock") => {
211        false
212    };
213    ("rng.apb_cycle_wait_num") => {
214        16
215    };
216    ("rng.apb_cycle_wait_num", str) => {
217        stringify!(16)
218    };
219    ("rsa.size_increment") => {
220        32
221    };
222    ("rsa.size_increment", str) => {
223        stringify!(32)
224    };
225    ("rsa.memory_size_bytes") => {
226        384
227    };
228    ("rsa.memory_size_bytes", str) => {
229        stringify!(384)
230    };
231    ("sha.dma") => {
232        true
233    };
234    ("spi_master.has_octal") => {
235        false
236    };
237    ("timergroup.timg_has_timer1") => {
238        false
239    };
240    ("timergroup.timg_has_divcnt_rst") => {
241        true
242    };
243    ("timergroup.default_clock_source") => {
244        0
245    };
246    ("timergroup.default_clock_source", str) => {
247        stringify!(0)
248    };
249    ("timergroup.default_wdt_clock_source") => {
250        0
251    };
252    ("timergroup.default_wdt_clock_source", str) => {
253        stringify!(0)
254    };
255    ("uart.ram_size") => {
256        128
257    };
258    ("uart.ram_size", str) => {
259        stringify!(128)
260    };
261    ("uart.peripheral_controls_mem_clk") => {
262        false
263    };
264    ("wifi.has_wifi6") => {
265        false
266    };
267    ("bt.controller") => {
268        "btdm"
269    };
270    ("phy.combo_module") => {
271        true
272    };
273    ("phy.backed_up_digital_register_count") => {
274        21
275    };
276    ("phy.backed_up_digital_register_count", str) => {
277        stringify!(21)
278    };
279}
280#[macro_export]
281#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
282macro_rules! for_each_soc_xtal_options {
283    ($($pattern:tt => $code:tt;)*) => {
284        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
285        _for_each_inner!((40)); _for_each_inner!((all(40)));
286    };
287}
288/// Implement the `Peripheral` enum and enable/disable/reset functions.
289///
290/// This macro is intended to be placed in `esp_hal::system`.
291#[macro_export]
292#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
293macro_rules! implement_peripheral_clocks {
294    () => {
295        #[doc(hidden)]
296        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
297        #[repr(u8)]
298        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
299        pub enum Peripheral {
300            #[doc = "AES peripheral clock signal"]
301            Aes,
302            #[doc = "APB_SAR_ADC peripheral clock signal"]
303            ApbSarAdc,
304            #[doc = "DMA peripheral clock signal"]
305            Dma,
306            #[doc = "DS peripheral clock signal"]
307            Ds,
308            #[doc = "HMAC peripheral clock signal"]
309            Hmac,
310            #[doc = "I2C_EXT0 peripheral clock signal"]
311            I2cExt0,
312            #[doc = "I2S0 peripheral clock signal"]
313            I2s0,
314            #[doc = "LEDC peripheral clock signal"]
315            Ledc,
316            #[doc = "RMT peripheral clock signal"]
317            Rmt,
318            #[doc = "RSA peripheral clock signal"]
319            Rsa,
320            #[doc = "SHA peripheral clock signal"]
321            Sha,
322            #[doc = "SPI2 peripheral clock signal"]
323            Spi2,
324            #[doc = "SYSTIMER peripheral clock signal"]
325            Systimer,
326            #[doc = "TIMG0 peripheral clock signal"]
327            Timg0,
328            #[doc = "TIMG1 peripheral clock signal"]
329            Timg1,
330            #[doc = "TSENS peripheral clock signal"]
331            Tsens,
332            #[doc = "TWAI0 peripheral clock signal"]
333            Twai0,
334            #[doc = "UART0 peripheral clock signal"]
335            Uart0,
336            #[doc = "UART1 peripheral clock signal"]
337            Uart1,
338            #[doc = "UART_MEM peripheral clock signal"]
339            UartMem,
340            #[doc = "UHCI0 peripheral clock signal"]
341            Uhci0,
342            #[doc = "USB_DEVICE peripheral clock signal"]
343            UsbDevice,
344        }
345        impl Peripheral {
346            const KEEP_ENABLED: &[Peripheral] = &[
347                Self::Systimer,
348                Self::Timg0,
349                Self::Uart0,
350                Self::UartMem,
351                Self::UsbDevice,
352            ];
353            const COUNT: usize = Self::ALL.len();
354            const ALL: &[Self] = &[
355                Self::Aes,
356                Self::ApbSarAdc,
357                Self::Dma,
358                Self::Ds,
359                Self::Hmac,
360                Self::I2cExt0,
361                Self::I2s0,
362                Self::Ledc,
363                Self::Rmt,
364                Self::Rsa,
365                Self::Sha,
366                Self::Spi2,
367                Self::Systimer,
368                Self::Timg0,
369                Self::Timg1,
370                Self::Tsens,
371                Self::Twai0,
372                Self::Uart0,
373                Self::Uart1,
374                Self::UartMem,
375                Self::Uhci0,
376                Self::UsbDevice,
377            ];
378        }
379        unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
380            match peripheral {
381                Peripheral::Aes => {
382                    crate::peripherals::SYSTEM::regs()
383                        .perip_clk_en1()
384                        .modify(|_, w| w.crypto_aes_clk_en().bit(enable));
385                }
386                Peripheral::ApbSarAdc => {
387                    crate::peripherals::SYSTEM::regs()
388                        .perip_clk_en0()
389                        .modify(|_, w| w.apb_saradc_clk_en().bit(enable));
390                }
391                Peripheral::Dma => {
392                    crate::peripherals::SYSTEM::regs()
393                        .perip_clk_en1()
394                        .modify(|_, w| w.dma_clk_en().bit(enable));
395                }
396                Peripheral::Ds => {
397                    crate::peripherals::SYSTEM::regs()
398                        .perip_clk_en1()
399                        .modify(|_, w| w.crypto_ds_clk_en().bit(enable));
400                }
401                Peripheral::Hmac => {
402                    crate::peripherals::SYSTEM::regs()
403                        .perip_clk_en1()
404                        .modify(|_, w| w.crypto_hmac_clk_en().bit(enable));
405                }
406                Peripheral::I2cExt0 => {
407                    crate::peripherals::SYSTEM::regs()
408                        .perip_clk_en0()
409                        .modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
410                }
411                Peripheral::I2s0 => {
412                    crate::peripherals::SYSTEM::regs()
413                        .perip_clk_en0()
414                        .modify(|_, w| w.i2s0_clk_en().bit(enable));
415                }
416                Peripheral::Ledc => {
417                    crate::peripherals::SYSTEM::regs()
418                        .perip_clk_en0()
419                        .modify(|_, w| w.ledc_clk_en().bit(enable));
420                }
421                Peripheral::Rmt => {
422                    crate::peripherals::SYSTEM::regs()
423                        .perip_clk_en0()
424                        .modify(|_, w| w.rmt_clk_en().bit(enable));
425                }
426                Peripheral::Rsa => {
427                    crate::peripherals::SYSTEM::regs()
428                        .perip_clk_en1()
429                        .modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
430                }
431                Peripheral::Sha => {
432                    crate::peripherals::SYSTEM::regs()
433                        .perip_clk_en1()
434                        .modify(|_, w| w.crypto_sha_clk_en().bit(enable));
435                }
436                Peripheral::Spi2 => {
437                    crate::peripherals::SYSTEM::regs()
438                        .perip_clk_en0()
439                        .modify(|_, w| w.spi2_clk_en().bit(enable));
440                }
441                Peripheral::Systimer => {
442                    crate::peripherals::SYSTEM::regs()
443                        .perip_clk_en0()
444                        .modify(|_, w| w.systimer_clk_en().bit(enable));
445                }
446                Peripheral::Timg0 => {
447                    crate::peripherals::SYSTEM::regs()
448                        .perip_clk_en0()
449                        .modify(|_, w| w.timergroup_clk_en().bit(enable));
450                }
451                Peripheral::Timg1 => {
452                    crate::peripherals::SYSTEM::regs()
453                        .perip_clk_en0()
454                        .modify(|_, w| w.timergroup1_clk_en().bit(enable));
455                }
456                Peripheral::Tsens => {
457                    crate::peripherals::SYSTEM::regs()
458                        .perip_clk_en1()
459                        .modify(|_, w| w.tsens_clk_en().bit(enable));
460                }
461                Peripheral::Twai0 => {
462                    crate::peripherals::SYSTEM::regs()
463                        .perip_clk_en0()
464                        .modify(|_, w| w.twai_clk_en().bit(enable));
465                }
466                Peripheral::Uart0 => {
467                    crate::peripherals::SYSTEM::regs()
468                        .perip_clk_en0()
469                        .modify(|_, w| w.uart_clk_en().bit(enable));
470                }
471                Peripheral::Uart1 => {
472                    crate::peripherals::SYSTEM::regs()
473                        .perip_clk_en0()
474                        .modify(|_, w| w.uart1_clk_en().bit(enable));
475                }
476                Peripheral::UartMem => {
477                    crate::peripherals::SYSTEM::regs()
478                        .perip_clk_en0()
479                        .modify(|_, w| w.uart_mem_clk_en().bit(enable));
480                }
481                Peripheral::Uhci0 => {
482                    crate::peripherals::SYSTEM::regs()
483                        .perip_clk_en0()
484                        .modify(|_, w| w.uhci0_clk_en().bit(enable));
485                }
486                Peripheral::UsbDevice => {
487                    crate::peripherals::SYSTEM::regs()
488                        .perip_clk_en0()
489                        .modify(|_, w| w.usb_device_clk_en().bit(enable));
490                }
491            }
492        }
493        unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
494            match peripheral {
495                Peripheral::Aes => {
496                    crate::peripherals::SYSTEM::regs()
497                        .perip_rst_en1()
498                        .modify(|_, w| w.crypto_aes_rst().bit(reset));
499                }
500                Peripheral::ApbSarAdc => {
501                    crate::peripherals::SYSTEM::regs()
502                        .perip_rst_en0()
503                        .modify(|_, w| w.apb_saradc_rst().bit(reset));
504                }
505                Peripheral::Dma => {
506                    crate::peripherals::SYSTEM::regs()
507                        .perip_rst_en1()
508                        .modify(|_, w| w.dma_rst().bit(reset));
509                }
510                Peripheral::Ds => {
511                    crate::peripherals::SYSTEM::regs()
512                        .perip_rst_en1()
513                        .modify(|_, w| w.crypto_ds_rst().bit(reset));
514                }
515                Peripheral::Hmac => {
516                    crate::peripherals::SYSTEM::regs()
517                        .perip_rst_en1()
518                        .modify(|_, w| w.crypto_hmac_rst().bit(reset));
519                }
520                Peripheral::I2cExt0 => {
521                    crate::peripherals::SYSTEM::regs()
522                        .perip_rst_en0()
523                        .modify(|_, w| w.i2c_ext0_rst().bit(reset));
524                }
525                Peripheral::I2s0 => {
526                    crate::peripherals::SYSTEM::regs()
527                        .perip_rst_en0()
528                        .modify(|_, w| w.i2s0_rst().bit(reset));
529                }
530                Peripheral::Ledc => {
531                    crate::peripherals::SYSTEM::regs()
532                        .perip_rst_en0()
533                        .modify(|_, w| w.ledc_rst().bit(reset));
534                }
535                Peripheral::Rmt => {
536                    crate::peripherals::SYSTEM::regs()
537                        .perip_rst_en0()
538                        .modify(|_, w| w.rmt_rst().bit(reset));
539                }
540                Peripheral::Rsa => {
541                    crate::peripherals::SYSTEM::regs()
542                        .perip_rst_en1()
543                        .modify(|_, w| w.crypto_rsa_rst().bit(reset));
544                }
545                Peripheral::Sha => {
546                    crate::peripherals::SYSTEM::regs()
547                        .perip_rst_en1()
548                        .modify(|_, w| w.crypto_sha_rst().bit(reset));
549                }
550                Peripheral::Spi2 => {
551                    crate::peripherals::SYSTEM::regs()
552                        .perip_rst_en0()
553                        .modify(|_, w| w.spi2_rst().bit(reset));
554                }
555                Peripheral::Systimer => {
556                    crate::peripherals::SYSTEM::regs()
557                        .perip_rst_en0()
558                        .modify(|_, w| w.systimer_rst().bit(reset));
559                }
560                Peripheral::Timg0 => {
561                    crate::peripherals::SYSTEM::regs()
562                        .perip_rst_en0()
563                        .modify(|_, w| w.timergroup_rst().bit(reset));
564                }
565                Peripheral::Timg1 => {
566                    crate::peripherals::SYSTEM::regs()
567                        .perip_rst_en0()
568                        .modify(|_, w| w.timergroup1_rst().bit(reset));
569                }
570                Peripheral::Tsens => {
571                    crate::peripherals::SYSTEM::regs()
572                        .perip_rst_en1()
573                        .modify(|_, w| w.tsens_rst().bit(reset));
574                }
575                Peripheral::Twai0 => {
576                    crate::peripherals::SYSTEM::regs()
577                        .perip_rst_en0()
578                        .modify(|_, w| w.twai_rst().bit(reset));
579                }
580                Peripheral::Uart0 => {
581                    crate::peripherals::SYSTEM::regs()
582                        .perip_rst_en0()
583                        .modify(|_, w| w.uart_rst().bit(reset));
584                }
585                Peripheral::Uart1 => {
586                    crate::peripherals::SYSTEM::regs()
587                        .perip_rst_en0()
588                        .modify(|_, w| w.uart1_rst().bit(reset));
589                }
590                Peripheral::UartMem => {
591                    crate::peripherals::SYSTEM::regs()
592                        .perip_rst_en0()
593                        .modify(|_, w| w.uart_mem_rst().bit(reset));
594                }
595                Peripheral::Uhci0 => {
596                    crate::peripherals::SYSTEM::regs()
597                        .perip_rst_en0()
598                        .modify(|_, w| w.uhci0_rst().bit(reset));
599                }
600                Peripheral::UsbDevice => {
601                    crate::peripherals::SYSTEM::regs()
602                        .perip_rst_en0()
603                        .modify(|_, w| w.usb_device_rst().bit(reset));
604                }
605            }
606        }
607    };
608}
609/// Macro to get the address range of the given memory region.
610///
611/// This macro provides two syntax options for each memory region:
612///
613/// - `memory_range!("region_name")` returns the address range as a range expression (`start..end`).
614/// - `memory_range!(size as str, "region_name")` returns the size of the region as a string
615///   literal.
616#[macro_export]
617#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
618macro_rules! memory_range {
619    ("DRAM") => {
620        1070071808..1070465024
621    };
622    (size as str, "DRAM") => {
623        "393216"
624    };
625    ("DRAM2_UNINIT") => {
626        1070392320..1070458640
627    };
628    (size as str, "DRAM2_UNINIT") => {
629        "66320"
630    };
631}
632#[macro_export]
633#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
634macro_rules! for_each_aes_key_length {
635    ($($pattern:tt => $code:tt;)*) => {
636        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
637        _for_each_inner!((128)); _for_each_inner!((256)); _for_each_inner!((128, 0, 4));
638        _for_each_inner!((256, 2, 6)); _for_each_inner!((bits(128), (256)));
639        _for_each_inner!((modes(128, 0, 4), (256, 2, 6)));
640    };
641}
642/// This macro can be used to generate code for each channel of the RMT peripheral.
643///
644/// For an explanation on the general syntax, as well as usage of individual/repeated
645/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
646///
647/// This macro has three options for its "Individual matcher" case:
648///
649/// - `all`: `($num:literal)`
650/// - `tx`: `($num:literal, $idx:literal)`
651/// - `rx`: `($num:literal, $idx:literal)`
652///
653/// Macro fragments:
654///
655/// - `$num`: number of the channel, e.g. `0`
656/// - `$idx`: index of the channel among channels of the same capability, e.g. `0`
657///
658/// Example data:
659///
660/// - `all`: `(0)`
661/// - `tx`: `(1, 1)`
662/// - `rx`: `(2, 0)`
663#[macro_export]
664#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
665macro_rules! for_each_rmt_channel {
666    ($($pattern:tt => $code:tt;)*) => {
667        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
668        _for_each_inner!((0)); _for_each_inner!((1)); _for_each_inner!((2));
669        _for_each_inner!((3)); _for_each_inner!((0, 0)); _for_each_inner!((1, 1));
670        _for_each_inner!((2, 0)); _for_each_inner!((3, 1)); _for_each_inner!((all(0),
671        (1), (2), (3))); _for_each_inner!((tx(0, 0), (1, 1))); _for_each_inner!((rx(2,
672        0), (3, 1)));
673    };
674}
675#[macro_export]
676#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
677macro_rules! for_each_rmt_clock_source {
678    ($($pattern:tt => $code:tt;)*) => {
679        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
680        _for_each_inner!((Apb, 1)); _for_each_inner!((RcFast, 2));
681        _for_each_inner!((Xtal, 3)); _for_each_inner!((Apb)); _for_each_inner!((all(Apb,
682        1), (RcFast, 2), (Xtal, 3))); _for_each_inner!((default(Apb)));
683    };
684}
685#[macro_export]
686#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
687macro_rules! for_each_rsa_exponentiation {
688    ($($pattern:tt => $code:tt;)*) => {
689        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
690        _for_each_inner!((32)); _for_each_inner!((64)); _for_each_inner!((96));
691        _for_each_inner!((128)); _for_each_inner!((160)); _for_each_inner!((192));
692        _for_each_inner!((224)); _for_each_inner!((256)); _for_each_inner!((288));
693        _for_each_inner!((320)); _for_each_inner!((352)); _for_each_inner!((384));
694        _for_each_inner!((416)); _for_each_inner!((448)); _for_each_inner!((480));
695        _for_each_inner!((512)); _for_each_inner!((544)); _for_each_inner!((576));
696        _for_each_inner!((608)); _for_each_inner!((640)); _for_each_inner!((672));
697        _for_each_inner!((704)); _for_each_inner!((736)); _for_each_inner!((768));
698        _for_each_inner!((800)); _for_each_inner!((832)); _for_each_inner!((864));
699        _for_each_inner!((896)); _for_each_inner!((928)); _for_each_inner!((960));
700        _for_each_inner!((992)); _for_each_inner!((1024)); _for_each_inner!((1056));
701        _for_each_inner!((1088)); _for_each_inner!((1120)); _for_each_inner!((1152));
702        _for_each_inner!((1184)); _for_each_inner!((1216)); _for_each_inner!((1248));
703        _for_each_inner!((1280)); _for_each_inner!((1312)); _for_each_inner!((1344));
704        _for_each_inner!((1376)); _for_each_inner!((1408)); _for_each_inner!((1440));
705        _for_each_inner!((1472)); _for_each_inner!((1504)); _for_each_inner!((1536));
706        _for_each_inner!((1568)); _for_each_inner!((1600)); _for_each_inner!((1632));
707        _for_each_inner!((1664)); _for_each_inner!((1696)); _for_each_inner!((1728));
708        _for_each_inner!((1760)); _for_each_inner!((1792)); _for_each_inner!((1824));
709        _for_each_inner!((1856)); _for_each_inner!((1888)); _for_each_inner!((1920));
710        _for_each_inner!((1952)); _for_each_inner!((1984)); _for_each_inner!((2016));
711        _for_each_inner!((2048)); _for_each_inner!((2080)); _for_each_inner!((2112));
712        _for_each_inner!((2144)); _for_each_inner!((2176)); _for_each_inner!((2208));
713        _for_each_inner!((2240)); _for_each_inner!((2272)); _for_each_inner!((2304));
714        _for_each_inner!((2336)); _for_each_inner!((2368)); _for_each_inner!((2400));
715        _for_each_inner!((2432)); _for_each_inner!((2464)); _for_each_inner!((2496));
716        _for_each_inner!((2528)); _for_each_inner!((2560)); _for_each_inner!((2592));
717        _for_each_inner!((2624)); _for_each_inner!((2656)); _for_each_inner!((2688));
718        _for_each_inner!((2720)); _for_each_inner!((2752)); _for_each_inner!((2784));
719        _for_each_inner!((2816)); _for_each_inner!((2848)); _for_each_inner!((2880));
720        _for_each_inner!((2912)); _for_each_inner!((2944)); _for_each_inner!((2976));
721        _for_each_inner!((3008)); _for_each_inner!((3040)); _for_each_inner!((3072));
722        _for_each_inner!((all(32), (64), (96), (128), (160), (192), (224), (256), (288),
723        (320), (352), (384), (416), (448), (480), (512), (544), (576), (608), (640),
724        (672), (704), (736), (768), (800), (832), (864), (896), (928), (960), (992),
725        (1024), (1056), (1088), (1120), (1152), (1184), (1216), (1248), (1280), (1312),
726        (1344), (1376), (1408), (1440), (1472), (1504), (1536), (1568), (1600), (1632),
727        (1664), (1696), (1728), (1760), (1792), (1824), (1856), (1888), (1920), (1952),
728        (1984), (2016), (2048), (2080), (2112), (2144), (2176), (2208), (2240), (2272),
729        (2304), (2336), (2368), (2400), (2432), (2464), (2496), (2528), (2560), (2592),
730        (2624), (2656), (2688), (2720), (2752), (2784), (2816), (2848), (2880), (2912),
731        (2944), (2976), (3008), (3040), (3072)));
732    };
733}
734#[macro_export]
735#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
736macro_rules! for_each_rsa_multiplication {
737    ($($pattern:tt => $code:tt;)*) => {
738        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
739        _for_each_inner!((32)); _for_each_inner!((64)); _for_each_inner!((96));
740        _for_each_inner!((128)); _for_each_inner!((160)); _for_each_inner!((192));
741        _for_each_inner!((224)); _for_each_inner!((256)); _for_each_inner!((288));
742        _for_each_inner!((320)); _for_each_inner!((352)); _for_each_inner!((384));
743        _for_each_inner!((416)); _for_each_inner!((448)); _for_each_inner!((480));
744        _for_each_inner!((512)); _for_each_inner!((544)); _for_each_inner!((576));
745        _for_each_inner!((608)); _for_each_inner!((640)); _for_each_inner!((672));
746        _for_each_inner!((704)); _for_each_inner!((736)); _for_each_inner!((768));
747        _for_each_inner!((800)); _for_each_inner!((832)); _for_each_inner!((864));
748        _for_each_inner!((896)); _for_each_inner!((928)); _for_each_inner!((960));
749        _for_each_inner!((992)); _for_each_inner!((1024)); _for_each_inner!((1056));
750        _for_each_inner!((1088)); _for_each_inner!((1120)); _for_each_inner!((1152));
751        _for_each_inner!((1184)); _for_each_inner!((1216)); _for_each_inner!((1248));
752        _for_each_inner!((1280)); _for_each_inner!((1312)); _for_each_inner!((1344));
753        _for_each_inner!((1376)); _for_each_inner!((1408)); _for_each_inner!((1440));
754        _for_each_inner!((1472)); _for_each_inner!((1504)); _for_each_inner!((1536));
755        _for_each_inner!((all(32), (64), (96), (128), (160), (192), (224), (256), (288),
756        (320), (352), (384), (416), (448), (480), (512), (544), (576), (608), (640),
757        (672), (704), (736), (768), (800), (832), (864), (896), (928), (960), (992),
758        (1024), (1056), (1088), (1120), (1152), (1184), (1216), (1248), (1280), (1312),
759        (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
760    };
761}
762#[macro_export]
763#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
764macro_rules! for_each_sha_algorithm {
765    ($($pattern:tt => $code:tt;)*) => {
766        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
767        _for_each_inner!((Sha1, "SHA-1"(sizes : 64, 20, 8) (insecure_against :
768        "collision", "length extension"), 0)); _for_each_inner!((Sha224, "SHA-224"(sizes
769        : 64, 28, 8) (insecure_against : "length extension"), 1));
770        _for_each_inner!((Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against :
771        "length extension"), 2)); _for_each_inner!((algos(Sha1, "SHA-1"(sizes : 64, 20,
772        8) (insecure_against : "collision", "length extension"), 0), (Sha224,
773        "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
774        (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
775        2)));
776    };
777}
778/// This macro can be used to generate code for each peripheral instance of the I2C master driver.
779///
780/// For an explanation on the general syntax, as well as usage of individual/repeated
781/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
782///
783/// This macro has one option for its "Individual matcher" case:
784///
785/// Syntax: `($instance:ident, $sys:ident, $scl:ident, $sda:ident)`
786///
787/// Macro fragments:
788///
789/// - `$instance`: the name of the I2C instance
790/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
791/// - `$scl`, `$sda`: peripheral signal names.
792///
793/// Example data: `(I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)`
794#[macro_export]
795#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
796macro_rules! for_each_i2c_master {
797    ($($pattern:tt => $code:tt;)*) => {
798        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
799        _for_each_inner!((I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA));
800        _for_each_inner!((all(I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)));
801    };
802}
803/// This macro can be used to generate code for each peripheral instance of the UART driver.
804///
805/// For an explanation on the general syntax, as well as usage of individual/repeated
806/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
807///
808/// This macro has one option for its "Individual matcher" case:
809///
810/// Syntax: `($instance:ident, $sys:ident, $rx:ident, $tx:ident, $cts:ident, $rts:ident)`
811///
812/// Macro fragments:
813///
814/// - `$instance`: the name of the UART instance
815/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
816/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
817///
818/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
819#[macro_export]
820#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
821macro_rules! for_each_uart {
822    ($($pattern:tt => $code:tt;)*) => {
823        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
824        _for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
825        _for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
826        _for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
827        U1RXD, U1TXD, U1CTS, U1RTS)));
828    };
829}
830/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
831///
832/// For an explanation on the general syntax, as well as usage of individual/repeated
833/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
834///
835/// This macro has one option for its "Individual matcher" case:
836///
837/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, [$($cs:ident),*] [$($sio:ident),*
838/// $($is_qspi:iteral)?])`
839///
840/// Macro fragments:
841///
842/// - `$instance`: the name of the SPI instance
843/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
844/// - `$cs`, `$sio`: chip select and SIO signal names.
845/// - `$is_qspi`: a `true` literal present if the SPI instance supports QSPI.
846///
847/// Example data:
848/// - `(SPI2, Spi2, FSPICLK [FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ,
849///   FSPIWP, FSPIHD, FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7], true)`
850/// - `(SPI3, Spi3, SPI3_CLK [SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q])`
851#[macro_export]
852#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
853macro_rules! for_each_spi_master {
854    ($($pattern:tt => $code:tt;)*) => {
855        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
856        _for_each_inner!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3,
857        FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true));
858        _for_each_inner!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3,
859        FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
860    };
861}
862/// This macro can be used to generate code for each peripheral instance of the SPI slave driver.
863///
864/// For an explanation on the general syntax, as well as usage of individual/repeated
865/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
866///
867/// This macro has one option for its "Individual matcher" case:
868///
869/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, $mosi:ident, $miso:ident, $cs:ident)`
870///
871/// Macro fragments:
872///
873/// - `$instance`: the name of the I2C instance
874/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
875/// - `$mosi`, `$miso`, `$cs`: signal names.
876///
877/// Example data: `(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)`
878#[macro_export]
879#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
880macro_rules! for_each_spi_slave {
881    ($($pattern:tt => $code:tt;)*) => {
882        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
883        _for_each_inner!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
884        _for_each_inner!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
885    };
886}
887#[macro_export]
888#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
889macro_rules! for_each_peripheral {
890    ($($pattern:tt => $code:tt;)*) => {
891        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
892        _for_each_inner!((GPIO0 <= virtual())); _for_each_inner!((GPIO1 <= virtual()));
893        _for_each_inner!((GPIO2 <= virtual())); _for_each_inner!((GPIO3 <= virtual()));
894        _for_each_inner!((GPIO4 <= virtual())); _for_each_inner!((GPIO5 <= virtual()));
895        _for_each_inner!((GPIO6 <= virtual())); _for_each_inner!((GPIO7 <= virtual()));
896        _for_each_inner!((GPIO8 <= virtual())); _for_each_inner!((GPIO9 <= virtual()));
897        _for_each_inner!((GPIO10 <= virtual())); _for_each_inner!((GPIO18 <= virtual()));
898        _for_each_inner!((GPIO19 <= virtual())); _for_each_inner!((GPIO20 <= virtual()));
899        _for_each_inner!((GPIO21 <= virtual())); _for_each_inner!((AES <= AES(AES : {
900        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
901        (unstable))); _for_each_inner!((APB_CTRL <= APB_CTRL() (unstable)));
902        _for_each_inner!((APB_SARADC <= APB_SARADC() (unstable)));
903        _for_each_inner!((ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
904        _for_each_inner!((BB <= BB() (unstable))); _for_each_inner!((DMA <= DMA()
905        (unstable))); _for_each_inner!((DS <= DS() (unstable))); _for_each_inner!((EFUSE
906        <= EFUSE() (unstable))); _for_each_inner!((EXTMEM <= EXTMEM() (unstable)));
907        _for_each_inner!((FE <= FE() (unstable))); _for_each_inner!((FE2 <= FE2()
908        (unstable))); _for_each_inner!((GPIO <= GPIO() (unstable)));
909        _for_each_inner!((GPIO_SD <= GPIO_SD() (unstable))); _for_each_inner!((HMAC <=
910        HMAC() (unstable))); _for_each_inner!((I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
911        _for_each_inner!((I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
912        enable_peri_interrupt, disable_peri_interrupt }))); _for_each_inner!((I2S0 <=
913        I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
914        }) (unstable))); _for_each_inner!((INTERRUPT_CORE0 <= INTERRUPT_CORE0()
915        (unstable))); _for_each_inner!((IO_MUX <= IO_MUX() (unstable)));
916        _for_each_inner!((LEDC <= LEDC() (unstable))); _for_each_inner!((NRX <= NRX()
917        (unstable))); _for_each_inner!((RMT <= RMT() (unstable))); _for_each_inner!((RNG
918        <= RNG() (unstable))); _for_each_inner!((RSA <= RSA(RSA : { bind_peri_interrupt,
919        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
920        _for_each_inner!((LPWR <= RTC_CNTL() (unstable))); _for_each_inner!((SENSITIVE <=
921        SENSITIVE() (unstable))); _for_each_inner!((SHA <= SHA(SHA : {
922        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
923        (unstable))); _for_each_inner!((SPI0 <= SPI0() (unstable)));
924        _for_each_inner!((SPI1 <= SPI1() (unstable))); _for_each_inner!((SPI2 <=
925        SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
926        }))); _for_each_inner!((SYSTEM <= SYSTEM() (unstable)));
927        _for_each_inner!((SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner!((TIMG0 <=
928        TIMG0() (unstable))); _for_each_inner!((TIMG1 <= TIMG1() (unstable)));
929        _for_each_inner!((TWAI0 <= TWAI0() (unstable))); _for_each_inner!((UART0 <=
930        UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
931        disable_peri_interrupt }))); _for_each_inner!((UART1 <= UART1(UART1 : {
932        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })));
933        _for_each_inner!((UHCI0 <= UHCI0() (unstable))); _for_each_inner!((USB_DEVICE <=
934        USB_DEVICE(USB_DEVICE : { bind_peri_interrupt, enable_peri_interrupt,
935        disable_peri_interrupt }) (unstable))); _for_each_inner!((XTS_AES <= XTS_AES()
936        (unstable))); _for_each_inner!((DMA_CH0 <= virtual() (unstable)));
937        _for_each_inner!((DMA_CH1 <= virtual() (unstable))); _for_each_inner!((DMA_CH2 <=
938        virtual() (unstable))); _for_each_inner!((ADC1 <= virtual() (unstable)));
939        _for_each_inner!((ADC2 <= virtual() (unstable))); _for_each_inner!((BT <=
940        virtual() (unstable))); _for_each_inner!((FLASH <= virtual() (unstable)));
941        _for_each_inner!((SW_INTERRUPT <= virtual() (unstable))); _for_each_inner!((TSENS
942        <= virtual() (unstable))); _for_each_inner!((WIFI <= virtual() (unstable)));
943        _for_each_inner!((all(GPIO0 <= virtual()), (GPIO1 <= virtual()), (GPIO2 <=
944        virtual()), (GPIO3 <= virtual()), (GPIO4 <= virtual()), (GPIO5 <= virtual()),
945        (GPIO6 <= virtual()), (GPIO7 <= virtual()), (GPIO8 <= virtual()), (GPIO9 <=
946        virtual()), (GPIO10 <= virtual()), (GPIO18 <= virtual()), (GPIO19 <= virtual()),
947        (GPIO20 <= virtual()), (GPIO21 <= virtual()), (AES <= AES(AES : {
948        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
949        (unstable)), (APB_CTRL <= APB_CTRL() (unstable)), (APB_SARADC <= APB_SARADC()
950        (unstable)), (ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)), (BB <= BB()
951        (unstable)), (DMA <= DMA() (unstable)), (DS <= DS() (unstable)), (EFUSE <=
952        EFUSE() (unstable)), (EXTMEM <= EXTMEM() (unstable)), (FE <= FE() (unstable)),
953        (FE2 <= FE2() (unstable)), (GPIO <= GPIO() (unstable)), (GPIO_SD <= GPIO_SD()
954        (unstable)), (HMAC <= HMAC() (unstable)), (I2C_ANA_MST <= I2C_ANA_MST()
955        (unstable)), (I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
956        enable_peri_interrupt, disable_peri_interrupt })), (I2S0 <= I2S0(I2S0 : {
957        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
958        (unstable)), (INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)), (IO_MUX <=
959        IO_MUX() (unstable)), (LEDC <= LEDC() (unstable)), (NRX <= NRX() (unstable)),
960        (RMT <= RMT() (unstable)), (RNG <= RNG() (unstable)), (RSA <= RSA(RSA : {
961        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
962        (unstable)), (LPWR <= RTC_CNTL() (unstable)), (SENSITIVE <= SENSITIVE()
963        (unstable)), (SHA <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt,
964        disable_peri_interrupt }) (unstable)), (SPI0 <= SPI0() (unstable)), (SPI1 <=
965        SPI1() (unstable)), (SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
966        enable_peri_interrupt, disable_peri_interrupt })), (SYSTEM <= SYSTEM()
967        (unstable)), (SYSTIMER <= SYSTIMER() (unstable)), (TIMG0 <= TIMG0() (unstable)),
968        (TIMG1 <= TIMG1() (unstable)), (TWAI0 <= TWAI0() (unstable)), (UART0 <=
969        UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
970        disable_peri_interrupt })), (UART1 <= UART1(UART1 : { bind_peri_interrupt,
971        enable_peri_interrupt, disable_peri_interrupt })), (UHCI0 <= UHCI0() (unstable)),
972        (USB_DEVICE <= USB_DEVICE(USB_DEVICE : { bind_peri_interrupt,
973        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (XTS_AES <=
974        XTS_AES() (unstable)), (DMA_CH0 <= virtual() (unstable)), (DMA_CH1 <= virtual()
975        (unstable)), (DMA_CH2 <= virtual() (unstable)), (ADC1 <= virtual() (unstable)),
976        (ADC2 <= virtual() (unstable)), (BT <= virtual() (unstable)), (FLASH <= virtual()
977        (unstable)), (SW_INTERRUPT <= virtual() (unstable)), (TSENS <= virtual()
978        (unstable)), (WIFI <= virtual() (unstable))));
979    };
980}
981/// This macro can be used to generate code for each `GPIOn` instance.
982///
983/// For an explanation on the general syntax, as well as usage of individual/repeated
984/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
985///
986/// This macro has one option for its "Individual matcher" case:
987///
988/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
989/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
990/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
991///
992/// Macro fragments:
993///
994/// - `$n`: the number of the GPIO. For `GPIO0`, `$n` is 0.
995/// - `$gpio`: the name of the GPIO.
996/// - `$digital_input_function`: the number of the digital function, as an identifier (i.e. for
997///   function 0 this is `_0`).
998/// - `$digital_input_function`: the name of the digital function, as an identifier.
999/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for
1000///   function 0 this is `_0`).
1001/// - `$digital_output_function`: the name of the digital function, as an identifier.
1002/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
1003///   Bracketed so that they can also be matched as optional fragments. Order is always Input first.
1004///
1005/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
1006/// [Output]))`
1007#[macro_export]
1008#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1009macro_rules! for_each_gpio {
1010    ($($pattern:tt => $code:tt;)*) => {
1011        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
1012        _for_each_inner!((0, GPIO0() () ([Input] [Output]))); _for_each_inner!((1,
1013        GPIO1() () ([Input] [Output]))); _for_each_inner!((2, GPIO2(_2 => FSPIQ) (_2 =>
1014        FSPIQ) ([Input] [Output]))); _for_each_inner!((3, GPIO3() () ([Input]
1015        [Output]))); _for_each_inner!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD)
1016        ([Input] [Output]))); _for_each_inner!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
1017        FSPIWP) ([Input] [Output]))); _for_each_inner!((6, GPIO6(_0 => MTCK _2 =>
1018        FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner!((7, GPIO7(_2 =>
1019        FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output]))); _for_each_inner!((8,
1020        GPIO8() () ([Input] [Output]))); _for_each_inner!((9, GPIO9() () ([Input]
1021        [Output]))); _for_each_inner!((10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
1022        [Output]))); _for_each_inner!((18, GPIO18() () ([Input] [Output])));
1023        _for_each_inner!((19, GPIO19() () ([Input] [Output]))); _for_each_inner!((20,
1024        GPIO20(_0 => U0RXD) () ([Input] [Output]))); _for_each_inner!((21, GPIO21() (_0
1025        => U0TXD) ([Input] [Output]))); _for_each_inner!((all(0, GPIO0() () ([Input]
1026        [Output])), (1, GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 =>
1027        FSPIQ) ([Input] [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 =>
1028        MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 =>
1029        FSPIWP) (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK)
1030        (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 =>
1031        FSPID) ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() ()
1032        ([Input] [Output])), (10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
1033        [Output])), (18, GPIO18() () ([Input] [Output])), (19, GPIO19() () ([Input]
1034        [Output])), (20, GPIO20(_0 => U0RXD) () ([Input] [Output])), (21, GPIO21() (_0 =>
1035        U0TXD) ([Input] [Output]))));
1036    };
1037}
1038/// This macro can be used to generate code for each analog function of each GPIO.
1039///
1040/// For an explanation on the general syntax, as well as usage of individual/repeated
1041/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
1042///
1043/// This macro has two options for its "Individual matcher" case:
1044///
1045/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
1046/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
1047///   expanded signal case, where you need the number(s) of a signal, or the general group to which
1048///   the signal belongs. For example, in case of `ADC2_CH3` the expanded form looks like
1049///   `(ADC2_CH3, ADCn_CHm, 2, 3)`.
1050///
1051/// Macro fragments:
1052///
1053/// - `$signal`: the name of the signal.
1054/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
1055///   is `ADCn_CHm`.
1056/// - `$number`: the numbers extracted from `$signal`.
1057/// - `$gpio`: the name of the GPIO.
1058///
1059/// Example data:
1060/// - `(ADC2_CH5, GPIO12)`
1061/// - `((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)`
1062///
1063/// The expanded syntax is only available when the signal has at least one numbered component.
1064#[macro_export]
1065#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1066macro_rules! for_each_analog_function {
1067    ($($pattern:tt => $code:tt;)*) => {
1068        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
1069        _for_each_inner!((ADC1_CH0, GPIO0)); _for_each_inner!((ADC1_CH1, GPIO1));
1070        _for_each_inner!((ADC1_CH2, GPIO2)); _for_each_inner!((ADC1_CH3, GPIO3));
1071        _for_each_inner!((ADC1_CH4, GPIO4)); _for_each_inner!((ADC2_CH0, GPIO5));
1072        _for_each_inner!((USB_DM, GPIO18)); _for_each_inner!((USB_DP, GPIO19));
1073        _for_each_inner!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0));
1074        _for_each_inner!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1));
1075        _for_each_inner!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2));
1076        _for_each_inner!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3));
1077        _for_each_inner!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4));
1078        _for_each_inner!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO5));
1079        _for_each_inner!((all(ADC1_CH0, GPIO0), (ADC1_CH1, GPIO1), (ADC1_CH2, GPIO2),
1080        (ADC1_CH3, GPIO3), (ADC1_CH4, GPIO4), (ADC2_CH0, GPIO5), (USB_DM, GPIO18),
1081        (USB_DP, GPIO19))); _for_each_inner!((all_expanded((ADC1_CH0, ADCn_CHm, 1, 0),
1082        GPIO0), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2),
1083        ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4),
1084        ((ADC2_CH0, ADCn_CHm, 2, 0), GPIO5)));
1085    };
1086}
1087/// This macro can be used to generate code for each LP/RTC function of each GPIO.
1088///
1089/// For an explanation on the general syntax, as well as usage of individual/repeated
1090/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
1091///
1092/// This macro has two options for its "Individual matcher" case:
1093///
1094/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
1095/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
1096///   expanded signal case, where you need the number(s) of a signal, or the general group to which
1097///   the signal belongs. For example, in case of `SAR_I2C_SCL_1` the expanded form looks like
1098///   `(SAR_I2C_SCL_1, SAR_I2C_SCL_n, 1)`.
1099///
1100/// Macro fragments:
1101///
1102/// - `$signal`: the name of the signal.
1103/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
1104///   is `ADCn_CHm`.
1105/// - `$number`: the numbers extracted from `$signal`.
1106/// - `$gpio`: the name of the GPIO.
1107///
1108/// Example data:
1109/// - `(RTC_GPIO15, GPIO12)`
1110/// - `((RTC_GPIO15, RTC_GPIOn, 15), GPIO12)`
1111///
1112/// The expanded syntax is only available when the signal has at least one numbered component.
1113#[macro_export]
1114#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1115macro_rules! for_each_lp_function {
1116    ($($pattern:tt => $code:tt;)*) => {
1117        macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
1118        _for_each_inner!((RTC_GPIO0, GPIO0)); _for_each_inner!((RTC_GPIO1, GPIO1));
1119        _for_each_inner!((RTC_GPIO2, GPIO2)); _for_each_inner!((RTC_GPIO3, GPIO3));
1120        _for_each_inner!((RTC_GPIO4, GPIO4)); _for_each_inner!((RTC_GPIO5, GPIO5));
1121        _for_each_inner!(((RTC_GPIO0, RTC_GPIOn, 0), GPIO0));
1122        _for_each_inner!(((RTC_GPIO1, RTC_GPIOn, 1), GPIO1));
1123        _for_each_inner!(((RTC_GPIO2, RTC_GPIOn, 2), GPIO2));
1124        _for_each_inner!(((RTC_GPIO3, RTC_GPIOn, 3), GPIO3));
1125        _for_each_inner!(((RTC_GPIO4, RTC_GPIOn, 4), GPIO4));
1126        _for_each_inner!(((RTC_GPIO5, RTC_GPIOn, 5), GPIO5));
1127        _for_each_inner!((all(RTC_GPIO0, GPIO0), (RTC_GPIO1, GPIO1), (RTC_GPIO2, GPIO2),
1128        (RTC_GPIO3, GPIO3), (RTC_GPIO4, GPIO4), (RTC_GPIO5, GPIO5)));
1129        _for_each_inner!((all_expanded((RTC_GPIO0, RTC_GPIOn, 0), GPIO0), ((RTC_GPIO1,
1130        RTC_GPIOn, 1), GPIO1), ((RTC_GPIO2, RTC_GPIOn, 2), GPIO2), ((RTC_GPIO3,
1131        RTC_GPIOn, 3), GPIO3), ((RTC_GPIO4, RTC_GPIOn, 4), GPIO4), ((RTC_GPIO5,
1132        RTC_GPIOn, 5), GPIO5)));
1133    };
1134}
1135/// Defines the `InputSignal` and `OutputSignal` enums.
1136///
1137/// This macro is intended to be called in esp-hal only.
1138#[macro_export]
1139#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1140macro_rules! define_io_mux_signals {
1141    () => {
1142        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
1143        #[derive(Debug, PartialEq, Copy, Clone)]
1144        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1145        #[doc(hidden)]
1146        pub enum InputSignal {
1147            SPIQ             = 0,
1148            SPID             = 1,
1149            SPIHD            = 2,
1150            SPIWP            = 3,
1151            U0RXD            = 6,
1152            U0CTS            = 7,
1153            U0DSR            = 8,
1154            U1RXD            = 9,
1155            U1CTS            = 10,
1156            U1DSR            = 11,
1157            I2S_MCLK         = 12,
1158            I2SO_BCK         = 13,
1159            I2SO_WS          = 14,
1160            I2SI_SD          = 15,
1161            I2SI_BCK         = 16,
1162            I2SI_WS          = 17,
1163            GPIO_BT_PRIORITY = 18,
1164            GPIO_BT_ACTIVE   = 19,
1165            CPU_GPIO_0       = 28,
1166            CPU_GPIO_1       = 29,
1167            CPU_GPIO_2       = 30,
1168            CPU_GPIO_3       = 31,
1169            CPU_GPIO_4       = 32,
1170            CPU_GPIO_5       = 33,
1171            CPU_GPIO_6       = 34,
1172            CPU_GPIO_7       = 35,
1173            EXT_ADC_START    = 45,
1174            RMT_SIG_0        = 51,
1175            RMT_SIG_1        = 52,
1176            I2CEXT0_SCL      = 53,
1177            I2CEXT0_SDA      = 54,
1178            FSPICLK          = 63,
1179            FSPIQ            = 64,
1180            FSPID            = 65,
1181            FSPIHD           = 66,
1182            FSPIWP           = 67,
1183            FSPICS0          = 68,
1184            TWAI_RX          = 74,
1185            SIG_FUNC_97      = 97,
1186            SIG_FUNC_98      = 98,
1187            SIG_FUNC_99      = 99,
1188            SIG_FUNC_100     = 100,
1189            MTCK,
1190            MTMS,
1191            MTDI,
1192        }
1193        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
1194        #[derive(Debug, PartialEq, Copy, Clone)]
1195        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1196        #[doc(hidden)]
1197        pub enum OutputSignal {
1198            SPIQ             = 0,
1199            SPID             = 1,
1200            SPIHD            = 2,
1201            SPIWP            = 3,
1202            SPICLK           = 4,
1203            SPICS0           = 5,
1204            U0TXD            = 6,
1205            U0RTS            = 7,
1206            U0DTR            = 8,
1207            U1TXD            = 9,
1208            U1RTS            = 10,
1209            U1DTR            = 11,
1210            I2S_MCLK         = 12,
1211            I2SO_BCK         = 13,
1212            I2SO_WS          = 14,
1213            I2SO_SD          = 15,
1214            I2SI_BCK         = 16,
1215            I2SI_WS          = 17,
1216            GPIO_WLAN_PRIO   = 18,
1217            GPIO_WLAN_ACTIVE = 19,
1218            CPU_GPIO_0       = 28,
1219            CPU_GPIO_1       = 29,
1220            CPU_GPIO_2       = 30,
1221            CPU_GPIO_3       = 31,
1222            CPU_GPIO_4       = 32,
1223            CPU_GPIO_5       = 33,
1224            CPU_GPIO_6       = 34,
1225            CPU_GPIO_7       = 35,
1226            USB_JTAG_TCK     = 36,
1227            USB_JTAG_TMS     = 37,
1228            USB_JTAG_TDI     = 38,
1229            USB_JTAG_TDO     = 39,
1230            LEDC_LS_SIG0     = 45,
1231            LEDC_LS_SIG1     = 46,
1232            LEDC_LS_SIG2     = 47,
1233            LEDC_LS_SIG3     = 48,
1234            LEDC_LS_SIG4     = 49,
1235            LEDC_LS_SIG5     = 50,
1236            RMT_SIG_0        = 51,
1237            RMT_SIG_1        = 52,
1238            I2CEXT0_SCL      = 53,
1239            I2CEXT0_SDA      = 54,
1240            GPIO_SD0         = 55,
1241            GPIO_SD1         = 56,
1242            GPIO_SD2         = 57,
1243            GPIO_SD3         = 58,
1244            I2SO_SD1         = 59,
1245            FSPICLK          = 63,
1246            FSPIQ            = 64,
1247            FSPID            = 65,
1248            FSPIHD           = 66,
1249            FSPIWP           = 67,
1250            FSPICS0          = 68,
1251            FSPICS1          = 69,
1252            FSPICS3          = 70,
1253            FSPICS2          = 71,
1254            FSPICS4          = 72,
1255            FSPICS5          = 73,
1256            TWAI_TX          = 74,
1257            TWAI_BUS_OFF_ON  = 75,
1258            TWAI_CLKOUT      = 76,
1259            ANT_SEL0         = 89,
1260            ANT_SEL1         = 90,
1261            ANT_SEL2         = 91,
1262            ANT_SEL3         = 92,
1263            ANT_SEL4         = 93,
1264            ANT_SEL5         = 94,
1265            ANT_SEL6         = 95,
1266            ANT_SEL7         = 96,
1267            SIG_FUNC_97      = 97,
1268            SIG_FUNC_98      = 98,
1269            SIG_FUNC_99      = 99,
1270            SIG_FUNC_100     = 100,
1271            CLK_OUT1         = 123,
1272            CLK_OUT2         = 124,
1273            CLK_OUT3         = 125,
1274            SPICS1           = 126,
1275            USB_JTAG_TRST    = 127,
1276            GPIO             = 128,
1277            MTDO,
1278        }
1279    };
1280}
1281/// Defines and implements the `io_mux_reg` function.
1282///
1283/// The generated function has the following signature:
1284///
1285/// ```rust,ignore
1286/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
1287///     // ...
1288/// # unimplemented!()
1289/// }
1290/// ```
1291///
1292/// This macro is intended to be called in esp-hal only.
1293#[macro_export]
1294#[expect(clippy::crate_in_macro_def)]
1295#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1296macro_rules! define_io_mux_reg {
1297    () => {
1298        pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
1299            crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
1300        }
1301    };
1302}