Skip to main content

esp_metadata_generated/
_generated_esp32c5.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        "esp32c5"
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-C5"
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        "esp32c5"
42    };
43    ("arch") => {
44        "riscv"
45    };
46    ("cores") => {
47        1
48    };
49    ("cores", str) => {
50        stringify!(1)
51    };
52    ("trm") => {
53        "https://www.espressif.com/sites/default/files/documentation/esp32-c5_technical_reference_manual_en.pdf"
54    };
55    ("gpio.version") => {
56        2
57    };
58    ("gpio.version", str) => {
59        stringify!(2)
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        96
72    };
73    ("gpio.constant_0_input", str) => {
74        stringify!(96)
75    };
76    ("gpio.constant_1_input") => {
77        64
78    };
79    ("gpio.constant_1_input", str) => {
80        stringify!(64)
81    };
82    ("gpio.remap_iomux_pin_registers") => {
83        false
84    };
85    ("gpio.func_in_sel_offset") => {
86        0
87    };
88    ("gpio.func_in_sel_offset", str) => {
89        stringify!(0)
90    };
91    ("gpio.need_soft_isolate_during_pd") => {
92        false
93    };
94    ("gpio.has_bank_1") => {
95        false
96    };
97    ("gpio.input_signal_max") => {
98        116
99    };
100    ("gpio.input_signal_max", str) => {
101        stringify!(116)
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_v1"
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        "v4"
123    };
124    ("lp_io.has_gpio_matrix") => {
125        false
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        true
141    };
142    ("uart.has_sclk_divider") => {
143        false
144    };
145    ("uart.has_sclk_enable") => {
146        true
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        true
177    };
178    ("i2c_master.has_arbitration_en") => {
179        true
180    };
181    ("i2c_master.has_tx_fifo_watermark") => {
182        true
183    };
184    ("i2c_master.bus_timeout_is_exponential") => {
185        true
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        true
237    };
238    ("spi_master.has_dma_segmented_transfer") => {
239        true
240    };
241    ("spi_master.has_clk_pre_div") => {
242        true
243    };
244    ("spi_master.dma_can_access_flash") => {
245        true
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        512
261    };
262    ("i2s.max_ws_width", str) => {
263        stringify!(512)
264    };
265    ("i2s.clock_configured_by_pcr") => {
266        true
267    };
268    ("i2s.clock_configured_by_hp_sys_clkrst") => {
269        false
270    };
271    ("i2s.supports_pdm_rx_hp_filter") => {
272        false
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        false
285    };
286    ("parl_io.version") => {
287        2
288    };
289    ("parl_io.version", str) => {
290        stringify!(2)
291    };
292    ("parl_io.max_data_width") => {
293        8
294    };
295    ("parl_io.max_data_width", str) => {
296        stringify!(8)
297    };
298    ("parl_io.has_tx_cs") => {
299        true
300    };
301    ("rmt.ram_start") => {
302        1610638336
303    };
304    ("rmt.ram_start", str) => {
305        stringify!(1610638336)
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    ("bt.controller") => {
338        "npl"
339    };
340    ("bt.requires_fast_cpu") => {
341        true
342    };
343    ("wifi.has_wifi6") => {
344        true
345    };
346    ("wifi.mac_version") => {
347        3
348    };
349    ("wifi.mac_version", str) => {
350        stringify!(3)
351    };
352    ("wifi.has_5g") => {
353        true
354    };
355    ("wifi.csi_supported") => {
356        true
357    };
358    ("wifi.has_nan") => {
359        true
360    };
361    ("wifi.has_ftm") => {
362        true
363    };
364    ("wifi.requires_fast_cpu") => {
365        true
366    };
367    ("ieee802154.requires_fast_cpu") => {
368        true
369    };
370    ("phy.combo_module") => {
371        false
372    };
373    ("adc.controller") => {
374        "digital"
375    };
376    ("adc.channel_count") => {
377        6
378    };
379    ("adc.channel_count", str) => {
380        stringify!(6)
381    };
382    ("adc.line_calibration") => {
383        true
384    };
385    ("adc.curve_calibration") => {
386        true
387    };
388    ("adc.basic_calibration") => {
389        true
390    };
391    ("adc.calibration_v1_scheme_supported") => {
392        true
393    };
394    ("adc.channel_compensation") => {
395        true
396    };
397    ("adc.pcr_clock") => {
398        true
399    };
400    ("adc.pcr_sar_clk_div") => {
401        true
402    };
403    ("adc.sar_power_override") => {
404        true
405    };
406    ("sdm.channel_count") => {
407        4
408    };
409    ("sdm.channel_count", str) => {
410        stringify!(4)
411    };
412    ("timergroup.timg_has_timer1") => {
413        false
414    };
415    ("timergroup.timg_has_divcnt_rst") => {
416        true
417    };
418    ("timergroup.wdt_has_conf_update") => {
419        true
420    };
421    ("timergroup.rc_fast_calibration_divider_min_rev") => {
422        0
423    };
424    ("timergroup.rc_fast_calibration_divider") => {
425        32
426    };
427    ("timergroup.rc_fast_calibration_tick_enable") => {
428        false
429    };
430    ("aes.has_split_text_registers") => {
431        true
432    };
433    ("aes.endianness_configurable") => {
434        false
435    };
436    ("ecc.zero_extend_writes") => {
437        false
438    };
439    ("ecc.separate_jacobian_point_memory") => {
440        true
441    };
442    ("ecc.has_memory_clock_gate") => {
443        true
444    };
445    ("ecc.supports_enhanced_security") => {
446        true
447    };
448    ("ecc.mem_block_size") => {
449        48
450    };
451    ("rng.apb_cycle_wait_num") => {
452        16
453    };
454    ("rng.apb_cycle_wait_num", str) => {
455        stringify!(16)
456    };
457    ("rng.trng_supported") => {
458        true
459    };
460    ("rng.is_lp_sys") => {
461        true
462    };
463    ("rsa.version") => {
464        3
465    };
466    ("rsa.version", str) => {
467        stringify!(3)
468    };
469    ("rsa.size_increment") => {
470        32
471    };
472    ("rsa.size_increment", str) => {
473        stringify!(32)
474    };
475    ("rsa.memory_size_bytes") => {
476        384
477    };
478    ("rsa.memory_size_bytes", str) => {
479        stringify!(384)
480    };
481    ("sleep.light_sleep") => {
482        true
483    };
484    ("sleep.deep_sleep") => {
485        true
486    };
487    ("sleep.rejectable_mask") => {
488        3582
489    };
490    ("sleep.ext1_version") => {
491        2
492    };
493    ("sleep.ext1_version", str) => {
494        stringify!(2)
495    };
496    ("sleep.pin_wakeup_version") => {
497        3
498    };
499    ("sleep.pin_wakeup_version", str) => {
500        stringify!(3)
501    };
502    ("sleep.deep_sleep_needs_gpio_isolation") => {
503        false
504    };
505    ("sleep.idle_frequency_scaling") => {
506        true
507    };
508    ("assist_debug.has_sp_monitor") => {
509        true
510    };
511    ("assist_debug.has_region_monitor") => {
512        true
513    };
514    ("dma.mem2mem_requires_peripheral") => {
515        false
516    };
517    ("dma.ext_mem_configurable_block_size") => {
518        false
519    };
520    ("dma.separate_in_out_interrupts") => {
521        true
522    };
523    ("dma.gdma_version") => {
524        2
525    };
526    ("dma.gdma_version", str) => {
527        stringify!(2)
528    };
529    ("interrupts.status_registers") => {
530        3
531    };
532    ("interrupts.status_registers", str) => {
533        stringify!(3)
534    };
535    ("interrupts.disabled_interrupt") => {
536        0
537    };
538    ("mmu.page_size") => {
539        65536
540    };
541    ("mmu.page_size", str) => {
542        stringify!(65536)
543    };
544    ("mmu.entry_num") => {
545        512
546    };
547    ("mmu.entry_num", str) => {
548        stringify!(512)
549    };
550    ("psram.octal_spi") => {
551        false
552    };
553    ("psram.hex_spi") => {
554        false
555    };
556    ("psram.has_timing_tuning") => {
557        true
558    };
559    ("psram.extmem_origin") => {
560        1107296256
561    };
562    ("psram.extmem_origin", str) => {
563        stringify!(1107296256)
564    };
565    ("psram.idle_low_speed_switch") => {
566        false
567    };
568    ("rom.has_crc_le") => {
569        true
570    };
571    ("rom.has_crc_be") => {
572        true
573    };
574    ("rom.has_md5_bsd") => {
575        true
576    };
577    ("rom.has_md5_mbedtls") => {
578        false
579    };
580    ("rom.no_libgcc") => {
581        false
582    };
583    ("soc.cpu_has_branch_predictor") => {
584        true
585    };
586    ("soc.cpu_has_csr_pc") => {
587        false
588    };
589    ("soc.cpu_has_zcmp_workaround") => {
590        false
591    };
592    ("soc.multi_core_enabled") => {
593        false
594    };
595    ("soc.cpu_pma_needs_core1_setup") => {
596        false
597    };
598    ("soc.cpu_csr_prv_mode") => {
599        2064
600    };
601    ("soc.cpu_csr_prv_mode", str) => {
602        stringify!(2064)
603    };
604    ("soc.internal_memory_cached") => {
605        false
606    };
607    ("soc.cpu_powers_down_cache") => {
608        true
609    };
610    ("soc.has_swd_watchdog") => {
611        true
612    };
613    ("soc.has_bus_clock_update") => {
614        true
615    };
616    ("soc.has_apb_frequency_reduction") => {
617        true
618    };
619    ("soc.cpu_mcause_mask") => {
620        31
621    };
622    ("soc.cpu_mcause_mask", str) => {
623        stringify!(31)
624    };
625    ("soc.cpu_pmp_granularity") => {
626        128
627    };
628    ("soc.cpu_pmp_granularity", str) => {
629        stringify!(128)
630    };
631    ("clock_tree.hp_root_clk") => {
632        [crate ::soc::clocks::HpRootClkConfig::Xtal, crate
633        ::soc::clocks::HpRootClkConfig::RcFast, crate
634        ::soc::clocks::HpRootClkConfig::PllF160m, crate
635        ::soc::clocks::HpRootClkConfig::PllF240m]
636    };
637    ("clock_tree.cpu_clk.divisor") => {
638        (0, 255)
639    };
640    ("clock_tree.ahb_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, crate
649        ::soc::clocks::LpFastClkConfig::Xtal]
650    };
651    ("clock_tree.lp_slow_clk") => {
652        [crate ::soc::clocks::LpSlowClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
653        ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
654        ::soc::clocks::LpSlowClkConfig::OscSlow]
655    };
656    ("clock_tree.ble_lp_clk") => {
657        [crate ::soc::clocks::BleLpClkConfig::Xtal, crate
658        ::soc::clocks::BleLpClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
659        ::soc::clocks::BleLpClkConfig::Xtal32k]
660    };
661    ("clock_tree.crypto_clk") => {
662        [crate ::soc::clocks::CryptoClkConfig::Xtal, crate
663        ::soc::clocks::CryptoClkConfig::Fosc, crate
664        ::soc::clocks::CryptoClkConfig::PllF480m]
665    };
666    ("clock_tree.iomux_function_clock") => {
667        [crate ::soc::clocks::IomuxFunctionClockConfig::XtalClk, crate
668        ::soc::clocks::IomuxFunctionClockConfig::RcFastClk, crate
669        ::soc::clocks::IomuxFunctionClockConfig::PllF80m]
670    };
671    ("clock_tree.timg_calibration_clock") => {
672        [crate ::soc::clocks::TimgCalibrationClockConfig::OscSlowClk, crate
673        ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
674        ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
675        crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
676    };
677    ("clock_tree.uart.function_clock.sclk") => {
678        [crate ::soc::clocks::UartFunctionClockSclk::Xtal, crate
679        ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
680        ::soc::clocks::UartFunctionClockSclk::RcFast]
681    };
682    ("clock_tree.uart.function_clock.div_num") => {
683        (0, 255)
684    };
685    ("clock_tree.uart.baud_rate_generator.fractional") => {
686        (0, 15)
687    };
688    ("clock_tree.uart.baud_rate_generator.integral") => {
689        (0, 4095)
690    };
691    ("clock_tree.timg.function_clock") => {
692        [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
693        ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
694        ::soc::clocks::TimgFunctionClockConfig::PllF80m]
695    };
696    ("clock_tree.timg.wdt_clock") => {
697        [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
698        ::soc::clocks::TimgWdtClockConfig::PllF80m, crate
699        ::soc::clocks::TimgWdtClockConfig::RcFastClk]
700    };
701    ("clock_tree.rmt.sclk") => {
702        [crate ::soc::clocks::RmtSclkConfig::XtalClk, crate
703        ::soc::clocks::RmtSclkConfig::RcFastClk, crate
704        ::soc::clocks::RmtSclkConfig::PllF80m]
705    };
706    ("clock_tree.parl_io.rx_clock") => {
707        [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
708        ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
709        ::soc::clocks::ParlIoClkConfig::PllF240m]
710    };
711    ("clock_tree.parl_io.tx_clock") => {
712        [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
713        ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
714        ::soc::clocks::ParlIoClkConfig::PllF240m]
715    };
716    ("clock_tree.i2s.tx_clk.sclk") => {
717        [crate ::soc::clocks::I2sClkSclk::Xtal, crate
718        ::soc::clocks::I2sClkSclk::PllF240m, crate ::soc::clocks::I2sClkSclk::PllF160m]
719    };
720    ("clock_tree.i2s.tx_clk.div_num") => {
721        (1, 255)
722    };
723    ("clock_tree.i2s.tx_clk.div_a") => {
724        (1, 511)
725    };
726    ("clock_tree.i2s.tx_clk.div_b") => {
727        (0, 511)
728    };
729    ("clock_tree.i2s.rx_clk.sclk") => {
730        [crate ::soc::clocks::I2sClkSclk::Xtal, crate
731        ::soc::clocks::I2sClkSclk::PllF240m, crate ::soc::clocks::I2sClkSclk::PllF160m]
732    };
733    ("clock_tree.i2s.rx_clk.div_num") => {
734        (1, 255)
735    };
736    ("clock_tree.i2s.rx_clk.div_a") => {
737        (1, 511)
738    };
739    ("clock_tree.i2s.rx_clk.div_b") => {
740        (0, 511)
741    };
742    ("clock_tree.i2s.mclk_out") => {
743        [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
744        ::soc::clocks::I2sMclkOutConfig::Rx]
745    };
746    ("clock_tree.i2c.function_clock.sclk") => {
747        [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
748        ::soc::clocks::I2cFunctionClockSclk::RcFast]
749    };
750    ("clock_tree.i2c.function_clock.div_num") => {
751        (0, 255)
752    };
753    ("clock_tree.spi.function_clock") => {
754        [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
755        ::soc::clocks::SpiFunctionClockConfig::PllF160m, crate
756        ::soc::clocks::SpiFunctionClockConfig::PllF120m, crate
757        ::soc::clocks::SpiFunctionClockConfig::RcFast]
758    };
759    ("clock_tree.twai.function_clock") => {
760        [crate ::soc::clocks::TwaiFunctionClockConfig::Xtal, crate
761        ::soc::clocks::TwaiFunctionClockConfig::PllF80m]
762    };
763    ("clock_tree.adc.function_clock") => {
764        [crate ::soc::clocks::AdcFunctionClockConfig::Xtal, crate
765        ::soc::clocks::AdcFunctionClockConfig::RcFast, crate
766        ::soc::clocks::AdcFunctionClockConfig::PllF80m]
767    };
768}
769#[macro_export]
770#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
771macro_rules! for_each_dedicated_gpio {
772    ($($pattern:tt => $code:tt;)*) => {
773        macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
774        tt) => {} } _for_each_inner_dedicated_gpio!((0));
775        _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
776        _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
777        _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
778        _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
779        CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
780        _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
781        _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
782        _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
783        _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
784        _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
785        _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
786        _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
787        (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
788        CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
789        CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
790    };
791}
792/// Defines the `LpInputSignal` and `LpOutputSignal` enums.
793///
794/// This macro is intended to be called in esp-hal only.
795#[macro_export]
796#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
797macro_rules! define_lp_io_signals {
798    () => {};
799}
800/// This macro can be used to generate code for each channel of the RMT peripheral.
801///
802/// For an explanation on the general syntax, as well as usage of individual/repeated
803/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
804///
805/// This macro has three options for its "Individual matcher" case:
806///
807/// - `all`: `($num:literal)`
808/// - `tx`: `($num:literal, $idx:literal)`
809/// - `rx`: `($num:literal, $idx:literal)`
810///
811/// Macro fragments:
812///
813/// - `$num`: number of the channel, e.g. `0`
814/// - `$idx`: index of the channel among channels of the same capability, e.g. `0`
815///
816/// Example data:
817///
818/// - `all`: `(0)`
819/// - `tx`: `(1, 1)`
820/// - `rx`: `(2, 0)`
821#[macro_export]
822#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
823macro_rules! for_each_rmt_channel {
824    ($($pattern:tt => $code:tt;)*) => {
825        macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
826        => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
827        _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
828        _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
829        _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
830        _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
831        _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
832        _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
833    };
834}
835#[macro_export]
836#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
837macro_rules! for_each_sdm_channel {
838    ($($pattern:tt => $code:tt;)*) => {
839        macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
840        => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
841        _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
842        _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
843        _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
844        _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
845        SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
846        GPIO_SD3)));
847    };
848}
849#[macro_export]
850#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
851macro_rules! for_each_aes_key_length {
852    ($($pattern:tt => $code:tt;)*) => {
853        macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
854        tt) => {} } _for_each_inner_aes_key_length!((128));
855        _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
856        4)); _for_each_inner_aes_key_length!((256, 2, 6));
857        _for_each_inner_aes_key_length!((bits(128), (256)));
858        _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
859    };
860}
861#[macro_export]
862#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
863macro_rules! for_each_ecc_working_mode {
864    ($($pattern:tt => $code:tt;)*) => {
865        macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
866        : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
867        _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
868        _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
869        _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
870        _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
871        _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
872        _for_each_inner_ecc_working_mode!((7,
873        AffinePointVerificationAndJacobianPointMultiplication));
874        _for_each_inner_ecc_working_mode!((8, ModularAddition));
875        _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
876        _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
877        _for_each_inner_ecc_working_mode!((11, ModularDivision));
878        _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
879        AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
880        JacobianPointMultiplication), (5, AffinePointAddition), (6,
881        JacobianPointVerification), (7,
882        AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
883        ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
884    };
885}
886#[macro_export]
887#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
888macro_rules! for_each_ecc_curve {
889    ($($pattern:tt => $code:tt;)*) => {
890        macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
891        => {} } _for_each_inner_ecc_curve!((0, P192, 192));
892        _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((2, P384,
893        384)); _for_each_inner_ecc_curve!((all(0, P192, 192), (1, P256, 256), (2, P384,
894        384)));
895    };
896}
897#[macro_export]
898#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
899macro_rules! for_each_rsa_exponentiation {
900    ($($pattern:tt => $code:tt;)*) => {
901        macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
902        ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
903        _for_each_inner_rsa_exponentiation!((64));
904        _for_each_inner_rsa_exponentiation!((96));
905        _for_each_inner_rsa_exponentiation!((128));
906        _for_each_inner_rsa_exponentiation!((160));
907        _for_each_inner_rsa_exponentiation!((192));
908        _for_each_inner_rsa_exponentiation!((224));
909        _for_each_inner_rsa_exponentiation!((256));
910        _for_each_inner_rsa_exponentiation!((288));
911        _for_each_inner_rsa_exponentiation!((320));
912        _for_each_inner_rsa_exponentiation!((352));
913        _for_each_inner_rsa_exponentiation!((384));
914        _for_each_inner_rsa_exponentiation!((416));
915        _for_each_inner_rsa_exponentiation!((448));
916        _for_each_inner_rsa_exponentiation!((480));
917        _for_each_inner_rsa_exponentiation!((512));
918        _for_each_inner_rsa_exponentiation!((544));
919        _for_each_inner_rsa_exponentiation!((576));
920        _for_each_inner_rsa_exponentiation!((608));
921        _for_each_inner_rsa_exponentiation!((640));
922        _for_each_inner_rsa_exponentiation!((672));
923        _for_each_inner_rsa_exponentiation!((704));
924        _for_each_inner_rsa_exponentiation!((736));
925        _for_each_inner_rsa_exponentiation!((768));
926        _for_each_inner_rsa_exponentiation!((800));
927        _for_each_inner_rsa_exponentiation!((832));
928        _for_each_inner_rsa_exponentiation!((864));
929        _for_each_inner_rsa_exponentiation!((896));
930        _for_each_inner_rsa_exponentiation!((928));
931        _for_each_inner_rsa_exponentiation!((960));
932        _for_each_inner_rsa_exponentiation!((992));
933        _for_each_inner_rsa_exponentiation!((1024));
934        _for_each_inner_rsa_exponentiation!((1056));
935        _for_each_inner_rsa_exponentiation!((1088));
936        _for_each_inner_rsa_exponentiation!((1120));
937        _for_each_inner_rsa_exponentiation!((1152));
938        _for_each_inner_rsa_exponentiation!((1184));
939        _for_each_inner_rsa_exponentiation!((1216));
940        _for_each_inner_rsa_exponentiation!((1248));
941        _for_each_inner_rsa_exponentiation!((1280));
942        _for_each_inner_rsa_exponentiation!((1312));
943        _for_each_inner_rsa_exponentiation!((1344));
944        _for_each_inner_rsa_exponentiation!((1376));
945        _for_each_inner_rsa_exponentiation!((1408));
946        _for_each_inner_rsa_exponentiation!((1440));
947        _for_each_inner_rsa_exponentiation!((1472));
948        _for_each_inner_rsa_exponentiation!((1504));
949        _for_each_inner_rsa_exponentiation!((1536));
950        _for_each_inner_rsa_exponentiation!((1568));
951        _for_each_inner_rsa_exponentiation!((1600));
952        _for_each_inner_rsa_exponentiation!((1632));
953        _for_each_inner_rsa_exponentiation!((1664));
954        _for_each_inner_rsa_exponentiation!((1696));
955        _for_each_inner_rsa_exponentiation!((1728));
956        _for_each_inner_rsa_exponentiation!((1760));
957        _for_each_inner_rsa_exponentiation!((1792));
958        _for_each_inner_rsa_exponentiation!((1824));
959        _for_each_inner_rsa_exponentiation!((1856));
960        _for_each_inner_rsa_exponentiation!((1888));
961        _for_each_inner_rsa_exponentiation!((1920));
962        _for_each_inner_rsa_exponentiation!((1952));
963        _for_each_inner_rsa_exponentiation!((1984));
964        _for_each_inner_rsa_exponentiation!((2016));
965        _for_each_inner_rsa_exponentiation!((2048));
966        _for_each_inner_rsa_exponentiation!((2080));
967        _for_each_inner_rsa_exponentiation!((2112));
968        _for_each_inner_rsa_exponentiation!((2144));
969        _for_each_inner_rsa_exponentiation!((2176));
970        _for_each_inner_rsa_exponentiation!((2208));
971        _for_each_inner_rsa_exponentiation!((2240));
972        _for_each_inner_rsa_exponentiation!((2272));
973        _for_each_inner_rsa_exponentiation!((2304));
974        _for_each_inner_rsa_exponentiation!((2336));
975        _for_each_inner_rsa_exponentiation!((2368));
976        _for_each_inner_rsa_exponentiation!((2400));
977        _for_each_inner_rsa_exponentiation!((2432));
978        _for_each_inner_rsa_exponentiation!((2464));
979        _for_each_inner_rsa_exponentiation!((2496));
980        _for_each_inner_rsa_exponentiation!((2528));
981        _for_each_inner_rsa_exponentiation!((2560));
982        _for_each_inner_rsa_exponentiation!((2592));
983        _for_each_inner_rsa_exponentiation!((2624));
984        _for_each_inner_rsa_exponentiation!((2656));
985        _for_each_inner_rsa_exponentiation!((2688));
986        _for_each_inner_rsa_exponentiation!((2720));
987        _for_each_inner_rsa_exponentiation!((2752));
988        _for_each_inner_rsa_exponentiation!((2784));
989        _for_each_inner_rsa_exponentiation!((2816));
990        _for_each_inner_rsa_exponentiation!((2848));
991        _for_each_inner_rsa_exponentiation!((2880));
992        _for_each_inner_rsa_exponentiation!((2912));
993        _for_each_inner_rsa_exponentiation!((2944));
994        _for_each_inner_rsa_exponentiation!((2976));
995        _for_each_inner_rsa_exponentiation!((3008));
996        _for_each_inner_rsa_exponentiation!((3040));
997        _for_each_inner_rsa_exponentiation!((3072));
998        _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
999        (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1000        (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1001        (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1002        (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
1003        (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
1004        (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
1005        (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
1006        (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
1007        (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
1008    };
1009}
1010#[macro_export]
1011#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1012macro_rules! for_each_rsa_multiplication {
1013    ($($pattern:tt => $code:tt;)*) => {
1014        macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
1015        ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
1016        _for_each_inner_rsa_multiplication!((64));
1017        _for_each_inner_rsa_multiplication!((96));
1018        _for_each_inner_rsa_multiplication!((128));
1019        _for_each_inner_rsa_multiplication!((160));
1020        _for_each_inner_rsa_multiplication!((192));
1021        _for_each_inner_rsa_multiplication!((224));
1022        _for_each_inner_rsa_multiplication!((256));
1023        _for_each_inner_rsa_multiplication!((288));
1024        _for_each_inner_rsa_multiplication!((320));
1025        _for_each_inner_rsa_multiplication!((352));
1026        _for_each_inner_rsa_multiplication!((384));
1027        _for_each_inner_rsa_multiplication!((416));
1028        _for_each_inner_rsa_multiplication!((448));
1029        _for_each_inner_rsa_multiplication!((480));
1030        _for_each_inner_rsa_multiplication!((512));
1031        _for_each_inner_rsa_multiplication!((544));
1032        _for_each_inner_rsa_multiplication!((576));
1033        _for_each_inner_rsa_multiplication!((608));
1034        _for_each_inner_rsa_multiplication!((640));
1035        _for_each_inner_rsa_multiplication!((672));
1036        _for_each_inner_rsa_multiplication!((704));
1037        _for_each_inner_rsa_multiplication!((736));
1038        _for_each_inner_rsa_multiplication!((768));
1039        _for_each_inner_rsa_multiplication!((800));
1040        _for_each_inner_rsa_multiplication!((832));
1041        _for_each_inner_rsa_multiplication!((864));
1042        _for_each_inner_rsa_multiplication!((896));
1043        _for_each_inner_rsa_multiplication!((928));
1044        _for_each_inner_rsa_multiplication!((960));
1045        _for_each_inner_rsa_multiplication!((992));
1046        _for_each_inner_rsa_multiplication!((1024));
1047        _for_each_inner_rsa_multiplication!((1056));
1048        _for_each_inner_rsa_multiplication!((1088));
1049        _for_each_inner_rsa_multiplication!((1120));
1050        _for_each_inner_rsa_multiplication!((1152));
1051        _for_each_inner_rsa_multiplication!((1184));
1052        _for_each_inner_rsa_multiplication!((1216));
1053        _for_each_inner_rsa_multiplication!((1248));
1054        _for_each_inner_rsa_multiplication!((1280));
1055        _for_each_inner_rsa_multiplication!((1312));
1056        _for_each_inner_rsa_multiplication!((1344));
1057        _for_each_inner_rsa_multiplication!((1376));
1058        _for_each_inner_rsa_multiplication!((1408));
1059        _for_each_inner_rsa_multiplication!((1440));
1060        _for_each_inner_rsa_multiplication!((1472));
1061        _for_each_inner_rsa_multiplication!((1504));
1062        _for_each_inner_rsa_multiplication!((1536));
1063        _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
1064        (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1065        (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1066        (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1067        (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
1068    };
1069}
1070#[macro_export]
1071#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1072macro_rules! for_each_sha_algorithm {
1073    ($($pattern:tt => $code:tt;)*) => {
1074        macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
1075        tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
1076        (insecure_against : "collision", "length extension"), 0));
1077        _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
1078        (insecure_against : "length extension"), 1));
1079        _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
1080        (insecure_against : "length extension"), 2));
1081        _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
1082        (insecure_against : "collision", "length extension"), 0), (Sha224,
1083        "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
1084        (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
1085        2)));
1086    };
1087}
1088#[macro_export]
1089#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1090macro_rules! for_each_wakeup_source {
1091    ($($pattern:tt => $code:tt;)*) => {
1092        macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
1093        tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
1094        _for_each_inner_wakeup_source!((Gpio, 2));
1095        _for_each_inner_wakeup_source!((WifiBeacon, 3));
1096        _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
1097        5)); _for_each_inner_wakeup_source!((Uart0, 6));
1098        _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
1099        8)); _for_each_inner_wakeup_source!((Bt, 10));
1100        _for_each_inner_wakeup_source!((LpCore, 11));
1101        _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3), (Timer,
1102        4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Bt, 10), (LpCore, 11)));
1103    };
1104}
1105#[macro_export]
1106#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1107macro_rules! for_each_dma_engine {
1108    ($($pattern:tt => $code:tt;)*) => {
1109        macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
1110        => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
1111        _for_each_inner_dma_engine!((all("AHB_GDMA")));
1112    };
1113}
1114#[macro_export]
1115#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1116macro_rules! for_each_dma_channel {
1117    ($($pattern:tt => $code:tt;)*) => {
1118        macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
1119        => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
1120        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
1121        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
1122        _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
1123        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
1124        interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1125        APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1,
1126        interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI2,
1127        UHCI0, I2S0, AES, SHA, APB_SARADC, PARL_IO]));
1128        _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1129        interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1130        APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
1131        ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2)));
1132        _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
1133        AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
1134        _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1135        DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES,
1136        SHA, APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
1137        interrupt_out = DMA_OUT_CH1, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1138        APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1139        interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1140        APB_SARADC, PARL_IO]))); _for_each_inner_dma_channel!((no_own_interrupt));
1141    };
1142}
1143#[macro_export]
1144#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1145macro_rules! for_each_dma_channel_peri_pair {
1146    ($($pattern:tt => $code:tt;)*) => {
1147        macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1148        ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1149        DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
1150        UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
1151        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
1152        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
1153        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
1154        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
1155        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
1156        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
1157        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
1158        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
1159        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
1160        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
1161        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
1162        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
1163        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
1164        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
1165        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
1166        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
1167        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
1168        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
1169        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1170        SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1171        AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1172        any_channel = AhbGdmaChannel, I2S0));
1173        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1174        AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1175        AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1176        any_channel = AhbGdmaChannel, APB_SARADC));
1177        _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1178        PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
1179        SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA",
1180        DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC),
1181        ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI2), ("AHB_GDMA",
1182        DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, AES),
1183        ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1, APB_SARADC), ("AHB_GDMA",
1184        DMA_CH1, PARL_IO), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
1185        ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
1186        SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC), ("AHB_GDMA", DMA_CH2, PARL_IO)));
1187        _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1188        AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
1189        ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
1190        AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
1191        ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC), ("AHB_GDMA", any_channel
1192        = AhbGdmaChannel, PARL_IO)));
1193    };
1194}
1195#[macro_export]
1196#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1197macro_rules! for_each_mem2mem_channel {
1198    ($($pattern:tt => $code:tt;)*) => {
1199        macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1200        tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1201        AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1202        AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
1203        _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
1204        10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1205        4, 1, 5, 2, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1206        AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1207        AhbGdmaChannel, DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5),
1208        ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 10)));
1209        _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1210        4, 1, 5, 2, 10))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1211        AhbGdmaChannel)));
1212    };
1213}
1214#[macro_export]
1215#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1216macro_rules! with_aes_dma_engine {
1217    ($($pattern:tt => $code:tt;)*) => {
1218        macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1219        => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1220    };
1221}
1222#[macro_export]
1223#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1224macro_rules! with_i2s_dma_engine {
1225    ($($pattern:tt => $code:tt;)*) => {
1226        macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1227        => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1228    };
1229}
1230#[macro_export]
1231#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1232macro_rules! with_parl_io_dma_engine {
1233    ($($pattern:tt => $code:tt;)*) => {
1234        macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
1235        tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1236    };
1237}
1238#[macro_export]
1239#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1240macro_rules! with_sha_dma_engine {
1241    ($($pattern:tt => $code:tt;)*) => {
1242        macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1243        => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1244    };
1245}
1246#[macro_export]
1247#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1248macro_rules! with_spi_master_dma_engine {
1249    ($($pattern:tt => $code:tt;)*) => {
1250        macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1251        : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1252    };
1253}
1254#[macro_export]
1255#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1256macro_rules! with_spi_slave_dma_engine {
1257    ($($pattern:tt => $code:tt;)*) => {
1258        macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1259        : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1260    };
1261}
1262#[macro_export]
1263#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1264macro_rules! with_uhci_dma_engine {
1265    ($($pattern:tt => $code:tt;)*) => {
1266        macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1267        => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1268    };
1269}
1270#[macro_export]
1271#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1272macro_rules! for_each_interrupt {
1273    ($($pattern:tt => $code:tt;)*) => {
1274        macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1275        => {} } _for_each_inner_interrupt!(([disabled 0] 0));
1276        _for_each_inner_interrupt!(([reserved 0] 1));
1277        _for_each_inner_interrupt!(([reserved 1] 2));
1278        _for_each_inner_interrupt!(([reserved 2] 3));
1279        _for_each_inner_interrupt!(([reserved 3] 4));
1280        _for_each_inner_interrupt!(([reserved 4] 5));
1281        _for_each_inner_interrupt!(([reserved 5] 6));
1282        _for_each_inner_interrupt!(([reserved 6] 7));
1283        _for_each_inner_interrupt!(([reserved 7] 8));
1284        _for_each_inner_interrupt!(([reserved 8] 9));
1285        _for_each_inner_interrupt!(([reserved 9] 10));
1286        _for_each_inner_interrupt!(([reserved 10] 11));
1287        _for_each_inner_interrupt!(([reserved 11] 12));
1288        _for_each_inner_interrupt!(([reserved 12] 13));
1289        _for_each_inner_interrupt!(([reserved 13] 14));
1290        _for_each_inner_interrupt!(([reserved 14] 15));
1291        _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1292        1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1293        _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1294        4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1295        _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1296        7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
1297        _for_each_inner_interrupt!(([direct_bindable 1] 25));
1298        _for_each_inner_interrupt!(([direct_bindable 2] 26));
1299        _for_each_inner_interrupt!(([direct_bindable 3] 27));
1300        _for_each_inner_interrupt!(([direct_bindable 4] 28));
1301        _for_each_inner_interrupt!(([direct_bindable 5] 29));
1302        _for_each_inner_interrupt!(([direct_bindable 6] 30));
1303        _for_each_inner_interrupt!(([direct_bindable 7] 31));
1304        _for_each_inner_interrupt!(([direct_bindable 8] 32));
1305        _for_each_inner_interrupt!(([direct_bindable 9] 33));
1306        _for_each_inner_interrupt!(([direct_bindable 10] 34));
1307        _for_each_inner_interrupt!(([direct_bindable 11] 35));
1308        _for_each_inner_interrupt!(([direct_bindable 12] 36));
1309        _for_each_inner_interrupt!(([direct_bindable 13] 37));
1310        _for_each_inner_interrupt!(([direct_bindable 14] 38));
1311        _for_each_inner_interrupt!(([direct_bindable 15] 39));
1312        _for_each_inner_interrupt!(([direct_bindable 16] 40));
1313        _for_each_inner_interrupt!(([direct_bindable 17] 41));
1314        _for_each_inner_interrupt!(([direct_bindable 18] 42));
1315        _for_each_inner_interrupt!(([direct_bindable 19] 43));
1316        _for_each_inner_interrupt!(([direct_bindable 20] 44));
1317        _for_each_inner_interrupt!(([direct_bindable 21] 45));
1318        _for_each_inner_interrupt!(([direct_bindable 22] 46));
1319        _for_each_inner_interrupt!(([direct_bindable 23] 47));
1320        _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
1321        2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
1322        ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
1323        ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
1324        ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
1325        3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
1326        ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
1327        ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
1328        ([direct_bindable 6] 30), ([direct_bindable 7] 31), ([direct_bindable 8] 32),
1329        ([direct_bindable 9] 33), ([direct_bindable 10] 34), ([direct_bindable 11] 35),
1330        ([direct_bindable 12] 36), ([direct_bindable 13] 37), ([direct_bindable 14] 38),
1331        ([direct_bindable 15] 39), ([direct_bindable 16] 40), ([direct_bindable 17] 41),
1332        ([direct_bindable 18] 42), ([direct_bindable 19] 43), ([direct_bindable 20] 44),
1333        ([direct_bindable 21] 45), ([direct_bindable 22] 46), ([direct_bindable 23]
1334        47)));
1335    };
1336}
1337#[macro_export]
1338#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1339macro_rules! for_each_classified_interrupt {
1340    ($($pattern:tt => $code:tt;)*) => {
1341        macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1342        ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1343        24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
1344        _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
1345        _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
1346        _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
1347        _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
1348        _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
1349        _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
1350        _for_each_inner_classified_interrupt!(([direct_bindable 8] 32));
1351        _for_each_inner_classified_interrupt!(([direct_bindable 9] 33));
1352        _for_each_inner_classified_interrupt!(([direct_bindable 10] 34));
1353        _for_each_inner_classified_interrupt!(([direct_bindable 11] 35));
1354        _for_each_inner_classified_interrupt!(([direct_bindable 12] 36));
1355        _for_each_inner_classified_interrupt!(([direct_bindable 13] 37));
1356        _for_each_inner_classified_interrupt!(([direct_bindable 14] 38));
1357        _for_each_inner_classified_interrupt!(([direct_bindable 15] 39));
1358        _for_each_inner_classified_interrupt!(([direct_bindable 16] 40));
1359        _for_each_inner_classified_interrupt!(([direct_bindable 17] 41));
1360        _for_each_inner_classified_interrupt!(([direct_bindable 18] 42));
1361        _for_each_inner_classified_interrupt!(([direct_bindable 19] 43));
1362        _for_each_inner_classified_interrupt!(([direct_bindable 20] 44));
1363        _for_each_inner_classified_interrupt!(([direct_bindable 21] 45));
1364        _for_each_inner_classified_interrupt!(([direct_bindable 22] 46));
1365        _for_each_inner_classified_interrupt!(([direct_bindable 23] 47));
1366        _for_each_inner_classified_interrupt!(([vector 0] 16));
1367        _for_each_inner_classified_interrupt!(([vector 1] 17));
1368        _for_each_inner_classified_interrupt!(([vector 2] 18));
1369        _for_each_inner_classified_interrupt!(([vector 3] 19));
1370        _for_each_inner_classified_interrupt!(([vector 4] 20));
1371        _for_each_inner_classified_interrupt!(([vector 5] 21));
1372        _for_each_inner_classified_interrupt!(([vector 6] 22));
1373        _for_each_inner_classified_interrupt!(([vector 7] 23));
1374        _for_each_inner_classified_interrupt!(([reserved 0] 1));
1375        _for_each_inner_classified_interrupt!(([reserved 1] 2));
1376        _for_each_inner_classified_interrupt!(([reserved 2] 3));
1377        _for_each_inner_classified_interrupt!(([reserved 3] 4));
1378        _for_each_inner_classified_interrupt!(([reserved 4] 5));
1379        _for_each_inner_classified_interrupt!(([reserved 5] 6));
1380        _for_each_inner_classified_interrupt!(([reserved 6] 7));
1381        _for_each_inner_classified_interrupt!(([reserved 7] 8));
1382        _for_each_inner_classified_interrupt!(([reserved 8] 9));
1383        _for_each_inner_classified_interrupt!(([reserved 9] 10));
1384        _for_each_inner_classified_interrupt!(([reserved 10] 11));
1385        _for_each_inner_classified_interrupt!(([reserved 11] 12));
1386        _for_each_inner_classified_interrupt!(([reserved 12] 13));
1387        _for_each_inner_classified_interrupt!(([reserved 13] 14));
1388        _for_each_inner_classified_interrupt!(([reserved 14] 15));
1389        _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
1390        ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
1391        ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
1392        ([direct_bindable 7] 31), ([direct_bindable 8] 32), ([direct_bindable 9] 33),
1393        ([direct_bindable 10] 34), ([direct_bindable 11] 35), ([direct_bindable 12] 36),
1394        ([direct_bindable 13] 37), ([direct_bindable 14] 38), ([direct_bindable 15] 39),
1395        ([direct_bindable 16] 40), ([direct_bindable 17] 41), ([direct_bindable 18] 42),
1396        ([direct_bindable 19] 43), ([direct_bindable 20] 44), ([direct_bindable 21] 45),
1397        ([direct_bindable 22] 46), ([direct_bindable 23] 47)));
1398        _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1399        ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1400        22), ([vector 7] 23))); _for_each_inner_classified_interrupt!((reserved([reserved
1401        0] 1), ([reserved 1] 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5),
1402        ([reserved 5] 6), ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9),
1403        ([reserved 9] 10), ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13),
1404        ([reserved 13] 14), ([reserved 14] 15)));
1405        _for_each_inner_classified_interrupt!((context_switch));
1406    };
1407}
1408#[macro_export]
1409#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1410macro_rules! for_each_interrupt_priority {
1411    ($($pattern:tt => $code:tt;)*) => {
1412        macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1413        ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1414        Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1415        _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1416        _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1417        _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1418        _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1419        _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1420        _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1421        _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1422        Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1423        Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1424        Priority8, Level8)));
1425    };
1426}
1427#[macro_export]
1428#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1429macro_rules! for_each_sw_interrupt {
1430    ($($pattern:tt => $code:tt;)*) => {
1431        macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1432        tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1433        software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1434        software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1435        software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1436        software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1437        software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1438        FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1439    };
1440}
1441#[macro_export]
1442/// ESP-HAL must provide implementation for the following functions:
1443/// ```rust, no_run
1444/// // XTAL_CLK
1445///
1446/// fn configure_xtal_clk_impl(
1447///     _clocks: &mut ClockTree,
1448///     _old_config: Option<XtalClkConfig>,
1449///     _new_config: XtalClkConfig,
1450/// ) {
1451///     todo!()
1452/// }
1453///
1454/// // PLL_CLK
1455///
1456/// fn enable_pll_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1457///     todo!()
1458/// }
1459///
1460/// // RC_FAST_CLK
1461///
1462/// fn enable_rc_fast_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1463///     todo!()
1464/// }
1465///
1466/// // XTAL32K_CLK
1467///
1468/// #[cfg(use_xtal32k)]
1469/// fn enable_xtal32k_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1470///     todo!()
1471/// }
1472///
1473/// // OSC_SLOW_CLK
1474///
1475/// fn enable_osc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1476///     todo!()
1477/// }
1478///
1479/// // RC_SLOW_CLK
1480///
1481/// fn enable_rc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1482///     todo!()
1483/// }
1484///
1485/// // PLL_F12M
1486///
1487/// fn enable_pll_f12m_impl(_clocks: &mut ClockTree, _en: bool) {
1488///     todo!()
1489/// }
1490///
1491/// // PLL_F20M
1492///
1493/// fn enable_pll_f20m_impl(_clocks: &mut ClockTree, _en: bool) {
1494///     todo!()
1495/// }
1496///
1497/// // PLL_F40M
1498///
1499/// fn enable_pll_f40m_impl(_clocks: &mut ClockTree, _en: bool) {
1500///     todo!()
1501/// }
1502///
1503/// // PLL_F48M
1504///
1505/// fn enable_pll_f48m_impl(_clocks: &mut ClockTree, _en: bool) {
1506///     todo!()
1507/// }
1508///
1509/// // PLL_F60M
1510///
1511/// fn enable_pll_f60m_impl(_clocks: &mut ClockTree, _en: bool) {
1512///     todo!()
1513/// }
1514///
1515/// // PLL_F80M
1516///
1517/// fn enable_pll_f80m_impl(_clocks: &mut ClockTree, _en: bool) {
1518///     todo!()
1519/// }
1520///
1521/// // PLL_F120M
1522///
1523/// fn enable_pll_f120m_impl(_clocks: &mut ClockTree, _en: bool) {
1524///     todo!()
1525/// }
1526///
1527/// // PLL_F160M
1528///
1529/// fn enable_pll_f160m_impl(_clocks: &mut ClockTree, _en: bool) {
1530///     todo!()
1531/// }
1532///
1533/// // PLL_F240M
1534///
1535/// fn enable_pll_f240m_impl(_clocks: &mut ClockTree, _en: bool) {
1536///     todo!()
1537/// }
1538///
1539/// // HP_ROOT_CLK
1540///
1541/// fn enable_hp_root_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1542///     todo!()
1543/// }
1544///
1545/// fn configure_hp_root_clk_impl(
1546///     _clocks: &mut ClockTree,
1547///     _old_config: Option<HpRootClkConfig>,
1548///     _new_config: HpRootClkConfig,
1549/// ) {
1550///     todo!()
1551/// }
1552///
1553/// // CPU_CLK
1554///
1555/// fn configure_cpu_clk_impl(
1556///     _clocks: &mut ClockTree,
1557///     _old_config: Option<CpuClkConfig>,
1558///     _new_config: CpuClkConfig,
1559/// ) {
1560///     todo!()
1561/// }
1562///
1563/// // AHB_CLK
1564///
1565/// fn configure_ahb_clk_impl(
1566///     _clocks: &mut ClockTree,
1567///     _old_config: Option<AhbClkConfig>,
1568///     _new_config: AhbClkConfig,
1569/// ) {
1570///     todo!()
1571/// }
1572///
1573/// // APB_CLK
1574///
1575/// fn enable_apb_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1576///     todo!()
1577/// }
1578///
1579/// fn configure_apb_clk_impl(
1580///     _clocks: &mut ClockTree,
1581///     _old_config: Option<ApbClkConfig>,
1582///     _new_config: ApbClkConfig,
1583/// ) {
1584///     todo!()
1585/// }
1586///
1587/// // XTAL_D2_CLK
1588///
1589/// fn enable_xtal_d2_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1590///     todo!()
1591/// }
1592///
1593/// // LP_FAST_CLK
1594///
1595/// fn enable_lp_fast_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1596///     todo!()
1597/// }
1598///
1599/// fn configure_lp_fast_clk_impl(
1600///     _clocks: &mut ClockTree,
1601///     _old_config: Option<LpFastClkConfig>,
1602///     _new_config: LpFastClkConfig,
1603/// ) {
1604///     todo!()
1605/// }
1606///
1607/// // LP_SLOW_CLK
1608///
1609/// fn enable_lp_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1610///     todo!()
1611/// }
1612///
1613/// fn configure_lp_slow_clk_impl(
1614///     _clocks: &mut ClockTree,
1615///     _old_config: Option<LpSlowClkConfig>,
1616///     _new_config: LpSlowClkConfig,
1617/// ) {
1618///     todo!()
1619/// }
1620///
1621/// // BLE_LP_XTAL_CLK
1622///
1623/// fn enable_ble_lp_xtal_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1624///     todo!()
1625/// }
1626///
1627/// // BLE_LP_RC_SLOW_CLK
1628///
1629/// fn enable_ble_lp_rc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1630///     todo!()
1631/// }
1632///
1633/// // BLE_LP_CLK
1634///
1635/// fn enable_ble_lp_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1636///     todo!()
1637/// }
1638///
1639/// fn configure_ble_lp_clk_impl(
1640///     _clocks: &mut ClockTree,
1641///     _old_config: Option<BleLpClkConfig>,
1642///     _new_config: BleLpClkConfig,
1643/// ) {
1644///     todo!()
1645/// }
1646///
1647/// // CRYPTO_PLL_DIV
1648///
1649/// fn enable_crypto_pll_div_impl(_clocks: &mut ClockTree, _en: bool) {
1650///     todo!()
1651/// }
1652///
1653/// // CRYPTO_CLK
1654///
1655/// fn enable_crypto_clk_impl(_clocks: &mut ClockTree, _en: bool) {
1656///     todo!()
1657/// }
1658///
1659/// fn configure_crypto_clk_impl(
1660///     _clocks: &mut ClockTree,
1661///     _old_config: Option<CryptoClkConfig>,
1662///     _new_config: CryptoClkConfig,
1663/// ) {
1664///     todo!()
1665/// }
1666///
1667/// // IOMUX_FUNCTION_CLOCK
1668///
1669/// fn configure_iomux_function_clock_impl(
1670///     _clocks: &mut ClockTree,
1671///     _old_config: Option<IomuxFunctionClockConfig>,
1672///     _new_config: IomuxFunctionClockConfig,
1673/// ) {
1674///     todo!()
1675/// }
1676///
1677/// // TIMG_CALIBRATION_CLOCK
1678///
1679/// fn enable_timg_calibration_clock_impl(_clocks: &mut ClockTree, _en: bool) {
1680///     todo!()
1681/// }
1682///
1683/// fn configure_timg_calibration_clock_impl(
1684///     _clocks: &mut ClockTree,
1685///     _old_config: Option<TimgCalibrationClockConfig>,
1686///     _new_config: TimgCalibrationClockConfig,
1687/// ) {
1688///     todo!()
1689/// }
1690///
1691/// impl AdcInstance {
1692///     // ADC_FUNCTION_CLOCK
1693///
1694///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1695///         todo!()
1696///     }
1697///
1698///     fn configure_function_clock_impl(
1699///         self,
1700///         _clocks: &mut ClockTree,
1701///         _old_config: Option<AdcFunctionClockConfig>,
1702///         _new_config: AdcFunctionClockConfig,
1703///     ) {
1704///         todo!()
1705///     }
1706/// }
1707/// impl SdmInstance {
1708///     // SDM_FUNCTION_CLOCK
1709///
1710///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1711///         todo!()
1712///     }
1713/// }
1714/// impl I2cInstance {
1715///     // I2C_FUNCTION_CLOCK
1716///
1717///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1718///         todo!()
1719///     }
1720///
1721///     fn configure_function_clock_impl(
1722///         self,
1723///         _clocks: &mut ClockTree,
1724///         _old_config: Option<I2cFunctionClockConfig>,
1725///         _new_config: I2cFunctionClockConfig,
1726///     ) {
1727///         todo!()
1728///     }
1729/// }
1730/// impl I2sInstance {
1731///     // I2S_TX_CLK
1732///
1733///     fn enable_tx_clk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1734///         todo!()
1735///     }
1736///
1737///     fn configure_tx_clk_impl(
1738///         self,
1739///         _clocks: &mut ClockTree,
1740///         _old_config: Option<I2sClkConfig>,
1741///         _new_config: I2sClkConfig,
1742///     ) {
1743///         todo!()
1744///     }
1745///
1746///     // I2S_RX_CLK
1747///
1748///     fn enable_rx_clk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1749///         todo!()
1750///     }
1751///
1752///     fn configure_rx_clk_impl(
1753///         self,
1754///         _clocks: &mut ClockTree,
1755///         _old_config: Option<I2sClkConfig>,
1756///         _new_config: I2sClkConfig,
1757///     ) {
1758///         todo!()
1759///     }
1760///
1761///     // I2S_MCLK_OUT
1762///
1763///     fn enable_mclk_out_impl(self, _clocks: &mut ClockTree, _en: bool) {
1764///         todo!()
1765///     }
1766///
1767///     fn configure_mclk_out_impl(
1768///         self,
1769///         _clocks: &mut ClockTree,
1770///         _old_config: Option<I2sMclkOutConfig>,
1771///         _new_config: I2sMclkOutConfig,
1772///     ) {
1773///         todo!()
1774///     }
1775/// }
1776/// impl ParlIoInstance {
1777///     // PARL_IO_RX_CLOCK
1778///
1779///     fn enable_rx_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1780///         todo!()
1781///     }
1782///
1783///     fn configure_rx_clock_impl(
1784///         self,
1785///         _clocks: &mut ClockTree,
1786///         _old_config: Option<ParlIoClkConfig>,
1787///         _new_config: ParlIoClkConfig,
1788///     ) {
1789///         todo!()
1790///     }
1791///
1792///     // PARL_IO_TX_CLOCK
1793///
1794///     fn enable_tx_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1795///         todo!()
1796///     }
1797///
1798///     fn configure_tx_clock_impl(
1799///         self,
1800///         _clocks: &mut ClockTree,
1801///         _old_config: Option<ParlIoClkConfig>,
1802///         _new_config: ParlIoClkConfig,
1803///     ) {
1804///         todo!()
1805///     }
1806/// }
1807/// impl PcntInstance {
1808///     // PCNT_FUNCTION_CLOCK
1809///
1810///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1811///         todo!()
1812///     }
1813/// }
1814/// impl RmtInstance {
1815///     // RMT_SCLK
1816///
1817///     fn enable_sclk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1818///         todo!()
1819///     }
1820///
1821///     fn configure_sclk_impl(
1822///         self,
1823///         _clocks: &mut ClockTree,
1824///         _old_config: Option<RmtSclkConfig>,
1825///         _new_config: RmtSclkConfig,
1826///     ) {
1827///         todo!()
1828///     }
1829/// }
1830/// impl SpiInstance {
1831///     // SPI_FUNCTION_CLOCK
1832///
1833///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1834///         todo!()
1835///     }
1836///
1837///     fn configure_function_clock_impl(
1838///         self,
1839///         _clocks: &mut ClockTree,
1840///         _old_config: Option<SpiFunctionClockConfig>,
1841///         _new_config: SpiFunctionClockConfig,
1842///     ) {
1843///         todo!()
1844///     }
1845/// }
1846/// impl TimgInstance {
1847///     // TIMG_FUNCTION_CLOCK
1848///
1849///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1850///         todo!()
1851///     }
1852///
1853///     fn configure_function_clock_impl(
1854///         self,
1855///         _clocks: &mut ClockTree,
1856///         _old_config: Option<TimgFunctionClockConfig>,
1857///         _new_config: TimgFunctionClockConfig,
1858///     ) {
1859///         todo!()
1860///     }
1861///
1862///     // TIMG_WDT_CLOCK
1863///
1864///     fn enable_wdt_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1865///         todo!()
1866///     }
1867///
1868///     fn configure_wdt_clock_impl(
1869///         self,
1870///         _clocks: &mut ClockTree,
1871///         _old_config: Option<TimgWdtClockConfig>,
1872///         _new_config: TimgWdtClockConfig,
1873///     ) {
1874///         todo!()
1875///     }
1876/// }
1877/// impl TwaiInstance {
1878///     // TWAI_FUNCTION_CLOCK
1879///
1880///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1881///         todo!()
1882///     }
1883///
1884///     fn configure_function_clock_impl(
1885///         self,
1886///         _clocks: &mut ClockTree,
1887///         _old_config: Option<TwaiFunctionClockConfig>,
1888///         _new_config: TwaiFunctionClockConfig,
1889///     ) {
1890///         todo!()
1891///     }
1892/// }
1893/// impl UartInstance {
1894///     // UART_FUNCTION_CLOCK
1895///
1896///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1897///         todo!()
1898///     }
1899///
1900///     fn configure_function_clock_impl(
1901///         self,
1902///         _clocks: &mut ClockTree,
1903///         _old_config: Option<UartFunctionClockConfig>,
1904///         _new_config: UartFunctionClockConfig,
1905///     ) {
1906///         todo!()
1907///     }
1908///
1909///     // UART_BAUD_RATE_GENERATOR
1910///
1911///     fn enable_baud_rate_generator_impl(self, _clocks: &mut ClockTree, _en: bool) {
1912///         todo!()
1913///     }
1914///
1915///     fn configure_baud_rate_generator_impl(
1916///         self,
1917///         _clocks: &mut ClockTree,
1918///         _old_config: Option<UartBaudRateGeneratorConfig>,
1919///         _new_config: UartBaudRateGeneratorConfig,
1920///     ) {
1921///         todo!()
1922///     }
1923/// }
1924/// ```
1925macro_rules! define_clock_tree_types {
1926    () => {
1927        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1928        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1929        pub enum AdcInstance {
1930            ApbSaradc = 0,
1931        }
1932        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1933        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1934        pub enum SdmInstance {
1935            GpioSd = 0,
1936        }
1937        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1938        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1939        pub enum I2cInstance {
1940            I2c0 = 0,
1941        }
1942        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1943        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1944        pub enum I2sInstance {
1945            I2s0 = 0,
1946        }
1947        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1948        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1949        pub enum ParlIoInstance {
1950            ParlIo = 0,
1951        }
1952        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1953        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1954        pub enum PcntInstance {
1955            Pcnt = 0,
1956        }
1957        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1958        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1959        pub enum RmtInstance {
1960            Rmt = 0,
1961        }
1962        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1963        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1964        pub enum SpiInstance {
1965            Spi2 = 0,
1966        }
1967        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1968        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1969        pub enum TimgInstance {
1970            Timg0 = 0,
1971            Timg1 = 1,
1972        }
1973        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1974        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1975        pub enum TwaiInstance {
1976            Twai0 = 0,
1977            Twai1 = 1,
1978        }
1979        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1980        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1981        pub enum UartInstance {
1982            Uart0 = 0,
1983            Uart1 = 1,
1984        }
1985        /// Selects the output frequency of `XTAL_CLK`.
1986        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1987        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1988        pub enum XtalClkConfig {
1989            /// 40 MHz
1990            _40,
1991            /// 48 MHz
1992            _48,
1993        }
1994        impl XtalClkConfig {
1995            pub fn value(&self) -> u32 {
1996                match self {
1997                    XtalClkConfig::_40 => 40000000,
1998                    XtalClkConfig::_48 => 48000000,
1999                }
2000            }
2001        }
2002        /// The list of clock signals that the `HP_ROOT_CLK` multiplexer can output.
2003        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2004        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2005        pub enum HpRootClkConfig {
2006            /// Selects `XTAL_CLK`.
2007            Xtal,
2008            /// Selects `RC_FAST_CLK`.
2009            RcFast,
2010            /// Selects `PLL_F160M`.
2011            PllF160m,
2012            /// Selects `PLL_F240M`.
2013            PllF240m,
2014        }
2015        /// Configures the `CPU_CLK` clock node.
2016        ///
2017        /// The output is calculated as `OUTPUT = HP_ROOT_CLK / (divisor + 1)`.
2018        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2019        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2020        pub struct CpuClkConfig {
2021            divisor: u32,
2022        }
2023        impl CpuClkConfig {
2024            /// Creates a new configuration for the CPU_CLK clock node.
2025            ///
2026            /// ## Panics
2027            ///
2028            /// Panics if the divisor value is outside the
2029            /// valid range (0 ..= 255).
2030            pub const fn new(divisor: u32) -> Self {
2031                ::core::assert!(
2032                    divisor <= 255,
2033                    "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
2034                );
2035                Self { divisor }
2036            }
2037            pub fn divisor(self) -> u32 {
2038                self.divisor as u32
2039            }
2040        }
2041        /// Configures the `AHB_CLK` clock node.
2042        ///
2043        /// The output is calculated as `OUTPUT = HP_ROOT_CLK / (divisor + 1)`.
2044        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2045        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2046        pub struct AhbClkConfig {
2047            divisor: u32,
2048        }
2049        impl AhbClkConfig {
2050            /// Creates a new configuration for the AHB_CLK clock node.
2051            ///
2052            /// ## Panics
2053            ///
2054            /// Panics if the divisor value is outside the
2055            /// valid range (0 ..= 255).
2056            pub const fn new(divisor: u32) -> Self {
2057                ::core::assert!(
2058                    divisor <= 255,
2059                    "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
2060                );
2061                Self { divisor }
2062            }
2063            pub fn divisor(self) -> u32 {
2064                self.divisor as u32
2065            }
2066        }
2067        /// Configures the `APB_CLK` clock node.
2068        ///
2069        /// The output is calculated as `OUTPUT = AHB_CLK / (divisor + 1)`.
2070        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2071        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2072        pub struct ApbClkConfig {
2073            divisor: u32,
2074        }
2075        impl ApbClkConfig {
2076            /// Creates a new configuration for the APB_CLK clock node.
2077            ///
2078            /// ## Panics
2079            ///
2080            /// Panics if the divisor value is outside the
2081            /// valid range (0 ..= 255).
2082            pub const fn new(divisor: u32) -> Self {
2083                ::core::assert!(
2084                    divisor <= 255,
2085                    "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
2086                );
2087                Self { divisor }
2088            }
2089            pub fn divisor(self) -> u32 {
2090                self.divisor as u32
2091            }
2092        }
2093        /// The list of clock signals that the `LP_FAST_CLK` multiplexer can output.
2094        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2095        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2096        pub enum LpFastClkConfig {
2097            /// Selects `RC_FAST_CLK`.
2098            RcFast,
2099            /// Selects `XTAL_D2_CLK`.
2100            XtalD2,
2101            /// Selects `XTAL_CLK`.
2102            Xtal,
2103        }
2104        /// The list of clock signals that the `LP_SLOW_CLK` multiplexer can output.
2105        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2106        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2107        pub enum LpSlowClkConfig {
2108            /// Selects `RC_SLOW_CLK`.
2109            RcSlow,
2110            #[cfg(use_xtal32k)]
2111            /// Selects `XTAL32K_CLK`.
2112            Xtal32k,
2113            /// Selects `OSC_SLOW_CLK`.
2114            OscSlow,
2115        }
2116        /// The list of clock signals that the `BLE_LP_CLK` multiplexer can output.
2117        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2118        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2119        pub enum BleLpClkConfig {
2120            /// Selects `BLE_LP_XTAL_CLK`.
2121            Xtal,
2122            /// Selects `BLE_LP_RC_SLOW_CLK`.
2123            RcSlow,
2124            #[cfg(use_xtal32k)]
2125            /// Selects `XTAL32K_CLK`.
2126            Xtal32k,
2127        }
2128        /// The list of clock signals that the `CRYPTO_CLK` multiplexer can output.
2129        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2130        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2131        pub enum CryptoClkConfig {
2132            /// Selects `XTAL_CLK`.
2133            Xtal,
2134            /// Selects `RC_FAST_CLK`.
2135            Fosc,
2136            /// Selects `CRYPTO_PLL_DIV`.
2137            PllF480m,
2138        }
2139        /// The list of clock signals that the `IOMUX_FUNCTION_CLOCK` multiplexer can output.
2140        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2141        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2142        pub enum IomuxFunctionClockConfig {
2143            /// Selects `XTAL_CLK`.
2144            XtalClk,
2145            /// Selects `RC_FAST_CLK`.
2146            RcFastClk,
2147            #[default]
2148            /// Selects `PLL_F80M`.
2149            PllF80m,
2150        }
2151        /// The list of clock signals that the `TIMG_CALIBRATION_CLOCK` multiplexer can output.
2152        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2153        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2154        pub enum TimgCalibrationClockConfig {
2155            /// Selects `OSC_SLOW_CLK`.
2156            OscSlowClk,
2157            /// Selects `RC_SLOW_CLK`.
2158            RcSlowClk,
2159            /// Selects `RC_FAST_CLK`.
2160            RcFastDivClk,
2161            #[cfg(use_xtal32k)]
2162            /// Selects `XTAL32K_CLK`.
2163            Xtal32kClk,
2164        }
2165        /// The list of clock signals that the `APB_SARADC_FUNCTION_CLOCK` multiplexer can output.
2166        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2167        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2168        pub enum AdcFunctionClockConfig {
2169            /// Selects `XTAL_CLK`.
2170            Xtal,
2171            /// Selects `RC_FAST_CLK`.
2172            RcFast,
2173            #[default]
2174            /// Selects `PLL_F80M`.
2175            PllF80m,
2176        }
2177        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2178        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2179        pub enum I2cFunctionClockSclk {
2180            #[default]
2181            /// Selects `XTAL_CLK`.
2182            Xtal,
2183            /// Selects `RC_FAST_CLK`.
2184            RcFast,
2185        }
2186        /// Configures the `I2C0_FUNCTION_CLOCK` clock node.
2187        ///
2188        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
2189        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2190        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2191        pub struct I2cFunctionClockConfig {
2192            sclk: I2cFunctionClockSclk,
2193            div_num: u32,
2194        }
2195        impl I2cFunctionClockConfig {
2196            /// Creates a new configuration for the FUNCTION_CLOCK clock node.
2197            ///
2198            /// ## Panics
2199            ///
2200            /// Panics if the div_num value is outside the
2201            /// valid range (0 ..= 255).
2202            pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
2203                ::core::assert!(
2204                    div_num <= 255,
2205                    "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2206                );
2207                Self { sclk, div_num }
2208            }
2209            pub fn sclk(self) -> I2cFunctionClockSclk {
2210                self.sclk
2211            }
2212            pub fn div_num(self) -> u32 {
2213                self.div_num as u32
2214            }
2215        }
2216        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2217        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2218        pub enum I2sClkSclk {
2219            /// Selects `XTAL_CLK`.
2220            Xtal,
2221            /// Selects `PLL_F240M`.
2222            PllF240m,
2223            #[default]
2224            /// Selects `PLL_F160M`.
2225            PllF160m,
2226        }
2227        /// Configures the `I2S0_TX_CLK` clock node.
2228        ///
2229        /// The output is calculated as `OUTPUT = (sclk * div_a) / (div_num * div_a + div_b)`.
2230        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2231        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2232        pub struct I2sClkConfig {
2233            sclk: I2sClkSclk,
2234            div_num: u32,
2235            div_a: u32,
2236            div_b: u32,
2237        }
2238        impl I2sClkConfig {
2239            /// Creates a new configuration for the TX_CLK clock node.
2240            ///
2241            /// ## Panics
2242            ///
2243            /// Panics if the div_num value is outside the
2244            /// valid range (1 ..= 255).
2245            ///
2246            /// Panics if the div_a value is outside the
2247            /// valid range (1 ..= 511).
2248            ///
2249            /// Panics if the div_b value is outside the
2250            /// valid range (0 ..= 511).
2251            pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
2252                ::core::assert!(
2253                    div_num >= 1 && div_num <= 255,
2254                    "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
2255                );
2256                ::core::assert!(
2257                    div_a >= 1 && div_a <= 511,
2258                    "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
2259                );
2260                ::core::assert!(
2261                    div_b <= 511,
2262                    "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
2263                );
2264                Self {
2265                    sclk,
2266                    div_num,
2267                    div_a,
2268                    div_b,
2269                }
2270            }
2271            pub fn sclk(self) -> I2sClkSclk {
2272                self.sclk
2273            }
2274            pub fn div_num(self) -> u32 {
2275                self.div_num as u32
2276            }
2277            pub fn div_a(self) -> u32 {
2278                self.div_a as u32
2279            }
2280            pub fn div_b(self) -> u32 {
2281                self.div_b as u32
2282            }
2283        }
2284        /// The list of clock signals that the `I2S0_MCLK_OUT` multiplexer can output.
2285        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2286        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2287        pub enum I2sMclkOutConfig {
2288            /// Selects `TX_CLK`.
2289            Tx,
2290            #[default]
2291            /// Selects `RX_CLK`.
2292            Rx,
2293        }
2294        /// The list of clock signals that the `PARL_IO_RX_CLOCK` multiplexer can output.
2295        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2296        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2297        pub enum ParlIoClkConfig {
2298            /// Selects `XTAL_CLK`.
2299            XtalClk,
2300            /// Selects `RC_FAST_CLK`.
2301            RcFastClk,
2302            #[default]
2303            /// Selects `PLL_F240M`.
2304            PllF240m,
2305        }
2306        /// The list of clock signals that the `RMT_SCLK` multiplexer can output.
2307        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2308        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2309        pub enum RmtSclkConfig {
2310            /// Selects `XTAL_CLK`.
2311            XtalClk,
2312            /// Selects `RC_FAST_CLK`.
2313            RcFastClk,
2314            #[default]
2315            /// Selects `PLL_F80M`.
2316            PllF80m,
2317        }
2318        /// The list of clock signals that the `SPI2_FUNCTION_CLOCK` multiplexer can output.
2319        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2320        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2321        pub enum SpiFunctionClockConfig {
2322            /// Selects `XTAL_CLK`.
2323            Xtal,
2324            #[default]
2325            /// Selects `PLL_F160M`.
2326            PllF160m,
2327            /// Selects `PLL_F120M`.
2328            PllF120m,
2329            /// Selects `RC_FAST_CLK`.
2330            RcFast,
2331        }
2332        /// The list of clock signals that the `TIMG0_FUNCTION_CLOCK` multiplexer can output.
2333        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2334        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2335        pub enum TimgFunctionClockConfig {
2336            #[default]
2337            /// Selects `XTAL_CLK`.
2338            XtalClk,
2339            /// Selects `RC_FAST_CLK`.
2340            RcFastClk,
2341            /// Selects `PLL_F80M`.
2342            PllF80m,
2343        }
2344        /// The list of clock signals that the `TIMG0_WDT_CLOCK` multiplexer can output.
2345        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2346        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2347        pub enum TimgWdtClockConfig {
2348            #[default]
2349            /// Selects `XTAL_CLK`.
2350            XtalClk,
2351            /// Selects `PLL_F80M`.
2352            PllF80m,
2353            /// Selects `RC_FAST_CLK`.
2354            RcFastClk,
2355        }
2356        /// The list of clock signals that the `TWAI0_FUNCTION_CLOCK` multiplexer can output.
2357        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2358        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2359        pub enum TwaiFunctionClockConfig {
2360            /// Selects `XTAL_CLK`.
2361            Xtal,
2362            #[default]
2363            /// Selects `PLL_F80M`.
2364            PllF80m,
2365        }
2366        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2367        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2368        pub enum UartFunctionClockSclk {
2369            #[default]
2370            /// Selects `XTAL_CLK`.
2371            Xtal,
2372            /// Selects `PLL_F80M`.
2373            PllF80m,
2374            /// Selects `RC_FAST_CLK`.
2375            RcFast,
2376        }
2377        /// Configures the `UART0_FUNCTION_CLOCK` clock node.
2378        ///
2379        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
2380        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2381        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2382        pub struct UartFunctionClockConfig {
2383            sclk: UartFunctionClockSclk,
2384            div_num: u32,
2385        }
2386        impl UartFunctionClockConfig {
2387            /// Creates a new configuration for the FUNCTION_CLOCK clock node.
2388            ///
2389            /// ## Panics
2390            ///
2391            /// Panics if the div_num value is outside the
2392            /// valid range (0 ..= 255).
2393            pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
2394                ::core::assert!(
2395                    div_num <= 255,
2396                    "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2397                );
2398                Self { sclk, div_num }
2399            }
2400            pub fn sclk(self) -> UartFunctionClockSclk {
2401                self.sclk
2402            }
2403            pub fn div_num(self) -> u32 {
2404                self.div_num as u32
2405            }
2406        }
2407        /// Configures the `UART0_BAUD_RATE_GENERATOR` clock node.
2408        ///
2409        /// The output is calculated as `OUTPUT = (FUNCTION_CLOCK * 16) / (integral * 16 +
2410        /// fractional)`.
2411        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2412        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2413        pub struct UartBaudRateGeneratorConfig {
2414            fractional: u32,
2415            integral: u32,
2416        }
2417        impl UartBaudRateGeneratorConfig {
2418            /// Creates a new configuration for the BAUD_RATE_GENERATOR clock node.
2419            ///
2420            /// ## Panics
2421            ///
2422            /// Panics if the fractional value is outside the
2423            /// valid range (0 ..= 15).
2424            ///
2425            /// Panics if the integral value is outside the
2426            /// valid range (0 ..= 4095).
2427            pub const fn new(fractional: u32, integral: u32) -> Self {
2428                ::core::assert!(
2429                    fractional <= 15,
2430                    "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2431                );
2432                ::core::assert!(
2433                    integral <= 4095,
2434                    "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2435                );
2436                Self {
2437                    fractional,
2438                    integral,
2439                }
2440            }
2441            pub fn fractional(self) -> u32 {
2442                self.fractional as u32
2443            }
2444            pub fn integral(self) -> u32 {
2445                self.integral as u32
2446            }
2447        }
2448        /// Represents the device's clock tree.
2449        pub struct ClockTree {
2450            xtal_clk: Option<XtalClkConfig>,
2451            hp_root_clk: Option<HpRootClkConfig>,
2452            cpu_clk: Option<CpuClkConfig>,
2453            ahb_clk: Option<AhbClkConfig>,
2454            apb_clk: Option<ApbClkConfig>,
2455            lp_fast_clk: Option<LpFastClkConfig>,
2456            lp_slow_clk: Option<LpSlowClkConfig>,
2457            ble_lp_clk: Option<BleLpClkConfig>,
2458            crypto_clk: Option<CryptoClkConfig>,
2459            iomux_function_clock: Option<IomuxFunctionClockConfig>,
2460            timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2461            adc_function_clock: [Option<AdcFunctionClockConfig>; 1],
2462            i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
2463            i2s_tx_clk: [Option<I2sClkConfig>; 1],
2464            i2s_rx_clk: [Option<I2sClkConfig>; 1],
2465            i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
2466            parl_io_rx_clock: [Option<ParlIoClkConfig>; 1],
2467            parl_io_tx_clock: [Option<ParlIoClkConfig>; 1],
2468            rmt_sclk: [Option<RmtSclkConfig>; 1],
2469            spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
2470            timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2471            timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2472            twai_function_clock: [Option<TwaiFunctionClockConfig>; 2],
2473            uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2474            uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2475            pub(crate) pll_clk_refcount: u32,
2476            pub(crate) rc_fast_clk_refcount: u32,
2477            #[cfg(use_xtal32k)]
2478            pub(crate) xtal32k_clk_refcount: u32,
2479            pub(crate) osc_slow_clk_refcount: u32,
2480            pub(crate) rc_slow_clk_refcount: u32,
2481            pub(crate) pll_f12m_refcount: u32,
2482            pub(crate) pll_f20m_refcount: u32,
2483            pub(crate) pll_f40m_refcount: u32,
2484            pub(crate) pll_f48m_refcount: u32,
2485            pub(crate) pll_f60m_refcount: u32,
2486            pub(crate) pll_f80m_refcount: u32,
2487            pub(crate) pll_f160m_refcount: u32,
2488            pub(crate) pll_f240m_refcount: u32,
2489            pub(crate) hp_root_clk_refcount: u32,
2490            pub(crate) apb_clk_refcount: u32,
2491            pub(crate) lp_fast_clk_refcount: u32,
2492            pub(crate) lp_slow_clk_refcount: u32,
2493            pub(crate) ble_lp_clk_refcount: u32,
2494            pub(crate) crypto_clk_refcount: u32,
2495            pub(crate) timg_calibration_clock_refcount: u32,
2496            pub(crate) adc_function_clock_refcount: [u32; 1],
2497            pub(crate) sdm_function_clock_refcount: [u32; 1],
2498            pub(crate) i2c_function_clock_refcount: [u32; 1],
2499            pub(crate) i2s_tx_clk_refcount: [u32; 1],
2500            pub(crate) i2s_rx_clk_refcount: [u32; 1],
2501            pub(crate) i2s_mclk_out_refcount: [u32; 1],
2502            pub(crate) parl_io_rx_clock_refcount: [u32; 1],
2503            pub(crate) parl_io_tx_clock_refcount: [u32; 1],
2504            pub(crate) pcnt_function_clock_refcount: [u32; 1],
2505            pub(crate) rmt_sclk_refcount: [u32; 1],
2506            pub(crate) spi_function_clock_refcount: [u32; 1],
2507            pub(crate) timg_function_clock_refcount: [u32; 2],
2508            pub(crate) timg_wdt_clock_refcount: [u32; 2],
2509            pub(crate) twai_function_clock_refcount: [u32; 2],
2510            pub(crate) uart_function_clock_refcount: [u32; 2],
2511            pub(crate) uart_baud_rate_generator_refcount: [u32; 2],
2512        }
2513        impl ClockTree {
2514            /// Locks the clock tree for exclusive access.
2515            pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2516                CLOCK_TREE.with(f)
2517            }
2518            /// Returns the current configuration of the XTAL_CLK clock tree node
2519            pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2520                self.xtal_clk
2521            }
2522            /// Returns the current configuration of the HP_ROOT_CLK clock tree node
2523            pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
2524                self.hp_root_clk
2525            }
2526            /// Returns the current configuration of the CPU_CLK clock tree node
2527            pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2528                self.cpu_clk
2529            }
2530            /// Returns the current configuration of the AHB_CLK clock tree node
2531            pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
2532                self.ahb_clk
2533            }
2534            /// Returns the current configuration of the APB_CLK clock tree node
2535            pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2536                self.apb_clk
2537            }
2538            /// Returns the current configuration of the LP_FAST_CLK clock tree node
2539            pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2540                self.lp_fast_clk
2541            }
2542            /// Returns the current configuration of the LP_SLOW_CLK clock tree node
2543            pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2544                self.lp_slow_clk
2545            }
2546            /// Returns the current configuration of the BLE_LP_CLK clock tree node
2547            pub fn ble_lp_clk(&self) -> Option<BleLpClkConfig> {
2548                self.ble_lp_clk
2549            }
2550            /// Returns the current configuration of the CRYPTO_CLK clock tree node
2551            pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
2552                self.crypto_clk
2553            }
2554            /// Returns the current configuration of the IOMUX_FUNCTION_CLOCK clock tree node
2555            pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2556                self.iomux_function_clock
2557            }
2558            /// Returns the current configuration of the TIMG_CALIBRATION_CLOCK clock tree node
2559            pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2560                self.timg_calibration_clock
2561            }
2562            /// Returns the current configuration of the APB_SARADC_FUNCTION_CLOCK clock tree node
2563            pub fn apb_saradc_function_clock(&self) -> Option<AdcFunctionClockConfig> {
2564                self.adc_function_clock[AdcInstance::ApbSaradc as usize]
2565            }
2566            /// Returns the current configuration of the I2C0_FUNCTION_CLOCK clock tree node
2567            pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2568                self.i2c_function_clock[I2cInstance::I2c0 as usize]
2569            }
2570            /// Returns the current configuration of the I2S0_TX_CLK clock tree node
2571            pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
2572                self.i2s_tx_clk[I2sInstance::I2s0 as usize]
2573            }
2574            /// Returns the current configuration of the I2S0_RX_CLK clock tree node
2575            pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
2576                self.i2s_rx_clk[I2sInstance::I2s0 as usize]
2577            }
2578            /// Returns the current configuration of the I2S0_MCLK_OUT clock tree node
2579            pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
2580                self.i2s_mclk_out[I2sInstance::I2s0 as usize]
2581            }
2582            /// Returns the current configuration of the PARL_IO_RX_CLOCK clock tree node
2583            pub fn parl_io_rx_clock(&self) -> Option<ParlIoClkConfig> {
2584                self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
2585            }
2586            /// Returns the current configuration of the PARL_IO_TX_CLOCK clock tree node
2587            pub fn parl_io_tx_clock(&self) -> Option<ParlIoClkConfig> {
2588                self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
2589            }
2590            /// Returns the current configuration of the RMT_SCLK clock tree node
2591            pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2592                self.rmt_sclk[RmtInstance::Rmt as usize]
2593            }
2594            /// Returns the current configuration of the SPI2_FUNCTION_CLOCK clock tree node
2595            pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2596                self.spi_function_clock[SpiInstance::Spi2 as usize]
2597            }
2598            /// Returns the current configuration of the TIMG0_FUNCTION_CLOCK clock tree node
2599            pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2600                self.timg_function_clock[TimgInstance::Timg0 as usize]
2601            }
2602            /// Returns the current configuration of the TIMG0_WDT_CLOCK clock tree node
2603            pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2604                self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2605            }
2606            /// Returns the current configuration of the TIMG1_FUNCTION_CLOCK clock tree node
2607            pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2608                self.timg_function_clock[TimgInstance::Timg1 as usize]
2609            }
2610            /// Returns the current configuration of the TIMG1_WDT_CLOCK clock tree node
2611            pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2612                self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2613            }
2614            /// Returns the current configuration of the TWAI0_FUNCTION_CLOCK clock tree node
2615            pub fn twai0_function_clock(&self) -> Option<TwaiFunctionClockConfig> {
2616                self.twai_function_clock[TwaiInstance::Twai0 as usize]
2617            }
2618            /// Returns the current configuration of the TWAI1_FUNCTION_CLOCK clock tree node
2619            pub fn twai1_function_clock(&self) -> Option<TwaiFunctionClockConfig> {
2620                self.twai_function_clock[TwaiInstance::Twai1 as usize]
2621            }
2622            /// Returns the current configuration of the UART0_FUNCTION_CLOCK clock tree node
2623            pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2624                self.uart_function_clock[UartInstance::Uart0 as usize]
2625            }
2626            /// Returns the current configuration of the UART0_BAUD_RATE_GENERATOR clock tree node
2627            pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2628                self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2629            }
2630            /// Returns the current configuration of the UART1_FUNCTION_CLOCK clock tree node
2631            pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2632                self.uart_function_clock[UartInstance::Uart1 as usize]
2633            }
2634            /// Returns the current configuration of the UART1_BAUD_RATE_GENERATOR clock tree node
2635            pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2636                self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2637            }
2638        }
2639        static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2640            ::esp_sync::NonReentrantMutex::new(ClockTree {
2641                xtal_clk: None,
2642                hp_root_clk: None,
2643                cpu_clk: None,
2644                ahb_clk: None,
2645                apb_clk: None,
2646                lp_fast_clk: None,
2647                lp_slow_clk: None,
2648                ble_lp_clk: None,
2649                crypto_clk: None,
2650                iomux_function_clock: None,
2651                timg_calibration_clock: None,
2652                adc_function_clock: [None; 1],
2653                i2c_function_clock: [None; 1],
2654                i2s_tx_clk: [None; 1],
2655                i2s_rx_clk: [None; 1],
2656                i2s_mclk_out: [None; 1],
2657                parl_io_rx_clock: [None; 1],
2658                parl_io_tx_clock: [None; 1],
2659                rmt_sclk: [None; 1],
2660                spi_function_clock: [None; 1],
2661                timg_function_clock: [None; 2],
2662                timg_wdt_clock: [None; 2],
2663                twai_function_clock: [None; 2],
2664                uart_function_clock: [None; 2],
2665                uart_baud_rate_generator: [None; 2],
2666                pll_clk_refcount: 0,
2667                rc_fast_clk_refcount: 0,
2668                #[cfg(use_xtal32k)]
2669                xtal32k_clk_refcount: 0,
2670                osc_slow_clk_refcount: 0,
2671                rc_slow_clk_refcount: 0,
2672                pll_f12m_refcount: 0,
2673                pll_f20m_refcount: 0,
2674                pll_f40m_refcount: 0,
2675                pll_f48m_refcount: 0,
2676                pll_f60m_refcount: 0,
2677                pll_f80m_refcount: 0,
2678                pll_f160m_refcount: 0,
2679                pll_f240m_refcount: 0,
2680                hp_root_clk_refcount: 0,
2681                apb_clk_refcount: 0,
2682                lp_fast_clk_refcount: 0,
2683                lp_slow_clk_refcount: 0,
2684                ble_lp_clk_refcount: 0,
2685                crypto_clk_refcount: 0,
2686                timg_calibration_clock_refcount: 0,
2687                adc_function_clock_refcount: [0; 1],
2688                sdm_function_clock_refcount: [0; 1],
2689                i2c_function_clock_refcount: [0; 1],
2690                i2s_tx_clk_refcount: [0; 1],
2691                i2s_rx_clk_refcount: [0; 1],
2692                i2s_mclk_out_refcount: [0; 1],
2693                parl_io_rx_clock_refcount: [0; 1],
2694                parl_io_tx_clock_refcount: [0; 1],
2695                pcnt_function_clock_refcount: [0; 1],
2696                rmt_sclk_refcount: [0; 1],
2697                spi_function_clock_refcount: [0; 1],
2698                timg_function_clock_refcount: [0; 2],
2699                timg_wdt_clock_refcount: [0; 2],
2700                twai_function_clock_refcount: [0; 2],
2701                uart_function_clock_refcount: [0; 2],
2702                uart_baud_rate_generator_refcount: [0; 2],
2703            });
2704        static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2705            ::core::sync::atomic::AtomicU32::new(0);
2706        static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2707            ::core::sync::atomic::AtomicU32::new(0);
2708        static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2709            ::core::sync::atomic::AtomicU32::new(0);
2710        static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2711            ::core::sync::atomic::AtomicU32::new(0);
2712        static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2713            ::core::sync::atomic::AtomicU32::new(0);
2714        static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2715            ::core::sync::atomic::AtomicU32::new(0);
2716        static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2717            ::core::sync::atomic::AtomicU32::new(0);
2718        static BLE_LP_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2719            ::core::sync::atomic::AtomicU32::new(0);
2720        static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2721            ::core::sync::atomic::AtomicU32::new(0);
2722        static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2723            ::core::sync::atomic::AtomicU32::new(0);
2724        static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2725            ::core::sync::atomic::AtomicU32::new(0);
2726        static ADC_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2727            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2728        static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2729            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2730        static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2731            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2732        static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2733            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2734        static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2735            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2736        static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2737            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2738        static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2739            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2740        static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2741            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2742        static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2743            [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2744        static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2745            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2746        static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2747            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2748        static TWAI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2749            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2750        static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2751            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2752        static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2753            [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2754        /// The clock sources of the device.
2755        ///
2756        /// A clock source is a node of the clock tree that other nodes derive their output
2757        /// from. Ask a node which source it runs on with its `..._root_source` function.
2758        #[derive(Debug, enumset::EnumSetType)]
2759        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2760        pub enum ClockSource {
2761            /// `XTAL_CLK`.
2762            XtalClk,
2763            /// `RC_FAST_CLK`.
2764            RcFastClk,
2765            #[cfg(use_xtal32k)]
2766            /// `XTAL32K_CLK`.
2767            Xtal32kClk,
2768            /// `OSC_SLOW_CLK`.
2769            OscSlowClk,
2770            /// `RC_SLOW_CLK`.
2771            RcSlowClk,
2772        }
2773        /// Returns the clock source that `XTAL_CLK` currently runs on.
2774        pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2775            Some(ClockSource::XtalClk)
2776        }
2777        /// Returns the clock source that `PLL_CLK` currently runs on.
2778        pub fn pll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2779            xtal_clk_root_source(clocks)
2780        }
2781        /// Returns the clock source that `RC_FAST_CLK` currently runs on.
2782        pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2783            Some(ClockSource::RcFastClk)
2784        }
2785        #[cfg(use_xtal32k)]
2786        /// Returns the clock source that `XTAL32K_CLK` currently runs on.
2787        pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2788            Some(ClockSource::Xtal32kClk)
2789        }
2790        /// Returns the clock source that `OSC_SLOW_CLK` currently runs on.
2791        pub fn osc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2792            Some(ClockSource::OscSlowClk)
2793        }
2794        /// Returns the clock source that `RC_SLOW_CLK` currently runs on.
2795        pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2796            Some(ClockSource::RcSlowClk)
2797        }
2798        /// Returns the clock source that `PLL_F12M` currently runs on.
2799        pub fn pll_f12m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2800            pll_clk_root_source(clocks)
2801        }
2802        /// Returns the clock source that `PLL_F20M` currently runs on.
2803        pub fn pll_f20m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2804            pll_clk_root_source(clocks)
2805        }
2806        /// Returns the clock source that `PLL_F40M` currently runs on.
2807        pub fn pll_f40m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2808            pll_clk_root_source(clocks)
2809        }
2810        /// Returns the clock source that `PLL_F48M` currently runs on.
2811        pub fn pll_f48m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2812            pll_clk_root_source(clocks)
2813        }
2814        /// Returns the clock source that `PLL_F60M` currently runs on.
2815        pub fn pll_f60m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2816            pll_clk_root_source(clocks)
2817        }
2818        /// Returns the clock source that `PLL_F80M` currently runs on.
2819        pub fn pll_f80m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2820            pll_clk_root_source(clocks)
2821        }
2822        /// Returns the clock source that `PLL_F120M` currently runs on.
2823        pub fn pll_f120m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2824            pll_clk_root_source(clocks)
2825        }
2826        /// Returns the clock source that `PLL_F160M` currently runs on.
2827        pub fn pll_f160m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2828            pll_clk_root_source(clocks)
2829        }
2830        /// Returns the clock source that `PLL_F240M` currently runs on.
2831        pub fn pll_f240m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2832            pll_clk_root_source(clocks)
2833        }
2834        /// Returns the clock source that `HP_ROOT_CLK` currently runs on.
2835        pub fn hp_root_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2836            let config = clocks.hp_root_clk?;
2837            match config {
2838                HpRootClkConfig::Xtal => xtal_clk_root_source(clocks),
2839                HpRootClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2840                HpRootClkConfig::PllF160m => pll_f160m_root_source(clocks),
2841                HpRootClkConfig::PllF240m => pll_f240m_root_source(clocks),
2842            }
2843        }
2844        /// Returns the clock source that `CPU_CLK` currently runs on.
2845        pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2846            hp_root_clk_root_source(clocks)
2847        }
2848        /// Returns the clock source that `AHB_CLK` currently runs on.
2849        pub fn ahb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2850            hp_root_clk_root_source(clocks)
2851        }
2852        /// Returns the clock source that `APB_CLK` currently runs on.
2853        pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2854            ahb_clk_root_source(clocks)
2855        }
2856        /// Returns the clock source that `XTAL_D2_CLK` currently runs on.
2857        pub fn xtal_d2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2858            xtal_clk_root_source(clocks)
2859        }
2860        /// Returns the clock source that `LP_FAST_CLK` currently runs on.
2861        pub fn lp_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2862            let config = clocks.lp_fast_clk?;
2863            match config {
2864                LpFastClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2865                LpFastClkConfig::XtalD2 => xtal_d2_clk_root_source(clocks),
2866                LpFastClkConfig::Xtal => xtal_clk_root_source(clocks),
2867            }
2868        }
2869        /// Returns the clock source that `LP_SLOW_CLK` currently runs on.
2870        pub fn lp_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2871            let config = clocks.lp_slow_clk?;
2872            match config {
2873                LpSlowClkConfig::RcSlow => rc_slow_clk_root_source(clocks),
2874                #[cfg(use_xtal32k)]
2875                LpSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2876                LpSlowClkConfig::OscSlow => osc_slow_clk_root_source(clocks),
2877            }
2878        }
2879        /// Returns the clock source that `BLE_LP_XTAL_CLK` currently runs on.
2880        pub fn ble_lp_xtal_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2881            xtal_clk_root_source(clocks)
2882        }
2883        /// Returns the clock source that `BLE_LP_RC_SLOW_CLK` currently runs on.
2884        pub fn ble_lp_rc_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2885            rc_slow_clk_root_source(clocks)
2886        }
2887        /// Returns the clock source that `BLE_LP_CLK` currently runs on.
2888        pub fn ble_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2889            let config = clocks.ble_lp_clk?;
2890            match config {
2891                BleLpClkConfig::Xtal => ble_lp_xtal_clk_root_source(clocks),
2892                BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_root_source(clocks),
2893                #[cfg(use_xtal32k)]
2894                BleLpClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2895            }
2896        }
2897        /// Returns the clock source that `CRYPTO_PLL_DIV` currently runs on.
2898        pub fn crypto_pll_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2899            pll_clk_root_source(clocks)
2900        }
2901        /// Returns the clock source that `CRYPTO_CLK` currently runs on.
2902        pub fn crypto_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2903            let config = clocks.crypto_clk?;
2904            match config {
2905                CryptoClkConfig::Xtal => xtal_clk_root_source(clocks),
2906                CryptoClkConfig::Fosc => rc_fast_clk_root_source(clocks),
2907                CryptoClkConfig::PllF480m => crypto_pll_div_root_source(clocks),
2908            }
2909        }
2910        /// Returns the clock source that `IOMUX_FUNCTION_CLOCK` currently runs on.
2911        pub fn iomux_function_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2912            let config = clocks.iomux_function_clock?;
2913            match config {
2914                IomuxFunctionClockConfig::XtalClk => xtal_clk_root_source(clocks),
2915                IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_root_source(clocks),
2916                IomuxFunctionClockConfig::PllF80m => pll_f80m_root_source(clocks),
2917            }
2918        }
2919        /// Returns the clock source that `TIMG_CALIBRATION_CLOCK` currently runs on.
2920        pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2921            let config = clocks.timg_calibration_clock?;
2922            match config {
2923                TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_root_source(clocks),
2924                TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_root_source(clocks),
2925                TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_root_source(clocks),
2926                #[cfg(use_xtal32k)]
2927                TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
2928            }
2929        }
2930        pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2931            let old_config = clocks.xtal_clk.replace(config);
2932            refresh_xtal_clk_downstream(clocks);
2933            configure_xtal_clk_impl(clocks, old_config, config);
2934        }
2935        pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2936            clocks.xtal_clk
2937        }
2938        fn request_xtal_clk(_clocks: &mut ClockTree) {}
2939        fn release_xtal_clk(_clocks: &mut ClockTree) {}
2940        pub fn xtal_clk_config_frequency(config: XtalClkConfig) -> u32 {
2941            config.value()
2942        }
2943        pub fn xtal_clk_frequency() -> u32 {
2944            XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2945        }
2946        pub fn request_pll_clk(clocks: &mut ClockTree) {
2947            trace!("Requesting PLL_CLK");
2948            if increment_reference_count(&mut clocks.pll_clk_refcount) {
2949                trace!("Enabling PLL_CLK");
2950                request_xtal_clk(clocks);
2951                enable_pll_clk_impl(clocks, true);
2952            }
2953        }
2954        pub fn release_pll_clk(clocks: &mut ClockTree) {
2955            trace!("Releasing PLL_CLK");
2956            if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2957                trace!("Disabling PLL_CLK");
2958                enable_pll_clk_impl(clocks, false);
2959                release_xtal_clk(clocks);
2960            }
2961        }
2962        pub fn pll_clk_frequency() -> u32 {
2963            480000000
2964        }
2965        pub fn pll_clk_source_frequency() -> u32 {
2966            xtal_clk_frequency()
2967        }
2968        pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2969            trace!("Requesting RC_FAST_CLK");
2970            if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2971                trace!("Enabling RC_FAST_CLK");
2972                enable_rc_fast_clk_impl(clocks, true);
2973            }
2974        }
2975        pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2976            trace!("Releasing RC_FAST_CLK");
2977            if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2978                trace!("Disabling RC_FAST_CLK");
2979                enable_rc_fast_clk_impl(clocks, false);
2980            }
2981        }
2982        static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2983            ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
2984        pub const fn rc_fast_clk_nominal_frequency() -> u32 {
2985            20000000
2986        }
2987        pub fn rc_fast_clk_frequency() -> u32 {
2988            RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2989        }
2990        pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2991            if !(10000000..=30000000).contains(&frequency) {
2992                warn!(
2993                    "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
2994                    frequency
2995                );
2996                return;
2997            }
2998            debug!(
2999                "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
3000                frequency,
3001                rc_fast_clk_nominal_frequency()
3002            );
3003            RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
3004            refresh_rc_fast_clk_downstream(clocks);
3005        }
3006        #[cfg(use_xtal32k)]
3007        pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
3008            trace!("Requesting XTAL32K_CLK");
3009            if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
3010                trace!("Enabling XTAL32K_CLK");
3011                enable_xtal32k_clk_impl(clocks, true);
3012            }
3013        }
3014        #[cfg(use_xtal32k)]
3015        pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
3016            trace!("Releasing XTAL32K_CLK");
3017            if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
3018                trace!("Disabling XTAL32K_CLK");
3019                enable_xtal32k_clk_impl(clocks, false);
3020            }
3021        }
3022        #[cfg(use_xtal32k)]
3023        pub fn xtal32k_clk_frequency() -> u32 {
3024            32768
3025        }
3026        pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
3027            trace!("Requesting OSC_SLOW_CLK");
3028            if increment_reference_count(&mut clocks.osc_slow_clk_refcount) {
3029                trace!("Enabling OSC_SLOW_CLK");
3030                enable_osc_slow_clk_impl(clocks, true);
3031            }
3032        }
3033        pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
3034            trace!("Releasing OSC_SLOW_CLK");
3035            if decrement_reference_count(&mut clocks.osc_slow_clk_refcount) {
3036                trace!("Disabling OSC_SLOW_CLK");
3037                enable_osc_slow_clk_impl(clocks, false);
3038            }
3039        }
3040        pub fn osc_slow_clk_frequency() -> u32 {
3041            32768
3042        }
3043        pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
3044            trace!("Requesting RC_SLOW_CLK");
3045            if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
3046                trace!("Enabling RC_SLOW_CLK");
3047                enable_rc_slow_clk_impl(clocks, true);
3048            }
3049        }
3050        pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
3051            trace!("Releasing RC_SLOW_CLK");
3052            if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
3053                trace!("Disabling RC_SLOW_CLK");
3054                enable_rc_slow_clk_impl(clocks, false);
3055            }
3056        }
3057        static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
3058            ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
3059        pub const fn rc_slow_clk_nominal_frequency() -> u32 {
3060            130000
3061        }
3062        pub fn rc_slow_clk_frequency() -> u32 {
3063            RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
3064        }
3065        pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
3066            if !(65000..=195000).contains(&frequency) {
3067                warn!(
3068                    "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
3069                    frequency
3070                );
3071                return;
3072            }
3073            debug!(
3074                "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
3075                frequency,
3076                rc_slow_clk_nominal_frequency()
3077            );
3078            RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
3079            refresh_rc_slow_clk_downstream(clocks);
3080        }
3081        pub fn request_pll_f12m(clocks: &mut ClockTree) {
3082            trace!("Requesting PLL_F12M");
3083            if increment_reference_count(&mut clocks.pll_f12m_refcount) {
3084                trace!("Enabling PLL_F12M");
3085                request_pll_clk(clocks);
3086                enable_pll_f12m_impl(clocks, true);
3087            }
3088        }
3089        pub fn release_pll_f12m(clocks: &mut ClockTree) {
3090            trace!("Releasing PLL_F12M");
3091            if decrement_reference_count(&mut clocks.pll_f12m_refcount) {
3092                trace!("Disabling PLL_F12M");
3093                enable_pll_f12m_impl(clocks, false);
3094                release_pll_clk(clocks);
3095            }
3096        }
3097        pub fn pll_f12m_frequency() -> u32 {
3098            (pll_clk_frequency() / 40)
3099        }
3100        pub fn pll_f12m_source_frequency() -> u32 {
3101            pll_clk_frequency()
3102        }
3103        pub fn request_pll_f20m(clocks: &mut ClockTree) {
3104            trace!("Requesting PLL_F20M");
3105            if increment_reference_count(&mut clocks.pll_f20m_refcount) {
3106                trace!("Enabling PLL_F20M");
3107                request_pll_clk(clocks);
3108                enable_pll_f20m_impl(clocks, true);
3109            }
3110        }
3111        pub fn release_pll_f20m(clocks: &mut ClockTree) {
3112            trace!("Releasing PLL_F20M");
3113            if decrement_reference_count(&mut clocks.pll_f20m_refcount) {
3114                trace!("Disabling PLL_F20M");
3115                enable_pll_f20m_impl(clocks, false);
3116                release_pll_clk(clocks);
3117            }
3118        }
3119        pub fn pll_f20m_frequency() -> u32 {
3120            (pll_clk_frequency() / 24)
3121        }
3122        pub fn pll_f20m_source_frequency() -> u32 {
3123            pll_clk_frequency()
3124        }
3125        pub fn request_pll_f40m(clocks: &mut ClockTree) {
3126            trace!("Requesting PLL_F40M");
3127            if increment_reference_count(&mut clocks.pll_f40m_refcount) {
3128                trace!("Enabling PLL_F40M");
3129                request_pll_clk(clocks);
3130                enable_pll_f40m_impl(clocks, true);
3131            }
3132        }
3133        pub fn release_pll_f40m(clocks: &mut ClockTree) {
3134            trace!("Releasing PLL_F40M");
3135            if decrement_reference_count(&mut clocks.pll_f40m_refcount) {
3136                trace!("Disabling PLL_F40M");
3137                enable_pll_f40m_impl(clocks, false);
3138                release_pll_clk(clocks);
3139            }
3140        }
3141        pub fn pll_f40m_frequency() -> u32 {
3142            (pll_clk_frequency() / 12)
3143        }
3144        pub fn pll_f40m_source_frequency() -> u32 {
3145            pll_clk_frequency()
3146        }
3147        pub fn request_pll_f48m(clocks: &mut ClockTree) {
3148            trace!("Requesting PLL_F48M");
3149            if increment_reference_count(&mut clocks.pll_f48m_refcount) {
3150                trace!("Enabling PLL_F48M");
3151                request_pll_clk(clocks);
3152                enable_pll_f48m_impl(clocks, true);
3153            }
3154        }
3155        pub fn release_pll_f48m(clocks: &mut ClockTree) {
3156            trace!("Releasing PLL_F48M");
3157            if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
3158                trace!("Disabling PLL_F48M");
3159                enable_pll_f48m_impl(clocks, false);
3160                release_pll_clk(clocks);
3161            }
3162        }
3163        pub fn pll_f48m_frequency() -> u32 {
3164            (pll_clk_frequency() / 10)
3165        }
3166        pub fn pll_f48m_source_frequency() -> u32 {
3167            pll_clk_frequency()
3168        }
3169        pub fn request_pll_f60m(clocks: &mut ClockTree) {
3170            trace!("Requesting PLL_F60M");
3171            if increment_reference_count(&mut clocks.pll_f60m_refcount) {
3172                trace!("Enabling PLL_F60M");
3173                request_pll_clk(clocks);
3174                enable_pll_f60m_impl(clocks, true);
3175            }
3176        }
3177        pub fn release_pll_f60m(clocks: &mut ClockTree) {
3178            trace!("Releasing PLL_F60M");
3179            if decrement_reference_count(&mut clocks.pll_f60m_refcount) {
3180                trace!("Disabling PLL_F60M");
3181                enable_pll_f60m_impl(clocks, false);
3182                release_pll_clk(clocks);
3183            }
3184        }
3185        pub fn pll_f60m_frequency() -> u32 {
3186            (pll_clk_frequency() / 8)
3187        }
3188        pub fn pll_f60m_source_frequency() -> u32 {
3189            pll_clk_frequency()
3190        }
3191        pub fn request_pll_f80m(clocks: &mut ClockTree) {
3192            trace!("Requesting PLL_F80M");
3193            if increment_reference_count(&mut clocks.pll_f80m_refcount) {
3194                trace!("Enabling PLL_F80M");
3195                request_pll_clk(clocks);
3196                enable_pll_f80m_impl(clocks, true);
3197            }
3198        }
3199        pub fn release_pll_f80m(clocks: &mut ClockTree) {
3200            trace!("Releasing PLL_F80M");
3201            if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
3202                trace!("Disabling PLL_F80M");
3203                enable_pll_f80m_impl(clocks, false);
3204                release_pll_clk(clocks);
3205            }
3206        }
3207        pub fn pll_f80m_frequency() -> u32 {
3208            (pll_clk_frequency() / 6)
3209        }
3210        pub fn pll_f80m_source_frequency() -> u32 {
3211            pll_clk_frequency()
3212        }
3213        pub fn request_pll_f120m(clocks: &mut ClockTree) {
3214            trace!("Enabling PLL_F120M");
3215            request_pll_clk(clocks);
3216            enable_pll_f120m_impl(clocks, true);
3217        }
3218        pub fn release_pll_f120m(clocks: &mut ClockTree) {
3219            trace!("Disabling PLL_F120M");
3220            enable_pll_f120m_impl(clocks, false);
3221            release_pll_clk(clocks);
3222        }
3223        pub fn pll_f120m_frequency() -> u32 {
3224            (pll_clk_frequency() / 4)
3225        }
3226        pub fn pll_f120m_source_frequency() -> u32 {
3227            pll_clk_frequency()
3228        }
3229        pub fn request_pll_f160m(clocks: &mut ClockTree) {
3230            trace!("Requesting PLL_F160M");
3231            if increment_reference_count(&mut clocks.pll_f160m_refcount) {
3232                trace!("Enabling PLL_F160M");
3233                request_pll_clk(clocks);
3234                enable_pll_f160m_impl(clocks, true);
3235            }
3236        }
3237        pub fn release_pll_f160m(clocks: &mut ClockTree) {
3238            trace!("Releasing PLL_F160M");
3239            if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
3240                trace!("Disabling PLL_F160M");
3241                enable_pll_f160m_impl(clocks, false);
3242                release_pll_clk(clocks);
3243            }
3244        }
3245        pub fn pll_f160m_frequency() -> u32 {
3246            (pll_clk_frequency() / 3)
3247        }
3248        pub fn pll_f160m_source_frequency() -> u32 {
3249            pll_clk_frequency()
3250        }
3251        pub fn request_pll_f240m(clocks: &mut ClockTree) {
3252            trace!("Requesting PLL_F240M");
3253            if increment_reference_count(&mut clocks.pll_f240m_refcount) {
3254                trace!("Enabling PLL_F240M");
3255                request_pll_clk(clocks);
3256                enable_pll_f240m_impl(clocks, true);
3257            }
3258        }
3259        pub fn release_pll_f240m(clocks: &mut ClockTree) {
3260            trace!("Releasing PLL_F240M");
3261            if decrement_reference_count(&mut clocks.pll_f240m_refcount) {
3262                trace!("Disabling PLL_F240M");
3263                enable_pll_f240m_impl(clocks, false);
3264                release_pll_clk(clocks);
3265            }
3266        }
3267        pub fn pll_f240m_frequency() -> u32 {
3268            (pll_clk_frequency() / 2)
3269        }
3270        pub fn pll_f240m_source_frequency() -> u32 {
3271            pll_clk_frequency()
3272        }
3273        pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
3274            let old_selector = clocks.hp_root_clk.replace(new_selector);
3275            refresh_hp_root_clk_downstream(clocks);
3276            let active = clocks.hp_root_clk_refcount > 0;
3277            if active {
3278                match new_selector {
3279                    HpRootClkConfig::Xtal => request_xtal_clk(clocks),
3280                    HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3281                    HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
3282                    HpRootClkConfig::PllF240m => request_pll_f240m(clocks),
3283                }
3284            }
3285            configure_hp_root_clk_impl(clocks, old_selector, new_selector);
3286            if active && let Some(old_selector) = old_selector {
3287                match old_selector {
3288                    HpRootClkConfig::Xtal => release_xtal_clk(clocks),
3289                    HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3290                    HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
3291                    HpRootClkConfig::PllF240m => release_pll_f240m(clocks),
3292                }
3293            }
3294        }
3295        pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
3296            clocks.hp_root_clk
3297        }
3298        pub fn request_hp_root_clk(clocks: &mut ClockTree) {
3299            trace!("Requesting HP_ROOT_CLK");
3300            if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
3301                trace!("Enabling HP_ROOT_CLK");
3302                match unwrap!(clocks.hp_root_clk) {
3303                    HpRootClkConfig::Xtal => request_xtal_clk(clocks),
3304                    HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3305                    HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
3306                    HpRootClkConfig::PllF240m => request_pll_f240m(clocks),
3307                }
3308                enable_hp_root_clk_impl(clocks, true);
3309            }
3310        }
3311        pub fn release_hp_root_clk(clocks: &mut ClockTree) {
3312            trace!("Releasing HP_ROOT_CLK");
3313            if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
3314                trace!("Disabling HP_ROOT_CLK");
3315                enable_hp_root_clk_impl(clocks, false);
3316                match unwrap!(clocks.hp_root_clk) {
3317                    HpRootClkConfig::Xtal => release_xtal_clk(clocks),
3318                    HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3319                    HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
3320                    HpRootClkConfig::PllF240m => release_pll_f240m(clocks),
3321                }
3322            }
3323        }
3324        pub fn hp_root_clk_config_frequency(config: HpRootClkConfig) -> u32 {
3325            match config {
3326                HpRootClkConfig::Xtal => xtal_clk_frequency(),
3327                HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
3328                HpRootClkConfig::PllF160m => pll_f160m_frequency(),
3329                HpRootClkConfig::PllF240m => pll_f240m_frequency(),
3330            }
3331        }
3332        pub fn hp_root_clk_frequency() -> u32 {
3333            HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3334        }
3335        pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
3336            hp_root_clk_config_frequency(source)
3337        }
3338        pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
3339            let old_config = clocks.cpu_clk.replace(config);
3340            refresh_cpu_clk_downstream(clocks);
3341            if old_config.is_none() {
3342                request_hp_root_clk(clocks);
3343            }
3344            configure_cpu_clk_impl(clocks, old_config, config);
3345        }
3346        pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
3347            clocks.cpu_clk
3348        }
3349        fn request_cpu_clk(_clocks: &mut ClockTree) {}
3350        fn release_cpu_clk(_clocks: &mut ClockTree) {}
3351        pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
3352            (hp_root_clk_frequency() / (config.divisor() + 1))
3353        }
3354        pub fn cpu_clk_frequency() -> u32 {
3355            CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3356        }
3357        pub fn cpu_clk_source_frequency() -> u32 {
3358            hp_root_clk_frequency()
3359        }
3360        pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
3361            let old_config = clocks.ahb_clk.replace(config);
3362            refresh_ahb_clk_downstream(clocks);
3363            if old_config.is_none() {
3364                request_hp_root_clk(clocks);
3365            }
3366            configure_ahb_clk_impl(clocks, old_config, config);
3367        }
3368        pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
3369            clocks.ahb_clk
3370        }
3371        fn request_ahb_clk(_clocks: &mut ClockTree) {}
3372        fn release_ahb_clk(_clocks: &mut ClockTree) {}
3373        pub fn ahb_clk_config_frequency(config: AhbClkConfig) -> u32 {
3374            (hp_root_clk_frequency() / (config.divisor() + 1))
3375        }
3376        pub fn ahb_clk_frequency() -> u32 {
3377            AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3378        }
3379        pub fn ahb_clk_source_frequency() -> u32 {
3380            hp_root_clk_frequency()
3381        }
3382        pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
3383            let old_config = clocks.apb_clk.replace(config);
3384            refresh_apb_clk_downstream(clocks);
3385            if old_config.is_none() {
3386                request_ahb_clk(clocks);
3387            }
3388            configure_apb_clk_impl(clocks, old_config, config);
3389        }
3390        pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
3391            clocks.apb_clk
3392        }
3393        pub fn request_apb_clk(clocks: &mut ClockTree) {
3394            trace!("Requesting APB_CLK");
3395            if increment_reference_count(&mut clocks.apb_clk_refcount) {
3396                enable_apb_clk_impl(clocks, true);
3397            }
3398        }
3399        pub fn release_apb_clk(clocks: &mut ClockTree) {
3400            trace!("Releasing APB_CLK");
3401            if decrement_reference_count(&mut clocks.apb_clk_refcount) {
3402                enable_apb_clk_impl(clocks, false);
3403            }
3404        }
3405        pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
3406            (ahb_clk_frequency() / (config.divisor() + 1))
3407        }
3408        pub fn apb_clk_frequency() -> u32 {
3409            APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3410        }
3411        pub fn apb_clk_source_frequency() -> u32 {
3412            ahb_clk_frequency()
3413        }
3414        pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
3415            trace!("Enabling XTAL_D2_CLK");
3416            request_xtal_clk(clocks);
3417            enable_xtal_d2_clk_impl(clocks, true);
3418        }
3419        pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
3420            trace!("Disabling XTAL_D2_CLK");
3421            enable_xtal_d2_clk_impl(clocks, false);
3422            release_xtal_clk(clocks);
3423        }
3424        pub fn xtal_d2_clk_frequency() -> u32 {
3425            (xtal_clk_frequency() / 2)
3426        }
3427        pub fn xtal_d2_clk_source_frequency() -> u32 {
3428            xtal_clk_frequency()
3429        }
3430        pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
3431            let old_selector = clocks.lp_fast_clk.replace(new_selector);
3432            refresh_lp_fast_clk_downstream(clocks);
3433            let active = clocks.lp_fast_clk_refcount > 0;
3434            if active {
3435                match new_selector {
3436                    LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
3437                    LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
3438                    LpFastClkConfig::Xtal => request_xtal_clk(clocks),
3439                }
3440            }
3441            configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
3442            if active && let Some(old_selector) = old_selector {
3443                match old_selector {
3444                    LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
3445                    LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
3446                    LpFastClkConfig::Xtal => release_xtal_clk(clocks),
3447                }
3448            }
3449        }
3450        pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
3451            clocks.lp_fast_clk
3452        }
3453        pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
3454            trace!("Requesting LP_FAST_CLK");
3455            if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
3456                trace!("Enabling LP_FAST_CLK");
3457                match unwrap!(clocks.lp_fast_clk) {
3458                    LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
3459                    LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
3460                    LpFastClkConfig::Xtal => request_xtal_clk(clocks),
3461                }
3462                enable_lp_fast_clk_impl(clocks, true);
3463            }
3464        }
3465        pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
3466            trace!("Releasing LP_FAST_CLK");
3467            if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
3468                trace!("Disabling LP_FAST_CLK");
3469                enable_lp_fast_clk_impl(clocks, false);
3470                match unwrap!(clocks.lp_fast_clk) {
3471                    LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
3472                    LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
3473                    LpFastClkConfig::Xtal => release_xtal_clk(clocks),
3474                }
3475            }
3476        }
3477        pub fn lp_fast_clk_config_frequency(config: LpFastClkConfig) -> u32 {
3478            match config {
3479                LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
3480                LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
3481                LpFastClkConfig::Xtal => xtal_clk_frequency(),
3482            }
3483        }
3484        pub fn lp_fast_clk_frequency() -> u32 {
3485            LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3486        }
3487        pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
3488            lp_fast_clk_config_frequency(source)
3489        }
3490        pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
3491            let old_selector = clocks.lp_slow_clk.replace(new_selector);
3492            refresh_lp_slow_clk_downstream(clocks);
3493            let active = clocks.lp_slow_clk_refcount > 0;
3494            if active {
3495                match new_selector {
3496                    LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3497                    #[cfg(use_xtal32k)]
3498                    LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3499                    LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3500                }
3501            }
3502            configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
3503            if active && let Some(old_selector) = old_selector {
3504                match old_selector {
3505                    LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3506                    #[cfg(use_xtal32k)]
3507                    LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3508                    LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3509                }
3510            }
3511        }
3512        pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
3513            clocks.lp_slow_clk
3514        }
3515        pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
3516            trace!("Requesting LP_SLOW_CLK");
3517            if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
3518                trace!("Enabling LP_SLOW_CLK");
3519                match unwrap!(clocks.lp_slow_clk) {
3520                    LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3521                    #[cfg(use_xtal32k)]
3522                    LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3523                    LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3524                }
3525                enable_lp_slow_clk_impl(clocks, true);
3526            }
3527        }
3528        pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
3529            trace!("Releasing LP_SLOW_CLK");
3530            if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
3531                trace!("Disabling LP_SLOW_CLK");
3532                enable_lp_slow_clk_impl(clocks, false);
3533                match unwrap!(clocks.lp_slow_clk) {
3534                    LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3535                    #[cfg(use_xtal32k)]
3536                    LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3537                    LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3538                }
3539            }
3540        }
3541        pub fn lp_slow_clk_config_frequency(config: LpSlowClkConfig) -> u32 {
3542            match config {
3543                LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3544                #[cfg(use_xtal32k)]
3545                LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3546                LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
3547            }
3548        }
3549        pub fn lp_slow_clk_frequency() -> u32 {
3550            LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3551        }
3552        pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
3553            lp_slow_clk_config_frequency(source)
3554        }
3555        pub fn request_ble_lp_xtal_clk(clocks: &mut ClockTree) {
3556            trace!("Enabling BLE_LP_XTAL_CLK");
3557            request_xtal_clk(clocks);
3558            enable_ble_lp_xtal_clk_impl(clocks, true);
3559        }
3560        pub fn release_ble_lp_xtal_clk(clocks: &mut ClockTree) {
3561            trace!("Disabling BLE_LP_XTAL_CLK");
3562            enable_ble_lp_xtal_clk_impl(clocks, false);
3563            release_xtal_clk(clocks);
3564        }
3565        pub fn ble_lp_xtal_clk_frequency() -> u32 {
3566            100000
3567        }
3568        pub fn ble_lp_xtal_clk_source_frequency() -> u32 {
3569            xtal_clk_frequency()
3570        }
3571        pub fn request_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
3572            trace!("Enabling BLE_LP_RC_SLOW_CLK");
3573            request_rc_slow_clk(clocks);
3574            enable_ble_lp_rc_slow_clk_impl(clocks, true);
3575        }
3576        pub fn release_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
3577            trace!("Disabling BLE_LP_RC_SLOW_CLK");
3578            enable_ble_lp_rc_slow_clk_impl(clocks, false);
3579            release_rc_slow_clk(clocks);
3580        }
3581        pub fn ble_lp_rc_slow_clk_frequency() -> u32 {
3582            (rc_slow_clk_frequency() / 5)
3583        }
3584        pub fn ble_lp_rc_slow_clk_source_frequency() -> u32 {
3585            rc_slow_clk_frequency()
3586        }
3587        pub fn configure_ble_lp_clk(clocks: &mut ClockTree, new_selector: BleLpClkConfig) {
3588            let old_selector = clocks.ble_lp_clk.replace(new_selector);
3589            refresh_ble_lp_clk_downstream(clocks);
3590            let active = clocks.ble_lp_clk_refcount > 0;
3591            if active {
3592                match new_selector {
3593                    BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
3594                    BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
3595                    #[cfg(use_xtal32k)]
3596                    BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3597                }
3598            }
3599            configure_ble_lp_clk_impl(clocks, old_selector, new_selector);
3600            if active && let Some(old_selector) = old_selector {
3601                match old_selector {
3602                    BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
3603                    BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
3604                    #[cfg(use_xtal32k)]
3605                    BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3606                }
3607            }
3608        }
3609        pub fn ble_lp_clk_config(clocks: &mut ClockTree) -> Option<BleLpClkConfig> {
3610            clocks.ble_lp_clk
3611        }
3612        pub fn request_ble_lp_clk(clocks: &mut ClockTree) {
3613            trace!("Requesting BLE_LP_CLK");
3614            if increment_reference_count(&mut clocks.ble_lp_clk_refcount) {
3615                trace!("Enabling BLE_LP_CLK");
3616                match unwrap!(clocks.ble_lp_clk) {
3617                    BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
3618                    BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
3619                    #[cfg(use_xtal32k)]
3620                    BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3621                }
3622                enable_ble_lp_clk_impl(clocks, true);
3623            }
3624        }
3625        pub fn release_ble_lp_clk(clocks: &mut ClockTree) {
3626            trace!("Releasing BLE_LP_CLK");
3627            if decrement_reference_count(&mut clocks.ble_lp_clk_refcount) {
3628                trace!("Disabling BLE_LP_CLK");
3629                enable_ble_lp_clk_impl(clocks, false);
3630                match unwrap!(clocks.ble_lp_clk) {
3631                    BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
3632                    BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
3633                    #[cfg(use_xtal32k)]
3634                    BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3635                }
3636            }
3637        }
3638        pub fn ble_lp_clk_config_frequency(config: BleLpClkConfig) -> u32 {
3639            match config {
3640                BleLpClkConfig::Xtal => ble_lp_xtal_clk_frequency(),
3641                BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_frequency(),
3642                #[cfg(use_xtal32k)]
3643                BleLpClkConfig::Xtal32k => xtal32k_clk_frequency(),
3644            }
3645        }
3646        pub fn ble_lp_clk_frequency() -> u32 {
3647            BLE_LP_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3648        }
3649        pub fn ble_lp_clk_source_frequency(source: BleLpClkConfig) -> u32 {
3650            ble_lp_clk_config_frequency(source)
3651        }
3652        pub fn request_crypto_pll_div(clocks: &mut ClockTree) {
3653            trace!("Enabling CRYPTO_PLL_DIV");
3654            request_pll_clk(clocks);
3655            enable_crypto_pll_div_impl(clocks, true);
3656        }
3657        pub fn release_crypto_pll_div(clocks: &mut ClockTree) {
3658            trace!("Disabling CRYPTO_PLL_DIV");
3659            enable_crypto_pll_div_impl(clocks, false);
3660            release_pll_clk(clocks);
3661        }
3662        pub fn crypto_pll_div_frequency() -> u32 {
3663            (pll_clk_frequency() / 3)
3664        }
3665        pub fn crypto_pll_div_source_frequency() -> u32 {
3666            pll_clk_frequency()
3667        }
3668        pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
3669            let old_selector = clocks.crypto_clk.replace(new_selector);
3670            refresh_crypto_clk_downstream(clocks);
3671            let active = clocks.crypto_clk_refcount > 0;
3672            if active {
3673                match new_selector {
3674                    CryptoClkConfig::Xtal => request_xtal_clk(clocks),
3675                    CryptoClkConfig::Fosc => request_rc_fast_clk(clocks),
3676                    CryptoClkConfig::PllF480m => request_crypto_pll_div(clocks),
3677                }
3678            }
3679            configure_crypto_clk_impl(clocks, old_selector, new_selector);
3680            if active && let Some(old_selector) = old_selector {
3681                match old_selector {
3682                    CryptoClkConfig::Xtal => release_xtal_clk(clocks),
3683                    CryptoClkConfig::Fosc => release_rc_fast_clk(clocks),
3684                    CryptoClkConfig::PllF480m => release_crypto_pll_div(clocks),
3685                }
3686            }
3687        }
3688        pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
3689            clocks.crypto_clk
3690        }
3691        pub fn request_crypto_clk(clocks: &mut ClockTree) {
3692            trace!("Requesting CRYPTO_CLK");
3693            if increment_reference_count(&mut clocks.crypto_clk_refcount) {
3694                trace!("Enabling CRYPTO_CLK");
3695                match unwrap!(clocks.crypto_clk) {
3696                    CryptoClkConfig::Xtal => request_xtal_clk(clocks),
3697                    CryptoClkConfig::Fosc => request_rc_fast_clk(clocks),
3698                    CryptoClkConfig::PllF480m => request_crypto_pll_div(clocks),
3699                }
3700                enable_crypto_clk_impl(clocks, true);
3701            }
3702        }
3703        pub fn release_crypto_clk(clocks: &mut ClockTree) {
3704            trace!("Releasing CRYPTO_CLK");
3705            if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
3706                trace!("Disabling CRYPTO_CLK");
3707                enable_crypto_clk_impl(clocks, false);
3708                match unwrap!(clocks.crypto_clk) {
3709                    CryptoClkConfig::Xtal => release_xtal_clk(clocks),
3710                    CryptoClkConfig::Fosc => release_rc_fast_clk(clocks),
3711                    CryptoClkConfig::PllF480m => release_crypto_pll_div(clocks),
3712                }
3713            }
3714        }
3715        pub fn crypto_clk_config_frequency(config: CryptoClkConfig) -> u32 {
3716            match config {
3717                CryptoClkConfig::Xtal => xtal_clk_frequency(),
3718                CryptoClkConfig::Fosc => rc_fast_clk_frequency(),
3719                CryptoClkConfig::PllF480m => crypto_pll_div_frequency(),
3720            }
3721        }
3722        pub fn crypto_clk_frequency() -> u32 {
3723            CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3724        }
3725        pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
3726            crypto_clk_config_frequency(source)
3727        }
3728        pub fn configure_iomux_function_clock(
3729            clocks: &mut ClockTree,
3730            new_selector: IomuxFunctionClockConfig,
3731        ) {
3732            let old_selector = clocks.iomux_function_clock.replace(new_selector);
3733            refresh_iomux_function_clock_downstream(clocks);
3734            match new_selector {
3735                IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3736                IomuxFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3737                IomuxFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3738            }
3739            configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
3740            if let Some(old_selector) = old_selector {
3741                match old_selector {
3742                    IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3743                    IomuxFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3744                    IomuxFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3745                }
3746            }
3747        }
3748        pub fn iomux_function_clock_config(
3749            clocks: &mut ClockTree,
3750        ) -> Option<IomuxFunctionClockConfig> {
3751            clocks.iomux_function_clock
3752        }
3753        fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
3754        fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
3755        pub fn iomux_function_clock_config_frequency(config: IomuxFunctionClockConfig) -> u32 {
3756            match config {
3757                IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3758                IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3759                IomuxFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3760            }
3761        }
3762        pub fn iomux_function_clock_frequency() -> u32 {
3763            IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3764        }
3765        pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
3766            iomux_function_clock_config_frequency(source)
3767        }
3768        pub fn configure_timg_calibration_clock(
3769            clocks: &mut ClockTree,
3770            new_selector: TimgCalibrationClockConfig,
3771        ) {
3772            let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3773            refresh_timg_calibration_clock_downstream(clocks);
3774            let active = clocks.timg_calibration_clock_refcount > 0;
3775            if active {
3776                match new_selector {
3777                    TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
3778                    TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3779                    TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3780                    #[cfg(use_xtal32k)]
3781                    TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3782                }
3783            }
3784            configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3785            if active && let Some(old_selector) = old_selector {
3786                match old_selector {
3787                    TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
3788                    TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3789                    TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3790                    #[cfg(use_xtal32k)]
3791                    TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3792                }
3793            }
3794        }
3795        pub fn timg_calibration_clock_config(
3796            clocks: &mut ClockTree,
3797        ) -> Option<TimgCalibrationClockConfig> {
3798            clocks.timg_calibration_clock
3799        }
3800        pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3801            trace!("Requesting TIMG_CALIBRATION_CLOCK");
3802            if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3803                trace!("Enabling TIMG_CALIBRATION_CLOCK");
3804                crate::rtc_cntl::WakeLock::acquire();
3805                match unwrap!(clocks.timg_calibration_clock) {
3806                    TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
3807                    TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3808                    TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3809                    #[cfg(use_xtal32k)]
3810                    TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3811                }
3812                enable_timg_calibration_clock_impl(clocks, true);
3813            }
3814        }
3815        pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3816            trace!("Releasing TIMG_CALIBRATION_CLOCK");
3817            if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3818                trace!("Disabling TIMG_CALIBRATION_CLOCK");
3819                crate::rtc_cntl::WakeLock::release();
3820                enable_timg_calibration_clock_impl(clocks, false);
3821                match unwrap!(clocks.timg_calibration_clock) {
3822                    TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
3823                    TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3824                    TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3825                    #[cfg(use_xtal32k)]
3826                    TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3827                }
3828            }
3829        }
3830        pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
3831            match config {
3832                TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
3833                TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3834                TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3835                #[cfg(use_xtal32k)]
3836                TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3837            }
3838        }
3839        pub fn timg_calibration_clock_frequency() -> u32 {
3840            TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3841        }
3842        pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3843            timg_calibration_clock_config_frequency(source)
3844        }
3845        impl AdcInstance {
3846            pub fn configure_function_clock(
3847                self,
3848                clocks: &mut ClockTree,
3849                new_selector: AdcFunctionClockConfig,
3850            ) {
3851                let old_selector = clocks.adc_function_clock[self as usize].replace(new_selector);
3852                refresh_adc_function_clock_downstream(clocks, self);
3853                let active = clocks.adc_function_clock_refcount[self as usize] > 0;
3854                if active {
3855                    match new_selector {
3856                        AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3857                        AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3858                        AdcFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3859                    }
3860                }
3861                self.configure_function_clock_impl(clocks, old_selector, new_selector);
3862                if active && let Some(old_selector) = old_selector {
3863                    match old_selector {
3864                        AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3865                        AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3866                        AdcFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3867                    }
3868                }
3869            }
3870            pub fn function_clock_config(
3871                self,
3872                clocks: &mut ClockTree,
3873            ) -> Option<AdcFunctionClockConfig> {
3874                clocks.adc_function_clock[self as usize]
3875            }
3876            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3877                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3878                if increment_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
3879                {
3880                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3881                    match unwrap!(clocks.adc_function_clock[self as usize]) {
3882                        AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3883                        AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3884                        AdcFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3885                    }
3886                    self.enable_function_clock_impl(clocks, true);
3887                }
3888            }
3889            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3890                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3891                if decrement_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
3892                {
3893                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3894                    self.enable_function_clock_impl(clocks, false);
3895                    match unwrap!(clocks.adc_function_clock[self as usize]) {
3896                        AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3897                        AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3898                        AdcFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3899                    }
3900                }
3901            }
3902            pub fn function_clock_config_frequency(config: AdcFunctionClockConfig) -> u32 {
3903                match config {
3904                    AdcFunctionClockConfig::Xtal => xtal_clk_frequency(),
3905                    AdcFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3906                    AdcFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3907                }
3908            }
3909            pub fn function_clock_frequency(self) -> u32 {
3910                ADC_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3911                    .load(::core::sync::atomic::Ordering::Acquire)
3912            }
3913            pub fn function_clock_source_frequency(source: AdcFunctionClockConfig) -> u32 {
3914                Self::function_clock_config_frequency(source)
3915            }
3916        }
3917        impl SdmInstance {
3918            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3919                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3920                if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3921                {
3922                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3923                    request_iomux_function_clock(clocks);
3924                    self.enable_function_clock_impl(clocks, true);
3925                }
3926            }
3927            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3928                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3929                if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3930                {
3931                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3932                    self.enable_function_clock_impl(clocks, false);
3933                    release_iomux_function_clock(clocks);
3934                }
3935            }
3936            pub fn function_clock_frequency(self) -> u32 {
3937                iomux_function_clock_frequency()
3938            }
3939            pub fn function_clock_source_frequency() -> u32 {
3940                iomux_function_clock_frequency()
3941            }
3942        }
3943        impl I2cInstance {
3944            pub fn configure_function_clock(
3945                self,
3946                clocks: &mut ClockTree,
3947                config: I2cFunctionClockConfig,
3948            ) {
3949                let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3950                refresh_i2c_function_clock_downstream(clocks, self);
3951                let active = clocks.i2c_function_clock_refcount[self as usize] > 0;
3952                if active {
3953                    match config.sclk {
3954                        I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3955                        I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3956                    }
3957                }
3958                self.configure_function_clock_impl(clocks, old_config, config);
3959                if active && let Some(old_config) = old_config {
3960                    match old_config.sclk {
3961                        I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3962                        I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3963                    }
3964                }
3965            }
3966            pub fn function_clock_config(
3967                self,
3968                clocks: &mut ClockTree,
3969            ) -> Option<I2cFunctionClockConfig> {
3970                clocks.i2c_function_clock[self as usize]
3971            }
3972            pub fn request_function_clock(self, clocks: &mut ClockTree) {
3973                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3974                if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3975                {
3976                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3977                    match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3978                        I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3979                        I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3980                    }
3981                    self.enable_function_clock_impl(clocks, true);
3982                }
3983            }
3984            pub fn release_function_clock(self, clocks: &mut ClockTree) {
3985                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3986                if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3987                {
3988                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3989                    self.enable_function_clock_impl(clocks, false);
3990                    match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3991                        I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3992                        I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3993                    }
3994                }
3995            }
3996            pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
3997                (match config.sclk {
3998                    I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3999                    I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4000                } / (config.div_num() + 1))
4001            }
4002            pub fn function_clock_frequency(self) -> u32 {
4003                I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4004                    .load(::core::sync::atomic::Ordering::Acquire)
4005            }
4006            pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
4007                match sclk {
4008                    I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4009                    I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4010                }
4011            }
4012        }
4013        impl I2sInstance {
4014            pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
4015                let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
4016                refresh_i2s_tx_clk_downstream(clocks, self);
4017                let active = clocks.i2s_tx_clk_refcount[self as usize] > 0;
4018                if active {
4019                    match config.sclk {
4020                        I2sClkSclk::Xtal => request_xtal_clk(clocks),
4021                        I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4022                        I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4023                    }
4024                }
4025                self.configure_tx_clk_impl(clocks, old_config, config);
4026                if active && let Some(old_config) = old_config {
4027                    match old_config.sclk {
4028                        I2sClkSclk::Xtal => release_xtal_clk(clocks),
4029                        I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4030                        I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4031                    }
4032                }
4033            }
4034            pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
4035                clocks.i2s_tx_clk[self as usize]
4036            }
4037            pub fn request_tx_clk(self, clocks: &mut ClockTree) {
4038                trace!("Requesting {:?}::TX_CLK", self);
4039                if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
4040                    trace!("Enabling {:?}::TX_CLK", self);
4041                    crate::rtc_cntl::WakeLock::acquire();
4042                    match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
4043                        I2sClkSclk::Xtal => request_xtal_clk(clocks),
4044                        I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4045                        I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4046                    }
4047                    self.enable_tx_clk_impl(clocks, true);
4048                }
4049            }
4050            pub fn release_tx_clk(self, clocks: &mut ClockTree) {
4051                trace!("Releasing {:?}::TX_CLK", self);
4052                if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
4053                    trace!("Disabling {:?}::TX_CLK", self);
4054                    crate::rtc_cntl::WakeLock::release();
4055                    self.enable_tx_clk_impl(clocks, false);
4056                    match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
4057                        I2sClkSclk::Xtal => release_xtal_clk(clocks),
4058                        I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4059                        I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4060                    }
4061                }
4062            }
4063            pub fn tx_clk_config_frequency(config: I2sClkConfig) -> u32 {
4064                (((match config.sclk {
4065                    I2sClkSclk::Xtal => xtal_clk_frequency(),
4066                    I2sClkSclk::PllF240m => pll_f240m_frequency(),
4067                    I2sClkSclk::PllF160m => pll_f160m_frequency(),
4068                } as u64)
4069                    * (config.div_a() as u64))
4070                    / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
4071                    as u32
4072            }
4073            pub fn tx_clk_frequency(self) -> u32 {
4074                I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4075            }
4076            pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
4077                match sclk {
4078                    I2sClkSclk::Xtal => xtal_clk_frequency(),
4079                    I2sClkSclk::PllF240m => pll_f240m_frequency(),
4080                    I2sClkSclk::PllF160m => pll_f160m_frequency(),
4081                }
4082            }
4083            pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
4084                let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
4085                refresh_i2s_rx_clk_downstream(clocks, self);
4086                let active = clocks.i2s_rx_clk_refcount[self as usize] > 0;
4087                if active {
4088                    match config.sclk {
4089                        I2sClkSclk::Xtal => request_xtal_clk(clocks),
4090                        I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4091                        I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4092                    }
4093                }
4094                self.configure_rx_clk_impl(clocks, old_config, config);
4095                if active && let Some(old_config) = old_config {
4096                    match old_config.sclk {
4097                        I2sClkSclk::Xtal => release_xtal_clk(clocks),
4098                        I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4099                        I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4100                    }
4101                }
4102            }
4103            pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
4104                clocks.i2s_rx_clk[self as usize]
4105            }
4106            pub fn request_rx_clk(self, clocks: &mut ClockTree) {
4107                trace!("Requesting {:?}::RX_CLK", self);
4108                if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
4109                    trace!("Enabling {:?}::RX_CLK", self);
4110                    crate::rtc_cntl::WakeLock::acquire();
4111                    match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
4112                        I2sClkSclk::Xtal => request_xtal_clk(clocks),
4113                        I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4114                        I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4115                    }
4116                    self.enable_rx_clk_impl(clocks, true);
4117                }
4118            }
4119            pub fn release_rx_clk(self, clocks: &mut ClockTree) {
4120                trace!("Releasing {:?}::RX_CLK", self);
4121                if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
4122                    trace!("Disabling {:?}::RX_CLK", self);
4123                    crate::rtc_cntl::WakeLock::release();
4124                    self.enable_rx_clk_impl(clocks, false);
4125                    match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
4126                        I2sClkSclk::Xtal => release_xtal_clk(clocks),
4127                        I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4128                        I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4129                    }
4130                }
4131            }
4132            pub fn rx_clk_config_frequency(config: I2sClkConfig) -> u32 {
4133                (((match config.sclk {
4134                    I2sClkSclk::Xtal => xtal_clk_frequency(),
4135                    I2sClkSclk::PllF240m => pll_f240m_frequency(),
4136                    I2sClkSclk::PllF160m => pll_f160m_frequency(),
4137                } as u64)
4138                    * (config.div_a() as u64))
4139                    / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
4140                    as u32
4141            }
4142            pub fn rx_clk_frequency(self) -> u32 {
4143                I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4144            }
4145            pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
4146                match sclk {
4147                    I2sClkSclk::Xtal => xtal_clk_frequency(),
4148                    I2sClkSclk::PllF240m => pll_f240m_frequency(),
4149                    I2sClkSclk::PllF160m => pll_f160m_frequency(),
4150                }
4151            }
4152            pub fn configure_mclk_out(
4153                self,
4154                clocks: &mut ClockTree,
4155                new_selector: I2sMclkOutConfig,
4156            ) {
4157                let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
4158                refresh_i2s_mclk_out_downstream(clocks, self);
4159                let active = clocks.i2s_mclk_out_refcount[self as usize] > 0;
4160                if active {
4161                    match new_selector {
4162                        I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
4163                        I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
4164                    }
4165                }
4166                self.configure_mclk_out_impl(clocks, old_selector, new_selector);
4167                if active && let Some(old_selector) = old_selector {
4168                    match old_selector {
4169                        I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
4170                        I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
4171                    }
4172                }
4173            }
4174            pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
4175                clocks.i2s_mclk_out[self as usize]
4176            }
4177            pub fn request_mclk_out(self, clocks: &mut ClockTree) {
4178                trace!("Requesting {:?}::MCLK_OUT", self);
4179                if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
4180                    trace!("Enabling {:?}::MCLK_OUT", self);
4181                    match unwrap!(clocks.i2s_mclk_out[self as usize]) {
4182                        I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
4183                        I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
4184                    }
4185                    self.enable_mclk_out_impl(clocks, true);
4186                }
4187            }
4188            pub fn release_mclk_out(self, clocks: &mut ClockTree) {
4189                trace!("Releasing {:?}::MCLK_OUT", self);
4190                if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
4191                    trace!("Disabling {:?}::MCLK_OUT", self);
4192                    self.enable_mclk_out_impl(clocks, false);
4193                    match unwrap!(clocks.i2s_mclk_out[self as usize]) {
4194                        I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
4195                        I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
4196                    }
4197                }
4198            }
4199            pub fn mclk_out_config_frequency(self, config: I2sMclkOutConfig) -> u32 {
4200                match config {
4201                    I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
4202                    I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
4203                }
4204            }
4205            pub fn mclk_out_frequency(self) -> u32 {
4206                I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4207            }
4208        }
4209        impl ParlIoInstance {
4210            pub fn configure_rx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4211                let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
4212                refresh_parl_io_rx_clock_downstream(clocks, self);
4213                let active = clocks.parl_io_rx_clock_refcount[self as usize] > 0;
4214                if active {
4215                    match new_selector {
4216                        ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4217                        ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4218                        ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4219                    }
4220                }
4221                self.configure_rx_clock_impl(clocks, old_selector, new_selector);
4222                if active && let Some(old_selector) = old_selector {
4223                    match old_selector {
4224                        ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4225                        ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4226                        ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4227                    }
4228                }
4229            }
4230            pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4231                clocks.parl_io_rx_clock[self as usize]
4232            }
4233            pub fn request_rx_clock(self, clocks: &mut ClockTree) {
4234                trace!("Requesting {:?}::RX_CLOCK", self);
4235                if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
4236                    trace!("Enabling {:?}::RX_CLOCK", self);
4237                    match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4238                        ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4239                        ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4240                        ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4241                    }
4242                    self.enable_rx_clock_impl(clocks, true);
4243                }
4244            }
4245            pub fn release_rx_clock(self, clocks: &mut ClockTree) {
4246                trace!("Releasing {:?}::RX_CLOCK", self);
4247                if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
4248                    trace!("Disabling {:?}::RX_CLOCK", self);
4249                    self.enable_rx_clock_impl(clocks, false);
4250                    match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4251                        ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4252                        ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4253                        ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4254                    }
4255                }
4256            }
4257            pub fn rx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
4258                match config {
4259                    ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4260                    ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4261                    ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4262                }
4263            }
4264            pub fn rx_clock_frequency(self) -> u32 {
4265                PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
4266                    .load(::core::sync::atomic::Ordering::Acquire)
4267            }
4268            pub fn rx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4269                Self::rx_clock_config_frequency(source)
4270            }
4271            pub fn configure_tx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4272                let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
4273                refresh_parl_io_tx_clock_downstream(clocks, self);
4274                let active = clocks.parl_io_tx_clock_refcount[self as usize] > 0;
4275                if active {
4276                    match new_selector {
4277                        ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4278                        ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4279                        ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4280                    }
4281                }
4282                self.configure_tx_clock_impl(clocks, old_selector, new_selector);
4283                if active && let Some(old_selector) = old_selector {
4284                    match old_selector {
4285                        ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4286                        ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4287                        ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4288                    }
4289                }
4290            }
4291            pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4292                clocks.parl_io_tx_clock[self as usize]
4293            }
4294            pub fn request_tx_clock(self, clocks: &mut ClockTree) {
4295                trace!("Requesting {:?}::TX_CLOCK", self);
4296                if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4297                    trace!("Enabling {:?}::TX_CLOCK", self);
4298                    match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4299                        ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4300                        ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4301                        ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4302                    }
4303                    self.enable_tx_clock_impl(clocks, true);
4304                }
4305            }
4306            pub fn release_tx_clock(self, clocks: &mut ClockTree) {
4307                trace!("Releasing {:?}::TX_CLOCK", self);
4308                if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4309                    trace!("Disabling {:?}::TX_CLOCK", self);
4310                    self.enable_tx_clock_impl(clocks, false);
4311                    match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4312                        ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4313                        ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4314                        ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4315                    }
4316                }
4317            }
4318            pub fn tx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
4319                match config {
4320                    ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4321                    ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4322                    ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4323                }
4324            }
4325            pub fn tx_clock_frequency(self) -> u32 {
4326                PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
4327                    .load(::core::sync::atomic::Ordering::Acquire)
4328            }
4329            pub fn tx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4330                Self::tx_clock_config_frequency(source)
4331            }
4332        }
4333        impl PcntInstance {
4334            pub fn request_function_clock(self, clocks: &mut ClockTree) {
4335                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4336                if increment_reference_count(
4337                    &mut clocks.pcnt_function_clock_refcount[self as usize],
4338                ) {
4339                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4340                    request_apb_clk(clocks);
4341                    self.enable_function_clock_impl(clocks, true);
4342                }
4343            }
4344            pub fn release_function_clock(self, clocks: &mut ClockTree) {
4345                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4346                if decrement_reference_count(
4347                    &mut clocks.pcnt_function_clock_refcount[self as usize],
4348                ) {
4349                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4350                    self.enable_function_clock_impl(clocks, false);
4351                    release_apb_clk(clocks);
4352                }
4353            }
4354            pub fn function_clock_frequency(self) -> u32 {
4355                apb_clk_frequency()
4356            }
4357            pub fn function_clock_source_frequency() -> u32 {
4358                apb_clk_frequency()
4359            }
4360        }
4361        impl RmtInstance {
4362            pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
4363                let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
4364                refresh_rmt_sclk_downstream(clocks, self);
4365                let active = clocks.rmt_sclk_refcount[self as usize] > 0;
4366                if active {
4367                    match new_selector {
4368                        RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4369                        RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4370                        RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
4371                    }
4372                }
4373                self.configure_sclk_impl(clocks, old_selector, new_selector);
4374                if active && let Some(old_selector) = old_selector {
4375                    match old_selector {
4376                        RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4377                        RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4378                        RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
4379                    }
4380                }
4381            }
4382            pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
4383                clocks.rmt_sclk[self as usize]
4384            }
4385            pub fn request_sclk(self, clocks: &mut ClockTree) {
4386                trace!("Requesting {:?}::SCLK", self);
4387                if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4388                    trace!("Enabling {:?}::SCLK", self);
4389                    match unwrap!(clocks.rmt_sclk[self as usize]) {
4390                        RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4391                        RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4392                        RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
4393                    }
4394                    self.enable_sclk_impl(clocks, true);
4395                }
4396            }
4397            pub fn release_sclk(self, clocks: &mut ClockTree) {
4398                trace!("Releasing {:?}::SCLK", self);
4399                if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4400                    trace!("Disabling {:?}::SCLK", self);
4401                    self.enable_sclk_impl(clocks, false);
4402                    match unwrap!(clocks.rmt_sclk[self as usize]) {
4403                        RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4404                        RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4405                        RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
4406                    }
4407                }
4408            }
4409            pub fn sclk_config_frequency(config: RmtSclkConfig) -> u32 {
4410                match config {
4411                    RmtSclkConfig::XtalClk => xtal_clk_frequency(),
4412                    RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4413                    RmtSclkConfig::PllF80m => pll_f80m_frequency(),
4414                }
4415            }
4416            pub fn sclk_frequency(self) -> u32 {
4417                RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4418            }
4419            pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
4420                Self::sclk_config_frequency(source)
4421            }
4422        }
4423        impl SpiInstance {
4424            pub fn configure_function_clock(
4425                self,
4426                clocks: &mut ClockTree,
4427                new_selector: SpiFunctionClockConfig,
4428            ) {
4429                let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
4430                refresh_spi_function_clock_downstream(clocks, self);
4431                let active = clocks.spi_function_clock_refcount[self as usize] > 0;
4432                if active {
4433                    match new_selector {
4434                        SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4435                        SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
4436                        SpiFunctionClockConfig::PllF120m => request_pll_f120m(clocks),
4437                        SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4438                    }
4439                }
4440                self.configure_function_clock_impl(clocks, old_selector, new_selector);
4441                if active && let Some(old_selector) = old_selector {
4442                    match old_selector {
4443                        SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4444                        SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
4445                        SpiFunctionClockConfig::PllF120m => release_pll_f120m(clocks),
4446                        SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4447                    }
4448                }
4449            }
4450            pub fn function_clock_config(
4451                self,
4452                clocks: &mut ClockTree,
4453            ) -> Option<SpiFunctionClockConfig> {
4454                clocks.spi_function_clock[self as usize]
4455            }
4456            pub fn request_function_clock(self, clocks: &mut ClockTree) {
4457                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4458                if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
4459                {
4460                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4461                    match unwrap!(clocks.spi_function_clock[self as usize]) {
4462                        SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4463                        SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
4464                        SpiFunctionClockConfig::PllF120m => request_pll_f120m(clocks),
4465                        SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4466                    }
4467                    self.enable_function_clock_impl(clocks, true);
4468                }
4469            }
4470            pub fn release_function_clock(self, clocks: &mut ClockTree) {
4471                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4472                if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
4473                {
4474                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4475                    self.enable_function_clock_impl(clocks, false);
4476                    match unwrap!(clocks.spi_function_clock[self as usize]) {
4477                        SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4478                        SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
4479                        SpiFunctionClockConfig::PllF120m => release_pll_f120m(clocks),
4480                        SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4481                    }
4482                }
4483            }
4484            pub fn function_clock_config_frequency(config: SpiFunctionClockConfig) -> u32 {
4485                match config {
4486                    SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
4487                    SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
4488                    SpiFunctionClockConfig::PllF120m => pll_f120m_frequency(),
4489                    SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
4490                }
4491            }
4492            pub fn function_clock_frequency(self) -> u32 {
4493                SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4494                    .load(::core::sync::atomic::Ordering::Acquire)
4495            }
4496            pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
4497                Self::function_clock_config_frequency(source)
4498            }
4499        }
4500        impl TimgInstance {
4501            pub fn configure_function_clock(
4502                self,
4503                clocks: &mut ClockTree,
4504                new_selector: TimgFunctionClockConfig,
4505            ) {
4506                let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
4507                refresh_timg_function_clock_downstream(clocks, self);
4508                let active = clocks.timg_function_clock_refcount[self as usize] > 0;
4509                if active {
4510                    match new_selector {
4511                        TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4512                        TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4513                        TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4514                    }
4515                }
4516                self.configure_function_clock_impl(clocks, old_selector, new_selector);
4517                if active && let Some(old_selector) = old_selector {
4518                    match old_selector {
4519                        TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4520                        TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4521                        TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4522                    }
4523                }
4524            }
4525            pub fn function_clock_config(
4526                self,
4527                clocks: &mut ClockTree,
4528            ) -> Option<TimgFunctionClockConfig> {
4529                clocks.timg_function_clock[self as usize]
4530            }
4531            pub fn request_function_clock(self, clocks: &mut ClockTree) {
4532                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4533                if increment_reference_count(
4534                    &mut clocks.timg_function_clock_refcount[self as usize],
4535                ) {
4536                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4537                    match unwrap!(clocks.timg_function_clock[self as usize]) {
4538                        TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4539                        TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4540                        TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4541                    }
4542                    self.enable_function_clock_impl(clocks, true);
4543                }
4544            }
4545            pub fn release_function_clock(self, clocks: &mut ClockTree) {
4546                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4547                if decrement_reference_count(
4548                    &mut clocks.timg_function_clock_refcount[self as usize],
4549                ) {
4550                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4551                    self.enable_function_clock_impl(clocks, false);
4552                    match unwrap!(clocks.timg_function_clock[self as usize]) {
4553                        TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4554                        TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4555                        TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4556                    }
4557                }
4558            }
4559            pub fn function_clock_config_frequency(config: TimgFunctionClockConfig) -> u32 {
4560                match config {
4561                    TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4562                    TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4563                    TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4564                }
4565            }
4566            pub fn function_clock_frequency(self) -> u32 {
4567                TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4568                    .load(::core::sync::atomic::Ordering::Acquire)
4569            }
4570            pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
4571                Self::function_clock_config_frequency(source)
4572            }
4573            pub fn configure_wdt_clock(
4574                self,
4575                clocks: &mut ClockTree,
4576                new_selector: TimgWdtClockConfig,
4577            ) {
4578                let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
4579                refresh_timg_wdt_clock_downstream(clocks, self);
4580                let active = clocks.timg_wdt_clock_refcount[self as usize] > 0;
4581                if active {
4582                    match new_selector {
4583                        TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
4584                        TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
4585                        TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4586                    }
4587                }
4588                self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
4589                if active && let Some(old_selector) = old_selector {
4590                    match old_selector {
4591                        TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
4592                        TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
4593                        TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4594                    }
4595                }
4596            }
4597            pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
4598                clocks.timg_wdt_clock[self as usize]
4599            }
4600            pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
4601                trace!("Requesting {:?}::WDT_CLOCK", self);
4602                if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
4603                    trace!("Enabling {:?}::WDT_CLOCK", self);
4604                    match unwrap!(clocks.timg_wdt_clock[self as usize]) {
4605                        TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
4606                        TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
4607                        TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4608                    }
4609                    self.enable_wdt_clock_impl(clocks, true);
4610                }
4611            }
4612            pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
4613                trace!("Releasing {:?}::WDT_CLOCK", self);
4614                if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
4615                    trace!("Disabling {:?}::WDT_CLOCK", self);
4616                    self.enable_wdt_clock_impl(clocks, false);
4617                    match unwrap!(clocks.timg_wdt_clock[self as usize]) {
4618                        TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
4619                        TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
4620                        TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4621                    }
4622                }
4623            }
4624            pub fn wdt_clock_config_frequency(config: TimgWdtClockConfig) -> u32 {
4625                match config {
4626                    TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
4627                    TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
4628                    TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
4629                }
4630            }
4631            pub fn wdt_clock_frequency(self) -> u32 {
4632                TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
4633                    .load(::core::sync::atomic::Ordering::Acquire)
4634            }
4635            pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
4636                Self::wdt_clock_config_frequency(source)
4637            }
4638        }
4639        impl TwaiInstance {
4640            pub fn configure_function_clock(
4641                self,
4642                clocks: &mut ClockTree,
4643                new_selector: TwaiFunctionClockConfig,
4644            ) {
4645                let old_selector = clocks.twai_function_clock[self as usize].replace(new_selector);
4646                refresh_twai_function_clock_downstream(clocks, self);
4647                let active = clocks.twai_function_clock_refcount[self as usize] > 0;
4648                if active {
4649                    match new_selector {
4650                        TwaiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4651                        TwaiFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4652                    }
4653                }
4654                self.configure_function_clock_impl(clocks, old_selector, new_selector);
4655                if active && let Some(old_selector) = old_selector {
4656                    match old_selector {
4657                        TwaiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4658                        TwaiFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4659                    }
4660                }
4661            }
4662            pub fn function_clock_config(
4663                self,
4664                clocks: &mut ClockTree,
4665            ) -> Option<TwaiFunctionClockConfig> {
4666                clocks.twai_function_clock[self as usize]
4667            }
4668            pub fn request_function_clock(self, clocks: &mut ClockTree) {
4669                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4670                if increment_reference_count(
4671                    &mut clocks.twai_function_clock_refcount[self as usize],
4672                ) {
4673                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4674                    match unwrap!(clocks.twai_function_clock[self as usize]) {
4675                        TwaiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4676                        TwaiFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4677                    }
4678                    self.enable_function_clock_impl(clocks, true);
4679                }
4680            }
4681            pub fn release_function_clock(self, clocks: &mut ClockTree) {
4682                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4683                if decrement_reference_count(
4684                    &mut clocks.twai_function_clock_refcount[self as usize],
4685                ) {
4686                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4687                    self.enable_function_clock_impl(clocks, false);
4688                    match unwrap!(clocks.twai_function_clock[self as usize]) {
4689                        TwaiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4690                        TwaiFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4691                    }
4692                }
4693            }
4694            pub fn function_clock_config_frequency(config: TwaiFunctionClockConfig) -> u32 {
4695                match config {
4696                    TwaiFunctionClockConfig::Xtal => xtal_clk_frequency(),
4697                    TwaiFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4698                }
4699            }
4700            pub fn function_clock_frequency(self) -> u32 {
4701                TWAI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4702                    .load(::core::sync::atomic::Ordering::Acquire)
4703            }
4704            pub fn function_clock_source_frequency(source: TwaiFunctionClockConfig) -> u32 {
4705                Self::function_clock_config_frequency(source)
4706            }
4707        }
4708        impl UartInstance {
4709            pub fn configure_function_clock(
4710                self,
4711                clocks: &mut ClockTree,
4712                config: UartFunctionClockConfig,
4713            ) {
4714                let old_config = clocks.uart_function_clock[self as usize].replace(config);
4715                refresh_uart_function_clock_downstream(clocks, self);
4716                let active = clocks.uart_function_clock_refcount[self as usize] > 0;
4717                if active {
4718                    match config.sclk {
4719                        UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4720                        UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
4721                        UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4722                    }
4723                }
4724                self.configure_function_clock_impl(clocks, old_config, config);
4725                if active && let Some(old_config) = old_config {
4726                    match old_config.sclk {
4727                        UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4728                        UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
4729                        UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4730                    }
4731                }
4732            }
4733            pub fn function_clock_config(
4734                self,
4735                clocks: &mut ClockTree,
4736            ) -> Option<UartFunctionClockConfig> {
4737                clocks.uart_function_clock[self as usize]
4738            }
4739            pub fn request_function_clock(self, clocks: &mut ClockTree) {
4740                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4741                if increment_reference_count(
4742                    &mut clocks.uart_function_clock_refcount[self as usize],
4743                ) {
4744                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4745                    match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
4746                        UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4747                        UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
4748                        UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4749                    }
4750                    self.enable_function_clock_impl(clocks, true);
4751                }
4752            }
4753            pub fn release_function_clock(self, clocks: &mut ClockTree) {
4754                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4755                if decrement_reference_count(
4756                    &mut clocks.uart_function_clock_refcount[self as usize],
4757                ) {
4758                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4759                    self.enable_function_clock_impl(clocks, false);
4760                    match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
4761                        UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4762                        UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
4763                        UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4764                    }
4765                }
4766            }
4767            pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
4768                (match config.sclk {
4769                    UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
4770                    UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
4771                    UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4772                } / (config.div_num() + 1))
4773            }
4774            pub fn function_clock_frequency(self) -> u32 {
4775                UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4776                    .load(::core::sync::atomic::Ordering::Acquire)
4777            }
4778            pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
4779                match sclk {
4780                    UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
4781                    UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
4782                    UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4783                }
4784            }
4785            pub fn configure_baud_rate_generator(
4786                self,
4787                clocks: &mut ClockTree,
4788                config: UartBaudRateGeneratorConfig,
4789            ) {
4790                let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
4791                refresh_uart_baud_rate_generator_downstream(clocks, self);
4792                self.configure_baud_rate_generator_impl(clocks, old_config, config);
4793            }
4794            pub fn baud_rate_generator_config(
4795                self,
4796                clocks: &mut ClockTree,
4797            ) -> Option<UartBaudRateGeneratorConfig> {
4798                clocks.uart_baud_rate_generator[self as usize]
4799            }
4800            pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
4801                trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
4802                if increment_reference_count(
4803                    &mut clocks.uart_baud_rate_generator_refcount[self as usize],
4804                ) {
4805                    trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
4806                    self.request_function_clock(clocks);
4807                    self.enable_baud_rate_generator_impl(clocks, true);
4808                }
4809            }
4810            pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
4811                trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
4812                if decrement_reference_count(
4813                    &mut clocks.uart_baud_rate_generator_refcount[self as usize],
4814                ) {
4815                    trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
4816                    self.enable_baud_rate_generator_impl(clocks, false);
4817                    self.release_function_clock(clocks);
4818                }
4819            }
4820            pub fn baud_rate_generator_config_frequency(
4821                self,
4822                config: UartBaudRateGeneratorConfig,
4823            ) -> u32 {
4824                ((self.function_clock_frequency() * 16)
4825                    / ((config.integral() * 16) + config.fractional()))
4826            }
4827            pub fn baud_rate_generator_frequency(self) -> u32 {
4828                UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
4829                    .load(::core::sync::atomic::Ordering::Acquire)
4830            }
4831        }
4832        /// Clock tree configuration.
4833        ///
4834        /// The fields of this struct are optional, with the following caveats:
4835        /// - If `XTAL_CLK` is not specified, the crystal frequency will be automatically detected
4836        ///   if possible.
4837        /// - The CPU and its upstream clock nodes will be set to a default configuration.
4838        /// - Other unspecified clock sources will not be useable by peripherals.
4839        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4840        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4841        #[instability::unstable]
4842        pub struct ClockConfig {
4843            /// `XTAL_CLK` configuration.
4844            pub xtal_clk: Option<XtalClkConfig>,
4845            /// `HP_ROOT_CLK` configuration.
4846            pub hp_root_clk: Option<HpRootClkConfig>,
4847            /// `CPU_CLK` configuration.
4848            pub cpu_clk: Option<CpuClkConfig>,
4849            /// `AHB_CLK` configuration.
4850            pub ahb_clk: Option<AhbClkConfig>,
4851            /// `APB_CLK` configuration.
4852            pub apb_clk: Option<ApbClkConfig>,
4853            /// `LP_FAST_CLK` configuration.
4854            pub lp_fast_clk: Option<LpFastClkConfig>,
4855            /// `LP_SLOW_CLK` configuration.
4856            pub lp_slow_clk: Option<LpSlowClkConfig>,
4857            /// `BLE_LP_CLK` configuration.
4858            pub ble_lp_clk: Option<BleLpClkConfig>,
4859            /// `CRYPTO_CLK` configuration.
4860            pub crypto_clk: Option<CryptoClkConfig>,
4861            /// `IOMUX_FUNCTION_CLOCK` configuration.
4862            pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
4863            /// `TIMG_CALIBRATION_CLOCK` configuration.
4864            pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
4865        }
4866        impl ClockConfig {
4867            fn apply(&self, clocks: &mut ClockTree) {
4868                if let Some(config) = self.xtal_clk {
4869                    configure_xtal_clk(clocks, config);
4870                }
4871                if let Some(config) = self.hp_root_clk {
4872                    configure_hp_root_clk(clocks, config);
4873                }
4874                if let Some(config) = self.cpu_clk {
4875                    configure_cpu_clk(clocks, config);
4876                }
4877                if let Some(config) = self.ahb_clk {
4878                    configure_ahb_clk(clocks, config);
4879                }
4880                if let Some(config) = self.apb_clk {
4881                    configure_apb_clk(clocks, config);
4882                }
4883                if let Some(config) = self.lp_fast_clk {
4884                    configure_lp_fast_clk(clocks, config);
4885                }
4886                if let Some(config) = self.lp_slow_clk {
4887                    configure_lp_slow_clk(clocks, config);
4888                }
4889                if let Some(config) = self.ble_lp_clk {
4890                    configure_ble_lp_clk(clocks, config);
4891                }
4892                if let Some(config) = self.crypto_clk {
4893                    configure_crypto_clk(clocks, config);
4894                }
4895                if let Some(config) = self.iomux_function_clock {
4896                    configure_iomux_function_clock(clocks, config);
4897                }
4898                if let Some(config) = self.timg_calibration_clock {
4899                    configure_timg_calibration_clock(clocks, config);
4900                }
4901            }
4902        }
4903        fn increment_reference_count(refcount: &mut u32) -> bool {
4904            let first = *refcount == 0;
4905            *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
4906            first
4907        }
4908        fn decrement_reference_count(refcount: &mut u32) -> bool {
4909            *refcount = refcount.saturating_sub(1);
4910            let last = *refcount == 0;
4911            last
4912        }
4913        fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
4914            if let Some(config) = clocks.xtal_clk {
4915                XTAL_CLK_FREQ_CACHE.store(
4916                    xtal_clk_config_frequency(config),
4917                    ::core::sync::atomic::Ordering::Release,
4918                );
4919            }
4920            refresh_hp_root_clk_downstream(clocks);
4921            refresh_lp_fast_clk_downstream(clocks);
4922            refresh_ble_lp_clk_downstream(clocks);
4923            refresh_crypto_clk_downstream(clocks);
4924            refresh_iomux_function_clock_downstream(clocks);
4925            for child_instance in [AdcInstance::ApbSaradc] {
4926                refresh_adc_function_clock_downstream(clocks, child_instance);
4927            }
4928            for child_instance in [I2cInstance::I2c0] {
4929                refresh_i2c_function_clock_downstream(clocks, child_instance);
4930            }
4931            for child_instance in [I2sInstance::I2s0] {
4932                refresh_i2s_tx_clk_downstream(clocks, child_instance);
4933                refresh_i2s_rx_clk_downstream(clocks, child_instance);
4934            }
4935            for child_instance in [ParlIoInstance::ParlIo] {
4936                refresh_parl_io_rx_clock_downstream(clocks, child_instance);
4937                refresh_parl_io_tx_clock_downstream(clocks, child_instance);
4938            }
4939            for child_instance in [RmtInstance::Rmt] {
4940                refresh_rmt_sclk_downstream(clocks, child_instance);
4941            }
4942            for child_instance in [SpiInstance::Spi2] {
4943                refresh_spi_function_clock_downstream(clocks, child_instance);
4944            }
4945            for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
4946                refresh_timg_function_clock_downstream(clocks, child_instance);
4947                refresh_timg_wdt_clock_downstream(clocks, child_instance);
4948            }
4949            for child_instance in [TwaiInstance::Twai0, TwaiInstance::Twai1] {
4950                refresh_twai_function_clock_downstream(clocks, child_instance);
4951            }
4952            for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4953                refresh_uart_function_clock_downstream(clocks, child_instance);
4954            }
4955        }
4956        fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
4957            refresh_hp_root_clk_downstream(clocks);
4958            refresh_lp_fast_clk_downstream(clocks);
4959            refresh_crypto_clk_downstream(clocks);
4960            refresh_iomux_function_clock_downstream(clocks);
4961            refresh_timg_calibration_clock_downstream(clocks);
4962            for child_instance in [AdcInstance::ApbSaradc] {
4963                refresh_adc_function_clock_downstream(clocks, child_instance);
4964            }
4965            for child_instance in [I2cInstance::I2c0] {
4966                refresh_i2c_function_clock_downstream(clocks, child_instance);
4967            }
4968            for child_instance in [ParlIoInstance::ParlIo] {
4969                refresh_parl_io_rx_clock_downstream(clocks, child_instance);
4970                refresh_parl_io_tx_clock_downstream(clocks, child_instance);
4971            }
4972            for child_instance in [RmtInstance::Rmt] {
4973                refresh_rmt_sclk_downstream(clocks, child_instance);
4974            }
4975            for child_instance in [SpiInstance::Spi2] {
4976                refresh_spi_function_clock_downstream(clocks, child_instance);
4977            }
4978            for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
4979                refresh_timg_function_clock_downstream(clocks, child_instance);
4980                refresh_timg_wdt_clock_downstream(clocks, child_instance);
4981            }
4982            for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4983                refresh_uart_function_clock_downstream(clocks, child_instance);
4984            }
4985        }
4986        fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
4987            refresh_lp_slow_clk_downstream(clocks);
4988            refresh_ble_lp_clk_downstream(clocks);
4989            refresh_timg_calibration_clock_downstream(clocks);
4990        }
4991        fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
4992            if let Some(config) = clocks.hp_root_clk {
4993                HP_ROOT_CLK_FREQ_CACHE.store(
4994                    hp_root_clk_config_frequency(config),
4995                    ::core::sync::atomic::Ordering::Release,
4996                );
4997            }
4998            refresh_cpu_clk_downstream(clocks);
4999            refresh_ahb_clk_downstream(clocks);
5000        }
5001        fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
5002            if let Some(config) = clocks.cpu_clk {
5003                CPU_CLK_FREQ_CACHE.store(
5004                    cpu_clk_config_frequency(config),
5005                    ::core::sync::atomic::Ordering::Release,
5006                );
5007            }
5008        }
5009        fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
5010            if let Some(config) = clocks.ahb_clk {
5011                AHB_CLK_FREQ_CACHE.store(
5012                    ahb_clk_config_frequency(config),
5013                    ::core::sync::atomic::Ordering::Release,
5014                );
5015            }
5016            refresh_apb_clk_downstream(clocks);
5017        }
5018        fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
5019            if let Some(config) = clocks.apb_clk {
5020                APB_CLK_FREQ_CACHE.store(
5021                    apb_clk_config_frequency(config),
5022                    ::core::sync::atomic::Ordering::Release,
5023                );
5024            }
5025        }
5026        fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
5027            if let Some(config) = clocks.lp_fast_clk {
5028                LP_FAST_CLK_FREQ_CACHE.store(
5029                    lp_fast_clk_config_frequency(config),
5030                    ::core::sync::atomic::Ordering::Release,
5031                );
5032            }
5033        }
5034        fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
5035            if let Some(config) = clocks.lp_slow_clk {
5036                LP_SLOW_CLK_FREQ_CACHE.store(
5037                    lp_slow_clk_config_frequency(config),
5038                    ::core::sync::atomic::Ordering::Release,
5039                );
5040            }
5041        }
5042        fn refresh_ble_lp_clk_downstream(clocks: &mut ClockTree) {
5043            if let Some(config) = clocks.ble_lp_clk {
5044                BLE_LP_CLK_FREQ_CACHE.store(
5045                    ble_lp_clk_config_frequency(config),
5046                    ::core::sync::atomic::Ordering::Release,
5047                );
5048            }
5049        }
5050        fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
5051            if let Some(config) = clocks.crypto_clk {
5052                CRYPTO_CLK_FREQ_CACHE.store(
5053                    crypto_clk_config_frequency(config),
5054                    ::core::sync::atomic::Ordering::Release,
5055                );
5056            }
5057        }
5058        fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
5059            if let Some(config) = clocks.iomux_function_clock {
5060                IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
5061                    iomux_function_clock_config_frequency(config),
5062                    ::core::sync::atomic::Ordering::Release,
5063                );
5064            }
5065        }
5066        fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
5067            if let Some(config) = clocks.timg_calibration_clock {
5068                TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
5069                    timg_calibration_clock_config_frequency(config),
5070                    ::core::sync::atomic::Ordering::Release,
5071                );
5072            }
5073        }
5074        fn refresh_adc_function_clock_downstream(clocks: &mut ClockTree, instance: AdcInstance) {
5075            if let Some(config) = clocks.adc_function_clock[instance as usize] {
5076                ADC_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5077                    AdcInstance::function_clock_config_frequency(config),
5078                    ::core::sync::atomic::Ordering::Release,
5079                );
5080            }
5081        }
5082        fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
5083            if let Some(config) = clocks.i2c_function_clock[instance as usize] {
5084                I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5085                    I2cInstance::function_clock_config_frequency(config),
5086                    ::core::sync::atomic::Ordering::Release,
5087                );
5088            }
5089        }
5090        fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5091            if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
5092                I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
5093                    I2sInstance::tx_clk_config_frequency(config),
5094                    ::core::sync::atomic::Ordering::Release,
5095                );
5096            }
5097            refresh_i2s_mclk_out_downstream(clocks, instance);
5098        }
5099        fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5100            if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
5101                I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
5102                    I2sInstance::rx_clk_config_frequency(config),
5103                    ::core::sync::atomic::Ordering::Release,
5104                );
5105            }
5106            refresh_i2s_mclk_out_downstream(clocks, instance);
5107        }
5108        fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5109            if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
5110                I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
5111                    instance.mclk_out_config_frequency(config),
5112                    ::core::sync::atomic::Ordering::Release,
5113                );
5114            }
5115        }
5116        fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
5117            if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
5118                PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
5119                    ParlIoInstance::rx_clock_config_frequency(config),
5120                    ::core::sync::atomic::Ordering::Release,
5121                );
5122            }
5123        }
5124        fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
5125            if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
5126                PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
5127                    ParlIoInstance::tx_clock_config_frequency(config),
5128                    ::core::sync::atomic::Ordering::Release,
5129                );
5130            }
5131        }
5132        fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
5133            if let Some(config) = clocks.rmt_sclk[instance as usize] {
5134                RMT_SCLK_FREQ_CACHE[instance as usize].store(
5135                    RmtInstance::sclk_config_frequency(config),
5136                    ::core::sync::atomic::Ordering::Release,
5137                );
5138            }
5139        }
5140        fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
5141            if let Some(config) = clocks.spi_function_clock[instance as usize] {
5142                SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5143                    SpiInstance::function_clock_config_frequency(config),
5144                    ::core::sync::atomic::Ordering::Release,
5145                );
5146            }
5147        }
5148        fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
5149            if let Some(config) = clocks.timg_function_clock[instance as usize] {
5150                TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5151                    TimgInstance::function_clock_config_frequency(config),
5152                    ::core::sync::atomic::Ordering::Release,
5153                );
5154            }
5155        }
5156        fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
5157            if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
5158                TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
5159                    TimgInstance::wdt_clock_config_frequency(config),
5160                    ::core::sync::atomic::Ordering::Release,
5161                );
5162            }
5163        }
5164        fn refresh_twai_function_clock_downstream(clocks: &mut ClockTree, instance: TwaiInstance) {
5165            if let Some(config) = clocks.twai_function_clock[instance as usize] {
5166                TWAI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5167                    TwaiInstance::function_clock_config_frequency(config),
5168                    ::core::sync::atomic::Ordering::Release,
5169                );
5170            }
5171        }
5172        fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
5173            if let Some(config) = clocks.uart_function_clock[instance as usize] {
5174                UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5175                    UartInstance::function_clock_config_frequency(config),
5176                    ::core::sync::atomic::Ordering::Release,
5177                );
5178            }
5179            refresh_uart_baud_rate_generator_downstream(clocks, instance);
5180        }
5181        fn refresh_uart_baud_rate_generator_downstream(
5182            clocks: &mut ClockTree,
5183            instance: UartInstance,
5184        ) {
5185            if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
5186                UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
5187                    instance.baud_rate_generator_config_frequency(config),
5188                    ::core::sync::atomic::Ordering::Release,
5189                );
5190            }
5191        }
5192    };
5193}
5194/// Implement the `Peripheral` enum and enable/disable/reset functions.
5195///
5196/// This macro is intended to be placed in `esp_hal::system`.
5197#[macro_export]
5198#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5199macro_rules! implement_peripheral_clocks {
5200    () => {
5201        #[doc(hidden)]
5202        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5203        #[repr(u8)]
5204        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5205        pub enum Peripheral {
5206            /// AES peripheral clock signal
5207            Aes,
5208            /// AHB_GDMA peripheral clock signal
5209            AhbGdma,
5210            /// APB_SAR_ADC peripheral clock signal
5211            ApbSarAdc,
5212            /// ECC peripheral clock signal
5213            Ecc,
5214            /// GPIO_SD peripheral clock signal
5215            GpioSd,
5216            /// I2C_EXT0 peripheral clock signal
5217            I2cExt0,
5218            /// I2S0 peripheral clock signal
5219            I2s0,
5220            /// PARL_IO peripheral clock signal
5221            ParlIo,
5222            /// PCNT peripheral clock signal
5223            Pcnt,
5224            /// RMT peripheral clock signal
5225            Rmt,
5226            /// RSA peripheral clock signal
5227            Rsa,
5228            /// SHA peripheral clock signal
5229            Sha,
5230            /// SPI2 peripheral clock signal
5231            Spi2,
5232            /// SYSTIMER peripheral clock signal
5233            Systimer,
5234            /// TIMG0 peripheral clock signal
5235            Timg0,
5236            /// TIMG1 peripheral clock signal
5237            Timg1,
5238            /// TWAI0 peripheral clock signal
5239            Twai0,
5240            /// TWAI1 peripheral clock signal
5241            Twai1,
5242            /// UART0 peripheral clock signal
5243            Uart0,
5244            /// UART1 peripheral clock signal
5245            Uart1,
5246            /// UHCI0 peripheral clock signal
5247            Uhci0,
5248            /// USB_DEVICE peripheral clock signal
5249            UsbDevice,
5250        }
5251        impl Peripheral {
5252            const KEEP_ENABLED: &[Peripheral] = &[
5253                Self::ApbSarAdc,
5254                Self::Systimer,
5255                Self::Timg0,
5256                Self::Uart0,
5257                Self::UsbDevice,
5258            ];
5259            const COUNT: usize = Self::ALL.len();
5260            const ALL: &[Self] = &[
5261                Self::Aes,
5262                Self::AhbGdma,
5263                Self::ApbSarAdc,
5264                Self::Ecc,
5265                Self::GpioSd,
5266                Self::I2cExt0,
5267                Self::I2s0,
5268                Self::ParlIo,
5269                Self::Pcnt,
5270                Self::Rmt,
5271                Self::Rsa,
5272                Self::Sha,
5273                Self::Spi2,
5274                Self::Systimer,
5275                Self::Timg0,
5276                Self::Timg1,
5277                Self::Twai0,
5278                Self::Twai1,
5279                Self::Uart0,
5280                Self::Uart1,
5281                Self::Uhci0,
5282                Self::UsbDevice,
5283            ];
5284        }
5285        unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
5286            match peripheral {
5287                Peripheral::Aes => {
5288                    crate::peripherals::SYSTEM::regs()
5289                        .aes_conf()
5290                        .modify(|_, w| w.aes_clk_en().bit(enable));
5291                }
5292                Peripheral::AhbGdma => {
5293                    crate::peripherals::SYSTEM::regs()
5294                        .gdma_conf()
5295                        .modify(|_, w| w.gdma_clk_en().bit(enable));
5296                }
5297                Peripheral::ApbSarAdc => {
5298                    crate::peripherals::SYSTEM::regs()
5299                        .saradc_conf()
5300                        .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
5301                }
5302                Peripheral::Ecc => {
5303                    crate::peripherals::SYSTEM::regs()
5304                        .ecc_conf()
5305                        .modify(|_, w| w.ecc_clk_en().bit(enable));
5306                }
5307                Peripheral::GpioSd => {
5308                    crate::peripherals::GPIO_SD::regs()
5309                        .clock_gate()
5310                        .modify(|_, w| w.clk_en().bit(enable));
5311                }
5312                Peripheral::I2cExt0 => {
5313                    crate::peripherals::SYSTEM::regs()
5314                        .i2c0_conf()
5315                        .modify(|_, w| w.i2c0_clk_en().bit(enable));
5316                }
5317                Peripheral::I2s0 => {
5318                    crate::peripherals::SYSTEM::regs()
5319                        .i2s_conf()
5320                        .modify(|_, w| w.i2s_clk_en().bit(enable));
5321                }
5322                Peripheral::ParlIo => {
5323                    crate::peripherals::SYSTEM::regs()
5324                        .parl_io_conf()
5325                        .modify(|_, w| w.parl_clk_en().bit(enable));
5326                }
5327                Peripheral::Pcnt => {
5328                    crate::peripherals::SYSTEM::regs()
5329                        .pcnt_conf()
5330                        .modify(|_, w| w.pcnt_clk_en().bit(enable));
5331                }
5332                Peripheral::Rmt => {
5333                    crate::peripherals::SYSTEM::regs()
5334                        .rmt_conf()
5335                        .modify(|_, w| w.rmt_clk_en().bit(enable));
5336                }
5337                Peripheral::Rsa => {
5338                    crate::peripherals::SYSTEM::regs()
5339                        .rsa_conf()
5340                        .modify(|_, w| w.rsa_clk_en().bit(enable));
5341                }
5342                Peripheral::Sha => {
5343                    crate::peripherals::SYSTEM::regs()
5344                        .sha_conf()
5345                        .modify(|_, w| w.sha_clk_en().bit(enable));
5346                }
5347                Peripheral::Spi2 => {
5348                    crate::peripherals::SYSTEM::regs()
5349                        .spi2_conf()
5350                        .modify(|_, w| w.spi2_clk_en().bit(enable));
5351                }
5352                Peripheral::Systimer => {
5353                    crate::peripherals::SYSTEM::regs()
5354                        .systimer_conf()
5355                        .modify(|_, w| w.systimer_clk_en().bit(enable));
5356                }
5357                Peripheral::Timg0 => {
5358                    crate::peripherals::SYSTEM::regs()
5359                        .timergroup(0)
5360                        .conf()
5361                        .modify(|_, w| w.clk_en().bit(enable));
5362                }
5363                Peripheral::Timg1 => {
5364                    crate::peripherals::SYSTEM::regs()
5365                        .timergroup(1)
5366                        .conf()
5367                        .modify(|_, w| w.clk_en().bit(enable));
5368                }
5369                Peripheral::Twai0 => {
5370                    crate::peripherals::SYSTEM::regs()
5371                        .twai0_conf()
5372                        .modify(|_, w| w.twai0_clk_en().bit(enable));
5373                }
5374                Peripheral::Twai1 => {
5375                    crate::peripherals::SYSTEM::regs()
5376                        .twai1_conf()
5377                        .modify(|_, w| w.twai1_clk_en().bit(enable));
5378                }
5379                Peripheral::Uart0 => {
5380                    crate::peripherals::SYSTEM::regs()
5381                        .uart(0)
5382                        .conf()
5383                        .modify(|_, w| w.clk_en().bit(enable));
5384                }
5385                Peripheral::Uart1 => {
5386                    crate::peripherals::SYSTEM::regs()
5387                        .uart(1)
5388                        .conf()
5389                        .modify(|_, w| w.clk_en().bit(enable));
5390                }
5391                Peripheral::Uhci0 => {
5392                    crate::peripherals::SYSTEM::regs()
5393                        .uhci_conf()
5394                        .modify(|_, w| w.uhci_clk_en().bit(enable));
5395                }
5396                Peripheral::UsbDevice => {
5397                    crate::peripherals::SYSTEM::regs()
5398                        .usb_device_conf()
5399                        .modify(|_, w| w.usb_device_clk_en().bit(enable));
5400                }
5401            }
5402        }
5403        unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
5404            match peripheral {
5405                Peripheral::Aes => {
5406                    crate::peripherals::SYSTEM::regs()
5407                        .aes_conf()
5408                        .modify(|_, w| w.aes_rst_en().bit(reset));
5409                }
5410                Peripheral::AhbGdma => {
5411                    crate::peripherals::SYSTEM::regs()
5412                        .gdma_conf()
5413                        .modify(|_, w| w.gdma_rst_en().bit(reset));
5414                }
5415                Peripheral::ApbSarAdc => {
5416                    crate::peripherals::SYSTEM::regs()
5417                        .saradc_conf()
5418                        .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
5419                }
5420                Peripheral::Ecc => {
5421                    crate::peripherals::SYSTEM::regs()
5422                        .ecc_conf()
5423                        .modify(|_, w| w.ecc_rst_en().bit(reset));
5424                }
5425                Peripheral::GpioSd => {
5426                    let _ = reset;
5427                }
5428                Peripheral::I2cExt0 => {
5429                    crate::peripherals::SYSTEM::regs()
5430                        .i2c0_conf()
5431                        .modify(|_, w| w.i2c0_rst_en().bit(reset));
5432                }
5433                Peripheral::I2s0 => {
5434                    crate::peripherals::SYSTEM::regs()
5435                        .i2s_conf()
5436                        .modify(|_, w| w.i2s_rst_en().bit(reset));
5437                }
5438                Peripheral::ParlIo => {
5439                    crate::peripherals::SYSTEM::regs()
5440                        .parl_io_conf()
5441                        .modify(|_, w| w.parl_rst_en().bit(reset));
5442                }
5443                Peripheral::Pcnt => {
5444                    crate::peripherals::SYSTEM::regs()
5445                        .pcnt_conf()
5446                        .modify(|_, w| w.pcnt_rst_en().bit(reset));
5447                }
5448                Peripheral::Rmt => {
5449                    crate::peripherals::SYSTEM::regs()
5450                        .rmt_conf()
5451                        .modify(|_, w| w.rmt_rst_en().bit(reset));
5452                }
5453                Peripheral::Rsa => {
5454                    crate::peripherals::SYSTEM::regs()
5455                        .rsa_conf()
5456                        .modify(|_, w| w.rsa_rst_en().bit(reset));
5457                }
5458                Peripheral::Sha => {
5459                    crate::peripherals::SYSTEM::regs()
5460                        .sha_conf()
5461                        .modify(|_, w| w.sha_rst_en().bit(reset));
5462                }
5463                Peripheral::Spi2 => {
5464                    crate::peripherals::SYSTEM::regs()
5465                        .spi2_conf()
5466                        .modify(|_, w| w.spi2_rst_en().bit(reset));
5467                }
5468                Peripheral::Systimer => {
5469                    crate::peripherals::SYSTEM::regs()
5470                        .systimer_conf()
5471                        .modify(|_, w| w.systimer_rst_en().bit(reset));
5472                }
5473                Peripheral::Timg0 => {
5474                    crate::peripherals::SYSTEM::regs()
5475                        .timergroup(0)
5476                        .conf()
5477                        .modify(|_, w| w.rst_en().bit(reset));
5478                }
5479                Peripheral::Timg1 => {
5480                    crate::peripherals::SYSTEM::regs()
5481                        .timergroup(1)
5482                        .conf()
5483                        .modify(|_, w| w.rst_en().bit(reset));
5484                }
5485                Peripheral::Twai0 => {
5486                    crate::peripherals::SYSTEM::regs()
5487                        .twai0_conf()
5488                        .modify(|_, w| w.twai0_rst_en().bit(reset));
5489                }
5490                Peripheral::Twai1 => {
5491                    crate::peripherals::SYSTEM::regs()
5492                        .twai1_conf()
5493                        .modify(|_, w| w.twai1_rst_en().bit(reset));
5494                }
5495                Peripheral::Uart0 => {
5496                    crate::peripherals::SYSTEM::regs()
5497                        .uart(0)
5498                        .conf()
5499                        .modify(|_, w| w.rst_en().bit(reset));
5500                }
5501                Peripheral::Uart1 => {
5502                    crate::peripherals::SYSTEM::regs()
5503                        .uart(1)
5504                        .conf()
5505                        .modify(|_, w| w.rst_en().bit(reset));
5506                }
5507                Peripheral::Uhci0 => {
5508                    crate::peripherals::SYSTEM::regs()
5509                        .uhci_conf()
5510                        .modify(|_, w| w.uhci_rst_en().bit(reset));
5511                }
5512                Peripheral::UsbDevice => {
5513                    crate::peripherals::SYSTEM::regs()
5514                        .usb_device_conf()
5515                        .modify(|_, w| w.usb_device_rst_en().bit(reset));
5516                }
5517            }
5518        }
5519    };
5520}
5521/// Macro to get the address range of the given memory region.
5522///
5523/// This macro provides two syntax options for each memory region:
5524///
5525/// - `memory_range!("region_name")` returns the address range as a range expression (`start..end`).
5526/// - `memory_range!(size as str, "region_name")` returns the size of the region as a string
5527///   literal.
5528#[macro_export]
5529#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5530macro_rules! memory_range {
5531    ("DRAM") => {
5532        0x40800000..0x40860000
5533    };
5534    (size as str, "DRAM") => {
5535        "393216"
5536    };
5537    ("DRAM2_UNINIT") => {
5538        0x4084E5A0..0x4085E5A0
5539    };
5540    (size as str, "DRAM2_UNINIT") => {
5541        "65536"
5542    };
5543    ("IROM") => {
5544        0x42000000..0x44000000
5545    };
5546    (size as str, "IROM") => {
5547        "33554432"
5548    };
5549    ("DROM") => {
5550        0x42000000..0x44000000
5551    };
5552    (size as str, "DROM") => {
5553        "33554432"
5554    };
5555}
5556/// This macro can be used to generate code for each peripheral instance of the I2C master driver.
5557///
5558/// For an explanation on the general syntax, as well as usage of individual/repeated
5559/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5560///
5561/// This macro has one option for its "Individual matcher" case:
5562///
5563/// Syntax: `($id:literal, $instance:ident, $sys:ident, $scl:ident, $sda:ident)`
5564///
5565/// Macro fragments:
5566/// - `$id`: the index of the I2C instance
5567/// - `$instance`: the name of the I2C instance
5568/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5569/// - `$scl`, `$sda`: peripheral signal names.
5570///
5571/// Example data: `(0, I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)`
5572#[macro_export]
5573#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5574macro_rules! for_each_i2c_master {
5575    ($($pattern:tt => $code:tt;)*) => {
5576        macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
5577        => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
5578        I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
5579        I2CEXT0_SDA)));
5580    };
5581}
5582/// This macro can be used to generate code for each peripheral instance of the I2S driver.
5583///
5584/// For an explanation on the general syntax, as well as usage of individual/repeated
5585/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5586///
5587/// This macro has one option for its "Individual matcher" case:
5588///
5589/// Syntax: `($instance:ident, $sys:ident, $mclk:ident, $bclk:ident, $ws:ident, $bclk_rx:ident,
5590/// $ws_rx:ident, [$($dout:ident),*], [$($din:ident),*], $pdm_tx:literal, $pdm_rx:literal,
5591/// $pcm2pdm:literal, $pdm2pcm:literal)`
5592///
5593/// Macro fragments:
5594///
5595/// - `$instance`: the name of the I2S instance
5596/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5597/// - `$mclk`: the MCLK output signal (a placeholder on chips without a GPIO-matrix MCLK).
5598/// - `$bclk`, `$ws`: TX bit clock and word select output signals.
5599/// - `$bclk_rx`, `$ws_rx`: RX bit clock and word select output signals.
5600/// - `$dout`, `$din`: data-out and data-in signal names.
5601/// - `$pdm_tx`, `$pdm_rx`: whether the instance supports PDM TX/RX.
5602/// - `$pcm2pdm`, `$pdm2pcm`: whether the instance supports the hardware PCM<->PDM format conversion
5603///   filter on TX/RX.
5604///
5605/// Example data:
5606/// - `(I2S0, I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
5607///   true, true, true)`
5608#[macro_export]
5609#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5610macro_rules! for_each_i2s {
5611    ($($pattern:tt => $code:tt;)*) => {
5612        macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
5613        _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
5614        I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
5615        false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
5616        I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
5617        true, true, false)));
5618    };
5619}
5620/// This macro can be used to generate code for each peripheral instance of the UART driver.
5621///
5622/// For an explanation on the general syntax, as well as usage of individual/repeated
5623/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5624///
5625/// This macro has one option for its "Individual matcher" case:
5626///
5627/// Syntax: `($id:literal, $instance:ident, $sys:ident, $rx:ident, $tx:ident, $cts:ident,
5628/// $rts:ident)`
5629///
5630/// Macro fragments:
5631///
5632/// - `$id`: the index of the UART instance
5633/// - `$instance`: the name of the UART instance
5634/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5635/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
5636///
5637/// Example data: `(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
5638#[macro_export]
5639#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5640macro_rules! for_each_uart {
5641    ($($pattern:tt => $code:tt;)*) => {
5642        macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
5643        } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
5644        wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
5645        U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
5646        U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
5647        U1TXD, U1CTS, U1RTS, wakeup_source = true)));
5648    };
5649}
5650/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
5651///
5652/// For an explanation on the general syntax, as well as usage of individual/repeated
5653/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5654///
5655/// This macro has one option for its "Individual matcher" case:
5656///
5657/// Syntax: `($instance:ident, $sys:ident, $sclk:ident [$($cs:ident),*] [$($sio:ident),*]
5658/// $($is_qspi:literal)?)`
5659///
5660/// Macro fragments:
5661///
5662/// - `$instance`: the name of the SPI instance
5663/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5664/// - `$cs`, `$sio`: chip select and SIO signal names.
5665/// - `$is_qspi`: a `true` literal present if the SPI instance supports QSPI.
5666///
5667/// Example data:
5668/// - `(SPI2, Spi2, FSPICLK [FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ,
5669///   FSPIWP, FSPIHD, FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7], true)`
5670/// - `(SPI3, Spi3, SPI3_CLK [SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q])`
5671#[macro_export]
5672#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5673macro_rules! for_each_spi_master {
5674    ($($pattern:tt => $code:tt;)*) => {
5675        macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
5676        => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
5677        Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
5678        FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
5679        _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
5680        FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
5681    };
5682}
5683/// This macro can be used to generate code for each peripheral instance of the SPI slave driver.
5684///
5685/// For an explanation on the general syntax, as well as usage of individual/repeated
5686/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5687///
5688/// This macro has one option for its "Individual matcher" case:
5689///
5690/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, $mosi:ident, $miso:ident, $cs:ident)`
5691///
5692/// Macro fragments:
5693///
5694/// - `$instance`: the name of the SPI instance
5695/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5696/// - `$sclk`, `$mosi`, `$miso`, `$cs`: signal names.
5697///
5698/// Example data: `(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)`
5699#[macro_export]
5700#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5701macro_rules! for_each_spi_slave {
5702    ($($pattern:tt => $code:tt;)*) => {
5703        macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
5704        => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
5705        Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
5706        _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
5707        Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
5708    };
5709}
5710/// This macro can be used to generate code for each PCNT unit.
5711///
5712/// For an explanation on the general syntax, as well as usage of individual/repeated
5713/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5714///
5715/// This macro has four options for its "Individual matcher" case:
5716///
5717/// - `names`: `($instance:ident)`
5718/// - `all`: `($peri:ident, $variant:ident, $sys:ident, $regs:ident, $unit:literal,
5719///   $interrupt:ident, $sig_ch0:ident, $sig_ch1:ident, $ctrl_ch0:ident, $ctrl_ch1:ident)`
5720/// - `interrupt`: `($interrupt:ident)` (repeated: one ident per unique IRQ)
5721/// - `regs`: `($regs:ident)` (repeated: one ident per register block)
5722///
5723/// Macro fragments:
5724///
5725/// - `$peri`: unit singleton name (`PCNT0_UNIT0`, `PCNT1_UNIT0`, …)
5726/// - `$variant`: `AnyPcntUnit` enum variant (`Pcnt0Unit0`, `Pcnt1Unit0`, …)
5727/// - `$sys`: `esp_hal::system::Peripheral` variant for clocks
5728/// - `$regs`: register-block singleton (`PCNT`, `PCNT1`)
5729/// - `$unit`: hardware unit index within that register block
5730/// - `$interrupt`: shared peripheral interrupt
5731/// - `$sig_ch0`, `$sig_ch1`, `$ctrl_ch0`, `$ctrl_ch1`: GPIO matrix input signals
5732#[macro_export]
5733#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5734macro_rules! for_each_pcnt_unit {
5735    ($($pattern:tt => $code:tt;)*) => {
5736        macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
5737        => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
5738        _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
5739        _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
5740        _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
5741        _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
5742        PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
5743        _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
5744        PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
5745        _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
5746        PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
5747        _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
5748        PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
5749        _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
5750        _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
5751        (PCNT0_UNIT3))); _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt,
5752        PCNT, 0, PCNT, PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1),
5753        (PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1,
5754        PCNT1_CTRL_CH0, PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
5755        PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3,
5756        Pcnt0Unit3, Pcnt, PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0,
5757        PCNT3_CTRL_CH1))); _for_each_inner_pcnt_unit!((interrupt(PCNT)));
5758        _for_each_inner_pcnt_unit!((regs(PCNT)));
5759    };
5760}
5761/// This macro can be used to generate code for each peripheral instance of the CAN FD driver.
5762///
5763/// For an explanation on the general syntax, as well as usage of individual/repeated
5764/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
5765///
5766/// This macro has one option for its "Individual matcher" case:
5767///
5768/// Syntax: `($instance:ident, $sys:ident, $rx:ident, $tx:ident)`
5769///
5770/// Macro fragments:
5771///
5772/// - `$instance`: the name of the CAN FD instance
5773/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
5774/// - `$rx`, `$tx`: signal names.
5775///
5776/// Example data: `(TWAI0, Twai0, TWAI0_RX, TWAI0_TX)`
5777#[macro_export]
5778#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5779macro_rules! for_each_canfd {
5780    ($($pattern:tt => $code:tt;)*) => {
5781        macro_rules! _for_each_inner_canfd { $(($pattern) => $code;)* ($other : tt) => {}
5782        } _for_each_inner_canfd!((TWAI0, Twai0, TWAI0_RX, TWAI0_TX));
5783        _for_each_inner_canfd!((TWAI1, Twai1, TWAI1_RX, TWAI1_TX));
5784        _for_each_inner_canfd!((all(TWAI0, Twai0, TWAI0_RX, TWAI0_TX), (TWAI1, Twai1,
5785        TWAI1_RX, TWAI1_TX)));
5786    };
5787}
5788#[macro_export]
5789#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5790macro_rules! for_each_peripheral {
5791    ($($pattern:tt => $code:tt;)*) => {
5792        macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
5793        => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
5794        "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
5795        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
5796        GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5797        "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5798        "<section class=\"warning\">"] #[doc =
5799        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5800        #[doc = "<ul>"] #[doc =
5801        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5802        =
5803        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5804        #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
5805        _for_each_inner_peripheral!((@ peri_type #[doc =
5806        "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5807        "<section class=\"warning\">"] #[doc =
5808        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5809        #[doc = "<ul>"] #[doc =
5810        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5811        =
5812        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5813        #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
5814        _for_each_inner_peripheral!((@ peri_type #[doc =
5815        "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5816        "<section class=\"warning\">"] #[doc =
5817        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5818        #[doc = "<ul>"] #[doc =
5819        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5820        #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
5821        _for_each_inner_peripheral!((@ peri_type #[doc =
5822        "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5823        "<section class=\"warning\">"] #[doc =
5824        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5825        #[doc = "<ul>"] #[doc =
5826        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5827        #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
5828        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO6 peripheral singleton"]
5829        GPIO6 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5830        "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5831        "<section class=\"warning\">"] #[doc =
5832        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5833        #[doc = "<ul>"] #[doc =
5834        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5835        = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
5836        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO8 peripheral singleton"]
5837        GPIO8 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5838        "GPIO9 peripheral singleton"] GPIO9 <= virtual()));
5839        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
5840        GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5841        "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5842        "<section class=\"warning\">"] #[doc =
5843        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5844        #[doc = "<ul>"] #[doc =
5845        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5846        = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
5847        _for_each_inner_peripheral!((@ peri_type #[doc =
5848        "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5849        "<section class=\"warning\">"] #[doc =
5850        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5851        #[doc = "<ul>"] #[doc =
5852        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5853        = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
5854        _for_each_inner_peripheral!((@ peri_type #[doc =
5855        "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5856        "<section class=\"warning\">"] #[doc =
5857        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5858        #[doc = "<ul>"] #[doc =
5859        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5860        #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
5861        peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
5862        #[doc = "<section class=\"warning\">"] #[doc =
5863        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5864        #[doc = "<ul>"] #[doc =
5865        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5866        #[doc = "</section>"] GPIO14 <= virtual())); _for_each_inner_peripheral!((@
5867        peri_type #[doc = "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""]
5868        #[doc = "<section class=\"warning\">"] #[doc =
5869        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5870        #[doc = "<ul>"] #[doc =
5871        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5872        "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
5873        _for_each_inner_peripheral!((@ peri_type #[doc =
5874        "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5875        "<section class=\"warning\">"] #[doc =
5876        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5877        #[doc = "<ul>"] #[doc =
5878        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5879        "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
5880        _for_each_inner_peripheral!((@ peri_type #[doc =
5881        "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5882        "<section class=\"warning\">"] #[doc =
5883        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5884        #[doc = "<ul>"] #[doc =
5885        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5886        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5887        "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
5888        _for_each_inner_peripheral!((@ peri_type #[doc =
5889        "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5890        "<section class=\"warning\">"] #[doc =
5891        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5892        #[doc = "<ul>"] #[doc =
5893        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5894        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5895        "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()));
5896        _for_each_inner_peripheral!((@ peri_type #[doc =
5897        "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5898        "<section class=\"warning\">"] #[doc =
5899        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5900        #[doc = "<ul>"] #[doc =
5901        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5902        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5903        "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()));
5904        _for_each_inner_peripheral!((@ peri_type #[doc =
5905        "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5906        "<section class=\"warning\">"] #[doc =
5907        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5908        #[doc = "<ul>"] #[doc =
5909        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5910        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5911        "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
5912        _for_each_inner_peripheral!((@ peri_type #[doc =
5913        "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5914        "<section class=\"warning\">"] #[doc =
5915        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5916        #[doc = "<ul>"] #[doc =
5917        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5918        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5919        "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
5920        _for_each_inner_peripheral!((@ peri_type #[doc =
5921        "GPIO22 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5922        "<section class=\"warning\">"] #[doc =
5923        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5924        #[doc = "<ul>"] #[doc =
5925        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5926        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5927        "</ul>"] #[doc = "</section>"] GPIO22 <= virtual()));
5928        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO23 peripheral singleton"]
5929        GPIO23 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5930        "GPIO24 peripheral singleton"] GPIO24 <= virtual()));
5931        _for_each_inner_peripheral!((@ peri_type #[doc =
5932        "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5933        "<section class=\"warning\">"] #[doc =
5934        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5935        #[doc = "<ul>"] #[doc =
5936        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5937        = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
5938        _for_each_inner_peripheral!((@ peri_type #[doc =
5939        "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5940        "<section class=\"warning\">"] #[doc =
5941        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5942        #[doc = "<ul>"] #[doc =
5943        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5944        = "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()));
5945        _for_each_inner_peripheral!((@ peri_type #[doc =
5946        "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5947        "<section class=\"warning\">"] #[doc =
5948        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5949        #[doc = "<ul>"] #[doc =
5950        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5951        = "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()));
5952        _for_each_inner_peripheral!((@ peri_type #[doc =
5953        "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5954        "<section class=\"warning\">"] #[doc =
5955        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5956        #[doc = "<ul>"] #[doc =
5957        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5958        = "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
5959        _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
5960        DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
5961        disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
5962        enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
5963        _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
5964        DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
5965        disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
5966        enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
5967        _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH2 peripheral singleton"]
5968        DMA_CH2 <= virtual(DMA_IN_CH2 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
5969        disable_dma_in_interrupt }, DMA_OUT_CH2 : { bind_dma_out_interrupt,
5970        enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
5971        _for_each_inner_peripheral!((@ peri_type #[doc =
5972        "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)));
5973        _for_each_inner_peripheral!((@ peri_type #[doc =
5974        "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
5975        _for_each_inner_peripheral!((@ peri_type #[doc =
5976        "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
5977        _for_each_inner_peripheral!((@ peri_type #[doc =
5978        "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
5979        _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
5980        SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5981        = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
5982        _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
5983        SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5984        = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
5985        _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
5986        <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5987        }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5988        "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
5989        _for_each_inner_peripheral!((@ peri_type #[doc =
5990        "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
5991        _for_each_inner_peripheral!((@ peri_type #[doc = "CACHE peripheral singleton"]
5992        CACHE <= CACHE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5993        "CLIC peripheral singleton"] CLIC <= CLIC() (unstable)));
5994        _for_each_inner_peripheral!((@ peri_type #[doc = "CLINT peripheral singleton"]
5995        CLINT <= CLINT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5996        "DMA peripheral singleton"] DMA <= DMA() (unstable)));
5997        _for_each_inner_peripheral!((@ peri_type #[doc = "DS peripheral singleton"] DS <=
5998        DS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5999        "ECC peripheral singleton"] ECC <= ECC() (unstable)));
6000        _for_each_inner_peripheral!((@ peri_type #[doc = "ECDSA peripheral singleton"]
6001        ECDSA <= ECDSA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6002        "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
6003        _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
6004        <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6005        "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
6006        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
6007        GPIO_SD <= GPIO_EXT() (unstable))); _for_each_inner_peripheral!((@ peri_type
6008        #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)));
6009        _for_each_inner_peripheral!((@ peri_type #[doc = "HP_APM peripheral singleton"]
6010        HP_APM <= HP_APM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6011        "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)));
6012        _for_each_inner_peripheral!((@ peri_type #[doc = "HUK peripheral singleton"] HUK
6013        <= HUK() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6014        "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
6015        _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
6016        I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
6017        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6018        "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
6019        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
6020        _for_each_inner_peripheral!((@ peri_type #[doc =
6021        "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
6022        bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
6023        _for_each_inner_peripheral!((@ peri_type #[doc =
6024        "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
6025        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6026        "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
6027        _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
6028        IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6029        "KEYMNG peripheral singleton"] KEYMNG <= KEYMNG() (unstable)));
6030        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_ANA peripheral singleton"]
6031        LP_ANA <= LP_ANA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6032        "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)));
6033        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM0 peripheral singleton"]
6034        LP_APM0 <= LP_APM0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6035        = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
6036        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_GPIO peripheral singleton"]
6037        LP_GPIO <= LP_IO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6038        "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)));
6039        _for_each_inner_peripheral!((@ peri_type #[doc =
6040        "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
6041        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6042        "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
6043        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
6044        LP_PERI <= LPPERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6045        = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
6046        _for_each_inner_peripheral!((@ peri_type #[doc =
6047        "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
6048        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_UART peripheral singleton"]
6049        LP_UART <= LP_UART() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6050        = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)));
6051        _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
6052        LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6053        = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
6054        _for_each_inner_peripheral!((@ peri_type #[doc =
6055        "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
6056        _for_each_inner_peripheral!((@ peri_type #[doc =
6057        "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
6058        _for_each_inner_peripheral!((@ peri_type #[doc =
6059        "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
6060        _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
6061        PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
6062        disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
6063        disable_tx_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
6064        #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
6065        _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
6066        PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
6067        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
6068        #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)));
6069        _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
6070        <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6071        "PVT_MONITOR peripheral singleton"] PVT_MONITOR <= PVT() (unstable)));
6072        _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
6073        <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6074        "RNG peripheral singleton"] RNG <= LPPERI() (unstable)));
6075        _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
6076        <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6077        }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6078        "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
6079        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
6080        _for_each_inner_peripheral!((@ peri_type #[doc = "SLC peripheral singleton"] SLC
6081        <= SLC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6082        "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
6083        _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
6084        SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6085        "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
6086        enable_peri_interrupt, disable_peri_interrupt })));
6087        _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
6088        SYSTEM <= PCR() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6089        "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
6090        _for_each_inner_peripheral!((@ peri_type #[doc = "TEE peripheral singleton"] TEE
6091        <= TEE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6092        "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
6093        _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
6094        TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6095        "TWAI0 peripheral singleton"] TWAI0 <= TWAI0(TWAI0 : { bind_peri_interrupt,
6096        enable_peri_interrupt, disable_peri_interrupt }, TWAI0_TIMER : {
6097        bind_timer_interrupt, enable_timer_interrupt, disable_timer_interrupt })
6098        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6099        "TWAI1 peripheral singleton"] TWAI1 <= TWAI1(TWAI1 : { bind_peri_interrupt,
6100        enable_peri_interrupt, disable_peri_interrupt }, TWAI1_TIMER : {
6101        bind_timer_interrupt, enable_timer_interrupt, disable_timer_interrupt })
6102        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6103        "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
6104        enable_peri_interrupt, disable_peri_interrupt })));
6105        _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
6106        UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
6107        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6108        "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
6109        _for_each_inner_peripheral!((@ peri_type #[doc =
6110        "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6111        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6112        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6113        "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
6114        _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
6115        virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
6116        disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
6117        enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
6118        _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
6119        FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6120        "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
6121        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_CORE peripheral singleton"]
6122        LP_CORE <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6123        = "WIFI peripheral singleton"] WIFI <= virtual(WIFI_BB : { bind_bb_interrupt,
6124        enable_bb_interrupt, disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt,
6125        enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
6126        enable_pwr_interrupt, disable_pwr_interrupt }))); _for_each_inner_peripheral!((@
6127        peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
6128        _for_each_inner_peripheral!((@ peri_type #[doc =
6129        "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
6130        _for_each_inner_peripheral!((@ peri_type #[doc =
6131        "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
6132        _for_each_inner_peripheral!((@ peri_type #[doc =
6133        "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
6134        _for_each_inner_peripheral!((@ peri_type #[doc =
6135        "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
6136        _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
6137        _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
6138        _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
6139        _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
6140        _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
6141        _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
6142        _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
6143        _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
6144        _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
6145        _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
6146        _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
6147        _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
6148        _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
6149        _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
6150        _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
6151        _for_each_inner_peripheral!((GPIO28));
6152        _for_each_inner_peripheral!((DMA_CH0(unstable)));
6153        _for_each_inner_peripheral!((DMA_CH1(unstable)));
6154        _for_each_inner_peripheral!((DMA_CH2(unstable)));
6155        _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
6156        _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
6157        _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
6158        _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
6159        _for_each_inner_peripheral!((SDM_CH0(unstable)));
6160        _for_each_inner_peripheral!((SDM_CH1(unstable)));
6161        _for_each_inner_peripheral!((SDM_CH2(unstable)));
6162        _for_each_inner_peripheral!((SDM_CH3(unstable)));
6163        _for_each_inner_peripheral!((AES(unstable)));
6164        _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
6165        _for_each_inner_peripheral!((APB_SARADC(unstable)));
6166        _for_each_inner_peripheral!((CACHE(unstable)));
6167        _for_each_inner_peripheral!((CLINT(unstable)));
6168        _for_each_inner_peripheral!((DMA(unstable)));
6169        _for_each_inner_peripheral!((DS(unstable)));
6170        _for_each_inner_peripheral!((ECC(unstable)));
6171        _for_each_inner_peripheral!((ECDSA(unstable)));
6172        _for_each_inner_peripheral!((ETM(unstable)));
6173        _for_each_inner_peripheral!((GPIO(unstable)));
6174        _for_each_inner_peripheral!((GPIO_SD(unstable)));
6175        _for_each_inner_peripheral!((HMAC(unstable)));
6176        _for_each_inner_peripheral!((HP_APM(unstable)));
6177        _for_each_inner_peripheral!((HP_SYS(unstable)));
6178        _for_each_inner_peripheral!((HUK(unstable)));
6179        _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
6180        _for_each_inner_peripheral!((I2C0));
6181        _for_each_inner_peripheral!((I2S0(unstable)));
6182        _for_each_inner_peripheral!((IEEE802154(unstable)));
6183        _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
6184        _for_each_inner_peripheral!((INTPRI(unstable)));
6185        _for_each_inner_peripheral!((IO_MUX(unstable)));
6186        _for_each_inner_peripheral!((KEYMNG(unstable)));
6187        _for_each_inner_peripheral!((LP_ANA(unstable)));
6188        _for_each_inner_peripheral!((LP_AON(unstable)));
6189        _for_each_inner_peripheral!((LP_APM0(unstable)));
6190        _for_each_inner_peripheral!((LP_CLKRST(unstable)));
6191        _for_each_inner_peripheral!((LP_GPIO(unstable)));
6192        _for_each_inner_peripheral!((LP_I2C0(unstable)));
6193        _for_each_inner_peripheral!((LP_I2C_ANA_MST(unstable)));
6194        _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
6195        _for_each_inner_peripheral!((LP_PERI(unstable)));
6196        _for_each_inner_peripheral!((LP_TEE(unstable)));
6197        _for_each_inner_peripheral!((RTC_TIMER(unstable)));
6198        _for_each_inner_peripheral!((LP_UART(unstable)));
6199        _for_each_inner_peripheral!((LP_WDT(unstable)));
6200        _for_each_inner_peripheral!((LPWR(unstable)));
6201        _for_each_inner_peripheral!((MCPWM0(unstable)));
6202        _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
6203        _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
6204        _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
6205        _for_each_inner_peripheral!((PARL_IO(unstable)));
6206        _for_each_inner_peripheral!((PAU(unstable)));
6207        _for_each_inner_peripheral!((PCNT(unstable)));
6208        _for_each_inner_peripheral!((PCR(unstable)));
6209        _for_each_inner_peripheral!((PMU(unstable)));
6210        _for_each_inner_peripheral!((PVT_MONITOR(unstable)));
6211        _for_each_inner_peripheral!((RMT(unstable)));
6212        _for_each_inner_peripheral!((RNG(unstable)));
6213        _for_each_inner_peripheral!((RSA(unstable)));
6214        _for_each_inner_peripheral!((SHA(unstable)));
6215        _for_each_inner_peripheral!((SLC(unstable)));
6216        _for_each_inner_peripheral!((SPI0(unstable)));
6217        _for_each_inner_peripheral!((SPI1(unstable)));
6218        _for_each_inner_peripheral!((SPI2));
6219        _for_each_inner_peripheral!((SYSTEM(unstable)));
6220        _for_each_inner_peripheral!((SYSTIMER(unstable)));
6221        _for_each_inner_peripheral!((TEE(unstable)));
6222        _for_each_inner_peripheral!((TIMG0(unstable)));
6223        _for_each_inner_peripheral!((TIMG1(unstable)));
6224        _for_each_inner_peripheral!((TWAI0(unstable)));
6225        _for_each_inner_peripheral!((TWAI1(unstable)));
6226        _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
6227        _for_each_inner_peripheral!((UHCI0(unstable)));
6228        _for_each_inner_peripheral!((USB_DEVICE(unstable)));
6229        _for_each_inner_peripheral!((ADC1(unstable)));
6230        _for_each_inner_peripheral!((BT(unstable)));
6231        _for_each_inner_peripheral!((FLASH(unstable)));
6232        _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
6233        _for_each_inner_peripheral!((LP_CORE(unstable)));
6234        _for_each_inner_peripheral!((WIFI));
6235        _for_each_inner_peripheral!((PSRAM(unstable)));
6236        _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
6237        _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
6238        _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
6239        _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
6240        _for_each_inner_peripheral!((SPI2, Spi2, 1, AhbGdmaChannel));
6241        _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
6242        _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
6243        _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
6244        _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
6245        _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
6246        _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
6247        _for_each_inner_peripheral!((all(@ peri_type #[doc =
6248        "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
6249        "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
6250        "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6251        "<section class=\"warning\">"] #[doc =
6252        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6253        #[doc = "<ul>"] #[doc =
6254        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6255        =
6256        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6257        #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
6258        "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6259        "<section class=\"warning\">"] #[doc =
6260        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6261        #[doc = "<ul>"] #[doc =
6262        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6263        =
6264        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6265        #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
6266        "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6267        "<section class=\"warning\">"] #[doc =
6268        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6269        #[doc = "<ul>"] #[doc =
6270        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6271        #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
6272        "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6273        "<section class=\"warning\">"] #[doc =
6274        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6275        #[doc = "<ul>"] #[doc =
6276        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6277        #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
6278        "GPIO6 peripheral singleton"] GPIO6 <= virtual()), (@ peri_type #[doc =
6279        "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6280        "<section class=\"warning\">"] #[doc =
6281        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6282        #[doc = "<ul>"] #[doc =
6283        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6284        = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
6285        "GPIO8 peripheral singleton"] GPIO8 <= virtual()), (@ peri_type #[doc =
6286        "GPIO9 peripheral singleton"] GPIO9 <= virtual()), (@ peri_type #[doc =
6287        "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
6288        "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6289        "<section class=\"warning\">"] #[doc =
6290        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6291        #[doc = "<ul>"] #[doc =
6292        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6293        = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
6294        "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6295        "<section class=\"warning\">"] #[doc =
6296        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6297        #[doc = "<ul>"] #[doc =
6298        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6299        = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
6300        "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6301        "<section class=\"warning\">"] #[doc =
6302        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6303        #[doc = "<ul>"] #[doc =
6304        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6305        #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
6306        "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6307        "<section class=\"warning\">"] #[doc =
6308        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6309        #[doc = "<ul>"] #[doc =
6310        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6311        #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
6312        "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6313        "<section class=\"warning\">"] #[doc =
6314        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6315        #[doc = "<ul>"] #[doc =
6316        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6317        "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
6318        "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6319        "<section class=\"warning\">"] #[doc =
6320        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6321        #[doc = "<ul>"] #[doc =
6322        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6323        "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
6324        "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6325        "<section class=\"warning\">"] #[doc =
6326        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6327        #[doc = "<ul>"] #[doc =
6328        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6329        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6330        "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
6331        "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6332        "<section class=\"warning\">"] #[doc =
6333        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6334        #[doc = "<ul>"] #[doc =
6335        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6336        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6337        "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
6338        "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6339        "<section class=\"warning\">"] #[doc =
6340        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6341        #[doc = "<ul>"] #[doc =
6342        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6343        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6344        "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
6345        "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6346        "<section class=\"warning\">"] #[doc =
6347        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6348        #[doc = "<ul>"] #[doc =
6349        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6350        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6351        "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
6352        "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6353        "<section class=\"warning\">"] #[doc =
6354        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6355        #[doc = "<ul>"] #[doc =
6356        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6357        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6358        "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
6359        "GPIO22 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6360        "<section class=\"warning\">"] #[doc =
6361        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6362        #[doc = "<ul>"] #[doc =
6363        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6364        "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
6365        "</ul>"] #[doc = "</section>"] GPIO22 <= virtual()), (@ peri_type #[doc =
6366        "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
6367        "GPIO24 peripheral singleton"] GPIO24 <= virtual()), (@ peri_type #[doc =
6368        "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6369        "<section class=\"warning\">"] #[doc =
6370        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6371        #[doc = "<ul>"] #[doc =
6372        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6373        = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
6374        "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6375        "<section class=\"warning\">"] #[doc =
6376        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6377        #[doc = "<ul>"] #[doc =
6378        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6379        = "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
6380        "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6381        "<section class=\"warning\">"] #[doc =
6382        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6383        #[doc = "<ul>"] #[doc =
6384        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6385        = "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
6386        "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6387        "<section class=\"warning\">"] #[doc =
6388        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6389        #[doc = "<ul>"] #[doc =
6390        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6391        = "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
6392        "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
6393        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6394        DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6395        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6396        "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
6397        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6398        DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6399        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6400        "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
6401        bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6402        DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6403        disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6404        "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)), (@
6405        peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual()
6406        (unstable)), (@ peri_type #[doc = "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2
6407        <= virtual() (unstable)), (@ peri_type #[doc =
6408        "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)), (@
6409        peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
6410        (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
6411        virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
6412        SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
6413        "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
6414        #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
6415        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6416        = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG()
6417        (unstable)), (@ peri_type #[doc = "APB_SARADC peripheral singleton"] APB_SARADC
6418        <= APB_SARADC() (unstable)), (@ peri_type #[doc = "CACHE peripheral singleton"]
6419        CACHE <= CACHE() (unstable)), (@ peri_type #[doc = "CLIC peripheral singleton"]
6420        CLIC <= CLIC() (unstable)), (@ peri_type #[doc = "CLINT peripheral singleton"]
6421        CLINT <= CLINT() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"]
6422        DMA <= DMA() (unstable)), (@ peri_type #[doc = "DS peripheral singleton"] DS <=
6423        DS() (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <= ECC()
6424        (unstable)), (@ peri_type #[doc = "ECDSA peripheral singleton"] ECDSA <= ECDSA()
6425        (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE()
6426        (unstable)), (@ peri_type #[doc = "ETM peripheral singleton"] ETM <= SOC_ETM()
6427        (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO()
6428        (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <=
6429        GPIO_EXT() (unstable)), (@ peri_type #[doc = "HMAC peripheral singleton"] HMAC <=
6430        HMAC() (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"] HP_APM <=
6431        HP_APM() (unstable)), (@ peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS
6432        <= HP_SYS() (unstable)), (@ peri_type #[doc = "HUK peripheral singleton"] HUK <=
6433        HUK() (unstable)), (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"]
6434        I2C_ANA_MST <= I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
6435        "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
6436        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
6437        "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
6438        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6439        = "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
6440        bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
6441        (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
6442        INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
6443        "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
6444        = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
6445        #[doc = "KEYMNG peripheral singleton"] KEYMNG <= KEYMNG() (unstable)), (@
6446        peri_type #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)),
6447        (@ peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON()
6448        (unstable)), (@ peri_type #[doc = "LP_APM0 peripheral singleton"] LP_APM0 <=
6449        LP_APM0() (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"]
6450        LP_CLKRST <= LP_CLKRST() (unstable)), (@ peri_type #[doc =
6451        "LP_GPIO peripheral singleton"] LP_GPIO <= LP_IO() (unstable)), (@ peri_type
6452        #[doc = "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)), (@
6453        peri_type #[doc = "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <=
6454        LP_I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
6455        "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)), (@
6456        peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LPPERI()
6457        (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE <=
6458        LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
6459        RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
6460        "LP_UART peripheral singleton"] LP_UART <= LP_UART() (unstable)), (@ peri_type
6461        #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@
6462        peri_type #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)),
6463        (@ peri_type #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0()
6464        (unstable)), (@ peri_type #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR
6465        <= MEM_MONITOR() (unstable)), (@ peri_type #[doc =
6466        "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)), (@
6467        peri_type #[doc = "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <=
6468        MODEM_SYSCON() (unstable)), (@ peri_type #[doc = "PARL_IO peripheral singleton"]
6469        PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
6470        disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
6471        disable_tx_interrupt }) (unstable)), (@ peri_type #[doc =
6472        "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@ peri_type #[doc =
6473        "PCNT peripheral singleton"] PCNT <= PCNT(PCNT : { bind_peri_interrupt,
6474        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6475        = "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@ peri_type #[doc =
6476        "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@ peri_type #[doc =
6477        "PVT_MONITOR peripheral singleton"] PVT_MONITOR <= PVT() (unstable)), (@
6478        peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@
6479        peri_type #[doc = "RNG peripheral singleton"] RNG <= LPPERI() (unstable)), (@
6480        peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
6481        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6482        (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
6483        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6484        (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <= SLC()
6485        (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
6486        (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
6487        (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
6488        : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6489        peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
6490        peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
6491        (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
6492        (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
6493        (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
6494        (unstable)), (@ peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <=
6495        TWAI0(TWAI0 : { bind_peri_interrupt, enable_peri_interrupt,
6496        disable_peri_interrupt }, TWAI0_TIMER : { bind_timer_interrupt,
6497        enable_timer_interrupt, disable_timer_interrupt }) (unstable)), (@ peri_type
6498        #[doc = "TWAI1 peripheral singleton"] TWAI1 <= TWAI1(TWAI1 : {
6499        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt }, TWAI1_TIMER
6500        : { bind_timer_interrupt, enable_timer_interrupt, disable_timer_interrupt })
6501        (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
6502        UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
6503        disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
6504        UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
6505        disable_peri_interrupt })), (@ peri_type #[doc = "UHCI0 peripheral singleton"]
6506        UHCI0 <= UHCI0() (unstable)), (@ peri_type #[doc =
6507        "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6508        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6509        (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
6510        (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
6511        virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
6512        disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
6513        enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
6514        "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
6515        = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
6516        (@ peri_type #[doc = "LP_CORE peripheral singleton"] LP_CORE <= virtual()
6517        (unstable)), (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <=
6518        virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt
6519        }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt
6520        }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt
6521        })), (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual()
6522        (unstable)), (@ peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"]
6523        FROM_CPU_INTR0 <= virtual() (unstable)), (@ peri_type #[doc =
6524        "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
6525        (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
6526        virtual() (unstable)), (@ peri_type #[doc =
6527        "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
6528        _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
6529        (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
6530        (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
6531        (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
6532        (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (DMA_CH0(unstable)),
6533        (DMA_CH1(unstable)), (DMA_CH2(unstable)), (PCNT0_UNIT0(unstable)),
6534        (PCNT0_UNIT1(unstable)), (PCNT0_UNIT2(unstable)), (PCNT0_UNIT3(unstable)),
6535        (SDM_CH0(unstable)), (SDM_CH1(unstable)), (SDM_CH2(unstable)),
6536        (SDM_CH3(unstable)), (AES(unstable)), (ASSIST_DEBUG(unstable)),
6537        (APB_SARADC(unstable)), (CACHE(unstable)), (CLINT(unstable)), (DMA(unstable)),
6538        (DS(unstable)), (ECC(unstable)), (ECDSA(unstable)), (ETM(unstable)),
6539        (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)), (HP_APM(unstable)),
6540        (HP_SYS(unstable)), (HUK(unstable)), (I2C_ANA_MST(unstable)), (I2C0),
6541        (I2S0(unstable)), (IEEE802154(unstable)), (INTERRUPT_CORE0(unstable)),
6542        (INTPRI(unstable)), (IO_MUX(unstable)), (KEYMNG(unstable)), (LP_ANA(unstable)),
6543        (LP_AON(unstable)), (LP_APM0(unstable)), (LP_CLKRST(unstable)),
6544        (LP_GPIO(unstable)), (LP_I2C0(unstable)), (LP_I2C_ANA_MST(unstable)),
6545        (LP_IO_MUX(unstable)), (LP_PERI(unstable)), (LP_TEE(unstable)),
6546        (RTC_TIMER(unstable)), (LP_UART(unstable)), (LP_WDT(unstable)), (LPWR(unstable)),
6547        (MCPWM0(unstable)), (MEM_MONITOR(unstable)), (MODEM_LPCON(unstable)),
6548        (MODEM_SYSCON(unstable)), (PARL_IO(unstable)), (PAU(unstable)), (PCNT(unstable)),
6549        (PCR(unstable)), (PMU(unstable)), (PVT_MONITOR(unstable)), (RMT(unstable)),
6550        (RNG(unstable)), (RSA(unstable)), (SHA(unstable)), (SLC(unstable)),
6551        (SPI0(unstable)), (SPI1(unstable)), (SPI2), (SYSTEM(unstable)),
6552        (SYSTIMER(unstable)), (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
6553        (TWAI0(unstable)), (TWAI1(unstable)), (UART0), (UART1), (UHCI0(unstable)),
6554        (USB_DEVICE(unstable)), (ADC1(unstable)), (BT(unstable)), (FLASH(unstable)),
6555        (GPIO_DEDICATED(unstable)), (LP_CORE(unstable)), (WIFI), (PSRAM(unstable)),
6556        (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
6557        (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
6558        _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 1, AhbGdmaChannel), (UHCI0,
6559        Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3, AhbGdmaChannel), (AES, Aes, 6,
6560        AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel), (APB_SARADC, ApbSaradc, 8,
6561        AhbGdmaChannel), (PARL_IO, ParlIo, 9, AhbGdmaChannel)));
6562    };
6563}
6564/// This macro can be used to generate code for each `GPIOn` instance.
6565///
6566/// For an explanation on the general syntax, as well as usage of individual/repeated
6567/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6568///
6569/// This macro has one option for its "Individual matcher" case:
6570///
6571/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
6572/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
6573/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
6574///
6575/// Macro fragments:
6576///
6577/// - `$n`: the number of the GPIO. For `GPIO0`, `$n` is 0.
6578/// - `$gpio`: the name of the GPIO.
6579/// - `$digital_input_function`: the number of the digital function, as an identifier (i.e. for
6580///   function 0 this is `_0`).
6581/// - `$digital_input_function`: the name of the digital function, as an identifier.
6582/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for
6583///   function 0 this is `_0`).
6584/// - `$digital_output_function`: the name of the digital function, as an identifier.
6585/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
6586///   Bracketed so that they can also be matched as optional fragments. Order is always Input first.
6587///
6588/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
6589/// [Output]))`
6590#[macro_export]
6591#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6592macro_rules! for_each_gpio {
6593    ($($pattern:tt => $code:tt;)*) => {
6594        macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
6595        } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
6596        _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
6597        _for_each_inner_gpio!((2, GPIO2(_0 => MTMS _2 => FSPIQ) (_2 => FSPIQ) ([Input]
6598        [Output]))); _for_each_inner_gpio!((3, GPIO3(_0 => MTDI) () ([Input] [Output])));
6599        _for_each_inner_gpio!((4, GPIO4(_0 => MTCK _2 => FSPIHD) (_2 => FSPIHD) ([Input]
6600        [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTDO _2 => FSPIWP) (_2 =>
6601        FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_2 => FSPICLK) (_2
6602        => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_0 =>
6603        SDIO_DATA1 _2 => FSPID) (_2 => FSPID) ([Input] [Output])));
6604        _for_each_inner_gpio!((8, GPIO8(_0 => SDIO_DATA0) () ([Input] [Output])));
6605        _for_each_inner_gpio!((9, GPIO9(_0 => SDIO_CLK) () ([Input] [Output])));
6606        _for_each_inner_gpio!((10, GPIO10(_0 => SDIO_CMD _2 => FSPICS0) (_2 => FSPICS0)
6607        ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11() (_0 => U0TXD) ([Input]
6608        [Output]))); _for_each_inner_gpio!((12, GPIO12(_0 => U0RXD) () ([Input]
6609        [Output]))); _for_each_inner_gpio!((13, GPIO13(_0 => SDIO_DATA3) () ([Input]
6610        [Output]))); _for_each_inner_gpio!((14, GPIO14(_0 => SDIO_DATA2) () ([Input]
6611        [Output]))); _for_each_inner_gpio!((15, GPIO15() () ([Input] [Output])));
6612        _for_each_inner_gpio!((16, GPIO16() () ([Input] [Output])));
6613        _for_each_inner_gpio!((17, GPIO17() () ([Input] [Output])));
6614        _for_each_inner_gpio!((18, GPIO18() () ([Input] [Output])));
6615        _for_each_inner_gpio!((19, GPIO19() () ([Input] [Output])));
6616        _for_each_inner_gpio!((20, GPIO20() () ([Input] [Output])));
6617        _for_each_inner_gpio!((21, GPIO21() () ([Input] [Output])));
6618        _for_each_inner_gpio!((22, GPIO22() () ([Input] [Output])));
6619        _for_each_inner_gpio!((23, GPIO23() () ([Input] [Output])));
6620        _for_each_inner_gpio!((24, GPIO24() () ([Input] [Output])));
6621        _for_each_inner_gpio!((25, GPIO25() () ([Input] [Output])));
6622        _for_each_inner_gpio!((26, GPIO26() () ([Input] [Output])));
6623        _for_each_inner_gpio!((27, GPIO27() () ([Input] [Output])));
6624        _for_each_inner_gpio!((28, GPIO28() () ([Input] [Output])));
6625        _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() ()
6626        ([Input] [Output])), (2, GPIO2(_0 => MTMS _2 => FSPIQ) (_2 => FSPIQ) ([Input]
6627        [Output])), (3, GPIO3(_0 => MTDI) () ([Input] [Output])), (4, GPIO4(_0 => MTCK _2
6628        => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDO _2 => FSPIWP)
6629        (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_2 => FSPICLK) (_2 => FSPICLK)
6630        ([Input] [Output])), (7, GPIO7(_0 => SDIO_DATA1 _2 => FSPID) (_2 => FSPID)
6631        ([Input] [Output])), (8, GPIO8(_0 => SDIO_DATA0) () ([Input] [Output])), (9,
6632        GPIO9(_0 => SDIO_CLK) () ([Input] [Output])), (10, GPIO10(_0 => SDIO_CMD _2 =>
6633        FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (11, GPIO11() (_0 => U0TXD)
6634        ([Input] [Output])), (12, GPIO12(_0 => U0RXD) () ([Input] [Output])), (13,
6635        GPIO13(_0 => SDIO_DATA3) () ([Input] [Output])), (14, GPIO14(_0 => SDIO_DATA2) ()
6636        ([Input] [Output])), (15, GPIO15() () ([Input] [Output])), (16, GPIO16() ()
6637        ([Input] [Output])), (17, GPIO17() () ([Input] [Output])), (18, GPIO18() ()
6638        ([Input] [Output])), (19, GPIO19() () ([Input] [Output])), (20, GPIO20() ()
6639        ([Input] [Output])), (21, GPIO21() () ([Input] [Output])), (22, GPIO22() ()
6640        ([Input] [Output])), (23, GPIO23() () ([Input] [Output])), (24, GPIO24() ()
6641        ([Input] [Output])), (25, GPIO25() () ([Input] [Output])), (26, GPIO26() ()
6642        ([Input] [Output])), (27, GPIO27() () ([Input] [Output])), (28, GPIO28() ()
6643        ([Input] [Output]))));
6644    };
6645}
6646/// This macro can be used to generate code for each analog function of each GPIO.
6647///
6648/// For an explanation on the general syntax, as well as usage of individual/repeated
6649/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6650///
6651/// This macro has two options for its "Individual matcher" case:
6652///
6653/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
6654/// - group: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` - expanded signal
6655///   case, where you need the number(s) of a signal, or the general group to which the signal
6656///   belongs. For example, in case of `ADC2_CH3` the expanded form looks like `(ADC2_CH3, ADCn_CHm,
6657///   2, 3)`.
6658///
6659/// Macro fragments:
6660///
6661/// - `$signal`: the name of the signal.
6662/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
6663///   is `ADCn_CHm`.
6664/// - `$number`: the numbers extracted from `$signal`.
6665/// - `$gpio`: the name of the GPIO.
6666///
6667/// Example data:
6668/// - `(ADC2_CH5, GPIO12)`
6669/// - `((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)`
6670///
6671/// The expanded syntax is only available when the signal has at least one numbered component.
6672#[macro_export]
6673#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6674macro_rules! for_each_analog_function {
6675    ($($pattern:tt => $code:tt;)*) => {
6676        macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
6677        tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
6678        _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
6679        _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
6680        _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
6681        _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
6682        _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
6683        _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
6684        _for_each_inner_analog_function!((ADC1_CH5, GPIO6));
6685        _for_each_inner_analog_function!((ZCD0, GPIO8));
6686        _for_each_inner_analog_function!((ZCD1, GPIO9));
6687        _for_each_inner_analog_function!((USJ_DM, GPIO13));
6688        _for_each_inner_analog_function!((USJ_DP, GPIO14));
6689        _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
6690        _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
6691        _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
6692        _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
6693        _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
6694        _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6));
6695        _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO8));
6696        _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO9));
6697        _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (XTAL_32K_N, GPIO1),
6698        (ADC1_CH0, GPIO1), (ADC1_CH1, GPIO2), (ADC1_CH2, GPIO3), (ADC1_CH3, GPIO4),
6699        (ADC1_CH4, GPIO5), (ADC1_CH5, GPIO6), (ZCD0, GPIO8), (ZCD1, GPIO9), (USJ_DM,
6700        GPIO13), (USJ_DP, GPIO14)));
6701        _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1),
6702        ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3),
6703        ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5),
6704        ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6)));
6705        _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO8), ((ZCD1, ZCDn, 1),
6706        GPIO9)));
6707    };
6708}
6709/// This macro can be used to generate code for each LP function of each GPIO.
6710///
6711/// For an explanation on the general syntax, as well as usage of individual/repeated
6712/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6713///
6714/// This macro has two options for its "Individual matcher" case:
6715///
6716/// - `all`: `($signal:ident, $gpio:ident, $af:ident)` - simple case where you only need
6717///   identifiers, and maybe the function.
6718/// - group: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident, $af:ident, ($(
6719///   $lp_input_af:ident => $lp_input_signal:ident )*) ($( $lp_output_af:ident =>
6720///   $lp_output_signal:ident )*))` - expanded signal case, where you need the number(s) of a
6721///   signal, or the general group to which the signal belongs. Every expanded branch ends with the
6722///   pad's LP input and output function groups (empty on chips without an LP GPIO matrix).
6723///
6724/// Macro fragments:
6725///
6726/// - `$signal`: the name of the signal.
6727/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
6728///   is `ADCn_CHm`.
6729/// - `$number`: the numbers extracted from `$signal`.
6730/// - `$gpio`: the name of the GPIO.
6731/// - `$af`: the LP IO MUX function, as an identifier (i.e. for function 0 this is `_0`). This is
6732///   the name of an `LpFunction` variant, and its number is the value to write to the pad's
6733///   function select field.
6734/// - `$lp_input_af`: the LP IO MUX function for an LP peripheral input on this pad.
6735/// - `$lp_input_signal`: the LP peripheral input signal name.
6736/// - `$lp_output_af`: the LP IO MUX function for an LP peripheral output on this pad.
6737/// - `$lp_output_signal`: the LP peripheral output signal name.
6738///
6739/// Example data:
6740/// - `(LP_GPIO15, GPIO12, _0)`
6741/// - `((LP_GPIO15, LP_GPIOn, 15), GPIO12, _0, () ())`
6742/// - `((LP_GPIO14, LP_GPIOn, 14), GPIO14, _1, () (_0 => LP_UART_TXD))`
6743/// - `((SAR_I2C_SCL_1, SAR_I2C_SCL_n, 1), GPIO2, _3, () ())`
6744///
6745/// The expanded syntax is only available when the signal has at least one numbered component.
6746#[macro_export]
6747#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6748macro_rules! for_each_lp_function {
6749    ($($pattern:tt => $code:tt;)*) => {
6750        macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
6751        => {} } _for_each_inner_lp_function!((LP_UART_DTRN, GPIO0, _0));
6752        _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
6753        _for_each_inner_lp_function!((LP_UART_DSRN, GPIO1, _0));
6754        _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
6755        _for_each_inner_lp_function!((LP_UART_RTSN, GPIO2, _0));
6756        _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
6757        _for_each_inner_lp_function!((LP_I2C_SDA, GPIO2, _3));
6758        _for_each_inner_lp_function!((LP_UART_CTSN, GPIO3, _0));
6759        _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
6760        _for_each_inner_lp_function!((LP_I2C_SCL, GPIO3, _3));
6761        _for_each_inner_lp_function!((LP_UART_RXD, GPIO4, _0));
6762        _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
6763        _for_each_inner_lp_function!((LP_UART_TXD, GPIO5, _0));
6764        _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
6765        _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _1));
6766        _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
6767        _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
6768        _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
6769        _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
6770        _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
6771        _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
6772        _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()));
6773        _for_each_inner_lp_function!((all(LP_UART_DTRN, GPIO0, _0), (LP_GPIO0, GPIO0,
6774        _1), (LP_UART_DSRN, GPIO1, _0), (LP_GPIO1, GPIO1, _1), (LP_UART_RTSN, GPIO2, _0),
6775        (LP_GPIO2, GPIO2, _1), (LP_I2C_SDA, GPIO2, _3), (LP_UART_CTSN, GPIO3, _0),
6776        (LP_GPIO3, GPIO3, _1), (LP_I2C_SCL, GPIO3, _3), (LP_UART_RXD, GPIO4, _0),
6777        (LP_GPIO4, GPIO4, _1), (LP_UART_TXD, GPIO5, _0), (LP_GPIO5, GPIO5, _1),
6778        (LP_GPIO6, GPIO6, _1))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0,
6779        LP_GPIOn, 0), GPIO0, _1, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()),
6780        ((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1,
6781        () ()), ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5),
6782        GPIO5, _1, () ()), ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ())));
6783    };
6784}
6785/// This macro can be used to generate code for each IOMUX digital function of each GPIO.
6786///
6787/// IOMUX functions are the alternate digital functions configured via the IO_MUX registers.
6788/// Use this to implement signal-specific traits for peripherals whose pins must bypass the
6789/// GPIO matrix (e.g., EMAC, USB).
6790///
6791/// For an explanation on the general syntax, as well as usage of individual/repeated
6792/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
6793///
6794/// This macro has two options for its "Individual matcher" case:
6795///
6796/// - `all`: `($signal:ident, $gpio:ident, $af:ident)` - simple case where you only need
6797///   identifiers, and maybe the alternate function.
6798/// - group: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident, $af:ident)` -
6799///   expanded signal case, where you need the number(s) of a signal, or the general group to which
6800///   the signal belongs.
6801///
6802/// Macro fragments:
6803///
6804/// - `$signal`: the name of the signal.
6805/// - `$group`: the name of the signal, with numbers replaced by placeholders.
6806/// - `$number`: the numbers extracted from `$signal`.
6807/// - `$gpio`: the name of the GPIO.
6808/// - `$af`: the alternate function number, as an identifier (e.g. `_5`).
6809///
6810/// Example data:
6811/// - `(EMAC_RXD0, GPIO25, _5)`
6812/// - `((EMAC_RXDn, EMAC_RXDn, 0), GPIO25, _5)`
6813///
6814/// The expanded syntax is only available when the signal has at least one numbered component.
6815#[macro_export]
6816#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6817macro_rules! for_each_iomux_function {
6818    ($($pattern:tt => $code:tt;)*) => {
6819        macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
6820        tt) => {} } _for_each_inner_iomux_function!((MTMS, GPIO2, _0));
6821        _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
6822        _for_each_inner_iomux_function!((MTDI, GPIO3, _0));
6823        _for_each_inner_iomux_function!((MTCK, GPIO4, _0));
6824        _for_each_inner_iomux_function!((FSPIHD, GPIO4, _2));
6825        _for_each_inner_iomux_function!((MTDO, GPIO5, _0));
6826        _for_each_inner_iomux_function!((FSPIWP, GPIO5, _2));
6827        _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
6828        _for_each_inner_iomux_function!((SDIO_DATA1, GPIO7, _0));
6829        _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
6830        _for_each_inner_iomux_function!((SDIO_DATA0, GPIO8, _0));
6831        _for_each_inner_iomux_function!((SDIO_CLK, GPIO9, _0));
6832        _for_each_inner_iomux_function!((SDIO_CMD, GPIO10, _0));
6833        _for_each_inner_iomux_function!((FSPICS0, GPIO10, _2));
6834        _for_each_inner_iomux_function!((U0TXD, GPIO11, _0));
6835        _for_each_inner_iomux_function!((U0RXD, GPIO12, _0));
6836        _for_each_inner_iomux_function!((SDIO_DATA3, GPIO13, _0));
6837        _for_each_inner_iomux_function!((SDIO_DATA2, GPIO14, _0));
6838        _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO7, _0));
6839        _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO8, _0));
6840        _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO13, _0));
6841        _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO14, _0));
6842        _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO10, _2));
6843        _for_each_inner_iomux_function!((all(MTMS, GPIO2, _0), (FSPIQ, GPIO2, _2), (MTDI,
6844        GPIO3, _0), (MTCK, GPIO4, _0), (FSPIHD, GPIO4, _2), (MTDO, GPIO5, _0), (FSPIWP,
6845        GPIO5, _2), (FSPICLK, GPIO6, _2), (SDIO_DATA1, GPIO7, _0), (FSPID, GPIO7, _2),
6846        (SDIO_DATA0, GPIO8, _0), (SDIO_CLK, GPIO9, _0), (SDIO_CMD, GPIO10, _0), (FSPICS0,
6847        GPIO10, _2), (U0TXD, GPIO11, _0), (U0RXD, GPIO12, _0), (SDIO_DATA3, GPIO13, _0),
6848        (SDIO_DATA2, GPIO14, _0)));
6849        _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA1, SDIO_DATAn, 1), GPIO7,
6850        _0), ((SDIO_DATA0, SDIO_DATAn, 0), GPIO8, _0), ((SDIO_DATA3, SDIO_DATAn, 3),
6851        GPIO13, _0), ((SDIO_DATA2, SDIO_DATAn, 2), GPIO14, _0)));
6852        _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO10, _2)));
6853    };
6854}
6855/// Returns the name of the GPIO that provides the given signal, as a string.
6856///
6857/// The macro takes the name of a direct function - a digital IO MUX function, an analog
6858/// function, or an LP IO MUX function - and expands to a string literal like `"GPIO4"`. It
6859/// is meant to keep documentation free of per-chip pin lists.
6860///
6861/// Signals that are not wired to a pad on this chip have to be routed through the GPIO
6862/// matrix, which can reach any pad. The macro has no pad to return for those, so it accepts
6863/// an optional fallback to expand to instead. The fallback is not validated.
6864///
6865/// If multiple pads provide the signal, the macro returns one that is not reserved for some
6866/// other purpose, such as booting or interfacing with flash.
6867///
6868/// Example usage:
6869/// - `gpio_for_signal!(ADC1_CH0)`
6870/// - `gpio_for_signal!(LP_I2C_SDA, "GPIO6")`
6871#[macro_export]
6872#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6873macro_rules! gpio_for_signal {
6874    (XTAL_32K_P $(, $_fallback:literal)?) => {
6875        "GPIO0"
6876    };
6877    (LP_UART_DTRN $(, $_fallback:literal)?) => {
6878        "GPIO0"
6879    };
6880    (LP_GPIO0 $(, $_fallback:literal)?) => {
6881        "GPIO0"
6882    };
6883    (XTAL_32K_N $(, $_fallback:literal)?) => {
6884        "GPIO1"
6885    };
6886    (ADC1_CH0 $(, $_fallback:literal)?) => {
6887        "GPIO1"
6888    };
6889    (LP_UART_DSRN $(, $_fallback:literal)?) => {
6890        "GPIO1"
6891    };
6892    (LP_GPIO1 $(, $_fallback:literal)?) => {
6893        "GPIO1"
6894    };
6895    (MTMS $(, $_fallback:literal)?) => {
6896        "GPIO2"
6897    };
6898    (FSPIQ $(, $_fallback:literal)?) => {
6899        "GPIO2"
6900    };
6901    (ADC1_CH1 $(, $_fallback:literal)?) => {
6902        "GPIO2"
6903    };
6904    (LP_UART_RTSN $(, $_fallback:literal)?) => {
6905        "GPIO2"
6906    };
6907    (LP_GPIO2 $(, $_fallback:literal)?) => {
6908        "GPIO2"
6909    };
6910    (LP_I2C_SDA $(, $_fallback:literal)?) => {
6911        "GPIO2"
6912    };
6913    (MTDI $(, $_fallback:literal)?) => {
6914        "GPIO3"
6915    };
6916    (ADC1_CH2 $(, $_fallback:literal)?) => {
6917        "GPIO3"
6918    };
6919    (LP_UART_CTSN $(, $_fallback:literal)?) => {
6920        "GPIO3"
6921    };
6922    (LP_GPIO3 $(, $_fallback:literal)?) => {
6923        "GPIO3"
6924    };
6925    (LP_I2C_SCL $(, $_fallback:literal)?) => {
6926        "GPIO3"
6927    };
6928    (MTCK $(, $_fallback:literal)?) => {
6929        "GPIO4"
6930    };
6931    (FSPIHD $(, $_fallback:literal)?) => {
6932        "GPIO4"
6933    };
6934    (ADC1_CH3 $(, $_fallback:literal)?) => {
6935        "GPIO4"
6936    };
6937    (LP_UART_RXD $(, $_fallback:literal)?) => {
6938        "GPIO4"
6939    };
6940    (LP_GPIO4 $(, $_fallback:literal)?) => {
6941        "GPIO4"
6942    };
6943    (MTDO $(, $_fallback:literal)?) => {
6944        "GPIO5"
6945    };
6946    (FSPIWP $(, $_fallback:literal)?) => {
6947        "GPIO5"
6948    };
6949    (ADC1_CH4 $(, $_fallback:literal)?) => {
6950        "GPIO5"
6951    };
6952    (LP_UART_TXD $(, $_fallback:literal)?) => {
6953        "GPIO5"
6954    };
6955    (LP_GPIO5 $(, $_fallback:literal)?) => {
6956        "GPIO5"
6957    };
6958    (FSPICLK $(, $_fallback:literal)?) => {
6959        "GPIO6"
6960    };
6961    (ADC1_CH5 $(, $_fallback:literal)?) => {
6962        "GPIO6"
6963    };
6964    (LP_GPIO6 $(, $_fallback:literal)?) => {
6965        "GPIO6"
6966    };
6967    (SDIO_DATA1 $(, $_fallback:literal)?) => {
6968        "GPIO7"
6969    };
6970    (FSPID $(, $_fallback:literal)?) => {
6971        "GPIO7"
6972    };
6973    (SDIO_DATA0 $(, $_fallback:literal)?) => {
6974        "GPIO8"
6975    };
6976    (ZCD0 $(, $_fallback:literal)?) => {
6977        "GPIO8"
6978    };
6979    (SDIO_CLK $(, $_fallback:literal)?) => {
6980        "GPIO9"
6981    };
6982    (ZCD1 $(, $_fallback:literal)?) => {
6983        "GPIO9"
6984    };
6985    (SDIO_CMD $(, $_fallback:literal)?) => {
6986        "GPIO10"
6987    };
6988    (FSPICS0 $(, $_fallback:literal)?) => {
6989        "GPIO10"
6990    };
6991    (U0TXD $(, $_fallback:literal)?) => {
6992        "GPIO11"
6993    };
6994    (U0RXD $(, $_fallback:literal)?) => {
6995        "GPIO12"
6996    };
6997    (SDIO_DATA3 $(, $_fallback:literal)?) => {
6998        "GPIO13"
6999    };
7000    (USJ_DM $(, $_fallback:literal)?) => {
7001        "GPIO13"
7002    };
7003    (SDIO_DATA2 $(, $_fallback:literal)?) => {
7004        "GPIO14"
7005    };
7006    (USJ_DP $(, $_fallback:literal)?) => {
7007        "GPIO14"
7008    };
7009    ($_signal:ident, $fallback:literal) => {
7010        $fallback
7011    };
7012}
7013/// Defines the `InputSignal` and `OutputSignal` enums.
7014///
7015/// This macro is intended to be called in esp-hal only.
7016#[macro_export]
7017#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7018macro_rules! define_io_mux_signals {
7019    () => {
7020        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7021        #[derive(Debug, PartialEq, Copy, Clone)]
7022        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7023        #[doc(hidden)]
7024        pub enum InputSignal {
7025            U0RXD               = 6,
7026            U0CTS               = 7,
7027            U0DSR               = 8,
7028            U1RXD               = 9,
7029            U1CTS               = 10,
7030            U1DSR               = 11,
7031            I2S_MCLK            = 12,
7032            I2SO_BCK            = 13,
7033            I2SO_WS             = 14,
7034            I2SI_SD             = 15,
7035            I2SI_BCK            = 16,
7036            I2SI_WS             = 17,
7037            CPU_GPIO_0          = 27,
7038            CPU_GPIO_1          = 28,
7039            CPU_GPIO_2          = 29,
7040            CPU_GPIO_3          = 30,
7041            CPU_GPIO_4          = 31,
7042            CPU_GPIO_5          = 32,
7043            CPU_GPIO_6          = 33,
7044            CPU_GPIO_7          = 34,
7045            USB_JTAG_TDO_BRIDGE = 35,
7046            I2CEXT0_SCL         = 46,
7047            I2CEXT0_SDA         = 47,
7048            PARL_RX_DATA0       = 48,
7049            PARL_RX_DATA1       = 49,
7050            PARL_RX_DATA2       = 50,
7051            PARL_RX_DATA3       = 51,
7052            PARL_RX_DATA4       = 52,
7053            PARL_RX_DATA5       = 53,
7054            PARL_RX_DATA6       = 54,
7055            PARL_RX_DATA7       = 55,
7056            FSPICLK             = 56,
7057            FSPIQ               = 57,
7058            FSPID               = 58,
7059            FSPIHD              = 59,
7060            FSPIWP              = 60,
7061            FSPICS0             = 61,
7062            PARL_RX_CLK         = 62,
7063            PARL_TX_CLK         = 63,
7064            RMT_SIG_0           = 64,
7065            RMT_SIG_1           = 65,
7066            TWAI0_RX            = 66,
7067            TWAI1_RX            = 70,
7068            PCNT0_RST           = 76,
7069            PCNT1_RST           = 77,
7070            PCNT2_RST           = 78,
7071            PCNT3_RST           = 79,
7072            PWM0_SYNC0          = 80,
7073            PWM0_SYNC1          = 81,
7074            PWM0_SYNC2          = 82,
7075            PWM0_F0             = 83,
7076            PWM0_F1             = 84,
7077            PWM0_F2             = 85,
7078            PWM0_CAP0           = 86,
7079            PWM0_CAP1           = 87,
7080            PWM0_CAP2           = 88,
7081            SIG_IN_FUNC97       = 97,
7082            SIG_IN_FUNC98       = 98,
7083            SIG_IN_FUNC99       = 99,
7084            SIG_IN_FUNC100      = 100,
7085            PCNT0_SIG_CH0       = 101,
7086            PCNT0_SIG_CH1       = 102,
7087            PCNT0_CTRL_CH0      = 103,
7088            PCNT0_CTRL_CH1      = 104,
7089            PCNT1_SIG_CH0       = 105,
7090            PCNT1_SIG_CH1       = 106,
7091            PCNT1_CTRL_CH0      = 107,
7092            PCNT1_CTRL_CH1      = 108,
7093            PCNT2_SIG_CH0       = 109,
7094            PCNT2_SIG_CH1       = 110,
7095            PCNT2_CTRL_CH0      = 111,
7096            PCNT2_CTRL_CH1      = 112,
7097            PCNT3_SIG_CH0       = 113,
7098            PCNT3_SIG_CH1       = 114,
7099            PCNT3_CTRL_CH0      = 115,
7100            PCNT3_CTRL_CH1      = 116,
7101            SDIO_CLK,
7102            SDIO_CMD,
7103            SDIO_DATA0,
7104            SDIO_DATA1,
7105            SDIO_DATA2,
7106            SDIO_DATA3,
7107            MTDI,
7108            MTDO,
7109            MTCK,
7110            MTMS,
7111        }
7112        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7113        #[derive(Debug, PartialEq, Copy, Clone)]
7114        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7115        #[doc(hidden)]
7116        pub enum OutputSignal {
7117            LEDC_LS_SIG0     = 0,
7118            LEDC_LS_SIG1     = 1,
7119            LEDC_LS_SIG2     = 2,
7120            LEDC_LS_SIG3     = 3,
7121            LEDC_LS_SIG4     = 4,
7122            LEDC_LS_SIG5     = 5,
7123            U0TXD            = 6,
7124            U0RTS            = 7,
7125            U0DTR            = 8,
7126            U1TXD            = 9,
7127            U1RTS            = 10,
7128            U1DTR            = 11,
7129            I2S_MCLK         = 12,
7130            I2SO_BCK         = 13,
7131            I2SO_WS          = 14,
7132            I2SO_SD          = 15,
7133            I2SI_BCK         = 16,
7134            I2SI_WS          = 17,
7135            I2SO_SD1         = 18,
7136            CPU_GPIO_0       = 27,
7137            CPU_GPIO_1       = 28,
7138            CPU_GPIO_2       = 29,
7139            CPU_GPIO_3       = 30,
7140            CPU_GPIO_4       = 31,
7141            CPU_GPIO_5       = 32,
7142            CPU_GPIO_6       = 33,
7143            CPU_GPIO_7       = 34,
7144            I2CEXT0_SCL      = 46,
7145            I2CEXT0_SDA      = 47,
7146            PARL_TX_DATA0    = 48,
7147            PARL_TX_DATA1    = 49,
7148            PARL_TX_DATA2    = 50,
7149            PARL_TX_DATA3    = 51,
7150            PARL_TX_DATA4    = 52,
7151            PARL_TX_DATA5    = 53,
7152            PARL_TX_DATA6    = 54,
7153            PARL_TX_DATA7    = 55,
7154            FSPICLK          = 56,
7155            FSPIQ            = 57,
7156            FSPID            = 58,
7157            FSPIHD           = 59,
7158            FSPIWP           = 60,
7159            FSPICS0          = 61,
7160            PARL_RX_CLK      = 62,
7161            PARL_TX_CLK      = 63,
7162            RMT_SIG_0        = 64,
7163            RMT_SIG_1        = 65,
7164            TWAI0_TX         = 66,
7165            TWAI0_BUS_OFF_ON = 67,
7166            TWAI0_CLKOUT     = 68,
7167            TWAI0_STANDBY    = 69,
7168            TWAI1_TX         = 70,
7169            TWAI1_BUS_OFF_ON = 71,
7170            TWAI1_CLKOUT     = 72,
7171            TWAI1_STANDBY    = 73,
7172            GPIO_SD0         = 76,
7173            GPIO_SD1         = 77,
7174            GPIO_SD2         = 78,
7175            GPIO_SD3         = 79,
7176            PWM0_0A          = 80,
7177            PWM0_0B          = 81,
7178            PWM0_1A          = 82,
7179            PWM0_1B          = 83,
7180            PWM0_2A          = 84,
7181            PWM0_2B          = 85,
7182            PARL_TX_CS       = 86,
7183            SIG_IN_FUNC97    = 97,
7184            SIG_IN_FUNC98    = 98,
7185            SIG_IN_FUNC99    = 99,
7186            SIG_IN_FUNC100   = 100,
7187            FSPICS1          = 101,
7188            FSPICS2          = 102,
7189            FSPICS3          = 103,
7190            FSPICS4          = 104,
7191            FSPICS5          = 105,
7192            GPIO             = 256,
7193        }
7194    };
7195}
7196/// Defines the `LpFunction` enum.
7197///
7198/// The enum only contains the LP IO MUX functions that the chip implements. It is
7199/// empty on chips without an LP IO peripheral.
7200///
7201/// This macro is intended to be called in esp-hal only.
7202#[macro_export]
7203#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7204macro_rules! define_lp_functions {
7205    () => {
7206        /// LP IO MUX function of a pad.
7207        ///
7208        /// This is the low-power counterpart of `AlternateFunction`: it selects which function
7209        /// drives a pad while the pad belongs to the low-power domain.
7210        #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
7211        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7212        #[doc(hidden)]
7213        pub enum LpFunction {
7214            /// LP IO MUX function 0.
7215            _0 = 0,
7216            /// LP IO MUX function 1.
7217            _1 = 1,
7218            /// LP IO MUX function 3.
7219            _3 = 3,
7220        }
7221        impl LpFunction {
7222            /// The function that connects the pad to the LP GPIO peripheral.
7223            pub const LP_GPIO: Self = Self::_1;
7224        }
7225    };
7226}
7227/// Defines and implements the `io_mux_reg` function.
7228///
7229/// The generated function has the following signature:
7230///
7231/// ```rust,ignore
7232/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
7233///     // ...
7234/// # unimplemented!()
7235/// }
7236/// ```
7237///
7238/// This macro is intended to be called in esp-hal only.
7239#[macro_export]
7240#[expect(clippy::crate_in_macro_def)]
7241#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7242macro_rules! define_io_mux_reg {
7243    () => {
7244        pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
7245            crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
7246        }
7247    };
7248}