Skip to main content

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