Skip to main content

esp_metadata_generated/
_generated_esp32p4.rs

1// Do NOT edit this file directly. Make your changes to esp-metadata,
2// then run `cargo 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        "esp32p4"
18    };
19}
20/// The pretty name of the chip as `&str`
21///
22/// # Example
23///
24/// ```rust, no_run
25/// use esp_hal::chip;
26/// let chip_name = chip_pretty!();
27#[doc = concat!("assert_eq!(chip_name, ", chip_pretty!(), ")")]
28/// ```
29#[macro_export]
30#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
31macro_rules! chip_pretty {
32    () => {
33        "ESP32-P4"
34    };
35}
36/// The properties of this chip and its drivers.
37#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40    ("chip") => {
41        "esp32p4"
42    };
43    ("arch") => {
44        "riscv"
45    };
46    ("cores") => {
47        2
48    };
49    ("cores", str) => {
50        stringify!(2)
51    };
52    ("trm") => {
53        "https://www.espressif.com/sites/default/files/documentation/esp32-p4_technical_reference_manual_en.pdf"
54    };
55    ("gpio.version") => {
56        3
57    };
58    ("gpio.version", str) => {
59        stringify!(3)
60    };
61    ("gpio.has_input_sync") => {
62        true
63    };
64    ("gpio.gpio_function") => {
65        1
66    };
67    ("gpio.gpio_function", str) => {
68        stringify!(1)
69    };
70    ("gpio.constant_0_input") => {
71        62
72    };
73    ("gpio.constant_0_input", str) => {
74        stringify!(62)
75    };
76    ("gpio.constant_1_input") => {
77        63
78    };
79    ("gpio.constant_1_input", str) => {
80        stringify!(63)
81    };
82    ("gpio.remap_iomux_pin_registers") => {
83        false
84    };
85    ("gpio.func_in_sel_offset") => {
86        1
87    };
88    ("gpio.func_in_sel_offset", str) => {
89        stringify!(1)
90    };
91    ("gpio.has_bank_1") => {
92        true
93    };
94    ("gpio.input_signal_max") => {
95        249
96    };
97    ("gpio.input_signal_max", str) => {
98        stringify!(249)
99    };
100    ("gpio.output_signal_max") => {
101        256
102    };
103    ("gpio.output_signal_max", str) => {
104        stringify!(256)
105    };
106    ("dedicated_gpio.version") => {
107        "riscv_v2"
108    };
109    ("dedicated_gpio.needs_initialization") => {
110        false
111    };
112    ("dedicated_gpio.channel_count") => {
113        8
114    };
115    ("dedicated_gpio.channel_count", str) => {
116        stringify!(8)
117    };
118    ("lp_io.version") => {
119        "esp32p4"
120    };
121    ("lp_io.has_gpio_matrix") => {
122        true
123    };
124    ("uart.ram_size") => {
125        128
126    };
127    ("uart.ram_size", str) => {
128        stringify!(128)
129    };
130    ("uart.version") => {
131        2
132    };
133    ("uart.version", str) => {
134        stringify!(2)
135    };
136    ("uart.peripheral_controls_mem_clk") => {
137        false
138    };
139    ("uart.has_sclk_divider") => {
140        false
141    };
142    ("uart.has_sclk_enable") => {
143        false
144    };
145    ("uhci.combined_uart_selector_field") => {
146        true
147    };
148    ("i2c_master.version") => {
149        4
150    };
151    ("i2c_master.version", str) => {
152        stringify!(4)
153    };
154    ("i2c_master.has_fsm_timeouts") => {
155        true
156    };
157    ("i2c_master.has_hw_bus_clear") => {
158        true
159    };
160    ("i2c_master.has_bus_timeout_enable") => {
161        true
162    };
163    ("i2c_master.separate_filter_config_registers") => {
164        false
165    };
166    ("i2c_master.can_estimate_nack_reason") => {
167        true
168    };
169    ("i2c_master.has_conf_update") => {
170        true
171    };
172    ("i2c_master.has_reliable_fsm_reset") => {
173        false
174    };
175    ("i2c_master.has_arbitration_en") => {
176        true
177    };
178    ("i2c_master.has_tx_fifo_watermark") => {
179        false
180    };
181    ("i2c_master.bus_timeout_is_exponential") => {
182        false
183    };
184    ("i2c_master.has_pd_en") => {
185        true
186    };
187    ("i2c_master.max_bus_timeout") => {
188        31
189    };
190    ("i2c_master.max_bus_timeout", str) => {
191        stringify!(31)
192    };
193    ("i2c_master.ll_intr_mask") => {
194        262143
195    };
196    ("i2c_master.ll_intr_mask", str) => {
197        stringify!(262143)
198    };
199    ("i2c_master.fifo_size") => {
200        32
201    };
202    ("i2c_master.fifo_size", str) => {
203        stringify!(32)
204    };
205    ("lp_i2c_master.version") => {
206        "lp_i2c"
207    };
208    ("lp_i2c_master.fifo_size") => {
209        16
210    };
211    ("lp_i2c_master.fifo_size", str) => {
212        stringify!(16)
213    };
214    ("spi_master.version") => {
215        3
216    };
217    ("spi_master.version", str) => {
218        stringify!(3)
219    };
220    ("spi_master.fifo_size") => {
221        64
222    };
223    ("spi_master.fifo_size", str) => {
224        stringify!(64)
225    };
226    ("spi_master.bit_order_is_bool") => {
227        false
228    };
229    ("spi_master.has_octal") => {
230        false
231    };
232    ("spi_master.has_app_interrupts") => {
233        false
234    };
235    ("spi_master.has_dma_segmented_transfer") => {
236        false
237    };
238    ("spi_master.has_clk_pre_div") => {
239        false
240    };
241    ("spi_master.dma_can_access_flash") => {
242        false
243    };
244    ("i2s.version") => {
245        3
246    };
247    ("i2s.version", str) => {
248        stringify!(3)
249    };
250    ("i2s.default_clock_source") => {
251        3
252    };
253    ("i2s.default_clock_source", str) => {
254        stringify!(3)
255    };
256    ("i2s.mclk_divider_bit_width") => {
257        6
258    };
259    ("i2s.mclk_divider_bit_width", str) => {
260        stringify!(6)
261    };
262    ("i2s.max_ws_width") => {
263        128
264    };
265    ("i2s.max_ws_width", str) => {
266        stringify!(128)
267    };
268    ("i2s.clock_configured_by_pcr") => {
269        false
270    };
271    ("i2s.clock_configured_by_hp_sys_clkrst") => {
272        true
273    };
274    ("i2s.supports_pdm_rx_hp_filter") => {
275        true
276    };
277    ("i2s.supports_pdm_tx") => {
278        true
279    };
280    ("i2s.supports_pdm_rx") => {
281        true
282    };
283    ("i2s.supports_pcm2pdm") => {
284        true
285    };
286    ("i2s.supports_pdm2pcm") => {
287        true
288    };
289    ("rmt.ram_start") => {
290        1342842880
291    };
292    ("rmt.ram_start", str) => {
293        stringify!(1342842880)
294    };
295    ("rmt.channel_ram_size") => {
296        48
297    };
298    ("rmt.channel_ram_size", str) => {
299        stringify!(48)
300    };
301    ("rmt.has_tx_immediate_stop") => {
302        true
303    };
304    ("rmt.has_tx_loop_count") => {
305        true
306    };
307    ("rmt.has_tx_loop_auto_stop") => {
308        true
309    };
310    ("rmt.has_tx_carrier_data_only") => {
311        true
312    };
313    ("rmt.has_tx_sync") => {
314        true
315    };
316    ("rmt.has_rx_wrap") => {
317        true
318    };
319    ("rmt.has_rx_demodulation") => {
320        true
321    };
322    ("rmt.has_per_channel_clock") => {
323        false
324    };
325    ("sdmmc.delay_phase_num") => {
326        8
327    };
328    ("sdmmc.delay_phase_num", str) => {
329        stringify!(8)
330    };
331    ("sdmmc.has_iomux") => {
332        true
333    };
334    ("sdmmc.has_gpio_matrix") => {
335        true
336    };
337    ("sdmmc.psram_dma") => {
338        true
339    };
340    ("sdmmc.uhs") => {
341        false
342    };
343    ("usb_otg.fifo_depth_words") => {
344        200
345    };
346    ("usb_otg.fifo_depth_words", str) => {
347        stringify!(200)
348    };
349    ("usb_otg_hs.fifo_depth_words") => {
350        896
351    };
352    ("usb_otg_hs.fifo_depth_words", str) => {
353        stringify!(896)
354    };
355    ("ethernet.mii_via_gpio_matrix") => {
356        true
357    };
358    ("sdm.channel_count") => {
359        8
360    };
361    ("sdm.channel_count", str) => {
362        stringify!(8)
363    };
364    ("timergroup.timg_has_timer1") => {
365        true
366    };
367    ("timergroup.timg_has_divcnt_rst") => {
368        true
369    };
370    ("aes.has_split_text_registers") => {
371        true
372    };
373    ("aes.endianness_configurable") => {
374        false
375    };
376    ("ecc.zero_extend_writes") => {
377        false
378    };
379    ("ecc.separate_jacobian_point_memory") => {
380        true
381    };
382    ("ecc.has_memory_clock_gate") => {
383        true
384    };
385    ("ecc.supports_enhanced_security") => {
386        true
387    };
388    ("ecc.mem_block_size") => {
389        48
390    };
391    ("rng.apb_cycle_wait_num") => {
392        16
393    };
394    ("rng.apb_cycle_wait_num", str) => {
395        stringify!(16)
396    };
397    ("rng.trng_supported") => {
398        false
399    };
400    ("rng.is_lp_sys") => {
401        true
402    };
403    ("rsa.version") => {
404        3
405    };
406    ("rsa.version", str) => {
407        stringify!(3)
408    };
409    ("rsa.size_increment") => {
410        32
411    };
412    ("rsa.size_increment", str) => {
413        stringify!(32)
414    };
415    ("rsa.memory_size_bytes") => {
416        512
417    };
418    ("rsa.memory_size_bytes", str) => {
419        stringify!(512)
420    };
421    ("sleep.light_sleep") => {
422        true
423    };
424    ("sleep.deep_sleep") => {
425        true
426    };
427    ("sleep.rejectable_mask") => {
428        14845
429    };
430    ("sleep.ext1_version") => {
431        3
432    };
433    ("sleep.ext1_version", str) => {
434        stringify!(3)
435    };
436    ("sleep.pin_wakeup_version") => {
437        3
438    };
439    ("sleep.pin_wakeup_version", str) => {
440        stringify!(3)
441    };
442    ("sleep.deep_sleep_needs_gpio_isolation") => {
443        false
444    };
445    ("dma.mem2mem_requires_peripheral") => {
446        false
447    };
448    ("dma.ext_mem_configurable_block_size") => {
449        false
450    };
451    ("dma.separate_in_out_interrupts") => {
452        true
453    };
454    ("dma.gdma_version") => {
455        2
456    };
457    ("dma.gdma_version", str) => {
458        stringify!(2)
459    };
460    ("interrupts.status_registers") => {
461        5
462    };
463    ("interrupts.status_registers", str) => {
464        stringify!(5)
465    };
466    ("interrupts.disabled_interrupt") => {
467        0
468    };
469    ("mmu.page_size") => {
470        65536
471    };
472    ("mmu.page_size", str) => {
473        stringify!(65536)
474    };
475    ("mmu.entry_num") => {
476        512
477    };
478    ("mmu.entry_num", str) => {
479        stringify!(512)
480    };
481    ("psram.octal_spi") => {
482        true
483    };
484    ("psram.hex_spi") => {
485        true
486    };
487    ("psram.extmem_origin") => {
488        1207959552
489    };
490    ("psram.extmem_origin", str) => {
491        stringify!(1207959552)
492    };
493    ("rom.has_crc_le") => {
494        true
495    };
496    ("rom.has_crc_be") => {
497        true
498    };
499    ("rom.has_md5_bsd") => {
500        true
501    };
502    ("rom.has_md5_mbedtls") => {
503        false
504    };
505    ("soc.cpu_has_branch_predictor") => {
506        true
507    };
508    ("soc.cpu_has_csr_pc") => {
509        false
510    };
511    ("soc.multi_core_enabled") => {
512        true
513    };
514    ("soc.internal_memory_cached") => {
515        true
516    };
517    ("soc.has_swd_watchdog") => {
518        true
519    };
520    ("soc.cpu_mcause_mask") => {
521        63
522    };
523    ("soc.cpu_mcause_mask", str) => {
524        stringify!(63)
525    };
526    ("clock_tree.iomux_function_clock.source") => {
527        [crate ::soc::clocks::IomuxFunctionClockSource::XtalClk, crate
528        ::soc::clocks::IomuxFunctionClockSource::PllF80m]
529    };
530    ("clock_tree.iomux_function_clock.div_num") => {
531        (0, 255)
532    };
533    ("clock_tree.cpu_root_clk") => {
534        [crate ::soc::clocks::CpuRootClkConfig::Xtal, crate
535        ::soc::clocks::CpuRootClkConfig::Cpll, crate
536        ::soc::clocks::CpuRootClkConfig::RcFast]
537    };
538    ("clock_tree.cpu_clk.divisor") => {
539        (0, 255)
540    };
541    ("clock_tree.mem_clk.divisor") => {
542        (0, 255)
543    };
544    ("clock_tree.sys_clk.divisor") => {
545        (0, 255)
546    };
547    ("clock_tree.apb_clk.divisor") => {
548        (0, 255)
549    };
550    ("clock_tree.lp_fast_clk") => {
551        [crate ::soc::clocks::LpFastClkConfig::RcFast, crate
552        ::soc::clocks::LpFastClkConfig::XtalD2]
553    };
554    ("clock_tree.lp_slow_clk") => {
555        [crate ::soc::clocks::LpSlowClkConfig::RcSlow, crate
556        ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
557        ::soc::clocks::LpSlowClkConfig::OscSlow]
558    };
559    ("clock_tree.timg_calibration_clock") => {
560        [crate ::soc::clocks::TimgCalibrationClockConfig::MpllClk, crate
561        ::soc::clocks::TimgCalibrationClockConfig::SpllClk, crate
562        ::soc::clocks::TimgCalibrationClockConfig::CpllClk, crate
563        ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, crate
564        ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
565        ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
566    };
567    ("clock_tree.psram.function_clock") => {
568        [crate ::soc::clocks::PsramFunctionClockConfig::Xtal, crate
569        ::soc::clocks::PsramFunctionClockConfig::Mpll, crate
570        ::soc::clocks::PsramFunctionClockConfig::Spll, crate
571        ::soc::clocks::PsramFunctionClockConfig::Cpll]
572    };
573    ("clock_tree.uart.function_clock.sclk") => {
574        [crate ::soc::clocks::UartFunctionClockSclk::Xtal, crate
575        ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
576        ::soc::clocks::UartFunctionClockSclk::RcFast]
577    };
578    ("clock_tree.uart.function_clock.div_num") => {
579        (0, 255)
580    };
581    ("clock_tree.uart.baud_rate_generator.fractional") => {
582        (0, 15)
583    };
584    ("clock_tree.uart.baud_rate_generator.integral") => {
585        (0, 4095)
586    };
587    ("clock_tree.timg.function_clock") => {
588        [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
589        ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
590        ::soc::clocks::TimgFunctionClockConfig::PllF80m]
591    };
592    ("clock_tree.timg.wdt_clock") => {
593        [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
594        ::soc::clocks::TimgWdtClockConfig::PllF80m, crate
595        ::soc::clocks::TimgWdtClockConfig::RcFastClk]
596    };
597    ("clock_tree.i2c.function_clock.sclk") => {
598        [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
599        ::soc::clocks::I2cFunctionClockSclk::RcFast]
600    };
601    ("clock_tree.i2c.function_clock.div_num") => {
602        (0, 255)
603    };
604    ("clock_tree.rmt.sclk") => {
605        [crate ::soc::clocks::RmtSclkConfig::PllF80m, crate
606        ::soc::clocks::RmtSclkConfig::RcFastClk, crate
607        ::soc::clocks::RmtSclkConfig::XtalClk]
608    };
609    ("clock_tree.spi.function_clock") => {
610        [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
611        ::soc::clocks::SpiFunctionClockConfig::RcFast, crate
612        ::soc::clocks::SpiFunctionClockConfig::Spll]
613    };
614    ("clock_tree.mipi_dsi.dpi_clk.sclk") => {
615        [crate ::soc::clocks::MipiDsiDpiClkSclk::Xtal, crate
616        ::soc::clocks::MipiDsiDpiClkSclk::PllF240m, crate
617        ::soc::clocks::MipiDsiDpiClkSclk::PllF160m]
618    };
619    ("clock_tree.mipi_dsi.dpi_clk.div_num") => {
620        (0, 255)
621    };
622    ("clock_tree.mipi_dsi.phy_pll_refclk.sclk") => {
623        [crate ::soc::clocks::MipiDsiPhyPllRefclkSclk::Xtal, crate
624        ::soc::clocks::MipiDsiPhyPllRefclkSclk::Cpll, crate
625        ::soc::clocks::MipiDsiPhyPllRefclkSclk::Spll, crate
626        ::soc::clocks::MipiDsiPhyPllRefclkSclk::Mpll]
627    };
628    ("clock_tree.mipi_dsi.phy_pll_refclk.div_num") => {
629        (0, 255)
630    };
631    ("clock_tree.mipi_dsi.phy_cfg_clk") => {
632        [crate ::soc::clocks::MipiDsiPhyCfgClkConfig::PllF20m, crate
633        ::soc::clocks::MipiDsiPhyCfgClkConfig::RcFast, crate
634        ::soc::clocks::MipiDsiPhyCfgClkConfig::PllF25m]
635    };
636}
637#[macro_export]
638#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
639macro_rules! for_each_dedicated_gpio {
640    ($($pattern:tt => $code:tt;)*) => {
641        macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
642        tt) => {} } _for_each_inner_dedicated_gpio!((0));
643        _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
644        _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
645        _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
646        _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
647        CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
648        _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
649        _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
650        _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
651        _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
652        _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
653        _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
654        _for_each_inner_dedicated_gpio!((1, 0, CPU_GPIO_8));
655        _for_each_inner_dedicated_gpio!((1, 1, CPU_GPIO_9));
656        _for_each_inner_dedicated_gpio!((1, 2, CPU_GPIO_10));
657        _for_each_inner_dedicated_gpio!((1, 3, CPU_GPIO_11));
658        _for_each_inner_dedicated_gpio!((1, 4, CPU_GPIO_12));
659        _for_each_inner_dedicated_gpio!((1, 5, CPU_GPIO_13));
660        _for_each_inner_dedicated_gpio!((1, 6, CPU_GPIO_14));
661        _for_each_inner_dedicated_gpio!((1, 7, CPU_GPIO_15));
662        _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
663        (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
664        CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
665        CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7), (1, 0, CPU_GPIO_8), (1, 1,
666        CPU_GPIO_9), (1, 2, CPU_GPIO_10), (1, 3, CPU_GPIO_11), (1, 4, CPU_GPIO_12), (1,
667        5, CPU_GPIO_13), (1, 6, CPU_GPIO_14), (1, 7, CPU_GPIO_15)));
668    };
669}
670/// Defines the `LpInputSignal` and `LpOutputSignal` enums.
671///
672/// This macro is intended to be called in esp-hal only.
673#[macro_export]
674#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
675macro_rules! define_lp_io_signals {
676    () => {
677        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
678        #[derive(Debug, PartialEq, Copy, Clone)]
679        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
680        #[doc(hidden)]
681        pub enum LpInputSignal {
682            LP_I2C_SCL   = 0,
683            LP_I2C_SDA   = 1,
684            LP_UART_RXD  = 2,
685            LP_UART_CTSN = 3,
686            LP_UART_DSRN = 4,
687            LP_SPI_CK    = 5,
688            LP_SPI_CS    = 6,
689            LP_SPI_D     = 7,
690            LP_SPI_Q     = 8,
691            LP_I2S_I_BCK = 9,
692            LP_I2S_I_SD  = 10,
693            LP_I2S_I_WS  = 11,
694            LP_I2S_O_BCK = 12,
695            LP_I2S_O_WS  = 13,
696        }
697        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
698        #[derive(Debug, PartialEq, Copy, Clone)]
699        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
700        #[doc(hidden)]
701        pub enum LpOutputSignal {
702            LP_I2C_SCL   = 0,
703            LP_I2C_SDA   = 1,
704            LP_UART_TXD  = 2,
705            LP_UART_RTSN = 3,
706            LP_UART_DTRN = 4,
707            LP_SPI_CK    = 5,
708            LP_SPI_CS    = 6,
709            LP_SPI_D     = 7,
710            LP_SPI_Q     = 8,
711            LP_I2S_I_BCK = 9,
712            LP_I2S_O_SD  = 10,
713            LP_I2S_I_WS  = 11,
714            LP_I2S_O_BCK = 12,
715            LP_I2S_O_WS  = 13,
716        }
717    };
718}
719/// This macro can be used to generate code for each channel of the RMT peripheral.
720///
721/// For an explanation on the general syntax, as well as usage of individual/repeated
722/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
723///
724/// This macro has three options for its "Individual matcher" case:
725///
726/// - `all`: `($num:literal)`
727/// - `tx`: `($num:literal, $idx:literal)`
728/// - `rx`: `($num:literal, $idx:literal)`
729///
730/// Macro fragments:
731///
732/// - `$num`: number of the channel, e.g. `0`
733/// - `$idx`: index of the channel among channels of the same capability, e.g. `0`
734///
735/// Example data:
736///
737/// - `all`: `(0)`
738/// - `tx`: `(1, 1)`
739/// - `rx`: `(2, 0)`
740#[macro_export]
741#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
742macro_rules! for_each_rmt_channel {
743    ($($pattern:tt => $code:tt;)*) => {
744        macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
745        => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
746        _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
747        _for_each_inner_rmt_channel!((4)); _for_each_inner_rmt_channel!((5));
748        _for_each_inner_rmt_channel!((6)); _for_each_inner_rmt_channel!((7));
749        _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
750        _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
751        _for_each_inner_rmt_channel!((4, 0)); _for_each_inner_rmt_channel!((5, 1));
752        _for_each_inner_rmt_channel!((6, 2)); _for_each_inner_rmt_channel!((7, 3));
753        _for_each_inner_rmt_channel!((all(0), (1), (2), (3), (4), (5), (6), (7)));
754        _for_each_inner_rmt_channel!((tx(0, 0), (1, 1), (2, 2), (3, 3)));
755        _for_each_inner_rmt_channel!((rx(4, 0), (5, 1), (6, 2), (7, 3)));
756    };
757}
758/// This macro can be used to generate code for each slot of the SDMMC/SDIO host driver.
759///
760/// For an explanation on the general syntax, as well as usage of individual/repeated
761/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
762///
763/// This macro has one option for its "Individual matcher" case:
764///
765/// Syntax: `($slot:ident, $idx:literal, $iomux:literal, [$($clk:ident)?]
766/// [$($cmd_in:ident)?] [$($cmd_out:ident)?] [$($data_in:ident),*] [$($data_out:ident),*]
767/// [$($cd:ident)?] [$($wp:ident)?] [$($card_int:ident)?] [$($data_strobe:ident)?]
768/// [$($rst:ident)?])`
769///
770/// Macro fragments:
771///
772/// - `$slot`: the name of the slot (`slot0`, `slot1`).
773/// - `$idx`: the zero-based slot index.
774/// - `$iomux`: `true` if the slot's clock/command/data signals are IO_MUX-routed.
775/// - `$clk`, `$cmd_in`, `$cmd_out`, `$data_in`, `$data_out`: GPIO-matrix bus signal names (absent
776///   for IO_MUX-routed slots).
777/// - `$cd`, `$wp`, `$card_int`, `$data_strobe`, `$rst`: auxiliary signal names, each present only
778///   when the slot routes that signal through the GPIO matrix.
779///
780/// Each optional signal is wrapped in brackets so the branch shape stays uniform: a set
781/// signal appears as `[SIGNAL]`, an absent one as `[]`.
782#[macro_export]
783#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
784macro_rules! for_each_sdmmc {
785    ($($pattern:tt => $code:tt;)*) => {
786        macro_rules! _for_each_inner_sdmmc { $(($pattern) => $code;)* ($other : tt) => {}
787        } _for_each_inner_sdmmc!((slot0, 0, true, [], [], [], [], [],
788        [SDHOST_CARD_DETECT_N_1], [SDHOST_CARD_WRITE_PRT_1], [SDHOST_CARD_INT_N_1],
789        [SDHOST_DATA_STROBE_1], [SD_RST_N_1])); _for_each_inner_sdmmc!((slot1, 1, false,
790        [SDHOST_CCLK_OUT_2], [SDHOST_CCMD_IN_2], [SDHOST_CCMD_OUT_2],
791        [SDHOST_CDATA_IN_20, SDHOST_CDATA_IN_21, SDHOST_CDATA_IN_22, SDHOST_CDATA_IN_23,
792        SDHOST_CDATA_IN_24, SDHOST_CDATA_IN_25, SDHOST_CDATA_IN_26, SDHOST_CDATA_IN_27],
793        [SDHOST_CDATA_OUT_20, SDHOST_CDATA_OUT_21, SDHOST_CDATA_OUT_22,
794        SDHOST_CDATA_OUT_23, SDHOST_CDATA_OUT_24, SDHOST_CDATA_OUT_25,
795        SDHOST_CDATA_OUT_26, SDHOST_CDATA_OUT_27], [SDHOST_CARD_DETECT_N_2],
796        [SDHOST_CARD_WRITE_PRT_2], [SDHOST_CARD_INT_N_2], [SDHOST_DATA_STROBE_2],
797        [SD_RST_N_2])); _for_each_inner_sdmmc!((all(slot0, 0, true, [], [], [], [], [],
798        [SDHOST_CARD_DETECT_N_1], [SDHOST_CARD_WRITE_PRT_1], [SDHOST_CARD_INT_N_1],
799        [SDHOST_DATA_STROBE_1], [SD_RST_N_1]), (slot1, 1, false, [SDHOST_CCLK_OUT_2],
800        [SDHOST_CCMD_IN_2], [SDHOST_CCMD_OUT_2], [SDHOST_CDATA_IN_20, SDHOST_CDATA_IN_21,
801        SDHOST_CDATA_IN_22, SDHOST_CDATA_IN_23, SDHOST_CDATA_IN_24, SDHOST_CDATA_IN_25,
802        SDHOST_CDATA_IN_26, SDHOST_CDATA_IN_27], [SDHOST_CDATA_OUT_20,
803        SDHOST_CDATA_OUT_21, SDHOST_CDATA_OUT_22, SDHOST_CDATA_OUT_23,
804        SDHOST_CDATA_OUT_24, SDHOST_CDATA_OUT_25, SDHOST_CDATA_OUT_26,
805        SDHOST_CDATA_OUT_27], [SDHOST_CARD_DETECT_N_2], [SDHOST_CARD_WRITE_PRT_2],
806        [SDHOST_CARD_INT_N_2], [SDHOST_DATA_STROBE_2], [SD_RST_N_2])));
807    };
808}
809#[macro_export]
810#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
811macro_rules! for_each_sdm_channel {
812    ($($pattern:tt => $code:tt;)*) => {
813        macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
814        => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
815        _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
816        _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
817        _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
818        _for_each_inner_sdm_channel!((4, SDM_CH4, SdmCh4, GPIO_SD4));
819        _for_each_inner_sdm_channel!((5, SDM_CH5, SdmCh5, GPIO_SD5));
820        _for_each_inner_sdm_channel!((6, SDM_CH6, SdmCh6, GPIO_SD6));
821        _for_each_inner_sdm_channel!((7, SDM_CH7, SdmCh7, GPIO_SD7));
822        _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
823        SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
824        GPIO_SD3), (4, SDM_CH4, SdmCh4, GPIO_SD4), (5, SDM_CH5, SdmCh5, GPIO_SD5), (6,
825        SDM_CH6, SdmCh6, GPIO_SD6), (7, SDM_CH7, SdmCh7, GPIO_SD7)));
826    };
827}
828#[macro_export]
829#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
830macro_rules! for_each_aes_key_length {
831    ($($pattern:tt => $code:tt;)*) => {
832        macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
833        tt) => {} } _for_each_inner_aes_key_length!((128));
834        _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
835        4)); _for_each_inner_aes_key_length!((256, 2, 6));
836        _for_each_inner_aes_key_length!((bits(128), (256)));
837        _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
838    };
839}
840#[macro_export]
841#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
842macro_rules! for_each_ecc_working_mode {
843    ($($pattern:tt => $code:tt;)*) => {
844        macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
845        : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
846        _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
847        _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
848        _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
849        _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
850        _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
851        _for_each_inner_ecc_working_mode!((7,
852        AffinePointVerificationAndJacobianPointMultiplication));
853        _for_each_inner_ecc_working_mode!((8, ModularAddition));
854        _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
855        _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
856        _for_each_inner_ecc_working_mode!((11, ModularDivision));
857        _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
858        AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
859        JacobianPointMultiplication), (5, AffinePointAddition), (6,
860        JacobianPointVerification), (7,
861        AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
862        ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
863    };
864}
865#[macro_export]
866#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
867macro_rules! for_each_ecc_curve {
868    ($($pattern:tt => $code:tt;)*) => {
869        macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
870        => {} } _for_each_inner_ecc_curve!((0, P192, 192));
871        _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((2, P384,
872        384)); _for_each_inner_ecc_curve!((all(0, P192, 192), (1, P256, 256), (2, P384,
873        384)));
874    };
875}
876#[macro_export]
877#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
878macro_rules! for_each_rsa_exponentiation {
879    ($($pattern:tt => $code:tt;)*) => {
880        macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
881        ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
882        _for_each_inner_rsa_exponentiation!((64));
883        _for_each_inner_rsa_exponentiation!((96));
884        _for_each_inner_rsa_exponentiation!((128));
885        _for_each_inner_rsa_exponentiation!((160));
886        _for_each_inner_rsa_exponentiation!((192));
887        _for_each_inner_rsa_exponentiation!((224));
888        _for_each_inner_rsa_exponentiation!((256));
889        _for_each_inner_rsa_exponentiation!((288));
890        _for_each_inner_rsa_exponentiation!((320));
891        _for_each_inner_rsa_exponentiation!((352));
892        _for_each_inner_rsa_exponentiation!((384));
893        _for_each_inner_rsa_exponentiation!((416));
894        _for_each_inner_rsa_exponentiation!((448));
895        _for_each_inner_rsa_exponentiation!((480));
896        _for_each_inner_rsa_exponentiation!((512));
897        _for_each_inner_rsa_exponentiation!((544));
898        _for_each_inner_rsa_exponentiation!((576));
899        _for_each_inner_rsa_exponentiation!((608));
900        _for_each_inner_rsa_exponentiation!((640));
901        _for_each_inner_rsa_exponentiation!((672));
902        _for_each_inner_rsa_exponentiation!((704));
903        _for_each_inner_rsa_exponentiation!((736));
904        _for_each_inner_rsa_exponentiation!((768));
905        _for_each_inner_rsa_exponentiation!((800));
906        _for_each_inner_rsa_exponentiation!((832));
907        _for_each_inner_rsa_exponentiation!((864));
908        _for_each_inner_rsa_exponentiation!((896));
909        _for_each_inner_rsa_exponentiation!((928));
910        _for_each_inner_rsa_exponentiation!((960));
911        _for_each_inner_rsa_exponentiation!((992));
912        _for_each_inner_rsa_exponentiation!((1024));
913        _for_each_inner_rsa_exponentiation!((1056));
914        _for_each_inner_rsa_exponentiation!((1088));
915        _for_each_inner_rsa_exponentiation!((1120));
916        _for_each_inner_rsa_exponentiation!((1152));
917        _for_each_inner_rsa_exponentiation!((1184));
918        _for_each_inner_rsa_exponentiation!((1216));
919        _for_each_inner_rsa_exponentiation!((1248));
920        _for_each_inner_rsa_exponentiation!((1280));
921        _for_each_inner_rsa_exponentiation!((1312));
922        _for_each_inner_rsa_exponentiation!((1344));
923        _for_each_inner_rsa_exponentiation!((1376));
924        _for_each_inner_rsa_exponentiation!((1408));
925        _for_each_inner_rsa_exponentiation!((1440));
926        _for_each_inner_rsa_exponentiation!((1472));
927        _for_each_inner_rsa_exponentiation!((1504));
928        _for_each_inner_rsa_exponentiation!((1536));
929        _for_each_inner_rsa_exponentiation!((1568));
930        _for_each_inner_rsa_exponentiation!((1600));
931        _for_each_inner_rsa_exponentiation!((1632));
932        _for_each_inner_rsa_exponentiation!((1664));
933        _for_each_inner_rsa_exponentiation!((1696));
934        _for_each_inner_rsa_exponentiation!((1728));
935        _for_each_inner_rsa_exponentiation!((1760));
936        _for_each_inner_rsa_exponentiation!((1792));
937        _for_each_inner_rsa_exponentiation!((1824));
938        _for_each_inner_rsa_exponentiation!((1856));
939        _for_each_inner_rsa_exponentiation!((1888));
940        _for_each_inner_rsa_exponentiation!((1920));
941        _for_each_inner_rsa_exponentiation!((1952));
942        _for_each_inner_rsa_exponentiation!((1984));
943        _for_each_inner_rsa_exponentiation!((2016));
944        _for_each_inner_rsa_exponentiation!((2048));
945        _for_each_inner_rsa_exponentiation!((2080));
946        _for_each_inner_rsa_exponentiation!((2112));
947        _for_each_inner_rsa_exponentiation!((2144));
948        _for_each_inner_rsa_exponentiation!((2176));
949        _for_each_inner_rsa_exponentiation!((2208));
950        _for_each_inner_rsa_exponentiation!((2240));
951        _for_each_inner_rsa_exponentiation!((2272));
952        _for_each_inner_rsa_exponentiation!((2304));
953        _for_each_inner_rsa_exponentiation!((2336));
954        _for_each_inner_rsa_exponentiation!((2368));
955        _for_each_inner_rsa_exponentiation!((2400));
956        _for_each_inner_rsa_exponentiation!((2432));
957        _for_each_inner_rsa_exponentiation!((2464));
958        _for_each_inner_rsa_exponentiation!((2496));
959        _for_each_inner_rsa_exponentiation!((2528));
960        _for_each_inner_rsa_exponentiation!((2560));
961        _for_each_inner_rsa_exponentiation!((2592));
962        _for_each_inner_rsa_exponentiation!((2624));
963        _for_each_inner_rsa_exponentiation!((2656));
964        _for_each_inner_rsa_exponentiation!((2688));
965        _for_each_inner_rsa_exponentiation!((2720));
966        _for_each_inner_rsa_exponentiation!((2752));
967        _for_each_inner_rsa_exponentiation!((2784));
968        _for_each_inner_rsa_exponentiation!((2816));
969        _for_each_inner_rsa_exponentiation!((2848));
970        _for_each_inner_rsa_exponentiation!((2880));
971        _for_each_inner_rsa_exponentiation!((2912));
972        _for_each_inner_rsa_exponentiation!((2944));
973        _for_each_inner_rsa_exponentiation!((2976));
974        _for_each_inner_rsa_exponentiation!((3008));
975        _for_each_inner_rsa_exponentiation!((3040));
976        _for_each_inner_rsa_exponentiation!((3072));
977        _for_each_inner_rsa_exponentiation!((3104));
978        _for_each_inner_rsa_exponentiation!((3136));
979        _for_each_inner_rsa_exponentiation!((3168));
980        _for_each_inner_rsa_exponentiation!((3200));
981        _for_each_inner_rsa_exponentiation!((3232));
982        _for_each_inner_rsa_exponentiation!((3264));
983        _for_each_inner_rsa_exponentiation!((3296));
984        _for_each_inner_rsa_exponentiation!((3328));
985        _for_each_inner_rsa_exponentiation!((3360));
986        _for_each_inner_rsa_exponentiation!((3392));
987        _for_each_inner_rsa_exponentiation!((3424));
988        _for_each_inner_rsa_exponentiation!((3456));
989        _for_each_inner_rsa_exponentiation!((3488));
990        _for_each_inner_rsa_exponentiation!((3520));
991        _for_each_inner_rsa_exponentiation!((3552));
992        _for_each_inner_rsa_exponentiation!((3584));
993        _for_each_inner_rsa_exponentiation!((3616));
994        _for_each_inner_rsa_exponentiation!((3648));
995        _for_each_inner_rsa_exponentiation!((3680));
996        _for_each_inner_rsa_exponentiation!((3712));
997        _for_each_inner_rsa_exponentiation!((3744));
998        _for_each_inner_rsa_exponentiation!((3776));
999        _for_each_inner_rsa_exponentiation!((3808));
1000        _for_each_inner_rsa_exponentiation!((3840));
1001        _for_each_inner_rsa_exponentiation!((3872));
1002        _for_each_inner_rsa_exponentiation!((3904));
1003        _for_each_inner_rsa_exponentiation!((3936));
1004        _for_each_inner_rsa_exponentiation!((3968));
1005        _for_each_inner_rsa_exponentiation!((4000));
1006        _for_each_inner_rsa_exponentiation!((4032));
1007        _for_each_inner_rsa_exponentiation!((4064));
1008        _for_each_inner_rsa_exponentiation!((4096));
1009        _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
1010        (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1011        (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1012        (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1013        (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
1014        (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
1015        (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
1016        (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
1017        (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
1018        (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072), (3104), (3136),
1019        (3168), (3200), (3232), (3264), (3296), (3328), (3360), (3392), (3424), (3456),
1020        (3488), (3520), (3552), (3584), (3616), (3648), (3680), (3712), (3744), (3776),
1021        (3808), (3840), (3872), (3904), (3936), (3968), (4000), (4032), (4064), (4096)));
1022    };
1023}
1024#[macro_export]
1025#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1026macro_rules! for_each_rsa_multiplication {
1027    ($($pattern:tt => $code:tt;)*) => {
1028        macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
1029        ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
1030        _for_each_inner_rsa_multiplication!((64));
1031        _for_each_inner_rsa_multiplication!((96));
1032        _for_each_inner_rsa_multiplication!((128));
1033        _for_each_inner_rsa_multiplication!((160));
1034        _for_each_inner_rsa_multiplication!((192));
1035        _for_each_inner_rsa_multiplication!((224));
1036        _for_each_inner_rsa_multiplication!((256));
1037        _for_each_inner_rsa_multiplication!((288));
1038        _for_each_inner_rsa_multiplication!((320));
1039        _for_each_inner_rsa_multiplication!((352));
1040        _for_each_inner_rsa_multiplication!((384));
1041        _for_each_inner_rsa_multiplication!((416));
1042        _for_each_inner_rsa_multiplication!((448));
1043        _for_each_inner_rsa_multiplication!((480));
1044        _for_each_inner_rsa_multiplication!((512));
1045        _for_each_inner_rsa_multiplication!((544));
1046        _for_each_inner_rsa_multiplication!((576));
1047        _for_each_inner_rsa_multiplication!((608));
1048        _for_each_inner_rsa_multiplication!((640));
1049        _for_each_inner_rsa_multiplication!((672));
1050        _for_each_inner_rsa_multiplication!((704));
1051        _for_each_inner_rsa_multiplication!((736));
1052        _for_each_inner_rsa_multiplication!((768));
1053        _for_each_inner_rsa_multiplication!((800));
1054        _for_each_inner_rsa_multiplication!((832));
1055        _for_each_inner_rsa_multiplication!((864));
1056        _for_each_inner_rsa_multiplication!((896));
1057        _for_each_inner_rsa_multiplication!((928));
1058        _for_each_inner_rsa_multiplication!((960));
1059        _for_each_inner_rsa_multiplication!((992));
1060        _for_each_inner_rsa_multiplication!((1024));
1061        _for_each_inner_rsa_multiplication!((1056));
1062        _for_each_inner_rsa_multiplication!((1088));
1063        _for_each_inner_rsa_multiplication!((1120));
1064        _for_each_inner_rsa_multiplication!((1152));
1065        _for_each_inner_rsa_multiplication!((1184));
1066        _for_each_inner_rsa_multiplication!((1216));
1067        _for_each_inner_rsa_multiplication!((1248));
1068        _for_each_inner_rsa_multiplication!((1280));
1069        _for_each_inner_rsa_multiplication!((1312));
1070        _for_each_inner_rsa_multiplication!((1344));
1071        _for_each_inner_rsa_multiplication!((1376));
1072        _for_each_inner_rsa_multiplication!((1408));
1073        _for_each_inner_rsa_multiplication!((1440));
1074        _for_each_inner_rsa_multiplication!((1472));
1075        _for_each_inner_rsa_multiplication!((1504));
1076        _for_each_inner_rsa_multiplication!((1536));
1077        _for_each_inner_rsa_multiplication!((1568));
1078        _for_each_inner_rsa_multiplication!((1600));
1079        _for_each_inner_rsa_multiplication!((1632));
1080        _for_each_inner_rsa_multiplication!((1664));
1081        _for_each_inner_rsa_multiplication!((1696));
1082        _for_each_inner_rsa_multiplication!((1728));
1083        _for_each_inner_rsa_multiplication!((1760));
1084        _for_each_inner_rsa_multiplication!((1792));
1085        _for_each_inner_rsa_multiplication!((1824));
1086        _for_each_inner_rsa_multiplication!((1856));
1087        _for_each_inner_rsa_multiplication!((1888));
1088        _for_each_inner_rsa_multiplication!((1920));
1089        _for_each_inner_rsa_multiplication!((1952));
1090        _for_each_inner_rsa_multiplication!((1984));
1091        _for_each_inner_rsa_multiplication!((2016));
1092        _for_each_inner_rsa_multiplication!((2048));
1093        _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
1094        (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1095        (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1096        (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1097        (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
1098        (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
1099        (1888), (1920), (1952), (1984), (2016), (2048)));
1100    };
1101}
1102#[macro_export]
1103#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1104macro_rules! for_each_sha_algorithm {
1105    ($($pattern:tt => $code:tt;)*) => {
1106        macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
1107        tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
1108        (insecure_against : "collision", "length extension"), 0));
1109        _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
1110        (insecure_against : "length extension"), 1));
1111        _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
1112        (insecure_against : "length extension"), 2));
1113        _for_each_inner_sha_algorithm!((Sha384, "SHA-384"(sizes : 128, 48, 16)
1114        (insecure_against :), 3)); _for_each_inner_sha_algorithm!((Sha512,
1115        "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 4));
1116        _for_each_inner_sha_algorithm!((Sha512_224, "SHA-512/224"(sizes : 128, 28, 16)
1117        (insecure_against :), 5)); _for_each_inner_sha_algorithm!((Sha512_256,
1118        "SHA-512/256"(sizes : 128, 32, 16) (insecure_against :), 6));
1119        _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
1120        (insecure_against : "collision", "length extension"), 0), (Sha224,
1121        "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
1122        (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
1123        2), (Sha384, "SHA-384"(sizes : 128, 48, 16) (insecure_against :), 3), (Sha512,
1124        "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 4),
1125        (Sha512_224, "SHA-512/224"(sizes : 128, 28, 16) (insecure_against :), 5),
1126        (Sha512_256, "SHA-512/256"(sizes : 128, 32, 16) (insecure_against :), 6)));
1127    };
1128}
1129#[macro_export]
1130#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1131macro_rules! for_each_wakeup_source {
1132    ($($pattern:tt => $code:tt;)*) => {
1133        macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
1134        tt) => {} } _for_each_inner_wakeup_source!((Sdio, 0));
1135        _for_each_inner_wakeup_source!((Gpio, 2)); _for_each_inner_wakeup_source!((Usb,
1136        3)); _for_each_inner_wakeup_source!((Uart4, 4));
1137        _for_each_inner_wakeup_source!((Uart3, 5));
1138        _for_each_inner_wakeup_source!((Uart2, 6));
1139        _for_each_inner_wakeup_source!((Uart1, 7));
1140        _for_each_inner_wakeup_source!((Uart0, 8));
1141        _for_each_inner_wakeup_source!((Touch, 11));
1142        _for_each_inner_wakeup_source!((Ext1, 12));
1143        _for_each_inner_wakeup_source!((Timer, 13));
1144        _for_each_inner_wakeup_source!((all(Sdio, 0), (Gpio, 2), (Usb, 3), (Uart4, 4),
1145        (Uart3, 5), (Uart2, 6), (Uart1, 7), (Uart0, 8), (Touch, 11), (Ext1, 12), (Timer,
1146        13)));
1147    };
1148}
1149#[macro_export]
1150#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1151macro_rules! for_each_dma_engine {
1152    ($($pattern:tt => $code:tt;)*) => {
1153        macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
1154        => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
1155        _for_each_inner_dma_engine!(("AXI_GDMA")); _for_each_inner_dma_engine!(("VDMA"));
1156        _for_each_inner_dma_engine!((all("AHB_GDMA"), ("AXI_GDMA"), ("VDMA")));
1157    };
1158}
1159#[macro_export]
1160#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1161macro_rules! for_each_dma_channel {
1162    ($($pattern:tt => $code:tt;)*) => {
1163        macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
1164        => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
1165        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
1166        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
1167        _for_each_inner_dma_channel!(("AXI_GDMA", DMA_AXI_CH0));
1168        _for_each_inner_dma_channel!(("AXI_GDMA", DMA_AXI_CH1));
1169        _for_each_inner_dma_channel!(("AXI_GDMA", DMA_AXI_CH2));
1170        _for_each_inner_dma_channel!(("VDMA", VDMA_CH0));
1171        _for_each_inner_dma_channel!(("VDMA", VDMA_CH1));
1172        _for_each_inner_dma_channel!(("VDMA", VDMA_CH2));
1173        _for_each_inner_dma_channel!(("VDMA", VDMA_CH3));
1174        _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
1175        _for_each_inner_dma_channel!(("AXI_GDMA", any_channel = AxiGdmaChannel));
1176        _for_each_inner_dma_channel!(("VDMA", any_channel = VdmaChannel));
1177        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1178        AHB_PDMA_IN_CH0, interrupt_out = AHB_PDMA_OUT_CH0, compatible = [UHCI0, I2S0,
1179        I2S1, I2S2])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt_in
1180        = AHB_PDMA_IN_CH1, interrupt_out = AHB_PDMA_OUT_CH1, compatible = [UHCI0, I2S0,
1181        I2S1, I2S2])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in
1182        = AHB_PDMA_IN_CH2, interrupt_out = AHB_PDMA_OUT_CH2, compatible = [UHCI0, I2S0,
1183        I2S1, I2S2])); _for_each_inner_dma_channel!(("AXI_GDMA", DMA_AXI_CH0, 0,
1184        interrupt_in = AXI_PDMA_IN_CH0, interrupt_out = AXI_PDMA_OUT_CH0, compatible =
1185        [SPI2, SPI3, AES, SHA])); _for_each_inner_dma_channel!(("AXI_GDMA", DMA_AXI_CH1,
1186        1, interrupt_in = AXI_PDMA_IN_CH1, interrupt_out = AXI_PDMA_OUT_CH1, compatible =
1187        [SPI2, SPI3, AES, SHA])); _for_each_inner_dma_channel!(("AXI_GDMA", DMA_AXI_CH2,
1188        2, interrupt_in = AXI_PDMA_IN_CH2, interrupt_out = AXI_PDMA_OUT_CH2, compatible =
1189        [SPI2, SPI3, AES, SHA])); _for_each_inner_dma_channel!(("VDMA", VDMA_CH0, 0,
1190        compatible = [])); _for_each_inner_dma_channel!(("VDMA", VDMA_CH1, 1, compatible
1191        = [])); _for_each_inner_dma_channel!(("VDMA", VDMA_CH2, 2, compatible = []));
1192        _for_each_inner_dma_channel!(("VDMA", VDMA_CH3, 3, compatible = []));
1193        _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0), ("AHB_GDMA", DMA_CH1),
1194        ("AHB_GDMA", DMA_CH2), ("AXI_GDMA", DMA_AXI_CH0), ("AXI_GDMA", DMA_AXI_CH1),
1195        ("AXI_GDMA", DMA_AXI_CH2), ("VDMA", VDMA_CH0), ("VDMA", VDMA_CH1), ("VDMA",
1196        VDMA_CH2), ("VDMA", VDMA_CH3)));
1197        _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
1198        AhbGdmaChannel), ("AXI_GDMA", any_channel = AxiGdmaChannel), ("VDMA", any_channel
1199        = VdmaChannel))); _for_each_inner_dma_channel!((shared));
1200        _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1201        AHB_PDMA_IN_CH0, interrupt_out = AHB_PDMA_OUT_CH0, compatible = [UHCI0, I2S0,
1202        I2S1, I2S2]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = AHB_PDMA_IN_CH1,
1203        interrupt_out = AHB_PDMA_OUT_CH1, compatible = [UHCI0, I2S0, I2S1, I2S2]),
1204        ("AHB_GDMA", DMA_CH2, 2, interrupt_in = AHB_PDMA_IN_CH2, interrupt_out =
1205        AHB_PDMA_OUT_CH2, compatible = [UHCI0, I2S0, I2S1, I2S2]), ("AXI_GDMA",
1206        DMA_AXI_CH0, 0, interrupt_in = AXI_PDMA_IN_CH0, interrupt_out = AXI_PDMA_OUT_CH0,
1207        compatible = [SPI2, SPI3, AES, SHA]), ("AXI_GDMA", DMA_AXI_CH1, 1, interrupt_in =
1208        AXI_PDMA_IN_CH1, interrupt_out = AXI_PDMA_OUT_CH1, compatible = [SPI2, SPI3, AES,
1209        SHA]), ("AXI_GDMA", DMA_AXI_CH2, 2, interrupt_in = AXI_PDMA_IN_CH2, interrupt_out
1210        = AXI_PDMA_OUT_CH2, compatible = [SPI2, SPI3, AES, SHA])));
1211        _for_each_inner_dma_channel!((no_own_interrupt("VDMA", VDMA_CH0, 0, compatible =
1212        []), ("VDMA", VDMA_CH1, 1, compatible = []), ("VDMA", VDMA_CH2, 2, compatible =
1213        []), ("VDMA", VDMA_CH3, 3, compatible = [])));
1214    };
1215}
1216#[macro_export]
1217#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1218macro_rules! for_each_dma_channel_peri_pair {
1219    ($($pattern:tt => $code:tt;)*) => {
1220        macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1221        ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1222        DMA_CH0, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
1223        I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S1));
1224        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S2));
1225        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
1226        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
1227        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S1));
1228        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S2));
1229        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
1230        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
1231        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S1));
1232        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S2));
1233        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH0, SPI2));
1234        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH0, SPI3));
1235        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH0, AES));
1236        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH0, SHA));
1237        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH1, SPI2));
1238        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH1, SPI3));
1239        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH1, AES));
1240        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH1, SHA));
1241        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH2, SPI2));
1242        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH2, SPI3));
1243        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH2, AES));
1244        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", DMA_AXI_CH2, SHA));
1245        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1246        UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1247        AhbGdmaChannel, I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1248        any_channel = AhbGdmaChannel, I2S1));
1249        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1250        I2S2)); _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", any_channel =
1251        AxiGdmaChannel, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA",
1252        any_channel = AxiGdmaChannel, SPI3));
1253        _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", any_channel = AxiGdmaChannel,
1254        AES)); _for_each_inner_dma_channel_peri_pair!(("AXI_GDMA", any_channel =
1255        AxiGdmaChannel, SHA));
1256        _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0, UHCI0),
1257        ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0, I2S1), ("AHB_GDMA", DMA_CH0,
1258        I2S2), ("AHB_GDMA", DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA",
1259        DMA_CH1, I2S1), ("AHB_GDMA", DMA_CH1, I2S2), ("AHB_GDMA", DMA_CH2, UHCI0),
1260        ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, I2S1), ("AHB_GDMA", DMA_CH2,
1261        I2S2), ("AXI_GDMA", DMA_AXI_CH0, SPI2), ("AXI_GDMA", DMA_AXI_CH0, SPI3),
1262        ("AXI_GDMA", DMA_AXI_CH0, AES), ("AXI_GDMA", DMA_AXI_CH0, SHA), ("AXI_GDMA",
1263        DMA_AXI_CH1, SPI2), ("AXI_GDMA", DMA_AXI_CH1, SPI3), ("AXI_GDMA", DMA_AXI_CH1,
1264        AES), ("AXI_GDMA", DMA_AXI_CH1, SHA), ("AXI_GDMA", DMA_AXI_CH2, SPI2),
1265        ("AXI_GDMA", DMA_AXI_CH2, SPI3), ("AXI_GDMA", DMA_AXI_CH2, AES), ("AXI_GDMA",
1266        DMA_AXI_CH2, SHA)));
1267        _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1268        AhbGdmaChannel, UHCI0), ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0),
1269        ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S1), ("AHB_GDMA", any_channel =
1270        AhbGdmaChannel, I2S2), ("AXI_GDMA", any_channel = AxiGdmaChannel, SPI2),
1271        ("AXI_GDMA", any_channel = AxiGdmaChannel, SPI3), ("AXI_GDMA", any_channel =
1272        AxiGdmaChannel, AES), ("AXI_GDMA", any_channel = AxiGdmaChannel, SHA)));
1273    };
1274}
1275#[macro_export]
1276#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1277macro_rules! for_each_mem2mem_channel {
1278    ($($pattern:tt => $code:tt;)*) => {
1279        macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1280        tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1281        AhbGdmaChannel, DMA_CH1, 11)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1282        AhbGdma, AhbGdmaChannel, DMA_CH2, 12));
1283        _for_each_inner_mem2mem_channel!(("AXI_GDMA", AxiGdma, AxiGdmaChannel,
1284        DMA_AXI_CH0, 6)); _for_each_inner_mem2mem_channel!(("AXI_GDMA", AxiGdma,
1285        AxiGdmaChannel, DMA_AXI_CH1, 7)); _for_each_inner_mem2mem_channel!(("AXI_GDMA",
1286        AxiGdma, AxiGdmaChannel, DMA_AXI_CH2, 8));
1287        _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 1, 11, 2,
1288        12)); _for_each_inner_mem2mem_channel!(("AXI_GDMA", AxiGdma, AxiGdmaChannel, 0,
1289        6, 1, 7, 2, 8)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1290        AhbGdmaChannel)); _for_each_inner_mem2mem_channel!(("AXI_GDMA", AxiGdma,
1291        AxiGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1292        AhbGdmaChannel, DMA_CH1, 11), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 12),
1293        ("AXI_GDMA", AxiGdma, AxiGdmaChannel, DMA_AXI_CH0, 6), ("AXI_GDMA", AxiGdma,
1294        AxiGdmaChannel, DMA_AXI_CH1, 7), ("AXI_GDMA", AxiGdma, AxiGdmaChannel,
1295        DMA_AXI_CH2, 8))); _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma,
1296        AhbGdmaChannel, 1, 11, 2, 12), ("AXI_GDMA", AxiGdma, AxiGdmaChannel, 0, 6, 1, 7,
1297        2, 8))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1298        AhbGdmaChannel), ("AXI_GDMA", AxiGdma, AxiGdmaChannel)));
1299    };
1300}
1301#[macro_export]
1302#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1303macro_rules! with_aes_dma_engine {
1304    ($($pattern:tt => $code:tt;)*) => {
1305        macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1306        => {} } _with_inner_aes_dma_engine!(("AXI_GDMA", AxiGdmaChannel));
1307    };
1308}
1309#[macro_export]
1310#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1311macro_rules! with_i2s_dma_engine {
1312    ($($pattern:tt => $code:tt;)*) => {
1313        macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1314        => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1315    };
1316}
1317#[macro_export]
1318#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1319macro_rules! with_mipi_dsi_dma_engine {
1320    ($($pattern:tt => $code:tt;)*) => {
1321        macro_rules! _with_inner_mipi_dsi_dma_engine { $(($pattern) => $code;)* ($other :
1322        tt) => {} } _with_inner_mipi_dsi_dma_engine!(("VDMA", VdmaChannel));
1323    };
1324}
1325#[macro_export]
1326#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1327macro_rules! with_sha_dma_engine {
1328    ($($pattern:tt => $code:tt;)*) => {
1329        macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1330        => {} } _with_inner_sha_dma_engine!(("AXI_GDMA", AxiGdmaChannel));
1331    };
1332}
1333#[macro_export]
1334#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1335macro_rules! with_spi_master_dma_engine {
1336    ($($pattern:tt => $code:tt;)*) => {
1337        macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1338        : tt) => {} } _with_inner_spi_master_dma_engine!(("AXI_GDMA", AxiGdmaChannel));
1339    };
1340}
1341#[macro_export]
1342#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1343macro_rules! with_spi_slave_dma_engine {
1344    ($($pattern:tt => $code:tt;)*) => {
1345        macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1346        : tt) => {} } _with_inner_spi_slave_dma_engine!(("AXI_GDMA", AxiGdmaChannel));
1347    };
1348}
1349#[macro_export]
1350#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1351macro_rules! with_uhci_dma_engine {
1352    ($($pattern:tt => $code:tt;)*) => {
1353        macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1354        => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1355    };
1356}
1357#[macro_export]
1358#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1359macro_rules! for_each_interrupt {
1360    ($($pattern:tt => $code:tt;)*) => {
1361        macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1362        => {} } _for_each_inner_interrupt!(([disabled 0] 0));
1363        _for_each_inner_interrupt!(([reserved 0] 1));
1364        _for_each_inner_interrupt!(([reserved 1] 2));
1365        _for_each_inner_interrupt!(([reserved 2] 3));
1366        _for_each_inner_interrupt!(([reserved 3] 4));
1367        _for_each_inner_interrupt!(([reserved 4] 5));
1368        _for_each_inner_interrupt!(([reserved 5] 6));
1369        _for_each_inner_interrupt!(([reserved 6] 7));
1370        _for_each_inner_interrupt!(([reserved 7] 8));
1371        _for_each_inner_interrupt!(([reserved 8] 9));
1372        _for_each_inner_interrupt!(([reserved 9] 10));
1373        _for_each_inner_interrupt!(([reserved 10] 11));
1374        _for_each_inner_interrupt!(([reserved 11] 12));
1375        _for_each_inner_interrupt!(([reserved 12] 13));
1376        _for_each_inner_interrupt!(([reserved 13] 14));
1377        _for_each_inner_interrupt!(([reserved 14] 15));
1378        _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1379        1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1380        _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1381        4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1382        _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1383        7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
1384        _for_each_inner_interrupt!(([direct_bindable 1] 25));
1385        _for_each_inner_interrupt!(([direct_bindable 2] 26));
1386        _for_each_inner_interrupt!(([direct_bindable 3] 27));
1387        _for_each_inner_interrupt!(([direct_bindable 4] 28));
1388        _for_each_inner_interrupt!(([direct_bindable 5] 29));
1389        _for_each_inner_interrupt!(([direct_bindable 6] 30));
1390        _for_each_inner_interrupt!(([direct_bindable 7] 31));
1391        _for_each_inner_interrupt!(([direct_bindable 8] 32));
1392        _for_each_inner_interrupt!(([direct_bindable 9] 33));
1393        _for_each_inner_interrupt!(([direct_bindable 10] 34));
1394        _for_each_inner_interrupt!(([direct_bindable 11] 35));
1395        _for_each_inner_interrupt!(([direct_bindable 12] 36));
1396        _for_each_inner_interrupt!(([direct_bindable 13] 37));
1397        _for_each_inner_interrupt!(([direct_bindable 14] 38));
1398        _for_each_inner_interrupt!(([direct_bindable 15] 39));
1399        _for_each_inner_interrupt!(([direct_bindable 16] 40));
1400        _for_each_inner_interrupt!(([direct_bindable 17] 41));
1401        _for_each_inner_interrupt!(([direct_bindable 18] 42));
1402        _for_each_inner_interrupt!(([direct_bindable 19] 43));
1403        _for_each_inner_interrupt!(([direct_bindable 20] 44));
1404        _for_each_inner_interrupt!(([direct_bindable 21] 45));
1405        _for_each_inner_interrupt!(([direct_bindable 22] 46));
1406        _for_each_inner_interrupt!(([direct_bindable 23] 47));
1407        _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
1408        2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
1409        ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
1410        ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
1411        ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
1412        3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
1413        ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
1414        ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
1415        ([direct_bindable 6] 30), ([direct_bindable 7] 31), ([direct_bindable 8] 32),
1416        ([direct_bindable 9] 33), ([direct_bindable 10] 34), ([direct_bindable 11] 35),
1417        ([direct_bindable 12] 36), ([direct_bindable 13] 37), ([direct_bindable 14] 38),
1418        ([direct_bindable 15] 39), ([direct_bindable 16] 40), ([direct_bindable 17] 41),
1419        ([direct_bindable 18] 42), ([direct_bindable 19] 43), ([direct_bindable 20] 44),
1420        ([direct_bindable 21] 45), ([direct_bindable 22] 46), ([direct_bindable 23]
1421        47)));
1422    };
1423}
1424#[macro_export]
1425#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1426macro_rules! for_each_classified_interrupt {
1427    ($($pattern:tt => $code:tt;)*) => {
1428        macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1429        ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1430        24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
1431        _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
1432        _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
1433        _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
1434        _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
1435        _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
1436        _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
1437        _for_each_inner_classified_interrupt!(([direct_bindable 8] 32));
1438        _for_each_inner_classified_interrupt!(([direct_bindable 9] 33));
1439        _for_each_inner_classified_interrupt!(([direct_bindable 10] 34));
1440        _for_each_inner_classified_interrupt!(([direct_bindable 11] 35));
1441        _for_each_inner_classified_interrupt!(([direct_bindable 12] 36));
1442        _for_each_inner_classified_interrupt!(([direct_bindable 13] 37));
1443        _for_each_inner_classified_interrupt!(([direct_bindable 14] 38));
1444        _for_each_inner_classified_interrupt!(([direct_bindable 15] 39));
1445        _for_each_inner_classified_interrupt!(([direct_bindable 16] 40));
1446        _for_each_inner_classified_interrupt!(([direct_bindable 17] 41));
1447        _for_each_inner_classified_interrupt!(([direct_bindable 18] 42));
1448        _for_each_inner_classified_interrupt!(([direct_bindable 19] 43));
1449        _for_each_inner_classified_interrupt!(([direct_bindable 20] 44));
1450        _for_each_inner_classified_interrupt!(([direct_bindable 21] 45));
1451        _for_each_inner_classified_interrupt!(([direct_bindable 22] 46));
1452        _for_each_inner_classified_interrupt!(([direct_bindable 23] 47));
1453        _for_each_inner_classified_interrupt!(([vector 0] 16));
1454        _for_each_inner_classified_interrupt!(([vector 1] 17));
1455        _for_each_inner_classified_interrupt!(([vector 2] 18));
1456        _for_each_inner_classified_interrupt!(([vector 3] 19));
1457        _for_each_inner_classified_interrupt!(([vector 4] 20));
1458        _for_each_inner_classified_interrupt!(([vector 5] 21));
1459        _for_each_inner_classified_interrupt!(([vector 6] 22));
1460        _for_each_inner_classified_interrupt!(([vector 7] 23));
1461        _for_each_inner_classified_interrupt!(([reserved 0] 1));
1462        _for_each_inner_classified_interrupt!(([reserved 1] 2));
1463        _for_each_inner_classified_interrupt!(([reserved 2] 3));
1464        _for_each_inner_classified_interrupt!(([reserved 3] 4));
1465        _for_each_inner_classified_interrupt!(([reserved 4] 5));
1466        _for_each_inner_classified_interrupt!(([reserved 5] 6));
1467        _for_each_inner_classified_interrupt!(([reserved 6] 7));
1468        _for_each_inner_classified_interrupt!(([reserved 7] 8));
1469        _for_each_inner_classified_interrupt!(([reserved 8] 9));
1470        _for_each_inner_classified_interrupt!(([reserved 9] 10));
1471        _for_each_inner_classified_interrupt!(([reserved 10] 11));
1472        _for_each_inner_classified_interrupt!(([reserved 11] 12));
1473        _for_each_inner_classified_interrupt!(([reserved 12] 13));
1474        _for_each_inner_classified_interrupt!(([reserved 13] 14));
1475        _for_each_inner_classified_interrupt!(([reserved 14] 15));
1476        _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
1477        ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
1478        ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
1479        ([direct_bindable 7] 31), ([direct_bindable 8] 32), ([direct_bindable 9] 33),
1480        ([direct_bindable 10] 34), ([direct_bindable 11] 35), ([direct_bindable 12] 36),
1481        ([direct_bindable 13] 37), ([direct_bindable 14] 38), ([direct_bindable 15] 39),
1482        ([direct_bindable 16] 40), ([direct_bindable 17] 41), ([direct_bindable 18] 42),
1483        ([direct_bindable 19] 43), ([direct_bindable 20] 44), ([direct_bindable 21] 45),
1484        ([direct_bindable 22] 46), ([direct_bindable 23] 47)));
1485        _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1486        ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1487        22), ([vector 7] 23))); _for_each_inner_classified_interrupt!((reserved([reserved
1488        0] 1), ([reserved 1] 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5),
1489        ([reserved 5] 6), ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9),
1490        ([reserved 9] 10), ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13),
1491        ([reserved 13] 14), ([reserved 14] 15)));
1492    };
1493}
1494#[macro_export]
1495#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1496macro_rules! for_each_interrupt_priority {
1497    ($($pattern:tt => $code:tt;)*) => {
1498        macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1499        ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1500        Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1501        _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1502        _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1503        _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1504        _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1505        _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1506        _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1507        _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1508        Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1509        Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1510        Priority8, Level8)));
1511    };
1512}
1513#[macro_export]
1514#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1515macro_rules! for_each_sw_interrupt {
1516    ($($pattern:tt => $code:tt;)*) => {
1517        macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1518        tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1519        software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1520        software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1521        software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1522        software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1523        software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1524        FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1525    };
1526}
1527#[macro_export]
1528/// ESP-HAL must provide implementation for the following functions:
1529/// ```rust, no_run
1530/// // XTAL_CLK
1531///
1532/// // CPLL_CLK
1533///
1534/// fn enable_cpll_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1535///     todo!()
1536/// }
1537///
1538/// fn configure_cpll_clk_impl(
1539///     _clocks: &mut ClockTree,
1540///     _old_config: Option<CpllClkConfig>,
1541///     _new_config: CpllClkConfig,
1542/// ) {
1543///     todo!()
1544/// }
1545///
1546/// // SPLL_CLK
1547///
1548/// fn enable_spll_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1549///     todo!()
1550/// }
1551///
1552/// // MPLL_CLK
1553///
1554/// fn enable_mpll_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1555///     todo!()
1556/// }
1557///
1558/// fn configure_mpll_clk_impl(
1559///     _clocks: &mut ClockTree,
1560///     _old_config: Option<MpllClkConfig>,
1561///     _new_config: MpllClkConfig,
1562/// ) {
1563///     todo!()
1564/// }
1565///
1566/// // RC_FAST_CLK
1567///
1568/// fn enable_rc_fast_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1569///     todo!()
1570/// }
1571///
1572/// // XTAL32K_CLK
1573///
1574/// fn enable_xtal32k_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1575///     todo!()
1576/// }
1577///
1578/// // OSC_SLOW_CLK
1579///
1580/// fn enable_osc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1581///     todo!()
1582/// }
1583///
1584/// // RC_SLOW_CLK
1585///
1586/// fn enable_rc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1587///     todo!()
1588/// }
1589///
1590/// // RC32K_CLK
1591///
1592/// fn enable_rc32k_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1593///     todo!()
1594/// }
1595///
1596/// // PLL_F20M
1597///
1598/// fn enable_pll_f20m_impl(_clocks: &mut ClockTree, _en: bool) {
1599///     todo!()
1600/// }
1601///
1602/// // PLL_F80M
1603///
1604/// fn enable_pll_f80m_impl(_clocks: &mut ClockTree, _en: bool) {
1605///     todo!()
1606/// }
1607///
1608/// // PLL_F120M
1609///
1610/// fn enable_pll_f120m_impl(_clocks: &mut ClockTree, _en: bool) {
1611///     todo!()
1612/// }
1613///
1614/// // PLL_F160M
1615///
1616/// fn enable_pll_f160m_impl(_clocks: &mut ClockTree, _en: bool) {
1617///     todo!()
1618/// }
1619///
1620/// // PLL_F240M
1621///
1622/// fn enable_pll_f240m_impl(_clocks: &mut ClockTree, _en: bool) {
1623///     todo!()
1624/// }
1625///
1626/// // IOMUX_FUNCTION_CLOCK
1627///
1628/// fn configure_iomux_function_clock_impl(
1629///     _clocks: &mut ClockTree,
1630///     _old_config: Option<IomuxFunctionClockConfig>,
1631///     _new_config: IomuxFunctionClockConfig,
1632/// ) {
1633///     todo!()
1634/// }
1635///
1636/// // PLL_F25M
1637///
1638/// fn enable_pll_f25m_impl(_clocks: &mut ClockTree, _en: bool) {
1639///     todo!()
1640/// }
1641///
1642/// // PLL_F50M
1643///
1644/// fn enable_pll_f50m_impl(_clocks: &mut ClockTree, _en: bool) {
1645///     todo!()
1646/// }
1647///
1648/// // XTAL_D2_CLK
1649///
1650/// fn enable_xtal_d2_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1651///     todo!()
1652/// }
1653///
1654/// // CPU_ROOT_CLK
1655///
1656/// fn enable_cpu_root_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1657///     todo!()
1658/// }
1659///
1660/// fn configure_cpu_root_clk_impl(
1661///     _clocks: &mut ClockTree,
1662///     _old_config: Option<CpuRootClkConfig>,
1663///     _new_config: CpuRootClkConfig,
1664/// ) {
1665///     todo!()
1666/// }
1667///
1668/// // CPU_CLK
1669///
1670/// fn enable_cpu_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1671///     todo!()
1672/// }
1673///
1674/// fn configure_cpu_clk_impl(
1675///     _clocks: &mut ClockTree,
1676///     _old_config: Option<CpuClkConfig>,
1677///     _new_config: CpuClkConfig,
1678/// ) {
1679///     todo!()
1680/// }
1681///
1682/// // MEM_CLK
1683///
1684/// fn enable_mem_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1685///     todo!()
1686/// }
1687///
1688/// fn configure_mem_clk_impl(
1689///     _clocks: &mut ClockTree,
1690///     _old_config: Option<MemClkConfig>,
1691///     _new_config: MemClkConfig,
1692/// ) {
1693///     todo!()
1694/// }
1695///
1696/// // SYS_CLK
1697///
1698/// fn enable_sys_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1699///     todo!()
1700/// }
1701///
1702/// fn configure_sys_clk_impl(
1703///     _clocks: &mut ClockTree,
1704///     _old_config: Option<SysClkConfig>,
1705///     _new_config: SysClkConfig,
1706/// ) {
1707///     todo!()
1708/// }
1709///
1710/// // APB_CLK
1711///
1712/// fn enable_apb_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1713///     todo!()
1714/// }
1715///
1716/// fn configure_apb_clk_impl(
1717///     _clocks: &mut ClockTree,
1718///     _old_config: Option<ApbClkConfig>,
1719///     _new_config: ApbClkConfig,
1720/// ) {
1721///     todo!()
1722/// }
1723///
1724/// // LP_FAST_CLK
1725///
1726/// fn enable_lp_fast_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1727///     todo!()
1728/// }
1729///
1730/// fn configure_lp_fast_clk_impl(
1731///     _clocks: &mut ClockTree,
1732///     _old_config: Option<LpFastClkConfig>,
1733///     _new_config: LpFastClkConfig,
1734/// ) {
1735///     todo!()
1736/// }
1737///
1738/// // LP_SLOW_CLK
1739///
1740/// fn enable_lp_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1741///     todo!()
1742/// }
1743///
1744/// fn configure_lp_slow_clk_impl(
1745///     _clocks: &mut ClockTree,
1746///     _old_config: Option<LpSlowClkConfig>,
1747///     _new_config: LpSlowClkConfig,
1748/// ) {
1749///     todo!()
1750/// }
1751///
1752/// // TIMG_CALIBRATION_CLOCK
1753///
1754/// fn enable_timg_calibration_clock_impl(_clocks: &mut ClockTree, _en: bool) {
1755///     todo!()
1756/// }
1757///
1758/// fn configure_timg_calibration_clock_impl(
1759///     _clocks: &mut ClockTree,
1760///     _old_config: Option<TimgCalibrationClockConfig>,
1761///     _new_config: TimgCalibrationClockConfig,
1762/// ) {
1763///     todo!()
1764/// }
1765///
1766/// impl SdmInstance {
1767///     // SDM_FUNCTION_CLOCK
1768///
1769///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1770///         todo!()
1771///     }
1772/// }
1773/// impl TimgInstance {
1774///     // TIMG_FUNCTION_CLOCK
1775///
1776///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1777///         todo!()
1778///     }
1779///
1780///     fn configure_function_clock_impl(
1781///         self,
1782///         _clocks: &mut ClockTree,
1783///         _old_config: Option<TimgFunctionClockConfig>,
1784///         _new_config: TimgFunctionClockConfig,
1785///     ) {
1786///         todo!()
1787///     }
1788///
1789///     // TIMG_WDT_CLOCK
1790///
1791///     fn enable_wdt_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1792///         todo!()
1793///     }
1794///
1795///     fn configure_wdt_clock_impl(
1796///         self,
1797///         _clocks: &mut ClockTree,
1798///         _old_config: Option<TimgWdtClockConfig>,
1799///         _new_config: TimgWdtClockConfig,
1800///     ) {
1801///         todo!()
1802///     }
1803/// }
1804/// impl UartInstance {
1805///     // UART_FUNCTION_CLOCK
1806///
1807///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1808///         todo!()
1809///     }
1810///
1811///     fn configure_function_clock_impl(
1812///         self,
1813///         _clocks: &mut ClockTree,
1814///         _old_config: Option<UartFunctionClockConfig>,
1815///         _new_config: UartFunctionClockConfig,
1816///     ) {
1817///         todo!()
1818///     }
1819///
1820///     // UART_BAUD_RATE_GENERATOR
1821///
1822///     fn enable_baud_rate_generator_impl(self, _clocks: &mut ClockTree, _en: bool) {
1823///         todo!()
1824///     }
1825///
1826///     fn configure_baud_rate_generator_impl(
1827///         self,
1828///         _clocks: &mut ClockTree,
1829///         _old_config: Option<UartBaudRateGeneratorConfig>,
1830///         _new_config: UartBaudRateGeneratorConfig,
1831///     ) {
1832///         todo!()
1833///     }
1834/// }
1835/// impl SpiInstance {
1836///     // SPI_FUNCTION_CLOCK
1837///
1838///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1839///         todo!()
1840///     }
1841///
1842///     fn configure_function_clock_impl(
1843///         self,
1844///         _clocks: &mut ClockTree,
1845///         _old_config: Option<SpiFunctionClockConfig>,
1846///         _new_config: SpiFunctionClockConfig,
1847///     ) {
1848///         todo!()
1849///     }
1850/// }
1851/// impl I2cInstance {
1852///     // I2C_FUNCTION_CLOCK
1853///
1854///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1855///         todo!()
1856///     }
1857///
1858///     fn configure_function_clock_impl(
1859///         self,
1860///         _clocks: &mut ClockTree,
1861///         _old_config: Option<I2cFunctionClockConfig>,
1862///         _new_config: I2cFunctionClockConfig,
1863///     ) {
1864///         todo!()
1865///     }
1866/// }
1867/// impl MipiDsiInstance {
1868///     // MIPI_DSI_DPI_CLK
1869///
1870///     fn enable_dpi_clk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1871///         todo!()
1872///     }
1873///
1874///     fn configure_dpi_clk_impl(
1875///         self,
1876///         _clocks: &mut ClockTree,
1877///         _old_config: Option<MipiDsiDpiClkConfig>,
1878///         _new_config: MipiDsiDpiClkConfig,
1879///     ) {
1880///         todo!()
1881///     }
1882///
1883///     // MIPI_DSI_PHY_PLL_REFCLK
1884///
1885///     fn enable_phy_pll_refclk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1886///         todo!()
1887///     }
1888///
1889///     fn configure_phy_pll_refclk_impl(
1890///         self,
1891///         _clocks: &mut ClockTree,
1892///         _old_config: Option<MipiDsiPhyPllRefclkConfig>,
1893///         _new_config: MipiDsiPhyPllRefclkConfig,
1894///     ) {
1895///         todo!()
1896///     }
1897///
1898///     // MIPI_DSI_PHY_CFG_CLK
1899///
1900///     fn enable_phy_cfg_clk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1901///         todo!()
1902///     }
1903///
1904///     fn configure_phy_cfg_clk_impl(
1905///         self,
1906///         _clocks: &mut ClockTree,
1907///         _old_config: Option<MipiDsiPhyCfgClkConfig>,
1908///         _new_config: MipiDsiPhyCfgClkConfig,
1909///     ) {
1910///         todo!()
1911///     }
1912/// }
1913/// impl RmtInstance {
1914///     // RMT_SCLK
1915///
1916///     fn enable_sclk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1917///         todo!()
1918///     }
1919///
1920///     fn configure_sclk_impl(
1921///         self,
1922///         _clocks: &mut ClockTree,
1923///         _old_config: Option<RmtSclkConfig>,
1924///         _new_config: RmtSclkConfig,
1925///     ) {
1926///         todo!()
1927///     }
1928/// }
1929/// impl PsramInstance {
1930///     // PSRAM_FUNCTION_CLOCK
1931///
1932///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1933///         todo!()
1934///     }
1935///
1936///     fn configure_function_clock_impl(
1937///         self,
1938///         _clocks: &mut ClockTree,
1939///         _old_config: Option<PsramFunctionClockConfig>,
1940///         _new_config: PsramFunctionClockConfig,
1941///     ) {
1942///         todo!()
1943///     }
1944/// }
1945/// ```
1946macro_rules! define_clock_tree_types {
1947    () => {
1948        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1949        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1950        pub enum SdmInstance {
1951            GpioSd = 0,
1952        }
1953        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1954        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1955        pub enum TimgInstance {
1956            Timg0 = 0,
1957            Timg1 = 1,
1958        }
1959        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1960        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1961        pub enum UartInstance {
1962            Uart0 = 0,
1963            Uart1 = 1,
1964            Uart2 = 2,
1965            Uart3 = 3,
1966            Uart4 = 4,
1967        }
1968        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1969        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1970        pub enum SpiInstance {
1971            Spi2 = 0,
1972            Spi3 = 1,
1973        }
1974        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1975        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1976        pub enum I2cInstance {
1977            I2c0 = 0,
1978            I2c1 = 1,
1979        }
1980        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1981        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1982        pub enum MipiDsiInstance {
1983            MipiDsi = 0,
1984        }
1985        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1986        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1987        pub enum RmtInstance {
1988            Rmt = 0,
1989        }
1990        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1991        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1992        pub enum PsramInstance {
1993            Psram = 0,
1994        }
1995        /// Selects the output frequency of `CPLL_CLK`. Depends on `XTAL_CLK`.
1996        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1997        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1998        pub enum CpllClkConfig {
1999            /// 360 MHz
2000            _360,
2001            /// 400 MHz
2002            _400,
2003        }
2004        impl CpllClkConfig {
2005            pub fn value(&self) -> u32 {
2006                match self {
2007                    CpllClkConfig::_360 => 360000000,
2008                    CpllClkConfig::_400 => 400000000,
2009                }
2010            }
2011        }
2012        /// Selects the output frequency of `MPLL_CLK`. Depends on `XTAL_CLK`.
2013        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2014        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2015        pub enum MpllClkConfig {
2016            /// 320 MHz
2017            _320,
2018            /// 400 MHz
2019            _400,
2020            /// 500 MHz
2021            _500,
2022        }
2023        impl MpllClkConfig {
2024            pub fn value(&self) -> u32 {
2025                match self {
2026                    MpllClkConfig::_320 => 320000000,
2027                    MpllClkConfig::_400 => 400000000,
2028                    MpllClkConfig::_500 => 500000000,
2029                }
2030            }
2031        }
2032        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2033        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2034        pub enum IomuxFunctionClockSource {
2035            /// Selects `XTAL_CLK`.
2036            XtalClk,
2037            #[default]
2038            /// Selects `PLL_F80M`.
2039            PllF80m,
2040        }
2041        /// Configures the `IOMUX_FUNCTION_CLOCK` clock node.
2042        ///
2043        /// The output is calculated as `OUTPUT = source / (div_num + 1)`.
2044        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2045        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2046        pub struct IomuxFunctionClockConfig {
2047            source: IomuxFunctionClockSource,
2048            div_num: u32,
2049        }
2050        impl IomuxFunctionClockConfig {
2051            /// Creates a new configuration for the IOMUX_FUNCTION_CLOCK clock node.
2052            ///
2053            /// ## Panics
2054            ///
2055            /// Panics if the div_num value is outside the
2056            /// valid range (0 ..= 255).
2057            pub const fn new(source: IomuxFunctionClockSource, div_num: u32) -> Self {
2058                ::core::assert!(
2059                    div_num <= 255,
2060                    "`IOMUX_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2061                );
2062                Self { source, div_num }
2063            }
2064            pub(crate) fn source(self) -> IomuxFunctionClockSource {
2065                self.source
2066            }
2067            pub(crate) fn div_num(self) -> u32 {
2068                self.div_num as u32
2069            }
2070        }
2071        /// The list of clock signals that the `CPU_ROOT_CLK` multiplexer can output.
2072        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2073        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2074        pub enum CpuRootClkConfig {
2075            /// Selects `XTAL_CLK`.
2076            Xtal,
2077            /// Selects `CPLL_CLK`.
2078            Cpll,
2079            /// Selects `RC_FAST_CLK`.
2080            RcFast,
2081        }
2082        /// Configures the `CPU_CLK` clock node.
2083        ///
2084        /// The output is calculated as `OUTPUT = CPU_ROOT_CLK / (divisor + 1)`.
2085        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2086        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2087        pub struct CpuClkConfig {
2088            divisor: u32,
2089        }
2090        impl CpuClkConfig {
2091            /// Creates a new configuration for the CPU_CLK clock node.
2092            ///
2093            /// ## Panics
2094            ///
2095            /// Panics if the divisor value is outside the
2096            /// valid range (0 ..= 255).
2097            pub const fn new(divisor: u32) -> Self {
2098                ::core::assert!(
2099                    divisor <= 255,
2100                    "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
2101                );
2102                Self { divisor }
2103            }
2104            pub(crate) fn divisor(self) -> u32 {
2105                self.divisor as u32
2106            }
2107        }
2108        /// Configures the `MEM_CLK` clock node.
2109        ///
2110        /// The output is calculated as `OUTPUT = CPU_CLK / (divisor + 1)`.
2111        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2112        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2113        pub struct MemClkConfig {
2114            divisor: u32,
2115        }
2116        impl MemClkConfig {
2117            /// Creates a new configuration for the MEM_CLK clock node.
2118            ///
2119            /// ## Panics
2120            ///
2121            /// Panics if the divisor value is outside the
2122            /// valid range (0 ..= 255).
2123            pub const fn new(divisor: u32) -> Self {
2124                ::core::assert!(
2125                    divisor <= 255,
2126                    "`MEM_CLK` divisor must be between 0 and 255 (inclusive)."
2127                );
2128                Self { divisor }
2129            }
2130            pub(crate) fn divisor(self) -> u32 {
2131                self.divisor as u32
2132            }
2133        }
2134        /// Configures the `SYS_CLK` clock node.
2135        ///
2136        /// The output is calculated as `OUTPUT = MEM_CLK / (divisor + 1)`.
2137        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2138        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2139        pub struct SysClkConfig {
2140            divisor: u32,
2141        }
2142        impl SysClkConfig {
2143            /// Creates a new configuration for the SYS_CLK clock node.
2144            ///
2145            /// ## Panics
2146            ///
2147            /// Panics if the divisor value is outside the
2148            /// valid range (0 ..= 255).
2149            pub const fn new(divisor: u32) -> Self {
2150                ::core::assert!(
2151                    divisor <= 255,
2152                    "`SYS_CLK` divisor must be between 0 and 255 (inclusive)."
2153                );
2154                Self { divisor }
2155            }
2156            pub(crate) fn divisor(self) -> u32 {
2157                self.divisor as u32
2158            }
2159        }
2160        /// Configures the `APB_CLK` clock node.
2161        ///
2162        /// The output is calculated as `OUTPUT = SYS_CLK / (divisor + 1)`.
2163        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2164        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2165        pub struct ApbClkConfig {
2166            divisor: u32,
2167        }
2168        impl ApbClkConfig {
2169            /// Creates a new configuration for the APB_CLK clock node.
2170            ///
2171            /// ## Panics
2172            ///
2173            /// Panics if the divisor value is outside the
2174            /// valid range (0 ..= 255).
2175            pub const fn new(divisor: u32) -> Self {
2176                ::core::assert!(
2177                    divisor <= 255,
2178                    "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
2179                );
2180                Self { divisor }
2181            }
2182            pub(crate) fn divisor(self) -> u32 {
2183                self.divisor as u32
2184            }
2185        }
2186        /// The list of clock signals that the `LP_FAST_CLK` multiplexer can output.
2187        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2188        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2189        pub enum LpFastClkConfig {
2190            /// Selects `RC_FAST_CLK`.
2191            RcFast,
2192            /// Selects `XTAL_D2_CLK`.
2193            XtalD2,
2194        }
2195        /// The list of clock signals that the `LP_SLOW_CLK` multiplexer can output.
2196        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2197        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2198        pub enum LpSlowClkConfig {
2199            /// Selects `RC_SLOW_CLK`.
2200            RcSlow,
2201            /// Selects `XTAL32K_CLK`.
2202            Xtal32k,
2203            /// Selects `OSC_SLOW_CLK`.
2204            OscSlow,
2205        }
2206        /// The list of clock signals that the `TIMG_CALIBRATION_CLOCK` multiplexer can output.
2207        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2208        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2209        pub enum TimgCalibrationClockConfig {
2210            /// Selects `MPLL_CLK`.
2211            MpllClk,
2212            /// Selects `SPLL_CLK`.
2213            SpllClk,
2214            /// Selects `CPLL_CLK`.
2215            CpllClk,
2216            /// Selects `RC_FAST_CLK`.
2217            RcFastDivClk,
2218            /// Selects `LP_SLOW_CLK`.
2219            RcSlowClk,
2220            /// Selects `XTAL32K_CLK`.
2221            Xtal32kClk,
2222        }
2223        /// The list of clock signals that the `TIMG0_FUNCTION_CLOCK` multiplexer can output.
2224        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2225        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2226        pub enum TimgFunctionClockConfig {
2227            #[default]
2228            /// Selects `XTAL_CLK`.
2229            XtalClk,
2230            /// Selects `RC_FAST_CLK`.
2231            RcFastClk,
2232            /// Selects `PLL_F80M`.
2233            PllF80m,
2234        }
2235        /// The list of clock signals that the `TIMG0_WDT_CLOCK` multiplexer can output.
2236        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2237        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2238        pub enum TimgWdtClockConfig {
2239            #[default]
2240            /// Selects `XTAL_CLK`.
2241            XtalClk,
2242            /// Selects `PLL_F80M`.
2243            PllF80m,
2244            /// Selects `RC_FAST_CLK`.
2245            RcFastClk,
2246        }
2247        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2248        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2249        pub enum UartFunctionClockSclk {
2250            #[default]
2251            /// Selects `XTAL_CLK`.
2252            Xtal,
2253            /// Selects `PLL_F80M`.
2254            PllF80m,
2255            /// Selects `RC_FAST_CLK`.
2256            RcFast,
2257        }
2258        /// Configures the `UART0_FUNCTION_CLOCK` clock node.
2259        ///
2260        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
2261        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2262        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2263        pub struct UartFunctionClockConfig {
2264            sclk: UartFunctionClockSclk,
2265            div_num: u32,
2266        }
2267        impl UartFunctionClockConfig {
2268            /// Creates a new configuration for the FUNCTION_CLOCK clock node.
2269            ///
2270            /// ## Panics
2271            ///
2272            /// Panics if the div_num value is outside the
2273            /// valid range (0 ..= 255).
2274            pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
2275                ::core::assert!(
2276                    div_num <= 255,
2277                    "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2278                );
2279                Self { sclk, div_num }
2280            }
2281            pub(crate) fn sclk(self) -> UartFunctionClockSclk {
2282                self.sclk
2283            }
2284            pub(crate) fn div_num(self) -> u32 {
2285                self.div_num as u32
2286            }
2287        }
2288        /// Configures the `UART0_BAUD_RATE_GENERATOR` clock node.
2289        ///
2290        /// The output is calculated as `OUTPUT = (FUNCTION_CLOCK * 16) / (integral * 16 +
2291        /// fractional)`.
2292        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2293        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2294        pub struct UartBaudRateGeneratorConfig {
2295            fractional: u32,
2296            integral: u32,
2297        }
2298        impl UartBaudRateGeneratorConfig {
2299            /// Creates a new configuration for the BAUD_RATE_GENERATOR clock node.
2300            ///
2301            /// ## Panics
2302            ///
2303            /// Panics if the fractional value is outside the
2304            /// valid range (0 ..= 15).
2305            ///
2306            /// Panics if the integral value is outside the
2307            /// valid range (0 ..= 4095).
2308            pub const fn new(fractional: u32, integral: u32) -> Self {
2309                ::core::assert!(
2310                    fractional <= 15,
2311                    "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2312                );
2313                ::core::assert!(
2314                    integral <= 4095,
2315                    "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2316                );
2317                Self {
2318                    fractional,
2319                    integral,
2320                }
2321            }
2322            pub(crate) fn fractional(self) -> u32 {
2323                self.fractional as u32
2324            }
2325            pub(crate) fn integral(self) -> u32 {
2326                self.integral as u32
2327            }
2328        }
2329        /// The list of clock signals that the `SPI2_FUNCTION_CLOCK` multiplexer can output.
2330        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2331        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2332        pub enum SpiFunctionClockConfig {
2333            #[default]
2334            /// Selects `XTAL_CLK`.
2335            Xtal,
2336            /// Selects `RC_FAST_CLK`.
2337            RcFast,
2338            /// Selects `SPLL_CLK`.
2339            Spll,
2340        }
2341        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2342        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2343        pub enum I2cFunctionClockSclk {
2344            #[default]
2345            /// Selects `XTAL_CLK`.
2346            Xtal,
2347            /// Selects `RC_FAST_CLK`.
2348            RcFast,
2349        }
2350        /// Configures the `I2C0_FUNCTION_CLOCK` clock node.
2351        ///
2352        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
2353        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2354        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2355        pub struct I2cFunctionClockConfig {
2356            sclk: I2cFunctionClockSclk,
2357            div_num: u32,
2358        }
2359        impl I2cFunctionClockConfig {
2360            /// Creates a new configuration for the FUNCTION_CLOCK clock node.
2361            ///
2362            /// ## Panics
2363            ///
2364            /// Panics if the div_num value is outside the
2365            /// valid range (0 ..= 255).
2366            pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
2367                ::core::assert!(
2368                    div_num <= 255,
2369                    "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2370                );
2371                Self { sclk, div_num }
2372            }
2373            pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
2374                self.sclk
2375            }
2376            pub(crate) fn div_num(self) -> u32 {
2377                self.div_num as u32
2378            }
2379        }
2380        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2381        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2382        pub enum MipiDsiDpiClkSclk {
2383            #[default]
2384            /// Selects `XTAL_CLK`.
2385            Xtal,
2386            /// Selects `PLL_F240M`.
2387            PllF240m,
2388            /// Selects `PLL_F160M`.
2389            PllF160m,
2390        }
2391        /// Configures the `MIPI_DSI_DPI_CLK` clock node.
2392        ///
2393        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
2394        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2395        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2396        pub struct MipiDsiDpiClkConfig {
2397            sclk: MipiDsiDpiClkSclk,
2398            div_num: u32,
2399        }
2400        impl MipiDsiDpiClkConfig {
2401            /// Creates a new configuration for the DPI_CLK clock node.
2402            ///
2403            /// ## Panics
2404            ///
2405            /// Panics if the div_num value is outside the
2406            /// valid range (0 ..= 255).
2407            pub const fn new(sclk: MipiDsiDpiClkSclk, div_num: u32) -> Self {
2408                ::core::assert!(
2409                    div_num <= 255,
2410                    "`MIPI_DSI_DPI_CLK` div_num must be between 0 and 255 (inclusive)."
2411                );
2412                Self { sclk, div_num }
2413            }
2414            pub(crate) fn sclk(self) -> MipiDsiDpiClkSclk {
2415                self.sclk
2416            }
2417            pub(crate) fn div_num(self) -> u32 {
2418                self.div_num as u32
2419            }
2420        }
2421        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2422        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2423        pub enum MipiDsiPhyPllRefclkSclk {
2424            #[default]
2425            /// Selects `XTAL_CLK`.
2426            Xtal,
2427            /// Selects `CPLL_CLK`.
2428            Cpll,
2429            /// Selects `SPLL_CLK`.
2430            Spll,
2431            /// Selects `MPLL_CLK`.
2432            Mpll,
2433        }
2434        /// Configures the `MIPI_DSI_PHY_PLL_REFCLK` clock node.
2435        ///
2436        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
2437        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2438        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2439        pub struct MipiDsiPhyPllRefclkConfig {
2440            sclk: MipiDsiPhyPllRefclkSclk,
2441            div_num: u32,
2442        }
2443        impl MipiDsiPhyPllRefclkConfig {
2444            /// Creates a new configuration for the PHY_PLL_REFCLK clock node.
2445            ///
2446            /// ## Panics
2447            ///
2448            /// Panics if the div_num value is outside the
2449            /// valid range (0 ..= 255).
2450            pub const fn new(sclk: MipiDsiPhyPllRefclkSclk, div_num: u32) -> Self {
2451                ::core::assert!(
2452                    div_num <= 255,
2453                    "`MIPI_DSI_PHY_PLL_REFCLK` div_num must be between 0 and 255 (inclusive)."
2454                );
2455                Self { sclk, div_num }
2456            }
2457            pub(crate) fn sclk(self) -> MipiDsiPhyPllRefclkSclk {
2458                self.sclk
2459            }
2460            pub(crate) fn div_num(self) -> u32 {
2461                self.div_num as u32
2462            }
2463        }
2464        /// The list of clock signals that the `MIPI_DSI_PHY_CFG_CLK` multiplexer can output.
2465        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2466        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2467        pub enum MipiDsiPhyCfgClkConfig {
2468            #[default]
2469            /// Selects `PLL_F20M`.
2470            PllF20m,
2471            /// Selects `RC_FAST_CLK`.
2472            RcFast,
2473            /// Selects `PLL_F25M`.
2474            PllF25m,
2475        }
2476        /// The list of clock signals that the `RMT_SCLK` multiplexer can output.
2477        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2478        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2479        pub enum RmtSclkConfig {
2480            #[default]
2481            /// Selects `PLL_F80M`.
2482            PllF80m,
2483            /// Selects `RC_FAST_CLK`.
2484            RcFastClk,
2485            /// Selects `XTAL_CLK`.
2486            XtalClk,
2487        }
2488        /// The list of clock signals that the `PSRAM_FUNCTION_CLOCK` multiplexer can output.
2489        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2490        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2491        pub enum PsramFunctionClockConfig {
2492            #[default]
2493            /// Selects `XTAL_CLK`.
2494            Xtal,
2495            /// Selects `MPLL_CLK`.
2496            Mpll,
2497            /// Selects `SPLL_CLK`.
2498            Spll,
2499            /// Selects `CPLL_CLK`.
2500            Cpll,
2501        }
2502        /// Represents the device's clock tree.
2503        pub struct ClockTree {
2504            cpll_clk: Option<CpllClkConfig>,
2505            mpll_clk: Option<MpllClkConfig>,
2506            iomux_function_clock: Option<IomuxFunctionClockConfig>,
2507            cpu_root_clk: Option<CpuRootClkConfig>,
2508            cpu_clk: Option<CpuClkConfig>,
2509            mem_clk: Option<MemClkConfig>,
2510            sys_clk: Option<SysClkConfig>,
2511            apb_clk: Option<ApbClkConfig>,
2512            lp_fast_clk: Option<LpFastClkConfig>,
2513            lp_slow_clk: Option<LpSlowClkConfig>,
2514            timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2515            timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2516            timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2517            uart_function_clock: [Option<UartFunctionClockConfig>; 5],
2518            uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 5],
2519            spi_function_clock: [Option<SpiFunctionClockConfig>; 2],
2520            i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
2521            mipi_dsi_dpi_clk: [Option<MipiDsiDpiClkConfig>; 1],
2522            mipi_dsi_phy_pll_refclk: [Option<MipiDsiPhyPllRefclkConfig>; 1],
2523            mipi_dsi_phy_cfg_clk: [Option<MipiDsiPhyCfgClkConfig>; 1],
2524            rmt_sclk: [Option<RmtSclkConfig>; 1],
2525            psram_function_clock: [Option<PsramFunctionClockConfig>; 1],
2526            cpll_clk_refcount: u32,
2527            spll_clk_refcount: u32,
2528            mpll_clk_refcount: u32,
2529            rc_fast_clk_refcount: u32,
2530            xtal32k_clk_refcount: u32,
2531            rc32k_clk_refcount: u32,
2532            pll_f80m_refcount: u32,
2533            pll_f120m_refcount: u32,
2534            pll_f50m_refcount: u32,
2535            apb_clk_refcount: u32,
2536            lp_fast_clk_refcount: u32,
2537            timg_calibration_clock_refcount: u32,
2538            sdm_function_clock_refcount: [u32; 1],
2539            timg_function_clock_refcount: [u32; 2],
2540            timg_wdt_clock_refcount: [u32; 2],
2541            uart_function_clock_refcount: [u32; 5],
2542            uart_baud_rate_generator_refcount: [u32; 5],
2543            spi_function_clock_refcount: [u32; 2],
2544            i2c_function_clock_refcount: [u32; 2],
2545            mipi_dsi_dpi_clk_refcount: [u32; 1],
2546            mipi_dsi_phy_pll_refclk_refcount: [u32; 1],
2547            mipi_dsi_phy_cfg_clk_refcount: [u32; 1],
2548            rmt_sclk_refcount: [u32; 1],
2549            psram_function_clock_refcount: [u32; 1],
2550        }
2551        impl ClockTree {
2552            /// Locks the clock tree for exclusive access.
2553            pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2554                CLOCK_TREE.with(f)
2555            }
2556            /// Returns the current configuration of the CPLL_CLK clock tree node
2557            pub fn cpll_clk(&self) -> Option<CpllClkConfig> {
2558                self.cpll_clk
2559            }
2560            /// Returns the current configuration of the MPLL_CLK clock tree node
2561            pub fn mpll_clk(&self) -> Option<MpllClkConfig> {
2562                self.mpll_clk
2563            }
2564            /// Returns the current configuration of the IOMUX_FUNCTION_CLOCK clock tree node
2565            pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2566                self.iomux_function_clock
2567            }
2568            /// Returns the current configuration of the CPU_ROOT_CLK clock tree node
2569            pub fn cpu_root_clk(&self) -> Option<CpuRootClkConfig> {
2570                self.cpu_root_clk
2571            }
2572            /// Returns the current configuration of the CPU_CLK clock tree node
2573            pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2574                self.cpu_clk
2575            }
2576            /// Returns the current configuration of the MEM_CLK clock tree node
2577            pub fn mem_clk(&self) -> Option<MemClkConfig> {
2578                self.mem_clk
2579            }
2580            /// Returns the current configuration of the SYS_CLK clock tree node
2581            pub fn sys_clk(&self) -> Option<SysClkConfig> {
2582                self.sys_clk
2583            }
2584            /// Returns the current configuration of the APB_CLK clock tree node
2585            pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2586                self.apb_clk
2587            }
2588            /// Returns the current configuration of the LP_FAST_CLK clock tree node
2589            pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2590                self.lp_fast_clk
2591            }
2592            /// Returns the current configuration of the LP_SLOW_CLK clock tree node
2593            pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2594                self.lp_slow_clk
2595            }
2596            /// Returns the current configuration of the TIMG_CALIBRATION_CLOCK clock tree node
2597            pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2598                self.timg_calibration_clock
2599            }
2600            /// Returns the current configuration of the TIMG0_FUNCTION_CLOCK clock tree node
2601            pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2602                self.timg_function_clock[TimgInstance::Timg0 as usize]
2603            }
2604            /// Returns the current configuration of the TIMG0_WDT_CLOCK clock tree node
2605            pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2606                self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2607            }
2608            /// Returns the current configuration of the TIMG1_FUNCTION_CLOCK clock tree node
2609            pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2610                self.timg_function_clock[TimgInstance::Timg1 as usize]
2611            }
2612            /// Returns the current configuration of the TIMG1_WDT_CLOCK clock tree node
2613            pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2614                self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2615            }
2616            /// Returns the current configuration of the UART0_FUNCTION_CLOCK clock tree node
2617            pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2618                self.uart_function_clock[UartInstance::Uart0 as usize]
2619            }
2620            /// Returns the current configuration of the UART0_BAUD_RATE_GENERATOR clock tree node
2621            pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2622                self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2623            }
2624            /// Returns the current configuration of the UART1_FUNCTION_CLOCK clock tree node
2625            pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2626                self.uart_function_clock[UartInstance::Uart1 as usize]
2627            }
2628            /// Returns the current configuration of the UART1_BAUD_RATE_GENERATOR clock tree node
2629            pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2630                self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2631            }
2632            /// Returns the current configuration of the UART2_FUNCTION_CLOCK clock tree node
2633            pub fn uart2_function_clock(&self) -> Option<UartFunctionClockConfig> {
2634                self.uart_function_clock[UartInstance::Uart2 as usize]
2635            }
2636            /// Returns the current configuration of the UART2_BAUD_RATE_GENERATOR clock tree node
2637            pub fn uart2_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2638                self.uart_baud_rate_generator[UartInstance::Uart2 as usize]
2639            }
2640            /// Returns the current configuration of the UART3_FUNCTION_CLOCK clock tree node
2641            pub fn uart3_function_clock(&self) -> Option<UartFunctionClockConfig> {
2642                self.uart_function_clock[UartInstance::Uart3 as usize]
2643            }
2644            /// Returns the current configuration of the UART3_BAUD_RATE_GENERATOR clock tree node
2645            pub fn uart3_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2646                self.uart_baud_rate_generator[UartInstance::Uart3 as usize]
2647            }
2648            /// Returns the current configuration of the UART4_FUNCTION_CLOCK clock tree node
2649            pub fn uart4_function_clock(&self) -> Option<UartFunctionClockConfig> {
2650                self.uart_function_clock[UartInstance::Uart4 as usize]
2651            }
2652            /// Returns the current configuration of the UART4_BAUD_RATE_GENERATOR clock tree node
2653            pub fn uart4_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2654                self.uart_baud_rate_generator[UartInstance::Uart4 as usize]
2655            }
2656            /// Returns the current configuration of the SPI2_FUNCTION_CLOCK clock tree node
2657            pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2658                self.spi_function_clock[SpiInstance::Spi2 as usize]
2659            }
2660            /// Returns the current configuration of the SPI3_FUNCTION_CLOCK clock tree node
2661            pub fn spi3_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2662                self.spi_function_clock[SpiInstance::Spi3 as usize]
2663            }
2664            /// Returns the current configuration of the I2C0_FUNCTION_CLOCK clock tree node
2665            pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2666                self.i2c_function_clock[I2cInstance::I2c0 as usize]
2667            }
2668            /// Returns the current configuration of the I2C1_FUNCTION_CLOCK clock tree node
2669            pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2670                self.i2c_function_clock[I2cInstance::I2c1 as usize]
2671            }
2672            /// Returns the current configuration of the MIPI_DSI_DPI_CLK clock tree node
2673            pub fn mipi_dsi_dpi_clk(&self) -> Option<MipiDsiDpiClkConfig> {
2674                self.mipi_dsi_dpi_clk[MipiDsiInstance::MipiDsi as usize]
2675            }
2676            /// Returns the current configuration of the MIPI_DSI_PHY_PLL_REFCLK clock tree node
2677            pub fn mipi_dsi_phy_pll_refclk(&self) -> Option<MipiDsiPhyPllRefclkConfig> {
2678                self.mipi_dsi_phy_pll_refclk[MipiDsiInstance::MipiDsi as usize]
2679            }
2680            /// Returns the current configuration of the MIPI_DSI_PHY_CFG_CLK clock tree node
2681            pub fn mipi_dsi_phy_cfg_clk(&self) -> Option<MipiDsiPhyCfgClkConfig> {
2682                self.mipi_dsi_phy_cfg_clk[MipiDsiInstance::MipiDsi as usize]
2683            }
2684            /// Returns the current configuration of the RMT_SCLK clock tree node
2685            pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2686                self.rmt_sclk[RmtInstance::Rmt as usize]
2687            }
2688            /// Returns the current configuration of the PSRAM_FUNCTION_CLOCK clock tree node
2689            pub fn psram_function_clock(&self) -> Option<PsramFunctionClockConfig> {
2690                self.psram_function_clock[PsramInstance::Psram as usize]
2691            }
2692        }
2693        static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2694            ::esp_sync::NonReentrantMutex::new(ClockTree {
2695                cpll_clk: None,
2696                mpll_clk: None,
2697                iomux_function_clock: None,
2698                cpu_root_clk: None,
2699                cpu_clk: None,
2700                mem_clk: None,
2701                sys_clk: None,
2702                apb_clk: None,
2703                lp_fast_clk: None,
2704                lp_slow_clk: None,
2705                timg_calibration_clock: None,
2706                timg_function_clock: [None; 2],
2707                timg_wdt_clock: [None; 2],
2708                uart_function_clock: [None; 5],
2709                uart_baud_rate_generator: [None; 5],
2710                spi_function_clock: [None; 2],
2711                i2c_function_clock: [None; 2],
2712                mipi_dsi_dpi_clk: [None; 1],
2713                mipi_dsi_phy_pll_refclk: [None; 1],
2714                mipi_dsi_phy_cfg_clk: [None; 1],
2715                rmt_sclk: [None; 1],
2716                psram_function_clock: [None; 1],
2717                cpll_clk_refcount: 0,
2718                spll_clk_refcount: 0,
2719                mpll_clk_refcount: 0,
2720                rc_fast_clk_refcount: 0,
2721                xtal32k_clk_refcount: 0,
2722                rc32k_clk_refcount: 0,
2723                pll_f80m_refcount: 0,
2724                pll_f120m_refcount: 0,
2725                pll_f50m_refcount: 0,
2726                apb_clk_refcount: 0,
2727                lp_fast_clk_refcount: 0,
2728                timg_calibration_clock_refcount: 0,
2729                sdm_function_clock_refcount: [0; 1],
2730                timg_function_clock_refcount: [0; 2],
2731                timg_wdt_clock_refcount: [0; 2],
2732                uart_function_clock_refcount: [0; 5],
2733                uart_baud_rate_generator_refcount: [0; 5],
2734                spi_function_clock_refcount: [0; 2],
2735                i2c_function_clock_refcount: [0; 2],
2736                mipi_dsi_dpi_clk_refcount: [0; 1],
2737                mipi_dsi_phy_pll_refclk_refcount: [0; 1],
2738                mipi_dsi_phy_cfg_clk_refcount: [0; 1],
2739                rmt_sclk_refcount: [0; 1],
2740                psram_function_clock_refcount: [0; 1],
2741            });
2742        static CPLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2743            ::core::sync::atomic::AtomicU32::new(0);
2744        static MPLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2745            ::core::sync::atomic::AtomicU32::new(0);
2746        static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2747            ::core::sync::atomic::AtomicU32::new(0);
2748        static CPU_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2749            ::core::sync::atomic::AtomicU32::new(0);
2750        static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2751            ::core::sync::atomic::AtomicU32::new(0);
2752        static MEM_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2753            ::core::sync::atomic::AtomicU32::new(0);
2754        static SYS_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2755            ::core::sync::atomic::AtomicU32::new(0);
2756        static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2757            ::core::sync::atomic::AtomicU32::new(0);
2758        static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2759            ::core::sync::atomic::AtomicU32::new(0);
2760        static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2761            ::core::sync::atomic::AtomicU32::new(0);
2762        static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2763            ::core::sync::atomic::AtomicU32::new(0);
2764        static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2765            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2766        static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2767            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2768        static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 5] =
2769            [const { ::core::sync::atomic::AtomicU32::new(0) }; 5];
2770        static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 5] =
2771            [const { ::core::sync::atomic::AtomicU32::new(0) }; 5];
2772        static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2773            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2774        static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2775            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2776        static MIPI_DSI_DPI_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2777            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2778        static MIPI_DSI_PHY_PLL_REFCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2779            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2780        static MIPI_DSI_PHY_CFG_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2781            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2782        static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2783            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2784        static PSRAM_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2785            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2786        fn request_xtal_clk(_clocks: &mut ClockTree) {}
2787        fn release_xtal_clk(_clocks: &mut ClockTree) {}
2788        pub fn xtal_clk_frequency() -> u32 {
2789            40000000
2790        }
2791        pub fn configure_cpll_clk(clocks: &mut ClockTree, config: CpllClkConfig) {
2792            let old_config = clocks.cpll_clk.replace(config);
2793            refresh_cpll_clk_downstream(clocks);
2794            configure_cpll_clk_impl(clocks, old_config, config);
2795        }
2796        pub fn cpll_clk_config(clocks: &mut ClockTree) -> Option<CpllClkConfig> {
2797            clocks.cpll_clk
2798        }
2799        pub fn request_cpll_clk(clocks: &mut ClockTree) {
2800            trace!("Requesting CPLL_CLK");
2801            if increment_reference_count(&mut clocks.cpll_clk_refcount) {
2802                trace!("Enabling CPLL_CLK");
2803                request_xtal_clk(clocks);
2804                enable_cpll_clk_impl(clocks, true);
2805            }
2806        }
2807        pub fn release_cpll_clk(clocks: &mut ClockTree) {
2808            trace!("Releasing CPLL_CLK");
2809            if decrement_reference_count(&mut clocks.cpll_clk_refcount) {
2810                trace!("Disabling CPLL_CLK");
2811                enable_cpll_clk_impl(clocks, false);
2812                release_xtal_clk(clocks);
2813            }
2814        }
2815        #[allow(unused_variables)]
2816        pub fn cpll_clk_config_frequency(clocks: &mut ClockTree, config: CpllClkConfig) -> u32 {
2817            config.value()
2818        }
2819        pub fn cpll_clk_frequency() -> u32 {
2820            CPLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2821        }
2822        pub fn cpll_clk_source_frequency() -> u32 {
2823            xtal_clk_frequency()
2824        }
2825        pub fn request_spll_clk(clocks: &mut ClockTree) {
2826            trace!("Requesting SPLL_CLK");
2827            if increment_reference_count(&mut clocks.spll_clk_refcount) {
2828                trace!("Enabling SPLL_CLK");
2829                request_xtal_clk(clocks);
2830                enable_spll_clk_impl(clocks, true);
2831            }
2832        }
2833        pub fn release_spll_clk(clocks: &mut ClockTree) {
2834            trace!("Releasing SPLL_CLK");
2835            if decrement_reference_count(&mut clocks.spll_clk_refcount) {
2836                trace!("Disabling SPLL_CLK");
2837                enable_spll_clk_impl(clocks, false);
2838                release_xtal_clk(clocks);
2839            }
2840        }
2841        pub fn spll_clk_frequency() -> u32 {
2842            (480 * 1000000)
2843        }
2844        pub fn spll_clk_source_frequency() -> u32 {
2845            xtal_clk_frequency()
2846        }
2847        pub fn configure_mpll_clk(clocks: &mut ClockTree, config: MpllClkConfig) {
2848            let old_config = clocks.mpll_clk.replace(config);
2849            refresh_mpll_clk_downstream(clocks);
2850            configure_mpll_clk_impl(clocks, old_config, config);
2851        }
2852        pub fn mpll_clk_config(clocks: &mut ClockTree) -> Option<MpllClkConfig> {
2853            clocks.mpll_clk
2854        }
2855        pub fn request_mpll_clk(clocks: &mut ClockTree) {
2856            trace!("Requesting MPLL_CLK");
2857            if increment_reference_count(&mut clocks.mpll_clk_refcount) {
2858                trace!("Enabling MPLL_CLK");
2859                request_xtal_clk(clocks);
2860                enable_mpll_clk_impl(clocks, true);
2861            }
2862        }
2863        pub fn release_mpll_clk(clocks: &mut ClockTree) {
2864            trace!("Releasing MPLL_CLK");
2865            if decrement_reference_count(&mut clocks.mpll_clk_refcount) {
2866                trace!("Disabling MPLL_CLK");
2867                enable_mpll_clk_impl(clocks, false);
2868                release_xtal_clk(clocks);
2869            }
2870        }
2871        #[allow(unused_variables)]
2872        pub fn mpll_clk_config_frequency(clocks: &mut ClockTree, config: MpllClkConfig) -> u32 {
2873            config.value()
2874        }
2875        pub fn mpll_clk_frequency() -> u32 {
2876            MPLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2877        }
2878        pub fn mpll_clk_source_frequency() -> u32 {
2879            xtal_clk_frequency()
2880        }
2881        pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2882            trace!("Requesting RC_FAST_CLK");
2883            if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2884                trace!("Enabling RC_FAST_CLK");
2885                enable_rc_fast_clk_impl(clocks, true);
2886            }
2887        }
2888        pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2889            trace!("Releasing RC_FAST_CLK");
2890            if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2891                trace!("Disabling RC_FAST_CLK");
2892                enable_rc_fast_clk_impl(clocks, false);
2893            }
2894        }
2895        pub fn rc_fast_clk_frequency() -> u32 {
2896            20000000
2897        }
2898        pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2899            trace!("Requesting XTAL32K_CLK");
2900            if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2901                trace!("Enabling XTAL32K_CLK");
2902                enable_xtal32k_clk_impl(clocks, true);
2903            }
2904        }
2905        pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2906            trace!("Releasing XTAL32K_CLK");
2907            if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2908                trace!("Disabling XTAL32K_CLK");
2909                enable_xtal32k_clk_impl(clocks, false);
2910            }
2911        }
2912        pub fn xtal32k_clk_frequency() -> u32 {
2913            32768
2914        }
2915        pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2916            trace!("Requesting OSC_SLOW_CLK");
2917            trace!("Enabling OSC_SLOW_CLK");
2918            enable_osc_slow_clk_impl(clocks, true);
2919        }
2920        pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2921            trace!("Releasing OSC_SLOW_CLK");
2922            trace!("Disabling OSC_SLOW_CLK");
2923            enable_osc_slow_clk_impl(clocks, false);
2924        }
2925        pub fn osc_slow_clk_frequency() -> u32 {
2926            32768
2927        }
2928        pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2929            trace!("Requesting RC_SLOW_CLK");
2930            trace!("Enabling RC_SLOW_CLK");
2931            enable_rc_slow_clk_impl(clocks, true);
2932        }
2933        pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2934            trace!("Releasing RC_SLOW_CLK");
2935            trace!("Disabling RC_SLOW_CLK");
2936            enable_rc_slow_clk_impl(clocks, false);
2937        }
2938        pub fn rc_slow_clk_frequency() -> u32 {
2939            136000
2940        }
2941        pub fn request_rc32k_clk(clocks: &mut ClockTree) {
2942            trace!("Requesting RC32K_CLK");
2943            if increment_reference_count(&mut clocks.rc32k_clk_refcount) {
2944                trace!("Enabling RC32K_CLK");
2945                enable_rc32k_clk_impl(clocks, true);
2946            }
2947        }
2948        pub fn release_rc32k_clk(clocks: &mut ClockTree) {
2949            trace!("Releasing RC32K_CLK");
2950            if decrement_reference_count(&mut clocks.rc32k_clk_refcount) {
2951                trace!("Disabling RC32K_CLK");
2952                enable_rc32k_clk_impl(clocks, false);
2953            }
2954        }
2955        pub fn rc32k_clk_frequency() -> u32 {
2956            32768
2957        }
2958        pub fn request_pll_f20m(clocks: &mut ClockTree) {
2959            trace!("Requesting PLL_F20M");
2960            trace!("Enabling PLL_F20M");
2961            request_spll_clk(clocks);
2962            enable_pll_f20m_impl(clocks, true);
2963        }
2964        pub fn release_pll_f20m(clocks: &mut ClockTree) {
2965            trace!("Releasing PLL_F20M");
2966            trace!("Disabling PLL_F20M");
2967            enable_pll_f20m_impl(clocks, false);
2968            release_spll_clk(clocks);
2969        }
2970        pub fn pll_f20m_frequency() -> u32 {
2971            (spll_clk_frequency() / 24)
2972        }
2973        pub fn pll_f20m_source_frequency() -> u32 {
2974            spll_clk_frequency()
2975        }
2976        pub fn request_pll_f80m(clocks: &mut ClockTree) {
2977            trace!("Requesting PLL_F80M");
2978            if increment_reference_count(&mut clocks.pll_f80m_refcount) {
2979                trace!("Enabling PLL_F80M");
2980                request_spll_clk(clocks);
2981                enable_pll_f80m_impl(clocks, true);
2982            }
2983        }
2984        pub fn release_pll_f80m(clocks: &mut ClockTree) {
2985            trace!("Releasing PLL_F80M");
2986            if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
2987                trace!("Disabling PLL_F80M");
2988                enable_pll_f80m_impl(clocks, false);
2989                release_spll_clk(clocks);
2990            }
2991        }
2992        pub fn pll_f80m_frequency() -> u32 {
2993            (spll_clk_frequency() / 6)
2994        }
2995        pub fn pll_f80m_source_frequency() -> u32 {
2996            spll_clk_frequency()
2997        }
2998        pub fn request_pll_f120m(clocks: &mut ClockTree) {
2999            trace!("Requesting PLL_F120M");
3000            if increment_reference_count(&mut clocks.pll_f120m_refcount) {
3001                trace!("Enabling PLL_F120M");
3002                request_spll_clk(clocks);
3003                enable_pll_f120m_impl(clocks, true);
3004            }
3005        }
3006        pub fn release_pll_f120m(clocks: &mut ClockTree) {
3007            trace!("Releasing PLL_F120M");
3008            if decrement_reference_count(&mut clocks.pll_f120m_refcount) {
3009                trace!("Disabling PLL_F120M");
3010                enable_pll_f120m_impl(clocks, false);
3011                release_spll_clk(clocks);
3012            }
3013        }
3014        pub fn pll_f120m_frequency() -> u32 {
3015            (spll_clk_frequency() / 4)
3016        }
3017        pub fn pll_f120m_source_frequency() -> u32 {
3018            spll_clk_frequency()
3019        }
3020        pub fn request_pll_f160m(clocks: &mut ClockTree) {
3021            trace!("Requesting PLL_F160M");
3022            trace!("Enabling PLL_F160M");
3023            request_spll_clk(clocks);
3024            enable_pll_f160m_impl(clocks, true);
3025        }
3026        pub fn release_pll_f160m(clocks: &mut ClockTree) {
3027            trace!("Releasing PLL_F160M");
3028            trace!("Disabling PLL_F160M");
3029            enable_pll_f160m_impl(clocks, false);
3030            release_spll_clk(clocks);
3031        }
3032        pub fn pll_f160m_frequency() -> u32 {
3033            (spll_clk_frequency() / 3)
3034        }
3035        pub fn pll_f160m_source_frequency() -> u32 {
3036            spll_clk_frequency()
3037        }
3038        pub fn request_pll_f240m(clocks: &mut ClockTree) {
3039            trace!("Requesting PLL_F240M");
3040            trace!("Enabling PLL_F240M");
3041            request_spll_clk(clocks);
3042            enable_pll_f240m_impl(clocks, true);
3043        }
3044        pub fn release_pll_f240m(clocks: &mut ClockTree) {
3045            trace!("Releasing PLL_F240M");
3046            trace!("Disabling PLL_F240M");
3047            enable_pll_f240m_impl(clocks, false);
3048            release_spll_clk(clocks);
3049        }
3050        pub fn pll_f240m_frequency() -> u32 {
3051            (spll_clk_frequency() / 2)
3052        }
3053        pub fn pll_f240m_source_frequency() -> u32 {
3054            spll_clk_frequency()
3055        }
3056        pub fn configure_iomux_function_clock(
3057            clocks: &mut ClockTree,
3058            config: IomuxFunctionClockConfig,
3059        ) {
3060            let old_config = clocks.iomux_function_clock.replace(config);
3061            refresh_iomux_function_clock_downstream(clocks);
3062            match config.source {
3063                IomuxFunctionClockSource::XtalClk => request_xtal_clk(clocks),
3064                IomuxFunctionClockSource::PllF80m => request_pll_f80m(clocks),
3065            }
3066            configure_iomux_function_clock_impl(clocks, old_config, config);
3067            if let Some(old_config) = old_config {
3068                match old_config.source {
3069                    IomuxFunctionClockSource::XtalClk => release_xtal_clk(clocks),
3070                    IomuxFunctionClockSource::PllF80m => release_pll_f80m(clocks),
3071                }
3072            }
3073        }
3074        pub fn iomux_function_clock_config(
3075            clocks: &mut ClockTree,
3076        ) -> Option<IomuxFunctionClockConfig> {
3077            clocks.iomux_function_clock
3078        }
3079        fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
3080        fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
3081        #[allow(unused_variables)]
3082        pub fn iomux_function_clock_config_frequency(
3083            clocks: &mut ClockTree,
3084            config: IomuxFunctionClockConfig,
3085        ) -> u32 {
3086            (match config.source {
3087                IomuxFunctionClockSource::XtalClk => xtal_clk_frequency(),
3088                IomuxFunctionClockSource::PllF80m => pll_f80m_frequency(),
3089            } / (config.div_num() + 1))
3090        }
3091        pub fn iomux_function_clock_frequency() -> u32 {
3092            IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3093        }
3094        pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockSource) -> u32 {
3095            match source {
3096                IomuxFunctionClockSource::XtalClk => xtal_clk_frequency(),
3097                IomuxFunctionClockSource::PllF80m => pll_f80m_frequency(),
3098            }
3099        }
3100        pub fn request_pll_f25m(clocks: &mut ClockTree) {
3101            trace!("Requesting PLL_F25M");
3102            trace!("Enabling PLL_F25M");
3103            request_mpll_clk(clocks);
3104            enable_pll_f25m_impl(clocks, true);
3105        }
3106        pub fn release_pll_f25m(clocks: &mut ClockTree) {
3107            trace!("Releasing PLL_F25M");
3108            trace!("Disabling PLL_F25M");
3109            enable_pll_f25m_impl(clocks, false);
3110            release_mpll_clk(clocks);
3111        }
3112        pub fn pll_f25m_frequency() -> u32 {
3113            (mpll_clk_frequency() / 20)
3114        }
3115        pub fn pll_f25m_source_frequency() -> u32 {
3116            mpll_clk_frequency()
3117        }
3118        pub fn request_pll_f50m(clocks: &mut ClockTree) {
3119            trace!("Requesting PLL_F50M");
3120            if increment_reference_count(&mut clocks.pll_f50m_refcount) {
3121                trace!("Enabling PLL_F50M");
3122                request_mpll_clk(clocks);
3123                enable_pll_f50m_impl(clocks, true);
3124            }
3125        }
3126        pub fn release_pll_f50m(clocks: &mut ClockTree) {
3127            trace!("Releasing PLL_F50M");
3128            if decrement_reference_count(&mut clocks.pll_f50m_refcount) {
3129                trace!("Disabling PLL_F50M");
3130                enable_pll_f50m_impl(clocks, false);
3131                release_mpll_clk(clocks);
3132            }
3133        }
3134        pub fn pll_f50m_frequency() -> u32 {
3135            (mpll_clk_frequency() / 10)
3136        }
3137        pub fn pll_f50m_source_frequency() -> u32 {
3138            mpll_clk_frequency()
3139        }
3140        pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
3141            trace!("Requesting XTAL_D2_CLK");
3142            trace!("Enabling XTAL_D2_CLK");
3143            request_xtal_clk(clocks);
3144            enable_xtal_d2_clk_impl(clocks, true);
3145        }
3146        pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
3147            trace!("Releasing XTAL_D2_CLK");
3148            trace!("Disabling XTAL_D2_CLK");
3149            enable_xtal_d2_clk_impl(clocks, false);
3150            release_xtal_clk(clocks);
3151        }
3152        pub fn xtal_d2_clk_frequency() -> u32 {
3153            (xtal_clk_frequency() / 2)
3154        }
3155        pub fn xtal_d2_clk_source_frequency() -> u32 {
3156            xtal_clk_frequency()
3157        }
3158        pub fn configure_cpu_root_clk(clocks: &mut ClockTree, new_selector: CpuRootClkConfig) {
3159            let old_selector = clocks.cpu_root_clk.replace(new_selector);
3160            refresh_cpu_root_clk_downstream(clocks);
3161            match new_selector {
3162                CpuRootClkConfig::Xtal => request_xtal_clk(clocks),
3163                CpuRootClkConfig::Cpll => request_cpll_clk(clocks),
3164                CpuRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3165            }
3166            configure_cpu_root_clk_impl(clocks, old_selector, new_selector);
3167            if let Some(old_selector) = old_selector {
3168                match old_selector {
3169                    CpuRootClkConfig::Xtal => release_xtal_clk(clocks),
3170                    CpuRootClkConfig::Cpll => release_cpll_clk(clocks),
3171                    CpuRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3172                }
3173            }
3174        }
3175        pub fn cpu_root_clk_config(clocks: &mut ClockTree) -> Option<CpuRootClkConfig> {
3176            clocks.cpu_root_clk
3177        }
3178        pub fn request_cpu_root_clk(clocks: &mut ClockTree) {
3179            trace!("Requesting CPU_ROOT_CLK");
3180            trace!("Enabling CPU_ROOT_CLK");
3181            match unwrap!(clocks.cpu_root_clk) {
3182                CpuRootClkConfig::Xtal => request_xtal_clk(clocks),
3183                CpuRootClkConfig::Cpll => request_cpll_clk(clocks),
3184                CpuRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3185            }
3186            enable_cpu_root_clk_impl(clocks, true);
3187        }
3188        pub fn release_cpu_root_clk(clocks: &mut ClockTree) {
3189            trace!("Releasing CPU_ROOT_CLK");
3190            trace!("Disabling CPU_ROOT_CLK");
3191            enable_cpu_root_clk_impl(clocks, false);
3192            match unwrap!(clocks.cpu_root_clk) {
3193                CpuRootClkConfig::Xtal => release_xtal_clk(clocks),
3194                CpuRootClkConfig::Cpll => release_cpll_clk(clocks),
3195                CpuRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3196            }
3197        }
3198        #[allow(unused_variables)]
3199        pub fn cpu_root_clk_config_frequency(
3200            clocks: &mut ClockTree,
3201            config: CpuRootClkConfig,
3202        ) -> u32 {
3203            match config {
3204                CpuRootClkConfig::Xtal => xtal_clk_frequency(),
3205                CpuRootClkConfig::Cpll => cpll_clk_frequency(),
3206                CpuRootClkConfig::RcFast => rc_fast_clk_frequency(),
3207            }
3208        }
3209        pub fn cpu_root_clk_frequency() -> u32 {
3210            CPU_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3211        }
3212        pub fn cpu_root_clk_source_frequency(source: CpuRootClkConfig) -> u32 {
3213            match source {
3214                CpuRootClkConfig::Xtal => xtal_clk_frequency(),
3215                CpuRootClkConfig::Cpll => cpll_clk_frequency(),
3216                CpuRootClkConfig::RcFast => rc_fast_clk_frequency(),
3217            }
3218        }
3219        pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
3220            let old_config = clocks.cpu_clk.replace(config);
3221            refresh_cpu_clk_downstream(clocks);
3222            configure_cpu_clk_impl(clocks, old_config, config);
3223        }
3224        pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
3225            clocks.cpu_clk
3226        }
3227        pub fn request_cpu_clk(clocks: &mut ClockTree) {
3228            trace!("Requesting CPU_CLK");
3229            trace!("Enabling CPU_CLK");
3230            request_cpu_root_clk(clocks);
3231            enable_cpu_clk_impl(clocks, true);
3232        }
3233        pub fn release_cpu_clk(clocks: &mut ClockTree) {
3234            trace!("Releasing CPU_CLK");
3235            trace!("Disabling CPU_CLK");
3236            enable_cpu_clk_impl(clocks, false);
3237            release_cpu_root_clk(clocks);
3238        }
3239        #[allow(unused_variables)]
3240        pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
3241            (cpu_root_clk_frequency() / (config.divisor() + 1))
3242        }
3243        pub fn cpu_clk_frequency() -> u32 {
3244            CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3245        }
3246        pub fn cpu_clk_source_frequency() -> u32 {
3247            cpu_root_clk_frequency()
3248        }
3249        pub fn configure_mem_clk(clocks: &mut ClockTree, config: MemClkConfig) {
3250            let old_config = clocks.mem_clk.replace(config);
3251            refresh_mem_clk_downstream(clocks);
3252            configure_mem_clk_impl(clocks, old_config, config);
3253        }
3254        pub fn mem_clk_config(clocks: &mut ClockTree) -> Option<MemClkConfig> {
3255            clocks.mem_clk
3256        }
3257        pub fn request_mem_clk(clocks: &mut ClockTree) {
3258            trace!("Requesting MEM_CLK");
3259            trace!("Enabling MEM_CLK");
3260            request_cpu_clk(clocks);
3261            enable_mem_clk_impl(clocks, true);
3262        }
3263        pub fn release_mem_clk(clocks: &mut ClockTree) {
3264            trace!("Releasing MEM_CLK");
3265            trace!("Disabling MEM_CLK");
3266            enable_mem_clk_impl(clocks, false);
3267            release_cpu_clk(clocks);
3268        }
3269        #[allow(unused_variables)]
3270        pub fn mem_clk_config_frequency(clocks: &mut ClockTree, config: MemClkConfig) -> u32 {
3271            (cpu_clk_frequency() / (config.divisor() + 1))
3272        }
3273        pub fn mem_clk_frequency() -> u32 {
3274            MEM_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3275        }
3276        pub fn mem_clk_source_frequency() -> u32 {
3277            cpu_clk_frequency()
3278        }
3279        pub fn configure_sys_clk(clocks: &mut ClockTree, config: SysClkConfig) {
3280            let old_config = clocks.sys_clk.replace(config);
3281            refresh_sys_clk_downstream(clocks);
3282            configure_sys_clk_impl(clocks, old_config, config);
3283        }
3284        pub fn sys_clk_config(clocks: &mut ClockTree) -> Option<SysClkConfig> {
3285            clocks.sys_clk
3286        }
3287        pub fn request_sys_clk(clocks: &mut ClockTree) {
3288            trace!("Requesting SYS_CLK");
3289            trace!("Enabling SYS_CLK");
3290            request_mem_clk(clocks);
3291            enable_sys_clk_impl(clocks, true);
3292        }
3293        pub fn release_sys_clk(clocks: &mut ClockTree) {
3294            trace!("Releasing SYS_CLK");
3295            trace!("Disabling SYS_CLK");
3296            enable_sys_clk_impl(clocks, false);
3297            release_mem_clk(clocks);
3298        }
3299        #[allow(unused_variables)]
3300        pub fn sys_clk_config_frequency(clocks: &mut ClockTree, config: SysClkConfig) -> u32 {
3301            (mem_clk_frequency() / (config.divisor() + 1))
3302        }
3303        pub fn sys_clk_frequency() -> u32 {
3304            SYS_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3305        }
3306        pub fn sys_clk_source_frequency() -> u32 {
3307            mem_clk_frequency()
3308        }
3309        pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
3310            let old_config = clocks.apb_clk.replace(config);
3311            refresh_apb_clk_downstream(clocks);
3312            configure_apb_clk_impl(clocks, old_config, config);
3313        }
3314        pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
3315            clocks.apb_clk
3316        }
3317        pub fn request_apb_clk(clocks: &mut ClockTree) {
3318            trace!("Requesting APB_CLK");
3319            if increment_reference_count(&mut clocks.apb_clk_refcount) {
3320                trace!("Enabling APB_CLK");
3321                request_sys_clk(clocks);
3322                enable_apb_clk_impl(clocks, true);
3323            }
3324        }
3325        pub fn release_apb_clk(clocks: &mut ClockTree) {
3326            trace!("Releasing APB_CLK");
3327            if decrement_reference_count(&mut clocks.apb_clk_refcount) {
3328                trace!("Disabling APB_CLK");
3329                enable_apb_clk_impl(clocks, false);
3330                release_sys_clk(clocks);
3331            }
3332        }
3333        #[allow(unused_variables)]
3334        pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
3335            (sys_clk_frequency() / (config.divisor() + 1))
3336        }
3337        pub fn apb_clk_frequency() -> u32 {
3338            APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3339        }
3340        pub fn apb_clk_source_frequency() -> u32 {
3341            sys_clk_frequency()
3342        }
3343        pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
3344            let old_selector = clocks.lp_fast_clk.replace(new_selector);
3345            refresh_lp_fast_clk_downstream(clocks);
3346            if clocks.lp_fast_clk_refcount > 0 {
3347                match new_selector {
3348                    LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
3349                    LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
3350                }
3351                configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
3352                if let Some(old_selector) = old_selector {
3353                    match old_selector {
3354                        LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
3355                        LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
3356                    }
3357                }
3358            } else {
3359                configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
3360            }
3361        }
3362        pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
3363            clocks.lp_fast_clk
3364        }
3365        pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
3366            trace!("Requesting LP_FAST_CLK");
3367            if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
3368                trace!("Enabling LP_FAST_CLK");
3369                match unwrap!(clocks.lp_fast_clk) {
3370                    LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
3371                    LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
3372                }
3373                enable_lp_fast_clk_impl(clocks, true);
3374            }
3375        }
3376        pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
3377            trace!("Releasing LP_FAST_CLK");
3378            if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
3379                trace!("Disabling LP_FAST_CLK");
3380                enable_lp_fast_clk_impl(clocks, false);
3381                match unwrap!(clocks.lp_fast_clk) {
3382                    LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
3383                    LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
3384                }
3385            }
3386        }
3387        #[allow(unused_variables)]
3388        pub fn lp_fast_clk_config_frequency(
3389            clocks: &mut ClockTree,
3390            config: LpFastClkConfig,
3391        ) -> u32 {
3392            match config {
3393                LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
3394                LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
3395            }
3396        }
3397        pub fn lp_fast_clk_frequency() -> u32 {
3398            LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3399        }
3400        pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
3401            match source {
3402                LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
3403                LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
3404            }
3405        }
3406        pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
3407            let old_selector = clocks.lp_slow_clk.replace(new_selector);
3408            refresh_lp_slow_clk_downstream(clocks);
3409            match new_selector {
3410                LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3411                LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3412                LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3413            }
3414            configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
3415            if let Some(old_selector) = old_selector {
3416                match old_selector {
3417                    LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3418                    LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3419                    LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3420                }
3421            }
3422        }
3423        pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
3424            clocks.lp_slow_clk
3425        }
3426        pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
3427            trace!("Requesting LP_SLOW_CLK");
3428            trace!("Enabling LP_SLOW_CLK");
3429            match unwrap!(clocks.lp_slow_clk) {
3430                LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3431                LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3432                LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3433            }
3434            enable_lp_slow_clk_impl(clocks, true);
3435        }
3436        pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
3437            trace!("Releasing LP_SLOW_CLK");
3438            trace!("Disabling LP_SLOW_CLK");
3439            enable_lp_slow_clk_impl(clocks, false);
3440            match unwrap!(clocks.lp_slow_clk) {
3441                LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3442                LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3443                LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3444            }
3445        }
3446        #[allow(unused_variables)]
3447        pub fn lp_slow_clk_config_frequency(
3448            clocks: &mut ClockTree,
3449            config: LpSlowClkConfig,
3450        ) -> u32 {
3451            match config {
3452                LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3453                LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3454                LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
3455            }
3456        }
3457        pub fn lp_slow_clk_frequency() -> u32 {
3458            LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3459        }
3460        pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
3461            match source {
3462                LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3463                LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3464                LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
3465            }
3466        }
3467        pub fn configure_timg_calibration_clock(
3468            clocks: &mut ClockTree,
3469            new_selector: TimgCalibrationClockConfig,
3470        ) {
3471            let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3472            refresh_timg_calibration_clock_downstream(clocks);
3473            if clocks.timg_calibration_clock_refcount > 0 {
3474                match new_selector {
3475                    TimgCalibrationClockConfig::MpllClk => request_mpll_clk(clocks),
3476                    TimgCalibrationClockConfig::SpllClk => request_spll_clk(clocks),
3477                    TimgCalibrationClockConfig::CpllClk => request_cpll_clk(clocks),
3478                    TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3479                    TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
3480                    TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3481                }
3482                configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3483                if let Some(old_selector) = old_selector {
3484                    match old_selector {
3485                        TimgCalibrationClockConfig::MpllClk => release_mpll_clk(clocks),
3486                        TimgCalibrationClockConfig::SpllClk => release_spll_clk(clocks),
3487                        TimgCalibrationClockConfig::CpllClk => release_cpll_clk(clocks),
3488                        TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3489                        TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
3490                        TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3491                    }
3492                }
3493            } else {
3494                configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3495            }
3496        }
3497        pub fn timg_calibration_clock_config(
3498            clocks: &mut ClockTree,
3499        ) -> Option<TimgCalibrationClockConfig> {
3500            clocks.timg_calibration_clock
3501        }
3502        pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3503            trace!("Requesting TIMG_CALIBRATION_CLOCK");
3504            if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3505                trace!("Enabling TIMG_CALIBRATION_CLOCK");
3506                crate::rtc_cntl::WakeLock::acquire();
3507                match unwrap!(clocks.timg_calibration_clock) {
3508                    TimgCalibrationClockConfig::MpllClk => request_mpll_clk(clocks),
3509                    TimgCalibrationClockConfig::SpllClk => request_spll_clk(clocks),
3510                    TimgCalibrationClockConfig::CpllClk => request_cpll_clk(clocks),
3511                    TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3512                    TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
3513                    TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3514                }
3515                enable_timg_calibration_clock_impl(clocks, true);
3516            }
3517        }
3518        pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3519            trace!("Releasing TIMG_CALIBRATION_CLOCK");
3520            if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3521                trace!("Disabling TIMG_CALIBRATION_CLOCK");
3522                crate::rtc_cntl::WakeLock::release();
3523                enable_timg_calibration_clock_impl(clocks, false);
3524                match unwrap!(clocks.timg_calibration_clock) {
3525                    TimgCalibrationClockConfig::MpllClk => release_mpll_clk(clocks),
3526                    TimgCalibrationClockConfig::SpllClk => release_spll_clk(clocks),
3527                    TimgCalibrationClockConfig::CpllClk => release_cpll_clk(clocks),
3528                    TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3529                    TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
3530                    TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3531                }
3532            }
3533        }
3534        #[allow(unused_variables)]
3535        pub fn timg_calibration_clock_config_frequency(
3536            clocks: &mut ClockTree,
3537            config: TimgCalibrationClockConfig,
3538        ) -> u32 {
3539            match config {
3540                TimgCalibrationClockConfig::MpllClk => mpll_clk_frequency(),
3541                TimgCalibrationClockConfig::SpllClk => spll_clk_frequency(),
3542                TimgCalibrationClockConfig::CpllClk => cpll_clk_frequency(),
3543                TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3544                TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
3545                TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3546            }
3547        }
3548        pub fn timg_calibration_clock_frequency() -> u32 {
3549            TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3550        }
3551        pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3552            match source {
3553                TimgCalibrationClockConfig::MpllClk => mpll_clk_frequency(),
3554                TimgCalibrationClockConfig::SpllClk => spll_clk_frequency(),
3555                TimgCalibrationClockConfig::CpllClk => cpll_clk_frequency(),
3556                TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3557                TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
3558                TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3559            }
3560        }
3561        impl SdmInstance {
3562            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3563                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3564                if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3565                {
3566                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3567                    request_iomux_function_clock(clocks);
3568                    self.enable_function_clock_impl(clocks, true);
3569                }
3570            }
3571            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3572                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3573                if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3574                {
3575                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3576                    self.enable_function_clock_impl(clocks, false);
3577                    release_iomux_function_clock(clocks);
3578                }
3579            }
3580            pub fn function_clock_frequency(self) -> u32 {
3581                iomux_function_clock_frequency()
3582            }
3583            pub fn function_clock_source_frequency() -> u32 {
3584                iomux_function_clock_frequency()
3585            }
3586        }
3587        impl TimgInstance {
3588            pub fn configure_function_clock(
3589                self,
3590                clocks: &mut ClockTree,
3591                new_selector: TimgFunctionClockConfig,
3592            ) {
3593                let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3594                refresh_timg_function_clock_downstream(clocks, self);
3595                if clocks.timg_function_clock_refcount[self as usize] > 0 {
3596                    match new_selector {
3597                        TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3598                        TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3599                        TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3600                    }
3601                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
3602                    if let Some(old_selector) = old_selector {
3603                        match old_selector {
3604                            TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3605                            TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3606                            TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3607                        }
3608                    }
3609                } else {
3610                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
3611                }
3612            }
3613            pub fn function_clock_config(
3614                self,
3615                clocks: &mut ClockTree,
3616            ) -> Option<TimgFunctionClockConfig> {
3617                clocks.timg_function_clock[self as usize]
3618            }
3619            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3620                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3621                if increment_reference_count(
3622                    &mut clocks.timg_function_clock_refcount[self as usize],
3623                ) {
3624                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3625                    match unwrap!(clocks.timg_function_clock[self as usize]) {
3626                        TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3627                        TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3628                        TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3629                    }
3630                    self.enable_function_clock_impl(clocks, true);
3631                }
3632            }
3633            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3634                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3635                if decrement_reference_count(
3636                    &mut clocks.timg_function_clock_refcount[self as usize],
3637                ) {
3638                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3639                    self.enable_function_clock_impl(clocks, false);
3640                    match unwrap!(clocks.timg_function_clock[self as usize]) {
3641                        TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3642                        TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3643                        TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3644                    }
3645                }
3646            }
3647            #[allow(unused_variables)]
3648            pub fn function_clock_config_frequency(
3649                clocks: &mut ClockTree,
3650                config: TimgFunctionClockConfig,
3651            ) -> u32 {
3652                match config {
3653                    TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3654                    TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3655                    TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3656                }
3657            }
3658            pub fn function_clock_frequency(self) -> u32 {
3659                TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3660                    .load(::core::sync::atomic::Ordering::Acquire)
3661            }
3662            pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3663                match source {
3664                    TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3665                    TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3666                    TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3667                }
3668            }
3669            pub fn configure_wdt_clock(
3670                self,
3671                clocks: &mut ClockTree,
3672                new_selector: TimgWdtClockConfig,
3673            ) {
3674                let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3675                refresh_timg_wdt_clock_downstream(clocks, self);
3676                if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
3677                    match new_selector {
3678                        TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3679                        TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3680                        TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3681                    }
3682                    self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3683                    if let Some(old_selector) = old_selector {
3684                        match old_selector {
3685                            TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3686                            TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3687                            TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3688                        }
3689                    }
3690                } else {
3691                    self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3692                }
3693            }
3694            pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3695                clocks.timg_wdt_clock[self as usize]
3696            }
3697            pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3698                trace!("Requesting {:?}::WDT_CLOCK", self);
3699                if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3700                    trace!("Enabling {:?}::WDT_CLOCK", self);
3701                    match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3702                        TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3703                        TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3704                        TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3705                    }
3706                    self.enable_wdt_clock_impl(clocks, true);
3707                }
3708            }
3709            pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3710                trace!("Releasing {:?}::WDT_CLOCK", self);
3711                if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3712                    trace!("Disabling {:?}::WDT_CLOCK", self);
3713                    self.enable_wdt_clock_impl(clocks, false);
3714                    match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3715                        TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3716                        TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3717                        TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3718                    }
3719                }
3720            }
3721            #[allow(unused_variables)]
3722            pub fn wdt_clock_config_frequency(
3723                clocks: &mut ClockTree,
3724                config: TimgWdtClockConfig,
3725            ) -> u32 {
3726                match config {
3727                    TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3728                    TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3729                    TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3730                }
3731            }
3732            pub fn wdt_clock_frequency(self) -> u32 {
3733                TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3734                    .load(::core::sync::atomic::Ordering::Acquire)
3735            }
3736            pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3737                match source {
3738                    TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3739                    TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3740                    TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3741                }
3742            }
3743        }
3744        impl UartInstance {
3745            pub fn configure_function_clock(
3746                self,
3747                clocks: &mut ClockTree,
3748                config: UartFunctionClockConfig,
3749            ) {
3750                let old_config = clocks.uart_function_clock[self as usize].replace(config);
3751                refresh_uart_function_clock_downstream(clocks, self);
3752                if clocks.uart_function_clock_refcount[self as usize] > 0 {
3753                    match config.sclk {
3754                        UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3755                        UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3756                        UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3757                    }
3758                    self.configure_function_clock_impl(clocks, old_config, config);
3759                    if let Some(old_config) = old_config {
3760                        match old_config.sclk {
3761                            UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3762                            UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3763                            UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3764                        }
3765                    }
3766                } else {
3767                    self.configure_function_clock_impl(clocks, old_config, config);
3768                }
3769            }
3770            pub fn function_clock_config(
3771                self,
3772                clocks: &mut ClockTree,
3773            ) -> Option<UartFunctionClockConfig> {
3774                clocks.uart_function_clock[self as usize]
3775            }
3776            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3777                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3778                if increment_reference_count(
3779                    &mut clocks.uart_function_clock_refcount[self as usize],
3780                ) {
3781                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3782                    match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3783                        UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3784                        UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3785                        UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3786                    }
3787                    self.enable_function_clock_impl(clocks, true);
3788                }
3789            }
3790            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3791                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3792                if decrement_reference_count(
3793                    &mut clocks.uart_function_clock_refcount[self as usize],
3794                ) {
3795                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3796                    self.enable_function_clock_impl(clocks, false);
3797                    match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3798                        UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3799                        UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3800                        UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3801                    }
3802                }
3803            }
3804            #[allow(unused_variables)]
3805            pub fn function_clock_config_frequency(
3806                clocks: &mut ClockTree,
3807                config: UartFunctionClockConfig,
3808            ) -> u32 {
3809                (match config.sclk {
3810                    UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3811                    UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3812                    UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3813                } / (config.div_num() + 1))
3814            }
3815            pub fn function_clock_frequency(self) -> u32 {
3816                UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3817                    .load(::core::sync::atomic::Ordering::Acquire)
3818            }
3819            pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3820                match sclk {
3821                    UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3822                    UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3823                    UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3824                }
3825            }
3826            pub fn configure_baud_rate_generator(
3827                self,
3828                clocks: &mut ClockTree,
3829                config: UartBaudRateGeneratorConfig,
3830            ) {
3831                let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3832                refresh_uart_baud_rate_generator_downstream(clocks, self);
3833                self.configure_baud_rate_generator_impl(clocks, old_config, config);
3834            }
3835            pub fn baud_rate_generator_config(
3836                self,
3837                clocks: &mut ClockTree,
3838            ) -> Option<UartBaudRateGeneratorConfig> {
3839                clocks.uart_baud_rate_generator[self as usize]
3840            }
3841            pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3842                trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3843                if increment_reference_count(
3844                    &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3845                ) {
3846                    trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3847                    self.request_function_clock(clocks);
3848                    self.enable_baud_rate_generator_impl(clocks, true);
3849                }
3850            }
3851            pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3852                trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3853                if decrement_reference_count(
3854                    &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3855                ) {
3856                    trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3857                    self.enable_baud_rate_generator_impl(clocks, false);
3858                    self.release_function_clock(clocks);
3859                }
3860            }
3861            #[allow(unused_variables)]
3862            pub fn baud_rate_generator_config_frequency(
3863                self,
3864                clocks: &mut ClockTree,
3865                config: UartBaudRateGeneratorConfig,
3866            ) -> u32 {
3867                ((self.function_clock_frequency() * 16)
3868                    / ((config.integral() * 16) + config.fractional()))
3869            }
3870            pub fn baud_rate_generator_frequency(self) -> u32 {
3871                UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3872                    .load(::core::sync::atomic::Ordering::Acquire)
3873            }
3874        }
3875        impl SpiInstance {
3876            pub fn configure_function_clock(
3877                self,
3878                clocks: &mut ClockTree,
3879                new_selector: SpiFunctionClockConfig,
3880            ) {
3881                let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3882                refresh_spi_function_clock_downstream(clocks, self);
3883                if clocks.spi_function_clock_refcount[self as usize] > 0 {
3884                    match new_selector {
3885                        SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3886                        SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3887                        SpiFunctionClockConfig::Spll => request_spll_clk(clocks),
3888                    }
3889                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
3890                    if let Some(old_selector) = old_selector {
3891                        match old_selector {
3892                            SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3893                            SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3894                            SpiFunctionClockConfig::Spll => release_spll_clk(clocks),
3895                        }
3896                    }
3897                } else {
3898                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
3899                }
3900            }
3901            pub fn function_clock_config(
3902                self,
3903                clocks: &mut ClockTree,
3904            ) -> Option<SpiFunctionClockConfig> {
3905                clocks.spi_function_clock[self as usize]
3906            }
3907            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3908                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3909                if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3910                {
3911                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3912                    match unwrap!(clocks.spi_function_clock[self as usize]) {
3913                        SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3914                        SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3915                        SpiFunctionClockConfig::Spll => request_spll_clk(clocks),
3916                    }
3917                    self.enable_function_clock_impl(clocks, true);
3918                }
3919            }
3920            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3921                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3922                if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3923                {
3924                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3925                    self.enable_function_clock_impl(clocks, false);
3926                    match unwrap!(clocks.spi_function_clock[self as usize]) {
3927                        SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3928                        SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3929                        SpiFunctionClockConfig::Spll => release_spll_clk(clocks),
3930                    }
3931                }
3932            }
3933            #[allow(unused_variables)]
3934            pub fn function_clock_config_frequency(
3935                clocks: &mut ClockTree,
3936                config: SpiFunctionClockConfig,
3937            ) -> u32 {
3938                match config {
3939                    SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3940                    SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3941                    SpiFunctionClockConfig::Spll => spll_clk_frequency(),
3942                }
3943            }
3944            pub fn function_clock_frequency(self) -> u32 {
3945                SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3946                    .load(::core::sync::atomic::Ordering::Acquire)
3947            }
3948            pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3949                match source {
3950                    SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3951                    SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3952                    SpiFunctionClockConfig::Spll => spll_clk_frequency(),
3953                }
3954            }
3955        }
3956        impl I2cInstance {
3957            pub fn configure_function_clock(
3958                self,
3959                clocks: &mut ClockTree,
3960                config: I2cFunctionClockConfig,
3961            ) {
3962                let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3963                refresh_i2c_function_clock_downstream(clocks, self);
3964                if clocks.i2c_function_clock_refcount[self as usize] > 0 {
3965                    match config.sclk {
3966                        I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3967                        I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3968                    }
3969                    self.configure_function_clock_impl(clocks, old_config, config);
3970                    if let Some(old_config) = old_config {
3971                        match old_config.sclk {
3972                            I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3973                            I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3974                        }
3975                    }
3976                } else {
3977                    self.configure_function_clock_impl(clocks, old_config, config);
3978                }
3979            }
3980            pub fn function_clock_config(
3981                self,
3982                clocks: &mut ClockTree,
3983            ) -> Option<I2cFunctionClockConfig> {
3984                clocks.i2c_function_clock[self as usize]
3985            }
3986            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3987                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3988                if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3989                {
3990                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3991                    match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3992                        I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3993                        I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3994                    }
3995                    self.enable_function_clock_impl(clocks, true);
3996                }
3997            }
3998            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3999                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4000                if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
4001                {
4002                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4003                    self.enable_function_clock_impl(clocks, false);
4004                    match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
4005                        I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4006                        I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4007                    }
4008                }
4009            }
4010            #[allow(unused_variables)]
4011            pub fn function_clock_config_frequency(
4012                clocks: &mut ClockTree,
4013                config: I2cFunctionClockConfig,
4014            ) -> u32 {
4015                (match config.sclk {
4016                    I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4017                    I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4018                } / (config.div_num() + 1))
4019            }
4020            pub fn function_clock_frequency(self) -> u32 {
4021                I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4022                    .load(::core::sync::atomic::Ordering::Acquire)
4023            }
4024            pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
4025                match sclk {
4026                    I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4027                    I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4028                }
4029            }
4030        }
4031        impl MipiDsiInstance {
4032            pub fn configure_dpi_clk(self, clocks: &mut ClockTree, config: MipiDsiDpiClkConfig) {
4033                let old_config = clocks.mipi_dsi_dpi_clk[self as usize].replace(config);
4034                refresh_mipi_dsi_dpi_clk_downstream(clocks, self);
4035                if clocks.mipi_dsi_dpi_clk_refcount[self as usize] > 0 {
4036                    match config.sclk {
4037                        MipiDsiDpiClkSclk::Xtal => request_xtal_clk(clocks),
4038                        MipiDsiDpiClkSclk::PllF240m => request_pll_f240m(clocks),
4039                        MipiDsiDpiClkSclk::PllF160m => request_pll_f160m(clocks),
4040                    }
4041                    self.configure_dpi_clk_impl(clocks, old_config, config);
4042                    if let Some(old_config) = old_config {
4043                        match old_config.sclk {
4044                            MipiDsiDpiClkSclk::Xtal => release_xtal_clk(clocks),
4045                            MipiDsiDpiClkSclk::PllF240m => release_pll_f240m(clocks),
4046                            MipiDsiDpiClkSclk::PllF160m => release_pll_f160m(clocks),
4047                        }
4048                    }
4049                } else {
4050                    self.configure_dpi_clk_impl(clocks, old_config, config);
4051                }
4052            }
4053            pub fn dpi_clk_config(self, clocks: &mut ClockTree) -> Option<MipiDsiDpiClkConfig> {
4054                clocks.mipi_dsi_dpi_clk[self as usize]
4055            }
4056            pub fn request_dpi_clk(self, clocks: &mut ClockTree) {
4057                trace!("Requesting {:?}::DPI_CLK", self);
4058                if increment_reference_count(&mut clocks.mipi_dsi_dpi_clk_refcount[self as usize]) {
4059                    trace!("Enabling {:?}::DPI_CLK", self);
4060                    match unwrap!(clocks.mipi_dsi_dpi_clk[self as usize]).sclk {
4061                        MipiDsiDpiClkSclk::Xtal => request_xtal_clk(clocks),
4062                        MipiDsiDpiClkSclk::PllF240m => request_pll_f240m(clocks),
4063                        MipiDsiDpiClkSclk::PllF160m => request_pll_f160m(clocks),
4064                    }
4065                    self.enable_dpi_clk_impl(clocks, true);
4066                }
4067            }
4068            pub fn release_dpi_clk(self, clocks: &mut ClockTree) {
4069                trace!("Releasing {:?}::DPI_CLK", self);
4070                if decrement_reference_count(&mut clocks.mipi_dsi_dpi_clk_refcount[self as usize]) {
4071                    trace!("Disabling {:?}::DPI_CLK", self);
4072                    self.enable_dpi_clk_impl(clocks, false);
4073                    match unwrap!(clocks.mipi_dsi_dpi_clk[self as usize]).sclk {
4074                        MipiDsiDpiClkSclk::Xtal => release_xtal_clk(clocks),
4075                        MipiDsiDpiClkSclk::PllF240m => release_pll_f240m(clocks),
4076                        MipiDsiDpiClkSclk::PllF160m => release_pll_f160m(clocks),
4077                    }
4078                }
4079            }
4080            #[allow(unused_variables)]
4081            pub fn dpi_clk_config_frequency(
4082                clocks: &mut ClockTree,
4083                config: MipiDsiDpiClkConfig,
4084            ) -> u32 {
4085                (match config.sclk {
4086                    MipiDsiDpiClkSclk::Xtal => xtal_clk_frequency(),
4087                    MipiDsiDpiClkSclk::PllF240m => pll_f240m_frequency(),
4088                    MipiDsiDpiClkSclk::PllF160m => pll_f160m_frequency(),
4089                } / (config.div_num() + 1))
4090            }
4091            pub fn dpi_clk_frequency(self) -> u32 {
4092                MIPI_DSI_DPI_CLK_FREQ_CACHE[self as usize]
4093                    .load(::core::sync::atomic::Ordering::Acquire)
4094            }
4095            pub fn dpi_clk_source_frequency(sclk: MipiDsiDpiClkSclk) -> u32 {
4096                match sclk {
4097                    MipiDsiDpiClkSclk::Xtal => xtal_clk_frequency(),
4098                    MipiDsiDpiClkSclk::PllF240m => pll_f240m_frequency(),
4099                    MipiDsiDpiClkSclk::PllF160m => pll_f160m_frequency(),
4100                }
4101            }
4102            pub fn configure_phy_pll_refclk(
4103                self,
4104                clocks: &mut ClockTree,
4105                config: MipiDsiPhyPllRefclkConfig,
4106            ) {
4107                let old_config = clocks.mipi_dsi_phy_pll_refclk[self as usize].replace(config);
4108                refresh_mipi_dsi_phy_pll_refclk_downstream(clocks, self);
4109                if clocks.mipi_dsi_phy_pll_refclk_refcount[self as usize] > 0 {
4110                    match config.sclk {
4111                        MipiDsiPhyPllRefclkSclk::Xtal => request_xtal_clk(clocks),
4112                        MipiDsiPhyPllRefclkSclk::Cpll => request_cpll_clk(clocks),
4113                        MipiDsiPhyPllRefclkSclk::Spll => request_spll_clk(clocks),
4114                        MipiDsiPhyPllRefclkSclk::Mpll => request_mpll_clk(clocks),
4115                    }
4116                    self.configure_phy_pll_refclk_impl(clocks, old_config, config);
4117                    if let Some(old_config) = old_config {
4118                        match old_config.sclk {
4119                            MipiDsiPhyPllRefclkSclk::Xtal => release_xtal_clk(clocks),
4120                            MipiDsiPhyPllRefclkSclk::Cpll => release_cpll_clk(clocks),
4121                            MipiDsiPhyPllRefclkSclk::Spll => release_spll_clk(clocks),
4122                            MipiDsiPhyPllRefclkSclk::Mpll => release_mpll_clk(clocks),
4123                        }
4124                    }
4125                } else {
4126                    self.configure_phy_pll_refclk_impl(clocks, old_config, config);
4127                }
4128            }
4129            pub fn phy_pll_refclk_config(
4130                self,
4131                clocks: &mut ClockTree,
4132            ) -> Option<MipiDsiPhyPllRefclkConfig> {
4133                clocks.mipi_dsi_phy_pll_refclk[self as usize]
4134            }
4135            pub fn request_phy_pll_refclk(self, clocks: &mut ClockTree) {
4136                trace!("Requesting {:?}::PHY_PLL_REFCLK", self);
4137                if increment_reference_count(
4138                    &mut clocks.mipi_dsi_phy_pll_refclk_refcount[self as usize],
4139                ) {
4140                    trace!("Enabling {:?}::PHY_PLL_REFCLK", self);
4141                    match unwrap!(clocks.mipi_dsi_phy_pll_refclk[self as usize]).sclk {
4142                        MipiDsiPhyPllRefclkSclk::Xtal => request_xtal_clk(clocks),
4143                        MipiDsiPhyPllRefclkSclk::Cpll => request_cpll_clk(clocks),
4144                        MipiDsiPhyPllRefclkSclk::Spll => request_spll_clk(clocks),
4145                        MipiDsiPhyPllRefclkSclk::Mpll => request_mpll_clk(clocks),
4146                    }
4147                    self.enable_phy_pll_refclk_impl(clocks, true);
4148                }
4149            }
4150            pub fn release_phy_pll_refclk(self, clocks: &mut ClockTree) {
4151                trace!("Releasing {:?}::PHY_PLL_REFCLK", self);
4152                if decrement_reference_count(
4153                    &mut clocks.mipi_dsi_phy_pll_refclk_refcount[self as usize],
4154                ) {
4155                    trace!("Disabling {:?}::PHY_PLL_REFCLK", self);
4156                    self.enable_phy_pll_refclk_impl(clocks, false);
4157                    match unwrap!(clocks.mipi_dsi_phy_pll_refclk[self as usize]).sclk {
4158                        MipiDsiPhyPllRefclkSclk::Xtal => release_xtal_clk(clocks),
4159                        MipiDsiPhyPllRefclkSclk::Cpll => release_cpll_clk(clocks),
4160                        MipiDsiPhyPllRefclkSclk::Spll => release_spll_clk(clocks),
4161                        MipiDsiPhyPllRefclkSclk::Mpll => release_mpll_clk(clocks),
4162                    }
4163                }
4164            }
4165            #[allow(unused_variables)]
4166            pub fn phy_pll_refclk_config_frequency(
4167                clocks: &mut ClockTree,
4168                config: MipiDsiPhyPllRefclkConfig,
4169            ) -> u32 {
4170                (match config.sclk {
4171                    MipiDsiPhyPllRefclkSclk::Xtal => xtal_clk_frequency(),
4172                    MipiDsiPhyPllRefclkSclk::Cpll => cpll_clk_frequency(),
4173                    MipiDsiPhyPllRefclkSclk::Spll => spll_clk_frequency(),
4174                    MipiDsiPhyPllRefclkSclk::Mpll => mpll_clk_frequency(),
4175                } / (config.div_num() + 1))
4176            }
4177            pub fn phy_pll_refclk_frequency(self) -> u32 {
4178                MIPI_DSI_PHY_PLL_REFCLK_FREQ_CACHE[self as usize]
4179                    .load(::core::sync::atomic::Ordering::Acquire)
4180            }
4181            pub fn phy_pll_refclk_source_frequency(sclk: MipiDsiPhyPllRefclkSclk) -> u32 {
4182                match sclk {
4183                    MipiDsiPhyPllRefclkSclk::Xtal => xtal_clk_frequency(),
4184                    MipiDsiPhyPllRefclkSclk::Cpll => cpll_clk_frequency(),
4185                    MipiDsiPhyPllRefclkSclk::Spll => spll_clk_frequency(),
4186                    MipiDsiPhyPllRefclkSclk::Mpll => mpll_clk_frequency(),
4187                }
4188            }
4189            pub fn configure_phy_cfg_clk(
4190                self,
4191                clocks: &mut ClockTree,
4192                new_selector: MipiDsiPhyCfgClkConfig,
4193            ) {
4194                let old_selector = clocks.mipi_dsi_phy_cfg_clk[self as usize].replace(new_selector);
4195                refresh_mipi_dsi_phy_cfg_clk_downstream(clocks, self);
4196                if clocks.mipi_dsi_phy_cfg_clk_refcount[self as usize] > 0 {
4197                    match new_selector {
4198                        MipiDsiPhyCfgClkConfig::PllF20m => request_pll_f20m(clocks),
4199                        MipiDsiPhyCfgClkConfig::RcFast => request_rc_fast_clk(clocks),
4200                        MipiDsiPhyCfgClkConfig::PllF25m => request_pll_f25m(clocks),
4201                    }
4202                    self.configure_phy_cfg_clk_impl(clocks, old_selector, new_selector);
4203                    if let Some(old_selector) = old_selector {
4204                        match old_selector {
4205                            MipiDsiPhyCfgClkConfig::PllF20m => release_pll_f20m(clocks),
4206                            MipiDsiPhyCfgClkConfig::RcFast => release_rc_fast_clk(clocks),
4207                            MipiDsiPhyCfgClkConfig::PllF25m => release_pll_f25m(clocks),
4208                        }
4209                    }
4210                } else {
4211                    self.configure_phy_cfg_clk_impl(clocks, old_selector, new_selector);
4212                }
4213            }
4214            pub fn phy_cfg_clk_config(
4215                self,
4216                clocks: &mut ClockTree,
4217            ) -> Option<MipiDsiPhyCfgClkConfig> {
4218                clocks.mipi_dsi_phy_cfg_clk[self as usize]
4219            }
4220            pub fn request_phy_cfg_clk(self, clocks: &mut ClockTree) {
4221                trace!("Requesting {:?}::PHY_CFG_CLK", self);
4222                if increment_reference_count(
4223                    &mut clocks.mipi_dsi_phy_cfg_clk_refcount[self as usize],
4224                ) {
4225                    trace!("Enabling {:?}::PHY_CFG_CLK", self);
4226                    match unwrap!(clocks.mipi_dsi_phy_cfg_clk[self as usize]) {
4227                        MipiDsiPhyCfgClkConfig::PllF20m => request_pll_f20m(clocks),
4228                        MipiDsiPhyCfgClkConfig::RcFast => request_rc_fast_clk(clocks),
4229                        MipiDsiPhyCfgClkConfig::PllF25m => request_pll_f25m(clocks),
4230                    }
4231                    self.enable_phy_cfg_clk_impl(clocks, true);
4232                }
4233            }
4234            pub fn release_phy_cfg_clk(self, clocks: &mut ClockTree) {
4235                trace!("Releasing {:?}::PHY_CFG_CLK", self);
4236                if decrement_reference_count(
4237                    &mut clocks.mipi_dsi_phy_cfg_clk_refcount[self as usize],
4238                ) {
4239                    trace!("Disabling {:?}::PHY_CFG_CLK", self);
4240                    self.enable_phy_cfg_clk_impl(clocks, false);
4241                    match unwrap!(clocks.mipi_dsi_phy_cfg_clk[self as usize]) {
4242                        MipiDsiPhyCfgClkConfig::PllF20m => release_pll_f20m(clocks),
4243                        MipiDsiPhyCfgClkConfig::RcFast => release_rc_fast_clk(clocks),
4244                        MipiDsiPhyCfgClkConfig::PllF25m => release_pll_f25m(clocks),
4245                    }
4246                }
4247            }
4248            #[allow(unused_variables)]
4249            pub fn phy_cfg_clk_config_frequency(
4250                clocks: &mut ClockTree,
4251                config: MipiDsiPhyCfgClkConfig,
4252            ) -> u32 {
4253                match config {
4254                    MipiDsiPhyCfgClkConfig::PllF20m => pll_f20m_frequency(),
4255                    MipiDsiPhyCfgClkConfig::RcFast => rc_fast_clk_frequency(),
4256                    MipiDsiPhyCfgClkConfig::PllF25m => pll_f25m_frequency(),
4257                }
4258            }
4259            pub fn phy_cfg_clk_frequency(self) -> u32 {
4260                MIPI_DSI_PHY_CFG_CLK_FREQ_CACHE[self as usize]
4261                    .load(::core::sync::atomic::Ordering::Acquire)
4262            }
4263            pub fn phy_cfg_clk_source_frequency(source: MipiDsiPhyCfgClkConfig) -> u32 {
4264                match source {
4265                    MipiDsiPhyCfgClkConfig::PllF20m => pll_f20m_frequency(),
4266                    MipiDsiPhyCfgClkConfig::RcFast => rc_fast_clk_frequency(),
4267                    MipiDsiPhyCfgClkConfig::PllF25m => pll_f25m_frequency(),
4268                }
4269            }
4270        }
4271        impl RmtInstance {
4272            pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
4273                let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
4274                refresh_rmt_sclk_downstream(clocks, self);
4275                if clocks.rmt_sclk_refcount[self as usize] > 0 {
4276                    match new_selector {
4277                        RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
4278                        RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4279                        RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4280                    }
4281                    self.configure_sclk_impl(clocks, old_selector, new_selector);
4282                    if let Some(old_selector) = old_selector {
4283                        match old_selector {
4284                            RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
4285                            RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4286                            RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4287                        }
4288                    }
4289                } else {
4290                    self.configure_sclk_impl(clocks, old_selector, new_selector);
4291                }
4292            }
4293            pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
4294                clocks.rmt_sclk[self as usize]
4295            }
4296            pub fn request_sclk(self, clocks: &mut ClockTree) {
4297                trace!("Requesting {:?}::SCLK", self);
4298                if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4299                    trace!("Enabling {:?}::SCLK", self);
4300                    crate::rtc_cntl::WakeLock::acquire();
4301                    match unwrap!(clocks.rmt_sclk[self as usize]) {
4302                        RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
4303                        RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4304                        RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4305                    }
4306                    self.enable_sclk_impl(clocks, true);
4307                }
4308            }
4309            pub fn release_sclk(self, clocks: &mut ClockTree) {
4310                trace!("Releasing {:?}::SCLK", self);
4311                if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4312                    trace!("Disabling {:?}::SCLK", self);
4313                    crate::rtc_cntl::WakeLock::release();
4314                    self.enable_sclk_impl(clocks, false);
4315                    match unwrap!(clocks.rmt_sclk[self as usize]) {
4316                        RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
4317                        RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4318                        RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4319                    }
4320                }
4321            }
4322            #[allow(unused_variables)]
4323            pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
4324                match config {
4325                    RmtSclkConfig::PllF80m => pll_f80m_frequency(),
4326                    RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4327                    RmtSclkConfig::XtalClk => xtal_clk_frequency(),
4328                }
4329            }
4330            pub fn sclk_frequency(self) -> u32 {
4331                RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4332            }
4333            pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
4334                match source {
4335                    RmtSclkConfig::PllF80m => pll_f80m_frequency(),
4336                    RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4337                    RmtSclkConfig::XtalClk => xtal_clk_frequency(),
4338                }
4339            }
4340        }
4341        impl PsramInstance {
4342            pub fn configure_function_clock(
4343                self,
4344                clocks: &mut ClockTree,
4345                new_selector: PsramFunctionClockConfig,
4346            ) {
4347                let old_selector = clocks.psram_function_clock[self as usize].replace(new_selector);
4348                refresh_psram_function_clock_downstream(clocks, self);
4349                if clocks.psram_function_clock_refcount[self as usize] > 0 {
4350                    match new_selector {
4351                        PsramFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4352                        PsramFunctionClockConfig::Mpll => request_mpll_clk(clocks),
4353                        PsramFunctionClockConfig::Spll => request_spll_clk(clocks),
4354                        PsramFunctionClockConfig::Cpll => request_cpll_clk(clocks),
4355                    }
4356                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
4357                    if let Some(old_selector) = old_selector {
4358                        match old_selector {
4359                            PsramFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4360                            PsramFunctionClockConfig::Mpll => release_mpll_clk(clocks),
4361                            PsramFunctionClockConfig::Spll => release_spll_clk(clocks),
4362                            PsramFunctionClockConfig::Cpll => release_cpll_clk(clocks),
4363                        }
4364                    }
4365                } else {
4366                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
4367                }
4368            }
4369            pub fn function_clock_config(
4370                self,
4371                clocks: &mut ClockTree,
4372            ) -> Option<PsramFunctionClockConfig> {
4373                clocks.psram_function_clock[self as usize]
4374            }
4375            pub fn request_function_clock(self, clocks: &mut ClockTree) {
4376                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4377                if increment_reference_count(
4378                    &mut clocks.psram_function_clock_refcount[self as usize],
4379                ) {
4380                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4381                    match unwrap!(clocks.psram_function_clock[self as usize]) {
4382                        PsramFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4383                        PsramFunctionClockConfig::Mpll => request_mpll_clk(clocks),
4384                        PsramFunctionClockConfig::Spll => request_spll_clk(clocks),
4385                        PsramFunctionClockConfig::Cpll => request_cpll_clk(clocks),
4386                    }
4387                    self.enable_function_clock_impl(clocks, true);
4388                }
4389            }
4390            pub fn release_function_clock(self, clocks: &mut ClockTree) {
4391                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4392                if decrement_reference_count(
4393                    &mut clocks.psram_function_clock_refcount[self as usize],
4394                ) {
4395                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4396                    self.enable_function_clock_impl(clocks, false);
4397                    match unwrap!(clocks.psram_function_clock[self as usize]) {
4398                        PsramFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4399                        PsramFunctionClockConfig::Mpll => release_mpll_clk(clocks),
4400                        PsramFunctionClockConfig::Spll => release_spll_clk(clocks),
4401                        PsramFunctionClockConfig::Cpll => release_cpll_clk(clocks),
4402                    }
4403                }
4404            }
4405            #[allow(unused_variables)]
4406            pub fn function_clock_config_frequency(
4407                clocks: &mut ClockTree,
4408                config: PsramFunctionClockConfig,
4409            ) -> u32 {
4410                match config {
4411                    PsramFunctionClockConfig::Xtal => xtal_clk_frequency(),
4412                    PsramFunctionClockConfig::Mpll => mpll_clk_frequency(),
4413                    PsramFunctionClockConfig::Spll => spll_clk_frequency(),
4414                    PsramFunctionClockConfig::Cpll => cpll_clk_frequency(),
4415                }
4416            }
4417            pub fn function_clock_frequency(self) -> u32 {
4418                PSRAM_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4419                    .load(::core::sync::atomic::Ordering::Acquire)
4420            }
4421            pub fn function_clock_source_frequency(source: PsramFunctionClockConfig) -> u32 {
4422                match source {
4423                    PsramFunctionClockConfig::Xtal => xtal_clk_frequency(),
4424                    PsramFunctionClockConfig::Mpll => mpll_clk_frequency(),
4425                    PsramFunctionClockConfig::Spll => spll_clk_frequency(),
4426                    PsramFunctionClockConfig::Cpll => cpll_clk_frequency(),
4427                }
4428            }
4429        }
4430        /// Clock tree configuration.
4431        ///
4432        /// The fields of this struct are optional, with the following caveats:
4433        /// - If `XTAL_CLK` is not specified, the crystal frequency will be automatically detected
4434        ///   if possible.
4435        /// - The CPU and its upstream clock nodes will be set to a default configuration.
4436        /// - Other unspecified clock sources will not be useable by peripherals.
4437        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4438        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4439        #[instability::unstable]
4440        pub struct ClockConfig {
4441            /// `CPLL_CLK` configuration.
4442            pub cpll_clk: Option<CpllClkConfig>,
4443            /// `MPLL_CLK` configuration.
4444            pub mpll_clk: Option<MpllClkConfig>,
4445            /// `IOMUX_FUNCTION_CLOCK` configuration.
4446            pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
4447            /// `CPU_ROOT_CLK` configuration.
4448            pub cpu_root_clk: Option<CpuRootClkConfig>,
4449            /// `CPU_CLK` configuration.
4450            pub cpu_clk: Option<CpuClkConfig>,
4451            /// `MEM_CLK` configuration.
4452            pub mem_clk: Option<MemClkConfig>,
4453            /// `SYS_CLK` configuration.
4454            pub sys_clk: Option<SysClkConfig>,
4455            /// `APB_CLK` configuration.
4456            pub apb_clk: Option<ApbClkConfig>,
4457            /// `LP_FAST_CLK` configuration.
4458            pub lp_fast_clk: Option<LpFastClkConfig>,
4459            /// `LP_SLOW_CLK` configuration.
4460            pub lp_slow_clk: Option<LpSlowClkConfig>,
4461            /// `TIMG_CALIBRATION_CLOCK` configuration.
4462            pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
4463        }
4464        impl ClockConfig {
4465            fn apply(&self, clocks: &mut ClockTree) {
4466                if let Some(config) = self.cpll_clk {
4467                    configure_cpll_clk(clocks, config);
4468                }
4469                if let Some(config) = self.mpll_clk {
4470                    configure_mpll_clk(clocks, config);
4471                }
4472                if let Some(config) = self.iomux_function_clock {
4473                    configure_iomux_function_clock(clocks, config);
4474                }
4475                if let Some(config) = self.cpu_root_clk {
4476                    configure_cpu_root_clk(clocks, config);
4477                }
4478                if let Some(config) = self.cpu_clk {
4479                    configure_cpu_clk(clocks, config);
4480                }
4481                if let Some(config) = self.mem_clk {
4482                    configure_mem_clk(clocks, config);
4483                }
4484                if let Some(config) = self.sys_clk {
4485                    configure_sys_clk(clocks, config);
4486                }
4487                if let Some(config) = self.apb_clk {
4488                    configure_apb_clk(clocks, config);
4489                }
4490                if let Some(config) = self.lp_fast_clk {
4491                    configure_lp_fast_clk(clocks, config);
4492                }
4493                if let Some(config) = self.lp_slow_clk {
4494                    configure_lp_slow_clk(clocks, config);
4495                }
4496                if let Some(config) = self.timg_calibration_clock {
4497                    configure_timg_calibration_clock(clocks, config);
4498                }
4499            }
4500        }
4501        fn increment_reference_count(refcount: &mut u32) -> bool {
4502            let first = *refcount == 0;
4503            *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
4504            first
4505        }
4506        fn decrement_reference_count(refcount: &mut u32) -> bool {
4507            *refcount = refcount.saturating_sub(1);
4508            let last = *refcount == 0;
4509            last
4510        }
4511        fn refresh_cpll_clk_downstream(clocks: &mut ClockTree) {
4512            if let Some(config) = clocks.cpll_clk {
4513                CPLL_CLK_FREQ_CACHE.store(
4514                    cpll_clk_config_frequency(clocks, config),
4515                    ::core::sync::atomic::Ordering::Release,
4516                );
4517            }
4518            refresh_cpu_root_clk_downstream(clocks);
4519            refresh_timg_calibration_clock_downstream(clocks);
4520            for child_instance in [MipiDsiInstance::MipiDsi] {
4521                refresh_mipi_dsi_phy_pll_refclk_downstream(clocks, child_instance);
4522            }
4523            for child_instance in [PsramInstance::Psram] {
4524                refresh_psram_function_clock_downstream(clocks, child_instance);
4525            }
4526        }
4527        fn refresh_mpll_clk_downstream(clocks: &mut ClockTree) {
4528            if let Some(config) = clocks.mpll_clk {
4529                MPLL_CLK_FREQ_CACHE.store(
4530                    mpll_clk_config_frequency(clocks, config),
4531                    ::core::sync::atomic::Ordering::Release,
4532                );
4533            }
4534            refresh_timg_calibration_clock_downstream(clocks);
4535            for child_instance in [MipiDsiInstance::MipiDsi] {
4536                refresh_mipi_dsi_phy_pll_refclk_downstream(clocks, child_instance);
4537                refresh_mipi_dsi_phy_cfg_clk_downstream(clocks, child_instance);
4538            }
4539            for child_instance in [PsramInstance::Psram] {
4540                refresh_psram_function_clock_downstream(clocks, child_instance);
4541            }
4542        }
4543        fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
4544            if let Some(config) = clocks.iomux_function_clock {
4545                IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
4546                    iomux_function_clock_config_frequency(clocks, config),
4547                    ::core::sync::atomic::Ordering::Release,
4548                );
4549            }
4550        }
4551        fn refresh_cpu_root_clk_downstream(clocks: &mut ClockTree) {
4552            if let Some(config) = clocks.cpu_root_clk {
4553                CPU_ROOT_CLK_FREQ_CACHE.store(
4554                    cpu_root_clk_config_frequency(clocks, config),
4555                    ::core::sync::atomic::Ordering::Release,
4556                );
4557            }
4558            refresh_cpu_clk_downstream(clocks);
4559        }
4560        fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
4561            if let Some(config) = clocks.cpu_clk {
4562                CPU_CLK_FREQ_CACHE.store(
4563                    cpu_clk_config_frequency(clocks, config),
4564                    ::core::sync::atomic::Ordering::Release,
4565                );
4566            }
4567            refresh_mem_clk_downstream(clocks);
4568        }
4569        fn refresh_mem_clk_downstream(clocks: &mut ClockTree) {
4570            if let Some(config) = clocks.mem_clk {
4571                MEM_CLK_FREQ_CACHE.store(
4572                    mem_clk_config_frequency(clocks, config),
4573                    ::core::sync::atomic::Ordering::Release,
4574                );
4575            }
4576            refresh_sys_clk_downstream(clocks);
4577        }
4578        fn refresh_sys_clk_downstream(clocks: &mut ClockTree) {
4579            if let Some(config) = clocks.sys_clk {
4580                SYS_CLK_FREQ_CACHE.store(
4581                    sys_clk_config_frequency(clocks, config),
4582                    ::core::sync::atomic::Ordering::Release,
4583                );
4584            }
4585            refresh_apb_clk_downstream(clocks);
4586        }
4587        fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
4588            if let Some(config) = clocks.apb_clk {
4589                APB_CLK_FREQ_CACHE.store(
4590                    apb_clk_config_frequency(clocks, config),
4591                    ::core::sync::atomic::Ordering::Release,
4592                );
4593            }
4594        }
4595        fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
4596            if let Some(config) = clocks.lp_fast_clk {
4597                LP_FAST_CLK_FREQ_CACHE.store(
4598                    lp_fast_clk_config_frequency(clocks, config),
4599                    ::core::sync::atomic::Ordering::Release,
4600                );
4601            }
4602        }
4603        fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
4604            if let Some(config) = clocks.lp_slow_clk {
4605                LP_SLOW_CLK_FREQ_CACHE.store(
4606                    lp_slow_clk_config_frequency(clocks, config),
4607                    ::core::sync::atomic::Ordering::Release,
4608                );
4609            }
4610            refresh_timg_calibration_clock_downstream(clocks);
4611        }
4612        fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
4613            if let Some(config) = clocks.timg_calibration_clock {
4614                TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
4615                    timg_calibration_clock_config_frequency(clocks, config),
4616                    ::core::sync::atomic::Ordering::Release,
4617                );
4618            }
4619        }
4620        fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4621            if let Some(config) = clocks.timg_function_clock[instance as usize] {
4622                TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4623                    TimgInstance::function_clock_config_frequency(clocks, config),
4624                    ::core::sync::atomic::Ordering::Release,
4625                );
4626            }
4627        }
4628        fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4629            if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
4630                TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
4631                    TimgInstance::wdt_clock_config_frequency(clocks, config),
4632                    ::core::sync::atomic::Ordering::Release,
4633                );
4634            }
4635        }
4636        fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4637            if let Some(config) = clocks.uart_function_clock[instance as usize] {
4638                UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4639                    UartInstance::function_clock_config_frequency(clocks, config),
4640                    ::core::sync::atomic::Ordering::Release,
4641                );
4642            }
4643            refresh_uart_baud_rate_generator_downstream(clocks, instance);
4644        }
4645        fn refresh_uart_baud_rate_generator_downstream(
4646            clocks: &mut ClockTree,
4647            instance: UartInstance,
4648        ) {
4649            if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4650                UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4651                    instance.baud_rate_generator_config_frequency(clocks, config),
4652                    ::core::sync::atomic::Ordering::Release,
4653                );
4654            }
4655        }
4656        fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
4657            if let Some(config) = clocks.spi_function_clock[instance as usize] {
4658                SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4659                    SpiInstance::function_clock_config_frequency(clocks, config),
4660                    ::core::sync::atomic::Ordering::Release,
4661                );
4662            }
4663        }
4664        fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
4665            if let Some(config) = clocks.i2c_function_clock[instance as usize] {
4666                I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4667                    I2cInstance::function_clock_config_frequency(clocks, config),
4668                    ::core::sync::atomic::Ordering::Release,
4669                );
4670            }
4671        }
4672        fn refresh_mipi_dsi_dpi_clk_downstream(clocks: &mut ClockTree, instance: MipiDsiInstance) {
4673            if let Some(config) = clocks.mipi_dsi_dpi_clk[instance as usize] {
4674                MIPI_DSI_DPI_CLK_FREQ_CACHE[instance as usize].store(
4675                    MipiDsiInstance::dpi_clk_config_frequency(clocks, config),
4676                    ::core::sync::atomic::Ordering::Release,
4677                );
4678            }
4679        }
4680        fn refresh_mipi_dsi_phy_pll_refclk_downstream(
4681            clocks: &mut ClockTree,
4682            instance: MipiDsiInstance,
4683        ) {
4684            if let Some(config) = clocks.mipi_dsi_phy_pll_refclk[instance as usize] {
4685                MIPI_DSI_PHY_PLL_REFCLK_FREQ_CACHE[instance as usize].store(
4686                    MipiDsiInstance::phy_pll_refclk_config_frequency(clocks, config),
4687                    ::core::sync::atomic::Ordering::Release,
4688                );
4689            }
4690        }
4691        fn refresh_mipi_dsi_phy_cfg_clk_downstream(
4692            clocks: &mut ClockTree,
4693            instance: MipiDsiInstance,
4694        ) {
4695            if let Some(config) = clocks.mipi_dsi_phy_cfg_clk[instance as usize] {
4696                MIPI_DSI_PHY_CFG_CLK_FREQ_CACHE[instance as usize].store(
4697                    MipiDsiInstance::phy_cfg_clk_config_frequency(clocks, config),
4698                    ::core::sync::atomic::Ordering::Release,
4699                );
4700            }
4701        }
4702        fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
4703            if let Some(config) = clocks.rmt_sclk[instance as usize] {
4704                RMT_SCLK_FREQ_CACHE[instance as usize].store(
4705                    RmtInstance::sclk_config_frequency(clocks, config),
4706                    ::core::sync::atomic::Ordering::Release,
4707                );
4708            }
4709        }
4710        fn refresh_psram_function_clock_downstream(
4711            clocks: &mut ClockTree,
4712            instance: PsramInstance,
4713        ) {
4714            if let Some(config) = clocks.psram_function_clock[instance as usize] {
4715                PSRAM_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4716                    PsramInstance::function_clock_config_frequency(clocks, config),
4717                    ::core::sync::atomic::Ordering::Release,
4718                );
4719            }
4720        }
4721    };
4722}
4723/// Implement the `Peripheral` enum and enable/disable/reset functions.
4724///
4725/// This macro is intended to be placed in `esp_hal::system`.
4726#[macro_export]
4727#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4728macro_rules! implement_peripheral_clocks {
4729    () => {
4730        #[doc(hidden)]
4731        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4732        #[repr(u8)]
4733        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4734        pub enum Peripheral {
4735            /// AES peripheral clock signal
4736            Aes,
4737            /// AHB_GDMA peripheral clock signal
4738            AhbGdma,
4739            /// APB_SAR_ADC peripheral clock signal
4740            ApbSarAdc,
4741            /// AXI_GDMA peripheral clock signal
4742            AxiGdma,
4743            /// DS peripheral clock signal
4744            Ds,
4745            /// ECC peripheral clock signal
4746            Ecc,
4747            /// ECDSA peripheral clock signal
4748            Ecdsa,
4749            /// EMAC peripheral clock signal
4750            Emac,
4751            /// GPIO_SD peripheral clock signal
4752            GpioSd,
4753            /// HMAC peripheral clock signal
4754            Hmac,
4755            /// I2C0 peripheral clock signal
4756            I2c0,
4757            /// I2C1 peripheral clock signal
4758            I2c1,
4759            /// I2S0 peripheral clock signal
4760            I2s0,
4761            /// I2S1 peripheral clock signal
4762            I2s1,
4763            /// I2S2 peripheral clock signal
4764            I2s2,
4765            /// IOMUX peripheral clock signal
4766            Iomux,
4767            /// LCD_CAM peripheral clock signal
4768            LcdCam,
4769            /// LEDC peripheral clock signal
4770            Ledc,
4771            /// MCPWM0 peripheral clock signal
4772            Mcpwm0,
4773            /// MCPWM1 peripheral clock signal
4774            Mcpwm1,
4775            /// MIPI_DSI peripheral clock signal
4776            MipiDsi,
4777            /// PARL_IO peripheral clock signal
4778            ParlIo,
4779            /// PCNT peripheral clock signal
4780            Pcnt,
4781            /// RMT peripheral clock signal
4782            Rmt,
4783            /// RSA peripheral clock signal
4784            Rsa,
4785            /// SDIO_HOST peripheral clock signal
4786            SdioHost,
4787            /// SHA peripheral clock signal
4788            Sha,
4789            /// SPI2 peripheral clock signal
4790            Spi2,
4791            /// SPI3 peripheral clock signal
4792            Spi3,
4793            /// SYSTIMER peripheral clock signal
4794            Systimer,
4795            /// TIMG0 peripheral clock signal
4796            Timg0,
4797            /// TIMG1 peripheral clock signal
4798            Timg1,
4799            /// TWAI0 peripheral clock signal
4800            Twai0,
4801            /// TWAI1 peripheral clock signal
4802            Twai1,
4803            /// TWAI2 peripheral clock signal
4804            Twai2,
4805            /// UART0 peripheral clock signal
4806            Uart0,
4807            /// UART1 peripheral clock signal
4808            Uart1,
4809            /// UART2 peripheral clock signal
4810            Uart2,
4811            /// UART3 peripheral clock signal
4812            Uart3,
4813            /// UART4 peripheral clock signal
4814            Uart4,
4815            /// UHCI0 peripheral clock signal
4816            Uhci0,
4817            /// USB_DEVICE peripheral clock signal
4818            UsbDevice,
4819            /// USB_FS peripheral clock signal
4820            UsbFs,
4821            /// USB_HS peripheral clock signal
4822            UsbHs,
4823            /// VDMA peripheral clock signal
4824            Vdma,
4825        }
4826        impl Peripheral {
4827            const KEEP_ENABLED: &[Peripheral] = &[
4828                Self::Iomux,
4829                Self::Systimer,
4830                Self::Timg0,
4831                Self::Uart0,
4832                Self::UsbDevice,
4833            ];
4834            const COUNT: usize = Self::ALL.len();
4835            const ALL: &[Self] = &[
4836                Self::Aes,
4837                Self::AhbGdma,
4838                Self::ApbSarAdc,
4839                Self::AxiGdma,
4840                Self::Ds,
4841                Self::Ecc,
4842                Self::Ecdsa,
4843                Self::Emac,
4844                Self::GpioSd,
4845                Self::Hmac,
4846                Self::I2c0,
4847                Self::I2c1,
4848                Self::I2s0,
4849                Self::I2s1,
4850                Self::I2s2,
4851                Self::Iomux,
4852                Self::LcdCam,
4853                Self::Ledc,
4854                Self::Mcpwm0,
4855                Self::Mcpwm1,
4856                Self::MipiDsi,
4857                Self::ParlIo,
4858                Self::Pcnt,
4859                Self::Rmt,
4860                Self::Rsa,
4861                Self::SdioHost,
4862                Self::Sha,
4863                Self::Spi2,
4864                Self::Spi3,
4865                Self::Systimer,
4866                Self::Timg0,
4867                Self::Timg1,
4868                Self::Twai0,
4869                Self::Twai1,
4870                Self::Twai2,
4871                Self::Uart0,
4872                Self::Uart1,
4873                Self::Uart2,
4874                Self::Uart3,
4875                Self::Uart4,
4876                Self::Uhci0,
4877                Self::UsbDevice,
4878                Self::UsbFs,
4879                Self::UsbHs,
4880                Self::Vdma,
4881            ];
4882        }
4883        unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4884            match peripheral {
4885                Peripheral::Aes => {
4886                    crate::peripherals::HP_SYS_CLKRST::regs()
4887                        .soc_clk_ctrl1()
4888                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
4889                }
4890                Peripheral::AhbGdma => {
4891                    crate::peripherals::HP_SYS_CLKRST::regs()
4892                        .soc_clk_ctrl1()
4893                        .modify(|_, w| w.ahb_pdma_sys_clk_en().bit(enable));
4894                }
4895                Peripheral::ApbSarAdc => {
4896                    crate::peripherals::HP_SYS_CLKRST::regs()
4897                        .soc_clk_ctrl2()
4898                        .modify(|_, w| w.adc_apb_clk_en().bit(enable));
4899                    crate::peripherals::HP_SYS_CLKRST::regs()
4900                        .peri_clk_ctrl23()
4901                        .modify(|_, w| w.adc_clk_en().bit(enable));
4902                }
4903                Peripheral::AxiGdma => {
4904                    crate::peripherals::HP_SYS_CLKRST::regs()
4905                        .soc_clk_ctrl1()
4906                        .modify(|_, w| w.axi_pdma_sys_clk_en().bit(enable));
4907                }
4908                Peripheral::Ds => {
4909                    crate::peripherals::HP_SYS_CLKRST::regs()
4910                        .soc_clk_ctrl1()
4911                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
4912                }
4913                Peripheral::Ecc => {
4914                    crate::peripherals::HP_SYS_CLKRST::regs()
4915                        .soc_clk_ctrl1()
4916                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
4917                }
4918                Peripheral::Ecdsa => {
4919                    crate::peripherals::HP_SYS_CLKRST::regs()
4920                        .soc_clk_ctrl1()
4921                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
4922                }
4923                Peripheral::Emac => {
4924                    crate::peripherals::HP_SYS_CLKRST::regs()
4925                        .soc_clk_ctrl1()
4926                        .modify(|_, w| w.emac_sys_clk_en().bit(enable));
4927                }
4928                Peripheral::GpioSd => {
4929                    crate::peripherals::GPIO_SD::regs()
4930                        .clock_gate()
4931                        .modify(|_, w| w.clk_en().bit(enable));
4932                }
4933                Peripheral::Hmac => {
4934                    crate::peripherals::HP_SYS_CLKRST::regs()
4935                        .soc_clk_ctrl1()
4936                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
4937                }
4938                Peripheral::I2c0 => {
4939                    crate::peripherals::HP_SYS_CLKRST::regs()
4940                        .soc_clk_ctrl2()
4941                        .modify(|_, w| w.i2c0_apb_clk_en().bit(enable));
4942                }
4943                Peripheral::I2c1 => {
4944                    crate::peripherals::HP_SYS_CLKRST::regs()
4945                        .soc_clk_ctrl2()
4946                        .modify(|_, w| w.i2c1_apb_clk_en().bit(enable));
4947                }
4948                Peripheral::I2s0 => {
4949                    crate::peripherals::HP_SYS_CLKRST::regs()
4950                        .soc_clk_ctrl2()
4951                        .modify(|_, w| w.i2s0_apb_clk_en().bit(enable));
4952                }
4953                Peripheral::I2s1 => {
4954                    crate::peripherals::HP_SYS_CLKRST::regs()
4955                        .soc_clk_ctrl2()
4956                        .modify(|_, w| w.i2s1_apb_clk_en().bit(enable));
4957                }
4958                Peripheral::I2s2 => {
4959                    crate::peripherals::HP_SYS_CLKRST::regs()
4960                        .soc_clk_ctrl2()
4961                        .modify(|_, w| w.i2s2_apb_clk_en().bit(enable));
4962                }
4963                Peripheral::Iomux => {
4964                    crate::peripherals::HP_SYS_CLKRST::regs()
4965                        .peri_clk_ctrl26()
4966                        .modify(|_, w| w.iomux_clk_en().bit(enable));
4967                }
4968                Peripheral::LcdCam => {
4969                    let _ = enable;
4970                }
4971                Peripheral::Ledc => {
4972                    let _ = enable;
4973                }
4974                Peripheral::Mcpwm0 => {
4975                    crate::peripherals::HP_SYS_CLKRST::regs()
4976                        .soc_clk_ctrl2()
4977                        .modify(|_, w| w.mcpwm0_apb_clk_en().bit(enable));
4978                }
4979                Peripheral::Mcpwm1 => {
4980                    crate::peripherals::HP_SYS_CLKRST::regs()
4981                        .soc_clk_ctrl2()
4982                        .modify(|_, w| w.mcpwm1_apb_clk_en().bit(enable));
4983                }
4984                Peripheral::MipiDsi => {
4985                    crate::peripherals::HP_SYS_CLKRST::regs()
4986                        .soc_clk_ctrl1()
4987                        .modify(|_, w| w.dsi_sys_clk_en().bit(enable));
4988                }
4989                Peripheral::ParlIo => {
4990                    crate::peripherals::HP_SYS_CLKRST::regs()
4991                        .soc_clk_ctrl1()
4992                        .modify(|_, w| w.parlio_sys_clk_en().bit(enable));
4993                    crate::peripherals::HP_SYS_CLKRST::regs()
4994                        .soc_clk_ctrl2()
4995                        .modify(|_, w| w.parlio_apb_clk_en().bit(enable));
4996                }
4997                Peripheral::Pcnt => {
4998                    crate::peripherals::HP_SYS_CLKRST::regs()
4999                        .soc_clk_ctrl2()
5000                        .modify(|_, w| w.pcnt_apb_clk_en().bit(enable));
5001                }
5002                Peripheral::Rmt => {
5003                    crate::peripherals::HP_SYS_CLKRST::regs()
5004                        .soc_clk_ctrl2()
5005                        .modify(|_, w| w.rmt_sys_clk_en().bit(enable));
5006                }
5007                Peripheral::Rsa => {
5008                    crate::peripherals::HP_SYS_CLKRST::regs()
5009                        .soc_clk_ctrl1()
5010                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
5011                }
5012                Peripheral::SdioHost => {
5013                    crate::peripherals::HP_SYS_CLKRST::regs()
5014                        .soc_clk_ctrl1()
5015                        .modify(|_, w| w.sdmmc_sys_clk_en().bit(enable));
5016                }
5017                Peripheral::Sha => {
5018                    crate::peripherals::HP_SYS_CLKRST::regs()
5019                        .soc_clk_ctrl1()
5020                        .modify(|_, w| w.crypto_sys_clk_en().bit(enable));
5021                }
5022                Peripheral::Spi2 => {
5023                    crate::peripherals::HP_SYS_CLKRST::regs()
5024                        .soc_clk_ctrl1()
5025                        .modify(|_, w| w.gpspi2_sys_clk_en().bit(enable));
5026                    crate::peripherals::HP_SYS_CLKRST::regs()
5027                        .soc_clk_ctrl2()
5028                        .modify(|_, w| w.gpspi2_apb_clk_en().bit(enable));
5029                }
5030                Peripheral::Spi3 => {
5031                    crate::peripherals::HP_SYS_CLKRST::regs()
5032                        .soc_clk_ctrl1()
5033                        .modify(|_, w| w.gpspi3_sys_clk_en().bit(enable));
5034                    crate::peripherals::HP_SYS_CLKRST::regs()
5035                        .soc_clk_ctrl2()
5036                        .modify(|_, w| w.gpspi3_apb_clk_en().bit(enable));
5037                }
5038                Peripheral::Systimer => {
5039                    crate::peripherals::HP_SYS_CLKRST::regs()
5040                        .soc_clk_ctrl2()
5041                        .modify(|_, w| w.systimer_apb_clk_en().bit(enable));
5042                    crate::peripherals::HP_SYS_CLKRST::regs()
5043                        .peri_clk_ctrl21()
5044                        .modify(|_, w| w.systimer_clk_en().bit(enable));
5045                }
5046                Peripheral::Timg0 => {
5047                    crate::peripherals::HP_SYS_CLKRST::regs()
5048                        .soc_clk_ctrl2()
5049                        .modify(|_, w| w.timergrp0_apb_clk_en().bit(enable));
5050                }
5051                Peripheral::Timg1 => {
5052                    crate::peripherals::HP_SYS_CLKRST::regs()
5053                        .soc_clk_ctrl2()
5054                        .modify(|_, w| w.timergrp1_apb_clk_en().bit(enable));
5055                }
5056                Peripheral::Twai0 => {
5057                    crate::peripherals::HP_SYS_CLKRST::regs()
5058                        .soc_clk_ctrl2()
5059                        .modify(|_, w| w.twai0_apb_clk_en().bit(enable));
5060                }
5061                Peripheral::Twai1 => {
5062                    crate::peripherals::HP_SYS_CLKRST::regs()
5063                        .soc_clk_ctrl2()
5064                        .modify(|_, w| w.twai1_apb_clk_en().bit(enable));
5065                }
5066                Peripheral::Twai2 => {
5067                    crate::peripherals::HP_SYS_CLKRST::regs()
5068                        .soc_clk_ctrl2()
5069                        .modify(|_, w| w.twai2_apb_clk_en().bit(enable));
5070                }
5071                Peripheral::Uart0 => {
5072                    crate::peripherals::HP_SYS_CLKRST::regs()
5073                        .soc_clk_ctrl1()
5074                        .modify(|_, w| w.uart0_sys_clk_en().bit(enable));
5075                    crate::peripherals::HP_SYS_CLKRST::regs()
5076                        .soc_clk_ctrl2()
5077                        .modify(|_, w| w.uart0_apb_clk_en().bit(enable));
5078                }
5079                Peripheral::Uart1 => {
5080                    crate::peripherals::HP_SYS_CLKRST::regs()
5081                        .soc_clk_ctrl1()
5082                        .modify(|_, w| w.uart1_sys_clk_en().bit(enable));
5083                    crate::peripherals::HP_SYS_CLKRST::regs()
5084                        .soc_clk_ctrl2()
5085                        .modify(|_, w| w.uart1_apb_clk_en().bit(enable));
5086                }
5087                Peripheral::Uart2 => {
5088                    crate::peripherals::HP_SYS_CLKRST::regs()
5089                        .soc_clk_ctrl1()
5090                        .modify(|_, w| w.uart2_sys_clk_en().bit(enable));
5091                    crate::peripherals::HP_SYS_CLKRST::regs()
5092                        .soc_clk_ctrl2()
5093                        .modify(|_, w| w.uart2_apb_clk_en().bit(enable));
5094                }
5095                Peripheral::Uart3 => {
5096                    crate::peripherals::HP_SYS_CLKRST::regs()
5097                        .soc_clk_ctrl1()
5098                        .modify(|_, w| w.uart3_sys_clk_en().bit(enable));
5099                    crate::peripherals::HP_SYS_CLKRST::regs()
5100                        .soc_clk_ctrl2()
5101                        .modify(|_, w| w.uart3_apb_clk_en().bit(enable));
5102                }
5103                Peripheral::Uart4 => {
5104                    crate::peripherals::HP_SYS_CLKRST::regs()
5105                        .soc_clk_ctrl1()
5106                        .modify(|_, w| w.uart4_sys_clk_en().bit(enable));
5107                    crate::peripherals::HP_SYS_CLKRST::regs()
5108                        .soc_clk_ctrl2()
5109                        .modify(|_, w| w.uart4_apb_clk_en().bit(enable));
5110                }
5111                Peripheral::Uhci0 => {
5112                    crate::peripherals::HP_SYS_CLKRST::regs()
5113                        .soc_clk_ctrl1()
5114                        .modify(|_, w| w.uhci_sys_clk_en().bit(enable));
5115                    crate::peripherals::HP_SYS_CLKRST::regs()
5116                        .soc_clk_ctrl2()
5117                        .modify(|_, w| w.uhci_apb_clk_en().bit(enable));
5118                }
5119                Peripheral::UsbDevice => {
5120                    crate::peripherals::HP_SYS_CLKRST::regs()
5121                        .soc_clk_ctrl2()
5122                        .modify(|_, w| w.usb_device_apb_clk_en().bit(enable));
5123                }
5124                Peripheral::UsbFs => {
5125                    crate::peripherals::HP_SYS_CLKRST::regs()
5126                        .soc_clk_ctrl1()
5127                        .modify(|_, w| w.usb_otg11_sys_clk_en().bit(enable));
5128                }
5129                Peripheral::UsbHs => {
5130                    crate::peripherals::HP_SYS_CLKRST::regs()
5131                        .soc_clk_ctrl1()
5132                        .modify(|_, w| w.usb_otg20_sys_clk_en().bit(enable));
5133                }
5134                Peripheral::Vdma => {
5135                    crate::peripherals::HP_SYS_CLKRST::regs()
5136                        .soc_clk_ctrl1()
5137                        .modify(|_, w| w.gdma_sys_clk_en().bit(enable));
5138                }
5139            }
5140        }
5141        unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
5142            match peripheral {
5143                Peripheral::Aes => {
5144                    crate::peripherals::HP_SYS_CLKRST::regs()
5145                        .hp_rst_en2()
5146                        .modify(|_, w| w.rst_en_aes().bit(reset));
5147                }
5148                Peripheral::AhbGdma => {
5149                    crate::peripherals::HP_SYS_CLKRST::regs()
5150                        .hp_rst_en1()
5151                        .modify(|_, w| w.rst_en_ahb_pdma().bit(reset));
5152                }
5153                Peripheral::ApbSarAdc => {
5154                    crate::peripherals::HP_SYS_CLKRST::regs()
5155                        .hp_rst_en2()
5156                        .modify(|_, w| w.rst_en_adc().bit(reset));
5157                }
5158                Peripheral::AxiGdma => {
5159                    crate::peripherals::HP_SYS_CLKRST::regs()
5160                        .hp_rst_en1()
5161                        .modify(|_, w| w.rst_en_axi_pdma().bit(reset));
5162                }
5163                Peripheral::Ds => {
5164                    crate::peripherals::HP_SYS_CLKRST::regs()
5165                        .hp_rst_en2()
5166                        .modify(|_, w| w.rst_en_ds().bit(reset));
5167                }
5168                Peripheral::Ecc => {
5169                    crate::peripherals::HP_SYS_CLKRST::regs()
5170                        .hp_rst_en2()
5171                        .modify(|_, w| w.rst_en_ecc().bit(reset));
5172                }
5173                Peripheral::Ecdsa => {
5174                    crate::peripherals::HP_SYS_CLKRST::regs()
5175                        .hp_rst_en2()
5176                        .modify(|_, w| w.rst_en_ecdsa().bit(reset));
5177                }
5178                Peripheral::Emac => {
5179                    let _ = reset;
5180                }
5181                Peripheral::GpioSd => {
5182                    let _ = reset;
5183                }
5184                Peripheral::Hmac => {
5185                    crate::peripherals::HP_SYS_CLKRST::regs()
5186                        .hp_rst_en2()
5187                        .modify(|_, w| w.rst_en_hmac().bit(reset));
5188                }
5189                Peripheral::I2c0 => {
5190                    crate::peripherals::HP_SYS_CLKRST::regs()
5191                        .hp_rst_en1()
5192                        .modify(|_, w| w.rst_en_i2c0().bit(reset));
5193                }
5194                Peripheral::I2c1 => {
5195                    crate::peripherals::HP_SYS_CLKRST::regs()
5196                        .hp_rst_en1()
5197                        .modify(|_, w| w.rst_en_i2c1().bit(reset));
5198                }
5199                Peripheral::I2s0 => {
5200                    crate::peripherals::HP_SYS_CLKRST::regs()
5201                        .hp_rst_en2()
5202                        .modify(|_, w| w.rst_en_i2s0_apb().bit(reset));
5203                }
5204                Peripheral::I2s1 => {
5205                    crate::peripherals::HP_SYS_CLKRST::regs()
5206                        .hp_rst_en2()
5207                        .modify(|_, w| w.rst_en_i2s1_apb().bit(reset));
5208                }
5209                Peripheral::I2s2 => {
5210                    crate::peripherals::HP_SYS_CLKRST::regs()
5211                        .hp_rst_en2()
5212                        .modify(|_, w| w.rst_en_i2s2_apb().bit(reset));
5213                }
5214                Peripheral::Iomux => {
5215                    crate::peripherals::HP_SYS_CLKRST::regs()
5216                        .hp_rst_en1()
5217                        .modify(|_, w| w.rst_en_iomux().bit(reset));
5218                }
5219                Peripheral::LcdCam => {
5220                    crate::peripherals::HP_SYS_CLKRST::regs()
5221                        .hp_rst_en2()
5222                        .modify(|_, w| w.rst_en_lcdcam().bit(reset));
5223                }
5224                Peripheral::Ledc => {
5225                    crate::peripherals::HP_SYS_CLKRST::regs()
5226                        .hp_rst_en1()
5227                        .modify(|_, w| w.rst_en_ledc().bit(reset));
5228                }
5229                Peripheral::Mcpwm0 => {
5230                    crate::peripherals::HP_SYS_CLKRST::regs()
5231                        .hp_rst_en1()
5232                        .modify(|_, w| w.rst_en_pwm0().bit(reset));
5233                }
5234                Peripheral::Mcpwm1 => {
5235                    crate::peripherals::HP_SYS_CLKRST::regs()
5236                        .hp_rst_en1()
5237                        .modify(|_, w| w.rst_en_pwm1().bit(reset));
5238                }
5239                Peripheral::MipiDsi => {
5240                    crate::peripherals::HP_SYS_CLKRST::regs()
5241                        .hp_rst_en0()
5242                        .modify(|_, w| w.rst_en_dsi_brg().bit(reset));
5243                }
5244                Peripheral::ParlIo => {
5245                    crate::peripherals::HP_SYS_CLKRST::regs()
5246                        .hp_rst_en2()
5247                        .modify(|_, w| {
5248                            w.rst_en_parlio()
5249                                .bit(reset)
5250                                .rst_en_parlio_rx()
5251                                .bit(reset)
5252                                .rst_en_parlio_tx()
5253                                .bit(reset)
5254                        });
5255                }
5256                Peripheral::Pcnt => {
5257                    crate::peripherals::HP_SYS_CLKRST::regs()
5258                        .hp_rst_en1()
5259                        .modify(|_, w| w.rst_en_pcnt().bit(reset));
5260                }
5261                Peripheral::Rmt => {
5262                    crate::peripherals::HP_SYS_CLKRST::regs()
5263                        .hp_rst_en1()
5264                        .modify(|_, w| w.rst_en_rmt().bit(reset));
5265                }
5266                Peripheral::Rsa => {
5267                    crate::peripherals::HP_SYS_CLKRST::regs()
5268                        .hp_rst_en2()
5269                        .modify(|_, w| w.rst_en_rsa().bit(reset));
5270                }
5271                Peripheral::SdioHost => {
5272                    crate::peripherals::LP_AON_CLKRST::regs()
5273                        .lp_aonclkrst_hp_sdmmc_emac_rst_ctrl()
5274                        .modify(|_, w| w.lp_aonclkrst_rst_en_sdmmc().bit(reset));
5275                }
5276                Peripheral::Sha => {
5277                    crate::peripherals::HP_SYS_CLKRST::regs()
5278                        .hp_rst_en2()
5279                        .modify(|_, w| w.rst_en_sha().bit(reset));
5280                }
5281                Peripheral::Spi2 => {
5282                    crate::peripherals::HP_SYS_CLKRST::regs()
5283                        .hp_rst_en2()
5284                        .modify(|_, w| w.rst_en_spi2().bit(reset));
5285                }
5286                Peripheral::Spi3 => {
5287                    crate::peripherals::HP_SYS_CLKRST::regs()
5288                        .hp_rst_en2()
5289                        .modify(|_, w| w.rst_en_spi3().bit(reset));
5290                }
5291                Peripheral::Systimer => {
5292                    crate::peripherals::HP_SYS_CLKRST::regs()
5293                        .hp_rst_en1()
5294                        .modify(|_, w| w.rst_en_stimer().bit(reset));
5295                }
5296                Peripheral::Timg0 => {
5297                    crate::peripherals::HP_SYS_CLKRST::regs()
5298                        .hp_rst_en1()
5299                        .modify(|_, w| w.rst_en_timergrp0().bit(reset));
5300                }
5301                Peripheral::Timg1 => {
5302                    crate::peripherals::HP_SYS_CLKRST::regs()
5303                        .hp_rst_en1()
5304                        .modify(|_, w| w.rst_en_timergrp1().bit(reset));
5305                }
5306                Peripheral::Twai0 => {
5307                    crate::peripherals::HP_SYS_CLKRST::regs()
5308                        .hp_rst_en1()
5309                        .modify(|_, w| w.rst_en_can0().bit(reset));
5310                }
5311                Peripheral::Twai1 => {
5312                    crate::peripherals::HP_SYS_CLKRST::regs()
5313                        .hp_rst_en1()
5314                        .modify(|_, w| w.rst_en_can1().bit(reset));
5315                }
5316                Peripheral::Twai2 => {
5317                    crate::peripherals::HP_SYS_CLKRST::regs()
5318                        .hp_rst_en1()
5319                        .modify(|_, w| w.rst_en_can2().bit(reset));
5320                }
5321                Peripheral::Uart0 => {
5322                    crate::peripherals::HP_SYS_CLKRST::regs()
5323                        .hp_rst_en1()
5324                        .modify(|_, w| {
5325                            w.rst_en_uart0_core()
5326                                .bit(reset)
5327                                .rst_en_uart0_apb()
5328                                .bit(reset)
5329                        });
5330                }
5331                Peripheral::Uart1 => {
5332                    crate::peripherals::HP_SYS_CLKRST::regs()
5333                        .hp_rst_en1()
5334                        .modify(|_, w| {
5335                            w.rst_en_uart1_core()
5336                                .bit(reset)
5337                                .rst_en_uart1_apb()
5338                                .bit(reset)
5339                        });
5340                }
5341                Peripheral::Uart2 => {
5342                    crate::peripherals::HP_SYS_CLKRST::regs()
5343                        .hp_rst_en1()
5344                        .modify(|_, w| {
5345                            w.rst_en_uart2_core()
5346                                .bit(reset)
5347                                .rst_en_uart2_apb()
5348                                .bit(reset)
5349                        });
5350                }
5351                Peripheral::Uart3 => {
5352                    crate::peripherals::HP_SYS_CLKRST::regs()
5353                        .hp_rst_en1()
5354                        .modify(|_, w| {
5355                            w.rst_en_uart3_core()
5356                                .bit(reset)
5357                                .rst_en_uart3_apb()
5358                                .bit(reset)
5359                        });
5360                }
5361                Peripheral::Uart4 => {
5362                    crate::peripherals::HP_SYS_CLKRST::regs()
5363                        .hp_rst_en1()
5364                        .modify(|_, w| {
5365                            w.rst_en_uart4_core()
5366                                .bit(reset)
5367                                .rst_en_uart4_apb()
5368                                .bit(reset)
5369                        });
5370                }
5371                Peripheral::Uhci0 => {
5372                    crate::peripherals::HP_SYS_CLKRST::regs()
5373                        .hp_rst_en1()
5374                        .modify(|_, w| w.rst_en_uhci().bit(reset));
5375                }
5376                Peripheral::UsbDevice => {
5377                    let _ = reset;
5378                }
5379                Peripheral::UsbFs => {
5380                    let _ = reset;
5381                }
5382                Peripheral::UsbHs => {
5383                    let _ = reset;
5384                }
5385                Peripheral::Vdma => {
5386                    crate::peripherals::HP_SYS_CLKRST::regs()
5387                        .hp_rst_en0()
5388                        .modify(|_, w| w.rst_en_gdma().bit(reset));
5389                }
5390            }
5391        }
5392    };
5393}
5394/// Macro to get the address range of the given memory region.
5395///
5396/// This macro provides two syntax options for each memory region:
5397///
5398/// - `memory_range!("region_name")` returns the address range as a range expression (`start..end`).
5399/// - `memory_range!(size as str, "region_name")` returns the size of the region as a string
5400///   literal.
5401#[macro_export]
5402#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5403macro_rules! memory_range {
5404    ("DRAM") => {
5405        0x4FF40000..0x4FFC0000
5406    };
5407    (size as str, "DRAM") => {
5408        "524288"
5409    };
5410    ("DRAM2_UNINIT") => {
5411        0x4FF00000..0x4FF40000
5412    };
5413    (size as str, "DRAM2_UNINIT") => {
5414        "262144"
5415    };
5416    ("IROM") => {
5417        0x40000000..0x44000000
5418    };
5419    (size as str, "IROM") => {
5420        "67108864"
5421    };
5422    ("DROM") => {
5423        0x40000000..0x44000000
5424    };
5425    (size as str, "DROM") => {
5426        "67108864"
5427    };
5428}
5429/// This macro can be used to generate code for each peripheral instance of the I2C master driver.
5430///
5431/// For an explanation on the general syntax, as well as usage of individual/repeated
5432/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5433///
5434/// This macro has one option for its "Individual matcher" case:
5435///
5436/// Syntax: `($id:literal, $instance:ident, $sys:ident, $scl:ident, $sda:ident)`
5437///
5438/// Macro fragments:
5439/// - `$id`: the index of the I2C instance
5440/// - `$instance`: the name of the I2C instance
5441/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5442/// - `$scl`, `$sda`: peripheral signal names.
5443///
5444/// Example data: `(0, I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)`
5445#[macro_export]
5446#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5447macro_rules! for_each_i2c_master {
5448    ($($pattern:tt => $code:tt;)*) => {
5449        macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
5450        => {} } _for_each_inner_i2c_master!((0, I2C0, I2c0, I2C0_SCL, I2C0_SDA));
5451        _for_each_inner_i2c_master!((1, I2C1, I2c1, I2C1_SCL, I2C1_SDA));
5452        _for_each_inner_i2c_master!((all(0, I2C0, I2c0, I2C0_SCL, I2C0_SDA), (1, I2C1,
5453        I2c1, I2C1_SCL, I2C1_SDA)));
5454    };
5455}
5456/// This macro can be used to generate code for each peripheral instance of the I2S driver.
5457///
5458/// For an explanation on the general syntax, as well as usage of individual/repeated
5459/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5460///
5461/// This macro has one option for its "Individual matcher" case:
5462///
5463/// Syntax: `($instance:ident, $sys:ident, $mclk:ident, $bclk:ident, $ws:ident, $bclk_rx:ident,
5464/// $ws_rx:ident, [$($dout:ident),*], [$($din:ident),*], $pdm_tx:literal, $pdm_rx:literal,
5465/// $pcm2pdm:literal, $pdm2pcm:literal)`
5466///
5467/// Macro fragments:
5468///
5469/// - `$instance`: the name of the I2S instance
5470/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5471/// - `$mclk`: the MCLK output signal (a placeholder on chips without a GPIO-matrix MCLK).
5472/// - `$bclk`, `$ws`: TX bit clock and word select output signals.
5473/// - `$bclk_rx`, `$ws_rx`: RX bit clock and word select output signals.
5474/// - `$dout`, `$din`: data-out and data-in signal names.
5475/// - `$pdm_tx`, `$pdm_rx`: whether the instance supports PDM TX/RX.
5476/// - `$pcm2pdm`, `$pdm2pcm`: whether the instance supports the hardware PCM<->PDM format conversion
5477///   filter on TX/RX.
5478///
5479/// Example data:
5480/// - `(I2S0, I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
5481///   true, true, true)`
5482#[macro_export]
5483#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5484macro_rules! for_each_i2s {
5485    ($($pattern:tt => $code:tt;)*) => {
5486        macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
5487        _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S1));
5488        _for_each_inner_i2s!((I2S2)); _for_each_inner_i2s!((I2S0, I2s0, I2S0_MCLK,
5489        I2S0_O_BCK, I2S0_O_WS, I2S0_I_BCK, I2S0_I_WS, [I2S0_O_SD, I2S0_O_SD1],
5490        [I2S0_I_SD, I2S0_I_SD1, I2S0_I_SD2, I2S0_I_SD3], true, true, true, true));
5491        _for_each_inner_i2s!((I2S1, I2s1, I2S1_MCLK, I2S1_O_BCK, I2S1_O_WS, I2S1_I_BCK,
5492        I2S1_I_WS, [I2S1_O_SD], [I2S1_I_SD], true, true, false, false));
5493        _for_each_inner_i2s!((I2S2, I2s2, I2S2_MCLK, I2S2_O_BCK, I2S2_O_WS, I2S2_I_BCK,
5494        I2S2_I_WS, [I2S2_O_SD], [I2S2_I_SD], true, true, false, false));
5495        _for_each_inner_i2s!((names(I2S0), (I2S1), (I2S2)));
5496        _for_each_inner_i2s!((all(I2S0, I2s0, I2S0_MCLK, I2S0_O_BCK, I2S0_O_WS,
5497        I2S0_I_BCK, I2S0_I_WS, [I2S0_O_SD, I2S0_O_SD1], [I2S0_I_SD, I2S0_I_SD1,
5498        I2S0_I_SD2, I2S0_I_SD3], true, true, true, true), (I2S1, I2s1, I2S1_MCLK,
5499        I2S1_O_BCK, I2S1_O_WS, I2S1_I_BCK, I2S1_I_WS, [I2S1_O_SD], [I2S1_I_SD], true,
5500        true, false, false), (I2S2, I2s2, I2S2_MCLK, I2S2_O_BCK, I2S2_O_WS, I2S2_I_BCK,
5501        I2S2_I_WS, [I2S2_O_SD], [I2S2_I_SD], true, true, false, false)));
5502    };
5503}
5504/// This macro can be used to generate code for each peripheral instance of the UART driver.
5505///
5506/// For an explanation on the general syntax, as well as usage of individual/repeated
5507/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5508///
5509/// This macro has one option for its "Individual matcher" case:
5510///
5511/// Syntax: `($id:literal, $instance:ident, $sys:ident, $rx:ident, $tx:ident, $cts:ident,
5512/// $rts:ident)`
5513///
5514/// Macro fragments:
5515///
5516/// - `$id`: the index of the UART instance
5517/// - `$instance`: the name of the UART instance
5518/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5519/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
5520///
5521/// Example data: `(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
5522#[macro_export]
5523#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5524macro_rules! for_each_uart {
5525    ($($pattern:tt => $code:tt;)*) => {
5526        macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
5527        } _for_each_inner_uart!((0, UART0, Uart0, UART0_RXD, UART0_TXD, UART0_CTS,
5528        UART0_RTS, wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1,
5529        UART1_RXD, UART1_TXD, UART1_CTS, UART1_RTS, wakeup_source = true));
5530        _for_each_inner_uart!((2, UART2, Uart2, UART2_RXD, UART2_TXD, UART2_CTS,
5531        UART2_RTS, wakeup_source = true)); _for_each_inner_uart!((3, UART3, Uart3,
5532        UART3_RXD, UART3_TXD, UART3_CTS, UART3_RTS, wakeup_source = true));
5533        _for_each_inner_uart!((4, UART4, Uart4, UART4_RXD, UART4_TXD, UART4_CTS,
5534        UART4_RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
5535        UART0_RXD, UART0_TXD, UART0_CTS, UART0_RTS, wakeup_source = true), (1, UART1,
5536        Uart1, UART1_RXD, UART1_TXD, UART1_CTS, UART1_RTS, wakeup_source = true), (2,
5537        UART2, Uart2, UART2_RXD, UART2_TXD, UART2_CTS, UART2_RTS, wakeup_source = true),
5538        (3, UART3, Uart3, UART3_RXD, UART3_TXD, UART3_CTS, UART3_RTS, wakeup_source =
5539        true), (4, UART4, Uart4, UART4_RXD, UART4_TXD, UART4_CTS, UART4_RTS,
5540        wakeup_source = true)));
5541    };
5542}
5543/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
5544///
5545/// For an explanation on the general syntax, as well as usage of individual/repeated
5546/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5547///
5548/// This macro has one option for its "Individual matcher" case:
5549///
5550/// Syntax: `($instance:ident, $sys:ident, $sclk:ident [$($cs:ident),*] [$($sio:ident),*]
5551/// $($is_qspi:literal)?)`
5552///
5553/// Macro fragments:
5554///
5555/// - `$instance`: the name of the SPI instance
5556/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5557/// - `$cs`, `$sio`: chip select and SIO signal names.
5558/// - `$is_qspi`: a `true` literal present if the SPI instance supports QSPI.
5559///
5560/// Example data:
5561/// - `(SPI2, Spi2, FSPICLK [FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ,
5562///   FSPIWP, FSPIHD, FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7], true)`
5563/// - `(SPI3, Spi3, SPI3_CLK [SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q])`
5564#[macro_export]
5565#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5566macro_rules! for_each_spi_master {
5567    ($($pattern:tt => $code:tt;)*) => {
5568        macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
5569        => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI3));
5570        _for_each_inner_spi_master!((SPI2, Spi2, SPI2_CK[SPI2_CS] [SPI2_D, SPI2_Q,
5571        SPI2_WP, SPI2_HOLD], true)); _for_each_inner_spi_master!((SPI3, Spi3,
5572        SPI3_CK[SPI3_CS, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q, SPI3_WP, SPI3_HOLD],
5573        true)); _for_each_inner_spi_master!((names(SPI2), (SPI3)));
5574        _for_each_inner_spi_master!((all(SPI2, Spi2, SPI2_CK[SPI2_CS] [SPI2_D, SPI2_Q,
5575        SPI2_WP, SPI2_HOLD], true), (SPI3, Spi3, SPI3_CK[SPI3_CS, SPI3_CS1, SPI3_CS2]
5576        [SPI3_D, SPI3_Q, SPI3_WP, SPI3_HOLD], true)));
5577    };
5578}
5579/// This macro can be used to generate code for each peripheral instance of the SPI slave driver.
5580///
5581/// For an explanation on the general syntax, as well as usage of individual/repeated
5582/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5583///
5584/// This macro has one option for its "Individual matcher" case:
5585///
5586/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, $mosi:ident, $miso:ident, $cs:ident)`
5587///
5588/// Macro fragments:
5589///
5590/// - `$instance`: the name of the SPI instance
5591/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5592/// - `$sclk`, `$mosi`, `$miso`, `$cs`: signal names.
5593///
5594/// Example data: `(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)`
5595#[macro_export]
5596#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5597macro_rules! for_each_spi_slave {
5598    ($($pattern:tt => $code:tt;)*) => {
5599        macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
5600        => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI3));
5601        _for_each_inner_spi_slave!((SPI2, Spi2, SPI2_CK, SPI2_D, SPI2_Q, SPI2_CS));
5602        _for_each_inner_spi_slave!((SPI3, Spi3, SPI3_CK, SPI3_D, SPI3_Q, SPI3_CS));
5603        _for_each_inner_spi_slave!((names(SPI2), (SPI3)));
5604        _for_each_inner_spi_slave!((all(SPI2, Spi2, SPI2_CK, SPI2_D, SPI2_Q, SPI2_CS),
5605        (SPI3, Spi3, SPI3_CK, SPI3_D, SPI3_Q, SPI3_CS)));
5606    };
5607}
5608#[macro_export]
5609#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5610macro_rules! for_each_peripheral {
5611    ($($pattern:tt => $code:tt;)*) => {
5612        macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
5613        => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
5614        "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
5615        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
5616        GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5617        "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5618        "<section class=\"warning\">"] #[doc =
5619        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5620        #[doc = "<ul>"] #[doc =
5621        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5622        #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
5623        _for_each_inner_peripheral!((@ peri_type #[doc =
5624        "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5625        "<section class=\"warning\">"] #[doc =
5626        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5627        #[doc = "<ul>"] #[doc =
5628        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5629        #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
5630        _for_each_inner_peripheral!((@ peri_type #[doc =
5631        "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5632        "<section class=\"warning\">"] #[doc =
5633        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5634        #[doc = "<ul>"] #[doc =
5635        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5636        #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
5637        _for_each_inner_peripheral!((@ peri_type #[doc =
5638        "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5639        "<section class=\"warning\">"] #[doc =
5640        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5641        #[doc = "<ul>"] #[doc =
5642        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5643        #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
5644        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO6 peripheral singleton"]
5645        GPIO6 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5646        "GPIO7 peripheral singleton"] GPIO7 <= virtual()));
5647        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO8 peripheral singleton"]
5648        GPIO8 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5649        "GPIO9 peripheral singleton"] GPIO9 <= virtual()));
5650        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
5651        GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5652        "GPIO11 peripheral singleton"] GPIO11 <= virtual()));
5653        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO12 peripheral singleton"]
5654        GPIO12 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5655        "GPIO13 peripheral singleton"] GPIO13 <= virtual()));
5656        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO14 peripheral singleton"]
5657        GPIO14 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5658        "GPIO15 peripheral singleton"] GPIO15 <= virtual()));
5659        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO16 peripheral singleton"]
5660        GPIO16 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5661        "GPIO17 peripheral singleton"] GPIO17 <= virtual()));
5662        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO18 peripheral singleton"]
5663        GPIO18 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5664        "GPIO19 peripheral singleton"] GPIO19 <= virtual()));
5665        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO20 peripheral singleton"]
5666        GPIO20 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5667        "GPIO21 peripheral singleton"] GPIO21 <= virtual()));
5668        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
5669        GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5670        "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
5671        _for_each_inner_peripheral!((@ peri_type #[doc =
5672        "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5673        "<section class=\"warning\">"] #[doc =
5674        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5675        #[doc = "<ul>"] #[doc =
5676        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5677        #[doc = "</section>"] GPIO24 <= virtual())); _for_each_inner_peripheral!((@
5678        peri_type #[doc = "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""]
5679        #[doc = "<section class=\"warning\">"] #[doc =
5680        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5681        #[doc = "<ul>"] #[doc =
5682        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5683        #[doc = "</section>"] GPIO25 <= virtual())); _for_each_inner_peripheral!((@
5684        peri_type #[doc = "GPIO26 peripheral singleton"] GPIO26 <= virtual()));
5685        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO27 peripheral singleton"]
5686        GPIO27 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5687        "GPIO28 peripheral singleton"] GPIO28 <= virtual()));
5688        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO29 peripheral singleton"]
5689        GPIO29 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5690        "GPIO30 peripheral singleton"] GPIO30 <= virtual()));
5691        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO31 peripheral singleton"]
5692        GPIO31 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5693        "GPIO32 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5694        "<section class=\"warning\">"] #[doc =
5695        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5696        #[doc = "<ul>"] #[doc =
5697        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5698        = "</ul>"] #[doc = "</section>"] GPIO32 <= virtual()));
5699        _for_each_inner_peripheral!((@ peri_type #[doc =
5700        "GPIO33 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5701        "<section class=\"warning\">"] #[doc =
5702        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5703        #[doc = "<ul>"] #[doc =
5704        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5705        = "</ul>"] #[doc = "</section>"] GPIO33 <= virtual()));
5706        _for_each_inner_peripheral!((@ peri_type #[doc =
5707        "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5708        "<section class=\"warning\">"] #[doc =
5709        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5710        #[doc = "<ul>"] #[doc =
5711        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5712        = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()));
5713        _for_each_inner_peripheral!((@ peri_type #[doc =
5714        "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5715        "<section class=\"warning\">"] #[doc =
5716        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5717        #[doc = "<ul>"] #[doc =
5718        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5719        = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()));
5720        _for_each_inner_peripheral!((@ peri_type #[doc =
5721        "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5722        "<section class=\"warning\">"] #[doc =
5723        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5724        #[doc = "<ul>"] #[doc =
5725        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5726        = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()));
5727        _for_each_inner_peripheral!((@ peri_type #[doc =
5728        "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5729        "<section class=\"warning\">"] #[doc =
5730        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5731        #[doc = "<ul>"] #[doc =
5732        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5733        = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()));
5734        _for_each_inner_peripheral!((@ peri_type #[doc =
5735        "GPIO38 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5736        "<section class=\"warning\">"] #[doc =
5737        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5738        #[doc = "<ul>"] #[doc =
5739        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5740        = "</ul>"] #[doc = "</section>"] GPIO38 <= virtual()));
5741        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO39 peripheral singleton"]
5742        GPIO39 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5743        "GPIO40 peripheral singleton"] GPIO40 <= virtual()));
5744        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO41 peripheral singleton"]
5745        GPIO41 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5746        "GPIO42 peripheral singleton"] GPIO42 <= virtual()));
5747        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO43 peripheral singleton"]
5748        GPIO43 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5749        "GPIO44 peripheral singleton"] GPIO44 <= virtual()));
5750        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO45 peripheral singleton"]
5751        GPIO45 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5752        "GPIO46 peripheral singleton"] GPIO46 <= virtual()));
5753        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO47 peripheral singleton"]
5754        GPIO47 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5755        "GPIO48 peripheral singleton"] GPIO48 <= virtual()));
5756        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO49 peripheral singleton"]
5757        GPIO49 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5758        "GPIO50 peripheral singleton"] GPIO50 <= virtual()));
5759        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO51 peripheral singleton"]
5760        GPIO51 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5761        "GPIO52 peripheral singleton"] GPIO52 <= virtual()));
5762        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO53 peripheral singleton"]
5763        GPIO53 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5764        "GPIO54 peripheral singleton"] GPIO54 <= virtual()));
5765        _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
5766        DMA_CH0 <= virtual(AHB_PDMA_IN_CH0 : { bind_dma_in_interrupt,
5767        enable_dma_in_interrupt, disable_dma_in_interrupt }, AHB_PDMA_OUT_CH0 : {
5768        bind_dma_out_interrupt, enable_dma_out_interrupt, disable_dma_out_interrupt })
5769        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5770        "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(AHB_PDMA_IN_CH1 : {
5771        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5772        AHB_PDMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5773        disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
5774        peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <=
5775        virtual(AHB_PDMA_IN_CH2 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
5776        disable_dma_in_interrupt }, AHB_PDMA_OUT_CH2 : { bind_dma_out_interrupt,
5777        enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
5778        _for_each_inner_peripheral!((@ peri_type #[doc =
5779        "DMA_AXI_CH0 peripheral singleton"] DMA_AXI_CH0 <= virtual(AXI_PDMA_IN_CH0 : {
5780        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5781        AXI_PDMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5782        disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
5783        peri_type #[doc = "DMA_AXI_CH1 peripheral singleton"] DMA_AXI_CH1 <=
5784        virtual(AXI_PDMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
5785        disable_dma_in_interrupt }, AXI_PDMA_OUT_CH1 : { bind_dma_out_interrupt,
5786        enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
5787        _for_each_inner_peripheral!((@ peri_type #[doc =
5788        "DMA_AXI_CH2 peripheral singleton"] DMA_AXI_CH2 <= virtual(AXI_PDMA_IN_CH2 : {
5789        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5790        AXI_PDMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5791        disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
5792        peri_type #[doc = "VDMA_CH0 peripheral singleton"] VDMA_CH0 <= virtual()
5793        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5794        "VDMA_CH1 peripheral singleton"] VDMA_CH1 <= virtual() (unstable)));
5795        _for_each_inner_peripheral!((@ peri_type #[doc = "VDMA_CH2 peripheral singleton"]
5796        VDMA_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
5797        #[doc = "VDMA_CH3 peripheral singleton"] VDMA_CH3 <= virtual() (unstable)));
5798        _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
5799        SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5800        = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
5801        _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
5802        SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5803        = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
5804        _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH4 peripheral singleton"]
5805        SDM_CH4 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5806        = "SDM_CH5 peripheral singleton"] SDM_CH5 <= virtual() (unstable)));
5807        _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH6 peripheral singleton"]
5808        SDM_CH6 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5809        = "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)));
5810        _for_each_inner_peripheral!((@ peri_type #[doc = "EFUSE peripheral singleton"]
5811        EFUSE <= EFUSE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5812        "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
5813        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
5814        GPIO_SD <= GPIO_SD() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5815        = "SYSTEM peripheral singleton"] SYSTEM <= HP_SYS() (unstable)));
5816        _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
5817        HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5818        "HP_SYS_CLKRST peripheral singleton"] HP_SYS_CLKRST <= HP_SYS_CLKRST()
5819        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5820        "RNG peripheral singleton"] RNG <= LP_SYS() (unstable)));
5821        _for_each_inner_peripheral!((@ peri_type #[doc =
5822        "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
5823        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5824        "INTERRUPT_CORE1 peripheral singleton"] INTERRUPT_CORE1 <= INTERRUPT_CORE1()
5825        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5826        "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
5827        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5828        "CLIC peripheral singleton"] CLIC <= CLIC() (unstable)));
5829        _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
5830        IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5831        "IOMUX_MSPI_PIN peripheral singleton"] IOMUX_MSPI_PIN <= IOMUX_MSPI_PIN()
5832        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5833        "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)));
5834        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
5835        LP_AON <= LP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5836        "LP_AON_CLKRST peripheral singleton"] LP_AON_CLKRST <= LP_AON_CLKRST()
5837        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5838        "LP_SYS peripheral singleton"] LP_SYS <= LP_SYS() (unstable)));
5839        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_GPIO peripheral singleton"]
5840        LP_GPIO <= LP_GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5841        = "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
5842        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
5843        LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5844        = "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
5845        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
5846        LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5847        "LPWR peripheral singleton"] LPWR <= LP_SYS() (unstable)));
5848        _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
5849        <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5850        "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
5851        _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
5852        TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5853        "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
5854        _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
5855        UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5856        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5857        "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
5858        enable_peri_interrupt, disable_peri_interrupt })));
5859        _for_each_inner_peripheral!((@ peri_type #[doc = "UART2 peripheral singleton"]
5860        UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
5861        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5862        "UART3 peripheral singleton"] UART3 <= UART3(UART3 : { bind_peri_interrupt,
5863        enable_peri_interrupt, disable_peri_interrupt })));
5864        _for_each_inner_peripheral!((@ peri_type #[doc = "UART4 peripheral singleton"]
5865        UART4 <= UART4(UART4 : { bind_peri_interrupt, enable_peri_interrupt,
5866        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5867        "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
5868        _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
5869        SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5870        "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
5871        _for_each_inner_peripheral!((@ peri_type #[doc = "MEMSPI2 peripheral singleton"]
5872        MEMSPI2 <= MEMSPI2() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5873        = "MEMSPI3 peripheral singleton"] MEMSPI3 <= MEMSPI3() (unstable)));
5874        _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
5875        SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
5876        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5877        "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3 : { bind_peri_interrupt,
5878        enable_peri_interrupt, disable_peri_interrupt })));
5879        _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
5880        I2C0 <= I2C0(I2C0 : { bind_peri_interrupt, enable_peri_interrupt,
5881        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5882        "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C1 : { bind_peri_interrupt,
5883        enable_peri_interrupt, disable_peri_interrupt })));
5884        _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
5885        I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
5886        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5887        #[doc = "I2S1 peripheral singleton"] I2S1 <= I2S1(I2S1 : { bind_peri_interrupt,
5888        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5889        _for_each_inner_peripheral!((@ peri_type #[doc = "I2S2 peripheral singleton"]
5890        I2S2 <= I2S2(I2S2 : { bind_peri_interrupt, enable_peri_interrupt,
5891        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5892        #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0(TWAI0 : {
5893        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5894        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5895        "TWAI1 peripheral singleton"] TWAI1 <= TWAI1(TWAI1 : { bind_peri_interrupt,
5896        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5897        _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI2 peripheral singleton"]
5898        TWAI2 <= TWAI2(TWAI2 : { bind_peri_interrupt, enable_peri_interrupt,
5899        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5900        #[doc = "DMA peripheral singleton"] DMA <= AHB_DMA() (unstable)));
5901        _for_each_inner_peripheral!((@ peri_type #[doc = "AXI_GDMA peripheral singleton"]
5902        AXI_GDMA <= AXI_DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type
5903        #[doc = "ETH peripheral singleton"] ETH <= virtual() (unstable)));
5904        _for_each_inner_peripheral!((@ peri_type #[doc = "EMAC_DMA peripheral singleton"]
5905        EMAC_DMA <= EMAC_DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type
5906        #[doc = "EMAC_MAC peripheral singleton"] EMAC_MAC <= EMAC_MAC() (unstable)));
5907        _for_each_inner_peripheral!((@ peri_type #[doc = "MIPI_DSI peripheral singleton"]
5908        MIPI_DSI <= virtual(DSI_BRIDGE : { bind_bridge_interrupt,
5909        enable_bridge_interrupt, disable_bridge_interrupt }, DSI : { bind_dsi_interrupt,
5910        enable_dsi_interrupt, disable_dsi_interrupt }) (unstable)));
5911        _for_each_inner_peripheral!((@ peri_type #[doc = "VDMA peripheral singleton"]
5912        VDMA <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5913        "MIPI_DSI_HOST peripheral singleton"] MIPI_DSI_HOST <= MIPI_DSI_HOST()
5914        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5915        "MIPI_DSI_BRIDGE peripheral singleton"] MIPI_DSI_BRIDGE <= MIPI_DSI_BRIDGE()
5916        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5917        "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
5918        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5919        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5920        "SDHOST peripheral singleton"] SDHOST <= SDHOST() (unstable)));
5921        _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
5922        LEDC <= LEDC(LEDC : { bind_peri_interrupt, enable_peri_interrupt,
5923        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5924        #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0(PWM0 : {
5925        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5926        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5927        "MCPWM1 peripheral singleton"] MCPWM1 <= MCPWM1(PWM1 : { bind_peri_interrupt,
5928        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5929        _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
5930        PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
5931        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5932        #[doc = "APB_SARADC peripheral singleton"] APB_SARADC <= ADC() (unstable)));
5933        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_ADC peripheral singleton"]
5934        LP_ADC <= LP_ADC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5935        "RMT peripheral singleton"] RMT <= virtual(RMT : { bind_peri_interrupt,
5936        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5937        _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
5938        <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5939        }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5940        "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
5941        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5942        _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
5943        <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5944        }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5945        "ECC peripheral singleton"] ECC <= ECC(ECC : { bind_peri_interrupt,
5946        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5947        _for_each_inner_peripheral!((@ peri_type #[doc = "USB_FS peripheral singleton"]
5948        USB_FS <= USB_FS(USB_FS : { bind_peri_interrupt, enable_peri_interrupt,
5949        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5950        #[doc = "USB_HS peripheral singleton"] USB_HS <= USB_HS(USB_HS : {
5951        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5952        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5953        "USB_WRAP peripheral singleton"] USB_WRAP <= USB_WRAP() (unstable)));
5954        _for_each_inner_peripheral!((@ peri_type #[doc = "ADC1 peripheral singleton"]
5955        ADC1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5956        "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)));
5957        _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
5958        FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5959        "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
5960        _for_each_inner_peripheral!((@ peri_type #[doc =
5961        "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
5962        _for_each_inner_peripheral!((@ peri_type #[doc = "CPU_CTRL peripheral singleton"]
5963        CPU_CTRL <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
5964        #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual()
5965        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5966        "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
5967        _for_each_inner_peripheral!((@ peri_type #[doc =
5968        "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
5969        _for_each_inner_peripheral!((@ peri_type #[doc =
5970        "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
5971        _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
5972        _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
5973        _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
5974        _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
5975        _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
5976        _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
5977        _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
5978        _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
5979        _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
5980        _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
5981        _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
5982        _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
5983        _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
5984        _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
5985        _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
5986        _for_each_inner_peripheral!((GPIO30)); _for_each_inner_peripheral!((GPIO31));
5987        _for_each_inner_peripheral!((GPIO32)); _for_each_inner_peripheral!((GPIO33));
5988        _for_each_inner_peripheral!((GPIO34)); _for_each_inner_peripheral!((GPIO35));
5989        _for_each_inner_peripheral!((GPIO36)); _for_each_inner_peripheral!((GPIO37));
5990        _for_each_inner_peripheral!((GPIO38)); _for_each_inner_peripheral!((GPIO39));
5991        _for_each_inner_peripheral!((GPIO40)); _for_each_inner_peripheral!((GPIO41));
5992        _for_each_inner_peripheral!((GPIO42)); _for_each_inner_peripheral!((GPIO43));
5993        _for_each_inner_peripheral!((GPIO44)); _for_each_inner_peripheral!((GPIO45));
5994        _for_each_inner_peripheral!((GPIO46)); _for_each_inner_peripheral!((GPIO47));
5995        _for_each_inner_peripheral!((GPIO48)); _for_each_inner_peripheral!((GPIO49));
5996        _for_each_inner_peripheral!((GPIO50)); _for_each_inner_peripheral!((GPIO51));
5997        _for_each_inner_peripheral!((GPIO52)); _for_each_inner_peripheral!((GPIO53));
5998        _for_each_inner_peripheral!((GPIO54));
5999        _for_each_inner_peripheral!((DMA_CH0(unstable)));
6000        _for_each_inner_peripheral!((DMA_CH1(unstable)));
6001        _for_each_inner_peripheral!((DMA_CH2(unstable)));
6002        _for_each_inner_peripheral!((DMA_AXI_CH0(unstable)));
6003        _for_each_inner_peripheral!((DMA_AXI_CH1(unstable)));
6004        _for_each_inner_peripheral!((DMA_AXI_CH2(unstable)));
6005        _for_each_inner_peripheral!((VDMA_CH0(unstable)));
6006        _for_each_inner_peripheral!((VDMA_CH1(unstable)));
6007        _for_each_inner_peripheral!((VDMA_CH2(unstable)));
6008        _for_each_inner_peripheral!((VDMA_CH3(unstable)));
6009        _for_each_inner_peripheral!((SDM_CH0(unstable)));
6010        _for_each_inner_peripheral!((SDM_CH1(unstable)));
6011        _for_each_inner_peripheral!((SDM_CH2(unstable)));
6012        _for_each_inner_peripheral!((SDM_CH3(unstable)));
6013        _for_each_inner_peripheral!((SDM_CH4(unstable)));
6014        _for_each_inner_peripheral!((SDM_CH5(unstable)));
6015        _for_each_inner_peripheral!((SDM_CH6(unstable)));
6016        _for_each_inner_peripheral!((SDM_CH7(unstable)));
6017        _for_each_inner_peripheral!((GPIO(unstable)));
6018        _for_each_inner_peripheral!((GPIO_SD(unstable)));
6019        _for_each_inner_peripheral!((SYSTEM(unstable)));
6020        _for_each_inner_peripheral!((HP_SYS(unstable)));
6021        _for_each_inner_peripheral!((HP_SYS_CLKRST(unstable)));
6022        _for_each_inner_peripheral!((RNG(unstable)));
6023        _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
6024        _for_each_inner_peripheral!((INTERRUPT_CORE1(unstable)));
6025        _for_each_inner_peripheral!((LP_I2C_ANA_MST(unstable)));
6026        _for_each_inner_peripheral!((CLIC(unstable)));
6027        _for_each_inner_peripheral!((IO_MUX(unstable)));
6028        _for_each_inner_peripheral!((LP_I2C0(unstable)));
6029        _for_each_inner_peripheral!((LP_AON(unstable)));
6030        _for_each_inner_peripheral!((LP_AON_CLKRST(unstable)));
6031        _for_each_inner_peripheral!((LP_SYS(unstable)));
6032        _for_each_inner_peripheral!((LP_GPIO(unstable)));
6033        _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
6034        _for_each_inner_peripheral!((LP_PERI(unstable)));
6035        _for_each_inner_peripheral!((RTC_TIMER(unstable)));
6036        _for_each_inner_peripheral!((LP_WDT(unstable)));
6037        _for_each_inner_peripheral!((LPWR(unstable)));
6038        _for_each_inner_peripheral!((PMU(unstable)));
6039        _for_each_inner_peripheral!((SYSTIMER(unstable)));
6040        _for_each_inner_peripheral!((TIMG0(unstable)));
6041        _for_each_inner_peripheral!((TIMG1(unstable)));
6042        _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
6043        _for_each_inner_peripheral!((UART2)); _for_each_inner_peripheral!((UART3));
6044        _for_each_inner_peripheral!((UART4));
6045        _for_each_inner_peripheral!((UHCI0(unstable)));
6046        _for_each_inner_peripheral!((SPI2)); _for_each_inner_peripheral!((SPI3));
6047        _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
6048        _for_each_inner_peripheral!((I2S0(unstable)));
6049        _for_each_inner_peripheral!((I2S1(unstable)));
6050        _for_each_inner_peripheral!((I2S2(unstable)));
6051        _for_each_inner_peripheral!((TWAI0(unstable)));
6052        _for_each_inner_peripheral!((TWAI1(unstable)));
6053        _for_each_inner_peripheral!((TWAI2(unstable)));
6054        _for_each_inner_peripheral!((DMA(unstable)));
6055        _for_each_inner_peripheral!((AXI_GDMA(unstable)));
6056        _for_each_inner_peripheral!((ETH(unstable)));
6057        _for_each_inner_peripheral!((MIPI_DSI(unstable)));
6058        _for_each_inner_peripheral!((USB_DEVICE(unstable)));
6059        _for_each_inner_peripheral!((SDHOST(unstable)));
6060        _for_each_inner_peripheral!((LEDC(unstable)));
6061        _for_each_inner_peripheral!((MCPWM0(unstable)));
6062        _for_each_inner_peripheral!((MCPWM1(unstable)));
6063        _for_each_inner_peripheral!((PCNT(unstable)));
6064        _for_each_inner_peripheral!((APB_SARADC(unstable)));
6065        _for_each_inner_peripheral!((LP_ADC(unstable)));
6066        _for_each_inner_peripheral!((RMT(unstable)));
6067        _for_each_inner_peripheral!((AES(unstable)));
6068        _for_each_inner_peripheral!((SHA(unstable)));
6069        _for_each_inner_peripheral!((RSA(unstable)));
6070        _for_each_inner_peripheral!((ECC(unstable)));
6071        _for_each_inner_peripheral!((USB_FS(unstable)));
6072        _for_each_inner_peripheral!((USB_HS(unstable)));
6073        _for_each_inner_peripheral!((ADC1(unstable)));
6074        _for_each_inner_peripheral!((ADC2(unstable)));
6075        _for_each_inner_peripheral!((FLASH(unstable)));
6076        _for_each_inner_peripheral!((PSRAM(unstable)));
6077        _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
6078        _for_each_inner_peripheral!((CPU_CTRL(unstable)));
6079        _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
6080        _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
6081        _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
6082        _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
6083        _for_each_inner_peripheral!((SPI2, Spi2, 1, AxiGdmaChannel));
6084        _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
6085        _for_each_inner_peripheral!((SPI3, Spi3, 2, AxiGdmaChannel));
6086        _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
6087        _for_each_inner_peripheral!((I2S1, I2s1, 4, AhbGdmaChannel));
6088        _for_each_inner_peripheral!((AES, Aes, 4, AxiGdmaChannel));
6089        _for_each_inner_peripheral!((I2S2, I2s2, 5, AhbGdmaChannel));
6090        _for_each_inner_peripheral!((SHA, Sha, 5, AxiGdmaChannel));
6091        _for_each_inner_peripheral!((all(@ peri_type #[doc =
6092        "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
6093        "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
6094        "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6095        "<section class=\"warning\">"] #[doc =
6096        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6097        #[doc = "<ul>"] #[doc =
6098        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6099        #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
6100        "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6101        "<section class=\"warning\">"] #[doc =
6102        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6103        #[doc = "<ul>"] #[doc =
6104        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6105        #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
6106        "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6107        "<section class=\"warning\">"] #[doc =
6108        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6109        #[doc = "<ul>"] #[doc =
6110        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6111        #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
6112        "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6113        "<section class=\"warning\">"] #[doc =
6114        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6115        #[doc = "<ul>"] #[doc =
6116        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6117        #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
6118        "GPIO6 peripheral singleton"] GPIO6 <= virtual()), (@ peri_type #[doc =
6119        "GPIO7 peripheral singleton"] GPIO7 <= virtual()), (@ peri_type #[doc =
6120        "GPIO8 peripheral singleton"] GPIO8 <= virtual()), (@ peri_type #[doc =
6121        "GPIO9 peripheral singleton"] GPIO9 <= virtual()), (@ peri_type #[doc =
6122        "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
6123        "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
6124        "GPIO12 peripheral singleton"] GPIO12 <= virtual()), (@ peri_type #[doc =
6125        "GPIO13 peripheral singleton"] GPIO13 <= virtual()), (@ peri_type #[doc =
6126        "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
6127        "GPIO15 peripheral singleton"] GPIO15 <= virtual()), (@ peri_type #[doc =
6128        "GPIO16 peripheral singleton"] GPIO16 <= virtual()), (@ peri_type #[doc =
6129        "GPIO17 peripheral singleton"] GPIO17 <= virtual()), (@ peri_type #[doc =
6130        "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
6131        "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
6132        "GPIO20 peripheral singleton"] GPIO20 <= virtual()), (@ peri_type #[doc =
6133        "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
6134        "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
6135        "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
6136        "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6137        "<section class=\"warning\">"] #[doc =
6138        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6139        #[doc = "<ul>"] #[doc =
6140        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6141        #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
6142        "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6143        "<section class=\"warning\">"] #[doc =
6144        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6145        #[doc = "<ul>"] #[doc =
6146        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6147        #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
6148        "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
6149        "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
6150        "GPIO28 peripheral singleton"] GPIO28 <= virtual()), (@ peri_type #[doc =
6151        "GPIO29 peripheral singleton"] GPIO29 <= virtual()), (@ peri_type #[doc =
6152        "GPIO30 peripheral singleton"] GPIO30 <= virtual()), (@ peri_type #[doc =
6153        "GPIO31 peripheral singleton"] GPIO31 <= virtual()), (@ peri_type #[doc =
6154        "GPIO32 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6155        "<section class=\"warning\">"] #[doc =
6156        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6157        #[doc = "<ul>"] #[doc =
6158        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6159        = "</ul>"] #[doc = "</section>"] GPIO32 <= virtual()), (@ peri_type #[doc =
6160        "GPIO33 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6161        "<section class=\"warning\">"] #[doc =
6162        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6163        #[doc = "<ul>"] #[doc =
6164        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6165        = "</ul>"] #[doc = "</section>"] GPIO33 <= virtual()), (@ peri_type #[doc =
6166        "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6167        "<section class=\"warning\">"] #[doc =
6168        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6169        #[doc = "<ul>"] #[doc =
6170        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6171        = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()), (@ peri_type #[doc =
6172        "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6173        "<section class=\"warning\">"] #[doc =
6174        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6175        #[doc = "<ul>"] #[doc =
6176        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6177        = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()), (@ peri_type #[doc =
6178        "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6179        "<section class=\"warning\">"] #[doc =
6180        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6181        #[doc = "<ul>"] #[doc =
6182        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6183        = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()), (@ peri_type #[doc =
6184        "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6185        "<section class=\"warning\">"] #[doc =
6186        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6187        #[doc = "<ul>"] #[doc =
6188        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6189        = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()), (@ peri_type #[doc =
6190        "GPIO38 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6191        "<section class=\"warning\">"] #[doc =
6192        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6193        #[doc = "<ul>"] #[doc =
6194        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6195        = "</ul>"] #[doc = "</section>"] GPIO38 <= virtual()), (@ peri_type #[doc =
6196        "GPIO39 peripheral singleton"] GPIO39 <= virtual()), (@ peri_type #[doc =
6197        "GPIO40 peripheral singleton"] GPIO40 <= virtual()), (@ peri_type #[doc =
6198        "GPIO41 peripheral singleton"] GPIO41 <= virtual()), (@ peri_type #[doc =
6199        "GPIO42 peripheral singleton"] GPIO42 <= virtual()), (@ peri_type #[doc =
6200        "GPIO43 peripheral singleton"] GPIO43 <= virtual()), (@ peri_type #[doc =
6201        "GPIO44 peripheral singleton"] GPIO44 <= virtual()), (@ peri_type #[doc =
6202        "GPIO45 peripheral singleton"] GPIO45 <= virtual()), (@ peri_type #[doc =
6203        "GPIO46 peripheral singleton"] GPIO46 <= virtual()), (@ peri_type #[doc =
6204        "GPIO47 peripheral singleton"] GPIO47 <= virtual()), (@ peri_type #[doc =
6205        "GPIO48 peripheral singleton"] GPIO48 <= virtual()), (@ peri_type #[doc =
6206        "GPIO49 peripheral singleton"] GPIO49 <= virtual()), (@ peri_type #[doc =
6207        "GPIO50 peripheral singleton"] GPIO50 <= virtual()), (@ peri_type #[doc =
6208        "GPIO51 peripheral singleton"] GPIO51 <= virtual()), (@ peri_type #[doc =
6209        "GPIO52 peripheral singleton"] GPIO52 <= virtual()), (@ peri_type #[doc =
6210        "GPIO53 peripheral singleton"] GPIO53 <= virtual()), (@ peri_type #[doc =
6211        "GPIO54 peripheral singleton"] GPIO54 <= virtual()), (@ peri_type #[doc =
6212        "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(AHB_PDMA_IN_CH0 : {
6213        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6214        AHB_PDMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6215        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6216        "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(AHB_PDMA_IN_CH1 : {
6217        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6218        AHB_PDMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6219        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6220        "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(AHB_PDMA_IN_CH2 : {
6221        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6222        AHB_PDMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6223        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6224        "DMA_AXI_CH0 peripheral singleton"] DMA_AXI_CH0 <= virtual(AXI_PDMA_IN_CH0 : {
6225        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6226        AXI_PDMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6227        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6228        "DMA_AXI_CH1 peripheral singleton"] DMA_AXI_CH1 <= virtual(AXI_PDMA_IN_CH1 : {
6229        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6230        AXI_PDMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6231        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6232        "DMA_AXI_CH2 peripheral singleton"] DMA_AXI_CH2 <= virtual(AXI_PDMA_IN_CH2 : {
6233        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6234        AXI_PDMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6235        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6236        "VDMA_CH0 peripheral singleton"] VDMA_CH0 <= virtual() (unstable)), (@ peri_type
6237        #[doc = "VDMA_CH1 peripheral singleton"] VDMA_CH1 <= virtual() (unstable)), (@
6238        peri_type #[doc = "VDMA_CH2 peripheral singleton"] VDMA_CH2 <= virtual()
6239        (unstable)), (@ peri_type #[doc = "VDMA_CH3 peripheral singleton"] VDMA_CH3 <=
6240        virtual() (unstable)), (@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
6241        SDM_CH0 <= virtual() (unstable)), (@ peri_type #[doc =
6242        "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)), (@ peri_type
6243        #[doc = "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual() (unstable)), (@
6244        peri_type #[doc = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual()
6245        (unstable)), (@ peri_type #[doc = "SDM_CH4 peripheral singleton"] SDM_CH4 <=
6246        virtual() (unstable)), (@ peri_type #[doc = "SDM_CH5 peripheral singleton"]
6247        SDM_CH5 <= virtual() (unstable)), (@ peri_type #[doc =
6248        "SDM_CH6 peripheral singleton"] SDM_CH6 <= virtual() (unstable)), (@ peri_type
6249        #[doc = "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)), (@
6250        peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@
6251        peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@
6252        peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD()
6253        (unstable)), (@ peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <=
6254        HP_SYS() (unstable)), (@ peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS
6255        <= HP_SYS() (unstable)), (@ peri_type #[doc =
6256        "HP_SYS_CLKRST peripheral singleton"] HP_SYS_CLKRST <= HP_SYS_CLKRST()
6257        (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= LP_SYS()
6258        (unstable)), (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"]
6259        INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
6260        "INTERRUPT_CORE1 peripheral singleton"] INTERRUPT_CORE1 <= INTERRUPT_CORE1()
6261        (unstable)), (@ peri_type #[doc = "LP_I2C_ANA_MST peripheral singleton"]
6262        LP_I2C_ANA_MST <= LP_I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
6263        "CLIC peripheral singleton"] CLIC <= CLIC() (unstable)), (@ peri_type #[doc =
6264        "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type #[doc
6265        = "IOMUX_MSPI_PIN peripheral singleton"] IOMUX_MSPI_PIN <= IOMUX_MSPI_PIN()
6266        (unstable)), (@ peri_type #[doc = "LP_I2C0 peripheral singleton"] LP_I2C0 <=
6267        LP_I2C0() (unstable)), (@ peri_type #[doc = "LP_AON peripheral singleton"] LP_AON
6268        <= LP_SYS() (unstable)), (@ peri_type #[doc =
6269        "LP_AON_CLKRST peripheral singleton"] LP_AON_CLKRST <= LP_AON_CLKRST()
6270        (unstable)), (@ peri_type #[doc = "LP_SYS peripheral singleton"] LP_SYS <=
6271        LP_SYS() (unstable)), (@ peri_type #[doc = "LP_GPIO peripheral singleton"]
6272        LP_GPIO <= LP_GPIO() (unstable)), (@ peri_type #[doc =
6273        "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)), (@
6274        peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LP_PERI()
6275        (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
6276        LP_TIMER() (unstable)), (@ peri_type #[doc = "LP_WDT peripheral singleton"]
6277        LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"]
6278        LPWR <= LP_SYS() (unstable)), (@ peri_type #[doc = "PMU peripheral singleton"]
6279        PMU <= PMU() (unstable)), (@ peri_type #[doc = "SYSTIMER peripheral singleton"]
6280        SYSTIMER <= SYSTIMER() (unstable)), (@ peri_type #[doc =
6281        "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@ peri_type #[doc =
6282        "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@ peri_type #[doc =
6283        "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
6284        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
6285        "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
6286        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
6287        "UART2 peripheral singleton"] UART2 <= UART2(UART2 : { bind_peri_interrupt,
6288        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
6289        "UART3 peripheral singleton"] UART3 <= UART3(UART3 : { bind_peri_interrupt,
6290        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
6291        "UART4 peripheral singleton"] UART4 <= UART4(UART4 : { bind_peri_interrupt,
6292        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
6293        "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@ peri_type #[doc =
6294        "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
6295        "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
6296        "MEMSPI2 peripheral singleton"] MEMSPI2 <= MEMSPI2() (unstable)), (@ peri_type
6297        #[doc = "MEMSPI3 peripheral singleton"] MEMSPI3 <= MEMSPI3() (unstable)), (@
6298        peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : {
6299        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6300        peri_type #[doc = "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3 : {
6301        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6302        peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C0 : {
6303        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6304        peri_type #[doc = "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C1 : {
6305        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6306        peri_type #[doc = "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : {
6307        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6308        (unstable)), (@ peri_type #[doc = "I2S1 peripheral singleton"] I2S1 <= I2S1(I2S1
6309        : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6310        (unstable)), (@ peri_type #[doc = "I2S2 peripheral singleton"] I2S2 <= I2S2(I2S2
6311        : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6312        (unstable)), (@ peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <=
6313        TWAI0(TWAI0 : { bind_peri_interrupt, enable_peri_interrupt,
6314        disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
6315        "TWAI1 peripheral singleton"] TWAI1 <= TWAI1(TWAI1 : { bind_peri_interrupt,
6316        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6317        = "TWAI2 peripheral singleton"] TWAI2 <= TWAI2(TWAI2 : { bind_peri_interrupt,
6318        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6319        = "DMA peripheral singleton"] DMA <= AHB_DMA() (unstable)), (@ peri_type #[doc =
6320        "AXI_GDMA peripheral singleton"] AXI_GDMA <= AXI_DMA() (unstable)), (@ peri_type
6321        #[doc = "ETH peripheral singleton"] ETH <= virtual() (unstable)), (@ peri_type
6322        #[doc = "EMAC_DMA peripheral singleton"] EMAC_DMA <= EMAC_DMA() (unstable)), (@
6323        peri_type #[doc = "EMAC_MAC peripheral singleton"] EMAC_MAC <= EMAC_MAC()
6324        (unstable)), (@ peri_type #[doc = "MIPI_DSI peripheral singleton"] MIPI_DSI <=
6325        virtual(DSI_BRIDGE : { bind_bridge_interrupt, enable_bridge_interrupt,
6326        disable_bridge_interrupt }, DSI : { bind_dsi_interrupt, enable_dsi_interrupt,
6327        disable_dsi_interrupt }) (unstable)), (@ peri_type #[doc =
6328        "VDMA peripheral singleton"] VDMA <= DMA() (unstable)), (@ peri_type #[doc =
6329        "MIPI_DSI_HOST peripheral singleton"] MIPI_DSI_HOST <= MIPI_DSI_HOST()
6330        (unstable)), (@ peri_type #[doc = "MIPI_DSI_BRIDGE peripheral singleton"]
6331        MIPI_DSI_BRIDGE <= MIPI_DSI_BRIDGE() (unstable)), (@ peri_type #[doc =
6332        "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6333        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6334        (unstable)), (@ peri_type #[doc = "SDHOST peripheral singleton"] SDHOST <=
6335        SDHOST() (unstable)), (@ peri_type #[doc = "LEDC peripheral singleton"] LEDC <=
6336        LEDC(LEDC : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6337        }) (unstable)), (@ peri_type #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <=
6338        MCPWM0(PWM0 : { bind_peri_interrupt, enable_peri_interrupt,
6339        disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
6340        "MCPWM1 peripheral singleton"] MCPWM1 <= MCPWM1(PWM1 : { bind_peri_interrupt,
6341        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6342        = "PCNT peripheral singleton"] PCNT <= PCNT(PCNT : { bind_peri_interrupt,
6343        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6344        = "APB_SARADC peripheral singleton"] APB_SARADC <= ADC() (unstable)), (@
6345        peri_type #[doc = "LP_ADC peripheral singleton"] LP_ADC <= LP_ADC() (unstable)),
6346        (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= virtual(RMT : {
6347        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6348        (unstable)), (@ peri_type #[doc = "AES peripheral singleton"] AES <= AES(AES : {
6349        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6350        (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
6351        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6352        (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
6353        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6354        (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <= ECC(ECC : {
6355        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6356        (unstable)), (@ peri_type #[doc = "USB_FS peripheral singleton"] USB_FS <=
6357        USB_FS(USB_FS : { bind_peri_interrupt, enable_peri_interrupt,
6358        disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
6359        "USB_HS peripheral singleton"] USB_HS <= USB_HS(USB_HS : { bind_peri_interrupt,
6360        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6361        = "USB_WRAP peripheral singleton"] USB_WRAP <= USB_WRAP() (unstable)), (@
6362        peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@
6363        peri_type #[doc = "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)), (@
6364        peri_type #[doc = "FLASH peripheral singleton"] FLASH <= virtual() (unstable)),
6365        (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual()
6366        (unstable)), (@ peri_type #[doc = "GPIO_DEDICATED peripheral singleton"]
6367        GPIO_DEDICATED <= virtual() (unstable)), (@ peri_type #[doc =
6368        "CPU_CTRL peripheral singleton"] CPU_CTRL <= virtual() (unstable)), (@ peri_type
6369        #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual()
6370        (unstable)), (@ peri_type #[doc = "FROM_CPU_INTR1 peripheral singleton"]
6371        FROM_CPU_INTR1 <= virtual() (unstable)), (@ peri_type #[doc =
6372        "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)),
6373        (@ peri_type #[doc = "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <=
6374        virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1),
6375        (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
6376        (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO15), (GPIO16), (GPIO17), (GPIO18),
6377        (GPIO19), (GPIO20), (GPIO21), (GPIO22), (GPIO23), (GPIO24), (GPIO25), (GPIO26),
6378        (GPIO27), (GPIO28), (GPIO29), (GPIO30), (GPIO31), (GPIO32), (GPIO33), (GPIO34),
6379        (GPIO35), (GPIO36), (GPIO37), (GPIO38), (GPIO39), (GPIO40), (GPIO41), (GPIO42),
6380        (GPIO43), (GPIO44), (GPIO45), (GPIO46), (GPIO47), (GPIO48), (GPIO49), (GPIO50),
6381        (GPIO51), (GPIO52), (GPIO53), (GPIO54), (DMA_CH0(unstable)), (DMA_CH1(unstable)),
6382        (DMA_CH2(unstable)), (DMA_AXI_CH0(unstable)), (DMA_AXI_CH1(unstable)),
6383        (DMA_AXI_CH2(unstable)), (VDMA_CH0(unstable)), (VDMA_CH1(unstable)),
6384        (VDMA_CH2(unstable)), (VDMA_CH3(unstable)), (SDM_CH0(unstable)),
6385        (SDM_CH1(unstable)), (SDM_CH2(unstable)), (SDM_CH3(unstable)),
6386        (SDM_CH4(unstable)), (SDM_CH5(unstable)), (SDM_CH6(unstable)),
6387        (SDM_CH7(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)), (SYSTEM(unstable)),
6388        (HP_SYS(unstable)), (HP_SYS_CLKRST(unstable)), (RNG(unstable)),
6389        (INTERRUPT_CORE0(unstable)), (INTERRUPT_CORE1(unstable)),
6390        (LP_I2C_ANA_MST(unstable)), (CLIC(unstable)), (IO_MUX(unstable)),
6391        (LP_I2C0(unstable)), (LP_AON(unstable)), (LP_AON_CLKRST(unstable)),
6392        (LP_SYS(unstable)), (LP_GPIO(unstable)), (LP_IO_MUX(unstable)),
6393        (LP_PERI(unstable)), (RTC_TIMER(unstable)), (LP_WDT(unstable)), (LPWR(unstable)),
6394        (PMU(unstable)), (SYSTIMER(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
6395        (UART0), (UART1), (UART2), (UART3), (UART4), (UHCI0(unstable)), (SPI2), (SPI3),
6396        (I2C0), (I2C1), (I2S0(unstable)), (I2S1(unstable)), (I2S2(unstable)),
6397        (TWAI0(unstable)), (TWAI1(unstable)), (TWAI2(unstable)), (DMA(unstable)),
6398        (AXI_GDMA(unstable)), (ETH(unstable)), (MIPI_DSI(unstable)),
6399        (USB_DEVICE(unstable)), (SDHOST(unstable)), (LEDC(unstable)), (MCPWM0(unstable)),
6400        (MCPWM1(unstable)), (PCNT(unstable)), (APB_SARADC(unstable)), (LP_ADC(unstable)),
6401        (RMT(unstable)), (AES(unstable)), (SHA(unstable)), (RSA(unstable)),
6402        (ECC(unstable)), (USB_FS(unstable)), (USB_HS(unstable)), (ADC1(unstable)),
6403        (ADC2(unstable)), (FLASH(unstable)), (PSRAM(unstable)),
6404        (GPIO_DEDICATED(unstable)), (CPU_CTRL(unstable)), (FROM_CPU_INTR0(unstable)),
6405        (FROM_CPU_INTR1(unstable)), (FROM_CPU_INTR2(unstable)),
6406        (FROM_CPU_INTR3(unstable)))); _for_each_inner_peripheral!((dma_eligible(SPI2,
6407        Spi2, 1, AxiGdmaChannel), (UHCI0, Uhci0, 2, AhbGdmaChannel), (SPI3, Spi3, 2,
6408        AxiGdmaChannel), (I2S0, I2s0, 3, AhbGdmaChannel), (I2S1, I2s1, 4,
6409        AhbGdmaChannel), (AES, Aes, 4, AxiGdmaChannel), (I2S2, I2s2, 5, AhbGdmaChannel),
6410        (SHA, Sha, 5, AxiGdmaChannel)));
6411    };
6412}
6413/// This macro can be used to generate code for each `GPIOn` instance.
6414///
6415/// For an explanation on the general syntax, as well as usage of individual/repeated
6416/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6417///
6418/// This macro has one option for its "Individual matcher" case:
6419///
6420/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
6421/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
6422/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
6423///
6424/// Macro fragments:
6425///
6426/// - `$n`: the number of the GPIO. For `GPIO0`, `$n` is 0.
6427/// - `$gpio`: the name of the GPIO.
6428/// - `$digital_input_function`: the number of the digital function, as an identifier (i.e. for
6429///   function 0 this is `_0`).
6430/// - `$digital_input_function`: the name of the digital function, as an identifier.
6431/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for
6432///   function 0 this is `_0`).
6433/// - `$digital_output_function`: the name of the digital function, as an identifier.
6434/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
6435///   Bracketed so that they can also be matched as optional fragments. Order is always Input first.
6436///
6437/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
6438/// [Output]))`
6439#[macro_export]
6440#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6441macro_rules! for_each_gpio {
6442    ($($pattern:tt => $code:tt;)*) => {
6443        macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
6444        } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
6445        _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
6446        _for_each_inner_gpio!((2, GPIO2(_0 => MTCK) (_0 => MTCK) ([Input] [Output])));
6447        _for_each_inner_gpio!((3, GPIO3(_0 => MTDI) (_0 => MTDI) ([Input] [Output])));
6448        _for_each_inner_gpio!((4, GPIO4(_0 => MTMS) (_0 => MTMS) ([Input] [Output])));
6449        _for_each_inner_gpio!((5, GPIO5(_0 => MTDO) (_0 => MTDO) ([Input] [Output])));
6450        _for_each_inner_gpio!((6, GPIO6(_3 => SPI2_HOLD) (_3 => SPI2_HOLD) ([Input]
6451        [Output]))); _for_each_inner_gpio!((7, GPIO7(_3 => SPI2_CS) (_3 => SPI2_CS)
6452        ([Input] [Output]))); _for_each_inner_gpio!((8, GPIO8(_3 => SPI2_D) (_2 =>
6453        UART0_RTS _3 => SPI2_D) ([Input] [Output]))); _for_each_inner_gpio!((9, GPIO9(_2
6454        => UART0_CTS _3 => SPI2_CK) (_3 => SPI2_CK) ([Input] [Output])));
6455        _for_each_inner_gpio!((10, GPIO10(_3 => SPI2_Q) (_2 => UART1_TXD _3 => SPI2_Q)
6456        ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11(_2 => UART1_RXD _3 =>
6457        SPI2_WP) (_3 => SPI2_WP) ([Input] [Output]))); _for_each_inner_gpio!((12,
6458        GPIO12() (_2 => UART1_RTS) ([Input] [Output]))); _for_each_inner_gpio!((13,
6459        GPIO13(_2 => UART1_CTS) () ([Input] [Output]))); _for_each_inner_gpio!((14,
6460        GPIO14() () ([Input] [Output]))); _for_each_inner_gpio!((15, GPIO15() () ([Input]
6461        [Output]))); _for_each_inner_gpio!((16, GPIO16() () ([Input] [Output])));
6462        _for_each_inner_gpio!((17, GPIO17() () ([Input] [Output])));
6463        _for_each_inner_gpio!((18, GPIO18() () ([Input] [Output])));
6464        _for_each_inner_gpio!((19, GPIO19() () ([Input] [Output])));
6465        _for_each_inner_gpio!((20, GPIO20() () ([Input] [Output])));
6466        _for_each_inner_gpio!((21, GPIO21() () ([Input] [Output])));
6467        _for_each_inner_gpio!((22, GPIO22(_4 => DBG_PSRAM_CK) (_4 => DBG_PSRAM_CK)
6468        ([Input] [Output]))); _for_each_inner_gpio!((23, GPIO23(_3 => REF_50M_CLK _4 =>
6469        DBG_PSRAM_CS) (_3 => REF_50M_CLK _4 => DBG_PSRAM_CS) ([Input] [Output])));
6470        _for_each_inner_gpio!((24, GPIO24() () ([Input] [Output])));
6471        _for_each_inner_gpio!((25, GPIO25() () ([Input] [Output])));
6472        _for_each_inner_gpio!((26, GPIO26() () ([Input] [Output])));
6473        _for_each_inner_gpio!((27, GPIO27() () ([Input] [Output])));
6474        _for_each_inner_gpio!((28, GPIO28(_2 => SPI2_CS _3 => EMAC_RXDV _4 =>
6475        DBG_PSRAM_D) (_2 => SPI2_CS _4 => DBG_PSRAM_D) ([Input] [Output])));
6476        _for_each_inner_gpio!((29, GPIO29(_2 => SPI2_D _3 => EMAC_RXD0 _4 => DBG_PSRAM_Q)
6477        (_2 => SPI2_D _4 => DBG_PSRAM_Q) ([Input] [Output]))); _for_each_inner_gpio!((30,
6478        GPIO30(_2 => SPI2_CK _3 => EMAC_RXD1 _4 => DBG_PSRAM_WP) (_2 => SPI2_CK _4 =>
6479        DBG_PSRAM_WP) ([Input] [Output]))); _for_each_inner_gpio!((31, GPIO31(_2 =>
6480        SPI2_Q _3 => EMAC_RXER _4 => DBG_PSRAM_HOLD) (_2 => SPI2_Q _4 => DBG_PSRAM_HOLD)
6481        ([Input] [Output]))); _for_each_inner_gpio!((32, GPIO32(_2 => SPI2_HOLD _3 =>
6482        EMAC_RMII_CLK _4 => DBG_PSRAM_DQ4) (_2 => SPI2_HOLD _3 => EMAC_RMII_CLK _4 =>
6483        DBG_PSRAM_DQ4) ([Input] [Output]))); _for_each_inner_gpio!((33, GPIO33(_2 =>
6484        SPI2_WP _4 => DBG_PSRAM_DQ5) (_2 => SPI2_WP _3 => EMAC_TXEN _4 => DBG_PSRAM_DQ5)
6485        ([Input] [Output]))); _for_each_inner_gpio!((34, GPIO34(_2 => SPI2_IO4 _4 =>
6486        DBG_PSRAM_DQ6) (_2 => SPI2_IO4 _3 => EMAC_TXD0 _4 => DBG_PSRAM_DQ6) ([Input]
6487        [Output]))); _for_each_inner_gpio!((35, GPIO35(_2 => SPI2_IO5 _4 =>
6488        DBG_PSRAM_DQ7) (_2 => SPI2_IO5 _3 => EMAC_TXD1 _4 => DBG_PSRAM_DQ7) ([Input]
6489        [Output]))); _for_each_inner_gpio!((36, GPIO36(_2 => SPI2_IO6 _4 =>
6490        DBG_PSRAM_DQS_0) (_2 => SPI2_IO6 _3 => EMAC_TXER _4 => DBG_PSRAM_DQS_0) ([Input]
6491        [Output]))); _for_each_inner_gpio!((37, GPIO37(_2 => SPI2_IO7) (_0 => UART0_TXD
6492        _2 => SPI2_IO7) ([Input] [Output]))); _for_each_inner_gpio!((38, GPIO38(_0 =>
6493        UART0_RXD _2 => SPI2_DQS) (_2 => SPI2_DQS) ([Input] [Output])));
6494        _for_each_inner_gpio!((39, GPIO39(_0 => SD1_DATA0 _2 => BIST _3 => REF_50M_CLK _4
6495        => DBG_PSRAM_DQ8) (_0 => SD1_DATA0 _2 => BIST _3 => REF_50M_CLK _4 =>
6496        DBG_PSRAM_DQ8) ([Input] [Output]))); _for_each_inner_gpio!((40, GPIO40(_0 =>
6497        SD1_DATA1 _2 => BIST _4 => DBG_PSRAM_DQ9) (_0 => SD1_DATA1 _2 => BIST _3 =>
6498        EMAC_TXEN _4 => DBG_PSRAM_DQ9) ([Input] [Output]))); _for_each_inner_gpio!((41,
6499        GPIO41(_0 => SD1_DATA2 _2 => BIST _4 => DBG_PSRAM_DQ10) (_0 => SD1_DATA2 _2 =>
6500        BIST _3 => EMAC_TXD0 _4 => DBG_PSRAM_DQ10) ([Input] [Output])));
6501        _for_each_inner_gpio!((42, GPIO42(_0 => SD1_DATA3 _2 => BIST _4 =>
6502        DBG_PSRAM_DQ11) (_0 => SD1_DATA3 _2 => BIST _3 => EMAC_TXD1 _4 => DBG_PSRAM_DQ11)
6503        ([Input] [Output]))); _for_each_inner_gpio!((43, GPIO43(_0 => SD1_CLK _2 => BIST
6504        _4 => DBG_PSRAM_DQ12) (_0 => SD1_CLK _2 => BIST _3 => EMAC_TXER _4 =>
6505        DBG_PSRAM_DQ12) ([Input] [Output]))); _for_each_inner_gpio!((44, GPIO44(_0 =>
6506        SD1_CMD _2 => BIST _3 => EMAC_RMII_CLK _4 => DBG_PSRAM_DQ13) (_0 => SD1_CMD _2 =>
6507        BIST _3 => EMAC_RMII_CLK _4 => DBG_PSRAM_DQ13) ([Input] [Output])));
6508        _for_each_inner_gpio!((45, GPIO45(_0 => SD1_DATA4 _2 => BIST _3 => EMAC_RXDV _4
6509        => DBG_PSRAM_DQ14) (_0 => SD1_DATA4 _2 => BIST _4 => DBG_PSRAM_DQ14) ([Input]
6510        [Output]))); _for_each_inner_gpio!((46, GPIO46(_0 => SD1_DATA5 _2 => BIST _3 =>
6511        EMAC_RXD0 _4 => DBG_PSRAM_DQ15) (_0 => SD1_DATA5 _2 => BIST _4 => DBG_PSRAM_DQ15)
6512        ([Input] [Output]))); _for_each_inner_gpio!((47, GPIO47(_0 => SD1_DATA6 _2 =>
6513        BIST _3 => EMAC_RXD1 _4 => DBG_PSRAM_DQS_1) (_0 => SD1_DATA6 _2 => BIST _4 =>
6514        DBG_PSRAM_DQS_1) ([Input] [Output]))); _for_each_inner_gpio!((48, GPIO48(_0 =>
6515        SD1_DATA7 _2 => BIST _3 => EMAC_RXER) (_0 => SD1_DATA7 _2 => BIST) ([Input]
6516        [Output]))); _for_each_inner_gpio!((49, GPIO49(_4 => DBG_FLASH_CS) (_3 =>
6517        EMAC_TXEN _4 => DBG_FLASH_CS) ([Input] [Output]))); _for_each_inner_gpio!((50,
6518        GPIO50(_3 => EMAC_RMII_CLK _4 => DBG_FLASH_Q) (_3 => EMAC_RMII_CLK _4 =>
6519        DBG_FLASH_Q) ([Input] [Output]))); _for_each_inner_gpio!((51, GPIO51(_3 =>
6520        EMAC_RXDV _4 => DBG_FLASH_WP) (_4 => DBG_FLASH_WP) ([Input] [Output])));
6521        _for_each_inner_gpio!((52, GPIO52(_3 => EMAC_RXD0 _4 => DBG_FLASH_HOLD) (_4 =>
6522        DBG_FLASH_HOLD) ([Input] [Output]))); _for_each_inner_gpio!((53, GPIO53(_3 =>
6523        EMAC_RXD1 _4 => DBG_FLASH_CK) (_4 => DBG_FLASH_CK) ([Input] [Output])));
6524        _for_each_inner_gpio!((54, GPIO54(_3 => EMAC_RXER _4 => DBG_FLASH_D) (_4 =>
6525        DBG_FLASH_D) ([Input] [Output]))); _for_each_inner_gpio!((all(0, GPIO0() ()
6526        ([Input] [Output])), (1, GPIO1() () ([Input] [Output])), (2, GPIO2(_0 => MTCK)
6527        (_0 => MTCK) ([Input] [Output])), (3, GPIO3(_0 => MTDI) (_0 => MTDI) ([Input]
6528        [Output])), (4, GPIO4(_0 => MTMS) (_0 => MTMS) ([Input] [Output])), (5, GPIO5(_0
6529        => MTDO) (_0 => MTDO) ([Input] [Output])), (6, GPIO6(_3 => SPI2_HOLD) (_3 =>
6530        SPI2_HOLD) ([Input] [Output])), (7, GPIO7(_3 => SPI2_CS) (_3 => SPI2_CS) ([Input]
6531        [Output])), (8, GPIO8(_3 => SPI2_D) (_2 => UART0_RTS _3 => SPI2_D) ([Input]
6532        [Output])), (9, GPIO9(_2 => UART0_CTS _3 => SPI2_CK) (_3 => SPI2_CK) ([Input]
6533        [Output])), (10, GPIO10(_3 => SPI2_Q) (_2 => UART1_TXD _3 => SPI2_Q) ([Input]
6534        [Output])), (11, GPIO11(_2 => UART1_RXD _3 => SPI2_WP) (_3 => SPI2_WP) ([Input]
6535        [Output])), (12, GPIO12() (_2 => UART1_RTS) ([Input] [Output])), (13, GPIO13(_2
6536        => UART1_CTS) () ([Input] [Output])), (14, GPIO14() () ([Input] [Output])), (15,
6537        GPIO15() () ([Input] [Output])), (16, GPIO16() () ([Input] [Output])), (17,
6538        GPIO17() () ([Input] [Output])), (18, GPIO18() () ([Input] [Output])), (19,
6539        GPIO19() () ([Input] [Output])), (20, GPIO20() () ([Input] [Output])), (21,
6540        GPIO21() () ([Input] [Output])), (22, GPIO22(_4 => DBG_PSRAM_CK) (_4 =>
6541        DBG_PSRAM_CK) ([Input] [Output])), (23, GPIO23(_3 => REF_50M_CLK _4 =>
6542        DBG_PSRAM_CS) (_3 => REF_50M_CLK _4 => DBG_PSRAM_CS) ([Input] [Output])), (24,
6543        GPIO24() () ([Input] [Output])), (25, GPIO25() () ([Input] [Output])), (26,
6544        GPIO26() () ([Input] [Output])), (27, GPIO27() () ([Input] [Output])), (28,
6545        GPIO28(_2 => SPI2_CS _3 => EMAC_RXDV _4 => DBG_PSRAM_D) (_2 => SPI2_CS _4 =>
6546        DBG_PSRAM_D) ([Input] [Output])), (29, GPIO29(_2 => SPI2_D _3 => EMAC_RXD0 _4 =>
6547        DBG_PSRAM_Q) (_2 => SPI2_D _4 => DBG_PSRAM_Q) ([Input] [Output])), (30, GPIO30(_2
6548        => SPI2_CK _3 => EMAC_RXD1 _4 => DBG_PSRAM_WP) (_2 => SPI2_CK _4 => DBG_PSRAM_WP)
6549        ([Input] [Output])), (31, GPIO31(_2 => SPI2_Q _3 => EMAC_RXER _4 =>
6550        DBG_PSRAM_HOLD) (_2 => SPI2_Q _4 => DBG_PSRAM_HOLD) ([Input] [Output])), (32,
6551        GPIO32(_2 => SPI2_HOLD _3 => EMAC_RMII_CLK _4 => DBG_PSRAM_DQ4) (_2 => SPI2_HOLD
6552        _3 => EMAC_RMII_CLK _4 => DBG_PSRAM_DQ4) ([Input] [Output])), (33, GPIO33(_2 =>
6553        SPI2_WP _4 => DBG_PSRAM_DQ5) (_2 => SPI2_WP _3 => EMAC_TXEN _4 => DBG_PSRAM_DQ5)
6554        ([Input] [Output])), (34, GPIO34(_2 => SPI2_IO4 _4 => DBG_PSRAM_DQ6) (_2 =>
6555        SPI2_IO4 _3 => EMAC_TXD0 _4 => DBG_PSRAM_DQ6) ([Input] [Output])), (35, GPIO35(_2
6556        => SPI2_IO5 _4 => DBG_PSRAM_DQ7) (_2 => SPI2_IO5 _3 => EMAC_TXD1 _4 =>
6557        DBG_PSRAM_DQ7) ([Input] [Output])), (36, GPIO36(_2 => SPI2_IO6 _4 =>
6558        DBG_PSRAM_DQS_0) (_2 => SPI2_IO6 _3 => EMAC_TXER _4 => DBG_PSRAM_DQS_0) ([Input]
6559        [Output])), (37, GPIO37(_2 => SPI2_IO7) (_0 => UART0_TXD _2 => SPI2_IO7) ([Input]
6560        [Output])), (38, GPIO38(_0 => UART0_RXD _2 => SPI2_DQS) (_2 => SPI2_DQS) ([Input]
6561        [Output])), (39, GPIO39(_0 => SD1_DATA0 _2 => BIST _3 => REF_50M_CLK _4 =>
6562        DBG_PSRAM_DQ8) (_0 => SD1_DATA0 _2 => BIST _3 => REF_50M_CLK _4 => DBG_PSRAM_DQ8)
6563        ([Input] [Output])), (40, GPIO40(_0 => SD1_DATA1 _2 => BIST _4 => DBG_PSRAM_DQ9)
6564        (_0 => SD1_DATA1 _2 => BIST _3 => EMAC_TXEN _4 => DBG_PSRAM_DQ9) ([Input]
6565        [Output])), (41, GPIO41(_0 => SD1_DATA2 _2 => BIST _4 => DBG_PSRAM_DQ10) (_0 =>
6566        SD1_DATA2 _2 => BIST _3 => EMAC_TXD0 _4 => DBG_PSRAM_DQ10) ([Input] [Output])),
6567        (42, GPIO42(_0 => SD1_DATA3 _2 => BIST _4 => DBG_PSRAM_DQ11) (_0 => SD1_DATA3 _2
6568        => BIST _3 => EMAC_TXD1 _4 => DBG_PSRAM_DQ11) ([Input] [Output])), (43, GPIO43(_0
6569        => SD1_CLK _2 => BIST _4 => DBG_PSRAM_DQ12) (_0 => SD1_CLK _2 => BIST _3 =>
6570        EMAC_TXER _4 => DBG_PSRAM_DQ12) ([Input] [Output])), (44, GPIO44(_0 => SD1_CMD _2
6571        => BIST _3 => EMAC_RMII_CLK _4 => DBG_PSRAM_DQ13) (_0 => SD1_CMD _2 => BIST _3 =>
6572        EMAC_RMII_CLK _4 => DBG_PSRAM_DQ13) ([Input] [Output])), (45, GPIO45(_0 =>
6573        SD1_DATA4 _2 => BIST _3 => EMAC_RXDV _4 => DBG_PSRAM_DQ14) (_0 => SD1_DATA4 _2 =>
6574        BIST _4 => DBG_PSRAM_DQ14) ([Input] [Output])), (46, GPIO46(_0 => SD1_DATA5 _2 =>
6575        BIST _3 => EMAC_RXD0 _4 => DBG_PSRAM_DQ15) (_0 => SD1_DATA5 _2 => BIST _4 =>
6576        DBG_PSRAM_DQ15) ([Input] [Output])), (47, GPIO47(_0 => SD1_DATA6 _2 => BIST _3 =>
6577        EMAC_RXD1 _4 => DBG_PSRAM_DQS_1) (_0 => SD1_DATA6 _2 => BIST _4 =>
6578        DBG_PSRAM_DQS_1) ([Input] [Output])), (48, GPIO48(_0 => SD1_DATA7 _2 => BIST _3
6579        => EMAC_RXER) (_0 => SD1_DATA7 _2 => BIST) ([Input] [Output])), (49, GPIO49(_4 =>
6580        DBG_FLASH_CS) (_3 => EMAC_TXEN _4 => DBG_FLASH_CS) ([Input] [Output])), (50,
6581        GPIO50(_3 => EMAC_RMII_CLK _4 => DBG_FLASH_Q) (_3 => EMAC_RMII_CLK _4 =>
6582        DBG_FLASH_Q) ([Input] [Output])), (51, GPIO51(_3 => EMAC_RXDV _4 => DBG_FLASH_WP)
6583        (_4 => DBG_FLASH_WP) ([Input] [Output])), (52, GPIO52(_3 => EMAC_RXD0 _4 =>
6584        DBG_FLASH_HOLD) (_4 => DBG_FLASH_HOLD) ([Input] [Output])), (53, GPIO53(_3 =>
6585        EMAC_RXD1 _4 => DBG_FLASH_CK) (_4 => DBG_FLASH_CK) ([Input] [Output])), (54,
6586        GPIO54(_3 => EMAC_RXER _4 => DBG_FLASH_D) (_4 => DBG_FLASH_D) ([Input]
6587        [Output]))));
6588    };
6589}
6590/// This macro can be used to generate code for each analog function of each GPIO.
6591///
6592/// For an explanation on the general syntax, as well as usage of individual/repeated
6593/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6594///
6595/// This macro has two options for its "Individual matcher" case:
6596///
6597/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
6598/// - group: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` - expanded signal
6599///   case, where you need the number(s) of a signal, or the general group to which the signal
6600///   belongs. For example, in case of `ADC2_CH3` the expanded form looks like `(ADC2_CH3, ADCn_CHm,
6601///   2, 3)`.
6602///
6603/// Macro fragments:
6604///
6605/// - `$signal`: the name of the signal.
6606/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
6607///   is `ADCn_CHm`.
6608/// - `$number`: the numbers extracted from `$signal`.
6609/// - `$gpio`: the name of the GPIO.
6610///
6611/// Example data:
6612/// - `(ADC2_CH5, GPIO12)`
6613/// - `((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)`
6614///
6615/// The expanded syntax is only available when the signal has at least one numbered component.
6616#[macro_export]
6617#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6618macro_rules! for_each_analog_function {
6619    ($($pattern:tt => $code:tt;)*) => {
6620        macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
6621        tt) => {} } _for_each_inner_analog_function!((ADC1_CH0, GPIO16));
6622        _for_each_inner_analog_function!((ADC1_CH1, GPIO17));
6623        _for_each_inner_analog_function!((ADC1_CH2, GPIO18));
6624        _for_each_inner_analog_function!((ADC1_CH3, GPIO19));
6625        _for_each_inner_analog_function!((ADC1_CH4, GPIO20));
6626        _for_each_inner_analog_function!((ADC1_CH5, GPIO21));
6627        _for_each_inner_analog_function!((ADC1_CH6, GPIO22));
6628        _for_each_inner_analog_function!((ADC1_CH7, GPIO23));
6629        _for_each_inner_analog_function!((USJ_DM, GPIO24));
6630        _for_each_inner_analog_function!((USJ_DP, GPIO25));
6631        _for_each_inner_analog_function!((USB_FS_DM, GPIO26));
6632        _for_each_inner_analog_function!((USB_FS_DP, GPIO27));
6633        _for_each_inner_analog_function!((ADC2_CH0, GPIO49));
6634        _for_each_inner_analog_function!((ADC2_CH1, GPIO50));
6635        _for_each_inner_analog_function!((ADC2_CH2, GPIO51));
6636        _for_each_inner_analog_function!((ADC2_CH3, GPIO52));
6637        _for_each_inner_analog_function!((ADC2_CH4, GPIO53));
6638        _for_each_inner_analog_function!((ADC2_CH5, GPIO54));
6639        _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO16));
6640        _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO17));
6641        _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO18));
6642        _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO19));
6643        _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO20));
6644        _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO21));
6645        _for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO22));
6646        _for_each_inner_analog_function!(((ADC1_CH7, ADCn_CHm, 1, 7), GPIO23));
6647        _for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO49));
6648        _for_each_inner_analog_function!(((ADC2_CH1, ADCn_CHm, 2, 1), GPIO50));
6649        _for_each_inner_analog_function!(((ADC2_CH2, ADCn_CHm, 2, 2), GPIO51));
6650        _for_each_inner_analog_function!(((ADC2_CH3, ADCn_CHm, 2, 3), GPIO52));
6651        _for_each_inner_analog_function!(((ADC2_CH4, ADCn_CHm, 2, 4), GPIO53));
6652        _for_each_inner_analog_function!(((ADC2_CH5, ADCn_CHm, 2, 5), GPIO54));
6653        _for_each_inner_analog_function!((all(ADC1_CH0, GPIO16), (ADC1_CH1, GPIO17),
6654        (ADC1_CH2, GPIO18), (ADC1_CH3, GPIO19), (ADC1_CH4, GPIO20), (ADC1_CH5, GPIO21),
6655        (ADC1_CH6, GPIO22), (ADC1_CH7, GPIO23), (USJ_DM, GPIO24), (USJ_DP, GPIO25),
6656        (USB_FS_DM, GPIO26), (USB_FS_DP, GPIO27), (ADC2_CH0, GPIO49), (ADC2_CH1, GPIO50),
6657        (ADC2_CH2, GPIO51), (ADC2_CH3, GPIO52), (ADC2_CH4, GPIO53), (ADC2_CH5, GPIO54)));
6658        _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO16),
6659        ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO17), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO18),
6660        ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO19), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO20),
6661        ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO21), ((ADC1_CH6, ADCn_CHm, 1, 6), GPIO22),
6662        ((ADC1_CH7, ADCn_CHm, 1, 7), GPIO23), ((ADC2_CH0, ADCn_CHm, 2, 0), GPIO49),
6663        ((ADC2_CH1, ADCn_CHm, 2, 1), GPIO50), ((ADC2_CH2, ADCn_CHm, 2, 2), GPIO51),
6664        ((ADC2_CH3, ADCn_CHm, 2, 3), GPIO52), ((ADC2_CH4, ADCn_CHm, 2, 4), GPIO53),
6665        ((ADC2_CH5, ADCn_CHm, 2, 5), GPIO54)));
6666    };
6667}
6668/// This macro can be used to generate code for each LP function of each GPIO.
6669///
6670/// For an explanation on the general syntax, as well as usage of individual/repeated
6671/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6672///
6673/// This macro has two options for its "Individual matcher" case:
6674///
6675/// - `all`: `($signal:ident, $gpio:ident, $af:ident)` - simple case where you only need
6676///   identifiers, and maybe the function.
6677/// - group: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident, $af:ident, ($(
6678///   $lp_input_af:ident => $lp_input_signal:ident )*) ($( $lp_output_af:ident =>
6679///   $lp_output_signal:ident )*))` - expanded signal case, where you need the number(s) of a
6680///   signal, or the general group to which the signal belongs. Every expanded branch ends with the
6681///   pad's LP input and output function groups (empty on chips without an LP GPIO matrix).
6682///
6683/// Macro fragments:
6684///
6685/// - `$signal`: the name of the signal.
6686/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
6687///   is `ADCn_CHm`.
6688/// - `$number`: the numbers extracted from `$signal`.
6689/// - `$gpio`: the name of the GPIO.
6690/// - `$af`: the LP IO MUX function, as an identifier (i.e. for function 0 this is `_0`). This is
6691///   the name of an `LpFunction` variant, and its number is the value to write to the pad's
6692///   function select field.
6693/// - `$lp_input_af`: the LP IO MUX function for an LP peripheral input on this pad.
6694/// - `$lp_input_signal`: the LP peripheral input signal name.
6695/// - `$lp_output_af`: the LP IO MUX function for an LP peripheral output on this pad.
6696/// - `$lp_output_signal`: the LP peripheral output signal name.
6697///
6698/// Example data:
6699/// - `(LP_GPIO15, GPIO12, _0)`
6700/// - `((LP_GPIO15, LP_GPIOn, 15), GPIO12, _0, () ())`
6701/// - `((LP_GPIO14, LP_GPIOn, 14), GPIO14, _1, () (_0 => LP_UART_TXD))`
6702/// - `((SAR_I2C_SCL_1, SAR_I2C_SCL_n, 1), GPIO2, _3, () ())`
6703///
6704/// The expanded syntax is only available when the signal has at least one numbered component.
6705#[macro_export]
6706#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6707macro_rules! for_each_lp_function {
6708    ($($pattern:tt => $code:tt;)*) => {
6709        macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
6710        => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
6711        _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
6712        _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
6713        _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
6714        _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
6715        _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
6716        _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _1));
6717        _for_each_inner_lp_function!((LP_GPIO7, GPIO7, _1));
6718        _for_each_inner_lp_function!((LP_GPIO8, GPIO8, _1));
6719        _for_each_inner_lp_function!((LP_GPIO9, GPIO9, _1));
6720        _for_each_inner_lp_function!((LP_GPIO10, GPIO10, _1));
6721        _for_each_inner_lp_function!((LP_GPIO11, GPIO11, _1));
6722        _for_each_inner_lp_function!((LP_GPIO12, GPIO12, _1));
6723        _for_each_inner_lp_function!((LP_GPIO13, GPIO13, _1));
6724        _for_each_inner_lp_function!((LP_UART_TXD, GPIO14, _0));
6725        _for_each_inner_lp_function!((LP_GPIO14, GPIO14, _1));
6726        _for_each_inner_lp_function!((LP_UART_RXD, GPIO15, _0));
6727        _for_each_inner_lp_function!((LP_GPIO15, GPIO15, _1));
6728        _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
6729        _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
6730        _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
6731        _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
6732        _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
6733        _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
6734        _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()));
6735        _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO7, _1, () ()));
6736        _for_each_inner_lp_function!(((LP_GPIO8, LP_GPIOn, 8), GPIO8, _1, () ()));
6737        _for_each_inner_lp_function!(((LP_GPIO9, LP_GPIOn, 9), GPIO9, _1, () ()));
6738        _for_each_inner_lp_function!(((LP_GPIO10, LP_GPIOn, 10), GPIO10, _1, () ()));
6739        _for_each_inner_lp_function!(((LP_GPIO11, LP_GPIOn, 11), GPIO11, _1, () ()));
6740        _for_each_inner_lp_function!(((LP_GPIO12, LP_GPIOn, 12), GPIO12, _1, () ()));
6741        _for_each_inner_lp_function!(((LP_GPIO13, LP_GPIOn, 13), GPIO13, _1, () ()));
6742        _for_each_inner_lp_function!(((LP_GPIO14, LP_GPIOn, 14), GPIO14, _1, () (_0 =>
6743        LP_UART_TXD))); _for_each_inner_lp_function!(((LP_GPIO15, LP_GPIOn, 15), GPIO15,
6744        _1, (_0 => LP_UART_RXD) ())); _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0,
6745        _1), (LP_GPIO1, GPIO1, _1), (LP_GPIO2, GPIO2, _1), (LP_GPIO3, GPIO3, _1),
6746        (LP_GPIO4, GPIO4, _1), (LP_GPIO5, GPIO5, _1), (LP_GPIO6, GPIO6, _1), (LP_GPIO7,
6747        GPIO7, _1), (LP_GPIO8, GPIO8, _1), (LP_GPIO9, GPIO9, _1), (LP_GPIO10, GPIO10,
6748        _1), (LP_GPIO11, GPIO11, _1), (LP_GPIO12, GPIO12, _1), (LP_GPIO13, GPIO13, _1),
6749        (LP_UART_TXD, GPIO14, _0), (LP_GPIO14, GPIO14, _1), (LP_UART_RXD, GPIO15, _0),
6750        (LP_GPIO15, GPIO15, _1))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0,
6751        LP_GPIOn, 0), GPIO0, _1, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()),
6752        ((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1,
6753        () ()), ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5),
6754        GPIO5, _1, () ()), ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()), ((LP_GPIO7,
6755        LP_GPIOn, 7), GPIO7, _1, () ()), ((LP_GPIO8, LP_GPIOn, 8), GPIO8, _1, () ()),
6756        ((LP_GPIO9, LP_GPIOn, 9), GPIO9, _1, () ()), ((LP_GPIO10, LP_GPIOn, 10), GPIO10,
6757        _1, () ()), ((LP_GPIO11, LP_GPIOn, 11), GPIO11, _1, () ()), ((LP_GPIO12,
6758        LP_GPIOn, 12), GPIO12, _1, () ()), ((LP_GPIO13, LP_GPIOn, 13), GPIO13, _1, ()
6759        ()), ((LP_GPIO14, LP_GPIOn, 14), GPIO14, _1, () (_0 => LP_UART_TXD)),
6760        ((LP_GPIO15, LP_GPIOn, 15), GPIO15, _1, (_0 => LP_UART_RXD) ())));
6761    };
6762}
6763/// This macro can be used to generate code for each IOMUX digital function of each GPIO.
6764///
6765/// IOMUX functions are the alternate digital functions configured via the IO_MUX registers.
6766/// Use this to implement signal-specific traits for peripherals whose pins must bypass the
6767/// GPIO matrix (e.g., EMAC, USB).
6768///
6769/// For an explanation on the general syntax, as well as usage of individual/repeated
6770/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6771///
6772/// This macro has two options for its "Individual matcher" case:
6773///
6774/// - `all`: `($signal:ident, $gpio:ident, $af:ident)` - simple case where you only need
6775///   identifiers, and maybe the alternate function.
6776/// - group: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident, $af:ident)` -
6777///   expanded signal case, where you need the number(s) of a signal, or the general group to which
6778///   the signal belongs.
6779///
6780/// Macro fragments:
6781///
6782/// - `$signal`: the name of the signal.
6783/// - `$group`: the name of the signal, with numbers replaced by placeholders.
6784/// - `$number`: the numbers extracted from `$signal`.
6785/// - `$gpio`: the name of the GPIO.
6786/// - `$af`: the alternate function number, as an identifier (e.g. `_5`).
6787///
6788/// Example data:
6789/// - `(EMAC_RXD0, GPIO25, _5)`
6790/// - `((EMAC_RXDn, EMAC_RXDn, 0), GPIO25, _5)`
6791///
6792/// The expanded syntax is only available when the signal has at least one numbered component.
6793#[macro_export]
6794#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6795macro_rules! for_each_iomux_function {
6796    ($($pattern:tt => $code:tt;)*) => {
6797        macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
6798        tt) => {} } _for_each_inner_iomux_function!((MTCK, GPIO2, _0));
6799        _for_each_inner_iomux_function!((MTDI, GPIO3, _0));
6800        _for_each_inner_iomux_function!((MTMS, GPIO4, _0));
6801        _for_each_inner_iomux_function!((MTDO, GPIO5, _0));
6802        _for_each_inner_iomux_function!((SPI2_HOLD, GPIO6, _3));
6803        _for_each_inner_iomux_function!((SPI2_CS, GPIO7, _3));
6804        _for_each_inner_iomux_function!((UART0_RTS, GPIO8, _2));
6805        _for_each_inner_iomux_function!((SPI2_D, GPIO8, _3));
6806        _for_each_inner_iomux_function!((UART0_CTS, GPIO9, _2));
6807        _for_each_inner_iomux_function!((SPI2_CK, GPIO9, _3));
6808        _for_each_inner_iomux_function!((UART1_TXD, GPIO10, _2));
6809        _for_each_inner_iomux_function!((SPI2_Q, GPIO10, _3));
6810        _for_each_inner_iomux_function!((UART1_RXD, GPIO11, _2));
6811        _for_each_inner_iomux_function!((SPI2_WP, GPIO11, _3));
6812        _for_each_inner_iomux_function!((UART1_RTS, GPIO12, _2));
6813        _for_each_inner_iomux_function!((UART1_CTS, GPIO13, _2));
6814        _for_each_inner_iomux_function!((DBG_PSRAM_CK, GPIO22, _4));
6815        _for_each_inner_iomux_function!((REF_50M_CLK, GPIO23, _3));
6816        _for_each_inner_iomux_function!((DBG_PSRAM_CS, GPIO23, _4));
6817        _for_each_inner_iomux_function!((SPI2_CS, GPIO28, _2));
6818        _for_each_inner_iomux_function!((EMAC_RXDV, GPIO28, _3));
6819        _for_each_inner_iomux_function!((DBG_PSRAM_D, GPIO28, _4));
6820        _for_each_inner_iomux_function!((SPI2_D, GPIO29, _2));
6821        _for_each_inner_iomux_function!((EMAC_RXD0, GPIO29, _3));
6822        _for_each_inner_iomux_function!((DBG_PSRAM_Q, GPIO29, _4));
6823        _for_each_inner_iomux_function!((SPI2_CK, GPIO30, _2));
6824        _for_each_inner_iomux_function!((EMAC_RXD1, GPIO30, _3));
6825        _for_each_inner_iomux_function!((DBG_PSRAM_WP, GPIO30, _4));
6826        _for_each_inner_iomux_function!((SPI2_Q, GPIO31, _2));
6827        _for_each_inner_iomux_function!((EMAC_RXER, GPIO31, _3));
6828        _for_each_inner_iomux_function!((DBG_PSRAM_HOLD, GPIO31, _4));
6829        _for_each_inner_iomux_function!((SPI2_HOLD, GPIO32, _2));
6830        _for_each_inner_iomux_function!((EMAC_RMII_CLK, GPIO32, _3));
6831        _for_each_inner_iomux_function!((DBG_PSRAM_DQ4, GPIO32, _4));
6832        _for_each_inner_iomux_function!((SPI2_WP, GPIO33, _2));
6833        _for_each_inner_iomux_function!((EMAC_TXEN, GPIO33, _3));
6834        _for_each_inner_iomux_function!((DBG_PSRAM_DQ5, GPIO33, _4));
6835        _for_each_inner_iomux_function!((SPI2_IO4, GPIO34, _2));
6836        _for_each_inner_iomux_function!((EMAC_TXD0, GPIO34, _3));
6837        _for_each_inner_iomux_function!((DBG_PSRAM_DQ6, GPIO34, _4));
6838        _for_each_inner_iomux_function!((SPI2_IO5, GPIO35, _2));
6839        _for_each_inner_iomux_function!((EMAC_TXD1, GPIO35, _3));
6840        _for_each_inner_iomux_function!((DBG_PSRAM_DQ7, GPIO35, _4));
6841        _for_each_inner_iomux_function!((SPI2_IO6, GPIO36, _2));
6842        _for_each_inner_iomux_function!((EMAC_TXER, GPIO36, _3));
6843        _for_each_inner_iomux_function!((DBG_PSRAM_DQS_0, GPIO36, _4));
6844        _for_each_inner_iomux_function!((UART0_TXD, GPIO37, _0));
6845        _for_each_inner_iomux_function!((SPI2_IO7, GPIO37, _2));
6846        _for_each_inner_iomux_function!((UART0_RXD, GPIO38, _0));
6847        _for_each_inner_iomux_function!((SPI2_DQS, GPIO38, _2));
6848        _for_each_inner_iomux_function!((SD1_DATA0, GPIO39, _0));
6849        _for_each_inner_iomux_function!((BIST, GPIO39, _2));
6850        _for_each_inner_iomux_function!((REF_50M_CLK, GPIO39, _3));
6851        _for_each_inner_iomux_function!((DBG_PSRAM_DQ8, GPIO39, _4));
6852        _for_each_inner_iomux_function!((SD1_DATA1, GPIO40, _0));
6853        _for_each_inner_iomux_function!((BIST, GPIO40, _2));
6854        _for_each_inner_iomux_function!((EMAC_TXEN, GPIO40, _3));
6855        _for_each_inner_iomux_function!((DBG_PSRAM_DQ9, GPIO40, _4));
6856        _for_each_inner_iomux_function!((SD1_DATA2, GPIO41, _0));
6857        _for_each_inner_iomux_function!((BIST, GPIO41, _2));
6858        _for_each_inner_iomux_function!((EMAC_TXD0, GPIO41, _3));
6859        _for_each_inner_iomux_function!((DBG_PSRAM_DQ10, GPIO41, _4));
6860        _for_each_inner_iomux_function!((SD1_DATA3, GPIO42, _0));
6861        _for_each_inner_iomux_function!((BIST, GPIO42, _2));
6862        _for_each_inner_iomux_function!((EMAC_TXD1, GPIO42, _3));
6863        _for_each_inner_iomux_function!((DBG_PSRAM_DQ11, GPIO42, _4));
6864        _for_each_inner_iomux_function!((SD1_CLK, GPIO43, _0));
6865        _for_each_inner_iomux_function!((BIST, GPIO43, _2));
6866        _for_each_inner_iomux_function!((EMAC_TXER, GPIO43, _3));
6867        _for_each_inner_iomux_function!((DBG_PSRAM_DQ12, GPIO43, _4));
6868        _for_each_inner_iomux_function!((SD1_CMD, GPIO44, _0));
6869        _for_each_inner_iomux_function!((BIST, GPIO44, _2));
6870        _for_each_inner_iomux_function!((EMAC_RMII_CLK, GPIO44, _3));
6871        _for_each_inner_iomux_function!((DBG_PSRAM_DQ13, GPIO44, _4));
6872        _for_each_inner_iomux_function!((SD1_DATA4, GPIO45, _0));
6873        _for_each_inner_iomux_function!((BIST, GPIO45, _2));
6874        _for_each_inner_iomux_function!((EMAC_RXDV, GPIO45, _3));
6875        _for_each_inner_iomux_function!((DBG_PSRAM_DQ14, GPIO45, _4));
6876        _for_each_inner_iomux_function!((SD1_DATA5, GPIO46, _0));
6877        _for_each_inner_iomux_function!((BIST, GPIO46, _2));
6878        _for_each_inner_iomux_function!((EMAC_RXD0, GPIO46, _3));
6879        _for_each_inner_iomux_function!((DBG_PSRAM_DQ15, GPIO46, _4));
6880        _for_each_inner_iomux_function!((SD1_DATA6, GPIO47, _0));
6881        _for_each_inner_iomux_function!((BIST, GPIO47, _2));
6882        _for_each_inner_iomux_function!((EMAC_RXD1, GPIO47, _3));
6883        _for_each_inner_iomux_function!((DBG_PSRAM_DQS_1, GPIO47, _4));
6884        _for_each_inner_iomux_function!((SD1_DATA7, GPIO48, _0));
6885        _for_each_inner_iomux_function!((BIST, GPIO48, _2));
6886        _for_each_inner_iomux_function!((EMAC_RXER, GPIO48, _3));
6887        _for_each_inner_iomux_function!((EMAC_TXEN, GPIO49, _3));
6888        _for_each_inner_iomux_function!((DBG_FLASH_CS, GPIO49, _4));
6889        _for_each_inner_iomux_function!((EMAC_RMII_CLK, GPIO50, _3));
6890        _for_each_inner_iomux_function!((DBG_FLASH_Q, GPIO50, _4));
6891        _for_each_inner_iomux_function!((EMAC_RXDV, GPIO51, _3));
6892        _for_each_inner_iomux_function!((DBG_FLASH_WP, GPIO51, _4));
6893        _for_each_inner_iomux_function!((EMAC_RXD0, GPIO52, _3));
6894        _for_each_inner_iomux_function!((DBG_FLASH_HOLD, GPIO52, _4));
6895        _for_each_inner_iomux_function!((EMAC_RXD1, GPIO53, _3));
6896        _for_each_inner_iomux_function!((DBG_FLASH_CK, GPIO53, _4));
6897        _for_each_inner_iomux_function!((EMAC_RXER, GPIO54, _3));
6898        _for_each_inner_iomux_function!((DBG_FLASH_D, GPIO54, _4));
6899        _for_each_inner_iomux_function!(((SPI2_HOLD, SPIn_HOLD, 2), GPIO6, _3));
6900        _for_each_inner_iomux_function!(((SPI2_HOLD, SPIn_HOLD, 2), GPIO32, _2));
6901        _for_each_inner_iomux_function!(((SPI2_CS, SPIn_CS, 2), GPIO7, _3));
6902        _for_each_inner_iomux_function!(((SPI2_CS, SPIn_CS, 2), GPIO28, _2));
6903        _for_each_inner_iomux_function!(((UART0_RTS, UARTn_RTS, 0), GPIO8, _2));
6904        _for_each_inner_iomux_function!(((UART1_RTS, UARTn_RTS, 1), GPIO12, _2));
6905        _for_each_inner_iomux_function!(((SPI2_D, SPIn_D, 2), GPIO8, _3));
6906        _for_each_inner_iomux_function!(((SPI2_D, SPIn_D, 2), GPIO29, _2));
6907        _for_each_inner_iomux_function!(((UART0_CTS, UARTn_CTS, 0), GPIO9, _2));
6908        _for_each_inner_iomux_function!(((UART1_CTS, UARTn_CTS, 1), GPIO13, _2));
6909        _for_each_inner_iomux_function!(((SPI2_CK, SPIn_CK, 2), GPIO9, _3));
6910        _for_each_inner_iomux_function!(((SPI2_CK, SPIn_CK, 2), GPIO30, _2));
6911        _for_each_inner_iomux_function!(((UART1_TXD, UARTn_TXD, 1), GPIO10, _2));
6912        _for_each_inner_iomux_function!(((UART0_TXD, UARTn_TXD, 0), GPIO37, _0));
6913        _for_each_inner_iomux_function!(((SPI2_Q, SPIn_Q, 2), GPIO10, _3));
6914        _for_each_inner_iomux_function!(((SPI2_Q, SPIn_Q, 2), GPIO31, _2));
6915        _for_each_inner_iomux_function!(((UART1_RXD, UARTn_RXD, 1), GPIO11, _2));
6916        _for_each_inner_iomux_function!(((UART0_RXD, UARTn_RXD, 0), GPIO38, _0));
6917        _for_each_inner_iomux_function!(((SPI2_WP, SPIn_WP, 2), GPIO11, _3));
6918        _for_each_inner_iomux_function!(((SPI2_WP, SPIn_WP, 2), GPIO33, _2));
6919        _for_each_inner_iomux_function!(((EMAC_RXD0, EMAC_RXDn, 0), GPIO29, _3));
6920        _for_each_inner_iomux_function!(((EMAC_RXD1, EMAC_RXDn, 1), GPIO30, _3));
6921        _for_each_inner_iomux_function!(((EMAC_RXD0, EMAC_RXDn, 0), GPIO46, _3));
6922        _for_each_inner_iomux_function!(((EMAC_RXD1, EMAC_RXDn, 1), GPIO47, _3));
6923        _for_each_inner_iomux_function!(((EMAC_RXD0, EMAC_RXDn, 0), GPIO52, _3));
6924        _for_each_inner_iomux_function!(((EMAC_RXD1, EMAC_RXDn, 1), GPIO53, _3));
6925        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ4, DBG_PSRAM_DQn, 4), GPIO32, _4));
6926        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ5, DBG_PSRAM_DQn, 5), GPIO33, _4));
6927        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ6, DBG_PSRAM_DQn, 6), GPIO34, _4));
6928        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ7, DBG_PSRAM_DQn, 7), GPIO35, _4));
6929        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ8, DBG_PSRAM_DQn, 8), GPIO39, _4));
6930        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ9, DBG_PSRAM_DQn, 9), GPIO40, _4));
6931        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ10, DBG_PSRAM_DQn, 10), GPIO41,
6932        _4)); _for_each_inner_iomux_function!(((DBG_PSRAM_DQ11, DBG_PSRAM_DQn, 11),
6933        GPIO42, _4)); _for_each_inner_iomux_function!(((DBG_PSRAM_DQ12, DBG_PSRAM_DQn,
6934        12), GPIO43, _4)); _for_each_inner_iomux_function!(((DBG_PSRAM_DQ13,
6935        DBG_PSRAM_DQn, 13), GPIO44, _4));
6936        _for_each_inner_iomux_function!(((DBG_PSRAM_DQ14, DBG_PSRAM_DQn, 14), GPIO45,
6937        _4)); _for_each_inner_iomux_function!(((DBG_PSRAM_DQ15, DBG_PSRAM_DQn, 15),
6938        GPIO46, _4)); _for_each_inner_iomux_function!(((SPI2_IO4, SPIn_IOm, 2, 4),
6939        GPIO34, _2)); _for_each_inner_iomux_function!(((SPI2_IO5, SPIn_IOm, 2, 5),
6940        GPIO35, _2)); _for_each_inner_iomux_function!(((SPI2_IO6, SPIn_IOm, 2, 6),
6941        GPIO36, _2)); _for_each_inner_iomux_function!(((SPI2_IO7, SPIn_IOm, 2, 7),
6942        GPIO37, _2)); _for_each_inner_iomux_function!(((EMAC_TXD0, EMAC_TXDn, 0), GPIO34,
6943        _3)); _for_each_inner_iomux_function!(((EMAC_TXD1, EMAC_TXDn, 1), GPIO35, _3));
6944        _for_each_inner_iomux_function!(((EMAC_TXD0, EMAC_TXDn, 0), GPIO41, _3));
6945        _for_each_inner_iomux_function!(((EMAC_TXD1, EMAC_TXDn, 1), GPIO42, _3));
6946        _for_each_inner_iomux_function!(((DBG_PSRAM_DQS_0, DBG_PSRAM_DQS_n, 0), GPIO36,
6947        _4)); _for_each_inner_iomux_function!(((DBG_PSRAM_DQS_1, DBG_PSRAM_DQS_n, 1),
6948        GPIO47, _4)); _for_each_inner_iomux_function!(((SPI2_DQS, SPIn_DQS, 2), GPIO38,
6949        _2)); _for_each_inner_iomux_function!(((SD1_DATA0, SDn_DATAm, 1, 0), GPIO39,
6950        _0)); _for_each_inner_iomux_function!(((SD1_DATA1, SDn_DATAm, 1, 1), GPIO40,
6951        _0)); _for_each_inner_iomux_function!(((SD1_DATA2, SDn_DATAm, 1, 2), GPIO41,
6952        _0)); _for_each_inner_iomux_function!(((SD1_DATA3, SDn_DATAm, 1, 3), GPIO42,
6953        _0)); _for_each_inner_iomux_function!(((SD1_DATA4, SDn_DATAm, 1, 4), GPIO45,
6954        _0)); _for_each_inner_iomux_function!(((SD1_DATA5, SDn_DATAm, 1, 5), GPIO46,
6955        _0)); _for_each_inner_iomux_function!(((SD1_DATA6, SDn_DATAm, 1, 6), GPIO47,
6956        _0)); _for_each_inner_iomux_function!(((SD1_DATA7, SDn_DATAm, 1, 7), GPIO48,
6957        _0)); _for_each_inner_iomux_function!(((SD1_CLK, SDn_CLK, 1), GPIO43, _0));
6958        _for_each_inner_iomux_function!(((SD1_CMD, SDn_CMD, 1), GPIO44, _0));
6959        _for_each_inner_iomux_function!((all(MTCK, GPIO2, _0), (MTDI, GPIO3, _0), (MTMS,
6960        GPIO4, _0), (MTDO, GPIO5, _0), (SPI2_HOLD, GPIO6, _3), (SPI2_CS, GPIO7, _3),
6961        (UART0_RTS, GPIO8, _2), (SPI2_D, GPIO8, _3), (UART0_CTS, GPIO9, _2), (SPI2_CK,
6962        GPIO9, _3), (UART1_TXD, GPIO10, _2), (SPI2_Q, GPIO10, _3), (UART1_RXD, GPIO11,
6963        _2), (SPI2_WP, GPIO11, _3), (UART1_RTS, GPIO12, _2), (UART1_CTS, GPIO13, _2),
6964        (DBG_PSRAM_CK, GPIO22, _4), (REF_50M_CLK, GPIO23, _3), (DBG_PSRAM_CS, GPIO23,
6965        _4), (SPI2_CS, GPIO28, _2), (EMAC_RXDV, GPIO28, _3), (DBG_PSRAM_D, GPIO28, _4),
6966        (SPI2_D, GPIO29, _2), (EMAC_RXD0, GPIO29, _3), (DBG_PSRAM_Q, GPIO29, _4),
6967        (SPI2_CK, GPIO30, _2), (EMAC_RXD1, GPIO30, _3), (DBG_PSRAM_WP, GPIO30, _4),
6968        (SPI2_Q, GPIO31, _2), (EMAC_RXER, GPIO31, _3), (DBG_PSRAM_HOLD, GPIO31, _4),
6969        (SPI2_HOLD, GPIO32, _2), (EMAC_RMII_CLK, GPIO32, _3), (DBG_PSRAM_DQ4, GPIO32,
6970        _4), (SPI2_WP, GPIO33, _2), (EMAC_TXEN, GPIO33, _3), (DBG_PSRAM_DQ5, GPIO33, _4),
6971        (SPI2_IO4, GPIO34, _2), (EMAC_TXD0, GPIO34, _3), (DBG_PSRAM_DQ6, GPIO34, _4),
6972        (SPI2_IO5, GPIO35, _2), (EMAC_TXD1, GPIO35, _3), (DBG_PSRAM_DQ7, GPIO35, _4),
6973        (SPI2_IO6, GPIO36, _2), (EMAC_TXER, GPIO36, _3), (DBG_PSRAM_DQS_0, GPIO36, _4),
6974        (UART0_TXD, GPIO37, _0), (SPI2_IO7, GPIO37, _2), (UART0_RXD, GPIO38, _0),
6975        (SPI2_DQS, GPIO38, _2), (SD1_DATA0, GPIO39, _0), (BIST, GPIO39, _2),
6976        (REF_50M_CLK, GPIO39, _3), (DBG_PSRAM_DQ8, GPIO39, _4), (SD1_DATA1, GPIO40, _0),
6977        (BIST, GPIO40, _2), (EMAC_TXEN, GPIO40, _3), (DBG_PSRAM_DQ9, GPIO40, _4),
6978        (SD1_DATA2, GPIO41, _0), (BIST, GPIO41, _2), (EMAC_TXD0, GPIO41, _3),
6979        (DBG_PSRAM_DQ10, GPIO41, _4), (SD1_DATA3, GPIO42, _0), (BIST, GPIO42, _2),
6980        (EMAC_TXD1, GPIO42, _3), (DBG_PSRAM_DQ11, GPIO42, _4), (SD1_CLK, GPIO43, _0),
6981        (BIST, GPIO43, _2), (EMAC_TXER, GPIO43, _3), (DBG_PSRAM_DQ12, GPIO43, _4),
6982        (SD1_CMD, GPIO44, _0), (BIST, GPIO44, _2), (EMAC_RMII_CLK, GPIO44, _3),
6983        (DBG_PSRAM_DQ13, GPIO44, _4), (SD1_DATA4, GPIO45, _0), (BIST, GPIO45, _2),
6984        (EMAC_RXDV, GPIO45, _3), (DBG_PSRAM_DQ14, GPIO45, _4), (SD1_DATA5, GPIO46, _0),
6985        (BIST, GPIO46, _2), (EMAC_RXD0, GPIO46, _3), (DBG_PSRAM_DQ15, GPIO46, _4),
6986        (SD1_DATA6, GPIO47, _0), (BIST, GPIO47, _2), (EMAC_RXD1, GPIO47, _3),
6987        (DBG_PSRAM_DQS_1, GPIO47, _4), (SD1_DATA7, GPIO48, _0), (BIST, GPIO48, _2),
6988        (EMAC_RXER, GPIO48, _3), (EMAC_TXEN, GPIO49, _3), (DBG_FLASH_CS, GPIO49, _4),
6989        (EMAC_RMII_CLK, GPIO50, _3), (DBG_FLASH_Q, GPIO50, _4), (EMAC_RXDV, GPIO51, _3),
6990        (DBG_FLASH_WP, GPIO51, _4), (EMAC_RXD0, GPIO52, _3), (DBG_FLASH_HOLD, GPIO52,
6991        _4), (EMAC_RXD1, GPIO53, _3), (DBG_FLASH_CK, GPIO53, _4), (EMAC_RXER, GPIO54,
6992        _3), (DBG_FLASH_D, GPIO54, _4)));
6993        _for_each_inner_iomux_function!((SPIn_HOLD((SPI2_HOLD, SPIn_HOLD, 2), GPIO6, _3),
6994        ((SPI2_HOLD, SPIn_HOLD, 2), GPIO32, _2)));
6995        _for_each_inner_iomux_function!((SPIn_CS((SPI2_CS, SPIn_CS, 2), GPIO7, _3),
6996        ((SPI2_CS, SPIn_CS, 2), GPIO28, _2)));
6997        _for_each_inner_iomux_function!((UARTn_RTS((UART0_RTS, UARTn_RTS, 0), GPIO8, _2),
6998        ((UART1_RTS, UARTn_RTS, 1), GPIO12, _2)));
6999        _for_each_inner_iomux_function!((SPIn_D((SPI2_D, SPIn_D, 2), GPIO8, _3),
7000        ((SPI2_D, SPIn_D, 2), GPIO29, _2)));
7001        _for_each_inner_iomux_function!((UARTn_CTS((UART0_CTS, UARTn_CTS, 0), GPIO9, _2),
7002        ((UART1_CTS, UARTn_CTS, 1), GPIO13, _2)));
7003        _for_each_inner_iomux_function!((SPIn_CK((SPI2_CK, SPIn_CK, 2), GPIO9, _3),
7004        ((SPI2_CK, SPIn_CK, 2), GPIO30, _2)));
7005        _for_each_inner_iomux_function!((UARTn_TXD((UART1_TXD, UARTn_TXD, 1), GPIO10,
7006        _2), ((UART0_TXD, UARTn_TXD, 0), GPIO37, _0)));
7007        _for_each_inner_iomux_function!((SPIn_Q((SPI2_Q, SPIn_Q, 2), GPIO10, _3),
7008        ((SPI2_Q, SPIn_Q, 2), GPIO31, _2)));
7009        _for_each_inner_iomux_function!((UARTn_RXD((UART1_RXD, UARTn_RXD, 1), GPIO11,
7010        _2), ((UART0_RXD, UARTn_RXD, 0), GPIO38, _0)));
7011        _for_each_inner_iomux_function!((SPIn_WP((SPI2_WP, SPIn_WP, 2), GPIO11, _3),
7012        ((SPI2_WP, SPIn_WP, 2), GPIO33, _2)));
7013        _for_each_inner_iomux_function!((EMAC_RXDn((EMAC_RXD0, EMAC_RXDn, 0), GPIO29,
7014        _3), ((EMAC_RXD1, EMAC_RXDn, 1), GPIO30, _3), ((EMAC_RXD0, EMAC_RXDn, 0), GPIO46,
7015        _3), ((EMAC_RXD1, EMAC_RXDn, 1), GPIO47, _3), ((EMAC_RXD0, EMAC_RXDn, 0), GPIO52,
7016        _3), ((EMAC_RXD1, EMAC_RXDn, 1), GPIO53, _3)));
7017        _for_each_inner_iomux_function!((DBG_PSRAM_DQn((DBG_PSRAM_DQ4, DBG_PSRAM_DQn, 4),
7018        GPIO32, _4), ((DBG_PSRAM_DQ5, DBG_PSRAM_DQn, 5), GPIO33, _4), ((DBG_PSRAM_DQ6,
7019        DBG_PSRAM_DQn, 6), GPIO34, _4), ((DBG_PSRAM_DQ7, DBG_PSRAM_DQn, 7), GPIO35, _4),
7020        ((DBG_PSRAM_DQ8, DBG_PSRAM_DQn, 8), GPIO39, _4), ((DBG_PSRAM_DQ9, DBG_PSRAM_DQn,
7021        9), GPIO40, _4), ((DBG_PSRAM_DQ10, DBG_PSRAM_DQn, 10), GPIO41, _4),
7022        ((DBG_PSRAM_DQ11, DBG_PSRAM_DQn, 11), GPIO42, _4), ((DBG_PSRAM_DQ12,
7023        DBG_PSRAM_DQn, 12), GPIO43, _4), ((DBG_PSRAM_DQ13, DBG_PSRAM_DQn, 13), GPIO44,
7024        _4), ((DBG_PSRAM_DQ14, DBG_PSRAM_DQn, 14), GPIO45, _4), ((DBG_PSRAM_DQ15,
7025        DBG_PSRAM_DQn, 15), GPIO46, _4)));
7026        _for_each_inner_iomux_function!((SPIn_IOm((SPI2_IO4, SPIn_IOm, 2, 4), GPIO34,
7027        _2), ((SPI2_IO5, SPIn_IOm, 2, 5), GPIO35, _2), ((SPI2_IO6, SPIn_IOm, 2, 6),
7028        GPIO36, _2), ((SPI2_IO7, SPIn_IOm, 2, 7), GPIO37, _2)));
7029        _for_each_inner_iomux_function!((EMAC_TXDn((EMAC_TXD0, EMAC_TXDn, 0), GPIO34,
7030        _3), ((EMAC_TXD1, EMAC_TXDn, 1), GPIO35, _3), ((EMAC_TXD0, EMAC_TXDn, 0), GPIO41,
7031        _3), ((EMAC_TXD1, EMAC_TXDn, 1), GPIO42, _3)));
7032        _for_each_inner_iomux_function!((DBG_PSRAM_DQS_n((DBG_PSRAM_DQS_0,
7033        DBG_PSRAM_DQS_n, 0), GPIO36, _4), ((DBG_PSRAM_DQS_1, DBG_PSRAM_DQS_n, 1), GPIO47,
7034        _4))); _for_each_inner_iomux_function!((SPIn_DQS((SPI2_DQS, SPIn_DQS, 2), GPIO38,
7035        _2))); _for_each_inner_iomux_function!((SDn_DATAm((SD1_DATA0, SDn_DATAm, 1, 0),
7036        GPIO39, _0), ((SD1_DATA1, SDn_DATAm, 1, 1), GPIO40, _0), ((SD1_DATA2, SDn_DATAm,
7037        1, 2), GPIO41, _0), ((SD1_DATA3, SDn_DATAm, 1, 3), GPIO42, _0), ((SD1_DATA4,
7038        SDn_DATAm, 1, 4), GPIO45, _0), ((SD1_DATA5, SDn_DATAm, 1, 5), GPIO46, _0),
7039        ((SD1_DATA6, SDn_DATAm, 1, 6), GPIO47, _0), ((SD1_DATA7, SDn_DATAm, 1, 7),
7040        GPIO48, _0))); _for_each_inner_iomux_function!((SDn_CLK((SD1_CLK, SDn_CLK, 1),
7041        GPIO43, _0))); _for_each_inner_iomux_function!((SDn_CMD((SD1_CMD, SDn_CMD, 1),
7042        GPIO44, _0)));
7043    };
7044}
7045/// Returns the name of the GPIO that provides the given signal, as a string.
7046///
7047/// The macro takes the name of a direct function - a digital IO MUX function, an analog
7048/// function, or an LP IO MUX function - and expands to a string literal like `"GPIO4"`. It
7049/// is meant to keep documentation free of per-chip pin lists.
7050///
7051/// Signals that are not wired to a pad on this chip have to be routed through the GPIO
7052/// matrix, which can reach any pad. The macro has no pad to return for those, so it accepts
7053/// an optional fallback to expand to instead. The fallback is not validated.
7054///
7055/// If multiple pads provide the signal, the macro returns one that is not reserved for some
7056/// other purpose, such as booting or interfacing with flash.
7057///
7058/// Example usage:
7059/// - `gpio_for_signal!(ADC1_CH0)`
7060/// - `gpio_for_signal!(LP_I2C_SDA, "GPIO6")`
7061#[macro_export]
7062#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7063macro_rules! gpio_for_signal {
7064    (LP_GPIO0 $(, $_fallback:literal)?) => {
7065        "GPIO0"
7066    };
7067    (LP_GPIO1 $(, $_fallback:literal)?) => {
7068        "GPIO1"
7069    };
7070    (MTCK $(, $_fallback:literal)?) => {
7071        "GPIO2"
7072    };
7073    (LP_GPIO2 $(, $_fallback:literal)?) => {
7074        "GPIO2"
7075    };
7076    (MTDI $(, $_fallback:literal)?) => {
7077        "GPIO3"
7078    };
7079    (LP_GPIO3 $(, $_fallback:literal)?) => {
7080        "GPIO3"
7081    };
7082    (MTMS $(, $_fallback:literal)?) => {
7083        "GPIO4"
7084    };
7085    (LP_GPIO4 $(, $_fallback:literal)?) => {
7086        "GPIO4"
7087    };
7088    (MTDO $(, $_fallback:literal)?) => {
7089        "GPIO5"
7090    };
7091    (LP_GPIO5 $(, $_fallback:literal)?) => {
7092        "GPIO5"
7093    };
7094    (SPI2_HOLD $(, $_fallback:literal)?) => {
7095        "GPIO6"
7096    };
7097    (LP_GPIO6 $(, $_fallback:literal)?) => {
7098        "GPIO6"
7099    };
7100    (SPI2_CS $(, $_fallback:literal)?) => {
7101        "GPIO7"
7102    };
7103    (LP_GPIO7 $(, $_fallback:literal)?) => {
7104        "GPIO7"
7105    };
7106    (UART0_RTS $(, $_fallback:literal)?) => {
7107        "GPIO8"
7108    };
7109    (SPI2_D $(, $_fallback:literal)?) => {
7110        "GPIO8"
7111    };
7112    (LP_GPIO8 $(, $_fallback:literal)?) => {
7113        "GPIO8"
7114    };
7115    (UART0_CTS $(, $_fallback:literal)?) => {
7116        "GPIO9"
7117    };
7118    (SPI2_CK $(, $_fallback:literal)?) => {
7119        "GPIO9"
7120    };
7121    (LP_GPIO9 $(, $_fallback:literal)?) => {
7122        "GPIO9"
7123    };
7124    (UART1_TXD $(, $_fallback:literal)?) => {
7125        "GPIO10"
7126    };
7127    (SPI2_Q $(, $_fallback:literal)?) => {
7128        "GPIO10"
7129    };
7130    (LP_GPIO10 $(, $_fallback:literal)?) => {
7131        "GPIO10"
7132    };
7133    (UART1_RXD $(, $_fallback:literal)?) => {
7134        "GPIO11"
7135    };
7136    (SPI2_WP $(, $_fallback:literal)?) => {
7137        "GPIO11"
7138    };
7139    (LP_GPIO11 $(, $_fallback:literal)?) => {
7140        "GPIO11"
7141    };
7142    (UART1_RTS $(, $_fallback:literal)?) => {
7143        "GPIO12"
7144    };
7145    (LP_GPIO12 $(, $_fallback:literal)?) => {
7146        "GPIO12"
7147    };
7148    (UART1_CTS $(, $_fallback:literal)?) => {
7149        "GPIO13"
7150    };
7151    (LP_GPIO13 $(, $_fallback:literal)?) => {
7152        "GPIO13"
7153    };
7154    (LP_UART_TXD $(, $_fallback:literal)?) => {
7155        "GPIO14"
7156    };
7157    (LP_GPIO14 $(, $_fallback:literal)?) => {
7158        "GPIO14"
7159    };
7160    (LP_UART_RXD $(, $_fallback:literal)?) => {
7161        "GPIO15"
7162    };
7163    (LP_GPIO15 $(, $_fallback:literal)?) => {
7164        "GPIO15"
7165    };
7166    (ADC1_CH0 $(, $_fallback:literal)?) => {
7167        "GPIO16"
7168    };
7169    (ADC1_CH1 $(, $_fallback:literal)?) => {
7170        "GPIO17"
7171    };
7172    (ADC1_CH2 $(, $_fallback:literal)?) => {
7173        "GPIO18"
7174    };
7175    (ADC1_CH3 $(, $_fallback:literal)?) => {
7176        "GPIO19"
7177    };
7178    (ADC1_CH4 $(, $_fallback:literal)?) => {
7179        "GPIO20"
7180    };
7181    (ADC1_CH5 $(, $_fallback:literal)?) => {
7182        "GPIO21"
7183    };
7184    (DBG_PSRAM_CK $(, $_fallback:literal)?) => {
7185        "GPIO22"
7186    };
7187    (ADC1_CH6 $(, $_fallback:literal)?) => {
7188        "GPIO22"
7189    };
7190    (REF_50M_CLK $(, $_fallback:literal)?) => {
7191        "GPIO23"
7192    };
7193    (DBG_PSRAM_CS $(, $_fallback:literal)?) => {
7194        "GPIO23"
7195    };
7196    (ADC1_CH7 $(, $_fallback:literal)?) => {
7197        "GPIO23"
7198    };
7199    (USJ_DM $(, $_fallback:literal)?) => {
7200        "GPIO24"
7201    };
7202    (USJ_DP $(, $_fallback:literal)?) => {
7203        "GPIO25"
7204    };
7205    (USB_FS_DM $(, $_fallback:literal)?) => {
7206        "GPIO26"
7207    };
7208    (USB_FS_DP $(, $_fallback:literal)?) => {
7209        "GPIO27"
7210    };
7211    (EMAC_RXDV $(, $_fallback:literal)?) => {
7212        "GPIO28"
7213    };
7214    (DBG_PSRAM_D $(, $_fallback:literal)?) => {
7215        "GPIO28"
7216    };
7217    (EMAC_RXD0 $(, $_fallback:literal)?) => {
7218        "GPIO29"
7219    };
7220    (DBG_PSRAM_Q $(, $_fallback:literal)?) => {
7221        "GPIO29"
7222    };
7223    (EMAC_RXD1 $(, $_fallback:literal)?) => {
7224        "GPIO30"
7225    };
7226    (DBG_PSRAM_WP $(, $_fallback:literal)?) => {
7227        "GPIO30"
7228    };
7229    (EMAC_RXER $(, $_fallback:literal)?) => {
7230        "GPIO31"
7231    };
7232    (DBG_PSRAM_HOLD $(, $_fallback:literal)?) => {
7233        "GPIO31"
7234    };
7235    (EMAC_RMII_CLK $(, $_fallback:literal)?) => {
7236        "GPIO44"
7237    };
7238    (DBG_PSRAM_DQ4 $(, $_fallback:literal)?) => {
7239        "GPIO32"
7240    };
7241    (EMAC_TXEN $(, $_fallback:literal)?) => {
7242        "GPIO40"
7243    };
7244    (DBG_PSRAM_DQ5 $(, $_fallback:literal)?) => {
7245        "GPIO33"
7246    };
7247    (SPI2_IO4 $(, $_fallback:literal)?) => {
7248        "GPIO34"
7249    };
7250    (EMAC_TXD0 $(, $_fallback:literal)?) => {
7251        "GPIO41"
7252    };
7253    (DBG_PSRAM_DQ6 $(, $_fallback:literal)?) => {
7254        "GPIO34"
7255    };
7256    (SPI2_IO5 $(, $_fallback:literal)?) => {
7257        "GPIO35"
7258    };
7259    (EMAC_TXD1 $(, $_fallback:literal)?) => {
7260        "GPIO42"
7261    };
7262    (DBG_PSRAM_DQ7 $(, $_fallback:literal)?) => {
7263        "GPIO35"
7264    };
7265    (SPI2_IO6 $(, $_fallback:literal)?) => {
7266        "GPIO36"
7267    };
7268    (EMAC_TXER $(, $_fallback:literal)?) => {
7269        "GPIO43"
7270    };
7271    (DBG_PSRAM_DQS_0 $(, $_fallback:literal)?) => {
7272        "GPIO36"
7273    };
7274    (UART0_TXD $(, $_fallback:literal)?) => {
7275        "GPIO37"
7276    };
7277    (SPI2_IO7 $(, $_fallback:literal)?) => {
7278        "GPIO37"
7279    };
7280    (UART0_RXD $(, $_fallback:literal)?) => {
7281        "GPIO38"
7282    };
7283    (SPI2_DQS $(, $_fallback:literal)?) => {
7284        "GPIO38"
7285    };
7286    (SD1_DATA0 $(, $_fallback:literal)?) => {
7287        "GPIO39"
7288    };
7289    (BIST $(, $_fallback:literal)?) => {
7290        "GPIO39"
7291    };
7292    (DBG_PSRAM_DQ8 $(, $_fallback:literal)?) => {
7293        "GPIO39"
7294    };
7295    (SD1_DATA1 $(, $_fallback:literal)?) => {
7296        "GPIO40"
7297    };
7298    (DBG_PSRAM_DQ9 $(, $_fallback:literal)?) => {
7299        "GPIO40"
7300    };
7301    (SD1_DATA2 $(, $_fallback:literal)?) => {
7302        "GPIO41"
7303    };
7304    (DBG_PSRAM_DQ10 $(, $_fallback:literal)?) => {
7305        "GPIO41"
7306    };
7307    (SD1_DATA3 $(, $_fallback:literal)?) => {
7308        "GPIO42"
7309    };
7310    (DBG_PSRAM_DQ11 $(, $_fallback:literal)?) => {
7311        "GPIO42"
7312    };
7313    (SD1_CLK $(, $_fallback:literal)?) => {
7314        "GPIO43"
7315    };
7316    (DBG_PSRAM_DQ12 $(, $_fallback:literal)?) => {
7317        "GPIO43"
7318    };
7319    (SD1_CMD $(, $_fallback:literal)?) => {
7320        "GPIO44"
7321    };
7322    (DBG_PSRAM_DQ13 $(, $_fallback:literal)?) => {
7323        "GPIO44"
7324    };
7325    (SD1_DATA4 $(, $_fallback:literal)?) => {
7326        "GPIO45"
7327    };
7328    (DBG_PSRAM_DQ14 $(, $_fallback:literal)?) => {
7329        "GPIO45"
7330    };
7331    (SD1_DATA5 $(, $_fallback:literal)?) => {
7332        "GPIO46"
7333    };
7334    (DBG_PSRAM_DQ15 $(, $_fallback:literal)?) => {
7335        "GPIO46"
7336    };
7337    (SD1_DATA6 $(, $_fallback:literal)?) => {
7338        "GPIO47"
7339    };
7340    (DBG_PSRAM_DQS_1 $(, $_fallback:literal)?) => {
7341        "GPIO47"
7342    };
7343    (SD1_DATA7 $(, $_fallback:literal)?) => {
7344        "GPIO48"
7345    };
7346    (DBG_FLASH_CS $(, $_fallback:literal)?) => {
7347        "GPIO49"
7348    };
7349    (ADC2_CH0 $(, $_fallback:literal)?) => {
7350        "GPIO49"
7351    };
7352    (DBG_FLASH_Q $(, $_fallback:literal)?) => {
7353        "GPIO50"
7354    };
7355    (ADC2_CH1 $(, $_fallback:literal)?) => {
7356        "GPIO50"
7357    };
7358    (DBG_FLASH_WP $(, $_fallback:literal)?) => {
7359        "GPIO51"
7360    };
7361    (ADC2_CH2 $(, $_fallback:literal)?) => {
7362        "GPIO51"
7363    };
7364    (DBG_FLASH_HOLD $(, $_fallback:literal)?) => {
7365        "GPIO52"
7366    };
7367    (ADC2_CH3 $(, $_fallback:literal)?) => {
7368        "GPIO52"
7369    };
7370    (DBG_FLASH_CK $(, $_fallback:literal)?) => {
7371        "GPIO53"
7372    };
7373    (ADC2_CH4 $(, $_fallback:literal)?) => {
7374        "GPIO53"
7375    };
7376    (DBG_FLASH_D $(, $_fallback:literal)?) => {
7377        "GPIO54"
7378    };
7379    (ADC2_CH5 $(, $_fallback:literal)?) => {
7380        "GPIO54"
7381    };
7382    ($_signal:ident, $fallback:literal) => {
7383        $fallback
7384    };
7385}
7386/// Defines the `InputSignal` and `OutputSignal` enums.
7387///
7388/// This macro is intended to be called in esp-hal only.
7389#[macro_export]
7390#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7391macro_rules! define_io_mux_signals {
7392    () => {
7393        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7394        #[derive(Debug, PartialEq, Copy, Clone)]
7395        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7396        #[doc(hidden)]
7397        pub enum InputSignal {
7398            SDHOST_CCMD_IN_2        = 1,
7399            SDHOST_CDATA_IN_20      = 2,
7400            SDHOST_CDATA_IN_21      = 3,
7401            SDHOST_CDATA_IN_22      = 4,
7402            SDHOST_CDATA_IN_23      = 5,
7403            SDHOST_CDATA_IN_24      = 6,
7404            SDHOST_CDATA_IN_25      = 7,
7405            SDHOST_CDATA_IN_26      = 8,
7406            SDHOST_CDATA_IN_27      = 9,
7407            UART0_RXD               = 10,
7408            UART0_CTS               = 11,
7409            UART0_DSR               = 12,
7410            UART1_RXD               = 13,
7411            UART1_CTS               = 14,
7412            UART1_DSR               = 15,
7413            UART2_RXD               = 16,
7414            UART2_CTS               = 17,
7415            UART2_DSR               = 18,
7416            UART3_RXD               = 19,
7417            UART3_CTS               = 20,
7418            UART3_DSR               = 21,
7419            UART4_RXD               = 22,
7420            UART4_CTS               = 23,
7421            UART4_DSR               = 24,
7422            I2S0_O_BCK              = 25,
7423            I2S0_MCLK               = 26,
7424            I2S0_O_WS               = 27,
7425            I2S0_I_SD               = 28,
7426            I2S0_I_BCK              = 29,
7427            I2S0_I_WS               = 30,
7428            I2S1_O_BCK              = 31,
7429            I2S1_MCLK               = 32,
7430            I2S1_O_WS               = 33,
7431            I2S1_I_SD               = 34,
7432            I2S1_I_BCK              = 35,
7433            I2S1_I_WS               = 36,
7434            I2S2_O_BCK              = 37,
7435            I2S2_MCLK               = 38,
7436            I2S2_O_WS               = 39,
7437            I2S2_I_SD               = 40,
7438            I2S2_I_BCK              = 41,
7439            I2S2_I_WS               = 42,
7440            I2S0_I_SD1              = 43,
7441            I2S0_I_SD2              = 44,
7442            I2S0_I_SD3              = 45,
7443            SPI3_CK                 = 47,
7444            SPI3_Q                  = 48,
7445            SPI3_D                  = 49,
7446            SPI3_HOLD               = 50,
7447            SPI3_WP                 = 51,
7448            SPI3_CS                 = 52,
7449            SPI2_CK                 = 53,
7450            SPI2_Q                  = 54,
7451            SPI2_D                  = 55,
7452            SPI2_HOLD               = 56,
7453            SPI2_WP                 = 57,
7454            SPI2_IO4                = 58,
7455            SPI2_IO5                = 59,
7456            SPI2_IO6                = 60,
7457            SPI2_IO7                = 61,
7458            SPI2_CS                 = 62,
7459            I2C0_SCL                = 68,
7460            I2C0_SDA                = 69,
7461            I2C1_SCL                = 70,
7462            I2C1_SDA                = 71,
7463            UART0_SLP_CLK           = 74,
7464            UART1_SLP_CLK           = 75,
7465            UART2_SLP_CLK           = 76,
7466            UART3_SLP_CLK           = 77,
7467            UART4_SLP_CLK           = 78,
7468            TWAI0_RX                = 80,
7469            TWAI1_RX                = 83,
7470            TWAI2_RX                = 86,
7471            PWM0_SYNC0              = 89,
7472            PWM0_SYNC1              = 90,
7473            PWM0_SYNC2              = 91,
7474            PWM0_F0                 = 92,
7475            PWM0_F1                 = 93,
7476            PWM0_F2                 = 94,
7477            PWM0_CAP0               = 95,
7478            PWM0_CAP1               = 96,
7479            PWM0_CAP2               = 97,
7480            PWM1_SYNC0              = 98,
7481            PWM1_SYNC1              = 99,
7482            PWM1_SYNC2              = 100,
7483            PWM1_F0                 = 101,
7484            PWM1_F1                 = 102,
7485            PWM1_F2                 = 103,
7486            PWM1_CAP0               = 104,
7487            PWM1_CAP1               = 105,
7488            PWM1_CAP2               = 106,
7489            EMAC_MDI                = 107,
7490            EMAC_COL                = 108,
7491            EMAC_CRS                = 109,
7492            USB_FS_IDDIG            = 110,
7493            USB_FS_AVALID           = 111,
7494            USB_FS_SRP_BVALID       = 112,
7495            USB_FS_VBUSVALID        = 113,
7496            USB_SRP_SESSEND         = 114,
7497            ULPI_CLK                = 117,
7498            USB_HSPHY_REFCLK        = 118,
7499            SDHOST_CARD_DETECT_N_1  = 126,
7500            SDHOST_CARD_DETECT_N_2  = 127,
7501            SDHOST_CARD_INT_N_1     = 128,
7502            SDHOST_CARD_INT_N_2     = 129,
7503            SDHOST_CARD_WRITE_PRT_1 = 130,
7504            SDHOST_CARD_WRITE_PRT_2 = 131,
7505            SDHOST_DATA_STROBE_1    = 132,
7506            SDHOST_DATA_STROBE_2    = 133,
7507            I3C_MST_SCL             = 134,
7508            I3C_MST_SDA             = 135,
7509            I3C_SLV_SCL             = 136,
7510            I3C_SLV_SDA             = 137,
7511            USB_JTAG_TDO_BRIDGE     = 140,
7512            CAM_PCLK                = 158,
7513            CAM_H_ENABLE            = 159,
7514            CAM_H_SYNC              = 160,
7515            CAM_V_SYNC              = 161,
7516            EMAC_RXDV               = 178,
7517            EMAC_RXD0               = 179,
7518            EMAC_RXD1               = 180,
7519            EMAC_RXD2               = 181,
7520            EMAC_RXD3               = 182,
7521            EMAC_RXER               = 183,
7522            EMAC_RX_CLK             = 184,
7523            EMAC_TX_CLK             = 185,
7524            PARLIO_RX_CLK           = 186,
7525            PARLIO_TX_CLK           = 187,
7526            PARLIO_RX_DATA0         = 188,
7527            PARLIO_RX_DATA1         = 189,
7528            PARLIO_RX_DATA2         = 190,
7529            PARLIO_RX_DATA3         = 191,
7530            PARLIO_RX_DATA4         = 192,
7531            PARLIO_RX_DATA5         = 193,
7532            PARLIO_RX_DATA6         = 194,
7533            PARLIO_RX_DATA7         = 195,
7534            PARLIO_RX_DATA8         = 196,
7535            PARLIO_RX_DATA9         = 197,
7536            PARLIO_RX_DATA10        = 198,
7537            PARLIO_RX_DATA11        = 199,
7538            PARLIO_RX_DATA12        = 200,
7539            PARLIO_RX_DATA13        = 201,
7540            PARLIO_RX_DATA14        = 202,
7541            PARLIO_RX_DATA15        = 203,
7542            CPU_GPIO_0              = 214,
7543            CPU_GPIO_1              = 215,
7544            CPU_GPIO_2              = 216,
7545            CPU_GPIO_3              = 217,
7546            CPU_GPIO_4              = 218,
7547            CPU_GPIO_5              = 219,
7548            CPU_GPIO_6              = 220,
7549            CPU_GPIO_7              = 221,
7550            CPU_GPIO_8              = 222,
7551            CPU_GPIO_9              = 223,
7552            CPU_GPIO_10             = 224,
7553            CPU_GPIO_11             = 225,
7554            CPU_GPIO_12             = 226,
7555            CPU_GPIO_13             = 227,
7556            CPU_GPIO_14             = 228,
7557            CPU_GPIO_15             = 229,
7558            RMT_SIG_0               = 246,
7559            RMT_SIG_1               = 247,
7560            RMT_SIG_2               = 248,
7561            RMT_SIG_3               = 249,
7562            MTCK,
7563            MTDI,
7564            MTMS,
7565            MTDO,
7566            SD1_DATA0,
7567            SD1_DATA1,
7568            SD1_DATA2,
7569            SD1_DATA3,
7570            SD1_CLK,
7571            SD1_CMD,
7572            SD1_DATA4,
7573            SD1_DATA5,
7574            SD1_DATA6,
7575            SD1_DATA7,
7576            EMAC_RMII_CLK,
7577            REF_50M_CLK,
7578            BIST,
7579            DBG_PSRAM_CK,
7580            DBG_PSRAM_CS,
7581            DBG_PSRAM_D,
7582            DBG_PSRAM_Q,
7583            DBG_PSRAM_WP,
7584            DBG_PSRAM_HOLD,
7585            DBG_PSRAM_DQ4,
7586            DBG_PSRAM_DQ5,
7587            DBG_PSRAM_DQ6,
7588            DBG_PSRAM_DQ7,
7589            DBG_PSRAM_DQS_0,
7590            DBG_PSRAM_DQ8,
7591            DBG_PSRAM_DQ9,
7592            DBG_PSRAM_DQ10,
7593            DBG_PSRAM_DQ11,
7594            DBG_PSRAM_DQ12,
7595            DBG_PSRAM_DQ13,
7596            DBG_PSRAM_DQ14,
7597            DBG_PSRAM_DQ15,
7598            DBG_PSRAM_DQS_1,
7599            DBG_FLASH_CS,
7600            DBG_FLASH_Q,
7601            DBG_FLASH_WP,
7602            DBG_FLASH_HOLD,
7603            DBG_FLASH_CK,
7604            DBG_FLASH_D,
7605            SPI2_DQS,
7606        }
7607        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7608        #[derive(Debug, PartialEq, Copy, Clone)]
7609        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7610        #[doc(hidden)]
7611        pub enum OutputSignal {
7612            SDHOST_CCLK_OUT_2          = 0,
7613            SDHOST_CCMD_OUT_2          = 1,
7614            SDHOST_CDATA_OUT_20        = 2,
7615            SDHOST_CDATA_OUT_21        = 3,
7616            SDHOST_CDATA_OUT_22        = 4,
7617            SDHOST_CDATA_OUT_23        = 5,
7618            SDHOST_CDATA_OUT_24        = 6,
7619            SDHOST_CDATA_OUT_25        = 7,
7620            SDHOST_CDATA_OUT_26        = 8,
7621            SDHOST_CDATA_OUT_27        = 9,
7622            UART0_TXD                  = 10,
7623            UART0_RTS                  = 11,
7624            UART0_DTR                  = 12,
7625            UART1_TXD                  = 13,
7626            UART1_RTS                  = 14,
7627            UART1_DTR                  = 15,
7628            UART2_TXD                  = 16,
7629            UART2_RTS                  = 17,
7630            UART2_DTR                  = 18,
7631            UART3_TXD                  = 19,
7632            UART3_RTS                  = 20,
7633            UART3_DTR                  = 21,
7634            UART4_TXD                  = 22,
7635            UART4_RTS                  = 23,
7636            UART4_DTR                  = 24,
7637            I2S0_O_BCK                 = 25,
7638            I2S0_MCLK                  = 26,
7639            I2S0_O_WS                  = 27,
7640            I2S0_O_SD                  = 28,
7641            I2S0_I_BCK                 = 29,
7642            I2S0_I_WS                  = 30,
7643            I2S1_O_BCK                 = 31,
7644            I2S1_MCLK                  = 32,
7645            I2S1_O_WS                  = 33,
7646            I2S1_O_SD                  = 34,
7647            I2S1_I_BCK                 = 35,
7648            I2S1_I_WS                  = 36,
7649            I2S2_O_BCK                 = 37,
7650            I2S2_MCLK                  = 38,
7651            I2S2_O_WS                  = 39,
7652            I2S2_O_SD                  = 40,
7653            I2S2_I_BCK                 = 41,
7654            I2S2_I_WS                  = 42,
7655            I2S0_O_SD1                 = 43,
7656            SPI2_DQS                   = 44,
7657            SPI3_CS2                   = 45,
7658            SPI3_CS1                   = 46,
7659            SPI3_CK                    = 47,
7660            SPI3_Q                     = 48,
7661            SPI3_D                     = 49,
7662            SPI3_HOLD                  = 50,
7663            SPI3_WP                    = 51,
7664            SPI3_CS                    = 52,
7665            SPI2_CK                    = 53,
7666            SPI2_Q                     = 54,
7667            SPI2_D                     = 55,
7668            SPI2_HOLD                  = 56,
7669            SPI2_WP                    = 57,
7670            SPI2_IO4                   = 58,
7671            SPI2_IO5                   = 59,
7672            SPI2_IO6                   = 60,
7673            SPI2_IO7                   = 61,
7674            SPI2_CS                    = 62,
7675            SPI2_CS1                   = 63,
7676            SPI2_CS2                   = 64,
7677            SPI2_CS3                   = 65,
7678            SPI2_CS4                   = 66,
7679            SPI2_CS5                   = 67,
7680            I2C0_SCL                   = 68,
7681            I2C0_SDA                   = 69,
7682            I2C1_SCL                   = 70,
7683            I2C1_SDA                   = 71,
7684            GPIO_SD0                   = 72,
7685            GPIO_SD1                   = 73,
7686            GPIO_SD2                   = 74,
7687            GPIO_SD3                   = 75,
7688            GPIO_SD4                   = 76,
7689            GPIO_SD5                   = 77,
7690            GPIO_SD6                   = 78,
7691            GPIO_SD7                   = 79,
7692            TWAI0_TX                   = 80,
7693            TWAI0_BUS_OFF_ON           = 81,
7694            TWAI0_CLKOUT               = 82,
7695            TWAI1_TX                   = 83,
7696            TWAI1_BUS_OFF_ON           = 84,
7697            TWAI1_CLKOUT               = 85,
7698            TWAI2_TX                   = 86,
7699            TWAI2_BUS_OFF_ON           = 87,
7700            TWAI2_CLKOUT               = 88,
7701            PWM0_CH0_A                 = 89,
7702            PWM0_CH0_B                 = 90,
7703            PWM0_CH1_A                 = 91,
7704            PWM0_CH1_B                 = 92,
7705            PWM0_CH2_A                 = 93,
7706            PWM0_CH2_B                 = 94,
7707            PWM1_CH0_A                 = 95,
7708            PWM1_CH0_B                 = 96,
7709            PWM1_CH1_A                 = 97,
7710            PWM1_CH1_B                 = 98,
7711            PWM1_CH2_A                 = 99,
7712            PWM1_CH2_B                 = 100,
7713            TWAI0_STANDBY              = 105,
7714            TWAI1_STANDBY              = 106,
7715            TWAI2_STANDBY              = 107,
7716            EMAC_MDC                   = 108,
7717            EMAC_MDO                   = 109,
7718            USB_SRP_DISCHRGVBUS        = 110,
7719            USB_OTG11_IDPULLUP         = 111,
7720            USB_OTG11_DPPULLDOWN       = 112,
7721            USB_OTG11_DMPULLDOWN       = 113,
7722            USB_OTG11_DRVVBUS          = 114,
7723            USB_SRP_CHRGVBUS           = 115,
7724            RNG_CHAIN_CLK              = 117,
7725            I3C_MST_SCL                = 134,
7726            I3C_MST_SDA                = 135,
7727            I3C_SLV_SCL                = 136,
7728            I3C_SLV_SDA                = 137,
7729            I3C_MST_SCL_PULLUP_EN      = 138,
7730            I3C_MST_SDA_PULLUP_EN      = 139,
7731            USB_JTAG_TDI_BRIDGE        = 140,
7732            USB_JTAG_TMS_BRIDGE        = 141,
7733            USB_JTAG_TCK_BRIDGE        = 142,
7734            USB_JTAG_TRST_BRIDGE       = 143,
7735            LCD_CS                     = 144,
7736            LCD_DC                     = 145,
7737            SD_RST_N_1                 = 146,
7738            SD_RST_N_2                 = 147,
7739            SDHOST_CCMD_OD_PULLUP_EN_N = 148,
7740            LCD_PCLK                   = 149,
7741            CAM_CLK                    = 150,
7742            LCD_H_ENABLE               = 151,
7743            LCD_H_SYNC                 = 152,
7744            LCD_V_SYNC                 = 153,
7745            EMAC_TXEN                  = 178,
7746            EMAC_TXD0                  = 179,
7747            EMAC_TXD1                  = 180,
7748            EMAC_TXD2                  = 181,
7749            EMAC_TXD3                  = 182,
7750            EMAC_TXER                  = 183,
7751            PARLIO_RX_CLK              = 186,
7752            PARLIO_TX_CLK              = 187,
7753            PARLIO_TX_DATA0            = 188,
7754            PARLIO_TX_DATA1            = 189,
7755            PARLIO_TX_DATA2            = 190,
7756            PARLIO_TX_DATA3            = 191,
7757            PARLIO_TX_DATA4            = 192,
7758            PARLIO_TX_DATA5            = 193,
7759            PARLIO_TX_DATA6            = 194,
7760            PARLIO_TX_DATA7            = 195,
7761            PARLIO_TX_DATA8            = 196,
7762            PARLIO_TX_DATA9            = 197,
7763            PARLIO_TX_DATA10           = 198,
7764            PARLIO_TX_DATA11           = 199,
7765            PARLIO_TX_DATA12           = 200,
7766            PARLIO_TX_DATA13           = 201,
7767            PARLIO_TX_DATA14           = 202,
7768            PARLIO_TX_DATA15           = 203,
7769            CONSTANT0                  = 212,
7770            CONSTANT1                  = 213,
7771            CPU_GPIO_0                 = 214,
7772            CPU_GPIO_1                 = 215,
7773            CPU_GPIO_2                 = 216,
7774            CPU_GPIO_3                 = 217,
7775            CPU_GPIO_4                 = 218,
7776            CPU_GPIO_5                 = 219,
7777            CPU_GPIO_6                 = 220,
7778            CPU_GPIO_7                 = 221,
7779            CPU_GPIO_8                 = 222,
7780            CPU_GPIO_9                 = 223,
7781            CPU_GPIO_10                = 224,
7782            CPU_GPIO_11                = 225,
7783            CPU_GPIO_12                = 226,
7784            CPU_GPIO_13                = 227,
7785            CPU_GPIO_14                = 228,
7786            CPU_GPIO_15                = 229,
7787            PARLIO_TX_CS               = 242,
7788            EMAC_PTP_PPS               = 243,
7789            ANA_COMP0                  = 244,
7790            ANA_COMP1                  = 245,
7791            RMT_SIG_0                  = 246,
7792            RMT_SIG_1                  = 247,
7793            RMT_SIG_2                  = 248,
7794            RMT_SIG_3                  = 249,
7795            GPIO                       = 256,
7796            MTCK,
7797            MTDI,
7798            MTMS,
7799            MTDO,
7800            SD1_DATA0,
7801            SD1_DATA1,
7802            SD1_DATA2,
7803            SD1_DATA3,
7804            SD1_CLK,
7805            SD1_CMD,
7806            SD1_DATA4,
7807            SD1_DATA5,
7808            SD1_DATA6,
7809            SD1_DATA7,
7810            EMAC_RMII_CLK,
7811            REF_50M_CLK,
7812            BIST,
7813            DBG_PSRAM_CK,
7814            DBG_PSRAM_CS,
7815            DBG_PSRAM_D,
7816            DBG_PSRAM_Q,
7817            DBG_PSRAM_WP,
7818            DBG_PSRAM_HOLD,
7819            DBG_PSRAM_DQ4,
7820            DBG_PSRAM_DQ5,
7821            DBG_PSRAM_DQ6,
7822            DBG_PSRAM_DQ7,
7823            DBG_PSRAM_DQS_0,
7824            DBG_PSRAM_DQ8,
7825            DBG_PSRAM_DQ9,
7826            DBG_PSRAM_DQ10,
7827            DBG_PSRAM_DQ11,
7828            DBG_PSRAM_DQ12,
7829            DBG_PSRAM_DQ13,
7830            DBG_PSRAM_DQ14,
7831            DBG_PSRAM_DQ15,
7832            DBG_PSRAM_DQS_1,
7833            DBG_FLASH_CS,
7834            DBG_FLASH_Q,
7835            DBG_FLASH_WP,
7836            DBG_FLASH_HOLD,
7837            DBG_FLASH_CK,
7838            DBG_FLASH_D,
7839        }
7840    };
7841}
7842/// Defines the `LpFunction` enum.
7843///
7844/// The enum only contains the LP IO MUX functions that the chip implements. It is
7845/// empty on chips without an LP IO peripheral.
7846///
7847/// This macro is intended to be called in esp-hal only.
7848#[macro_export]
7849#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7850macro_rules! define_lp_functions {
7851    () => {
7852        /// LP IO MUX function of a pad.
7853        ///
7854        /// This is the low-power counterpart of `AlternateFunction`: it selects which function
7855        /// drives a pad while the pad belongs to the low-power domain.
7856        #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
7857        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7858        #[doc(hidden)]
7859        pub enum LpFunction {
7860            /// LP IO MUX function 0.
7861            _0 = 0,
7862            /// LP IO MUX function 1.
7863            _1 = 1,
7864        }
7865        impl LpFunction {
7866            /// The function that connects the pad to the LP GPIO peripheral.
7867            pub const LP_GPIO: Self = Self::_1;
7868        }
7869    };
7870}
7871/// Defines and implements the `io_mux_reg` function.
7872///
7873/// The generated function has the following signature:
7874///
7875/// ```rust,ignore
7876/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
7877///     // ...
7878/// # unimplemented!()
7879/// }
7880/// ```
7881///
7882/// This macro is intended to be called in esp-hal only.
7883#[macro_export]
7884#[expect(clippy::crate_in_macro_def)]
7885#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7886macro_rules! define_io_mux_reg {
7887    () => {
7888        pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
7889            crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
7890        }
7891    };
7892}