Skip to main content

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