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