Skip to main content

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