Skip to main content

esp_metadata_generated/
_generated_esp32h2.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        "esp32h2"
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-H2"
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        "esp32h2"
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-h2_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        5
99    };
100    ("dma.max_priority", str) => {
101        stringify!(5)
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        true
114    };
115    ("ecc.has_memory_clock_gate") => {
116        true
117    };
118    ("ecc.supports_enhanced_security") => {
119        true
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        2
216    };
217    ("interrupts.status_registers", str) => {
218        stringify!(2)
219    };
220    ("interrupts.disabled_interrupt") => {
221        31
222    };
223    ("parl_io.version") => {
224        2
225    };
226    ("parl_io.version", str) => {
227        stringify!(2)
228    };
229    ("phy.combo_module") => {
230        false
231    };
232    ("rmt.ram_start") => {
233        1610642432
234    };
235    ("rmt.ram_start", str) => {
236        stringify!(1610642432)
237    };
238    ("rmt.channel_ram_size") => {
239        48
240    };
241    ("rmt.channel_ram_size", str) => {
242        stringify!(48)
243    };
244    ("rmt.has_tx_immediate_stop") => {
245        true
246    };
247    ("rmt.has_tx_loop_count") => {
248        true
249    };
250    ("rmt.has_tx_loop_auto_stop") => {
251        true
252    };
253    ("rmt.has_tx_carrier_data_only") => {
254        true
255    };
256    ("rmt.has_tx_sync") => {
257        true
258    };
259    ("rmt.has_rx_wrap") => {
260        true
261    };
262    ("rmt.has_rx_demodulation") => {
263        true
264    };
265    ("rmt.has_dma") => {
266        false
267    };
268    ("rmt.has_per_channel_clock") => {
269        false
270    };
271    ("rng.apb_cycle_wait_num") => {
272        16
273    };
274    ("rng.apb_cycle_wait_num", str) => {
275        stringify!(16)
276    };
277    ("rng.trng_supported") => {
278        true
279    };
280    ("rsa.size_increment") => {
281        32
282    };
283    ("rsa.size_increment", str) => {
284        stringify!(32)
285    };
286    ("rsa.memory_size_bytes") => {
287        384
288    };
289    ("rsa.memory_size_bytes", str) => {
290        stringify!(384)
291    };
292    ("sha.dma") => {
293        true
294    };
295    ("sleep.light_sleep") => {
296        true
297    };
298    ("sleep.deep_sleep") => {
299        true
300    };
301    ("soc.cpu_has_branch_predictor") => {
302        false
303    };
304    ("soc.cpu_has_csr_pc") => {
305        true
306    };
307    ("soc.multi_core_enabled") => {
308        false
309    };
310    ("soc.cpu_csr_prv_mode") => {
311        3088
312    };
313    ("soc.cpu_csr_prv_mode", str) => {
314        stringify!(3088)
315    };
316    ("soc.rc_fast_clk_default") => {
317        8500000
318    };
319    ("soc.rc_fast_clk_default", str) => {
320        stringify!(8500000)
321    };
322    ("clock_tree.cpu_clk.divisor") => {
323        (0, 255)
324    };
325    ("clock_tree.ahb_clk.divisor") => {
326        (0, 255)
327    };
328    ("clock_tree.apb_clk.divisor") => {
329        (0, 255)
330    };
331    ("clock_tree.uart.function_clock.div_num") => {
332        (0, 255)
333    };
334    ("clock_tree.uart.baud_rate_generator.fractional") => {
335        (0, 15)
336    };
337    ("clock_tree.uart.baud_rate_generator.integral") => {
338        (0, 4095)
339    };
340    ("spi_master.supports_dma") => {
341        true
342    };
343    ("spi_master.has_octal") => {
344        false
345    };
346    ("spi_master.has_app_interrupts") => {
347        true
348    };
349    ("spi_master.has_dma_segmented_transfer") => {
350        true
351    };
352    ("spi_master.has_clk_pre_div") => {
353        false
354    };
355    ("spi_slave.supports_dma") => {
356        true
357    };
358    ("timergroup.timg_has_timer1") => {
359        false
360    };
361    ("timergroup.timg_has_divcnt_rst") => {
362        true
363    };
364    ("timergroup.rc_fast_calibration_divider_min_rev") => {
365        2
366    };
367    ("timergroup.rc_fast_calibration_divider") => {
368        32
369    };
370    ("timergroup.rc_fast_calibration_tick_enable") => {
371        true
372    };
373    ("uart.ram_size") => {
374        128
375    };
376    ("uart.ram_size", str) => {
377        stringify!(128)
378    };
379    ("uart.peripheral_controls_mem_clk") => {
380        true
381    };
382    ("uart.has_sclk_divider") => {
383        false
384    };
385    ("uhci.combined_uart_selector_field") => {
386        false
387    };
388}
389#[macro_export]
390#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
391macro_rules! for_each_aes_key_length {
392    ($($pattern:tt => $code:tt;)*) => {
393        macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
394        tt) => {} } _for_each_inner_aes_key_length!((128));
395        _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
396        4)); _for_each_inner_aes_key_length!((256, 2, 6));
397        _for_each_inner_aes_key_length!((bits(128), (256)));
398        _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
399    };
400}
401#[macro_export]
402#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
403macro_rules! for_each_dedicated_gpio {
404    ($($pattern:tt => $code:tt;)*) => {
405        macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
406        tt) => {} } _for_each_inner_dedicated_gpio!((0));
407        _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
408        _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
409        _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
410        _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
411        CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
412        _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
413        _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
414        _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
415        _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
416        _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
417        _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
418        _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
419        (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
420        CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
421        CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
422    };
423}
424#[macro_export]
425#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
426macro_rules! for_each_ecc_working_mode {
427    ($($pattern:tt => $code:tt;)*) => {
428        macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
429        : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
430        _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
431        _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
432        _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
433        _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
434        _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
435        _for_each_inner_ecc_working_mode!((7,
436        AffinePointVerificationAndJacobianPointMultiplication));
437        _for_each_inner_ecc_working_mode!((8, ModularAddition));
438        _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
439        _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
440        _for_each_inner_ecc_working_mode!((11, ModularDivision));
441        _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
442        AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
443        JacobianPointMultiplication), (5, AffinePointAddition), (6,
444        JacobianPointVerification), (7,
445        AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
446        ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
447    };
448}
449#[macro_export]
450#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
451macro_rules! for_each_ecc_curve {
452    ($($pattern:tt => $code:tt;)*) => {
453        macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
454        => {} } _for_each_inner_ecc_curve!((0, P192, 192));
455        _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
456        P192, 192), (1, P256, 256)));
457    };
458}
459#[macro_export]
460#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
461macro_rules! for_each_interrupt {
462    ($($pattern:tt => $code:tt;)*) => {
463        macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
464        => {} } _for_each_inner_interrupt!(([reserved 0] 0));
465        _for_each_inner_interrupt!(([direct_bindable 0] 1));
466        _for_each_inner_interrupt!(([direct_bindable 1] 2));
467        _for_each_inner_interrupt!(([reserved 1] 3));
468        _for_each_inner_interrupt!(([reserved 2] 4));
469        _for_each_inner_interrupt!(([direct_bindable 2] 5));
470        _for_each_inner_interrupt!(([direct_bindable 3] 6));
471        _for_each_inner_interrupt!(([reserved 3] 7));
472        _for_each_inner_interrupt!(([direct_bindable 4] 8));
473        _for_each_inner_interrupt!(([direct_bindable 5] 9));
474        _for_each_inner_interrupt!(([direct_bindable 6] 10));
475        _for_each_inner_interrupt!(([direct_bindable 7] 11));
476        _for_each_inner_interrupt!(([direct_bindable 8] 12));
477        _for_each_inner_interrupt!(([direct_bindable 9] 13));
478        _for_each_inner_interrupt!(([direct_bindable 10] 14));
479        _for_each_inner_interrupt!(([direct_bindable 11] 15));
480        _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
481        1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
482        _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
483        4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
484        _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
485        7] 23)); _for_each_inner_interrupt!(([vector 8] 24));
486        _for_each_inner_interrupt!(([vector 9] 25)); _for_each_inner_interrupt!(([vector
487        10] 26)); _for_each_inner_interrupt!(([vector 11] 27));
488        _for_each_inner_interrupt!(([vector 12] 28)); _for_each_inner_interrupt!(([vector
489        13] 29)); _for_each_inner_interrupt!(([vector 14] 30));
490        _for_each_inner_interrupt!(([disabled 0] 31));
491        _for_each_inner_interrupt!((all([reserved 0] 0), ([direct_bindable 0] 1),
492        ([direct_bindable 1] 2), ([reserved 1] 3), ([reserved 2] 4), ([direct_bindable 2]
493        5), ([direct_bindable 3] 6), ([reserved 3] 7), ([direct_bindable 4] 8),
494        ([direct_bindable 5] 9), ([direct_bindable 6] 10), ([direct_bindable 7] 11),
495        ([direct_bindable 8] 12), ([direct_bindable 9] 13), ([direct_bindable 10] 14),
496        ([direct_bindable 11] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18),
497        ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7]
498        23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26), ([vector 11] 27),
499        ([vector 12] 28), ([vector 13] 29), ([vector 14] 30), ([disabled 0] 31)));
500    };
501}
502#[macro_export]
503#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
504macro_rules! for_each_classified_interrupt {
505    ($($pattern:tt => $code:tt;)*) => {
506        macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
507        ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
508        1)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 2));
509        _for_each_inner_classified_interrupt!(([direct_bindable 2] 5));
510        _for_each_inner_classified_interrupt!(([direct_bindable 3] 6));
511        _for_each_inner_classified_interrupt!(([direct_bindable 4] 8));
512        _for_each_inner_classified_interrupt!(([direct_bindable 5] 9));
513        _for_each_inner_classified_interrupt!(([direct_bindable 6] 10));
514        _for_each_inner_classified_interrupt!(([direct_bindable 7] 11));
515        _for_each_inner_classified_interrupt!(([direct_bindable 8] 12));
516        _for_each_inner_classified_interrupt!(([direct_bindable 9] 13));
517        _for_each_inner_classified_interrupt!(([direct_bindable 10] 14));
518        _for_each_inner_classified_interrupt!(([direct_bindable 11] 15));
519        _for_each_inner_classified_interrupt!(([vector 0] 16));
520        _for_each_inner_classified_interrupt!(([vector 1] 17));
521        _for_each_inner_classified_interrupt!(([vector 2] 18));
522        _for_each_inner_classified_interrupt!(([vector 3] 19));
523        _for_each_inner_classified_interrupt!(([vector 4] 20));
524        _for_each_inner_classified_interrupt!(([vector 5] 21));
525        _for_each_inner_classified_interrupt!(([vector 6] 22));
526        _for_each_inner_classified_interrupt!(([vector 7] 23));
527        _for_each_inner_classified_interrupt!(([vector 8] 24));
528        _for_each_inner_classified_interrupt!(([vector 9] 25));
529        _for_each_inner_classified_interrupt!(([vector 10] 26));
530        _for_each_inner_classified_interrupt!(([vector 11] 27));
531        _for_each_inner_classified_interrupt!(([vector 12] 28));
532        _for_each_inner_classified_interrupt!(([vector 13] 29));
533        _for_each_inner_classified_interrupt!(([vector 14] 30));
534        _for_each_inner_classified_interrupt!(([reserved 0] 0));
535        _for_each_inner_classified_interrupt!(([reserved 1] 3));
536        _for_each_inner_classified_interrupt!(([reserved 2] 4));
537        _for_each_inner_classified_interrupt!(([reserved 3] 7));
538        _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 1),
539        ([direct_bindable 1] 2), ([direct_bindable 2] 5), ([direct_bindable 3] 6),
540        ([direct_bindable 4] 8), ([direct_bindable 5] 9), ([direct_bindable 6] 10),
541        ([direct_bindable 7] 11), ([direct_bindable 8] 12), ([direct_bindable 9] 13),
542        ([direct_bindable 10] 14), ([direct_bindable 11] 15)));
543        _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
544        ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
545        22), ([vector 7] 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26),
546        ([vector 11] 27), ([vector 12] 28), ([vector 13] 29), ([vector 14] 30)));
547        _for_each_inner_classified_interrupt!((reserved([reserved 0] 0), ([reserved 1]
548        3), ([reserved 2] 4), ([reserved 3] 7)));
549    };
550}
551#[macro_export]
552#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
553macro_rules! for_each_interrupt_priority {
554    ($($pattern:tt => $code:tt;)*) => {
555        macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
556        ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
557        Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
558        _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
559        _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
560        _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
561        _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
562        _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
563        _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
564        _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
565        _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
566        _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
567        _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
568        _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
569        _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
570        _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
571        _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
572        Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
573        Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
574        Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
575        11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
576        Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
577    };
578}
579#[macro_export]
580#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
581macro_rules! for_each_sw_interrupt {
582    ($($pattern:tt => $code:tt;)*) => {
583        macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
584        tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
585        software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
586        software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
587        software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
588        software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
589        software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
590        FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
591    };
592}
593#[macro_export]
594macro_rules! sw_interrupt_delay {
595    () => {
596        unsafe {
597            ::core::arch::asm!("nop");
598            ::core::arch::asm!("nop");
599            ::core::arch::asm!("nop");
600            ::core::arch::asm!("nop");
601            ::core::arch::asm!("nop");
602        }
603    };
604}
605/// This macro can be used to generate code for each channel of the RMT peripheral.
606///
607/// For an explanation on the general syntax, as well as usage of individual/repeated
608/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
609///
610/// This macro has three options for its "Individual matcher" case:
611///
612/// - `all`: `($num:literal)`
613/// - `tx`: `($num:literal, $idx:literal)`
614/// - `rx`: `($num:literal, $idx:literal)`
615///
616/// Macro fragments:
617///
618/// - `$num`: number of the channel, e.g. `0`
619/// - `$idx`: index of the channel among channels of the same capability, e.g. `0`
620///
621/// Example data:
622///
623/// - `all`: `(0)`
624/// - `tx`: `(1, 1)`
625/// - `rx`: `(2, 0)`
626#[macro_export]
627#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
628macro_rules! for_each_rmt_channel {
629    ($($pattern:tt => $code:tt;)*) => {
630        macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
631        => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
632        _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
633        _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
634        _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
635        _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
636        _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
637        _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
638    };
639}
640#[macro_export]
641#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
642macro_rules! for_each_rmt_clock_source {
643    ($($pattern:tt => $code:tt;)*) => {
644        macro_rules! _for_each_inner_rmt_clock_source { $(($pattern) => $code;)* ($other
645        : tt) => {} } _for_each_inner_rmt_clock_source!((Xtal, 0));
646        _for_each_inner_rmt_clock_source!((RcFast, 1));
647        _for_each_inner_rmt_clock_source!((Xtal));
648        _for_each_inner_rmt_clock_source!((all(Xtal, 0), (RcFast, 1)));
649        _for_each_inner_rmt_clock_source!((default(Xtal)));
650        _for_each_inner_rmt_clock_source!((is_boolean));
651    };
652}
653#[macro_export]
654#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
655macro_rules! for_each_rsa_exponentiation {
656    ($($pattern:tt => $code:tt;)*) => {
657        macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
658        ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
659        _for_each_inner_rsa_exponentiation!((64));
660        _for_each_inner_rsa_exponentiation!((96));
661        _for_each_inner_rsa_exponentiation!((128));
662        _for_each_inner_rsa_exponentiation!((160));
663        _for_each_inner_rsa_exponentiation!((192));
664        _for_each_inner_rsa_exponentiation!((224));
665        _for_each_inner_rsa_exponentiation!((256));
666        _for_each_inner_rsa_exponentiation!((288));
667        _for_each_inner_rsa_exponentiation!((320));
668        _for_each_inner_rsa_exponentiation!((352));
669        _for_each_inner_rsa_exponentiation!((384));
670        _for_each_inner_rsa_exponentiation!((416));
671        _for_each_inner_rsa_exponentiation!((448));
672        _for_each_inner_rsa_exponentiation!((480));
673        _for_each_inner_rsa_exponentiation!((512));
674        _for_each_inner_rsa_exponentiation!((544));
675        _for_each_inner_rsa_exponentiation!((576));
676        _for_each_inner_rsa_exponentiation!((608));
677        _for_each_inner_rsa_exponentiation!((640));
678        _for_each_inner_rsa_exponentiation!((672));
679        _for_each_inner_rsa_exponentiation!((704));
680        _for_each_inner_rsa_exponentiation!((736));
681        _for_each_inner_rsa_exponentiation!((768));
682        _for_each_inner_rsa_exponentiation!((800));
683        _for_each_inner_rsa_exponentiation!((832));
684        _for_each_inner_rsa_exponentiation!((864));
685        _for_each_inner_rsa_exponentiation!((896));
686        _for_each_inner_rsa_exponentiation!((928));
687        _for_each_inner_rsa_exponentiation!((960));
688        _for_each_inner_rsa_exponentiation!((992));
689        _for_each_inner_rsa_exponentiation!((1024));
690        _for_each_inner_rsa_exponentiation!((1056));
691        _for_each_inner_rsa_exponentiation!((1088));
692        _for_each_inner_rsa_exponentiation!((1120));
693        _for_each_inner_rsa_exponentiation!((1152));
694        _for_each_inner_rsa_exponentiation!((1184));
695        _for_each_inner_rsa_exponentiation!((1216));
696        _for_each_inner_rsa_exponentiation!((1248));
697        _for_each_inner_rsa_exponentiation!((1280));
698        _for_each_inner_rsa_exponentiation!((1312));
699        _for_each_inner_rsa_exponentiation!((1344));
700        _for_each_inner_rsa_exponentiation!((1376));
701        _for_each_inner_rsa_exponentiation!((1408));
702        _for_each_inner_rsa_exponentiation!((1440));
703        _for_each_inner_rsa_exponentiation!((1472));
704        _for_each_inner_rsa_exponentiation!((1504));
705        _for_each_inner_rsa_exponentiation!((1536));
706        _for_each_inner_rsa_exponentiation!((1568));
707        _for_each_inner_rsa_exponentiation!((1600));
708        _for_each_inner_rsa_exponentiation!((1632));
709        _for_each_inner_rsa_exponentiation!((1664));
710        _for_each_inner_rsa_exponentiation!((1696));
711        _for_each_inner_rsa_exponentiation!((1728));
712        _for_each_inner_rsa_exponentiation!((1760));
713        _for_each_inner_rsa_exponentiation!((1792));
714        _for_each_inner_rsa_exponentiation!((1824));
715        _for_each_inner_rsa_exponentiation!((1856));
716        _for_each_inner_rsa_exponentiation!((1888));
717        _for_each_inner_rsa_exponentiation!((1920));
718        _for_each_inner_rsa_exponentiation!((1952));
719        _for_each_inner_rsa_exponentiation!((1984));
720        _for_each_inner_rsa_exponentiation!((2016));
721        _for_each_inner_rsa_exponentiation!((2048));
722        _for_each_inner_rsa_exponentiation!((2080));
723        _for_each_inner_rsa_exponentiation!((2112));
724        _for_each_inner_rsa_exponentiation!((2144));
725        _for_each_inner_rsa_exponentiation!((2176));
726        _for_each_inner_rsa_exponentiation!((2208));
727        _for_each_inner_rsa_exponentiation!((2240));
728        _for_each_inner_rsa_exponentiation!((2272));
729        _for_each_inner_rsa_exponentiation!((2304));
730        _for_each_inner_rsa_exponentiation!((2336));
731        _for_each_inner_rsa_exponentiation!((2368));
732        _for_each_inner_rsa_exponentiation!((2400));
733        _for_each_inner_rsa_exponentiation!((2432));
734        _for_each_inner_rsa_exponentiation!((2464));
735        _for_each_inner_rsa_exponentiation!((2496));
736        _for_each_inner_rsa_exponentiation!((2528));
737        _for_each_inner_rsa_exponentiation!((2560));
738        _for_each_inner_rsa_exponentiation!((2592));
739        _for_each_inner_rsa_exponentiation!((2624));
740        _for_each_inner_rsa_exponentiation!((2656));
741        _for_each_inner_rsa_exponentiation!((2688));
742        _for_each_inner_rsa_exponentiation!((2720));
743        _for_each_inner_rsa_exponentiation!((2752));
744        _for_each_inner_rsa_exponentiation!((2784));
745        _for_each_inner_rsa_exponentiation!((2816));
746        _for_each_inner_rsa_exponentiation!((2848));
747        _for_each_inner_rsa_exponentiation!((2880));
748        _for_each_inner_rsa_exponentiation!((2912));
749        _for_each_inner_rsa_exponentiation!((2944));
750        _for_each_inner_rsa_exponentiation!((2976));
751        _for_each_inner_rsa_exponentiation!((3008));
752        _for_each_inner_rsa_exponentiation!((3040));
753        _for_each_inner_rsa_exponentiation!((3072));
754        _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
755        (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
756        (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
757        (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
758        (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
759        (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
760        (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
761        (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
762        (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
763        (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
764    };
765}
766#[macro_export]
767#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
768macro_rules! for_each_rsa_multiplication {
769    ($($pattern:tt => $code:tt;)*) => {
770        macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
771        ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
772        _for_each_inner_rsa_multiplication!((64));
773        _for_each_inner_rsa_multiplication!((96));
774        _for_each_inner_rsa_multiplication!((128));
775        _for_each_inner_rsa_multiplication!((160));
776        _for_each_inner_rsa_multiplication!((192));
777        _for_each_inner_rsa_multiplication!((224));
778        _for_each_inner_rsa_multiplication!((256));
779        _for_each_inner_rsa_multiplication!((288));
780        _for_each_inner_rsa_multiplication!((320));
781        _for_each_inner_rsa_multiplication!((352));
782        _for_each_inner_rsa_multiplication!((384));
783        _for_each_inner_rsa_multiplication!((416));
784        _for_each_inner_rsa_multiplication!((448));
785        _for_each_inner_rsa_multiplication!((480));
786        _for_each_inner_rsa_multiplication!((512));
787        _for_each_inner_rsa_multiplication!((544));
788        _for_each_inner_rsa_multiplication!((576));
789        _for_each_inner_rsa_multiplication!((608));
790        _for_each_inner_rsa_multiplication!((640));
791        _for_each_inner_rsa_multiplication!((672));
792        _for_each_inner_rsa_multiplication!((704));
793        _for_each_inner_rsa_multiplication!((736));
794        _for_each_inner_rsa_multiplication!((768));
795        _for_each_inner_rsa_multiplication!((800));
796        _for_each_inner_rsa_multiplication!((832));
797        _for_each_inner_rsa_multiplication!((864));
798        _for_each_inner_rsa_multiplication!((896));
799        _for_each_inner_rsa_multiplication!((928));
800        _for_each_inner_rsa_multiplication!((960));
801        _for_each_inner_rsa_multiplication!((992));
802        _for_each_inner_rsa_multiplication!((1024));
803        _for_each_inner_rsa_multiplication!((1056));
804        _for_each_inner_rsa_multiplication!((1088));
805        _for_each_inner_rsa_multiplication!((1120));
806        _for_each_inner_rsa_multiplication!((1152));
807        _for_each_inner_rsa_multiplication!((1184));
808        _for_each_inner_rsa_multiplication!((1216));
809        _for_each_inner_rsa_multiplication!((1248));
810        _for_each_inner_rsa_multiplication!((1280));
811        _for_each_inner_rsa_multiplication!((1312));
812        _for_each_inner_rsa_multiplication!((1344));
813        _for_each_inner_rsa_multiplication!((1376));
814        _for_each_inner_rsa_multiplication!((1408));
815        _for_each_inner_rsa_multiplication!((1440));
816        _for_each_inner_rsa_multiplication!((1472));
817        _for_each_inner_rsa_multiplication!((1504));
818        _for_each_inner_rsa_multiplication!((1536));
819        _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
820        (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
821        (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
822        (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
823        (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
824    };
825}
826#[macro_export]
827#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
828macro_rules! for_each_sha_algorithm {
829    ($($pattern:tt => $code:tt;)*) => {
830        macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
831        tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
832        (insecure_against : "collision", "length extension"), 0));
833        _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
834        (insecure_against : "length extension"), 1));
835        _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
836        (insecure_against : "length extension"), 2));
837        _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
838        (insecure_against : "collision", "length extension"), 0), (Sha224,
839        "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
840        (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
841        2)));
842    };
843}
844#[macro_export]
845/// ESP-HAL must provide implementation for the following functions:
846/// ```rust, no_run
847/// // XTAL_CLK
848///
849/// fn configure_xtal_clk_impl(
850///     _clocks: &mut ClockTree,
851///     _old_config: Option<XtalClkConfig>,
852///     _new_config: XtalClkConfig,
853/// ) {
854///     todo!()
855/// }
856///
857/// // PLL_F96M_CLK
858///
859/// fn enable_pll_f96m_clk_impl(_clocks: &mut ClockTree, _en: bool) {
860///     todo!()
861/// }
862///
863/// // PLL_F64M_CLK
864///
865/// fn enable_pll_f64m_clk_impl(_clocks: &mut ClockTree, _en: bool) {
866///     todo!()
867/// }
868///
869/// // PLL_F48M_CLK
870///
871/// fn enable_pll_f48m_clk_impl(_clocks: &mut ClockTree, _en: bool) {
872///     todo!()
873/// }
874///
875/// // RC_FAST_CLK
876///
877/// fn enable_rc_fast_clk_impl(_clocks: &mut ClockTree, _en: bool) {
878///     todo!()
879/// }
880///
881/// // XTAL32K_CLK
882///
883/// fn enable_xtal32k_clk_impl(_clocks: &mut ClockTree, _en: bool) {
884///     todo!()
885/// }
886///
887/// // OSC_SLOW_CLK
888///
889/// fn enable_osc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
890///     todo!()
891/// }
892///
893/// // RC_SLOW_CLK
894///
895/// fn enable_rc_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
896///     todo!()
897/// }
898///
899/// // PLL_LP_CLK
900///
901/// fn enable_pll_lp_clk_impl(_clocks: &mut ClockTree, _en: bool) {
902///     todo!()
903/// }
904///
905/// // HP_ROOT_CLK
906///
907/// fn enable_hp_root_clk_impl(_clocks: &mut ClockTree, _en: bool) {
908///     todo!()
909/// }
910///
911/// fn configure_hp_root_clk_impl(
912///     _clocks: &mut ClockTree,
913///     _old_config: Option<HpRootClkConfig>,
914///     _new_config: HpRootClkConfig,
915/// ) {
916///     todo!()
917/// }
918///
919/// // CPU_CLK
920///
921/// fn configure_cpu_clk_impl(
922///     _clocks: &mut ClockTree,
923///     _old_config: Option<CpuClkConfig>,
924///     _new_config: CpuClkConfig,
925/// ) {
926///     todo!()
927/// }
928///
929/// // AHB_CLK
930///
931/// fn configure_ahb_clk_impl(
932///     _clocks: &mut ClockTree,
933///     _old_config: Option<AhbClkConfig>,
934///     _new_config: AhbClkConfig,
935/// ) {
936///     todo!()
937/// }
938///
939/// // APB_CLK
940///
941/// fn enable_apb_clk_impl(_clocks: &mut ClockTree, _en: bool) {
942///     todo!()
943/// }
944///
945/// fn configure_apb_clk_impl(
946///     _clocks: &mut ClockTree,
947///     _old_config: Option<ApbClkConfig>,
948///     _new_config: ApbClkConfig,
949/// ) {
950///     todo!()
951/// }
952///
953/// // XTAL_D2_CLK
954///
955/// fn enable_xtal_d2_clk_impl(_clocks: &mut ClockTree, _en: bool) {
956///     todo!()
957/// }
958///
959/// // LP_FAST_CLK
960///
961/// fn enable_lp_fast_clk_impl(_clocks: &mut ClockTree, _en: bool) {
962///     todo!()
963/// }
964///
965/// fn configure_lp_fast_clk_impl(
966///     _clocks: &mut ClockTree,
967///     _old_config: Option<LpFastClkConfig>,
968///     _new_config: LpFastClkConfig,
969/// ) {
970///     todo!()
971/// }
972///
973/// // LP_SLOW_CLK
974///
975/// fn enable_lp_slow_clk_impl(_clocks: &mut ClockTree, _en: bool) {
976///     todo!()
977/// }
978///
979/// fn configure_lp_slow_clk_impl(
980///     _clocks: &mut ClockTree,
981///     _old_config: Option<LpSlowClkConfig>,
982///     _new_config: LpSlowClkConfig,
983/// ) {
984///     todo!()
985/// }
986///
987/// // TIMG_CALIBRATION_CLOCK
988///
989/// fn enable_timg_calibration_clock_impl(_clocks: &mut ClockTree, _en: bool) {
990///     todo!()
991/// }
992///
993/// fn configure_timg_calibration_clock_impl(
994///     _clocks: &mut ClockTree,
995///     _old_config: Option<TimgCalibrationClockConfig>,
996///     _new_config: TimgCalibrationClockConfig,
997/// ) {
998///     todo!()
999/// }
1000///
1001/// impl McpwmInstance {
1002///     // MCPWM_FUNCTION_CLOCK
1003///
1004///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1005///         todo!()
1006///     }
1007///
1008///     fn configure_function_clock_impl(
1009///         self,
1010///         _clocks: &mut ClockTree,
1011///         _old_config: Option<McpwmFunctionClockConfig>,
1012///         _new_config: McpwmFunctionClockConfig,
1013///     ) {
1014///         todo!()
1015///     }
1016/// }
1017/// impl ParlIoInstance {
1018///     // PARL_IO_RX_CLOCK
1019///
1020///     fn enable_rx_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1021///         todo!()
1022///     }
1023///
1024///     fn configure_rx_clock_impl(
1025///         self,
1026///         _clocks: &mut ClockTree,
1027///         _old_config: Option<ParlIoRxClockConfig>,
1028///         _new_config: ParlIoRxClockConfig,
1029///     ) {
1030///         todo!()
1031///     }
1032///
1033///     // PARL_IO_TX_CLOCK
1034///
1035///     fn enable_tx_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1036///         todo!()
1037///     }
1038///
1039///     fn configure_tx_clock_impl(
1040///         self,
1041///         _clocks: &mut ClockTree,
1042///         _old_config: Option<ParlIoTxClockConfig>,
1043///         _new_config: ParlIoTxClockConfig,
1044///     ) {
1045///         todo!()
1046///     }
1047/// }
1048/// impl RmtInstance {
1049///     // RMT_SCLK
1050///
1051///     fn enable_sclk_impl(self, _clocks: &mut ClockTree, _en: bool) {
1052///         todo!()
1053///     }
1054///
1055///     fn configure_sclk_impl(
1056///         self,
1057///         _clocks: &mut ClockTree,
1058///         _old_config: Option<RmtSclkConfig>,
1059///         _new_config: RmtSclkConfig,
1060///     ) {
1061///         todo!()
1062///     }
1063/// }
1064/// impl TimgInstance {
1065///     // TIMG_FUNCTION_CLOCK
1066///
1067///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1068///         todo!()
1069///     }
1070///
1071///     fn configure_function_clock_impl(
1072///         self,
1073///         _clocks: &mut ClockTree,
1074///         _old_config: Option<TimgFunctionClockConfig>,
1075///         _new_config: TimgFunctionClockConfig,
1076///     ) {
1077///         todo!()
1078///     }
1079///
1080///     // TIMG_WDT_CLOCK
1081///
1082///     fn enable_wdt_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1083///         todo!()
1084///     }
1085///
1086///     fn configure_wdt_clock_impl(
1087///         self,
1088///         _clocks: &mut ClockTree,
1089///         _old_config: Option<TimgWdtClockConfig>,
1090///         _new_config: TimgWdtClockConfig,
1091///     ) {
1092///         todo!()
1093///     }
1094/// }
1095/// impl UartInstance {
1096///     // UART_FUNCTION_CLOCK
1097///
1098///     fn enable_function_clock_impl(self, _clocks: &mut ClockTree, _en: bool) {
1099///         todo!()
1100///     }
1101///
1102///     fn configure_function_clock_impl(
1103///         self,
1104///         _clocks: &mut ClockTree,
1105///         _old_config: Option<UartFunctionClockConfig>,
1106///         _new_config: UartFunctionClockConfig,
1107///     ) {
1108///         todo!()
1109///     }
1110///
1111///     // UART_BAUD_RATE_GENERATOR
1112///
1113///     fn enable_baud_rate_generator_impl(self, _clocks: &mut ClockTree, _en: bool) {
1114///         todo!()
1115///     }
1116///
1117///     fn configure_baud_rate_generator_impl(
1118///         self,
1119///         _clocks: &mut ClockTree,
1120///         _old_config: Option<UartBaudRateGeneratorConfig>,
1121///         _new_config: UartBaudRateGeneratorConfig,
1122///     ) {
1123///         todo!()
1124///     }
1125/// }
1126/// ```
1127macro_rules! define_clock_tree_types {
1128    () => {
1129        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1130        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1131        pub enum McpwmInstance {
1132            Mcpwm0 = 0,
1133        }
1134        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1135        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1136        pub enum ParlIoInstance {
1137            ParlIo = 0,
1138        }
1139        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1140        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1141        pub enum RmtInstance {
1142            Rmt = 0,
1143        }
1144        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1145        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1146        pub enum TimgInstance {
1147            Timg0 = 0,
1148            Timg1 = 1,
1149        }
1150        #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1151        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1152        pub enum UartInstance {
1153            Uart0 = 0,
1154            Uart1 = 1,
1155        }
1156        /// Selects the output frequency of `XTAL_CLK`.
1157        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1158        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1159        pub enum XtalClkConfig {
1160            /// 32 MHz
1161            _32,
1162        }
1163        impl XtalClkConfig {
1164            pub fn value(&self) -> u32 {
1165                match self {
1166                    XtalClkConfig::_32 => 32000000,
1167                }
1168            }
1169        }
1170        /// The list of clock signals that the `HP_ROOT_CLK` multiplexer can output.
1171        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1172        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1173        pub enum HpRootClkConfig {
1174            /// Selects `PLL_F96M_CLK`.
1175            Pll96,
1176            /// Selects `PLL_F64M_CLK`.
1177            Pll64,
1178            /// Selects `XTAL_CLK`.
1179            Xtal,
1180            /// Selects `RC_FAST_CLK`.
1181            RcFast,
1182        }
1183        /// Configures the `CPU_CLK` clock node.
1184        ///
1185        /// The output is calculated as `OUTPUT = HP_ROOT_CLK / (divisor + 1)`.
1186        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1187        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1188        pub struct CpuClkConfig {
1189            divisor: u32,
1190        }
1191        impl CpuClkConfig {
1192            /// Creates a new configuration for the CPU_CLK clock node.
1193            ///
1194            /// ## Panics
1195            ///
1196            /// Panics if the divisor value is outside the
1197            /// valid range (0 ..= 255).
1198            pub const fn new(divisor: u32) -> Self {
1199                ::core::assert!(
1200                    divisor <= 255,
1201                    "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1202                );
1203                Self { divisor }
1204            }
1205            fn divisor(self) -> u32 {
1206                self.divisor as u32
1207            }
1208        }
1209        /// Configures the `AHB_CLK` clock node.
1210        ///
1211        /// The output is calculated as `OUTPUT = HP_ROOT_CLK / (divisor + 1)`.
1212        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1213        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1214        pub struct AhbClkConfig {
1215            divisor: u32,
1216        }
1217        impl AhbClkConfig {
1218            /// Creates a new configuration for the AHB_CLK clock node.
1219            ///
1220            /// ## Panics
1221            ///
1222            /// Panics if the divisor value is outside the
1223            /// valid range (0 ..= 255).
1224            pub const fn new(divisor: u32) -> Self {
1225                ::core::assert!(
1226                    divisor <= 255,
1227                    "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1228                );
1229                Self { divisor }
1230            }
1231            fn divisor(self) -> u32 {
1232                self.divisor as u32
1233            }
1234        }
1235        /// Configures the `APB_CLK` clock node.
1236        ///
1237        /// The output is calculated as `OUTPUT = AHB_CLK / (divisor + 1)`.
1238        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1239        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1240        pub struct ApbClkConfig {
1241            divisor: u32,
1242        }
1243        impl ApbClkConfig {
1244            /// Creates a new configuration for the APB_CLK clock node.
1245            ///
1246            /// ## Panics
1247            ///
1248            /// Panics if the divisor value is outside the
1249            /// valid range (0 ..= 255).
1250            pub const fn new(divisor: u32) -> Self {
1251                ::core::assert!(
1252                    divisor <= 255,
1253                    "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1254                );
1255                Self { divisor }
1256            }
1257            fn divisor(self) -> u32 {
1258                self.divisor as u32
1259            }
1260        }
1261        /// The list of clock signals that the `LP_FAST_CLK` multiplexer can output.
1262        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1263        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1264        pub enum LpFastClkConfig {
1265            /// Selects `RC_FAST_CLK`.
1266            RcFastClk,
1267            /// Selects `PLL_LP_CLK`.
1268            PllLpClk,
1269            /// Selects `XTAL_D2_CLK`.
1270            XtalD2Clk,
1271        }
1272        /// The list of clock signals that the `LP_SLOW_CLK` multiplexer can output.
1273        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1274        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1275        pub enum LpSlowClkConfig {
1276            /// Selects `XTAL32K_CLK`.
1277            Xtal32k,
1278            /// Selects `RC_SLOW_CLK`.
1279            RcSlow,
1280            /// Selects `OSC_SLOW_CLK`.
1281            OscSlow,
1282        }
1283        /// The list of clock signals that the `TIMG_CALIBRATION_CLOCK` multiplexer can output.
1284        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1285        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1286        pub enum TimgCalibrationClockConfig {
1287            /// Selects `LP_SLOW_CLK`.
1288            RcSlowClk,
1289            /// Selects `RC_FAST_CLK`.
1290            RcFastDivClk,
1291            /// Selects `XTAL32K_CLK`.
1292            Xtal32kClk,
1293        }
1294        /// The list of clock signals that the `MCPWM0_FUNCTION_CLOCK` multiplexer can output.
1295        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1296        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1297        pub enum McpwmFunctionClockConfig {
1298            #[default]
1299            /// Selects `PLL_F96M_CLK`.
1300            PllF96m,
1301            /// Selects `RC_FAST_CLK`.
1302            RcFastClk,
1303            /// Selects `XTAL_CLK`.
1304            XtalClk,
1305        }
1306        /// The list of clock signals that the `PARL_IO_RX_CLOCK` multiplexer can output.
1307        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1308        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1309        pub enum ParlIoRxClockConfig {
1310            /// Selects `XTAL_CLK`.
1311            XtalClk,
1312            /// Selects `RC_FAST_CLK`.
1313            RcFastClk,
1314            #[default]
1315            /// Selects `PLL_F96M_CLK`.
1316            PllF96m,
1317        }
1318        /// The list of clock signals that the `PARL_IO_TX_CLOCK` multiplexer can output.
1319        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1320        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1321        pub enum ParlIoTxClockConfig {
1322            /// Selects `XTAL_CLK`.
1323            XtalClk,
1324            /// Selects `RC_FAST_CLK`.
1325            RcFastClk,
1326            #[default]
1327            /// Selects `PLL_F96M_CLK`.
1328            PllF96m,
1329        }
1330        /// The list of clock signals that the `RMT_SCLK` multiplexer can output.
1331        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1332        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1333        pub enum RmtSclkConfig {
1334            #[default]
1335            /// Selects `XTAL_CLK`.
1336            XtalClk,
1337            /// Selects `RC_FAST_CLK`.
1338            RcFastClk,
1339        }
1340        /// The list of clock signals that the `TIMG0_FUNCTION_CLOCK` multiplexer can output.
1341        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1342        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1343        pub enum TimgFunctionClockConfig {
1344            #[default]
1345            /// Selects `XTAL_CLK`.
1346            XtalClk,
1347            /// Selects `RC_FAST_CLK`.
1348            RcFastClk,
1349            /// Selects `PLL_F48M_CLK`.
1350            PllF48m,
1351        }
1352        /// The list of clock signals that the `TIMG0_WDT_CLOCK` multiplexer can output.
1353        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1354        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1355        pub enum TimgWdtClockConfig {
1356            #[default]
1357            /// Selects `XTAL_CLK`.
1358            XtalClk,
1359            /// Selects `RC_FAST_CLK`.
1360            RcFastClk,
1361            /// Selects `PLL_F48M_CLK`.
1362            PllF48m,
1363        }
1364        #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1365        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1366        pub enum UartFunctionClockSclk {
1367            /// Selects `PLL_F48M_CLK`.
1368            PllF48m,
1369            /// Selects `RC_FAST_CLK`.
1370            RcFast,
1371            #[default]
1372            /// Selects `XTAL_CLK`.
1373            Xtal,
1374        }
1375        /// Configures the `UART0_FUNCTION_CLOCK` clock node.
1376        ///
1377        /// The output is calculated as `OUTPUT = sclk / (div_num + 1)`.
1378        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1379        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1380        pub struct UartFunctionClockConfig {
1381            sclk: UartFunctionClockSclk,
1382            div_num: u32,
1383        }
1384        impl UartFunctionClockConfig {
1385            /// Creates a new configuration for the FUNCTION_CLOCK clock node.
1386            ///
1387            /// ## Panics
1388            ///
1389            /// Panics if the div_num value is outside the
1390            /// valid range (0 ..= 255).
1391            pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1392                ::core::assert!(
1393                    div_num <= 255,
1394                    "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1395                );
1396                Self { sclk, div_num }
1397            }
1398            fn sclk(self) -> UartFunctionClockSclk {
1399                self.sclk
1400            }
1401            fn div_num(self) -> u32 {
1402                self.div_num as u32
1403            }
1404        }
1405        /// Configures the `UART0_BAUD_RATE_GENERATOR` clock node.
1406        ///
1407        /// The output is calculated as `OUTPUT = (FUNCTION_CLOCK * 16) / (integral * 16 +
1408        /// fractional)`.
1409        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1410        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1411        pub struct UartBaudRateGeneratorConfig {
1412            fractional: u32,
1413            integral: u32,
1414        }
1415        impl UartBaudRateGeneratorConfig {
1416            /// Creates a new configuration for the BAUD_RATE_GENERATOR clock node.
1417            ///
1418            /// ## Panics
1419            ///
1420            /// Panics if the fractional value is outside the
1421            /// valid range (0 ..= 15).
1422            ///
1423            /// Panics if the integral value is outside the
1424            /// valid range (0 ..= 4095).
1425            pub const fn new(fractional: u32, integral: u32) -> Self {
1426                ::core::assert!(
1427                    fractional <= 15,
1428                    "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1429                );
1430                ::core::assert!(
1431                    integral <= 4095,
1432                    "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1433                );
1434                Self {
1435                    fractional,
1436                    integral,
1437                }
1438            }
1439            fn fractional(self) -> u32 {
1440                self.fractional as u32
1441            }
1442            fn integral(self) -> u32 {
1443                self.integral as u32
1444            }
1445        }
1446        /// Represents the device's clock tree.
1447        pub struct ClockTree {
1448            xtal_clk: Option<XtalClkConfig>,
1449            hp_root_clk: Option<HpRootClkConfig>,
1450            cpu_clk: Option<CpuClkConfig>,
1451            ahb_clk: Option<AhbClkConfig>,
1452            apb_clk: Option<ApbClkConfig>,
1453            lp_fast_clk: Option<LpFastClkConfig>,
1454            lp_slow_clk: Option<LpSlowClkConfig>,
1455            timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1456            mcpwm_function_clock: [Option<McpwmFunctionClockConfig>; 1],
1457            parl_io_rx_clock: [Option<ParlIoRxClockConfig>; 1],
1458            parl_io_tx_clock: [Option<ParlIoTxClockConfig>; 1],
1459            rmt_sclk: [Option<RmtSclkConfig>; 1],
1460            timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1461            timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1462            uart_function_clock: [Option<UartFunctionClockConfig>; 2],
1463            uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
1464            pll_f96m_clk_refcount: u32,
1465            pll_f48m_clk_refcount: u32,
1466            rc_fast_clk_refcount: u32,
1467            xtal32k_clk_refcount: u32,
1468            hp_root_clk_refcount: u32,
1469            apb_clk_refcount: u32,
1470            lp_fast_clk_refcount: u32,
1471            timg_calibration_clock_refcount: u32,
1472            mcpwm_function_clock_refcount: [u32; 1],
1473            parl_io_rx_clock_refcount: [u32; 1],
1474            parl_io_tx_clock_refcount: [u32; 1],
1475            rmt_sclk_refcount: [u32; 1],
1476            timg_function_clock_refcount: [u32; 2],
1477            timg_wdt_clock_refcount: [u32; 2],
1478            uart_function_clock_refcount: [u32; 2],
1479            uart_baud_rate_generator_refcount: [u32; 2],
1480        }
1481        impl ClockTree {
1482            /// Locks the clock tree for exclusive access.
1483            pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1484                CLOCK_TREE.with(f)
1485            }
1486            /// Returns the current configuration of the XTAL_CLK clock tree node
1487            pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1488                self.xtal_clk
1489            }
1490            /// Returns the current configuration of the HP_ROOT_CLK clock tree node
1491            pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
1492                self.hp_root_clk
1493            }
1494            /// Returns the current configuration of the CPU_CLK clock tree node
1495            pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1496                self.cpu_clk
1497            }
1498            /// Returns the current configuration of the AHB_CLK clock tree node
1499            pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
1500                self.ahb_clk
1501            }
1502            /// Returns the current configuration of the APB_CLK clock tree node
1503            pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1504                self.apb_clk
1505            }
1506            /// Returns the current configuration of the LP_FAST_CLK clock tree node
1507            pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
1508                self.lp_fast_clk
1509            }
1510            /// Returns the current configuration of the LP_SLOW_CLK clock tree node
1511            pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
1512                self.lp_slow_clk
1513            }
1514            /// Returns the current configuration of the TIMG_CALIBRATION_CLOCK clock tree node
1515            pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1516                self.timg_calibration_clock
1517            }
1518            /// Returns the current configuration of the MCPWM0_FUNCTION_CLOCK clock tree node
1519            pub fn mcpwm0_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
1520                self.mcpwm_function_clock[McpwmInstance::Mcpwm0 as usize]
1521            }
1522            /// Returns the current configuration of the PARL_IO_RX_CLOCK clock tree node
1523            pub fn parl_io_rx_clock(&self) -> Option<ParlIoRxClockConfig> {
1524                self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
1525            }
1526            /// Returns the current configuration of the PARL_IO_TX_CLOCK clock tree node
1527            pub fn parl_io_tx_clock(&self) -> Option<ParlIoTxClockConfig> {
1528                self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
1529            }
1530            /// Returns the current configuration of the RMT_SCLK clock tree node
1531            pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
1532                self.rmt_sclk[RmtInstance::Rmt as usize]
1533            }
1534            /// Returns the current configuration of the TIMG0_FUNCTION_CLOCK clock tree node
1535            pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1536                self.timg_function_clock[TimgInstance::Timg0 as usize]
1537            }
1538            /// Returns the current configuration of the TIMG0_WDT_CLOCK clock tree node
1539            pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1540                self.timg_wdt_clock[TimgInstance::Timg0 as usize]
1541            }
1542            /// Returns the current configuration of the TIMG1_FUNCTION_CLOCK clock tree node
1543            pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1544                self.timg_function_clock[TimgInstance::Timg1 as usize]
1545            }
1546            /// Returns the current configuration of the TIMG1_WDT_CLOCK clock tree node
1547            pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1548                self.timg_wdt_clock[TimgInstance::Timg1 as usize]
1549            }
1550            /// Returns the current configuration of the UART0_FUNCTION_CLOCK clock tree node
1551            pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1552                self.uart_function_clock[UartInstance::Uart0 as usize]
1553            }
1554            /// Returns the current configuration of the UART0_BAUD_RATE_GENERATOR clock tree node
1555            pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1556                self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1557            }
1558            /// Returns the current configuration of the UART1_FUNCTION_CLOCK clock tree node
1559            pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1560                self.uart_function_clock[UartInstance::Uart1 as usize]
1561            }
1562            /// Returns the current configuration of the UART1_BAUD_RATE_GENERATOR clock tree node
1563            pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1564                self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
1565            }
1566        }
1567        static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
1568            ::esp_sync::NonReentrantMutex::new(ClockTree {
1569                xtal_clk: None,
1570                hp_root_clk: None,
1571                cpu_clk: None,
1572                ahb_clk: None,
1573                apb_clk: None,
1574                lp_fast_clk: None,
1575                lp_slow_clk: None,
1576                timg_calibration_clock: None,
1577                mcpwm_function_clock: [None; 1],
1578                parl_io_rx_clock: [None; 1],
1579                parl_io_tx_clock: [None; 1],
1580                rmt_sclk: [None; 1],
1581                timg_function_clock: [None; 2],
1582                timg_wdt_clock: [None; 2],
1583                uart_function_clock: [None; 2],
1584                uart_baud_rate_generator: [None; 2],
1585                pll_f96m_clk_refcount: 0,
1586                pll_f48m_clk_refcount: 0,
1587                rc_fast_clk_refcount: 0,
1588                xtal32k_clk_refcount: 0,
1589                hp_root_clk_refcount: 0,
1590                apb_clk_refcount: 0,
1591                lp_fast_clk_refcount: 0,
1592                timg_calibration_clock_refcount: 0,
1593                mcpwm_function_clock_refcount: [0; 1],
1594                parl_io_rx_clock_refcount: [0; 1],
1595                parl_io_tx_clock_refcount: [0; 1],
1596                rmt_sclk_refcount: [0; 1],
1597                timg_function_clock_refcount: [0; 2],
1598                timg_wdt_clock_refcount: [0; 2],
1599                uart_function_clock_refcount: [0; 2],
1600                uart_baud_rate_generator_refcount: [0; 2],
1601            });
1602        pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
1603            let old_config = clocks.xtal_clk.replace(config);
1604            configure_xtal_clk_impl(clocks, old_config, config);
1605        }
1606        pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
1607            clocks.xtal_clk
1608        }
1609        fn request_xtal_clk(_clocks: &mut ClockTree) {}
1610        fn release_xtal_clk(_clocks: &mut ClockTree) {}
1611        #[allow(unused_variables)]
1612        pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
1613            config.value()
1614        }
1615        pub fn xtal_clk_frequency(clocks: &mut ClockTree) -> u32 {
1616            if let Some(config) = clocks.xtal_clk {
1617                xtal_clk_config_frequency(clocks, config)
1618            } else {
1619                0
1620            }
1621        }
1622        pub fn request_pll_f96m_clk(clocks: &mut ClockTree) {
1623            trace!("Requesting PLL_F96M_CLK");
1624            if increment_reference_count(&mut clocks.pll_f96m_clk_refcount) {
1625                trace!("Enabling PLL_F96M_CLK");
1626                request_xtal_clk(clocks);
1627                enable_pll_f96m_clk_impl(clocks, true);
1628            }
1629        }
1630        pub fn release_pll_f96m_clk(clocks: &mut ClockTree) {
1631            trace!("Releasing PLL_F96M_CLK");
1632            if decrement_reference_count(&mut clocks.pll_f96m_clk_refcount) {
1633                trace!("Disabling PLL_F96M_CLK");
1634                enable_pll_f96m_clk_impl(clocks, false);
1635                release_xtal_clk(clocks);
1636            }
1637        }
1638        pub fn pll_f96m_clk_frequency(clocks: &mut ClockTree) -> u32 {
1639            96000000
1640        }
1641        pub fn request_pll_f64m_clk(clocks: &mut ClockTree) {
1642            trace!("Requesting PLL_F64M_CLK");
1643            trace!("Enabling PLL_F64M_CLK");
1644            request_pll_f96m_clk(clocks);
1645            enable_pll_f64m_clk_impl(clocks, true);
1646        }
1647        pub fn release_pll_f64m_clk(clocks: &mut ClockTree) {
1648            trace!("Releasing PLL_F64M_CLK");
1649            trace!("Disabling PLL_F64M_CLK");
1650            enable_pll_f64m_clk_impl(clocks, false);
1651            release_pll_f96m_clk(clocks);
1652        }
1653        pub fn pll_f64m_clk_frequency(clocks: &mut ClockTree) -> u32 {
1654            ((pll_f96m_clk_frequency(clocks) * 2) / 3)
1655        }
1656        pub fn request_pll_f48m_clk(clocks: &mut ClockTree) {
1657            trace!("Requesting PLL_F48M_CLK");
1658            if increment_reference_count(&mut clocks.pll_f48m_clk_refcount) {
1659                trace!("Enabling PLL_F48M_CLK");
1660                request_pll_f96m_clk(clocks);
1661                enable_pll_f48m_clk_impl(clocks, true);
1662            }
1663        }
1664        pub fn release_pll_f48m_clk(clocks: &mut ClockTree) {
1665            trace!("Releasing PLL_F48M_CLK");
1666            if decrement_reference_count(&mut clocks.pll_f48m_clk_refcount) {
1667                trace!("Disabling PLL_F48M_CLK");
1668                enable_pll_f48m_clk_impl(clocks, false);
1669                release_pll_f96m_clk(clocks);
1670            }
1671        }
1672        pub fn pll_f48m_clk_frequency(clocks: &mut ClockTree) -> u32 {
1673            (pll_f96m_clk_frequency(clocks) / 2)
1674        }
1675        pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
1676            trace!("Requesting RC_FAST_CLK");
1677            if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
1678                trace!("Enabling RC_FAST_CLK");
1679                enable_rc_fast_clk_impl(clocks, true);
1680            }
1681        }
1682        pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
1683            trace!("Releasing RC_FAST_CLK");
1684            if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
1685                trace!("Disabling RC_FAST_CLK");
1686                enable_rc_fast_clk_impl(clocks, false);
1687            }
1688        }
1689        pub fn rc_fast_clk_frequency(clocks: &mut ClockTree) -> u32 {
1690            8000000
1691        }
1692        pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
1693            trace!("Requesting XTAL32K_CLK");
1694            if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
1695                trace!("Enabling XTAL32K_CLK");
1696                enable_xtal32k_clk_impl(clocks, true);
1697            }
1698        }
1699        pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
1700            trace!("Releasing XTAL32K_CLK");
1701            if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
1702                trace!("Disabling XTAL32K_CLK");
1703                enable_xtal32k_clk_impl(clocks, false);
1704            }
1705        }
1706        pub fn xtal32k_clk_frequency(clocks: &mut ClockTree) -> u32 {
1707            32768
1708        }
1709        pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
1710            trace!("Requesting OSC_SLOW_CLK");
1711            trace!("Enabling OSC_SLOW_CLK");
1712            enable_osc_slow_clk_impl(clocks, true);
1713        }
1714        pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
1715            trace!("Releasing OSC_SLOW_CLK");
1716            trace!("Disabling OSC_SLOW_CLK");
1717            enable_osc_slow_clk_impl(clocks, false);
1718        }
1719        pub fn osc_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
1720            32768
1721        }
1722        pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
1723            trace!("Requesting RC_SLOW_CLK");
1724            trace!("Enabling RC_SLOW_CLK");
1725            enable_rc_slow_clk_impl(clocks, true);
1726        }
1727        pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
1728            trace!("Releasing RC_SLOW_CLK");
1729            trace!("Disabling RC_SLOW_CLK");
1730            enable_rc_slow_clk_impl(clocks, false);
1731        }
1732        pub fn rc_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
1733            130000
1734        }
1735        pub fn request_pll_lp_clk(clocks: &mut ClockTree) {
1736            trace!("Requesting PLL_LP_CLK");
1737            trace!("Enabling PLL_LP_CLK");
1738            request_xtal32k_clk(clocks);
1739            enable_pll_lp_clk_impl(clocks, true);
1740        }
1741        pub fn release_pll_lp_clk(clocks: &mut ClockTree) {
1742            trace!("Releasing PLL_LP_CLK");
1743            trace!("Disabling PLL_LP_CLK");
1744            enable_pll_lp_clk_impl(clocks, false);
1745            release_xtal32k_clk(clocks);
1746        }
1747        pub fn pll_lp_clk_frequency(clocks: &mut ClockTree) -> u32 {
1748            8000000
1749        }
1750        pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
1751            let old_selector = clocks.hp_root_clk.replace(new_selector);
1752            if clocks.hp_root_clk_refcount > 0 {
1753                match new_selector {
1754                    HpRootClkConfig::Pll96 => request_pll_f96m_clk(clocks),
1755                    HpRootClkConfig::Pll64 => request_pll_f64m_clk(clocks),
1756                    HpRootClkConfig::Xtal => request_xtal_clk(clocks),
1757                    HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
1758                }
1759                configure_hp_root_clk_impl(clocks, old_selector, new_selector);
1760                if let Some(old_selector) = old_selector {
1761                    match old_selector {
1762                        HpRootClkConfig::Pll96 => release_pll_f96m_clk(clocks),
1763                        HpRootClkConfig::Pll64 => release_pll_f64m_clk(clocks),
1764                        HpRootClkConfig::Xtal => release_xtal_clk(clocks),
1765                        HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
1766                    }
1767                }
1768            } else {
1769                configure_hp_root_clk_impl(clocks, old_selector, new_selector);
1770            }
1771        }
1772        pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
1773            clocks.hp_root_clk
1774        }
1775        pub fn request_hp_root_clk(clocks: &mut ClockTree) {
1776            trace!("Requesting HP_ROOT_CLK");
1777            if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
1778                trace!("Enabling HP_ROOT_CLK");
1779                match unwrap!(clocks.hp_root_clk) {
1780                    HpRootClkConfig::Pll96 => request_pll_f96m_clk(clocks),
1781                    HpRootClkConfig::Pll64 => request_pll_f64m_clk(clocks),
1782                    HpRootClkConfig::Xtal => request_xtal_clk(clocks),
1783                    HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
1784                }
1785                enable_hp_root_clk_impl(clocks, true);
1786            }
1787        }
1788        pub fn release_hp_root_clk(clocks: &mut ClockTree) {
1789            trace!("Releasing HP_ROOT_CLK");
1790            if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
1791                trace!("Disabling HP_ROOT_CLK");
1792                enable_hp_root_clk_impl(clocks, false);
1793                match unwrap!(clocks.hp_root_clk) {
1794                    HpRootClkConfig::Pll96 => release_pll_f96m_clk(clocks),
1795                    HpRootClkConfig::Pll64 => release_pll_f64m_clk(clocks),
1796                    HpRootClkConfig::Xtal => release_xtal_clk(clocks),
1797                    HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
1798                }
1799            }
1800        }
1801        #[allow(unused_variables)]
1802        pub fn hp_root_clk_config_frequency(
1803            clocks: &mut ClockTree,
1804            config: HpRootClkConfig,
1805        ) -> u32 {
1806            match config {
1807                HpRootClkConfig::Pll96 => pll_f96m_clk_frequency(clocks),
1808                HpRootClkConfig::Pll64 => pll_f64m_clk_frequency(clocks),
1809                HpRootClkConfig::Xtal => xtal_clk_frequency(clocks),
1810                HpRootClkConfig::RcFast => rc_fast_clk_frequency(clocks),
1811            }
1812        }
1813        pub fn hp_root_clk_frequency(clocks: &mut ClockTree) -> u32 {
1814            if let Some(config) = clocks.hp_root_clk {
1815                hp_root_clk_config_frequency(clocks, config)
1816            } else {
1817                0
1818            }
1819        }
1820        pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
1821            let old_config = clocks.cpu_clk.replace(config);
1822            configure_cpu_clk_impl(clocks, old_config, config);
1823        }
1824        pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
1825            clocks.cpu_clk
1826        }
1827        fn request_cpu_clk(_clocks: &mut ClockTree) {}
1828        fn release_cpu_clk(_clocks: &mut ClockTree) {}
1829        #[allow(unused_variables)]
1830        pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
1831            (hp_root_clk_frequency(clocks) / (config.divisor() + 1))
1832        }
1833        pub fn cpu_clk_frequency(clocks: &mut ClockTree) -> u32 {
1834            if let Some(config) = clocks.cpu_clk {
1835                cpu_clk_config_frequency(clocks, config)
1836            } else {
1837                0
1838            }
1839        }
1840        pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
1841            let old_config = clocks.ahb_clk.replace(config);
1842            configure_ahb_clk_impl(clocks, old_config, config);
1843        }
1844        pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
1845            clocks.ahb_clk
1846        }
1847        fn request_ahb_clk(_clocks: &mut ClockTree) {}
1848        fn release_ahb_clk(_clocks: &mut ClockTree) {}
1849        #[allow(unused_variables)]
1850        pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
1851            (hp_root_clk_frequency(clocks) / (config.divisor() + 1))
1852        }
1853        pub fn ahb_clk_frequency(clocks: &mut ClockTree) -> u32 {
1854            if let Some(config) = clocks.ahb_clk {
1855                ahb_clk_config_frequency(clocks, config)
1856            } else {
1857                0
1858            }
1859        }
1860        pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
1861            let old_config = clocks.apb_clk.replace(config);
1862            configure_apb_clk_impl(clocks, old_config, config);
1863        }
1864        pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
1865            clocks.apb_clk
1866        }
1867        pub fn request_apb_clk(clocks: &mut ClockTree) {
1868            trace!("Requesting APB_CLK");
1869            if increment_reference_count(&mut clocks.apb_clk_refcount) {
1870                trace!("Enabling APB_CLK");
1871                request_ahb_clk(clocks);
1872                enable_apb_clk_impl(clocks, true);
1873            }
1874        }
1875        pub fn release_apb_clk(clocks: &mut ClockTree) {
1876            trace!("Releasing APB_CLK");
1877            if decrement_reference_count(&mut clocks.apb_clk_refcount) {
1878                trace!("Disabling APB_CLK");
1879                enable_apb_clk_impl(clocks, false);
1880                release_ahb_clk(clocks);
1881            }
1882        }
1883        #[allow(unused_variables)]
1884        pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
1885            (ahb_clk_frequency(clocks) / (config.divisor() + 1))
1886        }
1887        pub fn apb_clk_frequency(clocks: &mut ClockTree) -> u32 {
1888            if let Some(config) = clocks.apb_clk {
1889                apb_clk_config_frequency(clocks, config)
1890            } else {
1891                0
1892            }
1893        }
1894        pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
1895            trace!("Requesting XTAL_D2_CLK");
1896            trace!("Enabling XTAL_D2_CLK");
1897            request_xtal_clk(clocks);
1898            enable_xtal_d2_clk_impl(clocks, true);
1899        }
1900        pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
1901            trace!("Releasing XTAL_D2_CLK");
1902            trace!("Disabling XTAL_D2_CLK");
1903            enable_xtal_d2_clk_impl(clocks, false);
1904            release_xtal_clk(clocks);
1905        }
1906        pub fn xtal_d2_clk_frequency(clocks: &mut ClockTree) -> u32 {
1907            (xtal_clk_frequency(clocks) / 2)
1908        }
1909        pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
1910            let old_selector = clocks.lp_fast_clk.replace(new_selector);
1911            if clocks.lp_fast_clk_refcount > 0 {
1912                match new_selector {
1913                    LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
1914                    LpFastClkConfig::PllLpClk => request_pll_lp_clk(clocks),
1915                    LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
1916                }
1917                configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
1918                if let Some(old_selector) = old_selector {
1919                    match old_selector {
1920                        LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
1921                        LpFastClkConfig::PllLpClk => release_pll_lp_clk(clocks),
1922                        LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
1923                    }
1924                }
1925            } else {
1926                configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
1927            }
1928        }
1929        pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
1930            clocks.lp_fast_clk
1931        }
1932        pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
1933            trace!("Requesting LP_FAST_CLK");
1934            if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
1935                trace!("Enabling LP_FAST_CLK");
1936                match unwrap!(clocks.lp_fast_clk) {
1937                    LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
1938                    LpFastClkConfig::PllLpClk => request_pll_lp_clk(clocks),
1939                    LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
1940                }
1941                enable_lp_fast_clk_impl(clocks, true);
1942            }
1943        }
1944        pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
1945            trace!("Releasing LP_FAST_CLK");
1946            if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
1947                trace!("Disabling LP_FAST_CLK");
1948                enable_lp_fast_clk_impl(clocks, false);
1949                match unwrap!(clocks.lp_fast_clk) {
1950                    LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
1951                    LpFastClkConfig::PllLpClk => release_pll_lp_clk(clocks),
1952                    LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
1953                }
1954            }
1955        }
1956        #[allow(unused_variables)]
1957        pub fn lp_fast_clk_config_frequency(
1958            clocks: &mut ClockTree,
1959            config: LpFastClkConfig,
1960        ) -> u32 {
1961            match config {
1962                LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(clocks),
1963                LpFastClkConfig::PllLpClk => pll_lp_clk_frequency(clocks),
1964                LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(clocks),
1965            }
1966        }
1967        pub fn lp_fast_clk_frequency(clocks: &mut ClockTree) -> u32 {
1968            if let Some(config) = clocks.lp_fast_clk {
1969                lp_fast_clk_config_frequency(clocks, config)
1970            } else {
1971                0
1972            }
1973        }
1974        pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
1975            let old_selector = clocks.lp_slow_clk.replace(new_selector);
1976            match new_selector {
1977                LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
1978                LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
1979                LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
1980            }
1981            configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
1982            if let Some(old_selector) = old_selector {
1983                match old_selector {
1984                    LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
1985                    LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
1986                    LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
1987                }
1988            }
1989        }
1990        pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
1991            clocks.lp_slow_clk
1992        }
1993        pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
1994            trace!("Requesting LP_SLOW_CLK");
1995            trace!("Enabling LP_SLOW_CLK");
1996            match unwrap!(clocks.lp_slow_clk) {
1997                LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
1998                LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
1999                LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2000            }
2001            enable_lp_slow_clk_impl(clocks, true);
2002        }
2003        pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2004            trace!("Releasing LP_SLOW_CLK");
2005            trace!("Disabling LP_SLOW_CLK");
2006            enable_lp_slow_clk_impl(clocks, false);
2007            match unwrap!(clocks.lp_slow_clk) {
2008                LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2009                LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2010                LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2011            }
2012        }
2013        #[allow(unused_variables)]
2014        pub fn lp_slow_clk_config_frequency(
2015            clocks: &mut ClockTree,
2016            config: LpSlowClkConfig,
2017        ) -> u32 {
2018            match config {
2019                LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(clocks),
2020                LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(clocks),
2021                LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(clocks),
2022            }
2023        }
2024        pub fn lp_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
2025            if let Some(config) = clocks.lp_slow_clk {
2026                lp_slow_clk_config_frequency(clocks, config)
2027            } else {
2028                0
2029            }
2030        }
2031        pub fn configure_timg_calibration_clock(
2032            clocks: &mut ClockTree,
2033            new_selector: TimgCalibrationClockConfig,
2034        ) {
2035            let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2036            if clocks.timg_calibration_clock_refcount > 0 {
2037                match new_selector {
2038                    TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
2039                    TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2040                    TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2041                }
2042                configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2043                if let Some(old_selector) = old_selector {
2044                    match old_selector {
2045                        TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
2046                        TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2047                        TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2048                    }
2049                }
2050            } else {
2051                configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2052            }
2053        }
2054        pub fn timg_calibration_clock_config(
2055            clocks: &mut ClockTree,
2056        ) -> Option<TimgCalibrationClockConfig> {
2057            clocks.timg_calibration_clock
2058        }
2059        pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2060            trace!("Requesting TIMG_CALIBRATION_CLOCK");
2061            if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2062                trace!("Enabling TIMG_CALIBRATION_CLOCK");
2063                match unwrap!(clocks.timg_calibration_clock) {
2064                    TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
2065                    TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2066                    TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2067                }
2068                enable_timg_calibration_clock_impl(clocks, true);
2069            }
2070        }
2071        pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2072            trace!("Releasing TIMG_CALIBRATION_CLOCK");
2073            if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2074                trace!("Disabling TIMG_CALIBRATION_CLOCK");
2075                enable_timg_calibration_clock_impl(clocks, false);
2076                match unwrap!(clocks.timg_calibration_clock) {
2077                    TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
2078                    TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2079                    TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2080                }
2081            }
2082        }
2083        #[allow(unused_variables)]
2084        pub fn timg_calibration_clock_config_frequency(
2085            clocks: &mut ClockTree,
2086            config: TimgCalibrationClockConfig,
2087        ) -> u32 {
2088            match config {
2089                TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(clocks),
2090                TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(clocks),
2091                TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(clocks),
2092            }
2093        }
2094        pub fn timg_calibration_clock_frequency(clocks: &mut ClockTree) -> u32 {
2095            if let Some(config) = clocks.timg_calibration_clock {
2096                timg_calibration_clock_config_frequency(clocks, config)
2097            } else {
2098                0
2099            }
2100        }
2101        impl McpwmInstance {
2102            pub fn configure_function_clock(
2103                self,
2104                clocks: &mut ClockTree,
2105                new_selector: McpwmFunctionClockConfig,
2106            ) {
2107                let old_selector = clocks.mcpwm_function_clock[self as usize].replace(new_selector);
2108                if clocks.mcpwm_function_clock_refcount[self as usize] > 0 {
2109                    match new_selector {
2110                        McpwmFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2111                        McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2112                        McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2113                    }
2114                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
2115                    if let Some(old_selector) = old_selector {
2116                        match old_selector {
2117                            McpwmFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2118                            McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2119                            McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2120                        }
2121                    }
2122                } else {
2123                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
2124                }
2125            }
2126            pub fn function_clock_config(
2127                self,
2128                clocks: &mut ClockTree,
2129            ) -> Option<McpwmFunctionClockConfig> {
2130                clocks.mcpwm_function_clock[self as usize]
2131            }
2132            pub fn request_function_clock(self, clocks: &mut ClockTree) {
2133                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2134                if increment_reference_count(
2135                    &mut clocks.mcpwm_function_clock_refcount[self as usize],
2136                ) {
2137                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2138                    match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
2139                        McpwmFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2140                        McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2141                        McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2142                    }
2143                    self.enable_function_clock_impl(clocks, true);
2144                }
2145            }
2146            pub fn release_function_clock(self, clocks: &mut ClockTree) {
2147                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2148                if decrement_reference_count(
2149                    &mut clocks.mcpwm_function_clock_refcount[self as usize],
2150                ) {
2151                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2152                    self.enable_function_clock_impl(clocks, false);
2153                    match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
2154                        McpwmFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2155                        McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2156                        McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2157                    }
2158                }
2159            }
2160            #[allow(unused_variables)]
2161            pub fn function_clock_config_frequency(
2162                self,
2163                clocks: &mut ClockTree,
2164                config: McpwmFunctionClockConfig,
2165            ) -> u32 {
2166                match config {
2167                    McpwmFunctionClockConfig::PllF96m => pll_f96m_clk_frequency(clocks),
2168                    McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
2169                    McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(clocks),
2170                }
2171            }
2172            pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2173                if let Some(config) = clocks.mcpwm_function_clock[self as usize] {
2174                    self.function_clock_config_frequency(clocks, config)
2175                } else {
2176                    0
2177                }
2178            }
2179        }
2180        impl ParlIoInstance {
2181            pub fn configure_rx_clock(
2182                self,
2183                clocks: &mut ClockTree,
2184                new_selector: ParlIoRxClockConfig,
2185            ) {
2186                let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
2187                if clocks.parl_io_rx_clock_refcount[self as usize] > 0 {
2188                    match new_selector {
2189                        ParlIoRxClockConfig::XtalClk => request_xtal_clk(clocks),
2190                        ParlIoRxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2191                        ParlIoRxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2192                    }
2193                    self.configure_rx_clock_impl(clocks, old_selector, new_selector);
2194                    if let Some(old_selector) = old_selector {
2195                        match old_selector {
2196                            ParlIoRxClockConfig::XtalClk => release_xtal_clk(clocks),
2197                            ParlIoRxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2198                            ParlIoRxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2199                        }
2200                    }
2201                } else {
2202                    self.configure_rx_clock_impl(clocks, old_selector, new_selector);
2203                }
2204            }
2205            pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoRxClockConfig> {
2206                clocks.parl_io_rx_clock[self as usize]
2207            }
2208            pub fn request_rx_clock(self, clocks: &mut ClockTree) {
2209                trace!("Requesting {:?}::RX_CLOCK", self);
2210                if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
2211                    trace!("Enabling {:?}::RX_CLOCK", self);
2212                    match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
2213                        ParlIoRxClockConfig::XtalClk => request_xtal_clk(clocks),
2214                        ParlIoRxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2215                        ParlIoRxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2216                    }
2217                    self.enable_rx_clock_impl(clocks, true);
2218                }
2219            }
2220            pub fn release_rx_clock(self, clocks: &mut ClockTree) {
2221                trace!("Releasing {:?}::RX_CLOCK", self);
2222                if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
2223                    trace!("Disabling {:?}::RX_CLOCK", self);
2224                    self.enable_rx_clock_impl(clocks, false);
2225                    match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
2226                        ParlIoRxClockConfig::XtalClk => release_xtal_clk(clocks),
2227                        ParlIoRxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2228                        ParlIoRxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2229                    }
2230                }
2231            }
2232            #[allow(unused_variables)]
2233            pub fn rx_clock_config_frequency(
2234                self,
2235                clocks: &mut ClockTree,
2236                config: ParlIoRxClockConfig,
2237            ) -> u32 {
2238                match config {
2239                    ParlIoRxClockConfig::XtalClk => xtal_clk_frequency(clocks),
2240                    ParlIoRxClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
2241                    ParlIoRxClockConfig::PllF96m => pll_f96m_clk_frequency(clocks),
2242                }
2243            }
2244            pub fn rx_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2245                if let Some(config) = clocks.parl_io_rx_clock[self as usize] {
2246                    self.rx_clock_config_frequency(clocks, config)
2247                } else {
2248                    0
2249                }
2250            }
2251            pub fn configure_tx_clock(
2252                self,
2253                clocks: &mut ClockTree,
2254                new_selector: ParlIoTxClockConfig,
2255            ) {
2256                let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
2257                if clocks.parl_io_tx_clock_refcount[self as usize] > 0 {
2258                    match new_selector {
2259                        ParlIoTxClockConfig::XtalClk => request_xtal_clk(clocks),
2260                        ParlIoTxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2261                        ParlIoTxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2262                    }
2263                    self.configure_tx_clock_impl(clocks, old_selector, new_selector);
2264                    if let Some(old_selector) = old_selector {
2265                        match old_selector {
2266                            ParlIoTxClockConfig::XtalClk => release_xtal_clk(clocks),
2267                            ParlIoTxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2268                            ParlIoTxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2269                        }
2270                    }
2271                } else {
2272                    self.configure_tx_clock_impl(clocks, old_selector, new_selector);
2273                }
2274            }
2275            pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoTxClockConfig> {
2276                clocks.parl_io_tx_clock[self as usize]
2277            }
2278            pub fn request_tx_clock(self, clocks: &mut ClockTree) {
2279                trace!("Requesting {:?}::TX_CLOCK", self);
2280                if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
2281                    trace!("Enabling {:?}::TX_CLOCK", self);
2282                    match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
2283                        ParlIoTxClockConfig::XtalClk => request_xtal_clk(clocks),
2284                        ParlIoTxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2285                        ParlIoTxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2286                    }
2287                    self.enable_tx_clock_impl(clocks, true);
2288                }
2289            }
2290            pub fn release_tx_clock(self, clocks: &mut ClockTree) {
2291                trace!("Releasing {:?}::TX_CLOCK", self);
2292                if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
2293                    trace!("Disabling {:?}::TX_CLOCK", self);
2294                    self.enable_tx_clock_impl(clocks, false);
2295                    match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
2296                        ParlIoTxClockConfig::XtalClk => release_xtal_clk(clocks),
2297                        ParlIoTxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2298                        ParlIoTxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2299                    }
2300                }
2301            }
2302            #[allow(unused_variables)]
2303            pub fn tx_clock_config_frequency(
2304                self,
2305                clocks: &mut ClockTree,
2306                config: ParlIoTxClockConfig,
2307            ) -> u32 {
2308                match config {
2309                    ParlIoTxClockConfig::XtalClk => xtal_clk_frequency(clocks),
2310                    ParlIoTxClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
2311                    ParlIoTxClockConfig::PllF96m => pll_f96m_clk_frequency(clocks),
2312                }
2313            }
2314            pub fn tx_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2315                if let Some(config) = clocks.parl_io_tx_clock[self as usize] {
2316                    self.tx_clock_config_frequency(clocks, config)
2317                } else {
2318                    0
2319                }
2320            }
2321        }
2322        impl RmtInstance {
2323            pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
2324                let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
2325                if clocks.rmt_sclk_refcount[self as usize] > 0 {
2326                    match new_selector {
2327                        RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
2328                        RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
2329                    }
2330                    self.configure_sclk_impl(clocks, old_selector, new_selector);
2331                    if let Some(old_selector) = old_selector {
2332                        match old_selector {
2333                            RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
2334                            RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
2335                        }
2336                    }
2337                } else {
2338                    self.configure_sclk_impl(clocks, old_selector, new_selector);
2339                }
2340            }
2341            pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
2342                clocks.rmt_sclk[self as usize]
2343            }
2344            pub fn request_sclk(self, clocks: &mut ClockTree) {
2345                trace!("Requesting {:?}::SCLK", self);
2346                if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
2347                    trace!("Enabling {:?}::SCLK", self);
2348                    match unwrap!(clocks.rmt_sclk[self as usize]) {
2349                        RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
2350                        RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
2351                    }
2352                    self.enable_sclk_impl(clocks, true);
2353                }
2354            }
2355            pub fn release_sclk(self, clocks: &mut ClockTree) {
2356                trace!("Releasing {:?}::SCLK", self);
2357                if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
2358                    trace!("Disabling {:?}::SCLK", self);
2359                    self.enable_sclk_impl(clocks, false);
2360                    match unwrap!(clocks.rmt_sclk[self as usize]) {
2361                        RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
2362                        RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
2363                    }
2364                }
2365            }
2366            #[allow(unused_variables)]
2367            pub fn sclk_config_frequency(
2368                self,
2369                clocks: &mut ClockTree,
2370                config: RmtSclkConfig,
2371            ) -> u32 {
2372                match config {
2373                    RmtSclkConfig::XtalClk => xtal_clk_frequency(clocks),
2374                    RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(clocks),
2375                }
2376            }
2377            pub fn sclk_frequency(self, clocks: &mut ClockTree) -> u32 {
2378                if let Some(config) = clocks.rmt_sclk[self as usize] {
2379                    self.sclk_config_frequency(clocks, config)
2380                } else {
2381                    0
2382                }
2383            }
2384        }
2385        impl TimgInstance {
2386            pub fn configure_function_clock(
2387                self,
2388                clocks: &mut ClockTree,
2389                new_selector: TimgFunctionClockConfig,
2390            ) {
2391                let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
2392                if clocks.timg_function_clock_refcount[self as usize] > 0 {
2393                    match new_selector {
2394                        TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2395                        TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2396                        TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2397                    }
2398                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
2399                    if let Some(old_selector) = old_selector {
2400                        match old_selector {
2401                            TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2402                            TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2403                            TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2404                        }
2405                    }
2406                } else {
2407                    self.configure_function_clock_impl(clocks, old_selector, new_selector);
2408                }
2409            }
2410            pub fn function_clock_config(
2411                self,
2412                clocks: &mut ClockTree,
2413            ) -> Option<TimgFunctionClockConfig> {
2414                clocks.timg_function_clock[self as usize]
2415            }
2416            pub fn request_function_clock(self, clocks: &mut ClockTree) {
2417                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2418                if increment_reference_count(
2419                    &mut clocks.timg_function_clock_refcount[self as usize],
2420                ) {
2421                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2422                    match unwrap!(clocks.timg_function_clock[self as usize]) {
2423                        TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2424                        TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2425                        TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2426                    }
2427                    self.enable_function_clock_impl(clocks, true);
2428                }
2429            }
2430            pub fn release_function_clock(self, clocks: &mut ClockTree) {
2431                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2432                if decrement_reference_count(
2433                    &mut clocks.timg_function_clock_refcount[self as usize],
2434                ) {
2435                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2436                    self.enable_function_clock_impl(clocks, false);
2437                    match unwrap!(clocks.timg_function_clock[self as usize]) {
2438                        TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2439                        TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2440                        TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2441                    }
2442                }
2443            }
2444            #[allow(unused_variables)]
2445            pub fn function_clock_config_frequency(
2446                self,
2447                clocks: &mut ClockTree,
2448                config: TimgFunctionClockConfig,
2449            ) -> u32 {
2450                match config {
2451                    TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(clocks),
2452                    TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
2453                    TimgFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(clocks),
2454                }
2455            }
2456            pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2457                if let Some(config) = clocks.timg_function_clock[self as usize] {
2458                    self.function_clock_config_frequency(clocks, config)
2459                } else {
2460                    0
2461                }
2462            }
2463            pub fn configure_wdt_clock(
2464                self,
2465                clocks: &mut ClockTree,
2466                new_selector: TimgWdtClockConfig,
2467            ) {
2468                let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
2469                if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
2470                    match new_selector {
2471                        TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
2472                        TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2473                        TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2474                    }
2475                    self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
2476                    if let Some(old_selector) = old_selector {
2477                        match old_selector {
2478                            TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
2479                            TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2480                            TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2481                        }
2482                    }
2483                } else {
2484                    self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
2485                }
2486            }
2487            pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
2488                clocks.timg_wdt_clock[self as usize]
2489            }
2490            pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
2491                trace!("Requesting {:?}::WDT_CLOCK", self);
2492                if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
2493                    trace!("Enabling {:?}::WDT_CLOCK", self);
2494                    match unwrap!(clocks.timg_wdt_clock[self as usize]) {
2495                        TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
2496                        TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2497                        TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2498                    }
2499                    self.enable_wdt_clock_impl(clocks, true);
2500                }
2501            }
2502            pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
2503                trace!("Releasing {:?}::WDT_CLOCK", self);
2504                if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
2505                    trace!("Disabling {:?}::WDT_CLOCK", self);
2506                    self.enable_wdt_clock_impl(clocks, false);
2507                    match unwrap!(clocks.timg_wdt_clock[self as usize]) {
2508                        TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
2509                        TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2510                        TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2511                    }
2512                }
2513            }
2514            #[allow(unused_variables)]
2515            pub fn wdt_clock_config_frequency(
2516                self,
2517                clocks: &mut ClockTree,
2518                config: TimgWdtClockConfig,
2519            ) -> u32 {
2520                match config {
2521                    TimgWdtClockConfig::XtalClk => xtal_clk_frequency(clocks),
2522                    TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
2523                    TimgWdtClockConfig::PllF48m => pll_f48m_clk_frequency(clocks),
2524                }
2525            }
2526            pub fn wdt_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2527                if let Some(config) = clocks.timg_wdt_clock[self as usize] {
2528                    self.wdt_clock_config_frequency(clocks, config)
2529                } else {
2530                    0
2531                }
2532            }
2533        }
2534        impl UartInstance {
2535            pub fn configure_function_clock(
2536                self,
2537                clocks: &mut ClockTree,
2538                config: UartFunctionClockConfig,
2539            ) {
2540                let old_config = clocks.uart_function_clock[self as usize].replace(config);
2541                if clocks.uart_function_clock_refcount[self as usize] > 0 {
2542                    match config.sclk {
2543                        UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
2544                        UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2545                        UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2546                    }
2547                    self.configure_function_clock_impl(clocks, old_config, config);
2548                    if let Some(old_config) = old_config {
2549                        match old_config.sclk {
2550                            UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
2551                            UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2552                            UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2553                        }
2554                    }
2555                } else {
2556                    self.configure_function_clock_impl(clocks, old_config, config);
2557                }
2558            }
2559            pub fn function_clock_config(
2560                self,
2561                clocks: &mut ClockTree,
2562            ) -> Option<UartFunctionClockConfig> {
2563                clocks.uart_function_clock[self as usize]
2564            }
2565            pub fn request_function_clock(self, clocks: &mut ClockTree) {
2566                trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2567                if increment_reference_count(
2568                    &mut clocks.uart_function_clock_refcount[self as usize],
2569                ) {
2570                    trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2571                    match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
2572                        UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
2573                        UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2574                        UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2575                    }
2576                    self.enable_function_clock_impl(clocks, true);
2577                }
2578            }
2579            pub fn release_function_clock(self, clocks: &mut ClockTree) {
2580                trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2581                if decrement_reference_count(
2582                    &mut clocks.uart_function_clock_refcount[self as usize],
2583                ) {
2584                    trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2585                    self.enable_function_clock_impl(clocks, false);
2586                    match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
2587                        UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
2588                        UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2589                        UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2590                    }
2591                }
2592            }
2593            #[allow(unused_variables)]
2594            pub fn function_clock_config_frequency(
2595                self,
2596                clocks: &mut ClockTree,
2597                config: UartFunctionClockConfig,
2598            ) -> u32 {
2599                (match config.sclk {
2600                    UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(clocks),
2601                    UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(clocks),
2602                    UartFunctionClockSclk::Xtal => xtal_clk_frequency(clocks),
2603                } / (config.div_num() + 1))
2604            }
2605            pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2606                if let Some(config) = clocks.uart_function_clock[self as usize] {
2607                    self.function_clock_config_frequency(clocks, config)
2608                } else {
2609                    0
2610                }
2611            }
2612            pub fn configure_baud_rate_generator(
2613                self,
2614                clocks: &mut ClockTree,
2615                config: UartBaudRateGeneratorConfig,
2616            ) {
2617                let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
2618                self.configure_baud_rate_generator_impl(clocks, old_config, config);
2619            }
2620            pub fn baud_rate_generator_config(
2621                self,
2622                clocks: &mut ClockTree,
2623            ) -> Option<UartBaudRateGeneratorConfig> {
2624                clocks.uart_baud_rate_generator[self as usize]
2625            }
2626            pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
2627                trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
2628                if increment_reference_count(
2629                    &mut clocks.uart_baud_rate_generator_refcount[self as usize],
2630                ) {
2631                    trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
2632                    self.request_function_clock(clocks);
2633                    self.enable_baud_rate_generator_impl(clocks, true);
2634                }
2635            }
2636            pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
2637                trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
2638                if decrement_reference_count(
2639                    &mut clocks.uart_baud_rate_generator_refcount[self as usize],
2640                ) {
2641                    trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
2642                    self.enable_baud_rate_generator_impl(clocks, false);
2643                    self.release_function_clock(clocks);
2644                }
2645            }
2646            #[allow(unused_variables)]
2647            pub fn baud_rate_generator_config_frequency(
2648                self,
2649                clocks: &mut ClockTree,
2650                config: UartBaudRateGeneratorConfig,
2651            ) -> u32 {
2652                ((self.function_clock_frequency(clocks) * 16)
2653                    / ((config.integral() * 16) + config.fractional()))
2654            }
2655            pub fn baud_rate_generator_frequency(self, clocks: &mut ClockTree) -> u32 {
2656                if let Some(config) = clocks.uart_baud_rate_generator[self as usize] {
2657                    self.baud_rate_generator_config_frequency(clocks, config)
2658                } else {
2659                    0
2660                }
2661            }
2662        }
2663        /// Clock tree configuration.
2664        ///
2665        /// The fields of this struct are optional, with the following caveats:
2666        /// - If `XTAL_CLK` is not specified, the crystal frequency will be automatically detected
2667        ///   if possible.
2668        /// - The CPU and its upstream clock nodes will be set to a default configuration.
2669        /// - Other unspecified clock sources will not be useable by peripherals.
2670        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2671        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2672        #[instability::unstable]
2673        pub struct ClockConfig {
2674            /// `XTAL_CLK` configuration.
2675            pub xtal_clk: Option<XtalClkConfig>,
2676            /// `HP_ROOT_CLK` configuration.
2677            pub hp_root_clk: Option<HpRootClkConfig>,
2678            /// `CPU_CLK` configuration.
2679            pub cpu_clk: Option<CpuClkConfig>,
2680            /// `AHB_CLK` configuration.
2681            pub ahb_clk: Option<AhbClkConfig>,
2682            /// `APB_CLK` configuration.
2683            pub apb_clk: Option<ApbClkConfig>,
2684            /// `LP_FAST_CLK` configuration.
2685            pub lp_fast_clk: Option<LpFastClkConfig>,
2686            /// `LP_SLOW_CLK` configuration.
2687            pub lp_slow_clk: Option<LpSlowClkConfig>,
2688            /// `TIMG_CALIBRATION_CLOCK` configuration.
2689            pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2690        }
2691        impl ClockConfig {
2692            fn apply(&self) {
2693                ClockTree::with(|clocks| {
2694                    if let Some(config) = self.xtal_clk {
2695                        configure_xtal_clk(clocks, config);
2696                    }
2697                    if let Some(config) = self.hp_root_clk {
2698                        configure_hp_root_clk(clocks, config);
2699                    }
2700                    if let Some(config) = self.cpu_clk {
2701                        configure_cpu_clk(clocks, config);
2702                    }
2703                    if let Some(config) = self.ahb_clk {
2704                        configure_ahb_clk(clocks, config);
2705                    }
2706                    if let Some(config) = self.apb_clk {
2707                        configure_apb_clk(clocks, config);
2708                    }
2709                    if let Some(config) = self.lp_fast_clk {
2710                        configure_lp_fast_clk(clocks, config);
2711                    }
2712                    if let Some(config) = self.lp_slow_clk {
2713                        configure_lp_slow_clk(clocks, config);
2714                    }
2715                    if let Some(config) = self.timg_calibration_clock {
2716                        configure_timg_calibration_clock(clocks, config);
2717                    }
2718                });
2719            }
2720        }
2721        fn increment_reference_count(refcount: &mut u32) -> bool {
2722            let first = *refcount == 0;
2723            *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
2724            first
2725        }
2726        fn decrement_reference_count(refcount: &mut u32) -> bool {
2727            *refcount = refcount.saturating_sub(1);
2728            let last = *refcount == 0;
2729            last
2730        }
2731    };
2732}
2733/// Implement the `Peripheral` enum and enable/disable/reset functions.
2734///
2735/// This macro is intended to be placed in `esp_hal::system`.
2736#[macro_export]
2737#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2738macro_rules! implement_peripheral_clocks {
2739    () => {
2740        #[doc(hidden)]
2741        #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2742        #[repr(u8)]
2743        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2744        pub enum Peripheral {
2745            /// AES peripheral clock signal
2746            Aes,
2747            /// APB_SAR_ADC peripheral clock signal
2748            ApbSarAdc,
2749            /// DMA peripheral clock signal
2750            Dma,
2751            /// DS peripheral clock signal
2752            Ds,
2753            /// ECC peripheral clock signal
2754            Ecc,
2755            /// ECDSA peripheral clock signal
2756            Ecdsa,
2757            /// ETM peripheral clock signal
2758            Etm,
2759            /// HMAC peripheral clock signal
2760            Hmac,
2761            /// I2C_EXT0 peripheral clock signal
2762            I2cExt0,
2763            /// I2C_EXT1 peripheral clock signal
2764            I2cExt1,
2765            /// I2S0 peripheral clock signal
2766            I2s0,
2767            /// LEDC peripheral clock signal
2768            Ledc,
2769            /// MCPWM0 peripheral clock signal
2770            Mcpwm0,
2771            /// PARL_IO peripheral clock signal
2772            ParlIo,
2773            /// PCNT peripheral clock signal
2774            Pcnt,
2775            /// RMT peripheral clock signal
2776            Rmt,
2777            /// RSA peripheral clock signal
2778            Rsa,
2779            /// SHA peripheral clock signal
2780            Sha,
2781            /// SPI2 peripheral clock signal
2782            Spi2,
2783            /// SYSTIMER peripheral clock signal
2784            Systimer,
2785            /// TIMG0 peripheral clock signal
2786            Timg0,
2787            /// TIMG1 peripheral clock signal
2788            Timg1,
2789            /// TRACE0 peripheral clock signal
2790            Trace0,
2791            /// TSENS peripheral clock signal
2792            Tsens,
2793            /// TWAI0 peripheral clock signal
2794            Twai0,
2795            /// UART0 peripheral clock signal
2796            Uart0,
2797            /// UART1 peripheral clock signal
2798            Uart1,
2799            /// UHCI0 peripheral clock signal
2800            Uhci0,
2801            /// USB_DEVICE peripheral clock signal
2802            UsbDevice,
2803        }
2804        impl Peripheral {
2805            const KEEP_ENABLED: &[Peripheral] =
2806                &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
2807            const COUNT: usize = Self::ALL.len();
2808            const ALL: &[Self] = &[
2809                Self::Aes,
2810                Self::ApbSarAdc,
2811                Self::Dma,
2812                Self::Ds,
2813                Self::Ecc,
2814                Self::Ecdsa,
2815                Self::Etm,
2816                Self::Hmac,
2817                Self::I2cExt0,
2818                Self::I2cExt1,
2819                Self::I2s0,
2820                Self::Ledc,
2821                Self::Mcpwm0,
2822                Self::ParlIo,
2823                Self::Pcnt,
2824                Self::Rmt,
2825                Self::Rsa,
2826                Self::Sha,
2827                Self::Spi2,
2828                Self::Systimer,
2829                Self::Timg0,
2830                Self::Timg1,
2831                Self::Trace0,
2832                Self::Tsens,
2833                Self::Twai0,
2834                Self::Uart0,
2835                Self::Uart1,
2836                Self::Uhci0,
2837                Self::UsbDevice,
2838            ];
2839        }
2840        unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
2841            match peripheral {
2842                Peripheral::Aes => {
2843                    crate::peripherals::SYSTEM::regs()
2844                        .aes_conf()
2845                        .modify(|_, w| w.aes_clk_en().bit(enable));
2846                }
2847                Peripheral::ApbSarAdc => {
2848                    crate::peripherals::SYSTEM::regs()
2849                        .saradc_conf()
2850                        .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
2851                }
2852                Peripheral::Dma => {
2853                    crate::peripherals::SYSTEM::regs()
2854                        .gdma_conf()
2855                        .modify(|_, w| w.gdma_clk_en().bit(enable));
2856                }
2857                Peripheral::Ds => {
2858                    crate::peripherals::SYSTEM::regs()
2859                        .ds_conf()
2860                        .modify(|_, w| w.ds_clk_en().bit(enable));
2861                }
2862                Peripheral::Ecc => {
2863                    crate::peripherals::SYSTEM::regs()
2864                        .ecc_conf()
2865                        .modify(|_, w| w.ecc_clk_en().bit(enable));
2866                }
2867                Peripheral::Ecdsa => {
2868                    crate::peripherals::SYSTEM::regs()
2869                        .ecdsa_conf()
2870                        .modify(|_, w| w.ecdsa_clk_en().bit(enable));
2871                }
2872                Peripheral::Etm => {
2873                    crate::peripherals::SYSTEM::regs()
2874                        .etm_conf()
2875                        .modify(|_, w| w.etm_clk_en().bit(enable));
2876                }
2877                Peripheral::Hmac => {
2878                    crate::peripherals::SYSTEM::regs()
2879                        .hmac_conf()
2880                        .modify(|_, w| w.hmac_clk_en().bit(enable));
2881                }
2882                Peripheral::I2cExt0 => {
2883                    crate::peripherals::SYSTEM::regs()
2884                        .i2c0_conf()
2885                        .modify(|_, w| w.i2c0_clk_en().bit(enable));
2886                }
2887                Peripheral::I2cExt1 => {
2888                    crate::peripherals::SYSTEM::regs()
2889                        .i2c1_conf()
2890                        .modify(|_, w| w.i2c1_clk_en().bit(enable));
2891                }
2892                Peripheral::I2s0 => {
2893                    crate::peripherals::SYSTEM::regs()
2894                        .i2s_conf()
2895                        .modify(|_, w| w.i2s_clk_en().bit(enable));
2896                }
2897                Peripheral::Ledc => {
2898                    crate::peripherals::SYSTEM::regs()
2899                        .ledc_conf()
2900                        .modify(|_, w| w.ledc_clk_en().bit(enable));
2901                }
2902                Peripheral::Mcpwm0 => {
2903                    crate::peripherals::SYSTEM::regs()
2904                        .pwm_conf()
2905                        .modify(|_, w| w.pwm_clk_en().bit(enable));
2906                }
2907                Peripheral::ParlIo => {
2908                    crate::peripherals::SYSTEM::regs()
2909                        .parl_io_conf()
2910                        .modify(|_, w| w.parl_clk_en().bit(enable));
2911                }
2912                Peripheral::Pcnt => {
2913                    crate::peripherals::SYSTEM::regs()
2914                        .pcnt_conf()
2915                        .modify(|_, w| w.pcnt_clk_en().bit(enable));
2916                }
2917                Peripheral::Rmt => {
2918                    crate::peripherals::SYSTEM::regs()
2919                        .rmt_conf()
2920                        .modify(|_, w| w.rmt_clk_en().bit(enable));
2921                }
2922                Peripheral::Rsa => {
2923                    crate::peripherals::SYSTEM::regs()
2924                        .rsa_conf()
2925                        .modify(|_, w| w.rsa_clk_en().bit(enable));
2926                }
2927                Peripheral::Sha => {
2928                    crate::peripherals::SYSTEM::regs()
2929                        .sha_conf()
2930                        .modify(|_, w| w.sha_clk_en().bit(enable));
2931                }
2932                Peripheral::Spi2 => {
2933                    crate::peripherals::SYSTEM::regs()
2934                        .spi2_conf()
2935                        .modify(|_, w| w.spi2_clk_en().bit(enable));
2936                }
2937                Peripheral::Systimer => {
2938                    crate::peripherals::SYSTEM::regs()
2939                        .systimer_conf()
2940                        .modify(|_, w| w.systimer_clk_en().bit(enable));
2941                }
2942                Peripheral::Timg0 => {
2943                    crate::peripherals::SYSTEM::regs()
2944                        .timergroup(0)
2945                        .conf()
2946                        .modify(|_, w| w.clk_en().bit(enable));
2947                }
2948                Peripheral::Timg1 => {
2949                    crate::peripherals::SYSTEM::regs()
2950                        .timergroup(1)
2951                        .conf()
2952                        .modify(|_, w| w.clk_en().bit(enable));
2953                }
2954                Peripheral::Trace0 => {
2955                    crate::peripherals::SYSTEM::regs()
2956                        .trace_conf()
2957                        .modify(|_, w| w.trace_clk_en().bit(enable));
2958                }
2959                Peripheral::Tsens => {
2960                    crate::peripherals::SYSTEM::regs()
2961                        .tsens_clk_conf()
2962                        .modify(|_, w| w.tsens_clk_en().bit(enable));
2963                }
2964                Peripheral::Twai0 => {
2965                    crate::peripherals::SYSTEM::regs()
2966                        .twai0_conf()
2967                        .modify(|_, w| w.twai0_clk_en().bit(enable));
2968                    crate::peripherals::SYSTEM::regs()
2969                        .twai0_func_clk_conf()
2970                        .modify(|_, w| w.twai0_func_clk_en().bit(enable));
2971                }
2972                Peripheral::Uart0 => {
2973                    crate::peripherals::SYSTEM::regs()
2974                        .uart(0)
2975                        .conf()
2976                        .modify(|_, w| w.clk_en().bit(enable));
2977                }
2978                Peripheral::Uart1 => {
2979                    crate::peripherals::SYSTEM::regs()
2980                        .uart(1)
2981                        .conf()
2982                        .modify(|_, w| w.clk_en().bit(enable));
2983                }
2984                Peripheral::Uhci0 => {
2985                    crate::peripherals::SYSTEM::regs()
2986                        .uhci_conf()
2987                        .modify(|_, w| w.uhci_clk_en().bit(enable));
2988                }
2989                Peripheral::UsbDevice => {
2990                    crate::peripherals::SYSTEM::regs()
2991                        .usb_device_conf()
2992                        .modify(|_, w| w.usb_device_clk_en().bit(enable));
2993                }
2994            }
2995        }
2996        unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
2997            match peripheral {
2998                Peripheral::Aes => {
2999                    crate::peripherals::SYSTEM::regs()
3000                        .aes_conf()
3001                        .modify(|_, w| w.aes_rst_en().bit(reset));
3002                }
3003                Peripheral::ApbSarAdc => {
3004                    crate::peripherals::SYSTEM::regs()
3005                        .saradc_conf()
3006                        .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
3007                }
3008                Peripheral::Dma => {
3009                    crate::peripherals::SYSTEM::regs()
3010                        .gdma_conf()
3011                        .modify(|_, w| w.gdma_rst_en().bit(reset));
3012                }
3013                Peripheral::Ds => {
3014                    crate::peripherals::SYSTEM::regs()
3015                        .ds_conf()
3016                        .modify(|_, w| w.ds_rst_en().bit(reset));
3017                }
3018                Peripheral::Ecc => {
3019                    crate::peripherals::SYSTEM::regs()
3020                        .ecc_conf()
3021                        .modify(|_, w| w.ecc_rst_en().bit(reset));
3022                }
3023                Peripheral::Ecdsa => {
3024                    crate::peripherals::SYSTEM::regs()
3025                        .ecdsa_conf()
3026                        .modify(|_, w| w.ecdsa_rst_en().bit(reset));
3027                }
3028                Peripheral::Etm => {
3029                    crate::peripherals::SYSTEM::regs()
3030                        .etm_conf()
3031                        .modify(|_, w| w.etm_rst_en().bit(reset));
3032                }
3033                Peripheral::Hmac => {
3034                    crate::peripherals::SYSTEM::regs()
3035                        .hmac_conf()
3036                        .modify(|_, w| w.hmac_rst_en().bit(reset));
3037                }
3038                Peripheral::I2cExt0 => {
3039                    crate::peripherals::SYSTEM::regs()
3040                        .i2c0_conf()
3041                        .modify(|_, w| w.i2c0_rst_en().bit(reset));
3042                }
3043                Peripheral::I2cExt1 => {
3044                    crate::peripherals::SYSTEM::regs()
3045                        .i2c1_conf()
3046                        .modify(|_, w| w.i2c1_rst_en().bit(reset));
3047                }
3048                Peripheral::I2s0 => {
3049                    crate::peripherals::SYSTEM::regs()
3050                        .i2s_conf()
3051                        .modify(|_, w| w.i2s_rst_en().bit(reset));
3052                }
3053                Peripheral::Ledc => {
3054                    crate::peripherals::SYSTEM::regs()
3055                        .ledc_conf()
3056                        .modify(|_, w| w.ledc_rst_en().bit(reset));
3057                }
3058                Peripheral::Mcpwm0 => {
3059                    crate::peripherals::SYSTEM::regs()
3060                        .pwm_conf()
3061                        .modify(|_, w| w.pwm_rst_en().bit(reset));
3062                }
3063                Peripheral::ParlIo => {
3064                    crate::peripherals::SYSTEM::regs()
3065                        .parl_io_conf()
3066                        .modify(|_, w| w.parl_rst_en().bit(reset));
3067                }
3068                Peripheral::Pcnt => {
3069                    crate::peripherals::SYSTEM::regs()
3070                        .pcnt_conf()
3071                        .modify(|_, w| w.pcnt_rst_en().bit(reset));
3072                }
3073                Peripheral::Rmt => {
3074                    crate::peripherals::SYSTEM::regs()
3075                        .rmt_conf()
3076                        .modify(|_, w| w.rmt_rst_en().bit(reset));
3077                }
3078                Peripheral::Rsa => {
3079                    crate::peripherals::SYSTEM::regs()
3080                        .rsa_conf()
3081                        .modify(|_, w| w.rsa_rst_en().bit(reset));
3082                }
3083                Peripheral::Sha => {
3084                    crate::peripherals::SYSTEM::regs()
3085                        .sha_conf()
3086                        .modify(|_, w| w.sha_rst_en().bit(reset));
3087                }
3088                Peripheral::Spi2 => {
3089                    crate::peripherals::SYSTEM::regs()
3090                        .spi2_conf()
3091                        .modify(|_, w| w.spi2_rst_en().bit(reset));
3092                }
3093                Peripheral::Systimer => {
3094                    crate::peripherals::SYSTEM::regs()
3095                        .systimer_conf()
3096                        .modify(|_, w| w.systimer_rst_en().bit(reset));
3097                }
3098                Peripheral::Timg0 => {
3099                    crate::peripherals::SYSTEM::regs()
3100                        .timergroup(0)
3101                        .conf()
3102                        .modify(|_, w| w.rst_en().bit(reset));
3103                }
3104                Peripheral::Timg1 => {
3105                    crate::peripherals::SYSTEM::regs()
3106                        .timergroup(1)
3107                        .conf()
3108                        .modify(|_, w| w.rst_en().bit(reset));
3109                }
3110                Peripheral::Trace0 => {
3111                    crate::peripherals::SYSTEM::regs()
3112                        .trace_conf()
3113                        .modify(|_, w| w.trace_rst_en().bit(reset));
3114                }
3115                Peripheral::Tsens => {
3116                    crate::peripherals::SYSTEM::regs()
3117                        .tsens_clk_conf()
3118                        .modify(|_, w| w.tsens_rst_en().bit(reset));
3119                }
3120                Peripheral::Twai0 => {
3121                    crate::peripherals::SYSTEM::regs()
3122                        .twai0_conf()
3123                        .modify(|_, w| w.twai0_rst_en().bit(reset));
3124                }
3125                Peripheral::Uart0 => {
3126                    crate::peripherals::SYSTEM::regs()
3127                        .uart(0)
3128                        .conf()
3129                        .modify(|_, w| w.rst_en().bit(reset));
3130                }
3131                Peripheral::Uart1 => {
3132                    crate::peripherals::SYSTEM::regs()
3133                        .uart(1)
3134                        .conf()
3135                        .modify(|_, w| w.rst_en().bit(reset));
3136                }
3137                Peripheral::Uhci0 => {
3138                    crate::peripherals::SYSTEM::regs()
3139                        .uhci_conf()
3140                        .modify(|_, w| w.uhci_rst_en().bit(reset));
3141                }
3142                Peripheral::UsbDevice => {
3143                    crate::peripherals::SYSTEM::regs()
3144                        .usb_device_conf()
3145                        .modify(|_, w| w.usb_device_rst_en().bit(reset));
3146                }
3147            }
3148        }
3149    };
3150}
3151/// Macro to get the address range of the given memory region.
3152///
3153/// This macro provides two syntax options for each memory region:
3154///
3155/// - `memory_range!("region_name")` returns the address range as a range expression (`start..end`).
3156/// - `memory_range!(size as str, "region_name")` returns the size of the region as a string
3157///   literal.
3158#[macro_export]
3159#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3160macro_rules! memory_range {
3161    ("DRAM") => {
3162        0x40800000..0x40850000
3163    };
3164    (size as str, "DRAM") => {
3165        "327680"
3166    };
3167    ("DRAM2_UNINIT") => {
3168        0x4083EFD0..0x4084FEE0
3169    };
3170    (size as str, "DRAM2_UNINIT") => {
3171        "69392"
3172    };
3173}
3174/// This macro can be used to generate code for each peripheral instance of the I2C master driver.
3175///
3176/// For an explanation on the general syntax, as well as usage of individual/repeated
3177/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3178///
3179/// This macro has one option for its "Individual matcher" case:
3180///
3181/// Syntax: `($id:literal, $instance:ident, $sys:ident, $scl:ident, $sda:ident)`
3182///
3183/// Macro fragments:
3184/// - `$id`: the index of the I2C instance
3185/// - `$instance`: the name of the I2C instance
3186/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
3187/// - `$scl`, `$sda`: peripheral signal names.
3188///
3189/// Example data: `(0, I2C0, I2cExt0, I2CEXT0_SCL, I2CEXT0_SDA)`
3190#[macro_export]
3191#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3192macro_rules! for_each_i2c_master {
3193    ($($pattern:tt => $code:tt;)*) => {
3194        macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
3195        => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
3196        I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
3197        I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
3198        I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
3199    };
3200}
3201/// This macro can be used to generate code for each peripheral instance of the UART driver.
3202///
3203/// For an explanation on the general syntax, as well as usage of individual/repeated
3204/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3205///
3206/// This macro has one option for its "Individual matcher" case:
3207///
3208/// Syntax: `($id:literal, $instance:ident, $sys:ident, $rx:ident, $tx:ident, $cts:ident,
3209/// $rts:ident)`
3210///
3211/// Macro fragments:
3212///
3213/// - `$id`: the index of the UART instance
3214/// - `$instance`: the name of the UART instance
3215/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
3216/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
3217///
3218/// Example data: `(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
3219#[macro_export]
3220#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3221macro_rules! for_each_uart {
3222    ($($pattern:tt => $code:tt;)*) => {
3223        macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
3224        } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
3225        _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
3226        _for_each_inner_uart!((all(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (1,
3227        UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS)));
3228    };
3229}
3230/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
3231///
3232/// For an explanation on the general syntax, as well as usage of individual/repeated
3233/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3234///
3235/// This macro has one option for its "Individual matcher" case:
3236///
3237/// Syntax: `($instance:ident, $sys:ident, $sclk:ident [$($cs:ident),*] [$($sio:ident),*]
3238/// $($is_qspi:literal)?)`
3239///
3240/// Macro fragments:
3241///
3242/// - `$instance`: the name of the SPI instance
3243/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
3244/// - `$cs`, `$sio`: chip select and SIO signal names.
3245/// - `$is_qspi`: a `true` literal present if the SPI instance supports QSPI.
3246///
3247/// Example data:
3248/// - `(SPI2, Spi2, FSPICLK [FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ,
3249///   FSPIWP, FSPIHD, FSPIIO4, FSPIIO5, FSPIIO6, FSPIIO7], true)`
3250/// - `(SPI3, Spi3, SPI3_CLK [SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q])`
3251#[macro_export]
3252#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3253macro_rules! for_each_spi_master {
3254    ($($pattern:tt => $code:tt;)*) => {
3255        macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
3256        => {} } _for_each_inner_spi_master!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1,
3257        FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true));
3258        _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
3259        FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
3260    };
3261}
3262/// This macro can be used to generate code for each peripheral instance of the SPI slave driver.
3263///
3264/// For an explanation on the general syntax, as well as usage of individual/repeated
3265/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3266///
3267/// This macro has one option for its "Individual matcher" case:
3268///
3269/// Syntax: `($instance:ident, $sys:ident, $sclk:ident, $mosi:ident, $miso:ident, $cs:ident)`
3270///
3271/// Macro fragments:
3272///
3273/// - `$instance`: the name of the SPI instance
3274/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
3275/// - `$sclk`, `$mosi`, `$miso`, `$cs`: signal names.
3276///
3277/// Example data: `(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)`
3278#[macro_export]
3279#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3280macro_rules! for_each_spi_slave {
3281    ($($pattern:tt => $code:tt;)*) => {
3282        macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
3283        => {} } _for_each_inner_spi_slave!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
3284        _for_each_inner_spi_slave!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
3285    };
3286}
3287#[macro_export]
3288#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3289macro_rules! for_each_peripheral {
3290    ($($pattern:tt => $code:tt;)*) => {
3291        macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
3292        => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
3293        "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
3294        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
3295        GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3296        "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3297        "<section class=\"warning\">"] #[doc =
3298        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3299        #[doc = "<ul>"] #[doc =
3300        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3301        #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
3302        _for_each_inner_peripheral!((@ peri_type #[doc =
3303        "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3304        "<section class=\"warning\">"] #[doc =
3305        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3306        #[doc = "<ul>"] #[doc =
3307        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3308        #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
3309        _for_each_inner_peripheral!((@ peri_type #[doc =
3310        "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3311        "<section class=\"warning\">"] #[doc =
3312        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3313        #[doc = "<ul>"] #[doc =
3314        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3315        #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
3316        _for_each_inner_peripheral!((@ peri_type #[doc =
3317        "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3318        "<section class=\"warning\">"] #[doc =
3319        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3320        #[doc = "<ul>"] #[doc =
3321        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3322        #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
3323        _for_each_inner_peripheral!((@ peri_type #[doc =
3324        "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3325        "<section class=\"warning\">"] #[doc =
3326        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3327        #[doc = "<ul>"] #[doc =
3328        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3329        "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
3330        _for_each_inner_peripheral!((@ peri_type #[doc =
3331        "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3332        "<section class=\"warning\">"] #[doc =
3333        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3334        #[doc = "<ul>"] #[doc =
3335        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3336        "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
3337        _for_each_inner_peripheral!((@ peri_type #[doc =
3338        "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3339        "<section class=\"warning\">"] #[doc =
3340        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3341        #[doc = "<ul>"] #[doc =
3342        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3343        = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
3344        _for_each_inner_peripheral!((@ peri_type #[doc =
3345        "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3346        "<section class=\"warning\">"] #[doc =
3347        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3348        #[doc = "<ul>"] #[doc =
3349        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3350        = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
3351        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
3352        GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3353        "GPIO11 peripheral singleton"] GPIO11 <= virtual()));
3354        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO12 peripheral singleton"]
3355        GPIO12 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3356        "GPIO13 peripheral singleton"] GPIO13 <= virtual()));
3357        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO14 peripheral singleton"]
3358        GPIO14 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3359        "GPIO22 peripheral singleton"] GPIO22 <= virtual()));
3360        _for_each_inner_peripheral!((@ peri_type #[doc =
3361        "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3362        "<section class=\"warning\">"] #[doc =
3363        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3364        #[doc = "<ul>"] #[doc =
3365        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3366        = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()));
3367        _for_each_inner_peripheral!((@ peri_type #[doc =
3368        "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3369        "<section class=\"warning\">"] #[doc =
3370        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3371        #[doc = "<ul>"] #[doc =
3372        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3373        = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()));
3374        _for_each_inner_peripheral!((@ peri_type #[doc =
3375        "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3376        "<section class=\"warning\">"] #[doc =
3377        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3378        #[doc = "<ul>"] #[doc =
3379        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3380        = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
3381        _for_each_inner_peripheral!((@ peri_type #[doc =
3382        "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3383        "<section class=\"warning\">"] #[doc =
3384        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3385        #[doc = "<ul>"] #[doc =
3386        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3387        #[doc = "</section>"] GPIO26 <= virtual())); _for_each_inner_peripheral!((@
3388        peri_type #[doc = "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""]
3389        #[doc = "<section class=\"warning\">"] #[doc =
3390        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3391        #[doc = "<ul>"] #[doc =
3392        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3393        #[doc = "</section>"] GPIO27 <= virtual())); _for_each_inner_peripheral!((@
3394        peri_type #[doc = "AES peripheral singleton"] AES <= AES(AES : {
3395        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
3396        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3397        "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
3398        _for_each_inner_peripheral!((@ peri_type #[doc =
3399        "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
3400        _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
3401        <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3402        "DS peripheral singleton"] DS <= DS() (unstable)));
3403        _for_each_inner_peripheral!((@ peri_type #[doc = "ECC peripheral singleton"] ECC
3404        <= ECC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3405        "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
3406        _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
3407        GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3408        "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
3409        _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
3410        HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3411        "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
3412        _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
3413        HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3414        "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
3415        _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
3416        I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
3417        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3418        "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
3419        enable_peri_interrupt, disable_peri_interrupt })));
3420        _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
3421        I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
3422        disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
3423        #[doc = "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
3424        bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
3425        _for_each_inner_peripheral!((@ peri_type #[doc =
3426        "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
3427        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3428        "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
3429        _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
3430        IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3431        "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)));
3432        _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
3433        LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3434        = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
3435        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
3436        LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3437        "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
3438        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM0 peripheral singleton"]
3439        LP_APM0 <= LP_APM0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3440        = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
3441        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
3442        LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3443        = "LP_TIMER peripheral singleton"] LP_TIMER <= LP_TIMER() (unstable)));
3444        _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
3445        LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3446        "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
3447        _for_each_inner_peripheral!((@ peri_type #[doc =
3448        "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
3449        _for_each_inner_peripheral!((@ peri_type #[doc =
3450        "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
3451        _for_each_inner_peripheral!((@ peri_type #[doc =
3452        "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
3453        _for_each_inner_peripheral!((@ peri_type #[doc =
3454        "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)));
3455        _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
3456        PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
3457        disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
3458        disable_tx_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
3459        #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
3460        _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
3461        PCNT <= PCNT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3462        "PCR peripheral singleton"] PCR <= PCR() (unstable)));
3463        _for_each_inner_peripheral!((@ peri_type #[doc = "PLIC_MX peripheral singleton"]
3464        PLIC_MX <= PLIC_MX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3465        = "PMU peripheral singleton"] PMU <= PMU() (unstable)));
3466        _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
3467        <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3468        "RNG peripheral singleton"] RNG <= virtual() (unstable)));
3469        _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
3470        <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
3471        }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3472        "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
3473        enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
3474        _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
3475        <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3476        "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
3477        _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
3478        SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3479        "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
3480        enable_peri_interrupt, disable_peri_interrupt })));
3481        _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
3482        SYSTEM <= PCR() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3483        "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
3484        _for_each_inner_peripheral!((@ peri_type #[doc = "TEE peripheral singleton"] TEE
3485        <= TEE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3486        "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
3487        _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
3488        TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3489        "TRACE0 peripheral singleton"] TRACE0 <= TRACE() (unstable)));
3490        _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
3491        TWAI0 <= TWAI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3492        "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
3493        enable_peri_interrupt, disable_peri_interrupt })));
3494        _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
3495        UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
3496        disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3497        "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
3498        _for_each_inner_peripheral!((@ peri_type #[doc =
3499        "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
3500        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
3501        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3502        "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual() (unstable)));
3503        _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
3504        DMA_CH1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3505        = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual() (unstable)));
3506        _for_each_inner_peripheral!((@ peri_type #[doc = "ADC1 peripheral singleton"]
3507        ADC1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3508        "BT peripheral singleton"] BT <= virtual(LP_BLE_TIMER : {
3509        bind_lp_timer_interrupt, enable_lp_timer_interrupt, disable_lp_timer_interrupt },
3510        BT_MAC : { bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt })
3511        (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3512        "FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
3513        _for_each_inner_peripheral!((@ peri_type #[doc =
3514        "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
3515        _for_each_inner_peripheral!((@ peri_type #[doc =
3516        "SW_INTERRUPT peripheral singleton"] SW_INTERRUPT <= virtual() (unstable)));
3517        _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM0 peripheral singleton"]
3518        MEM2MEM0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
3519        #[doc = "MEM2MEM1 peripheral singleton"] MEM2MEM1 <= virtual() (unstable)));
3520        _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM2 peripheral singleton"]
3521        MEM2MEM2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
3522        #[doc = "MEM2MEM3 peripheral singleton"] MEM2MEM3 <= virtual() (unstable)));
3523        _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM4 peripheral singleton"]
3524        MEM2MEM4 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
3525        #[doc = "MEM2MEM5 peripheral singleton"] MEM2MEM5 <= virtual() (unstable)));
3526        _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM6 peripheral singleton"]
3527        MEM2MEM6 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
3528        #[doc = "MEM2MEM7 peripheral singleton"] MEM2MEM7 <= virtual() (unstable)));
3529        _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM8 peripheral singleton"]
3530        MEM2MEM8 <= virtual() (unstable))); _for_each_inner_peripheral!((GPIO0));
3531        _for_each_inner_peripheral!((GPIO1)); _for_each_inner_peripheral!((GPIO2));
3532        _for_each_inner_peripheral!((GPIO3)); _for_each_inner_peripheral!((GPIO4));
3533        _for_each_inner_peripheral!((GPIO5)); _for_each_inner_peripheral!((GPIO6));
3534        _for_each_inner_peripheral!((GPIO7)); _for_each_inner_peripheral!((GPIO8));
3535        _for_each_inner_peripheral!((GPIO9)); _for_each_inner_peripheral!((GPIO10));
3536        _for_each_inner_peripheral!((GPIO11)); _for_each_inner_peripheral!((GPIO12));
3537        _for_each_inner_peripheral!((GPIO13)); _for_each_inner_peripheral!((GPIO14));
3538        _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
3539        _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
3540        _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
3541        _for_each_inner_peripheral!((AES(unstable)));
3542        _for_each_inner_peripheral!((APB_SARADC(unstable)));
3543        _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
3544        _for_each_inner_peripheral!((DMA(unstable)));
3545        _for_each_inner_peripheral!((DS(unstable)));
3546        _for_each_inner_peripheral!((ECC(unstable)));
3547        _for_each_inner_peripheral!((GPIO(unstable)));
3548        _for_each_inner_peripheral!((GPIO_SD(unstable)));
3549        _for_each_inner_peripheral!((HMAC(unstable)));
3550        _for_each_inner_peripheral!((HP_APM(unstable)));
3551        _for_each_inner_peripheral!((HP_SYS(unstable)));
3552        _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
3553        _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
3554        _for_each_inner_peripheral!((I2S0(unstable)));
3555        _for_each_inner_peripheral!((IEEE802154(unstable)));
3556        _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
3557        _for_each_inner_peripheral!((INTPRI(unstable)));
3558        _for_each_inner_peripheral!((IO_MUX(unstable)));
3559        _for_each_inner_peripheral!((LEDC(unstable)));
3560        _for_each_inner_peripheral!((LPWR(unstable)));
3561        _for_each_inner_peripheral!((LP_ANA(unstable)));
3562        _for_each_inner_peripheral!((LP_AON(unstable)));
3563        _for_each_inner_peripheral!((LP_APM(unstable)));
3564        _for_each_inner_peripheral!((LP_APM0(unstable)));
3565        _for_each_inner_peripheral!((LP_CLKRST(unstable)));
3566        _for_each_inner_peripheral!((LP_PERI(unstable)));
3567        _for_each_inner_peripheral!((LP_TIMER(unstable)));
3568        _for_each_inner_peripheral!((LP_WDT(unstable)));
3569        _for_each_inner_peripheral!((MCPWM0(unstable)));
3570        _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
3571        _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
3572        _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
3573        _for_each_inner_peripheral!((OTP_DEBUG(unstable)));
3574        _for_each_inner_peripheral!((PARL_IO(unstable)));
3575        _for_each_inner_peripheral!((PAU(unstable)));
3576        _for_each_inner_peripheral!((PCNT(unstable)));
3577        _for_each_inner_peripheral!((PCR(unstable)));
3578        _for_each_inner_peripheral!((PLIC_MX(unstable)));
3579        _for_each_inner_peripheral!((PMU(unstable)));
3580        _for_each_inner_peripheral!((RMT(unstable)));
3581        _for_each_inner_peripheral!((RNG(unstable)));
3582        _for_each_inner_peripheral!((RSA(unstable)));
3583        _for_each_inner_peripheral!((SHA(unstable)));
3584        _for_each_inner_peripheral!((ETM(unstable)));
3585        _for_each_inner_peripheral!((SPI0(unstable)));
3586        _for_each_inner_peripheral!((SPI1(unstable)));
3587        _for_each_inner_peripheral!((SPI2));
3588        _for_each_inner_peripheral!((SYSTEM(unstable)));
3589        _for_each_inner_peripheral!((SYSTIMER(unstable)));
3590        _for_each_inner_peripheral!((TEE(unstable)));
3591        _for_each_inner_peripheral!((TIMG0(unstable)));
3592        _for_each_inner_peripheral!((TIMG1(unstable)));
3593        _for_each_inner_peripheral!((TRACE0(unstable)));
3594        _for_each_inner_peripheral!((TWAI0(unstable)));
3595        _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
3596        _for_each_inner_peripheral!((UHCI0(unstable)));
3597        _for_each_inner_peripheral!((USB_DEVICE(unstable)));
3598        _for_each_inner_peripheral!((DMA_CH0(unstable)));
3599        _for_each_inner_peripheral!((DMA_CH1(unstable)));
3600        _for_each_inner_peripheral!((DMA_CH2(unstable)));
3601        _for_each_inner_peripheral!((ADC1(unstable)));
3602        _for_each_inner_peripheral!((BT(unstable)));
3603        _for_each_inner_peripheral!((FLASH(unstable)));
3604        _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
3605        _for_each_inner_peripheral!((SW_INTERRUPT(unstable)));
3606        _for_each_inner_peripheral!((MEM2MEM0(unstable)));
3607        _for_each_inner_peripheral!((MEM2MEM1(unstable)));
3608        _for_each_inner_peripheral!((MEM2MEM2(unstable)));
3609        _for_each_inner_peripheral!((MEM2MEM3(unstable)));
3610        _for_each_inner_peripheral!((MEM2MEM4(unstable)));
3611        _for_each_inner_peripheral!((MEM2MEM5(unstable)));
3612        _for_each_inner_peripheral!((MEM2MEM6(unstable)));
3613        _for_each_inner_peripheral!((MEM2MEM7(unstable)));
3614        _for_each_inner_peripheral!((MEM2MEM8(unstable)));
3615        _for_each_inner_peripheral!((SPI2, Spi2, 0));
3616        _for_each_inner_peripheral!((MEM2MEM0, Mem2mem0, 1));
3617        _for_each_inner_peripheral!((UHCI0, Uhci0, 2));
3618        _for_each_inner_peripheral!((I2S0, I2s0, 3));
3619        _for_each_inner_peripheral!((MEM2MEM1, Mem2mem1, 4));
3620        _for_each_inner_peripheral!((MEM2MEM2, Mem2mem2, 5));
3621        _for_each_inner_peripheral!((AES, Aes, 6)); _for_each_inner_peripheral!((SHA,
3622        Sha, 7)); _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8));
3623        _for_each_inner_peripheral!((PARL_IO, ParlIo, 9));
3624        _for_each_inner_peripheral!((MEM2MEM3, Mem2mem3, 10));
3625        _for_each_inner_peripheral!((MEM2MEM4, Mem2mem4, 11));
3626        _for_each_inner_peripheral!((MEM2MEM5, Mem2mem5, 12));
3627        _for_each_inner_peripheral!((MEM2MEM6, Mem2mem6, 13));
3628        _for_each_inner_peripheral!((MEM2MEM7, Mem2mem7, 14));
3629        _for_each_inner_peripheral!((MEM2MEM8, Mem2mem8, 15));
3630        _for_each_inner_peripheral!((all(@ peri_type #[doc =
3631        "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
3632        "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
3633        "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3634        "<section class=\"warning\">"] #[doc =
3635        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3636        #[doc = "<ul>"] #[doc =
3637        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3638        #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
3639        "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3640        "<section class=\"warning\">"] #[doc =
3641        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3642        #[doc = "<ul>"] #[doc =
3643        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3644        #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
3645        "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3646        "<section class=\"warning\">"] #[doc =
3647        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3648        #[doc = "<ul>"] #[doc =
3649        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3650        #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
3651        "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3652        "<section class=\"warning\">"] #[doc =
3653        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3654        #[doc = "<ul>"] #[doc =
3655        "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3656        #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
3657        "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3658        "<section class=\"warning\">"] #[doc =
3659        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3660        #[doc = "<ul>"] #[doc =
3661        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3662        "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
3663        "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3664        "<section class=\"warning\">"] #[doc =
3665        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3666        #[doc = "<ul>"] #[doc =
3667        "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3668        "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
3669        "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3670        "<section class=\"warning\">"] #[doc =
3671        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3672        #[doc = "<ul>"] #[doc =
3673        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3674        = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
3675        "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3676        "<section class=\"warning\">"] #[doc =
3677        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3678        #[doc = "<ul>"] #[doc =
3679        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3680        = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
3681        "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
3682        "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
3683        "GPIO12 peripheral singleton"] GPIO12 <= virtual()), (@ peri_type #[doc =
3684        "GPIO13 peripheral singleton"] GPIO13 <= virtual()), (@ peri_type #[doc =
3685        "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
3686        "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
3687        "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3688        "<section class=\"warning\">"] #[doc =
3689        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3690        #[doc = "<ul>"] #[doc =
3691        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3692        = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()), (@ peri_type #[doc =
3693        "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3694        "<section class=\"warning\">"] #[doc =
3695        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3696        #[doc = "<ul>"] #[doc =
3697        "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3698        = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
3699        "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3700        "<section class=\"warning\">"] #[doc =
3701        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3702        #[doc = "<ul>"] #[doc =
3703        "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3704        = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
3705        "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3706        "<section class=\"warning\">"] #[doc =
3707        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3708        #[doc = "<ul>"] #[doc =
3709        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3710        #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
3711        "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3712        "<section class=\"warning\">"] #[doc =
3713        "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3714        #[doc = "<ul>"] #[doc =
3715        "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3716        #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
3717        "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
3718        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
3719        = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
3720        peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
3721        ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"] DMA
3722        <= DMA() (unstable)), (@ peri_type #[doc = "DS peripheral singleton"] DS <= DS()
3723        (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <= ECC()
3724        (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE()
3725        (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO()
3726        (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <=
3727        GPIO_SD() (unstable)), (@ peri_type #[doc = "HMAC peripheral singleton"] HMAC <=
3728        HMAC() (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"] HP_APM <=
3729        HP_APM() (unstable)), (@ peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS
3730        <= HP_SYS() (unstable)), (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"]
3731        I2C_ANA_MST <= I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
3732        "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
3733        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
3734        "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
3735        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
3736        "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
3737        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
3738        = "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
3739        bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
3740        (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
3741        INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
3742        "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
3743        = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
3744        #[doc = "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type
3745        #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)), (@
3746        peri_type #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)),
3747        (@ peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON()
3748        (unstable)), (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <=
3749        LP_APM() (unstable)), (@ peri_type #[doc = "LP_APM0 peripheral singleton"]
3750        LP_APM0 <= LP_APM0() (unstable)), (@ peri_type #[doc =
3751        "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)), (@
3752        peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LP_PERI()
3753        (unstable)), (@ peri_type #[doc = "LP_TIMER peripheral singleton"] LP_TIMER <=
3754        LP_TIMER() (unstable)), (@ peri_type #[doc = "LP_WDT peripheral singleton"]
3755        LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc =
3756        "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)), (@ peri_type #[doc
3757        = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)),
3758        (@ peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON <=
3759        MODEM_LPCON() (unstable)), (@ peri_type #[doc =
3760        "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
3761        (@ peri_type #[doc = "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG()
3762        (unstable)), (@ peri_type #[doc = "PARL_IO peripheral singleton"] PARL_IO <=
3763        PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
3764        disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
3765        disable_tx_interrupt }) (unstable)), (@ peri_type #[doc =
3766        "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@ peri_type #[doc =
3767        "PCNT peripheral singleton"] PCNT <= PCNT() (unstable)), (@ peri_type #[doc =
3768        "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@ peri_type #[doc =
3769        "PLIC_MX peripheral singleton"] PLIC_MX <= PLIC_MX() (unstable)), (@ peri_type
3770        #[doc = "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@ peri_type #[doc
3771        = "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@ peri_type #[doc =
3772        "RNG peripheral singleton"] RNG <= virtual() (unstable)), (@ peri_type #[doc =
3773        "RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
3774        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
3775        = "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
3776        enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
3777        = "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)), (@ peri_type #[doc =
3778        "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
3779        "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
3780        "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
3781        enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
3782        "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@ peri_type #[doc =
3783        "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@ peri_type
3784        #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)), (@ peri_type #[doc
3785        = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@ peri_type #[doc
3786        = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@ peri_type #[doc
3787        = "TRACE0 peripheral singleton"] TRACE0 <= TRACE() (unstable)), (@ peri_type
3788        #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@ peri_type
3789        #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
3790        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
3791        peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
3792        bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
3793        peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
3794        peri_type #[doc = "USB_DEVICE peripheral singleton"] USB_DEVICE <=
3795        USB_DEVICE(USB_DEVICE : { bind_peri_interrupt, enable_peri_interrupt,
3796        disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
3797        "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual() (unstable)), (@ peri_type
3798        #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual() (unstable)), (@
3799        peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual()
3800        (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
3801        (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
3802        virtual(LP_BLE_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
3803        disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
3804        enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
3805        "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
3806        = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
3807        (@ peri_type #[doc = "SW_INTERRUPT peripheral singleton"] SW_INTERRUPT <=
3808        virtual() (unstable)), (@ peri_type #[doc = "MEM2MEM0 peripheral singleton"]
3809        MEM2MEM0 <= virtual() (unstable)), (@ peri_type #[doc =
3810        "MEM2MEM1 peripheral singleton"] MEM2MEM1 <= virtual() (unstable)), (@ peri_type
3811        #[doc = "MEM2MEM2 peripheral singleton"] MEM2MEM2 <= virtual() (unstable)), (@
3812        peri_type #[doc = "MEM2MEM3 peripheral singleton"] MEM2MEM3 <= virtual()
3813        (unstable)), (@ peri_type #[doc = "MEM2MEM4 peripheral singleton"] MEM2MEM4 <=
3814        virtual() (unstable)), (@ peri_type #[doc = "MEM2MEM5 peripheral singleton"]
3815        MEM2MEM5 <= virtual() (unstable)), (@ peri_type #[doc =
3816        "MEM2MEM6 peripheral singleton"] MEM2MEM6 <= virtual() (unstable)), (@ peri_type
3817        #[doc = "MEM2MEM7 peripheral singleton"] MEM2MEM7 <= virtual() (unstable)), (@
3818        peri_type #[doc = "MEM2MEM8 peripheral singleton"] MEM2MEM8 <= virtual()
3819        (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1), (GPIO2),
3820        (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
3821        (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO22), (GPIO23), (GPIO24), (GPIO25),
3822        (GPIO26), (GPIO27), (AES(unstable)), (APB_SARADC(unstable)),
3823        (ASSIST_DEBUG(unstable)), (DMA(unstable)), (DS(unstable)), (ECC(unstable)),
3824        (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)), (HP_APM(unstable)),
3825        (HP_SYS(unstable)), (I2C_ANA_MST(unstable)), (I2C0), (I2C1), (I2S0(unstable)),
3826        (IEEE802154(unstable)), (INTERRUPT_CORE0(unstable)), (INTPRI(unstable)),
3827        (IO_MUX(unstable)), (LEDC(unstable)), (LPWR(unstable)), (LP_ANA(unstable)),
3828        (LP_AON(unstable)), (LP_APM(unstable)), (LP_APM0(unstable)),
3829        (LP_CLKRST(unstable)), (LP_PERI(unstable)), (LP_TIMER(unstable)),
3830        (LP_WDT(unstable)), (MCPWM0(unstable)), (MEM_MONITOR(unstable)),
3831        (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)), (OTP_DEBUG(unstable)),
3832        (PARL_IO(unstable)), (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)),
3833        (PLIC_MX(unstable)), (PMU(unstable)), (RMT(unstable)), (RNG(unstable)),
3834        (RSA(unstable)), (SHA(unstable)), (ETM(unstable)), (SPI0(unstable)),
3835        (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
3836        (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (TRACE0(unstable)),
3837        (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)), (USB_DEVICE(unstable)),
3838        (DMA_CH0(unstable)), (DMA_CH1(unstable)), (DMA_CH2(unstable)), (ADC1(unstable)),
3839        (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)),
3840        (SW_INTERRUPT(unstable)), (MEM2MEM0(unstable)), (MEM2MEM1(unstable)),
3841        (MEM2MEM2(unstable)), (MEM2MEM3(unstable)), (MEM2MEM4(unstable)),
3842        (MEM2MEM5(unstable)), (MEM2MEM6(unstable)), (MEM2MEM7(unstable)),
3843        (MEM2MEM8(unstable)))); _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 0),
3844        (MEM2MEM0, Mem2mem0, 1), (UHCI0, Uhci0, 2), (I2S0, I2s0, 3), (MEM2MEM1, Mem2mem1,
3845        4), (MEM2MEM2, Mem2mem2, 5), (AES, Aes, 6), (SHA, Sha, 7), (APB_SARADC,
3846        ApbSaradc, 8), (PARL_IO, ParlIo, 9), (MEM2MEM3, Mem2mem3, 10), (MEM2MEM4,
3847        Mem2mem4, 11), (MEM2MEM5, Mem2mem5, 12), (MEM2MEM6, Mem2mem6, 13), (MEM2MEM7,
3848        Mem2mem7, 14), (MEM2MEM8, Mem2mem8, 15)));
3849    };
3850}
3851/// This macro can be used to generate code for each `GPIOn` instance.
3852///
3853/// For an explanation on the general syntax, as well as usage of individual/repeated
3854/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3855///
3856/// This macro has one option for its "Individual matcher" case:
3857///
3858/// Syntax: `($n:literal, $gpio:ident ($($digital_input_function:ident =>
3859/// $digital_input_signal:ident)*) ($($digital_output_function:ident =>
3860/// $digital_output_signal:ident)*) ($([$pin_attribute:ident])*))`
3861///
3862/// Macro fragments:
3863///
3864/// - `$n`: the number of the GPIO. For `GPIO0`, `$n` is 0.
3865/// - `$gpio`: the name of the GPIO.
3866/// - `$digital_input_function`: the number of the digital function, as an identifier (i.e. for
3867///   function 0 this is `_0`).
3868/// - `$digital_input_function`: the name of the digital function, as an identifier.
3869/// - `$digital_output_function`: the number of the digital function, as an identifier (i.e. for
3870///   function 0 this is `_0`).
3871/// - `$digital_output_function`: the name of the digital function, as an identifier.
3872/// - `$pin_attribute`: `Input` and/or `Output`, marks the possible directions of the GPIO.
3873///   Bracketed so that they can also be matched as optional fragments. Order is always Input first.
3874///
3875/// Example data: `(0, GPIO0 (_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input]
3876/// [Output]))`
3877#[macro_export]
3878#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3879macro_rules! for_each_gpio {
3880    ($($pattern:tt => $code:tt;)*) => {
3881        macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
3882        } _for_each_inner_gpio!((0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
3883        [Output]))); _for_each_inner_gpio!((1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0)
3884        ([Input] [Output]))); _for_each_inner_gpio!((2, GPIO2(_0 => MTMS _2 => FSPIWP)
3885        (_2 => FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((3, GPIO3(_0 => MTDI
3886        _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((4,
3887        GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])));
3888        _for_each_inner_gpio!((5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input]
3889        [Output]))); _for_each_inner_gpio!((6, GPIO6() () ([Input] [Output])));
3890        _for_each_inner_gpio!((7, GPIO7() () ([Input] [Output])));
3891        _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
3892        _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
3893        _for_each_inner_gpio!((10, GPIO10() () ([Input] [Output])));
3894        _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
3895        _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
3896        _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
3897        _for_each_inner_gpio!((14, GPIO14() () ([Input] [Output])));
3898        _for_each_inner_gpio!((22, GPIO22() () ([Input] [Output])));
3899        _for_each_inner_gpio!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input]
3900        [Output]))); _for_each_inner_gpio!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2)
3901        ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25() (_2 => FSPICS3)
3902        ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26() (_2 => FSPICS4)
3903        ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27() (_2 => FSPICS5)
3904        ([Input] [Output]))); _for_each_inner_gpio!((all(0, GPIO0(_2 => FSPIQ) (_2 =>
3905        FSPIQ) ([Input] [Output])), (1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
3906        [Output])), (2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input]
3907        [Output])), (3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD) ([Input]
3908        [Output])), (4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
3909        [Output])), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
3910        (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input] [Output])), (8,
3911        GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10()
3912        () ([Input] [Output])), (11, GPIO11() () ([Input] [Output])), (12, GPIO12() ()
3913        ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14, GPIO14() ()
3914        ([Input] [Output])), (22, GPIO22() () ([Input] [Output])), (23, GPIO23(_0 =>
3915        U0RXD) (_2 => FSPICS1) ([Input] [Output])), (24, GPIO24() (_0 => U0TXD _2 =>
3916        FSPICS2) ([Input] [Output])), (25, GPIO25() (_2 => FSPICS3) ([Input] [Output])),
3917        (26, GPIO26() (_2 => FSPICS4) ([Input] [Output])), (27, GPIO27() (_2 => FSPICS5)
3918        ([Input] [Output]))));
3919    };
3920}
3921/// This macro can be used to generate code for each analog function of each GPIO.
3922///
3923/// For an explanation on the general syntax, as well as usage of individual/repeated
3924/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3925///
3926/// This macro has two options for its "Individual matcher" case:
3927///
3928/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
3929/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
3930///   expanded signal case, where you need the number(s) of a signal, or the general group to which
3931///   the signal belongs. For example, in case of `ADC2_CH3` the expanded form looks like
3932///   `(ADC2_CH3, ADCn_CHm, 2, 3)`.
3933///
3934/// Macro fragments:
3935///
3936/// - `$signal`: the name of the signal.
3937/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
3938///   is `ADCn_CHm`.
3939/// - `$number`: the numbers extracted from `$signal`.
3940/// - `$gpio`: the name of the GPIO.
3941///
3942/// Example data:
3943/// - `(ADC2_CH5, GPIO12)`
3944/// - `((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)`
3945///
3946/// The expanded syntax is only available when the signal has at least one numbered component.
3947#[macro_export]
3948#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3949macro_rules! for_each_analog_function {
3950    ($($pattern:tt => $code:tt;)*) => {
3951        macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
3952        tt) => {} } _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
3953        _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
3954        _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
3955        _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
3956        _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
3957        _for_each_inner_analog_function!((ZCD0, GPIO10));
3958        _for_each_inner_analog_function!((ZCD1, GPIO11));
3959        _for_each_inner_analog_function!((XTAL_32K_P, GPIO13));
3960        _for_each_inner_analog_function!((XTAL_32K_N, GPIO14));
3961        _for_each_inner_analog_function!((USB_DM, GPIO26));
3962        _for_each_inner_analog_function!((USB_DP, GPIO27));
3963        _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
3964        _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
3965        _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
3966        _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
3967        _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
3968        _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO10));
3969        _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO11));
3970        _for_each_inner_analog_function!((all(ADC1_CH0, GPIO1), (ADC1_CH1, GPIO2),
3971        (ADC1_CH2, GPIO3), (ADC1_CH3, GPIO4), (ADC1_CH4, GPIO5), (ZCD0, GPIO10), (ZCD1,
3972        GPIO11), (XTAL_32K_P, GPIO13), (XTAL_32K_N, GPIO14), (USB_DM, GPIO26), (USB_DP,
3973        GPIO27))); _for_each_inner_analog_function!((all_expanded((ADC1_CH0, ADCn_CHm, 1,
3974        0), GPIO1), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2, ADCn_CHm, 1, 2),
3975        GPIO3), ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5),
3976        ((ZCD0, ZCDn, 0), GPIO10), ((ZCD1, ZCDn, 1), GPIO11)));
3977    };
3978}
3979/// This macro can be used to generate code for each LP/RTC function of each GPIO.
3980///
3981/// For an explanation on the general syntax, as well as usage of individual/repeated
3982/// matchers, refer to [the crate-level documentation][crate#for_each-macros].
3983///
3984/// This macro has two options for its "Individual matcher" case:
3985///
3986/// - `all`: `($signal:ident, $gpio:ident)` - simple case where you only need identifiers
3987/// - `all_expanded`: `(($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident)` -
3988///   expanded signal case, where you need the number(s) of a signal, or the general group to which
3989///   the signal belongs. For example, in case of `SAR_I2C_SCL_1` the expanded form looks like
3990///   `(SAR_I2C_SCL_1, SAR_I2C_SCL_n, 1)`.
3991///
3992/// Macro fragments:
3993///
3994/// - `$signal`: the name of the signal.
3995/// - `$group`: the name of the signal, with numbers replaced by placeholders. For `ADC2_CH3` this
3996///   is `ADCn_CHm`.
3997/// - `$number`: the numbers extracted from `$signal`.
3998/// - `$gpio`: the name of the GPIO.
3999///
4000/// Example data:
4001/// - `(RTC_GPIO15, GPIO12)`
4002/// - `((RTC_GPIO15, RTC_GPIOn, 15), GPIO12)`
4003///
4004/// The expanded syntax is only available when the signal has at least one numbered component.
4005#[macro_export]
4006#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4007macro_rules! for_each_lp_function {
4008    ($($pattern:tt => $code:tt;)*) => {
4009        macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
4010        => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO7));
4011        _for_each_inner_lp_function!((LP_GPIO1, GPIO8));
4012        _for_each_inner_lp_function!((LP_GPIO2, GPIO9));
4013        _for_each_inner_lp_function!((LP_GPIO3, GPIO10));
4014        _for_each_inner_lp_function!((LP_GPIO4, GPIO11));
4015        _for_each_inner_lp_function!((LP_GPIO5, GPIO12));
4016        _for_each_inner_lp_function!((LP_GPIO6, GPIO13));
4017        _for_each_inner_lp_function!((LP_GPIO7, GPIO14));
4018        _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO7));
4019        _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO8));
4020        _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO9));
4021        _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO10));
4022        _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO11));
4023        _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO12));
4024        _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO13));
4025        _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO14));
4026        _for_each_inner_lp_function!((all(LP_GPIO0, GPIO7), (LP_GPIO1, GPIO8), (LP_GPIO2,
4027        GPIO9), (LP_GPIO3, GPIO10), (LP_GPIO4, GPIO11), (LP_GPIO5, GPIO12), (LP_GPIO6,
4028        GPIO13), (LP_GPIO7, GPIO14)));
4029        _for_each_inner_lp_function!((all_expanded((LP_GPIO0, LP_GPIOn, 0), GPIO7),
4030        ((LP_GPIO1, LP_GPIOn, 1), GPIO8), ((LP_GPIO2, LP_GPIOn, 2), GPIO9), ((LP_GPIO3,
4031        LP_GPIOn, 3), GPIO10), ((LP_GPIO4, LP_GPIOn, 4), GPIO11), ((LP_GPIO5, LP_GPIOn,
4032        5), GPIO12), ((LP_GPIO6, LP_GPIOn, 6), GPIO13), ((LP_GPIO7, LP_GPIOn, 7),
4033        GPIO14)));
4034    };
4035}
4036/// Defines the `InputSignal` and `OutputSignal` enums.
4037///
4038/// This macro is intended to be called in esp-hal only.
4039#[macro_export]
4040#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4041macro_rules! define_io_mux_signals {
4042    () => {
4043        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
4044        #[derive(Debug, PartialEq, Copy, Clone)]
4045        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4046        #[doc(hidden)]
4047        pub enum InputSignal {
4048            EXT_ADC_START       = 0,
4049            U0RXD               = 6,
4050            U0CTS               = 7,
4051            U0DSR               = 8,
4052            U1RXD               = 9,
4053            U1CTS               = 10,
4054            U1DSR               = 11,
4055            I2S_MCLK            = 12,
4056            I2SO_BCK            = 13,
4057            I2SO_WS             = 14,
4058            I2SI_SD             = 15,
4059            I2SI_BCK            = 16,
4060            I2SI_WS             = 17,
4061            USB_JTAG_TDO_BRIDGE = 19,
4062            CPU_GPIO_0          = 28,
4063            CPU_GPIO_1          = 29,
4064            CPU_GPIO_2          = 30,
4065            CPU_GPIO_3          = 31,
4066            CPU_GPIO_4          = 32,
4067            CPU_GPIO_5          = 33,
4068            CPU_GPIO_6          = 34,
4069            CPU_GPIO_7          = 35,
4070            I2CEXT0_SCL         = 45,
4071            I2CEXT0_SDA         = 46,
4072            PARL_RX_DATA0       = 47,
4073            PARL_RX_DATA1       = 48,
4074            PARL_RX_DATA2       = 49,
4075            PARL_RX_DATA3       = 50,
4076            PARL_RX_DATA4       = 51,
4077            PARL_RX_DATA5       = 52,
4078            PARL_RX_DATA6       = 53,
4079            PARL_RX_DATA7       = 54,
4080            I2CEXT1_SCL         = 55,
4081            I2CEXT1_SDA         = 56,
4082            FSPICLK             = 63,
4083            FSPIQ               = 64,
4084            FSPID               = 65,
4085            FSPIHD              = 66,
4086            FSPIWP              = 67,
4087            FSPICS0             = 68,
4088            PARL_RX_CLK         = 69,
4089            PARL_TX_CLK         = 70,
4090            RMT_SIG_0           = 71,
4091            RMT_SIG_1           = 72,
4092            TWAI0_RX            = 73,
4093            PWM0_SYNC0          = 87,
4094            PWM0_SYNC1          = 88,
4095            PWM0_SYNC2          = 89,
4096            PWM0_F0             = 90,
4097            PWM0_F1             = 91,
4098            PWM0_F2             = 92,
4099            PWM0_CAP0           = 93,
4100            PWM0_CAP1           = 94,
4101            PWM0_CAP2           = 95,
4102            SIG_FUNC_97         = 97,
4103            SIG_FUNC_98         = 98,
4104            SIG_FUNC_99         = 99,
4105            SIG_FUNC_100        = 100,
4106            PCNT0_SIG_CH0       = 101,
4107            PCNT0_SIG_CH1       = 102,
4108            PCNT0_CTRL_CH0      = 103,
4109            PCNT0_CTRL_CH1      = 104,
4110            PCNT1_SIG_CH0       = 105,
4111            PCNT1_SIG_CH1       = 106,
4112            PCNT1_CTRL_CH0      = 107,
4113            PCNT1_CTRL_CH1      = 108,
4114            PCNT2_SIG_CH0       = 109,
4115            PCNT2_SIG_CH1       = 110,
4116            PCNT2_CTRL_CH0      = 111,
4117            PCNT2_CTRL_CH1      = 112,
4118            PCNT3_SIG_CH0       = 113,
4119            PCNT3_SIG_CH1       = 114,
4120            PCNT3_CTRL_CH0      = 115,
4121            PCNT3_CTRL_CH1      = 116,
4122            SPIQ                = 121,
4123            SPID                = 122,
4124            SPIHD               = 123,
4125            SPIWP               = 124,
4126            MTDI,
4127            MTCK,
4128            MTMS,
4129        }
4130        #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
4131        #[derive(Debug, PartialEq, Copy, Clone)]
4132        #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4133        #[doc(hidden)]
4134        pub enum OutputSignal {
4135            LEDC_LS_SIG0     = 0,
4136            LEDC_LS_SIG1     = 1,
4137            LEDC_LS_SIG2     = 2,
4138            LEDC_LS_SIG3     = 3,
4139            LEDC_LS_SIG4     = 4,
4140            LEDC_LS_SIG5     = 5,
4141            U0TXD            = 6,
4142            U0RTS            = 7,
4143            U0DTR            = 8,
4144            U1TXD            = 9,
4145            U1RTS            = 10,
4146            U1DTR            = 11,
4147            I2S_MCLK         = 12,
4148            I2SO_BCK         = 13,
4149            I2SO_WS          = 14,
4150            I2SO_SD          = 15,
4151            I2SI_BCK         = 16,
4152            I2SI_WS          = 17,
4153            I2SO_SD1         = 18,
4154            USB_JTAG_TRST    = 19,
4155            CPU_GPIO_0       = 28,
4156            CPU_GPIO_1       = 29,
4157            CPU_GPIO_2       = 30,
4158            CPU_GPIO_3       = 31,
4159            CPU_GPIO_4       = 32,
4160            CPU_GPIO_5       = 33,
4161            CPU_GPIO_6       = 34,
4162            CPU_GPIO_7       = 35,
4163            I2CEXT0_SCL      = 45,
4164            I2CEXT0_SDA      = 46,
4165            PARL_TX_DATA0    = 47,
4166            PARL_TX_DATA1    = 48,
4167            PARL_TX_DATA2    = 49,
4168            PARL_TX_DATA3    = 50,
4169            PARL_TX_DATA4    = 51,
4170            PARL_TX_DATA5    = 52,
4171            PARL_TX_DATA6    = 53,
4172            PARL_TX_DATA7    = 54,
4173            I2CEXT1_SCL      = 55,
4174            I2CEXT1_SDA      = 56,
4175            FSPICLK          = 63,
4176            FSPIQ            = 64,
4177            FSPID            = 65,
4178            FSPIHD           = 66,
4179            FSPIWP           = 67,
4180            FSPICS0          = 68,
4181            PARL_RX_CLK      = 69,
4182            PARL_TX_CLK      = 70,
4183            RMT_SIG_0        = 71,
4184            RMT_SIG_1        = 72,
4185            TWAI0_TX         = 73,
4186            TWAI0_BUS_OFF_ON = 74,
4187            TWAI0_CLKOUT     = 75,
4188            TWAI0_STANDBY    = 76,
4189            CTE_ANT7         = 78,
4190            CTE_ANT8         = 79,
4191            CTE_ANT9         = 80,
4192            GPIO_SD0         = 83,
4193            GPIO_SD1         = 84,
4194            GPIO_SD2         = 85,
4195            GPIO_SD3         = 86,
4196            PWM0_0A          = 87,
4197            PWM0_0B          = 88,
4198            PWM0_1A          = 89,
4199            PWM0_1B          = 90,
4200            PWM0_2A          = 91,
4201            PWM0_2B          = 92,
4202            SIG_IN_FUNC97    = 97,
4203            SIG_IN_FUNC98    = 98,
4204            SIG_IN_FUNC99    = 99,
4205            SIG_IN_FUNC100   = 100,
4206            FSPICS1          = 101,
4207            FSPICS2          = 102,
4208            FSPICS3          = 103,
4209            FSPICS4          = 104,
4210            FSPICS5          = 105,
4211            CTE_ANT10        = 106,
4212            CTE_ANT11        = 107,
4213            CTE_ANT12        = 108,
4214            CTE_ANT13        = 109,
4215            CTE_ANT14        = 110,
4216            CTE_ANT15        = 111,
4217            SPICLK           = 114,
4218            SPICS0           = 115,
4219            SPICS1           = 116,
4220            SPIQ             = 121,
4221            SPID             = 122,
4222            SPIHD            = 123,
4223            SPIWP            = 124,
4224            CLK_OUT_OUT1     = 125,
4225            CLK_OUT_OUT2     = 126,
4226            CLK_OUT_OUT3     = 127,
4227            GPIO             = 128,
4228            MTDO,
4229        }
4230    };
4231}
4232/// Defines and implements the `io_mux_reg` function.
4233///
4234/// The generated function has the following signature:
4235///
4236/// ```rust,ignore
4237/// pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
4238///     // ...
4239/// # unimplemented!()
4240/// }
4241/// ```
4242///
4243/// This macro is intended to be called in esp-hal only.
4244#[macro_export]
4245#[expect(clippy::crate_in_macro_def)]
4246#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4247macro_rules! define_io_mux_reg {
4248    () => {
4249        pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
4250            crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
4251        }
4252    };
4253}