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.has_bank_1") => {
92 false
93 };
94 ("gpio.input_signal_max") => {
95 124
96 };
97 ("gpio.input_signal_max", str) => {
98 stringify!(124)
99 };
100 ("gpio.output_signal_max") => {
101 128
102 };
103 ("gpio.output_signal_max", str) => {
104 stringify!(128)
105 };
106 ("dedicated_gpio.version") => {
107 "riscv_v1"
108 };
109 ("dedicated_gpio.needs_initialization") => {
110 false
111 };
112 ("dedicated_gpio.channel_count") => {
113 8
114 };
115 ("dedicated_gpio.channel_count", str) => {
116 stringify!(8)
117 };
118 ("lp_io.version") => {
119 "v4"
120 };
121 ("lp_io.has_gpio_matrix") => {
122 false
123 };
124 ("uart.ram_size") => {
125 128
126 };
127 ("uart.ram_size", str) => {
128 stringify!(128)
129 };
130 ("uart.version") => {
131 2
132 };
133 ("uart.version", str) => {
134 stringify!(2)
135 };
136 ("uart.peripheral_controls_mem_clk") => {
137 true
138 };
139 ("uart.has_sclk_divider") => {
140 false
141 };
142 ("uart.has_sclk_enable") => {
143 true
144 };
145 ("lp_uart.ram_size") => {
146 32
147 };
148 ("lp_uart.ram_size", str) => {
149 stringify!(32)
150 };
151 ("uhci.combined_uart_selector_field") => {
152 false
153 };
154 ("i2c_master.version") => {
155 4
156 };
157 ("i2c_master.version", str) => {
158 stringify!(4)
159 };
160 ("i2c_master.has_fsm_timeouts") => {
161 true
162 };
163 ("i2c_master.has_hw_bus_clear") => {
164 true
165 };
166 ("i2c_master.has_bus_timeout_enable") => {
167 true
168 };
169 ("i2c_master.separate_filter_config_registers") => {
170 false
171 };
172 ("i2c_master.can_estimate_nack_reason") => {
173 true
174 };
175 ("i2c_master.has_conf_update") => {
176 true
177 };
178 ("i2c_master.has_reliable_fsm_reset") => {
179 true
180 };
181 ("i2c_master.has_arbitration_en") => {
182 true
183 };
184 ("i2c_master.has_tx_fifo_watermark") => {
185 true
186 };
187 ("i2c_master.bus_timeout_is_exponential") => {
188 true
189 };
190 ("i2c_master.has_pd_en") => {
191 true
192 };
193 ("i2c_master.max_bus_timeout") => {
194 31
195 };
196 ("i2c_master.max_bus_timeout", str) => {
197 stringify!(31)
198 };
199 ("i2c_master.ll_intr_mask") => {
200 262143
201 };
202 ("i2c_master.ll_intr_mask", str) => {
203 stringify!(262143)
204 };
205 ("i2c_master.fifo_size") => {
206 32
207 };
208 ("i2c_master.fifo_size", str) => {
209 stringify!(32)
210 };
211 ("lp_i2c_master.version") => {
212 "lp_i2c"
213 };
214 ("lp_i2c_master.fifo_size") => {
215 16
216 };
217 ("lp_i2c_master.fifo_size", str) => {
218 stringify!(16)
219 };
220 ("spi_master.version") => {
221 3
222 };
223 ("spi_master.version", str) => {
224 stringify!(3)
225 };
226 ("spi_master.fifo_size") => {
227 64
228 };
229 ("spi_master.fifo_size", str) => {
230 stringify!(64)
231 };
232 ("spi_master.bit_order_is_bool") => {
233 false
234 };
235 ("spi_master.has_octal") => {
236 false
237 };
238 ("spi_master.has_app_interrupts") => {
239 true
240 };
241 ("spi_master.has_dma_segmented_transfer") => {
242 true
243 };
244 ("spi_master.has_clk_pre_div") => {
245 false
246 };
247 ("spi_master.dma_can_access_flash") => {
248 false
249 };
250 ("i2s.version") => {
251 2
252 };
253 ("i2s.version", str) => {
254 stringify!(2)
255 };
256 ("i2s.mclk_divider_bit_width") => {
257 9
258 };
259 ("i2s.mclk_divider_bit_width", str) => {
260 stringify!(9)
261 };
262 ("i2s.max_ws_width") => {
263 128
264 };
265 ("i2s.max_ws_width", str) => {
266 stringify!(128)
267 };
268 ("i2s.clock_configured_by_pcr") => {
269 true
270 };
271 ("i2s.clock_configured_by_hp_sys_clkrst") => {
272 false
273 };
274 ("i2s.supports_pdm_rx_hp_filter") => {
275 false
276 };
277 ("i2s.supports_pdm_tx") => {
278 true
279 };
280 ("i2s.supports_pdm_rx") => {
281 true
282 };
283 ("i2s.supports_pcm2pdm") => {
284 true
285 };
286 ("i2s.supports_pdm2pcm") => {
287 false
288 };
289 ("parl_io.version") => {
290 1
291 };
292 ("parl_io.version", str) => {
293 stringify!(1)
294 };
295 ("rmt.ram_start") => {
296 1610638336
297 };
298 ("rmt.ram_start", str) => {
299 stringify!(1610638336)
300 };
301 ("rmt.channel_ram_size") => {
302 48
303 };
304 ("rmt.channel_ram_size", str) => {
305 stringify!(48)
306 };
307 ("rmt.has_tx_immediate_stop") => {
308 true
309 };
310 ("rmt.has_tx_loop_count") => {
311 true
312 };
313 ("rmt.has_tx_loop_auto_stop") => {
314 true
315 };
316 ("rmt.has_tx_carrier_data_only") => {
317 true
318 };
319 ("rmt.has_tx_sync") => {
320 true
321 };
322 ("rmt.has_rx_wrap") => {
323 true
324 };
325 ("rmt.has_rx_demodulation") => {
326 true
327 };
328 ("rmt.has_per_channel_clock") => {
329 false
330 };
331 ("bt.controller") => {
332 "npl"
333 };
334 ("wifi.has_wifi6") => {
335 true
336 };
337 ("wifi.mac_version") => {
338 2
339 };
340 ("wifi.mac_version", str) => {
341 stringify!(2)
342 };
343 ("wifi.has_5g") => {
344 false
345 };
346 ("wifi.csi_supported") => {
347 true
348 };
349 ("phy.combo_module") => {
350 true
351 };
352 ("ledc.version") => {
353 3
354 };
355 ("ledc.version", str) => {
356 stringify!(3)
357 };
358 ("ledc.channel_count") => {
359 6
360 };
361 ("ledc.channel_count", str) => {
362 stringify!(6)
363 };
364 ("sdm.channel_count") => {
365 4
366 };
367 ("sdm.channel_count", str) => {
368 stringify!(4)
369 };
370 ("timergroup.timg_has_timer1") => {
371 false
372 };
373 ("timergroup.timg_has_divcnt_rst") => {
374 true
375 };
376 ("timergroup.rc_fast_calibration_divider_min_rev") => {
377 1
378 };
379 ("timergroup.rc_fast_calibration_divider") => {
380 32
381 };
382 ("timergroup.rc_fast_calibration_tick_enable") => {
383 false
384 };
385 ("aes.has_split_text_registers") => {
386 true
387 };
388 ("aes.endianness_configurable") => {
389 false
390 };
391 ("ecc.zero_extend_writes") => {
392 true
393 };
394 ("ecc.separate_jacobian_point_memory") => {
395 false
396 };
397 ("ecc.has_memory_clock_gate") => {
398 true
399 };
400 ("ecc.supports_enhanced_security") => {
401 false
402 };
403 ("ecc.mem_block_size") => {
404 32
405 };
406 ("rng.apb_cycle_wait_num") => {
407 16
408 };
409 ("rng.apb_cycle_wait_num", str) => {
410 stringify!(16)
411 };
412 ("rng.trng_supported") => {
413 true
414 };
415 ("rng.is_lp_sys") => {
416 true
417 };
418 ("rsa.version") => {
419 3
420 };
421 ("rsa.version", str) => {
422 stringify!(3)
423 };
424 ("rsa.size_increment") => {
425 32
426 };
427 ("rsa.size_increment", str) => {
428 stringify!(32)
429 };
430 ("rsa.memory_size_bytes") => {
431 384
432 };
433 ("rsa.memory_size_bytes", str) => {
434 stringify!(384)
435 };
436 ("sleep.light_sleep") => {
437 true
438 };
439 ("sleep.deep_sleep") => {
440 true
441 };
442 ("sleep.rejectable_mask") => {
443 3582
444 };
445 ("sleep.ext1_version") => {
446 2
447 };
448 ("sleep.ext1_version", str) => {
449 stringify!(2)
450 };
451 ("sleep.pin_wakeup_version") => {
452 3
453 };
454 ("sleep.pin_wakeup_version", str) => {
455 stringify!(3)
456 };
457 ("sleep.deep_sleep_needs_gpio_isolation") => {
458 false
459 };
460 ("assist_debug.has_sp_monitor") => {
461 true
462 };
463 ("assist_debug.has_region_monitor") => {
464 true
465 };
466 ("dma.mem2mem_requires_peripheral") => {
467 false
468 };
469 ("dma.ext_mem_configurable_block_size") => {
470 false
471 };
472 ("dma.separate_in_out_interrupts") => {
473 true
474 };
475 ("dma.gdma_version") => {
476 1
477 };
478 ("dma.gdma_version", str) => {
479 stringify!(1)
480 };
481 ("interrupts.status_registers") => {
482 3
483 };
484 ("interrupts.status_registers", str) => {
485 stringify!(3)
486 };
487 ("interrupts.disabled_interrupt") => {
488 31
489 };
490 ("mmu.page_size") => {
491 65536
492 };
493 ("mmu.page_size", str) => {
494 stringify!(65536)
495 };
496 ("mmu.entry_num") => {
497 256
498 };
499 ("mmu.entry_num", str) => {
500 stringify!(256)
501 };
502 ("rom.has_crc_le") => {
503 true
504 };
505 ("rom.has_crc_be") => {
506 true
507 };
508 ("rom.has_md5_bsd") => {
509 true
510 };
511 ("rom.has_md5_mbedtls") => {
512 false
513 };
514 ("soc.cpu_has_branch_predictor") => {
515 false
516 };
517 ("soc.cpu_has_csr_pc") => {
518 true
519 };
520 ("soc.multi_core_enabled") => {
521 false
522 };
523 ("soc.cpu_csr_prv_mode") => {
524 3088
525 };
526 ("soc.cpu_csr_prv_mode", str) => {
527 stringify!(3088)
528 };
529 ("soc.internal_memory_cached") => {
530 false
531 };
532 ("soc.has_swd_watchdog") => {
533 true
534 };
535 ("soc.cpu_mcause_mask") => {
536 31
537 };
538 ("soc.cpu_mcause_mask", str) => {
539 stringify!(31)
540 };
541 ("clock_tree.soc_root_clk") => {
542 [crate ::soc::clocks::SocRootClkConfig::Xtal, crate
543 ::soc::clocks::SocRootClkConfig::RcFast, crate
544 ::soc::clocks::SocRootClkConfig::Pll]
545 };
546 ("clock_tree.hp_root_clk.divisor") => {
547 [1, 3]
548 };
549 ("clock_tree.cpu_hs_div.divisor") => {
550 [0, 1, 3]
551 };
552 ("clock_tree.cpu_ls_div.divisor") => {
553 [0, 1, 3, 7, 15, 31]
554 };
555 ("clock_tree.cpu_clk") => {
556 [crate ::soc::clocks::CpuClkConfig::Hs, crate ::soc::clocks::CpuClkConfig::Ls]
557 };
558 ("clock_tree.ahb_hs_div.divisor") => {
559 [3, 7, 15]
560 };
561 ("clock_tree.ahb_ls_div.divisor") => {
562 [0, 1, 3, 7, 15, 31]
563 };
564 ("clock_tree.ahb_clk") => {
565 [crate ::soc::clocks::AhbClkConfig::Hs, crate ::soc::clocks::AhbClkConfig::Ls]
566 };
567 ("clock_tree.apb_clk.divisor") => {
568 [0, 1, 3]
569 };
570 ("clock_tree.mspi_fast_hs_clk.divisor") => {
571 [3, 4, 5]
572 };
573 ("clock_tree.mspi_fast_ls_clk.divisor") => {
574 [0, 1, 2]
575 };
576 ("clock_tree.mspi_fast_clk") => {
577 [crate ::soc::clocks::MspiFastClkConfig::Hs, crate
578 ::soc::clocks::MspiFastClkConfig::Ls]
579 };
580 ("clock_tree.iomux_function_clock") => {
581 [crate ::soc::clocks::IomuxFunctionClockConfig::PllF80m, crate
582 ::soc::clocks::IomuxFunctionClockConfig::RcFastClk, crate
583 ::soc::clocks::IomuxFunctionClockConfig::XtalClk]
584 };
585 ("clock_tree.ledc_sclk") => {
586 [crate ::soc::clocks::LedcSclkConfig::PllF80m, crate
587 ::soc::clocks::LedcSclkConfig::RcFastClk, crate
588 ::soc::clocks::LedcSclkConfig::XtalClk]
589 };
590 ("clock_tree.lp_fast_clk") => {
591 [crate ::soc::clocks::LpFastClkConfig::RcFastClk, crate
592 ::soc::clocks::LpFastClkConfig::XtalD2Clk]
593 };
594 ("clock_tree.lp_slow_clk") => {
595 [#[cfg(use_xtal32k)] crate ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
596 ::soc::clocks::LpSlowClkConfig::RcSlow, crate
597 ::soc::clocks::LpSlowClkConfig::OscSlow]
598 };
599 ("clock_tree.timg_calibration_clock") => {
600 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
601 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
602 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
603 };
604 ("clock_tree.uart.function_clock.sclk") => {
605 [crate ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
606 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
607 ::soc::clocks::UartFunctionClockSclk::Xtal]
608 };
609 ("clock_tree.uart.function_clock.div_num") => {
610 (0, 255)
611 };
612 ("clock_tree.uart.baud_rate_generator.fractional") => {
613 (0, 15)
614 };
615 ("clock_tree.uart.baud_rate_generator.integral") => {
616 (0, 4095)
617 };
618 ("clock_tree.rmt.sclk") => {
619 [crate ::soc::clocks::RmtSclkConfig::PllF80m, crate
620 ::soc::clocks::RmtSclkConfig::RcFastClk, crate
621 ::soc::clocks::RmtSclkConfig::XtalClk]
622 };
623 ("clock_tree.timg.function_clock") => {
624 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
625 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
626 ::soc::clocks::TimgFunctionClockConfig::PllF80m]
627 };
628 ("clock_tree.timg.wdt_clock") => {
629 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
630 ::soc::clocks::TimgWdtClockConfig::PllF80m, crate
631 ::soc::clocks::TimgWdtClockConfig::RcFastClk]
632 };
633 ("clock_tree.mcpwm.function_clock") => {
634 [crate ::soc::clocks::McpwmFunctionClockConfig::PllF160m, crate
635 ::soc::clocks::McpwmFunctionClockConfig::RcFastClk, crate
636 ::soc::clocks::McpwmFunctionClockConfig::XtalClk]
637 };
638 ("clock_tree.parl_io.rx_clock") => {
639 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
640 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
641 ::soc::clocks::ParlIoClkConfig::PllF240m]
642 };
643 ("clock_tree.parl_io.tx_clock") => {
644 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
645 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
646 ::soc::clocks::ParlIoClkConfig::PllF240m]
647 };
648 ("clock_tree.i2s.tx_clk.sclk") => {
649 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
650 ::soc::clocks::I2sClkSclk::PllF240m, crate ::soc::clocks::I2sClkSclk::PllF160m]
651 };
652 ("clock_tree.i2s.tx_clk.div_num") => {
653 (1, 255)
654 };
655 ("clock_tree.i2s.tx_clk.div_a") => {
656 (1, 511)
657 };
658 ("clock_tree.i2s.tx_clk.div_b") => {
659 (0, 511)
660 };
661 ("clock_tree.i2s.rx_clk.sclk") => {
662 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
663 ::soc::clocks::I2sClkSclk::PllF240m, crate ::soc::clocks::I2sClkSclk::PllF160m]
664 };
665 ("clock_tree.i2s.rx_clk.div_num") => {
666 (1, 255)
667 };
668 ("clock_tree.i2s.rx_clk.div_a") => {
669 (1, 511)
670 };
671 ("clock_tree.i2s.rx_clk.div_b") => {
672 (0, 511)
673 };
674 ("clock_tree.i2s.mclk_out") => {
675 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
676 ::soc::clocks::I2sMclkOutConfig::Rx]
677 };
678 ("clock_tree.i2c.function_clock.sclk") => {
679 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
680 ::soc::clocks::I2cFunctionClockSclk::RcFast]
681 };
682 ("clock_tree.i2c.function_clock.div_num") => {
683 (0, 255)
684 };
685 ("clock_tree.spi.function_clock") => {
686 [crate ::soc::clocks::SpiFunctionClockConfig::PllF80m, crate
687 ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
688 ::soc::clocks::SpiFunctionClockConfig::RcFast]
689 };
690}
691#[macro_export]
692#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
693macro_rules! for_each_dedicated_gpio {
694 ($($pattern:tt => $code:tt;)*) => {
695 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
696 tt) => {} } _for_each_inner_dedicated_gpio!((0));
697 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
698 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
699 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
700 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
701 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
702 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
703 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
704 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
705 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
706 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
707 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
708 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
709 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
710 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
711 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
712 };
713}
714#[macro_export]
718#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
719macro_rules! define_lp_io_signals {
720 () => {};
721}
722#[macro_export]
744#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
745macro_rules! for_each_rmt_channel {
746 ($($pattern:tt => $code:tt;)*) => {
747 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
748 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
749 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
750 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
751 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
752 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
753 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
754 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
755 };
756}
757#[macro_export]
758#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
759macro_rules! for_each_sdm_channel {
760 ($($pattern:tt => $code:tt;)*) => {
761 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
762 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
763 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
764 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
765 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
766 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
767 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
768 GPIO_SD3)));
769 };
770}
771#[macro_export]
772#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
773macro_rules! for_each_aes_key_length {
774 ($($pattern:tt => $code:tt;)*) => {
775 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
776 tt) => {} } _for_each_inner_aes_key_length!((128));
777 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
778 4)); _for_each_inner_aes_key_length!((256, 2, 6));
779 _for_each_inner_aes_key_length!((bits(128), (256)));
780 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
781 };
782}
783#[macro_export]
784#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
785macro_rules! for_each_ecc_working_mode {
786 ($($pattern:tt => $code:tt;)*) => {
787 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
788 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
789 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
790 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
791 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
792 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
793 _for_each_inner_ecc_working_mode!((7,
794 AffinePointVerificationAndJacobianPointMultiplication));
795 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
796 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
797 JacobianPointMultiplication), (6, JacobianPointVerification), (7,
798 AffinePointVerificationAndJacobianPointMultiplication)));
799 };
800}
801#[macro_export]
802#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
803macro_rules! for_each_ecc_curve {
804 ($($pattern:tt => $code:tt;)*) => {
805 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
806 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
807 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
808 P192, 192), (1, P256, 256)));
809 };
810}
811#[macro_export]
812#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
813macro_rules! for_each_rsa_exponentiation {
814 ($($pattern:tt => $code:tt;)*) => {
815 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
816 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
817 _for_each_inner_rsa_exponentiation!((64));
818 _for_each_inner_rsa_exponentiation!((96));
819 _for_each_inner_rsa_exponentiation!((128));
820 _for_each_inner_rsa_exponentiation!((160));
821 _for_each_inner_rsa_exponentiation!((192));
822 _for_each_inner_rsa_exponentiation!((224));
823 _for_each_inner_rsa_exponentiation!((256));
824 _for_each_inner_rsa_exponentiation!((288));
825 _for_each_inner_rsa_exponentiation!((320));
826 _for_each_inner_rsa_exponentiation!((352));
827 _for_each_inner_rsa_exponentiation!((384));
828 _for_each_inner_rsa_exponentiation!((416));
829 _for_each_inner_rsa_exponentiation!((448));
830 _for_each_inner_rsa_exponentiation!((480));
831 _for_each_inner_rsa_exponentiation!((512));
832 _for_each_inner_rsa_exponentiation!((544));
833 _for_each_inner_rsa_exponentiation!((576));
834 _for_each_inner_rsa_exponentiation!((608));
835 _for_each_inner_rsa_exponentiation!((640));
836 _for_each_inner_rsa_exponentiation!((672));
837 _for_each_inner_rsa_exponentiation!((704));
838 _for_each_inner_rsa_exponentiation!((736));
839 _for_each_inner_rsa_exponentiation!((768));
840 _for_each_inner_rsa_exponentiation!((800));
841 _for_each_inner_rsa_exponentiation!((832));
842 _for_each_inner_rsa_exponentiation!((864));
843 _for_each_inner_rsa_exponentiation!((896));
844 _for_each_inner_rsa_exponentiation!((928));
845 _for_each_inner_rsa_exponentiation!((960));
846 _for_each_inner_rsa_exponentiation!((992));
847 _for_each_inner_rsa_exponentiation!((1024));
848 _for_each_inner_rsa_exponentiation!((1056));
849 _for_each_inner_rsa_exponentiation!((1088));
850 _for_each_inner_rsa_exponentiation!((1120));
851 _for_each_inner_rsa_exponentiation!((1152));
852 _for_each_inner_rsa_exponentiation!((1184));
853 _for_each_inner_rsa_exponentiation!((1216));
854 _for_each_inner_rsa_exponentiation!((1248));
855 _for_each_inner_rsa_exponentiation!((1280));
856 _for_each_inner_rsa_exponentiation!((1312));
857 _for_each_inner_rsa_exponentiation!((1344));
858 _for_each_inner_rsa_exponentiation!((1376));
859 _for_each_inner_rsa_exponentiation!((1408));
860 _for_each_inner_rsa_exponentiation!((1440));
861 _for_each_inner_rsa_exponentiation!((1472));
862 _for_each_inner_rsa_exponentiation!((1504));
863 _for_each_inner_rsa_exponentiation!((1536));
864 _for_each_inner_rsa_exponentiation!((1568));
865 _for_each_inner_rsa_exponentiation!((1600));
866 _for_each_inner_rsa_exponentiation!((1632));
867 _for_each_inner_rsa_exponentiation!((1664));
868 _for_each_inner_rsa_exponentiation!((1696));
869 _for_each_inner_rsa_exponentiation!((1728));
870 _for_each_inner_rsa_exponentiation!((1760));
871 _for_each_inner_rsa_exponentiation!((1792));
872 _for_each_inner_rsa_exponentiation!((1824));
873 _for_each_inner_rsa_exponentiation!((1856));
874 _for_each_inner_rsa_exponentiation!((1888));
875 _for_each_inner_rsa_exponentiation!((1920));
876 _for_each_inner_rsa_exponentiation!((1952));
877 _for_each_inner_rsa_exponentiation!((1984));
878 _for_each_inner_rsa_exponentiation!((2016));
879 _for_each_inner_rsa_exponentiation!((2048));
880 _for_each_inner_rsa_exponentiation!((2080));
881 _for_each_inner_rsa_exponentiation!((2112));
882 _for_each_inner_rsa_exponentiation!((2144));
883 _for_each_inner_rsa_exponentiation!((2176));
884 _for_each_inner_rsa_exponentiation!((2208));
885 _for_each_inner_rsa_exponentiation!((2240));
886 _for_each_inner_rsa_exponentiation!((2272));
887 _for_each_inner_rsa_exponentiation!((2304));
888 _for_each_inner_rsa_exponentiation!((2336));
889 _for_each_inner_rsa_exponentiation!((2368));
890 _for_each_inner_rsa_exponentiation!((2400));
891 _for_each_inner_rsa_exponentiation!((2432));
892 _for_each_inner_rsa_exponentiation!((2464));
893 _for_each_inner_rsa_exponentiation!((2496));
894 _for_each_inner_rsa_exponentiation!((2528));
895 _for_each_inner_rsa_exponentiation!((2560));
896 _for_each_inner_rsa_exponentiation!((2592));
897 _for_each_inner_rsa_exponentiation!((2624));
898 _for_each_inner_rsa_exponentiation!((2656));
899 _for_each_inner_rsa_exponentiation!((2688));
900 _for_each_inner_rsa_exponentiation!((2720));
901 _for_each_inner_rsa_exponentiation!((2752));
902 _for_each_inner_rsa_exponentiation!((2784));
903 _for_each_inner_rsa_exponentiation!((2816));
904 _for_each_inner_rsa_exponentiation!((2848));
905 _for_each_inner_rsa_exponentiation!((2880));
906 _for_each_inner_rsa_exponentiation!((2912));
907 _for_each_inner_rsa_exponentiation!((2944));
908 _for_each_inner_rsa_exponentiation!((2976));
909 _for_each_inner_rsa_exponentiation!((3008));
910 _for_each_inner_rsa_exponentiation!((3040));
911 _for_each_inner_rsa_exponentiation!((3072));
912 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
913 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
914 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
915 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
916 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
917 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
918 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
919 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
920 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
921 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
922 };
923}
924#[macro_export]
925#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
926macro_rules! for_each_rsa_multiplication {
927 ($($pattern:tt => $code:tt;)*) => {
928 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
929 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
930 _for_each_inner_rsa_multiplication!((64));
931 _for_each_inner_rsa_multiplication!((96));
932 _for_each_inner_rsa_multiplication!((128));
933 _for_each_inner_rsa_multiplication!((160));
934 _for_each_inner_rsa_multiplication!((192));
935 _for_each_inner_rsa_multiplication!((224));
936 _for_each_inner_rsa_multiplication!((256));
937 _for_each_inner_rsa_multiplication!((288));
938 _for_each_inner_rsa_multiplication!((320));
939 _for_each_inner_rsa_multiplication!((352));
940 _for_each_inner_rsa_multiplication!((384));
941 _for_each_inner_rsa_multiplication!((416));
942 _for_each_inner_rsa_multiplication!((448));
943 _for_each_inner_rsa_multiplication!((480));
944 _for_each_inner_rsa_multiplication!((512));
945 _for_each_inner_rsa_multiplication!((544));
946 _for_each_inner_rsa_multiplication!((576));
947 _for_each_inner_rsa_multiplication!((608));
948 _for_each_inner_rsa_multiplication!((640));
949 _for_each_inner_rsa_multiplication!((672));
950 _for_each_inner_rsa_multiplication!((704));
951 _for_each_inner_rsa_multiplication!((736));
952 _for_each_inner_rsa_multiplication!((768));
953 _for_each_inner_rsa_multiplication!((800));
954 _for_each_inner_rsa_multiplication!((832));
955 _for_each_inner_rsa_multiplication!((864));
956 _for_each_inner_rsa_multiplication!((896));
957 _for_each_inner_rsa_multiplication!((928));
958 _for_each_inner_rsa_multiplication!((960));
959 _for_each_inner_rsa_multiplication!((992));
960 _for_each_inner_rsa_multiplication!((1024));
961 _for_each_inner_rsa_multiplication!((1056));
962 _for_each_inner_rsa_multiplication!((1088));
963 _for_each_inner_rsa_multiplication!((1120));
964 _for_each_inner_rsa_multiplication!((1152));
965 _for_each_inner_rsa_multiplication!((1184));
966 _for_each_inner_rsa_multiplication!((1216));
967 _for_each_inner_rsa_multiplication!((1248));
968 _for_each_inner_rsa_multiplication!((1280));
969 _for_each_inner_rsa_multiplication!((1312));
970 _for_each_inner_rsa_multiplication!((1344));
971 _for_each_inner_rsa_multiplication!((1376));
972 _for_each_inner_rsa_multiplication!((1408));
973 _for_each_inner_rsa_multiplication!((1440));
974 _for_each_inner_rsa_multiplication!((1472));
975 _for_each_inner_rsa_multiplication!((1504));
976 _for_each_inner_rsa_multiplication!((1536));
977 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
978 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
979 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
980 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
981 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
982 };
983}
984#[macro_export]
985#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
986macro_rules! for_each_sha_algorithm {
987 ($($pattern:tt => $code:tt;)*) => {
988 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
989 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
990 (insecure_against : "collision", "length extension"), 0));
991 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
992 (insecure_against : "length extension"), 1));
993 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
994 (insecure_against : "length extension"), 2));
995 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
996 (insecure_against : "collision", "length extension"), 0), (Sha224,
997 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
998 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
999 2)));
1000 };
1001}
1002#[macro_export]
1003#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1004macro_rules! for_each_wakeup_source {
1005 ($($pattern:tt => $code:tt;)*) => {
1006 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
1007 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
1008 _for_each_inner_wakeup_source!((Gpio, 2));
1009 _for_each_inner_wakeup_source!((WifiBeacon, 3));
1010 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
1011 5)); _for_each_inner_wakeup_source!((Uart0, 6));
1012 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
1013 8)); _for_each_inner_wakeup_source!((Bt, 10));
1014 _for_each_inner_wakeup_source!((LpCore, 11));
1015 _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3), (Timer,
1016 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Bt, 10), (LpCore, 11)));
1017 };
1018}
1019#[macro_export]
1020#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1021macro_rules! for_each_dma_engine {
1022 ($($pattern:tt => $code:tt;)*) => {
1023 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
1024 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
1025 _for_each_inner_dma_engine!((all("AHB_GDMA")));
1026 };
1027}
1028#[macro_export]
1029#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1030macro_rules! for_each_dma_channel {
1031 ($($pattern:tt => $code:tt;)*) => {
1032 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
1033 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
1034 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
1035 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
1036 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
1037 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
1038 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1039 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1,
1040 interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI2,
1041 UHCI0, I2S0, AES, SHA, APB_SARADC, PARL_IO]));
1042 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1043 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1044 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
1045 ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2)));
1046 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
1047 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
1048 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1049 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES,
1050 SHA, APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
1051 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1052 APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1053 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1054 APB_SARADC, PARL_IO]))); _for_each_inner_dma_channel!((no_own_interrupt));
1055 };
1056}
1057#[macro_export]
1058#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1059macro_rules! for_each_dma_channel_peri_pair {
1060 ($($pattern:tt => $code:tt;)*) => {
1061 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1062 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1063 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
1064 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
1065 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
1066 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
1067 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
1068 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
1069 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
1070 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
1071 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
1072 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
1073 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
1074 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
1075 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
1076 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
1077 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
1078 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
1079 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
1080 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
1081 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
1082 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
1083 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1084 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1085 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1086 any_channel = AhbGdmaChannel, I2S0));
1087 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1088 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1089 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1090 any_channel = AhbGdmaChannel, APB_SARADC));
1091 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1092 PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
1093 SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA",
1094 DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC),
1095 ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI2), ("AHB_GDMA",
1096 DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, AES),
1097 ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1, APB_SARADC), ("AHB_GDMA",
1098 DMA_CH1, PARL_IO), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
1099 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
1100 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC), ("AHB_GDMA", DMA_CH2, PARL_IO)));
1101 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1102 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
1103 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
1104 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
1105 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC), ("AHB_GDMA", any_channel
1106 = AhbGdmaChannel, PARL_IO)));
1107 };
1108}
1109#[macro_export]
1110#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1111macro_rules! for_each_mem2mem_channel {
1112 ($($pattern:tt => $code:tt;)*) => {
1113 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1114 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1115 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1116 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
1117 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
1118 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1119 4, 1, 5, 2, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1120 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1121 AhbGdmaChannel, DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5),
1122 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 10)));
1123 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1124 4, 1, 5, 2, 10))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1125 AhbGdmaChannel)));
1126 };
1127}
1128#[macro_export]
1129#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1130macro_rules! with_aes_dma_engine {
1131 ($($pattern:tt => $code:tt;)*) => {
1132 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1133 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1134 };
1135}
1136#[macro_export]
1137#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1138macro_rules! with_i2s_dma_engine {
1139 ($($pattern:tt => $code:tt;)*) => {
1140 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1141 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1142 };
1143}
1144#[macro_export]
1145#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1146macro_rules! with_parl_io_dma_engine {
1147 ($($pattern:tt => $code:tt;)*) => {
1148 macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
1149 tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1150 };
1151}
1152#[macro_export]
1153#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1154macro_rules! with_sha_dma_engine {
1155 ($($pattern:tt => $code:tt;)*) => {
1156 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1157 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1158 };
1159}
1160#[macro_export]
1161#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1162macro_rules! with_spi_master_dma_engine {
1163 ($($pattern:tt => $code:tt;)*) => {
1164 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1165 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1166 };
1167}
1168#[macro_export]
1169#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1170macro_rules! with_spi_slave_dma_engine {
1171 ($($pattern:tt => $code:tt;)*) => {
1172 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1173 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1174 };
1175}
1176#[macro_export]
1177#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1178macro_rules! with_uhci_dma_engine {
1179 ($($pattern:tt => $code:tt;)*) => {
1180 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1181 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1182 };
1183}
1184#[macro_export]
1185#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1186macro_rules! for_each_interrupt {
1187 ($($pattern:tt => $code:tt;)*) => {
1188 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1189 => {} } _for_each_inner_interrupt!(([reserved 0] 0));
1190 _for_each_inner_interrupt!(([context_switch 0] 1));
1191 _for_each_inner_interrupt!(([direct_bindable 0] 2));
1192 _for_each_inner_interrupt!(([reserved 1] 3));
1193 _for_each_inner_interrupt!(([reserved 2] 4));
1194 _for_each_inner_interrupt!(([direct_bindable 1] 5));
1195 _for_each_inner_interrupt!(([direct_bindable 2] 6));
1196 _for_each_inner_interrupt!(([reserved 3] 7));
1197 _for_each_inner_interrupt!(([direct_bindable 3] 8));
1198 _for_each_inner_interrupt!(([direct_bindable 4] 9));
1199 _for_each_inner_interrupt!(([direct_bindable 5] 10));
1200 _for_each_inner_interrupt!(([direct_bindable 6] 11));
1201 _for_each_inner_interrupt!(([direct_bindable 7] 12));
1202 _for_each_inner_interrupt!(([direct_bindable 8] 13));
1203 _for_each_inner_interrupt!(([direct_bindable 9] 14));
1204 _for_each_inner_interrupt!(([direct_bindable 10] 15));
1205 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1206 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1207 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1208 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1209 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1210 7] 23)); _for_each_inner_interrupt!(([vector 8] 24));
1211 _for_each_inner_interrupt!(([vector 9] 25)); _for_each_inner_interrupt!(([vector
1212 10] 26)); _for_each_inner_interrupt!(([vector 11] 27));
1213 _for_each_inner_interrupt!(([vector 12] 28)); _for_each_inner_interrupt!(([vector
1214 13] 29)); _for_each_inner_interrupt!(([vector 14] 30));
1215 _for_each_inner_interrupt!(([disabled 0] 31));
1216 _for_each_inner_interrupt!((all([reserved 0] 0), ([context_switch 0] 1),
1217 ([direct_bindable 0] 2), ([reserved 1] 3), ([reserved 2] 4), ([direct_bindable 1]
1218 5), ([direct_bindable 2] 6), ([reserved 3] 7), ([direct_bindable 3] 8),
1219 ([direct_bindable 4] 9), ([direct_bindable 5] 10), ([direct_bindable 6] 11),
1220 ([direct_bindable 7] 12), ([direct_bindable 8] 13), ([direct_bindable 9] 14),
1221 ([direct_bindable 10] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18),
1222 ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7]
1223 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26), ([vector 11] 27),
1224 ([vector 12] 28), ([vector 13] 29), ([vector 14] 30), ([disabled 0] 31)));
1225 };
1226}
1227#[macro_export]
1228#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1229macro_rules! for_each_classified_interrupt {
1230 ($($pattern:tt => $code:tt;)*) => {
1231 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1232 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1233 2)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 5));
1234 _for_each_inner_classified_interrupt!(([direct_bindable 2] 6));
1235 _for_each_inner_classified_interrupt!(([direct_bindable 3] 8));
1236 _for_each_inner_classified_interrupt!(([direct_bindable 4] 9));
1237 _for_each_inner_classified_interrupt!(([direct_bindable 5] 10));
1238 _for_each_inner_classified_interrupt!(([direct_bindable 6] 11));
1239 _for_each_inner_classified_interrupt!(([direct_bindable 7] 12));
1240 _for_each_inner_classified_interrupt!(([direct_bindable 8] 13));
1241 _for_each_inner_classified_interrupt!(([direct_bindable 9] 14));
1242 _for_each_inner_classified_interrupt!(([direct_bindable 10] 15));
1243 _for_each_inner_classified_interrupt!(([vector 0] 16));
1244 _for_each_inner_classified_interrupt!(([vector 1] 17));
1245 _for_each_inner_classified_interrupt!(([vector 2] 18));
1246 _for_each_inner_classified_interrupt!(([vector 3] 19));
1247 _for_each_inner_classified_interrupt!(([vector 4] 20));
1248 _for_each_inner_classified_interrupt!(([vector 5] 21));
1249 _for_each_inner_classified_interrupt!(([vector 6] 22));
1250 _for_each_inner_classified_interrupt!(([vector 7] 23));
1251 _for_each_inner_classified_interrupt!(([vector 8] 24));
1252 _for_each_inner_classified_interrupt!(([vector 9] 25));
1253 _for_each_inner_classified_interrupt!(([vector 10] 26));
1254 _for_each_inner_classified_interrupt!(([vector 11] 27));
1255 _for_each_inner_classified_interrupt!(([vector 12] 28));
1256 _for_each_inner_classified_interrupt!(([vector 13] 29));
1257 _for_each_inner_classified_interrupt!(([vector 14] 30));
1258 _for_each_inner_classified_interrupt!(([reserved 0] 0));
1259 _for_each_inner_classified_interrupt!(([reserved 1] 3));
1260 _for_each_inner_classified_interrupt!(([reserved 2] 4));
1261 _for_each_inner_classified_interrupt!(([reserved 3] 7));
1262 _for_each_inner_classified_interrupt!(([context_switch 0] 1));
1263 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 2),
1264 ([direct_bindable 1] 5), ([direct_bindable 2] 6), ([direct_bindable 3] 8),
1265 ([direct_bindable 4] 9), ([direct_bindable 5] 10), ([direct_bindable 6] 11),
1266 ([direct_bindable 7] 12), ([direct_bindable 8] 13), ([direct_bindable 9] 14),
1267 ([direct_bindable 10] 15)));
1268 _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1269 ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1270 22), ([vector 7] 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26),
1271 ([vector 11] 27), ([vector 12] 28), ([vector 13] 29), ([vector 14] 30)));
1272 _for_each_inner_classified_interrupt!((reserved([reserved 0] 0), ([reserved 1]
1273 3), ([reserved 2] 4), ([reserved 3] 7)));
1274 _for_each_inner_classified_interrupt!((context_switch([context_switch 0] 1)));
1275 };
1276}
1277#[macro_export]
1278#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1279macro_rules! for_each_interrupt_priority {
1280 ($($pattern:tt => $code:tt;)*) => {
1281 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1282 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1283 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1284 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1285 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1286 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1287 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1288 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1289 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1290 _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
1291 _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
1292 _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
1293 _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
1294 _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
1295 _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
1296 _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
1297 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1298 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1299 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1300 Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
1301 11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
1302 Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
1303 };
1304}
1305#[macro_export]
1306#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1307macro_rules! for_each_sw_interrupt {
1308 ($($pattern:tt => $code:tt;)*) => {
1309 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1310 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1311 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1312 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1313 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1314 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1315 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1316 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1317 };
1318}
1319#[macro_export]
1320macro_rules! define_clock_tree_types {
1831 () => {
1832 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1833 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1834 pub enum SdmInstance {
1835 GpioSd = 0,
1836 }
1837 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1838 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1839 pub enum I2cInstance {
1840 I2c0 = 0,
1841 }
1842 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1843 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1844 pub enum I2sInstance {
1845 I2s0 = 0,
1846 }
1847 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1848 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1849 pub enum McpwmInstance {
1850 Mcpwm0 = 0,
1851 }
1852 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1853 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1854 pub enum ParlIoInstance {
1855 ParlIo = 0,
1856 }
1857 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1858 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1859 pub enum RmtInstance {
1860 Rmt = 0,
1861 }
1862 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1863 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1864 pub enum SpiInstance {
1865 Spi2 = 0,
1866 }
1867 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1868 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1869 pub enum TimgInstance {
1870 Timg0 = 0,
1871 Timg1 = 1,
1872 }
1873 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1874 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1875 pub enum UartInstance {
1876 Uart0 = 0,
1877 Uart1 = 1,
1878 }
1879 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1881 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1882 pub enum XtalClkConfig {
1883 _40,
1885 }
1886 impl XtalClkConfig {
1887 pub fn value(&self) -> u32 {
1888 match self {
1889 XtalClkConfig::_40 => 40000000,
1890 }
1891 }
1892 }
1893 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1894 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1895 pub enum HpRootClkDivisor {
1896 _1 = 1,
1898 _3 = 3,
1900 }
1901 impl HpRootClkDivisor {
1902 pub const fn new(raw: u32) -> Self {
1904 match raw {
1905 1 => Self::_1,
1906 3 => Self::_3,
1907 _ => ::core::panic!("Invalid HP_ROOT_CLK divisor value"),
1908 }
1909 }
1910 }
1911 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1915 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1916 pub struct HpRootClkConfig {
1917 divisor: HpRootClkDivisor,
1918 }
1919 impl HpRootClkConfig {
1920 pub const fn new(divisor: HpRootClkDivisor) -> Self {
1922 Self { divisor }
1923 }
1924 pub(crate) fn divisor(self) -> u32 {
1925 self.divisor as u32
1926 }
1927 }
1928 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1930 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1931 pub enum CpuClkConfig {
1932 Hs,
1934 Ls,
1936 }
1937 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1939 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1940 pub enum AhbClkConfig {
1941 Hs,
1943 Ls,
1945 }
1946 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1948 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1949 pub enum MspiFastClkConfig {
1950 Hs,
1952 Ls,
1954 }
1955 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1957 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1958 pub enum SocRootClkConfig {
1959 Xtal,
1961 RcFast,
1963 Pll,
1965 }
1966 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1967 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1968 pub enum CpuHsDivDivisor {
1969 _0 = 0,
1971 _1 = 1,
1973 _3 = 3,
1975 }
1976 impl CpuHsDivDivisor {
1977 pub const fn new(raw: u32) -> Self {
1979 match raw {
1980 0 => Self::_0,
1981 1 => Self::_1,
1982 3 => Self::_3,
1983 _ => ::core::panic!("Invalid CPU_HS_DIV divisor value"),
1984 }
1985 }
1986 }
1987 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1991 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1992 pub struct CpuHsDivConfig {
1993 divisor: CpuHsDivDivisor,
1994 }
1995 impl CpuHsDivConfig {
1996 pub const fn new(divisor: CpuHsDivDivisor) -> Self {
1998 Self { divisor }
1999 }
2000 pub(crate) fn divisor(self) -> u32 {
2001 self.divisor as u32
2002 }
2003 }
2004 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2005 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2006 pub enum CpuLsDivDivisor {
2007 _0 = 0,
2009 _1 = 1,
2011 _3 = 3,
2013 _7 = 7,
2015 _15 = 15,
2017 _31 = 31,
2019 }
2020 impl CpuLsDivDivisor {
2021 pub const fn new(raw: u32) -> Self {
2023 match raw {
2024 0 => Self::_0,
2025 1 => Self::_1,
2026 3 => Self::_3,
2027 7 => Self::_7,
2028 15 => Self::_15,
2029 31 => Self::_31,
2030 _ => ::core::panic!("Invalid CPU_LS_DIV divisor value"),
2031 }
2032 }
2033 }
2034 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2038 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2039 pub struct CpuLsDivConfig {
2040 divisor: CpuLsDivDivisor,
2041 }
2042 impl CpuLsDivConfig {
2043 pub const fn new(divisor: CpuLsDivDivisor) -> Self {
2045 Self { divisor }
2046 }
2047 pub(crate) fn divisor(self) -> u32 {
2048 self.divisor as u32
2049 }
2050 }
2051 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2052 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2053 pub enum AhbHsDivDivisor {
2054 _3 = 3,
2056 _7 = 7,
2058 _15 = 15,
2060 }
2061 impl AhbHsDivDivisor {
2062 pub const fn new(raw: u32) -> Self {
2064 match raw {
2065 3 => Self::_3,
2066 7 => Self::_7,
2067 15 => Self::_15,
2068 _ => ::core::panic!("Invalid AHB_HS_DIV divisor value"),
2069 }
2070 }
2071 }
2072 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2076 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2077 pub struct AhbHsDivConfig {
2078 divisor: AhbHsDivDivisor,
2079 }
2080 impl AhbHsDivConfig {
2081 pub const fn new(divisor: AhbHsDivDivisor) -> Self {
2083 Self { divisor }
2084 }
2085 pub(crate) fn divisor(self) -> u32 {
2086 self.divisor as u32
2087 }
2088 }
2089 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2090 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2091 pub enum AhbLsDivDivisor {
2092 _0 = 0,
2094 _1 = 1,
2096 _3 = 3,
2098 _7 = 7,
2100 _15 = 15,
2102 _31 = 31,
2104 }
2105 impl AhbLsDivDivisor {
2106 pub const fn new(raw: u32) -> Self {
2108 match raw {
2109 0 => Self::_0,
2110 1 => Self::_1,
2111 3 => Self::_3,
2112 7 => Self::_7,
2113 15 => Self::_15,
2114 31 => Self::_31,
2115 _ => ::core::panic!("Invalid AHB_LS_DIV divisor value"),
2116 }
2117 }
2118 }
2119 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2123 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2124 pub struct AhbLsDivConfig {
2125 divisor: AhbLsDivDivisor,
2126 }
2127 impl AhbLsDivConfig {
2128 pub const fn new(divisor: AhbLsDivDivisor) -> Self {
2130 Self { divisor }
2131 }
2132 pub(crate) fn divisor(self) -> u32 {
2133 self.divisor as u32
2134 }
2135 }
2136 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2137 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2138 pub enum ApbClkDivisor {
2139 _0 = 0,
2141 _1 = 1,
2143 _3 = 3,
2145 }
2146 impl ApbClkDivisor {
2147 pub const fn new(raw: u32) -> Self {
2149 match raw {
2150 0 => Self::_0,
2151 1 => Self::_1,
2152 3 => Self::_3,
2153 _ => ::core::panic!("Invalid APB_CLK divisor value"),
2154 }
2155 }
2156 }
2157 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2161 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2162 pub struct ApbClkConfig {
2163 divisor: ApbClkDivisor,
2164 }
2165 impl ApbClkConfig {
2166 pub const fn new(divisor: ApbClkDivisor) -> Self {
2168 Self { divisor }
2169 }
2170 pub(crate) fn divisor(self) -> u32 {
2171 self.divisor as u32
2172 }
2173 }
2174 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2175 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2176 pub enum MspiFastHsClkDivisor {
2177 _3 = 3,
2179 _4 = 4,
2181 _5 = 5,
2183 }
2184 impl MspiFastHsClkDivisor {
2185 pub const fn new(raw: u32) -> Self {
2187 match raw {
2188 3 => Self::_3,
2189 4 => Self::_4,
2190 5 => Self::_5,
2191 _ => ::core::panic!("Invalid MSPI_FAST_HS_CLK divisor value"),
2192 }
2193 }
2194 }
2195 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2199 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2200 pub struct MspiFastHsClkConfig {
2201 divisor: MspiFastHsClkDivisor,
2202 }
2203 impl MspiFastHsClkConfig {
2204 pub const fn new(divisor: MspiFastHsClkDivisor) -> Self {
2206 Self { divisor }
2207 }
2208 pub(crate) fn divisor(self) -> u32 {
2209 self.divisor as u32
2210 }
2211 }
2212 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2213 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2214 pub enum MspiFastLsClkDivisor {
2215 _0 = 0,
2217 _1 = 1,
2219 _2 = 2,
2221 }
2222 impl MspiFastLsClkDivisor {
2223 pub const fn new(raw: u32) -> Self {
2225 match raw {
2226 0 => Self::_0,
2227 1 => Self::_1,
2228 2 => Self::_2,
2229 _ => ::core::panic!("Invalid MSPI_FAST_LS_CLK divisor value"),
2230 }
2231 }
2232 }
2233 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2237 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2238 pub struct MspiFastLsClkConfig {
2239 divisor: MspiFastLsClkDivisor,
2240 }
2241 impl MspiFastLsClkConfig {
2242 pub const fn new(divisor: MspiFastLsClkDivisor) -> Self {
2244 Self { divisor }
2245 }
2246 pub(crate) fn divisor(self) -> u32 {
2247 self.divisor as u32
2248 }
2249 }
2250 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2252 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2253 pub enum IomuxFunctionClockConfig {
2254 #[default]
2255 PllF80m,
2257 RcFastClk,
2259 XtalClk,
2261 }
2262 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2264 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2265 pub enum LedcSclkConfig {
2266 PllF80m,
2268 RcFastClk,
2270 XtalClk,
2272 }
2273 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2275 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2276 pub enum LpFastClkConfig {
2277 RcFastClk,
2279 XtalD2Clk,
2281 }
2282 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2284 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2285 pub enum LpSlowClkConfig {
2286 #[cfg(use_xtal32k)]
2287 Xtal32k,
2289 RcSlow,
2291 OscSlow,
2293 }
2294 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2296 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2297 pub enum TimgCalibrationClockConfig {
2298 RcSlowClk,
2300 RcFastDivClk,
2302 #[cfg(use_xtal32k)]
2303 Xtal32kClk,
2305 }
2306 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2307 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2308 pub enum I2cFunctionClockSclk {
2309 #[default]
2310 Xtal,
2312 RcFast,
2314 }
2315 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2319 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2320 pub struct I2cFunctionClockConfig {
2321 sclk: I2cFunctionClockSclk,
2322 div_num: u32,
2323 }
2324 impl I2cFunctionClockConfig {
2325 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
2332 ::core::assert!(
2333 div_num <= 255,
2334 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2335 );
2336 Self { sclk, div_num }
2337 }
2338 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
2339 self.sclk
2340 }
2341 pub(crate) fn div_num(self) -> u32 {
2342 self.div_num as u32
2343 }
2344 }
2345 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2346 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2347 pub enum I2sClkSclk {
2348 Xtal,
2350 PllF240m,
2352 #[default]
2353 PllF160m,
2355 }
2356 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2360 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2361 pub struct I2sClkConfig {
2362 sclk: I2sClkSclk,
2363 div_num: u32,
2364 div_a: u32,
2365 div_b: u32,
2366 }
2367 impl I2sClkConfig {
2368 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
2381 ::core::assert!(
2382 div_num >= 1 && div_num <= 255,
2383 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
2384 );
2385 ::core::assert!(
2386 div_a >= 1 && div_a <= 511,
2387 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
2388 );
2389 ::core::assert!(
2390 div_b <= 511,
2391 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
2392 );
2393 Self {
2394 sclk,
2395 div_num,
2396 div_a,
2397 div_b,
2398 }
2399 }
2400 pub(crate) fn sclk(self) -> I2sClkSclk {
2401 self.sclk
2402 }
2403 pub(crate) fn div_num(self) -> u32 {
2404 self.div_num as u32
2405 }
2406 pub(crate) fn div_a(self) -> u32 {
2407 self.div_a as u32
2408 }
2409 pub(crate) fn div_b(self) -> u32 {
2410 self.div_b as u32
2411 }
2412 }
2413 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2415 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2416 pub enum I2sMclkOutConfig {
2417 Tx,
2419 #[default]
2420 Rx,
2422 }
2423 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2425 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2426 pub enum McpwmFunctionClockConfig {
2427 #[default]
2428 PllF160m,
2430 RcFastClk,
2432 XtalClk,
2434 }
2435 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2437 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2438 pub enum ParlIoClkConfig {
2439 XtalClk,
2441 RcFastClk,
2443 #[default]
2444 PllF240m,
2446 }
2447 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2449 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2450 pub enum RmtSclkConfig {
2451 #[default]
2452 PllF80m,
2454 RcFastClk,
2456 XtalClk,
2458 }
2459 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2461 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2462 pub enum SpiFunctionClockConfig {
2463 #[default]
2464 PllF80m,
2466 Xtal,
2468 RcFast,
2470 }
2471 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2473 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2474 pub enum TimgFunctionClockConfig {
2475 #[default]
2476 XtalClk,
2478 RcFastClk,
2480 PllF80m,
2482 }
2483 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2485 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2486 pub enum TimgWdtClockConfig {
2487 #[default]
2488 XtalClk,
2490 PllF80m,
2492 RcFastClk,
2494 }
2495 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2496 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2497 pub enum UartFunctionClockSclk {
2498 PllF80m,
2500 RcFast,
2502 #[default]
2503 Xtal,
2505 }
2506 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2510 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2511 pub struct UartFunctionClockConfig {
2512 sclk: UartFunctionClockSclk,
2513 div_num: u32,
2514 }
2515 impl UartFunctionClockConfig {
2516 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
2523 ::core::assert!(
2524 div_num <= 255,
2525 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2526 );
2527 Self { sclk, div_num }
2528 }
2529 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
2530 self.sclk
2531 }
2532 pub(crate) fn div_num(self) -> u32 {
2533 self.div_num as u32
2534 }
2535 }
2536 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2541 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2542 pub struct UartBaudRateGeneratorConfig {
2543 fractional: u32,
2544 integral: u32,
2545 }
2546 impl UartBaudRateGeneratorConfig {
2547 pub const fn new(fractional: u32, integral: u32) -> Self {
2557 ::core::assert!(
2558 fractional <= 15,
2559 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2560 );
2561 ::core::assert!(
2562 integral <= 4095,
2563 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2564 );
2565 Self {
2566 fractional,
2567 integral,
2568 }
2569 }
2570 pub(crate) fn fractional(self) -> u32 {
2571 self.fractional as u32
2572 }
2573 pub(crate) fn integral(self) -> u32 {
2574 self.integral as u32
2575 }
2576 }
2577 pub struct ClockTree {
2579 xtal_clk: Option<XtalClkConfig>,
2580 hp_root_clk: Option<HpRootClkConfig>,
2581 cpu_clk: Option<CpuClkConfig>,
2582 ahb_clk: Option<AhbClkConfig>,
2583 mspi_fast_clk: Option<MspiFastClkConfig>,
2584 soc_root_clk: Option<SocRootClkConfig>,
2585 cpu_hs_div: Option<CpuHsDivConfig>,
2586 cpu_ls_div: Option<CpuLsDivConfig>,
2587 ahb_hs_div: Option<AhbHsDivConfig>,
2588 ahb_ls_div: Option<AhbLsDivConfig>,
2589 apb_clk: Option<ApbClkConfig>,
2590 mspi_fast_hs_clk: Option<MspiFastHsClkConfig>,
2591 mspi_fast_ls_clk: Option<MspiFastLsClkConfig>,
2592 iomux_function_clock: Option<IomuxFunctionClockConfig>,
2593 ledc_sclk: Option<LedcSclkConfig>,
2594 lp_fast_clk: Option<LpFastClkConfig>,
2595 lp_slow_clk: Option<LpSlowClkConfig>,
2596 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2597 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
2598 i2s_tx_clk: [Option<I2sClkConfig>; 1],
2599 i2s_rx_clk: [Option<I2sClkConfig>; 1],
2600 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
2601 mcpwm_function_clock: [Option<McpwmFunctionClockConfig>; 1],
2602 parl_io_rx_clock: [Option<ParlIoClkConfig>; 1],
2603 parl_io_tx_clock: [Option<ParlIoClkConfig>; 1],
2604 rmt_sclk: [Option<RmtSclkConfig>; 1],
2605 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
2606 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2607 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2608 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2609 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2610 pll_clk_refcount: u32,
2611 rc_fast_clk_refcount: u32,
2612 #[cfg(use_xtal32k)]
2613 xtal32k_clk_refcount: u32,
2614 hp_root_clk_refcount: u32,
2615 mspi_fast_clk_refcount: u32,
2616 apb_clk_refcount: u32,
2617 pll_f48m_refcount: u32,
2618 pll_f80m_refcount: u32,
2619 pll_f160m_refcount: u32,
2620 pll_f240m_refcount: u32,
2621 ledc_sclk_refcount: u32,
2622 lp_fast_clk_refcount: u32,
2623 timg_calibration_clock_refcount: u32,
2624 sdm_function_clock_refcount: [u32; 1],
2625 i2c_function_clock_refcount: [u32; 1],
2626 i2s_tx_clk_refcount: [u32; 1],
2627 i2s_rx_clk_refcount: [u32; 1],
2628 i2s_mclk_out_refcount: [u32; 1],
2629 mcpwm_function_clock_refcount: [u32; 1],
2630 parl_io_rx_clock_refcount: [u32; 1],
2631 parl_io_tx_clock_refcount: [u32; 1],
2632 rmt_sclk_refcount: [u32; 1],
2633 spi_function_clock_refcount: [u32; 1],
2634 timg_function_clock_refcount: [u32; 2],
2635 timg_wdt_clock_refcount: [u32; 2],
2636 uart_function_clock_refcount: [u32; 2],
2637 uart_baud_rate_generator_refcount: [u32; 2],
2638 }
2639 impl ClockTree {
2640 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2642 CLOCK_TREE.with(f)
2643 }
2644 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2646 self.xtal_clk
2647 }
2648 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
2650 self.hp_root_clk
2651 }
2652 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2654 self.cpu_clk
2655 }
2656 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
2658 self.ahb_clk
2659 }
2660 pub fn mspi_fast_clk(&self) -> Option<MspiFastClkConfig> {
2662 self.mspi_fast_clk
2663 }
2664 pub fn soc_root_clk(&self) -> Option<SocRootClkConfig> {
2666 self.soc_root_clk
2667 }
2668 pub fn cpu_hs_div(&self) -> Option<CpuHsDivConfig> {
2670 self.cpu_hs_div
2671 }
2672 pub fn cpu_ls_div(&self) -> Option<CpuLsDivConfig> {
2674 self.cpu_ls_div
2675 }
2676 pub fn ahb_hs_div(&self) -> Option<AhbHsDivConfig> {
2678 self.ahb_hs_div
2679 }
2680 pub fn ahb_ls_div(&self) -> Option<AhbLsDivConfig> {
2682 self.ahb_ls_div
2683 }
2684 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2686 self.apb_clk
2687 }
2688 pub fn mspi_fast_hs_clk(&self) -> Option<MspiFastHsClkConfig> {
2690 self.mspi_fast_hs_clk
2691 }
2692 pub fn mspi_fast_ls_clk(&self) -> Option<MspiFastLsClkConfig> {
2694 self.mspi_fast_ls_clk
2695 }
2696 pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2698 self.iomux_function_clock
2699 }
2700 pub fn ledc_sclk(&self) -> Option<LedcSclkConfig> {
2702 self.ledc_sclk
2703 }
2704 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2706 self.lp_fast_clk
2707 }
2708 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2710 self.lp_slow_clk
2711 }
2712 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2714 self.timg_calibration_clock
2715 }
2716 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2718 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2719 }
2720 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
2722 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
2723 }
2724 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
2726 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
2727 }
2728 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
2730 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
2731 }
2732 pub fn mcpwm0_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
2734 self.mcpwm_function_clock[McpwmInstance::Mcpwm0 as usize]
2735 }
2736 pub fn parl_io_rx_clock(&self) -> Option<ParlIoClkConfig> {
2738 self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
2739 }
2740 pub fn parl_io_tx_clock(&self) -> Option<ParlIoClkConfig> {
2742 self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
2743 }
2744 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2746 self.rmt_sclk[RmtInstance::Rmt as usize]
2747 }
2748 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2750 self.spi_function_clock[SpiInstance::Spi2 as usize]
2751 }
2752 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2754 self.timg_function_clock[TimgInstance::Timg0 as usize]
2755 }
2756 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2758 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2759 }
2760 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2762 self.timg_function_clock[TimgInstance::Timg1 as usize]
2763 }
2764 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2766 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2767 }
2768 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2770 self.uart_function_clock[UartInstance::Uart0 as usize]
2771 }
2772 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2774 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2775 }
2776 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2778 self.uart_function_clock[UartInstance::Uart1 as usize]
2779 }
2780 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2782 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2783 }
2784 }
2785 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2786 ::esp_sync::NonReentrantMutex::new(ClockTree {
2787 xtal_clk: None,
2788 hp_root_clk: None,
2789 cpu_clk: None,
2790 ahb_clk: None,
2791 mspi_fast_clk: None,
2792 soc_root_clk: None,
2793 cpu_hs_div: None,
2794 cpu_ls_div: None,
2795 ahb_hs_div: None,
2796 ahb_ls_div: None,
2797 apb_clk: None,
2798 mspi_fast_hs_clk: None,
2799 mspi_fast_ls_clk: None,
2800 iomux_function_clock: None,
2801 ledc_sclk: None,
2802 lp_fast_clk: None,
2803 lp_slow_clk: None,
2804 timg_calibration_clock: None,
2805 i2c_function_clock: [None; 1],
2806 i2s_tx_clk: [None; 1],
2807 i2s_rx_clk: [None; 1],
2808 i2s_mclk_out: [None; 1],
2809 mcpwm_function_clock: [None; 1],
2810 parl_io_rx_clock: [None; 1],
2811 parl_io_tx_clock: [None; 1],
2812 rmt_sclk: [None; 1],
2813 spi_function_clock: [None; 1],
2814 timg_function_clock: [None; 2],
2815 timg_wdt_clock: [None; 2],
2816 uart_function_clock: [None; 2],
2817 uart_baud_rate_generator: [None; 2],
2818 pll_clk_refcount: 0,
2819 rc_fast_clk_refcount: 0,
2820 #[cfg(use_xtal32k)]
2821 xtal32k_clk_refcount: 0,
2822 hp_root_clk_refcount: 0,
2823 mspi_fast_clk_refcount: 0,
2824 apb_clk_refcount: 0,
2825 pll_f48m_refcount: 0,
2826 pll_f80m_refcount: 0,
2827 pll_f160m_refcount: 0,
2828 pll_f240m_refcount: 0,
2829 ledc_sclk_refcount: 0,
2830 lp_fast_clk_refcount: 0,
2831 timg_calibration_clock_refcount: 0,
2832 sdm_function_clock_refcount: [0; 1],
2833 i2c_function_clock_refcount: [0; 1],
2834 i2s_tx_clk_refcount: [0; 1],
2835 i2s_rx_clk_refcount: [0; 1],
2836 i2s_mclk_out_refcount: [0; 1],
2837 mcpwm_function_clock_refcount: [0; 1],
2838 parl_io_rx_clock_refcount: [0; 1],
2839 parl_io_tx_clock_refcount: [0; 1],
2840 rmt_sclk_refcount: [0; 1],
2841 spi_function_clock_refcount: [0; 1],
2842 timg_function_clock_refcount: [0; 2],
2843 timg_wdt_clock_refcount: [0; 2],
2844 uart_function_clock_refcount: [0; 2],
2845 uart_baud_rate_generator_refcount: [0; 2],
2846 });
2847 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2848 ::core::sync::atomic::AtomicU32::new(0);
2849 static SOC_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2850 ::core::sync::atomic::AtomicU32::new(0);
2851 static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2852 ::core::sync::atomic::AtomicU32::new(0);
2853 static LEDC_SCLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2854 ::core::sync::atomic::AtomicU32::new(0);
2855 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2856 ::core::sync::atomic::AtomicU32::new(0);
2857 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2858 ::core::sync::atomic::AtomicU32::new(0);
2859 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2860 ::core::sync::atomic::AtomicU32::new(0);
2861 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2862 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2863 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2864 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2865 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2866 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2867 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2868 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2869 static MCPWM_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2870 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2871 static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2872 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2873 static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2874 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2875 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2876 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2877 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2878 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2879 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2880 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2881 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2882 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2883 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2884 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2885 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2886 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2887 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2888 ::core::sync::atomic::AtomicU32::new(0);
2889 static CPU_HS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2890 ::core::sync::atomic::AtomicU32::new(0);
2891 static CPU_LS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2892 ::core::sync::atomic::AtomicU32::new(0);
2893 static AHB_HS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2894 ::core::sync::atomic::AtomicU32::new(0);
2895 static AHB_LS_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2896 ::core::sync::atomic::AtomicU32::new(0);
2897 static MSPI_FAST_HS_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2898 ::core::sync::atomic::AtomicU32::new(0);
2899 static MSPI_FAST_LS_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2900 ::core::sync::atomic::AtomicU32::new(0);
2901 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2902 ::core::sync::atomic::AtomicU32::new(0);
2903 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2904 ::core::sync::atomic::AtomicU32::new(0);
2905 static MSPI_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2906 ::core::sync::atomic::AtomicU32::new(0);
2907 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2908 ::core::sync::atomic::AtomicU32::new(0);
2909 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2910 let old_config = clocks.xtal_clk.replace(config);
2911 refresh_xtal_clk_downstream(clocks);
2912 configure_xtal_clk_impl(clocks, old_config, config);
2913 }
2914 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2915 clocks.xtal_clk
2916 }
2917 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2918 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2919 #[allow(unused_variables)]
2920 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
2921 config.value()
2922 }
2923 pub fn xtal_clk_frequency() -> u32 {
2924 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2925 }
2926 pub fn request_pll_clk(clocks: &mut ClockTree) {
2927 trace!("Requesting PLL_CLK");
2928 if increment_reference_count(&mut clocks.pll_clk_refcount) {
2929 trace!("Enabling PLL_CLK");
2930 request_xtal_clk(clocks);
2931 enable_pll_clk_impl(clocks, true);
2932 }
2933 }
2934 pub fn release_pll_clk(clocks: &mut ClockTree) {
2935 trace!("Releasing PLL_CLK");
2936 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2937 trace!("Disabling PLL_CLK");
2938 enable_pll_clk_impl(clocks, false);
2939 release_xtal_clk(clocks);
2940 }
2941 }
2942 pub fn pll_clk_frequency() -> u32 {
2943 480000000
2944 }
2945 pub fn pll_clk_source_frequency() -> u32 {
2946 xtal_clk_frequency()
2947 }
2948 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2949 trace!("Requesting RC_FAST_CLK");
2950 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2951 trace!("Enabling RC_FAST_CLK");
2952 enable_rc_fast_clk_impl(clocks, true);
2953 }
2954 }
2955 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2956 trace!("Releasing RC_FAST_CLK");
2957 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2958 trace!("Disabling RC_FAST_CLK");
2959 enable_rc_fast_clk_impl(clocks, false);
2960 }
2961 }
2962 pub fn rc_fast_clk_frequency() -> u32 {
2963 17500000
2964 }
2965 #[cfg(use_xtal32k)]
2966 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2967 trace!("Requesting XTAL32K_CLK");
2968 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2969 trace!("Enabling XTAL32K_CLK");
2970 enable_xtal32k_clk_impl(clocks, true);
2971 }
2972 }
2973 #[cfg(use_xtal32k)]
2974 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2975 trace!("Releasing XTAL32K_CLK");
2976 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2977 trace!("Disabling XTAL32K_CLK");
2978 enable_xtal32k_clk_impl(clocks, false);
2979 }
2980 }
2981 #[cfg(use_xtal32k)]
2982 pub fn xtal32k_clk_frequency() -> u32 {
2983 32768
2984 }
2985 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2986 trace!("Requesting OSC_SLOW_CLK");
2987 trace!("Enabling OSC_SLOW_CLK");
2988 enable_osc_slow_clk_impl(clocks, true);
2989 }
2990 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2991 trace!("Releasing OSC_SLOW_CLK");
2992 trace!("Disabling OSC_SLOW_CLK");
2993 enable_osc_slow_clk_impl(clocks, false);
2994 }
2995 pub fn osc_slow_clk_frequency() -> u32 {
2996 32768
2997 }
2998 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2999 trace!("Requesting RC_SLOW_CLK");
3000 trace!("Enabling RC_SLOW_CLK");
3001 enable_rc_slow_clk_impl(clocks, true);
3002 }
3003 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
3004 trace!("Releasing RC_SLOW_CLK");
3005 trace!("Disabling RC_SLOW_CLK");
3006 enable_rc_slow_clk_impl(clocks, false);
3007 }
3008 pub fn rc_slow_clk_frequency() -> u32 {
3009 136000
3010 }
3011 pub fn configure_hp_root_clk(clocks: &mut ClockTree, config: HpRootClkConfig) {
3012 let old_config = clocks.hp_root_clk.replace(config);
3013 refresh_hp_root_clk_downstream(clocks);
3014 configure_hp_root_clk_impl(clocks, old_config, config);
3015 }
3016 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
3017 clocks.hp_root_clk
3018 }
3019 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
3020 trace!("Requesting HP_ROOT_CLK");
3021 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
3022 trace!("Enabling HP_ROOT_CLK");
3023 request_soc_root_clk(clocks);
3024 enable_hp_root_clk_impl(clocks, true);
3025 }
3026 }
3027 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
3028 trace!("Releasing HP_ROOT_CLK");
3029 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
3030 trace!("Disabling HP_ROOT_CLK");
3031 enable_hp_root_clk_impl(clocks, false);
3032 release_soc_root_clk(clocks);
3033 }
3034 }
3035 #[allow(unused_variables)]
3036 pub fn hp_root_clk_config_frequency(
3037 clocks: &mut ClockTree,
3038 config: HpRootClkConfig,
3039 ) -> u32 {
3040 (soc_root_clk_frequency() / config.divisor())
3041 }
3042 pub fn hp_root_clk_frequency() -> u32 {
3043 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3044 }
3045 pub fn hp_root_clk_source_frequency() -> u32 {
3046 soc_root_clk_frequency()
3047 }
3048 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
3049 let old_selector = clocks.cpu_clk.replace(new_selector);
3050 refresh_cpu_clk_downstream(clocks);
3051 match new_selector {
3052 CpuClkConfig::Hs => request_cpu_hs_div(clocks),
3053 CpuClkConfig::Ls => request_cpu_ls_div(clocks),
3054 }
3055 configure_cpu_clk_impl(clocks, old_selector, new_selector);
3056 if let Some(old_selector) = old_selector {
3057 match old_selector {
3058 CpuClkConfig::Hs => release_cpu_hs_div(clocks),
3059 CpuClkConfig::Ls => release_cpu_ls_div(clocks),
3060 }
3061 }
3062 }
3063 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
3064 clocks.cpu_clk
3065 }
3066 fn request_cpu_clk(_clocks: &mut ClockTree) {}
3067 fn release_cpu_clk(_clocks: &mut ClockTree) {}
3068 #[allow(unused_variables)]
3069 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
3070 match config {
3071 CpuClkConfig::Hs => cpu_hs_div_frequency(),
3072 CpuClkConfig::Ls => cpu_ls_div_frequency(),
3073 }
3074 }
3075 pub fn cpu_clk_frequency() -> u32 {
3076 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3077 }
3078 pub fn cpu_clk_source_frequency(source: CpuClkConfig) -> u32 {
3079 match source {
3080 CpuClkConfig::Hs => cpu_hs_div_frequency(),
3081 CpuClkConfig::Ls => cpu_ls_div_frequency(),
3082 }
3083 }
3084 pub fn configure_ahb_clk(clocks: &mut ClockTree, new_selector: AhbClkConfig) {
3085 let old_selector = clocks.ahb_clk.replace(new_selector);
3086 refresh_ahb_clk_downstream(clocks);
3087 match new_selector {
3088 AhbClkConfig::Hs => request_ahb_hs_div(clocks),
3089 AhbClkConfig::Ls => request_ahb_ls_div(clocks),
3090 }
3091 configure_ahb_clk_impl(clocks, old_selector, new_selector);
3092 if let Some(old_selector) = old_selector {
3093 match old_selector {
3094 AhbClkConfig::Hs => release_ahb_hs_div(clocks),
3095 AhbClkConfig::Ls => release_ahb_ls_div(clocks),
3096 }
3097 }
3098 }
3099 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
3100 clocks.ahb_clk
3101 }
3102 fn request_ahb_clk(_clocks: &mut ClockTree) {}
3103 fn release_ahb_clk(_clocks: &mut ClockTree) {}
3104 #[allow(unused_variables)]
3105 pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
3106 match config {
3107 AhbClkConfig::Hs => ahb_hs_div_frequency(),
3108 AhbClkConfig::Ls => ahb_ls_div_frequency(),
3109 }
3110 }
3111 pub fn ahb_clk_frequency() -> u32 {
3112 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3113 }
3114 pub fn ahb_clk_source_frequency(source: AhbClkConfig) -> u32 {
3115 match source {
3116 AhbClkConfig::Hs => ahb_hs_div_frequency(),
3117 AhbClkConfig::Ls => ahb_ls_div_frequency(),
3118 }
3119 }
3120 pub fn configure_mspi_fast_clk(clocks: &mut ClockTree, new_selector: MspiFastClkConfig) {
3121 let old_selector = clocks.mspi_fast_clk.replace(new_selector);
3122 refresh_mspi_fast_clk_downstream(clocks);
3123 if clocks.mspi_fast_clk_refcount > 0 {
3124 match new_selector {
3125 MspiFastClkConfig::Hs => request_mspi_fast_hs_clk(clocks),
3126 MspiFastClkConfig::Ls => request_mspi_fast_ls_clk(clocks),
3127 }
3128 configure_mspi_fast_clk_impl(clocks, old_selector, new_selector);
3129 if let Some(old_selector) = old_selector {
3130 match old_selector {
3131 MspiFastClkConfig::Hs => release_mspi_fast_hs_clk(clocks),
3132 MspiFastClkConfig::Ls => release_mspi_fast_ls_clk(clocks),
3133 }
3134 }
3135 } else {
3136 configure_mspi_fast_clk_impl(clocks, old_selector, new_selector);
3137 }
3138 }
3139 pub fn mspi_fast_clk_config(clocks: &mut ClockTree) -> Option<MspiFastClkConfig> {
3140 clocks.mspi_fast_clk
3141 }
3142 pub fn request_mspi_fast_clk(clocks: &mut ClockTree) {
3143 trace!("Requesting MSPI_FAST_CLK");
3144 if increment_reference_count(&mut clocks.mspi_fast_clk_refcount) {
3145 trace!("Enabling MSPI_FAST_CLK");
3146 match unwrap!(clocks.mspi_fast_clk) {
3147 MspiFastClkConfig::Hs => request_mspi_fast_hs_clk(clocks),
3148 MspiFastClkConfig::Ls => request_mspi_fast_ls_clk(clocks),
3149 }
3150 enable_mspi_fast_clk_impl(clocks, true);
3151 }
3152 }
3153 pub fn release_mspi_fast_clk(clocks: &mut ClockTree) {
3154 trace!("Releasing MSPI_FAST_CLK");
3155 if decrement_reference_count(&mut clocks.mspi_fast_clk_refcount) {
3156 trace!("Disabling MSPI_FAST_CLK");
3157 enable_mspi_fast_clk_impl(clocks, false);
3158 match unwrap!(clocks.mspi_fast_clk) {
3159 MspiFastClkConfig::Hs => release_mspi_fast_hs_clk(clocks),
3160 MspiFastClkConfig::Ls => release_mspi_fast_ls_clk(clocks),
3161 }
3162 }
3163 }
3164 #[allow(unused_variables)]
3165 pub fn mspi_fast_clk_config_frequency(
3166 clocks: &mut ClockTree,
3167 config: MspiFastClkConfig,
3168 ) -> u32 {
3169 match config {
3170 MspiFastClkConfig::Hs => mspi_fast_hs_clk_frequency(),
3171 MspiFastClkConfig::Ls => mspi_fast_ls_clk_frequency(),
3172 }
3173 }
3174 pub fn mspi_fast_clk_frequency() -> u32 {
3175 MSPI_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3176 }
3177 pub fn mspi_fast_clk_source_frequency(source: MspiFastClkConfig) -> u32 {
3178 match source {
3179 MspiFastClkConfig::Hs => mspi_fast_hs_clk_frequency(),
3180 MspiFastClkConfig::Ls => mspi_fast_ls_clk_frequency(),
3181 }
3182 }
3183 pub fn configure_soc_root_clk(clocks: &mut ClockTree, new_selector: SocRootClkConfig) {
3184 let old_selector = clocks.soc_root_clk.replace(new_selector);
3185 refresh_soc_root_clk_downstream(clocks);
3186 match new_selector {
3187 SocRootClkConfig::Xtal => {
3188 let config_value = HpRootClkConfig::new(HpRootClkDivisor::new(1));
3189 configure_hp_root_clk(clocks, config_value);
3190 configure_cpu_clk(clocks, CpuClkConfig::Ls);
3191 configure_ahb_clk(clocks, AhbClkConfig::Ls);
3192 configure_mspi_fast_clk(clocks, MspiFastClkConfig::Ls);
3193 }
3194 SocRootClkConfig::RcFast => {
3195 let config_value = HpRootClkConfig::new(HpRootClkDivisor::new(1));
3196 configure_hp_root_clk(clocks, config_value);
3197 configure_cpu_clk(clocks, CpuClkConfig::Ls);
3198 configure_ahb_clk(clocks, AhbClkConfig::Ls);
3199 configure_mspi_fast_clk(clocks, MspiFastClkConfig::Ls);
3200 }
3201 SocRootClkConfig::Pll => {
3202 let config_value = HpRootClkConfig::new(HpRootClkDivisor::new(3));
3203 configure_hp_root_clk(clocks, config_value);
3204 configure_cpu_clk(clocks, CpuClkConfig::Hs);
3205 configure_ahb_clk(clocks, AhbClkConfig::Hs);
3206 configure_mspi_fast_clk(clocks, MspiFastClkConfig::Hs);
3207 }
3208 }
3209 match new_selector {
3210 SocRootClkConfig::Xtal => request_xtal_clk(clocks),
3211 SocRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3212 SocRootClkConfig::Pll => request_pll_clk(clocks),
3213 }
3214 configure_soc_root_clk_impl(clocks, old_selector, new_selector);
3215 if let Some(old_selector) = old_selector {
3216 match old_selector {
3217 SocRootClkConfig::Xtal => release_xtal_clk(clocks),
3218 SocRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3219 SocRootClkConfig::Pll => release_pll_clk(clocks),
3220 }
3221 }
3222 }
3223 pub fn soc_root_clk_config(clocks: &mut ClockTree) -> Option<SocRootClkConfig> {
3224 clocks.soc_root_clk
3225 }
3226 pub fn request_soc_root_clk(clocks: &mut ClockTree) {
3227 trace!("Requesting SOC_ROOT_CLK");
3228 trace!("Enabling SOC_ROOT_CLK");
3229 match unwrap!(clocks.soc_root_clk) {
3230 SocRootClkConfig::Xtal => request_xtal_clk(clocks),
3231 SocRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3232 SocRootClkConfig::Pll => request_pll_clk(clocks),
3233 }
3234 enable_soc_root_clk_impl(clocks, true);
3235 }
3236 pub fn release_soc_root_clk(clocks: &mut ClockTree) {
3237 trace!("Releasing SOC_ROOT_CLK");
3238 trace!("Disabling SOC_ROOT_CLK");
3239 enable_soc_root_clk_impl(clocks, false);
3240 match unwrap!(clocks.soc_root_clk) {
3241 SocRootClkConfig::Xtal => release_xtal_clk(clocks),
3242 SocRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3243 SocRootClkConfig::Pll => release_pll_clk(clocks),
3244 }
3245 }
3246 #[allow(unused_variables)]
3247 pub fn soc_root_clk_config_frequency(
3248 clocks: &mut ClockTree,
3249 config: SocRootClkConfig,
3250 ) -> u32 {
3251 match config {
3252 SocRootClkConfig::Xtal => xtal_clk_frequency(),
3253 SocRootClkConfig::RcFast => rc_fast_clk_frequency(),
3254 SocRootClkConfig::Pll => pll_clk_frequency(),
3255 }
3256 }
3257 pub fn soc_root_clk_frequency() -> u32 {
3258 SOC_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3259 }
3260 pub fn configure_cpu_hs_div(clocks: &mut ClockTree, config: CpuHsDivConfig) {
3261 let old_config = clocks.cpu_hs_div.replace(config);
3262 refresh_cpu_hs_div_downstream(clocks);
3263 configure_cpu_hs_div_impl(clocks, old_config, config);
3264 }
3265 pub fn cpu_hs_div_config(clocks: &mut ClockTree) -> Option<CpuHsDivConfig> {
3266 clocks.cpu_hs_div
3267 }
3268 pub fn request_cpu_hs_div(clocks: &mut ClockTree) {
3269 trace!("Requesting CPU_HS_DIV");
3270 trace!("Enabling CPU_HS_DIV");
3271 request_hp_root_clk(clocks);
3272 enable_cpu_hs_div_impl(clocks, true);
3273 }
3274 pub fn release_cpu_hs_div(clocks: &mut ClockTree) {
3275 trace!("Releasing CPU_HS_DIV");
3276 trace!("Disabling CPU_HS_DIV");
3277 enable_cpu_hs_div_impl(clocks, false);
3278 release_hp_root_clk(clocks);
3279 }
3280 #[allow(unused_variables)]
3281 pub fn cpu_hs_div_config_frequency(clocks: &mut ClockTree, config: CpuHsDivConfig) -> u32 {
3282 (hp_root_clk_frequency() / (config.divisor() + 1))
3283 }
3284 pub fn cpu_hs_div_frequency() -> u32 {
3285 CPU_HS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3286 }
3287 pub fn cpu_hs_div_source_frequency() -> u32 {
3288 hp_root_clk_frequency()
3289 }
3290 pub fn configure_cpu_ls_div(clocks: &mut ClockTree, config: CpuLsDivConfig) {
3291 let old_config = clocks.cpu_ls_div.replace(config);
3292 refresh_cpu_ls_div_downstream(clocks);
3293 configure_cpu_ls_div_impl(clocks, old_config, config);
3294 }
3295 pub fn cpu_ls_div_config(clocks: &mut ClockTree) -> Option<CpuLsDivConfig> {
3296 clocks.cpu_ls_div
3297 }
3298 pub fn request_cpu_ls_div(clocks: &mut ClockTree) {
3299 trace!("Requesting CPU_LS_DIV");
3300 trace!("Enabling CPU_LS_DIV");
3301 request_hp_root_clk(clocks);
3302 enable_cpu_ls_div_impl(clocks, true);
3303 }
3304 pub fn release_cpu_ls_div(clocks: &mut ClockTree) {
3305 trace!("Releasing CPU_LS_DIV");
3306 trace!("Disabling CPU_LS_DIV");
3307 enable_cpu_ls_div_impl(clocks, false);
3308 release_hp_root_clk(clocks);
3309 }
3310 #[allow(unused_variables)]
3311 pub fn cpu_ls_div_config_frequency(clocks: &mut ClockTree, config: CpuLsDivConfig) -> u32 {
3312 (hp_root_clk_frequency() / (config.divisor() + 1))
3313 }
3314 pub fn cpu_ls_div_frequency() -> u32 {
3315 CPU_LS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3316 }
3317 pub fn cpu_ls_div_source_frequency() -> u32 {
3318 hp_root_clk_frequency()
3319 }
3320 pub fn configure_ahb_hs_div(clocks: &mut ClockTree, config: AhbHsDivConfig) {
3321 let old_config = clocks.ahb_hs_div.replace(config);
3322 refresh_ahb_hs_div_downstream(clocks);
3323 configure_ahb_hs_div_impl(clocks, old_config, config);
3324 }
3325 pub fn ahb_hs_div_config(clocks: &mut ClockTree) -> Option<AhbHsDivConfig> {
3326 clocks.ahb_hs_div
3327 }
3328 pub fn request_ahb_hs_div(clocks: &mut ClockTree) {
3329 trace!("Requesting AHB_HS_DIV");
3330 trace!("Enabling AHB_HS_DIV");
3331 request_hp_root_clk(clocks);
3332 enable_ahb_hs_div_impl(clocks, true);
3333 }
3334 pub fn release_ahb_hs_div(clocks: &mut ClockTree) {
3335 trace!("Releasing AHB_HS_DIV");
3336 trace!("Disabling AHB_HS_DIV");
3337 enable_ahb_hs_div_impl(clocks, false);
3338 release_hp_root_clk(clocks);
3339 }
3340 #[allow(unused_variables)]
3341 pub fn ahb_hs_div_config_frequency(clocks: &mut ClockTree, config: AhbHsDivConfig) -> u32 {
3342 (hp_root_clk_frequency() / (config.divisor() + 1))
3343 }
3344 pub fn ahb_hs_div_frequency() -> u32 {
3345 AHB_HS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3346 }
3347 pub fn ahb_hs_div_source_frequency() -> u32 {
3348 hp_root_clk_frequency()
3349 }
3350 pub fn configure_ahb_ls_div(clocks: &mut ClockTree, config: AhbLsDivConfig) {
3351 let old_config = clocks.ahb_ls_div.replace(config);
3352 refresh_ahb_ls_div_downstream(clocks);
3353 configure_ahb_ls_div_impl(clocks, old_config, config);
3354 }
3355 pub fn ahb_ls_div_config(clocks: &mut ClockTree) -> Option<AhbLsDivConfig> {
3356 clocks.ahb_ls_div
3357 }
3358 pub fn request_ahb_ls_div(clocks: &mut ClockTree) {
3359 trace!("Requesting AHB_LS_DIV");
3360 trace!("Enabling AHB_LS_DIV");
3361 request_hp_root_clk(clocks);
3362 enable_ahb_ls_div_impl(clocks, true);
3363 }
3364 pub fn release_ahb_ls_div(clocks: &mut ClockTree) {
3365 trace!("Releasing AHB_LS_DIV");
3366 trace!("Disabling AHB_LS_DIV");
3367 enable_ahb_ls_div_impl(clocks, false);
3368 release_hp_root_clk(clocks);
3369 }
3370 #[allow(unused_variables)]
3371 pub fn ahb_ls_div_config_frequency(clocks: &mut ClockTree, config: AhbLsDivConfig) -> u32 {
3372 (hp_root_clk_frequency() / (config.divisor() + 1))
3373 }
3374 pub fn ahb_ls_div_frequency() -> u32 {
3375 AHB_LS_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3376 }
3377 pub fn ahb_ls_div_source_frequency() -> u32 {
3378 hp_root_clk_frequency()
3379 }
3380 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
3381 let old_config = clocks.apb_clk.replace(config);
3382 refresh_apb_clk_downstream(clocks);
3383 configure_apb_clk_impl(clocks, old_config, config);
3384 }
3385 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
3386 clocks.apb_clk
3387 }
3388 pub fn request_apb_clk(clocks: &mut ClockTree) {
3389 trace!("Requesting APB_CLK");
3390 if increment_reference_count(&mut clocks.apb_clk_refcount) {
3391 trace!("Enabling APB_CLK");
3392 request_ahb_clk(clocks);
3393 enable_apb_clk_impl(clocks, true);
3394 }
3395 }
3396 pub fn release_apb_clk(clocks: &mut ClockTree) {
3397 trace!("Releasing APB_CLK");
3398 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
3399 trace!("Disabling APB_CLK");
3400 enable_apb_clk_impl(clocks, false);
3401 release_ahb_clk(clocks);
3402 }
3403 }
3404 #[allow(unused_variables)]
3405 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
3406 (ahb_clk_frequency() / (config.divisor() + 1))
3407 }
3408 pub fn apb_clk_frequency() -> u32 {
3409 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3410 }
3411 pub fn apb_clk_source_frequency() -> u32 {
3412 ahb_clk_frequency()
3413 }
3414 pub fn configure_mspi_fast_hs_clk(clocks: &mut ClockTree, config: MspiFastHsClkConfig) {
3415 let old_config = clocks.mspi_fast_hs_clk.replace(config);
3416 refresh_mspi_fast_hs_clk_downstream(clocks);
3417 configure_mspi_fast_hs_clk_impl(clocks, old_config, config);
3418 }
3419 pub fn mspi_fast_hs_clk_config(clocks: &mut ClockTree) -> Option<MspiFastHsClkConfig> {
3420 clocks.mspi_fast_hs_clk
3421 }
3422 pub fn request_mspi_fast_hs_clk(clocks: &mut ClockTree) {
3423 trace!("Requesting MSPI_FAST_HS_CLK");
3424 trace!("Enabling MSPI_FAST_HS_CLK");
3425 request_hp_root_clk(clocks);
3426 enable_mspi_fast_hs_clk_impl(clocks, true);
3427 }
3428 pub fn release_mspi_fast_hs_clk(clocks: &mut ClockTree) {
3429 trace!("Releasing MSPI_FAST_HS_CLK");
3430 trace!("Disabling MSPI_FAST_HS_CLK");
3431 enable_mspi_fast_hs_clk_impl(clocks, false);
3432 release_hp_root_clk(clocks);
3433 }
3434 #[allow(unused_variables)]
3435 pub fn mspi_fast_hs_clk_config_frequency(
3436 clocks: &mut ClockTree,
3437 config: MspiFastHsClkConfig,
3438 ) -> u32 {
3439 (hp_root_clk_frequency() / (config.divisor() + 1))
3440 }
3441 pub fn mspi_fast_hs_clk_frequency() -> u32 {
3442 MSPI_FAST_HS_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3443 }
3444 pub fn mspi_fast_hs_clk_source_frequency() -> u32 {
3445 hp_root_clk_frequency()
3446 }
3447 pub fn configure_mspi_fast_ls_clk(clocks: &mut ClockTree, config: MspiFastLsClkConfig) {
3448 let old_config = clocks.mspi_fast_ls_clk.replace(config);
3449 refresh_mspi_fast_ls_clk_downstream(clocks);
3450 configure_mspi_fast_ls_clk_impl(clocks, old_config, config);
3451 }
3452 pub fn mspi_fast_ls_clk_config(clocks: &mut ClockTree) -> Option<MspiFastLsClkConfig> {
3453 clocks.mspi_fast_ls_clk
3454 }
3455 pub fn request_mspi_fast_ls_clk(clocks: &mut ClockTree) {
3456 trace!("Requesting MSPI_FAST_LS_CLK");
3457 trace!("Enabling MSPI_FAST_LS_CLK");
3458 request_hp_root_clk(clocks);
3459 enable_mspi_fast_ls_clk_impl(clocks, true);
3460 }
3461 pub fn release_mspi_fast_ls_clk(clocks: &mut ClockTree) {
3462 trace!("Releasing MSPI_FAST_LS_CLK");
3463 trace!("Disabling MSPI_FAST_LS_CLK");
3464 enable_mspi_fast_ls_clk_impl(clocks, false);
3465 release_hp_root_clk(clocks);
3466 }
3467 #[allow(unused_variables)]
3468 pub fn mspi_fast_ls_clk_config_frequency(
3469 clocks: &mut ClockTree,
3470 config: MspiFastLsClkConfig,
3471 ) -> u32 {
3472 (hp_root_clk_frequency() / (config.divisor() + 1))
3473 }
3474 pub fn mspi_fast_ls_clk_frequency() -> u32 {
3475 MSPI_FAST_LS_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3476 }
3477 pub fn mspi_fast_ls_clk_source_frequency() -> u32 {
3478 hp_root_clk_frequency()
3479 }
3480 pub fn request_pll_f48m(clocks: &mut ClockTree) {
3481 trace!("Requesting PLL_F48M");
3482 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
3483 trace!("Enabling PLL_F48M");
3484 request_pll_clk(clocks);
3485 enable_pll_f48m_impl(clocks, true);
3486 }
3487 }
3488 pub fn release_pll_f48m(clocks: &mut ClockTree) {
3489 trace!("Releasing PLL_F48M");
3490 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
3491 trace!("Disabling PLL_F48M");
3492 enable_pll_f48m_impl(clocks, false);
3493 release_pll_clk(clocks);
3494 }
3495 }
3496 pub fn pll_f48m_frequency() -> u32 {
3497 48000000
3498 }
3499 pub fn pll_f48m_source_frequency() -> u32 {
3500 pll_clk_frequency()
3501 }
3502 pub fn request_pll_f80m(clocks: &mut ClockTree) {
3503 trace!("Requesting PLL_F80M");
3504 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
3505 trace!("Enabling PLL_F80M");
3506 request_pll_clk(clocks);
3507 enable_pll_f80m_impl(clocks, true);
3508 }
3509 }
3510 pub fn release_pll_f80m(clocks: &mut ClockTree) {
3511 trace!("Releasing PLL_F80M");
3512 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
3513 trace!("Disabling PLL_F80M");
3514 enable_pll_f80m_impl(clocks, false);
3515 release_pll_clk(clocks);
3516 }
3517 }
3518 pub fn pll_f80m_frequency() -> u32 {
3519 80000000
3520 }
3521 pub fn pll_f80m_source_frequency() -> u32 {
3522 pll_clk_frequency()
3523 }
3524 pub fn request_pll_f160m(clocks: &mut ClockTree) {
3525 trace!("Requesting PLL_F160M");
3526 if increment_reference_count(&mut clocks.pll_f160m_refcount) {
3527 trace!("Enabling PLL_F160M");
3528 request_pll_clk(clocks);
3529 enable_pll_f160m_impl(clocks, true);
3530 }
3531 }
3532 pub fn release_pll_f160m(clocks: &mut ClockTree) {
3533 trace!("Releasing PLL_F160M");
3534 if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
3535 trace!("Disabling PLL_F160M");
3536 enable_pll_f160m_impl(clocks, false);
3537 release_pll_clk(clocks);
3538 }
3539 }
3540 pub fn pll_f160m_frequency() -> u32 {
3541 160000000
3542 }
3543 pub fn pll_f160m_source_frequency() -> u32 {
3544 pll_clk_frequency()
3545 }
3546 pub fn request_pll_f240m(clocks: &mut ClockTree) {
3547 trace!("Requesting PLL_F240M");
3548 if increment_reference_count(&mut clocks.pll_f240m_refcount) {
3549 trace!("Enabling PLL_F240M");
3550 request_pll_clk(clocks);
3551 enable_pll_f240m_impl(clocks, true);
3552 }
3553 }
3554 pub fn release_pll_f240m(clocks: &mut ClockTree) {
3555 trace!("Releasing PLL_F240M");
3556 if decrement_reference_count(&mut clocks.pll_f240m_refcount) {
3557 trace!("Disabling PLL_F240M");
3558 enable_pll_f240m_impl(clocks, false);
3559 release_pll_clk(clocks);
3560 }
3561 }
3562 pub fn pll_f240m_frequency() -> u32 {
3563 240000000
3564 }
3565 pub fn pll_f240m_source_frequency() -> u32 {
3566 pll_clk_frequency()
3567 }
3568 pub fn configure_iomux_function_clock(
3569 clocks: &mut ClockTree,
3570 new_selector: IomuxFunctionClockConfig,
3571 ) {
3572 let old_selector = clocks.iomux_function_clock.replace(new_selector);
3573 refresh_iomux_function_clock_downstream(clocks);
3574 match new_selector {
3575 IomuxFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3576 IomuxFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3577 IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3578 }
3579 configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
3580 if let Some(old_selector) = old_selector {
3581 match old_selector {
3582 IomuxFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3583 IomuxFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3584 IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3585 }
3586 }
3587 }
3588 pub fn iomux_function_clock_config(
3589 clocks: &mut ClockTree,
3590 ) -> Option<IomuxFunctionClockConfig> {
3591 clocks.iomux_function_clock
3592 }
3593 fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
3594 fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
3595 #[allow(unused_variables)]
3596 pub fn iomux_function_clock_config_frequency(
3597 clocks: &mut ClockTree,
3598 config: IomuxFunctionClockConfig,
3599 ) -> u32 {
3600 match config {
3601 IomuxFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3602 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3603 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3604 }
3605 }
3606 pub fn iomux_function_clock_frequency() -> u32 {
3607 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3608 }
3609 pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
3610 match source {
3611 IomuxFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3612 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3613 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3614 }
3615 }
3616 pub fn configure_ledc_sclk(clocks: &mut ClockTree, new_selector: LedcSclkConfig) {
3617 let old_selector = clocks.ledc_sclk.replace(new_selector);
3618 refresh_ledc_sclk_downstream(clocks);
3619 if clocks.ledc_sclk_refcount > 0 {
3620 match new_selector {
3621 LedcSclkConfig::PllF80m => request_pll_f80m(clocks),
3622 LedcSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3623 LedcSclkConfig::XtalClk => request_xtal_clk(clocks),
3624 }
3625 configure_ledc_sclk_impl(clocks, old_selector, new_selector);
3626 if let Some(old_selector) = old_selector {
3627 match old_selector {
3628 LedcSclkConfig::PllF80m => release_pll_f80m(clocks),
3629 LedcSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3630 LedcSclkConfig::XtalClk => release_xtal_clk(clocks),
3631 }
3632 }
3633 } else {
3634 configure_ledc_sclk_impl(clocks, old_selector, new_selector);
3635 }
3636 }
3637 pub fn ledc_sclk_config(clocks: &mut ClockTree) -> Option<LedcSclkConfig> {
3638 clocks.ledc_sclk
3639 }
3640 pub fn request_ledc_sclk(clocks: &mut ClockTree) {
3641 trace!("Requesting LEDC_SCLK");
3642 if increment_reference_count(&mut clocks.ledc_sclk_refcount) {
3643 trace!("Enabling LEDC_SCLK");
3644 match unwrap!(clocks.ledc_sclk) {
3645 LedcSclkConfig::PllF80m => request_pll_f80m(clocks),
3646 LedcSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3647 LedcSclkConfig::XtalClk => request_xtal_clk(clocks),
3648 }
3649 enable_ledc_sclk_impl(clocks, true);
3650 }
3651 }
3652 pub fn release_ledc_sclk(clocks: &mut ClockTree) {
3653 trace!("Releasing LEDC_SCLK");
3654 if decrement_reference_count(&mut clocks.ledc_sclk_refcount) {
3655 trace!("Disabling LEDC_SCLK");
3656 enable_ledc_sclk_impl(clocks, false);
3657 match unwrap!(clocks.ledc_sclk) {
3658 LedcSclkConfig::PllF80m => release_pll_f80m(clocks),
3659 LedcSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3660 LedcSclkConfig::XtalClk => release_xtal_clk(clocks),
3661 }
3662 }
3663 }
3664 #[allow(unused_variables)]
3665 pub fn ledc_sclk_config_frequency(clocks: &mut ClockTree, config: LedcSclkConfig) -> u32 {
3666 match config {
3667 LedcSclkConfig::PllF80m => pll_f80m_frequency(),
3668 LedcSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3669 LedcSclkConfig::XtalClk => xtal_clk_frequency(),
3670 }
3671 }
3672 pub fn ledc_sclk_frequency() -> u32 {
3673 LEDC_SCLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3674 }
3675 pub fn ledc_sclk_source_frequency(source: LedcSclkConfig) -> u32 {
3676 match source {
3677 LedcSclkConfig::PllF80m => pll_f80m_frequency(),
3678 LedcSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3679 LedcSclkConfig::XtalClk => xtal_clk_frequency(),
3680 }
3681 }
3682 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
3683 trace!("Requesting XTAL_D2_CLK");
3684 trace!("Enabling XTAL_D2_CLK");
3685 request_xtal_clk(clocks);
3686 enable_xtal_d2_clk_impl(clocks, true);
3687 }
3688 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
3689 trace!("Releasing XTAL_D2_CLK");
3690 trace!("Disabling XTAL_D2_CLK");
3691 enable_xtal_d2_clk_impl(clocks, false);
3692 release_xtal_clk(clocks);
3693 }
3694 pub fn xtal_d2_clk_frequency() -> u32 {
3695 (xtal_clk_frequency() / 2)
3696 }
3697 pub fn xtal_d2_clk_source_frequency() -> u32 {
3698 xtal_clk_frequency()
3699 }
3700 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
3701 let old_selector = clocks.lp_fast_clk.replace(new_selector);
3702 refresh_lp_fast_clk_downstream(clocks);
3703 if clocks.lp_fast_clk_refcount > 0 {
3704 match new_selector {
3705 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3706 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
3707 }
3708 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
3709 if let Some(old_selector) = old_selector {
3710 match old_selector {
3711 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3712 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
3713 }
3714 }
3715 } else {
3716 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
3717 }
3718 }
3719 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
3720 clocks.lp_fast_clk
3721 }
3722 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
3723 trace!("Requesting LP_FAST_CLK");
3724 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
3725 trace!("Enabling LP_FAST_CLK");
3726 match unwrap!(clocks.lp_fast_clk) {
3727 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3728 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
3729 }
3730 enable_lp_fast_clk_impl(clocks, true);
3731 }
3732 }
3733 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
3734 trace!("Releasing LP_FAST_CLK");
3735 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
3736 trace!("Disabling LP_FAST_CLK");
3737 enable_lp_fast_clk_impl(clocks, false);
3738 match unwrap!(clocks.lp_fast_clk) {
3739 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3740 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
3741 }
3742 }
3743 }
3744 #[allow(unused_variables)]
3745 pub fn lp_fast_clk_config_frequency(
3746 clocks: &mut ClockTree,
3747 config: LpFastClkConfig,
3748 ) -> u32 {
3749 match config {
3750 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
3751 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
3752 }
3753 }
3754 pub fn lp_fast_clk_frequency() -> u32 {
3755 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3756 }
3757 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
3758 match source {
3759 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
3760 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
3761 }
3762 }
3763 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
3764 let old_selector = clocks.lp_slow_clk.replace(new_selector);
3765 refresh_lp_slow_clk_downstream(clocks);
3766 match new_selector {
3767 #[cfg(use_xtal32k)]
3768 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3769 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3770 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3771 }
3772 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
3773 if let Some(old_selector) = old_selector {
3774 match old_selector {
3775 #[cfg(use_xtal32k)]
3776 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3777 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3778 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3779 }
3780 }
3781 }
3782 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
3783 clocks.lp_slow_clk
3784 }
3785 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
3786 trace!("Requesting LP_SLOW_CLK");
3787 trace!("Enabling LP_SLOW_CLK");
3788 match unwrap!(clocks.lp_slow_clk) {
3789 #[cfg(use_xtal32k)]
3790 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3791 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3792 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3793 }
3794 enable_lp_slow_clk_impl(clocks, true);
3795 }
3796 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
3797 trace!("Releasing LP_SLOW_CLK");
3798 trace!("Disabling LP_SLOW_CLK");
3799 enable_lp_slow_clk_impl(clocks, false);
3800 match unwrap!(clocks.lp_slow_clk) {
3801 #[cfg(use_xtal32k)]
3802 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3803 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3804 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3805 }
3806 }
3807 #[allow(unused_variables)]
3808 pub fn lp_slow_clk_config_frequency(
3809 clocks: &mut ClockTree,
3810 config: LpSlowClkConfig,
3811 ) -> u32 {
3812 match config {
3813 #[cfg(use_xtal32k)]
3814 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3815 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3816 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
3817 }
3818 }
3819 pub fn lp_slow_clk_frequency() -> u32 {
3820 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3821 }
3822 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
3823 match source {
3824 #[cfg(use_xtal32k)]
3825 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3826 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3827 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
3828 }
3829 }
3830 pub fn configure_timg_calibration_clock(
3831 clocks: &mut ClockTree,
3832 new_selector: TimgCalibrationClockConfig,
3833 ) {
3834 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3835 refresh_timg_calibration_clock_downstream(clocks);
3836 if clocks.timg_calibration_clock_refcount > 0 {
3837 match new_selector {
3838 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
3839 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3840 #[cfg(use_xtal32k)]
3841 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3842 }
3843 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3844 if let Some(old_selector) = old_selector {
3845 match old_selector {
3846 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
3847 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3848 #[cfg(use_xtal32k)]
3849 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3850 }
3851 }
3852 } else {
3853 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3854 }
3855 }
3856 pub fn timg_calibration_clock_config(
3857 clocks: &mut ClockTree,
3858 ) -> Option<TimgCalibrationClockConfig> {
3859 clocks.timg_calibration_clock
3860 }
3861 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3862 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3863 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3864 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3865 crate::rtc_cntl::WakeLock::acquire();
3866 match unwrap!(clocks.timg_calibration_clock) {
3867 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
3868 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3869 #[cfg(use_xtal32k)]
3870 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3871 }
3872 enable_timg_calibration_clock_impl(clocks, true);
3873 }
3874 }
3875 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3876 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3877 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3878 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3879 crate::rtc_cntl::WakeLock::release();
3880 enable_timg_calibration_clock_impl(clocks, false);
3881 match unwrap!(clocks.timg_calibration_clock) {
3882 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
3883 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3884 #[cfg(use_xtal32k)]
3885 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3886 }
3887 }
3888 }
3889 #[allow(unused_variables)]
3890 pub fn timg_calibration_clock_config_frequency(
3891 clocks: &mut ClockTree,
3892 config: TimgCalibrationClockConfig,
3893 ) -> u32 {
3894 match config {
3895 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
3896 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3897 #[cfg(use_xtal32k)]
3898 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3899 }
3900 }
3901 pub fn timg_calibration_clock_frequency() -> u32 {
3902 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3903 }
3904 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3905 match source {
3906 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
3907 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3908 #[cfg(use_xtal32k)]
3909 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3910 }
3911 }
3912 impl SdmInstance {
3913 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3914 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3915 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3916 {
3917 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3918 request_iomux_function_clock(clocks);
3919 self.enable_function_clock_impl(clocks, true);
3920 }
3921 }
3922 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3923 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3924 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3925 {
3926 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3927 self.enable_function_clock_impl(clocks, false);
3928 release_iomux_function_clock(clocks);
3929 }
3930 }
3931 pub fn function_clock_frequency(self) -> u32 {
3932 iomux_function_clock_frequency()
3933 }
3934 pub fn function_clock_source_frequency() -> u32 {
3935 iomux_function_clock_frequency()
3936 }
3937 }
3938 impl I2cInstance {
3939 pub fn configure_function_clock(
3940 self,
3941 clocks: &mut ClockTree,
3942 config: I2cFunctionClockConfig,
3943 ) {
3944 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3945 refresh_i2c_function_clock_downstream(clocks, self);
3946 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
3947 match config.sclk {
3948 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3949 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3950 }
3951 self.configure_function_clock_impl(clocks, old_config, config);
3952 if let Some(old_config) = old_config {
3953 match old_config.sclk {
3954 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3955 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3956 }
3957 }
3958 } else {
3959 self.configure_function_clock_impl(clocks, old_config, config);
3960 }
3961 }
3962 pub fn function_clock_config(
3963 self,
3964 clocks: &mut ClockTree,
3965 ) -> Option<I2cFunctionClockConfig> {
3966 clocks.i2c_function_clock[self as usize]
3967 }
3968 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3969 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3970 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3971 {
3972 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3973 crate::rtc_cntl::WakeLock::acquire();
3974 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3975 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3976 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3977 }
3978 self.enable_function_clock_impl(clocks, true);
3979 }
3980 }
3981 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3982 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3983 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3984 {
3985 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3986 crate::rtc_cntl::WakeLock::release();
3987 self.enable_function_clock_impl(clocks, false);
3988 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3989 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3990 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3991 }
3992 }
3993 }
3994 #[allow(unused_variables)]
3995 pub fn function_clock_config_frequency(
3996 clocks: &mut ClockTree,
3997 config: I2cFunctionClockConfig,
3998 ) -> u32 {
3999 (match config.sclk {
4000 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4001 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4002 } / (config.div_num() + 1))
4003 }
4004 pub fn function_clock_frequency(self) -> u32 {
4005 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4006 .load(::core::sync::atomic::Ordering::Acquire)
4007 }
4008 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
4009 match sclk {
4010 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
4011 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4012 }
4013 }
4014 }
4015 impl I2sInstance {
4016 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
4017 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
4018 refresh_i2s_tx_clk_downstream(clocks, self);
4019 if clocks.i2s_tx_clk_refcount[self as usize] > 0 {
4020 match config.sclk {
4021 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4022 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4023 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4024 }
4025 self.configure_tx_clk_impl(clocks, old_config, config);
4026 if let Some(old_config) = old_config {
4027 match old_config.sclk {
4028 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4029 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4030 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4031 }
4032 }
4033 } else {
4034 self.configure_tx_clk_impl(clocks, old_config, config);
4035 }
4036 }
4037 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
4038 clocks.i2s_tx_clk[self as usize]
4039 }
4040 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
4041 trace!("Requesting {:?}::TX_CLK", self);
4042 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
4043 trace!("Enabling {:?}::TX_CLK", self);
4044 crate::rtc_cntl::WakeLock::acquire();
4045 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
4046 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4047 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4048 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4049 }
4050 self.enable_tx_clk_impl(clocks, true);
4051 }
4052 }
4053 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
4054 trace!("Releasing {:?}::TX_CLK", self);
4055 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
4056 trace!("Disabling {:?}::TX_CLK", self);
4057 crate::rtc_cntl::WakeLock::release();
4058 self.enable_tx_clk_impl(clocks, false);
4059 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
4060 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4061 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4062 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4063 }
4064 }
4065 }
4066 #[allow(unused_variables)]
4067 pub fn tx_clk_config_frequency(clocks: &mut ClockTree, config: I2sClkConfig) -> u32 {
4068 (((match config.sclk {
4069 I2sClkSclk::Xtal => xtal_clk_frequency(),
4070 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4071 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4072 } as u64)
4073 * (config.div_a() as u64))
4074 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
4075 as u32
4076 }
4077 pub fn tx_clk_frequency(self) -> u32 {
4078 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4079 }
4080 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
4081 match sclk {
4082 I2sClkSclk::Xtal => xtal_clk_frequency(),
4083 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4084 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4085 }
4086 }
4087 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
4088 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
4089 refresh_i2s_rx_clk_downstream(clocks, self);
4090 if clocks.i2s_rx_clk_refcount[self as usize] > 0 {
4091 match config.sclk {
4092 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4093 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4094 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4095 }
4096 self.configure_rx_clk_impl(clocks, old_config, config);
4097 if let Some(old_config) = old_config {
4098 match old_config.sclk {
4099 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4100 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4101 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4102 }
4103 }
4104 } else {
4105 self.configure_rx_clk_impl(clocks, old_config, config);
4106 }
4107 }
4108 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
4109 clocks.i2s_rx_clk[self as usize]
4110 }
4111 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
4112 trace!("Requesting {:?}::RX_CLK", self);
4113 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
4114 trace!("Enabling {:?}::RX_CLK", self);
4115 crate::rtc_cntl::WakeLock::acquire();
4116 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
4117 I2sClkSclk::Xtal => request_xtal_clk(clocks),
4118 I2sClkSclk::PllF240m => request_pll_f240m(clocks),
4119 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
4120 }
4121 self.enable_rx_clk_impl(clocks, true);
4122 }
4123 }
4124 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
4125 trace!("Releasing {:?}::RX_CLK", self);
4126 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
4127 trace!("Disabling {:?}::RX_CLK", self);
4128 crate::rtc_cntl::WakeLock::release();
4129 self.enable_rx_clk_impl(clocks, false);
4130 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
4131 I2sClkSclk::Xtal => release_xtal_clk(clocks),
4132 I2sClkSclk::PllF240m => release_pll_f240m(clocks),
4133 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
4134 }
4135 }
4136 }
4137 #[allow(unused_variables)]
4138 pub fn rx_clk_config_frequency(clocks: &mut ClockTree, config: I2sClkConfig) -> u32 {
4139 (((match config.sclk {
4140 I2sClkSclk::Xtal => xtal_clk_frequency(),
4141 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4142 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4143 } as u64)
4144 * (config.div_a() as u64))
4145 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
4146 as u32
4147 }
4148 pub fn rx_clk_frequency(self) -> u32 {
4149 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4150 }
4151 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
4152 match sclk {
4153 I2sClkSclk::Xtal => xtal_clk_frequency(),
4154 I2sClkSclk::PllF240m => pll_f240m_frequency(),
4155 I2sClkSclk::PllF160m => pll_f160m_frequency(),
4156 }
4157 }
4158 pub fn configure_mclk_out(
4159 self,
4160 clocks: &mut ClockTree,
4161 new_selector: I2sMclkOutConfig,
4162 ) {
4163 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
4164 refresh_i2s_mclk_out_downstream(clocks, self);
4165 if clocks.i2s_mclk_out_refcount[self as usize] > 0 {
4166 match new_selector {
4167 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
4168 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
4169 }
4170 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
4171 if let Some(old_selector) = old_selector {
4172 match old_selector {
4173 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
4174 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
4175 }
4176 }
4177 } else {
4178 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
4179 }
4180 }
4181 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
4182 clocks.i2s_mclk_out[self as usize]
4183 }
4184 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
4185 trace!("Requesting {:?}::MCLK_OUT", self);
4186 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
4187 trace!("Enabling {:?}::MCLK_OUT", self);
4188 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
4189 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
4190 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
4191 }
4192 self.enable_mclk_out_impl(clocks, true);
4193 }
4194 }
4195 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
4196 trace!("Releasing {:?}::MCLK_OUT", self);
4197 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
4198 trace!("Disabling {:?}::MCLK_OUT", self);
4199 self.enable_mclk_out_impl(clocks, false);
4200 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
4201 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
4202 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
4203 }
4204 }
4205 }
4206 #[allow(unused_variables)]
4207 pub fn mclk_out_config_frequency(
4208 self,
4209 clocks: &mut ClockTree,
4210 config: I2sMclkOutConfig,
4211 ) -> u32 {
4212 match config {
4213 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
4214 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
4215 }
4216 }
4217 pub fn mclk_out_frequency(self) -> u32 {
4218 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4219 }
4220 }
4221 impl McpwmInstance {
4222 pub fn configure_function_clock(
4223 self,
4224 clocks: &mut ClockTree,
4225 new_selector: McpwmFunctionClockConfig,
4226 ) {
4227 let old_selector = clocks.mcpwm_function_clock[self as usize].replace(new_selector);
4228 refresh_mcpwm_function_clock_downstream(clocks, self);
4229 if clocks.mcpwm_function_clock_refcount[self as usize] > 0 {
4230 match new_selector {
4231 McpwmFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
4232 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4233 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4234 }
4235 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4236 if let Some(old_selector) = old_selector {
4237 match old_selector {
4238 McpwmFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
4239 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4240 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4241 }
4242 }
4243 } else {
4244 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4245 }
4246 }
4247 pub fn function_clock_config(
4248 self,
4249 clocks: &mut ClockTree,
4250 ) -> Option<McpwmFunctionClockConfig> {
4251 clocks.mcpwm_function_clock[self as usize]
4252 }
4253 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4254 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4255 if increment_reference_count(
4256 &mut clocks.mcpwm_function_clock_refcount[self as usize],
4257 ) {
4258 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4259 crate::rtc_cntl::WakeLock::acquire();
4260 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
4261 McpwmFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
4262 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4263 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4264 }
4265 self.enable_function_clock_impl(clocks, true);
4266 }
4267 }
4268 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4269 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4270 if decrement_reference_count(
4271 &mut clocks.mcpwm_function_clock_refcount[self as usize],
4272 ) {
4273 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4274 crate::rtc_cntl::WakeLock::release();
4275 self.enable_function_clock_impl(clocks, false);
4276 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
4277 McpwmFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
4278 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4279 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4280 }
4281 }
4282 }
4283 #[allow(unused_variables)]
4284 pub fn function_clock_config_frequency(
4285 clocks: &mut ClockTree,
4286 config: McpwmFunctionClockConfig,
4287 ) -> u32 {
4288 match config {
4289 McpwmFunctionClockConfig::PllF160m => pll_f160m_frequency(),
4290 McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4291 McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4292 }
4293 }
4294 pub fn function_clock_frequency(self) -> u32 {
4295 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4296 .load(::core::sync::atomic::Ordering::Acquire)
4297 }
4298 pub fn function_clock_source_frequency(source: McpwmFunctionClockConfig) -> u32 {
4299 match source {
4300 McpwmFunctionClockConfig::PllF160m => pll_f160m_frequency(),
4301 McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4302 McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4303 }
4304 }
4305 }
4306 impl ParlIoInstance {
4307 pub fn configure_rx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4308 let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
4309 refresh_parl_io_rx_clock_downstream(clocks, self);
4310 if clocks.parl_io_rx_clock_refcount[self as usize] > 0 {
4311 match new_selector {
4312 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4313 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4314 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4315 }
4316 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
4317 if let Some(old_selector) = old_selector {
4318 match old_selector {
4319 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4320 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4321 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4322 }
4323 }
4324 } else {
4325 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
4326 }
4327 }
4328 pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4329 clocks.parl_io_rx_clock[self as usize]
4330 }
4331 pub fn request_rx_clock(self, clocks: &mut ClockTree) {
4332 trace!("Requesting {:?}::RX_CLOCK", self);
4333 if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
4334 trace!("Enabling {:?}::RX_CLOCK", self);
4335 crate::rtc_cntl::WakeLock::acquire();
4336 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4337 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4338 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4339 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4340 }
4341 self.enable_rx_clock_impl(clocks, true);
4342 }
4343 }
4344 pub fn release_rx_clock(self, clocks: &mut ClockTree) {
4345 trace!("Releasing {:?}::RX_CLOCK", self);
4346 if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
4347 trace!("Disabling {:?}::RX_CLOCK", self);
4348 crate::rtc_cntl::WakeLock::release();
4349 self.enable_rx_clock_impl(clocks, false);
4350 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4351 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4352 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4353 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4354 }
4355 }
4356 }
4357 #[allow(unused_variables)]
4358 pub fn rx_clock_config_frequency(
4359 clocks: &mut ClockTree,
4360 config: ParlIoClkConfig,
4361 ) -> u32 {
4362 match config {
4363 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4364 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4365 ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4366 }
4367 }
4368 pub fn rx_clock_frequency(self) -> u32 {
4369 PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
4370 .load(::core::sync::atomic::Ordering::Acquire)
4371 }
4372 pub fn rx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4373 match source {
4374 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4375 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4376 ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4377 }
4378 }
4379 pub fn configure_tx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4380 let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
4381 refresh_parl_io_tx_clock_downstream(clocks, self);
4382 if clocks.parl_io_tx_clock_refcount[self as usize] > 0 {
4383 match new_selector {
4384 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4385 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4386 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4387 }
4388 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
4389 if let Some(old_selector) = old_selector {
4390 match old_selector {
4391 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4392 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4393 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4394 }
4395 }
4396 } else {
4397 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
4398 }
4399 }
4400 pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4401 clocks.parl_io_tx_clock[self as usize]
4402 }
4403 pub fn request_tx_clock(self, clocks: &mut ClockTree) {
4404 trace!("Requesting {:?}::TX_CLOCK", self);
4405 if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4406 trace!("Enabling {:?}::TX_CLOCK", self);
4407 crate::rtc_cntl::WakeLock::acquire();
4408 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4409 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4410 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4411 ParlIoClkConfig::PllF240m => request_pll_f240m(clocks),
4412 }
4413 self.enable_tx_clock_impl(clocks, true);
4414 }
4415 }
4416 pub fn release_tx_clock(self, clocks: &mut ClockTree) {
4417 trace!("Releasing {:?}::TX_CLOCK", self);
4418 if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4419 trace!("Disabling {:?}::TX_CLOCK", self);
4420 crate::rtc_cntl::WakeLock::release();
4421 self.enable_tx_clock_impl(clocks, false);
4422 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4423 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4424 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4425 ParlIoClkConfig::PllF240m => release_pll_f240m(clocks),
4426 }
4427 }
4428 }
4429 #[allow(unused_variables)]
4430 pub fn tx_clock_config_frequency(
4431 clocks: &mut ClockTree,
4432 config: ParlIoClkConfig,
4433 ) -> u32 {
4434 match config {
4435 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4436 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4437 ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4438 }
4439 }
4440 pub fn tx_clock_frequency(self) -> u32 {
4441 PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
4442 .load(::core::sync::atomic::Ordering::Acquire)
4443 }
4444 pub fn tx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4445 match source {
4446 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4447 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4448 ParlIoClkConfig::PllF240m => pll_f240m_frequency(),
4449 }
4450 }
4451 }
4452 impl RmtInstance {
4453 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
4454 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
4455 refresh_rmt_sclk_downstream(clocks, self);
4456 if clocks.rmt_sclk_refcount[self as usize] > 0 {
4457 match new_selector {
4458 RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
4459 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4460 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4461 }
4462 self.configure_sclk_impl(clocks, old_selector, new_selector);
4463 if let Some(old_selector) = old_selector {
4464 match old_selector {
4465 RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
4466 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4467 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4468 }
4469 }
4470 } else {
4471 self.configure_sclk_impl(clocks, old_selector, new_selector);
4472 }
4473 }
4474 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
4475 clocks.rmt_sclk[self as usize]
4476 }
4477 pub fn request_sclk(self, clocks: &mut ClockTree) {
4478 trace!("Requesting {:?}::SCLK", self);
4479 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4480 trace!("Enabling {:?}::SCLK", self);
4481 crate::rtc_cntl::WakeLock::acquire();
4482 match unwrap!(clocks.rmt_sclk[self as usize]) {
4483 RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
4484 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4485 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4486 }
4487 self.enable_sclk_impl(clocks, true);
4488 }
4489 }
4490 pub fn release_sclk(self, clocks: &mut ClockTree) {
4491 trace!("Releasing {:?}::SCLK", self);
4492 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4493 trace!("Disabling {:?}::SCLK", self);
4494 crate::rtc_cntl::WakeLock::release();
4495 self.enable_sclk_impl(clocks, false);
4496 match unwrap!(clocks.rmt_sclk[self as usize]) {
4497 RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
4498 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4499 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4500 }
4501 }
4502 }
4503 #[allow(unused_variables)]
4504 pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
4505 match config {
4506 RmtSclkConfig::PllF80m => pll_f80m_frequency(),
4507 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4508 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
4509 }
4510 }
4511 pub fn sclk_frequency(self) -> u32 {
4512 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4513 }
4514 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
4515 match source {
4516 RmtSclkConfig::PllF80m => pll_f80m_frequency(),
4517 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4518 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
4519 }
4520 }
4521 }
4522 impl SpiInstance {
4523 pub fn configure_function_clock(
4524 self,
4525 clocks: &mut ClockTree,
4526 new_selector: SpiFunctionClockConfig,
4527 ) {
4528 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
4529 refresh_spi_function_clock_downstream(clocks, self);
4530 if clocks.spi_function_clock_refcount[self as usize] > 0 {
4531 match new_selector {
4532 SpiFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4533 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4534 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4535 }
4536 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4537 if let Some(old_selector) = old_selector {
4538 match old_selector {
4539 SpiFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4540 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4541 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4542 }
4543 }
4544 } else {
4545 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4546 }
4547 }
4548 pub fn function_clock_config(
4549 self,
4550 clocks: &mut ClockTree,
4551 ) -> Option<SpiFunctionClockConfig> {
4552 clocks.spi_function_clock[self as usize]
4553 }
4554 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4555 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4556 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
4557 {
4558 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4559 crate::rtc_cntl::WakeLock::acquire();
4560 match unwrap!(clocks.spi_function_clock[self as usize]) {
4561 SpiFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4562 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4563 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4564 }
4565 self.enable_function_clock_impl(clocks, true);
4566 }
4567 }
4568 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4569 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4570 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
4571 {
4572 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4573 crate::rtc_cntl::WakeLock::release();
4574 self.enable_function_clock_impl(clocks, false);
4575 match unwrap!(clocks.spi_function_clock[self as usize]) {
4576 SpiFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4577 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4578 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4579 }
4580 }
4581 }
4582 #[allow(unused_variables)]
4583 pub fn function_clock_config_frequency(
4584 clocks: &mut ClockTree,
4585 config: SpiFunctionClockConfig,
4586 ) -> u32 {
4587 match config {
4588 SpiFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4589 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
4590 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
4591 }
4592 }
4593 pub fn function_clock_frequency(self) -> u32 {
4594 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4595 .load(::core::sync::atomic::Ordering::Acquire)
4596 }
4597 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
4598 match source {
4599 SpiFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4600 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
4601 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
4602 }
4603 }
4604 }
4605 impl TimgInstance {
4606 pub fn configure_function_clock(
4607 self,
4608 clocks: &mut ClockTree,
4609 new_selector: TimgFunctionClockConfig,
4610 ) {
4611 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
4612 refresh_timg_function_clock_downstream(clocks, self);
4613 if clocks.timg_function_clock_refcount[self as usize] > 0 {
4614 match new_selector {
4615 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4616 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4617 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4618 }
4619 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4620 if let Some(old_selector) = old_selector {
4621 match old_selector {
4622 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4623 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4624 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4625 }
4626 }
4627 } else {
4628 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4629 }
4630 }
4631 pub fn function_clock_config(
4632 self,
4633 clocks: &mut ClockTree,
4634 ) -> Option<TimgFunctionClockConfig> {
4635 clocks.timg_function_clock[self as usize]
4636 }
4637 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4638 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4639 if increment_reference_count(
4640 &mut clocks.timg_function_clock_refcount[self as usize],
4641 ) {
4642 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4643 match unwrap!(clocks.timg_function_clock[self as usize]) {
4644 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4645 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4646 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
4647 }
4648 self.enable_function_clock_impl(clocks, true);
4649 }
4650 }
4651 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4652 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4653 if decrement_reference_count(
4654 &mut clocks.timg_function_clock_refcount[self as usize],
4655 ) {
4656 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4657 self.enable_function_clock_impl(clocks, false);
4658 match unwrap!(clocks.timg_function_clock[self as usize]) {
4659 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4660 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4661 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
4662 }
4663 }
4664 }
4665 #[allow(unused_variables)]
4666 pub fn function_clock_config_frequency(
4667 clocks: &mut ClockTree,
4668 config: TimgFunctionClockConfig,
4669 ) -> u32 {
4670 match config {
4671 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4672 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4673 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4674 }
4675 }
4676 pub fn function_clock_frequency(self) -> u32 {
4677 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4678 .load(::core::sync::atomic::Ordering::Acquire)
4679 }
4680 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
4681 match source {
4682 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4683 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4684 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
4685 }
4686 }
4687 pub fn configure_wdt_clock(
4688 self,
4689 clocks: &mut ClockTree,
4690 new_selector: TimgWdtClockConfig,
4691 ) {
4692 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
4693 refresh_timg_wdt_clock_downstream(clocks, self);
4694 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
4695 match new_selector {
4696 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
4697 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
4698 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4699 }
4700 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
4701 if let Some(old_selector) = old_selector {
4702 match old_selector {
4703 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
4704 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
4705 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4706 }
4707 }
4708 } else {
4709 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
4710 }
4711 }
4712 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
4713 clocks.timg_wdt_clock[self as usize]
4714 }
4715 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
4716 trace!("Requesting {:?}::WDT_CLOCK", self);
4717 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
4718 trace!("Enabling {:?}::WDT_CLOCK", self);
4719 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
4720 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
4721 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
4722 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4723 }
4724 self.enable_wdt_clock_impl(clocks, true);
4725 }
4726 }
4727 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
4728 trace!("Releasing {:?}::WDT_CLOCK", self);
4729 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
4730 trace!("Disabling {:?}::WDT_CLOCK", self);
4731 self.enable_wdt_clock_impl(clocks, false);
4732 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
4733 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
4734 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
4735 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4736 }
4737 }
4738 }
4739 #[allow(unused_variables)]
4740 pub fn wdt_clock_config_frequency(
4741 clocks: &mut ClockTree,
4742 config: TimgWdtClockConfig,
4743 ) -> u32 {
4744 match config {
4745 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
4746 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
4747 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
4748 }
4749 }
4750 pub fn wdt_clock_frequency(self) -> u32 {
4751 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
4752 .load(::core::sync::atomic::Ordering::Acquire)
4753 }
4754 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
4755 match source {
4756 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
4757 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
4758 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
4759 }
4760 }
4761 }
4762 impl UartInstance {
4763 pub fn configure_function_clock(
4764 self,
4765 clocks: &mut ClockTree,
4766 config: UartFunctionClockConfig,
4767 ) {
4768 let old_config = clocks.uart_function_clock[self as usize].replace(config);
4769 refresh_uart_function_clock_downstream(clocks, self);
4770 if clocks.uart_function_clock_refcount[self as usize] > 0 {
4771 match config.sclk {
4772 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
4773 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4774 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4775 }
4776 self.configure_function_clock_impl(clocks, old_config, config);
4777 if let Some(old_config) = old_config {
4778 match old_config.sclk {
4779 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
4780 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4781 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4782 }
4783 }
4784 } else {
4785 self.configure_function_clock_impl(clocks, old_config, config);
4786 }
4787 }
4788 pub fn function_clock_config(
4789 self,
4790 clocks: &mut ClockTree,
4791 ) -> Option<UartFunctionClockConfig> {
4792 clocks.uart_function_clock[self as usize]
4793 }
4794 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4795 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4796 if increment_reference_count(
4797 &mut clocks.uart_function_clock_refcount[self as usize],
4798 ) {
4799 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4800 crate::rtc_cntl::WakeLock::acquire();
4801 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
4802 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
4803 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4804 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4805 }
4806 self.enable_function_clock_impl(clocks, true);
4807 }
4808 }
4809 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4810 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4811 if decrement_reference_count(
4812 &mut clocks.uart_function_clock_refcount[self as usize],
4813 ) {
4814 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4815 crate::rtc_cntl::WakeLock::release();
4816 self.enable_function_clock_impl(clocks, false);
4817 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
4818 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
4819 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4820 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4821 }
4822 }
4823 }
4824 #[allow(unused_variables)]
4825 pub fn function_clock_config_frequency(
4826 clocks: &mut ClockTree,
4827 config: UartFunctionClockConfig,
4828 ) -> u32 {
4829 (match config.sclk {
4830 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
4831 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4832 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
4833 } / (config.div_num() + 1))
4834 }
4835 pub fn function_clock_frequency(self) -> u32 {
4836 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4837 .load(::core::sync::atomic::Ordering::Acquire)
4838 }
4839 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
4840 match sclk {
4841 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
4842 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4843 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
4844 }
4845 }
4846 pub fn configure_baud_rate_generator(
4847 self,
4848 clocks: &mut ClockTree,
4849 config: UartBaudRateGeneratorConfig,
4850 ) {
4851 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
4852 refresh_uart_baud_rate_generator_downstream(clocks, self);
4853 self.configure_baud_rate_generator_impl(clocks, old_config, config);
4854 }
4855 pub fn baud_rate_generator_config(
4856 self,
4857 clocks: &mut ClockTree,
4858 ) -> Option<UartBaudRateGeneratorConfig> {
4859 clocks.uart_baud_rate_generator[self as usize]
4860 }
4861 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
4862 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
4863 if increment_reference_count(
4864 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
4865 ) {
4866 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
4867 self.request_function_clock(clocks);
4868 self.enable_baud_rate_generator_impl(clocks, true);
4869 }
4870 }
4871 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
4872 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
4873 if decrement_reference_count(
4874 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
4875 ) {
4876 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
4877 self.enable_baud_rate_generator_impl(clocks, false);
4878 self.release_function_clock(clocks);
4879 }
4880 }
4881 #[allow(unused_variables)]
4882 pub fn baud_rate_generator_config_frequency(
4883 self,
4884 clocks: &mut ClockTree,
4885 config: UartBaudRateGeneratorConfig,
4886 ) -> u32 {
4887 ((self.function_clock_frequency() * 16)
4888 / ((config.integral() * 16) + config.fractional()))
4889 }
4890 pub fn baud_rate_generator_frequency(self) -> u32 {
4891 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
4892 .load(::core::sync::atomic::Ordering::Acquire)
4893 }
4894 }
4895 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4903 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4904 #[instability::unstable]
4905 pub struct ClockConfig {
4906 pub xtal_clk: Option<XtalClkConfig>,
4908 pub soc_root_clk: Option<SocRootClkConfig>,
4910 pub cpu_hs_div: Option<CpuHsDivConfig>,
4912 pub cpu_ls_div: Option<CpuLsDivConfig>,
4914 pub ahb_hs_div: Option<AhbHsDivConfig>,
4916 pub ahb_ls_div: Option<AhbLsDivConfig>,
4918 pub apb_clk: Option<ApbClkConfig>,
4920 pub mspi_fast_hs_clk: Option<MspiFastHsClkConfig>,
4922 pub mspi_fast_ls_clk: Option<MspiFastLsClkConfig>,
4924 pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
4926 pub ledc_sclk: Option<LedcSclkConfig>,
4928 pub lp_fast_clk: Option<LpFastClkConfig>,
4930 pub lp_slow_clk: Option<LpSlowClkConfig>,
4932 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
4934 }
4935 impl ClockConfig {
4936 fn apply(&self, clocks: &mut ClockTree) {
4937 if let Some(config) = self.xtal_clk {
4938 configure_xtal_clk(clocks, config);
4939 }
4940 if let Some(config) = self.soc_root_clk {
4941 configure_soc_root_clk(clocks, config);
4942 }
4943 if let Some(config) = self.iomux_function_clock {
4944 configure_iomux_function_clock(clocks, config);
4945 }
4946 if let Some(config) = self.ledc_sclk {
4947 configure_ledc_sclk(clocks, config);
4948 }
4949 if let Some(config) = self.lp_fast_clk {
4950 configure_lp_fast_clk(clocks, config);
4951 }
4952 if let Some(config) = self.lp_slow_clk {
4953 configure_lp_slow_clk(clocks, config);
4954 }
4955 if let Some(config) = self.timg_calibration_clock {
4956 configure_timg_calibration_clock(clocks, config);
4957 }
4958 if let Some(config) = self.cpu_hs_div {
4959 configure_cpu_hs_div(clocks, config);
4960 }
4961 if let Some(config) = self.cpu_ls_div {
4962 configure_cpu_ls_div(clocks, config);
4963 }
4964 if let Some(config) = self.ahb_hs_div {
4965 configure_ahb_hs_div(clocks, config);
4966 }
4967 if let Some(config) = self.ahb_ls_div {
4968 configure_ahb_ls_div(clocks, config);
4969 }
4970 if let Some(config) = self.mspi_fast_hs_clk {
4971 configure_mspi_fast_hs_clk(clocks, config);
4972 }
4973 if let Some(config) = self.mspi_fast_ls_clk {
4974 configure_mspi_fast_ls_clk(clocks, config);
4975 }
4976 if let Some(config) = self.apb_clk {
4977 configure_apb_clk(clocks, config);
4978 }
4979 }
4980 }
4981 fn increment_reference_count(refcount: &mut u32) -> bool {
4982 let first = *refcount == 0;
4983 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
4984 first
4985 }
4986 fn decrement_reference_count(refcount: &mut u32) -> bool {
4987 *refcount = refcount.saturating_sub(1);
4988 let last = *refcount == 0;
4989 last
4990 }
4991 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
4992 if let Some(config) = clocks.xtal_clk {
4993 XTAL_CLK_FREQ_CACHE.store(
4994 xtal_clk_config_frequency(clocks, config),
4995 ::core::sync::atomic::Ordering::Release,
4996 );
4997 }
4998 refresh_soc_root_clk_downstream(clocks);
4999 refresh_iomux_function_clock_downstream(clocks);
5000 refresh_ledc_sclk_downstream(clocks);
5001 refresh_lp_fast_clk_downstream(clocks);
5002 for child_instance in [I2cInstance::I2c0] {
5003 refresh_i2c_function_clock_downstream(clocks, child_instance);
5004 }
5005 for child_instance in [I2sInstance::I2s0] {
5006 refresh_i2s_tx_clk_downstream(clocks, child_instance);
5007 refresh_i2s_rx_clk_downstream(clocks, child_instance);
5008 }
5009 for child_instance in [McpwmInstance::Mcpwm0] {
5010 refresh_mcpwm_function_clock_downstream(clocks, child_instance);
5011 }
5012 for child_instance in [ParlIoInstance::ParlIo] {
5013 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
5014 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
5015 }
5016 for child_instance in [RmtInstance::Rmt] {
5017 refresh_rmt_sclk_downstream(clocks, child_instance);
5018 }
5019 for child_instance in [SpiInstance::Spi2] {
5020 refresh_spi_function_clock_downstream(clocks, child_instance);
5021 }
5022 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
5023 refresh_timg_function_clock_downstream(clocks, child_instance);
5024 refresh_timg_wdt_clock_downstream(clocks, child_instance);
5025 }
5026 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
5027 refresh_uart_function_clock_downstream(clocks, child_instance);
5028 }
5029 }
5030 fn refresh_soc_root_clk_downstream(clocks: &mut ClockTree) {
5031 if let Some(config) = clocks.soc_root_clk {
5032 SOC_ROOT_CLK_FREQ_CACHE.store(
5033 soc_root_clk_config_frequency(clocks, config),
5034 ::core::sync::atomic::Ordering::Release,
5035 );
5036 }
5037 refresh_hp_root_clk_downstream(clocks);
5038 }
5039 fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
5040 if let Some(config) = clocks.iomux_function_clock {
5041 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
5042 iomux_function_clock_config_frequency(clocks, config),
5043 ::core::sync::atomic::Ordering::Release,
5044 );
5045 }
5046 }
5047 fn refresh_ledc_sclk_downstream(clocks: &mut ClockTree) {
5048 if let Some(config) = clocks.ledc_sclk {
5049 LEDC_SCLK_FREQ_CACHE.store(
5050 ledc_sclk_config_frequency(clocks, config),
5051 ::core::sync::atomic::Ordering::Release,
5052 );
5053 }
5054 }
5055 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
5056 if let Some(config) = clocks.lp_fast_clk {
5057 LP_FAST_CLK_FREQ_CACHE.store(
5058 lp_fast_clk_config_frequency(clocks, config),
5059 ::core::sync::atomic::Ordering::Release,
5060 );
5061 }
5062 }
5063 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
5064 if let Some(config) = clocks.lp_slow_clk {
5065 LP_SLOW_CLK_FREQ_CACHE.store(
5066 lp_slow_clk_config_frequency(clocks, config),
5067 ::core::sync::atomic::Ordering::Release,
5068 );
5069 }
5070 refresh_timg_calibration_clock_downstream(clocks);
5071 }
5072 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
5073 if let Some(config) = clocks.timg_calibration_clock {
5074 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
5075 timg_calibration_clock_config_frequency(clocks, config),
5076 ::core::sync::atomic::Ordering::Release,
5077 );
5078 }
5079 }
5080 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
5081 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
5082 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5083 I2cInstance::function_clock_config_frequency(clocks, config),
5084 ::core::sync::atomic::Ordering::Release,
5085 );
5086 }
5087 }
5088 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5089 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
5090 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
5091 I2sInstance::tx_clk_config_frequency(clocks, config),
5092 ::core::sync::atomic::Ordering::Release,
5093 );
5094 }
5095 refresh_i2s_mclk_out_downstream(clocks, instance);
5096 }
5097 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5098 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
5099 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
5100 I2sInstance::rx_clk_config_frequency(clocks, config),
5101 ::core::sync::atomic::Ordering::Release,
5102 );
5103 }
5104 refresh_i2s_mclk_out_downstream(clocks, instance);
5105 }
5106 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
5107 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
5108 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
5109 instance.mclk_out_config_frequency(clocks, config),
5110 ::core::sync::atomic::Ordering::Release,
5111 );
5112 }
5113 }
5114 fn refresh_mcpwm_function_clock_downstream(
5115 clocks: &mut ClockTree,
5116 instance: McpwmInstance,
5117 ) {
5118 if let Some(config) = clocks.mcpwm_function_clock[instance as usize] {
5119 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5120 McpwmInstance::function_clock_config_frequency(clocks, config),
5121 ::core::sync::atomic::Ordering::Release,
5122 );
5123 }
5124 }
5125 fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
5126 if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
5127 PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
5128 ParlIoInstance::rx_clock_config_frequency(clocks, config),
5129 ::core::sync::atomic::Ordering::Release,
5130 );
5131 }
5132 }
5133 fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
5134 if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
5135 PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
5136 ParlIoInstance::tx_clock_config_frequency(clocks, config),
5137 ::core::sync::atomic::Ordering::Release,
5138 );
5139 }
5140 }
5141 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
5142 if let Some(config) = clocks.rmt_sclk[instance as usize] {
5143 RMT_SCLK_FREQ_CACHE[instance as usize].store(
5144 RmtInstance::sclk_config_frequency(clocks, config),
5145 ::core::sync::atomic::Ordering::Release,
5146 );
5147 }
5148 }
5149 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
5150 if let Some(config) = clocks.spi_function_clock[instance as usize] {
5151 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5152 SpiInstance::function_clock_config_frequency(clocks, config),
5153 ::core::sync::atomic::Ordering::Release,
5154 );
5155 }
5156 }
5157 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
5158 if let Some(config) = clocks.timg_function_clock[instance as usize] {
5159 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5160 TimgInstance::function_clock_config_frequency(clocks, config),
5161 ::core::sync::atomic::Ordering::Release,
5162 );
5163 }
5164 }
5165 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
5166 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
5167 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
5168 TimgInstance::wdt_clock_config_frequency(clocks, config),
5169 ::core::sync::atomic::Ordering::Release,
5170 );
5171 }
5172 }
5173 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
5174 if let Some(config) = clocks.uart_function_clock[instance as usize] {
5175 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
5176 UartInstance::function_clock_config_frequency(clocks, config),
5177 ::core::sync::atomic::Ordering::Release,
5178 );
5179 }
5180 refresh_uart_baud_rate_generator_downstream(clocks, instance);
5181 }
5182 fn refresh_uart_baud_rate_generator_downstream(
5183 clocks: &mut ClockTree,
5184 instance: UartInstance,
5185 ) {
5186 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
5187 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
5188 instance.baud_rate_generator_config_frequency(clocks, config),
5189 ::core::sync::atomic::Ordering::Release,
5190 );
5191 }
5192 }
5193 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
5194 if let Some(config) = clocks.hp_root_clk {
5195 HP_ROOT_CLK_FREQ_CACHE.store(
5196 hp_root_clk_config_frequency(clocks, config),
5197 ::core::sync::atomic::Ordering::Release,
5198 );
5199 }
5200 refresh_cpu_hs_div_downstream(clocks);
5201 refresh_cpu_ls_div_downstream(clocks);
5202 refresh_ahb_hs_div_downstream(clocks);
5203 refresh_ahb_ls_div_downstream(clocks);
5204 refresh_mspi_fast_hs_clk_downstream(clocks);
5205 refresh_mspi_fast_ls_clk_downstream(clocks);
5206 }
5207 fn refresh_cpu_hs_div_downstream(clocks: &mut ClockTree) {
5208 if let Some(config) = clocks.cpu_hs_div {
5209 CPU_HS_DIV_FREQ_CACHE.store(
5210 cpu_hs_div_config_frequency(clocks, config),
5211 ::core::sync::atomic::Ordering::Release,
5212 );
5213 }
5214 refresh_cpu_clk_downstream(clocks);
5215 }
5216 fn refresh_cpu_ls_div_downstream(clocks: &mut ClockTree) {
5217 if let Some(config) = clocks.cpu_ls_div {
5218 CPU_LS_DIV_FREQ_CACHE.store(
5219 cpu_ls_div_config_frequency(clocks, config),
5220 ::core::sync::atomic::Ordering::Release,
5221 );
5222 }
5223 refresh_cpu_clk_downstream(clocks);
5224 }
5225 fn refresh_ahb_hs_div_downstream(clocks: &mut ClockTree) {
5226 if let Some(config) = clocks.ahb_hs_div {
5227 AHB_HS_DIV_FREQ_CACHE.store(
5228 ahb_hs_div_config_frequency(clocks, config),
5229 ::core::sync::atomic::Ordering::Release,
5230 );
5231 }
5232 refresh_ahb_clk_downstream(clocks);
5233 }
5234 fn refresh_ahb_ls_div_downstream(clocks: &mut ClockTree) {
5235 if let Some(config) = clocks.ahb_ls_div {
5236 AHB_LS_DIV_FREQ_CACHE.store(
5237 ahb_ls_div_config_frequency(clocks, config),
5238 ::core::sync::atomic::Ordering::Release,
5239 );
5240 }
5241 refresh_ahb_clk_downstream(clocks);
5242 }
5243 fn refresh_mspi_fast_hs_clk_downstream(clocks: &mut ClockTree) {
5244 if let Some(config) = clocks.mspi_fast_hs_clk {
5245 MSPI_FAST_HS_CLK_FREQ_CACHE.store(
5246 mspi_fast_hs_clk_config_frequency(clocks, config),
5247 ::core::sync::atomic::Ordering::Release,
5248 );
5249 }
5250 refresh_mspi_fast_clk_downstream(clocks);
5251 }
5252 fn refresh_mspi_fast_ls_clk_downstream(clocks: &mut ClockTree) {
5253 if let Some(config) = clocks.mspi_fast_ls_clk {
5254 MSPI_FAST_LS_CLK_FREQ_CACHE.store(
5255 mspi_fast_ls_clk_config_frequency(clocks, config),
5256 ::core::sync::atomic::Ordering::Release,
5257 );
5258 }
5259 refresh_mspi_fast_clk_downstream(clocks);
5260 }
5261 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
5262 if let Some(config) = clocks.cpu_clk {
5263 CPU_CLK_FREQ_CACHE.store(
5264 cpu_clk_config_frequency(clocks, config),
5265 ::core::sync::atomic::Ordering::Release,
5266 );
5267 }
5268 }
5269 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
5270 if let Some(config) = clocks.ahb_clk {
5271 AHB_CLK_FREQ_CACHE.store(
5272 ahb_clk_config_frequency(clocks, config),
5273 ::core::sync::atomic::Ordering::Release,
5274 );
5275 }
5276 refresh_apb_clk_downstream(clocks);
5277 }
5278 fn refresh_mspi_fast_clk_downstream(clocks: &mut ClockTree) {
5279 if let Some(config) = clocks.mspi_fast_clk {
5280 MSPI_FAST_CLK_FREQ_CACHE.store(
5281 mspi_fast_clk_config_frequency(clocks, config),
5282 ::core::sync::atomic::Ordering::Release,
5283 );
5284 }
5285 }
5286 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
5287 if let Some(config) = clocks.apb_clk {
5288 APB_CLK_FREQ_CACHE.store(
5289 apb_clk_config_frequency(clocks, config),
5290 ::core::sync::atomic::Ordering::Release,
5291 );
5292 }
5293 }
5294 };
5295}
5296#[macro_export]
5300#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5301macro_rules! implement_peripheral_clocks {
5302 () => {
5303 #[doc(hidden)]
5304 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5305 #[repr(u8)]
5306 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5307 pub enum Peripheral {
5308 Aes,
5310 AhbGdma,
5312 ApbSarAdc,
5314 Ds,
5316 Ecc,
5318 Etm,
5320 GpioSd,
5322 Hmac,
5324 I2cExt0,
5326 I2s0,
5328 Ledc,
5330 Mcpwm0,
5332 ParlIo,
5334 Pcnt,
5336 Rmt,
5338 Rsa,
5340 SdioSlave,
5342 Sha,
5344 Spi2,
5346 Systimer,
5348 Timg0,
5350 Timg1,
5352 Trace0,
5354 Tsens,
5356 Twai0,
5358 Twai1,
5360 Uart0,
5362 Uart1,
5364 Uhci0,
5366 UsbDevice,
5368 }
5369 impl Peripheral {
5370 const KEEP_ENABLED: &[Peripheral] = &[
5371 Self::ApbSarAdc,
5372 Self::Systimer,
5373 Self::Timg0,
5374 Self::Uart0,
5375 Self::UsbDevice,
5376 ];
5377 const COUNT: usize = Self::ALL.len();
5378 const ALL: &[Self] = &[
5379 Self::Aes,
5380 Self::AhbGdma,
5381 Self::ApbSarAdc,
5382 Self::Ds,
5383 Self::Ecc,
5384 Self::Etm,
5385 Self::GpioSd,
5386 Self::Hmac,
5387 Self::I2cExt0,
5388 Self::I2s0,
5389 Self::Ledc,
5390 Self::Mcpwm0,
5391 Self::ParlIo,
5392 Self::Pcnt,
5393 Self::Rmt,
5394 Self::Rsa,
5395 Self::SdioSlave,
5396 Self::Sha,
5397 Self::Spi2,
5398 Self::Systimer,
5399 Self::Timg0,
5400 Self::Timg1,
5401 Self::Trace0,
5402 Self::Tsens,
5403 Self::Twai0,
5404 Self::Twai1,
5405 Self::Uart0,
5406 Self::Uart1,
5407 Self::Uhci0,
5408 Self::UsbDevice,
5409 ];
5410 }
5411 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
5412 match peripheral {
5413 Peripheral::Aes => {
5414 crate::peripherals::SYSTEM::regs()
5415 .aes_conf()
5416 .modify(|_, w| w.aes_clk_en().bit(enable));
5417 }
5418 Peripheral::AhbGdma => {
5419 crate::peripherals::SYSTEM::regs()
5420 .gdma_conf()
5421 .modify(|_, w| w.gdma_clk_en().bit(enable));
5422 }
5423 Peripheral::ApbSarAdc => {
5424 crate::peripherals::SYSTEM::regs()
5425 .saradc_conf()
5426 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
5427 }
5428 Peripheral::Ds => {
5429 crate::peripherals::SYSTEM::regs()
5430 .ds_conf()
5431 .modify(|_, w| w.ds_clk_en().bit(enable));
5432 }
5433 Peripheral::Ecc => {
5434 crate::peripherals::SYSTEM::regs()
5435 .ecc_conf()
5436 .modify(|_, w| w.ecc_clk_en().bit(enable));
5437 }
5438 Peripheral::Etm => {
5439 crate::peripherals::SYSTEM::regs()
5440 .etm_conf()
5441 .modify(|_, w| w.etm_clk_en().bit(enable));
5442 }
5443 Peripheral::GpioSd => {
5444 crate::peripherals::GPIO_SD::regs()
5445 .clock_gate()
5446 .modify(|_, w| w.clk_en().bit(enable));
5447 }
5448 Peripheral::Hmac => {
5449 crate::peripherals::SYSTEM::regs()
5450 .hmac_conf()
5451 .modify(|_, w| w.hmac_clk_en().bit(enable));
5452 }
5453 Peripheral::I2cExt0 => {
5454 crate::peripherals::SYSTEM::regs()
5455 .i2c0_conf()
5456 .modify(|_, w| w.i2c0_clk_en().bit(enable));
5457 }
5458 Peripheral::I2s0 => {
5459 crate::peripherals::SYSTEM::regs()
5460 .i2s_conf()
5461 .modify(|_, w| w.i2s_clk_en().bit(enable));
5462 }
5463 Peripheral::Ledc => {
5464 crate::peripherals::SYSTEM::regs()
5465 .ledc_conf()
5466 .modify(|_, w| w.ledc_clk_en().bit(enable));
5467 }
5468 Peripheral::Mcpwm0 => {
5469 crate::peripherals::SYSTEM::regs()
5470 .pwm_conf()
5471 .modify(|_, w| w.pwm_clk_en().bit(enable));
5472 }
5473 Peripheral::ParlIo => {
5474 crate::peripherals::SYSTEM::regs()
5475 .parl_io_conf()
5476 .modify(|_, w| w.parl_clk_en().bit(enable));
5477 }
5478 Peripheral::Pcnt => {
5479 crate::peripherals::SYSTEM::regs()
5480 .pcnt_conf()
5481 .modify(|_, w| w.pcnt_clk_en().bit(enable));
5482 }
5483 Peripheral::Rmt => {
5484 crate::peripherals::SYSTEM::regs()
5485 .rmt_conf()
5486 .modify(|_, w| w.rmt_clk_en().bit(enable));
5487 }
5488 Peripheral::Rsa => {
5489 crate::peripherals::SYSTEM::regs()
5490 .rsa_conf()
5491 .modify(|_, w| w.rsa_clk_en().bit(enable));
5492 }
5493 Peripheral::SdioSlave => {
5494 crate::peripherals::SYSTEM::regs()
5495 .sdio_slave_conf()
5496 .modify(|_, w| w.sdio_slave_clk_en().bit(enable));
5497 }
5498 Peripheral::Sha => {
5499 crate::peripherals::SYSTEM::regs()
5500 .sha_conf()
5501 .modify(|_, w| w.sha_clk_en().bit(enable));
5502 }
5503 Peripheral::Spi2 => {
5504 crate::peripherals::SYSTEM::regs()
5505 .spi2_conf()
5506 .modify(|_, w| w.spi2_clk_en().bit(enable));
5507 }
5508 Peripheral::Systimer => {
5509 crate::peripherals::SYSTEM::regs()
5510 .systimer_conf()
5511 .modify(|_, w| w.systimer_clk_en().bit(enable));
5512 }
5513 Peripheral::Timg0 => {
5514 crate::peripherals::SYSTEM::regs()
5515 .timergroup(0)
5516 .conf()
5517 .modify(|_, w| w.clk_en().bit(enable));
5518 }
5519 Peripheral::Timg1 => {
5520 crate::peripherals::SYSTEM::regs()
5521 .timergroup(1)
5522 .conf()
5523 .modify(|_, w| w.clk_en().bit(enable));
5524 }
5525 Peripheral::Trace0 => {
5526 crate::peripherals::SYSTEM::regs()
5527 .trace_conf()
5528 .modify(|_, w| w.trace_clk_en().bit(enable));
5529 }
5530 Peripheral::Tsens => {
5531 crate::peripherals::SYSTEM::regs()
5532 .tsens_clk_conf()
5533 .modify(|_, w| w.tsens_clk_en().bit(enable));
5534 }
5535 Peripheral::Twai0 => {
5536 crate::peripherals::SYSTEM::regs()
5537 .twai0_conf()
5538 .modify(|_, w| w.twai0_clk_en().bit(enable));
5539 crate::peripherals::SYSTEM::regs()
5540 .twai0_func_clk_conf()
5541 .modify(|_, w| w.twai0_func_clk_en().bit(enable));
5542 }
5543 Peripheral::Twai1 => {
5544 crate::peripherals::SYSTEM::regs()
5545 .twai1_conf()
5546 .modify(|_, w| w.twai1_clk_en().bit(enable));
5547 crate::peripherals::SYSTEM::regs()
5548 .twai1_func_clk_conf()
5549 .modify(|_, w| w.twai1_func_clk_en().bit(enable));
5550 }
5551 Peripheral::Uart0 => {
5552 crate::peripherals::SYSTEM::regs()
5553 .uart(0)
5554 .conf()
5555 .modify(|_, w| w.clk_en().bit(enable));
5556 }
5557 Peripheral::Uart1 => {
5558 crate::peripherals::SYSTEM::regs()
5559 .uart(1)
5560 .conf()
5561 .modify(|_, w| w.clk_en().bit(enable));
5562 }
5563 Peripheral::Uhci0 => {
5564 crate::peripherals::SYSTEM::regs()
5565 .uhci_conf()
5566 .modify(|_, w| w.uhci_clk_en().bit(enable));
5567 }
5568 Peripheral::UsbDevice => {
5569 crate::peripherals::SYSTEM::regs()
5570 .usb_device_conf()
5571 .modify(|_, w| w.usb_device_clk_en().bit(enable));
5572 }
5573 }
5574 }
5575 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
5576 match peripheral {
5577 Peripheral::Aes => {
5578 crate::peripherals::SYSTEM::regs()
5579 .aes_conf()
5580 .modify(|_, w| w.aes_rst_en().bit(reset));
5581 }
5582 Peripheral::AhbGdma => {
5583 crate::peripherals::SYSTEM::regs()
5584 .gdma_conf()
5585 .modify(|_, w| w.gdma_rst_en().bit(reset));
5586 }
5587 Peripheral::ApbSarAdc => {
5588 crate::peripherals::SYSTEM::regs()
5589 .saradc_conf()
5590 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
5591 }
5592 Peripheral::Ds => {
5593 crate::peripherals::SYSTEM::regs()
5594 .ds_conf()
5595 .modify(|_, w| w.ds_rst_en().bit(reset));
5596 }
5597 Peripheral::Ecc => {
5598 crate::peripherals::SYSTEM::regs()
5599 .ecc_conf()
5600 .modify(|_, w| w.ecc_rst_en().bit(reset));
5601 }
5602 Peripheral::Etm => {
5603 crate::peripherals::SYSTEM::regs()
5604 .etm_conf()
5605 .modify(|_, w| w.etm_rst_en().bit(reset));
5606 }
5607 Peripheral::GpioSd => {
5608 let _ = reset;
5609 }
5610 Peripheral::Hmac => {
5611 crate::peripherals::SYSTEM::regs()
5612 .hmac_conf()
5613 .modify(|_, w| w.hmac_rst_en().bit(reset));
5614 }
5615 Peripheral::I2cExt0 => {
5616 crate::peripherals::SYSTEM::regs()
5617 .i2c0_conf()
5618 .modify(|_, w| w.i2c0_rst_en().bit(reset));
5619 }
5620 Peripheral::I2s0 => {
5621 crate::peripherals::SYSTEM::regs()
5622 .i2s_conf()
5623 .modify(|_, w| w.i2s_rst_en().bit(reset));
5624 }
5625 Peripheral::Ledc => {
5626 crate::peripherals::SYSTEM::regs()
5627 .ledc_conf()
5628 .modify(|_, w| w.ledc_rst_en().bit(reset));
5629 }
5630 Peripheral::Mcpwm0 => {
5631 crate::peripherals::SYSTEM::regs()
5632 .pwm_conf()
5633 .modify(|_, w| w.pwm_rst_en().bit(reset));
5634 }
5635 Peripheral::ParlIo => {
5636 crate::peripherals::SYSTEM::regs()
5637 .parl_io_conf()
5638 .modify(|_, w| w.parl_rst_en().bit(reset));
5639 }
5640 Peripheral::Pcnt => {
5641 crate::peripherals::SYSTEM::regs()
5642 .pcnt_conf()
5643 .modify(|_, w| w.pcnt_rst_en().bit(reset));
5644 }
5645 Peripheral::Rmt => {
5646 crate::peripherals::SYSTEM::regs()
5647 .rmt_conf()
5648 .modify(|_, w| w.rmt_rst_en().bit(reset));
5649 }
5650 Peripheral::Rsa => {
5651 crate::peripherals::SYSTEM::regs()
5652 .rsa_conf()
5653 .modify(|_, w| w.rsa_rst_en().bit(reset));
5654 }
5655 Peripheral::SdioSlave => {
5656 crate::peripherals::SYSTEM::regs()
5657 .sdio_slave_conf()
5658 .modify(|_, w| w.sdio_slave_rst_en().bit(reset));
5659 }
5660 Peripheral::Sha => {
5661 crate::peripherals::SYSTEM::regs()
5662 .sha_conf()
5663 .modify(|_, w| w.sha_rst_en().bit(reset));
5664 }
5665 Peripheral::Spi2 => {
5666 crate::peripherals::SYSTEM::regs()
5667 .spi2_conf()
5668 .modify(|_, w| w.spi2_rst_en().bit(reset));
5669 }
5670 Peripheral::Systimer => {
5671 crate::peripherals::SYSTEM::regs()
5672 .systimer_conf()
5673 .modify(|_, w| w.systimer_rst_en().bit(reset));
5674 }
5675 Peripheral::Timg0 => {
5676 crate::peripherals::SYSTEM::regs()
5677 .timergroup(0)
5678 .conf()
5679 .modify(|_, w| w.rst_en().bit(reset));
5680 }
5681 Peripheral::Timg1 => {
5682 crate::peripherals::SYSTEM::regs()
5683 .timergroup(1)
5684 .conf()
5685 .modify(|_, w| w.rst_en().bit(reset));
5686 }
5687 Peripheral::Trace0 => {
5688 crate::peripherals::SYSTEM::regs()
5689 .trace_conf()
5690 .modify(|_, w| w.trace_rst_en().bit(reset));
5691 }
5692 Peripheral::Tsens => {
5693 crate::peripherals::SYSTEM::regs()
5694 .tsens_clk_conf()
5695 .modify(|_, w| w.tsens_rst_en().bit(reset));
5696 }
5697 Peripheral::Twai0 => {
5698 crate::peripherals::SYSTEM::regs()
5699 .twai0_conf()
5700 .modify(|_, w| w.twai0_rst_en().bit(reset));
5701 }
5702 Peripheral::Twai1 => {
5703 crate::peripherals::SYSTEM::regs()
5704 .twai1_conf()
5705 .modify(|_, w| w.twai1_rst_en().bit(reset));
5706 }
5707 Peripheral::Uart0 => {
5708 crate::peripherals::SYSTEM::regs()
5709 .uart(0)
5710 .conf()
5711 .modify(|_, w| w.rst_en().bit(reset));
5712 }
5713 Peripheral::Uart1 => {
5714 crate::peripherals::SYSTEM::regs()
5715 .uart(1)
5716 .conf()
5717 .modify(|_, w| w.rst_en().bit(reset));
5718 }
5719 Peripheral::Uhci0 => {
5720 crate::peripherals::SYSTEM::regs()
5721 .uhci_conf()
5722 .modify(|_, w| w.uhci_rst_en().bit(reset));
5723 }
5724 Peripheral::UsbDevice => {
5725 crate::peripherals::SYSTEM::regs()
5726 .usb_device_conf()
5727 .modify(|_, w| w.usb_device_rst_en().bit(reset));
5728 }
5729 }
5730 }
5731 };
5732}
5733#[macro_export]
5741#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5742macro_rules! memory_range {
5743 ("DRAM") => {
5744 0x40800000..0x40880000
5745 };
5746 (size as str, "DRAM") => {
5747 "524288"
5748 };
5749 ("DRAM2_UNINIT") => {
5750 0x4086E610..0x4087E610
5751 };
5752 (size as str, "DRAM2_UNINIT") => {
5753 "65536"
5754 };
5755 ("IROM") => {
5756 0x42000000..0x43000000
5757 };
5758 (size as str, "IROM") => {
5759 "16777216"
5760 };
5761 ("DROM") => {
5762 0x42000000..0x43000000
5763 };
5764 (size as str, "DROM") => {
5765 "16777216"
5766 };
5767}
5768#[macro_export]
5785#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5786macro_rules! for_each_i2c_master {
5787 ($($pattern:tt => $code:tt;)*) => {
5788 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
5789 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
5790 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
5791 I2CEXT0_SDA)));
5792 };
5793}
5794#[macro_export]
5821#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5822macro_rules! for_each_i2s {
5823 ($($pattern:tt => $code:tt;)*) => {
5824 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
5825 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
5826 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
5827 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
5828 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
5829 true, true, false)));
5830 };
5831}
5832#[macro_export]
5851#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5852macro_rules! for_each_uart {
5853 ($($pattern:tt => $code:tt;)*) => {
5854 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
5855 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
5856 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
5857 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
5858 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
5859 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
5860 };
5861}
5862#[macro_export]
5884#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5885macro_rules! for_each_spi_master {
5886 ($($pattern:tt => $code:tt;)*) => {
5887 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
5888 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
5889 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
5890 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
5891 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
5892 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
5893 };
5894}
5895#[macro_export]
5912#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5913macro_rules! for_each_spi_slave {
5914 ($($pattern:tt => $code:tt;)*) => {
5915 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
5916 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
5917 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
5918 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
5919 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
5920 };
5921}
5922#[macro_export]
5945#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5946macro_rules! for_each_pcnt_unit {
5947 ($($pattern:tt => $code:tt;)*) => {
5948 macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
5949 => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
5950 _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
5951 _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
5952 _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
5953 _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
5954 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
5955 _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
5956 PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
5957 _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
5958 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
5959 _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
5960 PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
5961 _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
5962 _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
5963 (PCNT0_UNIT3))); _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt,
5964 PCNT, 0, PCNT, PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1),
5965 (PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1,
5966 PCNT1_CTRL_CH0, PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
5967 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3,
5968 Pcnt0Unit3, Pcnt, PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0,
5969 PCNT3_CTRL_CH1))); _for_each_inner_pcnt_unit!((interrupt(PCNT)));
5970 _for_each_inner_pcnt_unit!((regs(PCNT)));
5971 };
5972}
5973#[macro_export]
5974#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5975macro_rules! for_each_peripheral {
5976 ($($pattern:tt => $code:tt;)*) => {
5977 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
5978 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
5979 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
5980 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
5981 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5982 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
5983 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
5984 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5985 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5986 "<section class=\"warning\">"] #[doc =
5987 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5988 #[doc = "<ul>"] #[doc =
5989 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5990 =
5991 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5992 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
5993 _for_each_inner_peripheral!((@ peri_type #[doc =
5994 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5995 "<section class=\"warning\">"] #[doc =
5996 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5997 #[doc = "<ul>"] #[doc =
5998 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5999 =
6000 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6001 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
6002 _for_each_inner_peripheral!((@ peri_type #[doc =
6003 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6004 "<section class=\"warning\">"] #[doc =
6005 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6006 #[doc = "<ul>"] #[doc =
6007 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6008 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
6009 _for_each_inner_peripheral!((@ peri_type #[doc =
6010 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6011 "<section class=\"warning\">"] #[doc =
6012 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6013 #[doc = "<ul>"] #[doc =
6014 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6015 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
6016 _for_each_inner_peripheral!((@ peri_type #[doc =
6017 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6018 "<section class=\"warning\">"] #[doc =
6019 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6020 #[doc = "<ul>"] #[doc =
6021 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6022 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
6023 _for_each_inner_peripheral!((@ peri_type #[doc =
6024 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6025 "<section class=\"warning\">"] #[doc =
6026 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6027 #[doc = "<ul>"] #[doc =
6028 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6029 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
6030 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
6031 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6032 "GPIO11 peripheral singleton"] GPIO11 <= virtual()));
6033 _for_each_inner_peripheral!((@ peri_type #[doc =
6034 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6035 "<section class=\"warning\">"] #[doc =
6036 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6037 #[doc = "<ul>"] #[doc =
6038 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6039 #[doc = "</section>"] GPIO12 <= virtual())); _for_each_inner_peripheral!((@
6040 peri_type #[doc = "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""]
6041 #[doc = "<section class=\"warning\">"] #[doc =
6042 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6043 #[doc = "<ul>"] #[doc =
6044 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6045 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
6046 peri_type #[doc = "GPIO14 peripheral singleton"] GPIO14 <= virtual()));
6047 _for_each_inner_peripheral!((@ peri_type #[doc =
6048 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6049 "<section class=\"warning\">"] #[doc =
6050 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6051 #[doc = "<ul>"] #[doc =
6052 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6053 = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
6054 _for_each_inner_peripheral!((@ peri_type #[doc =
6055 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6056 "<section class=\"warning\">"] #[doc =
6057 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6058 #[doc = "<ul>"] #[doc =
6059 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6060 = "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
6061 _for_each_inner_peripheral!((@ peri_type #[doc =
6062 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6063 "<section class=\"warning\">"] #[doc =
6064 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6065 #[doc = "<ul>"] #[doc =
6066 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6067 = "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
6068 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO18 peripheral singleton"]
6069 GPIO18 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6070 "GPIO19 peripheral singleton"] GPIO19 <= virtual()));
6071 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO20 peripheral singleton"]
6072 GPIO20 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6073 "GPIO21 peripheral singleton"] GPIO21 <= virtual()));
6074 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
6075 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
6076 "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
6077 _for_each_inner_peripheral!((@ peri_type #[doc =
6078 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6079 "<section class=\"warning\">"] #[doc =
6080 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6081 #[doc = "<ul>"] #[doc =
6082 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6083 "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()));
6084 _for_each_inner_peripheral!((@ peri_type #[doc =
6085 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6086 "<section class=\"warning\">"] #[doc =
6087 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6088 #[doc = "<ul>"] #[doc =
6089 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6090 "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
6091 _for_each_inner_peripheral!((@ peri_type #[doc =
6092 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6093 "<section class=\"warning\">"] #[doc =
6094 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6095 #[doc = "<ul>"] #[doc =
6096 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6097 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()));
6098 _for_each_inner_peripheral!((@ peri_type #[doc =
6099 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6100 "<section class=\"warning\">"] #[doc =
6101 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6102 #[doc = "<ul>"] #[doc =
6103 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6104 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()));
6105 _for_each_inner_peripheral!((@ peri_type #[doc =
6106 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6107 "<section class=\"warning\">"] #[doc =
6108 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6109 #[doc = "<ul>"] #[doc =
6110 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6111 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
6112 _for_each_inner_peripheral!((@ peri_type #[doc =
6113 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6114 "<section class=\"warning\">"] #[doc =
6115 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6116 #[doc = "<ul>"] #[doc =
6117 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6118 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()));
6119 _for_each_inner_peripheral!((@ peri_type #[doc =
6120 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6121 "<section class=\"warning\">"] #[doc =
6122 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6123 #[doc = "<ul>"] #[doc =
6124 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6125 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()));
6126 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
6127 DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
6128 disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
6129 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
6130 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
6131 DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
6132 disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
6133 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
6134 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH2 peripheral singleton"]
6135 DMA_CH2 <= virtual(DMA_IN_CH2 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
6136 disable_dma_in_interrupt }, DMA_OUT_CH2 : { bind_dma_out_interrupt,
6137 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
6138 _for_each_inner_peripheral!((@ peri_type #[doc =
6139 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)));
6140 _for_each_inner_peripheral!((@ peri_type #[doc =
6141 "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
6142 _for_each_inner_peripheral!((@ peri_type #[doc =
6143 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
6144 _for_each_inner_peripheral!((@ peri_type #[doc =
6145 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
6146 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
6147 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6148 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
6149 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
6150 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6151 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
6152 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
6153 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6154 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6155 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
6156 _for_each_inner_peripheral!((@ peri_type #[doc =
6157 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
6158 _for_each_inner_peripheral!((@ peri_type #[doc = "ATOMIC peripheral singleton"]
6159 ATOMIC <= ATOMIC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6160 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)));
6161 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
6162 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6163 "DS peripheral singleton"] DS <= DS() (unstable)));
6164 _for_each_inner_peripheral!((@ peri_type #[doc = "ECC peripheral singleton"] ECC
6165 <= ECC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6166 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
6167 _for_each_inner_peripheral!((@ peri_type #[doc = "EXTMEM peripheral singleton"]
6168 EXTMEM <= EXTMEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6169 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
6170 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
6171 GPIO_SD <= GPIO_SD() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6172 = "HINF peripheral singleton"] HINF <= HINF() (unstable)));
6173 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
6174 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6175 "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
6176 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
6177 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6178 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
6179 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
6180 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
6181 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6182 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
6183 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
6184 _for_each_inner_peripheral!((@ peri_type #[doc =
6185 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
6186 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
6187 _for_each_inner_peripheral!((@ peri_type #[doc =
6188 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
6189 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6190 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
6191 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
6192 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6193 "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)));
6194 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_ANA peripheral singleton"]
6195 LP_ANA <= LP_ANA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6196 "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)));
6197 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM peripheral singleton"]
6198 LP_APM <= LP_APM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6199 "LP_APM0 peripheral singleton"] LP_APM0 <= LP_APM0() (unstable)));
6200 _for_each_inner_peripheral!((@ peri_type #[doc =
6201 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
6202 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
6203 LP_I2C0 <= LP_I2C0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6204 = "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
6205 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6206 "LP_IO peripheral singleton"] LP_IO <= LP_IO() (unstable)));
6207 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
6208 LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6209 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
6210 _for_each_inner_peripheral!((@ peri_type #[doc =
6211 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
6212 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_UART peripheral singleton"]
6213 LP_UART <= LP_UART() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6214 = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)));
6215 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
6216 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6217 = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
6218 _for_each_inner_peripheral!((@ peri_type #[doc =
6219 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
6220 _for_each_inner_peripheral!((@ peri_type #[doc =
6221 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
6222 _for_each_inner_peripheral!((@ peri_type #[doc =
6223 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
6224 _for_each_inner_peripheral!((@ peri_type #[doc =
6225 "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)));
6226 _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
6227 PARL_IO <= PARL_IO(PARL_IO : { bind_peri_interrupt, enable_peri_interrupt,
6228 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
6229 #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
6230 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
6231 PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
6232 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
6233 #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)));
6234 _for_each_inner_peripheral!((@ peri_type #[doc = "PLIC_MX peripheral singleton"]
6235 PLIC_MX <= PLIC_MX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6236 = "PMU peripheral singleton"] PMU <= PMU() (unstable)));
6237 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
6238 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6239 "RNG peripheral singleton"] RNG <= LP_PERI() (unstable)));
6240 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
6241 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6242 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6243 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
6244 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
6245 _for_each_inner_peripheral!((@ peri_type #[doc = "SLCHOST peripheral singleton"]
6246 SLCHOST <= SLCHOST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6247 = "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)));
6248 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
6249 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6250 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
6251 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
6252 SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
6253 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6254 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)));
6255 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
6256 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
6257 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)));
6258 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
6259 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6260 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
6261 _for_each_inner_peripheral!((@ peri_type #[doc = "TRACE0 peripheral singleton"]
6262 TRACE0 <= TRACE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6263 "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)));
6264 _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI1 peripheral singleton"]
6265 TWAI1 <= TWAI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6266 "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
6267 enable_peri_interrupt, disable_peri_interrupt })));
6268 _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
6269 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
6270 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
6271 "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
6272 _for_each_inner_peripheral!((@ peri_type #[doc =
6273 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6274 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6275 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6276 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
6277 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
6278 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
6279 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
6280 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
6281 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
6282 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6283 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
6284 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_CORE peripheral singleton"]
6285 LP_CORE <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
6286 = "TSENS peripheral singleton"] TSENS <= virtual() (unstable)));
6287 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
6288 WIFI <= virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt,
6289 disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
6290 disable_mac_interrupt }, MODEM_PERI_TIMEOUT : {
6291 bind_modem_peri_timeout_interrupt, enable_modem_peri_timeout_interrupt,
6292 disable_modem_peri_timeout_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
6293 enable_pwr_interrupt, disable_pwr_interrupt }))); _for_each_inner_peripheral!((@
6294 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
6295 virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
6296 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
6297 _for_each_inner_peripheral!((@ peri_type #[doc =
6298 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
6299 _for_each_inner_peripheral!((@ peri_type #[doc =
6300 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
6301 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
6302 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
6303 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
6304 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
6305 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
6306 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
6307 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
6308 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
6309 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
6310 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
6311 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
6312 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
6313 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
6314 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
6315 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
6316 _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
6317 _for_each_inner_peripheral!((GPIO30));
6318 _for_each_inner_peripheral!((DMA_CH0(unstable)));
6319 _for_each_inner_peripheral!((DMA_CH1(unstable)));
6320 _for_each_inner_peripheral!((DMA_CH2(unstable)));
6321 _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
6322 _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
6323 _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
6324 _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
6325 _for_each_inner_peripheral!((SDM_CH0(unstable)));
6326 _for_each_inner_peripheral!((SDM_CH1(unstable)));
6327 _for_each_inner_peripheral!((SDM_CH2(unstable)));
6328 _for_each_inner_peripheral!((SDM_CH3(unstable)));
6329 _for_each_inner_peripheral!((AES(unstable)));
6330 _for_each_inner_peripheral!((APB_SARADC(unstable)));
6331 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
6332 _for_each_inner_peripheral!((ATOMIC(unstable)));
6333 _for_each_inner_peripheral!((DMA(unstable)));
6334 _for_each_inner_peripheral!((DS(unstable)));
6335 _for_each_inner_peripheral!((ECC(unstable)));
6336 _for_each_inner_peripheral!((EXTMEM(unstable)));
6337 _for_each_inner_peripheral!((GPIO(unstable)));
6338 _for_each_inner_peripheral!((GPIO_SD(unstable)));
6339 _for_each_inner_peripheral!((HINF(unstable)));
6340 _for_each_inner_peripheral!((HMAC(unstable)));
6341 _for_each_inner_peripheral!((HP_APM(unstable)));
6342 _for_each_inner_peripheral!((HP_SYS(unstable)));
6343 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
6344 _for_each_inner_peripheral!((I2C0));
6345 _for_each_inner_peripheral!((I2S0(unstable)));
6346 _for_each_inner_peripheral!((IEEE802154(unstable)));
6347 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
6348 _for_each_inner_peripheral!((INTPRI(unstable)));
6349 _for_each_inner_peripheral!((IO_MUX(unstable)));
6350 _for_each_inner_peripheral!((LEDC(unstable)));
6351 _for_each_inner_peripheral!((LP_ANA(unstable)));
6352 _for_each_inner_peripheral!((LP_AON(unstable)));
6353 _for_each_inner_peripheral!((LP_APM(unstable)));
6354 _for_each_inner_peripheral!((LP_APM0(unstable)));
6355 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
6356 _for_each_inner_peripheral!((LP_I2C0(unstable)));
6357 _for_each_inner_peripheral!((LP_I2C_ANA_MST(unstable)));
6358 _for_each_inner_peripheral!((LP_IO(unstable)));
6359 _for_each_inner_peripheral!((LP_PERI(unstable)));
6360 _for_each_inner_peripheral!((LP_TEE(unstable)));
6361 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
6362 _for_each_inner_peripheral!((LP_UART(unstable)));
6363 _for_each_inner_peripheral!((LP_WDT(unstable)));
6364 _for_each_inner_peripheral!((LPWR(unstable)));
6365 _for_each_inner_peripheral!((MCPWM0(unstable)));
6366 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
6367 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
6368 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
6369 _for_each_inner_peripheral!((OTP_DEBUG(unstable)));
6370 _for_each_inner_peripheral!((PARL_IO(unstable)));
6371 _for_each_inner_peripheral!((PAU(unstable)));
6372 _for_each_inner_peripheral!((PCNT(unstable)));
6373 _for_each_inner_peripheral!((PCR(unstable)));
6374 _for_each_inner_peripheral!((PLIC_MX(unstable)));
6375 _for_each_inner_peripheral!((PMU(unstable)));
6376 _for_each_inner_peripheral!((RMT(unstable)));
6377 _for_each_inner_peripheral!((RNG(unstable)));
6378 _for_each_inner_peripheral!((RSA(unstable)));
6379 _for_each_inner_peripheral!((SHA(unstable)));
6380 _for_each_inner_peripheral!((SLCHOST(unstable)));
6381 _for_each_inner_peripheral!((ETM(unstable)));
6382 _for_each_inner_peripheral!((SPI0(unstable)));
6383 _for_each_inner_peripheral!((SPI1(unstable)));
6384 _for_each_inner_peripheral!((SPI2));
6385 _for_each_inner_peripheral!((SYSTEM(unstable)));
6386 _for_each_inner_peripheral!((SYSTIMER(unstable)));
6387 _for_each_inner_peripheral!((TEE(unstable)));
6388 _for_each_inner_peripheral!((TIMG0(unstable)));
6389 _for_each_inner_peripheral!((TIMG1(unstable)));
6390 _for_each_inner_peripheral!((TRACE0(unstable)));
6391 _for_each_inner_peripheral!((TWAI0(unstable)));
6392 _for_each_inner_peripheral!((TWAI1(unstable)));
6393 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
6394 _for_each_inner_peripheral!((UHCI0(unstable)));
6395 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
6396 _for_each_inner_peripheral!((ADC1(unstable)));
6397 _for_each_inner_peripheral!((BT(unstable)));
6398 _for_each_inner_peripheral!((FLASH(unstable)));
6399 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
6400 _for_each_inner_peripheral!((LP_CORE(unstable)));
6401 _for_each_inner_peripheral!((TSENS(unstable)));
6402 _for_each_inner_peripheral!((WIFI));
6403 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
6404 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
6405 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
6406 _for_each_inner_peripheral!((SPI2, Spi2, 0, AhbGdmaChannel));
6407 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
6408 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
6409 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
6410 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
6411 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
6412 _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
6413 _for_each_inner_peripheral!((all(@ peri_type #[doc =
6414 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
6415 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
6416 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
6417 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
6418 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6419 "<section class=\"warning\">"] #[doc =
6420 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6421 #[doc = "<ul>"] #[doc =
6422 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6423 =
6424 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6425 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
6426 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6427 "<section class=\"warning\">"] #[doc =
6428 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6429 #[doc = "<ul>"] #[doc =
6430 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6431 =
6432 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6433 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
6434 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6435 "<section class=\"warning\">"] #[doc =
6436 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6437 #[doc = "<ul>"] #[doc =
6438 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6439 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
6440 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6441 "<section class=\"warning\">"] #[doc =
6442 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6443 #[doc = "<ul>"] #[doc =
6444 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
6445 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
6446 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6447 "<section class=\"warning\">"] #[doc =
6448 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6449 #[doc = "<ul>"] #[doc =
6450 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6451 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
6452 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6453 "<section class=\"warning\">"] #[doc =
6454 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6455 #[doc = "<ul>"] #[doc =
6456 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6457 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
6458 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
6459 "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
6460 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6461 "<section class=\"warning\">"] #[doc =
6462 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6463 #[doc = "<ul>"] #[doc =
6464 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6465 #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
6466 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6467 "<section class=\"warning\">"] #[doc =
6468 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6469 #[doc = "<ul>"] #[doc =
6470 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
6471 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
6472 "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
6473 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6474 "<section class=\"warning\">"] #[doc =
6475 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6476 #[doc = "<ul>"] #[doc =
6477 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
6478 = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
6479 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6480 "<section class=\"warning\">"] #[doc =
6481 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6482 #[doc = "<ul>"] #[doc =
6483 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6484 = "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
6485 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6486 "<section class=\"warning\">"] #[doc =
6487 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6488 #[doc = "<ul>"] #[doc =
6489 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
6490 = "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
6491 "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
6492 "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
6493 "GPIO20 peripheral singleton"] GPIO20 <= virtual()), (@ peri_type #[doc =
6494 "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
6495 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
6496 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
6497 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6498 "<section class=\"warning\">"] #[doc =
6499 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6500 #[doc = "<ul>"] #[doc =
6501 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6502 "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
6503 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6504 "<section class=\"warning\">"] #[doc =
6505 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6506 #[doc = "<ul>"] #[doc =
6507 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6508 "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
6509 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6510 "<section class=\"warning\">"] #[doc =
6511 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6512 #[doc = "<ul>"] #[doc =
6513 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6514 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
6515 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6516 "<section class=\"warning\">"] #[doc =
6517 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6518 #[doc = "<ul>"] #[doc =
6519 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6520 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
6521 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6522 "<section class=\"warning\">"] #[doc =
6523 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6524 #[doc = "<ul>"] #[doc =
6525 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6526 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
6527 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6528 "<section class=\"warning\">"] #[doc =
6529 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6530 #[doc = "<ul>"] #[doc =
6531 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6532 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()), (@ peri_type #[doc =
6533 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
6534 "<section class=\"warning\">"] #[doc =
6535 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
6536 #[doc = "<ul>"] #[doc =
6537 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
6538 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()), (@ peri_type #[doc =
6539 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
6540 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6541 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6542 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6543 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
6544 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6545 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6546 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6547 "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
6548 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6549 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6550 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6551 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)), (@
6552 peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual()
6553 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2
6554 <= virtual() (unstable)), (@ peri_type #[doc =
6555 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)), (@
6556 peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
6557 (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
6558 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
6559 SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
6560 "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
6561 #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
6562 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6563 = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
6564 peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
6565 ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "ATOMIC peripheral singleton"]
6566 ATOMIC <= ATOMIC() (unstable)), (@ peri_type #[doc =
6567 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)), (@ peri_type #[doc =
6568 "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@ peri_type #[doc =
6569 "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type #[doc =
6570 "ECC peripheral singleton"] ECC <= ECC() (unstable)), (@ peri_type #[doc =
6571 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc =
6572 "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)), (@ peri_type #[doc
6573 = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
6574 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)), (@ peri_type
6575 #[doc = "HINF peripheral singleton"] HINF <= HINF() (unstable)), (@ peri_type
6576 #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)), (@ peri_type
6577 #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)), (@
6578 peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)),
6579 (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <=
6580 I2C_ANA_MST() (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0
6581 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
6582 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
6583 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
6584 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
6585 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
6586 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
6587 (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
6588 INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
6589 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
6590 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
6591 #[doc = "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type
6592 #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)), (@
6593 peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)),
6594 (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <= LP_APM()
6595 (unstable)), (@ peri_type #[doc = "LP_APM0 peripheral singleton"] LP_APM0 <=
6596 LP_APM0() (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"]
6597 LP_CLKRST <= LP_CLKRST() (unstable)), (@ peri_type #[doc =
6598 "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)), (@ peri_type
6599 #[doc = "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
6600 (unstable)), (@ peri_type #[doc = "LP_IO peripheral singleton"] LP_IO <= LP_IO()
6601 (unstable)), (@ peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <=
6602 LP_PERI() (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE
6603 <= LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
6604 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
6605 "LP_UART peripheral singleton"] LP_UART <= LP_UART() (unstable)), (@ peri_type
6606 #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@
6607 peri_type #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)),
6608 (@ peri_type #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0()
6609 (unstable)), (@ peri_type #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR
6610 <= MEM_MONITOR() (unstable)), (@ peri_type #[doc =
6611 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)), (@
6612 peri_type #[doc = "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <=
6613 MODEM_SYSCON() (unstable)), (@ peri_type #[doc =
6614 "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)), (@
6615 peri_type #[doc = "PARL_IO peripheral singleton"] PARL_IO <= PARL_IO(PARL_IO : {
6616 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6617 (unstable)), (@ peri_type #[doc = "PAU peripheral singleton"] PAU <= PAU()
6618 (unstable)), (@ peri_type #[doc = "PCNT peripheral singleton"] PCNT <= PCNT(PCNT
6619 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6620 (unstable)), (@ peri_type #[doc = "PCR peripheral singleton"] PCR <= PCR()
6621 (unstable)), (@ peri_type #[doc = "PLIC_MX peripheral singleton"] PLIC_MX <=
6622 PLIC_MX() (unstable)), (@ peri_type #[doc = "PMU peripheral singleton"] PMU <=
6623 PMU() (unstable)), (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT()
6624 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= LP_PERI()
6625 (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
6626 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6627 (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
6628 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6629 (unstable)), (@ peri_type #[doc = "SLCHOST peripheral singleton"] SLCHOST <=
6630 SLCHOST() (unstable)), (@ peri_type #[doc = "ETM peripheral singleton"] ETM <=
6631 SOC_ETM() (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <=
6632 SPI0() (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <=
6633 SPI1() (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <=
6634 SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
6635 })), (@ peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR()
6636 (unstable)), (@ peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <=
6637 SYSTIMER() (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <=
6638 TEE() (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <=
6639 TIMG0() (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <=
6640 TIMG1() (unstable)), (@ peri_type #[doc = "TRACE0 peripheral singleton"] TRACE0
6641 <= TRACE() (unstable)), (@ peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0
6642 <= TWAI0() (unstable)), (@ peri_type #[doc = "TWAI1 peripheral singleton"] TWAI1
6643 <= TWAI1() (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0
6644 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
6645 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
6646 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
6647 disable_peri_interrupt })), (@ peri_type #[doc = "UHCI0 peripheral singleton"]
6648 UHCI0 <= UHCI0() (unstable)), (@ peri_type #[doc =
6649 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6650 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6651 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
6652 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
6653 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
6654 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
6655 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
6656 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
6657 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
6658 (@ peri_type #[doc = "LP_CORE peripheral singleton"] LP_CORE <= virtual()
6659 (unstable)), (@ peri_type #[doc = "TSENS peripheral singleton"] TSENS <=
6660 virtual() (unstable)), (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <=
6661 virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt
6662 }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt
6663 }, MODEM_PERI_TIMEOUT : { bind_modem_peri_timeout_interrupt,
6664 enable_modem_peri_timeout_interrupt, disable_modem_peri_timeout_interrupt },
6665 WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt })),
6666 (@ peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
6667 virtual() (unstable)), (@ peri_type #[doc =
6668 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
6669 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
6670 virtual() (unstable)), (@ peri_type #[doc =
6671 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
6672 _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
6673 (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
6674 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
6675 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
6676 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (GPIO29), (GPIO30),
6677 (DMA_CH0(unstable)), (DMA_CH1(unstable)), (DMA_CH2(unstable)),
6678 (PCNT0_UNIT0(unstable)), (PCNT0_UNIT1(unstable)), (PCNT0_UNIT2(unstable)),
6679 (PCNT0_UNIT3(unstable)), (SDM_CH0(unstable)), (SDM_CH1(unstable)),
6680 (SDM_CH2(unstable)), (SDM_CH3(unstable)), (AES(unstable)),
6681 (APB_SARADC(unstable)), (ASSIST_DEBUG(unstable)), (ATOMIC(unstable)),
6682 (DMA(unstable)), (DS(unstable)), (ECC(unstable)), (EXTMEM(unstable)),
6683 (GPIO(unstable)), (GPIO_SD(unstable)), (HINF(unstable)), (HMAC(unstable)),
6684 (HP_APM(unstable)), (HP_SYS(unstable)), (I2C_ANA_MST(unstable)), (I2C0),
6685 (I2S0(unstable)), (IEEE802154(unstable)), (INTERRUPT_CORE0(unstable)),
6686 (INTPRI(unstable)), (IO_MUX(unstable)), (LEDC(unstable)), (LP_ANA(unstable)),
6687 (LP_AON(unstable)), (LP_APM(unstable)), (LP_APM0(unstable)),
6688 (LP_CLKRST(unstable)), (LP_I2C0(unstable)), (LP_I2C_ANA_MST(unstable)),
6689 (LP_IO(unstable)), (LP_PERI(unstable)), (LP_TEE(unstable)),
6690 (RTC_TIMER(unstable)), (LP_UART(unstable)), (LP_WDT(unstable)), (LPWR(unstable)),
6691 (MCPWM0(unstable)), (MEM_MONITOR(unstable)), (MODEM_LPCON(unstable)),
6692 (MODEM_SYSCON(unstable)), (OTP_DEBUG(unstable)), (PARL_IO(unstable)),
6693 (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)), (PLIC_MX(unstable)),
6694 (PMU(unstable)), (RMT(unstable)), (RNG(unstable)), (RSA(unstable)),
6695 (SHA(unstable)), (SLCHOST(unstable)), (ETM(unstable)), (SPI0(unstable)),
6696 (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
6697 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (TRACE0(unstable)),
6698 (TWAI0(unstable)), (TWAI1(unstable)), (UART0), (UART1), (UHCI0(unstable)),
6699 (USB_DEVICE(unstable)), (ADC1(unstable)), (BT(unstable)), (FLASH(unstable)),
6700 (GPIO_DEDICATED(unstable)), (LP_CORE(unstable)), (TSENS(unstable)), (WIFI),
6701 (FROM_CPU_INTR1(unstable)), (FROM_CPU_INTR2(unstable)),
6702 (FROM_CPU_INTR3(unstable)))); _for_each_inner_peripheral!((dma_eligible(SPI2,
6703 Spi2, 0, AhbGdmaChannel), (UHCI0, Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3,
6704 AhbGdmaChannel), (AES, Aes, 6, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel),
6705 (APB_SARADC, ApbSaradc, 8, AhbGdmaChannel), (PARL_IO, ParlIo, 9,
6706 AhbGdmaChannel)));
6707 };
6708}
6709#[macro_export]
6736#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6737macro_rules! for_each_gpio {
6738 ($($pattern:tt => $code:tt;)*) => {
6739 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
6740 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
6741 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
6742 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
6743 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
6744 _for_each_inner_gpio!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
6745 [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
6746 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTCK _2 =>
6747 FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2
6748 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])));
6749 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
6750 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
6751 _for_each_inner_gpio!((10, GPIO10() () ([Input] [Output])));
6752 _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
6753 _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
6754 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
6755 _for_each_inner_gpio!((14, GPIO14() () ([Input] [Output])));
6756 _for_each_inner_gpio!((15, GPIO15() () ([Input] [Output])));
6757 _for_each_inner_gpio!((16, GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0)
6758 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => U0RXD) (_2 =>
6759 FSPICS1) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18(_0 => SDIO_CMD)
6760 (_0 => SDIO_CMD _2 => FSPICS2) ([Input] [Output]))); _for_each_inner_gpio!((19,
6761 GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) ([Input] [Output])));
6762 _for_each_inner_gpio!((20, GPIO20(_0 => SDIO_DATA0) (_0 => SDIO_DATA0 _2 =>
6763 FSPICS4) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21(_0 =>
6764 SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])));
6765 _for_each_inner_gpio!((22, GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) ([Input]
6766 [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 => SDIO_DATA3) (_0 =>
6767 SDIO_DATA3) ([Input] [Output]))); _for_each_inner_gpio!((24, GPIO24() (_0 =>
6768 SPICS0) ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_0 => SPIQ) (_0
6769 => SPIQ) ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_0 => SPIWP) (_0
6770 => SPIWP) ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27() () ([Input]
6771 [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SPIHD) (_0 => SPIHD)
6772 ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() (_0 => SPICLK) ([Input]
6773 [Output]))); _for_each_inner_gpio!((30, GPIO30(_0 => SPID) (_0 => SPID) ([Input]
6774 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
6775 GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
6776 [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 =>
6777 FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP)
6778 (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 =>
6779 FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID)
6780 ([Input] [Output])), (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input]
6781 [Output])), (10, GPIO10() () ([Input] [Output])), (11, GPIO11() () ([Input]
6782 [Output])), (12, GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input]
6783 [Output])), (14, GPIO14() () ([Input] [Output])), (15, GPIO15() () ([Input]
6784 [Output])), (16, GPIO16(_2 => FSPICS0) (_0 => U0TXD _2 => FSPICS0) ([Input]
6785 [Output])), (17, GPIO17(_0 => U0RXD) (_2 => FSPICS1) ([Input] [Output])), (18,
6786 GPIO18(_0 => SDIO_CMD) (_0 => SDIO_CMD _2 => FSPICS2) ([Input] [Output])), (19,
6787 GPIO19() (_0 => SDIO_CLK _2 => FSPICS3) ([Input] [Output])), (20, GPIO20(_0 =>
6788 SDIO_DATA0) (_0 => SDIO_DATA0 _2 => FSPICS4) ([Input] [Output])), (21, GPIO21(_0
6789 => SDIO_DATA1) (_0 => SDIO_DATA1 _2 => FSPICS5) ([Input] [Output])), (22,
6790 GPIO22(_0 => SDIO_DATA2) (_0 => SDIO_DATA2) ([Input] [Output])), (23, GPIO23(_0
6791 => SDIO_DATA3) (_0 => SDIO_DATA3) ([Input] [Output])), (24, GPIO24() (_0 =>
6792 SPICS0) ([Input] [Output])), (25, GPIO25(_0 => SPIQ) (_0 => SPIQ) ([Input]
6793 [Output])), (26, GPIO26(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (27,
6794 GPIO27() () ([Input] [Output])), (28, GPIO28(_0 => SPIHD) (_0 => SPIHD) ([Input]
6795 [Output])), (29, GPIO29() (_0 => SPICLK) ([Input] [Output])), (30, GPIO30(_0 =>
6796 SPID) (_0 => SPID) ([Input] [Output]))));
6797 };
6798}
6799#[macro_export]
6826#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6827macro_rules! for_each_analog_function {
6828 ($($pattern:tt => $code:tt;)*) => {
6829 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
6830 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
6831 _for_each_inner_analog_function!((ADC1_CH0, GPIO0));
6832 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
6833 _for_each_inner_analog_function!((ADC1_CH1, GPIO1));
6834 _for_each_inner_analog_function!((ADC1_CH2, GPIO2));
6835 _for_each_inner_analog_function!((ADC1_CH3, GPIO3));
6836 _for_each_inner_analog_function!((ADC1_CH4, GPIO4));
6837 _for_each_inner_analog_function!((ADC1_CH5, GPIO5));
6838 _for_each_inner_analog_function!((ADC1_CH6, GPIO6));
6839 _for_each_inner_analog_function!((USJ_DM, GPIO12));
6840 _for_each_inner_analog_function!((USJ_DP, GPIO13));
6841 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0));
6842 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1));
6843 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2));
6844 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3));
6845 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4));
6846 _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO5));
6847 _for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO6));
6848 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (ADC1_CH0, GPIO0),
6849 (XTAL_32K_N, GPIO1), (ADC1_CH1, GPIO1), (ADC1_CH2, GPIO2), (ADC1_CH3, GPIO3),
6850 (ADC1_CH4, GPIO4), (ADC1_CH5, GPIO5), (ADC1_CH6, GPIO6), (USJ_DM, GPIO12),
6851 (USJ_DP, GPIO13))); _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0,
6852 ADCn_CHm, 1, 0), GPIO0), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1), ((ADC1_CH2,
6853 ADCn_CHm, 1, 2), GPIO2), ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3), ((ADC1_CH4,
6854 ADCn_CHm, 1, 4), GPIO4), ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO5), ((ADC1_CH6,
6855 ADCn_CHm, 1, 6), GPIO6)));
6856 };
6857}
6858#[macro_export]
6896#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6897macro_rules! for_each_lp_function {
6898 ($($pattern:tt => $code:tt;)*) => {
6899 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
6900 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _0));
6901 _for_each_inner_lp_function!((LP_UART_DTRN, GPIO0, _1));
6902 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _0));
6903 _for_each_inner_lp_function!((LP_UART_DSRN, GPIO1, _1));
6904 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _0));
6905 _for_each_inner_lp_function!((LP_UART_RTSN, GPIO2, _1));
6906 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _0));
6907 _for_each_inner_lp_function!((LP_UART_CTSN, GPIO3, _1));
6908 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _0));
6909 _for_each_inner_lp_function!((LP_UART_RXD, GPIO4, _1));
6910 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _0));
6911 _for_each_inner_lp_function!((LP_UART_TXD, GPIO5, _1));
6912 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _0));
6913 _for_each_inner_lp_function!((LP_I2C_SDA, GPIO6, _1));
6914 _for_each_inner_lp_function!((LP_GPIO7, GPIO7, _0));
6915 _for_each_inner_lp_function!((LP_I2C_SCL, GPIO7, _1));
6916 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, () ()));
6917 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()));
6918 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()));
6919 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()));
6920 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()));
6921 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()));
6922 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()));
6923 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO7, _0, () ()));
6924 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _0), (LP_UART_DTRN, GPIO0,
6925 _1), (LP_GPIO1, GPIO1, _0), (LP_UART_DSRN, GPIO1, _1), (LP_GPIO2, GPIO2, _0),
6926 (LP_UART_RTSN, GPIO2, _1), (LP_GPIO3, GPIO3, _0), (LP_UART_CTSN, GPIO3, _1),
6927 (LP_GPIO4, GPIO4, _0), (LP_UART_RXD, GPIO4, _1), (LP_GPIO5, GPIO5, _0),
6928 (LP_UART_TXD, GPIO5, _1), (LP_GPIO6, GPIO6, _0), (LP_I2C_SDA, GPIO6, _1),
6929 (LP_GPIO7, GPIO7, _0), (LP_I2C_SCL, GPIO7, _1)));
6930 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, ()
6931 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()), ((LP_GPIO2, LP_GPIOn, 2),
6932 GPIO2, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()), ((LP_GPIO4,
6933 LP_GPIOn, 4), GPIO4, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()),
6934 ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()), ((LP_GPIO7, LP_GPIOn, 7), GPIO7, _0,
6935 () ())));
6936 };
6937}
6938#[macro_export]
6969#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6970macro_rules! for_each_iomux_function {
6971 ($($pattern:tt => $code:tt;)*) => {
6972 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
6973 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
6974 _for_each_inner_iomux_function!((MTMS, GPIO4, _0));
6975 _for_each_inner_iomux_function!((FSPIHD, GPIO4, _2));
6976 _for_each_inner_iomux_function!((MTDI, GPIO5, _0));
6977 _for_each_inner_iomux_function!((FSPIWP, GPIO5, _2));
6978 _for_each_inner_iomux_function!((MTCK, GPIO6, _0));
6979 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
6980 _for_each_inner_iomux_function!((MTDO, GPIO7, _0));
6981 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
6982 _for_each_inner_iomux_function!((U0TXD, GPIO16, _0));
6983 _for_each_inner_iomux_function!((FSPICS0, GPIO16, _2));
6984 _for_each_inner_iomux_function!((U0RXD, GPIO17, _0));
6985 _for_each_inner_iomux_function!((FSPICS1, GPIO17, _2));
6986 _for_each_inner_iomux_function!((SDIO_CMD, GPIO18, _0));
6987 _for_each_inner_iomux_function!((FSPICS2, GPIO18, _2));
6988 _for_each_inner_iomux_function!((SDIO_CLK, GPIO19, _0));
6989 _for_each_inner_iomux_function!((FSPICS3, GPIO19, _2));
6990 _for_each_inner_iomux_function!((SDIO_DATA0, GPIO20, _0));
6991 _for_each_inner_iomux_function!((FSPICS4, GPIO20, _2));
6992 _for_each_inner_iomux_function!((SDIO_DATA1, GPIO21, _0));
6993 _for_each_inner_iomux_function!((FSPICS5, GPIO21, _2));
6994 _for_each_inner_iomux_function!((SDIO_DATA2, GPIO22, _0));
6995 _for_each_inner_iomux_function!((SDIO_DATA3, GPIO23, _0));
6996 _for_each_inner_iomux_function!((SPICS0, GPIO24, _0));
6997 _for_each_inner_iomux_function!((SPIQ, GPIO25, _0));
6998 _for_each_inner_iomux_function!((SPIWP, GPIO26, _0));
6999 _for_each_inner_iomux_function!((SPIHD, GPIO28, _0));
7000 _for_each_inner_iomux_function!((SPICLK, GPIO29, _0));
7001 _for_each_inner_iomux_function!((SPID, GPIO30, _0));
7002 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO16, _2));
7003 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO17, _2));
7004 _for_each_inner_iomux_function!(((FSPICS2, FSPICSn, 2), GPIO18, _2));
7005 _for_each_inner_iomux_function!(((FSPICS3, FSPICSn, 3), GPIO19, _2));
7006 _for_each_inner_iomux_function!(((FSPICS4, FSPICSn, 4), GPIO20, _2));
7007 _for_each_inner_iomux_function!(((FSPICS5, FSPICSn, 5), GPIO21, _2));
7008 _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO20, _0));
7009 _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO21, _0));
7010 _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO22, _0));
7011 _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0));
7012 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO24, _0));
7013 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO4, _0),
7014 (FSPIHD, GPIO4, _2), (MTDI, GPIO5, _0), (FSPIWP, GPIO5, _2), (MTCK, GPIO6, _0),
7015 (FSPICLK, GPIO6, _2), (MTDO, GPIO7, _0), (FSPID, GPIO7, _2), (U0TXD, GPIO16, _0),
7016 (FSPICS0, GPIO16, _2), (U0RXD, GPIO17, _0), (FSPICS1, GPIO17, _2), (SDIO_CMD,
7017 GPIO18, _0), (FSPICS2, GPIO18, _2), (SDIO_CLK, GPIO19, _0), (FSPICS3, GPIO19,
7018 _2), (SDIO_DATA0, GPIO20, _0), (FSPICS4, GPIO20, _2), (SDIO_DATA1, GPIO21, _0),
7019 (FSPICS5, GPIO21, _2), (SDIO_DATA2, GPIO22, _0), (SDIO_DATA3, GPIO23, _0),
7020 (SPICS0, GPIO24, _0), (SPIQ, GPIO25, _0), (SPIWP, GPIO26, _0), (SPIHD, GPIO28,
7021 _0), (SPICLK, GPIO29, _0), (SPID, GPIO30, _0)));
7022 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO16, _2),
7023 ((FSPICS1, FSPICSn, 1), GPIO17, _2), ((FSPICS2, FSPICSn, 2), GPIO18, _2),
7024 ((FSPICS3, FSPICSn, 3), GPIO19, _2), ((FSPICS4, FSPICSn, 4), GPIO20, _2),
7025 ((FSPICS5, FSPICSn, 5), GPIO21, _2)));
7026 _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA0, SDIO_DATAn, 0), GPIO20,
7027 _0), ((SDIO_DATA1, SDIO_DATAn, 1), GPIO21, _0), ((SDIO_DATA2, SDIO_DATAn, 2),
7028 GPIO22, _0), ((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0)));
7029 _for_each_inner_iomux_function!((SPICSn((SPICS0, SPICSn, 0), GPIO24, _0)));
7030 };
7031}
7032#[macro_export]
7049#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7050macro_rules! gpio_for_signal {
7051 (XTAL_32K_P $(, $_fallback:literal)?) => {
7052 "GPIO0"
7053 };
7054 (ADC1_CH0 $(, $_fallback:literal)?) => {
7055 "GPIO0"
7056 };
7057 (LP_GPIO0 $(, $_fallback:literal)?) => {
7058 "GPIO0"
7059 };
7060 (LP_UART_DTRN $(, $_fallback:literal)?) => {
7061 "GPIO0"
7062 };
7063 (XTAL_32K_N $(, $_fallback:literal)?) => {
7064 "GPIO1"
7065 };
7066 (ADC1_CH1 $(, $_fallback:literal)?) => {
7067 "GPIO1"
7068 };
7069 (LP_GPIO1 $(, $_fallback:literal)?) => {
7070 "GPIO1"
7071 };
7072 (LP_UART_DSRN $(, $_fallback:literal)?) => {
7073 "GPIO1"
7074 };
7075 (FSPIQ $(, $_fallback:literal)?) => {
7076 "GPIO2"
7077 };
7078 (ADC1_CH2 $(, $_fallback:literal)?) => {
7079 "GPIO2"
7080 };
7081 (LP_GPIO2 $(, $_fallback:literal)?) => {
7082 "GPIO2"
7083 };
7084 (LP_UART_RTSN $(, $_fallback:literal)?) => {
7085 "GPIO2"
7086 };
7087 (ADC1_CH3 $(, $_fallback:literal)?) => {
7088 "GPIO3"
7089 };
7090 (LP_GPIO3 $(, $_fallback:literal)?) => {
7091 "GPIO3"
7092 };
7093 (LP_UART_CTSN $(, $_fallback:literal)?) => {
7094 "GPIO3"
7095 };
7096 (MTMS $(, $_fallback:literal)?) => {
7097 "GPIO4"
7098 };
7099 (FSPIHD $(, $_fallback:literal)?) => {
7100 "GPIO4"
7101 };
7102 (ADC1_CH4 $(, $_fallback:literal)?) => {
7103 "GPIO4"
7104 };
7105 (LP_GPIO4 $(, $_fallback:literal)?) => {
7106 "GPIO4"
7107 };
7108 (LP_UART_RXD $(, $_fallback:literal)?) => {
7109 "GPIO4"
7110 };
7111 (MTDI $(, $_fallback:literal)?) => {
7112 "GPIO5"
7113 };
7114 (FSPIWP $(, $_fallback:literal)?) => {
7115 "GPIO5"
7116 };
7117 (ADC1_CH5 $(, $_fallback:literal)?) => {
7118 "GPIO5"
7119 };
7120 (LP_GPIO5 $(, $_fallback:literal)?) => {
7121 "GPIO5"
7122 };
7123 (LP_UART_TXD $(, $_fallback:literal)?) => {
7124 "GPIO5"
7125 };
7126 (MTCK $(, $_fallback:literal)?) => {
7127 "GPIO6"
7128 };
7129 (FSPICLK $(, $_fallback:literal)?) => {
7130 "GPIO6"
7131 };
7132 (ADC1_CH6 $(, $_fallback:literal)?) => {
7133 "GPIO6"
7134 };
7135 (LP_GPIO6 $(, $_fallback:literal)?) => {
7136 "GPIO6"
7137 };
7138 (LP_I2C_SDA $(, $_fallback:literal)?) => {
7139 "GPIO6"
7140 };
7141 (MTDO $(, $_fallback:literal)?) => {
7142 "GPIO7"
7143 };
7144 (FSPID $(, $_fallback:literal)?) => {
7145 "GPIO7"
7146 };
7147 (LP_GPIO7 $(, $_fallback:literal)?) => {
7148 "GPIO7"
7149 };
7150 (LP_I2C_SCL $(, $_fallback:literal)?) => {
7151 "GPIO7"
7152 };
7153 (USJ_DM $(, $_fallback:literal)?) => {
7154 "GPIO12"
7155 };
7156 (USJ_DP $(, $_fallback:literal)?) => {
7157 "GPIO13"
7158 };
7159 (U0TXD $(, $_fallback:literal)?) => {
7160 "GPIO16"
7161 };
7162 (FSPICS0 $(, $_fallback:literal)?) => {
7163 "GPIO16"
7164 };
7165 (U0RXD $(, $_fallback:literal)?) => {
7166 "GPIO17"
7167 };
7168 (FSPICS1 $(, $_fallback:literal)?) => {
7169 "GPIO17"
7170 };
7171 (SDIO_CMD $(, $_fallback:literal)?) => {
7172 "GPIO18"
7173 };
7174 (FSPICS2 $(, $_fallback:literal)?) => {
7175 "GPIO18"
7176 };
7177 (SDIO_CLK $(, $_fallback:literal)?) => {
7178 "GPIO19"
7179 };
7180 (FSPICS3 $(, $_fallback:literal)?) => {
7181 "GPIO19"
7182 };
7183 (SDIO_DATA0 $(, $_fallback:literal)?) => {
7184 "GPIO20"
7185 };
7186 (FSPICS4 $(, $_fallback:literal)?) => {
7187 "GPIO20"
7188 };
7189 (SDIO_DATA1 $(, $_fallback:literal)?) => {
7190 "GPIO21"
7191 };
7192 (FSPICS5 $(, $_fallback:literal)?) => {
7193 "GPIO21"
7194 };
7195 (SDIO_DATA2 $(, $_fallback:literal)?) => {
7196 "GPIO22"
7197 };
7198 (SDIO_DATA3 $(, $_fallback:literal)?) => {
7199 "GPIO23"
7200 };
7201 (SPICS0 $(, $_fallback:literal)?) => {
7202 "GPIO24"
7203 };
7204 (SPIQ $(, $_fallback:literal)?) => {
7205 "GPIO25"
7206 };
7207 (SPIWP $(, $_fallback:literal)?) => {
7208 "GPIO26"
7209 };
7210 (SPIHD $(, $_fallback:literal)?) => {
7211 "GPIO28"
7212 };
7213 (SPICLK $(, $_fallback:literal)?) => {
7214 "GPIO29"
7215 };
7216 (SPID $(, $_fallback:literal)?) => {
7217 "GPIO30"
7218 };
7219 ($_signal:ident, $fallback:literal) => {
7220 $fallback
7221 };
7222}
7223#[macro_export]
7227#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7228macro_rules! define_io_mux_signals {
7229 () => {
7230 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7231 #[derive(Debug, PartialEq, Copy, Clone)]
7232 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7233 #[doc(hidden)]
7234 pub enum InputSignal {
7235 EXT_ADC_START = 0,
7236 U0RXD = 6,
7237 U0CTS = 7,
7238 U0DSR = 8,
7239 U1RXD = 9,
7240 U1CTS = 10,
7241 U1DSR = 11,
7242 I2S_MCLK = 12,
7243 I2SO_BCK = 13,
7244 I2SO_WS = 14,
7245 I2SI_SD = 15,
7246 I2SI_BCK = 16,
7247 I2SI_WS = 17,
7248 USB_JTAG_TDO_BRIDGE = 19,
7249 CPU_TESTBUS0 = 20,
7250 CPU_TESTBUS1 = 21,
7251 CPU_TESTBUS2 = 22,
7252 CPU_TESTBUS3 = 23,
7253 CPU_TESTBUS4 = 24,
7254 CPU_TESTBUS5 = 25,
7255 CPU_TESTBUS6 = 26,
7256 CPU_TESTBUS7 = 27,
7257 CPU_GPIO_0 = 28,
7258 CPU_GPIO_1 = 29,
7259 CPU_GPIO_2 = 30,
7260 CPU_GPIO_3 = 31,
7261 CPU_GPIO_4 = 32,
7262 CPU_GPIO_5 = 33,
7263 CPU_GPIO_6 = 34,
7264 CPU_GPIO_7 = 35,
7265 USB_JTAG_TMS = 37,
7266 USB_EXTPHY_OEN = 40,
7267 USB_EXTPHY_VM = 41,
7268 USB_EXTPHY_VPO = 42,
7269 I2CEXT0_SCL = 45,
7270 I2CEXT0_SDA = 46,
7271 PARL_RX_DATA0 = 47,
7272 PARL_RX_DATA1 = 48,
7273 PARL_RX_DATA2 = 49,
7274 PARL_RX_DATA3 = 50,
7275 PARL_RX_DATA4 = 51,
7276 PARL_RX_DATA5 = 52,
7277 PARL_RX_DATA6 = 53,
7278 PARL_RX_DATA7 = 54,
7279 PARL_RX_DATA8 = 55,
7280 PARL_RX_DATA9 = 56,
7281 PARL_RX_DATA10 = 57,
7282 PARL_RX_DATA11 = 58,
7283 PARL_RX_DATA12 = 59,
7284 PARL_RX_DATA13 = 60,
7285 PARL_RX_DATA14 = 61,
7286 PARL_RX_DATA15 = 62,
7287 FSPICLK = 63,
7288 FSPIQ = 64,
7289 FSPID = 65,
7290 FSPIHD = 66,
7291 FSPIWP = 67,
7292 FSPICS0 = 68,
7293 PARL_RX_CLK = 69,
7294 PARL_TX_CLK = 70,
7295 RMT_SIG_0 = 71,
7296 RMT_SIG_1 = 72,
7297 TWAI0_RX = 73,
7298 TWAI1_RX = 77,
7299 PWM0_SYNC0 = 87,
7300 PWM0_SYNC1 = 88,
7301 PWM0_SYNC2 = 89,
7302 PWM0_F0 = 90,
7303 PWM0_F1 = 91,
7304 PWM0_F2 = 92,
7305 PWM0_CAP0 = 93,
7306 PWM0_CAP1 = 94,
7307 PWM0_CAP2 = 95,
7308 SIG_IN_FUNC97 = 97,
7309 SIG_IN_FUNC98 = 98,
7310 SIG_IN_FUNC99 = 99,
7311 SIG_IN_FUNC100 = 100,
7312 PCNT0_SIG_CH0 = 101,
7313 PCNT0_SIG_CH1 = 102,
7314 PCNT0_CTRL_CH0 = 103,
7315 PCNT0_CTRL_CH1 = 104,
7316 PCNT1_SIG_CH0 = 105,
7317 PCNT1_SIG_CH1 = 106,
7318 PCNT1_CTRL_CH0 = 107,
7319 PCNT1_CTRL_CH1 = 108,
7320 PCNT2_SIG_CH0 = 109,
7321 PCNT2_SIG_CH1 = 110,
7322 PCNT2_CTRL_CH0 = 111,
7323 PCNT2_CTRL_CH1 = 112,
7324 PCNT3_SIG_CH0 = 113,
7325 PCNT3_SIG_CH1 = 114,
7326 PCNT3_CTRL_CH0 = 115,
7327 PCNT3_CTRL_CH1 = 116,
7328 SPIQ = 121,
7329 SPID = 122,
7330 SPIHD = 123,
7331 SPIWP = 124,
7332 SDIO_CMD,
7333 SDIO_DATA0,
7334 SDIO_DATA1,
7335 SDIO_DATA2,
7336 SDIO_DATA3,
7337 MTDI,
7338 MTCK,
7339 MTMS,
7340 }
7341 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
7342 #[derive(Debug, PartialEq, Copy, Clone)]
7343 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7344 #[doc(hidden)]
7345 pub enum OutputSignal {
7346 LEDC_LS_SIG0 = 0,
7347 LEDC_LS_SIG1 = 1,
7348 LEDC_LS_SIG2 = 2,
7349 LEDC_LS_SIG3 = 3,
7350 LEDC_LS_SIG4 = 4,
7351 LEDC_LS_SIG5 = 5,
7352 U0TXD = 6,
7353 U0RTS = 7,
7354 U0DTR = 8,
7355 U1TXD = 9,
7356 U1RTS = 10,
7357 U1DTR = 11,
7358 I2S_MCLK = 12,
7359 I2SO_BCK = 13,
7360 I2SO_WS = 14,
7361 I2SO_SD = 15,
7362 I2SI_BCK = 16,
7363 I2SI_WS = 17,
7364 I2SO_SD1 = 18,
7365 USB_JTAG_TDO_BRIDGE = 19,
7366 CPU_TESTBUS0 = 20,
7367 CPU_TESTBUS1 = 21,
7368 CPU_TESTBUS2 = 22,
7369 CPU_TESTBUS3 = 23,
7370 CPU_TESTBUS4 = 24,
7371 CPU_TESTBUS5 = 25,
7372 CPU_TESTBUS6 = 26,
7373 CPU_TESTBUS7 = 27,
7374 CPU_GPIO_0 = 28,
7375 CPU_GPIO_1 = 29,
7376 CPU_GPIO_2 = 30,
7377 CPU_GPIO_3 = 31,
7378 CPU_GPIO_4 = 32,
7379 CPU_GPIO_5 = 33,
7380 CPU_GPIO_6 = 34,
7381 CPU_GPIO_7 = 35,
7382 USB_JTAG_TCK = 36,
7383 USB_JTAG_TMS = 37,
7384 USB_JTAG_TDI = 38,
7385 USB_JTAG_TDO = 39,
7386 I2CEXT0_SCL = 45,
7387 I2CEXT0_SDA = 46,
7388 PARL_TX_DATA0 = 47,
7389 PARL_TX_DATA1 = 48,
7390 PARL_TX_DATA2 = 49,
7391 PARL_TX_DATA3 = 50,
7392 PARL_TX_DATA4 = 51,
7393 PARL_TX_DATA5 = 52,
7394 PARL_TX_DATA6 = 53,
7395 PARL_TX_DATA7 = 54,
7396 PARL_TX_DATA8 = 55,
7397 PARL_TX_DATA9 = 56,
7398 PARL_TX_DATA10 = 57,
7399 PARL_TX_DATA11 = 58,
7400 PARL_TX_DATA12 = 59,
7401 PARL_TX_DATA13 = 60,
7402 PARL_TX_DATA14 = 61,
7403 PARL_TX_DATA15 = 62,
7404 FSPICLK = 63,
7405 FSPIQ = 64,
7406 FSPID = 65,
7407 FSPIHD = 66,
7408 FSPIWP = 67,
7409 FSPICS0 = 68,
7410 SDIO_TOHOST_INT = 69,
7411 PARL_TX_CLK = 70,
7412 RMT_SIG_0 = 71,
7413 RMT_SIG_1 = 72,
7414 TWAI0_TX = 73,
7415 TWAI0_BUS_OFF_ON = 74,
7416 TWAI0_CLKOUT = 75,
7417 TWAI0_STANDBY = 76,
7418 TWAI1_TX = 77,
7419 TWAI1_BUS_OFF_ON = 78,
7420 TWAI1_CLKOUT = 79,
7421 TWAI1_STANDBY = 80,
7422 GPIO_SD0 = 83,
7423 GPIO_SD1 = 84,
7424 GPIO_SD2 = 85,
7425 GPIO_SD3 = 86,
7426 PWM0_0A = 87,
7427 PWM0_0B = 88,
7428 PWM0_1A = 89,
7429 PWM0_1B = 90,
7430 PWM0_2A = 91,
7431 PWM0_2B = 92,
7432 SIG_IN_FUNC97 = 97,
7433 SIG_IN_FUNC98 = 98,
7434 SIG_IN_FUNC99 = 99,
7435 SIG_IN_FUNC100 = 100,
7436 FSPICS1 = 101,
7437 FSPICS2 = 102,
7438 FSPICS3 = 103,
7439 FSPICS4 = 104,
7440 FSPICS5 = 105,
7441 SPICLK = 114,
7442 SPICS0 = 115,
7443 SPICS1 = 116,
7444 GPIO_TASK_MATRIX_OUT0 = 117,
7445 GPIO_TASK_MATRIX_OUT1 = 118,
7446 GPIO_TASK_MATRIX_OUT2 = 119,
7447 GPIO_TASK_MATRIX_OUT3 = 120,
7448 SPIQ = 121,
7449 SPID = 122,
7450 SPIHD = 123,
7451 SPIWP = 124,
7452 CLK_OUT_OUT1 = 125,
7453 CLK_OUT_OUT2 = 126,
7454 CLK_OUT_OUT3 = 127,
7455 GPIO = 128,
7456 SDIO_CLK,
7457 SDIO_CMD,
7458 SDIO_DATA0,
7459 SDIO_DATA1,
7460 SDIO_DATA2,
7461 SDIO_DATA3,
7462 MTDO,
7463 }
7464 };
7465}
7466#[macro_export]
7473#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7474macro_rules! define_lp_functions {
7475 () => {
7476 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
7481 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
7482 #[doc(hidden)]
7483 pub enum LpFunction {
7484 _0 = 0,
7486 _1 = 1,
7488 }
7489 impl LpFunction {
7490 pub const LP_GPIO: Self = Self::_0;
7492 }
7493 };
7494}
7495#[macro_export]
7508#[expect(clippy::crate_in_macro_def)]
7509#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
7510macro_rules! define_io_mux_reg {
7511 () => {
7512 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
7513 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
7514 }
7515 };
7516}