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