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