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 "esp32h2"
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-H2"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32h2"
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-h2_technical_reference_manual_en.pdf"
54 };
55 ("gpio.version") => {
56 2
57 };
58 ("gpio.version", str) => {
59 stringify!(2)
60 };
61 ("gpio.has_input_sync") => {
62 true
63 };
64 ("gpio.gpio_function") => {
65 1
66 };
67 ("gpio.gpio_function", str) => {
68 stringify!(1)
69 };
70 ("gpio.constant_0_input") => {
71 60
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(60)
75 };
76 ("gpio.constant_1_input") => {
77 56
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(56)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 false
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.need_soft_isolate_during_pd") => {
92 false
93 };
94 ("gpio.has_bank_1") => {
95 false
96 };
97 ("gpio.input_signal_max") => {
98 124
99 };
100 ("gpio.input_signal_max", str) => {
101 stringify!(124)
102 };
103 ("gpio.output_signal_max") => {
104 128
105 };
106 ("gpio.output_signal_max", str) => {
107 stringify!(128)
108 };
109 ("dedicated_gpio.version") => {
110 "riscv_v1"
111 };
112 ("dedicated_gpio.needs_initialization") => {
113 false
114 };
115 ("dedicated_gpio.channel_count") => {
116 8
117 };
118 ("dedicated_gpio.channel_count", str) => {
119 stringify!(8)
120 };
121 ("lp_io.version") => {
122 "esp32h2"
123 };
124 ("lp_io.has_gpio_matrix") => {
125 false
126 };
127 ("uart.ram_size") => {
128 128
129 };
130 ("uart.ram_size", str) => {
131 stringify!(128)
132 };
133 ("uart.version") => {
134 2
135 };
136 ("uart.version", str) => {
137 stringify!(2)
138 };
139 ("uart.peripheral_controls_mem_clk") => {
140 true
141 };
142 ("uart.has_sclk_divider") => {
143 false
144 };
145 ("uart.has_sclk_enable") => {
146 true
147 };
148 ("uhci.combined_uart_selector_field") => {
149 false
150 };
151 ("i2c_master.version") => {
152 4
153 };
154 ("i2c_master.version", str) => {
155 stringify!(4)
156 };
157 ("i2c_master.has_fsm_timeouts") => {
158 true
159 };
160 ("i2c_master.has_hw_bus_clear") => {
161 true
162 };
163 ("i2c_master.has_bus_timeout_enable") => {
164 true
165 };
166 ("i2c_master.separate_filter_config_registers") => {
167 false
168 };
169 ("i2c_master.can_estimate_nack_reason") => {
170 true
171 };
172 ("i2c_master.has_conf_update") => {
173 true
174 };
175 ("i2c_master.has_reliable_fsm_reset") => {
176 true
177 };
178 ("i2c_master.has_arbitration_en") => {
179 true
180 };
181 ("i2c_master.has_tx_fifo_watermark") => {
182 true
183 };
184 ("i2c_master.bus_timeout_is_exponential") => {
185 true
186 };
187 ("i2c_master.has_pd_en") => {
188 true
189 };
190 ("i2c_master.max_bus_timeout") => {
191 31
192 };
193 ("i2c_master.max_bus_timeout", str) => {
194 stringify!(31)
195 };
196 ("i2c_master.ll_intr_mask") => {
197 262143
198 };
199 ("i2c_master.ll_intr_mask", str) => {
200 stringify!(262143)
201 };
202 ("i2c_master.fifo_size") => {
203 32
204 };
205 ("i2c_master.fifo_size", str) => {
206 stringify!(32)
207 };
208 ("spi_master.version") => {
209 3
210 };
211 ("spi_master.version", str) => {
212 stringify!(3)
213 };
214 ("spi_master.fifo_size") => {
215 64
216 };
217 ("spi_master.fifo_size", str) => {
218 stringify!(64)
219 };
220 ("spi_master.bit_order_is_bool") => {
221 false
222 };
223 ("spi_master.has_octal") => {
224 false
225 };
226 ("spi_master.has_app_interrupts") => {
227 true
228 };
229 ("spi_master.has_dma_segmented_transfer") => {
230 true
231 };
232 ("spi_master.has_clk_pre_div") => {
233 false
234 };
235 ("spi_master.dma_can_access_flash") => {
236 false
237 };
238 ("i2s.version") => {
239 3
240 };
241 ("i2s.version", str) => {
242 stringify!(3)
243 };
244 ("i2s.mclk_divider_bit_width") => {
245 9
246 };
247 ("i2s.mclk_divider_bit_width", str) => {
248 stringify!(9)
249 };
250 ("i2s.max_ws_width") => {
251 512
252 };
253 ("i2s.max_ws_width", str) => {
254 stringify!(512)
255 };
256 ("i2s.clock_configured_by_pcr") => {
257 true
258 };
259 ("i2s.clock_configured_by_hp_sys_clkrst") => {
260 false
261 };
262 ("i2s.supports_pdm_rx_hp_filter") => {
263 false
264 };
265 ("i2s.supports_pdm_tx") => {
266 true
267 };
268 ("i2s.supports_pdm_rx") => {
269 true
270 };
271 ("i2s.supports_pcm2pdm") => {
272 true
273 };
274 ("i2s.supports_pdm2pcm") => {
275 false
276 };
277 ("parl_io.version") => {
278 2
279 };
280 ("parl_io.version", str) => {
281 stringify!(2)
282 };
283 ("parl_io.max_data_width") => {
284 8
285 };
286 ("parl_io.max_data_width", str) => {
287 stringify!(8)
288 };
289 ("parl_io.has_tx_cs") => {
290 false
291 };
292 ("rmt.ram_start") => {
293 1610642432
294 };
295 ("rmt.ram_start", str) => {
296 stringify!(1610642432)
297 };
298 ("rmt.channel_ram_size") => {
299 48
300 };
301 ("rmt.channel_ram_size", str) => {
302 stringify!(48)
303 };
304 ("rmt.has_tx_immediate_stop") => {
305 true
306 };
307 ("rmt.has_tx_loop_count") => {
308 true
309 };
310 ("rmt.has_tx_loop_auto_stop") => {
311 true
312 };
313 ("rmt.has_tx_carrier_data_only") => {
314 true
315 };
316 ("rmt.has_tx_sync") => {
317 true
318 };
319 ("rmt.has_rx_wrap") => {
320 true
321 };
322 ("rmt.has_rx_demodulation") => {
323 true
324 };
325 ("rmt.has_per_channel_clock") => {
326 false
327 };
328 ("bt.controller") => {
329 "npl"
330 };
331 ("bt.requires_fast_cpu") => {
332 true
333 };
334 ("ieee802154.requires_fast_cpu") => {
335 true
336 };
337 ("phy.combo_module") => {
338 false
339 };
340 ("adc.controller") => {
341 "digital"
342 };
343 ("adc.channel_count") => {
344 5
345 };
346 ("adc.channel_count", str) => {
347 stringify!(5)
348 };
349 ("adc.line_calibration") => {
350 true
351 };
352 ("adc.curve_calibration") => {
353 true
354 };
355 ("adc.basic_calibration") => {
356 true
357 };
358 ("adc.calibration_v1_scheme_supported") => {
359 true
360 };
361 ("adc.channel_compensation") => {
362 true
363 };
364 ("adc.pcr_clock") => {
365 true
366 };
367 ("adc.pcr_sar_clk_div") => {
368 true
369 };
370 ("adc.sar_power_override") => {
371 true
372 };
373 ("ledc.version") => {
374 3
375 };
376 ("ledc.version", str) => {
377 stringify!(3)
378 };
379 ("ledc.channel_count") => {
380 6
381 };
382 ("ledc.channel_count", str) => {
383 stringify!(6)
384 };
385 ("sdm.channel_count") => {
386 4
387 };
388 ("sdm.channel_count", str) => {
389 stringify!(4)
390 };
391 ("timergroup.timg_has_timer1") => {
392 false
393 };
394 ("timergroup.timg_has_divcnt_rst") => {
395 true
396 };
397 ("timergroup.wdt_has_conf_update") => {
398 true
399 };
400 ("timergroup.rc_fast_calibration_divider_min_rev") => {
401 2
402 };
403 ("timergroup.rc_fast_calibration_divider") => {
404 32
405 };
406 ("timergroup.rc_fast_calibration_tick_enable") => {
407 true
408 };
409 ("aes.has_split_text_registers") => {
410 true
411 };
412 ("aes.endianness_configurable") => {
413 false
414 };
415 ("ecc.zero_extend_writes") => {
416 true
417 };
418 ("ecc.separate_jacobian_point_memory") => {
419 true
420 };
421 ("ecc.has_memory_clock_gate") => {
422 true
423 };
424 ("ecc.supports_enhanced_security") => {
425 true
426 };
427 ("ecc.mem_block_size") => {
428 32
429 };
430 ("rng.apb_cycle_wait_num") => {
431 16
432 };
433 ("rng.apb_cycle_wait_num", str) => {
434 stringify!(16)
435 };
436 ("rng.trng_supported") => {
437 true
438 };
439 ("rng.is_lp_sys") => {
440 false
441 };
442 ("rsa.version") => {
443 3
444 };
445 ("rsa.version", str) => {
446 stringify!(3)
447 };
448 ("rsa.size_increment") => {
449 32
450 };
451 ("rsa.size_increment", str) => {
452 stringify!(32)
453 };
454 ("rsa.memory_size_bytes") => {
455 384
456 };
457 ("rsa.memory_size_bytes", str) => {
458 stringify!(384)
459 };
460 ("sleep.light_sleep") => {
461 true
462 };
463 ("sleep.deep_sleep") => {
464 true
465 };
466 ("sleep.rejectable_mask") => {
467 3582
468 };
469 ("sleep.ext1_version") => {
470 2
471 };
472 ("sleep.ext1_version", str) => {
473 stringify!(2)
474 };
475 ("sleep.deep_sleep_needs_gpio_isolation") => {
476 false
477 };
478 ("sleep.idle_frequency_scaling") => {
479 true
480 };
481 ("assist_debug.has_sp_monitor") => {
482 true
483 };
484 ("assist_debug.has_region_monitor") => {
485 true
486 };
487 ("dma.mem2mem_requires_peripheral") => {
488 false
489 };
490 ("dma.ext_mem_configurable_block_size") => {
491 false
492 };
493 ("dma.separate_in_out_interrupts") => {
494 true
495 };
496 ("dma.gdma_version") => {
497 1
498 };
499 ("dma.gdma_version", str) => {
500 stringify!(1)
501 };
502 ("interrupts.status_registers") => {
503 2
504 };
505 ("interrupts.status_registers", str) => {
506 stringify!(2)
507 };
508 ("interrupts.disabled_interrupt") => {
509 31
510 };
511 ("mmu.page_size") => {
512 65536
513 };
514 ("mmu.page_size", str) => {
515 stringify!(65536)
516 };
517 ("mmu.entry_num") => {
518 256
519 };
520 ("mmu.entry_num", str) => {
521 stringify!(256)
522 };
523 ("rom.has_crc_le") => {
524 true
525 };
526 ("rom.has_crc_be") => {
527 true
528 };
529 ("rom.has_md5_bsd") => {
530 true
531 };
532 ("rom.has_md5_mbedtls") => {
533 false
534 };
535 ("rom.no_libgcc") => {
536 false
537 };
538 ("soc.cpu_has_branch_predictor") => {
539 false
540 };
541 ("soc.cpu_has_csr_pc") => {
542 true
543 };
544 ("soc.cpu_has_zcmp_workaround") => {
545 false
546 };
547 ("soc.multi_core_enabled") => {
548 false
549 };
550 ("soc.cpu_pma_needs_core1_setup") => {
551 false
552 };
553 ("soc.cpu_csr_prv_mode") => {
554 3088
555 };
556 ("soc.cpu_csr_prv_mode", str) => {
557 stringify!(3088)
558 };
559 ("soc.internal_memory_cached") => {
560 false
561 };
562 ("soc.cpu_powers_down_cache") => {
563 false
564 };
565 ("soc.has_swd_watchdog") => {
566 true
567 };
568 ("soc.has_bus_clock_update") => {
569 true
570 };
571 ("soc.has_apb_frequency_reduction") => {
572 true
573 };
574 ("soc.cpu_mcause_mask") => {
575 31
576 };
577 ("soc.cpu_mcause_mask", str) => {
578 stringify!(31)
579 };
580 ("soc.cpu_pmp_granularity") => {
581 4
582 };
583 ("soc.cpu_pmp_granularity", str) => {
584 stringify!(4)
585 };
586 ("clock_tree.iomux_function_clock") => {
587 [crate ::soc::clocks::IomuxFunctionClockConfig::XtalClk, crate
588 ::soc::clocks::IomuxFunctionClockConfig::PllF48m]
589 };
590 ("clock_tree.hp_root_clk") => {
591 [crate ::soc::clocks::HpRootClkConfig::Pll96, crate
592 ::soc::clocks::HpRootClkConfig::Pll64, crate
593 ::soc::clocks::HpRootClkConfig::Xtal, crate
594 ::soc::clocks::HpRootClkConfig::RcFast]
595 };
596 ("clock_tree.cpu_clk.divisor") => {
597 (0, 255)
598 };
599 ("clock_tree.ahb_clk.divisor") => {
600 (0, 255)
601 };
602 ("clock_tree.apb_clk.divisor") => {
603 (0, 255)
604 };
605 ("clock_tree.lp_fast_clk") => {
606 [crate ::soc::clocks::LpFastClkConfig::RcFastClk, #[cfg(use_xtal32k)] crate
607 ::soc::clocks::LpFastClkConfig::PllLpClk, crate
608 ::soc::clocks::LpFastClkConfig::XtalD2Clk]
609 };
610 ("clock_tree.lp_slow_clk") => {
611 [#[cfg(use_xtal32k)] crate ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
612 ::soc::clocks::LpSlowClkConfig::RcSlow, crate
613 ::soc::clocks::LpSlowClkConfig::OscSlow]
614 };
615 ("clock_tree.ble_lp_clk") => {
616 [crate ::soc::clocks::BleLpClkConfig::Xtal, crate
617 ::soc::clocks::BleLpClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
618 ::soc::clocks::BleLpClkConfig::Xtal32k]
619 };
620 ("clock_tree.crypto_clk") => {
621 [crate ::soc::clocks::CryptoClkConfig::Xtal, crate
622 ::soc::clocks::CryptoClkConfig::RcFast, crate
623 ::soc::clocks::CryptoClkConfig::PllF64m, crate
624 ::soc::clocks::CryptoClkConfig::PllF96m]
625 };
626 ("clock_tree.timg_calibration_clock") => {
627 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
628 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
629 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
630 };
631 ("clock_tree.uart.function_clock.sclk") => {
632 [crate ::soc::clocks::UartFunctionClockSclk::PllF48m, crate
633 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
634 ::soc::clocks::UartFunctionClockSclk::Xtal]
635 };
636 ("clock_tree.uart.function_clock.div_num") => {
637 (0, 255)
638 };
639 ("clock_tree.uart.baud_rate_generator.fractional") => {
640 (0, 15)
641 };
642 ("clock_tree.uart.baud_rate_generator.integral") => {
643 (0, 4095)
644 };
645 ("clock_tree.rmt.sclk") => {
646 [crate ::soc::clocks::RmtSclkConfig::XtalClk, crate
647 ::soc::clocks::RmtSclkConfig::RcFastClk]
648 };
649 ("clock_tree.timg.function_clock") => {
650 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
651 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
652 ::soc::clocks::TimgFunctionClockConfig::PllF48m]
653 };
654 ("clock_tree.timg.wdt_clock") => {
655 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
656 ::soc::clocks::TimgWdtClockConfig::RcFastClk, crate
657 ::soc::clocks::TimgWdtClockConfig::PllF48m]
658 };
659 ("clock_tree.mcpwm.function_clock") => {
660 [crate ::soc::clocks::McpwmFunctionClockConfig::PllF96m, crate
661 ::soc::clocks::McpwmFunctionClockConfig::RcFastClk, crate
662 ::soc::clocks::McpwmFunctionClockConfig::XtalClk]
663 };
664 ("clock_tree.parl_io.rx_clock") => {
665 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
666 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
667 ::soc::clocks::ParlIoClkConfig::PllF96m]
668 };
669 ("clock_tree.parl_io.tx_clock") => {
670 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
671 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
672 ::soc::clocks::ParlIoClkConfig::PllF96m]
673 };
674 ("clock_tree.i2s.tx_clk.sclk") => {
675 [crate ::soc::clocks::I2sClkSclk::Xtal, crate ::soc::clocks::I2sClkSclk::PllF96m,
676 crate ::soc::clocks::I2sClkSclk::PllF64m]
677 };
678 ("clock_tree.i2s.tx_clk.div_num") => {
679 (1, 255)
680 };
681 ("clock_tree.i2s.tx_clk.div_a") => {
682 (1, 511)
683 };
684 ("clock_tree.i2s.tx_clk.div_b") => {
685 (0, 511)
686 };
687 ("clock_tree.i2s.rx_clk.sclk") => {
688 [crate ::soc::clocks::I2sClkSclk::Xtal, crate ::soc::clocks::I2sClkSclk::PllF96m,
689 crate ::soc::clocks::I2sClkSclk::PllF64m]
690 };
691 ("clock_tree.i2s.rx_clk.div_num") => {
692 (1, 255)
693 };
694 ("clock_tree.i2s.rx_clk.div_a") => {
695 (1, 511)
696 };
697 ("clock_tree.i2s.rx_clk.div_b") => {
698 (0, 511)
699 };
700 ("clock_tree.i2s.mclk_out") => {
701 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
702 ::soc::clocks::I2sMclkOutConfig::Rx]
703 };
704 ("clock_tree.i2c.function_clock.sclk") => {
705 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
706 ::soc::clocks::I2cFunctionClockSclk::RcFast]
707 };
708 ("clock_tree.i2c.function_clock.div_num") => {
709 (0, 255)
710 };
711 ("clock_tree.spi.function_clock") => {
712 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
713 ::soc::clocks::SpiFunctionClockConfig::PllF48m, crate
714 ::soc::clocks::SpiFunctionClockConfig::RcFast]
715 };
716 ("clock_tree.adc.function_clock") => {
717 [crate ::soc::clocks::AdcFunctionClockConfig::Xtal, crate
718 ::soc::clocks::AdcFunctionClockConfig::PllF96m, crate
719 ::soc::clocks::AdcFunctionClockConfig::RcFast]
720 };
721}
722#[macro_export]
723#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
724macro_rules! for_each_dedicated_gpio {
725 ($($pattern:tt => $code:tt;)*) => {
726 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
727 tt) => {} } _for_each_inner_dedicated_gpio!((0));
728 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
729 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
730 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
731 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
732 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
733 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
734 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
735 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
736 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
737 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
738 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
739 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
740 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
741 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
742 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
743 };
744}
745#[macro_export]
749#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
750macro_rules! define_lp_io_signals {
751 () => {};
752}
753#[macro_export]
775#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
776macro_rules! for_each_rmt_channel {
777 ($($pattern:tt => $code:tt;)*) => {
778 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
779 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
780 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
781 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
782 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
783 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
784 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
785 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
786 };
787}
788#[macro_export]
789#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
790macro_rules! for_each_sdm_channel {
791 ($($pattern:tt => $code:tt;)*) => {
792 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
793 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
794 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
795 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
796 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
797 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
798 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
799 GPIO_SD3)));
800 };
801}
802#[macro_export]
803#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
804macro_rules! for_each_aes_key_length {
805 ($($pattern:tt => $code:tt;)*) => {
806 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
807 tt) => {} } _for_each_inner_aes_key_length!((128));
808 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
809 4)); _for_each_inner_aes_key_length!((256, 2, 6));
810 _for_each_inner_aes_key_length!((bits(128), (256)));
811 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
812 };
813}
814#[macro_export]
815#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
816macro_rules! for_each_ecc_working_mode {
817 ($($pattern:tt => $code:tt;)*) => {
818 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
819 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
820 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
821 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
822 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
823 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
824 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
825 _for_each_inner_ecc_working_mode!((7,
826 AffinePointVerificationAndJacobianPointMultiplication));
827 _for_each_inner_ecc_working_mode!((8, ModularAddition));
828 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
829 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
830 _for_each_inner_ecc_working_mode!((11, ModularDivision));
831 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
832 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
833 JacobianPointMultiplication), (5, AffinePointAddition), (6,
834 JacobianPointVerification), (7,
835 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
836 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
837 };
838}
839#[macro_export]
840#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
841macro_rules! for_each_ecc_curve {
842 ($($pattern:tt => $code:tt;)*) => {
843 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
844 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
845 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
846 P192, 192), (1, P256, 256)));
847 };
848}
849#[macro_export]
850#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
851macro_rules! for_each_rsa_exponentiation {
852 ($($pattern:tt => $code:tt;)*) => {
853 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
854 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
855 _for_each_inner_rsa_exponentiation!((64));
856 _for_each_inner_rsa_exponentiation!((96));
857 _for_each_inner_rsa_exponentiation!((128));
858 _for_each_inner_rsa_exponentiation!((160));
859 _for_each_inner_rsa_exponentiation!((192));
860 _for_each_inner_rsa_exponentiation!((224));
861 _for_each_inner_rsa_exponentiation!((256));
862 _for_each_inner_rsa_exponentiation!((288));
863 _for_each_inner_rsa_exponentiation!((320));
864 _for_each_inner_rsa_exponentiation!((352));
865 _for_each_inner_rsa_exponentiation!((384));
866 _for_each_inner_rsa_exponentiation!((416));
867 _for_each_inner_rsa_exponentiation!((448));
868 _for_each_inner_rsa_exponentiation!((480));
869 _for_each_inner_rsa_exponentiation!((512));
870 _for_each_inner_rsa_exponentiation!((544));
871 _for_each_inner_rsa_exponentiation!((576));
872 _for_each_inner_rsa_exponentiation!((608));
873 _for_each_inner_rsa_exponentiation!((640));
874 _for_each_inner_rsa_exponentiation!((672));
875 _for_each_inner_rsa_exponentiation!((704));
876 _for_each_inner_rsa_exponentiation!((736));
877 _for_each_inner_rsa_exponentiation!((768));
878 _for_each_inner_rsa_exponentiation!((800));
879 _for_each_inner_rsa_exponentiation!((832));
880 _for_each_inner_rsa_exponentiation!((864));
881 _for_each_inner_rsa_exponentiation!((896));
882 _for_each_inner_rsa_exponentiation!((928));
883 _for_each_inner_rsa_exponentiation!((960));
884 _for_each_inner_rsa_exponentiation!((992));
885 _for_each_inner_rsa_exponentiation!((1024));
886 _for_each_inner_rsa_exponentiation!((1056));
887 _for_each_inner_rsa_exponentiation!((1088));
888 _for_each_inner_rsa_exponentiation!((1120));
889 _for_each_inner_rsa_exponentiation!((1152));
890 _for_each_inner_rsa_exponentiation!((1184));
891 _for_each_inner_rsa_exponentiation!((1216));
892 _for_each_inner_rsa_exponentiation!((1248));
893 _for_each_inner_rsa_exponentiation!((1280));
894 _for_each_inner_rsa_exponentiation!((1312));
895 _for_each_inner_rsa_exponentiation!((1344));
896 _for_each_inner_rsa_exponentiation!((1376));
897 _for_each_inner_rsa_exponentiation!((1408));
898 _for_each_inner_rsa_exponentiation!((1440));
899 _for_each_inner_rsa_exponentiation!((1472));
900 _for_each_inner_rsa_exponentiation!((1504));
901 _for_each_inner_rsa_exponentiation!((1536));
902 _for_each_inner_rsa_exponentiation!((1568));
903 _for_each_inner_rsa_exponentiation!((1600));
904 _for_each_inner_rsa_exponentiation!((1632));
905 _for_each_inner_rsa_exponentiation!((1664));
906 _for_each_inner_rsa_exponentiation!((1696));
907 _for_each_inner_rsa_exponentiation!((1728));
908 _for_each_inner_rsa_exponentiation!((1760));
909 _for_each_inner_rsa_exponentiation!((1792));
910 _for_each_inner_rsa_exponentiation!((1824));
911 _for_each_inner_rsa_exponentiation!((1856));
912 _for_each_inner_rsa_exponentiation!((1888));
913 _for_each_inner_rsa_exponentiation!((1920));
914 _for_each_inner_rsa_exponentiation!((1952));
915 _for_each_inner_rsa_exponentiation!((1984));
916 _for_each_inner_rsa_exponentiation!((2016));
917 _for_each_inner_rsa_exponentiation!((2048));
918 _for_each_inner_rsa_exponentiation!((2080));
919 _for_each_inner_rsa_exponentiation!((2112));
920 _for_each_inner_rsa_exponentiation!((2144));
921 _for_each_inner_rsa_exponentiation!((2176));
922 _for_each_inner_rsa_exponentiation!((2208));
923 _for_each_inner_rsa_exponentiation!((2240));
924 _for_each_inner_rsa_exponentiation!((2272));
925 _for_each_inner_rsa_exponentiation!((2304));
926 _for_each_inner_rsa_exponentiation!((2336));
927 _for_each_inner_rsa_exponentiation!((2368));
928 _for_each_inner_rsa_exponentiation!((2400));
929 _for_each_inner_rsa_exponentiation!((2432));
930 _for_each_inner_rsa_exponentiation!((2464));
931 _for_each_inner_rsa_exponentiation!((2496));
932 _for_each_inner_rsa_exponentiation!((2528));
933 _for_each_inner_rsa_exponentiation!((2560));
934 _for_each_inner_rsa_exponentiation!((2592));
935 _for_each_inner_rsa_exponentiation!((2624));
936 _for_each_inner_rsa_exponentiation!((2656));
937 _for_each_inner_rsa_exponentiation!((2688));
938 _for_each_inner_rsa_exponentiation!((2720));
939 _for_each_inner_rsa_exponentiation!((2752));
940 _for_each_inner_rsa_exponentiation!((2784));
941 _for_each_inner_rsa_exponentiation!((2816));
942 _for_each_inner_rsa_exponentiation!((2848));
943 _for_each_inner_rsa_exponentiation!((2880));
944 _for_each_inner_rsa_exponentiation!((2912));
945 _for_each_inner_rsa_exponentiation!((2944));
946 _for_each_inner_rsa_exponentiation!((2976));
947 _for_each_inner_rsa_exponentiation!((3008));
948 _for_each_inner_rsa_exponentiation!((3040));
949 _for_each_inner_rsa_exponentiation!((3072));
950 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
951 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
952 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
953 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
954 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
955 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
956 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
957 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
958 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
959 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
960 };
961}
962#[macro_export]
963#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
964macro_rules! for_each_rsa_multiplication {
965 ($($pattern:tt => $code:tt;)*) => {
966 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
967 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
968 _for_each_inner_rsa_multiplication!((64));
969 _for_each_inner_rsa_multiplication!((96));
970 _for_each_inner_rsa_multiplication!((128));
971 _for_each_inner_rsa_multiplication!((160));
972 _for_each_inner_rsa_multiplication!((192));
973 _for_each_inner_rsa_multiplication!((224));
974 _for_each_inner_rsa_multiplication!((256));
975 _for_each_inner_rsa_multiplication!((288));
976 _for_each_inner_rsa_multiplication!((320));
977 _for_each_inner_rsa_multiplication!((352));
978 _for_each_inner_rsa_multiplication!((384));
979 _for_each_inner_rsa_multiplication!((416));
980 _for_each_inner_rsa_multiplication!((448));
981 _for_each_inner_rsa_multiplication!((480));
982 _for_each_inner_rsa_multiplication!((512));
983 _for_each_inner_rsa_multiplication!((544));
984 _for_each_inner_rsa_multiplication!((576));
985 _for_each_inner_rsa_multiplication!((608));
986 _for_each_inner_rsa_multiplication!((640));
987 _for_each_inner_rsa_multiplication!((672));
988 _for_each_inner_rsa_multiplication!((704));
989 _for_each_inner_rsa_multiplication!((736));
990 _for_each_inner_rsa_multiplication!((768));
991 _for_each_inner_rsa_multiplication!((800));
992 _for_each_inner_rsa_multiplication!((832));
993 _for_each_inner_rsa_multiplication!((864));
994 _for_each_inner_rsa_multiplication!((896));
995 _for_each_inner_rsa_multiplication!((928));
996 _for_each_inner_rsa_multiplication!((960));
997 _for_each_inner_rsa_multiplication!((992));
998 _for_each_inner_rsa_multiplication!((1024));
999 _for_each_inner_rsa_multiplication!((1056));
1000 _for_each_inner_rsa_multiplication!((1088));
1001 _for_each_inner_rsa_multiplication!((1120));
1002 _for_each_inner_rsa_multiplication!((1152));
1003 _for_each_inner_rsa_multiplication!((1184));
1004 _for_each_inner_rsa_multiplication!((1216));
1005 _for_each_inner_rsa_multiplication!((1248));
1006 _for_each_inner_rsa_multiplication!((1280));
1007 _for_each_inner_rsa_multiplication!((1312));
1008 _for_each_inner_rsa_multiplication!((1344));
1009 _for_each_inner_rsa_multiplication!((1376));
1010 _for_each_inner_rsa_multiplication!((1408));
1011 _for_each_inner_rsa_multiplication!((1440));
1012 _for_each_inner_rsa_multiplication!((1472));
1013 _for_each_inner_rsa_multiplication!((1504));
1014 _for_each_inner_rsa_multiplication!((1536));
1015 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
1016 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
1017 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
1018 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
1019 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
1020 };
1021}
1022#[macro_export]
1023#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1024macro_rules! for_each_sha_algorithm {
1025 ($($pattern:tt => $code:tt;)*) => {
1026 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
1027 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
1028 (insecure_against : "collision", "length extension"), 0));
1029 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
1030 (insecure_against : "length extension"), 1));
1031 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
1032 (insecure_against : "length extension"), 2));
1033 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
1034 (insecure_against : "collision", "length extension"), 0), (Sha224,
1035 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
1036 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
1037 2)));
1038 };
1039}
1040#[macro_export]
1041#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1042macro_rules! for_each_wakeup_source {
1043 ($($pattern:tt => $code:tt;)*) => {
1044 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
1045 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
1046 _for_each_inner_wakeup_source!((Gpio, 2));
1047 _for_each_inner_wakeup_source!((WifiBeacon, 3));
1048 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
1049 5)); _for_each_inner_wakeup_source!((Uart0, 6));
1050 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
1051 8)); _for_each_inner_wakeup_source!((Bt, 10));
1052 _for_each_inner_wakeup_source!((LpCore, 11));
1053 _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3), (Timer,
1054 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Bt, 10), (LpCore, 11)));
1055 };
1056}
1057#[macro_export]
1058#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1059macro_rules! for_each_dma_engine {
1060 ($($pattern:tt => $code:tt;)*) => {
1061 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
1062 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
1063 _for_each_inner_dma_engine!((all("AHB_GDMA")));
1064 };
1065}
1066#[macro_export]
1067#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1068macro_rules! for_each_dma_channel {
1069 ($($pattern:tt => $code:tt;)*) => {
1070 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
1071 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
1072 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
1073 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
1074 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
1075 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
1076 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1077 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1,
1078 interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI2,
1079 UHCI0, I2S0, AES, SHA, APB_SARADC, PARL_IO]));
1080 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1081 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1082 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
1083 ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2)));
1084 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
1085 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
1086 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1087 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES,
1088 SHA, APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
1089 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1090 APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1091 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1092 APB_SARADC, PARL_IO]))); _for_each_inner_dma_channel!((no_own_interrupt));
1093 };
1094}
1095#[macro_export]
1096#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1097macro_rules! for_each_dma_channel_peri_pair {
1098 ($($pattern:tt => $code:tt;)*) => {
1099 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1100 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1101 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
1102 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
1103 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
1104 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
1105 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
1106 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
1107 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
1108 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
1109 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
1110 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
1111 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
1112 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
1113 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
1114 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
1115 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
1116 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
1117 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
1118 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
1119 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
1120 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
1121 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1122 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1123 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1124 any_channel = AhbGdmaChannel, I2S0));
1125 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1126 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1127 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1128 any_channel = AhbGdmaChannel, APB_SARADC));
1129 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1130 PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
1131 SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA",
1132 DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC),
1133 ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI2), ("AHB_GDMA",
1134 DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, AES),
1135 ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1, APB_SARADC), ("AHB_GDMA",
1136 DMA_CH1, PARL_IO), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
1137 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
1138 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC), ("AHB_GDMA", DMA_CH2, PARL_IO)));
1139 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1140 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
1141 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
1142 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
1143 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC), ("AHB_GDMA", any_channel
1144 = AhbGdmaChannel, PARL_IO)));
1145 };
1146}
1147#[macro_export]
1148#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1149macro_rules! for_each_mem2mem_channel {
1150 ($($pattern:tt => $code:tt;)*) => {
1151 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1152 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1153 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1154 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
1155 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
1156 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1157 4, 1, 5, 2, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1158 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1159 AhbGdmaChannel, DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5),
1160 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 10)));
1161 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1162 4, 1, 5, 2, 10))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1163 AhbGdmaChannel)));
1164 };
1165}
1166#[macro_export]
1167#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1168macro_rules! with_aes_dma_engine {
1169 ($($pattern:tt => $code:tt;)*) => {
1170 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1171 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1172 };
1173}
1174#[macro_export]
1175#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1176macro_rules! with_i2s_dma_engine {
1177 ($($pattern:tt => $code:tt;)*) => {
1178 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1179 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1180 };
1181}
1182#[macro_export]
1183#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1184macro_rules! with_parl_io_dma_engine {
1185 ($($pattern:tt => $code:tt;)*) => {
1186 macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
1187 tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1188 };
1189}
1190#[macro_export]
1191#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1192macro_rules! with_sha_dma_engine {
1193 ($($pattern:tt => $code:tt;)*) => {
1194 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1195 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1196 };
1197}
1198#[macro_export]
1199#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1200macro_rules! with_spi_master_dma_engine {
1201 ($($pattern:tt => $code:tt;)*) => {
1202 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1203 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1204 };
1205}
1206#[macro_export]
1207#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1208macro_rules! with_spi_slave_dma_engine {
1209 ($($pattern:tt => $code:tt;)*) => {
1210 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1211 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1212 };
1213}
1214#[macro_export]
1215#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1216macro_rules! with_uhci_dma_engine {
1217 ($($pattern:tt => $code:tt;)*) => {
1218 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1219 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1220 };
1221}
1222#[macro_export]
1223#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1224macro_rules! for_each_interrupt {
1225 ($($pattern:tt => $code:tt;)*) => {
1226 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1227 => {} } _for_each_inner_interrupt!(([reserved 0] 0));
1228 _for_each_inner_interrupt!(([direct_bindable 0] 1));
1229 _for_each_inner_interrupt!(([direct_bindable 1] 2));
1230 _for_each_inner_interrupt!(([reserved 1] 3));
1231 _for_each_inner_interrupt!(([reserved 2] 4));
1232 _for_each_inner_interrupt!(([direct_bindable 2] 5));
1233 _for_each_inner_interrupt!(([direct_bindable 3] 6));
1234 _for_each_inner_interrupt!(([reserved 3] 7));
1235 _for_each_inner_interrupt!(([direct_bindable 4] 8));
1236 _for_each_inner_interrupt!(([direct_bindable 5] 9));
1237 _for_each_inner_interrupt!(([direct_bindable 6] 10));
1238 _for_each_inner_interrupt!(([direct_bindable 7] 11));
1239 _for_each_inner_interrupt!(([direct_bindable 8] 12));
1240 _for_each_inner_interrupt!(([direct_bindable 9] 13));
1241 _for_each_inner_interrupt!(([direct_bindable 10] 14));
1242 _for_each_inner_interrupt!(([direct_bindable 11] 15));
1243 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1244 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1245 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1246 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1247 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1248 7] 23)); _for_each_inner_interrupt!(([vector 8] 24));
1249 _for_each_inner_interrupt!(([vector 9] 25)); _for_each_inner_interrupt!(([vector
1250 10] 26)); _for_each_inner_interrupt!(([vector 11] 27));
1251 _for_each_inner_interrupt!(([vector 12] 28)); _for_each_inner_interrupt!(([vector
1252 13] 29)); _for_each_inner_interrupt!(([vector 14] 30));
1253 _for_each_inner_interrupt!(([disabled 0] 31));
1254 _for_each_inner_interrupt!((all([reserved 0] 0), ([direct_bindable 0] 1),
1255 ([direct_bindable 1] 2), ([reserved 1] 3), ([reserved 2] 4), ([direct_bindable 2]
1256 5), ([direct_bindable 3] 6), ([reserved 3] 7), ([direct_bindable 4] 8),
1257 ([direct_bindable 5] 9), ([direct_bindable 6] 10), ([direct_bindable 7] 11),
1258 ([direct_bindable 8] 12), ([direct_bindable 9] 13), ([direct_bindable 10] 14),
1259 ([direct_bindable 11] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18),
1260 ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7]
1261 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26), ([vector 11] 27),
1262 ([vector 12] 28), ([vector 13] 29), ([vector 14] 30), ([disabled 0] 31)));
1263 };
1264}
1265#[macro_export]
1266#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1267macro_rules! for_each_classified_interrupt {
1268 ($($pattern:tt => $code:tt;)*) => {
1269 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1270 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1271 1)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 2));
1272 _for_each_inner_classified_interrupt!(([direct_bindable 2] 5));
1273 _for_each_inner_classified_interrupt!(([direct_bindable 3] 6));
1274 _for_each_inner_classified_interrupt!(([direct_bindable 4] 8));
1275 _for_each_inner_classified_interrupt!(([direct_bindable 5] 9));
1276 _for_each_inner_classified_interrupt!(([direct_bindable 6] 10));
1277 _for_each_inner_classified_interrupt!(([direct_bindable 7] 11));
1278 _for_each_inner_classified_interrupt!(([direct_bindable 8] 12));
1279 _for_each_inner_classified_interrupt!(([direct_bindable 9] 13));
1280 _for_each_inner_classified_interrupt!(([direct_bindable 10] 14));
1281 _for_each_inner_classified_interrupt!(([direct_bindable 11] 15));
1282 _for_each_inner_classified_interrupt!(([vector 0] 16));
1283 _for_each_inner_classified_interrupt!(([vector 1] 17));
1284 _for_each_inner_classified_interrupt!(([vector 2] 18));
1285 _for_each_inner_classified_interrupt!(([vector 3] 19));
1286 _for_each_inner_classified_interrupt!(([vector 4] 20));
1287 _for_each_inner_classified_interrupt!(([vector 5] 21));
1288 _for_each_inner_classified_interrupt!(([vector 6] 22));
1289 _for_each_inner_classified_interrupt!(([vector 7] 23));
1290 _for_each_inner_classified_interrupt!(([vector 8] 24));
1291 _for_each_inner_classified_interrupt!(([vector 9] 25));
1292 _for_each_inner_classified_interrupt!(([vector 10] 26));
1293 _for_each_inner_classified_interrupt!(([vector 11] 27));
1294 _for_each_inner_classified_interrupt!(([vector 12] 28));
1295 _for_each_inner_classified_interrupt!(([vector 13] 29));
1296 _for_each_inner_classified_interrupt!(([vector 14] 30));
1297 _for_each_inner_classified_interrupt!(([reserved 0] 0));
1298 _for_each_inner_classified_interrupt!(([reserved 1] 3));
1299 _for_each_inner_classified_interrupt!(([reserved 2] 4));
1300 _for_each_inner_classified_interrupt!(([reserved 3] 7));
1301 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 1),
1302 ([direct_bindable 1] 2), ([direct_bindable 2] 5), ([direct_bindable 3] 6),
1303 ([direct_bindable 4] 8), ([direct_bindable 5] 9), ([direct_bindable 6] 10),
1304 ([direct_bindable 7] 11), ([direct_bindable 8] 12), ([direct_bindable 9] 13),
1305 ([direct_bindable 10] 14), ([direct_bindable 11] 15)));
1306 _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1307 ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1308 22), ([vector 7] 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26),
1309 ([vector 11] 27), ([vector 12] 28), ([vector 13] 29), ([vector 14] 30)));
1310 _for_each_inner_classified_interrupt!((reserved([reserved 0] 0), ([reserved 1]
1311 3), ([reserved 2] 4), ([reserved 3] 7)));
1312 _for_each_inner_classified_interrupt!((context_switch));
1313 };
1314}
1315#[macro_export]
1316#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1317macro_rules! for_each_interrupt_priority {
1318 ($($pattern:tt => $code:tt;)*) => {
1319 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1320 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1321 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1322 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1323 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1324 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1325 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1326 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1327 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1328 _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
1329 _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
1330 _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
1331 _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
1332 _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
1333 _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
1334 _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
1335 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1336 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1337 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1338 Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
1339 11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
1340 Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
1341 };
1342}
1343#[macro_export]
1344#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1345macro_rules! for_each_sw_interrupt {
1346 ($($pattern:tt => $code:tt;)*) => {
1347 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1348 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1349 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1350 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1351 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1352 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1353 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1354 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1355 };
1356}
1357#[macro_export]
1358macro_rules! define_clock_tree_types {
1801 () => {
1802 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1803 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1804 pub enum AdcInstance {
1805 ApbSaradc = 0,
1806 }
1807 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1808 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1809 pub enum SdmInstance {
1810 GpioSd = 0,
1811 }
1812 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1813 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1814 pub enum I2cInstance {
1815 I2c0 = 0,
1816 I2c1 = 1,
1817 }
1818 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1819 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1820 pub enum I2sInstance {
1821 I2s0 = 0,
1822 }
1823 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1824 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1825 pub enum McpwmInstance {
1826 Mcpwm0 = 0,
1827 }
1828 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1829 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1830 pub enum ParlIoInstance {
1831 ParlIo = 0,
1832 }
1833 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1834 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1835 pub enum PcntInstance {
1836 Pcnt = 0,
1837 }
1838 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1839 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1840 pub enum RmtInstance {
1841 Rmt = 0,
1842 }
1843 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1844 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1845 pub enum SpiInstance {
1846 Spi2 = 0,
1847 }
1848 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1849 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1850 pub enum TimgInstance {
1851 Timg0 = 0,
1852 Timg1 = 1,
1853 }
1854 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1855 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1856 pub enum UartInstance {
1857 Uart0 = 0,
1858 Uart1 = 1,
1859 }
1860 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1862 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1863 pub enum XtalClkConfig {
1864 _32,
1866 }
1867 impl XtalClkConfig {
1868 pub fn value(&self) -> u32 {
1869 match self {
1870 XtalClkConfig::_32 => 32000000,
1871 }
1872 }
1873 }
1874 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1876 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1877 pub enum IomuxFunctionClockConfig {
1878 XtalClk,
1880 #[default]
1881 PllF48m,
1883 }
1884 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1886 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1887 pub enum HpRootClkConfig {
1888 Pll96,
1890 Pll64,
1892 Xtal,
1894 RcFast,
1896 }
1897 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1901 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1902 pub struct CpuClkConfig {
1903 divisor: u32,
1904 }
1905 impl CpuClkConfig {
1906 pub const fn new(divisor: u32) -> Self {
1913 ::core::assert!(
1914 divisor <= 255,
1915 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1916 );
1917 Self { divisor }
1918 }
1919 pub fn divisor(self) -> u32 {
1920 self.divisor as u32
1921 }
1922 }
1923 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1927 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1928 pub struct AhbClkConfig {
1929 divisor: u32,
1930 }
1931 impl AhbClkConfig {
1932 pub const fn new(divisor: u32) -> Self {
1939 ::core::assert!(
1940 divisor <= 255,
1941 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1942 );
1943 Self { divisor }
1944 }
1945 pub fn divisor(self) -> u32 {
1946 self.divisor as u32
1947 }
1948 }
1949 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1953 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1954 pub struct ApbClkConfig {
1955 divisor: u32,
1956 }
1957 impl ApbClkConfig {
1958 pub const fn new(divisor: u32) -> Self {
1965 ::core::assert!(
1966 divisor <= 255,
1967 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1968 );
1969 Self { divisor }
1970 }
1971 pub fn divisor(self) -> u32 {
1972 self.divisor as u32
1973 }
1974 }
1975 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1977 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1978 pub enum LpFastClkConfig {
1979 RcFastClk,
1981 #[cfg(use_xtal32k)]
1982 PllLpClk,
1984 XtalD2Clk,
1986 }
1987 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1989 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1990 pub enum LpSlowClkConfig {
1991 #[cfg(use_xtal32k)]
1992 Xtal32k,
1994 RcSlow,
1996 OscSlow,
1998 }
1999 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2001 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2002 pub enum BleLpClkConfig {
2003 Xtal,
2005 RcSlow,
2007 #[cfg(use_xtal32k)]
2008 Xtal32k,
2010 }
2011 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2013 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2014 pub enum CryptoClkConfig {
2015 Xtal,
2017 RcFast,
2019 PllF64m,
2021 PllF96m,
2023 }
2024 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2026 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2027 pub enum TimgCalibrationClockConfig {
2028 RcSlowClk,
2030 RcFastDivClk,
2032 #[cfg(use_xtal32k)]
2033 Xtal32kClk,
2035 }
2036 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2038 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2039 pub enum AdcFunctionClockConfig {
2040 Xtal,
2042 #[default]
2043 PllF96m,
2045 RcFast,
2047 }
2048 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2049 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2050 pub enum I2cFunctionClockSclk {
2051 #[default]
2052 Xtal,
2054 RcFast,
2056 }
2057 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2061 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2062 pub struct I2cFunctionClockConfig {
2063 sclk: I2cFunctionClockSclk,
2064 div_num: u32,
2065 }
2066 impl I2cFunctionClockConfig {
2067 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
2074 ::core::assert!(
2075 div_num <= 255,
2076 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2077 );
2078 Self { sclk, div_num }
2079 }
2080 pub fn sclk(self) -> I2cFunctionClockSclk {
2081 self.sclk
2082 }
2083 pub fn div_num(self) -> u32 {
2084 self.div_num as u32
2085 }
2086 }
2087 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2088 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2089 pub enum I2sClkSclk {
2090 Xtal,
2092 #[default]
2093 PllF96m,
2095 PllF64m,
2097 }
2098 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2102 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2103 pub struct I2sClkConfig {
2104 sclk: I2sClkSclk,
2105 div_num: u32,
2106 div_a: u32,
2107 div_b: u32,
2108 }
2109 impl I2sClkConfig {
2110 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
2123 ::core::assert!(
2124 div_num >= 1 && div_num <= 255,
2125 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
2126 );
2127 ::core::assert!(
2128 div_a >= 1 && div_a <= 511,
2129 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
2130 );
2131 ::core::assert!(
2132 div_b <= 511,
2133 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
2134 );
2135 Self {
2136 sclk,
2137 div_num,
2138 div_a,
2139 div_b,
2140 }
2141 }
2142 pub fn sclk(self) -> I2sClkSclk {
2143 self.sclk
2144 }
2145 pub fn div_num(self) -> u32 {
2146 self.div_num as u32
2147 }
2148 pub fn div_a(self) -> u32 {
2149 self.div_a as u32
2150 }
2151 pub fn div_b(self) -> u32 {
2152 self.div_b as u32
2153 }
2154 }
2155 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2157 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2158 pub enum I2sMclkOutConfig {
2159 Tx,
2161 #[default]
2162 Rx,
2164 }
2165 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2167 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2168 pub enum McpwmFunctionClockConfig {
2169 #[default]
2170 PllF96m,
2172 RcFastClk,
2174 XtalClk,
2176 }
2177 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2179 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2180 pub enum ParlIoClkConfig {
2181 XtalClk,
2183 RcFastClk,
2185 #[default]
2186 PllF96m,
2188 }
2189 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2191 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2192 pub enum RmtSclkConfig {
2193 #[default]
2194 XtalClk,
2196 RcFastClk,
2198 }
2199 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2201 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2202 pub enum SpiFunctionClockConfig {
2203 Xtal,
2205 #[default]
2206 PllF48m,
2208 RcFast,
2210 }
2211 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2213 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2214 pub enum TimgFunctionClockConfig {
2215 #[default]
2216 XtalClk,
2218 RcFastClk,
2220 PllF48m,
2222 }
2223 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2225 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2226 pub enum TimgWdtClockConfig {
2227 #[default]
2228 XtalClk,
2230 RcFastClk,
2232 PllF48m,
2234 }
2235 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2236 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2237 pub enum UartFunctionClockSclk {
2238 PllF48m,
2240 RcFast,
2242 #[default]
2243 Xtal,
2245 }
2246 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2250 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2251 pub struct UartFunctionClockConfig {
2252 sclk: UartFunctionClockSclk,
2253 div_num: u32,
2254 }
2255 impl UartFunctionClockConfig {
2256 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
2263 ::core::assert!(
2264 div_num <= 255,
2265 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2266 );
2267 Self { sclk, div_num }
2268 }
2269 pub fn sclk(self) -> UartFunctionClockSclk {
2270 self.sclk
2271 }
2272 pub fn div_num(self) -> u32 {
2273 self.div_num as u32
2274 }
2275 }
2276 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2281 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2282 pub struct UartBaudRateGeneratorConfig {
2283 fractional: u32,
2284 integral: u32,
2285 }
2286 impl UartBaudRateGeneratorConfig {
2287 pub const fn new(fractional: u32, integral: u32) -> Self {
2297 ::core::assert!(
2298 fractional <= 15,
2299 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2300 );
2301 ::core::assert!(
2302 integral <= 4095,
2303 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2304 );
2305 Self {
2306 fractional,
2307 integral,
2308 }
2309 }
2310 pub fn fractional(self) -> u32 {
2311 self.fractional as u32
2312 }
2313 pub fn integral(self) -> u32 {
2314 self.integral as u32
2315 }
2316 }
2317 pub struct ClockTree {
2319 xtal_clk: Option<XtalClkConfig>,
2320 iomux_function_clock: Option<IomuxFunctionClockConfig>,
2321 hp_root_clk: Option<HpRootClkConfig>,
2322 cpu_clk: Option<CpuClkConfig>,
2323 ahb_clk: Option<AhbClkConfig>,
2324 apb_clk: Option<ApbClkConfig>,
2325 lp_fast_clk: Option<LpFastClkConfig>,
2326 lp_slow_clk: Option<LpSlowClkConfig>,
2327 ble_lp_clk: Option<BleLpClkConfig>,
2328 crypto_clk: Option<CryptoClkConfig>,
2329 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2330 adc_function_clock: [Option<AdcFunctionClockConfig>; 1],
2331 i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
2332 i2s_tx_clk: [Option<I2sClkConfig>; 1],
2333 i2s_rx_clk: [Option<I2sClkConfig>; 1],
2334 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
2335 mcpwm_function_clock: [Option<McpwmFunctionClockConfig>; 1],
2336 parl_io_rx_clock: [Option<ParlIoClkConfig>; 1],
2337 parl_io_tx_clock: [Option<ParlIoClkConfig>; 1],
2338 rmt_sclk: [Option<RmtSclkConfig>; 1],
2339 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
2340 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2341 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2342 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2343 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2344 pub(crate) pll_f96m_clk_refcount: u32,
2345 pub(crate) pll_f64m_clk_refcount: u32,
2346 pub(crate) pll_f48m_clk_refcount: u32,
2347 pub(crate) rc_fast_clk_refcount: u32,
2348 #[cfg(use_xtal32k)]
2349 pub(crate) xtal32k_clk_refcount: u32,
2350 pub(crate) rc_slow_clk_refcount: u32,
2351 pub(crate) hp_root_clk_refcount: u32,
2352 pub(crate) apb_clk_refcount: u32,
2353 pub(crate) lp_fast_clk_refcount: u32,
2354 pub(crate) ble_lp_clk_refcount: u32,
2355 pub(crate) crypto_clk_refcount: u32,
2356 pub(crate) timg_calibration_clock_refcount: u32,
2357 pub(crate) adc_function_clock_refcount: [u32; 1],
2358 pub(crate) sdm_function_clock_refcount: [u32; 1],
2359 pub(crate) i2c_function_clock_refcount: [u32; 2],
2360 pub(crate) i2s_tx_clk_refcount: [u32; 1],
2361 pub(crate) i2s_rx_clk_refcount: [u32; 1],
2362 pub(crate) i2s_mclk_out_refcount: [u32; 1],
2363 pub(crate) mcpwm_function_clock_refcount: [u32; 1],
2364 pub(crate) parl_io_rx_clock_refcount: [u32; 1],
2365 pub(crate) parl_io_tx_clock_refcount: [u32; 1],
2366 pub(crate) pcnt_function_clock_refcount: [u32; 1],
2367 pub(crate) rmt_sclk_refcount: [u32; 1],
2368 pub(crate) spi_function_clock_refcount: [u32; 1],
2369 pub(crate) timg_function_clock_refcount: [u32; 2],
2370 pub(crate) timg_wdt_clock_refcount: [u32; 2],
2371 pub(crate) uart_function_clock_refcount: [u32; 2],
2372 pub(crate) uart_baud_rate_generator_refcount: [u32; 2],
2373 }
2374 impl ClockTree {
2375 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2377 CLOCK_TREE.with(f)
2378 }
2379 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2381 self.xtal_clk
2382 }
2383 pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2385 self.iomux_function_clock
2386 }
2387 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
2389 self.hp_root_clk
2390 }
2391 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2393 self.cpu_clk
2394 }
2395 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
2397 self.ahb_clk
2398 }
2399 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2401 self.apb_clk
2402 }
2403 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2405 self.lp_fast_clk
2406 }
2407 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2409 self.lp_slow_clk
2410 }
2411 pub fn ble_lp_clk(&self) -> Option<BleLpClkConfig> {
2413 self.ble_lp_clk
2414 }
2415 pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
2417 self.crypto_clk
2418 }
2419 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2421 self.timg_calibration_clock
2422 }
2423 pub fn apb_saradc_function_clock(&self) -> Option<AdcFunctionClockConfig> {
2425 self.adc_function_clock[AdcInstance::ApbSaradc as usize]
2426 }
2427 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2429 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2430 }
2431 pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2433 self.i2c_function_clock[I2cInstance::I2c1 as usize]
2434 }
2435 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
2437 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
2438 }
2439 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
2441 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
2442 }
2443 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
2445 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
2446 }
2447 pub fn mcpwm0_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
2449 self.mcpwm_function_clock[McpwmInstance::Mcpwm0 as usize]
2450 }
2451 pub fn parl_io_rx_clock(&self) -> Option<ParlIoClkConfig> {
2453 self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
2454 }
2455 pub fn parl_io_tx_clock(&self) -> Option<ParlIoClkConfig> {
2457 self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
2458 }
2459 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2461 self.rmt_sclk[RmtInstance::Rmt as usize]
2462 }
2463 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2465 self.spi_function_clock[SpiInstance::Spi2 as usize]
2466 }
2467 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2469 self.timg_function_clock[TimgInstance::Timg0 as usize]
2470 }
2471 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2473 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2474 }
2475 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2477 self.timg_function_clock[TimgInstance::Timg1 as usize]
2478 }
2479 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2481 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2482 }
2483 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2485 self.uart_function_clock[UartInstance::Uart0 as usize]
2486 }
2487 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2489 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2490 }
2491 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2493 self.uart_function_clock[UartInstance::Uart1 as usize]
2494 }
2495 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2497 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2498 }
2499 }
2500 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2501 ::esp_sync::NonReentrantMutex::new(ClockTree {
2502 xtal_clk: None,
2503 iomux_function_clock: None,
2504 hp_root_clk: None,
2505 cpu_clk: None,
2506 ahb_clk: None,
2507 apb_clk: None,
2508 lp_fast_clk: None,
2509 lp_slow_clk: None,
2510 ble_lp_clk: None,
2511 crypto_clk: None,
2512 timg_calibration_clock: None,
2513 adc_function_clock: [None; 1],
2514 i2c_function_clock: [None; 2],
2515 i2s_tx_clk: [None; 1],
2516 i2s_rx_clk: [None; 1],
2517 i2s_mclk_out: [None; 1],
2518 mcpwm_function_clock: [None; 1],
2519 parl_io_rx_clock: [None; 1],
2520 parl_io_tx_clock: [None; 1],
2521 rmt_sclk: [None; 1],
2522 spi_function_clock: [None; 1],
2523 timg_function_clock: [None; 2],
2524 timg_wdt_clock: [None; 2],
2525 uart_function_clock: [None; 2],
2526 uart_baud_rate_generator: [None; 2],
2527 pll_f96m_clk_refcount: 0,
2528 pll_f64m_clk_refcount: 0,
2529 pll_f48m_clk_refcount: 0,
2530 rc_fast_clk_refcount: 0,
2531 #[cfg(use_xtal32k)]
2532 xtal32k_clk_refcount: 0,
2533 rc_slow_clk_refcount: 0,
2534 hp_root_clk_refcount: 0,
2535 apb_clk_refcount: 0,
2536 lp_fast_clk_refcount: 0,
2537 ble_lp_clk_refcount: 0,
2538 crypto_clk_refcount: 0,
2539 timg_calibration_clock_refcount: 0,
2540 adc_function_clock_refcount: [0; 1],
2541 sdm_function_clock_refcount: [0; 1],
2542 i2c_function_clock_refcount: [0; 2],
2543 i2s_tx_clk_refcount: [0; 1],
2544 i2s_rx_clk_refcount: [0; 1],
2545 i2s_mclk_out_refcount: [0; 1],
2546 mcpwm_function_clock_refcount: [0; 1],
2547 parl_io_rx_clock_refcount: [0; 1],
2548 parl_io_tx_clock_refcount: [0; 1],
2549 pcnt_function_clock_refcount: [0; 1],
2550 rmt_sclk_refcount: [0; 1],
2551 spi_function_clock_refcount: [0; 1],
2552 timg_function_clock_refcount: [0; 2],
2553 timg_wdt_clock_refcount: [0; 2],
2554 uart_function_clock_refcount: [0; 2],
2555 uart_baud_rate_generator_refcount: [0; 2],
2556 });
2557 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2558 ::core::sync::atomic::AtomicU32::new(0);
2559 static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2560 ::core::sync::atomic::AtomicU32::new(0);
2561 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2562 ::core::sync::atomic::AtomicU32::new(0);
2563 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2564 ::core::sync::atomic::AtomicU32::new(0);
2565 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2566 ::core::sync::atomic::AtomicU32::new(0);
2567 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2568 ::core::sync::atomic::AtomicU32::new(0);
2569 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2570 ::core::sync::atomic::AtomicU32::new(0);
2571 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2572 ::core::sync::atomic::AtomicU32::new(0);
2573 static BLE_LP_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2574 ::core::sync::atomic::AtomicU32::new(0);
2575 static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2576 ::core::sync::atomic::AtomicU32::new(0);
2577 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2578 ::core::sync::atomic::AtomicU32::new(0);
2579 static ADC_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2580 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2581 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2582 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2583 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2584 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2585 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2586 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2587 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2588 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2589 static MCPWM_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2590 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2591 static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2592 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2593 static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2594 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2595 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2596 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2597 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2598 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2599 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2600 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2601 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2602 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2603 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2604 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2605 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2606 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2607 #[derive(Debug, enumset::EnumSetType)]
2612 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2613 pub enum ClockSource {
2614 XtalClk,
2616 RcFastClk,
2618 #[cfg(use_xtal32k)]
2619 Xtal32kClk,
2621 OscSlowClk,
2623 RcSlowClk,
2625 }
2626 pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2628 Some(ClockSource::XtalClk)
2629 }
2630 pub fn pll_f96m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2632 xtal_clk_root_source(clocks)
2633 }
2634 pub fn pll_f64m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2636 pll_f96m_clk_root_source(clocks)
2637 }
2638 pub fn pll_f48m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2640 pll_f96m_clk_root_source(clocks)
2641 }
2642 pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2644 Some(ClockSource::RcFastClk)
2645 }
2646 pub fn iomux_function_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2648 let config = clocks.iomux_function_clock?;
2649 match config {
2650 IomuxFunctionClockConfig::XtalClk => xtal_clk_root_source(clocks),
2651 IomuxFunctionClockConfig::PllF48m => pll_f48m_clk_root_source(clocks),
2652 }
2653 }
2654 #[cfg(use_xtal32k)]
2655 pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2657 Some(ClockSource::Xtal32kClk)
2658 }
2659 pub fn osc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2661 Some(ClockSource::OscSlowClk)
2662 }
2663 pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2665 Some(ClockSource::RcSlowClk)
2666 }
2667 #[cfg(use_xtal32k)]
2668 pub fn pll_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2670 xtal32k_clk_root_source(clocks)
2671 }
2672 pub fn hp_root_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2674 let config = clocks.hp_root_clk?;
2675 match config {
2676 HpRootClkConfig::Pll96 => pll_f96m_clk_root_source(clocks),
2677 HpRootClkConfig::Pll64 => pll_f64m_clk_root_source(clocks),
2678 HpRootClkConfig::Xtal => xtal_clk_root_source(clocks),
2679 HpRootClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2680 }
2681 }
2682 pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2684 hp_root_clk_root_source(clocks)
2685 }
2686 pub fn ahb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2688 hp_root_clk_root_source(clocks)
2689 }
2690 pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2692 ahb_clk_root_source(clocks)
2693 }
2694 pub fn xtal_d2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2696 xtal_clk_root_source(clocks)
2697 }
2698 pub fn lp_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2700 let config = clocks.lp_fast_clk?;
2701 match config {
2702 LpFastClkConfig::RcFastClk => rc_fast_clk_root_source(clocks),
2703 #[cfg(use_xtal32k)]
2704 LpFastClkConfig::PllLpClk => pll_lp_clk_root_source(clocks),
2705 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_root_source(clocks),
2706 }
2707 }
2708 pub fn lp_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2710 let config = clocks.lp_slow_clk?;
2711 match config {
2712 #[cfg(use_xtal32k)]
2713 LpSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2714 LpSlowClkConfig::RcSlow => rc_slow_clk_root_source(clocks),
2715 LpSlowClkConfig::OscSlow => osc_slow_clk_root_source(clocks),
2716 }
2717 }
2718 pub fn ble_lp_xtal_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2720 xtal_clk_root_source(clocks)
2721 }
2722 pub fn ble_lp_rc_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2724 rc_slow_clk_root_source(clocks)
2725 }
2726 pub fn ble_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2728 let config = clocks.ble_lp_clk?;
2729 match config {
2730 BleLpClkConfig::Xtal => ble_lp_xtal_clk_root_source(clocks),
2731 BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_root_source(clocks),
2732 #[cfg(use_xtal32k)]
2733 BleLpClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2734 }
2735 }
2736 pub fn crypto_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2738 let config = clocks.crypto_clk?;
2739 match config {
2740 CryptoClkConfig::Xtal => xtal_clk_root_source(clocks),
2741 CryptoClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2742 CryptoClkConfig::PllF64m => pll_f64m_clk_root_source(clocks),
2743 CryptoClkConfig::PllF96m => pll_f96m_clk_root_source(clocks),
2744 }
2745 }
2746 pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2748 let config = clocks.timg_calibration_clock?;
2749 match config {
2750 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_root_source(clocks),
2751 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_root_source(clocks),
2752 #[cfg(use_xtal32k)]
2753 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
2754 }
2755 }
2756 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2757 let old_config = clocks.xtal_clk.replace(config);
2758 refresh_xtal_clk_downstream(clocks);
2759 configure_xtal_clk_impl(clocks, old_config, config);
2760 }
2761 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2762 clocks.xtal_clk
2763 }
2764 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2765 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2766 pub fn xtal_clk_config_frequency(config: XtalClkConfig) -> u32 {
2767 config.value()
2768 }
2769 pub fn xtal_clk_frequency() -> u32 {
2770 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2771 }
2772 pub fn request_pll_f96m_clk(clocks: &mut ClockTree) {
2773 trace!("Requesting PLL_F96M_CLK");
2774 if increment_reference_count(&mut clocks.pll_f96m_clk_refcount) {
2775 trace!("Enabling PLL_F96M_CLK");
2776 request_xtal_clk(clocks);
2777 enable_pll_f96m_clk_impl(clocks, true);
2778 }
2779 }
2780 pub fn release_pll_f96m_clk(clocks: &mut ClockTree) {
2781 trace!("Releasing PLL_F96M_CLK");
2782 if decrement_reference_count(&mut clocks.pll_f96m_clk_refcount) {
2783 trace!("Disabling PLL_F96M_CLK");
2784 enable_pll_f96m_clk_impl(clocks, false);
2785 release_xtal_clk(clocks);
2786 }
2787 }
2788 pub fn pll_f96m_clk_frequency() -> u32 {
2789 96000000
2790 }
2791 pub fn pll_f96m_clk_source_frequency() -> u32 {
2792 xtal_clk_frequency()
2793 }
2794 pub fn request_pll_f64m_clk(clocks: &mut ClockTree) {
2795 trace!("Requesting PLL_F64M_CLK");
2796 if increment_reference_count(&mut clocks.pll_f64m_clk_refcount) {
2797 trace!("Enabling PLL_F64M_CLK");
2798 request_pll_f96m_clk(clocks);
2799 enable_pll_f64m_clk_impl(clocks, true);
2800 }
2801 }
2802 pub fn release_pll_f64m_clk(clocks: &mut ClockTree) {
2803 trace!("Releasing PLL_F64M_CLK");
2804 if decrement_reference_count(&mut clocks.pll_f64m_clk_refcount) {
2805 trace!("Disabling PLL_F64M_CLK");
2806 enable_pll_f64m_clk_impl(clocks, false);
2807 release_pll_f96m_clk(clocks);
2808 }
2809 }
2810 pub fn pll_f64m_clk_frequency() -> u32 {
2811 ((pll_f96m_clk_frequency() * 2) / 3)
2812 }
2813 pub fn pll_f64m_clk_source_frequency() -> u32 {
2814 pll_f96m_clk_frequency()
2815 }
2816 pub fn request_pll_f48m_clk(clocks: &mut ClockTree) {
2817 trace!("Requesting PLL_F48M_CLK");
2818 if increment_reference_count(&mut clocks.pll_f48m_clk_refcount) {
2819 trace!("Enabling PLL_F48M_CLK");
2820 request_pll_f96m_clk(clocks);
2821 enable_pll_f48m_clk_impl(clocks, true);
2822 }
2823 }
2824 pub fn release_pll_f48m_clk(clocks: &mut ClockTree) {
2825 trace!("Releasing PLL_F48M_CLK");
2826 if decrement_reference_count(&mut clocks.pll_f48m_clk_refcount) {
2827 trace!("Disabling PLL_F48M_CLK");
2828 enable_pll_f48m_clk_impl(clocks, false);
2829 release_pll_f96m_clk(clocks);
2830 }
2831 }
2832 pub fn pll_f48m_clk_frequency() -> u32 {
2833 (pll_f96m_clk_frequency() / 2)
2834 }
2835 pub fn pll_f48m_clk_source_frequency() -> u32 {
2836 pll_f96m_clk_frequency()
2837 }
2838 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2839 trace!("Requesting RC_FAST_CLK");
2840 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2841 trace!("Enabling RC_FAST_CLK");
2842 enable_rc_fast_clk_impl(clocks, true);
2843 }
2844 }
2845 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2846 trace!("Releasing RC_FAST_CLK");
2847 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2848 trace!("Disabling RC_FAST_CLK");
2849 enable_rc_fast_clk_impl(clocks, false);
2850 }
2851 }
2852 static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2853 ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
2854 pub const fn rc_fast_clk_nominal_frequency() -> u32 {
2855 8000000
2856 }
2857 pub fn rc_fast_clk_frequency() -> u32 {
2858 RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2859 }
2860 pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2861 if !(4000000..=12000000).contains(&frequency) {
2862 warn!(
2863 "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
2864 frequency
2865 );
2866 return;
2867 }
2868 debug!(
2869 "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
2870 frequency,
2871 rc_fast_clk_nominal_frequency()
2872 );
2873 RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2874 refresh_rc_fast_clk_downstream(clocks);
2875 }
2876 pub fn configure_iomux_function_clock(
2877 clocks: &mut ClockTree,
2878 new_selector: IomuxFunctionClockConfig,
2879 ) {
2880 let old_selector = clocks.iomux_function_clock.replace(new_selector);
2881 refresh_iomux_function_clock_downstream(clocks);
2882 match new_selector {
2883 IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2884 IomuxFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2885 }
2886 configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
2887 if let Some(old_selector) = old_selector {
2888 match old_selector {
2889 IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2890 IomuxFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2891 }
2892 }
2893 }
2894 pub fn iomux_function_clock_config(
2895 clocks: &mut ClockTree,
2896 ) -> Option<IomuxFunctionClockConfig> {
2897 clocks.iomux_function_clock
2898 }
2899 fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
2900 fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
2901 pub fn iomux_function_clock_config_frequency(config: IomuxFunctionClockConfig) -> u32 {
2902 match config {
2903 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2904 IomuxFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
2905 }
2906 }
2907 pub fn iomux_function_clock_frequency() -> u32 {
2908 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2909 }
2910 pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
2911 iomux_function_clock_config_frequency(source)
2912 }
2913 #[cfg(use_xtal32k)]
2914 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2915 trace!("Requesting XTAL32K_CLK");
2916 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2917 trace!("Enabling XTAL32K_CLK");
2918 enable_xtal32k_clk_impl(clocks, true);
2919 }
2920 }
2921 #[cfg(use_xtal32k)]
2922 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2923 trace!("Releasing XTAL32K_CLK");
2924 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2925 trace!("Disabling XTAL32K_CLK");
2926 enable_xtal32k_clk_impl(clocks, false);
2927 }
2928 }
2929 #[cfg(use_xtal32k)]
2930 pub fn xtal32k_clk_frequency() -> u32 {
2931 32768
2932 }
2933 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2934 trace!("Enabling OSC_SLOW_CLK");
2935 enable_osc_slow_clk_impl(clocks, true);
2936 }
2937 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2938 trace!("Disabling OSC_SLOW_CLK");
2939 enable_osc_slow_clk_impl(clocks, false);
2940 }
2941 pub fn osc_slow_clk_frequency() -> u32 {
2942 32768
2943 }
2944 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2945 trace!("Requesting RC_SLOW_CLK");
2946 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
2947 trace!("Enabling RC_SLOW_CLK");
2948 enable_rc_slow_clk_impl(clocks, true);
2949 }
2950 }
2951 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2952 trace!("Releasing RC_SLOW_CLK");
2953 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
2954 trace!("Disabling RC_SLOW_CLK");
2955 enable_rc_slow_clk_impl(clocks, false);
2956 }
2957 }
2958 static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2959 ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
2960 pub const fn rc_slow_clk_nominal_frequency() -> u32 {
2961 130000
2962 }
2963 pub fn rc_slow_clk_frequency() -> u32 {
2964 RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2965 }
2966 pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2967 if !(65000..=195000).contains(&frequency) {
2968 warn!(
2969 "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
2970 frequency
2971 );
2972 return;
2973 }
2974 debug!(
2975 "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
2976 frequency,
2977 rc_slow_clk_nominal_frequency()
2978 );
2979 RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2980 refresh_rc_slow_clk_downstream(clocks);
2981 }
2982 #[cfg(use_xtal32k)]
2983 pub fn request_pll_lp_clk(clocks: &mut ClockTree) {
2984 trace!("Enabling PLL_LP_CLK");
2985 request_xtal32k_clk(clocks);
2986 enable_pll_lp_clk_impl(clocks, true);
2987 }
2988 #[cfg(use_xtal32k)]
2989 pub fn release_pll_lp_clk(clocks: &mut ClockTree) {
2990 trace!("Disabling PLL_LP_CLK");
2991 enable_pll_lp_clk_impl(clocks, false);
2992 release_xtal32k_clk(clocks);
2993 }
2994 #[cfg(use_xtal32k)]
2995 pub fn pll_lp_clk_frequency() -> u32 {
2996 8000000
2997 }
2998 #[cfg(use_xtal32k)]
2999 pub fn pll_lp_clk_source_frequency() -> u32 {
3000 xtal32k_clk_frequency()
3001 }
3002 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
3003 let old_selector = clocks.hp_root_clk.replace(new_selector);
3004 refresh_hp_root_clk_downstream(clocks);
3005 let active = clocks.hp_root_clk_refcount > 0;
3006 if active {
3007 match new_selector {
3008 HpRootClkConfig::Pll96 => request_pll_f96m_clk(clocks),
3009 HpRootClkConfig::Pll64 => request_pll_f64m_clk(clocks),
3010 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
3011 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3012 }
3013 }
3014 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
3015 if active && let Some(old_selector) = old_selector {
3016 match old_selector {
3017 HpRootClkConfig::Pll96 => release_pll_f96m_clk(clocks),
3018 HpRootClkConfig::Pll64 => release_pll_f64m_clk(clocks),
3019 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
3020 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3021 }
3022 }
3023 }
3024 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
3025 clocks.hp_root_clk
3026 }
3027 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
3028 trace!("Requesting HP_ROOT_CLK");
3029 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
3030 trace!("Enabling HP_ROOT_CLK");
3031 match unwrap!(clocks.hp_root_clk) {
3032 HpRootClkConfig::Pll96 => request_pll_f96m_clk(clocks),
3033 HpRootClkConfig::Pll64 => request_pll_f64m_clk(clocks),
3034 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
3035 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
3036 }
3037 enable_hp_root_clk_impl(clocks, true);
3038 }
3039 }
3040 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
3041 trace!("Releasing HP_ROOT_CLK");
3042 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
3043 trace!("Disabling HP_ROOT_CLK");
3044 enable_hp_root_clk_impl(clocks, false);
3045 match unwrap!(clocks.hp_root_clk) {
3046 HpRootClkConfig::Pll96 => release_pll_f96m_clk(clocks),
3047 HpRootClkConfig::Pll64 => release_pll_f64m_clk(clocks),
3048 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
3049 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
3050 }
3051 }
3052 }
3053 pub fn hp_root_clk_config_frequency(config: HpRootClkConfig) -> u32 {
3054 match config {
3055 HpRootClkConfig::Pll96 => pll_f96m_clk_frequency(),
3056 HpRootClkConfig::Pll64 => pll_f64m_clk_frequency(),
3057 HpRootClkConfig::Xtal => xtal_clk_frequency(),
3058 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
3059 }
3060 }
3061 pub fn hp_root_clk_frequency() -> u32 {
3062 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3063 }
3064 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
3065 hp_root_clk_config_frequency(source)
3066 }
3067 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
3068 let old_config = clocks.cpu_clk.replace(config);
3069 refresh_cpu_clk_downstream(clocks);
3070 if old_config.is_none() {
3071 request_hp_root_clk(clocks);
3072 }
3073 configure_cpu_clk_impl(clocks, old_config, config);
3074 }
3075 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
3076 clocks.cpu_clk
3077 }
3078 fn request_cpu_clk(_clocks: &mut ClockTree) {}
3079 fn release_cpu_clk(_clocks: &mut ClockTree) {}
3080 pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
3081 (hp_root_clk_frequency() / (config.divisor() + 1))
3082 }
3083 pub fn cpu_clk_frequency() -> u32 {
3084 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3085 }
3086 pub fn cpu_clk_source_frequency() -> u32 {
3087 hp_root_clk_frequency()
3088 }
3089 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
3090 let old_config = clocks.ahb_clk.replace(config);
3091 refresh_ahb_clk_downstream(clocks);
3092 if old_config.is_none() {
3093 request_hp_root_clk(clocks);
3094 }
3095 configure_ahb_clk_impl(clocks, old_config, config);
3096 }
3097 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
3098 clocks.ahb_clk
3099 }
3100 fn request_ahb_clk(_clocks: &mut ClockTree) {}
3101 fn release_ahb_clk(_clocks: &mut ClockTree) {}
3102 pub fn ahb_clk_config_frequency(config: AhbClkConfig) -> u32 {
3103 (hp_root_clk_frequency() / (config.divisor() + 1))
3104 }
3105 pub fn ahb_clk_frequency() -> u32 {
3106 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3107 }
3108 pub fn ahb_clk_source_frequency() -> u32 {
3109 hp_root_clk_frequency()
3110 }
3111 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
3112 let old_config = clocks.apb_clk.replace(config);
3113 refresh_apb_clk_downstream(clocks);
3114 if old_config.is_none() {
3115 request_ahb_clk(clocks);
3116 }
3117 configure_apb_clk_impl(clocks, old_config, config);
3118 }
3119 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
3120 clocks.apb_clk
3121 }
3122 pub fn request_apb_clk(clocks: &mut ClockTree) {
3123 trace!("Requesting APB_CLK");
3124 if increment_reference_count(&mut clocks.apb_clk_refcount) {
3125 enable_apb_clk_impl(clocks, true);
3126 }
3127 }
3128 pub fn release_apb_clk(clocks: &mut ClockTree) {
3129 trace!("Releasing APB_CLK");
3130 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
3131 enable_apb_clk_impl(clocks, false);
3132 }
3133 }
3134 pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
3135 (ahb_clk_frequency() / (config.divisor() + 1))
3136 }
3137 pub fn apb_clk_frequency() -> u32 {
3138 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3139 }
3140 pub fn apb_clk_source_frequency() -> u32 {
3141 ahb_clk_frequency()
3142 }
3143 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
3144 trace!("Enabling XTAL_D2_CLK");
3145 request_xtal_clk(clocks);
3146 enable_xtal_d2_clk_impl(clocks, true);
3147 }
3148 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
3149 trace!("Disabling XTAL_D2_CLK");
3150 enable_xtal_d2_clk_impl(clocks, false);
3151 release_xtal_clk(clocks);
3152 }
3153 pub fn xtal_d2_clk_frequency() -> u32 {
3154 (xtal_clk_frequency() / 2)
3155 }
3156 pub fn xtal_d2_clk_source_frequency() -> u32 {
3157 xtal_clk_frequency()
3158 }
3159 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
3160 let old_selector = clocks.lp_fast_clk.replace(new_selector);
3161 refresh_lp_fast_clk_downstream(clocks);
3162 let active = clocks.lp_fast_clk_refcount > 0;
3163 if active {
3164 match new_selector {
3165 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3166 #[cfg(use_xtal32k)]
3167 LpFastClkConfig::PllLpClk => request_pll_lp_clk(clocks),
3168 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
3169 }
3170 }
3171 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
3172 if active && let Some(old_selector) = old_selector {
3173 match old_selector {
3174 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3175 #[cfg(use_xtal32k)]
3176 LpFastClkConfig::PllLpClk => release_pll_lp_clk(clocks),
3177 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
3178 }
3179 }
3180 }
3181 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
3182 clocks.lp_fast_clk
3183 }
3184 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
3185 trace!("Requesting LP_FAST_CLK");
3186 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
3187 trace!("Enabling LP_FAST_CLK");
3188 match unwrap!(clocks.lp_fast_clk) {
3189 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3190 #[cfg(use_xtal32k)]
3191 LpFastClkConfig::PllLpClk => request_pll_lp_clk(clocks),
3192 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
3193 }
3194 enable_lp_fast_clk_impl(clocks, true);
3195 }
3196 }
3197 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
3198 trace!("Releasing LP_FAST_CLK");
3199 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
3200 trace!("Disabling LP_FAST_CLK");
3201 enable_lp_fast_clk_impl(clocks, false);
3202 match unwrap!(clocks.lp_fast_clk) {
3203 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3204 #[cfg(use_xtal32k)]
3205 LpFastClkConfig::PllLpClk => release_pll_lp_clk(clocks),
3206 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
3207 }
3208 }
3209 }
3210 pub fn lp_fast_clk_config_frequency(config: LpFastClkConfig) -> u32 {
3211 match config {
3212 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
3213 #[cfg(use_xtal32k)]
3214 LpFastClkConfig::PllLpClk => pll_lp_clk_frequency(),
3215 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
3216 }
3217 }
3218 pub fn lp_fast_clk_frequency() -> u32 {
3219 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3220 }
3221 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
3222 lp_fast_clk_config_frequency(source)
3223 }
3224 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
3225 let old_selector = clocks.lp_slow_clk.replace(new_selector);
3226 refresh_lp_slow_clk_downstream(clocks);
3227 match new_selector {
3228 #[cfg(use_xtal32k)]
3229 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3230 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3231 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3232 }
3233 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
3234 if let Some(old_selector) = old_selector {
3235 match old_selector {
3236 #[cfg(use_xtal32k)]
3237 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3238 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3239 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3240 }
3241 }
3242 }
3243 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
3244 clocks.lp_slow_clk
3245 }
3246 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
3247 trace!("Enabling LP_SLOW_CLK");
3248 match unwrap!(clocks.lp_slow_clk) {
3249 #[cfg(use_xtal32k)]
3250 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3251 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3252 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
3253 }
3254 enable_lp_slow_clk_impl(clocks, true);
3255 }
3256 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
3257 trace!("Disabling LP_SLOW_CLK");
3258 enable_lp_slow_clk_impl(clocks, false);
3259 match unwrap!(clocks.lp_slow_clk) {
3260 #[cfg(use_xtal32k)]
3261 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3262 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3263 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
3264 }
3265 }
3266 pub fn lp_slow_clk_config_frequency(config: LpSlowClkConfig) -> u32 {
3267 match config {
3268 #[cfg(use_xtal32k)]
3269 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3270 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3271 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
3272 }
3273 }
3274 pub fn lp_slow_clk_frequency() -> u32 {
3275 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3276 }
3277 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
3278 lp_slow_clk_config_frequency(source)
3279 }
3280 pub fn request_ble_lp_xtal_clk(clocks: &mut ClockTree) {
3281 trace!("Enabling BLE_LP_XTAL_CLK");
3282 request_xtal_clk(clocks);
3283 enable_ble_lp_xtal_clk_impl(clocks, true);
3284 }
3285 pub fn release_ble_lp_xtal_clk(clocks: &mut ClockTree) {
3286 trace!("Disabling BLE_LP_XTAL_CLK");
3287 enable_ble_lp_xtal_clk_impl(clocks, false);
3288 release_xtal_clk(clocks);
3289 }
3290 pub fn ble_lp_xtal_clk_frequency() -> u32 {
3291 100000
3292 }
3293 pub fn ble_lp_xtal_clk_source_frequency() -> u32 {
3294 xtal_clk_frequency()
3295 }
3296 pub fn request_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
3297 trace!("Enabling BLE_LP_RC_SLOW_CLK");
3298 request_rc_slow_clk(clocks);
3299 enable_ble_lp_rc_slow_clk_impl(clocks, true);
3300 }
3301 pub fn release_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
3302 trace!("Disabling BLE_LP_RC_SLOW_CLK");
3303 enable_ble_lp_rc_slow_clk_impl(clocks, false);
3304 release_rc_slow_clk(clocks);
3305 }
3306 pub fn ble_lp_rc_slow_clk_frequency() -> u32 {
3307 (rc_slow_clk_frequency() / 5)
3308 }
3309 pub fn ble_lp_rc_slow_clk_source_frequency() -> u32 {
3310 rc_slow_clk_frequency()
3311 }
3312 pub fn configure_ble_lp_clk(clocks: &mut ClockTree, new_selector: BleLpClkConfig) {
3313 let old_selector = clocks.ble_lp_clk.replace(new_selector);
3314 refresh_ble_lp_clk_downstream(clocks);
3315 let active = clocks.ble_lp_clk_refcount > 0;
3316 if active {
3317 match new_selector {
3318 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
3319 BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
3320 #[cfg(use_xtal32k)]
3321 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3322 }
3323 }
3324 configure_ble_lp_clk_impl(clocks, old_selector, new_selector);
3325 if active && let Some(old_selector) = old_selector {
3326 match old_selector {
3327 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
3328 BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
3329 #[cfg(use_xtal32k)]
3330 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3331 }
3332 }
3333 }
3334 pub fn ble_lp_clk_config(clocks: &mut ClockTree) -> Option<BleLpClkConfig> {
3335 clocks.ble_lp_clk
3336 }
3337 pub fn request_ble_lp_clk(clocks: &mut ClockTree) {
3338 trace!("Requesting BLE_LP_CLK");
3339 if increment_reference_count(&mut clocks.ble_lp_clk_refcount) {
3340 trace!("Enabling BLE_LP_CLK");
3341 match unwrap!(clocks.ble_lp_clk) {
3342 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
3343 BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
3344 #[cfg(use_xtal32k)]
3345 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3346 }
3347 enable_ble_lp_clk_impl(clocks, true);
3348 }
3349 }
3350 pub fn release_ble_lp_clk(clocks: &mut ClockTree) {
3351 trace!("Releasing BLE_LP_CLK");
3352 if decrement_reference_count(&mut clocks.ble_lp_clk_refcount) {
3353 trace!("Disabling BLE_LP_CLK");
3354 enable_ble_lp_clk_impl(clocks, false);
3355 match unwrap!(clocks.ble_lp_clk) {
3356 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
3357 BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
3358 #[cfg(use_xtal32k)]
3359 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3360 }
3361 }
3362 }
3363 pub fn ble_lp_clk_config_frequency(config: BleLpClkConfig) -> u32 {
3364 match config {
3365 BleLpClkConfig::Xtal => ble_lp_xtal_clk_frequency(),
3366 BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_frequency(),
3367 #[cfg(use_xtal32k)]
3368 BleLpClkConfig::Xtal32k => xtal32k_clk_frequency(),
3369 }
3370 }
3371 pub fn ble_lp_clk_frequency() -> u32 {
3372 BLE_LP_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3373 }
3374 pub fn ble_lp_clk_source_frequency(source: BleLpClkConfig) -> u32 {
3375 ble_lp_clk_config_frequency(source)
3376 }
3377 pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
3378 let old_selector = clocks.crypto_clk.replace(new_selector);
3379 refresh_crypto_clk_downstream(clocks);
3380 let active = clocks.crypto_clk_refcount > 0;
3381 if active {
3382 match new_selector {
3383 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
3384 CryptoClkConfig::RcFast => request_rc_fast_clk(clocks),
3385 CryptoClkConfig::PllF64m => request_pll_f64m_clk(clocks),
3386 CryptoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3387 }
3388 }
3389 configure_crypto_clk_impl(clocks, old_selector, new_selector);
3390 if active && let Some(old_selector) = old_selector {
3391 match old_selector {
3392 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
3393 CryptoClkConfig::RcFast => release_rc_fast_clk(clocks),
3394 CryptoClkConfig::PllF64m => release_pll_f64m_clk(clocks),
3395 CryptoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3396 }
3397 }
3398 }
3399 pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
3400 clocks.crypto_clk
3401 }
3402 pub fn request_crypto_clk(clocks: &mut ClockTree) {
3403 trace!("Requesting CRYPTO_CLK");
3404 if increment_reference_count(&mut clocks.crypto_clk_refcount) {
3405 trace!("Enabling CRYPTO_CLK");
3406 match unwrap!(clocks.crypto_clk) {
3407 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
3408 CryptoClkConfig::RcFast => request_rc_fast_clk(clocks),
3409 CryptoClkConfig::PllF64m => request_pll_f64m_clk(clocks),
3410 CryptoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3411 }
3412 enable_crypto_clk_impl(clocks, true);
3413 }
3414 }
3415 pub fn release_crypto_clk(clocks: &mut ClockTree) {
3416 trace!("Releasing CRYPTO_CLK");
3417 if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
3418 trace!("Disabling CRYPTO_CLK");
3419 enable_crypto_clk_impl(clocks, false);
3420 match unwrap!(clocks.crypto_clk) {
3421 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
3422 CryptoClkConfig::RcFast => release_rc_fast_clk(clocks),
3423 CryptoClkConfig::PllF64m => release_pll_f64m_clk(clocks),
3424 CryptoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3425 }
3426 }
3427 }
3428 pub fn crypto_clk_config_frequency(config: CryptoClkConfig) -> u32 {
3429 match config {
3430 CryptoClkConfig::Xtal => xtal_clk_frequency(),
3431 CryptoClkConfig::RcFast => rc_fast_clk_frequency(),
3432 CryptoClkConfig::PllF64m => pll_f64m_clk_frequency(),
3433 CryptoClkConfig::PllF96m => pll_f96m_clk_frequency(),
3434 }
3435 }
3436 pub fn crypto_clk_frequency() -> u32 {
3437 CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3438 }
3439 pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
3440 crypto_clk_config_frequency(source)
3441 }
3442 pub fn configure_timg_calibration_clock(
3443 clocks: &mut ClockTree,
3444 new_selector: TimgCalibrationClockConfig,
3445 ) {
3446 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3447 refresh_timg_calibration_clock_downstream(clocks);
3448 let active = clocks.timg_calibration_clock_refcount > 0;
3449 if active {
3450 match new_selector {
3451 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
3452 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3453 #[cfg(use_xtal32k)]
3454 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3455 }
3456 }
3457 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3458 if active && let Some(old_selector) = old_selector {
3459 match old_selector {
3460 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
3461 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3462 #[cfg(use_xtal32k)]
3463 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3464 }
3465 }
3466 }
3467 pub fn timg_calibration_clock_config(
3468 clocks: &mut ClockTree,
3469 ) -> Option<TimgCalibrationClockConfig> {
3470 clocks.timg_calibration_clock
3471 }
3472 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3473 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3474 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3475 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3476 crate::rtc_cntl::WakeLock::acquire();
3477 match unwrap!(clocks.timg_calibration_clock) {
3478 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
3479 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3480 #[cfg(use_xtal32k)]
3481 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3482 }
3483 enable_timg_calibration_clock_impl(clocks, true);
3484 }
3485 }
3486 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3487 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3488 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3489 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3490 crate::rtc_cntl::WakeLock::release();
3491 enable_timg_calibration_clock_impl(clocks, false);
3492 match unwrap!(clocks.timg_calibration_clock) {
3493 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
3494 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3495 #[cfg(use_xtal32k)]
3496 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3497 }
3498 }
3499 }
3500 pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
3501 match config {
3502 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
3503 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3504 #[cfg(use_xtal32k)]
3505 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3506 }
3507 }
3508 pub fn timg_calibration_clock_frequency() -> u32 {
3509 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3510 }
3511 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3512 timg_calibration_clock_config_frequency(source)
3513 }
3514 impl AdcInstance {
3515 pub fn configure_function_clock(
3516 self,
3517 clocks: &mut ClockTree,
3518 new_selector: AdcFunctionClockConfig,
3519 ) {
3520 let old_selector = clocks.adc_function_clock[self as usize].replace(new_selector);
3521 refresh_adc_function_clock_downstream(clocks, self);
3522 let active = clocks.adc_function_clock_refcount[self as usize] > 0;
3523 if active {
3524 match new_selector {
3525 AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3526 AdcFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
3527 AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3528 }
3529 }
3530 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3531 if active && let Some(old_selector) = old_selector {
3532 match old_selector {
3533 AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3534 AdcFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
3535 AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3536 }
3537 }
3538 }
3539 pub fn function_clock_config(
3540 self,
3541 clocks: &mut ClockTree,
3542 ) -> Option<AdcFunctionClockConfig> {
3543 clocks.adc_function_clock[self as usize]
3544 }
3545 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3546 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3547 if increment_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
3548 {
3549 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3550 match unwrap!(clocks.adc_function_clock[self as usize]) {
3551 AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3552 AdcFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
3553 AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3554 }
3555 self.enable_function_clock_impl(clocks, true);
3556 }
3557 }
3558 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3559 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3560 if decrement_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
3561 {
3562 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3563 self.enable_function_clock_impl(clocks, false);
3564 match unwrap!(clocks.adc_function_clock[self as usize]) {
3565 AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3566 AdcFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
3567 AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3568 }
3569 }
3570 }
3571 pub fn function_clock_config_frequency(config: AdcFunctionClockConfig) -> u32 {
3572 match config {
3573 AdcFunctionClockConfig::Xtal => xtal_clk_frequency(),
3574 AdcFunctionClockConfig::PllF96m => pll_f96m_clk_frequency(),
3575 AdcFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3576 }
3577 }
3578 pub fn function_clock_frequency(self) -> u32 {
3579 ADC_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3580 .load(::core::sync::atomic::Ordering::Acquire)
3581 }
3582 pub fn function_clock_source_frequency(source: AdcFunctionClockConfig) -> u32 {
3583 Self::function_clock_config_frequency(source)
3584 }
3585 }
3586 impl SdmInstance {
3587 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3588 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3589 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3590 {
3591 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3592 request_iomux_function_clock(clocks);
3593 self.enable_function_clock_impl(clocks, true);
3594 }
3595 }
3596 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3597 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3598 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3599 {
3600 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3601 self.enable_function_clock_impl(clocks, false);
3602 release_iomux_function_clock(clocks);
3603 }
3604 }
3605 pub fn function_clock_frequency(self) -> u32 {
3606 iomux_function_clock_frequency()
3607 }
3608 pub fn function_clock_source_frequency() -> u32 {
3609 iomux_function_clock_frequency()
3610 }
3611 }
3612 impl I2cInstance {
3613 pub fn configure_function_clock(
3614 self,
3615 clocks: &mut ClockTree,
3616 config: I2cFunctionClockConfig,
3617 ) {
3618 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3619 refresh_i2c_function_clock_downstream(clocks, self);
3620 let active = clocks.i2c_function_clock_refcount[self as usize] > 0;
3621 if active {
3622 match config.sclk {
3623 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3624 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3625 }
3626 }
3627 self.configure_function_clock_impl(clocks, old_config, config);
3628 if active && let Some(old_config) = old_config {
3629 match old_config.sclk {
3630 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3631 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3632 }
3633 }
3634 }
3635 pub fn function_clock_config(
3636 self,
3637 clocks: &mut ClockTree,
3638 ) -> Option<I2cFunctionClockConfig> {
3639 clocks.i2c_function_clock[self as usize]
3640 }
3641 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3642 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3643 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3644 {
3645 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3646 crate::rtc_cntl::WakeLock::acquire();
3647 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3648 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3649 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3650 }
3651 self.enable_function_clock_impl(clocks, true);
3652 }
3653 }
3654 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3655 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3656 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3657 {
3658 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3659 crate::rtc_cntl::WakeLock::release();
3660 self.enable_function_clock_impl(clocks, false);
3661 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3662 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3663 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3664 }
3665 }
3666 }
3667 pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
3668 (match config.sclk {
3669 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3670 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3671 } / (config.div_num() + 1))
3672 }
3673 pub fn function_clock_frequency(self) -> u32 {
3674 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3675 .load(::core::sync::atomic::Ordering::Acquire)
3676 }
3677 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3678 match sclk {
3679 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3680 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3681 }
3682 }
3683 }
3684 impl I2sInstance {
3685 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
3686 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
3687 refresh_i2s_tx_clk_downstream(clocks, self);
3688 let active = clocks.i2s_tx_clk_refcount[self as usize] > 0;
3689 if active {
3690 match config.sclk {
3691 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3692 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
3693 I2sClkSclk::PllF64m => request_pll_f64m_clk(clocks),
3694 }
3695 }
3696 self.configure_tx_clk_impl(clocks, old_config, config);
3697 if active && let Some(old_config) = old_config {
3698 match old_config.sclk {
3699 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3700 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
3701 I2sClkSclk::PllF64m => release_pll_f64m_clk(clocks),
3702 }
3703 }
3704 }
3705 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
3706 clocks.i2s_tx_clk[self as usize]
3707 }
3708 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
3709 trace!("Requesting {:?}::TX_CLK", self);
3710 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
3711 trace!("Enabling {:?}::TX_CLK", self);
3712 crate::rtc_cntl::WakeLock::acquire();
3713 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
3714 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3715 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
3716 I2sClkSclk::PllF64m => request_pll_f64m_clk(clocks),
3717 }
3718 self.enable_tx_clk_impl(clocks, true);
3719 }
3720 }
3721 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
3722 trace!("Releasing {:?}::TX_CLK", self);
3723 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
3724 trace!("Disabling {:?}::TX_CLK", self);
3725 crate::rtc_cntl::WakeLock::release();
3726 self.enable_tx_clk_impl(clocks, false);
3727 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
3728 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3729 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
3730 I2sClkSclk::PllF64m => release_pll_f64m_clk(clocks),
3731 }
3732 }
3733 }
3734 pub fn tx_clk_config_frequency(config: I2sClkConfig) -> u32 {
3735 (((match config.sclk {
3736 I2sClkSclk::Xtal => xtal_clk_frequency(),
3737 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
3738 I2sClkSclk::PllF64m => pll_f64m_clk_frequency(),
3739 } as u64)
3740 * (config.div_a() as u64))
3741 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3742 as u32
3743 }
3744 pub fn tx_clk_frequency(self) -> u32 {
3745 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3746 }
3747 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
3748 match sclk {
3749 I2sClkSclk::Xtal => xtal_clk_frequency(),
3750 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
3751 I2sClkSclk::PllF64m => pll_f64m_clk_frequency(),
3752 }
3753 }
3754 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
3755 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
3756 refresh_i2s_rx_clk_downstream(clocks, self);
3757 let active = clocks.i2s_rx_clk_refcount[self as usize] > 0;
3758 if active {
3759 match config.sclk {
3760 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3761 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
3762 I2sClkSclk::PllF64m => request_pll_f64m_clk(clocks),
3763 }
3764 }
3765 self.configure_rx_clk_impl(clocks, old_config, config);
3766 if active && let Some(old_config) = old_config {
3767 match old_config.sclk {
3768 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3769 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
3770 I2sClkSclk::PllF64m => release_pll_f64m_clk(clocks),
3771 }
3772 }
3773 }
3774 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
3775 clocks.i2s_rx_clk[self as usize]
3776 }
3777 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
3778 trace!("Requesting {:?}::RX_CLK", self);
3779 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
3780 trace!("Enabling {:?}::RX_CLK", self);
3781 crate::rtc_cntl::WakeLock::acquire();
3782 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
3783 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3784 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
3785 I2sClkSclk::PllF64m => request_pll_f64m_clk(clocks),
3786 }
3787 self.enable_rx_clk_impl(clocks, true);
3788 }
3789 }
3790 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
3791 trace!("Releasing {:?}::RX_CLK", self);
3792 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
3793 trace!("Disabling {:?}::RX_CLK", self);
3794 crate::rtc_cntl::WakeLock::release();
3795 self.enable_rx_clk_impl(clocks, false);
3796 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
3797 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3798 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
3799 I2sClkSclk::PllF64m => release_pll_f64m_clk(clocks),
3800 }
3801 }
3802 }
3803 pub fn rx_clk_config_frequency(config: I2sClkConfig) -> u32 {
3804 (((match config.sclk {
3805 I2sClkSclk::Xtal => xtal_clk_frequency(),
3806 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
3807 I2sClkSclk::PllF64m => pll_f64m_clk_frequency(),
3808 } as u64)
3809 * (config.div_a() as u64))
3810 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3811 as u32
3812 }
3813 pub fn rx_clk_frequency(self) -> u32 {
3814 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3815 }
3816 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
3817 match sclk {
3818 I2sClkSclk::Xtal => xtal_clk_frequency(),
3819 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
3820 I2sClkSclk::PllF64m => pll_f64m_clk_frequency(),
3821 }
3822 }
3823 pub fn configure_mclk_out(
3824 self,
3825 clocks: &mut ClockTree,
3826 new_selector: I2sMclkOutConfig,
3827 ) {
3828 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
3829 refresh_i2s_mclk_out_downstream(clocks, self);
3830 let active = clocks.i2s_mclk_out_refcount[self as usize] > 0;
3831 if active {
3832 match new_selector {
3833 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
3834 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3835 }
3836 }
3837 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
3838 if active && let Some(old_selector) = old_selector {
3839 match old_selector {
3840 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3841 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3842 }
3843 }
3844 }
3845 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
3846 clocks.i2s_mclk_out[self as usize]
3847 }
3848 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
3849 trace!("Requesting {:?}::MCLK_OUT", self);
3850 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3851 trace!("Enabling {:?}::MCLK_OUT", self);
3852 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3853 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
3854 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3855 }
3856 self.enable_mclk_out_impl(clocks, true);
3857 }
3858 }
3859 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
3860 trace!("Releasing {:?}::MCLK_OUT", self);
3861 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3862 trace!("Disabling {:?}::MCLK_OUT", self);
3863 self.enable_mclk_out_impl(clocks, false);
3864 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3865 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3866 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3867 }
3868 }
3869 }
3870 pub fn mclk_out_config_frequency(self, config: I2sMclkOutConfig) -> u32 {
3871 match config {
3872 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
3873 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
3874 }
3875 }
3876 pub fn mclk_out_frequency(self) -> u32 {
3877 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3878 }
3879 }
3880 impl McpwmInstance {
3881 pub fn configure_function_clock(
3882 self,
3883 clocks: &mut ClockTree,
3884 new_selector: McpwmFunctionClockConfig,
3885 ) {
3886 let old_selector = clocks.mcpwm_function_clock[self as usize].replace(new_selector);
3887 refresh_mcpwm_function_clock_downstream(clocks, self);
3888 let active = clocks.mcpwm_function_clock_refcount[self as usize] > 0;
3889 if active {
3890 match new_selector {
3891 McpwmFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
3892 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3893 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3894 }
3895 }
3896 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3897 if active && let Some(old_selector) = old_selector {
3898 match old_selector {
3899 McpwmFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
3900 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3901 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3902 }
3903 }
3904 }
3905 pub fn function_clock_config(
3906 self,
3907 clocks: &mut ClockTree,
3908 ) -> Option<McpwmFunctionClockConfig> {
3909 clocks.mcpwm_function_clock[self as usize]
3910 }
3911 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3912 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3913 if increment_reference_count(
3914 &mut clocks.mcpwm_function_clock_refcount[self as usize],
3915 ) {
3916 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3917 crate::rtc_cntl::WakeLock::acquire();
3918 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
3919 McpwmFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
3920 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3921 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3922 }
3923 self.enable_function_clock_impl(clocks, true);
3924 }
3925 }
3926 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3927 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3928 if decrement_reference_count(
3929 &mut clocks.mcpwm_function_clock_refcount[self as usize],
3930 ) {
3931 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3932 crate::rtc_cntl::WakeLock::release();
3933 self.enable_function_clock_impl(clocks, false);
3934 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
3935 McpwmFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
3936 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3937 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3938 }
3939 }
3940 }
3941 pub fn function_clock_config_frequency(config: McpwmFunctionClockConfig) -> u32 {
3942 match config {
3943 McpwmFunctionClockConfig::PllF96m => pll_f96m_clk_frequency(),
3944 McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3945 McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3946 }
3947 }
3948 pub fn function_clock_frequency(self) -> u32 {
3949 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3950 .load(::core::sync::atomic::Ordering::Acquire)
3951 }
3952 pub fn function_clock_source_frequency(source: McpwmFunctionClockConfig) -> u32 {
3953 Self::function_clock_config_frequency(source)
3954 }
3955 }
3956 impl ParlIoInstance {
3957 pub fn configure_rx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
3958 let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
3959 refresh_parl_io_rx_clock_downstream(clocks, self);
3960 let active = clocks.parl_io_rx_clock_refcount[self as usize] > 0;
3961 if active {
3962 match new_selector {
3963 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
3964 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3965 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3966 }
3967 }
3968 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
3969 if active && let Some(old_selector) = old_selector {
3970 match old_selector {
3971 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
3972 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3973 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3974 }
3975 }
3976 }
3977 pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
3978 clocks.parl_io_rx_clock[self as usize]
3979 }
3980 pub fn request_rx_clock(self, clocks: &mut ClockTree) {
3981 trace!("Requesting {:?}::RX_CLOCK", self);
3982 if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
3983 trace!("Enabling {:?}::RX_CLOCK", self);
3984 crate::rtc_cntl::WakeLock::acquire();
3985 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
3986 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
3987 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3988 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3989 }
3990 self.enable_rx_clock_impl(clocks, true);
3991 }
3992 }
3993 pub fn release_rx_clock(self, clocks: &mut ClockTree) {
3994 trace!("Releasing {:?}::RX_CLOCK", self);
3995 if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
3996 trace!("Disabling {:?}::RX_CLOCK", self);
3997 crate::rtc_cntl::WakeLock::release();
3998 self.enable_rx_clock_impl(clocks, false);
3999 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
4000 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4001 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4002 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
4003 }
4004 }
4005 }
4006 pub fn rx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
4007 match config {
4008 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4009 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4010 ParlIoClkConfig::PllF96m => pll_f96m_clk_frequency(),
4011 }
4012 }
4013 pub fn rx_clock_frequency(self) -> u32 {
4014 PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
4015 .load(::core::sync::atomic::Ordering::Acquire)
4016 }
4017 pub fn rx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4018 Self::rx_clock_config_frequency(source)
4019 }
4020 pub fn configure_tx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
4021 let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
4022 refresh_parl_io_tx_clock_downstream(clocks, self);
4023 let active = clocks.parl_io_tx_clock_refcount[self as usize] > 0;
4024 if active {
4025 match new_selector {
4026 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4027 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4028 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
4029 }
4030 }
4031 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
4032 if active && let Some(old_selector) = old_selector {
4033 match old_selector {
4034 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4035 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4036 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
4037 }
4038 }
4039 }
4040 pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
4041 clocks.parl_io_tx_clock[self as usize]
4042 }
4043 pub fn request_tx_clock(self, clocks: &mut ClockTree) {
4044 trace!("Requesting {:?}::TX_CLOCK", self);
4045 if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4046 trace!("Enabling {:?}::TX_CLOCK", self);
4047 crate::rtc_cntl::WakeLock::acquire();
4048 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4049 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
4050 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
4051 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
4052 }
4053 self.enable_tx_clock_impl(clocks, true);
4054 }
4055 }
4056 pub fn release_tx_clock(self, clocks: &mut ClockTree) {
4057 trace!("Releasing {:?}::TX_CLOCK", self);
4058 if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
4059 trace!("Disabling {:?}::TX_CLOCK", self);
4060 crate::rtc_cntl::WakeLock::release();
4061 self.enable_tx_clock_impl(clocks, false);
4062 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
4063 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
4064 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
4065 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
4066 }
4067 }
4068 }
4069 pub fn tx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
4070 match config {
4071 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
4072 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
4073 ParlIoClkConfig::PllF96m => pll_f96m_clk_frequency(),
4074 }
4075 }
4076 pub fn tx_clock_frequency(self) -> u32 {
4077 PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
4078 .load(::core::sync::atomic::Ordering::Acquire)
4079 }
4080 pub fn tx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
4081 Self::tx_clock_config_frequency(source)
4082 }
4083 }
4084 impl PcntInstance {
4085 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4086 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4087 if increment_reference_count(
4088 &mut clocks.pcnt_function_clock_refcount[self as usize],
4089 ) {
4090 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4091 request_apb_clk(clocks);
4092 self.enable_function_clock_impl(clocks, true);
4093 }
4094 }
4095 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4096 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4097 if decrement_reference_count(
4098 &mut clocks.pcnt_function_clock_refcount[self as usize],
4099 ) {
4100 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4101 self.enable_function_clock_impl(clocks, false);
4102 release_apb_clk(clocks);
4103 }
4104 }
4105 pub fn function_clock_frequency(self) -> u32 {
4106 apb_clk_frequency()
4107 }
4108 pub fn function_clock_source_frequency() -> u32 {
4109 apb_clk_frequency()
4110 }
4111 }
4112 impl RmtInstance {
4113 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
4114 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
4115 refresh_rmt_sclk_downstream(clocks, self);
4116 let active = clocks.rmt_sclk_refcount[self as usize] > 0;
4117 if active {
4118 match new_selector {
4119 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4120 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4121 }
4122 }
4123 self.configure_sclk_impl(clocks, old_selector, new_selector);
4124 if active && let Some(old_selector) = old_selector {
4125 match old_selector {
4126 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4127 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4128 }
4129 }
4130 }
4131 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
4132 clocks.rmt_sclk[self as usize]
4133 }
4134 pub fn request_sclk(self, clocks: &mut ClockTree) {
4135 trace!("Requesting {:?}::SCLK", self);
4136 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4137 trace!("Enabling {:?}::SCLK", self);
4138 crate::rtc_cntl::WakeLock::acquire();
4139 match unwrap!(clocks.rmt_sclk[self as usize]) {
4140 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
4141 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
4142 }
4143 self.enable_sclk_impl(clocks, true);
4144 }
4145 }
4146 pub fn release_sclk(self, clocks: &mut ClockTree) {
4147 trace!("Releasing {:?}::SCLK", self);
4148 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
4149 trace!("Disabling {:?}::SCLK", self);
4150 crate::rtc_cntl::WakeLock::release();
4151 self.enable_sclk_impl(clocks, false);
4152 match unwrap!(clocks.rmt_sclk[self as usize]) {
4153 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
4154 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
4155 }
4156 }
4157 }
4158 pub fn sclk_config_frequency(config: RmtSclkConfig) -> u32 {
4159 match config {
4160 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
4161 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
4162 }
4163 }
4164 pub fn sclk_frequency(self) -> u32 {
4165 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
4166 }
4167 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
4168 Self::sclk_config_frequency(source)
4169 }
4170 }
4171 impl SpiInstance {
4172 pub fn configure_function_clock(
4173 self,
4174 clocks: &mut ClockTree,
4175 new_selector: SpiFunctionClockConfig,
4176 ) {
4177 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
4178 refresh_spi_function_clock_downstream(clocks, self);
4179 let active = clocks.spi_function_clock_refcount[self as usize] > 0;
4180 if active {
4181 match new_selector {
4182 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4183 SpiFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
4184 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4185 }
4186 }
4187 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4188 if active && let Some(old_selector) = old_selector {
4189 match old_selector {
4190 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4191 SpiFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
4192 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4193 }
4194 }
4195 }
4196 pub fn function_clock_config(
4197 self,
4198 clocks: &mut ClockTree,
4199 ) -> Option<SpiFunctionClockConfig> {
4200 clocks.spi_function_clock[self as usize]
4201 }
4202 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4203 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4204 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
4205 {
4206 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4207 crate::rtc_cntl::WakeLock::acquire();
4208 match unwrap!(clocks.spi_function_clock[self as usize]) {
4209 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
4210 SpiFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
4211 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
4212 }
4213 self.enable_function_clock_impl(clocks, true);
4214 }
4215 }
4216 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4217 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4218 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
4219 {
4220 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4221 crate::rtc_cntl::WakeLock::release();
4222 self.enable_function_clock_impl(clocks, false);
4223 match unwrap!(clocks.spi_function_clock[self as usize]) {
4224 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
4225 SpiFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
4226 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
4227 }
4228 }
4229 }
4230 pub fn function_clock_config_frequency(config: SpiFunctionClockConfig) -> u32 {
4231 match config {
4232 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
4233 SpiFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
4234 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
4235 }
4236 }
4237 pub fn function_clock_frequency(self) -> u32 {
4238 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4239 .load(::core::sync::atomic::Ordering::Acquire)
4240 }
4241 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
4242 Self::function_clock_config_frequency(source)
4243 }
4244 }
4245 impl TimgInstance {
4246 pub fn configure_function_clock(
4247 self,
4248 clocks: &mut ClockTree,
4249 new_selector: TimgFunctionClockConfig,
4250 ) {
4251 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
4252 refresh_timg_function_clock_downstream(clocks, self);
4253 let active = clocks.timg_function_clock_refcount[self as usize] > 0;
4254 if active {
4255 match new_selector {
4256 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4257 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4258 TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
4259 }
4260 }
4261 self.configure_function_clock_impl(clocks, old_selector, new_selector);
4262 if active && let Some(old_selector) = old_selector {
4263 match old_selector {
4264 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4265 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4266 TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
4267 }
4268 }
4269 }
4270 pub fn function_clock_config(
4271 self,
4272 clocks: &mut ClockTree,
4273 ) -> Option<TimgFunctionClockConfig> {
4274 clocks.timg_function_clock[self as usize]
4275 }
4276 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4277 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4278 if increment_reference_count(
4279 &mut clocks.timg_function_clock_refcount[self as usize],
4280 ) {
4281 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4282 match unwrap!(clocks.timg_function_clock[self as usize]) {
4283 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
4284 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4285 TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
4286 }
4287 self.enable_function_clock_impl(clocks, true);
4288 }
4289 }
4290 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4291 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4292 if decrement_reference_count(
4293 &mut clocks.timg_function_clock_refcount[self as usize],
4294 ) {
4295 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4296 self.enable_function_clock_impl(clocks, false);
4297 match unwrap!(clocks.timg_function_clock[self as usize]) {
4298 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
4299 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4300 TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
4301 }
4302 }
4303 }
4304 pub fn function_clock_config_frequency(config: TimgFunctionClockConfig) -> u32 {
4305 match config {
4306 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
4307 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
4308 TimgFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
4309 }
4310 }
4311 pub fn function_clock_frequency(self) -> u32 {
4312 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4313 .load(::core::sync::atomic::Ordering::Acquire)
4314 }
4315 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
4316 Self::function_clock_config_frequency(source)
4317 }
4318 pub fn configure_wdt_clock(
4319 self,
4320 clocks: &mut ClockTree,
4321 new_selector: TimgWdtClockConfig,
4322 ) {
4323 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
4324 refresh_timg_wdt_clock_downstream(clocks, self);
4325 let active = clocks.timg_wdt_clock_refcount[self as usize] > 0;
4326 if active {
4327 match new_selector {
4328 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
4329 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4330 TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
4331 }
4332 }
4333 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
4334 if active && let Some(old_selector) = old_selector {
4335 match old_selector {
4336 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
4337 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4338 TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
4339 }
4340 }
4341 }
4342 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
4343 clocks.timg_wdt_clock[self as usize]
4344 }
4345 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
4346 trace!("Requesting {:?}::WDT_CLOCK", self);
4347 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
4348 trace!("Enabling {:?}::WDT_CLOCK", self);
4349 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
4350 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
4351 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
4352 TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
4353 }
4354 self.enable_wdt_clock_impl(clocks, true);
4355 }
4356 }
4357 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
4358 trace!("Releasing {:?}::WDT_CLOCK", self);
4359 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
4360 trace!("Disabling {:?}::WDT_CLOCK", self);
4361 self.enable_wdt_clock_impl(clocks, false);
4362 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
4363 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
4364 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
4365 TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
4366 }
4367 }
4368 }
4369 pub fn wdt_clock_config_frequency(config: TimgWdtClockConfig) -> u32 {
4370 match config {
4371 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
4372 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
4373 TimgWdtClockConfig::PllF48m => pll_f48m_clk_frequency(),
4374 }
4375 }
4376 pub fn wdt_clock_frequency(self) -> u32 {
4377 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
4378 .load(::core::sync::atomic::Ordering::Acquire)
4379 }
4380 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
4381 Self::wdt_clock_config_frequency(source)
4382 }
4383 }
4384 impl UartInstance {
4385 pub fn configure_function_clock(
4386 self,
4387 clocks: &mut ClockTree,
4388 config: UartFunctionClockConfig,
4389 ) {
4390 let old_config = clocks.uart_function_clock[self as usize].replace(config);
4391 refresh_uart_function_clock_downstream(clocks, self);
4392 let active = clocks.uart_function_clock_refcount[self as usize] > 0;
4393 if active {
4394 match config.sclk {
4395 UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
4396 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4397 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4398 }
4399 }
4400 self.configure_function_clock_impl(clocks, old_config, config);
4401 if active && let Some(old_config) = old_config {
4402 match old_config.sclk {
4403 UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
4404 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4405 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4406 }
4407 }
4408 }
4409 pub fn function_clock_config(
4410 self,
4411 clocks: &mut ClockTree,
4412 ) -> Option<UartFunctionClockConfig> {
4413 clocks.uart_function_clock[self as usize]
4414 }
4415 pub fn request_function_clock(self, clocks: &mut ClockTree) {
4416 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
4417 if increment_reference_count(
4418 &mut clocks.uart_function_clock_refcount[self as usize],
4419 ) {
4420 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
4421 crate::rtc_cntl::WakeLock::acquire();
4422 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
4423 UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
4424 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
4425 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
4426 }
4427 self.enable_function_clock_impl(clocks, true);
4428 }
4429 }
4430 pub fn release_function_clock(self, clocks: &mut ClockTree) {
4431 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
4432 if decrement_reference_count(
4433 &mut clocks.uart_function_clock_refcount[self as usize],
4434 ) {
4435 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
4436 crate::rtc_cntl::WakeLock::release();
4437 self.enable_function_clock_impl(clocks, false);
4438 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
4439 UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
4440 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
4441 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
4442 }
4443 }
4444 }
4445 pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
4446 (match config.sclk {
4447 UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(),
4448 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4449 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
4450 } / (config.div_num() + 1))
4451 }
4452 pub fn function_clock_frequency(self) -> u32 {
4453 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
4454 .load(::core::sync::atomic::Ordering::Acquire)
4455 }
4456 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
4457 match sclk {
4458 UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(),
4459 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
4460 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
4461 }
4462 }
4463 pub fn configure_baud_rate_generator(
4464 self,
4465 clocks: &mut ClockTree,
4466 config: UartBaudRateGeneratorConfig,
4467 ) {
4468 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
4469 refresh_uart_baud_rate_generator_downstream(clocks, self);
4470 self.configure_baud_rate_generator_impl(clocks, old_config, config);
4471 }
4472 pub fn baud_rate_generator_config(
4473 self,
4474 clocks: &mut ClockTree,
4475 ) -> Option<UartBaudRateGeneratorConfig> {
4476 clocks.uart_baud_rate_generator[self as usize]
4477 }
4478 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
4479 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
4480 if increment_reference_count(
4481 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
4482 ) {
4483 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
4484 self.request_function_clock(clocks);
4485 self.enable_baud_rate_generator_impl(clocks, true);
4486 }
4487 }
4488 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
4489 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
4490 if decrement_reference_count(
4491 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
4492 ) {
4493 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
4494 self.enable_baud_rate_generator_impl(clocks, false);
4495 self.release_function_clock(clocks);
4496 }
4497 }
4498 pub fn baud_rate_generator_config_frequency(
4499 self,
4500 config: UartBaudRateGeneratorConfig,
4501 ) -> u32 {
4502 ((self.function_clock_frequency() * 16)
4503 / ((config.integral() * 16) + config.fractional()))
4504 }
4505 pub fn baud_rate_generator_frequency(self) -> u32 {
4506 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
4507 .load(::core::sync::atomic::Ordering::Acquire)
4508 }
4509 }
4510 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4518 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4519 #[instability::unstable]
4520 pub struct ClockConfig {
4521 pub xtal_clk: Option<XtalClkConfig>,
4523 pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
4525 pub hp_root_clk: Option<HpRootClkConfig>,
4527 pub cpu_clk: Option<CpuClkConfig>,
4529 pub ahb_clk: Option<AhbClkConfig>,
4531 pub apb_clk: Option<ApbClkConfig>,
4533 pub lp_fast_clk: Option<LpFastClkConfig>,
4535 pub lp_slow_clk: Option<LpSlowClkConfig>,
4537 pub ble_lp_clk: Option<BleLpClkConfig>,
4539 pub crypto_clk: Option<CryptoClkConfig>,
4541 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
4543 }
4544 impl ClockConfig {
4545 fn apply(&self, clocks: &mut ClockTree) {
4546 if let Some(config) = self.xtal_clk {
4547 configure_xtal_clk(clocks, config);
4548 }
4549 if let Some(config) = self.iomux_function_clock {
4550 configure_iomux_function_clock(clocks, config);
4551 }
4552 if let Some(config) = self.hp_root_clk {
4553 configure_hp_root_clk(clocks, config);
4554 }
4555 if let Some(config) = self.cpu_clk {
4556 configure_cpu_clk(clocks, config);
4557 }
4558 if let Some(config) = self.ahb_clk {
4559 configure_ahb_clk(clocks, config);
4560 }
4561 if let Some(config) = self.apb_clk {
4562 configure_apb_clk(clocks, config);
4563 }
4564 if let Some(config) = self.lp_fast_clk {
4565 configure_lp_fast_clk(clocks, config);
4566 }
4567 if let Some(config) = self.lp_slow_clk {
4568 configure_lp_slow_clk(clocks, config);
4569 }
4570 if let Some(config) = self.ble_lp_clk {
4571 configure_ble_lp_clk(clocks, config);
4572 }
4573 if let Some(config) = self.crypto_clk {
4574 configure_crypto_clk(clocks, config);
4575 }
4576 if let Some(config) = self.timg_calibration_clock {
4577 configure_timg_calibration_clock(clocks, config);
4578 }
4579 }
4580 }
4581 fn increment_reference_count(refcount: &mut u32) -> bool {
4582 let first = *refcount == 0;
4583 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
4584 first
4585 }
4586 fn decrement_reference_count(refcount: &mut u32) -> bool {
4587 *refcount = refcount.saturating_sub(1);
4588 let last = *refcount == 0;
4589 last
4590 }
4591 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
4592 if let Some(config) = clocks.xtal_clk {
4593 XTAL_CLK_FREQ_CACHE.store(
4594 xtal_clk_config_frequency(config),
4595 ::core::sync::atomic::Ordering::Release,
4596 );
4597 }
4598 refresh_iomux_function_clock_downstream(clocks);
4599 refresh_hp_root_clk_downstream(clocks);
4600 refresh_lp_fast_clk_downstream(clocks);
4601 refresh_ble_lp_clk_downstream(clocks);
4602 refresh_crypto_clk_downstream(clocks);
4603 for child_instance in [AdcInstance::ApbSaradc] {
4604 refresh_adc_function_clock_downstream(clocks, child_instance);
4605 }
4606 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
4607 refresh_i2c_function_clock_downstream(clocks, child_instance);
4608 }
4609 for child_instance in [I2sInstance::I2s0] {
4610 refresh_i2s_tx_clk_downstream(clocks, child_instance);
4611 refresh_i2s_rx_clk_downstream(clocks, child_instance);
4612 }
4613 for child_instance in [McpwmInstance::Mcpwm0] {
4614 refresh_mcpwm_function_clock_downstream(clocks, child_instance);
4615 }
4616 for child_instance in [ParlIoInstance::ParlIo] {
4617 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
4618 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
4619 }
4620 for child_instance in [RmtInstance::Rmt] {
4621 refresh_rmt_sclk_downstream(clocks, child_instance);
4622 }
4623 for child_instance in [SpiInstance::Spi2] {
4624 refresh_spi_function_clock_downstream(clocks, child_instance);
4625 }
4626 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
4627 refresh_timg_function_clock_downstream(clocks, child_instance);
4628 refresh_timg_wdt_clock_downstream(clocks, child_instance);
4629 }
4630 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4631 refresh_uart_function_clock_downstream(clocks, child_instance);
4632 }
4633 }
4634 fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
4635 refresh_hp_root_clk_downstream(clocks);
4636 refresh_lp_fast_clk_downstream(clocks);
4637 refresh_crypto_clk_downstream(clocks);
4638 refresh_timg_calibration_clock_downstream(clocks);
4639 for child_instance in [AdcInstance::ApbSaradc] {
4640 refresh_adc_function_clock_downstream(clocks, child_instance);
4641 }
4642 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
4643 refresh_i2c_function_clock_downstream(clocks, child_instance);
4644 }
4645 for child_instance in [McpwmInstance::Mcpwm0] {
4646 refresh_mcpwm_function_clock_downstream(clocks, child_instance);
4647 }
4648 for child_instance in [ParlIoInstance::ParlIo] {
4649 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
4650 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
4651 }
4652 for child_instance in [RmtInstance::Rmt] {
4653 refresh_rmt_sclk_downstream(clocks, child_instance);
4654 }
4655 for child_instance in [SpiInstance::Spi2] {
4656 refresh_spi_function_clock_downstream(clocks, child_instance);
4657 }
4658 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
4659 refresh_timg_function_clock_downstream(clocks, child_instance);
4660 refresh_timg_wdt_clock_downstream(clocks, child_instance);
4661 }
4662 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4663 refresh_uart_function_clock_downstream(clocks, child_instance);
4664 }
4665 }
4666 fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
4667 if let Some(config) = clocks.iomux_function_clock {
4668 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
4669 iomux_function_clock_config_frequency(config),
4670 ::core::sync::atomic::Ordering::Release,
4671 );
4672 }
4673 }
4674 fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
4675 refresh_lp_slow_clk_downstream(clocks);
4676 refresh_ble_lp_clk_downstream(clocks);
4677 }
4678 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
4679 if let Some(config) = clocks.hp_root_clk {
4680 HP_ROOT_CLK_FREQ_CACHE.store(
4681 hp_root_clk_config_frequency(config),
4682 ::core::sync::atomic::Ordering::Release,
4683 );
4684 }
4685 refresh_cpu_clk_downstream(clocks);
4686 refresh_ahb_clk_downstream(clocks);
4687 }
4688 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
4689 if let Some(config) = clocks.cpu_clk {
4690 CPU_CLK_FREQ_CACHE.store(
4691 cpu_clk_config_frequency(config),
4692 ::core::sync::atomic::Ordering::Release,
4693 );
4694 }
4695 }
4696 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
4697 if let Some(config) = clocks.ahb_clk {
4698 AHB_CLK_FREQ_CACHE.store(
4699 ahb_clk_config_frequency(config),
4700 ::core::sync::atomic::Ordering::Release,
4701 );
4702 }
4703 refresh_apb_clk_downstream(clocks);
4704 }
4705 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
4706 if let Some(config) = clocks.apb_clk {
4707 APB_CLK_FREQ_CACHE.store(
4708 apb_clk_config_frequency(config),
4709 ::core::sync::atomic::Ordering::Release,
4710 );
4711 }
4712 }
4713 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
4714 if let Some(config) = clocks.lp_fast_clk {
4715 LP_FAST_CLK_FREQ_CACHE.store(
4716 lp_fast_clk_config_frequency(config),
4717 ::core::sync::atomic::Ordering::Release,
4718 );
4719 }
4720 }
4721 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
4722 if let Some(config) = clocks.lp_slow_clk {
4723 LP_SLOW_CLK_FREQ_CACHE.store(
4724 lp_slow_clk_config_frequency(config),
4725 ::core::sync::atomic::Ordering::Release,
4726 );
4727 }
4728 refresh_timg_calibration_clock_downstream(clocks);
4729 }
4730 fn refresh_ble_lp_clk_downstream(clocks: &mut ClockTree) {
4731 if let Some(config) = clocks.ble_lp_clk {
4732 BLE_LP_CLK_FREQ_CACHE.store(
4733 ble_lp_clk_config_frequency(config),
4734 ::core::sync::atomic::Ordering::Release,
4735 );
4736 }
4737 }
4738 fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
4739 if let Some(config) = clocks.crypto_clk {
4740 CRYPTO_CLK_FREQ_CACHE.store(
4741 crypto_clk_config_frequency(config),
4742 ::core::sync::atomic::Ordering::Release,
4743 );
4744 }
4745 }
4746 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
4747 if let Some(config) = clocks.timg_calibration_clock {
4748 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
4749 timg_calibration_clock_config_frequency(config),
4750 ::core::sync::atomic::Ordering::Release,
4751 );
4752 }
4753 }
4754 fn refresh_adc_function_clock_downstream(clocks: &mut ClockTree, instance: AdcInstance) {
4755 if let Some(config) = clocks.adc_function_clock[instance as usize] {
4756 ADC_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4757 AdcInstance::function_clock_config_frequency(config),
4758 ::core::sync::atomic::Ordering::Release,
4759 );
4760 }
4761 }
4762 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
4763 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
4764 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4765 I2cInstance::function_clock_config_frequency(config),
4766 ::core::sync::atomic::Ordering::Release,
4767 );
4768 }
4769 }
4770 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
4771 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
4772 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
4773 I2sInstance::tx_clk_config_frequency(config),
4774 ::core::sync::atomic::Ordering::Release,
4775 );
4776 }
4777 refresh_i2s_mclk_out_downstream(clocks, instance);
4778 }
4779 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
4780 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
4781 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
4782 I2sInstance::rx_clk_config_frequency(config),
4783 ::core::sync::atomic::Ordering::Release,
4784 );
4785 }
4786 refresh_i2s_mclk_out_downstream(clocks, instance);
4787 }
4788 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
4789 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
4790 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
4791 instance.mclk_out_config_frequency(config),
4792 ::core::sync::atomic::Ordering::Release,
4793 );
4794 }
4795 }
4796 fn refresh_mcpwm_function_clock_downstream(
4797 clocks: &mut ClockTree,
4798 instance: McpwmInstance,
4799 ) {
4800 if let Some(config) = clocks.mcpwm_function_clock[instance as usize] {
4801 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4802 McpwmInstance::function_clock_config_frequency(config),
4803 ::core::sync::atomic::Ordering::Release,
4804 );
4805 }
4806 }
4807 fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
4808 if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
4809 PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
4810 ParlIoInstance::rx_clock_config_frequency(config),
4811 ::core::sync::atomic::Ordering::Release,
4812 );
4813 }
4814 }
4815 fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
4816 if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
4817 PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
4818 ParlIoInstance::tx_clock_config_frequency(config),
4819 ::core::sync::atomic::Ordering::Release,
4820 );
4821 }
4822 }
4823 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
4824 if let Some(config) = clocks.rmt_sclk[instance as usize] {
4825 RMT_SCLK_FREQ_CACHE[instance as usize].store(
4826 RmtInstance::sclk_config_frequency(config),
4827 ::core::sync::atomic::Ordering::Release,
4828 );
4829 }
4830 }
4831 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
4832 if let Some(config) = clocks.spi_function_clock[instance as usize] {
4833 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4834 SpiInstance::function_clock_config_frequency(config),
4835 ::core::sync::atomic::Ordering::Release,
4836 );
4837 }
4838 }
4839 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4840 if let Some(config) = clocks.timg_function_clock[instance as usize] {
4841 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4842 TimgInstance::function_clock_config_frequency(config),
4843 ::core::sync::atomic::Ordering::Release,
4844 );
4845 }
4846 }
4847 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4848 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
4849 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
4850 TimgInstance::wdt_clock_config_frequency(config),
4851 ::core::sync::atomic::Ordering::Release,
4852 );
4853 }
4854 }
4855 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4856 if let Some(config) = clocks.uart_function_clock[instance as usize] {
4857 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4858 UartInstance::function_clock_config_frequency(config),
4859 ::core::sync::atomic::Ordering::Release,
4860 );
4861 }
4862 refresh_uart_baud_rate_generator_downstream(clocks, instance);
4863 }
4864 fn refresh_uart_baud_rate_generator_downstream(
4865 clocks: &mut ClockTree,
4866 instance: UartInstance,
4867 ) {
4868 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4869 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4870 instance.baud_rate_generator_config_frequency(config),
4871 ::core::sync::atomic::Ordering::Release,
4872 );
4873 }
4874 }
4875 };
4876}
4877#[macro_export]
4881#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4882macro_rules! implement_peripheral_clocks {
4883 () => {
4884 #[doc(hidden)]
4885 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4886 #[repr(u8)]
4887 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4888 pub enum Peripheral {
4889 Aes,
4891 AhbGdma,
4893 ApbSarAdc,
4895 Ds,
4897 Ecc,
4899 Ecdsa,
4901 Etm,
4903 GpioSd,
4905 Hmac,
4907 I2cExt0,
4909 I2cExt1,
4911 I2s0,
4913 Ledc,
4915 Mcpwm0,
4917 ParlIo,
4919 Pcnt,
4921 Rmt,
4923 Rsa,
4925 Sha,
4927 Spi2,
4929 Systimer,
4931 Timg0,
4933 Timg1,
4935 Trace0,
4937 Tsens,
4939 Twai0,
4941 Uart0,
4943 Uart1,
4945 Uhci0,
4947 UsbDevice,
4949 }
4950 impl Peripheral {
4951 const KEEP_ENABLED: &[Peripheral] =
4952 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
4953 const COUNT: usize = Self::ALL.len();
4954 const ALL: &[Self] = &[
4955 Self::Aes,
4956 Self::AhbGdma,
4957 Self::ApbSarAdc,
4958 Self::Ds,
4959 Self::Ecc,
4960 Self::Ecdsa,
4961 Self::Etm,
4962 Self::GpioSd,
4963 Self::Hmac,
4964 Self::I2cExt0,
4965 Self::I2cExt1,
4966 Self::I2s0,
4967 Self::Ledc,
4968 Self::Mcpwm0,
4969 Self::ParlIo,
4970 Self::Pcnt,
4971 Self::Rmt,
4972 Self::Rsa,
4973 Self::Sha,
4974 Self::Spi2,
4975 Self::Systimer,
4976 Self::Timg0,
4977 Self::Timg1,
4978 Self::Trace0,
4979 Self::Tsens,
4980 Self::Twai0,
4981 Self::Uart0,
4982 Self::Uart1,
4983 Self::Uhci0,
4984 Self::UsbDevice,
4985 ];
4986 }
4987 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4988 match peripheral {
4989 Peripheral::Aes => {
4990 crate::peripherals::SYSTEM::regs()
4991 .aes_conf()
4992 .modify(|_, w| w.aes_clk_en().bit(enable));
4993 }
4994 Peripheral::AhbGdma => {
4995 crate::peripherals::SYSTEM::regs()
4996 .gdma_conf()
4997 .modify(|_, w| w.gdma_clk_en().bit(enable));
4998 }
4999 Peripheral::ApbSarAdc => {
5000 crate::peripherals::SYSTEM::regs()
5001 .saradc_conf()
5002 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
5003 }
5004 Peripheral::Ds => {
5005 crate::peripherals::SYSTEM::regs()
5006 .ds_conf()
5007 .modify(|_, w| w.ds_clk_en().bit(enable));
5008 }
5009 Peripheral::Ecc => {
5010 crate::peripherals::SYSTEM::regs()
5011 .ecc_conf()
5012 .modify(|_, w| w.ecc_clk_en().bit(enable));
5013 }
5014 Peripheral::Ecdsa => {
5015 crate::peripherals::SYSTEM::regs()
5016 .ecdsa_conf()
5017 .modify(|_, w| w.ecdsa_clk_en().bit(enable));
5018 }
5019 Peripheral::Etm => {
5020 crate::peripherals::SYSTEM::regs()
5021 .etm_conf()
5022 .modify(|_, w| w.etm_clk_en().bit(enable));
5023 }
5024 Peripheral::GpioSd => {
5025 crate::peripherals::GPIO_SD::regs()
5026 .clock_gate()
5027 .modify(|_, w| w.clk_en().bit(enable));
5028 }
5029 Peripheral::Hmac => {
5030 crate::peripherals::SYSTEM::regs()
5031 .hmac_conf()
5032 .modify(|_, w| w.hmac_clk_en().bit(enable));
5033 }
5034 Peripheral::I2cExt0 => {
5035 crate::peripherals::SYSTEM::regs()
5036 .i2c0_conf()
5037 .modify(|_, w| w.i2c0_clk_en().bit(enable));
5038 }
5039 Peripheral::I2cExt1 => {
5040 crate::peripherals::SYSTEM::regs()
5041 .i2c1_conf()
5042 .modify(|_, w| w.i2c1_clk_en().bit(enable));
5043 }
5044 Peripheral::I2s0 => {
5045 crate::peripherals::SYSTEM::regs()
5046 .i2s_conf()
5047 .modify(|_, w| w.i2s_clk_en().bit(enable));
5048 }
5049 Peripheral::Ledc => {
5050 crate::peripherals::SYSTEM::regs()
5051 .ledc_conf()
5052 .modify(|_, w| w.ledc_clk_en().bit(enable));
5053 }
5054 Peripheral::Mcpwm0 => {
5055 crate::peripherals::SYSTEM::regs()
5056 .pwm_conf()
5057 .modify(|_, w| w.pwm_clk_en().bit(enable));
5058 }
5059 Peripheral::ParlIo => {
5060 crate::peripherals::SYSTEM::regs()
5061 .parl_io_conf()
5062 .modify(|_, w| w.parl_clk_en().bit(enable));
5063 }
5064 Peripheral::Pcnt => {
5065 crate::peripherals::SYSTEM::regs()
5066 .pcnt_conf()
5067 .modify(|_, w| w.pcnt_clk_en().bit(enable));
5068 }
5069 Peripheral::Rmt => {
5070 crate::peripherals::SYSTEM::regs()
5071 .rmt_conf()
5072 .modify(|_, w| w.rmt_clk_en().bit(enable));
5073 }
5074 Peripheral::Rsa => {
5075 crate::peripherals::SYSTEM::regs()
5076 .rsa_conf()
5077 .modify(|_, w| w.rsa_clk_en().bit(enable));
5078 }
5079 Peripheral::Sha => {
5080 crate::peripherals::SYSTEM::regs()
5081 .sha_conf()
5082 .modify(|_, w| w.sha_clk_en().bit(enable));
5083 }
5084 Peripheral::Spi2 => {
5085 crate::peripherals::SYSTEM::regs()
5086 .spi2_conf()
5087 .modify(|_, w| w.spi2_clk_en().bit(enable));
5088 }
5089 Peripheral::Systimer => {
5090 crate::peripherals::SYSTEM::regs()
5091 .systimer_conf()
5092 .modify(|_, w| w.systimer_clk_en().bit(enable));
5093 }
5094 Peripheral::Timg0 => {
5095 crate::peripherals::SYSTEM::regs()
5096 .timergroup(0)
5097 .conf()
5098 .modify(|_, w| w.clk_en().bit(enable));
5099 }
5100 Peripheral::Timg1 => {
5101 crate::peripherals::SYSTEM::regs()
5102 .timergroup(1)
5103 .conf()
5104 .modify(|_, w| w.clk_en().bit(enable));
5105 }
5106 Peripheral::Trace0 => {
5107 crate::peripherals::SYSTEM::regs()
5108 .trace_conf()
5109 .modify(|_, w| w.trace_clk_en().bit(enable));
5110 }
5111 Peripheral::Tsens => {
5112 crate::peripherals::SYSTEM::regs()
5113 .tsens_clk_conf()
5114 .modify(|_, w| w.tsens_clk_en().bit(enable));
5115 }
5116 Peripheral::Twai0 => {
5117 crate::peripherals::SYSTEM::regs()
5118 .twai0_conf()
5119 .modify(|_, w| w.twai0_clk_en().bit(enable));
5120 crate::peripherals::SYSTEM::regs()
5121 .twai0_func_clk_conf()
5122 .modify(|_, w| w.twai0_func_clk_en().bit(enable));
5123 }
5124 Peripheral::Uart0 => {
5125 crate::peripherals::SYSTEM::regs()
5126 .uart(0)
5127 .conf()
5128 .modify(|_, w| w.clk_en().bit(enable));
5129 }
5130 Peripheral::Uart1 => {
5131 crate::peripherals::SYSTEM::regs()
5132 .uart(1)
5133 .conf()
5134 .modify(|_, w| w.clk_en().bit(enable));
5135 }
5136 Peripheral::Uhci0 => {
5137 crate::peripherals::SYSTEM::regs()
5138 .uhci_conf()
5139 .modify(|_, w| w.uhci_clk_en().bit(enable));
5140 }
5141 Peripheral::UsbDevice => {
5142 crate::peripherals::SYSTEM::regs()
5143 .usb_device_conf()
5144 .modify(|_, w| w.usb_device_clk_en().bit(enable));
5145 }
5146 }
5147 }
5148 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
5149 match peripheral {
5150 Peripheral::Aes => {
5151 crate::peripherals::SYSTEM::regs()
5152 .aes_conf()
5153 .modify(|_, w| w.aes_rst_en().bit(reset));
5154 }
5155 Peripheral::AhbGdma => {
5156 crate::peripherals::SYSTEM::regs()
5157 .gdma_conf()
5158 .modify(|_, w| w.gdma_rst_en().bit(reset));
5159 }
5160 Peripheral::ApbSarAdc => {
5161 crate::peripherals::SYSTEM::regs()
5162 .saradc_conf()
5163 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
5164 }
5165 Peripheral::Ds => {
5166 crate::peripherals::SYSTEM::regs()
5167 .ds_conf()
5168 .modify(|_, w| w.ds_rst_en().bit(reset));
5169 }
5170 Peripheral::Ecc => {
5171 crate::peripherals::SYSTEM::regs()
5172 .ecc_conf()
5173 .modify(|_, w| w.ecc_rst_en().bit(reset));
5174 }
5175 Peripheral::Ecdsa => {
5176 crate::peripherals::SYSTEM::regs()
5177 .ecdsa_conf()
5178 .modify(|_, w| w.ecdsa_rst_en().bit(reset));
5179 }
5180 Peripheral::Etm => {
5181 crate::peripherals::SYSTEM::regs()
5182 .etm_conf()
5183 .modify(|_, w| w.etm_rst_en().bit(reset));
5184 }
5185 Peripheral::GpioSd => {
5186 let _ = reset;
5187 }
5188 Peripheral::Hmac => {
5189 crate::peripherals::SYSTEM::regs()
5190 .hmac_conf()
5191 .modify(|_, w| w.hmac_rst_en().bit(reset));
5192 }
5193 Peripheral::I2cExt0 => {
5194 crate::peripherals::SYSTEM::regs()
5195 .i2c0_conf()
5196 .modify(|_, w| w.i2c0_rst_en().bit(reset));
5197 }
5198 Peripheral::I2cExt1 => {
5199 crate::peripherals::SYSTEM::regs()
5200 .i2c1_conf()
5201 .modify(|_, w| w.i2c1_rst_en().bit(reset));
5202 }
5203 Peripheral::I2s0 => {
5204 crate::peripherals::SYSTEM::regs()
5205 .i2s_conf()
5206 .modify(|_, w| w.i2s_rst_en().bit(reset));
5207 }
5208 Peripheral::Ledc => {
5209 crate::peripherals::SYSTEM::regs()
5210 .ledc_conf()
5211 .modify(|_, w| w.ledc_rst_en().bit(reset));
5212 }
5213 Peripheral::Mcpwm0 => {
5214 crate::peripherals::SYSTEM::regs()
5215 .pwm_conf()
5216 .modify(|_, w| w.pwm_rst_en().bit(reset));
5217 }
5218 Peripheral::ParlIo => {
5219 crate::peripherals::SYSTEM::regs()
5220 .parl_io_conf()
5221 .modify(|_, w| w.parl_rst_en().bit(reset));
5222 }
5223 Peripheral::Pcnt => {
5224 crate::peripherals::SYSTEM::regs()
5225 .pcnt_conf()
5226 .modify(|_, w| w.pcnt_rst_en().bit(reset));
5227 }
5228 Peripheral::Rmt => {
5229 crate::peripherals::SYSTEM::regs()
5230 .rmt_conf()
5231 .modify(|_, w| w.rmt_rst_en().bit(reset));
5232 }
5233 Peripheral::Rsa => {
5234 crate::peripherals::SYSTEM::regs()
5235 .rsa_conf()
5236 .modify(|_, w| w.rsa_rst_en().bit(reset));
5237 }
5238 Peripheral::Sha => {
5239 crate::peripherals::SYSTEM::regs()
5240 .sha_conf()
5241 .modify(|_, w| w.sha_rst_en().bit(reset));
5242 }
5243 Peripheral::Spi2 => {
5244 crate::peripherals::SYSTEM::regs()
5245 .spi2_conf()
5246 .modify(|_, w| w.spi2_rst_en().bit(reset));
5247 }
5248 Peripheral::Systimer => {
5249 crate::peripherals::SYSTEM::regs()
5250 .systimer_conf()
5251 .modify(|_, w| w.systimer_rst_en().bit(reset));
5252 }
5253 Peripheral::Timg0 => {
5254 crate::peripherals::SYSTEM::regs()
5255 .timergroup(0)
5256 .conf()
5257 .modify(|_, w| w.rst_en().bit(reset));
5258 }
5259 Peripheral::Timg1 => {
5260 crate::peripherals::SYSTEM::regs()
5261 .timergroup(1)
5262 .conf()
5263 .modify(|_, w| w.rst_en().bit(reset));
5264 }
5265 Peripheral::Trace0 => {
5266 crate::peripherals::SYSTEM::regs()
5267 .trace_conf()
5268 .modify(|_, w| w.trace_rst_en().bit(reset));
5269 }
5270 Peripheral::Tsens => {
5271 crate::peripherals::SYSTEM::regs()
5272 .tsens_clk_conf()
5273 .modify(|_, w| w.tsens_rst_en().bit(reset));
5274 }
5275 Peripheral::Twai0 => {
5276 crate::peripherals::SYSTEM::regs()
5277 .twai0_conf()
5278 .modify(|_, w| w.twai0_rst_en().bit(reset));
5279 }
5280 Peripheral::Uart0 => {
5281 crate::peripherals::SYSTEM::regs()
5282 .uart(0)
5283 .conf()
5284 .modify(|_, w| w.rst_en().bit(reset));
5285 }
5286 Peripheral::Uart1 => {
5287 crate::peripherals::SYSTEM::regs()
5288 .uart(1)
5289 .conf()
5290 .modify(|_, w| w.rst_en().bit(reset));
5291 }
5292 Peripheral::Uhci0 => {
5293 crate::peripherals::SYSTEM::regs()
5294 .uhci_conf()
5295 .modify(|_, w| w.uhci_rst_en().bit(reset));
5296 }
5297 Peripheral::UsbDevice => {
5298 crate::peripherals::SYSTEM::regs()
5299 .usb_device_conf()
5300 .modify(|_, w| w.usb_device_rst_en().bit(reset));
5301 }
5302 }
5303 }
5304 };
5305}
5306#[macro_export]
5314#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5315macro_rules! memory_range {
5316 ("DRAM") => {
5317 0x40800000..0x40850000
5318 };
5319 (size as str, "DRAM") => {
5320 "327680"
5321 };
5322 ("DRAM2_UNINIT") => {
5323 0x4083EFD0..0x4084FEE0
5324 };
5325 (size as str, "DRAM2_UNINIT") => {
5326 "69392"
5327 };
5328 ("IROM") => {
5329 0x42000000..0x43000000
5330 };
5331 (size as str, "IROM") => {
5332 "16777216"
5333 };
5334 ("DROM") => {
5335 0x42000000..0x43000000
5336 };
5337 (size as str, "DROM") => {
5338 "16777216"
5339 };
5340}
5341#[macro_export]
5358#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5359macro_rules! for_each_i2c_master {
5360 ($($pattern:tt => $code:tt;)*) => {
5361 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
5362 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
5363 I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
5364 I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
5365 I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_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]
5519#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5520macro_rules! for_each_pcnt_unit {
5521 ($($pattern:tt => $code:tt;)*) => {
5522 macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
5523 => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
5524 _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
5525 _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
5526 _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
5527 _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
5528 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
5529 _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
5530 PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
5531 _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
5532 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
5533 _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
5534 PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
5535 _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
5536 _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
5537 (PCNT0_UNIT3))); _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt,
5538 PCNT, 0, PCNT, PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1),
5539 (PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1,
5540 PCNT1_CTRL_CH0, PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
5541 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3,
5542 Pcnt0Unit3, Pcnt, PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0,
5543 PCNT3_CTRL_CH1))); _for_each_inner_pcnt_unit!((interrupt(PCNT)));
5544 _for_each_inner_pcnt_unit!((regs(PCNT)));
5545 };
5546}
5547#[macro_export]
5548#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5549macro_rules! for_each_peripheral {
5550 ($($pattern:tt => $code:tt;)*) => {
5551 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
5552 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
5553 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
5554 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
5555 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5556 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5557 "<section class=\"warning\">"] #[doc =
5558 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5559 #[doc = "<ul>"] #[doc =
5560 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5561 #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
5562 _for_each_inner_peripheral!((@ peri_type #[doc =
5563 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5564 "<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 an external JTAG debugger.</li>"]
5568 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
5569 _for_each_inner_peripheral!((@ peri_type #[doc =
5570 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5571 "<section class=\"warning\">"] #[doc =
5572 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5573 #[doc = "<ul>"] #[doc =
5574 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5575 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
5576 _for_each_inner_peripheral!((@ peri_type #[doc =
5577 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5578 "<section class=\"warning\">"] #[doc =
5579 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5580 #[doc = "<ul>"] #[doc =
5581 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5582 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
5583 _for_each_inner_peripheral!((@ peri_type #[doc =
5584 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5585 "<section class=\"warning\">"] #[doc =
5586 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5587 #[doc = "<ul>"] #[doc =
5588 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5589 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
5590 _for_each_inner_peripheral!((@ peri_type #[doc =
5591 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5592 "<section class=\"warning\">"] #[doc =
5593 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5594 #[doc = "<ul>"] #[doc =
5595 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5596 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
5597 _for_each_inner_peripheral!((@ peri_type #[doc =
5598 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5599 "<section class=\"warning\">"] #[doc =
5600 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5601 #[doc = "<ul>"] #[doc =
5602 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5603 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
5604 _for_each_inner_peripheral!((@ peri_type #[doc =
5605 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5606 "<section class=\"warning\">"] #[doc =
5607 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5608 #[doc = "<ul>"] #[doc =
5609 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5610 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
5611 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
5612 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5613 "GPIO11 peripheral singleton"] GPIO11 <= virtual()));
5614 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO12 peripheral singleton"]
5615 GPIO12 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5616 "GPIO13 peripheral singleton"] GPIO13 <= virtual()));
5617 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO14 peripheral singleton"]
5618 GPIO14 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
5619 "GPIO22 peripheral singleton"] GPIO22 <= virtual()));
5620 _for_each_inner_peripheral!((@ peri_type #[doc =
5621 "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5622 "<section class=\"warning\">"] #[doc =
5623 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5624 #[doc = "<ul>"] #[doc =
5625 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5626 = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()));
5627 _for_each_inner_peripheral!((@ peri_type #[doc =
5628 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5629 "<section class=\"warning\">"] #[doc =
5630 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5631 #[doc = "<ul>"] #[doc =
5632 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5633 = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()));
5634 _for_each_inner_peripheral!((@ peri_type #[doc =
5635 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5636 "<section class=\"warning\">"] #[doc =
5637 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5638 #[doc = "<ul>"] #[doc =
5639 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5640 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
5641 _for_each_inner_peripheral!((@ peri_type #[doc =
5642 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5643 "<section class=\"warning\">"] #[doc =
5644 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5645 #[doc = "<ul>"] #[doc =
5646 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5647 #[doc = "</section>"] GPIO26 <= virtual())); _for_each_inner_peripheral!((@
5648 peri_type #[doc = "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""]
5649 #[doc = "<section class=\"warning\">"] #[doc =
5650 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5651 #[doc = "<ul>"] #[doc =
5652 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5653 #[doc = "</section>"] GPIO27 <= virtual())); _for_each_inner_peripheral!((@
5654 peri_type #[doc = "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 :
5655 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5656 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5657 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
5658 peri_type #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 :
5659 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5660 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5661 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
5662 peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 :
5663 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5664 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5665 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
5666 peri_type #[doc = "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual()
5667 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5668 "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
5669 _for_each_inner_peripheral!((@ peri_type #[doc =
5670 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
5671 _for_each_inner_peripheral!((@ peri_type #[doc =
5672 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
5673 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
5674 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5675 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
5676 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
5677 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5678 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
5679 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
5680 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5681 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5682 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
5683 _for_each_inner_peripheral!((@ peri_type #[doc =
5684 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
5685 _for_each_inner_peripheral!((@ peri_type #[doc = "CLINT peripheral singleton"]
5686 CLINT <= CLINT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5687 "DMA peripheral singleton"] DMA <= DMA() (unstable)));
5688 _for_each_inner_peripheral!((@ peri_type #[doc = "DS peripheral singleton"] DS <=
5689 DS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5690 "ECC peripheral singleton"] ECC <= ECC() (unstable)));
5691 _for_each_inner_peripheral!((@ peri_type #[doc = "EFUSE peripheral singleton"]
5692 EFUSE <= EFUSE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5693 "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)));
5694 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
5695 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5696 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
5697 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
5698 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5699 "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
5700 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
5701 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5702 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
5703 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
5704 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
5705 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5706 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
5707 enable_peri_interrupt, disable_peri_interrupt })));
5708 _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
5709 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
5710 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5711 #[doc = "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
5712 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
5713 _for_each_inner_peripheral!((@ peri_type #[doc =
5714 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
5715 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5716 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
5717 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
5718 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5719 "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)));
5720 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
5721 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5722 = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
5723 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
5724 LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5725 "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
5726 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM0 peripheral singleton"]
5727 LP_APM0 <= LP_APM0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5728 = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
5729 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
5730 LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5731 = "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
5732 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
5733 LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5734 "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
5735 _for_each_inner_peripheral!((@ peri_type #[doc =
5736 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
5737 _for_each_inner_peripheral!((@ peri_type #[doc =
5738 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
5739 _for_each_inner_peripheral!((@ peri_type #[doc =
5740 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
5741 _for_each_inner_peripheral!((@ peri_type #[doc =
5742 "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)));
5743 _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
5744 PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
5745 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
5746 disable_tx_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5747 #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
5748 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
5749 PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
5750 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5751 #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)));
5752 _for_each_inner_peripheral!((@ peri_type #[doc = "PLIC_MX peripheral singleton"]
5753 PLIC_MX <= PLIC_MX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5754 = "PLIC_UX peripheral singleton"] PLIC_UX <= PLIC_UX() (unstable)));
5755 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
5756 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5757 "RMT peripheral singleton"] RMT <= RMT() (unstable)));
5758 _for_each_inner_peripheral!((@ peri_type #[doc = "RNG peripheral singleton"] RNG
5759 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5760 "RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
5761 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5762 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
5763 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5764 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5765 "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)));
5766 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
5767 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5768 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
5769 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
5770 SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
5771 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5772 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)));
5773 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
5774 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
5775 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)));
5776 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
5777 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5778 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
5779 _for_each_inner_peripheral!((@ peri_type #[doc = "TRACE0 peripheral singleton"]
5780 TRACE0 <= TRACE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5781 "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)));
5782 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
5783 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5784 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5785 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
5786 enable_peri_interrupt, disable_peri_interrupt })));
5787 _for_each_inner_peripheral!((@ peri_type #[doc = "UHCI0 peripheral singleton"]
5788 UHCI0 <= UHCI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5789 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
5790 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5791 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5792 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
5793 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
5794 virtual(LP_BLE_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
5795 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
5796 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
5797 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
5798 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5799 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
5800 _for_each_inner_peripheral!((@ peri_type #[doc =
5801 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
5802 _for_each_inner_peripheral!((@ peri_type #[doc =
5803 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
5804 _for_each_inner_peripheral!((@ peri_type #[doc =
5805 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
5806 _for_each_inner_peripheral!((@ peri_type #[doc =
5807 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
5808 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
5809 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
5810 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
5811 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
5812 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
5813 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
5814 _for_each_inner_peripheral!((GPIO12));
5815 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO13));
5816 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO14));
5817 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
5818 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
5819 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
5820 _for_each_inner_peripheral!((DMA_CH0(unstable)));
5821 _for_each_inner_peripheral!((DMA_CH1(unstable)));
5822 _for_each_inner_peripheral!((DMA_CH2(unstable)));
5823 _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
5824 _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
5825 _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
5826 _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
5827 _for_each_inner_peripheral!((SDM_CH0(unstable)));
5828 _for_each_inner_peripheral!((SDM_CH1(unstable)));
5829 _for_each_inner_peripheral!((SDM_CH2(unstable)));
5830 _for_each_inner_peripheral!((SDM_CH3(unstable)));
5831 _for_each_inner_peripheral!((AES(unstable)));
5832 _for_each_inner_peripheral!((APB_SARADC(unstable)));
5833 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
5834 _for_each_inner_peripheral!((DMA(unstable)));
5835 _for_each_inner_peripheral!((DS(unstable)));
5836 _for_each_inner_peripheral!((ECC(unstable)));
5837 _for_each_inner_peripheral!((GPIO(unstable)));
5838 _for_each_inner_peripheral!((GPIO_SD(unstable)));
5839 _for_each_inner_peripheral!((HMAC(unstable)));
5840 _for_each_inner_peripheral!((HP_APM(unstable)));
5841 _for_each_inner_peripheral!((HP_SYS(unstable)));
5842 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
5843 _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
5844 _for_each_inner_peripheral!((I2S0(unstable)));
5845 _for_each_inner_peripheral!((IEEE802154(unstable)));
5846 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
5847 _for_each_inner_peripheral!((INTPRI(unstable)));
5848 _for_each_inner_peripheral!((IO_MUX(unstable)));
5849 _for_each_inner_peripheral!((LEDC(unstable)));
5850 _for_each_inner_peripheral!((LPWR(unstable)));
5851 _for_each_inner_peripheral!((LP_ANA(unstable)));
5852 _for_each_inner_peripheral!((LP_AON(unstable)));
5853 _for_each_inner_peripheral!((LP_APM(unstable)));
5854 _for_each_inner_peripheral!((LP_APM0(unstable)));
5855 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
5856 _for_each_inner_peripheral!((LP_PERI(unstable)));
5857 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
5858 _for_each_inner_peripheral!((LP_WDT(unstable)));
5859 _for_each_inner_peripheral!((MCPWM0(unstable)));
5860 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
5861 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
5862 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
5863 _for_each_inner_peripheral!((OTP_DEBUG(unstable)));
5864 _for_each_inner_peripheral!((PARL_IO(unstable)));
5865 _for_each_inner_peripheral!((PAU(unstable)));
5866 _for_each_inner_peripheral!((PCNT(unstable)));
5867 _for_each_inner_peripheral!((PCR(unstable)));
5868 _for_each_inner_peripheral!((PLIC_MX(unstable)));
5869 _for_each_inner_peripheral!((PMU(unstable)));
5870 _for_each_inner_peripheral!((RMT(unstable)));
5871 _for_each_inner_peripheral!((RNG(unstable)));
5872 _for_each_inner_peripheral!((RSA(unstable)));
5873 _for_each_inner_peripheral!((SHA(unstable)));
5874 _for_each_inner_peripheral!((ETM(unstable)));
5875 _for_each_inner_peripheral!((SPI0(unstable)));
5876 _for_each_inner_peripheral!((SPI1(unstable)));
5877 _for_each_inner_peripheral!((SPI2));
5878 _for_each_inner_peripheral!((SYSTEM(unstable)));
5879 _for_each_inner_peripheral!((SYSTIMER(unstable)));
5880 _for_each_inner_peripheral!((TEE(unstable)));
5881 _for_each_inner_peripheral!((TIMG0(unstable)));
5882 _for_each_inner_peripheral!((TIMG1(unstable)));
5883 _for_each_inner_peripheral!((TRACE0(unstable)));
5884 _for_each_inner_peripheral!((TWAI0(unstable)));
5885 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
5886 _for_each_inner_peripheral!((UHCI0(unstable)));
5887 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
5888 _for_each_inner_peripheral!((ADC1(unstable)));
5889 _for_each_inner_peripheral!((BT(unstable)));
5890 _for_each_inner_peripheral!((FLASH(unstable)));
5891 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
5892 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
5893 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
5894 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
5895 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
5896 _for_each_inner_peripheral!((SPI2, Spi2, 0, AhbGdmaChannel));
5897 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
5898 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
5899 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
5900 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
5901 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
5902 _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
5903 _for_each_inner_peripheral!((all(@ peri_type #[doc =
5904 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
5905 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
5906 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5907 "<section class=\"warning\">"] #[doc =
5908 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5909 #[doc = "<ul>"] #[doc =
5910 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5911 #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
5912 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5913 "<section class=\"warning\">"] #[doc =
5914 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5915 #[doc = "<ul>"] #[doc =
5916 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5917 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
5918 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5919 "<section class=\"warning\">"] #[doc =
5920 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5921 #[doc = "<ul>"] #[doc =
5922 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5923 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
5924 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5925 "<section class=\"warning\">"] #[doc =
5926 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5927 #[doc = "<ul>"] #[doc =
5928 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5929 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
5930 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5931 "<section class=\"warning\">"] #[doc =
5932 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5933 #[doc = "<ul>"] #[doc =
5934 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5935 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
5936 "GPIO7 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 may be reserved for interfacing with SPI flash.</li>"] #[doc =
5941 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
5942 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5943 "<section class=\"warning\">"] #[doc =
5944 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5945 #[doc = "<ul>"] #[doc =
5946 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5947 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
5948 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5949 "<section class=\"warning\">"] #[doc =
5950 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5951 #[doc = "<ul>"] #[doc =
5952 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5953 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
5954 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
5955 "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
5956 "GPIO12 peripheral singleton"] GPIO12 <= virtual()), (@ peri_type #[doc =
5957 "GPIO13 peripheral singleton"] GPIO13 <= virtual()), (@ peri_type #[doc =
5958 "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
5959 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
5960 "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5961 "<section class=\"warning\">"] #[doc =
5962 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5963 #[doc = "<ul>"] #[doc =
5964 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5965 = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()), (@ peri_type #[doc =
5966 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5967 "<section class=\"warning\">"] #[doc =
5968 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5969 #[doc = "<ul>"] #[doc =
5970 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5971 = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
5972 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5973 "<section class=\"warning\">"] #[doc =
5974 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5975 #[doc = "<ul>"] #[doc =
5976 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5977 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
5978 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5979 "<section class=\"warning\">"] #[doc =
5980 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5981 #[doc = "<ul>"] #[doc =
5982 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5983 #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
5984 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5985 "<section class=\"warning\">"] #[doc =
5986 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5987 #[doc = "<ul>"] #[doc =
5988 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5989 #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
5990 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
5991 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5992 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5993 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5994 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
5995 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5996 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5997 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5998 "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
5999 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
6000 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
6001 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
6002 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)), (@
6003 peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual()
6004 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2
6005 <= virtual() (unstable)), (@ peri_type #[doc =
6006 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)), (@
6007 peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
6008 (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
6009 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
6010 SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
6011 "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
6012 #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
6013 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6014 = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
6015 peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
6016 ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "CLINT peripheral singleton"]
6017 CLINT <= CLINT() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"]
6018 DMA <= DMA() (unstable)), (@ peri_type #[doc = "DS peripheral singleton"] DS <=
6019 DS() (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <= ECC()
6020 (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE()
6021 (unstable)), (@ peri_type #[doc = "EXTMEM peripheral singleton"] EXTMEM <=
6022 EXTMEM() (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <=
6023 GPIO() (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD
6024 <= GPIO_SD() (unstable)), (@ peri_type #[doc = "HMAC peripheral singleton"] HMAC
6025 <= HMAC() (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"] HP_APM
6026 <= HP_APM() (unstable)), (@ peri_type #[doc = "HP_SYS peripheral singleton"]
6027 HP_SYS <= HP_SYS() (unstable)), (@ peri_type #[doc =
6028 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)), (@
6029 peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : {
6030 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6031 peri_type #[doc = "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : {
6032 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6033 peri_type #[doc = "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : {
6034 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6035 (unstable)), (@ peri_type #[doc = "IEEE802154 peripheral singleton"] IEEE802154
6036 <= IEEE802154(ZB_MAC : { bind_mac_interrupt, enable_mac_interrupt,
6037 disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
6038 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
6039 (unstable)), (@ peri_type #[doc = "INTPRI peripheral singleton"] INTPRI <=
6040 INTPRI() (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX
6041 <= IO_MUX() (unstable)), (@ peri_type #[doc = "LEDC peripheral singleton"] LEDC
6042 <= LEDC() (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <=
6043 LP_CLKRST() (unstable)), (@ peri_type #[doc = "LP_ANA peripheral singleton"]
6044 LP_ANA <= LP_ANA() (unstable)), (@ peri_type #[doc =
6045 "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)), (@ peri_type #[doc
6046 = "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)), (@ peri_type
6047 #[doc = "LP_APM0 peripheral singleton"] LP_APM0 <= LP_APM0() (unstable)), (@
6048 peri_type #[doc = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST()
6049 (unstable)), (@ peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <=
6050 LP_PERI() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
6051 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
6052 "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc
6053 = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)), (@ peri_type
6054 #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR()
6055 (unstable)), (@ peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON
6056 <= MODEM_LPCON() (unstable)), (@ peri_type #[doc =
6057 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
6058 (@ peri_type #[doc = "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG()
6059 (unstable)), (@ peri_type #[doc = "PARL_IO peripheral singleton"] PARL_IO <=
6060 PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
6061 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
6062 disable_tx_interrupt }) (unstable)), (@ peri_type #[doc =
6063 "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@ peri_type #[doc =
6064 "PCNT peripheral singleton"] PCNT <= PCNT(PCNT : { bind_peri_interrupt,
6065 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
6066 = "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@ peri_type #[doc =
6067 "PLIC_MX peripheral singleton"] PLIC_MX <= PLIC_MX() (unstable)), (@ peri_type
6068 #[doc = "PLIC_UX peripheral singleton"] PLIC_UX <= PLIC_UX() (unstable)), (@
6069 peri_type #[doc = "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@
6070 peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@
6071 peri_type #[doc = "RNG peripheral singleton"] RNG <= virtual() (unstable)), (@
6072 peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
6073 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6074 (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
6075 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6076 (unstable)), (@ peri_type #[doc = "ETM peripheral singleton"] ETM <= SOC_ETM()
6077 (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
6078 (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
6079 (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
6080 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
6081 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
6082 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
6083 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
6084 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
6085 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
6086 (unstable)), (@ peri_type #[doc = "TRACE0 peripheral singleton"] TRACE0 <=
6087 TRACE() (unstable)), (@ peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <=
6088 TWAI0() (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
6089 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
6090 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
6091 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
6092 disable_peri_interrupt })), (@ peri_type #[doc = "UHCI0 peripheral singleton"]
6093 UHCI0 <= UHCI0() (unstable)), (@ peri_type #[doc =
6094 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
6095 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
6096 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
6097 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
6098 virtual(LP_BLE_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
6099 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
6100 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
6101 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
6102 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
6103 (@ peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
6104 virtual() (unstable)), (@ peri_type #[doc =
6105 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
6106 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
6107 virtual() (unstable)), (@ peri_type #[doc =
6108 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
6109 _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1), (GPIO2), (GPIO3),
6110 (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11),
6111 (GPIO12), (#[cfg(not(use_xtal32k))] GPIO13), (#[cfg(not(use_xtal32k))] GPIO14),
6112 (GPIO22), (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (DMA_CH0(unstable)),
6113 (DMA_CH1(unstable)), (DMA_CH2(unstable)), (PCNT0_UNIT0(unstable)),
6114 (PCNT0_UNIT1(unstable)), (PCNT0_UNIT2(unstable)), (PCNT0_UNIT3(unstable)),
6115 (SDM_CH0(unstable)), (SDM_CH1(unstable)), (SDM_CH2(unstable)),
6116 (SDM_CH3(unstable)), (AES(unstable)), (APB_SARADC(unstable)),
6117 (ASSIST_DEBUG(unstable)), (DMA(unstable)), (DS(unstable)), (ECC(unstable)),
6118 (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)), (HP_APM(unstable)),
6119 (HP_SYS(unstable)), (I2C_ANA_MST(unstable)), (I2C0), (I2C1), (I2S0(unstable)),
6120 (IEEE802154(unstable)), (INTERRUPT_CORE0(unstable)), (INTPRI(unstable)),
6121 (IO_MUX(unstable)), (LEDC(unstable)), (LPWR(unstable)), (LP_ANA(unstable)),
6122 (LP_AON(unstable)), (LP_APM(unstable)), (LP_APM0(unstable)),
6123 (LP_CLKRST(unstable)), (LP_PERI(unstable)), (RTC_TIMER(unstable)),
6124 (LP_WDT(unstable)), (MCPWM0(unstable)), (MEM_MONITOR(unstable)),
6125 (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)), (OTP_DEBUG(unstable)),
6126 (PARL_IO(unstable)), (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)),
6127 (PLIC_MX(unstable)), (PMU(unstable)), (RMT(unstable)), (RNG(unstable)),
6128 (RSA(unstable)), (SHA(unstable)), (ETM(unstable)), (SPI0(unstable)),
6129 (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
6130 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (TRACE0(unstable)),
6131 (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)), (USB_DEVICE(unstable)),
6132 (ADC1(unstable)), (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)),
6133 (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
6134 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
6135 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 0, AhbGdmaChannel), (UHCI0,
6136 Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3, AhbGdmaChannel), (AES, Aes, 6,
6137 AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel), (APB_SARADC, ApbSaradc, 8,
6138 AhbGdmaChannel), (PARL_IO, ParlIo, 9, AhbGdmaChannel)));
6139 };
6140}
6141#[macro_export]
6168#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6169macro_rules! for_each_gpio {
6170 ($($pattern:tt => $code:tt;)*) => {
6171 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
6172 } _for_each_inner_gpio!((0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
6173 [Output]))); _for_each_inner_gpio!((1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0)
6174 ([Input] [Output]))); _for_each_inner_gpio!((2, GPIO2(_0 => MTMS _2 => FSPIWP)
6175 (_2 => FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((3, GPIO3(_0 => MTDI
6176 _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((4,
6177 GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])));
6178 _for_each_inner_gpio!((5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input]
6179 [Output]))); _for_each_inner_gpio!((6, GPIO6() () ([Input] [Output])));
6180 _for_each_inner_gpio!((7, GPIO7() () ([Input] [Output])));
6181 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
6182 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
6183 _for_each_inner_gpio!((10, GPIO10() () ([Input] [Output])));
6184 _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
6185 _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
6186 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
6187 _for_each_inner_gpio!((14, GPIO14() () ([Input] [Output])));
6188 _for_each_inner_gpio!((22, GPIO22() () ([Input] [Output])));
6189 _for_each_inner_gpio!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input]
6190 [Output]))); _for_each_inner_gpio!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2)
6191 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25() (_2 => FSPICS3)
6192 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26() (_2 => FSPICS4)
6193 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27() (_2 => FSPICS5)
6194 ([Input] [Output]))); _for_each_inner_gpio!((all(0, GPIO0(_2 => FSPIQ) (_2 =>
6195 FSPIQ) ([Input] [Output])), (1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
6196 [Output])), (2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input]
6197 [Output])), (3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD) ([Input]
6198 [Output])), (4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
6199 [Output])), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
6200 (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input] [Output])), (8,
6201 GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10()
6202 () ([Input] [Output])), (11, GPIO11() () ([Input] [Output])), (12, GPIO12() ()
6203 ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14, GPIO14() ()
6204 ([Input] [Output])), (22, GPIO22() () ([Input] [Output])), (23, GPIO23(_0 =>
6205 U0RXD) (_2 => FSPICS1) ([Input] [Output])), (24, GPIO24() (_0 => U0TXD _2 =>
6206 FSPICS2) ([Input] [Output])), (25, GPIO25() (_2 => FSPICS3) ([Input] [Output])),
6207 (26, GPIO26() (_2 => FSPICS4) ([Input] [Output])), (27, GPIO27() (_2 => FSPICS5)
6208 ([Input] [Output]))));
6209 };
6210}
6211#[macro_export]
6238#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6239macro_rules! for_each_analog_function {
6240 ($($pattern:tt => $code:tt;)*) => {
6241 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
6242 tt) => {} } _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
6243 _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
6244 _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
6245 _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
6246 _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
6247 _for_each_inner_analog_function!((ZCD0, GPIO10));
6248 _for_each_inner_analog_function!((ZCD1, GPIO11));
6249 _for_each_inner_analog_function!((XTAL_32K_P, GPIO13));
6250 _for_each_inner_analog_function!((XTAL_32K_N, GPIO14));
6251 _for_each_inner_analog_function!((USJ_DM, GPIO26));
6252 _for_each_inner_analog_function!((USJ_DP, GPIO27));
6253 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
6254 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
6255 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
6256 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
6257 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
6258 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO10));
6259 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO11));
6260 _for_each_inner_analog_function!((all(ADC1_CH0, GPIO1), (ADC1_CH1, GPIO2),
6261 (ADC1_CH2, GPIO3), (ADC1_CH3, GPIO4), (ADC1_CH4, GPIO5), (ZCD0, GPIO10), (ZCD1,
6262 GPIO11), (XTAL_32K_P, GPIO13), (XTAL_32K_N, GPIO14), (USJ_DM, GPIO26), (USJ_DP,
6263 GPIO27))); _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0),
6264 GPIO1), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3),
6265 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5)));
6266 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO10), ((ZCD1, ZCDn,
6267 1), GPIO11)));
6268 };
6269}
6270#[macro_export]
6308#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6309macro_rules! for_each_lp_function {
6310 ($($pattern:tt => $code:tt;)*) => {
6311 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
6312 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO7, _0));
6313 _for_each_inner_lp_function!((LP_GPIO1, GPIO8, _0));
6314 _for_each_inner_lp_function!((LP_GPIO2, GPIO9, _0));
6315 _for_each_inner_lp_function!((LP_GPIO3, GPIO10, _0));
6316 _for_each_inner_lp_function!((LP_GPIO4, GPIO11, _0));
6317 _for_each_inner_lp_function!((LP_GPIO5, GPIO12, _0));
6318 _for_each_inner_lp_function!((LP_GPIO6, GPIO13, _0));
6319 _for_each_inner_lp_function!((LP_GPIO7, GPIO14, _0));
6320 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO7, _0, () ()));
6321 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO8, _0, () ()));
6322 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO9, _0, () ()));
6323 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO10, _0, () ()));
6324 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO11, _0, () ()));
6325 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO12, _0, () ()));
6326 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO13, _0, () ()));
6327 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO14, _0, () ()));
6328 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO7, _0), (LP_GPIO1, GPIO8, _0),
6329 (LP_GPIO2, GPIO9, _0), (LP_GPIO3, GPIO10, _0), (LP_GPIO4, GPIO11, _0), (LP_GPIO5,
6330 GPIO12, _0), (LP_GPIO6, GPIO13, _0), (LP_GPIO7, GPIO14, _0)));
6331 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO7, _0, ()
6332 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO8, _0, () ()), ((LP_GPIO2, LP_GPIOn, 2),
6333 GPIO9, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO10, _0, () ()), ((LP_GPIO4,
6334 LP_GPIOn, 4), GPIO11, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO12, _0, () ()),
6335 ((LP_GPIO6, LP_GPIOn, 6), GPIO13, _0, () ()), ((LP_GPIO7, LP_GPIOn, 7), GPIO14,
6336 _0, () ())));
6337 };
6338}
6339#[macro_export]
6370#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6371macro_rules! for_each_iomux_function {
6372 ($($pattern:tt => $code:tt;)*) => {
6373 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
6374 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO0, _2));
6375 _for_each_inner_iomux_function!((FSPICS0, GPIO1, _2));
6376 _for_each_inner_iomux_function!((MTMS, GPIO2, _0));
6377 _for_each_inner_iomux_function!((FSPIWP, GPIO2, _2));
6378 _for_each_inner_iomux_function!((MTDI, GPIO3, _0));
6379 _for_each_inner_iomux_function!((FSPIHD, GPIO3, _2));
6380 _for_each_inner_iomux_function!((MTCK, GPIO4, _0));
6381 _for_each_inner_iomux_function!((FSPICLK, GPIO4, _2));
6382 _for_each_inner_iomux_function!((MTDO, GPIO5, _0));
6383 _for_each_inner_iomux_function!((FSPID, GPIO5, _2));
6384 _for_each_inner_iomux_function!((U0RXD, GPIO23, _0));
6385 _for_each_inner_iomux_function!((FSPICS1, GPIO23, _2));
6386 _for_each_inner_iomux_function!((U0TXD, GPIO24, _0));
6387 _for_each_inner_iomux_function!((FSPICS2, GPIO24, _2));
6388 _for_each_inner_iomux_function!((FSPICS3, GPIO25, _2));
6389 _for_each_inner_iomux_function!((FSPICS4, GPIO26, _2));
6390 _for_each_inner_iomux_function!((FSPICS5, GPIO27, _2));
6391 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO1, _2));
6392 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO23, _2));
6393 _for_each_inner_iomux_function!(((FSPICS2, FSPICSn, 2), GPIO24, _2));
6394 _for_each_inner_iomux_function!(((FSPICS3, FSPICSn, 3), GPIO25, _2));
6395 _for_each_inner_iomux_function!(((FSPICS4, FSPICSn, 4), GPIO26, _2));
6396 _for_each_inner_iomux_function!(((FSPICS5, FSPICSn, 5), GPIO27, _2));
6397 _for_each_inner_iomux_function!((all(FSPIQ, GPIO0, _2), (FSPICS0, GPIO1, _2),
6398 (MTMS, GPIO2, _0), (FSPIWP, GPIO2, _2), (MTDI, GPIO3, _0), (FSPIHD, GPIO3, _2),
6399 (MTCK, GPIO4, _0), (FSPICLK, GPIO4, _2), (MTDO, GPIO5, _0), (FSPID, GPIO5, _2),
6400 (U0RXD, GPIO23, _0), (FSPICS1, GPIO23, _2), (U0TXD, GPIO24, _0), (FSPICS2,
6401 GPIO24, _2), (FSPICS3, GPIO25, _2), (FSPICS4, GPIO26, _2), (FSPICS5, GPIO27,
6402 _2))); _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO1,
6403 _2), ((FSPICS1, FSPICSn, 1), GPIO23, _2), ((FSPICS2, FSPICSn, 2), GPIO24, _2),
6404 ((FSPICS3, FSPICSn, 3), GPIO25, _2), ((FSPICS4, FSPICSn, 4), GPIO26, _2),
6405 ((FSPICS5, FSPICSn, 5), GPIO27, _2)));
6406 };
6407}
6408#[macro_export]
6425#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6426macro_rules! gpio_for_signal {
6427 (FSPIQ $(, $_fallback:literal)?) => {
6428 "GPIO0"
6429 };
6430 (FSPICS0 $(, $_fallback:literal)?) => {
6431 "GPIO1"
6432 };
6433 (ADC1_CH0 $(, $_fallback:literal)?) => {
6434 "GPIO1"
6435 };
6436 (MTMS $(, $_fallback:literal)?) => {
6437 "GPIO2"
6438 };
6439 (FSPIWP $(, $_fallback:literal)?) => {
6440 "GPIO2"
6441 };
6442 (ADC1_CH1 $(, $_fallback:literal)?) => {
6443 "GPIO2"
6444 };
6445 (MTDI $(, $_fallback:literal)?) => {
6446 "GPIO3"
6447 };
6448 (FSPIHD $(, $_fallback:literal)?) => {
6449 "GPIO3"
6450 };
6451 (ADC1_CH2 $(, $_fallback:literal)?) => {
6452 "GPIO3"
6453 };
6454 (MTCK $(, $_fallback:literal)?) => {
6455 "GPIO4"
6456 };
6457 (FSPICLK $(, $_fallback:literal)?) => {
6458 "GPIO4"
6459 };
6460 (ADC1_CH3 $(, $_fallback:literal)?) => {
6461 "GPIO4"
6462 };
6463 (MTDO $(, $_fallback:literal)?) => {
6464 "GPIO5"
6465 };
6466 (FSPID $(, $_fallback:literal)?) => {
6467 "GPIO5"
6468 };
6469 (ADC1_CH4 $(, $_fallback:literal)?) => {
6470 "GPIO5"
6471 };
6472 (LP_GPIO0 $(, $_fallback:literal)?) => {
6473 "GPIO7"
6474 };
6475 (LP_GPIO1 $(, $_fallback:literal)?) => {
6476 "GPIO8"
6477 };
6478 (LP_GPIO2 $(, $_fallback:literal)?) => {
6479 "GPIO9"
6480 };
6481 (ZCD0 $(, $_fallback:literal)?) => {
6482 "GPIO10"
6483 };
6484 (LP_GPIO3 $(, $_fallback:literal)?) => {
6485 "GPIO10"
6486 };
6487 (ZCD1 $(, $_fallback:literal)?) => {
6488 "GPIO11"
6489 };
6490 (LP_GPIO4 $(, $_fallback:literal)?) => {
6491 "GPIO11"
6492 };
6493 (LP_GPIO5 $(, $_fallback:literal)?) => {
6494 "GPIO12"
6495 };
6496 (XTAL_32K_P $(, $_fallback:literal)?) => {
6497 "GPIO13"
6498 };
6499 (LP_GPIO6 $(, $_fallback:literal)?) => {
6500 "GPIO13"
6501 };
6502 (XTAL_32K_N $(, $_fallback:literal)?) => {
6503 "GPIO14"
6504 };
6505 (LP_GPIO7 $(, $_fallback:literal)?) => {
6506 "GPIO14"
6507 };
6508 (U0RXD $(, $_fallback:literal)?) => {
6509 "GPIO23"
6510 };
6511 (FSPICS1 $(, $_fallback:literal)?) => {
6512 "GPIO23"
6513 };
6514 (U0TXD $(, $_fallback:literal)?) => {
6515 "GPIO24"
6516 };
6517 (FSPICS2 $(, $_fallback:literal)?) => {
6518 "GPIO24"
6519 };
6520 (FSPICS3 $(, $_fallback:literal)?) => {
6521 "GPIO25"
6522 };
6523 (FSPICS4 $(, $_fallback:literal)?) => {
6524 "GPIO26"
6525 };
6526 (USJ_DM $(, $_fallback:literal)?) => {
6527 "GPIO26"
6528 };
6529 (FSPICS5 $(, $_fallback:literal)?) => {
6530 "GPIO27"
6531 };
6532 (USJ_DP $(, $_fallback:literal)?) => {
6533 "GPIO27"
6534 };
6535 ($_signal:ident, $fallback:literal) => {
6536 $fallback
6537 };
6538}
6539#[macro_export]
6543#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6544macro_rules! define_io_mux_signals {
6545 () => {
6546 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
6547 #[derive(Debug, PartialEq, Copy, Clone)]
6548 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6549 #[doc(hidden)]
6550 pub enum InputSignal {
6551 EXT_ADC_START = 0,
6552 U0RXD = 6,
6553 U0CTS = 7,
6554 U0DSR = 8,
6555 U1RXD = 9,
6556 U1CTS = 10,
6557 U1DSR = 11,
6558 I2S_MCLK = 12,
6559 I2SO_BCK = 13,
6560 I2SO_WS = 14,
6561 I2SI_SD = 15,
6562 I2SI_BCK = 16,
6563 I2SI_WS = 17,
6564 USB_JTAG_TDO_BRIDGE = 19,
6565 CPU_GPIO_0 = 28,
6566 CPU_GPIO_1 = 29,
6567 CPU_GPIO_2 = 30,
6568 CPU_GPIO_3 = 31,
6569 CPU_GPIO_4 = 32,
6570 CPU_GPIO_5 = 33,
6571 CPU_GPIO_6 = 34,
6572 CPU_GPIO_7 = 35,
6573 I2CEXT0_SCL = 45,
6574 I2CEXT0_SDA = 46,
6575 PARL_RX_DATA0 = 47,
6576 PARL_RX_DATA1 = 48,
6577 PARL_RX_DATA2 = 49,
6578 PARL_RX_DATA3 = 50,
6579 PARL_RX_DATA4 = 51,
6580 PARL_RX_DATA5 = 52,
6581 PARL_RX_DATA6 = 53,
6582 PARL_RX_DATA7 = 54,
6583 I2CEXT1_SCL = 55,
6584 I2CEXT1_SDA = 56,
6585 FSPICLK = 63,
6586 FSPIQ = 64,
6587 FSPID = 65,
6588 FSPIHD = 66,
6589 FSPIWP = 67,
6590 FSPICS0 = 68,
6591 PARL_RX_CLK = 69,
6592 PARL_TX_CLK = 70,
6593 RMT_SIG_0 = 71,
6594 RMT_SIG_1 = 72,
6595 TWAI0_RX = 73,
6596 PWM0_SYNC0 = 87,
6597 PWM0_SYNC1 = 88,
6598 PWM0_SYNC2 = 89,
6599 PWM0_F0 = 90,
6600 PWM0_F1 = 91,
6601 PWM0_F2 = 92,
6602 PWM0_CAP0 = 93,
6603 PWM0_CAP1 = 94,
6604 PWM0_CAP2 = 95,
6605 SIG_FUNC_97 = 97,
6606 SIG_FUNC_98 = 98,
6607 SIG_FUNC_99 = 99,
6608 SIG_FUNC_100 = 100,
6609 PCNT0_SIG_CH0 = 101,
6610 PCNT0_SIG_CH1 = 102,
6611 PCNT0_CTRL_CH0 = 103,
6612 PCNT0_CTRL_CH1 = 104,
6613 PCNT1_SIG_CH0 = 105,
6614 PCNT1_SIG_CH1 = 106,
6615 PCNT1_CTRL_CH0 = 107,
6616 PCNT1_CTRL_CH1 = 108,
6617 PCNT2_SIG_CH0 = 109,
6618 PCNT2_SIG_CH1 = 110,
6619 PCNT2_CTRL_CH0 = 111,
6620 PCNT2_CTRL_CH1 = 112,
6621 PCNT3_SIG_CH0 = 113,
6622 PCNT3_SIG_CH1 = 114,
6623 PCNT3_CTRL_CH0 = 115,
6624 PCNT3_CTRL_CH1 = 116,
6625 SPIQ = 121,
6626 SPID = 122,
6627 SPIHD = 123,
6628 SPIWP = 124,
6629 MTDI,
6630 MTCK,
6631 MTMS,
6632 }
6633 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
6634 #[derive(Debug, PartialEq, Copy, Clone)]
6635 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6636 #[doc(hidden)]
6637 pub enum OutputSignal {
6638 LEDC_LS_SIG0 = 0,
6639 LEDC_LS_SIG1 = 1,
6640 LEDC_LS_SIG2 = 2,
6641 LEDC_LS_SIG3 = 3,
6642 LEDC_LS_SIG4 = 4,
6643 LEDC_LS_SIG5 = 5,
6644 U0TXD = 6,
6645 U0RTS = 7,
6646 U0DTR = 8,
6647 U1TXD = 9,
6648 U1RTS = 10,
6649 U1DTR = 11,
6650 I2S_MCLK = 12,
6651 I2SO_BCK = 13,
6652 I2SO_WS = 14,
6653 I2SO_SD = 15,
6654 I2SI_BCK = 16,
6655 I2SI_WS = 17,
6656 I2SO_SD1 = 18,
6657 USB_JTAG_TRST = 19,
6658 CPU_GPIO_0 = 28,
6659 CPU_GPIO_1 = 29,
6660 CPU_GPIO_2 = 30,
6661 CPU_GPIO_3 = 31,
6662 CPU_GPIO_4 = 32,
6663 CPU_GPIO_5 = 33,
6664 CPU_GPIO_6 = 34,
6665 CPU_GPIO_7 = 35,
6666 I2CEXT0_SCL = 45,
6667 I2CEXT0_SDA = 46,
6668 PARL_TX_DATA0 = 47,
6669 PARL_TX_DATA1 = 48,
6670 PARL_TX_DATA2 = 49,
6671 PARL_TX_DATA3 = 50,
6672 PARL_TX_DATA4 = 51,
6673 PARL_TX_DATA5 = 52,
6674 PARL_TX_DATA6 = 53,
6675 PARL_TX_DATA7 = 54,
6676 I2CEXT1_SCL = 55,
6677 I2CEXT1_SDA = 56,
6678 FSPICLK = 63,
6679 FSPIQ = 64,
6680 FSPID = 65,
6681 FSPIHD = 66,
6682 FSPIWP = 67,
6683 FSPICS0 = 68,
6684 PARL_RX_CLK = 69,
6685 PARL_TX_CLK = 70,
6686 RMT_SIG_0 = 71,
6687 RMT_SIG_1 = 72,
6688 TWAI0_TX = 73,
6689 TWAI0_BUS_OFF_ON = 74,
6690 TWAI0_CLKOUT = 75,
6691 TWAI0_STANDBY = 76,
6692 CTE_ANT7 = 78,
6693 CTE_ANT8 = 79,
6694 CTE_ANT9 = 80,
6695 GPIO_SD0 = 83,
6696 GPIO_SD1 = 84,
6697 GPIO_SD2 = 85,
6698 GPIO_SD3 = 86,
6699 PWM0_0A = 87,
6700 PWM0_0B = 88,
6701 PWM0_1A = 89,
6702 PWM0_1B = 90,
6703 PWM0_2A = 91,
6704 PWM0_2B = 92,
6705 SIG_IN_FUNC97 = 97,
6706 SIG_IN_FUNC98 = 98,
6707 SIG_IN_FUNC99 = 99,
6708 SIG_IN_FUNC100 = 100,
6709 FSPICS1 = 101,
6710 FSPICS2 = 102,
6711 FSPICS3 = 103,
6712 FSPICS4 = 104,
6713 FSPICS5 = 105,
6714 CTE_ANT10 = 106,
6715 CTE_ANT11 = 107,
6716 CTE_ANT12 = 108,
6717 CTE_ANT13 = 109,
6718 CTE_ANT14 = 110,
6719 CTE_ANT15 = 111,
6720 SPICLK = 114,
6721 SPICS0 = 115,
6722 SPICS1 = 116,
6723 SPIQ = 121,
6724 SPID = 122,
6725 SPIHD = 123,
6726 SPIWP = 124,
6727 CLK_OUT_OUT1 = 125,
6728 CLK_OUT_OUT2 = 126,
6729 CLK_OUT_OUT3 = 127,
6730 GPIO = 128,
6731 MTDO,
6732 }
6733 };
6734}
6735#[macro_export]
6742#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6743macro_rules! define_lp_functions {
6744 () => {
6745 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
6750 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6751 #[doc(hidden)]
6752 pub enum LpFunction {
6753 _0 = 0,
6755 }
6756 impl LpFunction {
6757 pub const LP_GPIO: Self = Self::_0;
6759 }
6760 };
6761}
6762#[macro_export]
6775#[expect(clippy::crate_in_macro_def)]
6776#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6777macro_rules! define_io_mux_reg {
6778 () => {
6779 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
6780 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
6781 }
6782 };
6783}