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