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