1#[doc = concat!("assert_eq!(chip_name, ", chip!(), ")")]
12#[macro_export]
14#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
15macro_rules! chip {
16 () => {
17 "esp32"
18 };
19}
20#[doc = concat!("assert_eq!(chip_name, ", chip_pretty!(), ")")]
28#[macro_export]
30#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
31macro_rules! chip_pretty {
32 () => {
33 "ESP32"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32"
42 };
43 ("arch") => {
44 "xtensa"
45 };
46 ("cores") => {
47 2
48 };
49 ("cores", str) => {
50 stringify!(2)
51 };
52 ("trm") => {
53 "https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf"
54 };
55 ("gpio.version") => {
56 1
57 };
58 ("gpio.version", str) => {
59 stringify!(1)
60 };
61 ("gpio.has_input_sync") => {
62 false
63 };
64 ("gpio.gpio_function") => {
65 2
66 };
67 ("gpio.gpio_function", str) => {
68 stringify!(2)
69 };
70 ("gpio.constant_0_input") => {
71 48
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(48)
75 };
76 ("gpio.constant_1_input") => {
77 56
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(56)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 true
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.need_soft_isolate_during_pd") => {
92 false
93 };
94 ("gpio.has_bank_1") => {
95 true
96 };
97 ("gpio.input_signal_max") => {
98 206
99 };
100 ("gpio.input_signal_max", str) => {
101 stringify!(206)
102 };
103 ("gpio.output_signal_max") => {
104 256
105 };
106 ("gpio.output_signal_max", str) => {
107 stringify!(256)
108 };
109 ("lp_io.version") => {
110 "esp32"
111 };
112 ("lp_io.has_gpio_matrix") => {
113 false
114 };
115 ("uart.ram_size") => {
116 128
117 };
118 ("uart.ram_size", str) => {
119 stringify!(128)
120 };
121 ("uart.version") => {
122 1
123 };
124 ("uart.version", str) => {
125 stringify!(1)
126 };
127 ("uart.peripheral_controls_mem_clk") => {
128 false
129 };
130 ("uart.has_sclk_divider") => {
131 false
132 };
133 ("uart.has_sclk_enable") => {
134 false
135 };
136 ("i2c_master.version") => {
137 1
138 };
139 ("i2c_master.version", str) => {
140 stringify!(1)
141 };
142 ("i2c_master.has_fsm_timeouts") => {
143 false
144 };
145 ("i2c_master.has_hw_bus_clear") => {
146 false
147 };
148 ("i2c_master.has_bus_timeout_enable") => {
149 false
150 };
151 ("i2c_master.separate_filter_config_registers") => {
152 true
153 };
154 ("i2c_master.can_estimate_nack_reason") => {
155 false
156 };
157 ("i2c_master.has_conf_update") => {
158 false
159 };
160 ("i2c_master.has_reliable_fsm_reset") => {
161 false
162 };
163 ("i2c_master.has_arbitration_en") => {
164 false
165 };
166 ("i2c_master.has_tx_fifo_watermark") => {
167 false
168 };
169 ("i2c_master.bus_timeout_is_exponential") => {
170 false
171 };
172 ("i2c_master.has_pd_en") => {
173 false
174 };
175 ("i2c_master.i2c0_data_register_ahb_address") => {
176 1610690588
177 };
178 ("i2c_master.i2c0_data_register_ahb_address", str) => {
179 stringify!(1610690588)
180 };
181 ("i2c_master.max_bus_timeout") => {
182 1048575
183 };
184 ("i2c_master.max_bus_timeout", str) => {
185 stringify!(1048575)
186 };
187 ("i2c_master.ll_intr_mask") => {
188 262143
189 };
190 ("i2c_master.ll_intr_mask", str) => {
191 stringify!(262143)
192 };
193 ("i2c_master.fifo_size") => {
194 32
195 };
196 ("i2c_master.fifo_size", str) => {
197 stringify!(32)
198 };
199 ("spi_master.version") => {
200 1
201 };
202 ("spi_master.version", str) => {
203 stringify!(1)
204 };
205 ("spi_master.fifo_size") => {
206 64
207 };
208 ("spi_master.fifo_size", str) => {
209 stringify!(64)
210 };
211 ("spi_master.bit_order_is_bool") => {
212 true
213 };
214 ("spi_master.has_octal") => {
215 false
216 };
217 ("spi_master.has_app_interrupts") => {
218 false
219 };
220 ("spi_master.has_dma_segmented_transfer") => {
221 false
222 };
223 ("spi_master.has_clk_pre_div") => {
224 false
225 };
226 ("spi_master.dma_can_access_flash") => {
227 false
228 };
229 ("i2s.version") => {
230 1
231 };
232 ("i2s.version", str) => {
233 stringify!(1)
234 };
235 ("i2s.mclk_divider_bit_width") => {
236 6
237 };
238 ("i2s.mclk_divider_bit_width", str) => {
239 stringify!(6)
240 };
241 ("i2s.max_ws_width") => {
242 128
243 };
244 ("i2s.max_ws_width", str) => {
245 stringify!(128)
246 };
247 ("i2s.clock_configured_by_pcr") => {
248 false
249 };
250 ("i2s.clock_configured_by_hp_sys_clkrst") => {
251 false
252 };
253 ("i2s.supports_pdm_rx_hp_filter") => {
254 false
255 };
256 ("i2s.supports_pdm_tx") => {
257 true
258 };
259 ("i2s.supports_pdm_rx") => {
260 true
261 };
262 ("i2s.supports_pcm2pdm") => {
263 true
264 };
265 ("i2s.supports_pdm2pcm") => {
266 true
267 };
268 ("rmt.ram_start") => {
269 1073047552
270 };
271 ("rmt.ram_start", str) => {
272 stringify!(1073047552)
273 };
274 ("rmt.channel_ram_size") => {
275 64
276 };
277 ("rmt.channel_ram_size", str) => {
278 stringify!(64)
279 };
280 ("rmt.has_tx_immediate_stop") => {
281 false
282 };
283 ("rmt.has_tx_loop_count") => {
284 false
285 };
286 ("rmt.has_tx_loop_auto_stop") => {
287 false
288 };
289 ("rmt.has_tx_carrier_data_only") => {
290 false
291 };
292 ("rmt.has_tx_sync") => {
293 false
294 };
295 ("rmt.has_rx_wrap") => {
296 false
297 };
298 ("rmt.has_rx_demodulation") => {
299 false
300 };
301 ("rmt.has_per_channel_clock") => {
302 true
303 };
304 ("sdmmc.has_iomux") => {
305 true
306 };
307 ("sdmmc.has_gpio_matrix") => {
308 false
309 };
310 ("sdmmc.psram_dma") => {
311 false
312 };
313 ("sdmmc.uhs") => {
314 false
315 };
316 ("bt.controller") => {
317 "btdm"
318 };
319 ("wifi.has_wifi6") => {
320 false
321 };
322 ("wifi.mac_version") => {
323 1
324 };
325 ("wifi.mac_version", str) => {
326 stringify!(1)
327 };
328 ("wifi.has_5g") => {
329 false
330 };
331 ("wifi.csi_supported") => {
332 true
333 };
334 ("wifi.has_nan") => {
335 true
336 };
337 ("wifi.has_ftm") => {
338 false
339 };
340 ("ethernet.mii_via_gpio_matrix") => {
341 false
342 };
343 ("ethernet.rx_store_and_forward") => {
344 true
345 };
346 ("ethernet.rx_checksum_offload") => {
347 false
348 };
349 ("ethernet.tx_checksum_offload") => {
350 false
351 };
352 ("ethernet.dma_burst_len") => {
353 32
354 };
355 ("ethernet.dma_burst_len", str) => {
356 stringify!(32)
357 };
358 ("ethernet.has_rgmii") => {
359 false
360 };
361 ("phy.combo_module") => {
362 true
363 };
364 ("rgb_display.output_lines") => {
365 24
366 };
367 ("rgb_display.output_lines", str) => {
368 stringify!(24)
369 };
370 ("adc.line_calibration") => {
371 true
372 };
373 ("adc.curve_calibration") => {
374 false
375 };
376 ("adc.basic_calibration") => {
377 false
378 };
379 ("adc.calibration_v1_scheme_supported") => {
380 false
381 };
382 ("adc.channel_compensation") => {
383 false
384 };
385 ("adc.pcr_clock") => {
386 false
387 };
388 ("adc.pcr_sar_clk_div") => {
389 false
390 };
391 ("adc.sar_power_override") => {
392 false
393 };
394 ("ledc.version") => {
395 1
396 };
397 ("ledc.version", str) => {
398 stringify!(1)
399 };
400 ("ledc.channel_count") => {
401 8
402 };
403 ("ledc.channel_count", str) => {
404 stringify!(8)
405 };
406 ("sdm.channel_count") => {
407 8
408 };
409 ("sdm.channel_count", str) => {
410 stringify!(8)
411 };
412 ("timergroup.timg_has_timer1") => {
413 true
414 };
415 ("timergroup.timg_has_divcnt_rst") => {
416 false
417 };
418 ("timergroup.wdt_has_conf_update") => {
419 false
420 };
421 ("aes.has_split_text_registers") => {
422 false
423 };
424 ("aes.endianness_configurable") => {
425 true
426 };
427 ("rng.apb_cycle_wait_num") => {
428 16
429 };
430 ("rng.apb_cycle_wait_num", str) => {
431 stringify!(16)
432 };
433 ("rng.trng_supported") => {
434 true
435 };
436 ("rng.is_lp_sys") => {
437 false
438 };
439 ("rsa.version") => {
440 1
441 };
442 ("rsa.version", str) => {
443 stringify!(1)
444 };
445 ("rsa.size_increment") => {
446 512
447 };
448 ("rsa.size_increment", str) => {
449 stringify!(512)
450 };
451 ("rsa.memory_size_bytes") => {
452 512
453 };
454 ("rsa.memory_size_bytes", str) => {
455 stringify!(512)
456 };
457 ("sleep.light_sleep") => {
458 true
459 };
460 ("sleep.deep_sleep") => {
461 true
462 };
463 ("sleep.rejectable_mask") => {
464 20
465 };
466 ("sleep.ext1_version") => {
467 1
468 };
469 ("sleep.ext1_version", str) => {
470 stringify!(1)
471 };
472 ("sleep.pin_wakeup_version") => {
473 1
474 };
475 ("sleep.pin_wakeup_version", str) => {
476 stringify!(1)
477 };
478 ("sleep.deep_sleep_needs_gpio_isolation") => {
479 true
480 };
481 ("dma.mem2mem_requires_peripheral") => {
482 false
483 };
484 ("dma.ext_mem_configurable_block_size") => {
485 false
486 };
487 ("dma.separate_in_out_interrupts") => {
488 false
489 };
490 ("interrupts.status_registers") => {
491 3
492 };
493 ("interrupts.status_registers", str) => {
494 stringify!(3)
495 };
496 ("mmu.page_size") => {
497 65536
498 };
499 ("mmu.page_size", str) => {
500 stringify!(65536)
501 };
502 ("mmu.entry_num") => {
503 256
504 };
505 ("mmu.entry_num", str) => {
506 stringify!(256)
507 };
508 ("psram.octal_spi") => {
509 false
510 };
511 ("psram.hex_spi") => {
512 false
513 };
514 ("psram.extmem_origin") => {
515 1065353216
516 };
517 ("psram.extmem_origin", str) => {
518 stringify!(1065353216)
519 };
520 ("rom.has_crc_le") => {
521 true
522 };
523 ("rom.has_crc_be") => {
524 true
525 };
526 ("rom.has_md5_bsd") => {
527 true
528 };
529 ("rom.has_md5_mbedtls") => {
530 false
531 };
532 ("soc.cpu_has_branch_predictor") => {
533 false
534 };
535 ("soc.cpu_has_csr_pc") => {
536 false
537 };
538 ("soc.cpu_has_zcmp_workaround") => {
539 false
540 };
541 ("soc.multi_core_enabled") => {
542 true
543 };
544 ("soc.internal_memory_cached") => {
545 false
546 };
547 ("soc.has_swd_watchdog") => {
548 false
549 };
550 ("soc.cpu_mcause_mask") => {
551 0
552 };
553 ("soc.cpu_mcause_mask", str) => {
554 stringify!(0)
555 };
556 ("soc.cpu_pmp_granularity") => {
557 4
558 };
559 ("soc.cpu_pmp_granularity", str) => {
560 stringify!(4)
561 };
562 ("clock_tree.cpu_pll_div_in") => {
563 [crate ::soc::clocks::CpuPllDivInConfig::Pll, crate
564 ::soc::clocks::CpuPllDivInConfig::Apll]
565 };
566 ("clock_tree.cpu_pll_div.divisor") => {
567 [2, 4]
568 };
569 ("clock_tree.syscon_pre_div_in") => {
570 [crate ::soc::clocks::SysconPreDivInConfig::Xtal, crate
571 ::soc::clocks::SysconPreDivInConfig::RcFast]
572 };
573 ("clock_tree.syscon_pre_div.divisor") => {
574 (0, 1023)
575 };
576 ("clock_tree.cpu_clk") => {
577 [crate ::soc::clocks::CpuClkConfig::Xtal, crate
578 ::soc::clocks::CpuClkConfig::RcFast, crate ::soc::clocks::CpuClkConfig::Apll,
579 crate ::soc::clocks::CpuClkConfig::Pll]
580 };
581 ("clock_tree.apb_clk") => {
582 [crate ::soc::clocks::ApbClkConfig::Pll80m, crate
583 ::soc::clocks::ApbClkConfig::CpuDiv2, crate ::soc::clocks::ApbClkConfig::Cpu]
584 };
585 ("clock_tree.ref_tick_pll.divisor") => {
586 (0, 255)
587 };
588 ("clock_tree.ref_tick_apll.divisor") => {
589 (0, 255)
590 };
591 ("clock_tree.ref_tick_xtal.divisor") => {
592 (0, 255)
593 };
594 ("clock_tree.ref_tick_fosc.divisor") => {
595 (0, 255)
596 };
597 ("clock_tree.ref_tick") => {
598 [crate ::soc::clocks::RefTickConfig::Pll, crate
599 ::soc::clocks::RefTickConfig::Apll, crate ::soc::clocks::RefTickConfig::Xtal,
600 crate ::soc::clocks::RefTickConfig::Fosc]
601 };
602 ("clock_tree.rtc_slow_clk") => {
603 [#[cfg(use_xtal32k)] crate ::soc::clocks::RtcSlowClkConfig::Xtal32k, crate
604 ::soc::clocks::RtcSlowClkConfig::RcSlow, crate
605 ::soc::clocks::RtcSlowClkConfig::RcFast]
606 };
607 ("clock_tree.ble_lp_clk") => {
608 [crate ::soc::clocks::BleLpClkConfig::Xtal, crate
609 ::soc::clocks::BleLpClkConfig::RtcSlow]
610 };
611 ("clock_tree.rtc_fast_clk") => {
612 [crate ::soc::clocks::RtcFastClkConfig::Xtal, crate
613 ::soc::clocks::RtcFastClkConfig::Rc]
614 };
615 ("clock_tree.timg_calibration_clock") => {
616 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
617 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
618 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
619 };
620 ("clock_tree.i2c.function_clock.sclk") => {
621 [crate ::soc::clocks::I2cFunctionClockSclk::Apb]
622 };
623 ("clock_tree.uart.function_clock.sclk") => {
624 [crate ::soc::clocks::UartFunctionClockSclk::Apb, crate
625 ::soc::clocks::UartFunctionClockSclk::RefTick]
626 };
627 ("clock_tree.uart.baud_rate_generator.fractional") => {
628 (0, 15)
629 };
630 ("clock_tree.uart.baud_rate_generator.integral") => {
631 (0, 1048575)
632 };
633 ("clock_tree.rmt.sclk") => {
634 [crate ::soc::clocks::RmtSclkConfig::RefTick, crate
635 ::soc::clocks::RmtSclkConfig::ApbClk]
636 };
637 ("clock_tree.i2s.mclk.sclk") => {
638 [crate ::soc::clocks::I2sMclkSclk::PllF160m, crate
639 ::soc::clocks::I2sMclkSclk::Apll]
640 };
641 ("clock_tree.i2s.mclk.div_num") => {
642 (1, 255)
643 };
644 ("clock_tree.i2s.mclk.div_a") => {
645 (1, 63)
646 };
647 ("clock_tree.i2s.mclk.div_b") => {
648 (0, 63)
649 };
650}
651#[macro_export]
655#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
656macro_rules! define_lp_io_signals {
657 () => {};
658}
659#[macro_export]
681#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
682macro_rules! for_each_rmt_channel {
683 ($($pattern:tt => $code:tt;)*) => {
684 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
685 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
686 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
687 _for_each_inner_rmt_channel!((4)); _for_each_inner_rmt_channel!((5));
688 _for_each_inner_rmt_channel!((6)); _for_each_inner_rmt_channel!((7));
689 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
690 _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
691 _for_each_inner_rmt_channel!((4, 4)); _for_each_inner_rmt_channel!((5, 5));
692 _for_each_inner_rmt_channel!((6, 6)); _for_each_inner_rmt_channel!((7, 7));
693 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
694 _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
695 _for_each_inner_rmt_channel!((4, 4)); _for_each_inner_rmt_channel!((5, 5));
696 _for_each_inner_rmt_channel!((6, 6)); _for_each_inner_rmt_channel!((7, 7));
697 _for_each_inner_rmt_channel!((all(0), (1), (2), (3), (4), (5), (6), (7)));
698 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5),
699 (6, 6), (7, 7))); _for_each_inner_rmt_channel!((rx(0, 0), (1, 1), (2, 2), (3, 3),
700 (4, 4), (5, 5), (6, 6), (7, 7)));
701 };
702}
703#[macro_export]
728#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
729macro_rules! for_each_sdmmc {
730 ($($pattern:tt => $code:tt;)*) => {
731 macro_rules! _for_each_inner_sdmmc { $(($pattern) => $code;)* ($other : tt) => {}
732 } _for_each_inner_sdmmc!((slot0, 0, true, [], [], [], [], [],
733 [HOST_CARD_DETECT_N_1], [HOST_CARD_WRITE_PRT_1], [HOST_CARD_INT_N_1], [],
734 [HOST_RST_N_1])); _for_each_inner_sdmmc!((slot1, 1, true, [], [], [], [], [],
735 [HOST_CARD_DETECT_N_2], [HOST_CARD_WRITE_PRT_2], [HOST_CARD_INT_N_2], [],
736 [HOST_RST_N_2])); _for_each_inner_sdmmc!((all(slot0, 0, true, [], [], [], [], [],
737 [HOST_CARD_DETECT_N_1], [HOST_CARD_WRITE_PRT_1], [HOST_CARD_INT_N_1], [],
738 [HOST_RST_N_1]), (slot1, 1, true, [], [], [], [], [], [HOST_CARD_DETECT_N_2],
739 [HOST_CARD_WRITE_PRT_2], [HOST_CARD_INT_N_2], [], [HOST_RST_N_2])));
740 };
741}
742#[macro_export]
743#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
744macro_rules! for_each_sdm_channel {
745 ($($pattern:tt => $code:tt;)*) => {
746 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
747 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
748 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
749 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
750 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
751 _for_each_inner_sdm_channel!((4, SDM_CH4, SdmCh4, GPIO_SD4));
752 _for_each_inner_sdm_channel!((5, SDM_CH5, SdmCh5, GPIO_SD5));
753 _for_each_inner_sdm_channel!((6, SDM_CH6, SdmCh6, GPIO_SD6));
754 _for_each_inner_sdm_channel!((7, SDM_CH7, SdmCh7, GPIO_SD7));
755 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
756 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
757 GPIO_SD3), (4, SDM_CH4, SdmCh4, GPIO_SD4), (5, SDM_CH5, SdmCh5, GPIO_SD5), (6,
758 SDM_CH6, SdmCh6, GPIO_SD6), (7, SDM_CH7, SdmCh7, GPIO_SD7)));
759 };
760}
761#[macro_export]
762#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
763macro_rules! for_each_aes_key_length {
764 ($($pattern:tt => $code:tt;)*) => {
765 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
766 tt) => {} } _for_each_inner_aes_key_length!((128));
767 _for_each_inner_aes_key_length!((192)); _for_each_inner_aes_key_length!((256));
768 _for_each_inner_aes_key_length!((128, 0, 4));
769 _for_each_inner_aes_key_length!((192, 1, 5));
770 _for_each_inner_aes_key_length!((256, 2, 6));
771 _for_each_inner_aes_key_length!((bits(128), (192), (256)));
772 _for_each_inner_aes_key_length!((modes(128, 0, 4), (192, 1, 5), (256, 2, 6)));
773 };
774}
775#[macro_export]
776#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
777macro_rules! for_each_rsa_exponentiation {
778 ($($pattern:tt => $code:tt;)*) => {
779 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
780 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((512));
781 _for_each_inner_rsa_exponentiation!((1024));
782 _for_each_inner_rsa_exponentiation!((1536));
783 _for_each_inner_rsa_exponentiation!((2048));
784 _for_each_inner_rsa_exponentiation!((2560));
785 _for_each_inner_rsa_exponentiation!((3072));
786 _for_each_inner_rsa_exponentiation!((3584));
787 _for_each_inner_rsa_exponentiation!((4096));
788 _for_each_inner_rsa_exponentiation!((all(512), (1024), (1536), (2048), (2560),
789 (3072), (3584), (4096)));
790 };
791}
792#[macro_export]
793#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
794macro_rules! for_each_rsa_multiplication {
795 ($($pattern:tt => $code:tt;)*) => {
796 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
797 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((512));
798 _for_each_inner_rsa_multiplication!((1024));
799 _for_each_inner_rsa_multiplication!((1536));
800 _for_each_inner_rsa_multiplication!((2048));
801 _for_each_inner_rsa_multiplication!((all(512), (1024), (1536), (2048)));
802 };
803}
804#[macro_export]
805#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
806macro_rules! for_each_sha_algorithm {
807 ($($pattern:tt => $code:tt;)*) => {
808 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
809 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
810 (insecure_against : "collision", "length extension"), 0));
811 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
812 (insecure_against : "length extension"), 0));
813 _for_each_inner_sha_algorithm!((Sha384, "SHA-384"(sizes : 128, 48, 16)
814 (insecure_against :), 0)); _for_each_inner_sha_algorithm!((Sha512,
815 "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 0));
816 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
817 (insecure_against : "collision", "length extension"), 0), (Sha256,
818 "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"), 0),
819 (Sha384, "SHA-384"(sizes : 128, 48, 16) (insecure_against :), 0), (Sha512,
820 "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 0)));
821 };
822}
823#[macro_export]
824#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
825macro_rules! for_each_wakeup_source {
826 ($($pattern:tt => $code:tt;)*) => {
827 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
828 tt) => {} } _for_each_inner_wakeup_source!((Ext0, 0));
829 _for_each_inner_wakeup_source!((Ext1, 1)); _for_each_inner_wakeup_source!((Gpio,
830 2)); _for_each_inner_wakeup_source!((Timer, 3));
831 _for_each_inner_wakeup_source!((Sdio, 4)); _for_each_inner_wakeup_source!((Wifi,
832 5)); _for_each_inner_wakeup_source!((Uart0, 6));
833 _for_each_inner_wakeup_source!((Uart1, 7));
834 _for_each_inner_wakeup_source!((Touch, 8)); _for_each_inner_wakeup_source!((Ulp,
835 9)); _for_each_inner_wakeup_source!((Bt, 10));
836 _for_each_inner_wakeup_source!((all(Ext0, 0), (Ext1, 1), (Gpio, 2), (Timer, 3),
837 (Sdio, 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Touch, 8), (Ulp, 9), (Bt, 10)));
838 };
839}
840#[macro_export]
841#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
842macro_rules! for_each_dma_engine {
843 ($($pattern:tt => $code:tt;)*) => {
844 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
845 => {} } _for_each_inner_dma_engine!(("SPI_DMA"));
846 _for_each_inner_dma_engine!(("I2S_DMA"));
847 _for_each_inner_dma_engine!((all("SPI_DMA"), ("I2S_DMA")));
848 };
849}
850#[macro_export]
851#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
852macro_rules! for_each_dma_channel {
853 ($($pattern:tt => $code:tt;)*) => {
854 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
855 => {} } _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI2));
856 _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI3));
857 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S0));
858 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S1));
859 _for_each_inner_dma_channel!(("SPI_DMA", any_channel = SpiDmaChannel));
860 _for_each_inner_dma_channel!(("I2S_DMA", any_channel = I2sDmaChannel));
861 _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI2, 0, interrupt = SPI2_DMA,
862 compatible = [SPI2])); _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI3, 1,
863 interrupt = SPI3_DMA, compatible = [SPI3]));
864 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S0, 0, interrupt = I2S0,
865 compatible = [I2S0])); _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S1, 1,
866 interrupt = I2S1, compatible = [I2S1]));
867 _for_each_inner_dma_channel!((names("SPI_DMA", DMA_SPI2), ("SPI_DMA", DMA_SPI3),
868 ("I2S_DMA", DMA_I2S0), ("I2S_DMA", DMA_I2S1)));
869 _for_each_inner_dma_channel!((separate_any_type("SPI_DMA", any_channel =
870 SpiDmaChannel), ("I2S_DMA", any_channel = I2sDmaChannel)));
871 _for_each_inner_dma_channel!((shared("SPI_DMA", DMA_SPI2, 0, interrupt =
872 SPI2_DMA, compatible = [SPI2]), ("SPI_DMA", DMA_SPI3, 1, interrupt = SPI3_DMA,
873 compatible = [SPI3]), ("I2S_DMA", DMA_I2S0, 0, interrupt = I2S0, compatible =
874 [I2S0]), ("I2S_DMA", DMA_I2S1, 1, interrupt = I2S1, compatible = [I2S1])));
875 _for_each_inner_dma_channel!((split));
876 _for_each_inner_dma_channel!((no_own_interrupt));
877 };
878}
879#[macro_export]
880#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
881macro_rules! for_each_dma_channel_peri_pair {
882 ($($pattern:tt => $code:tt;)*) => {
883 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
884 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("SPI_DMA",
885 DMA_SPI2, SPI2)); _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", DMA_SPI3,
886 SPI3)); _for_each_inner_dma_channel_peri_pair!(("I2S_DMA", DMA_I2S0, I2S0));
887 _for_each_inner_dma_channel_peri_pair!(("I2S_DMA", DMA_I2S1, I2S1));
888 _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", any_channel = SpiDmaChannel,
889 SPI2)); _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", any_channel =
890 SpiDmaChannel, SPI3)); _for_each_inner_dma_channel_peri_pair!(("I2S_DMA",
891 any_channel = I2sDmaChannel, I2S0));
892 _for_each_inner_dma_channel_peri_pair!(("I2S_DMA", any_channel = I2sDmaChannel,
893 I2S1)); _for_each_inner_dma_channel_peri_pair!((channels("SPI_DMA", DMA_SPI2,
894 SPI2), ("SPI_DMA", DMA_SPI3, SPI3), ("I2S_DMA", DMA_I2S0, I2S0), ("I2S_DMA",
895 DMA_I2S1, I2S1)));
896 _for_each_inner_dma_channel_peri_pair!((any_channels("SPI_DMA", any_channel =
897 SpiDmaChannel, SPI2), ("SPI_DMA", any_channel = SpiDmaChannel, SPI3), ("I2S_DMA",
898 any_channel = I2sDmaChannel, I2S0), ("I2S_DMA", any_channel = I2sDmaChannel,
899 I2S1)));
900 };
901}
902#[macro_export]
903#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
904macro_rules! with_i2s_dma_engine {
905 ($($pattern:tt => $code:tt;)*) => {
906 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
907 => {} } _with_inner_i2s_dma_engine!(("I2S_DMA", I2sDmaChannel));
908 };
909}
910#[macro_export]
911#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
912macro_rules! with_spi_master_dma_engine {
913 ($($pattern:tt => $code:tt;)*) => {
914 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
915 : tt) => {} } _with_inner_spi_master_dma_engine!(("SPI_DMA", SpiDmaChannel));
916 };
917}
918#[macro_export]
919#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
920macro_rules! with_spi_slave_dma_engine {
921 ($($pattern:tt => $code:tt;)*) => {
922 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
923 : tt) => {} } _with_inner_spi_slave_dma_engine!(("SPI_DMA", SpiDmaChannel));
924 };
925}
926#[macro_export]
927#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
928macro_rules! for_each_sw_interrupt {
929 ($($pattern:tt => $code:tt;)*) => {
930 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
931 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
932 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
933 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
934 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
935 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
936 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
937 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
938 };
939}
940#[macro_export]
941macro_rules! define_clock_tree_types {
1362 () => {
1363 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1364 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1365 pub enum SdmInstance {
1366 GpioSd = 0,
1367 }
1368 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1369 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1370 pub enum I2cInstance {
1371 I2c0 = 0,
1372 I2c1 = 1,
1373 }
1374 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1375 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1376 pub enum I2sInstance {
1377 I2s0 = 0,
1378 I2s1 = 1,
1379 }
1380 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1381 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1382 pub enum McpwmInstance {
1383 Mcpwm0 = 0,
1384 Mcpwm1 = 1,
1385 }
1386 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1387 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1388 pub enum RmtInstance {
1389 Rmt = 0,
1390 }
1391 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1392 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1393 pub enum SpiInstance {
1394 Spi2 = 0,
1395 Spi3 = 1,
1396 }
1397 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1398 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1399 pub enum UartInstance {
1400 Uart0 = 0,
1401 Uart1 = 1,
1402 Uart2 = 2,
1403 }
1404 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1406 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1407 pub enum XtalClkConfig {
1408 _26,
1410 _40,
1412 }
1413 impl XtalClkConfig {
1414 pub fn value(&self) -> u32 {
1415 match self {
1416 XtalClkConfig::_26 => 26000000,
1417 XtalClkConfig::_40 => 40000000,
1418 }
1419 }
1420 }
1421 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1423 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1424 pub enum PllClkConfig {
1425 _320,
1427 _480,
1429 }
1430 impl PllClkConfig {
1431 pub fn value(&self) -> u32 {
1432 match self {
1433 PllClkConfig::_320 => 320000000,
1434 PllClkConfig::_480 => 480000000,
1435 }
1436 }
1437 }
1438 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1440 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1441 pub struct ApllClkConfig(u32);
1442 impl ApllClkConfig {
1443 pub const fn new(frequency: u32) -> Self {
1450 ::core::assert!(
1451 frequency >= 16000000u32 && frequency <= 128000000u32,
1452 "`APLL_CLK` output frequency value must be between 16000000 and 128000000 \
1453 (inclusive)."
1454 );
1455 Self(frequency)
1456 }
1457 }
1458 impl ApllClkConfig {
1459 pub fn value(&self) -> u32 {
1460 self.0
1461 }
1462 }
1463 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1465 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1466 pub enum CpuPllDivInConfig {
1467 Pll,
1469 Apll,
1471 }
1472 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1473 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1474 pub enum CpuPllDivDivisor {
1475 _2 = 2,
1477 _4 = 4,
1479 }
1480 impl CpuPllDivDivisor {
1481 pub const fn new(raw: u32) -> Self {
1483 match raw {
1484 2 => Self::_2,
1485 4 => Self::_4,
1486 _ => ::core::panic!("Invalid CPU_PLL_DIV divisor value"),
1487 }
1488 }
1489 }
1490 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1494 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1495 pub struct CpuPllDivConfig {
1496 divisor: CpuPllDivDivisor,
1497 }
1498 impl CpuPllDivConfig {
1499 pub const fn new(divisor: CpuPllDivDivisor) -> Self {
1501 Self { divisor }
1502 }
1503 pub fn divisor(self) -> u32 {
1504 self.divisor as u32
1505 }
1506 }
1507 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1509 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1510 pub enum SysconPreDivInConfig {
1511 Xtal,
1513 RcFast,
1515 }
1516 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1520 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1521 pub struct SysconPreDivConfig {
1522 divisor: u32,
1523 }
1524 impl SysconPreDivConfig {
1525 pub const fn new(divisor: u32) -> Self {
1532 ::core::assert!(
1533 divisor <= 1023,
1534 "`SYSCON_PRE_DIV` divisor must be between 0 and 1023 (inclusive)."
1535 );
1536 Self { divisor }
1537 }
1538 pub fn divisor(self) -> u32 {
1539 self.divisor as u32
1540 }
1541 }
1542 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1544 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1545 pub enum ApbClkConfig {
1546 Pll80m,
1548 CpuDiv2,
1550 Cpu,
1552 }
1553 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1555 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1556 pub enum RefTickConfig {
1557 Pll,
1559 Apll,
1561 Xtal,
1563 Fosc,
1565 }
1566 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1570 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1571 pub struct RefTickXtalConfig {
1572 divisor: u32,
1573 }
1574 impl RefTickXtalConfig {
1575 pub const fn new(divisor: u32) -> Self {
1582 ::core::assert!(
1583 divisor <= 255,
1584 "`REF_TICK_XTAL` divisor must be between 0 and 255 (inclusive)."
1585 );
1586 Self { divisor }
1587 }
1588 pub fn divisor(self) -> u32 {
1589 self.divisor as u32
1590 }
1591 }
1592 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1596 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1597 pub struct RefTickFoscConfig {
1598 divisor: u32,
1599 }
1600 impl RefTickFoscConfig {
1601 pub const fn new(divisor: u32) -> Self {
1608 ::core::assert!(
1609 divisor <= 255,
1610 "`REF_TICK_FOSC` divisor must be between 0 and 255 (inclusive)."
1611 );
1612 Self { divisor }
1613 }
1614 pub fn divisor(self) -> u32 {
1615 self.divisor as u32
1616 }
1617 }
1618 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1622 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1623 pub struct RefTickApllConfig {
1624 divisor: u32,
1625 }
1626 impl RefTickApllConfig {
1627 pub const fn new(divisor: u32) -> Self {
1634 ::core::assert!(
1635 divisor <= 255,
1636 "`REF_TICK_APLL` divisor must be between 0 and 255 (inclusive)."
1637 );
1638 Self { divisor }
1639 }
1640 pub fn divisor(self) -> u32 {
1641 self.divisor as u32
1642 }
1643 }
1644 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1648 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1649 pub struct RefTickPllConfig {
1650 divisor: u32,
1651 }
1652 impl RefTickPllConfig {
1653 pub const fn new(divisor: u32) -> Self {
1660 ::core::assert!(
1661 divisor <= 255,
1662 "`REF_TICK_PLL` divisor must be between 0 and 255 (inclusive)."
1663 );
1664 Self { divisor }
1665 }
1666 pub fn divisor(self) -> u32 {
1667 self.divisor as u32
1668 }
1669 }
1670 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1672 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1673 pub enum CpuClkConfig {
1674 Xtal,
1676 RcFast,
1678 Apll,
1680 Pll,
1682 }
1683 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1685 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1686 pub enum RtcSlowClkConfig {
1687 #[cfg(use_xtal32k)]
1688 Xtal32k,
1690 RcSlow,
1692 RcFast,
1694 }
1695 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1697 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1698 pub enum BleLpClkConfig {
1699 Xtal,
1701 RtcSlow,
1703 }
1704 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1706 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1707 pub enum RtcFastClkConfig {
1708 Xtal,
1710 Rc,
1712 }
1713 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1715 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1716 pub enum UartMemClkConfig {
1717 #[default]
1718 Xtal,
1720 }
1721 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1723 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1724 pub enum TimgCalibrationClockConfig {
1725 RcSlowClk,
1727 RcFastDivClk,
1729 #[cfg(use_xtal32k)]
1730 Xtal32kClk,
1732 }
1733 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1734 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1735 pub enum I2cFunctionClockSclk {
1736 #[default]
1737 Apb,
1739 }
1740 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1744 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1745 pub struct I2cFunctionClockConfig {
1746 sclk: I2cFunctionClockSclk,
1747 }
1748 impl I2cFunctionClockConfig {
1749 pub const fn new(sclk: I2cFunctionClockSclk) -> Self {
1751 Self { sclk }
1752 }
1753 pub fn sclk(self) -> I2cFunctionClockSclk {
1754 self.sclk
1755 }
1756 }
1757 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1758 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1759 pub enum I2sMclkSclk {
1760 #[default]
1761 PllF160m,
1763 Apll,
1765 }
1766 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1770 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1771 pub struct I2sMclkConfig {
1772 sclk: I2sMclkSclk,
1773 div_num: u32,
1774 div_a: u32,
1775 div_b: u32,
1776 }
1777 impl I2sMclkConfig {
1778 pub const fn new(sclk: I2sMclkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
1791 ::core::assert!(
1792 div_num >= 1 && div_num <= 255,
1793 "`I2S0_MCLK` div_num must be between 1 and 255 (inclusive)."
1794 );
1795 ::core::assert!(
1796 div_a >= 1 && div_a <= 63,
1797 "`I2S0_MCLK` div_a must be between 1 and 63 (inclusive)."
1798 );
1799 ::core::assert!(
1800 div_b <= 63,
1801 "`I2S0_MCLK` div_b must be between 0 and 63 (inclusive)."
1802 );
1803 Self {
1804 sclk,
1805 div_num,
1806 div_a,
1807 div_b,
1808 }
1809 }
1810 pub fn sclk(self) -> I2sMclkSclk {
1811 self.sclk
1812 }
1813 pub fn div_num(self) -> u32 {
1814 self.div_num as u32
1815 }
1816 pub fn div_a(self) -> u32 {
1817 self.div_a as u32
1818 }
1819 pub fn div_b(self) -> u32 {
1820 self.div_b as u32
1821 }
1822 }
1823 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1825 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1826 pub enum McpwmFunctionClockConfig {
1827 #[default]
1828 PllF160m,
1830 }
1831 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1833 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1834 pub enum RmtSclkConfig {
1835 RefTick,
1837 #[default]
1838 ApbClk,
1840 }
1841 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1843 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1844 pub enum SpiFunctionClockConfig {
1845 #[default]
1846 Apb,
1848 }
1849 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1850 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1851 pub enum UartFunctionClockSclk {
1852 #[default]
1853 Apb,
1855 RefTick,
1857 }
1858 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1862 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1863 pub struct UartFunctionClockConfig {
1864 sclk: UartFunctionClockSclk,
1865 }
1866 impl UartFunctionClockConfig {
1867 pub const fn new(sclk: UartFunctionClockSclk) -> Self {
1869 Self { sclk }
1870 }
1871 pub fn sclk(self) -> UartFunctionClockSclk {
1872 self.sclk
1873 }
1874 }
1875 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1880 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1881 pub struct UartBaudRateGeneratorConfig {
1882 fractional: u32,
1883 integral: u32,
1884 }
1885 impl UartBaudRateGeneratorConfig {
1886 pub const fn new(fractional: u32, integral: u32) -> Self {
1896 ::core::assert!(
1897 fractional <= 15,
1898 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1899 );
1900 ::core::assert!(
1901 integral <= 1048575,
1902 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 1048575 \
1903 (inclusive)."
1904 );
1905 Self {
1906 fractional,
1907 integral,
1908 }
1909 }
1910 pub fn fractional(self) -> u32 {
1911 self.fractional as u32
1912 }
1913 pub fn integral(self) -> u32 {
1914 self.integral as u32
1915 }
1916 }
1917 pub struct ClockTree {
1919 xtal_clk: Option<XtalClkConfig>,
1920 pll_clk: Option<PllClkConfig>,
1921 apll_clk: Option<ApllClkConfig>,
1922 cpu_pll_div_in: Option<CpuPllDivInConfig>,
1923 cpu_pll_div: Option<CpuPllDivConfig>,
1924 syscon_pre_div_in: Option<SysconPreDivInConfig>,
1925 syscon_pre_div: Option<SysconPreDivConfig>,
1926 apb_clk: Option<ApbClkConfig>,
1927 ref_tick: Option<RefTickConfig>,
1928 ref_tick_xtal: Option<RefTickXtalConfig>,
1929 ref_tick_fosc: Option<RefTickFoscConfig>,
1930 ref_tick_apll: Option<RefTickApllConfig>,
1931 ref_tick_pll: Option<RefTickPllConfig>,
1932 cpu_clk: Option<CpuClkConfig>,
1933 rtc_slow_clk: Option<RtcSlowClkConfig>,
1934 ble_lp_clk: Option<BleLpClkConfig>,
1935 rtc_fast_clk: Option<RtcFastClkConfig>,
1936 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1937 i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
1938 i2s_mclk: [Option<I2sMclkConfig>; 2],
1939 rmt_sclk: [Option<RmtSclkConfig>; 1],
1940 uart_function_clock: [Option<UartFunctionClockConfig>; 3],
1941 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 3],
1942 pll_clk_refcount: u32,
1943 apll_clk_refcount: u32,
1944 rc_fast_clk_refcount: u32,
1945 pll_f160m_clk_refcount: u32,
1946 pll_d2_clk_refcount: u32,
1947 apb_clk_refcount: u32,
1948 ref_tick_refcount: u32,
1949 #[cfg(use_xtal32k)]
1950 xtal32k_clk_refcount: u32,
1951 rc_slow_clk_refcount: u32,
1952 rc_fast_div_clk_refcount: u32,
1953 ble_lp_clk_refcount: u32,
1954 rtc_fast_clk_refcount: u32,
1955 uart_mem_clk_refcount: u32,
1956 timg_calibration_clock_refcount: u32,
1957 sdm_function_clock_refcount: [u32; 1],
1958 i2c_function_clock_refcount: [u32; 2],
1959 i2s_mclk_refcount: [u32; 2],
1960 mcpwm_function_clock_refcount: [u32; 2],
1961 rmt_sclk_refcount: [u32; 1],
1962 spi_function_clock_refcount: [u32; 2],
1963 uart_function_clock_refcount: [u32; 3],
1964 uart_mem_clock_refcount: [u32; 3],
1965 uart_baud_rate_generator_refcount: [u32; 3],
1966 }
1967 impl ClockTree {
1968 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1970 CLOCK_TREE.with(f)
1971 }
1972 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1974 self.xtal_clk
1975 }
1976 pub fn pll_clk(&self) -> Option<PllClkConfig> {
1978 self.pll_clk
1979 }
1980 pub fn apll_clk(&self) -> Option<ApllClkConfig> {
1982 self.apll_clk
1983 }
1984 pub fn cpu_pll_div_in(&self) -> Option<CpuPllDivInConfig> {
1986 self.cpu_pll_div_in
1987 }
1988 pub fn cpu_pll_div(&self) -> Option<CpuPllDivConfig> {
1990 self.cpu_pll_div
1991 }
1992 pub fn syscon_pre_div_in(&self) -> Option<SysconPreDivInConfig> {
1994 self.syscon_pre_div_in
1995 }
1996 pub fn syscon_pre_div(&self) -> Option<SysconPreDivConfig> {
1998 self.syscon_pre_div
1999 }
2000 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2002 self.apb_clk
2003 }
2004 pub fn ref_tick(&self) -> Option<RefTickConfig> {
2006 self.ref_tick
2007 }
2008 pub fn ref_tick_xtal(&self) -> Option<RefTickXtalConfig> {
2010 self.ref_tick_xtal
2011 }
2012 pub fn ref_tick_fosc(&self) -> Option<RefTickFoscConfig> {
2014 self.ref_tick_fosc
2015 }
2016 pub fn ref_tick_apll(&self) -> Option<RefTickApllConfig> {
2018 self.ref_tick_apll
2019 }
2020 pub fn ref_tick_pll(&self) -> Option<RefTickPllConfig> {
2022 self.ref_tick_pll
2023 }
2024 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2026 self.cpu_clk
2027 }
2028 pub fn rtc_slow_clk(&self) -> Option<RtcSlowClkConfig> {
2030 self.rtc_slow_clk
2031 }
2032 pub fn ble_lp_clk(&self) -> Option<BleLpClkConfig> {
2034 self.ble_lp_clk
2035 }
2036 pub fn rtc_fast_clk(&self) -> Option<RtcFastClkConfig> {
2038 self.rtc_fast_clk
2039 }
2040 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2042 self.timg_calibration_clock
2043 }
2044 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2046 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2047 }
2048 pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2050 self.i2c_function_clock[I2cInstance::I2c1 as usize]
2051 }
2052 pub fn i2s0_mclk(&self) -> Option<I2sMclkConfig> {
2054 self.i2s_mclk[I2sInstance::I2s0 as usize]
2055 }
2056 pub fn i2s1_mclk(&self) -> Option<I2sMclkConfig> {
2058 self.i2s_mclk[I2sInstance::I2s1 as usize]
2059 }
2060 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2062 self.rmt_sclk[RmtInstance::Rmt as usize]
2063 }
2064 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2066 self.uart_function_clock[UartInstance::Uart0 as usize]
2067 }
2068 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2070 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2071 }
2072 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2074 self.uart_function_clock[UartInstance::Uart1 as usize]
2075 }
2076 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2078 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2079 }
2080 pub fn uart2_function_clock(&self) -> Option<UartFunctionClockConfig> {
2082 self.uart_function_clock[UartInstance::Uart2 as usize]
2083 }
2084 pub fn uart2_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2086 self.uart_baud_rate_generator[UartInstance::Uart2 as usize]
2087 }
2088 }
2089 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2090 ::esp_sync::NonReentrantMutex::new(ClockTree {
2091 xtal_clk: None,
2092 pll_clk: None,
2093 apll_clk: None,
2094 cpu_pll_div_in: None,
2095 cpu_pll_div: None,
2096 syscon_pre_div_in: None,
2097 syscon_pre_div: None,
2098 apb_clk: None,
2099 ref_tick: None,
2100 ref_tick_xtal: None,
2101 ref_tick_fosc: None,
2102 ref_tick_apll: None,
2103 ref_tick_pll: None,
2104 cpu_clk: None,
2105 rtc_slow_clk: None,
2106 ble_lp_clk: None,
2107 rtc_fast_clk: None,
2108 timg_calibration_clock: None,
2109 i2c_function_clock: [None; 2],
2110 i2s_mclk: [None; 2],
2111 rmt_sclk: [None; 1],
2112 uart_function_clock: [None; 3],
2113 uart_baud_rate_generator: [None; 3],
2114 pll_clk_refcount: 0,
2115 apll_clk_refcount: 0,
2116 rc_fast_clk_refcount: 0,
2117 pll_f160m_clk_refcount: 0,
2118 pll_d2_clk_refcount: 0,
2119 apb_clk_refcount: 0,
2120 ref_tick_refcount: 0,
2121 #[cfg(use_xtal32k)]
2122 xtal32k_clk_refcount: 0,
2123 rc_slow_clk_refcount: 0,
2124 rc_fast_div_clk_refcount: 0,
2125 ble_lp_clk_refcount: 0,
2126 rtc_fast_clk_refcount: 0,
2127 uart_mem_clk_refcount: 0,
2128 timg_calibration_clock_refcount: 0,
2129 sdm_function_clock_refcount: [0; 1],
2130 i2c_function_clock_refcount: [0; 2],
2131 i2s_mclk_refcount: [0; 2],
2132 mcpwm_function_clock_refcount: [0; 2],
2133 rmt_sclk_refcount: [0; 1],
2134 spi_function_clock_refcount: [0; 2],
2135 uart_function_clock_refcount: [0; 3],
2136 uart_mem_clock_refcount: [0; 3],
2137 uart_baud_rate_generator_refcount: [0; 3],
2138 });
2139 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2140 ::core::sync::atomic::AtomicU32::new(0);
2141 static PLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2142 ::core::sync::atomic::AtomicU32::new(0);
2143 static APLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2144 ::core::sync::atomic::AtomicU32::new(0);
2145 static CPU_PLL_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2146 ::core::sync::atomic::AtomicU32::new(0);
2147 static CPU_PLL_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2148 ::core::sync::atomic::AtomicU32::new(0);
2149 static SYSCON_PRE_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2150 ::core::sync::atomic::AtomicU32::new(0);
2151 static SYSCON_PRE_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2152 ::core::sync::atomic::AtomicU32::new(0);
2153 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2154 ::core::sync::atomic::AtomicU32::new(0);
2155 static RTC_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2156 ::core::sync::atomic::AtomicU32::new(0);
2157 static BLE_LP_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2158 ::core::sync::atomic::AtomicU32::new(0);
2159 static RTC_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2160 ::core::sync::atomic::AtomicU32::new(0);
2161 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2162 ::core::sync::atomic::AtomicU32::new(0);
2163 static I2S_MCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2164 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2165 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2166 ::core::sync::atomic::AtomicU32::new(0);
2167 static REF_TICK_XTAL_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2168 ::core::sync::atomic::AtomicU32::new(0);
2169 static REF_TICK_FOSC_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2170 ::core::sync::atomic::AtomicU32::new(0);
2171 static REF_TICK_APLL_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2172 ::core::sync::atomic::AtomicU32::new(0);
2173 static REF_TICK_PLL_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2174 ::core::sync::atomic::AtomicU32::new(0);
2175 static REF_TICK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2176 ::core::sync::atomic::AtomicU32::new(0);
2177 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2178 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2179 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
2180 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
2181 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
2182 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
2183 #[derive(Debug, enumset::EnumSetType)]
2188 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2189 pub enum ClockSource {
2190 XtalClk,
2192 RcFastClk,
2194 #[cfg(use_xtal32k)]
2195 Xtal32kClk,
2197 RcSlowClk,
2199 }
2200 pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2202 Some(ClockSource::XtalClk)
2203 }
2204 pub fn pll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2206 xtal_clk_root_source(clocks)
2207 }
2208 pub fn apll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2210 pll_clk_root_source(clocks)
2211 }
2212 pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2214 Some(ClockSource::RcFastClk)
2215 }
2216 pub fn pll_f160m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2218 pll_clk_root_source(clocks)
2219 }
2220 pub fn pll_d2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2222 pll_clk_root_source(clocks)
2223 }
2224 pub fn cpu_pll_div_in_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2226 let config = clocks.cpu_pll_div_in?;
2227 match config {
2228 CpuPllDivInConfig::Pll => pll_clk_root_source(clocks),
2229 CpuPllDivInConfig::Apll => apll_clk_root_source(clocks),
2230 }
2231 }
2232 pub fn cpu_pll_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2234 cpu_pll_div_in_root_source(clocks)
2235 }
2236 pub fn syscon_pre_div_in_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2238 let config = clocks.syscon_pre_div_in?;
2239 match config {
2240 SysconPreDivInConfig::Xtal => xtal_clk_root_source(clocks),
2241 SysconPreDivInConfig::RcFast => rc_fast_clk_root_source(clocks),
2242 }
2243 }
2244 pub fn syscon_pre_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2246 syscon_pre_div_in_root_source(clocks)
2247 }
2248 pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2250 let config = clocks.cpu_clk?;
2251 match config {
2252 CpuClkConfig::Xtal => syscon_pre_div_root_source(clocks),
2253 CpuClkConfig::RcFast => syscon_pre_div_root_source(clocks),
2254 CpuClkConfig::Apll => cpu_pll_div_root_source(clocks),
2255 CpuClkConfig::Pll => cpu_pll_div_root_source(clocks),
2256 }
2257 }
2258 pub fn apb_clk_cpu_div2_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2260 cpu_clk_root_source(clocks)
2261 }
2262 pub fn apb_clk_80m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2264 cpu_clk_root_source(clocks)
2265 }
2266 #[cfg(use_xtal32k)]
2267 pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2269 Some(ClockSource::Xtal32kClk)
2270 }
2271 pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2273 Some(ClockSource::RcSlowClk)
2274 }
2275 pub fn rc_fast_div_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2277 rc_fast_clk_root_source(clocks)
2278 }
2279 pub fn xtal_div_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2281 xtal_clk_root_source(clocks)
2282 }
2283 pub fn rtc_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2285 let config = clocks.rtc_slow_clk?;
2286 match config {
2287 #[cfg(use_xtal32k)]
2288 RtcSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2289 RtcSlowClkConfig::RcSlow => rc_slow_clk_root_source(clocks),
2290 RtcSlowClkConfig::RcFast => rc_fast_div_clk_root_source(clocks),
2291 }
2292 }
2293 pub fn ble_lp_xtal_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2295 xtal_clk_root_source(clocks)
2296 }
2297 pub fn ble_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2299 let config = clocks.ble_lp_clk?;
2300 match config {
2301 BleLpClkConfig::Xtal => ble_lp_xtal_clk_root_source(clocks),
2302 BleLpClkConfig::RtcSlow => rtc_slow_clk_root_source(clocks),
2303 }
2304 }
2305 pub fn rtc_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2307 let config = clocks.rtc_fast_clk?;
2308 match config {
2309 RtcFastClkConfig::Xtal => xtal_div_clk_root_source(clocks),
2310 RtcFastClkConfig::Rc => rc_fast_clk_root_source(clocks),
2311 }
2312 }
2313 pub fn uart_mem_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2315 xtal_clk_root_source(clocks)
2316 }
2317 pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2319 let config = clocks.timg_calibration_clock?;
2320 match config {
2321 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_root_source(clocks),
2322 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_root_source(clocks),
2323 #[cfg(use_xtal32k)]
2324 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
2325 }
2326 }
2327 pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2329 let config = clocks.apb_clk?;
2330 match config {
2331 ApbClkConfig::Pll80m => apb_clk_80m_root_source(clocks),
2332 ApbClkConfig::CpuDiv2 => apb_clk_cpu_div2_root_source(clocks),
2333 ApbClkConfig::Cpu => cpu_clk_root_source(clocks),
2334 }
2335 }
2336 pub fn ref_tick_xtal_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2338 apb_clk_root_source(clocks)
2339 }
2340 pub fn ref_tick_fosc_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2342 apb_clk_root_source(clocks)
2343 }
2344 pub fn ref_tick_apll_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2346 apb_clk_root_source(clocks)
2347 }
2348 pub fn ref_tick_pll_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2350 apb_clk_root_source(clocks)
2351 }
2352 pub fn ref_tick_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2354 let config = clocks.ref_tick?;
2355 match config {
2356 RefTickConfig::Pll => ref_tick_pll_root_source(clocks),
2357 RefTickConfig::Apll => ref_tick_apll_root_source(clocks),
2358 RefTickConfig::Xtal => ref_tick_xtal_root_source(clocks),
2359 RefTickConfig::Fosc => ref_tick_fosc_root_source(clocks),
2360 }
2361 }
2362 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2363 let old_config = clocks.xtal_clk.replace(config);
2364 refresh_xtal_clk_downstream(clocks);
2365 configure_xtal_clk_impl(clocks, old_config, config);
2366 }
2367 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2368 clocks.xtal_clk
2369 }
2370 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2371 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2372 pub fn xtal_clk_config_frequency(config: XtalClkConfig) -> u32 {
2373 config.value()
2374 }
2375 pub fn xtal_clk_frequency() -> u32 {
2376 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2377 }
2378 pub fn configure_pll_clk(clocks: &mut ClockTree, config: PllClkConfig) {
2379 if clocks.cpu_pll_div.is_some() {
2380 assert!(
2381 !((config.value() == 480000000)
2382 && (unwrap!(clocks.cpu_pll_div).divisor() == 4))
2383 );
2384 }
2385 let old_config = clocks.pll_clk.replace(config);
2386 refresh_pll_clk_downstream(clocks);
2387 configure_pll_clk_impl(clocks, old_config, config);
2388 }
2389 pub fn pll_clk_config(clocks: &mut ClockTree) -> Option<PllClkConfig> {
2390 clocks.pll_clk
2391 }
2392 pub fn request_pll_clk(clocks: &mut ClockTree) {
2393 trace!("Requesting PLL_CLK");
2394 if increment_reference_count(&mut clocks.pll_clk_refcount) {
2395 trace!("Enabling PLL_CLK");
2396 request_xtal_clk(clocks);
2397 enable_pll_clk_impl(clocks, true);
2398 }
2399 }
2400 pub fn release_pll_clk(clocks: &mut ClockTree) {
2401 trace!("Releasing PLL_CLK");
2402 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2403 trace!("Disabling PLL_CLK");
2404 enable_pll_clk_impl(clocks, false);
2405 release_xtal_clk(clocks);
2406 }
2407 }
2408 pub fn pll_clk_config_frequency(config: PllClkConfig) -> u32 {
2409 config.value()
2410 }
2411 pub fn pll_clk_frequency() -> u32 {
2412 PLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2413 }
2414 pub fn pll_clk_source_frequency() -> u32 {
2415 xtal_clk_frequency()
2416 }
2417 pub fn configure_apll_clk(clocks: &mut ClockTree, config: ApllClkConfig) {
2418 let old_config = clocks.apll_clk.replace(config);
2419 refresh_apll_clk_downstream(clocks);
2420 configure_apll_clk_impl(clocks, old_config, config);
2421 }
2422 pub fn apll_clk_config(clocks: &mut ClockTree) -> Option<ApllClkConfig> {
2423 clocks.apll_clk
2424 }
2425 pub fn request_apll_clk(clocks: &mut ClockTree) {
2426 trace!("Requesting APLL_CLK");
2427 if increment_reference_count(&mut clocks.apll_clk_refcount) {
2428 trace!("Enabling APLL_CLK");
2429 request_pll_clk(clocks);
2430 enable_apll_clk_impl(clocks, true);
2431 }
2432 }
2433 pub fn release_apll_clk(clocks: &mut ClockTree) {
2434 trace!("Releasing APLL_CLK");
2435 if decrement_reference_count(&mut clocks.apll_clk_refcount) {
2436 trace!("Disabling APLL_CLK");
2437 enable_apll_clk_impl(clocks, false);
2438 release_pll_clk(clocks);
2439 }
2440 }
2441 pub fn apll_clk_config_frequency(config: ApllClkConfig) -> u32 {
2442 config.value()
2443 }
2444 pub fn apll_clk_frequency() -> u32 {
2445 APLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2446 }
2447 pub fn apll_clk_source_frequency() -> u32 {
2448 pll_clk_frequency()
2449 }
2450 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2451 trace!("Requesting RC_FAST_CLK");
2452 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2453 trace!("Enabling RC_FAST_CLK");
2454 enable_rc_fast_clk_impl(clocks, true);
2455 }
2456 }
2457 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2458 trace!("Releasing RC_FAST_CLK");
2459 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2460 trace!("Disabling RC_FAST_CLK");
2461 enable_rc_fast_clk_impl(clocks, false);
2462 }
2463 }
2464 static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2465 ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
2466 pub const fn rc_fast_clk_nominal_frequency() -> u32 {
2467 8000000
2468 }
2469 pub fn rc_fast_clk_frequency() -> u32 {
2470 RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2471 }
2472 pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2473 if !(4000000..=12000000).contains(&frequency) {
2474 warn!(
2475 "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
2476 frequency
2477 );
2478 return;
2479 }
2480 debug!(
2481 "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
2482 frequency,
2483 rc_fast_clk_nominal_frequency()
2484 );
2485 RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2486 refresh_rc_fast_clk_downstream(clocks);
2487 }
2488 pub fn request_pll_f160m_clk(clocks: &mut ClockTree) {
2489 trace!("Requesting PLL_F160M_CLK");
2490 if increment_reference_count(&mut clocks.pll_f160m_clk_refcount) {
2491 trace!("Enabling PLL_F160M_CLK");
2492 request_pll_clk(clocks);
2493 enable_pll_f160m_clk_impl(clocks, true);
2494 }
2495 }
2496 pub fn release_pll_f160m_clk(clocks: &mut ClockTree) {
2497 trace!("Releasing PLL_F160M_CLK");
2498 if decrement_reference_count(&mut clocks.pll_f160m_clk_refcount) {
2499 trace!("Disabling PLL_F160M_CLK");
2500 enable_pll_f160m_clk_impl(clocks, false);
2501 release_pll_clk(clocks);
2502 }
2503 }
2504 pub fn pll_f160m_clk_frequency() -> u32 {
2505 160000000
2506 }
2507 pub fn pll_f160m_clk_source_frequency() -> u32 {
2508 pll_clk_frequency()
2509 }
2510 pub fn request_pll_d2_clk(clocks: &mut ClockTree) {
2511 trace!("Requesting PLL_D2_CLK");
2512 if increment_reference_count(&mut clocks.pll_d2_clk_refcount) {
2513 trace!("Enabling PLL_D2_CLK");
2514 request_pll_clk(clocks);
2515 enable_pll_d2_clk_impl(clocks, true);
2516 }
2517 }
2518 pub fn release_pll_d2_clk(clocks: &mut ClockTree) {
2519 trace!("Releasing PLL_D2_CLK");
2520 if decrement_reference_count(&mut clocks.pll_d2_clk_refcount) {
2521 trace!("Disabling PLL_D2_CLK");
2522 enable_pll_d2_clk_impl(clocks, false);
2523 release_pll_clk(clocks);
2524 }
2525 }
2526 pub fn pll_d2_clk_frequency() -> u32 {
2527 (pll_clk_frequency() / 2)
2528 }
2529 pub fn pll_d2_clk_source_frequency() -> u32 {
2530 pll_clk_frequency()
2531 }
2532 pub fn configure_cpu_pll_div_in(clocks: &mut ClockTree, new_selector: CpuPllDivInConfig) {
2533 let old_selector = clocks.cpu_pll_div_in.replace(new_selector);
2534 refresh_cpu_pll_div_in_downstream(clocks);
2535 match new_selector {
2536 CpuPllDivInConfig::Pll => request_pll_clk(clocks),
2537 CpuPllDivInConfig::Apll => request_apll_clk(clocks),
2538 }
2539 configure_cpu_pll_div_in_impl(clocks, old_selector, new_selector);
2540 if let Some(old_selector) = old_selector {
2541 match old_selector {
2542 CpuPllDivInConfig::Pll => release_pll_clk(clocks),
2543 CpuPllDivInConfig::Apll => release_apll_clk(clocks),
2544 }
2545 }
2546 }
2547 pub fn cpu_pll_div_in_config(clocks: &mut ClockTree) -> Option<CpuPllDivInConfig> {
2548 clocks.cpu_pll_div_in
2549 }
2550 pub fn request_cpu_pll_div_in(clocks: &mut ClockTree) {
2551 trace!("Enabling CPU_PLL_DIV_IN");
2552 match unwrap!(clocks.cpu_pll_div_in) {
2553 CpuPllDivInConfig::Pll => request_pll_clk(clocks),
2554 CpuPllDivInConfig::Apll => request_apll_clk(clocks),
2555 }
2556 enable_cpu_pll_div_in_impl(clocks, true);
2557 }
2558 pub fn release_cpu_pll_div_in(clocks: &mut ClockTree) {
2559 trace!("Disabling CPU_PLL_DIV_IN");
2560 enable_cpu_pll_div_in_impl(clocks, false);
2561 match unwrap!(clocks.cpu_pll_div_in) {
2562 CpuPllDivInConfig::Pll => release_pll_clk(clocks),
2563 CpuPllDivInConfig::Apll => release_apll_clk(clocks),
2564 }
2565 }
2566 pub fn cpu_pll_div_in_config_frequency(config: CpuPllDivInConfig) -> u32 {
2567 match config {
2568 CpuPllDivInConfig::Pll => pll_clk_frequency(),
2569 CpuPllDivInConfig::Apll => apll_clk_frequency(),
2570 }
2571 }
2572 pub fn cpu_pll_div_in_frequency() -> u32 {
2573 CPU_PLL_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2574 }
2575 pub fn cpu_pll_div_in_source_frequency(source: CpuPllDivInConfig) -> u32 {
2576 cpu_pll_div_in_config_frequency(source)
2577 }
2578 pub fn configure_cpu_pll_div(clocks: &mut ClockTree, config: CpuPllDivConfig) {
2579 if clocks.pll_clk.is_some() {
2580 assert!(!((pll_clk_frequency() == 480000000) && (config.divisor() == 4)));
2581 }
2582 let old_config = clocks.cpu_pll_div.replace(config);
2583 refresh_cpu_pll_div_downstream(clocks);
2584 configure_cpu_pll_div_impl(clocks, old_config, config);
2585 }
2586 pub fn cpu_pll_div_config(clocks: &mut ClockTree) -> Option<CpuPllDivConfig> {
2587 clocks.cpu_pll_div
2588 }
2589 pub fn request_cpu_pll_div(clocks: &mut ClockTree) {
2590 trace!("Enabling CPU_PLL_DIV");
2591 request_cpu_pll_div_in(clocks);
2592 enable_cpu_pll_div_impl(clocks, true);
2593 }
2594 pub fn release_cpu_pll_div(clocks: &mut ClockTree) {
2595 trace!("Disabling CPU_PLL_DIV");
2596 enable_cpu_pll_div_impl(clocks, false);
2597 release_cpu_pll_div_in(clocks);
2598 }
2599 pub fn cpu_pll_div_config_frequency(config: CpuPllDivConfig) -> u32 {
2600 (cpu_pll_div_in_frequency() / config.divisor())
2601 }
2602 pub fn cpu_pll_div_frequency() -> u32 {
2603 CPU_PLL_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2604 }
2605 pub fn cpu_pll_div_source_frequency() -> u32 {
2606 cpu_pll_div_in_frequency()
2607 }
2608 pub fn configure_syscon_pre_div_in(
2609 clocks: &mut ClockTree,
2610 new_selector: SysconPreDivInConfig,
2611 ) {
2612 let old_selector = clocks.syscon_pre_div_in.replace(new_selector);
2613 refresh_syscon_pre_div_in_downstream(clocks);
2614 match new_selector {
2615 SysconPreDivInConfig::Xtal => request_xtal_clk(clocks),
2616 SysconPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2617 }
2618 configure_syscon_pre_div_in_impl(clocks, old_selector, new_selector);
2619 if let Some(old_selector) = old_selector {
2620 match old_selector {
2621 SysconPreDivInConfig::Xtal => release_xtal_clk(clocks),
2622 SysconPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2623 }
2624 }
2625 }
2626 pub fn syscon_pre_div_in_config(clocks: &mut ClockTree) -> Option<SysconPreDivInConfig> {
2627 clocks.syscon_pre_div_in
2628 }
2629 pub fn request_syscon_pre_div_in(clocks: &mut ClockTree) {
2630 trace!("Enabling SYSCON_PRE_DIV_IN");
2631 match unwrap!(clocks.syscon_pre_div_in) {
2632 SysconPreDivInConfig::Xtal => request_xtal_clk(clocks),
2633 SysconPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2634 }
2635 enable_syscon_pre_div_in_impl(clocks, true);
2636 }
2637 pub fn release_syscon_pre_div_in(clocks: &mut ClockTree) {
2638 trace!("Disabling SYSCON_PRE_DIV_IN");
2639 enable_syscon_pre_div_in_impl(clocks, false);
2640 match unwrap!(clocks.syscon_pre_div_in) {
2641 SysconPreDivInConfig::Xtal => release_xtal_clk(clocks),
2642 SysconPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2643 }
2644 }
2645 pub fn syscon_pre_div_in_config_frequency(config: SysconPreDivInConfig) -> u32 {
2646 match config {
2647 SysconPreDivInConfig::Xtal => xtal_clk_frequency(),
2648 SysconPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2649 }
2650 }
2651 pub fn syscon_pre_div_in_frequency() -> u32 {
2652 SYSCON_PRE_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2653 }
2654 pub fn syscon_pre_div_in_source_frequency(source: SysconPreDivInConfig) -> u32 {
2655 syscon_pre_div_in_config_frequency(source)
2656 }
2657 pub fn configure_syscon_pre_div(clocks: &mut ClockTree, config: SysconPreDivConfig) {
2658 let old_config = clocks.syscon_pre_div.replace(config);
2659 refresh_syscon_pre_div_downstream(clocks);
2660 configure_syscon_pre_div_impl(clocks, old_config, config);
2661 }
2662 pub fn syscon_pre_div_config(clocks: &mut ClockTree) -> Option<SysconPreDivConfig> {
2663 clocks.syscon_pre_div
2664 }
2665 pub fn request_syscon_pre_div(clocks: &mut ClockTree) {
2666 trace!("Enabling SYSCON_PRE_DIV");
2667 request_syscon_pre_div_in(clocks);
2668 enable_syscon_pre_div_impl(clocks, true);
2669 }
2670 pub fn release_syscon_pre_div(clocks: &mut ClockTree) {
2671 trace!("Disabling SYSCON_PRE_DIV");
2672 enable_syscon_pre_div_impl(clocks, false);
2673 release_syscon_pre_div_in(clocks);
2674 }
2675 pub fn syscon_pre_div_config_frequency(config: SysconPreDivConfig) -> u32 {
2676 (syscon_pre_div_in_frequency() / (config.divisor() + 1))
2677 }
2678 pub fn syscon_pre_div_frequency() -> u32 {
2679 SYSCON_PRE_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2680 }
2681 pub fn syscon_pre_div_source_frequency() -> u32 {
2682 syscon_pre_div_in_frequency()
2683 }
2684 pub fn configure_apb_clk(clocks: &mut ClockTree, new_selector: ApbClkConfig) {
2685 let old_selector = clocks.apb_clk.replace(new_selector);
2686 refresh_apb_clk_downstream(clocks);
2687 let active = clocks.apb_clk_refcount > 0;
2688 if active {
2689 match new_selector {
2690 ApbClkConfig::Pll80m => request_apb_clk_80m(clocks),
2691 ApbClkConfig::CpuDiv2 => request_apb_clk_cpu_div2(clocks),
2692 ApbClkConfig::Cpu => request_cpu_clk(clocks),
2693 }
2694 }
2695 configure_apb_clk_impl(clocks, old_selector, new_selector);
2696 if active && let Some(old_selector) = old_selector {
2697 match old_selector {
2698 ApbClkConfig::Pll80m => release_apb_clk_80m(clocks),
2699 ApbClkConfig::CpuDiv2 => release_apb_clk_cpu_div2(clocks),
2700 ApbClkConfig::Cpu => release_cpu_clk(clocks),
2701 }
2702 }
2703 }
2704 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2705 clocks.apb_clk
2706 }
2707 pub fn request_apb_clk(clocks: &mut ClockTree) {
2708 trace!("Requesting APB_CLK");
2709 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2710 trace!("Enabling APB_CLK");
2711 match unwrap!(clocks.apb_clk) {
2712 ApbClkConfig::Pll80m => request_apb_clk_80m(clocks),
2713 ApbClkConfig::CpuDiv2 => request_apb_clk_cpu_div2(clocks),
2714 ApbClkConfig::Cpu => request_cpu_clk(clocks),
2715 }
2716 enable_apb_clk_impl(clocks, true);
2717 }
2718 }
2719 pub fn release_apb_clk(clocks: &mut ClockTree) {
2720 trace!("Releasing APB_CLK");
2721 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2722 trace!("Disabling APB_CLK");
2723 enable_apb_clk_impl(clocks, false);
2724 match unwrap!(clocks.apb_clk) {
2725 ApbClkConfig::Pll80m => release_apb_clk_80m(clocks),
2726 ApbClkConfig::CpuDiv2 => release_apb_clk_cpu_div2(clocks),
2727 ApbClkConfig::Cpu => release_cpu_clk(clocks),
2728 }
2729 }
2730 }
2731 pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
2732 match config {
2733 ApbClkConfig::Pll80m => apb_clk_80m_frequency(),
2734 ApbClkConfig::CpuDiv2 => apb_clk_cpu_div2_frequency(),
2735 ApbClkConfig::Cpu => cpu_clk_frequency(),
2736 }
2737 }
2738 pub fn apb_clk_frequency() -> u32 {
2739 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2740 }
2741 pub fn apb_clk_source_frequency(source: ApbClkConfig) -> u32 {
2742 apb_clk_config_frequency(source)
2743 }
2744 pub fn configure_ref_tick(clocks: &mut ClockTree, new_selector: RefTickConfig) {
2745 let old_selector = clocks.ref_tick.replace(new_selector);
2746 refresh_ref_tick_downstream(clocks);
2747 let active = clocks.ref_tick_refcount > 0;
2748 if active {
2749 match new_selector {
2750 RefTickConfig::Pll => request_ref_tick_pll(clocks),
2751 RefTickConfig::Apll => request_ref_tick_apll(clocks),
2752 RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
2753 RefTickConfig::Fosc => request_ref_tick_fosc(clocks),
2754 }
2755 }
2756 configure_ref_tick_impl(clocks, old_selector, new_selector);
2757 if active && let Some(old_selector) = old_selector {
2758 match old_selector {
2759 RefTickConfig::Pll => release_ref_tick_pll(clocks),
2760 RefTickConfig::Apll => release_ref_tick_apll(clocks),
2761 RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
2762 RefTickConfig::Fosc => release_ref_tick_fosc(clocks),
2763 }
2764 }
2765 }
2766 pub fn ref_tick_config(clocks: &mut ClockTree) -> Option<RefTickConfig> {
2767 clocks.ref_tick
2768 }
2769 pub fn request_ref_tick(clocks: &mut ClockTree) {
2770 trace!("Requesting REF_TICK");
2771 if increment_reference_count(&mut clocks.ref_tick_refcount) {
2772 trace!("Enabling REF_TICK");
2773 match unwrap!(clocks.ref_tick) {
2774 RefTickConfig::Pll => request_ref_tick_pll(clocks),
2775 RefTickConfig::Apll => request_ref_tick_apll(clocks),
2776 RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
2777 RefTickConfig::Fosc => request_ref_tick_fosc(clocks),
2778 }
2779 enable_ref_tick_impl(clocks, true);
2780 }
2781 }
2782 pub fn release_ref_tick(clocks: &mut ClockTree) {
2783 trace!("Releasing REF_TICK");
2784 if decrement_reference_count(&mut clocks.ref_tick_refcount) {
2785 trace!("Disabling REF_TICK");
2786 enable_ref_tick_impl(clocks, false);
2787 match unwrap!(clocks.ref_tick) {
2788 RefTickConfig::Pll => release_ref_tick_pll(clocks),
2789 RefTickConfig::Apll => release_ref_tick_apll(clocks),
2790 RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
2791 RefTickConfig::Fosc => release_ref_tick_fosc(clocks),
2792 }
2793 }
2794 }
2795 pub fn ref_tick_config_frequency(config: RefTickConfig) -> u32 {
2796 match config {
2797 RefTickConfig::Pll => ref_tick_pll_frequency(),
2798 RefTickConfig::Apll => ref_tick_apll_frequency(),
2799 RefTickConfig::Xtal => ref_tick_xtal_frequency(),
2800 RefTickConfig::Fosc => ref_tick_fosc_frequency(),
2801 }
2802 }
2803 pub fn ref_tick_frequency() -> u32 {
2804 REF_TICK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2805 }
2806 pub fn ref_tick_source_frequency(source: RefTickConfig) -> u32 {
2807 ref_tick_config_frequency(source)
2808 }
2809 pub fn configure_ref_tick_xtal(clocks: &mut ClockTree, config: RefTickXtalConfig) {
2810 let old_config = clocks.ref_tick_xtal.replace(config);
2811 refresh_ref_tick_xtal_downstream(clocks);
2812 configure_ref_tick_xtal_impl(clocks, old_config, config);
2813 }
2814 pub fn ref_tick_xtal_config(clocks: &mut ClockTree) -> Option<RefTickXtalConfig> {
2815 clocks.ref_tick_xtal
2816 }
2817 pub fn request_ref_tick_xtal(clocks: &mut ClockTree) {
2818 trace!("Enabling REF_TICK_XTAL");
2819 request_apb_clk(clocks);
2820 enable_ref_tick_xtal_impl(clocks, true);
2821 }
2822 pub fn release_ref_tick_xtal(clocks: &mut ClockTree) {
2823 trace!("Disabling REF_TICK_XTAL");
2824 enable_ref_tick_xtal_impl(clocks, false);
2825 release_apb_clk(clocks);
2826 }
2827 pub fn ref_tick_xtal_config_frequency(config: RefTickXtalConfig) -> u32 {
2828 (apb_clk_frequency() / (config.divisor() + 1))
2829 }
2830 pub fn ref_tick_xtal_frequency() -> u32 {
2831 REF_TICK_XTAL_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2832 }
2833 pub fn ref_tick_xtal_source_frequency() -> u32 {
2834 apb_clk_frequency()
2835 }
2836 pub fn configure_ref_tick_fosc(clocks: &mut ClockTree, config: RefTickFoscConfig) {
2837 let old_config = clocks.ref_tick_fosc.replace(config);
2838 refresh_ref_tick_fosc_downstream(clocks);
2839 configure_ref_tick_fosc_impl(clocks, old_config, config);
2840 }
2841 pub fn ref_tick_fosc_config(clocks: &mut ClockTree) -> Option<RefTickFoscConfig> {
2842 clocks.ref_tick_fosc
2843 }
2844 pub fn request_ref_tick_fosc(clocks: &mut ClockTree) {
2845 trace!("Enabling REF_TICK_FOSC");
2846 request_apb_clk(clocks);
2847 enable_ref_tick_fosc_impl(clocks, true);
2848 }
2849 pub fn release_ref_tick_fosc(clocks: &mut ClockTree) {
2850 trace!("Disabling REF_TICK_FOSC");
2851 enable_ref_tick_fosc_impl(clocks, false);
2852 release_apb_clk(clocks);
2853 }
2854 pub fn ref_tick_fosc_config_frequency(config: RefTickFoscConfig) -> u32 {
2855 (apb_clk_frequency() / (config.divisor() + 1))
2856 }
2857 pub fn ref_tick_fosc_frequency() -> u32 {
2858 REF_TICK_FOSC_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2859 }
2860 pub fn ref_tick_fosc_source_frequency() -> u32 {
2861 apb_clk_frequency()
2862 }
2863 pub fn configure_ref_tick_apll(clocks: &mut ClockTree, config: RefTickApllConfig) {
2864 let old_config = clocks.ref_tick_apll.replace(config);
2865 refresh_ref_tick_apll_downstream(clocks);
2866 configure_ref_tick_apll_impl(clocks, old_config, config);
2867 }
2868 pub fn ref_tick_apll_config(clocks: &mut ClockTree) -> Option<RefTickApllConfig> {
2869 clocks.ref_tick_apll
2870 }
2871 pub fn request_ref_tick_apll(clocks: &mut ClockTree) {
2872 trace!("Enabling REF_TICK_APLL");
2873 request_apb_clk(clocks);
2874 enable_ref_tick_apll_impl(clocks, true);
2875 }
2876 pub fn release_ref_tick_apll(clocks: &mut ClockTree) {
2877 trace!("Disabling REF_TICK_APLL");
2878 enable_ref_tick_apll_impl(clocks, false);
2879 release_apb_clk(clocks);
2880 }
2881 pub fn ref_tick_apll_config_frequency(config: RefTickApllConfig) -> u32 {
2882 (apb_clk_frequency() / (config.divisor() + 1))
2883 }
2884 pub fn ref_tick_apll_frequency() -> u32 {
2885 REF_TICK_APLL_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2886 }
2887 pub fn ref_tick_apll_source_frequency() -> u32 {
2888 apb_clk_frequency()
2889 }
2890 pub fn configure_ref_tick_pll(clocks: &mut ClockTree, config: RefTickPllConfig) {
2891 let old_config = clocks.ref_tick_pll.replace(config);
2892 refresh_ref_tick_pll_downstream(clocks);
2893 configure_ref_tick_pll_impl(clocks, old_config, config);
2894 }
2895 pub fn ref_tick_pll_config(clocks: &mut ClockTree) -> Option<RefTickPllConfig> {
2896 clocks.ref_tick_pll
2897 }
2898 pub fn request_ref_tick_pll(clocks: &mut ClockTree) {
2899 trace!("Enabling REF_TICK_PLL");
2900 request_apb_clk(clocks);
2901 enable_ref_tick_pll_impl(clocks, true);
2902 }
2903 pub fn release_ref_tick_pll(clocks: &mut ClockTree) {
2904 trace!("Disabling REF_TICK_PLL");
2905 enable_ref_tick_pll_impl(clocks, false);
2906 release_apb_clk(clocks);
2907 }
2908 pub fn ref_tick_pll_config_frequency(config: RefTickPllConfig) -> u32 {
2909 (apb_clk_frequency() / (config.divisor() + 1))
2910 }
2911 pub fn ref_tick_pll_frequency() -> u32 {
2912 REF_TICK_PLL_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2913 }
2914 pub fn ref_tick_pll_source_frequency() -> u32 {
2915 apb_clk_frequency()
2916 }
2917 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
2918 let old_selector = clocks.cpu_clk.replace(new_selector);
2919 refresh_cpu_clk_downstream(clocks);
2920 match new_selector {
2921 CpuClkConfig::Xtal => {
2922 configure_apb_clk(clocks, ApbClkConfig::Cpu);
2923 configure_syscon_pre_div_in(clocks, SysconPreDivInConfig::Xtal);
2924 configure_ref_tick(clocks, RefTickConfig::Xtal);
2925 let config_value =
2926 RefTickXtalConfig::new(((apb_clk_frequency() / 1000000) - 1));
2927 configure_ref_tick_xtal(clocks, config_value);
2928 }
2929 CpuClkConfig::RcFast => {
2930 configure_apb_clk(clocks, ApbClkConfig::Cpu);
2931 configure_syscon_pre_div_in(clocks, SysconPreDivInConfig::RcFast);
2932 configure_ref_tick(clocks, RefTickConfig::Fosc);
2933 let config_value =
2934 RefTickFoscConfig::new(((apb_clk_frequency() / 1000000) - 1));
2935 configure_ref_tick_fosc(clocks, config_value);
2936 }
2937 CpuClkConfig::Apll => {
2938 configure_apb_clk(clocks, ApbClkConfig::CpuDiv2);
2939 configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Apll);
2940 configure_ref_tick(clocks, RefTickConfig::Apll);
2941 let config_value =
2942 RefTickApllConfig::new(((apb_clk_frequency() / 1000000) - 1));
2943 configure_ref_tick_apll(clocks, config_value);
2944 }
2945 CpuClkConfig::Pll => {
2946 configure_apb_clk(clocks, ApbClkConfig::Pll80m);
2947 configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Pll);
2948 configure_ref_tick(clocks, RefTickConfig::Pll);
2949 let config_value = RefTickPllConfig::new(((apb_clk_frequency() / 1000000) - 1));
2950 configure_ref_tick_pll(clocks, config_value);
2951 }
2952 }
2953 match new_selector {
2954 CpuClkConfig::Xtal => request_syscon_pre_div(clocks),
2955 CpuClkConfig::RcFast => request_syscon_pre_div(clocks),
2956 CpuClkConfig::Apll => request_cpu_pll_div(clocks),
2957 CpuClkConfig::Pll => request_cpu_pll_div(clocks),
2958 }
2959 configure_cpu_clk_impl(clocks, old_selector, new_selector);
2960 if let Some(old_selector) = old_selector {
2961 match old_selector {
2962 CpuClkConfig::Xtal => release_syscon_pre_div(clocks),
2963 CpuClkConfig::RcFast => release_syscon_pre_div(clocks),
2964 CpuClkConfig::Apll => release_cpu_pll_div(clocks),
2965 CpuClkConfig::Pll => release_cpu_pll_div(clocks),
2966 }
2967 }
2968 }
2969 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2970 clocks.cpu_clk
2971 }
2972 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2973 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2974 pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
2975 match config {
2976 CpuClkConfig::Xtal => syscon_pre_div_frequency(),
2977 CpuClkConfig::RcFast => syscon_pre_div_frequency(),
2978 CpuClkConfig::Apll => cpu_pll_div_frequency(),
2979 CpuClkConfig::Pll => cpu_pll_div_frequency(),
2980 }
2981 }
2982 pub fn cpu_clk_frequency() -> u32 {
2983 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2984 }
2985 pub fn request_apb_clk_cpu_div2(clocks: &mut ClockTree) {
2986 trace!("Enabling APB_CLK_CPU_DIV2");
2987 request_cpu_clk(clocks);
2988 enable_apb_clk_cpu_div2_impl(clocks, true);
2989 }
2990 pub fn release_apb_clk_cpu_div2(clocks: &mut ClockTree) {
2991 trace!("Disabling APB_CLK_CPU_DIV2");
2992 enable_apb_clk_cpu_div2_impl(clocks, false);
2993 release_cpu_clk(clocks);
2994 }
2995 pub fn apb_clk_cpu_div2_frequency() -> u32 {
2996 (cpu_clk_frequency() / 2)
2997 }
2998 pub fn apb_clk_cpu_div2_source_frequency() -> u32 {
2999 cpu_clk_frequency()
3000 }
3001 pub fn request_apb_clk_80m(clocks: &mut ClockTree) {
3002 trace!("Enabling APB_CLK_80M");
3003 request_cpu_clk(clocks);
3004 enable_apb_clk_80m_impl(clocks, true);
3005 }
3006 pub fn release_apb_clk_80m(clocks: &mut ClockTree) {
3007 trace!("Disabling APB_CLK_80M");
3008 enable_apb_clk_80m_impl(clocks, false);
3009 release_cpu_clk(clocks);
3010 }
3011 pub fn apb_clk_80m_frequency() -> u32 {
3012 80000000
3013 }
3014 pub fn apb_clk_80m_source_frequency() -> u32 {
3015 cpu_clk_frequency()
3016 }
3017 #[cfg(use_xtal32k)]
3018 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
3019 trace!("Requesting XTAL32K_CLK");
3020 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
3021 trace!("Enabling XTAL32K_CLK");
3022 enable_xtal32k_clk_impl(clocks, true);
3023 }
3024 }
3025 #[cfg(use_xtal32k)]
3026 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
3027 trace!("Releasing XTAL32K_CLK");
3028 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
3029 trace!("Disabling XTAL32K_CLK");
3030 enable_xtal32k_clk_impl(clocks, false);
3031 }
3032 }
3033 #[cfg(use_xtal32k)]
3034 pub fn xtal32k_clk_frequency() -> u32 {
3035 32768
3036 }
3037 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
3038 trace!("Requesting RC_SLOW_CLK");
3039 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
3040 trace!("Enabling RC_SLOW_CLK");
3041 enable_rc_slow_clk_impl(clocks, true);
3042 }
3043 }
3044 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
3045 trace!("Releasing RC_SLOW_CLK");
3046 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
3047 trace!("Disabling RC_SLOW_CLK");
3048 enable_rc_slow_clk_impl(clocks, false);
3049 }
3050 }
3051 static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
3052 ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
3053 pub const fn rc_slow_clk_nominal_frequency() -> u32 {
3054 150000
3055 }
3056 pub fn rc_slow_clk_frequency() -> u32 {
3057 RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
3058 }
3059 pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
3060 if !(75000..=225000).contains(&frequency) {
3061 warn!(
3062 "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
3063 frequency
3064 );
3065 return;
3066 }
3067 debug!(
3068 "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
3069 frequency,
3070 rc_slow_clk_nominal_frequency()
3071 );
3072 RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
3073 refresh_rc_slow_clk_downstream(clocks);
3074 }
3075 pub fn request_rc_fast_div_clk(clocks: &mut ClockTree) {
3076 trace!("Requesting RC_FAST_DIV_CLK");
3077 if increment_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
3078 trace!("Enabling RC_FAST_DIV_CLK");
3079 request_rc_fast_clk(clocks);
3080 enable_rc_fast_div_clk_impl(clocks, true);
3081 }
3082 }
3083 pub fn release_rc_fast_div_clk(clocks: &mut ClockTree) {
3084 trace!("Releasing RC_FAST_DIV_CLK");
3085 if decrement_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
3086 trace!("Disabling RC_FAST_DIV_CLK");
3087 enable_rc_fast_div_clk_impl(clocks, false);
3088 release_rc_fast_clk(clocks);
3089 }
3090 }
3091 pub fn rc_fast_div_clk_frequency() -> u32 {
3092 (rc_fast_clk_frequency() / 256)
3093 }
3094 pub fn rc_fast_div_clk_source_frequency() -> u32 {
3095 rc_fast_clk_frequency()
3096 }
3097 pub fn request_xtal_div_clk(clocks: &mut ClockTree) {
3098 trace!("Enabling XTAL_DIV_CLK");
3099 request_xtal_clk(clocks);
3100 enable_xtal_div_clk_impl(clocks, true);
3101 }
3102 pub fn release_xtal_div_clk(clocks: &mut ClockTree) {
3103 trace!("Disabling XTAL_DIV_CLK");
3104 enable_xtal_div_clk_impl(clocks, false);
3105 release_xtal_clk(clocks);
3106 }
3107 pub fn xtal_div_clk_frequency() -> u32 {
3108 (xtal_clk_frequency() / 4)
3109 }
3110 pub fn xtal_div_clk_source_frequency() -> u32 {
3111 xtal_clk_frequency()
3112 }
3113 pub fn configure_rtc_slow_clk(clocks: &mut ClockTree, new_selector: RtcSlowClkConfig) {
3114 let old_selector = clocks.rtc_slow_clk.replace(new_selector);
3115 refresh_rtc_slow_clk_downstream(clocks);
3116 match new_selector {
3117 #[cfg(use_xtal32k)]
3118 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3119 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3120 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
3121 }
3122 configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
3123 if let Some(old_selector) = old_selector {
3124 match old_selector {
3125 #[cfg(use_xtal32k)]
3126 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3127 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3128 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
3129 }
3130 }
3131 }
3132 pub fn rtc_slow_clk_config(clocks: &mut ClockTree) -> Option<RtcSlowClkConfig> {
3133 clocks.rtc_slow_clk
3134 }
3135 pub fn request_rtc_slow_clk(clocks: &mut ClockTree) {
3136 trace!("Enabling RTC_SLOW_CLK");
3137 match unwrap!(clocks.rtc_slow_clk) {
3138 #[cfg(use_xtal32k)]
3139 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3140 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3141 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
3142 }
3143 enable_rtc_slow_clk_impl(clocks, true);
3144 }
3145 pub fn release_rtc_slow_clk(clocks: &mut ClockTree) {
3146 trace!("Disabling RTC_SLOW_CLK");
3147 enable_rtc_slow_clk_impl(clocks, false);
3148 match unwrap!(clocks.rtc_slow_clk) {
3149 #[cfg(use_xtal32k)]
3150 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3151 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3152 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
3153 }
3154 }
3155 pub fn rtc_slow_clk_config_frequency(config: RtcSlowClkConfig) -> u32 {
3156 match config {
3157 #[cfg(use_xtal32k)]
3158 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3159 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3160 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
3161 }
3162 }
3163 pub fn rtc_slow_clk_frequency() -> u32 {
3164 RTC_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3165 }
3166 pub fn rtc_slow_clk_source_frequency(source: RtcSlowClkConfig) -> u32 {
3167 rtc_slow_clk_config_frequency(source)
3168 }
3169 pub fn request_ble_lp_xtal_clk(clocks: &mut ClockTree) {
3170 trace!("Enabling BLE_LP_XTAL_CLK");
3171 request_xtal_clk(clocks);
3172 enable_ble_lp_xtal_clk_impl(clocks, true);
3173 }
3174 pub fn release_ble_lp_xtal_clk(clocks: &mut ClockTree) {
3175 trace!("Disabling BLE_LP_XTAL_CLK");
3176 enable_ble_lp_xtal_clk_impl(clocks, false);
3177 release_xtal_clk(clocks);
3178 }
3179 pub fn ble_lp_xtal_clk_frequency() -> u32 {
3180 500000
3181 }
3182 pub fn ble_lp_xtal_clk_source_frequency() -> u32 {
3183 xtal_clk_frequency()
3184 }
3185 pub fn configure_ble_lp_clk(clocks: &mut ClockTree, new_selector: BleLpClkConfig) {
3186 let old_selector = clocks.ble_lp_clk.replace(new_selector);
3187 refresh_ble_lp_clk_downstream(clocks);
3188 let active = clocks.ble_lp_clk_refcount > 0;
3189 if active {
3190 match new_selector {
3191 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
3192 BleLpClkConfig::RtcSlow => request_rtc_slow_clk(clocks),
3193 }
3194 }
3195 configure_ble_lp_clk_impl(clocks, old_selector, new_selector);
3196 if active && let Some(old_selector) = old_selector {
3197 match old_selector {
3198 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
3199 BleLpClkConfig::RtcSlow => release_rtc_slow_clk(clocks),
3200 }
3201 }
3202 }
3203 pub fn ble_lp_clk_config(clocks: &mut ClockTree) -> Option<BleLpClkConfig> {
3204 clocks.ble_lp_clk
3205 }
3206 pub fn request_ble_lp_clk(clocks: &mut ClockTree) {
3207 trace!("Requesting BLE_LP_CLK");
3208 if increment_reference_count(&mut clocks.ble_lp_clk_refcount) {
3209 trace!("Enabling BLE_LP_CLK");
3210 match unwrap!(clocks.ble_lp_clk) {
3211 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
3212 BleLpClkConfig::RtcSlow => request_rtc_slow_clk(clocks),
3213 }
3214 enable_ble_lp_clk_impl(clocks, true);
3215 }
3216 }
3217 pub fn release_ble_lp_clk(clocks: &mut ClockTree) {
3218 trace!("Releasing BLE_LP_CLK");
3219 if decrement_reference_count(&mut clocks.ble_lp_clk_refcount) {
3220 trace!("Disabling BLE_LP_CLK");
3221 enable_ble_lp_clk_impl(clocks, false);
3222 match unwrap!(clocks.ble_lp_clk) {
3223 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
3224 BleLpClkConfig::RtcSlow => release_rtc_slow_clk(clocks),
3225 }
3226 }
3227 }
3228 pub fn ble_lp_clk_config_frequency(config: BleLpClkConfig) -> u32 {
3229 match config {
3230 BleLpClkConfig::Xtal => ble_lp_xtal_clk_frequency(),
3231 BleLpClkConfig::RtcSlow => rtc_slow_clk_frequency(),
3232 }
3233 }
3234 pub fn ble_lp_clk_frequency() -> u32 {
3235 BLE_LP_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3236 }
3237 pub fn ble_lp_clk_source_frequency(source: BleLpClkConfig) -> u32 {
3238 ble_lp_clk_config_frequency(source)
3239 }
3240 pub fn configure_rtc_fast_clk(clocks: &mut ClockTree, new_selector: RtcFastClkConfig) {
3241 let old_selector = clocks.rtc_fast_clk.replace(new_selector);
3242 refresh_rtc_fast_clk_downstream(clocks);
3243 let active = clocks.rtc_fast_clk_refcount > 0;
3244 if active {
3245 match new_selector {
3246 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
3247 RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
3248 }
3249 }
3250 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
3251 if active && let Some(old_selector) = old_selector {
3252 match old_selector {
3253 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
3254 RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
3255 }
3256 }
3257 }
3258 pub fn rtc_fast_clk_config(clocks: &mut ClockTree) -> Option<RtcFastClkConfig> {
3259 clocks.rtc_fast_clk
3260 }
3261 pub fn request_rtc_fast_clk(clocks: &mut ClockTree) {
3262 trace!("Requesting RTC_FAST_CLK");
3263 if increment_reference_count(&mut clocks.rtc_fast_clk_refcount) {
3264 trace!("Enabling RTC_FAST_CLK");
3265 match unwrap!(clocks.rtc_fast_clk) {
3266 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
3267 RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
3268 }
3269 enable_rtc_fast_clk_impl(clocks, true);
3270 }
3271 }
3272 pub fn release_rtc_fast_clk(clocks: &mut ClockTree) {
3273 trace!("Releasing RTC_FAST_CLK");
3274 if decrement_reference_count(&mut clocks.rtc_fast_clk_refcount) {
3275 trace!("Disabling RTC_FAST_CLK");
3276 enable_rtc_fast_clk_impl(clocks, false);
3277 match unwrap!(clocks.rtc_fast_clk) {
3278 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
3279 RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
3280 }
3281 }
3282 }
3283 pub fn rtc_fast_clk_config_frequency(config: RtcFastClkConfig) -> u32 {
3284 match config {
3285 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
3286 RtcFastClkConfig::Rc => rc_fast_clk_frequency(),
3287 }
3288 }
3289 pub fn rtc_fast_clk_frequency() -> u32 {
3290 RTC_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3291 }
3292 pub fn rtc_fast_clk_source_frequency(source: RtcFastClkConfig) -> u32 {
3293 rtc_fast_clk_config_frequency(source)
3294 }
3295 pub fn request_uart_mem_clk(clocks: &mut ClockTree) {
3296 trace!("Requesting UART_MEM_CLK");
3297 if increment_reference_count(&mut clocks.uart_mem_clk_refcount) {
3298 trace!("Enabling UART_MEM_CLK");
3299 request_xtal_clk(clocks);
3300 enable_uart_mem_clk_impl(clocks, true);
3301 }
3302 }
3303 pub fn release_uart_mem_clk(clocks: &mut ClockTree) {
3304 trace!("Releasing UART_MEM_CLK");
3305 if decrement_reference_count(&mut clocks.uart_mem_clk_refcount) {
3306 trace!("Disabling UART_MEM_CLK");
3307 enable_uart_mem_clk_impl(clocks, false);
3308 release_xtal_clk(clocks);
3309 }
3310 }
3311 pub fn uart_mem_clk_frequency() -> u32 {
3312 xtal_clk_frequency()
3313 }
3314 pub fn uart_mem_clk_source_frequency(source: UartMemClkConfig) -> u32 {
3315 match source {
3316 UartMemClkConfig::Xtal => xtal_clk_frequency(),
3317 }
3318 }
3319 pub fn configure_timg_calibration_clock(
3320 clocks: &mut ClockTree,
3321 new_selector: TimgCalibrationClockConfig,
3322 ) {
3323 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3324 refresh_timg_calibration_clock_downstream(clocks);
3325 let active = clocks.timg_calibration_clock_refcount > 0;
3326 if active {
3327 match new_selector {
3328 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3329 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
3330 #[cfg(use_xtal32k)]
3331 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3332 }
3333 }
3334 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3335 if active && let Some(old_selector) = old_selector {
3336 match old_selector {
3337 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3338 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
3339 #[cfg(use_xtal32k)]
3340 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3341 }
3342 }
3343 }
3344 pub fn timg_calibration_clock_config(
3345 clocks: &mut ClockTree,
3346 ) -> Option<TimgCalibrationClockConfig> {
3347 clocks.timg_calibration_clock
3348 }
3349 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3350 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3351 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3352 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3353 crate::rtc_cntl::WakeLock::acquire();
3354 match unwrap!(clocks.timg_calibration_clock) {
3355 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3356 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
3357 #[cfg(use_xtal32k)]
3358 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3359 }
3360 enable_timg_calibration_clock_impl(clocks, true);
3361 }
3362 }
3363 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3364 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3365 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3366 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3367 crate::rtc_cntl::WakeLock::release();
3368 enable_timg_calibration_clock_impl(clocks, false);
3369 match unwrap!(clocks.timg_calibration_clock) {
3370 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3371 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
3372 #[cfg(use_xtal32k)]
3373 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3374 }
3375 }
3376 }
3377 pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
3378 match config {
3379 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3380 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
3381 #[cfg(use_xtal32k)]
3382 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3383 }
3384 }
3385 pub fn timg_calibration_clock_frequency() -> u32 {
3386 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3387 }
3388 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3389 timg_calibration_clock_config_frequency(source)
3390 }
3391 impl SdmInstance {
3392 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3393 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3394 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3395 {
3396 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3397 request_apb_clk(clocks);
3398 self.enable_function_clock_impl(clocks, true);
3399 }
3400 }
3401 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3402 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3403 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3404 {
3405 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3406 self.enable_function_clock_impl(clocks, false);
3407 release_apb_clk(clocks);
3408 }
3409 }
3410 pub fn function_clock_frequency(self) -> u32 {
3411 apb_clk_frequency()
3412 }
3413 pub fn function_clock_source_frequency() -> u32 {
3414 apb_clk_frequency()
3415 }
3416 }
3417 impl I2cInstance {
3418 pub fn configure_function_clock(
3419 self,
3420 clocks: &mut ClockTree,
3421 config: I2cFunctionClockConfig,
3422 ) {
3423 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3424 refresh_i2c_function_clock_downstream(clocks, self);
3425 self.configure_function_clock_impl(clocks, old_config, config);
3426 }
3427 pub fn function_clock_config(
3428 self,
3429 clocks: &mut ClockTree,
3430 ) -> Option<I2cFunctionClockConfig> {
3431 clocks.i2c_function_clock[self as usize]
3432 }
3433 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3434 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3435 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3436 {
3437 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3438 crate::rtc_cntl::WakeLock::acquire();
3439 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3440 I2cFunctionClockSclk::Apb => request_apb_clk(clocks),
3441 }
3442 self.enable_function_clock_impl(clocks, true);
3443 }
3444 }
3445 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3446 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3447 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3448 {
3449 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3450 crate::rtc_cntl::WakeLock::release();
3451 self.enable_function_clock_impl(clocks, false);
3452 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3453 I2cFunctionClockSclk::Apb => release_apb_clk(clocks),
3454 }
3455 }
3456 }
3457 #[allow(unused_variables)]
3458 pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
3459 apb_clk_frequency()
3460 }
3461 pub fn function_clock_frequency(self) -> u32 {
3462 apb_clk_frequency()
3463 }
3464 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3465 match sclk {
3466 I2cFunctionClockSclk::Apb => apb_clk_frequency(),
3467 }
3468 }
3469 }
3470 impl I2sInstance {
3471 pub fn configure_mclk(self, clocks: &mut ClockTree, config: I2sMclkConfig) {
3472 let old_config = clocks.i2s_mclk[self as usize].replace(config);
3473 refresh_i2s_mclk_downstream(clocks, self);
3474 let active = clocks.i2s_mclk_refcount[self as usize] > 0;
3475 if active {
3476 match config.sclk {
3477 I2sMclkSclk::PllF160m => request_pll_f160m_clk(clocks),
3478 I2sMclkSclk::Apll => request_apll_clk(clocks),
3479 }
3480 }
3481 self.configure_mclk_impl(clocks, old_config, config);
3482 if active && let Some(old_config) = old_config {
3483 match old_config.sclk {
3484 I2sMclkSclk::PllF160m => release_pll_f160m_clk(clocks),
3485 I2sMclkSclk::Apll => release_apll_clk(clocks),
3486 }
3487 }
3488 }
3489 pub fn mclk_config(self, clocks: &mut ClockTree) -> Option<I2sMclkConfig> {
3490 clocks.i2s_mclk[self as usize]
3491 }
3492 pub fn request_mclk(self, clocks: &mut ClockTree) {
3493 trace!("Requesting {:?}::MCLK", self);
3494 if increment_reference_count(&mut clocks.i2s_mclk_refcount[self as usize]) {
3495 trace!("Enabling {:?}::MCLK", self);
3496 crate::rtc_cntl::WakeLock::acquire();
3497 match unwrap!(clocks.i2s_mclk[self as usize]).sclk {
3498 I2sMclkSclk::PllF160m => request_pll_f160m_clk(clocks),
3499 I2sMclkSclk::Apll => request_apll_clk(clocks),
3500 }
3501 self.enable_mclk_impl(clocks, true);
3502 }
3503 }
3504 pub fn release_mclk(self, clocks: &mut ClockTree) {
3505 trace!("Releasing {:?}::MCLK", self);
3506 if decrement_reference_count(&mut clocks.i2s_mclk_refcount[self as usize]) {
3507 trace!("Disabling {:?}::MCLK", self);
3508 crate::rtc_cntl::WakeLock::release();
3509 self.enable_mclk_impl(clocks, false);
3510 match unwrap!(clocks.i2s_mclk[self as usize]).sclk {
3511 I2sMclkSclk::PllF160m => release_pll_f160m_clk(clocks),
3512 I2sMclkSclk::Apll => release_apll_clk(clocks),
3513 }
3514 }
3515 }
3516 pub fn mclk_config_frequency(config: I2sMclkConfig) -> u32 {
3517 (((match config.sclk {
3518 I2sMclkSclk::PllF160m => pll_f160m_clk_frequency(),
3519 I2sMclkSclk::Apll => apll_clk_frequency(),
3520 } as u64)
3521 * (config.div_a() as u64))
3522 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3523 as u32
3524 }
3525 pub fn mclk_frequency(self) -> u32 {
3526 I2S_MCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3527 }
3528 pub fn mclk_source_frequency(sclk: I2sMclkSclk) -> u32 {
3529 match sclk {
3530 I2sMclkSclk::PllF160m => pll_f160m_clk_frequency(),
3531 I2sMclkSclk::Apll => apll_clk_frequency(),
3532 }
3533 }
3534 }
3535 impl McpwmInstance {
3536 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3537 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3538 if increment_reference_count(
3539 &mut clocks.mcpwm_function_clock_refcount[self as usize],
3540 ) {
3541 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3542 crate::rtc_cntl::WakeLock::acquire();
3543 request_pll_f160m_clk(clocks);
3544 self.enable_function_clock_impl(clocks, true);
3545 }
3546 }
3547 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3548 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3549 if decrement_reference_count(
3550 &mut clocks.mcpwm_function_clock_refcount[self as usize],
3551 ) {
3552 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3553 crate::rtc_cntl::WakeLock::release();
3554 self.enable_function_clock_impl(clocks, false);
3555 release_pll_f160m_clk(clocks);
3556 }
3557 }
3558 pub fn function_clock_frequency(self) -> u32 {
3559 pll_f160m_clk_frequency()
3560 }
3561 pub fn function_clock_source_frequency(source: McpwmFunctionClockConfig) -> u32 {
3562 match source {
3563 McpwmFunctionClockConfig::PllF160m => pll_f160m_clk_frequency(),
3564 }
3565 }
3566 }
3567 impl RmtInstance {
3568 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3569 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3570 refresh_rmt_sclk_downstream(clocks, self);
3571 let active = clocks.rmt_sclk_refcount[self as usize] > 0;
3572 if active {
3573 match new_selector {
3574 RmtSclkConfig::RefTick => request_ref_tick(clocks),
3575 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3576 }
3577 }
3578 self.configure_sclk_impl(clocks, old_selector, new_selector);
3579 if active && let Some(old_selector) = old_selector {
3580 match old_selector {
3581 RmtSclkConfig::RefTick => release_ref_tick(clocks),
3582 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3583 }
3584 }
3585 }
3586 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3587 clocks.rmt_sclk[self as usize]
3588 }
3589 pub fn request_sclk(self, clocks: &mut ClockTree) {
3590 trace!("Requesting {:?}::SCLK", self);
3591 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3592 trace!("Enabling {:?}::SCLK", self);
3593 crate::rtc_cntl::WakeLock::acquire();
3594 match unwrap!(clocks.rmt_sclk[self as usize]) {
3595 RmtSclkConfig::RefTick => request_ref_tick(clocks),
3596 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3597 }
3598 self.enable_sclk_impl(clocks, true);
3599 }
3600 }
3601 pub fn release_sclk(self, clocks: &mut ClockTree) {
3602 trace!("Releasing {:?}::SCLK", self);
3603 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3604 trace!("Disabling {:?}::SCLK", self);
3605 crate::rtc_cntl::WakeLock::release();
3606 self.enable_sclk_impl(clocks, false);
3607 match unwrap!(clocks.rmt_sclk[self as usize]) {
3608 RmtSclkConfig::RefTick => release_ref_tick(clocks),
3609 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3610 }
3611 }
3612 }
3613 pub fn sclk_config_frequency(config: RmtSclkConfig) -> u32 {
3614 match config {
3615 RmtSclkConfig::RefTick => ref_tick_frequency(),
3616 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3617 }
3618 }
3619 pub fn sclk_frequency(self) -> u32 {
3620 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3621 }
3622 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3623 Self::sclk_config_frequency(source)
3624 }
3625 }
3626 impl SpiInstance {
3627 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3628 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3629 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3630 {
3631 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3632 crate::rtc_cntl::WakeLock::acquire();
3633 request_apb_clk(clocks);
3634 self.enable_function_clock_impl(clocks, true);
3635 }
3636 }
3637 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3638 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3639 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3640 {
3641 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3642 crate::rtc_cntl::WakeLock::release();
3643 self.enable_function_clock_impl(clocks, false);
3644 release_apb_clk(clocks);
3645 }
3646 }
3647 pub fn function_clock_frequency(self) -> u32 {
3648 apb_clk_frequency()
3649 }
3650 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3651 match source {
3652 SpiFunctionClockConfig::Apb => apb_clk_frequency(),
3653 }
3654 }
3655 }
3656 impl UartInstance {
3657 pub fn configure_function_clock(
3658 self,
3659 clocks: &mut ClockTree,
3660 config: UartFunctionClockConfig,
3661 ) {
3662 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3663 refresh_uart_function_clock_downstream(clocks, self);
3664 let active = clocks.uart_function_clock_refcount[self as usize] > 0;
3665 if active {
3666 match config.sclk {
3667 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3668 UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
3669 }
3670 }
3671 self.configure_function_clock_impl(clocks, old_config, config);
3672 if active && let Some(old_config) = old_config {
3673 match old_config.sclk {
3674 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3675 UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
3676 }
3677 }
3678 }
3679 pub fn function_clock_config(
3680 self,
3681 clocks: &mut ClockTree,
3682 ) -> Option<UartFunctionClockConfig> {
3683 clocks.uart_function_clock[self as usize]
3684 }
3685 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3686 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3687 if increment_reference_count(
3688 &mut clocks.uart_function_clock_refcount[self as usize],
3689 ) {
3690 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3691 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3692 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3693 UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
3694 }
3695 self.enable_function_clock_impl(clocks, true);
3696 }
3697 }
3698 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3699 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3700 if decrement_reference_count(
3701 &mut clocks.uart_function_clock_refcount[self as usize],
3702 ) {
3703 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3704 self.enable_function_clock_impl(clocks, false);
3705 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3706 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3707 UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
3708 }
3709 }
3710 }
3711 pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
3712 match config.sclk {
3713 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3714 UartFunctionClockSclk::RefTick => ref_tick_frequency(),
3715 }
3716 }
3717 pub fn function_clock_frequency(self) -> u32 {
3718 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3719 .load(::core::sync::atomic::Ordering::Acquire)
3720 }
3721 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3722 match sclk {
3723 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3724 UartFunctionClockSclk::RefTick => ref_tick_frequency(),
3725 }
3726 }
3727 pub fn request_mem_clock(self, clocks: &mut ClockTree) {
3728 trace!("Requesting {:?}::MEM_CLOCK", self);
3729 if increment_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3730 trace!("Enabling {:?}::MEM_CLOCK", self);
3731 request_uart_mem_clk(clocks);
3732 self.enable_mem_clock_impl(clocks, true);
3733 }
3734 }
3735 pub fn release_mem_clock(self, clocks: &mut ClockTree) {
3736 trace!("Releasing {:?}::MEM_CLOCK", self);
3737 if decrement_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3738 trace!("Disabling {:?}::MEM_CLOCK", self);
3739 self.enable_mem_clock_impl(clocks, false);
3740 release_uart_mem_clk(clocks);
3741 }
3742 }
3743 pub fn mem_clock_frequency(self) -> u32 {
3744 uart_mem_clk_frequency()
3745 }
3746 pub fn mem_clock_source_frequency() -> u32 {
3747 uart_mem_clk_frequency()
3748 }
3749 pub fn configure_baud_rate_generator(
3750 self,
3751 clocks: &mut ClockTree,
3752 config: UartBaudRateGeneratorConfig,
3753 ) {
3754 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3755 refresh_uart_baud_rate_generator_downstream(clocks, self);
3756 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3757 }
3758 pub fn baud_rate_generator_config(
3759 self,
3760 clocks: &mut ClockTree,
3761 ) -> Option<UartBaudRateGeneratorConfig> {
3762 clocks.uart_baud_rate_generator[self as usize]
3763 }
3764 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3765 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3766 if increment_reference_count(
3767 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3768 ) {
3769 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3770 self.request_function_clock(clocks);
3771 self.enable_baud_rate_generator_impl(clocks, true);
3772 }
3773 }
3774 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3775 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3776 if decrement_reference_count(
3777 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3778 ) {
3779 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3780 self.enable_baud_rate_generator_impl(clocks, false);
3781 self.release_function_clock(clocks);
3782 }
3783 }
3784 pub fn baud_rate_generator_config_frequency(
3785 self,
3786 config: UartBaudRateGeneratorConfig,
3787 ) -> u32 {
3788 ((self.function_clock_frequency() * 16)
3789 / ((config.integral() * 16) + config.fractional()))
3790 }
3791 pub fn baud_rate_generator_frequency(self) -> u32 {
3792 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3793 .load(::core::sync::atomic::Ordering::Acquire)
3794 }
3795 }
3796 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3804 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3805 #[instability::unstable]
3806 pub struct ClockConfig {
3807 pub xtal_clk: Option<XtalClkConfig>,
3809 pub pll_clk: Option<PllClkConfig>,
3811 pub apll_clk: Option<ApllClkConfig>,
3813 pub cpu_pll_div: Option<CpuPllDivConfig>,
3815 pub syscon_pre_div: Option<SysconPreDivConfig>,
3817 pub cpu_clk: Option<CpuClkConfig>,
3819 pub rtc_slow_clk: Option<RtcSlowClkConfig>,
3821 pub ble_lp_clk: Option<BleLpClkConfig>,
3823 pub rtc_fast_clk: Option<RtcFastClkConfig>,
3825 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3827 }
3828 impl ClockConfig {
3829 fn apply(&self, clocks: &mut ClockTree) {
3830 if let Some(config) = self.xtal_clk {
3831 configure_xtal_clk(clocks, config);
3832 }
3833 if let Some(config) = self.pll_clk {
3834 configure_pll_clk(clocks, config);
3835 }
3836 if let Some(config) = self.apll_clk {
3837 configure_apll_clk(clocks, config);
3838 }
3839 if let Some(config) = self.cpu_pll_div {
3840 configure_cpu_pll_div(clocks, config);
3841 }
3842 if let Some(config) = self.syscon_pre_div {
3843 configure_syscon_pre_div(clocks, config);
3844 }
3845 if let Some(config) = self.cpu_clk {
3846 configure_cpu_clk(clocks, config);
3847 }
3848 if let Some(config) = self.rtc_slow_clk {
3849 configure_rtc_slow_clk(clocks, config);
3850 }
3851 if let Some(config) = self.ble_lp_clk {
3852 configure_ble_lp_clk(clocks, config);
3853 }
3854 if let Some(config) = self.rtc_fast_clk {
3855 configure_rtc_fast_clk(clocks, config);
3856 }
3857 if let Some(config) = self.timg_calibration_clock {
3858 configure_timg_calibration_clock(clocks, config);
3859 }
3860 }
3861 }
3862 fn increment_reference_count(refcount: &mut u32) -> bool {
3863 let first = *refcount == 0;
3864 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3865 first
3866 }
3867 fn decrement_reference_count(refcount: &mut u32) -> bool {
3868 *refcount = refcount.saturating_sub(1);
3869 let last = *refcount == 0;
3870 last
3871 }
3872 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3873 if let Some(config) = clocks.xtal_clk {
3874 XTAL_CLK_FREQ_CACHE.store(
3875 xtal_clk_config_frequency(config),
3876 ::core::sync::atomic::Ordering::Release,
3877 );
3878 }
3879 refresh_pll_clk_downstream(clocks);
3880 refresh_syscon_pre_div_in_downstream(clocks);
3881 refresh_ble_lp_clk_downstream(clocks);
3882 refresh_rtc_fast_clk_downstream(clocks);
3883 }
3884 fn refresh_pll_clk_downstream(clocks: &mut ClockTree) {
3885 if let Some(config) = clocks.pll_clk {
3886 PLL_CLK_FREQ_CACHE.store(
3887 pll_clk_config_frequency(config),
3888 ::core::sync::atomic::Ordering::Release,
3889 );
3890 }
3891 refresh_apll_clk_downstream(clocks);
3892 refresh_cpu_pll_div_in_downstream(clocks);
3893 for child_instance in [I2sInstance::I2s0, I2sInstance::I2s1] {
3894 refresh_i2s_mclk_downstream(clocks, child_instance);
3895 }
3896 }
3897 fn refresh_apll_clk_downstream(clocks: &mut ClockTree) {
3898 if let Some(config) = clocks.apll_clk {
3899 APLL_CLK_FREQ_CACHE.store(
3900 apll_clk_config_frequency(config),
3901 ::core::sync::atomic::Ordering::Release,
3902 );
3903 }
3904 refresh_cpu_pll_div_in_downstream(clocks);
3905 for child_instance in [I2sInstance::I2s0, I2sInstance::I2s1] {
3906 refresh_i2s_mclk_downstream(clocks, child_instance);
3907 }
3908 }
3909 fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
3910 refresh_syscon_pre_div_in_downstream(clocks);
3911 refresh_rtc_slow_clk_downstream(clocks);
3912 refresh_rtc_fast_clk_downstream(clocks);
3913 refresh_timg_calibration_clock_downstream(clocks);
3914 }
3915 fn refresh_cpu_pll_div_in_downstream(clocks: &mut ClockTree) {
3916 if let Some(config) = clocks.cpu_pll_div_in {
3917 CPU_PLL_DIV_IN_FREQ_CACHE.store(
3918 cpu_pll_div_in_config_frequency(config),
3919 ::core::sync::atomic::Ordering::Release,
3920 );
3921 }
3922 refresh_cpu_pll_div_downstream(clocks);
3923 }
3924 fn refresh_cpu_pll_div_downstream(clocks: &mut ClockTree) {
3925 if let Some(config) = clocks.cpu_pll_div {
3926 CPU_PLL_DIV_FREQ_CACHE.store(
3927 cpu_pll_div_config_frequency(config),
3928 ::core::sync::atomic::Ordering::Release,
3929 );
3930 }
3931 refresh_cpu_clk_downstream(clocks);
3932 }
3933 fn refresh_syscon_pre_div_in_downstream(clocks: &mut ClockTree) {
3934 if let Some(config) = clocks.syscon_pre_div_in {
3935 SYSCON_PRE_DIV_IN_FREQ_CACHE.store(
3936 syscon_pre_div_in_config_frequency(config),
3937 ::core::sync::atomic::Ordering::Release,
3938 );
3939 }
3940 refresh_syscon_pre_div_downstream(clocks);
3941 }
3942 fn refresh_syscon_pre_div_downstream(clocks: &mut ClockTree) {
3943 if let Some(config) = clocks.syscon_pre_div {
3944 SYSCON_PRE_DIV_FREQ_CACHE.store(
3945 syscon_pre_div_config_frequency(config),
3946 ::core::sync::atomic::Ordering::Release,
3947 );
3948 }
3949 refresh_cpu_clk_downstream(clocks);
3950 }
3951 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3952 if let Some(config) = clocks.cpu_clk {
3953 CPU_CLK_FREQ_CACHE.store(
3954 cpu_clk_config_frequency(config),
3955 ::core::sync::atomic::Ordering::Release,
3956 );
3957 }
3958 refresh_apb_clk_downstream(clocks);
3959 }
3960 fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
3961 refresh_rtc_slow_clk_downstream(clocks);
3962 refresh_timg_calibration_clock_downstream(clocks);
3963 }
3964 fn refresh_rtc_slow_clk_downstream(clocks: &mut ClockTree) {
3965 if let Some(config) = clocks.rtc_slow_clk {
3966 RTC_SLOW_CLK_FREQ_CACHE.store(
3967 rtc_slow_clk_config_frequency(config),
3968 ::core::sync::atomic::Ordering::Release,
3969 );
3970 }
3971 refresh_ble_lp_clk_downstream(clocks);
3972 }
3973 fn refresh_ble_lp_clk_downstream(clocks: &mut ClockTree) {
3974 if let Some(config) = clocks.ble_lp_clk {
3975 BLE_LP_CLK_FREQ_CACHE.store(
3976 ble_lp_clk_config_frequency(config),
3977 ::core::sync::atomic::Ordering::Release,
3978 );
3979 }
3980 }
3981 fn refresh_rtc_fast_clk_downstream(clocks: &mut ClockTree) {
3982 if let Some(config) = clocks.rtc_fast_clk {
3983 RTC_FAST_CLK_FREQ_CACHE.store(
3984 rtc_fast_clk_config_frequency(config),
3985 ::core::sync::atomic::Ordering::Release,
3986 );
3987 }
3988 }
3989 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3990 if let Some(config) = clocks.timg_calibration_clock {
3991 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3992 timg_calibration_clock_config_frequency(config),
3993 ::core::sync::atomic::Ordering::Release,
3994 );
3995 }
3996 }
3997 fn refresh_i2s_mclk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3998 if let Some(config) = clocks.i2s_mclk[instance as usize] {
3999 I2S_MCLK_FREQ_CACHE[instance as usize].store(
4000 I2sInstance::mclk_config_frequency(config),
4001 ::core::sync::atomic::Ordering::Release,
4002 );
4003 }
4004 }
4005 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
4006 if let Some(config) = clocks.apb_clk {
4007 APB_CLK_FREQ_CACHE.store(
4008 apb_clk_config_frequency(config),
4009 ::core::sync::atomic::Ordering::Release,
4010 );
4011 }
4012 refresh_ref_tick_xtal_downstream(clocks);
4013 refresh_ref_tick_fosc_downstream(clocks);
4014 refresh_ref_tick_apll_downstream(clocks);
4015 refresh_ref_tick_pll_downstream(clocks);
4016 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
4017 refresh_i2c_function_clock_downstream(clocks, child_instance);
4018 }
4019 for child_instance in [RmtInstance::Rmt] {
4020 refresh_rmt_sclk_downstream(clocks, child_instance);
4021 }
4022 for child_instance in [
4023 UartInstance::Uart0,
4024 UartInstance::Uart1,
4025 UartInstance::Uart2,
4026 ] {
4027 refresh_uart_function_clock_downstream(clocks, child_instance);
4028 }
4029 }
4030 fn refresh_ref_tick_xtal_downstream(clocks: &mut ClockTree) {
4031 if let Some(config) = clocks.ref_tick_xtal {
4032 REF_TICK_XTAL_FREQ_CACHE.store(
4033 ref_tick_xtal_config_frequency(config),
4034 ::core::sync::atomic::Ordering::Release,
4035 );
4036 }
4037 refresh_ref_tick_downstream(clocks);
4038 }
4039 fn refresh_ref_tick_fosc_downstream(clocks: &mut ClockTree) {
4040 if let Some(config) = clocks.ref_tick_fosc {
4041 REF_TICK_FOSC_FREQ_CACHE.store(
4042 ref_tick_fosc_config_frequency(config),
4043 ::core::sync::atomic::Ordering::Release,
4044 );
4045 }
4046 refresh_ref_tick_downstream(clocks);
4047 }
4048 fn refresh_ref_tick_apll_downstream(clocks: &mut ClockTree) {
4049 if let Some(config) = clocks.ref_tick_apll {
4050 REF_TICK_APLL_FREQ_CACHE.store(
4051 ref_tick_apll_config_frequency(config),
4052 ::core::sync::atomic::Ordering::Release,
4053 );
4054 }
4055 refresh_ref_tick_downstream(clocks);
4056 }
4057 fn refresh_ref_tick_pll_downstream(clocks: &mut ClockTree) {
4058 if let Some(config) = clocks.ref_tick_pll {
4059 REF_TICK_PLL_FREQ_CACHE.store(
4060 ref_tick_pll_config_frequency(config),
4061 ::core::sync::atomic::Ordering::Release,
4062 );
4063 }
4064 refresh_ref_tick_downstream(clocks);
4065 }
4066 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {}
4067 fn refresh_ref_tick_downstream(clocks: &mut ClockTree) {
4068 if let Some(config) = clocks.ref_tick {
4069 REF_TICK_FREQ_CACHE.store(
4070 ref_tick_config_frequency(config),
4071 ::core::sync::atomic::Ordering::Release,
4072 );
4073 }
4074 for child_instance in [RmtInstance::Rmt] {
4075 refresh_rmt_sclk_downstream(clocks, child_instance);
4076 }
4077 for child_instance in [
4078 UartInstance::Uart0,
4079 UartInstance::Uart1,
4080 UartInstance::Uart2,
4081 ] {
4082 refresh_uart_function_clock_downstream(clocks, child_instance);
4083 }
4084 }
4085 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
4086 if let Some(config) = clocks.rmt_sclk[instance as usize] {
4087 RMT_SCLK_FREQ_CACHE[instance as usize].store(
4088 RmtInstance::sclk_config_frequency(config),
4089 ::core::sync::atomic::Ordering::Release,
4090 );
4091 }
4092 }
4093 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4094 if let Some(config) = clocks.uart_function_clock[instance as usize] {
4095 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4096 UartInstance::function_clock_config_frequency(config),
4097 ::core::sync::atomic::Ordering::Release,
4098 );
4099 }
4100 refresh_uart_baud_rate_generator_downstream(clocks, instance);
4101 }
4102 fn refresh_uart_baud_rate_generator_downstream(
4103 clocks: &mut ClockTree,
4104 instance: UartInstance,
4105 ) {
4106 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4107 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4108 instance.baud_rate_generator_config_frequency(config),
4109 ::core::sync::atomic::Ordering::Release,
4110 );
4111 }
4112 }
4113 };
4114}
4115#[macro_export]
4119#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4120macro_rules! implement_peripheral_clocks {
4121 () => {
4122 #[doc(hidden)]
4123 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4124 #[repr(u8)]
4125 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4126 pub enum Peripheral {
4127 Aes,
4129 Emac,
4131 GpioSd,
4133 I2cExt0,
4135 I2cExt1,
4137 I2s0,
4139 I2s1,
4141 Ledc,
4143 Mcpwm0,
4145 Mcpwm1,
4147 Pcnt,
4149 Rmt,
4151 Rsa,
4153 SdioHost,
4155 Sha,
4157 Spi2,
4159 Spi3,
4161 SpiDma,
4163 Timg0,
4165 Timg1,
4167 Twai0,
4169 Uart0,
4171 Uart1,
4173 Uart2,
4175 UartMem,
4177 Uhci0,
4179 Uhci1,
4181 }
4182 impl Peripheral {
4183 const KEEP_ENABLED: &[Peripheral] = &[Self::Timg0, Self::Uart0, Self::UartMem];
4184 const COUNT: usize = Self::ALL.len();
4185 const ALL: &[Self] = &[
4186 Self::Aes,
4187 Self::Emac,
4188 Self::GpioSd,
4189 Self::I2cExt0,
4190 Self::I2cExt1,
4191 Self::I2s0,
4192 Self::I2s1,
4193 Self::Ledc,
4194 Self::Mcpwm0,
4195 Self::Mcpwm1,
4196 Self::Pcnt,
4197 Self::Rmt,
4198 Self::Rsa,
4199 Self::SdioHost,
4200 Self::Sha,
4201 Self::Spi2,
4202 Self::Spi3,
4203 Self::SpiDma,
4204 Self::Timg0,
4205 Self::Timg1,
4206 Self::Twai0,
4207 Self::Uart0,
4208 Self::Uart1,
4209 Self::Uart2,
4210 Self::UartMem,
4211 Self::Uhci0,
4212 Self::Uhci1,
4213 ];
4214 }
4215 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4216 match peripheral {
4217 Peripheral::Aes => {
4218 crate::peripherals::SYSTEM::regs()
4219 .peri_clk_en()
4220 .modify(|_, w| w.crypto_aes_clk_en().bit(enable));
4221 }
4222 Peripheral::Emac => {
4223 crate::peripherals::SYSTEM::regs()
4224 .wifi_clk_en()
4225 .modify(|_, w| w.emac_clk_en().bit(enable));
4226 }
4227 Peripheral::GpioSd => {
4228 let _ = enable;
4229 }
4230 Peripheral::I2cExt0 => {
4231 crate::peripherals::SYSTEM::regs()
4232 .perip_clk_en()
4233 .modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
4234 }
4235 Peripheral::I2cExt1 => {
4236 crate::peripherals::SYSTEM::regs()
4237 .perip_clk_en()
4238 .modify(|_, w| w.i2c_ext1_clk_en().bit(enable));
4239 }
4240 Peripheral::I2s0 => {
4241 crate::peripherals::SYSTEM::regs()
4242 .perip_clk_en()
4243 .modify(|_, w| w.i2s0_clk_en().bit(enable));
4244 }
4245 Peripheral::I2s1 => {
4246 crate::peripherals::SYSTEM::regs()
4247 .perip_clk_en()
4248 .modify(|_, w| w.i2s1_clk_en().bit(enable));
4249 }
4250 Peripheral::Ledc => {
4251 crate::peripherals::SYSTEM::regs()
4252 .perip_clk_en()
4253 .modify(|_, w| w.ledc_clk_en().bit(enable));
4254 }
4255 Peripheral::Mcpwm0 => {
4256 crate::peripherals::SYSTEM::regs()
4257 .perip_clk_en()
4258 .modify(|_, w| w.pwm0_clk_en().bit(enable));
4259 }
4260 Peripheral::Mcpwm1 => {
4261 crate::peripherals::SYSTEM::regs()
4262 .perip_clk_en()
4263 .modify(|_, w| w.pwm1_clk_en().bit(enable));
4264 }
4265 Peripheral::Pcnt => {
4266 crate::peripherals::SYSTEM::regs()
4267 .perip_clk_en()
4268 .modify(|_, w| w.pcnt_clk_en().bit(enable));
4269 }
4270 Peripheral::Rmt => {
4271 crate::peripherals::SYSTEM::regs()
4272 .perip_clk_en()
4273 .modify(|_, w| w.rmt_clk_en().bit(enable));
4274 }
4275 Peripheral::Rsa => {
4276 crate::peripherals::SYSTEM::regs()
4277 .peri_clk_en()
4278 .modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
4279 }
4280 Peripheral::SdioHost => {
4281 crate::peripherals::SYSTEM::regs()
4282 .wifi_clk_en()
4283 .modify(|_, w| w.sdio_host_clk_en().bit(enable));
4284 }
4285 Peripheral::Sha => {
4286 crate::peripherals::SYSTEM::regs()
4287 .peri_clk_en()
4288 .modify(|_, w| w.crypto_sha_clk_en().bit(enable));
4289 }
4290 Peripheral::Spi2 => {
4291 crate::peripherals::SYSTEM::regs()
4292 .perip_clk_en()
4293 .modify(|_, w| w.spi2_clk_en().bit(enable));
4294 }
4295 Peripheral::Spi3 => {
4296 crate::peripherals::SYSTEM::regs()
4297 .perip_clk_en()
4298 .modify(|_, w| w.spi3_clk_en().bit(enable));
4299 }
4300 Peripheral::SpiDma => {
4301 crate::peripherals::SYSTEM::regs()
4302 .perip_clk_en()
4303 .modify(|_, w| w.spi_dma_clk_en().bit(enable));
4304 }
4305 Peripheral::Timg0 => {
4306 crate::peripherals::SYSTEM::regs()
4307 .perip_clk_en()
4308 .modify(|_, w| w.timergroup_clk_en().bit(enable));
4309 }
4310 Peripheral::Timg1 => {
4311 crate::peripherals::SYSTEM::regs()
4312 .perip_clk_en()
4313 .modify(|_, w| w.timergroup1_clk_en().bit(enable));
4314 }
4315 Peripheral::Twai0 => {
4316 crate::peripherals::SYSTEM::regs()
4317 .perip_clk_en()
4318 .modify(|_, w| w.twai_clk_en().bit(enable));
4319 }
4320 Peripheral::Uart0 => {
4321 crate::peripherals::SYSTEM::regs()
4322 .perip_clk_en()
4323 .modify(|_, w| w.uart_clk_en().bit(enable));
4324 }
4325 Peripheral::Uart1 => {
4326 crate::peripherals::SYSTEM::regs()
4327 .perip_clk_en()
4328 .modify(|_, w| w.uart1_clk_en().bit(enable));
4329 }
4330 Peripheral::Uart2 => {
4331 crate::peripherals::SYSTEM::regs()
4332 .perip_clk_en()
4333 .modify(|_, w| w.uart2_clk_en().bit(enable));
4334 }
4335 Peripheral::UartMem => {
4336 crate::peripherals::SYSTEM::regs()
4337 .perip_clk_en()
4338 .modify(|_, w| w.uart_mem_clk_en().bit(enable));
4339 }
4340 Peripheral::Uhci0 => {
4341 crate::peripherals::SYSTEM::regs()
4342 .perip_clk_en()
4343 .modify(|_, w| w.uhci0_clk_en().bit(enable));
4344 }
4345 Peripheral::Uhci1 => {
4346 crate::peripherals::SYSTEM::regs()
4347 .perip_clk_en()
4348 .modify(|_, w| w.uhci1_clk_en().bit(enable));
4349 }
4350 }
4351 }
4352 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4353 match peripheral {
4354 Peripheral::Aes => {
4355 crate::peripherals::SYSTEM::regs()
4356 .peri_rst_en()
4357 .modify(|_, w| w.crypto_aes_rst().bit(reset));
4358 }
4359 Peripheral::Emac => {
4360 crate::peripherals::SYSTEM::regs()
4361 .wifi_rst_en()
4362 .modify(|_, w| w.emac_rst().bit(reset));
4363 }
4364 Peripheral::GpioSd => {
4365 let _ = reset;
4366 }
4367 Peripheral::I2cExt0 => {
4368 crate::peripherals::SYSTEM::regs()
4369 .perip_rst_en()
4370 .modify(|_, w| w.i2c_ext0_rst().bit(reset));
4371 }
4372 Peripheral::I2cExt1 => {
4373 crate::peripherals::SYSTEM::regs()
4374 .perip_rst_en()
4375 .modify(|_, w| w.i2c_ext1_rst().bit(reset));
4376 }
4377 Peripheral::I2s0 => {
4378 crate::peripherals::SYSTEM::regs()
4379 .perip_rst_en()
4380 .modify(|_, w| w.i2s0_rst().bit(reset));
4381 }
4382 Peripheral::I2s1 => {
4383 crate::peripherals::SYSTEM::regs()
4384 .perip_rst_en()
4385 .modify(|_, w| w.i2s1_rst().bit(reset));
4386 }
4387 Peripheral::Ledc => {
4388 crate::peripherals::SYSTEM::regs()
4389 .perip_rst_en()
4390 .modify(|_, w| w.ledc_rst().bit(reset));
4391 }
4392 Peripheral::Mcpwm0 => {
4393 crate::peripherals::SYSTEM::regs()
4394 .perip_rst_en()
4395 .modify(|_, w| w.pwm0_rst().bit(reset));
4396 }
4397 Peripheral::Mcpwm1 => {
4398 crate::peripherals::SYSTEM::regs()
4399 .perip_rst_en()
4400 .modify(|_, w| w.pwm1_rst().bit(reset));
4401 }
4402 Peripheral::Pcnt => {
4403 crate::peripherals::SYSTEM::regs()
4404 .perip_rst_en()
4405 .modify(|_, w| w.pcnt_rst().bit(reset));
4406 }
4407 Peripheral::Rmt => {
4408 crate::peripherals::SYSTEM::regs()
4409 .perip_rst_en()
4410 .modify(|_, w| w.rmt_rst().bit(reset));
4411 }
4412 Peripheral::Rsa => {
4413 crate::peripherals::SYSTEM::regs()
4414 .peri_rst_en()
4415 .modify(|_, w| w.crypto_rsa_rst().bit(reset));
4416 }
4417 Peripheral::SdioHost => {
4418 crate::peripherals::SYSTEM::regs()
4419 .wifi_rst_en()
4420 .modify(|_, w| w.sdio_host_rst().bit(reset));
4421 }
4422 Peripheral::Sha => {
4423 crate::peripherals::SYSTEM::regs()
4424 .peri_rst_en()
4425 .modify(|_, w| w.crypto_sha_rst().bit(reset));
4426 }
4427 Peripheral::Spi2 => {
4428 crate::peripherals::SYSTEM::regs()
4429 .perip_rst_en()
4430 .modify(|_, w| w.spi2_rst().bit(reset));
4431 }
4432 Peripheral::Spi3 => {
4433 crate::peripherals::SYSTEM::regs()
4434 .perip_rst_en()
4435 .modify(|_, w| w.spi3_rst().bit(reset));
4436 }
4437 Peripheral::SpiDma => {
4438 crate::peripherals::SYSTEM::regs()
4439 .perip_rst_en()
4440 .modify(|_, w| w.spi_dma_rst().bit(reset));
4441 }
4442 Peripheral::Timg0 => {
4443 crate::peripherals::SYSTEM::regs()
4444 .perip_rst_en()
4445 .modify(|_, w| w.timergroup_rst().bit(reset));
4446 }
4447 Peripheral::Timg1 => {
4448 crate::peripherals::SYSTEM::regs()
4449 .perip_rst_en()
4450 .modify(|_, w| w.timergroup1_rst().bit(reset));
4451 }
4452 Peripheral::Twai0 => {
4453 crate::peripherals::SYSTEM::regs()
4454 .perip_rst_en()
4455 .modify(|_, w| w.twai_rst().bit(reset));
4456 }
4457 Peripheral::Uart0 => {
4458 crate::peripherals::SYSTEM::regs()
4459 .perip_rst_en()
4460 .modify(|_, w| w.uart_rst().bit(reset));
4461 }
4462 Peripheral::Uart1 => {
4463 crate::peripherals::SYSTEM::regs()
4464 .perip_rst_en()
4465 .modify(|_, w| w.uart1_rst().bit(reset));
4466 }
4467 Peripheral::Uart2 => {
4468 crate::peripherals::SYSTEM::regs()
4469 .perip_rst_en()
4470 .modify(|_, w| w.uart2_rst().bit(reset));
4471 }
4472 Peripheral::UartMem => {
4473 crate::peripherals::SYSTEM::regs()
4474 .perip_rst_en()
4475 .modify(|_, w| w.uart_mem_rst().bit(reset));
4476 }
4477 Peripheral::Uhci0 => {
4478 crate::peripherals::SYSTEM::regs()
4479 .perip_rst_en()
4480 .modify(|_, w| w.uhci0_rst().bit(reset));
4481 }
4482 Peripheral::Uhci1 => {
4483 crate::peripherals::SYSTEM::regs()
4484 .perip_rst_en()
4485 .modify(|_, w| w.uhci1_rst().bit(reset));
4486 }
4487 }
4488 }
4489 };
4490}
4491#[macro_export]
4499#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4500macro_rules! memory_range {
4501 ("DRAM") => {
4502 0x3FFAE000..0x40000000
4503 };
4504 (size as str, "DRAM") => {
4505 "335872"
4506 };
4507 ("DRAM2_UNINIT") => {
4508 0x3FFE7E30..0x40000000
4509 };
4510 (size as str, "DRAM2_UNINIT") => {
4511 "98768"
4512 };
4513 ("IROM") => {
4514 0x400D0000..0x40400000
4515 };
4516 (size as str, "IROM") => {
4517 "3342336"
4518 };
4519 ("DROM") => {
4520 0x3F400000..0x3F800000
4521 };
4522 (size as str, "DROM") => {
4523 "4194304"
4524 };
4525}
4526#[macro_export]
4543#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4544macro_rules! for_each_i2c_master {
4545 ($($pattern:tt => $code:tt;)*) => {
4546 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4547 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4548 I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
4549 I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4550 I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
4551 };
4552}
4553#[macro_export]
4580#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4581macro_rules! for_each_i2s {
4582 ($($pattern:tt => $code:tt;)*) => {
4583 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4584 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S1));
4585 _for_each_inner_i2s!((I2S0, I2s0, __NO_MCLK, I2S0O_BCK, I2S0O_WS, I2S0I_BCK,
4586 I2S0I_WS, [I2S0O_DATA_23], [I2S0I_DATA_15], true, true, true, true));
4587 _for_each_inner_i2s!((I2S1, I2s1, __NO_MCLK, I2S1O_BCK, I2S1O_WS, I2S1I_BCK,
4588 I2S1I_WS, [I2S1O_DATA_23], [I2S1I_DATA_15], true, false, false, false));
4589 _for_each_inner_i2s!((names(I2S0), (I2S1))); _for_each_inner_i2s!((all(I2S0,
4590 I2s0, __NO_MCLK, I2S0O_BCK, I2S0O_WS, I2S0I_BCK, I2S0I_WS, [I2S0O_DATA_23],
4591 [I2S0I_DATA_15], true, true, true, true), (I2S1, I2s1, __NO_MCLK, I2S1O_BCK,
4592 I2S1O_WS, I2S1I_BCK, I2S1I_WS, [I2S1O_DATA_23], [I2S1I_DATA_15], true, false,
4593 false, false)));
4594 };
4595}
4596#[macro_export]
4615#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4616macro_rules! for_each_uart {
4617 ($($pattern:tt => $code:tt;)*) => {
4618 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4619 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4620 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4621 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((2, UART2, Uart2,
4622 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = false));
4623 _for_each_inner_uart!((all(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4624 wakeup_source = true), (1, UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS,
4625 wakeup_source = true), (2, UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS,
4626 wakeup_source = false)));
4627 };
4628}
4629#[macro_export]
4651#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4652macro_rules! for_each_spi_master {
4653 ($($pattern:tt => $code:tt;)*) => {
4654 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4655 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI3));
4656 _for_each_inner_spi_master!((SPI2, Spi2, HSPICLK[HSPICS0, HSPICS1, HSPICS2]
4657 [HSPID, HSPIQ, HSPIWP, HSPIHD], true)); _for_each_inner_spi_master!((SPI3, Spi3,
4658 VSPICLK[VSPICS0, VSPICS1, VSPICS2] [VSPID, VSPIQ, VSPIWP, VSPIHD], true));
4659 _for_each_inner_spi_master!((names(SPI2), (SPI3)));
4660 _for_each_inner_spi_master!((all(SPI2, Spi2, HSPICLK[HSPICS0, HSPICS1, HSPICS2]
4661 [HSPID, HSPIQ, HSPIWP, HSPIHD], true), (SPI3, Spi3, VSPICLK[VSPICS0, VSPICS1,
4662 VSPICS2] [VSPID, VSPIQ, VSPIWP, VSPIHD], true)));
4663 };
4664}
4665#[macro_export]
4682#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4683macro_rules! for_each_spi_slave {
4684 ($($pattern:tt => $code:tt;)*) => {
4685 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4686 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI3));
4687 _for_each_inner_spi_slave!((SPI2, Spi2, HSPICLK, HSPID, HSPIQ, HSPICS0));
4688 _for_each_inner_spi_slave!((SPI3, Spi3, VSPICLK, VSPID, VSPIQ, VSPICS0));
4689 _for_each_inner_spi_slave!((names(SPI2), (SPI3)));
4690 _for_each_inner_spi_slave!((all(SPI2, Spi2, HSPICLK, HSPID, HSPIQ, HSPICS0),
4691 (SPI3, Spi3, VSPICLK, VSPID, VSPIQ, VSPICS0)));
4692 };
4693}
4694#[macro_export]
4717#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4718macro_rules! for_each_pcnt_unit {
4719 ($($pattern:tt => $code:tt;)*) => {
4720 macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
4721 => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
4722 _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
4723 _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
4724 _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
4725 _for_each_inner_pcnt_unit!((PCNT0_UNIT4));
4726 _for_each_inner_pcnt_unit!((PCNT0_UNIT5));
4727 _for_each_inner_pcnt_unit!((PCNT0_UNIT6));
4728 _for_each_inner_pcnt_unit!((PCNT0_UNIT7));
4729 _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
4730 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
4731 _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
4732 PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
4733 _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
4734 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
4735 _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
4736 PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
4737 _for_each_inner_pcnt_unit!((PCNT0_UNIT4, Pcnt0Unit4, Pcnt, PCNT, 4, PCNT,
4738 PCNT4_SIG_CH0, PCNT4_SIG_CH1, PCNT4_CTRL_CH0, PCNT4_CTRL_CH1));
4739 _for_each_inner_pcnt_unit!((PCNT0_UNIT5, Pcnt0Unit5, Pcnt, PCNT, 5, PCNT,
4740 PCNT5_SIG_CH0, PCNT5_SIG_CH1, PCNT5_CTRL_CH0, PCNT5_CTRL_CH1));
4741 _for_each_inner_pcnt_unit!((PCNT0_UNIT6, Pcnt0Unit6, Pcnt, PCNT, 6, PCNT,
4742 PCNT6_SIG_CH0, PCNT6_SIG_CH1, PCNT6_CTRL_CH0, PCNT6_CTRL_CH1));
4743 _for_each_inner_pcnt_unit!((PCNT0_UNIT7, Pcnt0Unit7, Pcnt, PCNT, 7, PCNT,
4744 PCNT7_SIG_CH0, PCNT7_SIG_CH1, PCNT7_CTRL_CH0, PCNT7_CTRL_CH1));
4745 _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
4746 _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
4747 (PCNT0_UNIT3), (PCNT0_UNIT4), (PCNT0_UNIT5), (PCNT0_UNIT6), (PCNT0_UNIT7)));
4748 _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
4749 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1), (PCNT0_UNIT1,
4750 Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0,
4751 PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT, PCNT2_SIG_CH0,
4752 PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3, Pcnt0Unit3, Pcnt,
4753 PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1),
4754 (PCNT0_UNIT4, Pcnt0Unit4, Pcnt, PCNT, 4, PCNT, PCNT4_SIG_CH0, PCNT4_SIG_CH1,
4755 PCNT4_CTRL_CH0, PCNT4_CTRL_CH1), (PCNT0_UNIT5, Pcnt0Unit5, Pcnt, PCNT, 5, PCNT,
4756 PCNT5_SIG_CH0, PCNT5_SIG_CH1, PCNT5_CTRL_CH0, PCNT5_CTRL_CH1), (PCNT0_UNIT6,
4757 Pcnt0Unit6, Pcnt, PCNT, 6, PCNT, PCNT6_SIG_CH0, PCNT6_SIG_CH1, PCNT6_CTRL_CH0,
4758 PCNT6_CTRL_CH1), (PCNT0_UNIT7, Pcnt0Unit7, Pcnt, PCNT, 7, PCNT, PCNT7_SIG_CH0,
4759 PCNT7_SIG_CH1, PCNT7_CTRL_CH0, PCNT7_CTRL_CH1)));
4760 _for_each_inner_pcnt_unit!((interrupt(PCNT)));
4761 _for_each_inner_pcnt_unit!((regs(PCNT)));
4762 };
4763}
4764#[macro_export]
4765#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4766macro_rules! for_each_peripheral {
4767 ($($pattern:tt => $code:tt;)*) => {
4768 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4769 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4770 "GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4771 "<section class=\"warning\">"] #[doc =
4772 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4773 #[doc = "<ul>"] #[doc =
4774 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4775 = "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()));
4776 _for_each_inner_peripheral!((@ peri_type #[doc =
4777 "GPIO1 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4778 "<section class=\"warning\">"] #[doc =
4779 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4780 #[doc = "<ul>"] #[doc =
4781 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4782 = "</ul>"] #[doc = "</section>"] GPIO1 <= virtual()));
4783 _for_each_inner_peripheral!((@ peri_type #[doc =
4784 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4785 "<section class=\"warning\">"] #[doc =
4786 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4787 #[doc = "<ul>"] #[doc =
4788 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4789 = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
4790 _for_each_inner_peripheral!((@ peri_type #[doc =
4791 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4792 "<section class=\"warning\">"] #[doc =
4793 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4794 #[doc = "<ul>"] #[doc =
4795 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4796 = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
4797 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO4 peripheral singleton"]
4798 GPIO4 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4799 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4800 "<section class=\"warning\">"] #[doc =
4801 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4802 #[doc = "<ul>"] #[doc =
4803 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4804 = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4805 _for_each_inner_peripheral!((@ peri_type #[doc =
4806 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4807 "<section class=\"warning\">"] #[doc =
4808 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4809 #[doc = "<ul>"] #[doc =
4810 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4811 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4812 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4813 _for_each_inner_peripheral!((@ peri_type #[doc =
4814 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4815 "<section class=\"warning\">"] #[doc =
4816 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4817 #[doc = "<ul>"] #[doc =
4818 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4819 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4820 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4821 _for_each_inner_peripheral!((@ peri_type #[doc =
4822 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4823 "<section class=\"warning\">"] #[doc =
4824 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4825 #[doc = "<ul>"] #[doc =
4826 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4827 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4828 "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4829 _for_each_inner_peripheral!((@ peri_type #[doc =
4830 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4831 "<section class=\"warning\">"] #[doc =
4832 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4833 #[doc = "<ul>"] #[doc =
4834 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4835 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4836 "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4837 _for_each_inner_peripheral!((@ peri_type #[doc =
4838 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4839 "<section class=\"warning\">"] #[doc =
4840 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4841 #[doc = "<ul>"] #[doc =
4842 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4843 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4844 "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
4845 _for_each_inner_peripheral!((@ peri_type #[doc =
4846 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4847 "<section class=\"warning\">"] #[doc =
4848 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4849 #[doc = "<ul>"] #[doc =
4850 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4851 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4852 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4853 _for_each_inner_peripheral!((@ peri_type #[doc =
4854 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4855 "<section class=\"warning\">"] #[doc =
4856 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4857 #[doc = "<ul>"] #[doc =
4858 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4859 =
4860 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4861 #[doc = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
4862 _for_each_inner_peripheral!((@ peri_type #[doc =
4863 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4864 "<section class=\"warning\">"] #[doc =
4865 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4866 #[doc = "<ul>"] #[doc =
4867 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4868 #[doc = "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()));
4869 _for_each_inner_peripheral!((@ peri_type #[doc =
4870 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4871 "<section class=\"warning\">"] #[doc =
4872 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4873 #[doc = "<ul>"] #[doc =
4874 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4875 #[doc = "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
4876 _for_each_inner_peripheral!((@ peri_type #[doc =
4877 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4878 "<section class=\"warning\">"] #[doc =
4879 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4880 #[doc = "<ul>"] #[doc =
4881 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4882 =
4883 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4884 #[doc = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
4885 _for_each_inner_peripheral!((@ peri_type #[doc =
4886 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4887 "<section class=\"warning\">"] #[doc =
4888 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4889 #[doc = "<ul>"] #[doc =
4890 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4891 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4892 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
4893 _for_each_inner_peripheral!((@ peri_type #[doc =
4894 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4895 "<section class=\"warning\">"] #[doc =
4896 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4897 #[doc = "<ul>"] #[doc =
4898 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4899 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
4900 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO18 peripheral singleton"]
4901 GPIO18 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4902 "GPIO19 peripheral singleton"] GPIO19 <= virtual()));
4903 _for_each_inner_peripheral!((@ peri_type #[doc =
4904 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4905 "<section class=\"warning\">"] #[doc =
4906 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4907 #[doc = "<ul>"] #[doc = "<li>This pin is only available on ESP32-PICO-V3.</li>"]
4908 #[doc = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
4909 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO21 peripheral singleton"]
4910 GPIO21 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4911 "GPIO22 peripheral singleton"] GPIO22 <= virtual()));
4912 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO23 peripheral singleton"]
4913 GPIO23 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4914 "GPIO25 peripheral singleton"] GPIO25 <= virtual()));
4915 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
4916 GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4917 "GPIO27 peripheral singleton"] GPIO27 <= virtual()));
4918 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO32 peripheral singleton"]
4919 GPIO32 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4920 "GPIO33 peripheral singleton"] GPIO33 <= virtual()));
4921 _for_each_inner_peripheral!((@ peri_type #[doc =
4922 "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4923 "<section class=\"warning\">"] #[doc =
4924 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4925 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
4926 = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()));
4927 _for_each_inner_peripheral!((@ peri_type #[doc =
4928 "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4929 "<section class=\"warning\">"] #[doc =
4930 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4931 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
4932 = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()));
4933 _for_each_inner_peripheral!((@ peri_type #[doc =
4934 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4935 "<section class=\"warning\">"] #[doc =
4936 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4937 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
4938 = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()));
4939 _for_each_inner_peripheral!((@ peri_type #[doc =
4940 "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4941 "<section class=\"warning\">"] #[doc =
4942 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4943 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
4944 = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()));
4945 _for_each_inner_peripheral!((@ peri_type #[doc =
4946 "GPIO38 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4947 "<section class=\"warning\">"] #[doc =
4948 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4949 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
4950 = "</ul>"] #[doc = "</section>"] GPIO38 <= virtual()));
4951 _for_each_inner_peripheral!((@ peri_type #[doc =
4952 "GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4953 "<section class=\"warning\">"] #[doc =
4954 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4955 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
4956 = "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()));
4957 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_SPI2 peripheral singleton"]
4958 DMA_SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt,
4959 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4960 #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3(SPI3_DMA : {
4961 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4962 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_I2S0 peripheral singleton"]
4963 DMA_I2S0 <= I2S0(I2S0 : { bind_dma_interrupt, enable_dma_interrupt,
4964 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4965 #[doc = "DMA_I2S1 peripheral singleton"] DMA_I2S1 <= I2S1(I2S1 : {
4966 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4967 _for_each_inner_peripheral!((@ peri_type #[doc =
4968 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)));
4969 _for_each_inner_peripheral!((@ peri_type #[doc =
4970 "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
4971 _for_each_inner_peripheral!((@ peri_type #[doc =
4972 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
4973 _for_each_inner_peripheral!((@ peri_type #[doc =
4974 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
4975 _for_each_inner_peripheral!((@ peri_type #[doc =
4976 "PCNT0_UNIT4 peripheral singleton"] PCNT0_UNIT4 <= virtual() (unstable)));
4977 _for_each_inner_peripheral!((@ peri_type #[doc =
4978 "PCNT0_UNIT5 peripheral singleton"] PCNT0_UNIT5 <= virtual() (unstable)));
4979 _for_each_inner_peripheral!((@ peri_type #[doc =
4980 "PCNT0_UNIT6 peripheral singleton"] PCNT0_UNIT6 <= virtual() (unstable)));
4981 _for_each_inner_peripheral!((@ peri_type #[doc =
4982 "PCNT0_UNIT7 peripheral singleton"] PCNT0_UNIT7 <= virtual() (unstable)));
4983 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
4984 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4985 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
4986 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
4987 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4988 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
4989 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH4 peripheral singleton"]
4990 SDM_CH4 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4991 = "SDM_CH5 peripheral singleton"] SDM_CH5 <= virtual() (unstable)));
4992 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH6 peripheral singleton"]
4993 SDM_CH6 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4994 = "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)));
4995 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
4996 <= AES() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4997 "APB_CTRL peripheral singleton"] APB_CTRL <= APB_CTRL() (unstable)));
4998 _for_each_inner_peripheral!((@ peri_type #[doc = "BB peripheral singleton"] BB <=
4999 BB() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5000 "DPORT peripheral singleton"] DPORT <= DPORT() (unstable)));
5001 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
5002 SYSTEM <= DPORT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5003 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
5004 _for_each_inner_peripheral!((@ peri_type #[doc = "ETH peripheral singleton"] ETH
5005 <= virtual(ETH_MAC : { bind_peri_interrupt, enable_peri_interrupt,
5006 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5007 #[doc = "EMAC_DMA peripheral singleton"] EMAC_DMA <= GMAC_DMA() (unstable)));
5008 _for_each_inner_peripheral!((@ peri_type #[doc = "EMAC_EXT peripheral singleton"]
5009 EMAC_EXT <= EMAC_EXT() (unstable))); _for_each_inner_peripheral!((@ peri_type
5010 #[doc = "EMAC_MAC peripheral singleton"] EMAC_MAC <= GMAC() (unstable)));
5011 _for_each_inner_peripheral!((@ peri_type #[doc =
5012 "FLASH_ENCRYPTION peripheral singleton"] FLASH_ENCRYPTION <= FLASH_ENCRYPTION()
5013 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5014 "FRC_TIMER peripheral singleton"] FRC_TIMER <= FRC_TIMER() (unstable)));
5015 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
5016 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5017 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
5018 _for_each_inner_peripheral!((@ peri_type #[doc = "HINF peripheral singleton"]
5019 HINF <= HINF() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5020 "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
5021 enable_peri_interrupt, disable_peri_interrupt })));
5022 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C1 peripheral singleton"]
5023 I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt, enable_peri_interrupt,
5024 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5025 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
5026 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5027 _for_each_inner_peripheral!((@ peri_type #[doc = "I2S1 peripheral singleton"]
5028 I2S1 <= I2S1(I2S1 : { bind_peri_interrupt, enable_peri_interrupt,
5029 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5030 #[doc = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)));
5031 _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
5032 LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5033 "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
5034 _for_each_inner_peripheral!((@ peri_type #[doc =
5035 "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)));
5036 _for_each_inner_peripheral!((@ peri_type #[doc = "MCPWM1 peripheral singleton"]
5037 MCPWM1 <= MCPWM1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5038 "NRX peripheral singleton"] NRX <= NRX() (unstable)));
5039 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
5040 PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
5041 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5042 #[doc = "RMT peripheral singleton"] RMT <= RMT() (unstable)));
5043 _for_each_inner_peripheral!((@ peri_type #[doc = "RNG peripheral singleton"] RNG
5044 <= RNG() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5045 "RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
5046 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5047 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
5048 LPWR <= RTC_CNTL() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5049 "RTC_TIMER peripheral singleton"] RTC_TIMER <= RTC_CNTL() (unstable)));
5050 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
5051 LP_I2C0 <= RTC_I2C() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5052 = "RTC_IO peripheral singleton"] RTC_IO <= RTC_IO() (unstable)));
5053 _for_each_inner_peripheral!((@ peri_type #[doc = "SDHOST peripheral singleton"]
5054 SDHOST <= SDHOST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5055 "SENS peripheral singleton"] SENS <= SENS() (unstable)));
5056 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
5057 <= SHA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5058 "SLC peripheral singleton"] SLC <= SLC() (unstable)));
5059 _for_each_inner_peripheral!((@ peri_type #[doc = "SLCHOST peripheral singleton"]
5060 SLCHOST <= SLCHOST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5061 = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
5062 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
5063 SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5064 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt,
5065 enable_dma_interrupt, disable_dma_interrupt }, SPI2 : { bind_peri_interrupt,
5066 enable_peri_interrupt, disable_peri_interrupt })));
5067 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI3 peripheral singleton"]
5068 SPI3 <= SPI3(SPI3_DMA : { bind_dma_interrupt, enable_dma_interrupt,
5069 disable_dma_interrupt }, SPI3 : { bind_peri_interrupt, enable_peri_interrupt,
5070 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5071 "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
5072 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
5073 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5074 "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)));
5075 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
5076 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5077 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5078 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
5079 enable_peri_interrupt, disable_peri_interrupt })));
5080 _for_each_inner_peripheral!((@ peri_type #[doc = "UART2 peripheral singleton"]
5081 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
5082 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5083 "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
5084 _for_each_inner_peripheral!((@ peri_type #[doc = "UHCI1 peripheral singleton"]
5085 UHCI1 <= UHCI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5086 "WIFI peripheral singleton"] WIFI <= WIFI(WIFI_MAC : { bind_mac_interrupt,
5087 enable_mac_interrupt, disable_mac_interrupt }))); _for_each_inner_peripheral!((@
5088 peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
5089 _for_each_inner_peripheral!((@ peri_type #[doc = "ADC2 peripheral singleton"]
5090 ADC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5091 "BT peripheral singleton"] BT <= virtual(BT_BB : { bind_bb_interrupt,
5092 enable_bb_interrupt, disable_bb_interrupt }, RWBLE : { bind_rwble_interrupt,
5093 enable_rwble_interrupt, disable_rwble_interrupt }, RWBT : { bind_rwbt_interrupt,
5094 enable_rwbt_interrupt, disable_rwbt_interrupt }) (unstable)));
5095 _for_each_inner_peripheral!((@ peri_type #[doc = "CPU_CTRL peripheral singleton"]
5096 CPU_CTRL <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
5097 #[doc = "DAC1 peripheral singleton"] DAC1 <= virtual() (unstable)));
5098 _for_each_inner_peripheral!((@ peri_type #[doc = "DAC2 peripheral singleton"]
5099 DAC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5100 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
5101 _for_each_inner_peripheral!((@ peri_type #[doc = "PSRAM peripheral singleton"]
5102 PSRAM <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5103 "TOUCH peripheral singleton"] TOUCH <= virtual() (unstable)));
5104 _for_each_inner_peripheral!((@ peri_type #[doc = "IPC peripheral singleton"] IPC
5105 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5106 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
5107 _for_each_inner_peripheral!((@ peri_type #[doc =
5108 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
5109 _for_each_inner_peripheral!((@ peri_type #[doc =
5110 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
5111 _for_each_inner_peripheral!((@ peri_type #[doc =
5112 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
5113 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
5114 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
5115 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
5116 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
5117 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
5118 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
5119 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
5120 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
5121 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
5122 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
5123 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
5124 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
5125 _for_each_inner_peripheral!((GPIO25)); _for_each_inner_peripheral!((GPIO26));
5126 _for_each_inner_peripheral!((GPIO27));
5127 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO32));
5128 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO33));
5129 _for_each_inner_peripheral!((GPIO34)); _for_each_inner_peripheral!((GPIO35));
5130 _for_each_inner_peripheral!((GPIO36)); _for_each_inner_peripheral!((GPIO37));
5131 _for_each_inner_peripheral!((GPIO38)); _for_each_inner_peripheral!((GPIO39));
5132 _for_each_inner_peripheral!((DMA_SPI2(unstable)));
5133 _for_each_inner_peripheral!((DMA_SPI3(unstable)));
5134 _for_each_inner_peripheral!((DMA_I2S0(unstable)));
5135 _for_each_inner_peripheral!((DMA_I2S1(unstable)));
5136 _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
5137 _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
5138 _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
5139 _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
5140 _for_each_inner_peripheral!((PCNT0_UNIT4(unstable)));
5141 _for_each_inner_peripheral!((PCNT0_UNIT5(unstable)));
5142 _for_each_inner_peripheral!((PCNT0_UNIT6(unstable)));
5143 _for_each_inner_peripheral!((PCNT0_UNIT7(unstable)));
5144 _for_each_inner_peripheral!((SDM_CH0(unstable)));
5145 _for_each_inner_peripheral!((SDM_CH1(unstable)));
5146 _for_each_inner_peripheral!((SDM_CH2(unstable)));
5147 _for_each_inner_peripheral!((SDM_CH3(unstable)));
5148 _for_each_inner_peripheral!((SDM_CH4(unstable)));
5149 _for_each_inner_peripheral!((SDM_CH5(unstable)));
5150 _for_each_inner_peripheral!((SDM_CH6(unstable)));
5151 _for_each_inner_peripheral!((SDM_CH7(unstable)));
5152 _for_each_inner_peripheral!((AES(unstable)));
5153 _for_each_inner_peripheral!((APB_CTRL(unstable)));
5154 _for_each_inner_peripheral!((BB(unstable)));
5155 _for_each_inner_peripheral!((DPORT(unstable)));
5156 _for_each_inner_peripheral!((SYSTEM(unstable)));
5157 _for_each_inner_peripheral!((ETH(unstable)));
5158 _for_each_inner_peripheral!((FLASH_ENCRYPTION(unstable)));
5159 _for_each_inner_peripheral!((FRC_TIMER(unstable)));
5160 _for_each_inner_peripheral!((GPIO(unstable)));
5161 _for_each_inner_peripheral!((GPIO_SD(unstable)));
5162 _for_each_inner_peripheral!((HINF(unstable)));
5163 _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
5164 _for_each_inner_peripheral!((I2S0(unstable)));
5165 _for_each_inner_peripheral!((I2S1(unstable)));
5166 _for_each_inner_peripheral!((IO_MUX(unstable)));
5167 _for_each_inner_peripheral!((LEDC(unstable)));
5168 _for_each_inner_peripheral!((MCPWM0(unstable)));
5169 _for_each_inner_peripheral!((MCPWM1(unstable)));
5170 _for_each_inner_peripheral!((NRX(unstable)));
5171 _for_each_inner_peripheral!((PCNT(unstable)));
5172 _for_each_inner_peripheral!((RMT(unstable)));
5173 _for_each_inner_peripheral!((RNG(unstable)));
5174 _for_each_inner_peripheral!((RSA(unstable)));
5175 _for_each_inner_peripheral!((LPWR(unstable)));
5176 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
5177 _for_each_inner_peripheral!((LP_I2C0(unstable)));
5178 _for_each_inner_peripheral!((RTC_IO(unstable)));
5179 _for_each_inner_peripheral!((SDHOST(unstable)));
5180 _for_each_inner_peripheral!((SENS(unstable)));
5181 _for_each_inner_peripheral!((SHA(unstable)));
5182 _for_each_inner_peripheral!((SLC(unstable)));
5183 _for_each_inner_peripheral!((SLCHOST(unstable)));
5184 _for_each_inner_peripheral!((SPI0(unstable)));
5185 _for_each_inner_peripheral!((SPI1(unstable)));
5186 _for_each_inner_peripheral!((SPI2)); _for_each_inner_peripheral!((SPI3));
5187 _for_each_inner_peripheral!((TIMG0(unstable)));
5188 _for_each_inner_peripheral!((TIMG1(unstable)));
5189 _for_each_inner_peripheral!((TWAI0(unstable)));
5190 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
5191 _for_each_inner_peripheral!((UART2));
5192 _for_each_inner_peripheral!((UHCI0(unstable)));
5193 _for_each_inner_peripheral!((UHCI1(unstable)));
5194 _for_each_inner_peripheral!((WIFI));
5195 _for_each_inner_peripheral!((ADC1(unstable)));
5196 _for_each_inner_peripheral!((ADC2(unstable)));
5197 _for_each_inner_peripheral!((BT(unstable)));
5198 _for_each_inner_peripheral!((CPU_CTRL(unstable)));
5199 _for_each_inner_peripheral!((DAC1(unstable)));
5200 _for_each_inner_peripheral!((DAC2(unstable)));
5201 _for_each_inner_peripheral!((FLASH(unstable)));
5202 _for_each_inner_peripheral!((PSRAM(unstable)));
5203 _for_each_inner_peripheral!((TOUCH(unstable)));
5204 _for_each_inner_peripheral!((IPC(unstable)));
5205 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
5206 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
5207 _for_each_inner_peripheral!((SPI2, Spi2, 0, SpiDmaChannel));
5208 _for_each_inner_peripheral!((I2S0, I2s0, 0, I2sDmaChannel));
5209 _for_each_inner_peripheral!((SPI3, Spi3, 1, SpiDmaChannel));
5210 _for_each_inner_peripheral!((I2S1, I2s1, 1, I2sDmaChannel));
5211 _for_each_inner_peripheral!((all(@ peri_type #[doc =
5212 "GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5213 "<section class=\"warning\">"] #[doc =
5214 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5215 #[doc = "<ul>"] #[doc =
5216 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5217 = "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()), (@ peri_type #[doc =
5218 "GPIO1 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5219 "<section class=\"warning\">"] #[doc =
5220 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5221 #[doc = "<ul>"] #[doc =
5222 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5223 = "</ul>"] #[doc = "</section>"] GPIO1 <= virtual()), (@ peri_type #[doc =
5224 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5225 "<section class=\"warning\">"] #[doc =
5226 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5227 #[doc = "<ul>"] #[doc =
5228 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5229 = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
5230 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5231 "<section class=\"warning\">"] #[doc =
5232 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5233 #[doc = "<ul>"] #[doc =
5234 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5235 = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
5236 "GPIO4 peripheral singleton"] GPIO4 <= virtual()), (@ peri_type #[doc =
5237 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5238 "<section class=\"warning\">"] #[doc =
5239 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5240 #[doc = "<ul>"] #[doc =
5241 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5242 = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
5243 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5244 "<section class=\"warning\">"] #[doc =
5245 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5246 #[doc = "<ul>"] #[doc =
5247 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5248 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5249 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
5250 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5251 "<section class=\"warning\">"] #[doc =
5252 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5253 #[doc = "<ul>"] #[doc =
5254 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5255 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5256 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
5257 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5258 "<section class=\"warning\">"] #[doc =
5259 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5260 #[doc = "<ul>"] #[doc =
5261 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5262 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5263 "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
5264 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5265 "<section class=\"warning\">"] #[doc =
5266 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5267 #[doc = "<ul>"] #[doc =
5268 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5269 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5270 "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
5271 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5272 "<section class=\"warning\">"] #[doc =
5273 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5274 #[doc = "<ul>"] #[doc =
5275 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5276 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5277 "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
5278 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5279 "<section class=\"warning\">"] #[doc =
5280 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5281 #[doc = "<ul>"] #[doc =
5282 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5283 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5284 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
5285 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5286 "<section class=\"warning\">"] #[doc =
5287 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5288 #[doc = "<ul>"] #[doc =
5289 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5290 =
5291 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5292 #[doc = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
5293 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5294 "<section class=\"warning\">"] #[doc =
5295 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5296 #[doc = "<ul>"] #[doc =
5297 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5298 #[doc = "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
5299 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5300 "<section class=\"warning\">"] #[doc =
5301 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5302 #[doc = "<ul>"] #[doc =
5303 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5304 #[doc = "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
5305 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5306 "<section class=\"warning\">"] #[doc =
5307 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5308 #[doc = "<ul>"] #[doc =
5309 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5310 =
5311 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5312 #[doc = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
5313 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5314 "<section class=\"warning\">"] #[doc =
5315 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5316 #[doc = "<ul>"] #[doc =
5317 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5318 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5319 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
5320 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5321 "<section class=\"warning\">"] #[doc =
5322 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5323 #[doc = "<ul>"] #[doc =
5324 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5325 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
5326 "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
5327 "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
5328 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5329 "<section class=\"warning\">"] #[doc =
5330 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5331 #[doc = "<ul>"] #[doc = "<li>This pin is only available on ESP32-PICO-V3.</li>"]
5332 #[doc = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
5333 "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
5334 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
5335 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
5336 "GPIO25 peripheral singleton"] GPIO25 <= virtual()), (@ peri_type #[doc =
5337 "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
5338 "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
5339 "GPIO32 peripheral singleton"] GPIO32 <= virtual()), (@ peri_type #[doc =
5340 "GPIO33 peripheral singleton"] GPIO33 <= virtual()), (@ peri_type #[doc =
5341 "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5342 "<section class=\"warning\">"] #[doc =
5343 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5344 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
5345 = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()), (@ peri_type #[doc =
5346 "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5347 "<section class=\"warning\">"] #[doc =
5348 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5349 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
5350 = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()), (@ peri_type #[doc =
5351 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5352 "<section class=\"warning\">"] #[doc =
5353 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5354 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
5355 = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()), (@ peri_type #[doc =
5356 "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5357 "<section class=\"warning\">"] #[doc =
5358 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5359 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
5360 = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()), (@ peri_type #[doc =
5361 "GPIO38 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5362 "<section class=\"warning\">"] #[doc =
5363 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5364 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
5365 = "</ul>"] #[doc = "</section>"] GPIO38 <= virtual()), (@ peri_type #[doc =
5366 "GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5367 "<section class=\"warning\">"] #[doc =
5368 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5369 #[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
5370 = "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()), (@ peri_type #[doc =
5371 "DMA_SPI2 peripheral singleton"] DMA_SPI2 <= SPI2(SPI2_DMA : {
5372 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5373 (@ peri_type #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3(SPI3_DMA :
5374 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5375 (@ peri_type #[doc = "DMA_I2S0 peripheral singleton"] DMA_I2S0 <= I2S0(I2S0 : {
5376 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5377 (@ peri_type #[doc = "DMA_I2S1 peripheral singleton"] DMA_I2S1 <= I2S1(I2S1 : {
5378 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5379 (@ peri_type #[doc = "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual()
5380 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1
5381 <= virtual() (unstable)), (@ peri_type #[doc =
5382 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)), (@
5383 peri_type #[doc = "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual()
5384 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT4 peripheral singleton"] PCNT0_UNIT4
5385 <= virtual() (unstable)), (@ peri_type #[doc =
5386 "PCNT0_UNIT5 peripheral singleton"] PCNT0_UNIT5 <= virtual() (unstable)), (@
5387 peri_type #[doc = "PCNT0_UNIT6 peripheral singleton"] PCNT0_UNIT6 <= virtual()
5388 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT7 peripheral singleton"] PCNT0_UNIT7
5389 <= virtual() (unstable)), (@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
5390 SDM_CH0 <= virtual() (unstable)), (@ peri_type #[doc =
5391 "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)), (@ peri_type
5392 #[doc = "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual() (unstable)), (@
5393 peri_type #[doc = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual()
5394 (unstable)), (@ peri_type #[doc = "SDM_CH4 peripheral singleton"] SDM_CH4 <=
5395 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH5 peripheral singleton"]
5396 SDM_CH5 <= virtual() (unstable)), (@ peri_type #[doc =
5397 "SDM_CH6 peripheral singleton"] SDM_CH6 <= virtual() (unstable)), (@ peri_type
5398 #[doc = "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)), (@
5399 peri_type #[doc = "AES peripheral singleton"] AES <= AES() (unstable)), (@
5400 peri_type #[doc = "APB_CTRL peripheral singleton"] APB_CTRL <= APB_CTRL()
5401 (unstable)), (@ peri_type #[doc = "BB peripheral singleton"] BB <= BB()
5402 (unstable)), (@ peri_type #[doc = "DPORT peripheral singleton"] DPORT <= DPORT()
5403 (unstable)), (@ peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <=
5404 DPORT() (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <=
5405 EFUSE() (unstable)), (@ peri_type #[doc = "ETH peripheral singleton"] ETH <=
5406 virtual(ETH_MAC : { bind_peri_interrupt, enable_peri_interrupt,
5407 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5408 "EMAC_DMA peripheral singleton"] EMAC_DMA <= GMAC_DMA() (unstable)), (@ peri_type
5409 #[doc = "EMAC_EXT peripheral singleton"] EMAC_EXT <= EMAC_EXT() (unstable)), (@
5410 peri_type #[doc = "EMAC_MAC peripheral singleton"] EMAC_MAC <= GMAC()
5411 (unstable)), (@ peri_type #[doc = "FLASH_ENCRYPTION peripheral singleton"]
5412 FLASH_ENCRYPTION <= FLASH_ENCRYPTION() (unstable)), (@ peri_type #[doc =
5413 "FRC_TIMER peripheral singleton"] FRC_TIMER <= FRC_TIMER() (unstable)), (@
5414 peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@
5415 peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD()
5416 (unstable)), (@ peri_type #[doc = "HINF peripheral singleton"] HINF <= HINF()
5417 (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <=
5418 I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
5419 disable_peri_interrupt })), (@ peri_type #[doc = "I2C1 peripheral singleton"]
5420 I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt, enable_peri_interrupt,
5421 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
5422 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
5423 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5424 "I2S1 peripheral singleton"] I2S1 <= I2S1(I2S1 : { bind_peri_interrupt,
5425 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5426 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
5427 #[doc = "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type
5428 #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)), (@
5429 peri_type #[doc = "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE()
5430 (unstable)), (@ peri_type #[doc = "MCPWM1 peripheral singleton"] MCPWM1 <=
5431 MCPWM1() (unstable)), (@ peri_type #[doc = "NRX peripheral singleton"] NRX <=
5432 NRX() (unstable)), (@ peri_type #[doc = "PCNT peripheral singleton"] PCNT <=
5433 PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5434 }) (unstable)), (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT()
5435 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG()
5436 (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
5437 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5438 (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= RTC_CNTL()
5439 (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
5440 RTC_CNTL() (unstable)), (@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
5441 LP_I2C0 <= RTC_I2C() (unstable)), (@ peri_type #[doc =
5442 "RTC_IO peripheral singleton"] RTC_IO <= RTC_IO() (unstable)), (@ peri_type #[doc
5443 = "SDHOST peripheral singleton"] SDHOST <= SDHOST() (unstable)), (@ peri_type
5444 #[doc = "SENS peripheral singleton"] SENS <= SENS() (unstable)), (@ peri_type
5445 #[doc = "SHA peripheral singleton"] SHA <= SHA() (unstable)), (@ peri_type #[doc
5446 = "SLC peripheral singleton"] SLC <= SLC() (unstable)), (@ peri_type #[doc =
5447 "SLCHOST peripheral singleton"] SLCHOST <= SLCHOST() (unstable)), (@ peri_type
5448 #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type
5449 #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type
5450 #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2_DMA : {
5451 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }, SPI2 : {
5452 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5453 peri_type #[doc = "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : {
5454 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }, SPI3 : {
5455 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5456 peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@
5457 peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@
5458 peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@
5459 peri_type #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
5460 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5461 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
5462 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5463 peri_type #[doc = "UART2 peripheral singleton"] UART2 <= UART2(UART2 : {
5464 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5465 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
5466 peri_type #[doc = "UHCI1 peripheral singleton"] UHCI1 <= UHCI1() (unstable)), (@
5467 peri_type #[doc = "WIFI peripheral singleton"] WIFI <= WIFI(WIFI_MAC : {
5468 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt })), (@ peri_type
5469 #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type
5470 #[doc = "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)), (@ peri_type
5471 #[doc = "BT peripheral singleton"] BT <= virtual(BT_BB : { bind_bb_interrupt,
5472 enable_bb_interrupt, disable_bb_interrupt }, RWBLE : { bind_rwble_interrupt,
5473 enable_rwble_interrupt, disable_rwble_interrupt }, RWBT : { bind_rwbt_interrupt,
5474 enable_rwbt_interrupt, disable_rwbt_interrupt }) (unstable)), (@ peri_type #[doc
5475 = "CPU_CTRL peripheral singleton"] CPU_CTRL <= virtual() (unstable)), (@
5476 peri_type #[doc = "DAC1 peripheral singleton"] DAC1 <= virtual() (unstable)), (@
5477 peri_type #[doc = "DAC2 peripheral singleton"] DAC2 <= virtual() (unstable)), (@
5478 peri_type #[doc = "FLASH peripheral singleton"] FLASH <= virtual() (unstable)),
5479 (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual()
5480 (unstable)), (@ peri_type #[doc = "TOUCH peripheral singleton"] TOUCH <=
5481 virtual() (unstable)), (@ peri_type #[doc = "IPC peripheral singleton"] IPC <=
5482 virtual() (unstable)), (@ peri_type #[doc =
5483 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)),
5484 (@ peri_type #[doc = "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <=
5485 virtual() (unstable)), (@ peri_type #[doc =
5486 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)),
5487 (@ peri_type #[doc = "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <=
5488 virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1),
5489 (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
5490 (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO15), (GPIO16), (GPIO17), (GPIO18),
5491 (GPIO19), (GPIO20), (GPIO21), (GPIO22), (GPIO23), (GPIO25), (GPIO26), (GPIO27),
5492 (#[cfg(not(use_xtal32k))] GPIO32), (#[cfg(not(use_xtal32k))] GPIO33), (GPIO34),
5493 (GPIO35), (GPIO36), (GPIO37), (GPIO38), (GPIO39), (DMA_SPI2(unstable)),
5494 (DMA_SPI3(unstable)), (DMA_I2S0(unstable)), (DMA_I2S1(unstable)),
5495 (PCNT0_UNIT0(unstable)), (PCNT0_UNIT1(unstable)), (PCNT0_UNIT2(unstable)),
5496 (PCNT0_UNIT3(unstable)), (PCNT0_UNIT4(unstable)), (PCNT0_UNIT5(unstable)),
5497 (PCNT0_UNIT6(unstable)), (PCNT0_UNIT7(unstable)), (SDM_CH0(unstable)),
5498 (SDM_CH1(unstable)), (SDM_CH2(unstable)), (SDM_CH3(unstable)),
5499 (SDM_CH4(unstable)), (SDM_CH5(unstable)), (SDM_CH6(unstable)),
5500 (SDM_CH7(unstable)), (AES(unstable)), (APB_CTRL(unstable)), (BB(unstable)),
5501 (DPORT(unstable)), (SYSTEM(unstable)), (ETH(unstable)),
5502 (FLASH_ENCRYPTION(unstable)), (FRC_TIMER(unstable)), (GPIO(unstable)),
5503 (GPIO_SD(unstable)), (HINF(unstable)), (I2C0), (I2C1), (I2S0(unstable)),
5504 (I2S1(unstable)), (IO_MUX(unstable)), (LEDC(unstable)), (MCPWM0(unstable)),
5505 (MCPWM1(unstable)), (NRX(unstable)), (PCNT(unstable)), (RMT(unstable)),
5506 (RNG(unstable)), (RSA(unstable)), (LPWR(unstable)), (RTC_TIMER(unstable)),
5507 (LP_I2C0(unstable)), (RTC_IO(unstable)), (SDHOST(unstable)), (SENS(unstable)),
5508 (SHA(unstable)), (SLC(unstable)), (SLCHOST(unstable)), (SPI0(unstable)),
5509 (SPI1(unstable)), (SPI2), (SPI3), (TIMG0(unstable)), (TIMG1(unstable)),
5510 (TWAI0(unstable)), (UART0), (UART1), (UART2), (UHCI0(unstable)),
5511 (UHCI1(unstable)), (WIFI), (ADC1(unstable)), (ADC2(unstable)), (BT(unstable)),
5512 (CPU_CTRL(unstable)), (DAC1(unstable)), (DAC2(unstable)), (FLASH(unstable)),
5513 (PSRAM(unstable)), (TOUCH(unstable)), (IPC(unstable)),
5514 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
5515 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 0, SpiDmaChannel), (I2S0,
5516 I2s0, 0, I2sDmaChannel), (SPI3, Spi3, 1, SpiDmaChannel), (I2S1, I2s1, 1,
5517 I2sDmaChannel)));
5518 };
5519}
5520#[macro_export]
5547#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5548macro_rules! for_each_gpio {
5549 ($($pattern:tt => $code:tt;)*) => {
5550 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5551 } _for_each_inner_gpio!((0, GPIO0(_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 =>
5552 EMAC_TX_CLK) ([Input] [Output]))); _for_each_inner_gpio!((1, GPIO1(_5 =>
5553 EMAC_RXD2) (_0 => U0TXD _1 => CLK_OUT3) ([Input] [Output])));
5554 _for_each_inner_gpio!((2, GPIO2(_1 => HSPIWP _3 => SD2_DATA0 _4 => SD_DATA0) (_1
5555 => HSPIWP _3 => SD2_DATA0 _4 => SD_DATA0) ([Input] [Output])));
5556 _for_each_inner_gpio!((3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) ([Input]
5557 [Output]))); _for_each_inner_gpio!((4, GPIO4(_1 => HSPIHD _3 => SD2_DATA1 _4 =>
5558 SD_DATA1 _5 => EMAC_TXER) (_1 => HSPIHD _3 => SD2_DATA1 _4 => SD_DATA1 _5 =>
5559 EMAC_TXER) ([Input] [Output]))); _for_each_inner_gpio!((5, GPIO5(_1 => VSPICS0 _3
5560 => SD1_DATA6 _5 => EMAC_RX_CLK) (_1 => VSPICS0 _3 => SD1_DATA6) ([Input]
5561 [Output]))); _for_each_inner_gpio!((6, GPIO6(_1 => SPICLK _4 => U1CTS) (_0 =>
5562 SD_CLK _1 => SPICLK _3 => SD1_CLK) ([Input] [Output])));
5563 _for_each_inner_gpio!((7, GPIO7(_0 => SD_DATA0 _1 => SPIQ _3 => SD1_DATA0) (_0 =>
5564 SD_DATA0 _1 => SPIQ _3 => SD1_DATA0 _4 => U2RTS) ([Input] [Output])));
5565 _for_each_inner_gpio!((8, GPIO8(_0 => SD_DATA1 _1 => SPID _3 => SD1_DATA1 _4 =>
5566 U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => SD1_DATA1) ([Input] [Output])));
5567 _for_each_inner_gpio!((9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => SD1_DATA2 _4 =>
5568 U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => SD1_DATA2) ([Input] [Output])));
5569 _for_each_inner_gpio!((10, GPIO10(_0 => SD_DATA3 _1 => SPIWP _3 => SD1_DATA3) (_0
5570 => SD_DATA3 _1 => SPIWP _3 => SD1_DATA3 _4 => U1TXD) ([Input] [Output])));
5571 _for_each_inner_gpio!((11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 => SD_CMD _1 =>
5572 SPICS0 _3 => SD1_CMD _4 => U1RTS) ([Input] [Output])));
5573 _for_each_inner_gpio!((12, GPIO12(_0 => MTDI _1 => HSPIQ _3 => SD2_DATA2 _4 =>
5574 SD_DATA2) (_1 => HSPIQ _3 => SD2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) ([Input]
5575 [Output]))); _for_each_inner_gpio!((13, GPIO13(_0 => MTCK _1 => HSPID _3 =>
5576 SD2_DATA3 _4 => SD_DATA3 _5 => EMAC_RXER) (_1 => HSPID _3 => SD2_DATA3 _4 =>
5577 SD_DATA3 _5 => EMAC_RXER) ([Input] [Output]))); _for_each_inner_gpio!((14,
5578 GPIO14(_0 => MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => SD2_CLK _4 => SD_CLK _5 =>
5579 EMAC_TXD2) ([Input] [Output]))); _for_each_inner_gpio!((15, GPIO15(_1 => HSPICS0
5580 _4 => SD_CMD _5 => EMAC_RXD3) (_0 => MTDO _1 => HSPICS0 _3 => SD2_CMD _4 =>
5581 SD_CMD) ([Input] [Output]))); _for_each_inner_gpio!((16, GPIO16(_3 => SD1_DATA4
5582 _4 => U2RXD) (_3 => SD1_DATA4 _5 => EMAC_CLK_OUT) ([Input] [Output])));
5583 _for_each_inner_gpio!((17, GPIO17(_3 => SD1_DATA5) (_3 => SD1_DATA5 _4 => U2TXD
5584 _5 => EMAC_CLK_180) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18(_1 =>
5585 VSPICLK _3 => SD1_DATA7) (_1 => VSPICLK _3 => SD1_DATA7) ([Input] [Output])));
5586 _for_each_inner_gpio!((19, GPIO19(_1 => VSPIQ _3 => U0CTS) (_1 => VSPIQ _5 =>
5587 EMAC_TXD0) ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20() () ([Input]
5588 [Output]))); _for_each_inner_gpio!((21, GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 =>
5589 EMAC_TXEN) ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22(_1 => VSPIWP)
5590 (_1 => VSPIWP _3 => U0RTS _5 => EMAC_TXD1) ([Input] [Output])));
5591 _for_each_inner_gpio!((23, GPIO23(_1 => VSPID) (_1 => VSPID _3 => SD1_STROBE)
5592 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_5 => EMAC_RXD0) ()
5593 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_5 => EMAC_RXD1) ()
5594 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27(_5 => EMAC_RXDV) ()
5595 ([Input] [Output]))); _for_each_inner_gpio!((32, GPIO32() () ([Input]
5596 [Output]))); _for_each_inner_gpio!((33, GPIO33() () ([Input] [Output])));
5597 _for_each_inner_gpio!((34, GPIO34() () ([Input] []))); _for_each_inner_gpio!((35,
5598 GPIO35() () ([Input] []))); _for_each_inner_gpio!((36, GPIO36() () ([Input]
5599 []))); _for_each_inner_gpio!((37, GPIO37() () ([Input] [])));
5600 _for_each_inner_gpio!((38, GPIO38() () ([Input] []))); _for_each_inner_gpio!((39,
5601 GPIO39() () ([Input] []))); _for_each_inner_gpio!((all(0, GPIO0(_5 =>
5602 EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output])), (1, GPIO1(_5
5603 => EMAC_RXD2) (_0 => U0TXD _1 => CLK_OUT3) ([Input] [Output])), (2, GPIO2(_1 =>
5604 HSPIWP _3 => SD2_DATA0 _4 => SD_DATA0) (_1 => HSPIWP _3 => SD2_DATA0 _4 =>
5605 SD_DATA0) ([Input] [Output])), (3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) ([Input]
5606 [Output])), (4, GPIO4(_1 => HSPIHD _3 => SD2_DATA1 _4 => SD_DATA1 _5 =>
5607 EMAC_TXER) (_1 => HSPIHD _3 => SD2_DATA1 _4 => SD_DATA1 _5 => EMAC_TXER) ([Input]
5608 [Output])), (5, GPIO5(_1 => VSPICS0 _3 => SD1_DATA6 _5 => EMAC_RX_CLK) (_1 =>
5609 VSPICS0 _3 => SD1_DATA6) ([Input] [Output])), (6, GPIO6(_1 => SPICLK _4 => U1CTS)
5610 (_0 => SD_CLK _1 => SPICLK _3 => SD1_CLK) ([Input] [Output])), (7, GPIO7(_0 =>
5611 SD_DATA0 _1 => SPIQ _3 => SD1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 => SD1_DATA0
5612 _4 => U2RTS) ([Input] [Output])), (8, GPIO8(_0 => SD_DATA1 _1 => SPID _3 =>
5613 SD1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => SD1_DATA1) ([Input]
5614 [Output])), (9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => SD1_DATA2 _4 => U1RXD) (_0
5615 => SD_DATA2 _1 => SPIHD _3 => SD1_DATA2) ([Input] [Output])), (10, GPIO10(_0 =>
5616 SD_DATA3 _1 => SPIWP _3 => SD1_DATA3) (_0 => SD_DATA3 _1 => SPIWP _3 => SD1_DATA3
5617 _4 => U1TXD) ([Input] [Output])), (11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 =>
5618 SD_CMD _1 => SPICS0 _3 => SD1_CMD _4 => U1RTS) ([Input] [Output])), (12,
5619 GPIO12(_0 => MTDI _1 => HSPIQ _3 => SD2_DATA2 _4 => SD_DATA2) (_1 => HSPIQ _3 =>
5620 SD2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) ([Input] [Output])), (13, GPIO13(_0 =>
5621 MTCK _1 => HSPID _3 => SD2_DATA3 _4 => SD_DATA3 _5 => EMAC_RXER) (_1 => HSPID _3
5622 => SD2_DATA3 _4 => SD_DATA3 _5 => EMAC_RXER) ([Input] [Output])), (14, GPIO14(_0
5623 => MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => SD2_CLK _4 => SD_CLK _5 => EMAC_TXD2)
5624 ([Input] [Output])), (15, GPIO15(_1 => HSPICS0 _4 => SD_CMD _5 => EMAC_RXD3) (_0
5625 => MTDO _1 => HSPICS0 _3 => SD2_CMD _4 => SD_CMD) ([Input] [Output])), (16,
5626 GPIO16(_3 => SD1_DATA4 _4 => U2RXD) (_3 => SD1_DATA4 _5 => EMAC_CLK_OUT) ([Input]
5627 [Output])), (17, GPIO17(_3 => SD1_DATA5) (_3 => SD1_DATA5 _4 => U2TXD _5 =>
5628 EMAC_CLK_180) ([Input] [Output])), (18, GPIO18(_1 => VSPICLK _3 => SD1_DATA7) (_1
5629 => VSPICLK _3 => SD1_DATA7) ([Input] [Output])), (19, GPIO19(_1 => VSPIQ _3 =>
5630 U0CTS) (_1 => VSPIQ _5 => EMAC_TXD0) ([Input] [Output])), (20, GPIO20() ()
5631 ([Input] [Output])), (21, GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 => EMAC_TXEN)
5632 ([Input] [Output])), (22, GPIO22(_1 => VSPIWP) (_1 => VSPIWP _3 => U0RTS _5 =>
5633 EMAC_TXD1) ([Input] [Output])), (23, GPIO23(_1 => VSPID) (_1 => VSPID _3 =>
5634 SD1_STROBE) ([Input] [Output])), (25, GPIO25(_5 => EMAC_RXD0) () ([Input]
5635 [Output])), (26, GPIO26(_5 => EMAC_RXD1) () ([Input] [Output])), (27, GPIO27(_5
5636 => EMAC_RXDV) () ([Input] [Output])), (32, GPIO32() () ([Input] [Output])), (33,
5637 GPIO33() () ([Input] [Output])), (34, GPIO34() () ([Input] [])), (35, GPIO35() ()
5638 ([Input] [])), (36, GPIO36() () ([Input] [])), (37, GPIO37() () ([Input] [])),
5639 (38, GPIO38() () ([Input] [])), (39, GPIO39() () ([Input] []))));
5640 };
5641}
5642#[macro_export]
5669#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5670macro_rules! for_each_analog_function {
5671 ($($pattern:tt => $code:tt;)*) => {
5672 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5673 tt) => {} } _for_each_inner_analog_function!((ADC2_CH1, GPIO0));
5674 _for_each_inner_analog_function!((TOUCH1, GPIO0));
5675 _for_each_inner_analog_function!((ADC2_CH2, GPIO2));
5676 _for_each_inner_analog_function!((TOUCH2, GPIO2));
5677 _for_each_inner_analog_function!((ADC2_CH0, GPIO4));
5678 _for_each_inner_analog_function!((TOUCH0, GPIO4));
5679 _for_each_inner_analog_function!((ADC2_CH5, GPIO12));
5680 _for_each_inner_analog_function!((TOUCH5, GPIO12));
5681 _for_each_inner_analog_function!((ADC2_CH4, GPIO13));
5682 _for_each_inner_analog_function!((TOUCH4, GPIO13));
5683 _for_each_inner_analog_function!((ADC2_CH6, GPIO14));
5684 _for_each_inner_analog_function!((TOUCH6, GPIO14));
5685 _for_each_inner_analog_function!((ADC2_CH3, GPIO15));
5686 _for_each_inner_analog_function!((TOUCH3, GPIO15));
5687 _for_each_inner_analog_function!((DAC1, GPIO25));
5688 _for_each_inner_analog_function!((ADC2_CH8, GPIO25));
5689 _for_each_inner_analog_function!((DAC2, GPIO26));
5690 _for_each_inner_analog_function!((ADC2_CH9, GPIO26));
5691 _for_each_inner_analog_function!((ADC2_CH7, GPIO27));
5692 _for_each_inner_analog_function!((TOUCH7, GPIO27));
5693 _for_each_inner_analog_function!((XTAL_32K_P, GPIO32));
5694 _for_each_inner_analog_function!((ADC1_CH4, GPIO32));
5695 _for_each_inner_analog_function!((TOUCH9, GPIO32));
5696 _for_each_inner_analog_function!((XTAL_32K_N, GPIO33));
5697 _for_each_inner_analog_function!((ADC1_CH5, GPIO33));
5698 _for_each_inner_analog_function!((TOUCH8, GPIO33));
5699 _for_each_inner_analog_function!((ADC1_CH6, GPIO34));
5700 _for_each_inner_analog_function!((ADC1_CH7, GPIO35));
5701 _for_each_inner_analog_function!((ADC_H, GPIO36));
5702 _for_each_inner_analog_function!((ADC1_CH0, GPIO36));
5703 _for_each_inner_analog_function!((ADC_H, GPIO37));
5704 _for_each_inner_analog_function!((ADC1_CH1, GPIO37));
5705 _for_each_inner_analog_function!((ADC_H, GPIO38));
5706 _for_each_inner_analog_function!((ADC1_CH2, GPIO38));
5707 _for_each_inner_analog_function!((ADC_H, GPIO39));
5708 _for_each_inner_analog_function!((ADC1_CH3, GPIO39));
5709 _for_each_inner_analog_function!(((ADC2_CH1, ADCn_CHm, 2, 1), GPIO0));
5710 _for_each_inner_analog_function!(((ADC2_CH2, ADCn_CHm, 2, 2), GPIO2));
5711 _for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO4));
5712 _for_each_inner_analog_function!(((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12));
5713 _for_each_inner_analog_function!(((ADC2_CH4, ADCn_CHm, 2, 4), GPIO13));
5714 _for_each_inner_analog_function!(((ADC2_CH6, ADCn_CHm, 2, 6), GPIO14));
5715 _for_each_inner_analog_function!(((ADC2_CH3, ADCn_CHm, 2, 3), GPIO15));
5716 _for_each_inner_analog_function!(((ADC2_CH8, ADCn_CHm, 2, 8), GPIO25));
5717 _for_each_inner_analog_function!(((ADC2_CH9, ADCn_CHm, 2, 9), GPIO26));
5718 _for_each_inner_analog_function!(((ADC2_CH7, ADCn_CHm, 2, 7), GPIO27));
5719 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO32));
5720 _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO33));
5721 _for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO34));
5722 _for_each_inner_analog_function!(((ADC1_CH7, ADCn_CHm, 1, 7), GPIO35));
5723 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO36));
5724 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO37));
5725 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO38));
5726 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO39));
5727 _for_each_inner_analog_function!(((TOUCH1, TOUCHn, 1), GPIO0));
5728 _for_each_inner_analog_function!(((TOUCH2, TOUCHn, 2), GPIO2));
5729 _for_each_inner_analog_function!(((TOUCH0, TOUCHn, 0), GPIO4));
5730 _for_each_inner_analog_function!(((TOUCH5, TOUCHn, 5), GPIO12));
5731 _for_each_inner_analog_function!(((TOUCH4, TOUCHn, 4), GPIO13));
5732 _for_each_inner_analog_function!(((TOUCH6, TOUCHn, 6), GPIO14));
5733 _for_each_inner_analog_function!(((TOUCH3, TOUCHn, 3), GPIO15));
5734 _for_each_inner_analog_function!(((TOUCH7, TOUCHn, 7), GPIO27));
5735 _for_each_inner_analog_function!(((TOUCH9, TOUCHn, 9), GPIO32));
5736 _for_each_inner_analog_function!(((TOUCH8, TOUCHn, 8), GPIO33));
5737 _for_each_inner_analog_function!(((DAC1, DACn, 1), GPIO25));
5738 _for_each_inner_analog_function!(((DAC2, DACn, 2), GPIO26));
5739 _for_each_inner_analog_function!((all(ADC2_CH1, GPIO0), (TOUCH1, GPIO0),
5740 (ADC2_CH2, GPIO2), (TOUCH2, GPIO2), (ADC2_CH0, GPIO4), (TOUCH0, GPIO4),
5741 (ADC2_CH5, GPIO12), (TOUCH5, GPIO12), (ADC2_CH4, GPIO13), (TOUCH4, GPIO13),
5742 (ADC2_CH6, GPIO14), (TOUCH6, GPIO14), (ADC2_CH3, GPIO15), (TOUCH3, GPIO15),
5743 (DAC1, GPIO25), (ADC2_CH8, GPIO25), (DAC2, GPIO26), (ADC2_CH9, GPIO26),
5744 (ADC2_CH7, GPIO27), (TOUCH7, GPIO27), (XTAL_32K_P, GPIO32), (ADC1_CH4, GPIO32),
5745 (TOUCH9, GPIO32), (XTAL_32K_N, GPIO33), (ADC1_CH5, GPIO33), (TOUCH8, GPIO33),
5746 (ADC1_CH6, GPIO34), (ADC1_CH7, GPIO35), (ADC_H, GPIO36), (ADC1_CH0, GPIO36),
5747 (ADC_H, GPIO37), (ADC1_CH1, GPIO37), (ADC_H, GPIO38), (ADC1_CH2, GPIO38), (ADC_H,
5748 GPIO39), (ADC1_CH3, GPIO39)));
5749 _for_each_inner_analog_function!((ADCn_CHm((ADC2_CH1, ADCn_CHm, 2, 1), GPIO0),
5750 ((ADC2_CH2, ADCn_CHm, 2, 2), GPIO2), ((ADC2_CH0, ADCn_CHm, 2, 0), GPIO4),
5751 ((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12), ((ADC2_CH4, ADCn_CHm, 2, 4), GPIO13),
5752 ((ADC2_CH6, ADCn_CHm, 2, 6), GPIO14), ((ADC2_CH3, ADCn_CHm, 2, 3), GPIO15),
5753 ((ADC2_CH8, ADCn_CHm, 2, 8), GPIO25), ((ADC2_CH9, ADCn_CHm, 2, 9), GPIO26),
5754 ((ADC2_CH7, ADCn_CHm, 2, 7), GPIO27), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO32),
5755 ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO33), ((ADC1_CH6, ADCn_CHm, 1, 6), GPIO34),
5756 ((ADC1_CH7, ADCn_CHm, 1, 7), GPIO35), ((ADC1_CH0, ADCn_CHm, 1, 0), GPIO36),
5757 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO37), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO38),
5758 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO39)));
5759 _for_each_inner_analog_function!((TOUCHn((TOUCH1, TOUCHn, 1), GPIO0), ((TOUCH2,
5760 TOUCHn, 2), GPIO2), ((TOUCH0, TOUCHn, 0), GPIO4), ((TOUCH5, TOUCHn, 5), GPIO12),
5761 ((TOUCH4, TOUCHn, 4), GPIO13), ((TOUCH6, TOUCHn, 6), GPIO14), ((TOUCH3, TOUCHn,
5762 3), GPIO15), ((TOUCH7, TOUCHn, 7), GPIO27), ((TOUCH9, TOUCHn, 9), GPIO32),
5763 ((TOUCH8, TOUCHn, 8), GPIO33))); _for_each_inner_analog_function!((DACn((DAC1,
5764 DACn, 1), GPIO25), ((DAC2, DACn, 2), GPIO26)));
5765 };
5766}
5767#[macro_export]
5805#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5806macro_rules! for_each_lp_function {
5807 ($($pattern:tt => $code:tt;)*) => {
5808 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5809 => {} } _for_each_inner_lp_function!((LP_GPIO11, GPIO0, _0));
5810 _for_each_inner_lp_function!((SAR_I2C_SDA, GPIO0, _3));
5811 _for_each_inner_lp_function!((LP_GPIO12, GPIO2, _0));
5812 _for_each_inner_lp_function!((SAR_I2C_SCL, GPIO2, _3));
5813 _for_each_inner_lp_function!((LP_GPIO10, GPIO4, _0));
5814 _for_each_inner_lp_function!((SAR_I2C_SCL, GPIO4, _3));
5815 _for_each_inner_lp_function!((LP_GPIO15, GPIO12, _0));
5816 _for_each_inner_lp_function!((LP_GPIO14, GPIO13, _0));
5817 _for_each_inner_lp_function!((LP_GPIO16, GPIO14, _0));
5818 _for_each_inner_lp_function!((LP_GPIO13, GPIO15, _0));
5819 _for_each_inner_lp_function!((SAR_I2C_SDA, GPIO15, _3));
5820 _for_each_inner_lp_function!((LP_GPIO6, GPIO25, _0));
5821 _for_each_inner_lp_function!((LP_GPIO7, GPIO26, _0));
5822 _for_each_inner_lp_function!((LP_GPIO17, GPIO27, _0));
5823 _for_each_inner_lp_function!((LP_GPIO9, GPIO32, _0));
5824 _for_each_inner_lp_function!((LP_GPIO8, GPIO33, _0));
5825 _for_each_inner_lp_function!((LP_GPIO4, GPIO34, _0));
5826 _for_each_inner_lp_function!((LP_GPIO5, GPIO35, _0));
5827 _for_each_inner_lp_function!((LP_GPIO0, GPIO36, _0));
5828 _for_each_inner_lp_function!((LP_GPIO1, GPIO37, _0));
5829 _for_each_inner_lp_function!((LP_GPIO2, GPIO38, _0));
5830 _for_each_inner_lp_function!((LP_GPIO3, GPIO39, _0));
5831 _for_each_inner_lp_function!(((LP_GPIO11, LP_GPIOn, 11), GPIO0, _0, () ()));
5832 _for_each_inner_lp_function!(((LP_GPIO12, LP_GPIOn, 12), GPIO2, _0, () ()));
5833 _for_each_inner_lp_function!(((LP_GPIO10, LP_GPIOn, 10), GPIO4, _0, () ()));
5834 _for_each_inner_lp_function!(((LP_GPIO15, LP_GPIOn, 15), GPIO12, _0, () ()));
5835 _for_each_inner_lp_function!(((LP_GPIO14, LP_GPIOn, 14), GPIO13, _0, () ()));
5836 _for_each_inner_lp_function!(((LP_GPIO16, LP_GPIOn, 16), GPIO14, _0, () ()));
5837 _for_each_inner_lp_function!(((LP_GPIO13, LP_GPIOn, 13), GPIO15, _0, () ()));
5838 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO25, _0, () ()));
5839 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO26, _0, () ()));
5840 _for_each_inner_lp_function!(((LP_GPIO17, LP_GPIOn, 17), GPIO27, _0, () ()));
5841 _for_each_inner_lp_function!(((LP_GPIO9, LP_GPIOn, 9), GPIO32, _0, () ()));
5842 _for_each_inner_lp_function!(((LP_GPIO8, LP_GPIOn, 8), GPIO33, _0, () ()));
5843 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO34, _0, () ()));
5844 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO35, _0, () ()));
5845 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO36, _0, () ()));
5846 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO37, _0, () ()));
5847 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO38, _0, () ()));
5848 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO39, _0, () ()));
5849 _for_each_inner_lp_function!((all(LP_GPIO11, GPIO0, _0), (SAR_I2C_SDA, GPIO0,
5850 _3), (LP_GPIO12, GPIO2, _0), (SAR_I2C_SCL, GPIO2, _3), (LP_GPIO10, GPIO4, _0),
5851 (SAR_I2C_SCL, GPIO4, _3), (LP_GPIO15, GPIO12, _0), (LP_GPIO14, GPIO13, _0),
5852 (LP_GPIO16, GPIO14, _0), (LP_GPIO13, GPIO15, _0), (SAR_I2C_SDA, GPIO15, _3),
5853 (LP_GPIO6, GPIO25, _0), (LP_GPIO7, GPIO26, _0), (LP_GPIO17, GPIO27, _0),
5854 (LP_GPIO9, GPIO32, _0), (LP_GPIO8, GPIO33, _0), (LP_GPIO4, GPIO34, _0),
5855 (LP_GPIO5, GPIO35, _0), (LP_GPIO0, GPIO36, _0), (LP_GPIO1, GPIO37, _0),
5856 (LP_GPIO2, GPIO38, _0), (LP_GPIO3, GPIO39, _0)));
5857 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO11, LP_GPIOn, 11), GPIO0, _0, ()
5858 ()), ((LP_GPIO12, LP_GPIOn, 12), GPIO2, _0, () ()), ((LP_GPIO10, LP_GPIOn, 10),
5859 GPIO4, _0, () ()), ((LP_GPIO15, LP_GPIOn, 15), GPIO12, _0, () ()), ((LP_GPIO14,
5860 LP_GPIOn, 14), GPIO13, _0, () ()), ((LP_GPIO16, LP_GPIOn, 16), GPIO14, _0, ()
5861 ()), ((LP_GPIO13, LP_GPIOn, 13), GPIO15, _0, () ()), ((LP_GPIO6, LP_GPIOn, 6),
5862 GPIO25, _0, () ()), ((LP_GPIO7, LP_GPIOn, 7), GPIO26, _0, () ()), ((LP_GPIO17,
5863 LP_GPIOn, 17), GPIO27, _0, () ()), ((LP_GPIO9, LP_GPIOn, 9), GPIO32, _0, () ()),
5864 ((LP_GPIO8, LP_GPIOn, 8), GPIO33, _0, () ()), ((LP_GPIO4, LP_GPIOn, 4), GPIO34,
5865 _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO35, _0, () ()), ((LP_GPIO0, LP_GPIOn,
5866 0), GPIO36, _0, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO37, _0, () ()), ((LP_GPIO2,
5867 LP_GPIOn, 2), GPIO38, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO39, _0, () ())));
5868 };
5869}
5870#[macro_export]
5901#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5902macro_rules! for_each_iomux_function {
5903 ($($pattern:tt => $code:tt;)*) => {
5904 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5905 tt) => {} } _for_each_inner_iomux_function!((CLK_OUT1, GPIO0, _1));
5906 _for_each_inner_iomux_function!((EMAC_TX_CLK, GPIO0, _5));
5907 _for_each_inner_iomux_function!((U0TXD, GPIO1, _0));
5908 _for_each_inner_iomux_function!((CLK_OUT3, GPIO1, _1));
5909 _for_each_inner_iomux_function!((EMAC_RXD2, GPIO1, _5));
5910 _for_each_inner_iomux_function!((HSPIWP, GPIO2, _1));
5911 _for_each_inner_iomux_function!((SD2_DATA0, GPIO2, _3));
5912 _for_each_inner_iomux_function!((SD_DATA0, GPIO2, _4));
5913 _for_each_inner_iomux_function!((U0RXD, GPIO3, _0));
5914 _for_each_inner_iomux_function!((CLK_OUT2, GPIO3, _1));
5915 _for_each_inner_iomux_function!((HSPIHD, GPIO4, _1));
5916 _for_each_inner_iomux_function!((SD2_DATA1, GPIO4, _3));
5917 _for_each_inner_iomux_function!((SD_DATA1, GPIO4, _4));
5918 _for_each_inner_iomux_function!((EMAC_TXER, GPIO4, _5));
5919 _for_each_inner_iomux_function!((VSPICS0, GPIO5, _1));
5920 _for_each_inner_iomux_function!((SD1_DATA6, GPIO5, _3));
5921 _for_each_inner_iomux_function!((EMAC_RX_CLK, GPIO5, _5));
5922 _for_each_inner_iomux_function!((SD_CLK, GPIO6, _0));
5923 _for_each_inner_iomux_function!((SPICLK, GPIO6, _1));
5924 _for_each_inner_iomux_function!((SD1_CLK, GPIO6, _3));
5925 _for_each_inner_iomux_function!((U1CTS, GPIO6, _4));
5926 _for_each_inner_iomux_function!((SD_DATA0, GPIO7, _0));
5927 _for_each_inner_iomux_function!((SPIQ, GPIO7, _1));
5928 _for_each_inner_iomux_function!((SD1_DATA0, GPIO7, _3));
5929 _for_each_inner_iomux_function!((U2RTS, GPIO7, _4));
5930 _for_each_inner_iomux_function!((SD_DATA1, GPIO8, _0));
5931 _for_each_inner_iomux_function!((SPID, GPIO8, _1));
5932 _for_each_inner_iomux_function!((SD1_DATA1, GPIO8, _3));
5933 _for_each_inner_iomux_function!((U2CTS, GPIO8, _4));
5934 _for_each_inner_iomux_function!((SD_DATA2, GPIO9, _0));
5935 _for_each_inner_iomux_function!((SPIHD, GPIO9, _1));
5936 _for_each_inner_iomux_function!((SD1_DATA2, GPIO9, _3));
5937 _for_each_inner_iomux_function!((U1RXD, GPIO9, _4));
5938 _for_each_inner_iomux_function!((SD_DATA3, GPIO10, _0));
5939 _for_each_inner_iomux_function!((SPIWP, GPIO10, _1));
5940 _for_each_inner_iomux_function!((SD1_DATA3, GPIO10, _3));
5941 _for_each_inner_iomux_function!((U1TXD, GPIO10, _4));
5942 _for_each_inner_iomux_function!((SD_CMD, GPIO11, _0));
5943 _for_each_inner_iomux_function!((SPICS0, GPIO11, _1));
5944 _for_each_inner_iomux_function!((SD1_CMD, GPIO11, _3));
5945 _for_each_inner_iomux_function!((U1RTS, GPIO11, _4));
5946 _for_each_inner_iomux_function!((MTDI, GPIO12, _0));
5947 _for_each_inner_iomux_function!((HSPIQ, GPIO12, _1));
5948 _for_each_inner_iomux_function!((SD2_DATA2, GPIO12, _3));
5949 _for_each_inner_iomux_function!((SD_DATA2, GPIO12, _4));
5950 _for_each_inner_iomux_function!((EMAC_TXD3, GPIO12, _5));
5951 _for_each_inner_iomux_function!((MTCK, GPIO13, _0));
5952 _for_each_inner_iomux_function!((HSPID, GPIO13, _1));
5953 _for_each_inner_iomux_function!((SD2_DATA3, GPIO13, _3));
5954 _for_each_inner_iomux_function!((SD_DATA3, GPIO13, _4));
5955 _for_each_inner_iomux_function!((EMAC_RXER, GPIO13, _5));
5956 _for_each_inner_iomux_function!((MTMS, GPIO14, _0));
5957 _for_each_inner_iomux_function!((HSPICLK, GPIO14, _1));
5958 _for_each_inner_iomux_function!((SD2_CLK, GPIO14, _3));
5959 _for_each_inner_iomux_function!((SD_CLK, GPIO14, _4));
5960 _for_each_inner_iomux_function!((EMAC_TXD2, GPIO14, _5));
5961 _for_each_inner_iomux_function!((MTDO, GPIO15, _0));
5962 _for_each_inner_iomux_function!((HSPICS0, GPIO15, _1));
5963 _for_each_inner_iomux_function!((SD2_CMD, GPIO15, _3));
5964 _for_each_inner_iomux_function!((SD_CMD, GPIO15, _4));
5965 _for_each_inner_iomux_function!((EMAC_RXD3, GPIO15, _5));
5966 _for_each_inner_iomux_function!((SD1_DATA4, GPIO16, _3));
5967 _for_each_inner_iomux_function!((U2RXD, GPIO16, _4));
5968 _for_each_inner_iomux_function!((EMAC_CLK_OUT, GPIO16, _5));
5969 _for_each_inner_iomux_function!((SD1_DATA5, GPIO17, _3));
5970 _for_each_inner_iomux_function!((U2TXD, GPIO17, _4));
5971 _for_each_inner_iomux_function!((EMAC_CLK_180, GPIO17, _5));
5972 _for_each_inner_iomux_function!((VSPICLK, GPIO18, _1));
5973 _for_each_inner_iomux_function!((SD1_DATA7, GPIO18, _3));
5974 _for_each_inner_iomux_function!((VSPIQ, GPIO19, _1));
5975 _for_each_inner_iomux_function!((U0CTS, GPIO19, _3));
5976 _for_each_inner_iomux_function!((EMAC_TXD0, GPIO19, _5));
5977 _for_each_inner_iomux_function!((VSPIHD, GPIO21, _1));
5978 _for_each_inner_iomux_function!((EMAC_TXEN, GPIO21, _5));
5979 _for_each_inner_iomux_function!((VSPIWP, GPIO22, _1));
5980 _for_each_inner_iomux_function!((U0RTS, GPIO22, _3));
5981 _for_each_inner_iomux_function!((EMAC_TXD1, GPIO22, _5));
5982 _for_each_inner_iomux_function!((VSPID, GPIO23, _1));
5983 _for_each_inner_iomux_function!((SD1_STROBE, GPIO23, _3));
5984 _for_each_inner_iomux_function!((EMAC_RXD0, GPIO25, _5));
5985 _for_each_inner_iomux_function!((EMAC_RXD1, GPIO26, _5));
5986 _for_each_inner_iomux_function!((EMAC_RXDV, GPIO27, _5));
5987 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO0, _1));
5988 _for_each_inner_iomux_function!(((CLK_OUT3, CLK_OUTn, 3), GPIO1, _1));
5989 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO3, _1));
5990 _for_each_inner_iomux_function!(((EMAC_RXD2, EMAC_RXDn, 2), GPIO1, _5));
5991 _for_each_inner_iomux_function!(((EMAC_RXD3, EMAC_RXDn, 3), GPIO15, _5));
5992 _for_each_inner_iomux_function!(((EMAC_RXD0, EMAC_RXDn, 0), GPIO25, _5));
5993 _for_each_inner_iomux_function!(((EMAC_RXD1, EMAC_RXDn, 1), GPIO26, _5));
5994 _for_each_inner_iomux_function!(((SD2_DATA0, SDn_DATAm, 2, 0), GPIO2, _3));
5995 _for_each_inner_iomux_function!(((SD2_DATA1, SDn_DATAm, 2, 1), GPIO4, _3));
5996 _for_each_inner_iomux_function!(((SD1_DATA6, SDn_DATAm, 1, 6), GPIO5, _3));
5997 _for_each_inner_iomux_function!(((SD1_DATA0, SDn_DATAm, 1, 0), GPIO7, _3));
5998 _for_each_inner_iomux_function!(((SD1_DATA1, SDn_DATAm, 1, 1), GPIO8, _3));
5999 _for_each_inner_iomux_function!(((SD1_DATA2, SDn_DATAm, 1, 2), GPIO9, _3));
6000 _for_each_inner_iomux_function!(((SD1_DATA3, SDn_DATAm, 1, 3), GPIO10, _3));
6001 _for_each_inner_iomux_function!(((SD2_DATA2, SDn_DATAm, 2, 2), GPIO12, _3));
6002 _for_each_inner_iomux_function!(((SD2_DATA3, SDn_DATAm, 2, 3), GPIO13, _3));
6003 _for_each_inner_iomux_function!(((SD1_DATA4, SDn_DATAm, 1, 4), GPIO16, _3));
6004 _for_each_inner_iomux_function!(((SD1_DATA5, SDn_DATAm, 1, 5), GPIO17, _3));
6005 _for_each_inner_iomux_function!(((SD1_DATA7, SDn_DATAm, 1, 7), GPIO18, _3));
6006 _for_each_inner_iomux_function!(((SD_DATA0, SD_DATAn, 0), GPIO2, _4));
6007 _for_each_inner_iomux_function!(((SD_DATA1, SD_DATAn, 1), GPIO4, _4));
6008 _for_each_inner_iomux_function!(((SD_DATA0, SD_DATAn, 0), GPIO7, _0));
6009 _for_each_inner_iomux_function!(((SD_DATA1, SD_DATAn, 1), GPIO8, _0));
6010 _for_each_inner_iomux_function!(((SD_DATA2, SD_DATAn, 2), GPIO9, _0));
6011 _for_each_inner_iomux_function!(((SD_DATA3, SD_DATAn, 3), GPIO10, _0));
6012 _for_each_inner_iomux_function!(((SD_DATA2, SD_DATAn, 2), GPIO12, _4));
6013 _for_each_inner_iomux_function!(((SD_DATA3, SD_DATAn, 3), GPIO13, _4));
6014 _for_each_inner_iomux_function!(((VSPICS0, VSPICSn, 0), GPIO5, _1));
6015 _for_each_inner_iomux_function!(((SD1_CLK, SDn_CLK, 1), GPIO6, _3));
6016 _for_each_inner_iomux_function!(((SD2_CLK, SDn_CLK, 2), GPIO14, _3));
6017 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO11, _1));
6018 _for_each_inner_iomux_function!(((SD1_CMD, SDn_CMD, 1), GPIO11, _3));
6019 _for_each_inner_iomux_function!(((SD2_CMD, SDn_CMD, 2), GPIO15, _3));
6020 _for_each_inner_iomux_function!(((EMAC_TXD3, EMAC_TXDn, 3), GPIO12, _5));
6021 _for_each_inner_iomux_function!(((EMAC_TXD2, EMAC_TXDn, 2), GPIO14, _5));
6022 _for_each_inner_iomux_function!(((EMAC_TXD0, EMAC_TXDn, 0), GPIO19, _5));
6023 _for_each_inner_iomux_function!(((EMAC_TXD1, EMAC_TXDn, 1), GPIO22, _5));
6024 _for_each_inner_iomux_function!(((HSPICS0, HSPICSn, 0), GPIO15, _1));
6025 _for_each_inner_iomux_function!(((EMAC_CLK_180, EMAC_CLK_n, 180), GPIO17, _5));
6026 _for_each_inner_iomux_function!(((SD1_STROBE, SDn_STROBE, 1), GPIO23, _3));
6027 _for_each_inner_iomux_function!((all(CLK_OUT1, GPIO0, _1), (EMAC_TX_CLK, GPIO0,
6028 _5), (U0TXD, GPIO1, _0), (CLK_OUT3, GPIO1, _1), (EMAC_RXD2, GPIO1, _5), (HSPIWP,
6029 GPIO2, _1), (SD2_DATA0, GPIO2, _3), (SD_DATA0, GPIO2, _4), (U0RXD, GPIO3, _0),
6030 (CLK_OUT2, GPIO3, _1), (HSPIHD, GPIO4, _1), (SD2_DATA1, GPIO4, _3), (SD_DATA1,
6031 GPIO4, _4), (EMAC_TXER, GPIO4, _5), (VSPICS0, GPIO5, _1), (SD1_DATA6, GPIO5, _3),
6032 (EMAC_RX_CLK, GPIO5, _5), (SD_CLK, GPIO6, _0), (SPICLK, GPIO6, _1), (SD1_CLK,
6033 GPIO6, _3), (U1CTS, GPIO6, _4), (SD_DATA0, GPIO7, _0), (SPIQ, GPIO7, _1),
6034 (SD1_DATA0, GPIO7, _3), (U2RTS, GPIO7, _4), (SD_DATA1, GPIO8, _0), (SPID, GPIO8,
6035 _1), (SD1_DATA1, GPIO8, _3), (U2CTS, GPIO8, _4), (SD_DATA2, GPIO9, _0), (SPIHD,
6036 GPIO9, _1), (SD1_DATA2, GPIO9, _3), (U1RXD, GPIO9, _4), (SD_DATA3, GPIO10, _0),
6037 (SPIWP, GPIO10, _1), (SD1_DATA3, GPIO10, _3), (U1TXD, GPIO10, _4), (SD_CMD,
6038 GPIO11, _0), (SPICS0, GPIO11, _1), (SD1_CMD, GPIO11, _3), (U1RTS, GPIO11, _4),
6039 (MTDI, GPIO12, _0), (HSPIQ, GPIO12, _1), (SD2_DATA2, GPIO12, _3), (SD_DATA2,
6040 GPIO12, _4), (EMAC_TXD3, GPIO12, _5), (MTCK, GPIO13, _0), (HSPID, GPIO13, _1),
6041 (SD2_DATA3, GPIO13, _3), (SD_DATA3, GPIO13, _4), (EMAC_RXER, GPIO13, _5), (MTMS,
6042 GPIO14, _0), (HSPICLK, GPIO14, _1), (SD2_CLK, GPIO14, _3), (SD_CLK, GPIO14, _4),
6043 (EMAC_TXD2, GPIO14, _5), (MTDO, GPIO15, _0), (HSPICS0, GPIO15, _1), (SD2_CMD,
6044 GPIO15, _3), (SD_CMD, GPIO15, _4), (EMAC_RXD3, GPIO15, _5), (SD1_DATA4, GPIO16,
6045 _3), (U2RXD, GPIO16, _4), (EMAC_CLK_OUT, GPIO16, _5), (SD1_DATA5, GPIO17, _3),
6046 (U2TXD, GPIO17, _4), (EMAC_CLK_180, GPIO17, _5), (VSPICLK, GPIO18, _1),
6047 (SD1_DATA7, GPIO18, _3), (VSPIQ, GPIO19, _1), (U0CTS, GPIO19, _3), (EMAC_TXD0,
6048 GPIO19, _5), (VSPIHD, GPIO21, _1), (EMAC_TXEN, GPIO21, _5), (VSPIWP, GPIO22, _1),
6049 (U0RTS, GPIO22, _3), (EMAC_TXD1, GPIO22, _5), (VSPID, GPIO23, _1), (SD1_STROBE,
6050 GPIO23, _3), (EMAC_RXD0, GPIO25, _5), (EMAC_RXD1, GPIO26, _5), (EMAC_RXDV,
6051 GPIO27, _5))); _for_each_inner_iomux_function!((CLK_OUTn((CLK_OUT1, CLK_OUTn, 1),
6052 GPIO0, _1), ((CLK_OUT3, CLK_OUTn, 3), GPIO1, _1), ((CLK_OUT2, CLK_OUTn, 2),
6053 GPIO3, _1))); _for_each_inner_iomux_function!((EMAC_RXDn((EMAC_RXD2, EMAC_RXDn,
6054 2), GPIO1, _5), ((EMAC_RXD3, EMAC_RXDn, 3), GPIO15, _5), ((EMAC_RXD0, EMAC_RXDn,
6055 0), GPIO25, _5), ((EMAC_RXD1, EMAC_RXDn, 1), GPIO26, _5)));
6056 _for_each_inner_iomux_function!((SDn_DATAm((SD2_DATA0, SDn_DATAm, 2, 0), GPIO2,
6057 _3), ((SD2_DATA1, SDn_DATAm, 2, 1), GPIO4, _3), ((SD1_DATA6, SDn_DATAm, 1, 6),
6058 GPIO5, _3), ((SD1_DATA0, SDn_DATAm, 1, 0), GPIO7, _3), ((SD1_DATA1, SDn_DATAm, 1,
6059 1), GPIO8, _3), ((SD1_DATA2, SDn_DATAm, 1, 2), GPIO9, _3), ((SD1_DATA3,
6060 SDn_DATAm, 1, 3), GPIO10, _3), ((SD2_DATA2, SDn_DATAm, 2, 2), GPIO12, _3),
6061 ((SD2_DATA3, SDn_DATAm, 2, 3), GPIO13, _3), ((SD1_DATA4, SDn_DATAm, 1, 4),
6062 GPIO16, _3), ((SD1_DATA5, SDn_DATAm, 1, 5), GPIO17, _3), ((SD1_DATA7, SDn_DATAm,
6063 1, 7), GPIO18, _3))); _for_each_inner_iomux_function!((SD_DATAn((SD_DATA0,
6064 SD_DATAn, 0), GPIO2, _4), ((SD_DATA1, SD_DATAn, 1), GPIO4, _4), ((SD_DATA0,
6065 SD_DATAn, 0), GPIO7, _0), ((SD_DATA1, SD_DATAn, 1), GPIO8, _0), ((SD_DATA2,
6066 SD_DATAn, 2), GPIO9, _0), ((SD_DATA3, SD_DATAn, 3), GPIO10, _0), ((SD_DATA2,
6067 SD_DATAn, 2), GPIO12, _4), ((SD_DATA3, SD_DATAn, 3), GPIO13, _4)));
6068 _for_each_inner_iomux_function!((VSPICSn((VSPICS0, VSPICSn, 0), GPIO5, _1)));
6069 _for_each_inner_iomux_function!((SDn_CLK((SD1_CLK, SDn_CLK, 1), GPIO6, _3),
6070 ((SD2_CLK, SDn_CLK, 2), GPIO14, _3)));
6071 _for_each_inner_iomux_function!((SPICSn((SPICS0, SPICSn, 0), GPIO11, _1)));
6072 _for_each_inner_iomux_function!((SDn_CMD((SD1_CMD, SDn_CMD, 1), GPIO11, _3),
6073 ((SD2_CMD, SDn_CMD, 2), GPIO15, _3)));
6074 _for_each_inner_iomux_function!((EMAC_TXDn((EMAC_TXD3, EMAC_TXDn, 3), GPIO12,
6075 _5), ((EMAC_TXD2, EMAC_TXDn, 2), GPIO14, _5), ((EMAC_TXD0, EMAC_TXDn, 0), GPIO19,
6076 _5), ((EMAC_TXD1, EMAC_TXDn, 1), GPIO22, _5)));
6077 _for_each_inner_iomux_function!((HSPICSn((HSPICS0, HSPICSn, 0), GPIO15, _1)));
6078 _for_each_inner_iomux_function!((EMAC_CLK_n((EMAC_CLK_180, EMAC_CLK_n, 180),
6079 GPIO17, _5))); _for_each_inner_iomux_function!((SDn_STROBE((SD1_STROBE,
6080 SDn_STROBE, 1), GPIO23, _3)));
6081 };
6082}
6083#[macro_export]
6100#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6101macro_rules! gpio_for_signal {
6102 (CLK_OUT1 $(, $_fallback:literal)?) => {
6103 "GPIO0"
6104 };
6105 (EMAC_TX_CLK $(, $_fallback:literal)?) => {
6106 "GPIO0"
6107 };
6108 (ADC2_CH1 $(, $_fallback:literal)?) => {
6109 "GPIO0"
6110 };
6111 (TOUCH1 $(, $_fallback:literal)?) => {
6112 "GPIO0"
6113 };
6114 (LP_GPIO11 $(, $_fallback:literal)?) => {
6115 "GPIO0"
6116 };
6117 (SAR_I2C_SDA $(, $_fallback:literal)?) => {
6118 "GPIO0"
6119 };
6120 (U0TXD $(, $_fallback:literal)?) => {
6121 "GPIO1"
6122 };
6123 (CLK_OUT3 $(, $_fallback:literal)?) => {
6124 "GPIO1"
6125 };
6126 (EMAC_RXD2 $(, $_fallback:literal)?) => {
6127 "GPIO1"
6128 };
6129 (HSPIWP $(, $_fallback:literal)?) => {
6130 "GPIO2"
6131 };
6132 (SD2_DATA0 $(, $_fallback:literal)?) => {
6133 "GPIO2"
6134 };
6135 (SD_DATA0 $(, $_fallback:literal)?) => {
6136 "GPIO2"
6137 };
6138 (ADC2_CH2 $(, $_fallback:literal)?) => {
6139 "GPIO2"
6140 };
6141 (TOUCH2 $(, $_fallback:literal)?) => {
6142 "GPIO2"
6143 };
6144 (LP_GPIO12 $(, $_fallback:literal)?) => {
6145 "GPIO2"
6146 };
6147 (SAR_I2C_SCL $(, $_fallback:literal)?) => {
6148 "GPIO4"
6149 };
6150 (U0RXD $(, $_fallback:literal)?) => {
6151 "GPIO3"
6152 };
6153 (CLK_OUT2 $(, $_fallback:literal)?) => {
6154 "GPIO3"
6155 };
6156 (HSPIHD $(, $_fallback:literal)?) => {
6157 "GPIO4"
6158 };
6159 (SD2_DATA1 $(, $_fallback:literal)?) => {
6160 "GPIO4"
6161 };
6162 (SD_DATA1 $(, $_fallback:literal)?) => {
6163 "GPIO4"
6164 };
6165 (EMAC_TXER $(, $_fallback:literal)?) => {
6166 "GPIO4"
6167 };
6168 (ADC2_CH0 $(, $_fallback:literal)?) => {
6169 "GPIO4"
6170 };
6171 (TOUCH0 $(, $_fallback:literal)?) => {
6172 "GPIO4"
6173 };
6174 (LP_GPIO10 $(, $_fallback:literal)?) => {
6175 "GPIO4"
6176 };
6177 (VSPICS0 $(, $_fallback:literal)?) => {
6178 "GPIO5"
6179 };
6180 (SD1_DATA6 $(, $_fallback:literal)?) => {
6181 "GPIO5"
6182 };
6183 (EMAC_RX_CLK $(, $_fallback:literal)?) => {
6184 "GPIO5"
6185 };
6186 (SD_CLK $(, $_fallback:literal)?) => {
6187 "GPIO6"
6188 };
6189 (SPICLK $(, $_fallback:literal)?) => {
6190 "GPIO6"
6191 };
6192 (SD1_CLK $(, $_fallback:literal)?) => {
6193 "GPIO6"
6194 };
6195 (U1CTS $(, $_fallback:literal)?) => {
6196 "GPIO6"
6197 };
6198 (SPIQ $(, $_fallback:literal)?) => {
6199 "GPIO7"
6200 };
6201 (SD1_DATA0 $(, $_fallback:literal)?) => {
6202 "GPIO7"
6203 };
6204 (U2RTS $(, $_fallback:literal)?) => {
6205 "GPIO7"
6206 };
6207 (SPID $(, $_fallback:literal)?) => {
6208 "GPIO8"
6209 };
6210 (SD1_DATA1 $(, $_fallback:literal)?) => {
6211 "GPIO8"
6212 };
6213 (U2CTS $(, $_fallback:literal)?) => {
6214 "GPIO8"
6215 };
6216 (SD_DATA2 $(, $_fallback:literal)?) => {
6217 "GPIO9"
6218 };
6219 (SPIHD $(, $_fallback:literal)?) => {
6220 "GPIO9"
6221 };
6222 (SD1_DATA2 $(, $_fallback:literal)?) => {
6223 "GPIO9"
6224 };
6225 (U1RXD $(, $_fallback:literal)?) => {
6226 "GPIO9"
6227 };
6228 (SD_DATA3 $(, $_fallback:literal)?) => {
6229 "GPIO10"
6230 };
6231 (SPIWP $(, $_fallback:literal)?) => {
6232 "GPIO10"
6233 };
6234 (SD1_DATA3 $(, $_fallback:literal)?) => {
6235 "GPIO10"
6236 };
6237 (U1TXD $(, $_fallback:literal)?) => {
6238 "GPIO10"
6239 };
6240 (SD_CMD $(, $_fallback:literal)?) => {
6241 "GPIO11"
6242 };
6243 (SPICS0 $(, $_fallback:literal)?) => {
6244 "GPIO11"
6245 };
6246 (SD1_CMD $(, $_fallback:literal)?) => {
6247 "GPIO11"
6248 };
6249 (U1RTS $(, $_fallback:literal)?) => {
6250 "GPIO11"
6251 };
6252 (MTDI $(, $_fallback:literal)?) => {
6253 "GPIO12"
6254 };
6255 (HSPIQ $(, $_fallback:literal)?) => {
6256 "GPIO12"
6257 };
6258 (SD2_DATA2 $(, $_fallback:literal)?) => {
6259 "GPIO12"
6260 };
6261 (EMAC_TXD3 $(, $_fallback:literal)?) => {
6262 "GPIO12"
6263 };
6264 (ADC2_CH5 $(, $_fallback:literal)?) => {
6265 "GPIO12"
6266 };
6267 (TOUCH5 $(, $_fallback:literal)?) => {
6268 "GPIO12"
6269 };
6270 (LP_GPIO15 $(, $_fallback:literal)?) => {
6271 "GPIO12"
6272 };
6273 (MTCK $(, $_fallback:literal)?) => {
6274 "GPIO13"
6275 };
6276 (HSPID $(, $_fallback:literal)?) => {
6277 "GPIO13"
6278 };
6279 (SD2_DATA3 $(, $_fallback:literal)?) => {
6280 "GPIO13"
6281 };
6282 (EMAC_RXER $(, $_fallback:literal)?) => {
6283 "GPIO13"
6284 };
6285 (ADC2_CH4 $(, $_fallback:literal)?) => {
6286 "GPIO13"
6287 };
6288 (TOUCH4 $(, $_fallback:literal)?) => {
6289 "GPIO13"
6290 };
6291 (LP_GPIO14 $(, $_fallback:literal)?) => {
6292 "GPIO13"
6293 };
6294 (MTMS $(, $_fallback:literal)?) => {
6295 "GPIO14"
6296 };
6297 (HSPICLK $(, $_fallback:literal)?) => {
6298 "GPIO14"
6299 };
6300 (SD2_CLK $(, $_fallback:literal)?) => {
6301 "GPIO14"
6302 };
6303 (EMAC_TXD2 $(, $_fallback:literal)?) => {
6304 "GPIO14"
6305 };
6306 (ADC2_CH6 $(, $_fallback:literal)?) => {
6307 "GPIO14"
6308 };
6309 (TOUCH6 $(, $_fallback:literal)?) => {
6310 "GPIO14"
6311 };
6312 (LP_GPIO16 $(, $_fallback:literal)?) => {
6313 "GPIO14"
6314 };
6315 (MTDO $(, $_fallback:literal)?) => {
6316 "GPIO15"
6317 };
6318 (HSPICS0 $(, $_fallback:literal)?) => {
6319 "GPIO15"
6320 };
6321 (SD2_CMD $(, $_fallback:literal)?) => {
6322 "GPIO15"
6323 };
6324 (EMAC_RXD3 $(, $_fallback:literal)?) => {
6325 "GPIO15"
6326 };
6327 (ADC2_CH3 $(, $_fallback:literal)?) => {
6328 "GPIO15"
6329 };
6330 (TOUCH3 $(, $_fallback:literal)?) => {
6331 "GPIO15"
6332 };
6333 (LP_GPIO13 $(, $_fallback:literal)?) => {
6334 "GPIO15"
6335 };
6336 (SD1_DATA4 $(, $_fallback:literal)?) => {
6337 "GPIO16"
6338 };
6339 (U2RXD $(, $_fallback:literal)?) => {
6340 "GPIO16"
6341 };
6342 (EMAC_CLK_OUT $(, $_fallback:literal)?) => {
6343 "GPIO16"
6344 };
6345 (SD1_DATA5 $(, $_fallback:literal)?) => {
6346 "GPIO17"
6347 };
6348 (U2TXD $(, $_fallback:literal)?) => {
6349 "GPIO17"
6350 };
6351 (EMAC_CLK_180 $(, $_fallback:literal)?) => {
6352 "GPIO17"
6353 };
6354 (VSPICLK $(, $_fallback:literal)?) => {
6355 "GPIO18"
6356 };
6357 (SD1_DATA7 $(, $_fallback:literal)?) => {
6358 "GPIO18"
6359 };
6360 (VSPIQ $(, $_fallback:literal)?) => {
6361 "GPIO19"
6362 };
6363 (U0CTS $(, $_fallback:literal)?) => {
6364 "GPIO19"
6365 };
6366 (EMAC_TXD0 $(, $_fallback:literal)?) => {
6367 "GPIO19"
6368 };
6369 (VSPIHD $(, $_fallback:literal)?) => {
6370 "GPIO21"
6371 };
6372 (EMAC_TXEN $(, $_fallback:literal)?) => {
6373 "GPIO21"
6374 };
6375 (VSPIWP $(, $_fallback:literal)?) => {
6376 "GPIO22"
6377 };
6378 (U0RTS $(, $_fallback:literal)?) => {
6379 "GPIO22"
6380 };
6381 (EMAC_TXD1 $(, $_fallback:literal)?) => {
6382 "GPIO22"
6383 };
6384 (VSPID $(, $_fallback:literal)?) => {
6385 "GPIO23"
6386 };
6387 (SD1_STROBE $(, $_fallback:literal)?) => {
6388 "GPIO23"
6389 };
6390 (EMAC_RXD0 $(, $_fallback:literal)?) => {
6391 "GPIO25"
6392 };
6393 (DAC1 $(, $_fallback:literal)?) => {
6394 "GPIO25"
6395 };
6396 (ADC2_CH8 $(, $_fallback:literal)?) => {
6397 "GPIO25"
6398 };
6399 (LP_GPIO6 $(, $_fallback:literal)?) => {
6400 "GPIO25"
6401 };
6402 (EMAC_RXD1 $(, $_fallback:literal)?) => {
6403 "GPIO26"
6404 };
6405 (DAC2 $(, $_fallback:literal)?) => {
6406 "GPIO26"
6407 };
6408 (ADC2_CH9 $(, $_fallback:literal)?) => {
6409 "GPIO26"
6410 };
6411 (LP_GPIO7 $(, $_fallback:literal)?) => {
6412 "GPIO26"
6413 };
6414 (EMAC_RXDV $(, $_fallback:literal)?) => {
6415 "GPIO27"
6416 };
6417 (ADC2_CH7 $(, $_fallback:literal)?) => {
6418 "GPIO27"
6419 };
6420 (TOUCH7 $(, $_fallback:literal)?) => {
6421 "GPIO27"
6422 };
6423 (LP_GPIO17 $(, $_fallback:literal)?) => {
6424 "GPIO27"
6425 };
6426 (XTAL_32K_P $(, $_fallback:literal)?) => {
6427 "GPIO32"
6428 };
6429 (ADC1_CH4 $(, $_fallback:literal)?) => {
6430 "GPIO32"
6431 };
6432 (TOUCH9 $(, $_fallback:literal)?) => {
6433 "GPIO32"
6434 };
6435 (LP_GPIO9 $(, $_fallback:literal)?) => {
6436 "GPIO32"
6437 };
6438 (XTAL_32K_N $(, $_fallback:literal)?) => {
6439 "GPIO33"
6440 };
6441 (ADC1_CH5 $(, $_fallback:literal)?) => {
6442 "GPIO33"
6443 };
6444 (TOUCH8 $(, $_fallback:literal)?) => {
6445 "GPIO33"
6446 };
6447 (LP_GPIO8 $(, $_fallback:literal)?) => {
6448 "GPIO33"
6449 };
6450 (ADC1_CH6 $(, $_fallback:literal)?) => {
6451 "GPIO34"
6452 };
6453 (LP_GPIO4 $(, $_fallback:literal)?) => {
6454 "GPIO34"
6455 };
6456 (ADC1_CH7 $(, $_fallback:literal)?) => {
6457 "GPIO35"
6458 };
6459 (LP_GPIO5 $(, $_fallback:literal)?) => {
6460 "GPIO35"
6461 };
6462 (ADC_H $(, $_fallback:literal)?) => {
6463 "GPIO36"
6464 };
6465 (ADC1_CH0 $(, $_fallback:literal)?) => {
6466 "GPIO36"
6467 };
6468 (LP_GPIO0 $(, $_fallback:literal)?) => {
6469 "GPIO36"
6470 };
6471 (ADC1_CH1 $(, $_fallback:literal)?) => {
6472 "GPIO37"
6473 };
6474 (LP_GPIO1 $(, $_fallback:literal)?) => {
6475 "GPIO37"
6476 };
6477 (ADC1_CH2 $(, $_fallback:literal)?) => {
6478 "GPIO38"
6479 };
6480 (LP_GPIO2 $(, $_fallback:literal)?) => {
6481 "GPIO38"
6482 };
6483 (ADC1_CH3 $(, $_fallback:literal)?) => {
6484 "GPIO39"
6485 };
6486 (LP_GPIO3 $(, $_fallback:literal)?) => {
6487 "GPIO39"
6488 };
6489 ($_signal:ident, $fallback:literal) => {
6490 $fallback
6491 };
6492}
6493#[macro_export]
6497#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6498macro_rules! define_io_mux_signals {
6499 () => {
6500 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
6501 #[derive(Debug, PartialEq, Copy, Clone)]
6502 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6503 #[doc(hidden)]
6504 pub enum InputSignal {
6505 SPICLK = 0,
6506 SPIQ = 1,
6507 SPID = 2,
6508 SPIHD = 3,
6509 SPIWP = 4,
6510 SPICS0 = 5,
6511 SPICS1 = 6,
6512 SPICS2 = 7,
6513 HSPICLK = 8,
6514 HSPIQ = 9,
6515 HSPID = 10,
6516 HSPICS0 = 11,
6517 HSPIHD = 12,
6518 HSPIWP = 13,
6519 U0RXD = 14,
6520 U0CTS = 15,
6521 U0DSR = 16,
6522 U1RXD = 17,
6523 U1CTS = 18,
6524 I2S0O_BCK = 23,
6525 I2S1O_BCK = 24,
6526 I2S0O_WS = 25,
6527 I2S1O_WS = 26,
6528 I2S0I_BCK = 27,
6529 I2S0I_WS = 28,
6530 I2CEXT0_SCL = 29,
6531 I2CEXT0_SDA = 30,
6532 PWM0_SYNC0 = 31,
6533 PWM0_SYNC1 = 32,
6534 PWM0_SYNC2 = 33,
6535 PWM0_F0 = 34,
6536 PWM0_F1 = 35,
6537 PWM0_F2 = 36,
6538 PCNT0_SIG_CH0 = 39,
6539 PCNT0_SIG_CH1 = 40,
6540 PCNT0_CTRL_CH0 = 41,
6541 PCNT0_CTRL_CH1 = 42,
6542 PCNT1_SIG_CH0 = 43,
6543 PCNT1_SIG_CH1 = 44,
6544 PCNT1_CTRL_CH0 = 45,
6545 PCNT1_CTRL_CH1 = 46,
6546 PCNT2_SIG_CH0 = 47,
6547 PCNT2_SIG_CH1 = 48,
6548 PCNT2_CTRL_CH0 = 49,
6549 PCNT2_CTRL_CH1 = 50,
6550 PCNT3_SIG_CH0 = 51,
6551 PCNT3_SIG_CH1 = 52,
6552 PCNT3_CTRL_CH0 = 53,
6553 PCNT3_CTRL_CH1 = 54,
6554 PCNT4_SIG_CH0 = 55,
6555 PCNT4_SIG_CH1 = 56,
6556 PCNT4_CTRL_CH0 = 57,
6557 PCNT4_CTRL_CH1 = 58,
6558 HSPICS1 = 61,
6559 HSPICS2 = 62,
6560 VSPICLK = 63,
6561 VSPIQ = 64,
6562 VSPID = 65,
6563 VSPIHD = 66,
6564 VSPIWP = 67,
6565 VSPICS0 = 68,
6566 VSPICS1 = 69,
6567 VSPICS2 = 70,
6568 PCNT5_SIG_CH0 = 71,
6569 PCNT5_SIG_CH1 = 72,
6570 PCNT5_CTRL_CH0 = 73,
6571 PCNT5_CTRL_CH1 = 74,
6572 PCNT6_SIG_CH0 = 75,
6573 PCNT6_SIG_CH1 = 76,
6574 PCNT6_CTRL_CH0 = 77,
6575 PCNT6_CTRL_CH1 = 78,
6576 PCNT7_SIG_CH0 = 79,
6577 PCNT7_SIG_CH1 = 80,
6578 PCNT7_CTRL_CH0 = 81,
6579 PCNT7_CTRL_CH1 = 82,
6580 RMT_SIG_0 = 83,
6581 RMT_SIG_1 = 84,
6582 RMT_SIG_2 = 85,
6583 RMT_SIG_3 = 86,
6584 RMT_SIG_4 = 87,
6585 RMT_SIG_5 = 88,
6586 RMT_SIG_6 = 89,
6587 RMT_SIG_7 = 90,
6588 TWAI_RX = 94,
6589 I2CEXT1_SCL = 95,
6590 I2CEXT1_SDA = 96,
6591 HOST_CARD_DETECT_N_1 = 97,
6592 HOST_CARD_DETECT_N_2 = 98,
6593 HOST_CARD_WRITE_PRT_1 = 99,
6594 HOST_CARD_WRITE_PRT_2 = 100,
6595 HOST_CARD_INT_N_1 = 101,
6596 HOST_CARD_INT_N_2 = 102,
6597 PWM1_SYNC0 = 103,
6598 PWM1_SYNC1 = 104,
6599 PWM1_SYNC2 = 105,
6600 PWM1_F0 = 106,
6601 PWM1_F1 = 107,
6602 PWM1_F2 = 108,
6603 PWM0_CAP0 = 109,
6604 PWM0_CAP1 = 110,
6605 PWM0_CAP2 = 111,
6606 PWM1_CAP0 = 112,
6607 PWM1_CAP1 = 113,
6608 PWM1_CAP2 = 114,
6609 I2S0I_DATA_0 = 140,
6610 I2S0I_DATA_1 = 141,
6611 I2S0I_DATA_2 = 142,
6612 I2S0I_DATA_3 = 143,
6613 I2S0I_DATA_4 = 144,
6614 I2S0I_DATA_5 = 145,
6615 I2S0I_DATA_6 = 146,
6616 I2S0I_DATA_7 = 147,
6617 I2S0I_DATA_8 = 148,
6618 I2S0I_DATA_9 = 149,
6619 I2S0I_DATA_10 = 150,
6620 I2S0I_DATA_11 = 151,
6621 I2S0I_DATA_12 = 152,
6622 I2S0I_DATA_13 = 153,
6623 I2S0I_DATA_14 = 154,
6624 I2S0I_DATA_15 = 155,
6625 I2S1I_BCK = 164,
6626 I2S1I_WS = 165,
6627 I2S1I_DATA_0 = 166,
6628 I2S1I_DATA_1 = 167,
6629 I2S1I_DATA_2 = 168,
6630 I2S1I_DATA_3 = 169,
6631 I2S1I_DATA_4 = 170,
6632 I2S1I_DATA_5 = 171,
6633 I2S1I_DATA_6 = 172,
6634 I2S1I_DATA_7 = 173,
6635 I2S1I_DATA_8 = 174,
6636 I2S1I_DATA_9 = 175,
6637 I2S1I_DATA_10 = 176,
6638 I2S1I_DATA_11 = 177,
6639 I2S1I_DATA_12 = 178,
6640 I2S1I_DATA_13 = 179,
6641 I2S1I_DATA_14 = 180,
6642 I2S1I_DATA_15 = 181,
6643 I2S0I_H_SYNC = 190,
6644 I2S0I_V_SYNC = 191,
6645 I2S0I_H_ENABLE = 192,
6646 I2S1I_H_SYNC = 193,
6647 I2S1I_V_SYNC = 194,
6648 I2S1I_H_ENABLE = 195,
6649 U2RXD = 198,
6650 U2CTS = 199,
6651 EMAC_MDC = 200,
6652 EMAC_MDI = 201,
6653 EMAC_CRS = 202,
6654 EMAC_COL = 203,
6655 PCMFSYNC = 204,
6656 PCMCLK = 205,
6657 PCMDIN = 206,
6658 SD_CMD,
6659 SD_DATA0,
6660 SD_DATA1,
6661 SD_DATA2,
6662 SD_DATA3,
6663 SD1_DATA0,
6664 SD1_DATA1,
6665 SD1_DATA2,
6666 SD1_DATA3,
6667 SD1_DATA4,
6668 SD1_DATA5,
6669 SD1_DATA6,
6670 SD1_DATA7,
6671 SD2_DATA0,
6672 SD2_DATA1,
6673 SD2_DATA2,
6674 SD2_DATA3,
6675 EMAC_TX_CLK,
6676 EMAC_RXD2,
6677 EMAC_TXER,
6678 EMAC_RX_CLK,
6679 EMAC_RXER,
6680 EMAC_RXD3,
6681 EMAC_RXD0,
6682 EMAC_RXD1,
6683 EMAC_RXDV,
6684 MTDI,
6685 MTCK,
6686 MTMS,
6687 }
6688 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
6689 #[derive(Debug, PartialEq, Copy, Clone)]
6690 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6691 #[doc(hidden)]
6692 pub enum OutputSignal {
6693 SPICLK = 0,
6694 SPIQ = 1,
6695 SPID = 2,
6696 SPIHD = 3,
6697 SPIWP = 4,
6698 SPICS0 = 5,
6699 SPICS1 = 6,
6700 SPICS2 = 7,
6701 HSPICLK = 8,
6702 HSPIQ = 9,
6703 HSPID = 10,
6704 HSPICS0 = 11,
6705 HSPIHD = 12,
6706 HSPIWP = 13,
6707 U0TXD = 14,
6708 U0RTS = 15,
6709 U0DTR = 16,
6710 U1TXD = 17,
6711 U1RTS = 18,
6712 I2S0O_BCK = 23,
6713 I2S1O_BCK = 24,
6714 I2S0O_WS = 25,
6715 I2S1O_WS = 26,
6716 I2S0I_BCK = 27,
6717 I2S0I_WS = 28,
6718 I2CEXT0_SCL = 29,
6719 I2CEXT0_SDA = 30,
6720 SDIO_TOHOST_INT = 31,
6721 PWM0_0A = 32,
6722 PWM0_0B = 33,
6723 PWM0_1A = 34,
6724 PWM0_1B = 35,
6725 PWM0_2A = 36,
6726 PWM0_2B = 37,
6727 HSPICS1 = 61,
6728 HSPICS2 = 62,
6729 VSPICLK = 63,
6730 VSPIQ = 64,
6731 VSPID = 65,
6732 VSPIHD = 66,
6733 VSPIWP = 67,
6734 VSPICS0 = 68,
6735 VSPICS1 = 69,
6736 VSPICS2 = 70,
6737 LEDC_HS_SIG0 = 71,
6738 LEDC_HS_SIG1 = 72,
6739 LEDC_HS_SIG2 = 73,
6740 LEDC_HS_SIG3 = 74,
6741 LEDC_HS_SIG4 = 75,
6742 LEDC_HS_SIG5 = 76,
6743 LEDC_HS_SIG6 = 77,
6744 LEDC_HS_SIG7 = 78,
6745 LEDC_LS_SIG0 = 79,
6746 LEDC_LS_SIG1 = 80,
6747 LEDC_LS_SIG2 = 81,
6748 LEDC_LS_SIG3 = 82,
6749 LEDC_LS_SIG4 = 83,
6750 LEDC_LS_SIG5 = 84,
6751 LEDC_LS_SIG6 = 85,
6752 LEDC_LS_SIG7 = 86,
6753 RMT_SIG_0 = 87,
6754 RMT_SIG_1 = 88,
6755 RMT_SIG_2 = 89,
6756 RMT_SIG_3 = 90,
6757 RMT_SIG_4 = 91,
6758 RMT_SIG_5 = 92,
6759 RMT_SIG_6 = 93,
6760 RMT_SIG_7 = 94,
6761 I2CEXT1_SCL = 95,
6762 I2CEXT1_SDA = 96,
6763 HOST_CCMD_OD_PULLUP_EN_N = 97,
6764 HOST_RST_N_1 = 98,
6765 HOST_RST_N_2 = 99,
6766 GPIO_SD0 = 100,
6767 GPIO_SD1 = 101,
6768 GPIO_SD2 = 102,
6769 GPIO_SD3 = 103,
6770 GPIO_SD4 = 104,
6771 GPIO_SD5 = 105,
6772 GPIO_SD6 = 106,
6773 GPIO_SD7 = 107,
6774 PWM1_0A = 108,
6775 PWM1_0B = 109,
6776 PWM1_1A = 110,
6777 PWM1_1B = 111,
6778 PWM1_2A = 112,
6779 PWM1_2B = 113,
6780 TWAI_TX = 123,
6781 TWAI_BUS_OFF_ON = 124,
6782 TWAI_CLKOUT = 125,
6783 I2S0O_DATA_0 = 140,
6784 I2S0O_DATA_1 = 141,
6785 I2S0O_DATA_2 = 142,
6786 I2S0O_DATA_3 = 143,
6787 I2S0O_DATA_4 = 144,
6788 I2S0O_DATA_5 = 145,
6789 I2S0O_DATA_6 = 146,
6790 I2S0O_DATA_7 = 147,
6791 I2S0O_DATA_8 = 148,
6792 I2S0O_DATA_9 = 149,
6793 I2S0O_DATA_10 = 150,
6794 I2S0O_DATA_11 = 151,
6795 I2S0O_DATA_12 = 152,
6796 I2S0O_DATA_13 = 153,
6797 I2S0O_DATA_14 = 154,
6798 I2S0O_DATA_15 = 155,
6799 I2S0O_DATA_16 = 156,
6800 I2S0O_DATA_17 = 157,
6801 I2S0O_DATA_18 = 158,
6802 I2S0O_DATA_19 = 159,
6803 I2S0O_DATA_20 = 160,
6804 I2S0O_DATA_21 = 161,
6805 I2S0O_DATA_22 = 162,
6806 I2S0O_DATA_23 = 163,
6807 I2S1I_BCK = 164,
6808 I2S1I_WS = 165,
6809 I2S1O_DATA_0 = 166,
6810 I2S1O_DATA_1 = 167,
6811 I2S1O_DATA_2 = 168,
6812 I2S1O_DATA_3 = 169,
6813 I2S1O_DATA_4 = 170,
6814 I2S1O_DATA_5 = 171,
6815 I2S1O_DATA_6 = 172,
6816 I2S1O_DATA_7 = 173,
6817 I2S1O_DATA_8 = 174,
6818 I2S1O_DATA_9 = 175,
6819 I2S1O_DATA_10 = 176,
6820 I2S1O_DATA_11 = 177,
6821 I2S1O_DATA_12 = 178,
6822 I2S1O_DATA_13 = 179,
6823 I2S1O_DATA_14 = 180,
6824 I2S1O_DATA_15 = 181,
6825 I2S1O_DATA_16 = 182,
6826 I2S1O_DATA_17 = 183,
6827 I2S1O_DATA_18 = 184,
6828 I2S1O_DATA_19 = 185,
6829 I2S1O_DATA_20 = 186,
6830 I2S1O_DATA_21 = 187,
6831 I2S1O_DATA_22 = 188,
6832 I2S1O_DATA_23 = 189,
6833 U2TXD = 198,
6834 U2RTS = 199,
6835 EMAC_MDC = 200,
6836 EMAC_MDO = 201,
6837 EMAC_CRS = 202,
6838 EMAC_COL = 203,
6839 BT_AUDIO0RQ = 204,
6840 BT_AUDIO1RQ = 205,
6841 BT_AUDIO2RQ = 206,
6842 BLE_AUDIO0RQ = 207,
6843 BLE_AUDIO1RQ = 208,
6844 BLE_AUDIO2RQ = 209,
6845 PCMFSYNC = 210,
6846 PCMCLK = 211,
6847 PCMDOUT = 212,
6848 BLE_AUDIO_SYNC0_P = 213,
6849 BLE_AUDIO_SYNC1_P = 214,
6850 BLE_AUDIO_SYNC2_P = 215,
6851 ANT_SEL0 = 216,
6852 ANT_SEL1 = 217,
6853 ANT_SEL2 = 218,
6854 ANT_SEL3 = 219,
6855 ANT_SEL4 = 220,
6856 ANT_SEL5 = 221,
6857 ANT_SEL6 = 222,
6858 ANT_SEL7 = 223,
6859 SIGNAL_224 = 224,
6860 SIGNAL_225 = 225,
6861 SIGNAL_226 = 226,
6862 SIGNAL_227 = 227,
6863 SIGNAL_228 = 228,
6864 GPIO = 256,
6865 CLK_OUT1,
6866 CLK_OUT2,
6867 CLK_OUT3,
6868 SD_CLK,
6869 SD_CMD,
6870 SD_DATA0,
6871 SD_DATA1,
6872 SD_DATA2,
6873 SD_DATA3,
6874 SD1_CLK,
6875 SD1_CMD,
6876 SD1_DATA0,
6877 SD1_DATA1,
6878 SD1_DATA2,
6879 SD1_DATA3,
6880 SD1_DATA4,
6881 SD1_DATA5,
6882 SD1_DATA6,
6883 SD1_DATA7,
6884 SD1_STROBE,
6885 SD2_CLK,
6886 SD2_CMD,
6887 SD2_DATA0,
6888 SD2_DATA1,
6889 SD2_DATA2,
6890 SD2_DATA3,
6891 EMAC_TX_CLK,
6892 EMAC_TXER,
6893 EMAC_TXD3,
6894 EMAC_RXER,
6895 EMAC_TXD2,
6896 EMAC_CLK_OUT,
6897 EMAC_CLK_180,
6898 EMAC_TXD0,
6899 EMAC_TXEN,
6900 EMAC_TXD1,
6901 MTDO,
6902 }
6903 };
6904}
6905#[macro_export]
6912#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6913macro_rules! define_lp_functions {
6914 () => {
6915 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
6920 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6921 #[doc(hidden)]
6922 pub enum LpFunction {
6923 _0 = 0,
6925 _3 = 3,
6927 }
6928 impl LpFunction {
6929 pub const LP_GPIO: Self = Self::_0;
6931 }
6932 };
6933}
6934#[macro_export]
6947#[expect(clippy::crate_in_macro_def)]
6948#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6949macro_rules! define_io_mux_reg {
6950 () => {
6951 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
6952 let iomux = crate::peripherals::IO_MUX::regs();
6953 match gpio_num {
6954 0 => iomux.gpio0(),
6955 1 => iomux.gpio1(),
6956 2 => iomux.gpio2(),
6957 3 => iomux.gpio3(),
6958 4 => iomux.gpio4(),
6959 5 => iomux.gpio5(),
6960 6 => iomux.gpio6(),
6961 7 => iomux.gpio7(),
6962 8 => iomux.gpio8(),
6963 9 => iomux.gpio9(),
6964 10 => iomux.gpio10(),
6965 11 => iomux.gpio11(),
6966 12 => iomux.gpio12(),
6967 13 => iomux.gpio13(),
6968 14 => iomux.gpio14(),
6969 15 => iomux.gpio15(),
6970 16 => iomux.gpio16(),
6971 17 => iomux.gpio17(),
6972 18 => iomux.gpio18(),
6973 19 => iomux.gpio19(),
6974 20 => iomux.gpio20(),
6975 21 => iomux.gpio21(),
6976 22 => iomux.gpio22(),
6977 23 => iomux.gpio23(),
6978 25 => iomux.gpio25(),
6979 26 => iomux.gpio26(),
6980 27 => iomux.gpio27(),
6981 32 => iomux.gpio32(),
6982 33 => iomux.gpio33(),
6983 34 => iomux.gpio34(),
6984 35 => iomux.gpio35(),
6985 36 => iomux.gpio36(),
6986 37 => iomux.gpio37(),
6987 38 => iomux.gpio38(),
6988 39 => iomux.gpio39(),
6989 other => panic!("GPIO {} does not exist", other),
6990 }
6991 }
6992 };
6993}