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