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