Skip to main content

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