Skip to main content

esp_metadata_generated/
_generated_esp32c6.rs

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