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