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