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