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 "esp32c6"
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-C6"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32c6"
42 };
43 ("arch") => {
44 "riscv"
45 };
46 ("cores") => {
47 1
48 };
49 ("cores", str) => {
50 stringify!(1)
51 };
52 ("trm") => {
53 "https://www.espressif.com/sites/default/files/documentation/esp32-c6_technical_reference_manual_en.pdf"
54 };
55 ("gpio.version") => {
56 2
57 };
58 ("gpio.version", str) => {
59 stringify!(2)
60 };
61 ("gpio.has_input_sync") => {
62 true
63 };
64 ("gpio.gpio_function") => {
65 1
66 };
67 ("gpio.gpio_function", str) => {
68 stringify!(1)
69 };
70 ("gpio.constant_0_input") => {
71 60
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(60)
75 };
76 ("gpio.constant_1_input") => {
77 56
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(56)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 false
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.need_soft_isolate_during_pd") => {
92 false
93 };
94 ("gpio.has_bank_1") => {
95 false
96 };
97 ("gpio.input_signal_max") => {
98 124
99 };
100 ("gpio.input_signal_max", str) => {
101 stringify!(124)
102 };
103 ("gpio.output_signal_max") => {
104 128
105 };
106 ("gpio.output_signal_max", str) => {
107 stringify!(128)
108 };
109 ("dedicated_gpio.version") => {
110 "riscv_v1"
111 };
112 ("dedicated_gpio.needs_initialization") => {
113 false
114 };
115 ("dedicated_gpio.channel_count") => {
116 8
117 };
118 ("dedicated_gpio.channel_count", str) => {
119 stringify!(8)
120 };
121 ("lp_io.version") => {
122 "v4"
123 };
124 ("lp_io.has_gpio_matrix") => {
125 false
126 };
127 ("uart.ram_size") => {
128 128
129 };
130 ("uart.ram_size", str) => {
131 stringify!(128)
132 };
133 ("uart.version") => {
134 2
135 };
136 ("uart.version", str) => {
137 stringify!(2)
138 };
139 ("uart.peripheral_controls_mem_clk") => {
140 true
141 };
142 ("uart.has_sclk_divider") => {
143 false
144 };
145 ("uart.has_sclk_enable") => {
146 true
147 };
148 ("lp_uart.ram_size") => {
149 32
150 };
151 ("lp_uart.ram_size", str) => {
152 stringify!(32)
153 };
154 ("uhci.combined_uart_selector_field") => {
155 false
156 };
157 ("i2c_master.version") => {
158 4
159 };
160 ("i2c_master.version", str) => {
161 stringify!(4)
162 };
163 ("i2c_master.has_fsm_timeouts") => {
164 true
165 };
166 ("i2c_master.has_hw_bus_clear") => {
167 true
168 };
169 ("i2c_master.has_bus_timeout_enable") => {
170 true
171 };
172 ("i2c_master.separate_filter_config_registers") => {
173 false
174 };
175 ("i2c_master.can_estimate_nack_reason") => {
176 true
177 };
178 ("i2c_master.has_conf_update") => {
179 true
180 };
181 ("i2c_master.has_reliable_fsm_reset") => {
182 true
183 };
184 ("i2c_master.has_arbitration_en") => {
185 true
186 };
187 ("i2c_master.has_tx_fifo_watermark") => {
188 true
189 };
190 ("i2c_master.bus_timeout_is_exponential") => {
191 true
192 };
193 ("i2c_master.has_pd_en") => {
194 true
195 };
196 ("i2c_master.max_bus_timeout") => {
197 31
198 };
199 ("i2c_master.max_bus_timeout", str) => {
200 stringify!(31)
201 };
202 ("i2c_master.ll_intr_mask") => {
203 262143
204 };
205 ("i2c_master.ll_intr_mask", str) => {
206 stringify!(262143)
207 };
208 ("i2c_master.fifo_size") => {
209 32
210 };
211 ("i2c_master.fifo_size", str) => {
212 stringify!(32)
213 };
214 ("lp_i2c_master.version") => {
215 "lp_i2c"
216 };
217 ("lp_i2c_master.fifo_size") => {
218 16
219 };
220 ("lp_i2c_master.fifo_size", str) => {
221 stringify!(16)
222 };
223 ("spi_master.version") => {
224 3
225 };
226 ("spi_master.version", str) => {
227 stringify!(3)
228 };
229 ("spi_master.fifo_size") => {
230 64
231 };
232 ("spi_master.fifo_size", str) => {
233 stringify!(64)
234 };
235 ("spi_master.bit_order_is_bool") => {
236 false
237 };
238 ("spi_master.has_octal") => {
239 false
240 };
241 ("spi_master.has_app_interrupts") => {
242 true
243 };
244 ("spi_master.has_dma_segmented_transfer") => {
245 true
246 };
247 ("spi_master.has_clk_pre_div") => {
248 false
249 };
250 ("spi_master.dma_can_access_flash") => {
251 false
252 };
253 ("i2s.version") => {
254 2
255 };
256 ("i2s.version", str) => {
257 stringify!(2)
258 };
259 ("i2s.mclk_divider_bit_width") => {
260 9
261 };
262 ("i2s.mclk_divider_bit_width", str) => {
263 stringify!(9)
264 };
265 ("i2s.max_ws_width") => {
266 128
267 };
268 ("i2s.max_ws_width", str) => {
269 stringify!(128)
270 };
271 ("i2s.clock_configured_by_pcr") => {
272 true
273 };
274 ("i2s.clock_configured_by_hp_sys_clkrst") => {
275 false
276 };
277 ("i2s.supports_pdm_rx_hp_filter") => {
278 false
279 };
280 ("i2s.supports_pdm_tx") => {
281 true
282 };
283 ("i2s.supports_pdm_rx") => {
284 true
285 };
286 ("i2s.supports_pcm2pdm") => {
287 true
288 };
289 ("i2s.supports_pdm2pcm") => {
290 false
291 };
292 ("parl_io.version") => {
293 1
294 };
295 ("parl_io.version", str) => {
296 stringify!(1)
297 };
298 ("parl_io.max_data_width") => {
299 16
300 };
301 ("parl_io.max_data_width", str) => {
302 stringify!(16)
303 };
304 ("parl_io.has_tx_cs") => {
305 false
306 };
307 ("rmt.ram_start") => {
308 1610638336
309 };
310 ("rmt.ram_start", str) => {
311 stringify!(1610638336)
312 };
313 ("rmt.channel_ram_size") => {
314 48
315 };
316 ("rmt.channel_ram_size", str) => {
317 stringify!(48)
318 };
319 ("rmt.has_tx_immediate_stop") => {
320 true
321 };
322 ("rmt.has_tx_loop_count") => {
323 true
324 };
325 ("rmt.has_tx_loop_auto_stop") => {
326 true
327 };
328 ("rmt.has_tx_carrier_data_only") => {
329 true
330 };
331 ("rmt.has_tx_sync") => {
332 true
333 };
334 ("rmt.has_rx_wrap") => {
335 true
336 };
337 ("rmt.has_rx_demodulation") => {
338 true
339 };
340 ("rmt.has_per_channel_clock") => {
341 false
342 };
343 ("bt.controller") => {
344 "npl"
345 };
346 ("bt.requires_fast_cpu") => {
347 true
348 };
349 ("wifi.has_wifi6") => {
350 true
351 };
352 ("wifi.mac_version") => {
353 2
354 };
355 ("wifi.mac_version", str) => {
356 stringify!(2)
357 };
358 ("wifi.has_5g") => {
359 false
360 };
361 ("wifi.csi_supported") => {
362 true
363 };
364 ("wifi.has_nan") => {
365 false
366 };
367 ("wifi.has_ftm") => {
368 true
369 };
370 ("wifi.requires_fast_cpu") => {
371 true
372 };
373 ("ieee802154.requires_fast_cpu") => {
374 true
375 };
376 ("phy.combo_module") => {
377 true
378 };
379 ("adc.controller") => {
380 "digital"
381 };
382 ("adc.channel_count") => {
383 7
384 };
385 ("adc.channel_count", str) => {
386 stringify!(7)
387 };
388 ("adc.line_calibration") => {
389 true
390 };
391 ("adc.curve_calibration") => {
392 true
393 };
394 ("adc.basic_calibration") => {
395 true
396 };
397 ("adc.calibration_v1_scheme_supported") => {
398 true
399 };
400 ("adc.channel_compensation") => {
401 true
402 };
403 ("adc.pcr_clock") => {
404 true
405 };
406 ("adc.pcr_sar_clk_div") => {
407 false
408 };
409 ("adc.sar_power_override") => {
410 true
411 };
412 ("ledc.version") => {
413 3
414 };
415 ("ledc.version", str) => {
416 stringify!(3)
417 };
418 ("ledc.channel_count") => {
419 6
420 };
421 ("ledc.channel_count", str) => {
422 stringify!(6)
423 };
424 ("sdm.channel_count") => {
425 4
426 };
427 ("sdm.channel_count", str) => {
428 stringify!(4)
429 };
430 ("timergroup.timg_has_timer1") => {
431 false
432 };
433 ("timergroup.timg_has_divcnt_rst") => {
434 true
435 };
436 ("timergroup.wdt_has_conf_update") => {
437 true
438 };
439 ("timergroup.rc_fast_calibration_divider_min_rev") => {
440 1
441 };
442 ("timergroup.rc_fast_calibration_divider") => {
443 32
444 };
445 ("timergroup.rc_fast_calibration_tick_enable") => {
446 false
447 };
448 ("aes.has_split_text_registers") => {
449 true
450 };
451 ("aes.endianness_configurable") => {
452 false
453 };
454 ("ecc.zero_extend_writes") => {
455 true
456 };
457 ("ecc.separate_jacobian_point_memory") => {
458 false
459 };
460 ("ecc.has_memory_clock_gate") => {
461 true
462 };
463 ("ecc.supports_enhanced_security") => {
464 false
465 };
466 ("ecc.mem_block_size") => {
467 32
468 };
469 ("rng.apb_cycle_wait_num") => {
470 16
471 };
472 ("rng.apb_cycle_wait_num", str) => {
473 stringify!(16)
474 };
475 ("rng.trng_supported") => {
476 true
477 };
478 ("rng.is_lp_sys") => {
479 true
480 };
481 ("rsa.version") => {
482 3
483 };
484 ("rsa.version", str) => {
485 stringify!(3)
486 };
487 ("rsa.size_increment") => {
488 32
489 };
490 ("rsa.size_increment", str) => {
491 stringify!(32)
492 };
493 ("rsa.memory_size_bytes") => {
494 384
495 };
496 ("rsa.memory_size_bytes", str) => {
497 stringify!(384)
498 };
499 ("sleep.light_sleep") => {
500 true
501 };
502 ("sleep.deep_sleep") => {
503 true
504 };
505 ("sleep.rejectable_mask") => {
506 3582
507 };
508 ("sleep.ext1_version") => {
509 2
510 };
511 ("sleep.ext1_version", str) => {
512 stringify!(2)
513 };
514 ("sleep.pin_wakeup_version") => {
515 3
516 };
517 ("sleep.pin_wakeup_version", str) => {
518 stringify!(3)
519 };
520 ("sleep.deep_sleep_needs_gpio_isolation") => {
521 false
522 };
523 ("sleep.idle_frequency_scaling") => {
524 true
525 };
526 ("assist_debug.has_sp_monitor") => {
527 true
528 };
529 ("assist_debug.has_region_monitor") => {
530 true
531 };
532 ("dma.mem2mem_requires_peripheral") => {
533 false
534 };
535 ("dma.ext_mem_configurable_block_size") => {
536 false
537 };
538 ("dma.separate_in_out_interrupts") => {
539 true
540 };
541 ("dma.gdma_version") => {
542 1
543 };
544 ("dma.gdma_version", str) => {
545 stringify!(1)
546 };
547 ("interrupts.status_registers") => {
548 3
549 };
550 ("interrupts.status_registers", str) => {
551 stringify!(3)
552 };
553 ("interrupts.disabled_interrupt") => {
554 31
555 };
556 ("mmu.page_size") => {
557 65536
558 };
559 ("mmu.page_size", str) => {
560 stringify!(65536)
561 };
562 ("mmu.entry_num") => {
563 256
564 };
565 ("mmu.entry_num", str) => {
566 stringify!(256)
567 };
568 ("rom.has_crc_le") => {
569 true
570 };
571 ("rom.has_crc_be") => {
572 true
573 };
574 ("rom.has_md5_bsd") => {
575 true
576 };
577 ("rom.has_md5_mbedtls") => {
578 false
579 };
580 ("rom.no_libgcc") => {
581 false
582 };
583 ("soc.cpu_has_branch_predictor") => {
584 false
585 };
586 ("soc.cpu_has_csr_pc") => {
587 true
588 };
589 ("soc.cpu_has_zcmp_workaround") => {
590 false
591 };
592 ("soc.multi_core_enabled") => {
593 false
594 };
595 ("soc.cpu_pma_needs_core1_setup") => {
596 false
597 };
598 ("soc.cpu_csr_prv_mode") => {
599 3088
600 };
601 ("soc.cpu_csr_prv_mode", str) => {
602 stringify!(3088)
603 };
604 ("soc.internal_memory_cached") => {
605 false
606 };
607 ("soc.cpu_powers_down_cache") => {
608 false
609 };
610 ("soc.has_swd_watchdog") => {
611 true
612 };
613 ("soc.has_bus_clock_update") => {
614 false
615 };
616 ("soc.has_apb_frequency_reduction") => {
617 true
618 };
619 ("soc.cpu_mcause_mask") => {
620 31
621 };
622 ("soc.cpu_mcause_mask", str) => {
623 stringify!(31)
624 };
625 ("soc.cpu_pmp_granularity") => {
626 4
627 };
628 ("soc.cpu_pmp_granularity", str) => {
629 stringify!(4)
630 };
631 ("clock_tree.soc_root_clk") => {
632 [crate ::soc::clocks::SocRootClkConfig::Xtal, crate
633 ::soc::clocks::SocRootClkConfig::RcFast, crate
634 ::soc::clocks::SocRootClkConfig::Pll]
635 };
636 ("clock_tree.hp_root_clk.divisor") => {
637 [1, 3]
638 };
639 ("clock_tree.cpu_hs_div.divisor") => {
640 [0, 1, 3]
641 };
642 ("clock_tree.cpu_ls_div.divisor") => {
643 [0, 1, 3, 7, 15, 31]
644 };
645 ("clock_tree.cpu_clk") => {
646 [crate ::soc::clocks::CpuClkConfig::Hs, crate ::soc::clocks::CpuClkConfig::Ls]
647 };
648 ("clock_tree.ahb_hs_div.divisor") => {
649 [3, 7, 15]
650 };
651 ("clock_tree.ahb_ls_div.divisor") => {
652 [0, 1, 3, 7, 15, 31]
653 };
654 ("clock_tree.ahb_clk") => {
655 [crate ::soc::clocks::AhbClkConfig::Hs, crate ::soc::clocks::AhbClkConfig::Ls]
656 };
657 ("clock_tree.apb_clk.divisor") => {
658 [0, 1, 3]
659 };
660 ("clock_tree.mspi_fast_hs_clk.divisor") => {
661 [3, 4, 5]
662 };
663 ("clock_tree.mspi_fast_ls_clk.divisor") => {
664 [0, 1, 2]
665 };
666 ("clock_tree.mspi_fast_clk") => {
667 [crate ::soc::clocks::MspiFastClkConfig::Hs, crate
668 ::soc::clocks::MspiFastClkConfig::Ls]
669 };
670 ("clock_tree.iomux_function_clock") => {
671 [crate ::soc::clocks::IomuxFunctionClockConfig::PllF80m, crate
672 ::soc::clocks::IomuxFunctionClockConfig::RcFastClk, crate
673 ::soc::clocks::IomuxFunctionClockConfig::XtalClk]
674 };
675 ("clock_tree.ledc_sclk") => {
676 [crate ::soc::clocks::LedcSclkConfig::PllF80m, crate
677 ::soc::clocks::LedcSclkConfig::RcFastClk, crate
678 ::soc::clocks::LedcSclkConfig::XtalClk]
679 };
680 ("clock_tree.lp_fast_clk") => {
681 [crate ::soc::clocks::LpFastClkConfig::RcFastClk, crate
682 ::soc::clocks::LpFastClkConfig::XtalD2Clk]
683 };
684 ("clock_tree.lp_slow_clk") => {
685 [#[cfg(use_xtal32k)] crate ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
686 ::soc::clocks::LpSlowClkConfig::RcSlow, crate
687 ::soc::clocks::LpSlowClkConfig::OscSlow]
688 };
689 ("clock_tree.ble_lp_clk") => {
690 [crate ::soc::clocks::BleLpClkConfig::Xtal, crate
691 ::soc::clocks::BleLpClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
692 ::soc::clocks::BleLpClkConfig::Xtal32k]
693 };
694 ("clock_tree.timg_calibration_clock") => {
695 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
696 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
697 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
698 };
699 ("clock_tree.uart.function_clock.sclk") => {
700 [crate ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
701 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
702 ::soc::clocks::UartFunctionClockSclk::Xtal]
703 };
704 ("clock_tree.uart.function_clock.div_num") => {
705 (0, 255)
706 };
707 ("clock_tree.uart.baud_rate_generator.fractional") => {
708 (0, 15)
709 };
710 ("clock_tree.uart.baud_rate_generator.integral") => {
711 (0, 4095)
712 };
713 ("clock_tree.rmt.sclk") => {
714 [crate ::soc::clocks::RmtSclkConfig::PllF80m, crate
715 ::soc::clocks::RmtSclkConfig::RcFastClk, crate
716 ::soc::clocks::RmtSclkConfig::XtalClk]
717 };
718 ("clock_tree.timg.function_clock") => {
719 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
720 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
721 ::soc::clocks::TimgFunctionClockConfig::PllF80m]
722 };
723 ("clock_tree.timg.wdt_clock") => {
724 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
725 ::soc::clocks::TimgWdtClockConfig::PllF80m, crate
726 ::soc::clocks::TimgWdtClockConfig::RcFastClk]
727 };
728 ("clock_tree.mcpwm.function_clock") => {
729 [crate ::soc::clocks::McpwmFunctionClockConfig::PllF160m, crate
730 ::soc::clocks::McpwmFunctionClockConfig::RcFastClk, crate
731 ::soc::clocks::McpwmFunctionClockConfig::XtalClk]
732 };
733 ("clock_tree.parl_io.rx_clock") => {
734 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
735 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
736 ::soc::clocks::ParlIoClkConfig::PllF240m]
737 };
738 ("clock_tree.parl_io.tx_clock") => {
739 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
740 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
741 ::soc::clocks::ParlIoClkConfig::PllF240m]
742 };
743 ("clock_tree.i2s.tx_clk.sclk") => {
744 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
745 ::soc::clocks::I2sClkSclk::PllF240m, crate ::soc::clocks::I2sClkSclk::PllF160m]
746 };
747 ("clock_tree.i2s.tx_clk.div_num") => {
748 (1, 255)
749 };
750 ("clock_tree.i2s.tx_clk.div_a") => {
751 (1, 511)
752 };
753 ("clock_tree.i2s.tx_clk.div_b") => {
754 (0, 511)
755 };
756 ("clock_tree.i2s.rx_clk.sclk") => {
757 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
758 ::soc::clocks::I2sClkSclk::PllF240m, crate ::soc::clocks::I2sClkSclk::PllF160m]
759 };
760 ("clock_tree.i2s.rx_clk.div_num") => {
761 (1, 255)
762 };
763 ("clock_tree.i2s.rx_clk.div_a") => {
764 (1, 511)
765 };
766 ("clock_tree.i2s.rx_clk.div_b") => {
767 (0, 511)
768 };
769 ("clock_tree.i2s.mclk_out") => {
770 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
771 ::soc::clocks::I2sMclkOutConfig::Rx]
772 };
773 ("clock_tree.i2c.function_clock.sclk") => {
774 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
775 ::soc::clocks::I2cFunctionClockSclk::RcFast]
776 };
777 ("clock_tree.i2c.function_clock.div_num") => {
778 (0, 255)
779 };
780 ("clock_tree.tsens.sclk") => {
781 [crate ::soc::clocks::TsensSclkConfig::RcFast, crate
782 ::soc::clocks::TsensSclkConfig::Xtal]
783 };
784 ("clock_tree.spi.function_clock") => {
785 [crate ::soc::clocks::SpiFunctionClockConfig::PllF80m, crate
786 ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
787 ::soc::clocks::SpiFunctionClockConfig::RcFast]
788 };
789 ("clock_tree.adc.function_clock") => {
790 [crate ::soc::clocks::AdcFunctionClockConfig::Xtal, crate
791 ::soc::clocks::AdcFunctionClockConfig::PllF80m, crate
792 ::soc::clocks::AdcFunctionClockConfig::RcFast]
793 };
794}
795#[macro_export]
796#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
797macro_rules! for_each_dedicated_gpio {
798 ($($pattern:tt => $code:tt;)*) => {
799 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
800 tt) => {} } _for_each_inner_dedicated_gpio!((0));
801 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
802 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
803 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
804 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
805 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
806 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
807 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
808 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
809 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
810 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
811 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
812 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
813 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
814 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
815 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
816 };
817}
818#[macro_export]
822#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
823macro_rules! define_lp_io_signals {
824 () => {};
825}
826#[macro_export]
848#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
849macro_rules! for_each_rmt_channel {
850 ($($pattern:tt => $code:tt;)*) => {
851 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
852 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
853 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
854 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
855 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
856 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
857 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
858 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
859 };
860}
861#[macro_export]
862#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
863macro_rules! for_each_sdm_channel {
864 ($($pattern:tt => $code:tt;)*) => {
865 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
866 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
867 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
868 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
869 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
870 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
871 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
872 GPIO_SD3)));
873 };
874}
875#[macro_export]
876#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
877macro_rules! for_each_aes_key_length {
878 ($($pattern:tt => $code:tt;)*) => {
879 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
880 tt) => {} } _for_each_inner_aes_key_length!((128));
881 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
882 4)); _for_each_inner_aes_key_length!((256, 2, 6));
883 _for_each_inner_aes_key_length!((bits(128), (256)));
884 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
885 };
886}
887#[macro_export]
888#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
889macro_rules! for_each_ecc_working_mode {
890 ($($pattern:tt => $code:tt;)*) => {
891 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
892 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
893 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
894 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
895 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
896 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
897 _for_each_inner_ecc_working_mode!((7,
898 AffinePointVerificationAndJacobianPointMultiplication));
899 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
900 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
901 JacobianPointMultiplication), (6, JacobianPointVerification), (7,
902 AffinePointVerificationAndJacobianPointMultiplication)));
903 };
904}
905#[macro_export]
906#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
907macro_rules! for_each_ecc_curve {
908 ($($pattern:tt => $code:tt;)*) => {
909 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
910 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
911 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
912 P192, 192), (1, P256, 256)));
913 };
914}
915#[macro_export]
916#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
917macro_rules! for_each_rsa_exponentiation {
918 ($($pattern:tt => $code:tt;)*) => {
919 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
920 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
921 _for_each_inner_rsa_exponentiation!((64));
922 _for_each_inner_rsa_exponentiation!((96));
923 _for_each_inner_rsa_exponentiation!((128));
924 _for_each_inner_rsa_exponentiation!((160));
925 _for_each_inner_rsa_exponentiation!((192));
926 _for_each_inner_rsa_exponentiation!((224));
927 _for_each_inner_rsa_exponentiation!((256));
928 _for_each_inner_rsa_exponentiation!((288));
929 _for_each_inner_rsa_exponentiation!((320));
930 _for_each_inner_rsa_exponentiation!((352));
931 _for_each_inner_rsa_exponentiation!((384));
932 _for_each_inner_rsa_exponentiation!((416));
933 _for_each_inner_rsa_exponentiation!((448));
934 _for_each_inner_rsa_exponentiation!((480));
935 _for_each_inner_rsa_exponentiation!((512));
936 _for_each_inner_rsa_exponentiation!((544));
937 _for_each_inner_rsa_exponentiation!((576));
938 _for_each_inner_rsa_exponentiation!((608));
939 _for_each_inner_rsa_exponentiation!((640));
940 _for_each_inner_rsa_exponentiation!((672));
941 _for_each_inner_rsa_exponentiation!((704));
942 _for_each_inner_rsa_exponentiation!((736));
943 _for_each_inner_rsa_exponentiation!((768));
944 _for_each_inner_rsa_exponentiation!((800));
945 _for_each_inner_rsa_exponentiation!((832));
946 _for_each_inner_rsa_exponentiation!((864));
947 _for_each_inner_rsa_exponentiation!((896));
948 _for_each_inner_rsa_exponentiation!((928));
949 _for_each_inner_rsa_exponentiation!((960));
950 _for_each_inner_rsa_exponentiation!((992));
951 _for_each_inner_rsa_exponentiation!((1024));
952 _for_each_inner_rsa_exponentiation!((1056));
953 _for_each_inner_rsa_exponentiation!((1088));
954 _for_each_inner_rsa_exponentiation!((1120));
955 _for_each_inner_rsa_exponentiation!((1152));
956 _for_each_inner_rsa_exponentiation!((1184));
957 _for_each_inner_rsa_exponentiation!((1216));
958 _for_each_inner_rsa_exponentiation!((1248));
959 _for_each_inner_rsa_exponentiation!((1280));
960 _for_each_inner_rsa_exponentiation!((1312));
961 _for_each_inner_rsa_exponentiation!((1344));
962 _for_each_inner_rsa_exponentiation!((1376));
963 _for_each_inner_rsa_exponentiation!((1408));
964 _for_each_inner_rsa_exponentiation!((1440));
965 _for_each_inner_rsa_exponentiation!((1472));
966 _for_each_inner_rsa_exponentiation!((1504));
967 _for_each_inner_rsa_exponentiation!((1536));
968 _for_each_inner_rsa_exponentiation!((1568));
969 _for_each_inner_rsa_exponentiation!((1600));
970 _for_each_inner_rsa_exponentiation!((1632));
971 _for_each_inner_rsa_exponentiation!((1664));
972 _for_each_inner_rsa_exponentiation!((1696));
973 _for_each_inner_rsa_exponentiation!((1728));
974 _for_each_inner_rsa_exponentiation!((1760));
975 _for_each_inner_rsa_exponentiation!((1792));
976 _for_each_inner_rsa_exponentiation!((1824));
977 _for_each_inner_rsa_exponentiation!((1856));
978 _for_each_inner_rsa_exponentiation!((1888));
979 _for_each_inner_rsa_exponentiation!((1920));
980 _for_each_inner_rsa_exponentiation!((1952));
981 _for_each_inner_rsa_exponentiation!((1984));
982 _for_each_inner_rsa_exponentiation!((2016));
983 _for_each_inner_rsa_exponentiation!((2048));
984 _for_each_inner_rsa_exponentiation!((2080));
985 _for_each_inner_rsa_exponentiation!((2112));
986 _for_each_inner_rsa_exponentiation!((2144));
987 _for_each_inner_rsa_exponentiation!((2176));
988 _for_each_inner_rsa_exponentiation!((2208));
989 _for_each_inner_rsa_exponentiation!((2240));
990 _for_each_inner_rsa_exponentiation!((2272));
991 _for_each_inner_rsa_exponentiation!((2304));
992 _for_each_inner_rsa_exponentiation!((2336));
993 _for_each_inner_rsa_exponentiation!((2368));
994 _for_each_inner_rsa_exponentiation!((2400));
995 _for_each_inner_rsa_exponentiation!((2432));
996 _for_each_inner_rsa_exponentiation!((2464));
997 _for_each_inner_rsa_exponentiation!((2496));
998 _for_each_inner_rsa_exponentiation!((2528));
999 _for_each_inner_rsa_exponentiation!((2560));
1000 _for_each_inner_rsa_exponentiation!((2592));
1001 _for_each_inner_rsa_exponentiation!((2624));
1002 _for_each_inner_rsa_exponentiation!((2656));
1003 _for_each_inner_rsa_exponentiation!((2688));
1004 _for_each_inner_rsa_exponentiation!((2720));
1005 _for_each_inner_rsa_exponentiation!((2752));
1006 _for_each_inner_rsa_exponentiation!((2784));
1007 _for_each_inner_rsa_exponentiation!((2816));
1008 _for_each_inner_rsa_exponentiation!((2848));
1009 _for_each_inner_rsa_exponentiation!((2880));
1010 _for_each_inner_rsa_exponentiation!((2912));
1011 _for_each_inner_rsa_exponentiation!((2944));
1012 _for_each_inner_rsa_exponentiation!((2976));
1013 _for_each_inner_rsa_exponentiation!((3008));
1014 _for_each_inner_rsa_exponentiation!((3040));
1015 _for_each_inner_rsa_exponentiation!((3072));
1016 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
1017 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1018 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1019 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1020 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
1021 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
1022 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
1023 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
1024 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
1025 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
1026 };
1027}
1028#[macro_export]
1029#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1030macro_rules! for_each_rsa_multiplication {
1031 ($($pattern:tt => $code:tt;)*) => {
1032 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
1033 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
1034 _for_each_inner_rsa_multiplication!((64));
1035 _for_each_inner_rsa_multiplication!((96));
1036 _for_each_inner_rsa_multiplication!((128));
1037 _for_each_inner_rsa_multiplication!((160));
1038 _for_each_inner_rsa_multiplication!((192));
1039 _for_each_inner_rsa_multiplication!((224));
1040 _for_each_inner_rsa_multiplication!((256));
1041 _for_each_inner_rsa_multiplication!((288));
1042 _for_each_inner_rsa_multiplication!((320));
1043 _for_each_inner_rsa_multiplication!((352));
1044 _for_each_inner_rsa_multiplication!((384));
1045 _for_each_inner_rsa_multiplication!((416));
1046 _for_each_inner_rsa_multiplication!((448));
1047 _for_each_inner_rsa_multiplication!((480));
1048 _for_each_inner_rsa_multiplication!((512));
1049 _for_each_inner_rsa_multiplication!((544));
1050 _for_each_inner_rsa_multiplication!((576));
1051 _for_each_inner_rsa_multiplication!((608));
1052 _for_each_inner_rsa_multiplication!((640));
1053 _for_each_inner_rsa_multiplication!((672));
1054 _for_each_inner_rsa_multiplication!((704));
1055 _for_each_inner_rsa_multiplication!((736));
1056 _for_each_inner_rsa_multiplication!((768));
1057 _for_each_inner_rsa_multiplication!((800));
1058 _for_each_inner_rsa_multiplication!((832));
1059 _for_each_inner_rsa_multiplication!((864));
1060 _for_each_inner_rsa_multiplication!((896));
1061 _for_each_inner_rsa_multiplication!((928));
1062 _for_each_inner_rsa_multiplication!((960));
1063 _for_each_inner_rsa_multiplication!((992));
1064 _for_each_inner_rsa_multiplication!((1024));
1065 _for_each_inner_rsa_multiplication!((1056));
1066 _for_each_inner_rsa_multiplication!((1088));
1067 _for_each_inner_rsa_multiplication!((1120));
1068 _for_each_inner_rsa_multiplication!((1152));
1069 _for_each_inner_rsa_multiplication!((1184));
1070 _for_each_inner_rsa_multiplication!((1216));
1071 _for_each_inner_rsa_multiplication!((1248));
1072 _for_each_inner_rsa_multiplication!((1280));
1073 _for_each_inner_rsa_multiplication!((1312));
1074 _for_each_inner_rsa_multiplication!((1344));
1075 _for_each_inner_rsa_multiplication!((1376));
1076 _for_each_inner_rsa_multiplication!((1408));
1077 _for_each_inner_rsa_multiplication!((1440));
1078 _for_each_inner_rsa_multiplication!((1472));
1079 _for_each_inner_rsa_multiplication!((1504));
1080 _for_each_inner_rsa_multiplication!((1536));
1081 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
1082 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1083 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1084 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1085 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
1086 };
1087}
1088#[macro_export]
1089#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1090macro_rules! for_each_sha_algorithm {
1091 ($($pattern:tt => $code:tt;)*) => {
1092 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
1093 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
1094 (insecure_against : "collision", "length extension"), 0));
1095 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
1096 (insecure_against : "length extension"), 1));
1097 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
1098 (insecure_against : "length extension"), 2));
1099 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
1100 (insecure_against : "collision", "length extension"), 0), (Sha224,
1101 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
1102 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
1103 2)));
1104 };
1105}
1106#[macro_export]
1107#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1108macro_rules! for_each_wakeup_source {
1109 ($($pattern:tt => $code:tt;)*) => {
1110 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
1111 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
1112 _for_each_inner_wakeup_source!((Gpio, 2));
1113 _for_each_inner_wakeup_source!((WifiBeacon, 3));
1114 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
1115 5)); _for_each_inner_wakeup_source!((Uart0, 6));
1116 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
1117 8)); _for_each_inner_wakeup_source!((Bt, 10));
1118 _for_each_inner_wakeup_source!((LpCore, 11));
1119 _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3), (Timer,
1120 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Bt, 10), (LpCore, 11)));
1121 };
1122}
1123#[macro_export]
1124#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1125macro_rules! for_each_dma_engine {
1126 ($($pattern:tt => $code:tt;)*) => {
1127 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
1128 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
1129 _for_each_inner_dma_engine!((all("AHB_GDMA")));
1130 };
1131}
1132#[macro_export]
1133#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1134macro_rules! for_each_dma_channel {
1135 ($($pattern:tt => $code:tt;)*) => {
1136 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
1137 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
1138 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
1139 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
1140 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
1141 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
1142 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1143 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1,
1144 interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI2,
1145 UHCI0, I2S0, AES, SHA, APB_SARADC, PARL_IO]));
1146 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1147 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1148 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
1149 ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2)));
1150 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
1151 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
1152 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1153 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES,
1154 SHA, APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
1155 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1156 APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1157 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1158 APB_SARADC, PARL_IO]))); _for_each_inner_dma_channel!((no_own_interrupt));
1159 };
1160}
1161#[macro_export]
1162#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1163macro_rules! for_each_dma_channel_peri_pair {
1164 ($($pattern:tt => $code:tt;)*) => {
1165 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1166 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1167 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
1168 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
1169 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
1170 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
1171 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
1172 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
1173 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
1174 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
1175 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
1176 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
1177 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
1178 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
1179 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
1180 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
1181 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
1182 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
1183 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
1184 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
1185 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
1186 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
1187 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1188 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1189 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1190 any_channel = AhbGdmaChannel, I2S0));
1191 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1192 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1193 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1194 any_channel = AhbGdmaChannel, APB_SARADC));
1195 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1196 PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
1197 SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA",
1198 DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC),
1199 ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI2), ("AHB_GDMA",
1200 DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, AES),
1201 ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1, APB_SARADC), ("AHB_GDMA",
1202 DMA_CH1, PARL_IO), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
1203 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
1204 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC), ("AHB_GDMA", DMA_CH2, PARL_IO)));
1205 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1206 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
1207 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
1208 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
1209 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC), ("AHB_GDMA", any_channel
1210 = AhbGdmaChannel, PARL_IO)));
1211 };
1212}
1213#[macro_export]
1214#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1215macro_rules! for_each_mem2mem_channel {
1216 ($($pattern:tt => $code:tt;)*) => {
1217 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1218 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1219 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1220 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
1221 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
1222 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1223 4, 1, 5, 2, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1224 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1225 AhbGdmaChannel, DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5),
1226 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 10)));
1227 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1228 4, 1, 5, 2, 10))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1229 AhbGdmaChannel)));
1230 };
1231}
1232#[macro_export]
1233#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1234macro_rules! with_aes_dma_engine {
1235 ($($pattern:tt => $code:tt;)*) => {
1236 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1237 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1238 };
1239}
1240#[macro_export]
1241#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1242macro_rules! with_i2s_dma_engine {
1243 ($($pattern:tt => $code:tt;)*) => {
1244 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1245 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1246 };
1247}
1248#[macro_export]
1249#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1250macro_rules! with_parl_io_dma_engine {
1251 ($($pattern:tt => $code:tt;)*) => {
1252 macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
1253 tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1254 };
1255}
1256#[macro_export]
1257#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1258macro_rules! with_sha_dma_engine {
1259 ($($pattern:tt => $code:tt;)*) => {
1260 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1261 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1262 };
1263}
1264#[macro_export]
1265#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1266macro_rules! with_spi_master_dma_engine {
1267 ($($pattern:tt => $code:tt;)*) => {
1268 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1269 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1270 };
1271}
1272#[macro_export]
1273#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1274macro_rules! with_spi_slave_dma_engine {
1275 ($($pattern:tt => $code:tt;)*) => {
1276 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1277 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1278 };
1279}
1280#[macro_export]
1281#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1282macro_rules! with_uhci_dma_engine {
1283 ($($pattern:tt => $code:tt;)*) => {
1284 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1285 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1286 };
1287}
1288#[macro_export]
1289#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1290macro_rules! for_each_interrupt {
1291 ($($pattern:tt => $code:tt;)*) => {
1292 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1293 => {} } _for_each_inner_interrupt!(([reserved 0] 0));
1294 _for_each_inner_interrupt!(([context_switch 0] 1));
1295 _for_each_inner_interrupt!(([direct_bindable 0] 2));
1296 _for_each_inner_interrupt!(([reserved 1] 3));
1297 _for_each_inner_interrupt!(([reserved 2] 4));
1298 _for_each_inner_interrupt!(([direct_bindable 1] 5));
1299 _for_each_inner_interrupt!(([direct_bindable 2] 6));
1300 _for_each_inner_interrupt!(([reserved 3] 7));
1301 _for_each_inner_interrupt!(([direct_bindable 3] 8));
1302 _for_each_inner_interrupt!(([direct_bindable 4] 9));
1303 _for_each_inner_interrupt!(([direct_bindable 5] 10));
1304 _for_each_inner_interrupt!(([direct_bindable 6] 11));
1305 _for_each_inner_interrupt!(([direct_bindable 7] 12));
1306 _for_each_inner_interrupt!(([direct_bindable 8] 13));
1307 _for_each_inner_interrupt!(([direct_bindable 9] 14));
1308 _for_each_inner_interrupt!(([direct_bindable 10] 15));
1309 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1310 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1311 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1312 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1313 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1314 7] 23)); _for_each_inner_interrupt!(([vector 8] 24));
1315 _for_each_inner_interrupt!(([vector 9] 25)); _for_each_inner_interrupt!(([vector
1316 10] 26)); _for_each_inner_interrupt!(([vector 11] 27));
1317 _for_each_inner_interrupt!(([vector 12] 28)); _for_each_inner_interrupt!(([vector
1318 13] 29)); _for_each_inner_interrupt!(([vector 14] 30));
1319 _for_each_inner_interrupt!(([disabled 0] 31));
1320 _for_each_inner_interrupt!((all([reserved 0] 0), ([context_switch 0] 1),
1321 ([direct_bindable 0] 2), ([reserved 1] 3), ([reserved 2] 4), ([direct_bindable 1]
1322 5), ([direct_bindable 2] 6), ([reserved 3] 7), ([direct_bindable 3] 8),
1323 ([direct_bindable 4] 9), ([direct_bindable 5] 10), ([direct_bindable 6] 11),
1324 ([direct_bindable 7] 12), ([direct_bindable 8] 13), ([direct_bindable 9] 14),
1325 ([direct_bindable 10] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18),
1326 ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7]
1327 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26), ([vector 11] 27),
1328 ([vector 12] 28), ([vector 13] 29), ([vector 14] 30), ([disabled 0] 31)));
1329 };
1330}
1331#[macro_export]
1332#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1333macro_rules! for_each_classified_interrupt {
1334 ($($pattern:tt => $code:tt;)*) => {
1335 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1336 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1337 2)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 5));
1338 _for_each_inner_classified_interrupt!(([direct_bindable 2] 6));
1339 _for_each_inner_classified_interrupt!(([direct_bindable 3] 8));
1340 _for_each_inner_classified_interrupt!(([direct_bindable 4] 9));
1341 _for_each_inner_classified_interrupt!(([direct_bindable 5] 10));
1342 _for_each_inner_classified_interrupt!(([direct_bindable 6] 11));
1343 _for_each_inner_classified_interrupt!(([direct_bindable 7] 12));
1344 _for_each_inner_classified_interrupt!(([direct_bindable 8] 13));
1345 _for_each_inner_classified_interrupt!(([direct_bindable 9] 14));
1346 _for_each_inner_classified_interrupt!(([direct_bindable 10] 15));
1347 _for_each_inner_classified_interrupt!(([vector 0] 16));
1348 _for_each_inner_classified_interrupt!(([vector 1] 17));
1349 _for_each_inner_classified_interrupt!(([vector 2] 18));
1350 _for_each_inner_classified_interrupt!(([vector 3] 19));
1351 _for_each_inner_classified_interrupt!(([vector 4] 20));
1352 _for_each_inner_classified_interrupt!(([vector 5] 21));
1353 _for_each_inner_classified_interrupt!(([vector 6] 22));
1354 _for_each_inner_classified_interrupt!(([vector 7] 23));
1355 _for_each_inner_classified_interrupt!(([vector 8] 24));
1356 _for_each_inner_classified_interrupt!(([vector 9] 25));
1357 _for_each_inner_classified_interrupt!(([vector 10] 26));
1358 _for_each_inner_classified_interrupt!(([vector 11] 27));
1359 _for_each_inner_classified_interrupt!(([vector 12] 28));
1360 _for_each_inner_classified_interrupt!(([vector 13] 29));
1361 _for_each_inner_classified_interrupt!(([vector 14] 30));
1362 _for_each_inner_classified_interrupt!(([reserved 0] 0));
1363 _for_each_inner_classified_interrupt!(([reserved 1] 3));
1364 _for_each_inner_classified_interrupt!(([reserved 2] 4));
1365 _for_each_inner_classified_interrupt!(([reserved 3] 7));
1366 _for_each_inner_classified_interrupt!(([context_switch 0] 1));
1367 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 2),
1368 ([direct_bindable 1] 5), ([direct_bindable 2] 6), ([direct_bindable 3] 8),
1369 ([direct_bindable 4] 9), ([direct_bindable 5] 10), ([direct_bindable 6] 11),
1370 ([direct_bindable 7] 12), ([direct_bindable 8] 13), ([direct_bindable 9] 14),
1371 ([direct_bindable 10] 15)));
1372 _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1373 ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1374 22), ([vector 7] 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26),
1375 ([vector 11] 27), ([vector 12] 28), ([vector 13] 29), ([vector 14] 30)));
1376 _for_each_inner_classified_interrupt!((reserved([reserved 0] 0), ([reserved 1]
1377 3), ([reserved 2] 4), ([reserved 3] 7)));
1378 _for_each_inner_classified_interrupt!((context_switch([context_switch 0] 1)));
1379 };
1380}
1381#[macro_export]
1382#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1383macro_rules! for_each_interrupt_priority {
1384 ($($pattern:tt => $code:tt;)*) => {
1385 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1386 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1387 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1388 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1389 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1390 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1391 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1392 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1393 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1394 _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
1395 _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
1396 _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
1397 _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
1398 _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
1399 _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
1400 _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
1401 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1402 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1403 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1404 Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
1405 11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
1406 Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
1407 };
1408}
1409#[macro_export]
1410#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1411macro_rules! for_each_sw_interrupt {
1412 ($($pattern:tt => $code:tt;)*) => {
1413 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1414 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1415 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1416 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1417 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1418 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1419 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1420 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1421 };
1422}
1423#[macro_export]
1424macro_rules! define_clock_tree_types {
2000 () => {
2001 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2002 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2003 pub enum AdcInstance {
2004 ApbSaradc = 0,
2005 }
2006 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2007 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2008 pub enum SdmInstance {
2009 GpioSd = 0,
2010 }
2011 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2012 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2013 pub enum I2cInstance {
2014 I2c0 = 0,
2015 }
2016 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2017 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2018 pub enum I2sInstance {
2019 I2s0 = 0,
2020 }
2021 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2022 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2023 pub enum McpwmInstance {
2024 Mcpwm0 = 0,
2025 }
2026 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2027 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2028 pub enum ParlIoInstance {
2029 ParlIo = 0,
2030 }
2031 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2032 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2033 pub enum PcntInstance {
2034 Pcnt = 0,
2035 }
2036 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2037 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2038 pub enum RmtInstance {
2039 Rmt = 0,
2040 }
2041 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2042 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2043 pub enum SpiInstance {
2044 Spi2 = 0,
2045 }
2046 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2047 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2048 pub enum TimgInstance {
2049 Timg0 = 0,
2050 Timg1 = 1,
2051 }
2052 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2053 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2054 pub enum UartInstance {
2055 Uart0 = 0,
2056 Uart1 = 1,
2057 }
2058 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
2059 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2060 pub enum TsensInstance {
2061 Tsens = 0,
2062 }
2063 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2065 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2066 pub enum XtalClkConfig {
2067 _40,
2069 }
2070 impl XtalClkConfig {
2071 pub fn value(&self) -> u32 {
2072 match self {
2073 XtalClkConfig::_40 => 40000000,
2074 }
2075 }
2076 }
2077 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2078 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2079 pub enum HpRootClkDivisor {
2080 _1 = 1,
2082 _3 = 3,
2084 }
2085 impl HpRootClkDivisor {
2086 pub const fn new(raw: u32) -> Self {
2088 match raw {
2089 1 => Self::_1,
2090 3 => Self::_3,
2091 _ => ::core::panic!("Invalid HP_ROOT_CLK divisor value"),
2092 }
2093 }
2094 }
2095 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2099 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2100 pub struct HpRootClkConfig {
2101 divisor: HpRootClkDivisor,
2102 }
2103 impl HpRootClkConfig {
2104 pub const fn new(divisor: HpRootClkDivisor) -> Self {
2106 Self { divisor }
2107 }
2108 pub fn divisor(self) -> u32 {
2109 self.divisor as u32
2110 }
2111 }
2112 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2114 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2115 pub enum CpuClkConfig {
2116 Hs,
2118 Ls,
2120 }
2121 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2123 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2124 pub enum AhbClkConfig {
2125 Hs,
2127 Ls,
2129 }
2130 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2132 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2133 pub enum MspiFastClkConfig {
2134 Hs,
2136 Ls,
2138 }
2139 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2141 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2142 pub enum SocRootClkConfig {
2143 Xtal,
2145 RcFast,
2147 Pll,
2149 }
2150 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2151 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2152 pub enum CpuHsDivDivisor {
2153 _0 = 0,
2155 _1 = 1,
2157 _3 = 3,
2159 }
2160 impl CpuHsDivDivisor {
2161 pub const fn new(raw: u32) -> Self {
2163 match raw {
2164 0 => Self::_0,
2165 1 => Self::_1,
2166 3 => Self::_3,
2167 _ => ::core::panic!("Invalid CPU_HS_DIV divisor value"),
2168 }
2169 }
2170 }
2171 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2175 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2176 pub struct CpuHsDivConfig {
2177 divisor: CpuHsDivDivisor,
2178 }
2179 impl CpuHsDivConfig {
2180 pub const fn new(divisor: CpuHsDivDivisor) -> Self {
2182 Self { divisor }
2183 }
2184 pub fn divisor(self) -> u32 {
2185 self.divisor as u32
2186 }
2187 }
2188 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2189 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2190 pub enum CpuLsDivDivisor {
2191 _0 = 0,
2193 _1 = 1,
2195 _3 = 3,
2197 _7 = 7,
2199 _15 = 15,
2201 _31 = 31,
2203 }
2204 impl CpuLsDivDivisor {
2205 pub const fn new(raw: u32) -> Self {
2207 match raw {
2208 0 => Self::_0,
2209 1 => Self::_1,
2210 3 => Self::_3,
2211 7 => Self::_7,
2212 15 => Self::_15,
2213 31 => Self::_31,
2214 _ => ::core::panic!("Invalid CPU_LS_DIV divisor value"),
2215 }
2216 }
2217 }
2218 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2222 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2223 pub struct CpuLsDivConfig {
2224 divisor: CpuLsDivDivisor,
2225 }
2226 impl CpuLsDivConfig {
2227 pub const fn new(divisor: CpuLsDivDivisor) -> Self {
2229 Self { divisor }
2230 }
2231 pub fn divisor(self) -> u32 {
2232 self.divisor as u32
2233 }
2234 }
2235 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2236 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2237 pub enum AhbHsDivDivisor {
2238 _3 = 3,
2240 _7 = 7,
2242 _15 = 15,
2244 }
2245 impl AhbHsDivDivisor {
2246 pub const fn new(raw: u32) -> Self {
2248 match raw {
2249 3 => Self::_3,
2250 7 => Self::_7,
2251 15 => Self::_15,
2252 _ => ::core::panic!("Invalid AHB_HS_DIV divisor value"),
2253 }
2254 }
2255 }
2256 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2260 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2261 pub struct AhbHsDivConfig {
2262 divisor: AhbHsDivDivisor,
2263 }
2264 impl AhbHsDivConfig {
2265 pub const fn new(divisor: AhbHsDivDivisor) -> Self {
2267 Self { divisor }
2268 }
2269 pub fn divisor(self) -> u32 {
2270 self.divisor as u32
2271 }
2272 }
2273 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2274 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2275 pub enum AhbLsDivDivisor {
2276 _0 = 0,
2278 _1 = 1,
2280 _3 = 3,
2282 _7 = 7,
2284 _15 = 15,
2286 _31 = 31,
2288 }
2289 impl AhbLsDivDivisor {
2290 pub const fn new(raw: u32) -> Self {
2292 match raw {
2293 0 => Self::_0,
2294 1 => Self::_1,
2295 3 => Self::_3,
2296 7 => Self::_7,
2297 15 => Self::_15,
2298 31 => Self::_31,
2299 _ => ::core::panic!("Invalid AHB_LS_DIV divisor value"),
2300 }
2301 }
2302 }
2303 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2307 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2308 pub struct AhbLsDivConfig {
2309 divisor: AhbLsDivDivisor,
2310 }
2311 impl AhbLsDivConfig {
2312 pub const fn new(divisor: AhbLsDivDivisor) -> Self {
2314 Self { divisor }
2315 }
2316 pub fn divisor(self) -> u32 {
2317 self.divisor as u32
2318 }
2319 }
2320 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2321 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2322 pub enum ApbClkDivisor {
2323 _0 = 0,
2325 _1 = 1,
2327 _3 = 3,
2329 }
2330 impl ApbClkDivisor {
2331 pub const fn new(raw: u32) -> Self {
2333 match raw {
2334 0 => Self::_0,
2335 1 => Self::_1,
2336 3 => Self::_3,
2337 _ => ::core::panic!("Invalid APB_CLK divisor value"),
2338 }
2339 }
2340 }
2341 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2345 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2346 pub struct ApbClkConfig {
2347 divisor: ApbClkDivisor,
2348 }
2349 impl ApbClkConfig {
2350 pub const fn new(divisor: ApbClkDivisor) -> Self {
2352 Self { divisor }
2353 }
2354 pub fn divisor(self) -> u32 {
2355 self.divisor as u32
2356 }
2357 }
2358 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2359 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2360 pub enum MspiFastHsClkDivisor {
2361 _3 = 3,
2363 _4 = 4,
2365 _5 = 5,
2367 }
2368 impl MspiFastHsClkDivisor {
2369 pub const fn new(raw: u32) -> Self {
2371 match raw {
2372 3 => Self::_3,
2373 4 => Self::_4,
2374 5 => Self::_5,
2375 _ => ::core::panic!("Invalid MSPI_FAST_HS_CLK divisor value"),
2376 }
2377 }
2378 }
2379 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2383 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2384 pub struct MspiFastHsClkConfig {
2385 divisor: MspiFastHsClkDivisor,
2386 }
2387 impl MspiFastHsClkConfig {
2388 pub const fn new(divisor: MspiFastHsClkDivisor) -> Self {
2390 Self { divisor }
2391 }
2392 pub fn divisor(self) -> u32 {
2393 self.divisor as u32
2394 }
2395 }
2396 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2397 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2398 pub enum MspiFastLsClkDivisor {
2399 _0 = 0,
2401 _1 = 1,
2403 _2 = 2,
2405 }
2406 impl MspiFastLsClkDivisor {
2407 pub const fn new(raw: u32) -> Self {
2409 match raw {
2410 0 => Self::_0,
2411 1 => Self::_1,
2412 2 => Self::_2,
2413 _ => ::core::panic!("Invalid MSPI_FAST_LS_CLK divisor value"),
2414 }
2415 }
2416 }
2417 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2421 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2422 pub struct MspiFastLsClkConfig {
2423 divisor: MspiFastLsClkDivisor,
2424 }
2425 impl MspiFastLsClkConfig {
2426 pub const fn new(divisor: MspiFastLsClkDivisor) -> Self {
2428 Self { divisor }
2429 }
2430 pub fn divisor(self) -> u32 {
2431 self.divisor as u32
2432 }
2433 }
2434 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2436 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2437 pub enum IomuxFunctionClockConfig {
2438 #[default]
2439 PllF80m,
2441 RcFastClk,
2443 XtalClk,
2445 }
2446 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2448 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2449 pub enum LedcSclkConfig {
2450 PllF80m,
2452 RcFastClk,
2454 XtalClk,
2456 }
2457 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2459 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2460 pub enum LpFastClkConfig {
2461 RcFastClk,
2463 XtalD2Clk,
2465 }
2466 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2468 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2469 pub enum LpSlowClkConfig {
2470 #[cfg(use_xtal32k)]
2471 Xtal32k,
2473 RcSlow,
2475 OscSlow,
2477 }
2478 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2480 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2481 pub enum BleLpClkConfig {
2482 Xtal,
2484 RcSlow,
2486 #[cfg(use_xtal32k)]
2487 Xtal32k,
2489 }
2490 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2492 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2493 pub enum TimgCalibrationClockConfig {
2494 RcSlowClk,
2496 RcFastDivClk,
2498 #[cfg(use_xtal32k)]
2499 Xtal32kClk,
2501 }
2502 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2504 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2505 pub enum AdcFunctionClockConfig {
2506 Xtal,
2508 #[default]
2509 PllF80m,
2511 RcFast,
2513 }
2514 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2515 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2516 pub enum I2cFunctionClockSclk {
2517 #[default]
2518 Xtal,
2520 RcFast,
2522 }
2523 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2527 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2528 pub struct I2cFunctionClockConfig {
2529 sclk: I2cFunctionClockSclk,
2530 div_num: u32,
2531 }
2532 impl I2cFunctionClockConfig {
2533 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
2540 ::core::assert!(
2541 div_num <= 255,
2542 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2543 );
2544 Self { sclk, div_num }
2545 }
2546 pub fn sclk(self) -> I2cFunctionClockSclk {
2547 self.sclk
2548 }
2549 pub fn div_num(self) -> u32 {
2550 self.div_num as u32
2551 }
2552 }
2553 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2554 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2555 pub enum I2sClkSclk {
2556 Xtal,
2558 PllF240m,
2560 #[default]
2561 PllF160m,
2563 }
2564 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2568 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2569 pub struct I2sClkConfig {
2570 sclk: I2sClkSclk,
2571 div_num: u32,
2572 div_a: u32,
2573 div_b: u32,
2574 }
2575 impl I2sClkConfig {
2576 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
2589 ::core::assert!(
2590 div_num >= 1 && div_num <= 255,
2591 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
2592 );
2593 ::core::assert!(
2594 div_a >= 1 && div_a <= 511,
2595 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
2596 );
2597 ::core::assert!(
2598 div_b <= 511,
2599 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
2600 );
2601 Self {
2602 sclk,
2603 div_num,
2604 div_a,
2605 div_b,
2606 }
2607 }
2608 pub fn sclk(self) -> I2sClkSclk {
2609 self.sclk
2610 }
2611 pub fn div_num(self) -> u32 {
2612 self.div_num as u32
2613 }
2614 pub fn div_a(self) -> u32 {
2615 self.div_a as u32
2616 }
2617 pub fn div_b(self) -> u32 {
2618 self.div_b as u32
2619 }
2620 }
2621 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2623 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2624 pub enum I2sMclkOutConfig {
2625 Tx,
2627 #[default]
2628 Rx,
2630 }
2631 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2633 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2634 pub enum McpwmFunctionClockConfig {
2635 #[default]
2636 PllF160m,
2638 RcFastClk,
2640 XtalClk,
2642 }
2643 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2645 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2646 pub enum ParlIoClkConfig {
2647 XtalClk,
2649 RcFastClk,
2651 #[default]
2652 PllF240m,
2654 }
2655 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2657 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2658 pub enum RmtSclkConfig {
2659 #[default]
2660 PllF80m,
2662 RcFastClk,
2664 XtalClk,
2666 }
2667 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2669 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2670 pub enum SpiFunctionClockConfig {
2671 #[default]
2672 PllF80m,
2674 Xtal,
2676 RcFast,
2678 }
2679 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2681 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2682 pub enum TimgFunctionClockConfig {
2683 #[default]
2684 XtalClk,
2686 RcFastClk,
2688 PllF80m,
2690 }
2691 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2693 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2694 pub enum TimgWdtClockConfig {
2695 #[default]
2696 XtalClk,
2698 PllF80m,
2700 RcFastClk,
2702 }
2703 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2704 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2705 pub enum UartFunctionClockSclk {
2706 PllF80m,
2708 RcFast,
2710 #[default]
2711 Xtal,
2713 }
2714 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2718 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2719 pub struct UartFunctionClockConfig {
2720 sclk: UartFunctionClockSclk,
2721 div_num: u32,
2722 }
2723 impl UartFunctionClockConfig {
2724 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
2731 ::core::assert!(
2732 div_num <= 255,
2733 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2734 );
2735 Self { sclk, div_num }
2736 }
2737 pub fn sclk(self) -> UartFunctionClockSclk {
2738 self.sclk
2739 }
2740 pub fn div_num(self) -> u32 {
2741 self.div_num as u32
2742 }
2743 }
2744 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2749 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2750 pub struct UartBaudRateGeneratorConfig {
2751 fractional: u32,
2752 integral: u32,
2753 }
2754 impl UartBaudRateGeneratorConfig {
2755 pub const fn new(fractional: u32, integral: u32) -> Self {
2765 ::core::assert!(
2766 fractional <= 15,
2767 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2768 );
2769 ::core::assert!(
2770 integral <= 4095,
2771 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2772 );
2773 Self {
2774 fractional,
2775 integral,
2776 }
2777 }
2778 pub fn fractional(self) -> u32 {
2779 self.fractional as u32
2780 }
2781 pub fn integral(self) -> u32 {
2782 self.integral as u32
2783 }
2784 }
2785 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2787 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2788 pub enum TsensSclkConfig {
2789 RcFast,
2791 #[default]
2792 Xtal,
2794 }
2795 pub struct ClockTree {
2797 xtal_clk: Option<XtalClkConfig>,
2798 hp_root_clk: Option<HpRootClkConfig>,
2799 cpu_clk: Option<CpuClkConfig>,
2800 ahb_clk: Option<AhbClkConfig>,
2801 mspi_fast_clk: Option<MspiFastClkConfig>,
2802 soc_root_clk: Option<SocRootClkConfig>,
2803 cpu_hs_div: Option<CpuHsDivConfig>,
2804 cpu_ls_div: Option<CpuLsDivConfig>,
2805 ahb_hs_div: Option<AhbHsDivConfig>,
2806 ahb_ls_div: Option<AhbLsDivConfig>,
2807 apb_clk: Option<ApbClkConfig>,
2808 mspi_fast_hs_clk: Option<MspiFastHsClkConfig>,
2809 mspi_fast_ls_clk: Option<MspiFastLsClkConfig>,
2810 iomux_function_clock: Option<IomuxFunctionClockConfig>,
2811 ledc_sclk: Option<LedcSclkConfig>,
2812 lp_fast_clk: Option<LpFastClkConfig>,
2813 lp_slow_clk: Option<LpSlowClkConfig>,
2814 ble_lp_clk: Option<BleLpClkConfig>,
2815 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2816 adc_function_clock: [Option<AdcFunctionClockConfig>; 1],
2817 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
2818 i2s_tx_clk: [Option<I2sClkConfig>; 1],
2819 i2s_rx_clk: [Option<I2sClkConfig>; 1],
2820 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
2821 mcpwm_function_clock: [Option<McpwmFunctionClockConfig>; 1],
2822 parl_io_rx_clock: [Option<ParlIoClkConfig>; 1],
2823 parl_io_tx_clock: [Option<ParlIoClkConfig>; 1],
2824 rmt_sclk: [Option<RmtSclkConfig>; 1],
2825 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
2826 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2827 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2828 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2829 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2830 tsens_sclk: [Option<TsensSclkConfig>; 1],
2831 pub(crate) pll_clk_refcount: u32,
2832 pub(crate) rc_fast_clk_refcount: u32,
2833 #[cfg(use_xtal32k)]
2834 pub(crate) xtal32k_clk_refcount: u32,
2835 pub(crate) rc_slow_clk_refcount: u32,
2836 pub(crate) hp_root_clk_refcount: u32,
2837 pub(crate) mspi_fast_clk_refcount: u32,
2838 pub(crate) apb_clk_refcount: u32,
2839 pub(crate) pll_f48m_refcount: u32,
2840 pub(crate) pll_f80m_refcount: u32,
2841 pub(crate) pll_f160m_refcount: u32,
2842 pub(crate) pll_f240m_refcount: u32,
2843 pub(crate) ledc_sclk_refcount: u32,
2844 pub(crate) lp_fast_clk_refcount: u32,
2845 pub(crate) ble_lp_clk_refcount: u32,
2846 pub(crate) timg_calibration_clock_refcount: u32,
2847 pub(crate) adc_function_clock_refcount: [u32; 1],
2848 pub(crate) sdm_function_clock_refcount: [u32; 1],
2849 pub(crate) i2c_function_clock_refcount: [u32; 1],
2850 pub(crate) i2s_tx_clk_refcount: [u32; 1],
2851 pub(crate) i2s_rx_clk_refcount: [u32; 1],
2852 pub(crate) i2s_mclk_out_refcount: [u32; 1],
2853 pub(crate) mcpwm_function_clock_refcount: [u32; 1],
2854 pub(crate) parl_io_rx_clock_refcount: [u32; 1],
2855 pub(crate) parl_io_tx_clock_refcount: [u32; 1],
2856 pub(crate) pcnt_function_clock_refcount: [u32; 1],
2857 pub(crate) rmt_sclk_refcount: [u32; 1],
2858 pub(crate) spi_function_clock_refcount: [u32; 1],
2859 pub(crate) timg_function_clock_refcount: [u32; 2],
2860 pub(crate) timg_wdt_clock_refcount: [u32; 2],
2861 pub(crate) uart_function_clock_refcount: [u32; 2],
2862 pub(crate) uart_baud_rate_generator_refcount: [u32; 2],
2863 pub(crate) tsens_sclk_refcount: [u32; 1],
2864 }
2865 impl ClockTree {
2866 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2868 CLOCK_TREE.with(f)
2869 }
2870 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2872 self.xtal_clk
2873 }
2874 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
2876 self.hp_root_clk
2877 }
2878 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2880 self.cpu_clk
2881 }
2882 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
2884 self.ahb_clk
2885 }
2886 pub fn mspi_fast_clk(&self) -> Option<MspiFastClkConfig> {
2888 self.mspi_fast_clk
2889 }
2890 pub fn soc_root_clk(&self) -> Option<SocRootClkConfig> {
2892 self.soc_root_clk
2893 }
2894 pub fn cpu_hs_div(&self) -> Option<CpuHsDivConfig> {
2896 self.cpu_hs_div
2897 }
2898 pub fn cpu_ls_div(&self) -> Option<CpuLsDivConfig> {
2900 self.cpu_ls_div
2901 }
2902 pub fn ahb_hs_div(&self) -> Option<AhbHsDivConfig> {
2904 self.ahb_hs_div
2905 }
2906 pub fn ahb_ls_div(&self) -> Option<AhbLsDivConfig> {
2908 self.ahb_ls_div
2909 }
2910 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2912 self.apb_clk
2913 }
2914 pub fn mspi_fast_hs_clk(&self) -> Option<MspiFastHsClkConfig> {
2916 self.mspi_fast_hs_clk
2917 }
2918 pub fn mspi_fast_ls_clk(&self) -> Option<MspiFastLsClkConfig> {
2920 self.mspi_fast_ls_clk
2921 }
2922 pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2924 self.iomux_function_clock
2925 }
2926 pub fn ledc_sclk(&self) -> Option<LedcSclkConfig> {
2928 self.ledc_sclk
2929 }
2930 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2932 self.lp_fast_clk
2933 }
2934 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2936 self.lp_slow_clk
2937 }
2938 pub fn ble_lp_clk(&self) -> Option<BleLpClkConfig> {
2940 self.ble_lp_clk
2941 }
2942 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2944 self.timg_calibration_clock
2945 }
2946 pub fn apb_saradc_function_clock(&self) -> Option<AdcFunctionClockConfig> {
2948 self.adc_function_clock[AdcInstance::ApbSaradc as usize]
2949 }
2950 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2952 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2953 }
2954 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
2956 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
2957 }
2958 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
2960 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
2961 }
2962 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
2964 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
2965 }
2966 pub fn mcpwm0_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
2968 self.mcpwm_function_clock[McpwmInstance::Mcpwm0 as usize]
2969 }
2970 pub fn parl_io_rx_clock(&self) -> Option<ParlIoClkConfig> {
2972 self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
2973 }
2974 pub fn parl_io_tx_clock(&self) -> Option<ParlIoClkConfig> {
2976 self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
2977 }
2978 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2980 self.rmt_sclk[RmtInstance::Rmt as usize]
2981 }
2982 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2984 self.spi_function_clock[SpiInstance::Spi2 as usize]
2985 }
2986 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2988 self.timg_function_clock[TimgInstance::Timg0 as usize]
2989 }
2990 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2992 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2993 }
2994 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2996 self.timg_function_clock[TimgInstance::Timg1 as usize]
2997 }
2998 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
3000 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
3001 }
3002 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
3004 self.uart_function_clock[UartInstance::Uart0 as usize]
3005 }
3006 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
3008 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
3009 }
3010 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
3012 self.uart_function_clock[UartInstance::Uart1 as usize]
3013 }
3014 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
3016 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
3017 }
3018 pub fn tsens_sclk(&self) -> Option<TsensSclkConfig> {
3020 self.tsens_sclk[TsensInstance::Tsens as usize]
3021 }
3022 }
3023 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
3024 ::esp_sync::NonReentrantMutex::new(ClockTree {
3025 xtal_clk: None,
3026 hp_root_clk: None,
3027 cpu_clk: None,
3028 ahb_clk: None,
3029 mspi_fast_clk: None,
3030 soc_root_clk: None,
3031 cpu_hs_div: None,
3032 cpu_ls_div: None,
3033 ahb_hs_div: None,
3034 ahb_ls_div: None,
3035 apb_clk: None,
3036 mspi_fast_hs_clk: None,
3037 mspi_fast_ls_clk: None,
3038 iomux_function_clock: None,
3039 ledc_sclk: None,
3040 lp_fast_clk: None,
3041 lp_slow_clk: None,
3042 ble_lp_clk: None,
3043 timg_calibration_clock: None,
3044 adc_function_clock: [None; 1],
3045 i2c_function_clock: [None; 1],
3046 i2s_tx_clk: [None; 1],
3047 i2s_rx_clk: [None; 1],
3048 i2s_mclk_out: [None; 1],
3049 mcpwm_function_clock: [None; 1],
3050 parl_io_rx_clock: [None; 1],
3051 parl_io_tx_clock: [None; 1],
3052 rmt_sclk: [None; 1],
3053 spi_function_clock: [None; 1],
3054 timg_function_clock: [None; 2],
3055 timg_wdt_clock: [None; 2],
3056 uart_function_clock: [None; 2],
3057 uart_baud_rate_generator: [None; 2],
3058 tsens_sclk: [None; 1],
3059 pll_clk_refcount: 0,
3060 rc_fast_clk_refcount: 0,
3061 #[cfg(use_xtal32k)]
3062 xtal32k_clk_refcount: 0,
3063 rc_slow_clk_refcount: 0,
3064 hp_root_clk_refcount: 0,
3065 mspi_fast_clk_refcount: 0,
3066 apb_clk_refcount: 0,
3067 pll_f48m_refcount: 0,
3068 pll_f80m_refcount: 0,
3069 pll_f160m_refcount: 0,
3070 pll_f240m_refcount: 0,
3071 ledc_sclk_refcount: 0,
3072 lp_fast_clk_refcount: 0,
3073 ble_lp_clk_refcount: 0,
3074 timg_calibration_clock_refcount: 0,
3075 adc_function_clock_refcount: [0; 1],
3076 sdm_function_clock_refcount: [0; 1],
3077 i2c_function_clock_refcount: [0; 1],
3078 i2s_tx_clk_refcount: [0; 1],
3079 i2s_rx_clk_refcount: [0; 1],
3080 i2s_mclk_out_refcount: [0; 1],
3081 mcpwm_function_clock_refcount: [0; 1],
3082 parl_io_rx_clock_refcount: [0; 1],
3083 parl_io_tx_clock_refcount: [0; 1],
3084 pcnt_function_clock_refcount: [0; 1],
3085 rmt_sclk_refcount: [0; 1],
3086 spi_function_clock_refcount: [0; 1],
3087 timg_function_clock_refcount: [0; 2],
3088 timg_wdt_clock_refcount: [0; 2],
3089 uart_function_clock_refcount: [0; 2],
3090 uart_baud_rate_generator_refcount: [0; 2],
3091 tsens_sclk_refcount: [0; 1],
3092 });
3093 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3094 ::core::sync::atomic::AtomicU32::new(0);
3095 static SOC_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3096 ::core::sync::atomic::AtomicU32::new(0);
3097 static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3098 ::core::sync::atomic::AtomicU32::new(0);
3099 static LEDC_SCLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3100 ::core::sync::atomic::AtomicU32::new(0);
3101 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3102 ::core::sync::atomic::AtomicU32::new(0);
3103 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3104 ::core::sync::atomic::AtomicU32::new(0);
3105 static BLE_LP_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3106 ::core::sync::atomic::AtomicU32::new(0);
3107 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3108 ::core::sync::atomic::AtomicU32::new(0);
3109 static ADC_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3110 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3111 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3112 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3113 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3114 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3115 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3116 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3117 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3118 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3119 static MCPWM_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3120 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3121 static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3122 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3123 static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3124 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3125 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3126 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3127 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3128 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3129 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
3130 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
3131 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
3132 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
3133 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
3134 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
3135 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
3136 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
3137 static TSENS_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
3138 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
3139 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3140 ::core::sync::atomic::AtomicU32::new(0);
3141 static CPU_HS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3142 ::core::sync::atomic::AtomicU32::new(0);
3143 static CPU_LS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3144 ::core::sync::atomic::AtomicU32::new(0);
3145 static AHB_HS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3146 ::core::sync::atomic::AtomicU32::new(0);
3147 static AHB_LS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3148 ::core::sync::atomic::AtomicU32::new(0);
3149 static MSPI_FAST_HS_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3150 ::core::sync::atomic::AtomicU32::new(0);
3151 static MSPI_FAST_LS_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3152 ::core::sync::atomic::AtomicU32::new(0);
3153 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3154 ::core::sync::atomic::AtomicU32::new(0);
3155 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3156 ::core::sync::atomic::AtomicU32::new(0);
3157 static MSPI_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3158 ::core::sync::atomic::AtomicU32::new(0);
3159 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
3160 ::core::sync::atomic::AtomicU32::new(0);
3161 #[derive(Debug, enumset::EnumSetType)]
3166 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3167 pub enum ClockSource {
3168 XtalClk,
3170 RcFastClk,
3172 #[cfg(use_xtal32k)]
3173 Xtal32kClk,
3175 OscSlowClk,
3177 RcSlowClk,
3179 }
3180 pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
3182 Some(ClockSource::XtalClk)
3183 }
3184 pub fn pll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3186 xtal_clk_root_source(clocks)
3187 }
3188 pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
3190 Some(ClockSource::RcFastClk)
3191 }
3192 #[cfg(use_xtal32k)]
3193 pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
3195 Some(ClockSource::Xtal32kClk)
3196 }
3197 pub fn osc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
3199 Some(ClockSource::OscSlowClk)
3200 }
3201 pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
3203 Some(ClockSource::RcSlowClk)
3204 }
3205 pub fn soc_root_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3207 let config = clocks.soc_root_clk?;
3208 match config {
3209 SocRootClkConfig::Xtal => xtal_clk_root_source(clocks),
3210 SocRootClkConfig::RcFast => rc_fast_clk_root_source(clocks),
3211 SocRootClkConfig::Pll => pll_clk_root_source(clocks),
3212 }
3213 }
3214 pub fn pll_f48m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3216 pll_clk_root_source(clocks)
3217 }
3218 pub fn pll_f80m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3220 pll_clk_root_source(clocks)
3221 }
3222 pub fn pll_f160m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3224 pll_clk_root_source(clocks)
3225 }
3226 pub fn pll_f240m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3228 pll_clk_root_source(clocks)
3229 }
3230 pub fn iomux_function_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3232 let config = clocks.iomux_function_clock?;
3233 match config {
3234 IomuxFunctionClockConfig::PllF80m => pll_f80m_root_source(clocks),
3235 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_root_source(clocks),
3236 IomuxFunctionClockConfig::XtalClk => xtal_clk_root_source(clocks),
3237 }
3238 }
3239 pub fn ledc_sclk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3241 let config = clocks.ledc_sclk?;
3242 match config {
3243 LedcSclkConfig::PllF80m => pll_f80m_root_source(clocks),
3244 LedcSclkConfig::RcFastClk => rc_fast_clk_root_source(clocks),
3245 LedcSclkConfig::XtalClk => xtal_clk_root_source(clocks),
3246 }
3247 }
3248 pub fn xtal_d2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3250 xtal_clk_root_source(clocks)
3251 }
3252 pub fn lp_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3254 let config = clocks.lp_fast_clk?;
3255 match config {
3256 LpFastClkConfig::RcFastClk => rc_fast_clk_root_source(clocks),
3257 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_root_source(clocks),
3258 }
3259 }
3260 pub fn lp_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3262 let config = clocks.lp_slow_clk?;
3263 match config {
3264 #[cfg(use_xtal32k)]
3265 LpSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
3266 LpSlowClkConfig::RcSlow => rc_slow_clk_root_source(clocks),
3267 LpSlowClkConfig::OscSlow => osc_slow_clk_root_source(clocks),
3268 }
3269 }
3270 pub fn ble_lp_xtal_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3272 xtal_clk_root_source(clocks)
3273 }
3274 pub fn ble_lp_rc_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3276 rc_slow_clk_root_source(clocks)
3277 }
3278 pub fn ble_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3280 let config = clocks.ble_lp_clk?;
3281 match config {
3282 BleLpClkConfig::Xtal => ble_lp_xtal_clk_root_source(clocks),
3283 BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_root_source(clocks),
3284 #[cfg(use_xtal32k)]
3285 BleLpClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
3286 }
3287 }
3288 pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3290 let config = clocks.timg_calibration_clock?;
3291 match config {
3292 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_root_source(clocks),
3293 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_root_source(clocks),
3294 #[cfg(use_xtal32k)]
3295 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
3296 }
3297 }
3298 pub fn hp_root_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3300 soc_root_clk_root_source(clocks)
3301 }
3302 pub fn cpu_hs_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3304 hp_root_clk_root_source(clocks)
3305 }
3306 pub fn cpu_ls_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3308 hp_root_clk_root_source(clocks)
3309 }
3310 pub fn ahb_hs_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3312 hp_root_clk_root_source(clocks)
3313 }
3314 pub fn ahb_ls_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3316 hp_root_clk_root_source(clocks)
3317 }
3318 pub fn mspi_fast_hs_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3320 hp_root_clk_root_source(clocks)
3321 }
3322 pub fn mspi_fast_ls_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3324 hp_root_clk_root_source(clocks)
3325 }
3326 pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3328 let config = clocks.cpu_clk?;
3329 match config {
3330 CpuClkConfig::Hs => cpu_hs_div_root_source(clocks),
3331 CpuClkConfig::Ls => cpu_ls_div_root_source(clocks),
3332 }
3333 }
3334 pub fn ahb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3336 let config = clocks.ahb_clk?;
3337 match config {
3338 AhbClkConfig::Hs => ahb_hs_div_root_source(clocks),
3339 AhbClkConfig::Ls => ahb_ls_div_root_source(clocks),
3340 }
3341 }
3342 pub fn mspi_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3344 let config = clocks.mspi_fast_clk?;
3345 match config {
3346 MspiFastClkConfig::Hs => mspi_fast_hs_clk_root_source(clocks),
3347 MspiFastClkConfig::Ls => mspi_fast_ls_clk_root_source(clocks),
3348 }
3349 }
3350 pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
3352 ahb_clk_root_source(clocks)
3353 }
3354 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
3355 let old_config = clocks.xtal_clk.replace(config);
3356 refresh_xtal_clk_downstream(clocks);
3357 configure_xtal_clk_impl(clocks, old_config, config);
3358 }
3359 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
3360 clocks.xtal_clk
3361 }
3362 fn request_xtal_clk(_clocks: &mut ClockTree) {}
3363 fn release_xtal_clk(_clocks: &mut ClockTree) {}
3364 pub fn xtal_clk_config_frequency(config: XtalClkConfig) -> u32 {
3365 config.value()
3366 }
3367 pub fn xtal_clk_frequency() -> u32 {
3368 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3369 }
3370 pub fn request_pll_clk(clocks: &mut ClockTree) {
3371 trace!("Requesting PLL_CLK");
3372 if increment_reference_count(&mut clocks.pll_clk_refcount) {
3373 trace!("Enabling PLL_CLK");
3374 request_xtal_clk(clocks);
3375 enable_pll_clk_impl(clocks, true);
3376 }
3377 }
3378 pub fn release_pll_clk(clocks: &mut ClockTree) {
3379 trace!("Releasing PLL_CLK");
3380 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
3381 trace!("Disabling PLL_CLK");
3382 enable_pll_clk_impl(clocks, false);
3383 release_xtal_clk(clocks);
3384 }
3385 }
3386 pub fn pll_clk_frequency() -> u32 {
3387 480000000
3388 }
3389 pub fn pll_clk_source_frequency() -> u32 {
3390 xtal_clk_frequency()
3391 }
3392 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
3393 trace!("Requesting RC_FAST_CLK");
3394 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
3395 trace!("Enabling RC_FAST_CLK");
3396 enable_rc_fast_clk_impl(clocks, true);
3397 }
3398 }
3399 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
3400 trace!("Releasing RC_FAST_CLK");
3401 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
3402 trace!("Disabling RC_FAST_CLK");
3403 enable_rc_fast_clk_impl(clocks, false);
3404 }
3405 }
3406 static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
3407 ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
3408 pub const fn rc_fast_clk_nominal_frequency() -> u32 {
3409 17500000
3410 }
3411 pub fn rc_fast_clk_frequency() -> u32 {
3412 RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
3413 }
3414 pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
3415 if !(8750000..=26250000).contains(&frequency) {
3416 warn!(
3417 "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
3418 frequency
3419 );
3420 return;
3421 }
3422 debug!(
3423 "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
3424 frequency,
3425 rc_fast_clk_nominal_frequency()
3426 );
3427 RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
3428 refresh_rc_fast_clk_downstream(clocks);
3429 }
3430 #[cfg(use_xtal32k)]
3431 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
3432 trace!("Requesting XTAL32K_CLK");
3433 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
3434 trace!("Enabling XTAL32K_CLK");
3435 enable_xtal32k_clk_impl(clocks, true);
3436 }
3437 }
3438 #[cfg(use_xtal32k)]
3439 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
3440 trace!("Releasing XTAL32K_CLK");
3441 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
3442 trace!("Disabling XTAL32K_CLK");
3443 enable_xtal32k_clk_impl(clocks, false);
3444 }
3445 }
3446 #[cfg(use_xtal32k)]
3447 pub fn xtal32k_clk_frequency() -> u32 {
3448 32768
3449 }
3450 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
3451 trace!("Enabling OSC_SLOW_CLK");
3452 enable_osc_slow_clk_impl(clocks, true);
3453 }
3454 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
3455 trace!("Disabling OSC_SLOW_CLK");
3456 enable_osc_slow_clk_impl(clocks, false);
3457 }
3458 pub fn osc_slow_clk_frequency() -> u32 {
3459 32768
3460 }
3461 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
3462 trace!("Requesting RC_SLOW_CLK");
3463 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
3464 trace!("Enabling RC_SLOW_CLK");
3465 enable_rc_slow_clk_impl(clocks, true);
3466 }
3467 }
3468 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
3469 trace!("Releasing RC_SLOW_CLK");
3470 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
3471 trace!("Disabling RC_SLOW_CLK");
3472 enable_rc_slow_clk_impl(clocks, false);
3473 }
3474 }
3475 static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
3476 ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
3477 pub const fn rc_slow_clk_nominal_frequency() -> u32 {
3478 136000
3479 }
3480 pub fn rc_slow_clk_frequency() -> u32 {
3481 RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
3482 }
3483 pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
3484 if !(68000..=204000).contains(&frequency) {
3485 warn!(
3486 "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
3487 frequency
3488 );
3489 return;
3490 }
3491 debug!(
3492 "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
3493 frequency,
3494 rc_slow_clk_nominal_frequency()
3495 );
3496 RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
3497 refresh_rc_slow_clk_downstream(clocks);
3498 }
3499 pub fn configure_hp_root_clk(clocks: &mut ClockTree, config: HpRootClkConfig) {
3500 let old_config = clocks.hp_root_clk.replace(config);
3501 refresh_hp_root_clk_downstream(clocks);
3502 configure_hp_root_clk_impl(clocks, old_config, config);
3503 }
3504 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
3505 clocks.hp_root_clk
3506 }
3507 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
3508 trace!("Requesting HP_ROOT_CLK");
3509 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
3510 trace!("Enabling HP_ROOT_CLK");
3511 request_soc_root_clk(clocks);
3512 enable_hp_root_clk_impl(clocks, true);
3513 }
3514 }
3515 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
3516 trace!("Releasing HP_ROOT_CLK");
3517 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
3518 trace!("Disabling HP_ROOT_CLK");
3519 enable_hp_root_clk_impl(clocks, false);
3520 release_soc_root_clk(clocks);
3521 }
3522 }
3523 pub fn hp_root_clk_config_frequency(config: HpRootClkConfig) -> u32 {
3524 (soc_root_clk_frequency() / config.divisor())
3525 }
3526 pub fn hp_root_clk_frequency() -> u32 {
3527 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3528 }
3529 pub fn hp_root_clk_source_frequency() -> u32 {
3530 soc_root_clk_frequency()
3531 }
3532 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
3533 let old_selector = clocks.cpu_clk.replace(new_selector);
3534 refresh_cpu_clk_downstream(clocks);
3535 match new_selector {
3536 CpuClkConfig::Hs => request_cpu_hs_div(clocks),
3537 CpuClkConfig::Ls => request_cpu_ls_div(clocks),
3538 }
3539 configure_cpu_clk_impl(clocks, old_selector, new_selector);
3540 if let Some(old_selector) = old_selector {
3541 match old_selector {
3542 CpuClkConfig::Hs => release_cpu_hs_div(clocks),
3543 CpuClkConfig::Ls => release_cpu_ls_div(clocks),
3544 }
3545 }
3546 }
3547 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
3548 clocks.cpu_clk
3549 }
3550 fn request_cpu_clk(_clocks: &mut ClockTree) {}
3551 fn release_cpu_clk(_clocks: &mut ClockTree) {}
3552 pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
3553 match config {
3554 CpuClkConfig::Hs => cpu_hs_div_frequency(),
3555 CpuClkConfig::Ls => cpu_ls_div_frequency(),
3556 }
3557 }
3558 pub fn cpu_clk_frequency() -> u32 {
3559 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3560 }
3561 pub fn cpu_clk_source_frequency(source: CpuClkConfig) -> u32 {
3562 cpu_clk_config_frequency(source)
3563 }
3564 pub fn configure_ahb_clk(clocks: &mut ClockTree, new_selector: AhbClkConfig) {
3565 let old_selector = clocks.ahb_clk.replace(new_selector);
3566 refresh_ahb_clk_downstream(clocks);
3567 match new_selector {
3568 AhbClkConfig::Hs => request_ahb_hs_div(clocks),
3569 AhbClkConfig::Ls => request_ahb_ls_div(clocks),
3570 }
3571 configure_ahb_clk_impl(clocks, old_selector, new_selector);
3572 if let Some(old_selector) = old_selector {
3573 match old_selector {
3574 AhbClkConfig::Hs => release_ahb_hs_div(clocks),
3575 AhbClkConfig::Ls => release_ahb_ls_div(clocks),
3576 }
3577 }
3578 }
3579 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
3580 clocks.ahb_clk
3581 }
3582 fn request_ahb_clk(_clocks: &mut ClockTree) {}
3583 fn release_ahb_clk(_clocks: &mut ClockTree) {}
3584 pub fn ahb_clk_config_frequency(config: AhbClkConfig) -> u32 {
3585 match config {
3586 AhbClkConfig::Hs => ahb_hs_div_frequency(),
3587 AhbClkConfig::Ls => ahb_ls_div_frequency(),
3588 }
3589 }
3590 pub fn ahb_clk_frequency() -> u32 {
3591 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3592 }
3593 pub fn ahb_clk_source_frequency(source: AhbClkConfig) -> u32 {
3594 ahb_clk_config_frequency(source)
3595 }
3596 pub fn configure_mspi_fast_clk(clocks: &mut ClockTree, new_selector: MspiFastClkConfig) {
3597 let old_selector = clocks.mspi_fast_clk.replace(new_selector);
3598 refresh_mspi_fast_clk_downstream(clocks);
3599 let active = clocks.mspi_fast_clk_refcount > 0;
3600 if active {
3601 match new_selector {
3602 MspiFastClkConfig::Hs => request_mspi_fast_hs_clk(clocks),
3603 MspiFastClkConfig::Ls => request_mspi_fast_ls_clk(clocks),
3604 }
3605 }
3606 configure_mspi_fast_clk_impl(clocks, old_selector, new_selector);
3607 if active && let Some(old_selector) = old_selector {
3608 match old_selector {
3609 MspiFastClkConfig::Hs => release_mspi_fast_hs_clk(clocks),
3610 MspiFastClkConfig::Ls => release_mspi_fast_ls_clk(clocks),
3611 }
3612 }
3613 }
3614 pub fn mspi_fast_clk_config(clocks: &mut ClockTree) -> Option<MspiFastClkConfig> {
3615 clocks.mspi_fast_clk
3616 }
3617 pub fn request_mspi_fast_clk(clocks: &mut ClockTree) {
3618 trace!("Requesting MSPI_FAST_CLK");
3619 if increment_reference_count(&mut clocks.mspi_fast_clk_refcount) {
3620 trace!("Enabling MSPI_FAST_CLK");
3621 match unwrap!(clocks.mspi_fast_clk) {
3622 MspiFastClkConfig::Hs => request_mspi_fast_hs_clk(clocks),
3623 MspiFastClkConfig::Ls => request_mspi_fast_ls_clk(clocks),
3624 }
3625 enable_mspi_fast_clk_impl(clocks, true);
3626 }
3627 }
3628 pub fn release_mspi_fast_clk(clocks: &mut ClockTree) {
3629 trace!("Releasing MSPI_FAST_CLK");
3630 if decrement_reference_count(&mut clocks.mspi_fast_clk_refcount) {
3631 trace!("Disabling MSPI_FAST_CLK");
3632 enable_mspi_fast_clk_impl(clocks, false);
3633 match unwrap!(clocks.mspi_fast_clk) {
3634 MspiFastClkConfig::Hs => release_mspi_fast_hs_clk(clocks),
3635 MspiFastClkConfig::Ls => release_mspi_fast_ls_clk(clocks),
3636 }
3637 }
3638 }
3639 pub fn mspi_fast_clk_config_frequency(config: MspiFastClkConfig) -> u32 {
3640 match config {
3641 MspiFastClkConfig::Hs => mspi_fast_hs_clk_frequency(),
3642 MspiFastClkConfig::Ls => mspi_fast_ls_clk_frequency(),
3643 }
3644 }
3645 pub fn mspi_fast_clk_frequency() -> u32 {
3646 MSPI_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3647 }
3648 pub fn mspi_fast_clk_source_frequency(source: MspiFastClkConfig) -> u32 {
3649 mspi_fast_clk_config_frequency(source)
3650 }
3651 pub fn configure_soc_root_clk(clocks: &mut ClockTree, new_selector: SocRootClkConfig) {
3652 let old_selector = clocks.soc_root_clk.replace(new_selector);
3653 refresh_soc_root_clk_downstream(clocks);
3654 match new_selector {
3655 SocRootClkConfig::Xtal => {
3656 let config_value = HpRootClkConfig::new(HpRootClkDivisor::new(1));
3657 configure_hp_root_clk(clocks, config_value);
3658 configure_cpu_clk(clocks, CpuClkConfig::Ls);
3659 configure_ahb_clk(clocks, AhbClkConfig::Ls);
3660 configure_mspi_fast_clk(clocks, MspiFastClkConfig::Ls);
3661 }
3662 SocRootClkConfig::RcFast => {
3663 let config_value = HpRootClkConfig::new(HpRootClkDivisor::new(1));
3664 configure_hp_root_clk(clocks, config_value);
3665 configure_cpu_clk(clocks, CpuClkConfig::Ls);
3666 configure_ahb_clk(clocks, AhbClkConfig::Ls);
3667 configure_mspi_fast_clk(clocks, MspiFastClkConfig::Ls);
3668 }
3669 SocRootClkConfig::Pll => {
3670 let config_value = HpRootClkConfig::new(HpRootClkDivisor::new(3));
3671 configure_hp_root_clk(clocks, config_value);
3672 configure_cpu_clk(clocks, CpuClkConfig::Hs);
3673 configure_ahb_clk(clocks, AhbClkConfig::Hs);
3674 configure_mspi_fast_clk(clocks, MspiFastClkConfig::Hs);
3675 }
3676 }
3677 match new_selector {
3678 SocRootClkConfig::Xtal => request_xtal_clk(clocks),
3679 SocRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3680 SocRootClkConfig::Pll => request_pll_clk(clocks),
3681 }
3682 configure_soc_root_clk_impl(clocks, old_selector, new_selector);
3683 if let Some(old_selector) = old_selector {
3684 match old_selector {
3685 SocRootClkConfig::Xtal => release_xtal_clk(clocks),
3686 SocRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3687 SocRootClkConfig::Pll => release_pll_clk(clocks),
3688 }
3689 }
3690 }
3691 pub fn soc_root_clk_config(clocks: &mut ClockTree) -> Option<SocRootClkConfig> {
3692 clocks.soc_root_clk
3693 }
3694 pub fn request_soc_root_clk(clocks: &mut ClockTree) {
3695 trace!("Enabling SOC_ROOT_CLK");
3696 match unwrap!(clocks.soc_root_clk) {
3697 SocRootClkConfig::Xtal => request_xtal_clk(clocks),
3698 SocRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3699 SocRootClkConfig::Pll => request_pll_clk(clocks),
3700 }
3701 enable_soc_root_clk_impl(clocks, true);
3702 }
3703 pub fn release_soc_root_clk(clocks: &mut ClockTree) {
3704 trace!("Disabling SOC_ROOT_CLK");
3705 enable_soc_root_clk_impl(clocks, false);
3706 match unwrap!(clocks.soc_root_clk) {
3707 SocRootClkConfig::Xtal => release_xtal_clk(clocks),
3708 SocRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3709 SocRootClkConfig::Pll => release_pll_clk(clocks),
3710 }
3711 }
3712 pub fn soc_root_clk_config_frequency(config: SocRootClkConfig) -> u32 {
3713 match config {
3714 SocRootClkConfig::Xtal => xtal_clk_frequency(),
3715 SocRootClkConfig::RcFast => rc_fast_clk_frequency(),
3716 SocRootClkConfig::Pll => pll_clk_frequency(),
3717 }
3718 }
3719 pub fn soc_root_clk_frequency() -> u32 {
3720 SOC_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3721 }
3722 pub fn configure_cpu_hs_div(clocks: &mut ClockTree, config: CpuHsDivConfig) {
3723 let old_config = clocks.cpu_hs_div.replace(config);
3724 refresh_cpu_hs_div_downstream(clocks);
3725 configure_cpu_hs_div_impl(clocks, old_config, config);
3726 }
3727 pub fn cpu_hs_div_config(clocks: &mut ClockTree) -> Option<CpuHsDivConfig> {
3728 clocks.cpu_hs_div
3729 }
3730 pub fn request_cpu_hs_div(clocks: &mut ClockTree) {
3731 trace!("Enabling CPU_HS_DIV");
3732 request_hp_root_clk(clocks);
3733 enable_cpu_hs_div_impl(clocks, true);
3734 }
3735 pub fn release_cpu_hs_div(clocks: &mut ClockTree) {
3736 trace!("Disabling CPU_HS_DIV");
3737 enable_cpu_hs_div_impl(clocks, false);
3738 release_hp_root_clk(clocks);
3739 }
3740 pub fn cpu_hs_div_config_frequency(config: CpuHsDivConfig) -> u32 {
3741 (hp_root_clk_frequency() / (config.divisor() + 1))
3742 }
3743 pub fn cpu_hs_div_frequency() -> u32 {
3744 CPU_HS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3745 }
3746 pub fn cpu_hs_div_source_frequency() -> u32 {
3747 hp_root_clk_frequency()
3748 }
3749 pub fn configure_cpu_ls_div(clocks: &mut ClockTree, config: CpuLsDivConfig) {
3750 let old_config = clocks.cpu_ls_div.replace(config);
3751 refresh_cpu_ls_div_downstream(clocks);
3752 configure_cpu_ls_div_impl(clocks, old_config, config);
3753 }
3754 pub fn cpu_ls_div_config(clocks: &mut ClockTree) -> Option<CpuLsDivConfig> {
3755 clocks.cpu_ls_div
3756 }
3757 pub fn request_cpu_ls_div(clocks: &mut ClockTree) {
3758 trace!("Enabling CPU_LS_DIV");
3759 request_hp_root_clk(clocks);
3760 enable_cpu_ls_div_impl(clocks, true);
3761 }
3762 pub fn release_cpu_ls_div(clocks: &mut ClockTree) {
3763 trace!("Disabling CPU_LS_DIV");
3764 enable_cpu_ls_div_impl(clocks, false);
3765 release_hp_root_clk(clocks);
3766 }
3767 pub fn cpu_ls_div_config_frequency(config: CpuLsDivConfig) -> u32 {
3768 (hp_root_clk_frequency() / (config.divisor() + 1))
3769 }
3770 pub fn cpu_ls_div_frequency() -> u32 {
3771 CPU_LS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3772 }
3773 pub fn cpu_ls_div_source_frequency() -> u32 {
3774 hp_root_clk_frequency()
3775 }
3776 pub fn configure_ahb_hs_div(clocks: &mut ClockTree, config: AhbHsDivConfig) {
3777 let old_config = clocks.ahb_hs_div.replace(config);
3778 refresh_ahb_hs_div_downstream(clocks);
3779 configure_ahb_hs_div_impl(clocks, old_config, config);
3780 }
3781 pub fn ahb_hs_div_config(clocks: &mut ClockTree) -> Option<AhbHsDivConfig> {
3782 clocks.ahb_hs_div
3783 }
3784 pub fn request_ahb_hs_div(clocks: &mut ClockTree) {
3785 trace!("Enabling AHB_HS_DIV");
3786 request_hp_root_clk(clocks);
3787 enable_ahb_hs_div_impl(clocks, true);
3788 }
3789 pub fn release_ahb_hs_div(clocks: &mut ClockTree) {
3790 trace!("Disabling AHB_HS_DIV");
3791 enable_ahb_hs_div_impl(clocks, false);
3792 release_hp_root_clk(clocks);
3793 }
3794 pub fn ahb_hs_div_config_frequency(config: AhbHsDivConfig) -> u32 {
3795 (hp_root_clk_frequency() / (config.divisor() + 1))
3796 }
3797 pub fn ahb_hs_div_frequency() -> u32 {
3798 AHB_HS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3799 }
3800 pub fn ahb_hs_div_source_frequency() -> u32 {
3801 hp_root_clk_frequency()
3802 }
3803 pub fn configure_ahb_ls_div(clocks: &mut ClockTree, config: AhbLsDivConfig) {
3804 let old_config = clocks.ahb_ls_div.replace(config);
3805 refresh_ahb_ls_div_downstream(clocks);
3806 configure_ahb_ls_div_impl(clocks, old_config, config);
3807 }
3808 pub fn ahb_ls_div_config(clocks: &mut ClockTree) -> Option<AhbLsDivConfig> {
3809 clocks.ahb_ls_div
3810 }
3811 pub fn request_ahb_ls_div(clocks: &mut ClockTree) {
3812 trace!("Enabling AHB_LS_DIV");
3813 request_hp_root_clk(clocks);
3814 enable_ahb_ls_div_impl(clocks, true);
3815 }
3816 pub fn release_ahb_ls_div(clocks: &mut ClockTree) {
3817 trace!("Disabling AHB_LS_DIV");
3818 enable_ahb_ls_div_impl(clocks, false);
3819 release_hp_root_clk(clocks);
3820 }
3821 pub fn ahb_ls_div_config_frequency(config: AhbLsDivConfig) -> u32 {
3822 (hp_root_clk_frequency() / (config.divisor() + 1))
3823 }
3824 pub fn ahb_ls_div_frequency() -> u32 {
3825 AHB_LS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3826 }
3827 pub fn ahb_ls_div_source_frequency() -> u32 {
3828 hp_root_clk_frequency()
3829 }
3830 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
3831 let old_config = clocks.apb_clk.replace(config);
3832 refresh_apb_clk_downstream(clocks);
3833 if old_config.is_none() {
3834 request_ahb_clk(clocks);
3835 }
3836 configure_apb_clk_impl(clocks, old_config, config);
3837 }
3838 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
3839 clocks.apb_clk
3840 }
3841 pub fn request_apb_clk(clocks: &mut ClockTree) {
3842 trace!("Requesting APB_CLK");
3843 if increment_reference_count(&mut clocks.apb_clk_refcount) {
3844 enable_apb_clk_impl(clocks, true);
3845 }
3846 }
3847 pub fn release_apb_clk(clocks: &mut ClockTree) {
3848 trace!("Releasing APB_CLK");
3849 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
3850 enable_apb_clk_impl(clocks, false);
3851 }
3852 }
3853 pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
3854 (ahb_clk_frequency() / (config.divisor() + 1))
3855 }
3856 pub fn apb_clk_frequency() -> u32 {
3857 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3858 }
3859 pub fn apb_clk_source_frequency() -> u32 {
3860 ahb_clk_frequency()
3861 }
3862 pub fn configure_mspi_fast_hs_clk(clocks: &mut ClockTree, config: MspiFastHsClkConfig) {
3863 let old_config = clocks.mspi_fast_hs_clk.replace(config);
3864 refresh_mspi_fast_hs_clk_downstream(clocks);
3865 configure_mspi_fast_hs_clk_impl(clocks, old_config, config);
3866 }
3867 pub fn mspi_fast_hs_clk_config(clocks: &mut ClockTree) -> Option<MspiFastHsClkConfig> {
3868 clocks.mspi_fast_hs_clk
3869 }
3870 pub fn request_mspi_fast_hs_clk(clocks: &mut ClockTree) {
3871 trace!("Enabling MSPI_FAST_HS_CLK");
3872 request_hp_root_clk(clocks);
3873 enable_mspi_fast_hs_clk_impl(clocks, true);
3874 }
3875 pub fn release_mspi_fast_hs_clk(clocks: &mut ClockTree) {
3876 trace!("Disabling MSPI_FAST_HS_CLK");
3877 enable_mspi_fast_hs_clk_impl(clocks, false);
3878 release_hp_root_clk(clocks);
3879 }
3880 pub fn mspi_fast_hs_clk_config_frequency(config: MspiFastHsClkConfig) -> u32 {
3881 (hp_root_clk_frequency() / (config.divisor() + 1))
3882 }
3883 pub fn mspi_fast_hs_clk_frequency() -> u32 {
3884 MSPI_FAST_HS_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3885 }
3886 pub fn mspi_fast_hs_clk_source_frequency() -> u32 {
3887 hp_root_clk_frequency()
3888 }
3889 pub fn configure_mspi_fast_ls_clk(clocks: &mut ClockTree, config: MspiFastLsClkConfig) {
3890 let old_config = clocks.mspi_fast_ls_clk.replace(config);
3891 refresh_mspi_fast_ls_clk_downstream(clocks);
3892 configure_mspi_fast_ls_clk_impl(clocks, old_config, config);
3893 }
3894 pub fn mspi_fast_ls_clk_config(clocks: &mut ClockTree) -> Option<MspiFastLsClkConfig> {
3895 clocks.mspi_fast_ls_clk
3896 }
3897 pub fn request_mspi_fast_ls_clk(clocks: &mut ClockTree) {
3898 trace!("Enabling MSPI_FAST_LS_CLK");
3899 request_hp_root_clk(clocks);
3900 enable_mspi_fast_ls_clk_impl(clocks, true);
3901 }
3902 pub fn release_mspi_fast_ls_clk(clocks: &mut ClockTree) {
3903 trace!("Disabling MSPI_FAST_LS_CLK");
3904 enable_mspi_fast_ls_clk_impl(clocks, false);
3905 release_hp_root_clk(clocks);
3906 }
3907 pub fn mspi_fast_ls_clk_config_frequency(config: MspiFastLsClkConfig) -> u32 {
3908 (hp_root_clk_frequency() / (config.divisor() + 1))
3909 }
3910 pub fn mspi_fast_ls_clk_frequency() -> u32 {
3911 MSPI_FAST_LS_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3912 }
3913 pub fn mspi_fast_ls_clk_source_frequency() -> u32 {
3914 hp_root_clk_frequency()
3915 }
3916 pub fn request_pll_f48m(clocks: &mut ClockTree) {
3917 trace!("Requesting PLL_F48M");
3918 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
3919 trace!("Enabling PLL_F48M");
3920 request_pll_clk(clocks);
3921 enable_pll_f48m_impl(clocks, true);
3922 }
3923 }
3924 pub fn release_pll_f48m(clocks: &mut ClockTree) {
3925 trace!("Releasing PLL_F48M");
3926 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
3927 trace!("Disabling PLL_F48M");
3928 enable_pll_f48m_impl(clocks, false);
3929 release_pll_clk(clocks);
3930 }
3931 }
3932 pub fn pll_f48m_frequency() -> u32 {
3933 48000000
3934 }
3935 pub fn pll_f48m_source_frequency() -> u32 {
3936 pll_clk_frequency()
3937 }
3938 pub fn request_pll_f80m(clocks: &mut ClockTree) {
3939 trace!("Requesting PLL_F80M");
3940 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
3941 trace!("Enabling PLL_F80M");
3942 request_pll_clk(clocks);
3943 enable_pll_f80m_impl(clocks, true);
3944 }
3945 }
3946 pub fn release_pll_f80m(clocks: &mut ClockTree) {
3947 trace!("Releasing PLL_F80M");
3948 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
3949 trace!("Disabling PLL_F80M");
3950 enable_pll_f80m_impl(clocks, false);
3951 release_pll_clk(clocks);
3952 }
3953 }
3954 pub fn pll_f80m_frequency() -> u32 {
3955 80000000
3956 }
3957 pub fn pll_f80m_source_frequency() -> u32 {
3958 pll_clk_frequency()
3959 }
3960 pub fn request_pll_f160m(clocks: &mut ClockTree) {
3961 trace!("Requesting PLL_F160M");
3962 if increment_reference_count(&mut clocks.pll_f160m_refcount) {
3963 trace!("Enabling PLL_F160M");
3964 request_pll_clk(clocks);
3965 enable_pll_f160m_impl(clocks, true);
3966 }
3967 }
3968 pub fn release_pll_f160m(clocks: &mut ClockTree) {
3969 trace!("Releasing PLL_F160M");
3970 if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
3971 trace!("Disabling PLL_F160M");
3972 enable_pll_f160m_impl(clocks, false);
3973 release_pll_clk(clocks);
3974 }
3975 }
3976 pub fn pll_f160m_frequency() -> u32 {
3977 160000000
3978 }
3979 pub fn pll_f160m_source_frequency() -> u32 {
3980 pll_clk_frequency()
3981 }
3982 pub fn request_pll_f240m(clocks: &mut ClockTree) {
3983 trace!("Requesting PLL_F240M");
3984 if increment_reference_count(&mut clocks.pll_f240m_refcount) {
3985 trace!("Enabling PLL_F240M");
3986 request_pll_clk(clocks);
3987 enable_pll_f240m_impl(clocks, true);
3988 }
3989 }
3990 pub fn release_pll_f240m(clocks: &mut ClockTree) {
3991 trace!("Releasing PLL_F240M");
3992 if decrement_reference_count(&mut clocks.pll_f240m_refcount) {
3993 trace!("Disabling PLL_F240M");
3994 enable_pll_f240m_impl(clocks, false);
3995 release_pll_clk(clocks);
3996 }
3997 }
3998 pub fn pll_f240m_frequency() -> u32 {
3999 240000000
4000 }
4001 pub fn pll_f240m_source_frequency() -> u32 {
4002 pll_clk_frequency()
4003 }
4004 pub fn configure_iomux_function_clock(
4005 clocks: &mut ClockTree,
4006 new_selector: IomuxFunctionClockConfig,
4007 ) {
4008 let old_selector = clocks.iomux_function_clock.replace(new_selector);
4009 refresh_iomux_function_clock_downstream(clocks);
4010 match new_selector {
4011 IomuxFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4012 IomuxFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4013 IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4014 }
4015 configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
4016 if let Some(old_selector) = old_selector {
4017 match old_selector {
4018 IomuxFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4019 IomuxFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4020 IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4021 }
4022 }
4023 }
4024 pub fn iomux_function_clock_config(
4025 clocks: &mut ClockTree,
4026 ) -> Option<IomuxFunctionClockConfig> {
4027 clocks.iomux_function_clock
4028 }
4029 fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
4030 fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
4031 pub fn iomux_function_clock_config_frequency(config: IomuxFunctionClockConfig) -> u32 {
4032 match config {
4033 IomuxFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4034 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4035 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4036 }
4037 }
4038 pub fn iomux_function_clock_frequency() -> u32 {
4039 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
4040 }
4041 pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
4042 iomux_function_clock_config_frequency(source)
4043 }
4044 pub fn configure_ledc_sclk(clocks: &mut ClockTree, new_selector: LedcSclkConfig) {
4045 let old_selector = clocks.ledc_sclk.replace(new_selector);
4046 refresh_ledc_sclk_downstream(clocks);
4047 let active = clocks.ledc_sclk_refcount > 0;
4048 if active {
4049 match new_selector {
4050 LedcSclkConfig::PllF80m => request_pll_f80m(clocks),
4051 LedcSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4052 LedcSclkConfig::XtalClk => request_xtal_clk(clocks),
4053 }
4054 }
4055 configure_ledc_sclk_impl(clocks, old_selector, new_selector);
4056 if active && let Some(old_selector) = old_selector {
4057 match old_selector {
4058 LedcSclkConfig::PllF80m => release_pll_f80m(clocks),
4059 LedcSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4060 LedcSclkConfig::XtalClk => release_xtal_clk(clocks),
4061 }
4062 }
4063 }
4064 pub fn ledc_sclk_config(clocks: &mut ClockTree) -> Option<LedcSclkConfig> {
4065 clocks.ledc_sclk
4066 }
4067 pub fn request_ledc_sclk(clocks: &mut ClockTree) {
4068 trace!("Requesting LEDC_SCLK");
4069 if increment_reference_count(&mut clocks.ledc_sclk_refcount) {
4070 trace!("Enabling LEDC_SCLK");
4071 match unwrap!(clocks.ledc_sclk) {
4072 LedcSclkConfig::PllF80m => request_pll_f80m(clocks),
4073 LedcSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4074 LedcSclkConfig::XtalClk => request_xtal_clk(clocks),
4075 }
4076 enable_ledc_sclk_impl(clocks, true);
4077 }
4078 }
4079 pub fn release_ledc_sclk(clocks: &mut ClockTree) {
4080 trace!("Releasing LEDC_SCLK");
4081 if decrement_reference_count(&mut clocks.ledc_sclk_refcount) {
4082 trace!("Disabling LEDC_SCLK");
4083 enable_ledc_sclk_impl(clocks, false);
4084 match unwrap!(clocks.ledc_sclk) {
4085 LedcSclkConfig::PllF80m => release_pll_f80m(clocks),
4086 LedcSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4087 LedcSclkConfig::XtalClk => release_xtal_clk(clocks),
4088 }
4089 }
4090 }
4091 pub fn ledc_sclk_config_frequency(config: LedcSclkConfig) -> u32 {
4092 match config {
4093 LedcSclkConfig::PllF80m => pll_f80m_frequency(),
4094 LedcSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4095 LedcSclkConfig::XtalClk => xtal_clk_frequency(),
4096 }
4097 }
4098 pub fn ledc_sclk_frequency() -> u32 {
4099 LEDC_SCLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
4100 }
4101 pub fn ledc_sclk_source_frequency(source: LedcSclkConfig) -> u32 {
4102 ledc_sclk_config_frequency(source)
4103 }
4104 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
4105 trace!("Enabling XTAL_D2_CLK");
4106 request_xtal_clk(clocks);
4107 enable_xtal_d2_clk_impl(clocks, true);
4108 }
4109 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
4110 trace!("Disabling XTAL_D2_CLK");
4111 enable_xtal_d2_clk_impl(clocks, false);
4112 release_xtal_clk(clocks);
4113 }
4114 pub fn xtal_d2_clk_frequency() -> u32 {
4115 (xtal_clk_frequency() / 2)
4116 }
4117 pub fn xtal_d2_clk_source_frequency() -> u32 {
4118 xtal_clk_frequency()
4119 }
4120 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
4121 let old_selector = clocks.lp_fast_clk.replace(new_selector);
4122 refresh_lp_fast_clk_downstream(clocks);
4123 let active = clocks.lp_fast_clk_refcount > 0;
4124 if active {
4125 match new_selector {
4126 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4127 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
4128 }
4129 }
4130 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
4131 if active && let Some(old_selector) = old_selector {
4132 match old_selector {
4133 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4134 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
4135 }
4136 }
4137 }
4138 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
4139 clocks.lp_fast_clk
4140 }
4141 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
4142 trace!("Requesting LP_FAST_CLK");
4143 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
4144 trace!("Enabling LP_FAST_CLK");
4145 match unwrap!(clocks.lp_fast_clk) {
4146 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4147 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
4148 }
4149 enable_lp_fast_clk_impl(clocks, true);
4150 }
4151 }
4152 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
4153 trace!("Releasing LP_FAST_CLK");
4154 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
4155 trace!("Disabling LP_FAST_CLK");
4156 enable_lp_fast_clk_impl(clocks, false);
4157 match unwrap!(clocks.lp_fast_clk) {
4158 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4159 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
4160 }
4161 }
4162 }
4163 pub fn lp_fast_clk_config_frequency(config: LpFastClkConfig) -> u32 {
4164 match config {
4165 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
4166 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
4167 }
4168 }
4169 pub fn lp_fast_clk_frequency() -> u32 {
4170 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
4171 }
4172 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
4173 lp_fast_clk_config_frequency(source)
4174 }
4175 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
4176 let old_selector = clocks.lp_slow_clk.replace(new_selector);
4177 refresh_lp_slow_clk_downstream(clocks);
4178 match new_selector {
4179 #[cfg(use_xtal32k)]
4180 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
4181 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
4182 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
4183 }
4184 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
4185 if let Some(old_selector) = old_selector {
4186 match old_selector {
4187 #[cfg(use_xtal32k)]
4188 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
4189 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
4190 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
4191 }
4192 }
4193 }
4194 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
4195 clocks.lp_slow_clk
4196 }
4197 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
4198 trace!("Enabling LP_SLOW_CLK");
4199 match unwrap!(clocks.lp_slow_clk) {
4200 #[cfg(use_xtal32k)]
4201 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
4202 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
4203 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
4204 }
4205 enable_lp_slow_clk_impl(clocks, true);
4206 }
4207 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
4208 trace!("Disabling LP_SLOW_CLK");
4209 enable_lp_slow_clk_impl(clocks, false);
4210 match unwrap!(clocks.lp_slow_clk) {
4211 #[cfg(use_xtal32k)]
4212 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
4213 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
4214 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
4215 }
4216 }
4217 pub fn lp_slow_clk_config_frequency(config: LpSlowClkConfig) -> u32 {
4218 match config {
4219 #[cfg(use_xtal32k)]
4220 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
4221 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
4222 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
4223 }
4224 }
4225 pub fn lp_slow_clk_frequency() -> u32 {
4226 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
4227 }
4228 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
4229 lp_slow_clk_config_frequency(source)
4230 }
4231 pub fn request_ble_lp_xtal_clk(clocks: &mut ClockTree) {
4232 trace!("Enabling BLE_LP_XTAL_CLK");
4233 request_xtal_clk(clocks);
4234 enable_ble_lp_xtal_clk_impl(clocks, true);
4235 }
4236 pub fn release_ble_lp_xtal_clk(clocks: &mut ClockTree) {
4237 trace!("Disabling BLE_LP_XTAL_CLK");
4238 enable_ble_lp_xtal_clk_impl(clocks, false);
4239 release_xtal_clk(clocks);
4240 }
4241 pub fn ble_lp_xtal_clk_frequency() -> u32 {
4242 100000
4243 }
4244 pub fn ble_lp_xtal_clk_source_frequency() -> u32 {
4245 xtal_clk_frequency()
4246 }
4247 pub fn request_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
4248 trace!("Enabling BLE_LP_RC_SLOW_CLK");
4249 request_rc_slow_clk(clocks);
4250 enable_ble_lp_rc_slow_clk_impl(clocks, true);
4251 }
4252 pub fn release_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
4253 trace!("Disabling BLE_LP_RC_SLOW_CLK");
4254 enable_ble_lp_rc_slow_clk_impl(clocks, false);
4255 release_rc_slow_clk(clocks);
4256 }
4257 pub fn ble_lp_rc_slow_clk_frequency() -> u32 {
4258 (rc_slow_clk_frequency() / 5)
4259 }
4260 pub fn ble_lp_rc_slow_clk_source_frequency() -> u32 {
4261 rc_slow_clk_frequency()
4262 }
4263 pub fn configure_ble_lp_clk(clocks: &mut ClockTree, new_selector: BleLpClkConfig) {
4264 let old_selector = clocks.ble_lp_clk.replace(new_selector);
4265 refresh_ble_lp_clk_downstream(clocks);
4266 let active = clocks.ble_lp_clk_refcount > 0;
4267 if active {
4268 match new_selector {
4269 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
4270 BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
4271 #[cfg(use_xtal32k)]
4272 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
4273 }
4274 }
4275 configure_ble_lp_clk_impl(clocks, old_selector, new_selector);
4276 if active && let Some(old_selector) = old_selector {
4277 match old_selector {
4278 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
4279 BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
4280 #[cfg(use_xtal32k)]
4281 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
4282 }
4283 }
4284 }
4285 pub fn ble_lp_clk_config(clocks: &mut ClockTree) -> Option<BleLpClkConfig> {
4286 clocks.ble_lp_clk
4287 }
4288 pub fn request_ble_lp_clk(clocks: &mut ClockTree) {
4289 trace!("Requesting BLE_LP_CLK");
4290 if increment_reference_count(&mut clocks.ble_lp_clk_refcount) {
4291 trace!("Enabling BLE_LP_CLK");
4292 match unwrap!(clocks.ble_lp_clk) {
4293 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
4294 BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
4295 #[cfg(use_xtal32k)]
4296 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
4297 }
4298 enable_ble_lp_clk_impl(clocks, true);
4299 }
4300 }
4301 pub fn release_ble_lp_clk(clocks: &mut ClockTree) {
4302 trace!("Releasing BLE_LP_CLK");
4303 if decrement_reference_count(&mut clocks.ble_lp_clk_refcount) {
4304 trace!("Disabling BLE_LP_CLK");
4305 enable_ble_lp_clk_impl(clocks, false);
4306 match unwrap!(clocks.ble_lp_clk) {
4307 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
4308 BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
4309 #[cfg(use_xtal32k)]
4310 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
4311 }
4312 }
4313 }
4314 pub fn ble_lp_clk_config_frequency(config: BleLpClkConfig) -> u32 {
4315 match config {
4316 BleLpClkConfig::Xtal => ble_lp_xtal_clk_frequency(),
4317 BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_frequency(),
4318 #[cfg(use_xtal32k)]
4319 BleLpClkConfig::Xtal32k => xtal32k_clk_frequency(),
4320 }
4321 }
4322 pub fn ble_lp_clk_frequency() -> u32 {
4323 BLE_LP_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
4324 }
4325 pub fn ble_lp_clk_source_frequency(source: BleLpClkConfig) -> u32 {
4326 ble_lp_clk_config_frequency(source)
4327 }
4328 pub fn configure_timg_calibration_clock(
4329 clocks: &mut ClockTree,
4330 new_selector: TimgCalibrationClockConfig,
4331 ) {
4332 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
4333 refresh_timg_calibration_clock_downstream(clocks);
4334 let active = clocks.timg_calibration_clock_refcount > 0;
4335 if active {
4336 match new_selector {
4337 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
4338 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
4339 #[cfg(use_xtal32k)]
4340 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
4341 }
4342 }
4343 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
4344 if active && let Some(old_selector) = old_selector {
4345 match old_selector {
4346 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
4347 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
4348 #[cfg(use_xtal32k)]
4349 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
4350 }
4351 }
4352 }
4353 pub fn timg_calibration_clock_config(
4354 clocks: &mut ClockTree,
4355 ) -> Option<TimgCalibrationClockConfig> {
4356 clocks.timg_calibration_clock
4357 }
4358 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
4359 trace!("Requesting TIMG_CALIBRATION_CLOCK");
4360 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
4361 trace!("Enabling TIMG_CALIBRATION_CLOCK");
4362 crate::rtc_cntl::WakeLock::acquire();
4363 match unwrap!(clocks.timg_calibration_clock) {
4364 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
4365 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
4366 #[cfg(use_xtal32k)]
4367 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
4368 }
4369 enable_timg_calibration_clock_impl(clocks, true);
4370 }
4371 }
4372 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
4373 trace!("Releasing TIMG_CALIBRATION_CLOCK");
4374 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
4375 trace!("Disabling TIMG_CALIBRATION_CLOCK");
4376 crate::rtc_cntl::WakeLock::release();
4377 enable_timg_calibration_clock_impl(clocks, false);
4378 match unwrap!(clocks.timg_calibration_clock) {
4379 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
4380 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
4381 #[cfg(use_xtal32k)]
4382 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
4383 }
4384 }
4385 }
4386 pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
4387 match config {
4388 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
4389 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
4390 #[cfg(use_xtal32k)]
4391 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
4392 }
4393 }
4394 pub fn timg_calibration_clock_frequency() -> u32 {
4395 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
4396 }
4397 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
4398 timg_calibration_clock_config_frequency(source)
4399 }
4400 impl AdcInstance {
4401 pub fn configure_function_clock(
4402 self,
4403 clocks: &mut ClockTree,
4404 new_selector: AdcFunctionClockConfig,
4405 ) {
4406 let old_selector = clocks.adc_function_clock[self as usize].replace(new_selector);
4407 refresh_adc_function_clock_downstream(clocks, self);
4408 let active = clocks.adc_function_clock_refcount[self as usize] > 0;
4409 if active {
4410 match new_selector {
4411 AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4412 AdcFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4413 AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4414 }
4415 }
4416 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4417 if active && let Some(old_selector) = old_selector {
4418 match old_selector {
4419 AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4420 AdcFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4421 AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4422 }
4423 }
4424 }
4425 pub fn function_clock_config(
4426 self,
4427 clocks: &mut ClockTree,
4428 ) -> Option<AdcFunctionClockConfig> {
4429 clocks.adc_function_clock[self as usize]
4430 }
4431 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4432 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4433 if increment_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
4434 {
4435 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4436 match unwrap!(clocks.adc_function_clock[self as usize]) {
4437 AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4438 AdcFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4439 AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4440 }
4441 self.enable_function_clock_impl(clocks, true);
4442 }
4443 }
4444 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4445 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4446 if decrement_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
4447 {
4448 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4449 self.enable_function_clock_impl(clocks, false);
4450 match unwrap!(clocks.adc_function_clock[self as usize]) {
4451 AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4452 AdcFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4453 AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4454 }
4455 }
4456 }
4457 pub fn function_clock_config_frequency(config: AdcFunctionClockConfig) -> u32 {
4458 match config {
4459 AdcFunctionClockConfig::Xtal => xtal_clk_frequency(),
4460 AdcFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4461 AdcFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
4462 }
4463 }
4464 pub fn function_clock_frequency(self) -> u32 {
4465 ADC_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4466 .load(::core::sync::atomic::Ordering::Acquire)
4467 }
4468 pub fn function_clock_source_frequency(source: AdcFunctionClockConfig) -> u32 {
4469 Self::function_clock_config_frequency(source)
4470 }
4471 }
4472 impl SdmInstance {
4473 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4474 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4475 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
4476 {
4477 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4478 request_iomux_function_clock(clocks);
4479 self.enable_function_clock_impl(clocks, true);
4480 }
4481 }
4482 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4483 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4484 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
4485 {
4486 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4487 self.enable_function_clock_impl(clocks, false);
4488 release_iomux_function_clock(clocks);
4489 }
4490 }
4491 pub fn function_clock_frequency(self) -> u32 {
4492 iomux_function_clock_frequency()
4493 }
4494 pub fn function_clock_source_frequency() -> u32 {
4495 iomux_function_clock_frequency()
4496 }
4497 }
4498 impl I2cInstance {
4499 pub fn configure_function_clock(
4500 self,
4501 clocks: &mut ClockTree,
4502 config: I2cFunctionClockConfig,
4503 ) {
4504 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
4505 refresh_i2c_function_clock_downstream(clocks, self);
4506 let active = clocks.i2c_function_clock_refcount[self as usize] > 0;
4507 if active {
4508 match config.sclk {
4509 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4510 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4511 }
4512 }
4513 self.configure_function_clock_impl(clocks, old_config, config);
4514 if active && let Some(old_config) = old_config {
4515 match old_config.sclk {
4516 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4517 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4518 }
4519 }
4520 }
4521 pub fn function_clock_config(
4522 self,
4523 clocks: &mut ClockTree,
4524 ) -> Option<I2cFunctionClockConfig> {
4525 clocks.i2c_function_clock[self as usize]
4526 }
4527 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4528 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4529 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
4530 {
4531 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4532 crate::rtc_cntl::WakeLock::acquire();
4533 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
4534 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4535 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4536 }
4537 self.enable_function_clock_impl(clocks, true);
4538 }
4539 }
4540 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4541 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4542 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
4543 {
4544 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4545 crate::rtc_cntl::WakeLock::release();
4546 self.enable_function_clock_impl(clocks, false);
4547 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
4548 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4549 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4550 }
4551 }
4552 }
4553 pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
4554 (match config.sclk {
4555 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4556 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4557 } / (config.div_num() + 1))
4558 }
4559 pub fn function_clock_frequency(self) -> u32 {
4560 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4561 .load(::core::sync::atomic::Ordering::Acquire)
4562 }
4563 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
4564 match sclk {
4565 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4566 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4567 }
4568 }
4569 }
4570 impl I2sInstance {
4571 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
4572 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
4573 refresh_i2s_tx_clk_downstream(clocks, self);
4574 let active = clocks.i2s_tx_clk_refcount[self as usize] > 0;
4575 if active {
4576 match config.sclk {
4577 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4578 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4579 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4580 }
4581 }
4582 self.configure_tx_clk_impl(clocks, old_config, config);
4583 if active && let Some(old_config) = old_config {
4584 match old_config.sclk {
4585 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4586 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4587 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4588 }
4589 }
4590 }
4591 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
4592 clocks.i2s_tx_clk[self as usize]
4593 }
4594 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
4595 trace!("Requesting {:?}::TX_CLK", self);
4596 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
4597 trace!("Enabling {:?}::TX_CLK", self);
4598 crate::rtc_cntl::WakeLock::acquire();
4599 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
4600 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4601 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4602 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4603 }
4604 self.enable_tx_clk_impl(clocks, true);
4605 }
4606 }
4607 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
4608 trace!("Releasing {:?}::TX_CLK", self);
4609 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
4610 trace!("Disabling {:?}::TX_CLK", self);
4611 crate::rtc_cntl::WakeLock::release();
4612 self.enable_tx_clk_impl(clocks, false);
4613 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
4614 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4615 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4616 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4617 }
4618 }
4619 }
4620 pub fn tx_clk_config_frequency(config: I2sClkConfig) -> u32 {
4621 (((match config.sclk {
4622 I2sClkSclk::Xtal => xtal_clk_frequency(),
4623 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4624 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4625 } as u64)
4626 * (config.div_a() as u64))
4627 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
4628 as u32
4629 }
4630 pub fn tx_clk_frequency(self) -> u32 {
4631 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4632 }
4633 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
4634 match sclk {
4635 I2sClkSclk::Xtal => xtal_clk_frequency(),
4636 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4637 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4638 }
4639 }
4640 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
4641 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
4642 refresh_i2s_rx_clk_downstream(clocks, self);
4643 let active = clocks.i2s_rx_clk_refcount[self as usize] > 0;
4644 if active {
4645 match config.sclk {
4646 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4647 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4648 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4649 }
4650 }
4651 self.configure_rx_clk_impl(clocks, old_config, config);
4652 if active && let Some(old_config) = old_config {
4653 match old_config.sclk {
4654 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4655 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4656 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4657 }
4658 }
4659 }
4660 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
4661 clocks.i2s_rx_clk[self as usize]
4662 }
4663 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
4664 trace!("Requesting {:?}::RX_CLK", self);
4665 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
4666 trace!("Enabling {:?}::RX_CLK", self);
4667 crate::rtc_cntl::WakeLock::acquire();
4668 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
4669 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4670 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4671 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4672 }
4673 self.enable_rx_clk_impl(clocks, true);
4674 }
4675 }
4676 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
4677 trace!("Releasing {:?}::RX_CLK", self);
4678 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
4679 trace!("Disabling {:?}::RX_CLK", self);
4680 crate::rtc_cntl::WakeLock::release();
4681 self.enable_rx_clk_impl(clocks, false);
4682 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
4683 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4684 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4685 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4686 }
4687 }
4688 }
4689 pub fn rx_clk_config_frequency(config: I2sClkConfig) -> u32 {
4690 (((match config.sclk {
4691 I2sClkSclk::Xtal => xtal_clk_frequency(),
4692 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4693 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4694 } as u64)
4695 * (config.div_a() as u64))
4696 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
4697 as u32
4698 }
4699 pub fn rx_clk_frequency(self) -> u32 {
4700 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4701 }
4702 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
4703 match sclk {
4704 I2sClkSclk::Xtal => xtal_clk_frequency(),
4705 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4706 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4707 }
4708 }
4709 pub fn configure_mclk_out(
4710 self,
4711 clocks: &mut ClockTree,
4712 new_selector: I2sMclkOutConfig,
4713 ) {
4714 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
4715 refresh_i2s_mclk_out_downstream(clocks, self);
4716 let active = clocks.i2s_mclk_out_refcount[self as usize] > 0;
4717 if active {
4718 match new_selector {
4719 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
4720 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
4721 }
4722 }
4723 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
4724 if active && let Some(old_selector) = old_selector {
4725 match old_selector {
4726 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
4727 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
4728 }
4729 }
4730 }
4731 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
4732 clocks.i2s_mclk_out[self as usize]
4733 }
4734 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
4735 trace!("Requesting {:?}::MCLK_OUT", self);
4736 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
4737 trace!("Enabling {:?}::MCLK_OUT", self);
4738 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
4739 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
4740 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
4741 }
4742 self.enable_mclk_out_impl(clocks, true);
4743 }
4744 }
4745 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
4746 trace!("Releasing {:?}::MCLK_OUT", self);
4747 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
4748 trace!("Disabling {:?}::MCLK_OUT", self);
4749 self.enable_mclk_out_impl(clocks, false);
4750 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
4751 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
4752 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
4753 }
4754 }
4755 }
4756 pub fn mclk_out_config_frequency(self, config: I2sMclkOutConfig) -> u32 {
4757 match config {
4758 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
4759 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
4760 }
4761 }
4762 pub fn mclk_out_frequency(self) -> u32 {
4763 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4764 }
4765 }
4766 impl McpwmInstance {
4767 pub fn configure_function_clock(
4768 self,
4769 clocks: &mut ClockTree,
4770 new_selector: McpwmFunctionClockConfig,
4771 ) {
4772 let old_selector = clocks.mcpwm_function_clock[self as usize].replace(new_selector);
4773 refresh_mcpwm_function_clock_downstream(clocks, self);
4774 let active = clocks.mcpwm_function_clock_refcount[self as usize] > 0;
4775 if active {
4776 match new_selector {
4777 McpwmFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
4778 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4779 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4780 }
4781 }
4782 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4783 if active && let Some(old_selector) = old_selector {
4784 match old_selector {
4785 McpwmFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
4786 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4787 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4788 }
4789 }
4790 }
4791 pub fn function_clock_config(
4792 self,
4793 clocks: &mut ClockTree,
4794 ) -> Option<McpwmFunctionClockConfig> {
4795 clocks.mcpwm_function_clock[self as usize]
4796 }
4797 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4798 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4799 if increment_reference_count(
4800 &mut clocks.mcpwm_function_clock_refcount[self as usize],
4801 ) {
4802 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4803 crate::rtc_cntl::WakeLock::acquire();
4804 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
4805 McpwmFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
4806 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4807 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4808 }
4809 self.enable_function_clock_impl(clocks, true);
4810 }
4811 }
4812 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4813 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4814 if decrement_reference_count(
4815 &mut clocks.mcpwm_function_clock_refcount[self as usize],
4816 ) {
4817 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4818 crate::rtc_cntl::WakeLock::release();
4819 self.enable_function_clock_impl(clocks, false);
4820 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
4821 McpwmFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
4822 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4823 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4824 }
4825 }
4826 }
4827 pub fn function_clock_config_frequency(config: McpwmFunctionClockConfig) -> u32 {
4828 match config {
4829 McpwmFunctionClockConfig::PllF160m => pll_f160m_frequency(),
4830 McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4831 McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4832 }
4833 }
4834 pub fn function_clock_frequency(self) -> u32 {
4835 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4836 .load(::core::sync::atomic::Ordering::Acquire)
4837 }
4838 pub fn function_clock_source_frequency(source: McpwmFunctionClockConfig) -> u32 {
4839 Self::function_clock_config_frequency(source)
4840 }
4841 }
4842 impl ParlIoInstance {
4843 pub fn configure_rx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4844 let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
4845 refresh_parl_io_rx_clock_downstream(clocks, self);
4846 let active = clocks.parl_io_rx_clock_refcount[self as usize] > 0;
4847 if active {
4848 match new_selector {
4849 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4850 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4851 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4852 }
4853 }
4854 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
4855 if active && let Some(old_selector) = old_selector {
4856 match old_selector {
4857 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4858 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4859 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4860 }
4861 }
4862 }
4863 pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4864 clocks.parl_io_rx_clock[self as usize]
4865 }
4866 pub fn request_rx_clock(self, clocks: &mut ClockTree) {
4867 trace!("Requesting {:?}::RX_CLOCK", self);
4868 if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
4869 trace!("Enabling {:?}::RX_CLOCK", self);
4870 crate::rtc_cntl::WakeLock::acquire();
4871 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4872 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4873 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4874 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4875 }
4876 self.enable_rx_clock_impl(clocks, true);
4877 }
4878 }
4879 pub fn release_rx_clock(self, clocks: &mut ClockTree) {
4880 trace!("Releasing {:?}::RX_CLOCK", self);
4881 if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
4882 trace!("Disabling {:?}::RX_CLOCK", self);
4883 crate::rtc_cntl::WakeLock::release();
4884 self.enable_rx_clock_impl(clocks, false);
4885 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4886 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4887 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4888 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4889 }
4890 }
4891 }
4892 pub fn rx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
4893 match config {
4894 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4895 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4896 ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4897 }
4898 }
4899 pub fn rx_clock_frequency(self) -> u32 {
4900 PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
4901 .load(::core::sync::atomic::Ordering::Acquire)
4902 }
4903 pub fn rx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4904 Self::rx_clock_config_frequency(source)
4905 }
4906 pub fn configure_tx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4907 let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
4908 refresh_parl_io_tx_clock_downstream(clocks, self);
4909 let active = clocks.parl_io_tx_clock_refcount[self as usize] > 0;
4910 if active {
4911 match new_selector {
4912 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4913 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4914 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4915 }
4916 }
4917 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
4918 if active && let Some(old_selector) = old_selector {
4919 match old_selector {
4920 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4921 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4922 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4923 }
4924 }
4925 }
4926 pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4927 clocks.parl_io_tx_clock[self as usize]
4928 }
4929 pub fn request_tx_clock(self, clocks: &mut ClockTree) {
4930 trace!("Requesting {:?}::TX_CLOCK", self);
4931 if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4932 trace!("Enabling {:?}::TX_CLOCK", self);
4933 crate::rtc_cntl::WakeLock::acquire();
4934 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4935 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4936 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4937 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4938 }
4939 self.enable_tx_clock_impl(clocks, true);
4940 }
4941 }
4942 pub fn release_tx_clock(self, clocks: &mut ClockTree) {
4943 trace!("Releasing {:?}::TX_CLOCK", self);
4944 if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4945 trace!("Disabling {:?}::TX_CLOCK", self);
4946 crate::rtc_cntl::WakeLock::release();
4947 self.enable_tx_clock_impl(clocks, false);
4948 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4949 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4950 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4951 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4952 }
4953 }
4954 }
4955 pub fn tx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
4956 match config {
4957 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4958 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4959 ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4960 }
4961 }
4962 pub fn tx_clock_frequency(self) -> u32 {
4963 PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
4964 .load(::core::sync::atomic::Ordering::Acquire)
4965 }
4966 pub fn tx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4967 Self::tx_clock_config_frequency(source)
4968 }
4969 }
4970 impl PcntInstance {
4971 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4972 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4973 if increment_reference_count(
4974 &mut clocks.pcnt_function_clock_refcount[self as usize],
4975 ) {
4976 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4977 request_apb_clk(clocks);
4978 self.enable_function_clock_impl(clocks, true);
4979 }
4980 }
4981 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4982 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4983 if decrement_reference_count(
4984 &mut clocks.pcnt_function_clock_refcount[self as usize],
4985 ) {
4986 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4987 self.enable_function_clock_impl(clocks, false);
4988 release_apb_clk(clocks);
4989 }
4990 }
4991 pub fn function_clock_frequency(self) -> u32 {
4992 apb_clk_frequency()
4993 }
4994 pub fn function_clock_source_frequency() -> u32 {
4995 apb_clk_frequency()
4996 }
4997 }
4998 impl RmtInstance {
4999 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
5000 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
5001 refresh_rmt_sclk_downstream(clocks, self);
5002 let active = clocks.rmt_sclk_refcount[self as usize] > 0;
5003 if active {
5004 match new_selector {
5005 RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
5006 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
5007 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
5008 }
5009 }
5010 self.configure_sclk_impl(clocks, old_selector, new_selector);
5011 if active && let Some(old_selector) = old_selector {
5012 match old_selector {
5013 RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
5014 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
5015 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
5016 }
5017 }
5018 }
5019 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
5020 clocks.rmt_sclk[self as usize]
5021 }
5022 pub fn request_sclk(self, clocks: &mut ClockTree) {
5023 trace!("Requesting {:?}::SCLK", self);
5024 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
5025 trace!("Enabling {:?}::SCLK", self);
5026 crate::rtc_cntl::WakeLock::acquire();
5027 match unwrap!(clocks.rmt_sclk[self as usize]) {
5028 RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
5029 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
5030 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
5031 }
5032 self.enable_sclk_impl(clocks, true);
5033 }
5034 }
5035 pub fn release_sclk(self, clocks: &mut ClockTree) {
5036 trace!("Releasing {:?}::SCLK", self);
5037 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
5038 trace!("Disabling {:?}::SCLK", self);
5039 crate::rtc_cntl::WakeLock::release();
5040 self.enable_sclk_impl(clocks, false);
5041 match unwrap!(clocks.rmt_sclk[self as usize]) {
5042 RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
5043 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
5044 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
5045 }
5046 }
5047 }
5048 pub fn sclk_config_frequency(config: RmtSclkConfig) -> u32 {
5049 match config {
5050 RmtSclkConfig::PllF80m => pll_f80m_frequency(),
5051 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
5052 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
5053 }
5054 }
5055 pub fn sclk_frequency(self) -> u32 {
5056 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
5057 }
5058 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
5059 Self::sclk_config_frequency(source)
5060 }
5061 }
5062 impl SpiInstance {
5063 pub fn configure_function_clock(
5064 self,
5065 clocks: &mut ClockTree,
5066 new_selector: SpiFunctionClockConfig,
5067 ) {
5068 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
5069 refresh_spi_function_clock_downstream(clocks, self);
5070 let active = clocks.spi_function_clock_refcount[self as usize] > 0;
5071 if active {
5072 match new_selector {
5073 SpiFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
5074 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
5075 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
5076 }
5077 }
5078 self.configure_function_clock_impl(clocks, old_selector, new_selector);
5079 if active && let Some(old_selector) = old_selector {
5080 match old_selector {
5081 SpiFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
5082 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
5083 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
5084 }
5085 }
5086 }
5087 pub fn function_clock_config(
5088 self,
5089 clocks: &mut ClockTree,
5090 ) -> Option<SpiFunctionClockConfig> {
5091 clocks.spi_function_clock[self as usize]
5092 }
5093 pub fn request_function_clock(self, clocks: &mut ClockTree) {
5094 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
5095 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
5096 {
5097 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
5098 crate::rtc_cntl::WakeLock::acquire();
5099 match unwrap!(clocks.spi_function_clock[self as usize]) {
5100 SpiFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
5101 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
5102 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
5103 }
5104 self.enable_function_clock_impl(clocks, true);
5105 }
5106 }
5107 pub fn release_function_clock(self, clocks: &mut ClockTree) {
5108 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
5109 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
5110 {
5111 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
5112 crate::rtc_cntl::WakeLock::release();
5113 self.enable_function_clock_impl(clocks, false);
5114 match unwrap!(clocks.spi_function_clock[self as usize]) {
5115 SpiFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
5116 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
5117 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
5118 }
5119 }
5120 }
5121 pub fn function_clock_config_frequency(config: SpiFunctionClockConfig) -> u32 {
5122 match config {
5123 SpiFunctionClockConfig::PllF80m => pll_f80m_frequency(),
5124 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
5125 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
5126 }
5127 }
5128 pub fn function_clock_frequency(self) -> u32 {
5129 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
5130 .load(::core::sync::atomic::Ordering::Acquire)
5131 }
5132 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
5133 Self::function_clock_config_frequency(source)
5134 }
5135 }
5136 impl TimgInstance {
5137 pub fn configure_function_clock(
5138 self,
5139 clocks: &mut ClockTree,
5140 new_selector: TimgFunctionClockConfig,
5141 ) {
5142 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
5143 refresh_timg_function_clock_downstream(clocks, self);
5144 let active = clocks.timg_function_clock_refcount[self as usize] > 0;
5145 if active {
5146 match new_selector {
5147 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
5148 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
5149 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
5150 }
5151 }
5152 self.configure_function_clock_impl(clocks, old_selector, new_selector);
5153 if active && let Some(old_selector) = old_selector {
5154 match old_selector {
5155 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
5156 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
5157 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
5158 }
5159 }
5160 }
5161 pub fn function_clock_config(
5162 self,
5163 clocks: &mut ClockTree,
5164 ) -> Option<TimgFunctionClockConfig> {
5165 clocks.timg_function_clock[self as usize]
5166 }
5167 pub fn request_function_clock(self, clocks: &mut ClockTree) {
5168 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
5169 if increment_reference_count(
5170 &mut clocks.timg_function_clock_refcount[self as usize],
5171 ) {
5172 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
5173 match unwrap!(clocks.timg_function_clock[self as usize]) {
5174 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
5175 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
5176 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
5177 }
5178 self.enable_function_clock_impl(clocks, true);
5179 }
5180 }
5181 pub fn release_function_clock(self, clocks: &mut ClockTree) {
5182 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
5183 if decrement_reference_count(
5184 &mut clocks.timg_function_clock_refcount[self as usize],
5185 ) {
5186 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
5187 self.enable_function_clock_impl(clocks, false);
5188 match unwrap!(clocks.timg_function_clock[self as usize]) {
5189 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
5190 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
5191 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
5192 }
5193 }
5194 }
5195 pub fn function_clock_config_frequency(config: TimgFunctionClockConfig) -> u32 {
5196 match config {
5197 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
5198 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
5199 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
5200 }
5201 }
5202 pub fn function_clock_frequency(self) -> u32 {
5203 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
5204 .load(::core::sync::atomic::Ordering::Acquire)
5205 }
5206 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
5207 Self::function_clock_config_frequency(source)
5208 }
5209 pub fn configure_wdt_clock(
5210 self,
5211 clocks: &mut ClockTree,
5212 new_selector: TimgWdtClockConfig,
5213 ) {
5214 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
5215 refresh_timg_wdt_clock_downstream(clocks, self);
5216 let active = clocks.timg_wdt_clock_refcount[self as usize] > 0;
5217 if active {
5218 match new_selector {
5219 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
5220 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
5221 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
5222 }
5223 }
5224 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
5225 if active && let Some(old_selector) = old_selector {
5226 match old_selector {
5227 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
5228 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
5229 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
5230 }
5231 }
5232 }
5233 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
5234 clocks.timg_wdt_clock[self as usize]
5235 }
5236 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
5237 trace!("Requesting {:?}::WDT_CLOCK", self);
5238 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
5239 trace!("Enabling {:?}::WDT_CLOCK", self);
5240 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
5241 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
5242 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
5243 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
5244 }
5245 self.enable_wdt_clock_impl(clocks, true);
5246 }
5247 }
5248 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
5249 trace!("Releasing {:?}::WDT_CLOCK", self);
5250 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
5251 trace!("Disabling {:?}::WDT_CLOCK", self);
5252 self.enable_wdt_clock_impl(clocks, false);
5253 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
5254 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
5255 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
5256 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
5257 }
5258 }
5259 }
5260 pub fn wdt_clock_config_frequency(config: TimgWdtClockConfig) -> u32 {
5261 match config {
5262 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
5263 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
5264 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
5265 }
5266 }
5267 pub fn wdt_clock_frequency(self) -> u32 {
5268 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
5269 .load(::core::sync::atomic::Ordering::Acquire)
5270 }
5271 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
5272 Self::wdt_clock_config_frequency(source)
5273 }
5274 }
5275 impl UartInstance {
5276 pub fn configure_function_clock(
5277 self,
5278 clocks: &mut ClockTree,
5279 config: UartFunctionClockConfig,
5280 ) {
5281 let old_config = clocks.uart_function_clock[self as usize].replace(config);
5282 refresh_uart_function_clock_downstream(clocks, self);
5283 let active = clocks.uart_function_clock_refcount[self as usize] > 0;
5284 if active {
5285 match config.sclk {
5286 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
5287 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
5288 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
5289 }
5290 }
5291 self.configure_function_clock_impl(clocks, old_config, config);
5292 if active && let Some(old_config) = old_config {
5293 match old_config.sclk {
5294 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
5295 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
5296 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
5297 }
5298 }
5299 }
5300 pub fn function_clock_config(
5301 self,
5302 clocks: &mut ClockTree,
5303 ) -> Option<UartFunctionClockConfig> {
5304 clocks.uart_function_clock[self as usize]
5305 }
5306 pub fn request_function_clock(self, clocks: &mut ClockTree) {
5307 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
5308 if increment_reference_count(
5309 &mut clocks.uart_function_clock_refcount[self as usize],
5310 ) {
5311 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
5312 crate::rtc_cntl::WakeLock::acquire();
5313 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
5314 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
5315 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
5316 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
5317 }
5318 self.enable_function_clock_impl(clocks, true);
5319 }
5320 }
5321 pub fn release_function_clock(self, clocks: &mut ClockTree) {
5322 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
5323 if decrement_reference_count(
5324 &mut clocks.uart_function_clock_refcount[self as usize],
5325 ) {
5326 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
5327 crate::rtc_cntl::WakeLock::release();
5328 self.enable_function_clock_impl(clocks, false);
5329 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
5330 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
5331 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
5332 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
5333 }
5334 }
5335 }
5336 pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
5337 (match config.sclk {
5338 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
5339 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
5340 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
5341 } / (config.div_num() + 1))
5342 }
5343 pub fn function_clock_frequency(self) -> u32 {
5344 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
5345 .load(::core::sync::atomic::Ordering::Acquire)
5346 }
5347 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
5348 match sclk {
5349 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
5350 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
5351 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
5352 }
5353 }
5354 pub fn configure_baud_rate_generator(
5355 self,
5356 clocks: &mut ClockTree,
5357 config: UartBaudRateGeneratorConfig,
5358 ) {
5359 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
5360 refresh_uart_baud_rate_generator_downstream(clocks, self);
5361 self.configure_baud_rate_generator_impl(clocks, old_config, config);
5362 }
5363 pub fn baud_rate_generator_config(
5364 self,
5365 clocks: &mut ClockTree,
5366 ) -> Option<UartBaudRateGeneratorConfig> {
5367 clocks.uart_baud_rate_generator[self as usize]
5368 }
5369 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
5370 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
5371 if increment_reference_count(
5372 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
5373 ) {
5374 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
5375 self.request_function_clock(clocks);
5376 self.enable_baud_rate_generator_impl(clocks, true);
5377 }
5378 }
5379 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
5380 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
5381 if decrement_reference_count(
5382 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
5383 ) {
5384 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
5385 self.enable_baud_rate_generator_impl(clocks, false);
5386 self.release_function_clock(clocks);
5387 }
5388 }
5389 pub fn baud_rate_generator_config_frequency(
5390 self,
5391 config: UartBaudRateGeneratorConfig,
5392 ) -> u32 {
5393 ((self.function_clock_frequency() * 16)
5394 / ((config.integral() * 16) + config.fractional()))
5395 }
5396 pub fn baud_rate_generator_frequency(self) -> u32 {
5397 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
5398 .load(::core::sync::atomic::Ordering::Acquire)
5399 }
5400 }
5401 impl TsensInstance {
5402 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: TsensSclkConfig) {
5403 let old_selector = clocks.tsens_sclk[self as usize].replace(new_selector);
5404 refresh_tsens_sclk_downstream(clocks, self);
5405 let active = clocks.tsens_sclk_refcount[self as usize] > 0;
5406 if active {
5407 match new_selector {
5408 TsensSclkConfig::RcFast => request_rc_fast_clk(clocks),
5409 TsensSclkConfig::Xtal => request_xtal_clk(clocks),
5410 }
5411 }
5412 self.configure_sclk_impl(clocks, old_selector, new_selector);
5413 if active && let Some(old_selector) = old_selector {
5414 match old_selector {
5415 TsensSclkConfig::RcFast => release_rc_fast_clk(clocks),
5416 TsensSclkConfig::Xtal => release_xtal_clk(clocks),
5417 }
5418 }
5419 }
5420 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<TsensSclkConfig> {
5421 clocks.tsens_sclk[self as usize]
5422 }
5423 pub fn request_sclk(self, clocks: &mut ClockTree) {
5424 trace!("Requesting {:?}::SCLK", self);
5425 if increment_reference_count(&mut clocks.tsens_sclk_refcount[self as usize]) {
5426 trace!("Enabling {:?}::SCLK", self);
5427 match unwrap!(clocks.tsens_sclk[self as usize]) {
5428 TsensSclkConfig::RcFast => request_rc_fast_clk(clocks),
5429 TsensSclkConfig::Xtal => request_xtal_clk(clocks),
5430 }
5431 self.enable_sclk_impl(clocks, true);
5432 }
5433 }
5434 pub fn release_sclk(self, clocks: &mut ClockTree) {
5435 trace!("Releasing {:?}::SCLK", self);
5436 if decrement_reference_count(&mut clocks.tsens_sclk_refcount[self as usize]) {
5437 trace!("Disabling {:?}::SCLK", self);
5438 self.enable_sclk_impl(clocks, false);
5439 match unwrap!(clocks.tsens_sclk[self as usize]) {
5440 TsensSclkConfig::RcFast => release_rc_fast_clk(clocks),
5441 TsensSclkConfig::Xtal => release_xtal_clk(clocks),
5442 }
5443 }
5444 }
5445 pub fn sclk_config_frequency(config: TsensSclkConfig) -> u32 {
5446 match config {
5447 TsensSclkConfig::RcFast => rc_fast_clk_frequency(),
5448 TsensSclkConfig::Xtal => xtal_clk_frequency(),
5449 }
5450 }
5451 pub fn sclk_frequency(self) -> u32 {
5452 TSENS_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
5453 }
5454 pub fn sclk_source_frequency(source: TsensSclkConfig) -> u32 {
5455 Self::sclk_config_frequency(source)
5456 }
5457 }
5458 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5466 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5467 #[instability::unstable]
5468 pub struct ClockConfig {
5469 pub xtal_clk: Option<XtalClkConfig>,
5471 pub soc_root_clk: Option<SocRootClkConfig>,
5473 pub cpu_hs_div: Option<CpuHsDivConfig>,
5475 pub cpu_ls_div: Option<CpuLsDivConfig>,
5477 pub ahb_hs_div: Option<AhbHsDivConfig>,
5479 pub ahb_ls_div: Option<AhbLsDivConfig>,
5481 pub apb_clk: Option<ApbClkConfig>,
5483 pub mspi_fast_hs_clk: Option<MspiFastHsClkConfig>,
5485 pub mspi_fast_ls_clk: Option<MspiFastLsClkConfig>,
5487 pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
5489 pub ledc_sclk: Option<LedcSclkConfig>,
5491 pub lp_fast_clk: Option<LpFastClkConfig>,
5493 pub lp_slow_clk: Option<LpSlowClkConfig>,
5495 pub ble_lp_clk: Option<BleLpClkConfig>,
5497 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
5499 }
5500 impl ClockConfig {
5501 fn apply(&self, clocks: &mut ClockTree) {
5502 if let Some(config) = self.xtal_clk {
5503 configure_xtal_clk(clocks, config);
5504 }
5505 if let Some(config) = self.soc_root_clk {
5506 configure_soc_root_clk(clocks, config);
5507 }
5508 if let Some(config) = self.iomux_function_clock {
5509 configure_iomux_function_clock(clocks, config);
5510 }
5511 if let Some(config) = self.ledc_sclk {
5512 configure_ledc_sclk(clocks, config);
5513 }
5514 if let Some(config) = self.lp_fast_clk {
5515 configure_lp_fast_clk(clocks, config);
5516 }
5517 if let Some(config) = self.lp_slow_clk {
5518 configure_lp_slow_clk(clocks, config);
5519 }
5520 if let Some(config) = self.ble_lp_clk {
5521 configure_ble_lp_clk(clocks, config);
5522 }
5523 if let Some(config) = self.timg_calibration_clock {
5524 configure_timg_calibration_clock(clocks, config);
5525 }
5526 if let Some(config) = self.cpu_hs_div {
5527 configure_cpu_hs_div(clocks, config);
5528 }
5529 if let Some(config) = self.cpu_ls_div {
5530 configure_cpu_ls_div(clocks, config);
5531 }
5532 if let Some(config) = self.ahb_hs_div {
5533 configure_ahb_hs_div(clocks, config);
5534 }
5535 if let Some(config) = self.ahb_ls_div {
5536 configure_ahb_ls_div(clocks, config);
5537 }
5538 if let Some(config) = self.mspi_fast_hs_clk {
5539 configure_mspi_fast_hs_clk(clocks, config);
5540 }
5541 if let Some(config) = self.mspi_fast_ls_clk {
5542 configure_mspi_fast_ls_clk(clocks, config);
5543 }
5544 if let Some(config) = self.apb_clk {
5545 configure_apb_clk(clocks, config);
5546 }
5547 }
5548 }
5549 fn increment_reference_count(refcount: &mut u32) -> bool {
5550 let first = *refcount == 0;
5551 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
5552 first
5553 }
5554 fn decrement_reference_count(refcount: &mut u32) -> bool {
5555 *refcount = refcount.saturating_sub(1);
5556 let last = *refcount == 0;
5557 last
5558 }
5559 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
5560 if let Some(config) = clocks.xtal_clk {
5561 XTAL_CLK_FREQ_CACHE.store(
5562 xtal_clk_config_frequency(config),
5563 ::core::sync::atomic::Ordering::Release,
5564 );
5565 }
5566 refresh_soc_root_clk_downstream(clocks);
5567 refresh_iomux_function_clock_downstream(clocks);
5568 refresh_ledc_sclk_downstream(clocks);
5569 refresh_lp_fast_clk_downstream(clocks);
5570 refresh_ble_lp_clk_downstream(clocks);
5571 for child_instance in [AdcInstance::ApbSaradc] {
5572 refresh_adc_function_clock_downstream(clocks, child_instance);
5573 }
5574 for child_instance in [I2cInstance::I2c0] {
5575 refresh_i2c_function_clock_downstream(clocks, child_instance);
5576 }
5577 for child_instance in [I2sInstance::I2s0] {
5578 refresh_i2s_tx_clk_downstream(clocks, child_instance);
5579 refresh_i2s_rx_clk_downstream(clocks, child_instance);
5580 }
5581 for child_instance in [McpwmInstance::Mcpwm0] {
5582 refresh_mcpwm_function_clock_downstream(clocks, child_instance);
5583 }
5584 for child_instance in [ParlIoInstance::ParlIo] {
5585 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
5586 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
5587 }
5588 for child_instance in [RmtInstance::Rmt] {
5589 refresh_rmt_sclk_downstream(clocks, child_instance);
5590 }
5591 for child_instance in [SpiInstance::Spi2] {
5592 refresh_spi_function_clock_downstream(clocks, child_instance);
5593 }
5594 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
5595 refresh_timg_function_clock_downstream(clocks, child_instance);
5596 refresh_timg_wdt_clock_downstream(clocks, child_instance);
5597 }
5598 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
5599 refresh_uart_function_clock_downstream(clocks, child_instance);
5600 }
5601 for child_instance in [TsensInstance::Tsens] {
5602 refresh_tsens_sclk_downstream(clocks, child_instance);
5603 }
5604 }
5605 fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
5606 refresh_soc_root_clk_downstream(clocks);
5607 refresh_iomux_function_clock_downstream(clocks);
5608 refresh_ledc_sclk_downstream(clocks);
5609 refresh_lp_fast_clk_downstream(clocks);
5610 refresh_timg_calibration_clock_downstream(clocks);
5611 for child_instance in [AdcInstance::ApbSaradc] {
5612 refresh_adc_function_clock_downstream(clocks, child_instance);
5613 }
5614 for child_instance in [I2cInstance::I2c0] {
5615 refresh_i2c_function_clock_downstream(clocks, child_instance);
5616 }
5617 for child_instance in [McpwmInstance::Mcpwm0] {
5618 refresh_mcpwm_function_clock_downstream(clocks, child_instance);
5619 }
5620 for child_instance in [ParlIoInstance::ParlIo] {
5621 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
5622 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
5623 }
5624 for child_instance in [RmtInstance::Rmt] {
5625 refresh_rmt_sclk_downstream(clocks, child_instance);
5626 }
5627 for child_instance in [SpiInstance::Spi2] {
5628 refresh_spi_function_clock_downstream(clocks, child_instance);
5629 }
5630 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
5631 refresh_timg_function_clock_downstream(clocks, child_instance);
5632 refresh_timg_wdt_clock_downstream(clocks, child_instance);
5633 }
5634 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
5635 refresh_uart_function_clock_downstream(clocks, child_instance);
5636 }
5637 for child_instance in [TsensInstance::Tsens] {
5638 refresh_tsens_sclk_downstream(clocks, child_instance);
5639 }
5640 }
5641 fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
5642 refresh_lp_slow_clk_downstream(clocks);
5643 refresh_ble_lp_clk_downstream(clocks);
5644 }
5645 fn refresh_soc_root_clk_downstream(clocks: &mut ClockTree) {
5646 if let Some(config) = clocks.soc_root_clk {
5647 SOC_ROOT_CLK_FREQ_CACHE.store(
5648 soc_root_clk_config_frequency(config),
5649 ::core::sync::atomic::Ordering::Release,
5650 );
5651 }
5652 refresh_hp_root_clk_downstream(clocks);
5653 }
5654 fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
5655 if let Some(config) = clocks.iomux_function_clock {
5656 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
5657 iomux_function_clock_config_frequency(config),
5658 ::core::sync::atomic::Ordering::Release,
5659 );
5660 }
5661 }
5662 fn refresh_ledc_sclk_downstream(clocks: &mut ClockTree) {
5663 if let Some(config) = clocks.ledc_sclk {
5664 LEDC_SCLK_FREQ_CACHE.store(
5665 ledc_sclk_config_frequency(config),
5666 ::core::sync::atomic::Ordering::Release,
5667 );
5668 }
5669 }
5670 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
5671 if let Some(config) = clocks.lp_fast_clk {
5672 LP_FAST_CLK_FREQ_CACHE.store(
5673 lp_fast_clk_config_frequency(config),
5674 ::core::sync::atomic::Ordering::Release,
5675 );
5676 }
5677 }
5678 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
5679 if let Some(config) = clocks.lp_slow_clk {
5680 LP_SLOW_CLK_FREQ_CACHE.store(
5681 lp_slow_clk_config_frequency(config),
5682 ::core::sync::atomic::Ordering::Release,
5683 );
5684 }
5685 refresh_timg_calibration_clock_downstream(clocks);
5686 }
5687 fn refresh_ble_lp_clk_downstream(clocks: &mut ClockTree) {
5688 if let Some(config) = clocks.ble_lp_clk {
5689 BLE_LP_CLK_FREQ_CACHE.store(
5690 ble_lp_clk_config_frequency(config),
5691 ::core::sync::atomic::Ordering::Release,
5692 );
5693 }
5694 }
5695 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
5696 if let Some(config) = clocks.timg_calibration_clock {
5697 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
5698 timg_calibration_clock_config_frequency(config),
5699 ::core::sync::atomic::Ordering::Release,
5700 );
5701 }
5702 }
5703 fn refresh_adc_function_clock_downstream(clocks: &mut ClockTree, instance: AdcInstance) {
5704 if let Some(config) = clocks.adc_function_clock[instance as usize] {
5705 ADC_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5706 AdcInstance::function_clock_config_frequency(config),
5707 ::core::sync::atomic::Ordering::Release,
5708 );
5709 }
5710 }
5711 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
5712 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
5713 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5714 I2cInstance::function_clock_config_frequency(config),
5715 ::core::sync::atomic::Ordering::Release,
5716 );
5717 }
5718 }
5719 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5720 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
5721 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
5722 I2sInstance::tx_clk_config_frequency(config),
5723 ::core::sync::atomic::Ordering::Release,
5724 );
5725 }
5726 refresh_i2s_mclk_out_downstream(clocks, instance);
5727 }
5728 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5729 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
5730 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
5731 I2sInstance::rx_clk_config_frequency(config),
5732 ::core::sync::atomic::Ordering::Release,
5733 );
5734 }
5735 refresh_i2s_mclk_out_downstream(clocks, instance);
5736 }
5737 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5738 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
5739 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
5740 instance.mclk_out_config_frequency(config),
5741 ::core::sync::atomic::Ordering::Release,
5742 );
5743 }
5744 }
5745 fn refresh_mcpwm_function_clock_downstream(
5746 clocks: &mut ClockTree,
5747 instance: McpwmInstance,
5748 ) {
5749 if let Some(config) = clocks.mcpwm_function_clock[instance as usize] {
5750 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5751 McpwmInstance::function_clock_config_frequency(config),
5752 ::core::sync::atomic::Ordering::Release,
5753 );
5754 }
5755 }
5756 fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
5757 if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
5758 PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
5759 ParlIoInstance::rx_clock_config_frequency(config),
5760 ::core::sync::atomic::Ordering::Release,
5761 );
5762 }
5763 }
5764 fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
5765 if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
5766 PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
5767 ParlIoInstance::tx_clock_config_frequency(config),
5768 ::core::sync::atomic::Ordering::Release,
5769 );
5770 }
5771 }
5772 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
5773 if let Some(config) = clocks.rmt_sclk[instance as usize] {
5774 RMT_SCLK_FREQ_CACHE[instance as usize].store(
5775 RmtInstance::sclk_config_frequency(config),
5776 ::core::sync::atomic::Ordering::Release,
5777 );
5778 }
5779 }
5780 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
5781 if let Some(config) = clocks.spi_function_clock[instance as usize] {
5782 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5783 SpiInstance::function_clock_config_frequency(config),
5784 ::core::sync::atomic::Ordering::Release,
5785 );
5786 }
5787 }
5788 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
5789 if let Some(config) = clocks.timg_function_clock[instance as usize] {
5790 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5791 TimgInstance::function_clock_config_frequency(config),
5792 ::core::sync::atomic::Ordering::Release,
5793 );
5794 }
5795 }
5796 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
5797 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
5798 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
5799 TimgInstance::wdt_clock_config_frequency(config),
5800 ::core::sync::atomic::Ordering::Release,
5801 );
5802 }
5803 }
5804 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
5805 if let Some(config) = clocks.uart_function_clock[instance as usize] {
5806 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5807 UartInstance::function_clock_config_frequency(config),
5808 ::core::sync::atomic::Ordering::Release,
5809 );
5810 }
5811 refresh_uart_baud_rate_generator_downstream(clocks, instance);
5812 }
5813 fn refresh_uart_baud_rate_generator_downstream(
5814 clocks: &mut ClockTree,
5815 instance: UartInstance,
5816 ) {
5817 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
5818 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
5819 instance.baud_rate_generator_config_frequency(config),
5820 ::core::sync::atomic::Ordering::Release,
5821 );
5822 }
5823 }
5824 fn refresh_tsens_sclk_downstream(clocks: &mut ClockTree, instance: TsensInstance) {
5825 if let Some(config) = clocks.tsens_sclk[instance as usize] {
5826 TSENS_SCLK_FREQ_CACHE[instance as usize].store(
5827 TsensInstance::sclk_config_frequency(config),
5828 ::core::sync::atomic::Ordering::Release,
5829 );
5830 }
5831 }
5832 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
5833 if let Some(config) = clocks.hp_root_clk {
5834 HP_ROOT_CLK_FREQ_CACHE.store(
5835 hp_root_clk_config_frequency(config),
5836 ::core::sync::atomic::Ordering::Release,
5837 );
5838 }
5839 refresh_cpu_hs_div_downstream(clocks);
5840 refresh_cpu_ls_div_downstream(clocks);
5841 refresh_ahb_hs_div_downstream(clocks);
5842 refresh_ahb_ls_div_downstream(clocks);
5843 refresh_mspi_fast_hs_clk_downstream(clocks);
5844 refresh_mspi_fast_ls_clk_downstream(clocks);
5845 }
5846 fn refresh_cpu_hs_div_downstream(clocks: &mut ClockTree) {
5847 if let Some(config) = clocks.cpu_hs_div {
5848 CPU_HS_DIV_FREQ_CACHE.store(
5849 cpu_hs_div_config_frequency(config),
5850 ::core::sync::atomic::Ordering::Release,
5851 );
5852 }
5853 refresh_cpu_clk_downstream(clocks);
5854 }
5855 fn refresh_cpu_ls_div_downstream(clocks: &mut ClockTree) {
5856 if let Some(config) = clocks.cpu_ls_div {
5857 CPU_LS_DIV_FREQ_CACHE.store(
5858 cpu_ls_div_config_frequency(config),
5859 ::core::sync::atomic::Ordering::Release,
5860 );
5861 }
5862 refresh_cpu_clk_downstream(clocks);
5863 }
5864 fn refresh_ahb_hs_div_downstream(clocks: &mut ClockTree) {
5865 if let Some(config) = clocks.ahb_hs_div {
5866 AHB_HS_DIV_FREQ_CACHE.store(
5867 ahb_hs_div_config_frequency(config),
5868 ::core::sync::atomic::Ordering::Release,
5869 );
5870 }
5871 refresh_ahb_clk_downstream(clocks);
5872 }
5873 fn refresh_ahb_ls_div_downstream(clocks: &mut ClockTree) {
5874 if let Some(config) = clocks.ahb_ls_div {
5875 AHB_LS_DIV_FREQ_CACHE.store(
5876 ahb_ls_div_config_frequency(config),
5877 ::core::sync::atomic::Ordering::Release,
5878 );
5879 }
5880 refresh_ahb_clk_downstream(clocks);
5881 }
5882 fn refresh_mspi_fast_hs_clk_downstream(clocks: &mut ClockTree) {
5883 if let Some(config) = clocks.mspi_fast_hs_clk {
5884 MSPI_FAST_HS_CLK_FREQ_CACHE.store(
5885 mspi_fast_hs_clk_config_frequency(config),
5886 ::core::sync::atomic::Ordering::Release,
5887 );
5888 }
5889 refresh_mspi_fast_clk_downstream(clocks);
5890 }
5891 fn refresh_mspi_fast_ls_clk_downstream(clocks: &mut ClockTree) {
5892 if let Some(config) = clocks.mspi_fast_ls_clk {
5893 MSPI_FAST_LS_CLK_FREQ_CACHE.store(
5894 mspi_fast_ls_clk_config_frequency(config),
5895 ::core::sync::atomic::Ordering::Release,
5896 );
5897 }
5898 refresh_mspi_fast_clk_downstream(clocks);
5899 }
5900 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
5901 if let Some(config) = clocks.cpu_clk {
5902 CPU_CLK_FREQ_CACHE.store(
5903 cpu_clk_config_frequency(config),
5904 ::core::sync::atomic::Ordering::Release,
5905 );
5906 }
5907 }
5908 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
5909 if let Some(config) = clocks.ahb_clk {
5910 AHB_CLK_FREQ_CACHE.store(
5911 ahb_clk_config_frequency(config),
5912 ::core::sync::atomic::Ordering::Release,
5913 );
5914 }
5915 refresh_apb_clk_downstream(clocks);
5916 }
5917 fn refresh_mspi_fast_clk_downstream(clocks: &mut ClockTree) {
5918 if let Some(config) = clocks.mspi_fast_clk {
5919 MSPI_FAST_CLK_FREQ_CACHE.store(
5920 mspi_fast_clk_config_frequency(config),
5921 ::core::sync::atomic::Ordering::Release,
5922 );
5923 }
5924 }
5925 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
5926 if let Some(config) = clocks.apb_clk {
5927 APB_CLK_FREQ_CACHE.store(
5928 apb_clk_config_frequency(config),
5929 ::core::sync::atomic::Ordering::Release,
5930 );
5931 }
5932 }
5933 };
5934}
5935#[macro_export]
5939#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5940macro_rules! implement_peripheral_clocks {
5941 () => {
5942 #[doc(hidden)]
5943 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5944 #[repr(u8)]
5945 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5946 pub enum Peripheral {
5947 Aes,
5949 AhbGdma,
5951 ApbSarAdc,
5953 Ds,
5955 Ecc,
5957 Etm,
5959 GpioSd,
5961 Hmac,
5963 I2cExt0,
5965 I2s0,
5967 Ledc,
5969 Mcpwm0,
5971 ParlIo,
5973 Pcnt,
5975 Rmt,
5977 Rsa,
5979 SdioSlave,
5981 Sha,
5983 Spi2,
5985 Systimer,
5987 Timg0,
5989 Timg1,
5991 Trace0,
5993 Tsens,
5995 Twai0,
5997 Twai1,
5999 Uart0,
6001 Uart1,
6003 Uhci0,
6005 UsbDevice,
6007 }
6008 impl Peripheral {
6009 const KEEP_ENABLED: &[Peripheral] = &[
6010 Self::ApbSarAdc,
6011 Self::Systimer,
6012 Self::Timg0,
6013 Self::Uart0,
6014 Self::UsbDevice,
6015 ];
6016 const COUNT: usize = Self::ALL.len();
6017 const ALL: &[Self] = &[
6018 Self::Aes,
6019 Self::AhbGdma,
6020 Self::ApbSarAdc,
6021 Self::Ds,
6022 Self::Ecc,
6023 Self::Etm,
6024 Self::GpioSd,
6025 Self::Hmac,
6026 Self::I2cExt0,
6027 Self::I2s0,
6028 Self::Ledc,
6029 Self::Mcpwm0,
6030 Self::ParlIo,
6031 Self::Pcnt,
6032 Self::Rmt,
6033 Self::Rsa,
6034 Self::SdioSlave,
6035 Self::Sha,
6036 Self::Spi2,
6037 Self::Systimer,
6038 Self::Timg0,
6039 Self::Timg1,
6040 Self::Trace0,
6041 Self::Tsens,
6042 Self::Twai0,
6043 Self::Twai1,
6044 Self::Uart0,
6045 Self::Uart1,
6046 Self::Uhci0,
6047 Self::UsbDevice,
6048 ];
6049 }
6050 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
6051 match peripheral {
6052 Peripheral::Aes => {
6053 crate::peripherals::SYSTEM::regs()
6054 .aes_conf()
6055 .modify(|_, w| w.aes_clk_en().bit(enable));
6056 }
6057 Peripheral::AhbGdma => {
6058 crate::peripherals::SYSTEM::regs()
6059 .gdma_conf()
6060 .modify(|_, w| w.gdma_clk_en().bit(enable));
6061 }
6062 Peripheral::ApbSarAdc => {
6063 crate::peripherals::SYSTEM::regs()
6064 .saradc_conf()
6065 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
6066 }
6067 Peripheral::Ds => {
6068 crate::peripherals::SYSTEM::regs()
6069 .ds_conf()
6070 .modify(|_, w| w.ds_clk_en().bit(enable));
6071 }
6072 Peripheral::Ecc => {
6073 crate::peripherals::SYSTEM::regs()
6074 .ecc_conf()
6075 .modify(|_, w| w.ecc_clk_en().bit(enable));
6076 }
6077 Peripheral::Etm => {
6078 crate::peripherals::SYSTEM::regs()
6079 .etm_conf()
6080 .modify(|_, w| w.etm_clk_en().bit(enable));
6081 }
6082 Peripheral::GpioSd => {
6083 crate::peripherals::GPIO_SD::regs()
6084 .clock_gate()
6085 .modify(|_, w| w.clk_en().bit(enable));
6086 }
6087 Peripheral::Hmac => {
6088 crate::peripherals::SYSTEM::regs()
6089 .hmac_conf()
6090 .modify(|_, w| w.hmac_clk_en().bit(enable));
6091 }
6092 Peripheral::I2cExt0 => {
6093 crate::peripherals::SYSTEM::regs()
6094 .i2c0_conf()
6095 .modify(|_, w| w.i2c0_clk_en().bit(enable));
6096 }
6097 Peripheral::I2s0 => {
6098 crate::peripherals::SYSTEM::regs()
6099 .i2s_conf()
6100 .modify(|_, w| w.i2s_clk_en().bit(enable));
6101 }
6102 Peripheral::Ledc => {
6103 crate::peripherals::SYSTEM::regs()
6104 .ledc_conf()
6105 .modify(|_, w| w.ledc_clk_en().bit(enable));
6106 }
6107 Peripheral::Mcpwm0 => {
6108 crate::peripherals::SYSTEM::regs()
6109 .pwm_conf()
6110 .modify(|_, w| w.pwm_clk_en().bit(enable));
6111 }
6112 Peripheral::ParlIo => {
6113 crate::peripherals::SYSTEM::regs()
6114 .parl_io_conf()
6115 .modify(|_, w| w.parl_clk_en().bit(enable));
6116 }
6117 Peripheral::Pcnt => {
6118 crate::peripherals::SYSTEM::regs()
6119 .pcnt_conf()
6120 .modify(|_, w| w.pcnt_clk_en().bit(enable));
6121 }
6122 Peripheral::Rmt => {
6123 crate::peripherals::SYSTEM::regs()
6124 .rmt_conf()
6125 .modify(|_, w| w.rmt_clk_en().bit(enable));
6126 }
6127 Peripheral::Rsa => {
6128 crate::peripherals::SYSTEM::regs()
6129 .rsa_conf()
6130 .modify(|_, w| w.rsa_clk_en().bit(enable));
6131 }
6132 Peripheral::SdioSlave => {
6133 crate::peripherals::SYSTEM::regs()
6134 .sdio_slave_conf()
6135 .modify(|_, w| w.sdio_slave_clk_en().bit(enable));
6136 }
6137 Peripheral::Sha => {
6138 crate::peripherals::SYSTEM::regs()
6139 .sha_conf()
6140 .modify(|_, w| w.sha_clk_en().bit(enable));
6141 }
6142 Peripheral::Spi2 => {
6143 crate::peripherals::SYSTEM::regs()
6144 .spi2_conf()
6145 .modify(|_, w| w.spi2_clk_en().bit(enable));
6146 }
6147 Peripheral::Systimer => {
6148 crate::peripherals::SYSTEM::regs()
6149 .systimer_conf()
6150 .modify(|_, w| w.systimer_clk_en().bit(enable));
6151 }
6152 Peripheral::Timg0 => {
6153 crate::peripherals::SYSTEM::regs()
6154 .timergroup(0)
6155 .conf()
6156 .modify(|_, w| w.clk_en().bit(enable));
6157 }
6158 Peripheral::Timg1 => {
6159 crate::peripherals::SYSTEM::regs()
6160 .timergroup(1)
6161 .conf()
6162 .modify(|_, w| w.clk_en().bit(enable));
6163 }
6164 Peripheral::Trace0 => {
6165 crate::peripherals::SYSTEM::regs()
6166 .trace_conf()
6167 .modify(|_, w| w.trace_clk_en().bit(enable));
6168 }
6169 Peripheral::Tsens => {
6170 crate::peripherals::SYSTEM::regs()
6171 .tsens_clk_conf()
6172 .modify(|_, w| w.tsens_clk_en().bit(enable));
6173 }
6174 Peripheral::Twai0 => {
6175 crate::peripherals::SYSTEM::regs()
6176 .twai0_conf()
6177 .modify(|_, w| w.twai0_clk_en().bit(enable));
6178 crate::peripherals::SYSTEM::regs()
6179 .twai0_func_clk_conf()
6180 .modify(|_, w| w.twai0_func_clk_en().bit(enable));
6181 }
6182 Peripheral::Twai1 => {
6183 crate::peripherals::SYSTEM::regs()
6184 .twai1_conf()
6185 .modify(|_, w| w.twai1_clk_en().bit(enable));
6186 crate::peripherals::SYSTEM::regs()
6187 .twai1_func_clk_conf()
6188 .modify(|_, w| w.twai1_func_clk_en().bit(enable));
6189 }
6190 Peripheral::Uart0 => {
6191 crate::peripherals::SYSTEM::regs()
6192 .uart(0)
6193 .conf()
6194 .modify(|_, w| w.clk_en().bit(enable));
6195 }
6196 Peripheral::Uart1 => {
6197 crate::peripherals::SYSTEM::regs()
6198 .uart(1)
6199 .conf()
6200 .modify(|_, w| w.clk_en().bit(enable));
6201 }
6202 Peripheral::Uhci0 => {
6203 crate::peripherals::SYSTEM::regs()
6204 .uhci_conf()
6205 .modify(|_, w| w.uhci_clk_en().bit(enable));
6206 }
6207 Peripheral::UsbDevice => {
6208 crate::peripherals::SYSTEM::regs()
6209 .usb_device_conf()
6210 .modify(|_, w| w.usb_device_clk_en().bit(enable));
6211 }
6212 }
6213 }
6214 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
6215 match peripheral {
6216 Peripheral::Aes => {
6217 crate::peripherals::SYSTEM::regs()
6218 .aes_conf()
6219 .modify(|_, w| w.aes_rst_en().bit(reset));
6220 }
6221 Peripheral::AhbGdma => {
6222 crate::peripherals::SYSTEM::regs()
6223 .gdma_conf()
6224 .modify(|_, w| w.gdma_rst_en().bit(reset));
6225 }
6226 Peripheral::ApbSarAdc => {
6227 crate::peripherals::SYSTEM::regs()
6228 .saradc_conf()
6229 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
6230 }
6231 Peripheral::Ds => {
6232 crate::peripherals::SYSTEM::regs()
6233 .ds_conf()
6234 .modify(|_, w| w.ds_rst_en().bit(reset));
6235 }
6236 Peripheral::Ecc => {
6237 crate::peripherals::SYSTEM::regs()
6238 .ecc_conf()
6239 .modify(|_, w| w.ecc_rst_en().bit(reset));
6240 }
6241 Peripheral::Etm => {
6242 crate::peripherals::SYSTEM::regs()
6243 .etm_conf()
6244 .modify(|_, w| w.etm_rst_en().bit(reset));
6245 }
6246 Peripheral::GpioSd => {
6247 let _ = reset;
6248 }
6249 Peripheral::Hmac => {
6250 crate::peripherals::SYSTEM::regs()
6251 .hmac_conf()
6252 .modify(|_, w| w.hmac_rst_en().bit(reset));
6253 }
6254 Peripheral::I2cExt0 => {
6255 crate::peripherals::SYSTEM::regs()
6256 .i2c0_conf()
6257 .modify(|_, w| w.i2c0_rst_en().bit(reset));
6258 }
6259 Peripheral::I2s0 => {
6260 crate::peripherals::SYSTEM::regs()
6261 .i2s_conf()
6262 .modify(|_, w| w.i2s_rst_en().bit(reset));
6263 }
6264 Peripheral::Ledc => {
6265 crate::peripherals::SYSTEM::regs()
6266 .ledc_conf()
6267 .modify(|_, w| w.ledc_rst_en().bit(reset));
6268 }
6269 Peripheral::Mcpwm0 => {
6270 crate::peripherals::SYSTEM::regs()
6271 .pwm_conf()
6272 .modify(|_, w| w.pwm_rst_en().bit(reset));
6273 }
6274 Peripheral::ParlIo => {
6275 crate::peripherals::SYSTEM::regs()
6276 .parl_io_conf()
6277 .modify(|_, w| w.parl_rst_en().bit(reset));
6278 }
6279 Peripheral::Pcnt => {
6280 crate::peripherals::SYSTEM::regs()
6281 .pcnt_conf()
6282 .modify(|_, w| w.pcnt_rst_en().bit(reset));
6283 }
6284 Peripheral::Rmt => {
6285 crate::peripherals::SYSTEM::regs()
6286 .rmt_conf()
6287 .modify(|_, w| w.rmt_rst_en().bit(reset));
6288 }
6289 Peripheral::Rsa => {
6290 crate::peripherals::SYSTEM::regs()
6291 .rsa_conf()
6292 .modify(|_, w| w.rsa_rst_en().bit(reset));
6293 }
6294 Peripheral::SdioSlave => {
6295 crate::peripherals::SYSTEM::regs()
6296 .sdio_slave_conf()
6297 .modify(|_, w| w.sdio_slave_rst_en().bit(reset));
6298 }
6299 Peripheral::Sha => {
6300 crate::peripherals::SYSTEM::regs()
6301 .sha_conf()
6302 .modify(|_, w| w.sha_rst_en().bit(reset));
6303 }
6304 Peripheral::Spi2 => {
6305 crate::peripherals::SYSTEM::regs()
6306 .spi2_conf()
6307 .modify(|_, w| w.spi2_rst_en().bit(reset));
6308 }
6309 Peripheral::Systimer => {
6310 crate::peripherals::SYSTEM::regs()
6311 .systimer_conf()
6312 .modify(|_, w| w.systimer_rst_en().bit(reset));
6313 }
6314 Peripheral::Timg0 => {
6315 crate::peripherals::SYSTEM::regs()
6316 .timergroup(0)
6317 .conf()
6318 .modify(|_, w| w.rst_en().bit(reset));
6319 }
6320 Peripheral::Timg1 => {
6321 crate::peripherals::SYSTEM::regs()
6322 .timergroup(1)
6323 .conf()
6324 .modify(|_, w| w.rst_en().bit(reset));
6325 }
6326 Peripheral::Trace0 => {
6327 crate::peripherals::SYSTEM::regs()
6328 .trace_conf()
6329 .modify(|_, w| w.trace_rst_en().bit(reset));
6330 }
6331 Peripheral::Tsens => {
6332 crate::peripherals::SYSTEM::regs()
6333 .tsens_clk_conf()
6334 .modify(|_, w| w.tsens_rst_en().bit(reset));
6335 }
6336 Peripheral::Twai0 => {
6337 crate::peripherals::SYSTEM::regs()
6338 .twai0_conf()
6339 .modify(|_, w| w.twai0_rst_en().bit(reset));
6340 }
6341 Peripheral::Twai1 => {
6342 crate::peripherals::SYSTEM::regs()
6343 .twai1_conf()
6344 .modify(|_, w| w.twai1_rst_en().bit(reset));
6345 }
6346 Peripheral::Uart0 => {
6347 crate::peripherals::SYSTEM::regs()
6348 .uart(0)
6349 .conf()
6350 .modify(|_, w| w.rst_en().bit(reset));
6351 }
6352 Peripheral::Uart1 => {
6353 crate::peripherals::SYSTEM::regs()
6354 .uart(1)
6355 .conf()
6356 .modify(|_, w| w.rst_en().bit(reset));
6357 }
6358 Peripheral::Uhci0 => {
6359 crate::peripherals::SYSTEM::regs()
6360 .uhci_conf()
6361 .modify(|_, w| w.uhci_rst_en().bit(reset));
6362 }
6363 Peripheral::UsbDevice => {
6364 crate::peripherals::SYSTEM::regs()
6365 .usb_device_conf()
6366 .modify(|_, w| w.usb_device_rst_en().bit(reset));
6367 }
6368 }
6369 }
6370 };
6371}
6372#[macro_export]
6380#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6381macro_rules! memory_range {
6382 ("DRAM") => {
6383 0x40800000..0x40880000
6384 };
6385 (size as str, "DRAM") => {
6386 "524288"
6387 };
6388 ("DRAM2_UNINIT") => {
6389 0x4086E610..0x4087E610
6390 };
6391 (size as str, "DRAM2_UNINIT") => {
6392 "65536"
6393 };
6394 ("IROM") => {
6395 0x42000000..0x43000000
6396 };
6397 (size as str, "IROM") => {
6398 "16777216"
6399 };
6400 ("DROM") => {
6401 0x42000000..0x43000000
6402 };
6403 (size as str, "DROM") => {
6404 "16777216"
6405 };
6406}
6407#[macro_export]
6424#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6425macro_rules! for_each_i2c_master {
6426 ($($pattern:tt => $code:tt;)*) => {
6427 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
6428 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
6429 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
6430 I2CEXT0_SDA)));
6431 };
6432}
6433#[macro_export]
6460#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6461macro_rules! for_each_i2s {
6462 ($($pattern:tt => $code:tt;)*) => {
6463 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
6464 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
6465 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
6466 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
6467 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
6468 true, true, false)));
6469 };
6470}
6471#[macro_export]
6490#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6491macro_rules! for_each_uart {
6492 ($($pattern:tt => $code:tt;)*) => {
6493 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
6494 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
6495 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
6496 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
6497 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
6498 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
6499 };
6500}
6501#[macro_export]
6523#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6524macro_rules! for_each_spi_master {
6525 ($($pattern:tt => $code:tt;)*) => {
6526 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
6527 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
6528 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
6529 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
6530 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
6531 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
6532 };
6533}
6534#[macro_export]
6551#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6552macro_rules! for_each_spi_slave {
6553 ($($pattern:tt => $code:tt;)*) => {
6554 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
6555 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
6556 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
6557 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
6558 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
6559 };
6560}
6561#[macro_export]
6584#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6585macro_rules! for_each_pcnt_unit {
6586 ($($pattern:tt => $code:tt;)*) => {
6587 macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
6588 => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
6589 _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
6590 _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
6591 _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
6592 _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
6593 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
6594 _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
6595 PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
6596 _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
6597 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
6598 _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
6599 PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
6600 _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
6601 _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
6602 (PCNT0_UNIT3))); _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt,
6603 PCNT, 0, PCNT, PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1),
6604 (PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1,
6605 PCNT1_CTRL_CH0, PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
6606 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3,
6607 Pcnt0Unit3, Pcnt, PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0,
6608 PCNT3_CTRL_CH1))); _for_each_inner_pcnt_unit!((interrupt(PCNT)));
6609 _for_each_inner_pcnt_unit!((regs(PCNT)));
6610 };
6611}
6612#[macro_export]
6613#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6614macro_rules! for_each_peripheral {
6615 ($($pattern:tt => $code:tt;)*) => {
6616 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
6617 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
6618 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
6619 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
6620 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6621 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
6622 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
6623 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6624 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6625 "<section class=\"warning\">"] #[doc =
6626 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6627 #[doc = "<ul>"] #[doc =
6628 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6629 =
6630 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6631 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
6632 _for_each_inner_peripheral!((@ peri_type #[doc =
6633 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6634 "<section class=\"warning\">"] #[doc =
6635 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6636 #[doc = "<ul>"] #[doc =
6637 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6638 =
6639 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6640 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
6641 _for_each_inner_peripheral!((@ peri_type #[doc =
6642 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6643 "<section class=\"warning\">"] #[doc =
6644 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6645 #[doc = "<ul>"] #[doc =
6646 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6647 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
6648 _for_each_inner_peripheral!((@ peri_type #[doc =
6649 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6650 "<section class=\"warning\">"] #[doc =
6651 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6652 #[doc = "<ul>"] #[doc =
6653 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6654 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
6655 _for_each_inner_peripheral!((@ peri_type #[doc =
6656 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6657 "<section class=\"warning\">"] #[doc =
6658 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6659 #[doc = "<ul>"] #[doc =
6660 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6661 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
6662 _for_each_inner_peripheral!((@ peri_type #[doc =
6663 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6664 "<section class=\"warning\">"] #[doc =
6665 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6666 #[doc = "<ul>"] #[doc =
6667 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6668 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
6669 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
6670 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6671 "GPIO11 peripheral singleton"] GPIO11 <= virtual()));
6672 _for_each_inner_peripheral!((@ peri_type #[doc =
6673 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6674 "<section class=\"warning\">"] #[doc =
6675 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6676 #[doc = "<ul>"] #[doc =
6677 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6678 #[doc = "</section>"] GPIO12 <= virtual())); _for_each_inner_peripheral!((@
6679 peri_type #[doc = "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""]
6680 #[doc = "<section class=\"warning\">"] #[doc =
6681 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6682 #[doc = "<ul>"] #[doc =
6683 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6684 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
6685 peri_type #[doc = "GPIO14 peripheral singleton"] GPIO14 <= virtual()));
6686 _for_each_inner_peripheral!((@ peri_type #[doc =
6687 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6688 "<section class=\"warning\">"] #[doc =
6689 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6690 #[doc = "<ul>"] #[doc =
6691 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6692 = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
6693 _for_each_inner_peripheral!((@ peri_type #[doc =
6694 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6695 "<section class=\"warning\">"] #[doc =
6696 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6697 #[doc = "<ul>"] #[doc =
6698 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6699 = "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
6700 _for_each_inner_peripheral!((@ peri_type #[doc =
6701 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6702 "<section class=\"warning\">"] #[doc =
6703 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6704 #[doc = "<ul>"] #[doc =
6705 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6706 = "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
6707 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO18 peripheral singleton"]
6708 GPIO18 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6709 "GPIO19 peripheral singleton"] GPIO19 <= virtual()));
6710 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO20 peripheral singleton"]
6711 GPIO20 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6712 "GPIO21 peripheral singleton"] GPIO21 <= virtual()));
6713 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
6714 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6715 "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
6716 _for_each_inner_peripheral!((@ peri_type #[doc =
6717 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6718 "<section class=\"warning\">"] #[doc =
6719 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6720 #[doc = "<ul>"] #[doc =
6721 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6722 "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()));
6723 _for_each_inner_peripheral!((@ peri_type #[doc =
6724 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6725 "<section class=\"warning\">"] #[doc =
6726 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6727 #[doc = "<ul>"] #[doc =
6728 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6729 "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
6730 _for_each_inner_peripheral!((@ peri_type #[doc =
6731 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6732 "<section class=\"warning\">"] #[doc =
6733 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6734 #[doc = "<ul>"] #[doc =
6735 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6736 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()));
6737 _for_each_inner_peripheral!((@ peri_type #[doc =
6738 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6739 "<section class=\"warning\">"] #[doc =
6740 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6741 #[doc = "<ul>"] #[doc =
6742 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6743 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()));
6744 _for_each_inner_peripheral!((@ peri_type #[doc =
6745 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6746 "<section class=\"warning\">"] #[doc =
6747 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6748 #[doc = "<ul>"] #[doc =
6749 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6750 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
6751 _for_each_inner_peripheral!((@ peri_type #[doc =
6752 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6753 "<section class=\"warning\">"] #[doc =
6754 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6755 #[doc = "<ul>"] #[doc =
6756 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6757 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()));
6758 _for_each_inner_peripheral!((@ peri_type #[doc =
6759 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6760 "<section class=\"warning\">"] #[doc =
6761 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6762 #[doc = "<ul>"] #[doc =
6763 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6764 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()));
6765 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
6766 DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
6767 disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
6768 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
6769 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
6770 DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
6771 disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
6772 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
6773 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH2 peripheral singleton"]
6774 DMA_CH2 <= virtual(DMA_IN_CH2 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
6775 disable_dma_in_interrupt }, DMA_OUT_CH2 : { bind_dma_out_interrupt,
6776 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
6777 _for_each_inner_peripheral!((@ peri_type #[doc =
6778 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)));
6779 _for_each_inner_peripheral!((@ peri_type #[doc =
6780 "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
6781 _for_each_inner_peripheral!((@ peri_type #[doc =
6782 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
6783 _for_each_inner_peripheral!((@ peri_type #[doc =
6784 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
6785 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
6786 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6787 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
6788 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
6789 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6790 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
6791 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
6792 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6793 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6794 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
6795 _for_each_inner_peripheral!((@ peri_type #[doc =
6796 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
6797 _for_each_inner_peripheral!((@ peri_type #[doc = "ATOMIC peripheral singleton"]
6798 ATOMIC <= ATOMIC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6799 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)));
6800 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
6801 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6802 "DS peripheral singleton"] DS <= DS() (unstable)));
6803 _for_each_inner_peripheral!((@ peri_type #[doc = "ECC peripheral singleton"] ECC
6804 <= ECC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6805 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
6806 _for_each_inner_peripheral!((@ peri_type #[doc = "EXTMEM peripheral singleton"]
6807 EXTMEM <= EXTMEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6808 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
6809 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
6810 GPIO_SD <= GPIO_SD() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6811 = "HINF peripheral singleton"] HINF <= HINF() (unstable)));
6812 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
6813 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6814 "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
6815 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
6816 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6817 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
6818 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
6819 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
6820 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6821 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
6822 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
6823 _for_each_inner_peripheral!((@ peri_type #[doc =
6824 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
6825 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
6826 _for_each_inner_peripheral!((@ peri_type #[doc =
6827 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
6828 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6829 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
6830 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
6831 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6832 "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)));
6833 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_ANA peripheral singleton"]
6834 LP_ANA <= LP_ANA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6835 "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)));
6836 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM peripheral singleton"]
6837 LP_APM <= LP_APM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6838 "LP_APM0 peripheral singleton"] LP_APM0 <= LP_APM0() (unstable)));
6839 _for_each_inner_peripheral!((@ peri_type #[doc =
6840 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
6841 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
6842 LP_I2C0 <= LP_I2C0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6843 = "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
6844 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6845 "LP_IO peripheral singleton"] LP_IO <= LP_IO() (unstable)));
6846 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
6847 LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6848 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
6849 _for_each_inner_peripheral!((@ peri_type #[doc =
6850 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
6851 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_UART peripheral singleton"]
6852 LP_UART <= LP_UART() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6853 = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)));
6854 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
6855 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6856 = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
6857 _for_each_inner_peripheral!((@ peri_type #[doc =
6858 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
6859 _for_each_inner_peripheral!((@ peri_type #[doc =
6860 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
6861 _for_each_inner_peripheral!((@ peri_type #[doc =
6862 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
6863 _for_each_inner_peripheral!((@ peri_type #[doc =
6864 "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)));
6865 _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
6866 PARL_IO <= PARL_IO(PARL_IO : { bind_peri_interrupt, enable_peri_interrupt,
6867 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
6868 #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
6869 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
6870 PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
6871 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
6872 #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)));
6873 _for_each_inner_peripheral!((@ peri_type #[doc = "PLIC_MX peripheral singleton"]
6874 PLIC_MX <= PLIC_MX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6875 = "PLIC_UX peripheral singleton"] PLIC_UX <= PLIC_UX() (unstable)));
6876 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
6877 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6878 "RMT peripheral singleton"] RMT <= RMT() (unstable)));
6879 _for_each_inner_peripheral!((@ peri_type #[doc = "RNG peripheral singleton"] RNG
6880 <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6881 "RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
6882 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
6883 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
6884 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6885 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6886 "SLCHOST peripheral singleton"] SLCHOST <= SLCHOST() (unstable)));
6887 _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
6888 <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6889 "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
6890 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
6891 SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6892 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
6893 enable_peri_interrupt, disable_peri_interrupt })));
6894 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
6895 SYSTEM <= PCR() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6896 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
6897 _for_each_inner_peripheral!((@ peri_type #[doc = "TEE peripheral singleton"] TEE
6898 <= TEE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6899 "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
6900 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
6901 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6902 "TRACE0 peripheral singleton"] TRACE0 <= TRACE() (unstable)));
6903 _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
6904 TWAI0 <= TWAI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6905 "TWAI1 peripheral singleton"] TWAI1 <= TWAI1() (unstable)));
6906 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
6907 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
6908 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6909 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
6910 enable_peri_interrupt, disable_peri_interrupt })));
6911 _for_each_inner_peripheral!((@ peri_type #[doc = "UHCI0 peripheral singleton"]
6912 UHCI0 <= UHCI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6913 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6914 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6915 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6916 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
6917 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
6918 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
6919 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
6920 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
6921 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
6922 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6923 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
6924 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_CORE peripheral singleton"]
6925 LP_CORE <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6926 = "TSENS peripheral singleton"] TSENS <= virtual() (unstable)));
6927 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
6928 WIFI <= virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt,
6929 disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
6930 disable_mac_interrupt }, MODEM_PERI_TIMEOUT : {
6931 bind_modem_peri_timeout_interrupt, enable_modem_peri_timeout_interrupt,
6932 disable_modem_peri_timeout_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
6933 enable_pwr_interrupt, disable_pwr_interrupt }))); _for_each_inner_peripheral!((@
6934 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
6935 virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6936 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
6937 _for_each_inner_peripheral!((@ peri_type #[doc =
6938 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
6939 _for_each_inner_peripheral!((@ peri_type #[doc =
6940 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
6941 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
6942 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
6943 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
6944 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
6945 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
6946 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
6947 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
6948 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
6949 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
6950 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
6951 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
6952 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
6953 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
6954 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
6955 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
6956 _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
6957 _for_each_inner_peripheral!((GPIO30));
6958 _for_each_inner_peripheral!((DMA_CH0(unstable)));
6959 _for_each_inner_peripheral!((DMA_CH1(unstable)));
6960 _for_each_inner_peripheral!((DMA_CH2(unstable)));
6961 _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
6962 _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
6963 _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
6964 _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
6965 _for_each_inner_peripheral!((SDM_CH0(unstable)));
6966 _for_each_inner_peripheral!((SDM_CH1(unstable)));
6967 _for_each_inner_peripheral!((SDM_CH2(unstable)));
6968 _for_each_inner_peripheral!((SDM_CH3(unstable)));
6969 _for_each_inner_peripheral!((AES(unstable)));
6970 _for_each_inner_peripheral!((APB_SARADC(unstable)));
6971 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
6972 _for_each_inner_peripheral!((ATOMIC(unstable)));
6973 _for_each_inner_peripheral!((DMA(unstable)));
6974 _for_each_inner_peripheral!((DS(unstable)));
6975 _for_each_inner_peripheral!((ECC(unstable)));
6976 _for_each_inner_peripheral!((EXTMEM(unstable)));
6977 _for_each_inner_peripheral!((GPIO(unstable)));
6978 _for_each_inner_peripheral!((GPIO_SD(unstable)));
6979 _for_each_inner_peripheral!((HINF(unstable)));
6980 _for_each_inner_peripheral!((HMAC(unstable)));
6981 _for_each_inner_peripheral!((HP_APM(unstable)));
6982 _for_each_inner_peripheral!((HP_SYS(unstable)));
6983 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
6984 _for_each_inner_peripheral!((I2C0));
6985 _for_each_inner_peripheral!((I2S0(unstable)));
6986 _for_each_inner_peripheral!((IEEE802154(unstable)));
6987 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
6988 _for_each_inner_peripheral!((INTPRI(unstable)));
6989 _for_each_inner_peripheral!((IO_MUX(unstable)));
6990 _for_each_inner_peripheral!((LEDC(unstable)));
6991 _for_each_inner_peripheral!((LP_ANA(unstable)));
6992 _for_each_inner_peripheral!((LP_AON(unstable)));
6993 _for_each_inner_peripheral!((LP_APM(unstable)));
6994 _for_each_inner_peripheral!((LP_APM0(unstable)));
6995 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
6996 _for_each_inner_peripheral!((LP_I2C0(unstable)));
6997 _for_each_inner_peripheral!((LP_I2C_ANA_MST(unstable)));
6998 _for_each_inner_peripheral!((LP_IO(unstable)));
6999 _for_each_inner_peripheral!((LP_PERI(unstable)));
7000 _for_each_inner_peripheral!((LP_TEE(unstable)));
7001 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
7002 _for_each_inner_peripheral!((LP_UART(unstable)));
7003 _for_each_inner_peripheral!((LP_WDT(unstable)));
7004 _for_each_inner_peripheral!((LPWR(unstable)));
7005 _for_each_inner_peripheral!((MCPWM0(unstable)));
7006 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
7007 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
7008 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
7009 _for_each_inner_peripheral!((OTP_DEBUG(unstable)));
7010 _for_each_inner_peripheral!((PARL_IO(unstable)));
7011 _for_each_inner_peripheral!((PAU(unstable)));
7012 _for_each_inner_peripheral!((PCNT(unstable)));
7013 _for_each_inner_peripheral!((PCR(unstable)));
7014 _for_each_inner_peripheral!((PLIC_MX(unstable)));
7015 _for_each_inner_peripheral!((PMU(unstable)));
7016 _for_each_inner_peripheral!((RMT(unstable)));
7017 _for_each_inner_peripheral!((RNG(unstable)));
7018 _for_each_inner_peripheral!((RSA(unstable)));
7019 _for_each_inner_peripheral!((SHA(unstable)));
7020 _for_each_inner_peripheral!((SLCHOST(unstable)));
7021 _for_each_inner_peripheral!((ETM(unstable)));
7022 _for_each_inner_peripheral!((SPI0(unstable)));
7023 _for_each_inner_peripheral!((SPI1(unstable)));
7024 _for_each_inner_peripheral!((SPI2));
7025 _for_each_inner_peripheral!((SYSTEM(unstable)));
7026 _for_each_inner_peripheral!((SYSTIMER(unstable)));
7027 _for_each_inner_peripheral!((TEE(unstable)));
7028 _for_each_inner_peripheral!((TIMG0(unstable)));
7029 _for_each_inner_peripheral!((TIMG1(unstable)));
7030 _for_each_inner_peripheral!((TRACE0(unstable)));
7031 _for_each_inner_peripheral!((TWAI0(unstable)));
7032 _for_each_inner_peripheral!((TWAI1(unstable)));
7033 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
7034 _for_each_inner_peripheral!((UHCI0(unstable)));
7035 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
7036 _for_each_inner_peripheral!((ADC1(unstable)));
7037 _for_each_inner_peripheral!((BT(unstable)));
7038 _for_each_inner_peripheral!((FLASH(unstable)));
7039 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
7040 _for_each_inner_peripheral!((LP_CORE(unstable)));
7041 _for_each_inner_peripheral!((TSENS(unstable)));
7042 _for_each_inner_peripheral!((WIFI));
7043 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
7044 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
7045 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
7046 _for_each_inner_peripheral!((SPI2, Spi2, 0, AhbGdmaChannel));
7047 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
7048 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
7049 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
7050 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
7051 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
7052 _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
7053 _for_each_inner_peripheral!((all(@ peri_type #[doc =
7054 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
7055 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
7056 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
7057 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
7058 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7059 "<section class=\"warning\">"] #[doc =
7060 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7061 #[doc = "<ul>"] #[doc =
7062 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
7063 =
7064 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
7065 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
7066 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7067 "<section class=\"warning\">"] #[doc =
7068 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7069 #[doc = "<ul>"] #[doc =
7070 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
7071 =
7072 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
7073 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
7074 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7075 "<section class=\"warning\">"] #[doc =
7076 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7077 #[doc = "<ul>"] #[doc =
7078 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
7079 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
7080 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7081 "<section class=\"warning\">"] #[doc =
7082 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7083 #[doc = "<ul>"] #[doc =
7084 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
7085 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
7086 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7087 "<section class=\"warning\">"] #[doc =
7088 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7089 #[doc = "<ul>"] #[doc =
7090 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
7091 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
7092 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7093 "<section class=\"warning\">"] #[doc =
7094 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7095 #[doc = "<ul>"] #[doc =
7096 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
7097 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
7098 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
7099 "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
7100 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7101 "<section class=\"warning\">"] #[doc =
7102 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7103 #[doc = "<ul>"] #[doc =
7104 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
7105 #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
7106 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7107 "<section class=\"warning\">"] #[doc =
7108 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7109 #[doc = "<ul>"] #[doc =
7110 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
7111 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
7112 "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
7113 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7114 "<section class=\"warning\">"] #[doc =
7115 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7116 #[doc = "<ul>"] #[doc =
7117 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
7118 = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
7119 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7120 "<section class=\"warning\">"] #[doc =
7121 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7122 #[doc = "<ul>"] #[doc =
7123 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
7124 = "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
7125 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7126 "<section class=\"warning\">"] #[doc =
7127 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7128 #[doc = "<ul>"] #[doc =
7129 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
7130 = "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
7131 "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
7132 "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
7133 "GPIO20 peripheral singleton"] GPIO20 <= virtual()), (@ peri_type #[doc =
7134 "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
7135 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
7136 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
7137 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7138 "<section class=\"warning\">"] #[doc =
7139 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7140 #[doc = "<ul>"] #[doc =
7141 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7142 "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
7143 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7144 "<section class=\"warning\">"] #[doc =
7145 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7146 #[doc = "<ul>"] #[doc =
7147 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7148 "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
7149 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7150 "<section class=\"warning\">"] #[doc =
7151 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7152 #[doc = "<ul>"] #[doc =
7153 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7154 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
7155 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7156 "<section class=\"warning\">"] #[doc =
7157 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7158 #[doc = "<ul>"] #[doc =
7159 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7160 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
7161 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7162 "<section class=\"warning\">"] #[doc =
7163 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7164 #[doc = "<ul>"] #[doc =
7165 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7166 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
7167 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7168 "<section class=\"warning\">"] #[doc =
7169 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7170 #[doc = "<ul>"] #[doc =
7171 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7172 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()), (@ peri_type #[doc =
7173 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
7174 "<section class=\"warning\">"] #[doc =
7175 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
7176 #[doc = "<ul>"] #[doc =
7177 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
7178 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()), (@ peri_type #[doc =
7179 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
7180 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
7181 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
7182 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
7183 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
7184 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
7185 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
7186 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
7187 "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
7188 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
7189 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
7190 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
7191 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)), (@
7192 peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual()
7193 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2
7194 <= virtual() (unstable)), (@ peri_type #[doc =
7195 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)), (@
7196 peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
7197 (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
7198 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
7199 SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
7200 "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
7201 #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
7202 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
7203 = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
7204 peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
7205 ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "ATOMIC peripheral singleton"]
7206 ATOMIC <= ATOMIC() (unstable)), (@ peri_type #[doc =
7207 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)), (@ peri_type #[doc =
7208 "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@ peri_type #[doc =
7209 "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type #[doc =
7210 "ECC peripheral singleton"] ECC <= ECC() (unstable)), (@ peri_type #[doc =
7211 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc =
7212 "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)), (@ peri_type #[doc
7213 = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
7214 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)), (@ peri_type
7215 #[doc = "HINF peripheral singleton"] HINF <= HINF() (unstable)), (@ peri_type
7216 #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)), (@ peri_type
7217 #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)), (@
7218 peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)),
7219 (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <=
7220 I2C_ANA_MST() (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0
7221 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
7222 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
7223 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
7224 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
7225 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
7226 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
7227 (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
7228 INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
7229 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
7230 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
7231 #[doc = "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type
7232 #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)), (@
7233 peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)),
7234 (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <= LP_APM()
7235 (unstable)), (@ peri_type #[doc = "LP_APM0 peripheral singleton"] LP_APM0 <=
7236 LP_APM0() (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"]
7237 LP_CLKRST <= LP_CLKRST() (unstable)), (@ peri_type #[doc =
7238 "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)), (@ peri_type
7239 #[doc = "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
7240 (unstable)), (@ peri_type #[doc = "LP_IO peripheral singleton"] LP_IO <= LP_IO()
7241 (unstable)), (@ peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <=
7242 LP_PERI() (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE
7243 <= LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
7244 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
7245 "LP_UART peripheral singleton"] LP_UART <= LP_UART() (unstable)), (@ peri_type
7246 #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@
7247 peri_type #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)),
7248 (@ peri_type #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0()
7249 (unstable)), (@ peri_type #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR
7250 <= MEM_MONITOR() (unstable)), (@ peri_type #[doc =
7251 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)), (@
7252 peri_type #[doc = "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <=
7253 MODEM_SYSCON() (unstable)), (@ peri_type #[doc =
7254 "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)), (@
7255 peri_type #[doc = "PARL_IO peripheral singleton"] PARL_IO <= PARL_IO(PARL_IO : {
7256 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
7257 (unstable)), (@ peri_type #[doc = "PAU peripheral singleton"] PAU <= PAU()
7258 (unstable)), (@ peri_type #[doc = "PCNT peripheral singleton"] PCNT <= PCNT(PCNT
7259 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
7260 (unstable)), (@ peri_type #[doc = "PCR peripheral singleton"] PCR <= PCR()
7261 (unstable)), (@ peri_type #[doc = "PLIC_MX peripheral singleton"] PLIC_MX <=
7262 PLIC_MX() (unstable)), (@ peri_type #[doc = "PLIC_UX peripheral singleton"]
7263 PLIC_UX <= PLIC_UX() (unstable)), (@ peri_type #[doc =
7264 "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@ peri_type #[doc =
7265 "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@ peri_type #[doc =
7266 "RNG peripheral singleton"] RNG <= LP_PERI() (unstable)), (@ peri_type #[doc =
7267 "RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
7268 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
7269 = "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
7270 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
7271 = "SLCHOST peripheral singleton"] SLCHOST <= SLCHOST() (unstable)), (@ peri_type
7272 #[doc = "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)), (@ peri_type
7273 #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type
7274 #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type
7275 #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
7276 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
7277 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@ peri_type #[doc =
7278 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@ peri_type
7279 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)), (@ peri_type #[doc
7280 = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@ peri_type #[doc
7281 = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@ peri_type #[doc
7282 = "TRACE0 peripheral singleton"] TRACE0 <= TRACE() (unstable)), (@ peri_type
7283 #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@ peri_type
7284 #[doc = "TWAI1 peripheral singleton"] TWAI1 <= TWAI1() (unstable)), (@ peri_type
7285 #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
7286 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
7287 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
7288 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
7289 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
7290 peri_type #[doc = "USB_DEVICE peripheral singleton"] USB_DEVICE <=
7291 USB_DEVICE(USB_DEVICE : { bind_peri_interrupt, enable_peri_interrupt,
7292 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
7293 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type #[doc =
7294 "BT peripheral singleton"] BT <= virtual(LP_TIMER : { bind_lp_timer_interrupt,
7295 enable_lp_timer_interrupt, disable_lp_timer_interrupt }, BT_MAC : {
7296 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
7297 (@ peri_type #[doc = "FLASH peripheral singleton"] FLASH <= virtual()
7298 (unstable)), (@ peri_type #[doc = "GPIO_DEDICATED peripheral singleton"]
7299 GPIO_DEDICATED <= virtual() (unstable)), (@ peri_type #[doc =
7300 "LP_CORE peripheral singleton"] LP_CORE <= virtual() (unstable)), (@ peri_type
7301 #[doc = "TSENS peripheral singleton"] TSENS <= virtual() (unstable)), (@
7302 peri_type #[doc = "WIFI peripheral singleton"] WIFI <= virtual(WIFI_BB : {
7303 bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt }, WIFI_MAC : {
7304 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt },
7305 MODEM_PERI_TIMEOUT : { bind_modem_peri_timeout_interrupt,
7306 enable_modem_peri_timeout_interrupt, disable_modem_peri_timeout_interrupt },
7307 WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt })),
7308 (@ peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
7309 virtual() (unstable)), (@ peri_type #[doc =
7310 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
7311 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
7312 virtual() (unstable)), (@ peri_type #[doc =
7313 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
7314 _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
7315 (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
7316 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
7317 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
7318 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (GPIO29), (GPIO30),
7319 (DMA_CH0(unstable)), (DMA_CH1(unstable)), (DMA_CH2(unstable)),
7320 (PCNT0_UNIT0(unstable)), (PCNT0_UNIT1(unstable)), (PCNT0_UNIT2(unstable)),
7321 (PCNT0_UNIT3(unstable)), (SDM_CH0(unstable)), (SDM_CH1(unstable)),
7322 (SDM_CH2(unstable)), (SDM_CH3(unstable)), (AES(unstable)),
7323 (APB_SARADC(unstable)), (ASSIST_DEBUG(unstable)), (ATOMIC(unstable)),
7324 (DMA(unstable)), (DS(unstable)), (ECC(unstable)), (EXTMEM(unstable)),
7325 (GPIO(unstable)), (GPIO_SD(unstable)), (HINF(unstable)), (HMAC(unstable)),
7326 (HP_APM(unstable)), (HP_SYS(unstable)), (I2C_ANA_MST(unstable)), (I2C0),
7327 (I2S0(unstable)), (IEEE802154(unstable)), (INTERRUPT_CORE0(unstable)),
7328 (INTPRI(unstable)), (IO_MUX(unstable)), (LEDC(unstable)), (LP_ANA(unstable)),
7329 (LP_AON(unstable)), (LP_APM(unstable)), (LP_APM0(unstable)),
7330 (LP_CLKRST(unstable)), (LP_I2C0(unstable)), (LP_I2C_ANA_MST(unstable)),
7331 (LP_IO(unstable)), (LP_PERI(unstable)), (LP_TEE(unstable)),
7332 (RTC_TIMER(unstable)), (LP_UART(unstable)), (LP_WDT(unstable)), (LPWR(unstable)),
7333 (MCPWM0(unstable)), (MEM_MONITOR(unstable)), (MODEM_LPCON(unstable)),
7334 (MODEM_SYSCON(unstable)), (OTP_DEBUG(unstable)), (PARL_IO(unstable)),
7335 (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)), (PLIC_MX(unstable)),
7336 (PMU(unstable)), (RMT(unstable)), (RNG(unstable)), (RSA(unstable)),
7337 (SHA(unstable)), (SLCHOST(unstable)), (ETM(unstable)), (SPI0(unstable)),
7338 (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
7339 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (TRACE0(unstable)),
7340 (TWAI0(unstable)), (TWAI1(unstable)), (UART0), (UART1), (UHCI0(unstable)),
7341 (USB_DEVICE(unstable)), (ADC1(unstable)), (BT(unstable)), (FLASH(unstable)),
7342 (GPIO_DEDICATED(unstable)), (LP_CORE(unstable)), (TSENS(unstable)), (WIFI),
7343 (FROM_CPU_INTR1(unstable)), (FROM_CPU_INTR2(unstable)),
7344 (FROM_CPU_INTR3(unstable)))); _for_each_inner_peripheral!((dma_eligible(SPI2,
7345 Spi2, 0, AhbGdmaChannel), (UHCI0, Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3,
7346 AhbGdmaChannel), (AES, Aes, 6, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel),
7347 (APB_SARADC, ApbSaradc, 8, AhbGdmaChannel), (PARL_IO, ParlIo, 9,
7348 AhbGdmaChannel)));
7349 };
7350}
7351#[macro_export]
7378#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7379macro_rules! for_each_gpio {
7380 ($($pattern:tt => $code:tt;)*) => {
7381 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
7382 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
7383 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
7384 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
7385 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
7386 _for_each_inner_gpio!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
7387 [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
7388 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTCK _2 =>
7389 FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2
7390 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])));
7391 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
7392 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
7393 _for_each_inner_gpio!((10, GPIO10() () ([Input] [Output])));
7394 _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
7395 _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
7396 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
7397 _for_each_inner_gpio!((14, GPIO14() () ([Input] [Output])));
7398 _for_each_inner_gpio!((15, GPIO15() () ([Input] [Output])));
7399 _for_each_inner_gpio!((16, GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0)
7400 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => U0RXD) (_2 =>
7401 FSPICS1) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18(_0 => SDIO_CMD)
7402 (_0 => SDIO_CMD _2 => FSPICS2) ([Input] [Output]))); _for_each_inner_gpio!((19,
7403 GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) ([Input] [Output])));
7404 _for_each_inner_gpio!((20, GPIO20(_0 => SDIO_DATA0) (_0 => SDIO_DATA0 _2 =>
7405 FSPICS4) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21(_0 =>
7406 SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])));
7407 _for_each_inner_gpio!((22, GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) ([Input]
7408 [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 => SDIO_DATA3) (_0 =>
7409 SDIO_DATA3) ([Input] [Output]))); _for_each_inner_gpio!((24, GPIO24() (_0 =>
7410 SPICS0) ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_0 => SPIQ) (_0
7411 => SPIQ) ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_0 => SPIWP) (_0
7412 => SPIWP) ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27() () ([Input]
7413 [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SPIHD) (_0 => SPIHD)
7414 ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() (_0 => SPICLK) ([Input]
7415 [Output]))); _for_each_inner_gpio!((30, GPIO30(_0 => SPID) (_0 => SPID) ([Input]
7416 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
7417 GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
7418 [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 =>
7419 FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP)
7420 (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 =>
7421 FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID)
7422 ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input]
7423 [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input]
7424 [Output])), (12, GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input]
7425 [Output])), (14, GPIO14() () ([Input] [Output])), (15, GPIO15() () ([Input]
7426 [Output])), (16, GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) ([Input]
7427 [Output])), (17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (18,
7428 GPIO18(_0 => SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) ([Input] [Output])), (19,
7429 GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) ([Input] [Output])), (20, GPIO20(_0 =>
7430 SDIO_DATA0) (_0 => SDIO_DATA0 _2 => FSPICS4) ([Input] [Output])), (21, GPIO21(_0
7431 => SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])), (22,
7432 GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) ([Input] [Output])), (23, GPIO23(_0
7433 => SDIO_DATA3) (_0 => SDIO_DATA3) ([Input] [Output])), (24, GPIO24() (_0 =>
7434 SPICS0) ([Input] [Output])), (25, GPIO25(_0 => SPIQ) (_0 => SPIQ) ([Input]
7435 [Output])), (26, GPIO26(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (27,
7436 GPIO27() () ([Input] [Output])), (28, GPIO28(_0 => SPIHD) (_0 => SPIHD) ([Input]
7437 [Output])), (29, GPIO29() (_0 => SPICLK) ([Input] [Output])), (30, GPIO30(_0 =>
7438 SPID) (_0 => SPID) ([Input] [Output]))));
7439 };
7440}
7441#[macro_export]
7468#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7469macro_rules! for_each_analog_function {
7470 ($($pattern:tt => $code:tt;)*) => {
7471 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
7472 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
7473 _for_each_inner_analog_function!((ADC1_CH0, GPIO0));
7474 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
7475 _for_each_inner_analog_function!((ADC1_CH1, GPIO1));
7476 _for_each_inner_analog_function!((ADC1_CH2, GPIO2));
7477 _for_each_inner_analog_function!((ADC1_CH3, GPIO3));
7478 _for_each_inner_analog_function!((ADC1_CH4, GPIO4));
7479 _for_each_inner_analog_function!((ADC1_CH5, GPIO5));
7480 _for_each_inner_analog_function!((ADC1_CH6, GPIO6));
7481 _for_each_inner_analog_function!((USJ_DM, GPIO12));
7482 _for_each_inner_analog_function!((USJ_DP, GPIO13));
7483 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0));
7484 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1));
7485 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2));
7486 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3));
7487 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4));
7488 _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO5));
7489 _for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO6));
7490 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (ADC1_CH0, GPIO0),
7491 (XTAL_32K_N, GPIO1), (ADC1_CH1, GPIO1), (ADC1_CH2, GPIO2), (ADC1_CH3, GPIO3),
7492 (ADC1_CH4, GPIO4), (ADC1_CH5, GPIO5), (ADC1_CH6, GPIO6), (USJ_DM, GPIO12),
7493 (USJ_DP, GPIO13))); _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0,
7494 ADCn_CHm, 1, 0), GPIO0), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1), ((ADC1_CH2,
7495 ADCn_CHm, 1, 2), GPIO2), ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3), ((ADC1_CH4,
7496 ADCn_CHm, 1, 4), GPIO4), ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO5), ((ADC1_CH6,
7497 ADCn_CHm, 1, 6), GPIO6)));
7498 };
7499}
7500#[macro_export]
7538#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7539macro_rules! for_each_lp_function {
7540 ($($pattern:tt => $code:tt;)*) => {
7541 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
7542 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _0));
7543 _for_each_inner_lp_function!((LP_UART_DTRN, GPIO0, _1));
7544 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _0));
7545 _for_each_inner_lp_function!((LP_UART_DSRN, GPIO1, _1));
7546 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _0));
7547 _for_each_inner_lp_function!((LP_UART_RTSN, GPIO2, _1));
7548 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _0));
7549 _for_each_inner_lp_function!((LP_UART_CTSN, GPIO3, _1));
7550 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _0));
7551 _for_each_inner_lp_function!((LP_UART_RXD, GPIO4, _1));
7552 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _0));
7553 _for_each_inner_lp_function!((LP_UART_TXD, GPIO5, _1));
7554 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _0));
7555 _for_each_inner_lp_function!((LP_I2C_SDA, GPIO6, _1));
7556 _for_each_inner_lp_function!((LP_GPIO7, GPIO7, _0));
7557 _for_each_inner_lp_function!((LP_I2C_SCL, GPIO7, _1));
7558 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, () ()));
7559 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()));
7560 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()));
7561 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()));
7562 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()));
7563 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()));
7564 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()));
7565 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO7, _0, () ()));
7566 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _0), (LP_UART_DTRN, GPIO0,
7567 _1), (LP_GPIO1, GPIO1, _0), (LP_UART_DSRN, GPIO1, _1), (LP_GPIO2, GPIO2, _0),
7568 (LP_UART_RTSN, GPIO2, _1), (LP_GPIO3, GPIO3, _0), (LP_UART_CTSN, GPIO3, _1),
7569 (LP_GPIO4, GPIO4, _0), (LP_UART_RXD, GPIO4, _1), (LP_GPIO5, GPIO5, _0),
7570 (LP_UART_TXD, GPIO5, _1), (LP_GPIO6, GPIO6, _0), (LP_I2C_SDA, GPIO6, _1),
7571 (LP_GPIO7, GPIO7, _0), (LP_I2C_SCL, GPIO7, _1)));
7572 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, ()
7573 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()), ((LP_GPIO2, LP_GPIOn, 2),
7574 GPIO2, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()), ((LP_GPIO4,
7575 LP_GPIOn, 4), GPIO4, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()),
7576 ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()), ((LP_GPIO7, LP_GPIOn, 7), GPIO7, _0,
7577 () ())));
7578 };
7579}
7580#[macro_export]
7611#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7612macro_rules! for_each_iomux_function {
7613 ($($pattern:tt => $code:tt;)*) => {
7614 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
7615 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
7616 _for_each_inner_iomux_function!((MTMS, GPIO4, _0));
7617 _for_each_inner_iomux_function!((FSPIHD, GPIO4, _2));
7618 _for_each_inner_iomux_function!((MTDI, GPIO5, _0));
7619 _for_each_inner_iomux_function!((FSPIWP, GPIO5, _2));
7620 _for_each_inner_iomux_function!((MTCK, GPIO6, _0));
7621 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
7622 _for_each_inner_iomux_function!((MTDO, GPIO7, _0));
7623 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
7624 _for_each_inner_iomux_function!((U0TXD, GPIO16, _0));
7625 _for_each_inner_iomux_function!((FSPICS0, GPIO16, _2));
7626 _for_each_inner_iomux_function!((U0RXD, GPIO17, _0));
7627 _for_each_inner_iomux_function!((FSPICS1, GPIO17, _2));
7628 _for_each_inner_iomux_function!((SDIO_CMD, GPIO18, _0));
7629 _for_each_inner_iomux_function!((FSPICS2, GPIO18, _2));
7630 _for_each_inner_iomux_function!((SDIO_CLK, GPIO19, _0));
7631 _for_each_inner_iomux_function!((FSPICS3, GPIO19, _2));
7632 _for_each_inner_iomux_function!((SDIO_DATA0, GPIO20, _0));
7633 _for_each_inner_iomux_function!((FSPICS4, GPIO20, _2));
7634 _for_each_inner_iomux_function!((SDIO_DATA1, GPIO21, _0));
7635 _for_each_inner_iomux_function!((FSPICS5, GPIO21, _2));
7636 _for_each_inner_iomux_function!((SDIO_DATA2, GPIO22, _0));
7637 _for_each_inner_iomux_function!((SDIO_DATA3, GPIO23, _0));
7638 _for_each_inner_iomux_function!((SPICS0, GPIO24, _0));
7639 _for_each_inner_iomux_function!((SPIQ, GPIO25, _0));
7640 _for_each_inner_iomux_function!((SPIWP, GPIO26, _0));
7641 _for_each_inner_iomux_function!((SPIHD, GPIO28, _0));
7642 _for_each_inner_iomux_function!((SPICLK, GPIO29, _0));
7643 _for_each_inner_iomux_function!((SPID, GPIO30, _0));
7644 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO16, _2));
7645 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO17, _2));
7646 _for_each_inner_iomux_function!(((FSPICS2, FSPICSn, 2), GPIO18, _2));
7647 _for_each_inner_iomux_function!(((FSPICS3, FSPICSn, 3), GPIO19, _2));
7648 _for_each_inner_iomux_function!(((FSPICS4, FSPICSn, 4), GPIO20, _2));
7649 _for_each_inner_iomux_function!(((FSPICS5, FSPICSn, 5), GPIO21, _2));
7650 _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO20, _0));
7651 _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO21, _0));
7652 _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO22, _0));
7653 _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0));
7654 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO24, _0));
7655 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO4, _0),
7656 (FSPIHD, GPIO4, _2), (MTDI, GPIO5, _0), (FSPIWP, GPIO5, _2), (MTCK, GPIO6, _0),
7657 (FSPICLK, GPIO6, _2), (MTDO, GPIO7, _0), (FSPID, GPIO7, _2), (U0TXD, GPIO16, _0),
7658 (FSPICS0, GPIO16, _2), (U0RXD, GPIO17, _0), (FSPICS1, GPIO17, _2), (SDIO_CMD,
7659 GPIO18, _0), (FSPICS2, GPIO18, _2), (SDIO_CLK, GPIO19, _0), (FSPICS3, GPIO19,
7660 _2), (SDIO_DATA0, GPIO20, _0), (FSPICS4, GPIO20, _2), (SDIO_DATA1, GPIO21, _0),
7661 (FSPICS5, GPIO21, _2), (SDIO_DATA2, GPIO22, _0), (SDIO_DATA3, GPIO23, _0),
7662 (SPICS0, GPIO24, _0), (SPIQ, GPIO25, _0), (SPIWP, GPIO26, _0), (SPIHD, GPIO28,
7663 _0), (SPICLK, GPIO29, _0), (SPID, GPIO30, _0)));
7664 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO16, _2),
7665 ((FSPICS1, FSPICSn, 1), GPIO17, _2), ((FSPICS2, FSPICSn, 2), GPIO18, _2),
7666 ((FSPICS3, FSPICSn, 3), GPIO19, _2), ((FSPICS4, FSPICSn, 4), GPIO20, _2),
7667 ((FSPICS5, FSPICSn, 5), GPIO21, _2)));
7668 _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA0, SDIO_DATAn, 0), GPIO20,
7669 _0), ((SDIO_DATA1, SDIO_DATAn, 1), GPIO21, _0), ((SDIO_DATA2, SDIO_DATAn, 2),
7670 GPIO22, _0), ((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0)));
7671 _for_each_inner_iomux_function!((SPICSn((SPICS0, SPICSn, 0), GPIO24, _0)));
7672 };
7673}
7674#[macro_export]
7691#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7692macro_rules! gpio_for_signal {
7693 (XTAL_32K_P $(, $_fallback:literal)?) => {
7694 "GPIO0"
7695 };
7696 (ADC1_CH0 $(, $_fallback:literal)?) => {
7697 "GPIO0"
7698 };
7699 (LP_GPIO0 $(, $_fallback:literal)?) => {
7700 "GPIO0"
7701 };
7702 (LP_UART_DTRN $(, $_fallback:literal)?) => {
7703 "GPIO0"
7704 };
7705 (XTAL_32K_N $(, $_fallback:literal)?) => {
7706 "GPIO1"
7707 };
7708 (ADC1_CH1 $(, $_fallback:literal)?) => {
7709 "GPIO1"
7710 };
7711 (LP_GPIO1 $(, $_fallback:literal)?) => {
7712 "GPIO1"
7713 };
7714 (LP_UART_DSRN $(, $_fallback:literal)?) => {
7715 "GPIO1"
7716 };
7717 (FSPIQ $(, $_fallback:literal)?) => {
7718 "GPIO2"
7719 };
7720 (ADC1_CH2 $(, $_fallback:literal)?) => {
7721 "GPIO2"
7722 };
7723 (LP_GPIO2 $(, $_fallback:literal)?) => {
7724 "GPIO2"
7725 };
7726 (LP_UART_RTSN $(, $_fallback:literal)?) => {
7727 "GPIO2"
7728 };
7729 (ADC1_CH3 $(, $_fallback:literal)?) => {
7730 "GPIO3"
7731 };
7732 (LP_GPIO3 $(, $_fallback:literal)?) => {
7733 "GPIO3"
7734 };
7735 (LP_UART_CTSN $(, $_fallback:literal)?) => {
7736 "GPIO3"
7737 };
7738 (MTMS $(, $_fallback:literal)?) => {
7739 "GPIO4"
7740 };
7741 (FSPIHD $(, $_fallback:literal)?) => {
7742 "GPIO4"
7743 };
7744 (ADC1_CH4 $(, $_fallback:literal)?) => {
7745 "GPIO4"
7746 };
7747 (LP_GPIO4 $(, $_fallback:literal)?) => {
7748 "GPIO4"
7749 };
7750 (LP_UART_RXD $(, $_fallback:literal)?) => {
7751 "GPIO4"
7752 };
7753 (MTDI $(, $_fallback:literal)?) => {
7754 "GPIO5"
7755 };
7756 (FSPIWP $(, $_fallback:literal)?) => {
7757 "GPIO5"
7758 };
7759 (ADC1_CH5 $(, $_fallback:literal)?) => {
7760 "GPIO5"
7761 };
7762 (LP_GPIO5 $(, $_fallback:literal)?) => {
7763 "GPIO5"
7764 };
7765 (LP_UART_TXD $(, $_fallback:literal)?) => {
7766 "GPIO5"
7767 };
7768 (MTCK $(, $_fallback:literal)?) => {
7769 "GPIO6"
7770 };
7771 (FSPICLK $(, $_fallback:literal)?) => {
7772 "GPIO6"
7773 };
7774 (ADC1_CH6 $(, $_fallback:literal)?) => {
7775 "GPIO6"
7776 };
7777 (LP_GPIO6 $(, $_fallback:literal)?) => {
7778 "GPIO6"
7779 };
7780 (LP_I2C_SDA $(, $_fallback:literal)?) => {
7781 "GPIO6"
7782 };
7783 (MTDO $(, $_fallback:literal)?) => {
7784 "GPIO7"
7785 };
7786 (FSPID $(, $_fallback:literal)?) => {
7787 "GPIO7"
7788 };
7789 (LP_GPIO7 $(, $_fallback:literal)?) => {
7790 "GPIO7"
7791 };
7792 (LP_I2C_SCL $(, $_fallback:literal)?) => {
7793 "GPIO7"
7794 };
7795 (USJ_DM $(, $_fallback:literal)?) => {
7796 "GPIO12"
7797 };
7798 (USJ_DP $(, $_fallback:literal)?) => {
7799 "GPIO13"
7800 };
7801 (U0TXD $(, $_fallback:literal)?) => {
7802 "GPIO16"
7803 };
7804 (FSPICS0 $(, $_fallback:literal)?) => {
7805 "GPIO16"
7806 };
7807 (U0RXD $(, $_fallback:literal)?) => {
7808 "GPIO17"
7809 };
7810 (FSPICS1 $(, $_fallback:literal)?) => {
7811 "GPIO17"
7812 };
7813 (SDIO_CMD $(, $_fallback:literal)?) => {
7814 "GPIO18"
7815 };
7816 (FSPICS2 $(, $_fallback:literal)?) => {
7817 "GPIO18"
7818 };
7819 (SDIO_CLK $(, $_fallback:literal)?) => {
7820 "GPIO19"
7821 };
7822 (FSPICS3 $(, $_fallback:literal)?) => {
7823 "GPIO19"
7824 };
7825 (SDIO_DATA0 $(, $_fallback:literal)?) => {
7826 "GPIO20"
7827 };
7828 (FSPICS4 $(, $_fallback:literal)?) => {
7829 "GPIO20"
7830 };
7831 (SDIO_DATA1 $(, $_fallback:literal)?) => {
7832 "GPIO21"
7833 };
7834 (FSPICS5 $(, $_fallback:literal)?) => {
7835 "GPIO21"
7836 };
7837 (SDIO_DATA2 $(, $_fallback:literal)?) => {
7838 "GPIO22"
7839 };
7840 (SDIO_DATA3 $(, $_fallback:literal)?) => {
7841 "GPIO23"
7842 };
7843 (SPICS0 $(, $_fallback:literal)?) => {
7844 "GPIO24"
7845 };
7846 (SPIQ $(, $_fallback:literal)?) => {
7847 "GPIO25"
7848 };
7849 (SPIWP $(, $_fallback:literal)?) => {
7850 "GPIO26"
7851 };
7852 (SPIHD $(, $_fallback:literal)?) => {
7853 "GPIO28"
7854 };
7855 (SPICLK $(, $_fallback:literal)?) => {
7856 "GPIO29"
7857 };
7858 (SPID $(, $_fallback:literal)?) => {
7859 "GPIO30"
7860 };
7861 ($_signal:ident, $fallback:literal) => {
7862 $fallback
7863 };
7864}
7865#[macro_export]
7869#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7870macro_rules! define_io_mux_signals {
7871 () => {
7872 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7873 #[derive(Debug, PartialEq, Copy, Clone)]
7874 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7875 #[doc(hidden)]
7876 pub enum InputSignal {
7877 EXT_ADC_START = 0,
7878 U0RXD = 6,
7879 U0CTS = 7,
7880 U0DSR = 8,
7881 U1RXD = 9,
7882 U1CTS = 10,
7883 U1DSR = 11,
7884 I2S_MCLK = 12,
7885 I2SO_BCK = 13,
7886 I2SO_WS = 14,
7887 I2SI_SD = 15,
7888 I2SI_BCK = 16,
7889 I2SI_WS = 17,
7890 USB_JTAG_TDO_BRIDGE = 19,
7891 CPU_TESTBUS0 = 20,
7892 CPU_TESTBUS1 = 21,
7893 CPU_TESTBUS2 = 22,
7894 CPU_TESTBUS3 = 23,
7895 CPU_TESTBUS4 = 24,
7896 CPU_TESTBUS5 = 25,
7897 CPU_TESTBUS6 = 26,
7898 CPU_TESTBUS7 = 27,
7899 CPU_GPIO_0 = 28,
7900 CPU_GPIO_1 = 29,
7901 CPU_GPIO_2 = 30,
7902 CPU_GPIO_3 = 31,
7903 CPU_GPIO_4 = 32,
7904 CPU_GPIO_5 = 33,
7905 CPU_GPIO_6 = 34,
7906 CPU_GPIO_7 = 35,
7907 USB_JTAG_TMS = 37,
7908 USB_EXTPHY_OEN = 40,
7909 USB_EXTPHY_VM = 41,
7910 USB_EXTPHY_VPO = 42,
7911 I2CEXT0_SCL = 45,
7912 I2CEXT0_SDA = 46,
7913 PARL_RX_DATA0 = 47,
7914 PARL_RX_DATA1 = 48,
7915 PARL_RX_DATA2 = 49,
7916 PARL_RX_DATA3 = 50,
7917 PARL_RX_DATA4 = 51,
7918 PARL_RX_DATA5 = 52,
7919 PARL_RX_DATA6 = 53,
7920 PARL_RX_DATA7 = 54,
7921 PARL_RX_DATA8 = 55,
7922 PARL_RX_DATA9 = 56,
7923 PARL_RX_DATA10 = 57,
7924 PARL_RX_DATA11 = 58,
7925 PARL_RX_DATA12 = 59,
7926 PARL_RX_DATA13 = 60,
7927 PARL_RX_DATA14 = 61,
7928 PARL_RX_DATA15 = 62,
7929 FSPICLK = 63,
7930 FSPIQ = 64,
7931 FSPID = 65,
7932 FSPIHD = 66,
7933 FSPIWP = 67,
7934 FSPICS0 = 68,
7935 PARL_RX_CLK = 69,
7936 PARL_TX_CLK = 70,
7937 RMT_SIG_0 = 71,
7938 RMT_SIG_1 = 72,
7939 TWAI0_RX = 73,
7940 TWAI1_RX = 77,
7941 PWM0_SYNC0 = 87,
7942 PWM0_SYNC1 = 88,
7943 PWM0_SYNC2 = 89,
7944 PWM0_F0 = 90,
7945 PWM0_F1 = 91,
7946 PWM0_F2 = 92,
7947 PWM0_CAP0 = 93,
7948 PWM0_CAP1 = 94,
7949 PWM0_CAP2 = 95,
7950 SIG_IN_FUNC97 = 97,
7951 SIG_IN_FUNC98 = 98,
7952 SIG_IN_FUNC99 = 99,
7953 SIG_IN_FUNC100 = 100,
7954 PCNT0_SIG_CH0 = 101,
7955 PCNT0_SIG_CH1 = 102,
7956 PCNT0_CTRL_CH0 = 103,
7957 PCNT0_CTRL_CH1 = 104,
7958 PCNT1_SIG_CH0 = 105,
7959 PCNT1_SIG_CH1 = 106,
7960 PCNT1_CTRL_CH0 = 107,
7961 PCNT1_CTRL_CH1 = 108,
7962 PCNT2_SIG_CH0 = 109,
7963 PCNT2_SIG_CH1 = 110,
7964 PCNT2_CTRL_CH0 = 111,
7965 PCNT2_CTRL_CH1 = 112,
7966 PCNT3_SIG_CH0 = 113,
7967 PCNT3_SIG_CH1 = 114,
7968 PCNT3_CTRL_CH0 = 115,
7969 PCNT3_CTRL_CH1 = 116,
7970 SPIQ = 121,
7971 SPID = 122,
7972 SPIHD = 123,
7973 SPIWP = 124,
7974 SDIO_CMD,
7975 SDIO_DATA0,
7976 SDIO_DATA1,
7977 SDIO_DATA2,
7978 SDIO_DATA3,
7979 MTDI,
7980 MTCK,
7981 MTMS,
7982 }
7983 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7984 #[derive(Debug, PartialEq, Copy, Clone)]
7985 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7986 #[doc(hidden)]
7987 pub enum OutputSignal {
7988 LEDC_LS_SIG0 = 0,
7989 LEDC_LS_SIG1 = 1,
7990 LEDC_LS_SIG2 = 2,
7991 LEDC_LS_SIG3 = 3,
7992 LEDC_LS_SIG4 = 4,
7993 LEDC_LS_SIG5 = 5,
7994 U0TXD = 6,
7995 U0RTS = 7,
7996 U0DTR = 8,
7997 U1TXD = 9,
7998 U1RTS = 10,
7999 U1DTR = 11,
8000 I2S_MCLK = 12,
8001 I2SO_BCK = 13,
8002 I2SO_WS = 14,
8003 I2SO_SD = 15,
8004 I2SI_BCK = 16,
8005 I2SI_WS = 17,
8006 I2SO_SD1 = 18,
8007 USB_JTAG_TDO_BRIDGE = 19,
8008 CPU_TESTBUS0 = 20,
8009 CPU_TESTBUS1 = 21,
8010 CPU_TESTBUS2 = 22,
8011 CPU_TESTBUS3 = 23,
8012 CPU_TESTBUS4 = 24,
8013 CPU_TESTBUS5 = 25,
8014 CPU_TESTBUS6 = 26,
8015 CPU_TESTBUS7 = 27,
8016 CPU_GPIO_0 = 28,
8017 CPU_GPIO_1 = 29,
8018 CPU_GPIO_2 = 30,
8019 CPU_GPIO_3 = 31,
8020 CPU_GPIO_4 = 32,
8021 CPU_GPIO_5 = 33,
8022 CPU_GPIO_6 = 34,
8023 CPU_GPIO_7 = 35,
8024 USB_JTAG_TCK = 36,
8025 USB_JTAG_TMS = 37,
8026 USB_JTAG_TDI = 38,
8027 USB_JTAG_TDO = 39,
8028 I2CEXT0_SCL = 45,
8029 I2CEXT0_SDA = 46,
8030 PARL_TX_DATA0 = 47,
8031 PARL_TX_DATA1 = 48,
8032 PARL_TX_DATA2 = 49,
8033 PARL_TX_DATA3 = 50,
8034 PARL_TX_DATA4 = 51,
8035 PARL_TX_DATA5 = 52,
8036 PARL_TX_DATA6 = 53,
8037 PARL_TX_DATA7 = 54,
8038 PARL_TX_DATA8 = 55,
8039 PARL_TX_DATA9 = 56,
8040 PARL_TX_DATA10 = 57,
8041 PARL_TX_DATA11 = 58,
8042 PARL_TX_DATA12 = 59,
8043 PARL_TX_DATA13 = 60,
8044 PARL_TX_DATA14 = 61,
8045 PARL_TX_DATA15 = 62,
8046 FSPICLK = 63,
8047 FSPIQ = 64,
8048 FSPID = 65,
8049 FSPIHD = 66,
8050 FSPIWP = 67,
8051 FSPICS0 = 68,
8052 SDIO_TOHOST_INT = 69,
8053 PARL_TX_CLK = 70,
8054 RMT_SIG_0 = 71,
8055 RMT_SIG_1 = 72,
8056 TWAI0_TX = 73,
8057 TWAI0_BUS_OFF_ON = 74,
8058 TWAI0_CLKOUT = 75,
8059 TWAI0_STANDBY = 76,
8060 TWAI1_TX = 77,
8061 TWAI1_BUS_OFF_ON = 78,
8062 TWAI1_CLKOUT = 79,
8063 TWAI1_STANDBY = 80,
8064 GPIO_SD0 = 83,
8065 GPIO_SD1 = 84,
8066 GPIO_SD2 = 85,
8067 GPIO_SD3 = 86,
8068 PWM0_0A = 87,
8069 PWM0_0B = 88,
8070 PWM0_1A = 89,
8071 PWM0_1B = 90,
8072 PWM0_2A = 91,
8073 PWM0_2B = 92,
8074 SIG_IN_FUNC97 = 97,
8075 SIG_IN_FUNC98 = 98,
8076 SIG_IN_FUNC99 = 99,
8077 SIG_IN_FUNC100 = 100,
8078 FSPICS1 = 101,
8079 FSPICS2 = 102,
8080 FSPICS3 = 103,
8081 FSPICS4 = 104,
8082 FSPICS5 = 105,
8083 SPICLK = 114,
8084 SPICS0 = 115,
8085 SPICS1 = 116,
8086 GPIO_TASK_MATRIX_OUT0 = 117,
8087 GPIO_TASK_MATRIX_OUT1 = 118,
8088 GPIO_TASK_MATRIX_OUT2 = 119,
8089 GPIO_TASK_MATRIX_OUT3 = 120,
8090 SPIQ = 121,
8091 SPID = 122,
8092 SPIHD = 123,
8093 SPIWP = 124,
8094 CLK_OUT_OUT1 = 125,
8095 CLK_OUT_OUT2 = 126,
8096 CLK_OUT_OUT3 = 127,
8097 GPIO = 128,
8098 SDIO_CLK,
8099 SDIO_CMD,
8100 SDIO_DATA0,
8101 SDIO_DATA1,
8102 SDIO_DATA2,
8103 SDIO_DATA3,
8104 MTDO,
8105 }
8106 };
8107}
8108#[macro_export]
8115#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
8116macro_rules! define_lp_functions {
8117 () => {
8118 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
8123 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
8124 #[doc(hidden)]
8125 pub enum LpFunction {
8126 _0 = 0,
8128 _1 = 1,
8130 }
8131 impl LpFunction {
8132 pub const LP_GPIO: Self = Self::_0;
8134 }
8135 };
8136}
8137#[macro_export]
8150#[expect(clippy::crate_in_macro_def)]
8151#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
8152macro_rules! define_io_mux_reg {
8153 () => {
8154 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
8155 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
8156 }
8157 };
8158}