Skip to main content

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