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