Skip to main content

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