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