Skip to main content

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