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 "esp32c61"
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-C61"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32c61"
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-c61_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 96
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(96)
75 };
76 ("gpio.constant_1_input") => {
77 64
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(64)
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 100
99 };
100 ("gpio.input_signal_max", str) => {
101 stringify!(100)
102 };
103 ("gpio.output_signal_max") => {
104 256
105 };
106 ("gpio.output_signal_max", str) => {
107 stringify!(256)
108 };
109 ("dedicated_gpio.version") => {
110 "riscv_v1"
111 };
112 ("dedicated_gpio.needs_initialization") => {
113 false
114 };
115 ("dedicated_gpio.channel_count") => {
116 8
117 };
118 ("dedicated_gpio.channel_count", str) => {
119 stringify!(8)
120 };
121 ("lp_io.version") => {
122 "v4"
123 };
124 ("lp_io.has_gpio_matrix") => {
125 false
126 };
127 ("uart.ram_size") => {
128 128
129 };
130 ("uart.ram_size", str) => {
131 stringify!(128)
132 };
133 ("uart.version") => {
134 2
135 };
136 ("uart.version", str) => {
137 stringify!(2)
138 };
139 ("uart.peripheral_controls_mem_clk") => {
140 true
141 };
142 ("uart.has_sclk_divider") => {
143 false
144 };
145 ("uart.has_sclk_enable") => {
146 true
147 };
148 ("i2c_master.version") => {
149 4
150 };
151 ("i2c_master.version", str) => {
152 stringify!(4)
153 };
154 ("i2c_master.has_fsm_timeouts") => {
155 true
156 };
157 ("i2c_master.has_hw_bus_clear") => {
158 true
159 };
160 ("i2c_master.has_bus_timeout_enable") => {
161 true
162 };
163 ("i2c_master.separate_filter_config_registers") => {
164 false
165 };
166 ("i2c_master.can_estimate_nack_reason") => {
167 true
168 };
169 ("i2c_master.has_conf_update") => {
170 true
171 };
172 ("i2c_master.has_reliable_fsm_reset") => {
173 true
174 };
175 ("i2c_master.has_arbitration_en") => {
176 true
177 };
178 ("i2c_master.has_tx_fifo_watermark") => {
179 true
180 };
181 ("i2c_master.bus_timeout_is_exponential") => {
182 true
183 };
184 ("i2c_master.has_pd_en") => {
185 true
186 };
187 ("i2c_master.max_bus_timeout") => {
188 31
189 };
190 ("i2c_master.max_bus_timeout", str) => {
191 stringify!(31)
192 };
193 ("i2c_master.ll_intr_mask") => {
194 262143
195 };
196 ("i2c_master.ll_intr_mask", str) => {
197 stringify!(262143)
198 };
199 ("i2c_master.fifo_size") => {
200 32
201 };
202 ("i2c_master.fifo_size", str) => {
203 stringify!(32)
204 };
205 ("spi_master.version") => {
206 3
207 };
208 ("spi_master.version", str) => {
209 stringify!(3)
210 };
211 ("spi_master.fifo_size") => {
212 64
213 };
214 ("spi_master.fifo_size", str) => {
215 stringify!(64)
216 };
217 ("spi_master.bit_order_is_bool") => {
218 false
219 };
220 ("spi_master.has_octal") => {
221 false
222 };
223 ("spi_master.has_app_interrupts") => {
224 true
225 };
226 ("spi_master.has_dma_segmented_transfer") => {
227 true
228 };
229 ("spi_master.has_clk_pre_div") => {
230 true
231 };
232 ("spi_master.dma_can_access_flash") => {
233 true
234 };
235 ("i2s.version") => {
236 3
237 };
238 ("i2s.version", str) => {
239 stringify!(3)
240 };
241 ("i2s.mclk_divider_bit_width") => {
242 9
243 };
244 ("i2s.mclk_divider_bit_width", str) => {
245 stringify!(9)
246 };
247 ("i2s.max_ws_width") => {
248 512
249 };
250 ("i2s.max_ws_width", str) => {
251 stringify!(512)
252 };
253 ("i2s.clock_configured_by_pcr") => {
254 true
255 };
256 ("i2s.clock_configured_by_hp_sys_clkrst") => {
257 false
258 };
259 ("i2s.supports_pdm_rx_hp_filter") => {
260 false
261 };
262 ("i2s.supports_pdm_tx") => {
263 true
264 };
265 ("i2s.supports_pdm_rx") => {
266 true
267 };
268 ("i2s.supports_pcm2pdm") => {
269 true
270 };
271 ("i2s.supports_pdm2pcm") => {
272 false
273 };
274 ("bt.controller") => {
275 "npl"
276 };
277 ("wifi.has_wifi6") => {
278 true
279 };
280 ("wifi.mac_version") => {
281 3
282 };
283 ("wifi.mac_version", str) => {
284 stringify!(3)
285 };
286 ("wifi.has_5g") => {
287 false
288 };
289 ("wifi.csi_supported") => {
290 true
291 };
292 ("wifi.has_nan") => {
293 true
294 };
295 ("wifi.has_ftm") => {
296 true
297 };
298 ("phy.combo_module") => {
299 true
300 };
301 ("adc.controller") => {
302 "digital"
303 };
304 ("adc.channel_count") => {
305 4
306 };
307 ("adc.channel_count", str) => {
308 stringify!(4)
309 };
310 ("adc.line_calibration") => {
311 true
312 };
313 ("adc.curve_calibration") => {
314 true
315 };
316 ("adc.basic_calibration") => {
317 true
318 };
319 ("adc.calibration_v1_scheme_supported") => {
320 true
321 };
322 ("adc.channel_compensation") => {
323 true
324 };
325 ("adc.pcr_clock") => {
326 true
327 };
328 ("adc.pcr_sar_clk_div") => {
329 true
330 };
331 ("adc.sar_power_override") => {
332 true
333 };
334 ("timergroup.timg_has_timer1") => {
335 false
336 };
337 ("timergroup.timg_has_divcnt_rst") => {
338 true
339 };
340 ("timergroup.wdt_has_conf_update") => {
341 true
342 };
343 ("timergroup.rc_fast_calibration_divider_min_rev") => {
344 0
345 };
346 ("timergroup.rc_fast_calibration_divider") => {
347 32
348 };
349 ("timergroup.rc_fast_calibration_tick_enable") => {
350 false
351 };
352 ("ecc.zero_extend_writes") => {
353 true
354 };
355 ("ecc.separate_jacobian_point_memory") => {
356 true
357 };
358 ("ecc.has_memory_clock_gate") => {
359 true
360 };
361 ("ecc.supports_enhanced_security") => {
362 true
363 };
364 ("ecc.mem_block_size") => {
365 32
366 };
367 ("rng.apb_cycle_wait_num") => {
368 16
369 };
370 ("rng.apb_cycle_wait_num", str) => {
371 stringify!(16)
372 };
373 ("rng.trng_supported") => {
374 true
375 };
376 ("rng.is_lp_sys") => {
377 true
378 };
379 ("sleep.light_sleep") => {
380 true
381 };
382 ("sleep.deep_sleep") => {
383 true
384 };
385 ("sleep.rejectable_mask") => {
386 4094
387 };
388 ("sleep.ext1_version") => {
389 2
390 };
391 ("sleep.ext1_version", str) => {
392 stringify!(2)
393 };
394 ("sleep.pin_wakeup_version") => {
395 3
396 };
397 ("sleep.pin_wakeup_version", str) => {
398 stringify!(3)
399 };
400 ("sleep.deep_sleep_needs_gpio_isolation") => {
401 false
402 };
403 ("assist_debug.has_sp_monitor") => {
404 true
405 };
406 ("assist_debug.has_region_monitor") => {
407 true
408 };
409 ("dma.mem2mem_requires_peripheral") => {
410 false
411 };
412 ("dma.ext_mem_configurable_block_size") => {
413 false
414 };
415 ("dma.separate_in_out_interrupts") => {
416 true
417 };
418 ("dma.gdma_version") => {
419 2
420 };
421 ("dma.gdma_version", str) => {
422 stringify!(2)
423 };
424 ("interrupts.status_registers") => {
425 3
426 };
427 ("interrupts.status_registers", str) => {
428 stringify!(3)
429 };
430 ("interrupts.disabled_interrupt") => {
431 0
432 };
433 ("mmu.page_size") => {
434 65536
435 };
436 ("mmu.page_size", str) => {
437 stringify!(65536)
438 };
439 ("mmu.entry_num") => {
440 512
441 };
442 ("mmu.entry_num", str) => {
443 stringify!(512)
444 };
445 ("psram.octal_spi") => {
446 false
447 };
448 ("psram.hex_spi") => {
449 false
450 };
451 ("psram.extmem_origin") => {
452 1107296256
453 };
454 ("psram.extmem_origin", str) => {
455 stringify!(1107296256)
456 };
457 ("rom.has_crc_le") => {
458 true
459 };
460 ("rom.has_crc_be") => {
461 true
462 };
463 ("rom.has_md5_bsd") => {
464 true
465 };
466 ("rom.has_md5_mbedtls") => {
467 false
468 };
469 ("soc.cpu_has_branch_predictor") => {
470 true
471 };
472 ("soc.cpu_has_csr_pc") => {
473 false
474 };
475 ("soc.cpu_has_zcmp_workaround") => {
476 false
477 };
478 ("soc.multi_core_enabled") => {
479 false
480 };
481 ("soc.cpu_csr_prv_mode") => {
482 2064
483 };
484 ("soc.cpu_csr_prv_mode", str) => {
485 stringify!(2064)
486 };
487 ("soc.internal_memory_cached") => {
488 false
489 };
490 ("soc.has_swd_watchdog") => {
491 true
492 };
493 ("soc.cpu_mcause_mask") => {
494 31
495 };
496 ("soc.cpu_mcause_mask", str) => {
497 stringify!(31)
498 };
499 ("soc.cpu_pmp_granularity") => {
500 128
501 };
502 ("soc.cpu_pmp_granularity", str) => {
503 stringify!(128)
504 };
505 ("clock_tree.hp_root_clk") => {
506 [crate ::soc::clocks::HpRootClkConfig::Xtal, crate
507 ::soc::clocks::HpRootClkConfig::RcFast, crate
508 ::soc::clocks::HpRootClkConfig::PllF160m]
509 };
510 ("clock_tree.cpu_clk.divisor") => {
511 (0, 255)
512 };
513 ("clock_tree.ahb_clk.divisor") => {
514 (0, 255)
515 };
516 ("clock_tree.apb_clk.divisor") => {
517 (0, 255)
518 };
519 ("clock_tree.lp_fast_clk") => {
520 [crate ::soc::clocks::LpFastClkConfig::RcFast, crate
521 ::soc::clocks::LpFastClkConfig::XtalD2, crate
522 ::soc::clocks::LpFastClkConfig::Xtal]
523 };
524 ("clock_tree.lp_slow_clk") => {
525 [crate ::soc::clocks::LpSlowClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
526 ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
527 ::soc::clocks::LpSlowClkConfig::OscSlow]
528 };
529 ("clock_tree.ble_lp_clk") => {
530 [crate ::soc::clocks::BleLpClkConfig::Xtal, crate
531 ::soc::clocks::BleLpClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
532 ::soc::clocks::BleLpClkConfig::Xtal32k]
533 };
534 ("clock_tree.crypto_clk") => {
535 [crate ::soc::clocks::CryptoClkConfig::Xtal, crate
536 ::soc::clocks::CryptoClkConfig::RcFast, crate
537 ::soc::clocks::CryptoClkConfig::PllF480m]
538 };
539 ("clock_tree.timg_calibration_clock") => {
540 [crate ::soc::clocks::TimgCalibrationClockConfig::OscSlowClk, crate
541 ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
542 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
543 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
544 };
545 ("clock_tree.uart.function_clock.sclk") => {
546 [crate ::soc::clocks::UartFunctionClockSclk::Xtal, crate
547 ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
548 ::soc::clocks::UartFunctionClockSclk::RcFast]
549 };
550 ("clock_tree.uart.function_clock.div_num") => {
551 (0, 255)
552 };
553 ("clock_tree.uart.baud_rate_generator.fractional") => {
554 (0, 15)
555 };
556 ("clock_tree.uart.baud_rate_generator.integral") => {
557 (0, 4095)
558 };
559 ("clock_tree.timg.function_clock") => {
560 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
561 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
562 ::soc::clocks::TimgFunctionClockConfig::PllF80m]
563 };
564 ("clock_tree.timg.wdt_clock") => {
565 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
566 ::soc::clocks::TimgWdtClockConfig::RcFastClk, crate
567 ::soc::clocks::TimgWdtClockConfig::PllF80m]
568 };
569 ("clock_tree.i2c.function_clock.sclk") => {
570 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
571 ::soc::clocks::I2cFunctionClockSclk::RcFast]
572 };
573 ("clock_tree.i2c.function_clock.div_num") => {
574 (0, 255)
575 };
576 ("clock_tree.spi.function_clock") => {
577 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
578 ::soc::clocks::SpiFunctionClockConfig::PllF160m, crate
579 ::soc::clocks::SpiFunctionClockConfig::RcFast]
580 };
581 ("clock_tree.adc.function_clock") => {
582 [crate ::soc::clocks::AdcFunctionClockConfig::Xtal, crate
583 ::soc::clocks::AdcFunctionClockConfig::RcFast, crate
584 ::soc::clocks::AdcFunctionClockConfig::PllF80m]
585 };
586 ("clock_tree.i2s.tx_clk.sclk") => {
587 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
588 ::soc::clocks::I2sClkSclk::PllF120m, crate ::soc::clocks::I2sClkSclk::PllF160m]
589 };
590 ("clock_tree.i2s.tx_clk.div_num") => {
591 (1, 255)
592 };
593 ("clock_tree.i2s.tx_clk.div_a") => {
594 (1, 511)
595 };
596 ("clock_tree.i2s.tx_clk.div_b") => {
597 (0, 511)
598 };
599 ("clock_tree.i2s.rx_clk.sclk") => {
600 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
601 ::soc::clocks::I2sClkSclk::PllF120m, crate ::soc::clocks::I2sClkSclk::PllF160m]
602 };
603 ("clock_tree.i2s.rx_clk.div_num") => {
604 (1, 255)
605 };
606 ("clock_tree.i2s.rx_clk.div_a") => {
607 (1, 511)
608 };
609 ("clock_tree.i2s.rx_clk.div_b") => {
610 (0, 511)
611 };
612 ("clock_tree.i2s.mclk_out") => {
613 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
614 ::soc::clocks::I2sMclkOutConfig::Rx]
615 };
616}
617#[macro_export]
618#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
619macro_rules! for_each_dedicated_gpio {
620 ($($pattern:tt => $code:tt;)*) => {
621 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
622 tt) => {} } _for_each_inner_dedicated_gpio!((0));
623 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
624 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
625 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
626 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
627 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
628 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
629 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
630 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
631 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
632 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
633 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
634 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
635 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
636 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
637 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
638 };
639}
640#[macro_export]
644#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
645macro_rules! define_lp_io_signals {
646 () => {};
647}
648#[macro_export]
649#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
650macro_rules! for_each_ecc_working_mode {
651 ($($pattern:tt => $code:tt;)*) => {
652 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
653 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
654 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
655 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
656 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
657 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
658 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
659 _for_each_inner_ecc_working_mode!((7,
660 AffinePointVerificationAndJacobianPointMultiplication));
661 _for_each_inner_ecc_working_mode!((8, ModularAddition));
662 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
663 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
664 _for_each_inner_ecc_working_mode!((11, ModularDivision));
665 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
666 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
667 JacobianPointMultiplication), (5, AffinePointAddition), (6,
668 JacobianPointVerification), (7,
669 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
670 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
671 };
672}
673#[macro_export]
674#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
675macro_rules! for_each_ecc_curve {
676 ($($pattern:tt => $code:tt;)*) => {
677 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
678 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
679 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
680 P192, 192), (1, P256, 256)));
681 };
682}
683#[macro_export]
684#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
685macro_rules! for_each_sha_algorithm {
686 ($($pattern:tt => $code:tt;)*) => {
687 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
688 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
689 (insecure_against : "collision", "length extension"), 0));
690 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
691 (insecure_against : "length extension"), 1));
692 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
693 (insecure_against : "length extension"), 2));
694 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
695 (insecure_against : "collision", "length extension"), 0), (Sha224,
696 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
697 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
698 2)));
699 };
700}
701#[macro_export]
702#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
703macro_rules! for_each_wakeup_source {
704 ($($pattern:tt => $code:tt;)*) => {
705 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
706 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
707 _for_each_inner_wakeup_source!((Gpio, 2));
708 _for_each_inner_wakeup_source!((WifiBeacon, 3));
709 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
710 5)); _for_each_inner_wakeup_source!((Uart0, 6));
711 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
712 8)); _for_each_inner_wakeup_source!((Uart2, 9));
713 _for_each_inner_wakeup_source!((Bt, 10)); _for_each_inner_wakeup_source!((LpCore,
714 11)); _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3),
715 (Timer, 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Uart2, 9), (Bt, 10),
716 (LpCore, 11)));
717 };
718}
719#[macro_export]
720#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
721macro_rules! for_each_dma_engine {
722 ($($pattern:tt => $code:tt;)*) => {
723 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
724 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
725 _for_each_inner_dma_engine!((all("AHB_GDMA")));
726 };
727}
728#[macro_export]
729#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
730macro_rules! for_each_dma_channel {
731 ($($pattern:tt => $code:tt;)*) => {
732 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
733 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
734 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
735 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
736 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
737 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, I2S0, SHA]));
738 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
739 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, I2S0, SHA]));
740 _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0), ("AHB_GDMA",
741 DMA_CH1))); _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA",
742 any_channel = AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
743 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
744 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, I2S0, SHA]),
745 ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1,
746 compatible = [SPI2, I2S0, SHA])));
747 _for_each_inner_dma_channel!((no_own_interrupt));
748 };
749}
750#[macro_export]
751#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
752macro_rules! for_each_dma_channel_peri_pair {
753 ($($pattern:tt => $code:tt;)*) => {
754 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
755 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
756 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
757 I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
758 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
759 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
760 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
761 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
762 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
763 AhbGdmaChannel, I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
764 any_channel = AhbGdmaChannel, SHA));
765 _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0, SPI2),
766 ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH1,
767 SPI2), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, SHA)));
768 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
769 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0),
770 ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA)));
771 };
772}
773#[macro_export]
774#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
775macro_rules! for_each_mem2mem_channel {
776 ($($pattern:tt => $code:tt;)*) => {
777 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
778 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
779 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
780 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
781 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0, 4, 1,
782 5)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel));
783 _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma, AhbGdmaChannel,
784 DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5)));
785 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
786 4, 1, 5))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
787 AhbGdmaChannel)));
788 };
789}
790#[macro_export]
791#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
792macro_rules! with_i2s_dma_engine {
793 ($($pattern:tt => $code:tt;)*) => {
794 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
795 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
796 };
797}
798#[macro_export]
799#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
800macro_rules! with_sha_dma_engine {
801 ($($pattern:tt => $code:tt;)*) => {
802 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
803 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
804 };
805}
806#[macro_export]
807#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
808macro_rules! with_spi_master_dma_engine {
809 ($($pattern:tt => $code:tt;)*) => {
810 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
811 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
812 };
813}
814#[macro_export]
815#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
816macro_rules! with_spi_slave_dma_engine {
817 ($($pattern:tt => $code:tt;)*) => {
818 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
819 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
820 };
821}
822#[macro_export]
823#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
824macro_rules! for_each_interrupt {
825 ($($pattern:tt => $code:tt;)*) => {
826 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
827 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
828 _for_each_inner_interrupt!(([reserved 0] 1));
829 _for_each_inner_interrupt!(([reserved 1] 2));
830 _for_each_inner_interrupt!(([reserved 2] 3));
831 _for_each_inner_interrupt!(([reserved 3] 4));
832 _for_each_inner_interrupt!(([reserved 4] 5));
833 _for_each_inner_interrupt!(([reserved 5] 6));
834 _for_each_inner_interrupt!(([reserved 6] 7));
835 _for_each_inner_interrupt!(([reserved 7] 8));
836 _for_each_inner_interrupt!(([reserved 8] 9));
837 _for_each_inner_interrupt!(([reserved 9] 10));
838 _for_each_inner_interrupt!(([reserved 10] 11));
839 _for_each_inner_interrupt!(([reserved 11] 12));
840 _for_each_inner_interrupt!(([reserved 12] 13));
841 _for_each_inner_interrupt!(([reserved 13] 14));
842 _for_each_inner_interrupt!(([reserved 14] 15));
843 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
844 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
845 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
846 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
847 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
848 7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
849 _for_each_inner_interrupt!(([direct_bindable 1] 25));
850 _for_each_inner_interrupt!(([direct_bindable 2] 26));
851 _for_each_inner_interrupt!(([direct_bindable 3] 27));
852 _for_each_inner_interrupt!(([direct_bindable 4] 28));
853 _for_each_inner_interrupt!(([direct_bindable 5] 29));
854 _for_each_inner_interrupt!(([direct_bindable 6] 30));
855 _for_each_inner_interrupt!(([direct_bindable 7] 31));
856 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
857 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
858 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
859 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
860 ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
861 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
862 ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
863 ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
864 ([direct_bindable 6] 30), ([direct_bindable 7] 31)));
865 };
866}
867#[macro_export]
868#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
869macro_rules! for_each_classified_interrupt {
870 ($($pattern:tt => $code:tt;)*) => {
871 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
872 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
873 24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
874 _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
875 _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
876 _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
877 _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
878 _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
879 _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
880 _for_each_inner_classified_interrupt!(([vector 0] 16));
881 _for_each_inner_classified_interrupt!(([vector 1] 17));
882 _for_each_inner_classified_interrupt!(([vector 2] 18));
883 _for_each_inner_classified_interrupt!(([vector 3] 19));
884 _for_each_inner_classified_interrupt!(([vector 4] 20));
885 _for_each_inner_classified_interrupt!(([vector 5] 21));
886 _for_each_inner_classified_interrupt!(([vector 6] 22));
887 _for_each_inner_classified_interrupt!(([vector 7] 23));
888 _for_each_inner_classified_interrupt!(([reserved 0] 1));
889 _for_each_inner_classified_interrupt!(([reserved 1] 2));
890 _for_each_inner_classified_interrupt!(([reserved 2] 3));
891 _for_each_inner_classified_interrupt!(([reserved 3] 4));
892 _for_each_inner_classified_interrupt!(([reserved 4] 5));
893 _for_each_inner_classified_interrupt!(([reserved 5] 6));
894 _for_each_inner_classified_interrupt!(([reserved 6] 7));
895 _for_each_inner_classified_interrupt!(([reserved 7] 8));
896 _for_each_inner_classified_interrupt!(([reserved 8] 9));
897 _for_each_inner_classified_interrupt!(([reserved 9] 10));
898 _for_each_inner_classified_interrupt!(([reserved 10] 11));
899 _for_each_inner_classified_interrupt!(([reserved 11] 12));
900 _for_each_inner_classified_interrupt!(([reserved 12] 13));
901 _for_each_inner_classified_interrupt!(([reserved 13] 14));
902 _for_each_inner_classified_interrupt!(([reserved 14] 15));
903 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
904 ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
905 ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
906 ([direct_bindable 7] 31))); _for_each_inner_classified_interrupt!((vector([vector
907 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector 3] 19), ([vector 4] 20),
908 ([vector 5] 21), ([vector 6] 22), ([vector 7] 23)));
909 _for_each_inner_classified_interrupt!((reserved([reserved 0] 1), ([reserved 1]
910 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
911 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
912 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
913 ([reserved 14] 15))); _for_each_inner_classified_interrupt!((context_switch));
914 };
915}
916#[macro_export]
917#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
918macro_rules! for_each_interrupt_priority {
919 ($($pattern:tt => $code:tt;)*) => {
920 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
921 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
922 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
923 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
924 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
925 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
926 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
927 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
928 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
929 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
930 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
931 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
932 Priority8, Level8)));
933 };
934}
935#[macro_export]
936#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
937macro_rules! for_each_sw_interrupt {
938 ($($pattern:tt => $code:tt;)*) => {
939 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
940 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
941 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
942 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
943 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
944 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
945 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
946 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
947 };
948}
949#[macro_export]
950macro_rules! define_clock_tree_types {
1343 () => {
1344 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1345 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1346 pub enum AdcInstance {
1347 ApbSaradc = 0,
1348 }
1349 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1350 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1351 pub enum I2cInstance {
1352 I2c0 = 0,
1353 }
1354 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1355 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1356 pub enum I2sInstance {
1357 I2s0 = 0,
1358 }
1359 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1360 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1361 pub enum SpiInstance {
1362 Spi2 = 0,
1363 }
1364 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1365 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1366 pub enum TimgInstance {
1367 Timg0 = 0,
1368 Timg1 = 1,
1369 }
1370 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1371 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1372 pub enum UartInstance {
1373 Uart0 = 0,
1374 Uart1 = 1,
1375 Uart2 = 2,
1376 }
1377 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1379 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1380 pub enum XtalClkConfig {
1381 _40,
1383 }
1384 impl XtalClkConfig {
1385 pub fn value(&self) -> u32 {
1386 match self {
1387 XtalClkConfig::_40 => 40000000,
1388 }
1389 }
1390 }
1391 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1393 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1394 pub enum HpRootClkConfig {
1395 Xtal,
1397 RcFast,
1399 PllF160m,
1401 }
1402 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1406 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1407 pub struct CpuClkConfig {
1408 divisor: u32,
1409 }
1410 impl CpuClkConfig {
1411 pub const fn new(divisor: u32) -> Self {
1418 ::core::assert!(
1419 divisor <= 255,
1420 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1421 );
1422 Self { divisor }
1423 }
1424 pub fn divisor(self) -> u32 {
1425 self.divisor as u32
1426 }
1427 }
1428 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1432 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1433 pub struct AhbClkConfig {
1434 divisor: u32,
1435 }
1436 impl AhbClkConfig {
1437 pub const fn new(divisor: u32) -> Self {
1444 ::core::assert!(
1445 divisor <= 255,
1446 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1447 );
1448 Self { divisor }
1449 }
1450 pub fn divisor(self) -> u32 {
1451 self.divisor as u32
1452 }
1453 }
1454 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1458 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1459 pub struct ApbClkConfig {
1460 divisor: u32,
1461 }
1462 impl ApbClkConfig {
1463 pub const fn new(divisor: u32) -> Self {
1470 ::core::assert!(
1471 divisor <= 255,
1472 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1473 );
1474 Self { divisor }
1475 }
1476 pub fn divisor(self) -> u32 {
1477 self.divisor as u32
1478 }
1479 }
1480 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1482 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1483 pub enum LpFastClkConfig {
1484 RcFast,
1486 XtalD2,
1488 Xtal,
1490 }
1491 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1493 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1494 pub enum LpSlowClkConfig {
1495 RcSlow,
1497 #[cfg(use_xtal32k)]
1498 Xtal32k,
1500 OscSlow,
1502 }
1503 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1505 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1506 pub enum BleLpClkConfig {
1507 Xtal,
1509 RcSlow,
1511 #[cfg(use_xtal32k)]
1512 Xtal32k,
1514 }
1515 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1517 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1518 pub enum CryptoClkConfig {
1519 Xtal,
1521 RcFast,
1523 PllF480m,
1525 }
1526 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1528 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1529 pub enum TimgCalibrationClockConfig {
1530 OscSlowClk,
1532 RcSlowClk,
1534 RcFastDivClk,
1536 #[cfg(use_xtal32k)]
1537 Xtal32kClk,
1539 }
1540 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1542 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1543 pub enum AdcFunctionClockConfig {
1544 Xtal,
1546 RcFast,
1548 #[default]
1549 PllF80m,
1551 }
1552 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1553 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1554 pub enum I2cFunctionClockSclk {
1555 #[default]
1556 Xtal,
1558 RcFast,
1560 }
1561 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1565 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1566 pub struct I2cFunctionClockConfig {
1567 sclk: I2cFunctionClockSclk,
1568 div_num: u32,
1569 }
1570 impl I2cFunctionClockConfig {
1571 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1578 ::core::assert!(
1579 div_num <= 255,
1580 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1581 );
1582 Self { sclk, div_num }
1583 }
1584 pub fn sclk(self) -> I2cFunctionClockSclk {
1585 self.sclk
1586 }
1587 pub fn div_num(self) -> u32 {
1588 self.div_num as u32
1589 }
1590 }
1591 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1592 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1593 pub enum I2sClkSclk {
1594 Xtal,
1596 PllF120m,
1598 #[default]
1599 PllF160m,
1601 }
1602 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1606 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1607 pub struct I2sClkConfig {
1608 sclk: I2sClkSclk,
1609 div_num: u32,
1610 div_a: u32,
1611 div_b: u32,
1612 }
1613 impl I2sClkConfig {
1614 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
1627 ::core::assert!(
1628 div_num >= 1 && div_num <= 255,
1629 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
1630 );
1631 ::core::assert!(
1632 div_a >= 1 && div_a <= 511,
1633 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
1634 );
1635 ::core::assert!(
1636 div_b <= 511,
1637 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
1638 );
1639 Self {
1640 sclk,
1641 div_num,
1642 div_a,
1643 div_b,
1644 }
1645 }
1646 pub fn sclk(self) -> I2sClkSclk {
1647 self.sclk
1648 }
1649 pub fn div_num(self) -> u32 {
1650 self.div_num as u32
1651 }
1652 pub fn div_a(self) -> u32 {
1653 self.div_a as u32
1654 }
1655 pub fn div_b(self) -> u32 {
1656 self.div_b as u32
1657 }
1658 }
1659 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1661 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1662 pub enum I2sMclkOutConfig {
1663 Tx,
1665 #[default]
1666 Rx,
1668 }
1669 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1671 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1672 pub enum SpiFunctionClockConfig {
1673 Xtal,
1675 #[default]
1676 PllF160m,
1678 RcFast,
1680 }
1681 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1683 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1684 pub enum TimgFunctionClockConfig {
1685 #[default]
1686 XtalClk,
1688 RcFastClk,
1690 PllF80m,
1692 }
1693 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1695 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1696 pub enum TimgWdtClockConfig {
1697 #[default]
1698 XtalClk,
1700 RcFastClk,
1702 PllF80m,
1704 }
1705 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1706 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1707 pub enum UartFunctionClockSclk {
1708 #[default]
1709 Xtal,
1711 PllF80m,
1713 RcFast,
1715 }
1716 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1720 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1721 pub struct UartFunctionClockConfig {
1722 sclk: UartFunctionClockSclk,
1723 div_num: u32,
1724 }
1725 impl UartFunctionClockConfig {
1726 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1733 ::core::assert!(
1734 div_num <= 255,
1735 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1736 );
1737 Self { sclk, div_num }
1738 }
1739 pub fn sclk(self) -> UartFunctionClockSclk {
1740 self.sclk
1741 }
1742 pub fn div_num(self) -> u32 {
1743 self.div_num as u32
1744 }
1745 }
1746 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1751 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1752 pub struct UartBaudRateGeneratorConfig {
1753 fractional: u32,
1754 integral: u32,
1755 }
1756 impl UartBaudRateGeneratorConfig {
1757 pub const fn new(fractional: u32, integral: u32) -> Self {
1767 ::core::assert!(
1768 fractional <= 15,
1769 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1770 );
1771 ::core::assert!(
1772 integral <= 4095,
1773 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1774 );
1775 Self {
1776 fractional,
1777 integral,
1778 }
1779 }
1780 pub fn fractional(self) -> u32 {
1781 self.fractional as u32
1782 }
1783 pub fn integral(self) -> u32 {
1784 self.integral as u32
1785 }
1786 }
1787 pub struct ClockTree {
1789 xtal_clk: Option<XtalClkConfig>,
1790 hp_root_clk: Option<HpRootClkConfig>,
1791 cpu_clk: Option<CpuClkConfig>,
1792 ahb_clk: Option<AhbClkConfig>,
1793 apb_clk: Option<ApbClkConfig>,
1794 lp_fast_clk: Option<LpFastClkConfig>,
1795 lp_slow_clk: Option<LpSlowClkConfig>,
1796 ble_lp_clk: Option<BleLpClkConfig>,
1797 crypto_clk: Option<CryptoClkConfig>,
1798 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1799 adc_function_clock: [Option<AdcFunctionClockConfig>; 1],
1800 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
1801 i2s_tx_clk: [Option<I2sClkConfig>; 1],
1802 i2s_rx_clk: [Option<I2sClkConfig>; 1],
1803 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
1804 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
1805 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1806 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1807 uart_function_clock: [Option<UartFunctionClockConfig>; 3],
1808 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 3],
1809 rc_fast_clk_refcount: u32,
1810 pll_clk_refcount: u32,
1811 #[cfg(use_xtal32k)]
1812 xtal32k_clk_refcount: u32,
1813 osc_slow_clk_refcount: u32,
1814 rc_slow_clk_refcount: u32,
1815 pll_f20m_refcount: u32,
1816 pll_f40m_refcount: u32,
1817 pll_f48m_refcount: u32,
1818 pll_f60m_refcount: u32,
1819 pll_f80m_refcount: u32,
1820 pll_f120m_refcount: u32,
1821 pll_f160m_refcount: u32,
1822 hp_root_clk_refcount: u32,
1823 cpu_clk_refcount: u32,
1824 apb_clk_refcount: u32,
1825 lp_fast_clk_refcount: u32,
1826 lp_slow_clk_refcount: u32,
1827 ble_lp_clk_refcount: u32,
1828 crypto_clk_refcount: u32,
1829 timg_calibration_clock_refcount: u32,
1830 adc_function_clock_refcount: [u32; 1],
1831 i2c_function_clock_refcount: [u32; 1],
1832 i2s_tx_clk_refcount: [u32; 1],
1833 i2s_rx_clk_refcount: [u32; 1],
1834 i2s_mclk_out_refcount: [u32; 1],
1835 spi_function_clock_refcount: [u32; 1],
1836 timg_function_clock_refcount: [u32; 2],
1837 timg_wdt_clock_refcount: [u32; 2],
1838 uart_function_clock_refcount: [u32; 3],
1839 uart_baud_rate_generator_refcount: [u32; 3],
1840 }
1841 impl ClockTree {
1842 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1844 CLOCK_TREE.with(f)
1845 }
1846 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1848 self.xtal_clk
1849 }
1850 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
1852 self.hp_root_clk
1853 }
1854 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1856 self.cpu_clk
1857 }
1858 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
1860 self.ahb_clk
1861 }
1862 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1864 self.apb_clk
1865 }
1866 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
1868 self.lp_fast_clk
1869 }
1870 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
1872 self.lp_slow_clk
1873 }
1874 pub fn ble_lp_clk(&self) -> Option<BleLpClkConfig> {
1876 self.ble_lp_clk
1877 }
1878 pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
1880 self.crypto_clk
1881 }
1882 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1884 self.timg_calibration_clock
1885 }
1886 pub fn apb_saradc_function_clock(&self) -> Option<AdcFunctionClockConfig> {
1888 self.adc_function_clock[AdcInstance::ApbSaradc as usize]
1889 }
1890 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1892 self.i2c_function_clock[I2cInstance::I2c0 as usize]
1893 }
1894 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
1896 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
1897 }
1898 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
1900 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
1901 }
1902 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
1904 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
1905 }
1906 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
1908 self.spi_function_clock[SpiInstance::Spi2 as usize]
1909 }
1910 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1912 self.timg_function_clock[TimgInstance::Timg0 as usize]
1913 }
1914 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1916 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
1917 }
1918 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1920 self.timg_function_clock[TimgInstance::Timg1 as usize]
1921 }
1922 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1924 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
1925 }
1926 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1928 self.uart_function_clock[UartInstance::Uart0 as usize]
1929 }
1930 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1932 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1933 }
1934 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1936 self.uart_function_clock[UartInstance::Uart1 as usize]
1937 }
1938 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1940 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
1941 }
1942 pub fn uart2_function_clock(&self) -> Option<UartFunctionClockConfig> {
1944 self.uart_function_clock[UartInstance::Uart2 as usize]
1945 }
1946 pub fn uart2_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1948 self.uart_baud_rate_generator[UartInstance::Uart2 as usize]
1949 }
1950 }
1951 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
1952 ::esp_sync::NonReentrantMutex::new(ClockTree {
1953 xtal_clk: None,
1954 hp_root_clk: None,
1955 cpu_clk: None,
1956 ahb_clk: None,
1957 apb_clk: None,
1958 lp_fast_clk: None,
1959 lp_slow_clk: None,
1960 ble_lp_clk: None,
1961 crypto_clk: None,
1962 timg_calibration_clock: None,
1963 adc_function_clock: [None; 1],
1964 i2c_function_clock: [None; 1],
1965 i2s_tx_clk: [None; 1],
1966 i2s_rx_clk: [None; 1],
1967 i2s_mclk_out: [None; 1],
1968 spi_function_clock: [None; 1],
1969 timg_function_clock: [None; 2],
1970 timg_wdt_clock: [None; 2],
1971 uart_function_clock: [None; 3],
1972 uart_baud_rate_generator: [None; 3],
1973 rc_fast_clk_refcount: 0,
1974 pll_clk_refcount: 0,
1975 #[cfg(use_xtal32k)]
1976 xtal32k_clk_refcount: 0,
1977 osc_slow_clk_refcount: 0,
1978 rc_slow_clk_refcount: 0,
1979 pll_f20m_refcount: 0,
1980 pll_f40m_refcount: 0,
1981 pll_f48m_refcount: 0,
1982 pll_f60m_refcount: 0,
1983 pll_f80m_refcount: 0,
1984 pll_f120m_refcount: 0,
1985 pll_f160m_refcount: 0,
1986 hp_root_clk_refcount: 0,
1987 cpu_clk_refcount: 0,
1988 apb_clk_refcount: 0,
1989 lp_fast_clk_refcount: 0,
1990 lp_slow_clk_refcount: 0,
1991 ble_lp_clk_refcount: 0,
1992 crypto_clk_refcount: 0,
1993 timg_calibration_clock_refcount: 0,
1994 adc_function_clock_refcount: [0; 1],
1995 i2c_function_clock_refcount: [0; 1],
1996 i2s_tx_clk_refcount: [0; 1],
1997 i2s_rx_clk_refcount: [0; 1],
1998 i2s_mclk_out_refcount: [0; 1],
1999 spi_function_clock_refcount: [0; 1],
2000 timg_function_clock_refcount: [0; 2],
2001 timg_wdt_clock_refcount: [0; 2],
2002 uart_function_clock_refcount: [0; 3],
2003 uart_baud_rate_generator_refcount: [0; 3],
2004 });
2005 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2006 ::core::sync::atomic::AtomicU32::new(0);
2007 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2008 ::core::sync::atomic::AtomicU32::new(0);
2009 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2010 ::core::sync::atomic::AtomicU32::new(0);
2011 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2012 ::core::sync::atomic::AtomicU32::new(0);
2013 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2014 ::core::sync::atomic::AtomicU32::new(0);
2015 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2016 ::core::sync::atomic::AtomicU32::new(0);
2017 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2018 ::core::sync::atomic::AtomicU32::new(0);
2019 static BLE_LP_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2020 ::core::sync::atomic::AtomicU32::new(0);
2021 static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2022 ::core::sync::atomic::AtomicU32::new(0);
2023 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2024 ::core::sync::atomic::AtomicU32::new(0);
2025 static ADC_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2026 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2027 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2028 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2029 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2030 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2031 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2032 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2033 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2034 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2035 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2036 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2037 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2038 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2039 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2040 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2041 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
2042 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
2043 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
2044 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
2045 #[derive(Debug, enumset::EnumSetType)]
2050 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2051 pub enum ClockSource {
2052 XtalClk,
2054 RcFastClk,
2056 #[cfg(use_xtal32k)]
2057 Xtal32kClk,
2059 OscSlowClk,
2061 RcSlowClk,
2063 }
2064 pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2066 Some(ClockSource::XtalClk)
2067 }
2068 pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2070 Some(ClockSource::RcFastClk)
2071 }
2072 pub fn pll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2074 xtal_clk_root_source(clocks)
2075 }
2076 #[cfg(use_xtal32k)]
2077 pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2079 Some(ClockSource::Xtal32kClk)
2080 }
2081 pub fn osc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2083 Some(ClockSource::OscSlowClk)
2084 }
2085 pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2087 Some(ClockSource::RcSlowClk)
2088 }
2089 pub fn pll_f20m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2091 pll_clk_root_source(clocks)
2092 }
2093 pub fn pll_f40m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2095 pll_clk_root_source(clocks)
2096 }
2097 pub fn pll_f48m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2099 pll_clk_root_source(clocks)
2100 }
2101 pub fn pll_f60m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2103 pll_clk_root_source(clocks)
2104 }
2105 pub fn pll_f80m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2107 pll_clk_root_source(clocks)
2108 }
2109 pub fn pll_f120m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2111 pll_clk_root_source(clocks)
2112 }
2113 pub fn pll_f160m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2115 pll_clk_root_source(clocks)
2116 }
2117 pub fn hp_root_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2119 let config = clocks.hp_root_clk?;
2120 match config {
2121 HpRootClkConfig::Xtal => xtal_clk_root_source(clocks),
2122 HpRootClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2123 HpRootClkConfig::PllF160m => pll_f160m_root_source(clocks),
2124 }
2125 }
2126 pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2128 hp_root_clk_root_source(clocks)
2129 }
2130 pub fn ahb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2132 hp_root_clk_root_source(clocks)
2133 }
2134 pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2136 ahb_clk_root_source(clocks)
2137 }
2138 pub fn xtal_d2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2140 xtal_clk_root_source(clocks)
2141 }
2142 pub fn lp_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2144 let config = clocks.lp_fast_clk?;
2145 match config {
2146 LpFastClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2147 LpFastClkConfig::XtalD2 => xtal_d2_clk_root_source(clocks),
2148 LpFastClkConfig::Xtal => xtal_clk_root_source(clocks),
2149 }
2150 }
2151 pub fn lp_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2153 let config = clocks.lp_slow_clk?;
2154 match config {
2155 LpSlowClkConfig::RcSlow => rc_slow_clk_root_source(clocks),
2156 #[cfg(use_xtal32k)]
2157 LpSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2158 LpSlowClkConfig::OscSlow => osc_slow_clk_root_source(clocks),
2159 }
2160 }
2161 pub fn ble_lp_xtal_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2163 xtal_clk_root_source(clocks)
2164 }
2165 pub fn ble_lp_rc_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2167 rc_slow_clk_root_source(clocks)
2168 }
2169 pub fn ble_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2171 let config = clocks.ble_lp_clk?;
2172 match config {
2173 BleLpClkConfig::Xtal => ble_lp_xtal_clk_root_source(clocks),
2174 BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_root_source(clocks),
2175 #[cfg(use_xtal32k)]
2176 BleLpClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2177 }
2178 }
2179 pub fn crypto_pll_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2181 pll_clk_root_source(clocks)
2182 }
2183 pub fn crypto_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2185 let config = clocks.crypto_clk?;
2186 match config {
2187 CryptoClkConfig::Xtal => xtal_clk_root_source(clocks),
2188 CryptoClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2189 CryptoClkConfig::PllF480m => crypto_pll_div_root_source(clocks),
2190 }
2191 }
2192 pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2194 let config = clocks.timg_calibration_clock?;
2195 match config {
2196 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_root_source(clocks),
2197 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_root_source(clocks),
2198 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_root_source(clocks),
2199 #[cfg(use_xtal32k)]
2200 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
2201 }
2202 }
2203 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2204 let old_config = clocks.xtal_clk.replace(config);
2205 refresh_xtal_clk_downstream(clocks);
2206 configure_xtal_clk_impl(clocks, old_config, config);
2207 }
2208 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2209 clocks.xtal_clk
2210 }
2211 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2212 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2213 pub fn xtal_clk_config_frequency(config: XtalClkConfig) -> u32 {
2214 config.value()
2215 }
2216 pub fn xtal_clk_frequency() -> u32 {
2217 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2218 }
2219 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2220 trace!("Requesting RC_FAST_CLK");
2221 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2222 trace!("Enabling RC_FAST_CLK");
2223 enable_rc_fast_clk_impl(clocks, true);
2224 }
2225 }
2226 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2227 trace!("Releasing RC_FAST_CLK");
2228 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2229 trace!("Disabling RC_FAST_CLK");
2230 enable_rc_fast_clk_impl(clocks, false);
2231 }
2232 }
2233 static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2234 ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
2235 pub const fn rc_fast_clk_nominal_frequency() -> u32 {
2236 17500000
2237 }
2238 pub fn rc_fast_clk_frequency() -> u32 {
2239 RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2240 }
2241 pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2242 if !(8750000..=26250000).contains(&frequency) {
2243 warn!(
2244 "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
2245 frequency
2246 );
2247 return;
2248 }
2249 debug!(
2250 "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
2251 frequency,
2252 rc_fast_clk_nominal_frequency()
2253 );
2254 RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2255 refresh_rc_fast_clk_downstream(clocks);
2256 }
2257 pub fn request_pll_clk(clocks: &mut ClockTree) {
2258 trace!("Requesting PLL_CLK");
2259 if increment_reference_count(&mut clocks.pll_clk_refcount) {
2260 trace!("Enabling PLL_CLK");
2261 request_xtal_clk(clocks);
2262 enable_pll_clk_impl(clocks, true);
2263 }
2264 }
2265 pub fn release_pll_clk(clocks: &mut ClockTree) {
2266 trace!("Releasing PLL_CLK");
2267 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2268 trace!("Disabling PLL_CLK");
2269 enable_pll_clk_impl(clocks, false);
2270 release_xtal_clk(clocks);
2271 }
2272 }
2273 pub fn pll_clk_frequency() -> u32 {
2274 480000000
2275 }
2276 pub fn pll_clk_source_frequency() -> u32 {
2277 xtal_clk_frequency()
2278 }
2279 #[cfg(use_xtal32k)]
2280 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2281 trace!("Requesting XTAL32K_CLK");
2282 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2283 trace!("Enabling XTAL32K_CLK");
2284 enable_xtal32k_clk_impl(clocks, true);
2285 }
2286 }
2287 #[cfg(use_xtal32k)]
2288 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2289 trace!("Releasing XTAL32K_CLK");
2290 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2291 trace!("Disabling XTAL32K_CLK");
2292 enable_xtal32k_clk_impl(clocks, false);
2293 }
2294 }
2295 #[cfg(use_xtal32k)]
2296 pub fn xtal32k_clk_frequency() -> u32 {
2297 32768
2298 }
2299 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2300 trace!("Requesting OSC_SLOW_CLK");
2301 if increment_reference_count(&mut clocks.osc_slow_clk_refcount) {
2302 trace!("Enabling OSC_SLOW_CLK");
2303 enable_osc_slow_clk_impl(clocks, true);
2304 }
2305 }
2306 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2307 trace!("Releasing OSC_SLOW_CLK");
2308 if decrement_reference_count(&mut clocks.osc_slow_clk_refcount) {
2309 trace!("Disabling OSC_SLOW_CLK");
2310 enable_osc_slow_clk_impl(clocks, false);
2311 }
2312 }
2313 pub fn osc_slow_clk_frequency() -> u32 {
2314 32768
2315 }
2316 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2317 trace!("Requesting RC_SLOW_CLK");
2318 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
2319 trace!("Enabling RC_SLOW_CLK");
2320 enable_rc_slow_clk_impl(clocks, true);
2321 }
2322 }
2323 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2324 trace!("Releasing RC_SLOW_CLK");
2325 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
2326 trace!("Disabling RC_SLOW_CLK");
2327 enable_rc_slow_clk_impl(clocks, false);
2328 }
2329 }
2330 static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2331 ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
2332 pub const fn rc_slow_clk_nominal_frequency() -> u32 {
2333 136000
2334 }
2335 pub fn rc_slow_clk_frequency() -> u32 {
2336 RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2337 }
2338 pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2339 if !(68000..=204000).contains(&frequency) {
2340 warn!(
2341 "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
2342 frequency
2343 );
2344 return;
2345 }
2346 debug!(
2347 "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
2348 frequency,
2349 rc_slow_clk_nominal_frequency()
2350 );
2351 RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2352 refresh_rc_slow_clk_downstream(clocks);
2353 }
2354 pub fn request_pll_f20m(clocks: &mut ClockTree) {
2355 trace!("Requesting PLL_F20M");
2356 if increment_reference_count(&mut clocks.pll_f20m_refcount) {
2357 trace!("Enabling PLL_F20M");
2358 request_pll_clk(clocks);
2359 enable_pll_f20m_impl(clocks, true);
2360 }
2361 }
2362 pub fn release_pll_f20m(clocks: &mut ClockTree) {
2363 trace!("Releasing PLL_F20M");
2364 if decrement_reference_count(&mut clocks.pll_f20m_refcount) {
2365 trace!("Disabling PLL_F20M");
2366 enable_pll_f20m_impl(clocks, false);
2367 release_pll_clk(clocks);
2368 }
2369 }
2370 pub fn pll_f20m_frequency() -> u32 {
2371 (pll_clk_frequency() / 24)
2372 }
2373 pub fn pll_f20m_source_frequency() -> u32 {
2374 pll_clk_frequency()
2375 }
2376 pub fn request_pll_f40m(clocks: &mut ClockTree) {
2377 trace!("Requesting PLL_F40M");
2378 if increment_reference_count(&mut clocks.pll_f40m_refcount) {
2379 trace!("Enabling PLL_F40M");
2380 request_pll_clk(clocks);
2381 enable_pll_f40m_impl(clocks, true);
2382 }
2383 }
2384 pub fn release_pll_f40m(clocks: &mut ClockTree) {
2385 trace!("Releasing PLL_F40M");
2386 if decrement_reference_count(&mut clocks.pll_f40m_refcount) {
2387 trace!("Disabling PLL_F40M");
2388 enable_pll_f40m_impl(clocks, false);
2389 release_pll_clk(clocks);
2390 }
2391 }
2392 pub fn pll_f40m_frequency() -> u32 {
2393 (pll_clk_frequency() / 12)
2394 }
2395 pub fn pll_f40m_source_frequency() -> u32 {
2396 pll_clk_frequency()
2397 }
2398 pub fn request_pll_f48m(clocks: &mut ClockTree) {
2399 trace!("Requesting PLL_F48M");
2400 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
2401 trace!("Enabling PLL_F48M");
2402 request_pll_clk(clocks);
2403 enable_pll_f48m_impl(clocks, true);
2404 }
2405 }
2406 pub fn release_pll_f48m(clocks: &mut ClockTree) {
2407 trace!("Releasing PLL_F48M");
2408 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
2409 trace!("Disabling PLL_F48M");
2410 enable_pll_f48m_impl(clocks, false);
2411 release_pll_clk(clocks);
2412 }
2413 }
2414 pub fn pll_f48m_frequency() -> u32 {
2415 (pll_clk_frequency() / 10)
2416 }
2417 pub fn pll_f48m_source_frequency() -> u32 {
2418 pll_clk_frequency()
2419 }
2420 pub fn request_pll_f60m(clocks: &mut ClockTree) {
2421 trace!("Requesting PLL_F60M");
2422 if increment_reference_count(&mut clocks.pll_f60m_refcount) {
2423 trace!("Enabling PLL_F60M");
2424 request_pll_clk(clocks);
2425 enable_pll_f60m_impl(clocks, true);
2426 }
2427 }
2428 pub fn release_pll_f60m(clocks: &mut ClockTree) {
2429 trace!("Releasing PLL_F60M");
2430 if decrement_reference_count(&mut clocks.pll_f60m_refcount) {
2431 trace!("Disabling PLL_F60M");
2432 enable_pll_f60m_impl(clocks, false);
2433 release_pll_clk(clocks);
2434 }
2435 }
2436 pub fn pll_f60m_frequency() -> u32 {
2437 (pll_clk_frequency() / 8)
2438 }
2439 pub fn pll_f60m_source_frequency() -> u32 {
2440 pll_clk_frequency()
2441 }
2442 pub fn request_pll_f80m(clocks: &mut ClockTree) {
2443 trace!("Requesting PLL_F80M");
2444 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
2445 trace!("Enabling PLL_F80M");
2446 request_pll_clk(clocks);
2447 enable_pll_f80m_impl(clocks, true);
2448 }
2449 }
2450 pub fn release_pll_f80m(clocks: &mut ClockTree) {
2451 trace!("Releasing PLL_F80M");
2452 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
2453 trace!("Disabling PLL_F80M");
2454 enable_pll_f80m_impl(clocks, false);
2455 release_pll_clk(clocks);
2456 }
2457 }
2458 pub fn pll_f80m_frequency() -> u32 {
2459 (pll_clk_frequency() / 6)
2460 }
2461 pub fn pll_f80m_source_frequency() -> u32 {
2462 pll_clk_frequency()
2463 }
2464 pub fn request_pll_f120m(clocks: &mut ClockTree) {
2465 trace!("Requesting PLL_F120M");
2466 if increment_reference_count(&mut clocks.pll_f120m_refcount) {
2467 trace!("Enabling PLL_F120M");
2468 request_pll_clk(clocks);
2469 enable_pll_f120m_impl(clocks, true);
2470 }
2471 }
2472 pub fn release_pll_f120m(clocks: &mut ClockTree) {
2473 trace!("Releasing PLL_F120M");
2474 if decrement_reference_count(&mut clocks.pll_f120m_refcount) {
2475 trace!("Disabling PLL_F120M");
2476 enable_pll_f120m_impl(clocks, false);
2477 release_pll_clk(clocks);
2478 }
2479 }
2480 pub fn pll_f120m_frequency() -> u32 {
2481 (pll_clk_frequency() / 4)
2482 }
2483 pub fn pll_f120m_source_frequency() -> u32 {
2484 pll_clk_frequency()
2485 }
2486 pub fn request_pll_f160m(clocks: &mut ClockTree) {
2487 trace!("Requesting PLL_F160M");
2488 if increment_reference_count(&mut clocks.pll_f160m_refcount) {
2489 trace!("Enabling PLL_F160M");
2490 request_pll_clk(clocks);
2491 enable_pll_f160m_impl(clocks, true);
2492 }
2493 }
2494 pub fn release_pll_f160m(clocks: &mut ClockTree) {
2495 trace!("Releasing PLL_F160M");
2496 if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
2497 trace!("Disabling PLL_F160M");
2498 enable_pll_f160m_impl(clocks, false);
2499 release_pll_clk(clocks);
2500 }
2501 }
2502 pub fn pll_f160m_frequency() -> u32 {
2503 (pll_clk_frequency() / 3)
2504 }
2505 pub fn pll_f160m_source_frequency() -> u32 {
2506 pll_clk_frequency()
2507 }
2508 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
2509 let old_selector = clocks.hp_root_clk.replace(new_selector);
2510 refresh_hp_root_clk_downstream(clocks);
2511 let active = clocks.hp_root_clk_refcount > 0;
2512 if active {
2513 match new_selector {
2514 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2515 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2516 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
2517 }
2518 }
2519 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2520 if active && let Some(old_selector) = old_selector {
2521 match old_selector {
2522 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2523 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2524 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
2525 }
2526 }
2527 }
2528 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
2529 clocks.hp_root_clk
2530 }
2531 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
2532 trace!("Requesting HP_ROOT_CLK");
2533 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
2534 trace!("Enabling HP_ROOT_CLK");
2535 match unwrap!(clocks.hp_root_clk) {
2536 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2537 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2538 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
2539 }
2540 enable_hp_root_clk_impl(clocks, true);
2541 }
2542 }
2543 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
2544 trace!("Releasing HP_ROOT_CLK");
2545 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
2546 trace!("Disabling HP_ROOT_CLK");
2547 enable_hp_root_clk_impl(clocks, false);
2548 match unwrap!(clocks.hp_root_clk) {
2549 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2550 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2551 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
2552 }
2553 }
2554 }
2555 pub fn hp_root_clk_config_frequency(config: HpRootClkConfig) -> u32 {
2556 match config {
2557 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2558 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2559 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
2560 }
2561 }
2562 pub fn hp_root_clk_frequency() -> u32 {
2563 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2564 }
2565 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
2566 hp_root_clk_config_frequency(source)
2567 }
2568 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
2569 let old_config = clocks.cpu_clk.replace(config);
2570 refresh_cpu_clk_downstream(clocks);
2571 configure_cpu_clk_impl(clocks, old_config, config);
2572 }
2573 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2574 clocks.cpu_clk
2575 }
2576 pub fn request_cpu_clk(clocks: &mut ClockTree) {
2577 trace!("Requesting CPU_CLK");
2578 if increment_reference_count(&mut clocks.cpu_clk_refcount) {
2579 trace!("Enabling CPU_CLK");
2580 request_hp_root_clk(clocks);
2581 enable_cpu_clk_impl(clocks, true);
2582 }
2583 }
2584 pub fn release_cpu_clk(clocks: &mut ClockTree) {
2585 trace!("Releasing CPU_CLK");
2586 if decrement_reference_count(&mut clocks.cpu_clk_refcount) {
2587 trace!("Disabling CPU_CLK");
2588 enable_cpu_clk_impl(clocks, false);
2589 release_hp_root_clk(clocks);
2590 }
2591 }
2592 pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
2593 (hp_root_clk_frequency() / (config.divisor() + 1))
2594 }
2595 pub fn cpu_clk_frequency() -> u32 {
2596 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2597 }
2598 pub fn cpu_clk_source_frequency() -> u32 {
2599 hp_root_clk_frequency()
2600 }
2601 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
2602 let old_config = clocks.ahb_clk.replace(config);
2603 refresh_ahb_clk_downstream(clocks);
2604 configure_ahb_clk_impl(clocks, old_config, config);
2605 }
2606 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
2607 clocks.ahb_clk
2608 }
2609 pub fn request_ahb_clk(clocks: &mut ClockTree) {
2610 trace!("Enabling AHB_CLK");
2611 request_hp_root_clk(clocks);
2612 enable_ahb_clk_impl(clocks, true);
2613 }
2614 pub fn release_ahb_clk(clocks: &mut ClockTree) {
2615 trace!("Disabling AHB_CLK");
2616 enable_ahb_clk_impl(clocks, false);
2617 release_hp_root_clk(clocks);
2618 }
2619 pub fn ahb_clk_config_frequency(config: AhbClkConfig) -> u32 {
2620 (hp_root_clk_frequency() / (config.divisor() + 1))
2621 }
2622 pub fn ahb_clk_frequency() -> u32 {
2623 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2624 }
2625 pub fn ahb_clk_source_frequency() -> u32 {
2626 hp_root_clk_frequency()
2627 }
2628 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
2629 let old_config = clocks.apb_clk.replace(config);
2630 refresh_apb_clk_downstream(clocks);
2631 configure_apb_clk_impl(clocks, old_config, config);
2632 }
2633 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2634 clocks.apb_clk
2635 }
2636 pub fn request_apb_clk(clocks: &mut ClockTree) {
2637 trace!("Requesting APB_CLK");
2638 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2639 trace!("Enabling APB_CLK");
2640 request_ahb_clk(clocks);
2641 enable_apb_clk_impl(clocks, true);
2642 }
2643 }
2644 pub fn release_apb_clk(clocks: &mut ClockTree) {
2645 trace!("Releasing APB_CLK");
2646 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2647 trace!("Disabling APB_CLK");
2648 enable_apb_clk_impl(clocks, false);
2649 release_ahb_clk(clocks);
2650 }
2651 }
2652 pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
2653 (ahb_clk_frequency() / (config.divisor() + 1))
2654 }
2655 pub fn apb_clk_frequency() -> u32 {
2656 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2657 }
2658 pub fn apb_clk_source_frequency() -> u32 {
2659 ahb_clk_frequency()
2660 }
2661 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
2662 trace!("Enabling XTAL_D2_CLK");
2663 request_xtal_clk(clocks);
2664 enable_xtal_d2_clk_impl(clocks, true);
2665 }
2666 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
2667 trace!("Disabling XTAL_D2_CLK");
2668 enable_xtal_d2_clk_impl(clocks, false);
2669 release_xtal_clk(clocks);
2670 }
2671 pub fn xtal_d2_clk_frequency() -> u32 {
2672 (xtal_clk_frequency() / 2)
2673 }
2674 pub fn xtal_d2_clk_source_frequency() -> u32 {
2675 xtal_clk_frequency()
2676 }
2677 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
2678 let old_selector = clocks.lp_fast_clk.replace(new_selector);
2679 refresh_lp_fast_clk_downstream(clocks);
2680 let active = clocks.lp_fast_clk_refcount > 0;
2681 if active {
2682 match new_selector {
2683 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2684 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2685 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2686 }
2687 }
2688 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2689 if active && let Some(old_selector) = old_selector {
2690 match old_selector {
2691 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2692 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2693 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2694 }
2695 }
2696 }
2697 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
2698 clocks.lp_fast_clk
2699 }
2700 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
2701 trace!("Requesting LP_FAST_CLK");
2702 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
2703 trace!("Enabling LP_FAST_CLK");
2704 match unwrap!(clocks.lp_fast_clk) {
2705 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2706 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2707 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2708 }
2709 enable_lp_fast_clk_impl(clocks, true);
2710 }
2711 }
2712 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
2713 trace!("Releasing LP_FAST_CLK");
2714 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
2715 trace!("Disabling LP_FAST_CLK");
2716 enable_lp_fast_clk_impl(clocks, false);
2717 match unwrap!(clocks.lp_fast_clk) {
2718 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2719 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2720 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2721 }
2722 }
2723 }
2724 pub fn lp_fast_clk_config_frequency(config: LpFastClkConfig) -> u32 {
2725 match config {
2726 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2727 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2728 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2729 }
2730 }
2731 pub fn lp_fast_clk_frequency() -> u32 {
2732 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2733 }
2734 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
2735 lp_fast_clk_config_frequency(source)
2736 }
2737 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
2738 let old_selector = clocks.lp_slow_clk.replace(new_selector);
2739 refresh_lp_slow_clk_downstream(clocks);
2740 let active = clocks.lp_slow_clk_refcount > 0;
2741 if active {
2742 match new_selector {
2743 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2744 #[cfg(use_xtal32k)]
2745 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2746 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2747 }
2748 }
2749 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2750 if active && let Some(old_selector) = old_selector {
2751 match old_selector {
2752 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2753 #[cfg(use_xtal32k)]
2754 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2755 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2756 }
2757 }
2758 }
2759 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
2760 clocks.lp_slow_clk
2761 }
2762 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
2763 trace!("Requesting LP_SLOW_CLK");
2764 if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
2765 trace!("Enabling LP_SLOW_CLK");
2766 match unwrap!(clocks.lp_slow_clk) {
2767 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2768 #[cfg(use_xtal32k)]
2769 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2770 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2771 }
2772 enable_lp_slow_clk_impl(clocks, true);
2773 }
2774 }
2775 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2776 trace!("Releasing LP_SLOW_CLK");
2777 if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
2778 trace!("Disabling LP_SLOW_CLK");
2779 enable_lp_slow_clk_impl(clocks, false);
2780 match unwrap!(clocks.lp_slow_clk) {
2781 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2782 #[cfg(use_xtal32k)]
2783 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2784 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2785 }
2786 }
2787 }
2788 pub fn lp_slow_clk_config_frequency(config: LpSlowClkConfig) -> u32 {
2789 match config {
2790 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2791 #[cfg(use_xtal32k)]
2792 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2793 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2794 }
2795 }
2796 pub fn lp_slow_clk_frequency() -> u32 {
2797 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2798 }
2799 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
2800 lp_slow_clk_config_frequency(source)
2801 }
2802 pub fn request_ble_lp_xtal_clk(clocks: &mut ClockTree) {
2803 trace!("Enabling BLE_LP_XTAL_CLK");
2804 request_xtal_clk(clocks);
2805 enable_ble_lp_xtal_clk_impl(clocks, true);
2806 }
2807 pub fn release_ble_lp_xtal_clk(clocks: &mut ClockTree) {
2808 trace!("Disabling BLE_LP_XTAL_CLK");
2809 enable_ble_lp_xtal_clk_impl(clocks, false);
2810 release_xtal_clk(clocks);
2811 }
2812 pub fn ble_lp_xtal_clk_frequency() -> u32 {
2813 100000
2814 }
2815 pub fn ble_lp_xtal_clk_source_frequency() -> u32 {
2816 xtal_clk_frequency()
2817 }
2818 pub fn request_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
2819 trace!("Enabling BLE_LP_RC_SLOW_CLK");
2820 request_rc_slow_clk(clocks);
2821 enable_ble_lp_rc_slow_clk_impl(clocks, true);
2822 }
2823 pub fn release_ble_lp_rc_slow_clk(clocks: &mut ClockTree) {
2824 trace!("Disabling BLE_LP_RC_SLOW_CLK");
2825 enable_ble_lp_rc_slow_clk_impl(clocks, false);
2826 release_rc_slow_clk(clocks);
2827 }
2828 pub fn ble_lp_rc_slow_clk_frequency() -> u32 {
2829 (rc_slow_clk_frequency() / 5)
2830 }
2831 pub fn ble_lp_rc_slow_clk_source_frequency() -> u32 {
2832 rc_slow_clk_frequency()
2833 }
2834 pub fn configure_ble_lp_clk(clocks: &mut ClockTree, new_selector: BleLpClkConfig) {
2835 let old_selector = clocks.ble_lp_clk.replace(new_selector);
2836 refresh_ble_lp_clk_downstream(clocks);
2837 let active = clocks.ble_lp_clk_refcount > 0;
2838 if active {
2839 match new_selector {
2840 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
2841 BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
2842 #[cfg(use_xtal32k)]
2843 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2844 }
2845 }
2846 configure_ble_lp_clk_impl(clocks, old_selector, new_selector);
2847 if active && let Some(old_selector) = old_selector {
2848 match old_selector {
2849 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
2850 BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
2851 #[cfg(use_xtal32k)]
2852 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2853 }
2854 }
2855 }
2856 pub fn ble_lp_clk_config(clocks: &mut ClockTree) -> Option<BleLpClkConfig> {
2857 clocks.ble_lp_clk
2858 }
2859 pub fn request_ble_lp_clk(clocks: &mut ClockTree) {
2860 trace!("Requesting BLE_LP_CLK");
2861 if increment_reference_count(&mut clocks.ble_lp_clk_refcount) {
2862 trace!("Enabling BLE_LP_CLK");
2863 match unwrap!(clocks.ble_lp_clk) {
2864 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
2865 BleLpClkConfig::RcSlow => request_ble_lp_rc_slow_clk(clocks),
2866 #[cfg(use_xtal32k)]
2867 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2868 }
2869 enable_ble_lp_clk_impl(clocks, true);
2870 }
2871 }
2872 pub fn release_ble_lp_clk(clocks: &mut ClockTree) {
2873 trace!("Releasing BLE_LP_CLK");
2874 if decrement_reference_count(&mut clocks.ble_lp_clk_refcount) {
2875 trace!("Disabling BLE_LP_CLK");
2876 enable_ble_lp_clk_impl(clocks, false);
2877 match unwrap!(clocks.ble_lp_clk) {
2878 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
2879 BleLpClkConfig::RcSlow => release_ble_lp_rc_slow_clk(clocks),
2880 #[cfg(use_xtal32k)]
2881 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2882 }
2883 }
2884 }
2885 pub fn ble_lp_clk_config_frequency(config: BleLpClkConfig) -> u32 {
2886 match config {
2887 BleLpClkConfig::Xtal => ble_lp_xtal_clk_frequency(),
2888 BleLpClkConfig::RcSlow => ble_lp_rc_slow_clk_frequency(),
2889 #[cfg(use_xtal32k)]
2890 BleLpClkConfig::Xtal32k => xtal32k_clk_frequency(),
2891 }
2892 }
2893 pub fn ble_lp_clk_frequency() -> u32 {
2894 BLE_LP_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2895 }
2896 pub fn ble_lp_clk_source_frequency(source: BleLpClkConfig) -> u32 {
2897 ble_lp_clk_config_frequency(source)
2898 }
2899 pub fn request_crypto_pll_div(clocks: &mut ClockTree) {
2900 trace!("Enabling CRYPTO_PLL_DIV");
2901 request_pll_clk(clocks);
2902 enable_crypto_pll_div_impl(clocks, true);
2903 }
2904 pub fn release_crypto_pll_div(clocks: &mut ClockTree) {
2905 trace!("Disabling CRYPTO_PLL_DIV");
2906 enable_crypto_pll_div_impl(clocks, false);
2907 release_pll_clk(clocks);
2908 }
2909 pub fn crypto_pll_div_frequency() -> u32 {
2910 (pll_clk_frequency() / 3)
2911 }
2912 pub fn crypto_pll_div_source_frequency() -> u32 {
2913 pll_clk_frequency()
2914 }
2915 pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
2916 let old_selector = clocks.crypto_clk.replace(new_selector);
2917 refresh_crypto_clk_downstream(clocks);
2918 let active = clocks.crypto_clk_refcount > 0;
2919 if active {
2920 match new_selector {
2921 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
2922 CryptoClkConfig::RcFast => request_rc_fast_clk(clocks),
2923 CryptoClkConfig::PllF480m => request_crypto_pll_div(clocks),
2924 }
2925 }
2926 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2927 if active && let Some(old_selector) = old_selector {
2928 match old_selector {
2929 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
2930 CryptoClkConfig::RcFast => release_rc_fast_clk(clocks),
2931 CryptoClkConfig::PllF480m => release_crypto_pll_div(clocks),
2932 }
2933 }
2934 }
2935 pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
2936 clocks.crypto_clk
2937 }
2938 pub fn request_crypto_clk(clocks: &mut ClockTree) {
2939 trace!("Requesting CRYPTO_CLK");
2940 if increment_reference_count(&mut clocks.crypto_clk_refcount) {
2941 trace!("Enabling CRYPTO_CLK");
2942 match unwrap!(clocks.crypto_clk) {
2943 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
2944 CryptoClkConfig::RcFast => request_rc_fast_clk(clocks),
2945 CryptoClkConfig::PllF480m => request_crypto_pll_div(clocks),
2946 }
2947 enable_crypto_clk_impl(clocks, true);
2948 }
2949 }
2950 pub fn release_crypto_clk(clocks: &mut ClockTree) {
2951 trace!("Releasing CRYPTO_CLK");
2952 if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
2953 trace!("Disabling CRYPTO_CLK");
2954 enable_crypto_clk_impl(clocks, false);
2955 match unwrap!(clocks.crypto_clk) {
2956 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
2957 CryptoClkConfig::RcFast => release_rc_fast_clk(clocks),
2958 CryptoClkConfig::PllF480m => release_crypto_pll_div(clocks),
2959 }
2960 }
2961 }
2962 pub fn crypto_clk_config_frequency(config: CryptoClkConfig) -> u32 {
2963 match config {
2964 CryptoClkConfig::Xtal => xtal_clk_frequency(),
2965 CryptoClkConfig::RcFast => rc_fast_clk_frequency(),
2966 CryptoClkConfig::PllF480m => crypto_pll_div_frequency(),
2967 }
2968 }
2969 pub fn crypto_clk_frequency() -> u32 {
2970 CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2971 }
2972 pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
2973 crypto_clk_config_frequency(source)
2974 }
2975 pub fn configure_timg_calibration_clock(
2976 clocks: &mut ClockTree,
2977 new_selector: TimgCalibrationClockConfig,
2978 ) {
2979 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2980 refresh_timg_calibration_clock_downstream(clocks);
2981 let active = clocks.timg_calibration_clock_refcount > 0;
2982 if active {
2983 match new_selector {
2984 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
2985 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2986 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2987 #[cfg(use_xtal32k)]
2988 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2989 }
2990 }
2991 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2992 if active && let Some(old_selector) = old_selector {
2993 match old_selector {
2994 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
2995 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2996 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2997 #[cfg(use_xtal32k)]
2998 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2999 }
3000 }
3001 }
3002 pub fn timg_calibration_clock_config(
3003 clocks: &mut ClockTree,
3004 ) -> Option<TimgCalibrationClockConfig> {
3005 clocks.timg_calibration_clock
3006 }
3007 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3008 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3009 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3010 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3011 crate::rtc_cntl::WakeLock::acquire();
3012 match unwrap!(clocks.timg_calibration_clock) {
3013 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
3014 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3015 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3016 #[cfg(use_xtal32k)]
3017 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3018 }
3019 enable_timg_calibration_clock_impl(clocks, true);
3020 }
3021 }
3022 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3023 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3024 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3025 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3026 crate::rtc_cntl::WakeLock::release();
3027 enable_timg_calibration_clock_impl(clocks, false);
3028 match unwrap!(clocks.timg_calibration_clock) {
3029 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
3030 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3031 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3032 #[cfg(use_xtal32k)]
3033 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3034 }
3035 }
3036 }
3037 pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
3038 match config {
3039 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
3040 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3041 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3042 #[cfg(use_xtal32k)]
3043 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3044 }
3045 }
3046 pub fn timg_calibration_clock_frequency() -> u32 {
3047 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3048 }
3049 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3050 timg_calibration_clock_config_frequency(source)
3051 }
3052 impl AdcInstance {
3053 pub fn configure_function_clock(
3054 self,
3055 clocks: &mut ClockTree,
3056 new_selector: AdcFunctionClockConfig,
3057 ) {
3058 let old_selector = clocks.adc_function_clock[self as usize].replace(new_selector);
3059 refresh_adc_function_clock_downstream(clocks, self);
3060 let active = clocks.adc_function_clock_refcount[self as usize] > 0;
3061 if active {
3062 match new_selector {
3063 AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3064 AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3065 AdcFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3066 }
3067 }
3068 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3069 if active && let Some(old_selector) = old_selector {
3070 match old_selector {
3071 AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3072 AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3073 AdcFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3074 }
3075 }
3076 }
3077 pub fn function_clock_config(
3078 self,
3079 clocks: &mut ClockTree,
3080 ) -> Option<AdcFunctionClockConfig> {
3081 clocks.adc_function_clock[self as usize]
3082 }
3083 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3084 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3085 if increment_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
3086 {
3087 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3088 match unwrap!(clocks.adc_function_clock[self as usize]) {
3089 AdcFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3090 AdcFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3091 AdcFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3092 }
3093 self.enable_function_clock_impl(clocks, true);
3094 }
3095 }
3096 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3097 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3098 if decrement_reference_count(&mut clocks.adc_function_clock_refcount[self as usize])
3099 {
3100 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3101 self.enable_function_clock_impl(clocks, false);
3102 match unwrap!(clocks.adc_function_clock[self as usize]) {
3103 AdcFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3104 AdcFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3105 AdcFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3106 }
3107 }
3108 }
3109 pub fn function_clock_config_frequency(config: AdcFunctionClockConfig) -> u32 {
3110 match config {
3111 AdcFunctionClockConfig::Xtal => xtal_clk_frequency(),
3112 AdcFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3113 AdcFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3114 }
3115 }
3116 pub fn function_clock_frequency(self) -> u32 {
3117 ADC_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3118 .load(::core::sync::atomic::Ordering::Acquire)
3119 }
3120 pub fn function_clock_source_frequency(source: AdcFunctionClockConfig) -> u32 {
3121 Self::function_clock_config_frequency(source)
3122 }
3123 }
3124 impl I2cInstance {
3125 pub fn configure_function_clock(
3126 self,
3127 clocks: &mut ClockTree,
3128 config: I2cFunctionClockConfig,
3129 ) {
3130 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3131 refresh_i2c_function_clock_downstream(clocks, self);
3132 let active = clocks.i2c_function_clock_refcount[self as usize] > 0;
3133 if active {
3134 match config.sclk {
3135 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3136 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3137 }
3138 }
3139 self.configure_function_clock_impl(clocks, old_config, config);
3140 if active && let Some(old_config) = old_config {
3141 match old_config.sclk {
3142 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3143 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3144 }
3145 }
3146 }
3147 pub fn function_clock_config(
3148 self,
3149 clocks: &mut ClockTree,
3150 ) -> Option<I2cFunctionClockConfig> {
3151 clocks.i2c_function_clock[self as usize]
3152 }
3153 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3154 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3155 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3156 {
3157 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3158 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3159 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3160 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3161 }
3162 self.enable_function_clock_impl(clocks, true);
3163 }
3164 }
3165 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3166 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3167 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3168 {
3169 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3170 self.enable_function_clock_impl(clocks, false);
3171 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3172 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3173 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3174 }
3175 }
3176 }
3177 pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
3178 (match config.sclk {
3179 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3180 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3181 } / (config.div_num() + 1))
3182 }
3183 pub fn function_clock_frequency(self) -> u32 {
3184 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3185 .load(::core::sync::atomic::Ordering::Acquire)
3186 }
3187 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3188 match sclk {
3189 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3190 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3191 }
3192 }
3193 }
3194 impl I2sInstance {
3195 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
3196 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
3197 refresh_i2s_tx_clk_downstream(clocks, self);
3198 let active = clocks.i2s_tx_clk_refcount[self as usize] > 0;
3199 if active {
3200 match config.sclk {
3201 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3202 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
3203 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
3204 }
3205 }
3206 self.configure_tx_clk_impl(clocks, old_config, config);
3207 if active && let Some(old_config) = old_config {
3208 match old_config.sclk {
3209 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3210 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
3211 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
3212 }
3213 }
3214 }
3215 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
3216 clocks.i2s_tx_clk[self as usize]
3217 }
3218 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
3219 trace!("Requesting {:?}::TX_CLK", self);
3220 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
3221 trace!("Enabling {:?}::TX_CLK", self);
3222 crate::rtc_cntl::WakeLock::acquire();
3223 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
3224 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3225 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
3226 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
3227 }
3228 self.enable_tx_clk_impl(clocks, true);
3229 }
3230 }
3231 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
3232 trace!("Releasing {:?}::TX_CLK", self);
3233 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
3234 trace!("Disabling {:?}::TX_CLK", self);
3235 crate::rtc_cntl::WakeLock::release();
3236 self.enable_tx_clk_impl(clocks, false);
3237 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
3238 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3239 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
3240 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
3241 }
3242 }
3243 }
3244 pub fn tx_clk_config_frequency(config: I2sClkConfig) -> u32 {
3245 (((match config.sclk {
3246 I2sClkSclk::Xtal => xtal_clk_frequency(),
3247 I2sClkSclk::PllF120m => pll_f120m_frequency(),
3248 I2sClkSclk::PllF160m => pll_f160m_frequency(),
3249 } as u64)
3250 * (config.div_a() as u64))
3251 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3252 as u32
3253 }
3254 pub fn tx_clk_frequency(self) -> u32 {
3255 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3256 }
3257 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
3258 match sclk {
3259 I2sClkSclk::Xtal => xtal_clk_frequency(),
3260 I2sClkSclk::PllF120m => pll_f120m_frequency(),
3261 I2sClkSclk::PllF160m => pll_f160m_frequency(),
3262 }
3263 }
3264 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
3265 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
3266 refresh_i2s_rx_clk_downstream(clocks, self);
3267 let active = clocks.i2s_rx_clk_refcount[self as usize] > 0;
3268 if active {
3269 match config.sclk {
3270 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3271 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
3272 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
3273 }
3274 }
3275 self.configure_rx_clk_impl(clocks, old_config, config);
3276 if active && let Some(old_config) = old_config {
3277 match old_config.sclk {
3278 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3279 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
3280 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
3281 }
3282 }
3283 }
3284 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
3285 clocks.i2s_rx_clk[self as usize]
3286 }
3287 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
3288 trace!("Requesting {:?}::RX_CLK", self);
3289 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
3290 trace!("Enabling {:?}::RX_CLK", self);
3291 crate::rtc_cntl::WakeLock::acquire();
3292 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
3293 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3294 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
3295 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
3296 }
3297 self.enable_rx_clk_impl(clocks, true);
3298 }
3299 }
3300 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
3301 trace!("Releasing {:?}::RX_CLK", self);
3302 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
3303 trace!("Disabling {:?}::RX_CLK", self);
3304 crate::rtc_cntl::WakeLock::release();
3305 self.enable_rx_clk_impl(clocks, false);
3306 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
3307 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3308 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
3309 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
3310 }
3311 }
3312 }
3313 pub fn rx_clk_config_frequency(config: I2sClkConfig) -> u32 {
3314 (((match config.sclk {
3315 I2sClkSclk::Xtal => xtal_clk_frequency(),
3316 I2sClkSclk::PllF120m => pll_f120m_frequency(),
3317 I2sClkSclk::PllF160m => pll_f160m_frequency(),
3318 } as u64)
3319 * (config.div_a() as u64))
3320 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3321 as u32
3322 }
3323 pub fn rx_clk_frequency(self) -> u32 {
3324 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3325 }
3326 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
3327 match sclk {
3328 I2sClkSclk::Xtal => xtal_clk_frequency(),
3329 I2sClkSclk::PllF120m => pll_f120m_frequency(),
3330 I2sClkSclk::PllF160m => pll_f160m_frequency(),
3331 }
3332 }
3333 pub fn configure_mclk_out(
3334 self,
3335 clocks: &mut ClockTree,
3336 new_selector: I2sMclkOutConfig,
3337 ) {
3338 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
3339 refresh_i2s_mclk_out_downstream(clocks, self);
3340 let active = clocks.i2s_mclk_out_refcount[self as usize] > 0;
3341 if active {
3342 match new_selector {
3343 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
3344 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3345 }
3346 }
3347 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
3348 if active && let Some(old_selector) = old_selector {
3349 match old_selector {
3350 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3351 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3352 }
3353 }
3354 }
3355 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
3356 clocks.i2s_mclk_out[self as usize]
3357 }
3358 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
3359 trace!("Requesting {:?}::MCLK_OUT", self);
3360 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3361 trace!("Enabling {:?}::MCLK_OUT", self);
3362 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3363 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
3364 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3365 }
3366 self.enable_mclk_out_impl(clocks, true);
3367 }
3368 }
3369 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
3370 trace!("Releasing {:?}::MCLK_OUT", self);
3371 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3372 trace!("Disabling {:?}::MCLK_OUT", self);
3373 self.enable_mclk_out_impl(clocks, false);
3374 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3375 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3376 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3377 }
3378 }
3379 }
3380 pub fn mclk_out_config_frequency(self, config: I2sMclkOutConfig) -> u32 {
3381 match config {
3382 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
3383 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
3384 }
3385 }
3386 pub fn mclk_out_frequency(self) -> u32 {
3387 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3388 }
3389 }
3390 impl SpiInstance {
3391 pub fn configure_function_clock(
3392 self,
3393 clocks: &mut ClockTree,
3394 new_selector: SpiFunctionClockConfig,
3395 ) {
3396 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3397 refresh_spi_function_clock_downstream(clocks, self);
3398 let active = clocks.spi_function_clock_refcount[self as usize] > 0;
3399 if active {
3400 match new_selector {
3401 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3402 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
3403 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3404 }
3405 }
3406 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3407 if active && let Some(old_selector) = old_selector {
3408 match old_selector {
3409 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3410 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
3411 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3412 }
3413 }
3414 }
3415 pub fn function_clock_config(
3416 self,
3417 clocks: &mut ClockTree,
3418 ) -> Option<SpiFunctionClockConfig> {
3419 clocks.spi_function_clock[self as usize]
3420 }
3421 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3422 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3423 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3424 {
3425 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3426 match unwrap!(clocks.spi_function_clock[self as usize]) {
3427 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3428 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
3429 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3430 }
3431 self.enable_function_clock_impl(clocks, true);
3432 }
3433 }
3434 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3435 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3436 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3437 {
3438 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3439 self.enable_function_clock_impl(clocks, false);
3440 match unwrap!(clocks.spi_function_clock[self as usize]) {
3441 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3442 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
3443 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3444 }
3445 }
3446 }
3447 pub fn function_clock_config_frequency(config: SpiFunctionClockConfig) -> u32 {
3448 match config {
3449 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3450 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
3451 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3452 }
3453 }
3454 pub fn function_clock_frequency(self) -> u32 {
3455 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3456 .load(::core::sync::atomic::Ordering::Acquire)
3457 }
3458 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3459 Self::function_clock_config_frequency(source)
3460 }
3461 }
3462 impl TimgInstance {
3463 pub fn configure_function_clock(
3464 self,
3465 clocks: &mut ClockTree,
3466 new_selector: TimgFunctionClockConfig,
3467 ) {
3468 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3469 refresh_timg_function_clock_downstream(clocks, self);
3470 let active = clocks.timg_function_clock_refcount[self as usize] > 0;
3471 if active {
3472 match new_selector {
3473 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3474 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3475 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3476 }
3477 }
3478 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3479 if active && let Some(old_selector) = old_selector {
3480 match old_selector {
3481 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3482 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3483 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3484 }
3485 }
3486 }
3487 pub fn function_clock_config(
3488 self,
3489 clocks: &mut ClockTree,
3490 ) -> Option<TimgFunctionClockConfig> {
3491 clocks.timg_function_clock[self as usize]
3492 }
3493 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3494 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3495 if increment_reference_count(
3496 &mut clocks.timg_function_clock_refcount[self as usize],
3497 ) {
3498 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3499 match unwrap!(clocks.timg_function_clock[self as usize]) {
3500 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3501 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3502 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3503 }
3504 self.enable_function_clock_impl(clocks, true);
3505 }
3506 }
3507 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3508 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3509 if decrement_reference_count(
3510 &mut clocks.timg_function_clock_refcount[self as usize],
3511 ) {
3512 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3513 self.enable_function_clock_impl(clocks, false);
3514 match unwrap!(clocks.timg_function_clock[self as usize]) {
3515 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3516 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3517 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3518 }
3519 }
3520 }
3521 pub fn function_clock_config_frequency(config: TimgFunctionClockConfig) -> u32 {
3522 match config {
3523 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3524 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3525 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3526 }
3527 }
3528 pub fn function_clock_frequency(self) -> u32 {
3529 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3530 .load(::core::sync::atomic::Ordering::Acquire)
3531 }
3532 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3533 Self::function_clock_config_frequency(source)
3534 }
3535 pub fn configure_wdt_clock(
3536 self,
3537 clocks: &mut ClockTree,
3538 new_selector: TimgWdtClockConfig,
3539 ) {
3540 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3541 refresh_timg_wdt_clock_downstream(clocks, self);
3542 let active = clocks.timg_wdt_clock_refcount[self as usize] > 0;
3543 if active {
3544 match new_selector {
3545 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3546 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3547 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3548 }
3549 }
3550 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3551 if active && let Some(old_selector) = old_selector {
3552 match old_selector {
3553 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3554 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3555 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3556 }
3557 }
3558 }
3559 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3560 clocks.timg_wdt_clock[self as usize]
3561 }
3562 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3563 trace!("Requesting {:?}::WDT_CLOCK", self);
3564 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3565 trace!("Enabling {:?}::WDT_CLOCK", self);
3566 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3567 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3568 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3569 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3570 }
3571 self.enable_wdt_clock_impl(clocks, true);
3572 }
3573 }
3574 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3575 trace!("Releasing {:?}::WDT_CLOCK", self);
3576 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3577 trace!("Disabling {:?}::WDT_CLOCK", self);
3578 self.enable_wdt_clock_impl(clocks, false);
3579 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3580 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3581 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3582 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3583 }
3584 }
3585 }
3586 pub fn wdt_clock_config_frequency(config: TimgWdtClockConfig) -> u32 {
3587 match config {
3588 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3589 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3590 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3591 }
3592 }
3593 pub fn wdt_clock_frequency(self) -> u32 {
3594 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3595 .load(::core::sync::atomic::Ordering::Acquire)
3596 }
3597 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3598 Self::wdt_clock_config_frequency(source)
3599 }
3600 }
3601 impl UartInstance {
3602 pub fn configure_function_clock(
3603 self,
3604 clocks: &mut ClockTree,
3605 config: UartFunctionClockConfig,
3606 ) {
3607 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3608 refresh_uart_function_clock_downstream(clocks, self);
3609 let active = clocks.uart_function_clock_refcount[self as usize] > 0;
3610 if active {
3611 match config.sclk {
3612 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3613 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3614 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3615 }
3616 }
3617 self.configure_function_clock_impl(clocks, old_config, config);
3618 if active && let Some(old_config) = old_config {
3619 match old_config.sclk {
3620 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3621 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3622 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3623 }
3624 }
3625 }
3626 pub fn function_clock_config(
3627 self,
3628 clocks: &mut ClockTree,
3629 ) -> Option<UartFunctionClockConfig> {
3630 clocks.uart_function_clock[self as usize]
3631 }
3632 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3633 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3634 if increment_reference_count(
3635 &mut clocks.uart_function_clock_refcount[self as usize],
3636 ) {
3637 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3638 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3639 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3640 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3641 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3642 }
3643 self.enable_function_clock_impl(clocks, true);
3644 }
3645 }
3646 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3647 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3648 if decrement_reference_count(
3649 &mut clocks.uart_function_clock_refcount[self as usize],
3650 ) {
3651 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3652 self.enable_function_clock_impl(clocks, false);
3653 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3654 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3655 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3656 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3657 }
3658 }
3659 }
3660 pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
3661 (match config.sclk {
3662 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3663 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3664 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3665 } / (config.div_num() + 1))
3666 }
3667 pub fn function_clock_frequency(self) -> u32 {
3668 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3669 .load(::core::sync::atomic::Ordering::Acquire)
3670 }
3671 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3672 match sclk {
3673 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3674 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3675 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3676 }
3677 }
3678 pub fn configure_baud_rate_generator(
3679 self,
3680 clocks: &mut ClockTree,
3681 config: UartBaudRateGeneratorConfig,
3682 ) {
3683 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3684 refresh_uart_baud_rate_generator_downstream(clocks, self);
3685 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3686 }
3687 pub fn baud_rate_generator_config(
3688 self,
3689 clocks: &mut ClockTree,
3690 ) -> Option<UartBaudRateGeneratorConfig> {
3691 clocks.uart_baud_rate_generator[self as usize]
3692 }
3693 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3694 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3695 if increment_reference_count(
3696 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3697 ) {
3698 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3699 self.request_function_clock(clocks);
3700 self.enable_baud_rate_generator_impl(clocks, true);
3701 }
3702 }
3703 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3704 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3705 if decrement_reference_count(
3706 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3707 ) {
3708 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3709 self.enable_baud_rate_generator_impl(clocks, false);
3710 self.release_function_clock(clocks);
3711 }
3712 }
3713 pub fn baud_rate_generator_config_frequency(
3714 self,
3715 config: UartBaudRateGeneratorConfig,
3716 ) -> u32 {
3717 ((self.function_clock_frequency() * 16)
3718 / ((config.integral() * 16) + config.fractional()))
3719 }
3720 pub fn baud_rate_generator_frequency(self) -> u32 {
3721 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3722 .load(::core::sync::atomic::Ordering::Acquire)
3723 }
3724 }
3725 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3733 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3734 #[instability::unstable]
3735 pub struct ClockConfig {
3736 pub xtal_clk: Option<XtalClkConfig>,
3738 pub hp_root_clk: Option<HpRootClkConfig>,
3740 pub cpu_clk: Option<CpuClkConfig>,
3742 pub ahb_clk: Option<AhbClkConfig>,
3744 pub apb_clk: Option<ApbClkConfig>,
3746 pub lp_fast_clk: Option<LpFastClkConfig>,
3748 pub lp_slow_clk: Option<LpSlowClkConfig>,
3750 pub ble_lp_clk: Option<BleLpClkConfig>,
3752 pub crypto_clk: Option<CryptoClkConfig>,
3754 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3756 }
3757 impl ClockConfig {
3758 fn apply(&self, clocks: &mut ClockTree) {
3759 if let Some(config) = self.xtal_clk {
3760 configure_xtal_clk(clocks, config);
3761 }
3762 if let Some(config) = self.hp_root_clk {
3763 configure_hp_root_clk(clocks, config);
3764 }
3765 if let Some(config) = self.cpu_clk {
3766 configure_cpu_clk(clocks, config);
3767 }
3768 if let Some(config) = self.ahb_clk {
3769 configure_ahb_clk(clocks, config);
3770 }
3771 if let Some(config) = self.apb_clk {
3772 configure_apb_clk(clocks, config);
3773 }
3774 if let Some(config) = self.lp_fast_clk {
3775 configure_lp_fast_clk(clocks, config);
3776 }
3777 if let Some(config) = self.lp_slow_clk {
3778 configure_lp_slow_clk(clocks, config);
3779 }
3780 if let Some(config) = self.ble_lp_clk {
3781 configure_ble_lp_clk(clocks, config);
3782 }
3783 if let Some(config) = self.crypto_clk {
3784 configure_crypto_clk(clocks, config);
3785 }
3786 if let Some(config) = self.timg_calibration_clock {
3787 configure_timg_calibration_clock(clocks, config);
3788 }
3789 }
3790 }
3791 fn increment_reference_count(refcount: &mut u32) -> bool {
3792 let first = *refcount == 0;
3793 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3794 first
3795 }
3796 fn decrement_reference_count(refcount: &mut u32) -> bool {
3797 *refcount = refcount.saturating_sub(1);
3798 let last = *refcount == 0;
3799 last
3800 }
3801 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3802 if let Some(config) = clocks.xtal_clk {
3803 XTAL_CLK_FREQ_CACHE.store(
3804 xtal_clk_config_frequency(config),
3805 ::core::sync::atomic::Ordering::Release,
3806 );
3807 }
3808 refresh_hp_root_clk_downstream(clocks);
3809 refresh_lp_fast_clk_downstream(clocks);
3810 refresh_ble_lp_clk_downstream(clocks);
3811 refresh_crypto_clk_downstream(clocks);
3812 for child_instance in [AdcInstance::ApbSaradc] {
3813 refresh_adc_function_clock_downstream(clocks, child_instance);
3814 }
3815 for child_instance in [I2cInstance::I2c0] {
3816 refresh_i2c_function_clock_downstream(clocks, child_instance);
3817 }
3818 for child_instance in [I2sInstance::I2s0] {
3819 refresh_i2s_tx_clk_downstream(clocks, child_instance);
3820 refresh_i2s_rx_clk_downstream(clocks, child_instance);
3821 }
3822 for child_instance in [SpiInstance::Spi2] {
3823 refresh_spi_function_clock_downstream(clocks, child_instance);
3824 }
3825 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3826 refresh_timg_function_clock_downstream(clocks, child_instance);
3827 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3828 }
3829 for child_instance in [
3830 UartInstance::Uart0,
3831 UartInstance::Uart1,
3832 UartInstance::Uart2,
3833 ] {
3834 refresh_uart_function_clock_downstream(clocks, child_instance);
3835 }
3836 }
3837 fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
3838 refresh_hp_root_clk_downstream(clocks);
3839 refresh_lp_fast_clk_downstream(clocks);
3840 refresh_crypto_clk_downstream(clocks);
3841 refresh_timg_calibration_clock_downstream(clocks);
3842 for child_instance in [AdcInstance::ApbSaradc] {
3843 refresh_adc_function_clock_downstream(clocks, child_instance);
3844 }
3845 for child_instance in [I2cInstance::I2c0] {
3846 refresh_i2c_function_clock_downstream(clocks, child_instance);
3847 }
3848 for child_instance in [SpiInstance::Spi2] {
3849 refresh_spi_function_clock_downstream(clocks, child_instance);
3850 }
3851 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3852 refresh_timg_function_clock_downstream(clocks, child_instance);
3853 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3854 }
3855 for child_instance in [
3856 UartInstance::Uart0,
3857 UartInstance::Uart1,
3858 UartInstance::Uart2,
3859 ] {
3860 refresh_uart_function_clock_downstream(clocks, child_instance);
3861 }
3862 }
3863 fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
3864 refresh_lp_slow_clk_downstream(clocks);
3865 refresh_ble_lp_clk_downstream(clocks);
3866 refresh_timg_calibration_clock_downstream(clocks);
3867 }
3868 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
3869 if let Some(config) = clocks.hp_root_clk {
3870 HP_ROOT_CLK_FREQ_CACHE.store(
3871 hp_root_clk_config_frequency(config),
3872 ::core::sync::atomic::Ordering::Release,
3873 );
3874 }
3875 refresh_cpu_clk_downstream(clocks);
3876 refresh_ahb_clk_downstream(clocks);
3877 }
3878 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3879 if let Some(config) = clocks.cpu_clk {
3880 CPU_CLK_FREQ_CACHE.store(
3881 cpu_clk_config_frequency(config),
3882 ::core::sync::atomic::Ordering::Release,
3883 );
3884 }
3885 }
3886 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
3887 if let Some(config) = clocks.ahb_clk {
3888 AHB_CLK_FREQ_CACHE.store(
3889 ahb_clk_config_frequency(config),
3890 ::core::sync::atomic::Ordering::Release,
3891 );
3892 }
3893 refresh_apb_clk_downstream(clocks);
3894 }
3895 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3896 if let Some(config) = clocks.apb_clk {
3897 APB_CLK_FREQ_CACHE.store(
3898 apb_clk_config_frequency(config),
3899 ::core::sync::atomic::Ordering::Release,
3900 );
3901 }
3902 }
3903 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
3904 if let Some(config) = clocks.lp_fast_clk {
3905 LP_FAST_CLK_FREQ_CACHE.store(
3906 lp_fast_clk_config_frequency(config),
3907 ::core::sync::atomic::Ordering::Release,
3908 );
3909 }
3910 }
3911 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
3912 if let Some(config) = clocks.lp_slow_clk {
3913 LP_SLOW_CLK_FREQ_CACHE.store(
3914 lp_slow_clk_config_frequency(config),
3915 ::core::sync::atomic::Ordering::Release,
3916 );
3917 }
3918 }
3919 fn refresh_ble_lp_clk_downstream(clocks: &mut ClockTree) {
3920 if let Some(config) = clocks.ble_lp_clk {
3921 BLE_LP_CLK_FREQ_CACHE.store(
3922 ble_lp_clk_config_frequency(config),
3923 ::core::sync::atomic::Ordering::Release,
3924 );
3925 }
3926 }
3927 fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
3928 if let Some(config) = clocks.crypto_clk {
3929 CRYPTO_CLK_FREQ_CACHE.store(
3930 crypto_clk_config_frequency(config),
3931 ::core::sync::atomic::Ordering::Release,
3932 );
3933 }
3934 }
3935 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3936 if let Some(config) = clocks.timg_calibration_clock {
3937 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3938 timg_calibration_clock_config_frequency(config),
3939 ::core::sync::atomic::Ordering::Release,
3940 );
3941 }
3942 }
3943 fn refresh_adc_function_clock_downstream(clocks: &mut ClockTree, instance: AdcInstance) {
3944 if let Some(config) = clocks.adc_function_clock[instance as usize] {
3945 ADC_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3946 AdcInstance::function_clock_config_frequency(config),
3947 ::core::sync::atomic::Ordering::Release,
3948 );
3949 }
3950 }
3951 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
3952 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
3953 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3954 I2cInstance::function_clock_config_frequency(config),
3955 ::core::sync::atomic::Ordering::Release,
3956 );
3957 }
3958 }
3959 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3960 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
3961 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
3962 I2sInstance::tx_clk_config_frequency(config),
3963 ::core::sync::atomic::Ordering::Release,
3964 );
3965 }
3966 refresh_i2s_mclk_out_downstream(clocks, instance);
3967 }
3968 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3969 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
3970 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
3971 I2sInstance::rx_clk_config_frequency(config),
3972 ::core::sync::atomic::Ordering::Release,
3973 );
3974 }
3975 refresh_i2s_mclk_out_downstream(clocks, instance);
3976 }
3977 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3978 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
3979 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
3980 instance.mclk_out_config_frequency(config),
3981 ::core::sync::atomic::Ordering::Release,
3982 );
3983 }
3984 }
3985 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
3986 if let Some(config) = clocks.spi_function_clock[instance as usize] {
3987 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3988 SpiInstance::function_clock_config_frequency(config),
3989 ::core::sync::atomic::Ordering::Release,
3990 );
3991 }
3992 }
3993 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3994 if let Some(config) = clocks.timg_function_clock[instance as usize] {
3995 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3996 TimgInstance::function_clock_config_frequency(config),
3997 ::core::sync::atomic::Ordering::Release,
3998 );
3999 }
4000 }
4001 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4002 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
4003 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
4004 TimgInstance::wdt_clock_config_frequency(config),
4005 ::core::sync::atomic::Ordering::Release,
4006 );
4007 }
4008 }
4009 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4010 if let Some(config) = clocks.uart_function_clock[instance as usize] {
4011 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4012 UartInstance::function_clock_config_frequency(config),
4013 ::core::sync::atomic::Ordering::Release,
4014 );
4015 }
4016 refresh_uart_baud_rate_generator_downstream(clocks, instance);
4017 }
4018 fn refresh_uart_baud_rate_generator_downstream(
4019 clocks: &mut ClockTree,
4020 instance: UartInstance,
4021 ) {
4022 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4023 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4024 instance.baud_rate_generator_config_frequency(config),
4025 ::core::sync::atomic::Ordering::Release,
4026 );
4027 }
4028 }
4029 };
4030}
4031#[macro_export]
4035#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4036macro_rules! implement_peripheral_clocks {
4037 () => {
4038 #[doc(hidden)]
4039 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4040 #[repr(u8)]
4041 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4042 pub enum Peripheral {
4043 AhbGdma,
4045 ApbSarAdc,
4047 Ecc,
4049 I2cExt0,
4051 I2s0,
4053 Sha,
4055 Spi2,
4057 Systimer,
4059 Timg0,
4061 Timg1,
4063 Uart0,
4065 Uart1,
4067 Uart2,
4069 UsbDevice,
4071 }
4072 impl Peripheral {
4073 const KEEP_ENABLED: &[Peripheral] =
4074 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
4075 const COUNT: usize = Self::ALL.len();
4076 const ALL: &[Self] = &[
4077 Self::AhbGdma,
4078 Self::ApbSarAdc,
4079 Self::Ecc,
4080 Self::I2cExt0,
4081 Self::I2s0,
4082 Self::Sha,
4083 Self::Spi2,
4084 Self::Systimer,
4085 Self::Timg0,
4086 Self::Timg1,
4087 Self::Uart0,
4088 Self::Uart1,
4089 Self::Uart2,
4090 Self::UsbDevice,
4091 ];
4092 }
4093 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4094 match peripheral {
4095 Peripheral::AhbGdma => {
4096 crate::peripherals::SYSTEM::regs()
4097 .gdma_conf()
4098 .modify(|_, w| w.gdma_clk_en().bit(enable));
4099 }
4100 Peripheral::ApbSarAdc => {
4101 crate::peripherals::SYSTEM::regs()
4102 .saradc_conf()
4103 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
4104 }
4105 Peripheral::Ecc => {
4106 crate::peripherals::SYSTEM::regs()
4107 .ecc_conf()
4108 .modify(|_, w| w.ecc_clk_en().bit(enable));
4109 }
4110 Peripheral::I2cExt0 => {
4111 crate::peripherals::SYSTEM::regs()
4112 .i2c0_conf()
4113 .modify(|_, w| w.i2c0_clk_en().bit(enable));
4114 }
4115 Peripheral::I2s0 => {
4116 crate::peripherals::SYSTEM::regs()
4117 .i2s_conf()
4118 .modify(|_, w| w.i2s_clk_en().bit(enable));
4119 }
4120 Peripheral::Sha => {
4121 crate::peripherals::SYSTEM::regs()
4122 .sha_conf()
4123 .modify(|_, w| w.sha_clk_en().bit(enable));
4124 }
4125 Peripheral::Spi2 => {
4126 crate::peripherals::SYSTEM::regs()
4127 .spi2_conf()
4128 .modify(|_, w| w.spi2_clk_en().bit(enable));
4129 }
4130 Peripheral::Systimer => {
4131 crate::peripherals::SYSTEM::regs()
4132 .systimer_conf()
4133 .modify(|_, w| w.systimer_clk_en().bit(enable));
4134 }
4135 Peripheral::Timg0 => {
4136 crate::peripherals::SYSTEM::regs()
4137 .timergroup(0)
4138 .conf()
4139 .modify(|_, w| w.clk_en().bit(enable));
4140 }
4141 Peripheral::Timg1 => {
4142 crate::peripherals::SYSTEM::regs()
4143 .timergroup(1)
4144 .conf()
4145 .modify(|_, w| w.clk_en().bit(enable));
4146 }
4147 Peripheral::Uart0 => {
4148 crate::peripherals::SYSTEM::regs()
4149 .uart(0)
4150 .conf()
4151 .modify(|_, w| w.clk_en().bit(enable));
4152 }
4153 Peripheral::Uart1 => {
4154 crate::peripherals::SYSTEM::regs()
4155 .uart(1)
4156 .conf()
4157 .modify(|_, w| w.clk_en().bit(enable));
4158 }
4159 Peripheral::Uart2 => {
4160 crate::peripherals::SYSTEM::regs()
4161 .uart(2)
4162 .conf()
4163 .modify(|_, w| w.clk_en().bit(enable));
4164 }
4165 Peripheral::UsbDevice => {
4166 crate::peripherals::SYSTEM::regs()
4167 .usb_device_conf()
4168 .modify(|_, w| w.usb_device_clk_en().bit(enable));
4169 }
4170 }
4171 }
4172 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4173 match peripheral {
4174 Peripheral::AhbGdma => {
4175 crate::peripherals::SYSTEM::regs()
4176 .gdma_conf()
4177 .modify(|_, w| w.gdma_rst_en().bit(reset));
4178 }
4179 Peripheral::ApbSarAdc => {
4180 crate::peripherals::SYSTEM::regs()
4181 .saradc_conf()
4182 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
4183 }
4184 Peripheral::Ecc => {
4185 crate::peripherals::SYSTEM::regs()
4186 .ecc_conf()
4187 .modify(|_, w| w.ecc_rst_en().bit(reset));
4188 }
4189 Peripheral::I2cExt0 => {
4190 crate::peripherals::SYSTEM::regs()
4191 .i2c0_conf()
4192 .modify(|_, w| w.i2c0_rst_en().bit(reset));
4193 }
4194 Peripheral::I2s0 => {
4195 crate::peripherals::SYSTEM::regs()
4196 .i2s_conf()
4197 .modify(|_, w| w.i2s_rst_en().bit(reset));
4198 }
4199 Peripheral::Sha => {
4200 crate::peripherals::SYSTEM::regs()
4201 .sha_conf()
4202 .modify(|_, w| w.sha_rst_en().bit(reset));
4203 }
4204 Peripheral::Spi2 => {
4205 crate::peripherals::SYSTEM::regs()
4206 .spi2_conf()
4207 .modify(|_, w| w.spi2_rst_en().bit(reset));
4208 }
4209 Peripheral::Systimer => {
4210 crate::peripherals::SYSTEM::regs()
4211 .systimer_conf()
4212 .modify(|_, w| w.systimer_rst_en().bit(reset));
4213 }
4214 Peripheral::Timg0 => {
4215 crate::peripherals::SYSTEM::regs()
4216 .timergroup(0)
4217 .conf()
4218 .modify(|_, w| w.rst_en().bit(reset));
4219 }
4220 Peripheral::Timg1 => {
4221 crate::peripherals::SYSTEM::regs()
4222 .timergroup(1)
4223 .conf()
4224 .modify(|_, w| w.rst_en().bit(reset));
4225 }
4226 Peripheral::Uart0 => {
4227 crate::peripherals::SYSTEM::regs()
4228 .uart(0)
4229 .conf()
4230 .modify(|_, w| w.rst_en().bit(reset));
4231 }
4232 Peripheral::Uart1 => {
4233 crate::peripherals::SYSTEM::regs()
4234 .uart(1)
4235 .conf()
4236 .modify(|_, w| w.rst_en().bit(reset));
4237 }
4238 Peripheral::Uart2 => {
4239 crate::peripherals::SYSTEM::regs()
4240 .uart(2)
4241 .conf()
4242 .modify(|_, w| w.rst_en().bit(reset));
4243 }
4244 Peripheral::UsbDevice => {
4245 crate::peripherals::SYSTEM::regs()
4246 .usb_device_conf()
4247 .modify(|_, w| w.usb_device_rst_en().bit(reset));
4248 }
4249 }
4250 }
4251 };
4252}
4253#[macro_export]
4261#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4262macro_rules! memory_range {
4263 ("DRAM") => {
4264 0x40800000..0x40850000
4265 };
4266 (size as str, "DRAM") => {
4267 "327680"
4268 };
4269 ("DRAM2_UNINIT") => {
4270 0x4083EA70..0x4084EA70
4271 };
4272 (size as str, "DRAM2_UNINIT") => {
4273 "65536"
4274 };
4275 ("IROM") => {
4276 0x42000000..0x44000000
4277 };
4278 (size as str, "IROM") => {
4279 "33554432"
4280 };
4281 ("DROM") => {
4282 0x42000000..0x44000000
4283 };
4284 (size as str, "DROM") => {
4285 "33554432"
4286 };
4287}
4288#[macro_export]
4305#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4306macro_rules! for_each_i2c_master {
4307 ($($pattern:tt => $code:tt;)*) => {
4308 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4309 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4310 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4311 I2CEXT0_SDA)));
4312 };
4313}
4314#[macro_export]
4341#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4342macro_rules! for_each_i2s {
4343 ($($pattern:tt => $code:tt;)*) => {
4344 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4345 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
4346 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
4347 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
4348 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
4349 true, true, false)));
4350 };
4351}
4352#[macro_export]
4371#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4372macro_rules! for_each_uart {
4373 ($($pattern:tt => $code:tt;)*) => {
4374 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4375 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4376 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4377 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((2, UART2, Uart2,
4378 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = true)); _for_each_inner_uart!((all(0,
4379 UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1,
4380 Uart1, U1RXD, U1TXD, U1CTS, U1RTS, wakeup_source = true), (2, UART2, Uart2,
4381 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = true)));
4382 };
4383}
4384#[macro_export]
4406#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4407macro_rules! for_each_spi_master {
4408 ($($pattern:tt => $code:tt;)*) => {
4409 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4410 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
4411 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
4412 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
4413 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4414 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
4415 };
4416}
4417#[macro_export]
4434#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4435macro_rules! for_each_spi_slave {
4436 ($($pattern:tt => $code:tt;)*) => {
4437 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4438 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
4439 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4440 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
4441 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
4442 };
4443}
4444#[macro_export]
4445#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4446macro_rules! for_each_peripheral {
4447 ($($pattern:tt => $code:tt;)*) => {
4448 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4449 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4450 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
4451 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4452 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4453 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
4454 _for_each_inner_peripheral!((@ peri_type #[doc =
4455 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4456 "<section class=\"warning\">"] #[doc =
4457 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4458 #[doc = "<ul>"] #[doc =
4459 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4460 =
4461 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4462 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
4463 _for_each_inner_peripheral!((@ peri_type #[doc =
4464 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4465 "<section class=\"warning\">"] #[doc =
4466 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4467 #[doc = "<ul>"] #[doc =
4468 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4469 =
4470 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4471 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
4472 _for_each_inner_peripheral!((@ peri_type #[doc =
4473 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4474 "<section class=\"warning\">"] #[doc =
4475 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4476 #[doc = "<ul>"] #[doc =
4477 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4478 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4479 _for_each_inner_peripheral!((@ peri_type #[doc =
4480 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4481 "<section class=\"warning\">"] #[doc =
4482 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4483 #[doc = "<ul>"] #[doc =
4484 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4485 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4486 _for_each_inner_peripheral!((@ peri_type #[doc =
4487 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4488 "<section class=\"warning\">"] #[doc =
4489 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4490 #[doc = "<ul>"] #[doc =
4491 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4492 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4493 _for_each_inner_peripheral!((@ peri_type #[doc =
4494 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4495 "<section class=\"warning\">"] #[doc =
4496 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4497 #[doc = "<ul>"] #[doc =
4498 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4499 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4500 _for_each_inner_peripheral!((@ peri_type #[doc =
4501 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4502 "<section class=\"warning\">"] #[doc =
4503 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4504 #[doc = "<ul>"] #[doc =
4505 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4506 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4507 _for_each_inner_peripheral!((@ peri_type #[doc =
4508 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4509 "<section class=\"warning\">"] #[doc =
4510 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4511 #[doc = "<ul>"] #[doc =
4512 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4513 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
4514 _for_each_inner_peripheral!((@ peri_type #[doc =
4515 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4516 "<section class=\"warning\">"] #[doc =
4517 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4518 #[doc = "<ul>"] #[doc =
4519 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4520 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4521 _for_each_inner_peripheral!((@ peri_type #[doc =
4522 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4523 "<section class=\"warning\">"] #[doc =
4524 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4525 #[doc = "<ul>"] #[doc =
4526 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4527 #[doc = "</section>"] GPIO12 <= virtual())); _for_each_inner_peripheral!((@
4528 peri_type #[doc = "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""]
4529 #[doc = "<section class=\"warning\">"] #[doc =
4530 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4531 #[doc = "<ul>"] #[doc =
4532 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4533 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
4534 peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
4535 #[doc = "<section class=\"warning\">"] #[doc =
4536 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4537 #[doc = "<ul>"] #[doc =
4538 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4539 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
4540 _for_each_inner_peripheral!((@ peri_type #[doc =
4541 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4542 "<section class=\"warning\">"] #[doc =
4543 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4544 #[doc = "<ul>"] #[doc =
4545 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4546 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
4547 _for_each_inner_peripheral!((@ peri_type #[doc =
4548 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4549 "<section class=\"warning\">"] #[doc =
4550 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4551 #[doc = "<ul>"] #[doc =
4552 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4553 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4554 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
4555 _for_each_inner_peripheral!((@ peri_type #[doc =
4556 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4557 "<section class=\"warning\">"] #[doc =
4558 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4559 #[doc = "<ul>"] #[doc =
4560 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4561 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4562 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
4563 _for_each_inner_peripheral!((@ peri_type #[doc =
4564 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4565 "<section class=\"warning\">"] #[doc =
4566 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4567 #[doc = "<ul>"] #[doc =
4568 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4569 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4570 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()));
4571 _for_each_inner_peripheral!((@ peri_type #[doc =
4572 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4573 "<section class=\"warning\">"] #[doc =
4574 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4575 #[doc = "<ul>"] #[doc =
4576 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4577 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4578 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()));
4579 _for_each_inner_peripheral!((@ peri_type #[doc =
4580 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4581 "<section class=\"warning\">"] #[doc =
4582 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4583 #[doc = "<ul>"] #[doc =
4584 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4585 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4586 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
4587 _for_each_inner_peripheral!((@ peri_type #[doc =
4588 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4589 "<section class=\"warning\">"] #[doc =
4590 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4591 #[doc = "<ul>"] #[doc =
4592 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4593 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4594 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
4595 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
4596 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4597 "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
4598 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO24 peripheral singleton"]
4599 GPIO24 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4600 "GPIO25 peripheral singleton"] GPIO25 <= virtual()));
4601 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
4602 GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4603 "GPIO27 peripheral singleton"] GPIO27 <= virtual()));
4604 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO28 peripheral singleton"]
4605 GPIO28 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4606 "GPIO29 peripheral singleton"] GPIO29 <= virtual()));
4607 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
4608 DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4609 disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
4610 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4611 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
4612 DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4613 disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
4614 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4615 _for_each_inner_peripheral!((@ peri_type #[doc =
4616 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
4617 _for_each_inner_peripheral!((@ peri_type #[doc =
4618 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
4619 _for_each_inner_peripheral!((@ peri_type #[doc = "CACHE peripheral singleton"]
4620 CACHE <= CACHE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4621 "CLIC peripheral singleton"] CLIC <= CLIC() (unstable)));
4622 _for_each_inner_peripheral!((@ peri_type #[doc = "CLINT peripheral singleton"]
4623 CLINT <= CLINT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4624 "DMA peripheral singleton"] DMA <= DMA() (unstable)));
4625 _for_each_inner_peripheral!((@ peri_type #[doc = "ECC peripheral singleton"] ECC
4626 <= ECC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4627 "ECDSA peripheral singleton"] ECDSA <= ECDSA() (unstable)));
4628 _for_each_inner_peripheral!((@ peri_type #[doc = "EFUSE peripheral singleton"]
4629 EFUSE <= EFUSE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4630 "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)));
4631 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
4632 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4633 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_EXT() (unstable)));
4634 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_APM peripheral singleton"]
4635 HP_APM <= HP_APM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4636 "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)));
4637 _for_each_inner_peripheral!((@ peri_type #[doc =
4638 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4639 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4640 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4641 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4642 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
4643 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4644 _for_each_inner_peripheral!((@ peri_type #[doc =
4645 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4646 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4647 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
4648 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
4649 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4650 "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
4651 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
4652 LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4653 "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
4654 _for_each_inner_peripheral!((@ peri_type #[doc =
4655 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
4656 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
4657 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4658 = "LP_GPIO peripheral singleton"] LP_GPIO <= LP_GPIO() (unstable)));
4659 _for_each_inner_peripheral!((@ peri_type #[doc =
4660 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
4661 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
4662 LP_PERI <= LPPERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4663 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
4664 _for_each_inner_peripheral!((@ peri_type #[doc =
4665 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
4666 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
4667 LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4668 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
4669 _for_each_inner_peripheral!((@ peri_type #[doc =
4670 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
4671 _for_each_inner_peripheral!((@ peri_type #[doc =
4672 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
4673 _for_each_inner_peripheral!((@ peri_type #[doc = "PAU peripheral singleton"] PAU
4674 <= PAU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4675 "PCR peripheral singleton"] PCR <= PCR() (unstable)));
4676 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
4677 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4678 "RNG peripheral singleton"] RNG <= LPPERI() (unstable)));
4679 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
4680 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4681 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4682 "SLC peripheral singleton"] SLC <= SLC() (unstable)));
4683 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
4684 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4685 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
4686 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
4687 SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
4688 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4689 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)));
4690 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
4691 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
4692 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)));
4693 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
4694 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4695 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
4696 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
4697 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
4698 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4699 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
4700 enable_peri_interrupt, disable_peri_interrupt })));
4701 _for_each_inner_peripheral!((@ peri_type #[doc = "UART2 peripheral singleton"]
4702 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
4703 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4704 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4705 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4706 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4707 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
4708 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4709 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
4710 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
4711 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4712 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
4713 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4714 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4715 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
4716 WIFI <= virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt,
4717 disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
4718 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
4719 disable_pwr_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4720 "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
4721 _for_each_inner_peripheral!((@ peri_type #[doc =
4722 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
4723 _for_each_inner_peripheral!((@ peri_type #[doc =
4724 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4725 _for_each_inner_peripheral!((@ peri_type #[doc =
4726 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4727 _for_each_inner_peripheral!((@ peri_type #[doc =
4728 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4729 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
4730 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
4731 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4732 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4733 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4734 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4735 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4736 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4737 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
4738 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
4739 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
4740 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
4741 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
4742 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
4743 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
4744 _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
4745 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4746 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4747 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4748 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
4749 _for_each_inner_peripheral!((CACHE(unstable)));
4750 _for_each_inner_peripheral!((CLINT(unstable)));
4751 _for_each_inner_peripheral!((DMA(unstable)));
4752 _for_each_inner_peripheral!((ECC(unstable)));
4753 _for_each_inner_peripheral!((ECDSA(unstable)));
4754 _for_each_inner_peripheral!((EFUSE(unstable)));
4755 _for_each_inner_peripheral!((ETM(unstable)));
4756 _for_each_inner_peripheral!((GPIO(unstable)));
4757 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4758 _for_each_inner_peripheral!((HP_APM(unstable)));
4759 _for_each_inner_peripheral!((HP_SYS(unstable)));
4760 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4761 _for_each_inner_peripheral!((I2C0));
4762 _for_each_inner_peripheral!((I2S0(unstable)));
4763 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4764 _for_each_inner_peripheral!((INTPRI(unstable)));
4765 _for_each_inner_peripheral!((IO_MUX(unstable)));
4766 _for_each_inner_peripheral!((LP_ANA(unstable)));
4767 _for_each_inner_peripheral!((LP_AON(unstable)));
4768 _for_each_inner_peripheral!((LP_APM(unstable)));
4769 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
4770 _for_each_inner_peripheral!((LPWR(unstable)));
4771 _for_each_inner_peripheral!((LP_GPIO(unstable)));
4772 _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
4773 _for_each_inner_peripheral!((LP_PERI(unstable)));
4774 _for_each_inner_peripheral!((LP_TEE(unstable)));
4775 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4776 _for_each_inner_peripheral!((LP_WDT(unstable)));
4777 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
4778 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
4779 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
4780 _for_each_inner_peripheral!((PAU(unstable)));
4781 _for_each_inner_peripheral!((PCR(unstable)));
4782 _for_each_inner_peripheral!((PMU(unstable)));
4783 _for_each_inner_peripheral!((RNG(unstable)));
4784 _for_each_inner_peripheral!((SHA(unstable)));
4785 _for_each_inner_peripheral!((SLC(unstable)));
4786 _for_each_inner_peripheral!((SPI0(unstable)));
4787 _for_each_inner_peripheral!((SPI1(unstable)));
4788 _for_each_inner_peripheral!((SPI2));
4789 _for_each_inner_peripheral!((SYSTEM(unstable)));
4790 _for_each_inner_peripheral!((SYSTIMER(unstable)));
4791 _for_each_inner_peripheral!((TEE(unstable)));
4792 _for_each_inner_peripheral!((TIMG0(unstable)));
4793 _for_each_inner_peripheral!((TIMG1(unstable)));
4794 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
4795 _for_each_inner_peripheral!((UART2));
4796 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
4797 _for_each_inner_peripheral!((ADC1(unstable)));
4798 _for_each_inner_peripheral!((BT(unstable)));
4799 _for_each_inner_peripheral!((FLASH(unstable)));
4800 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
4801 _for_each_inner_peripheral!((WIFI));
4802 _for_each_inner_peripheral!((PSRAM(unstable)));
4803 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
4804 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
4805 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
4806 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
4807 _for_each_inner_peripheral!((SPI2, Spi2, 1, AhbGdmaChannel));
4808 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
4809 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
4810 _for_each_inner_peripheral!((all(@ peri_type #[doc =
4811 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
4812 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
4813 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
4814 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4815 "<section class=\"warning\">"] #[doc =
4816 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4817 #[doc = "<ul>"] #[doc =
4818 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4819 =
4820 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4821 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
4822 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4823 "<section class=\"warning\">"] #[doc =
4824 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4825 #[doc = "<ul>"] #[doc =
4826 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4827 =
4828 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4829 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
4830 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4831 "<section class=\"warning\">"] #[doc =
4832 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4833 #[doc = "<ul>"] #[doc =
4834 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4835 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
4836 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4837 "<section class=\"warning\">"] #[doc =
4838 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4839 #[doc = "<ul>"] #[doc =
4840 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4841 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
4842 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4843 "<section class=\"warning\">"] #[doc =
4844 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4845 #[doc = "<ul>"] #[doc =
4846 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4847 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
4848 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4849 "<section class=\"warning\">"] #[doc =
4850 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4851 #[doc = "<ul>"] #[doc =
4852 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4853 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
4854 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4855 "<section class=\"warning\">"] #[doc =
4856 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4857 #[doc = "<ul>"] #[doc =
4858 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4859 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
4860 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4861 "<section class=\"warning\">"] #[doc =
4862 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4863 #[doc = "<ul>"] #[doc =
4864 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4865 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
4866 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4867 "<section class=\"warning\">"] #[doc =
4868 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4869 #[doc = "<ul>"] #[doc =
4870 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4871 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
4872 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4873 "<section class=\"warning\">"] #[doc =
4874 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4875 #[doc = "<ul>"] #[doc =
4876 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4877 #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
4878 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4879 "<section class=\"warning\">"] #[doc =
4880 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4881 #[doc = "<ul>"] #[doc =
4882 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4883 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
4884 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4885 "<section class=\"warning\">"] #[doc =
4886 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4887 #[doc = "<ul>"] #[doc =
4888 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4889 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
4890 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4891 "<section class=\"warning\">"] #[doc =
4892 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4893 #[doc = "<ul>"] #[doc =
4894 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4895 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
4896 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4897 "<section class=\"warning\">"] #[doc =
4898 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4899 #[doc = "<ul>"] #[doc =
4900 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4901 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4902 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
4903 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4904 "<section class=\"warning\">"] #[doc =
4905 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4906 #[doc = "<ul>"] #[doc =
4907 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4908 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4909 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
4910 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4911 "<section class=\"warning\">"] #[doc =
4912 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4913 #[doc = "<ul>"] #[doc =
4914 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4915 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4916 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
4917 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4918 "<section class=\"warning\">"] #[doc =
4919 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4920 #[doc = "<ul>"] #[doc =
4921 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4922 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4923 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
4924 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4925 "<section class=\"warning\">"] #[doc =
4926 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4927 #[doc = "<ul>"] #[doc =
4928 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4929 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4930 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
4931 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4932 "<section class=\"warning\">"] #[doc =
4933 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4934 #[doc = "<ul>"] #[doc =
4935 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4936 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4937 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
4938 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
4939 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
4940 "GPIO24 peripheral singleton"] GPIO24 <= virtual()), (@ peri_type #[doc =
4941 "GPIO25 peripheral singleton"] GPIO25 <= virtual()), (@ peri_type #[doc =
4942 "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
4943 "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
4944 "GPIO28 peripheral singleton"] GPIO28 <= virtual()), (@ peri_type #[doc =
4945 "GPIO29 peripheral singleton"] GPIO29 <= virtual()), (@ peri_type #[doc =
4946 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
4947 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4948 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4949 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4950 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
4951 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4952 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4953 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4954 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
4955 peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
4956 ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "CACHE peripheral singleton"]
4957 CACHE <= CACHE() (unstable)), (@ peri_type #[doc = "CLIC peripheral singleton"]
4958 CLIC <= CLIC() (unstable)), (@ peri_type #[doc = "CLINT peripheral singleton"]
4959 CLINT <= CLINT() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"]
4960 DMA <= DMA() (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <=
4961 ECC() (unstable)), (@ peri_type #[doc = "ECDSA peripheral singleton"] ECDSA <=
4962 ECDSA() (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <=
4963 EFUSE() (unstable)), (@ peri_type #[doc = "ETM peripheral singleton"] ETM <=
4964 SOC_ETM() (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <=
4965 GPIO() (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD
4966 <= GPIO_EXT() (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"]
4967 HP_APM <= HP_APM() (unstable)), (@ peri_type #[doc =
4968 "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)), (@ peri_type #[doc
4969 = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)),
4970 (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : {
4971 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4972 peri_type #[doc = "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : {
4973 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4974 (unstable)), (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"]
4975 INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
4976 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
4977 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
4978 #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)), (@
4979 peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)),
4980 (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <= LP_APM()
4981 (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"] LP_CLKRST <=
4982 LP_CLKRST() (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR
4983 <= LP_CLKRST() (unstable)), (@ peri_type #[doc = "LP_GPIO peripheral singleton"]
4984 LP_GPIO <= LP_GPIO() (unstable)), (@ peri_type #[doc =
4985 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)), (@
4986 peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LPPERI()
4987 (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE <=
4988 LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
4989 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
4990 "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc
4991 = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)),
4992 (@ peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON <=
4993 MODEM_LPCON() (unstable)), (@ peri_type #[doc =
4994 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
4995 (@ peri_type #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@
4996 peri_type #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@
4997 peri_type #[doc = "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@
4998 peri_type #[doc = "RNG peripheral singleton"] RNG <= LPPERI() (unstable)), (@
4999 peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
5000 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5001 (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <= SLC()
5002 (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
5003 (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
5004 (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
5005 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5006 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
5007 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
5008 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
5009 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
5010 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
5011 (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
5012 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5013 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
5014 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
5015 disable_peri_interrupt })), (@ peri_type #[doc = "UART2 peripheral singleton"]
5016 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
5017 disable_peri_interrupt })), (@ peri_type #[doc =
5018 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
5019 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5020 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
5021 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
5022 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
5023 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
5024 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
5025 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
5026 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
5027 (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <= virtual(WIFI_BB : {
5028 bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt }, WIFI_MAC : {
5029 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : {
5030 bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt })), (@ peri_type
5031 #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)), (@
5032 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
5033 virtual() (unstable)), (@ peri_type #[doc =
5034 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
5035 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
5036 virtual() (unstable)), (@ peri_type #[doc =
5037 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
5038 _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
5039 (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
5040 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
5041 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
5042 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (GPIO29),
5043 (DMA_CH0(unstable)), (DMA_CH1(unstable)), (APB_SARADC(unstable)),
5044 (ASSIST_DEBUG(unstable)), (CACHE(unstable)), (CLINT(unstable)), (DMA(unstable)),
5045 (ECC(unstable)), (ECDSA(unstable)), (EFUSE(unstable)), (ETM(unstable)),
5046 (GPIO(unstable)), (GPIO_SD(unstable)), (HP_APM(unstable)), (HP_SYS(unstable)),
5047 (I2C_ANA_MST(unstable)), (I2C0), (I2S0(unstable)), (INTERRUPT_CORE0(unstable)),
5048 (INTPRI(unstable)), (IO_MUX(unstable)), (LP_ANA(unstable)), (LP_AON(unstable)),
5049 (LP_APM(unstable)), (LP_CLKRST(unstable)), (LPWR(unstable)), (LP_GPIO(unstable)),
5050 (LP_IO_MUX(unstable)), (LP_PERI(unstable)), (LP_TEE(unstable)),
5051 (RTC_TIMER(unstable)), (LP_WDT(unstable)), (MEM_MONITOR(unstable)),
5052 (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)), (PAU(unstable)),
5053 (PCR(unstable)), (PMU(unstable)), (RNG(unstable)), (SHA(unstable)),
5054 (SLC(unstable)), (SPI0(unstable)), (SPI1(unstable)), (SPI2), (SYSTEM(unstable)),
5055 (SYSTIMER(unstable)), (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
5056 (UART0), (UART1), (UART2), (USB_DEVICE(unstable)), (ADC1(unstable)),
5057 (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (WIFI),
5058 (PSRAM(unstable)), (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
5059 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
5060 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 1, AhbGdmaChannel), (I2S0,
5061 I2s0, 3, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel)));
5062 };
5063}
5064#[macro_export]
5091#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5092macro_rules! for_each_gpio {
5093 ($($pattern:tt => $code:tt;)*) => {
5094 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5095 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
5096 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
5097 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
5098 _for_each_inner_gpio!((3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
5099 [Output]))); _for_each_inner_gpio!((4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 =>
5100 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTCK) ()
5101 ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTDO _2 => FSPICLK)
5102 (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2 =>
5103 FSPID) (_2 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((8, GPIO8(_2 =>
5104 FSPICS0) (_2 => FSPICS0) ([Input] [Output]))); _for_each_inner_gpio!((9, GPIO9()
5105 () ([Input] [Output]))); _for_each_inner_gpio!((10, GPIO10(_0 => U0RXD) ()
5106 ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11() (_0 => U0TXD) ([Input]
5107 [Output]))); _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
5108 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
5109 _for_each_inner_gpio!((14, GPIO14() (_0 => FSPICS1) ([Input] [Output])));
5110 _for_each_inner_gpio!((15, GPIO15(_0 => FSPICS0) (_0 => FSPICS0) ([Input]
5111 [Output]))); _for_each_inner_gpio!((16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ)
5112 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => FSPIWP) (_0 =>
5113 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18() () ([Input]
5114 [Output]))); _for_each_inner_gpio!((19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
5115 ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_0 => FSPICLK) (_0 =>
5116 FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21(_0 => FSPID) (_0
5117 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22(_0 =>
5118 SDIO_DATA2) () ([Input] [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 =>
5119 SDIO_DATA3) () ([Input] [Output]))); _for_each_inner_gpio!((24, GPIO24() ()
5120 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_0 => SDIO_CMD) ()
5121 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_0 => SDIO_CLK) ()
5122 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27(_0 => SDIO_DATA0) ()
5123 ([Input] [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SDIO_DATA1) ()
5124 ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() () ([Input]
5125 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
5126 GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
5127 [Output])), (3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
5128 [Output])), (4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) ([Input]
5129 [Output])), (5, GPIO5(_0 => MTCK) () ([Input] [Output])), (6, GPIO6(_0 => MTDO _2
5130 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_2 =>
5131 FSPID) ([Input] [Output])), (8, GPIO8(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
5132 [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10(_0 => U0RXD) ()
5133 ([Input] [Output])), (11, GPIO11() (_0 => U0TXD) ([Input] [Output])), (12,
5134 GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14,
5135 GPIO14() (_0 => FSPICS1) ([Input] [Output])), (15, GPIO15(_0 => FSPICS0) (_0 =>
5136 FSPICS0) ([Input] [Output])), (16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ) ([Input]
5137 [Output])), (17, GPIO17(_0 => FSPIWP) (_0 => FSPIWP) ([Input] [Output])), (18,
5138 GPIO18() () ([Input] [Output])), (19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
5139 ([Input] [Output])), (20, GPIO20(_0 => FSPICLK) (_0 => FSPICLK) ([Input]
5140 [Output])), (21, GPIO21(_0 => FSPID) (_0 => FSPID) ([Input] [Output])), (22,
5141 GPIO22(_0 => SDIO_DATA2) () ([Input] [Output])), (23, GPIO23(_0 => SDIO_DATA3) ()
5142 ([Input] [Output])), (24, GPIO24() () ([Input] [Output])), (25, GPIO25(_0 =>
5143 SDIO_CMD) () ([Input] [Output])), (26, GPIO26(_0 => SDIO_CLK) () ([Input]
5144 [Output])), (27, GPIO27(_0 => SDIO_DATA0) () ([Input] [Output])), (28, GPIO28(_0
5145 => SDIO_DATA1) () ([Input] [Output])), (29, GPIO29() () ([Input] [Output]))));
5146 };
5147}
5148#[macro_export]
5175#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5176macro_rules! for_each_analog_function {
5177 ($($pattern:tt => $code:tt;)*) => {
5178 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5179 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
5180 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
5181 _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
5182 _for_each_inner_analog_function!((ADC1_CH1, GPIO3));
5183 _for_each_inner_analog_function!((ADC1_CH2, GPIO4));
5184 _for_each_inner_analog_function!((ADC1_CH3, GPIO5));
5185 _for_each_inner_analog_function!((ZCD0, GPIO8));
5186 _for_each_inner_analog_function!((ZCD1, GPIO9));
5187 _for_each_inner_analog_function!((USJ_DM, GPIO12));
5188 _for_each_inner_analog_function!((USJ_DP, GPIO13));
5189 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
5190 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO3));
5191 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO4));
5192 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO5));
5193 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO8));
5194 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO9));
5195 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (XTAL_32K_N, GPIO1),
5196 (ADC1_CH0, GPIO1), (ADC1_CH1, GPIO3), (ADC1_CH2, GPIO4), (ADC1_CH3, GPIO5),
5197 (ZCD0, GPIO8), (ZCD1, GPIO9), (USJ_DM, GPIO12), (USJ_DP, GPIO13)));
5198 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1),
5199 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO3), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO4),
5200 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO5)));
5201 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO8), ((ZCD1, ZCDn, 1),
5202 GPIO9)));
5203 };
5204}
5205#[macro_export]
5243#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5244macro_rules! for_each_lp_function {
5245 ($($pattern:tt => $code:tt;)*) => {
5246 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5247 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
5248 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
5249 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
5250 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
5251 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
5252 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
5253 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _1));
5254 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
5255 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
5256 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
5257 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
5258 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
5259 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
5260 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()));
5261 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _1), (LP_GPIO1, GPIO1, _1),
5262 (LP_GPIO2, GPIO2, _1), (LP_GPIO3, GPIO3, _1), (LP_GPIO4, GPIO4, _1), (LP_GPIO5,
5263 GPIO5, _1), (LP_GPIO6, GPIO6, _1)));
5264 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, ()
5265 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()), ((LP_GPIO2, LP_GPIOn, 2),
5266 GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()), ((LP_GPIO4,
5267 LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()),
5268 ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ())));
5269 };
5270}
5271#[macro_export]
5302#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5303macro_rules! for_each_iomux_function {
5304 ($($pattern:tt => $code:tt;)*) => {
5305 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5306 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
5307 _for_each_inner_iomux_function!((MTMS, GPIO3, _0));
5308 _for_each_inner_iomux_function!((FSPIHD, GPIO3, _2));
5309 _for_each_inner_iomux_function!((MTDI, GPIO4, _0));
5310 _for_each_inner_iomux_function!((FSPIWP, GPIO4, _2));
5311 _for_each_inner_iomux_function!((MTCK, GPIO5, _0));
5312 _for_each_inner_iomux_function!((MTDO, GPIO6, _0));
5313 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
5314 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
5315 _for_each_inner_iomux_function!((FSPICS0, GPIO8, _2));
5316 _for_each_inner_iomux_function!((U0RXD, GPIO10, _0));
5317 _for_each_inner_iomux_function!((U0TXD, GPIO11, _0));
5318 _for_each_inner_iomux_function!((FSPICS1, GPIO14, _0));
5319 _for_each_inner_iomux_function!((FSPICS0, GPIO15, _0));
5320 _for_each_inner_iomux_function!((FSPIQ, GPIO16, _0));
5321 _for_each_inner_iomux_function!((FSPIWP, GPIO17, _0));
5322 _for_each_inner_iomux_function!((FSPIHD, GPIO19, _0));
5323 _for_each_inner_iomux_function!((FSPICLK, GPIO20, _0));
5324 _for_each_inner_iomux_function!((FSPID, GPIO21, _0));
5325 _for_each_inner_iomux_function!((SDIO_DATA2, GPIO22, _0));
5326 _for_each_inner_iomux_function!((SDIO_DATA3, GPIO23, _0));
5327 _for_each_inner_iomux_function!((SDIO_CMD, GPIO25, _0));
5328 _for_each_inner_iomux_function!((SDIO_CLK, GPIO26, _0));
5329 _for_each_inner_iomux_function!((SDIO_DATA0, GPIO27, _0));
5330 _for_each_inner_iomux_function!((SDIO_DATA1, GPIO28, _0));
5331 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO8, _2));
5332 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO14, _0));
5333 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO15, _0));
5334 _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO22, _0));
5335 _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0));
5336 _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO27, _0));
5337 _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO28, _0));
5338 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO3, _0),
5339 (FSPIHD, GPIO3, _2), (MTDI, GPIO4, _0), (FSPIWP, GPIO4, _2), (MTCK, GPIO5, _0),
5340 (MTDO, GPIO6, _0), (FSPICLK, GPIO6, _2), (FSPID, GPIO7, _2), (FSPICS0, GPIO8,
5341 _2), (U0RXD, GPIO10, _0), (U0TXD, GPIO11, _0), (FSPICS1, GPIO14, _0), (FSPICS0,
5342 GPIO15, _0), (FSPIQ, GPIO16, _0), (FSPIWP, GPIO17, _0), (FSPIHD, GPIO19, _0),
5343 (FSPICLK, GPIO20, _0), (FSPID, GPIO21, _0), (SDIO_DATA2, GPIO22, _0),
5344 (SDIO_DATA3, GPIO23, _0), (SDIO_CMD, GPIO25, _0), (SDIO_CLK, GPIO26, _0),
5345 (SDIO_DATA0, GPIO27, _0), (SDIO_DATA1, GPIO28, _0)));
5346 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO8, _2),
5347 ((FSPICS1, FSPICSn, 1), GPIO14, _0), ((FSPICS0, FSPICSn, 0), GPIO15, _0)));
5348 _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA2, SDIO_DATAn, 2), GPIO22,
5349 _0), ((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0), ((SDIO_DATA0, SDIO_DATAn, 0),
5350 GPIO27, _0), ((SDIO_DATA1, SDIO_DATAn, 1), GPIO28, _0)));
5351 };
5352}
5353#[macro_export]
5370#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5371macro_rules! gpio_for_signal {
5372 (XTAL_32K_P $(, $_fallback:literal)?) => {
5373 "GPIO0"
5374 };
5375 (LP_GPIO0 $(, $_fallback:literal)?) => {
5376 "GPIO0"
5377 };
5378 (XTAL_32K_N $(, $_fallback:literal)?) => {
5379 "GPIO1"
5380 };
5381 (ADC1_CH0 $(, $_fallback:literal)?) => {
5382 "GPIO1"
5383 };
5384 (LP_GPIO1 $(, $_fallback:literal)?) => {
5385 "GPIO1"
5386 };
5387 (FSPIQ $(, $_fallback:literal)?) => {
5388 "GPIO2"
5389 };
5390 (LP_GPIO2 $(, $_fallback:literal)?) => {
5391 "GPIO2"
5392 };
5393 (MTMS $(, $_fallback:literal)?) => {
5394 "GPIO3"
5395 };
5396 (FSPIHD $(, $_fallback:literal)?) => {
5397 "GPIO3"
5398 };
5399 (ADC1_CH1 $(, $_fallback:literal)?) => {
5400 "GPIO3"
5401 };
5402 (LP_GPIO3 $(, $_fallback:literal)?) => {
5403 "GPIO3"
5404 };
5405 (MTDI $(, $_fallback:literal)?) => {
5406 "GPIO4"
5407 };
5408 (FSPIWP $(, $_fallback:literal)?) => {
5409 "GPIO4"
5410 };
5411 (ADC1_CH2 $(, $_fallback:literal)?) => {
5412 "GPIO4"
5413 };
5414 (LP_GPIO4 $(, $_fallback:literal)?) => {
5415 "GPIO4"
5416 };
5417 (MTCK $(, $_fallback:literal)?) => {
5418 "GPIO5"
5419 };
5420 (ADC1_CH3 $(, $_fallback:literal)?) => {
5421 "GPIO5"
5422 };
5423 (LP_GPIO5 $(, $_fallback:literal)?) => {
5424 "GPIO5"
5425 };
5426 (MTDO $(, $_fallback:literal)?) => {
5427 "GPIO6"
5428 };
5429 (FSPICLK $(, $_fallback:literal)?) => {
5430 "GPIO6"
5431 };
5432 (LP_GPIO6 $(, $_fallback:literal)?) => {
5433 "GPIO6"
5434 };
5435 (FSPID $(, $_fallback:literal)?) => {
5436 "GPIO7"
5437 };
5438 (FSPICS0 $(, $_fallback:literal)?) => {
5439 "GPIO8"
5440 };
5441 (ZCD0 $(, $_fallback:literal)?) => {
5442 "GPIO8"
5443 };
5444 (ZCD1 $(, $_fallback:literal)?) => {
5445 "GPIO9"
5446 };
5447 (U0RXD $(, $_fallback:literal)?) => {
5448 "GPIO10"
5449 };
5450 (U0TXD $(, $_fallback:literal)?) => {
5451 "GPIO11"
5452 };
5453 (USJ_DM $(, $_fallback:literal)?) => {
5454 "GPIO12"
5455 };
5456 (USJ_DP $(, $_fallback:literal)?) => {
5457 "GPIO13"
5458 };
5459 (FSPICS1 $(, $_fallback:literal)?) => {
5460 "GPIO14"
5461 };
5462 (SDIO_DATA2 $(, $_fallback:literal)?) => {
5463 "GPIO22"
5464 };
5465 (SDIO_DATA3 $(, $_fallback:literal)?) => {
5466 "GPIO23"
5467 };
5468 (SDIO_CMD $(, $_fallback:literal)?) => {
5469 "GPIO25"
5470 };
5471 (SDIO_CLK $(, $_fallback:literal)?) => {
5472 "GPIO26"
5473 };
5474 (SDIO_DATA0 $(, $_fallback:literal)?) => {
5475 "GPIO27"
5476 };
5477 (SDIO_DATA1 $(, $_fallback:literal)?) => {
5478 "GPIO28"
5479 };
5480 ($_signal:ident, $fallback:literal) => {
5481 $fallback
5482 };
5483}
5484#[macro_export]
5488#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5489macro_rules! define_io_mux_signals {
5490 () => {
5491 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5492 #[derive(Debug, PartialEq, Copy, Clone)]
5493 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5494 #[doc(hidden)]
5495 pub enum InputSignal {
5496 U0RXD = 6,
5497 U0CTS = 7,
5498 U0DSR = 8,
5499 U1RXD = 9,
5500 U1CTS = 10,
5501 U1DSR = 11,
5502 I2S_MCLK = 12,
5503 I2SO_BCK = 13,
5504 I2SO_WS = 14,
5505 I2SI_SD = 15,
5506 I2SI_BCK = 16,
5507 I2SI_WS = 17,
5508 CPU_GPIO_0 = 27,
5509 CPU_GPIO_1 = 28,
5510 CPU_GPIO_2 = 29,
5511 CPU_GPIO_3 = 30,
5512 CPU_GPIO_4 = 31,
5513 CPU_GPIO_5 = 32,
5514 CPU_GPIO_6 = 33,
5515 CPU_GPIO_7 = 34,
5516 USB_JTAG_TDO_BRIDGE = 35,
5517 I2CEXT0_SCL = 46,
5518 I2CEXT0_SDA = 47,
5519 FSPICLK = 64,
5520 FSPIQ = 65,
5521 FSPID = 66,
5522 FSPIHD = 67,
5523 FSPIWP = 68,
5524 FSPICS0 = 69,
5525 U2RXD = 72,
5526 U2CTS = 73,
5527 U2DSR = 74,
5528 SIG_IN_FUNC97 = 97,
5529 SIG_IN_FUNC98 = 98,
5530 SIG_IN_FUNC99 = 99,
5531 SIG_IN_FUNC100 = 100,
5532 SDIO_CLK,
5533 SDIO_CMD,
5534 SDIO_DATA0,
5535 SDIO_DATA1,
5536 SDIO_DATA2,
5537 SDIO_DATA3,
5538 MTDI,
5539 MTDO,
5540 MTCK,
5541 MTMS,
5542 }
5543 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5544 #[derive(Debug, PartialEq, Copy, Clone)]
5545 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5546 #[doc(hidden)]
5547 pub enum OutputSignal {
5548 LEDC_LS_SIG0 = 0,
5549 LEDC_LS_SIG1 = 1,
5550 LEDC_LS_SIG2 = 2,
5551 LEDC_LS_SIG3 = 3,
5552 LEDC_LS_SIG4 = 4,
5553 LEDC_LS_SIG5 = 5,
5554 U0TXD = 6,
5555 U0RTS = 7,
5556 U0DTR = 8,
5557 U1TXD = 9,
5558 U1RTS = 10,
5559 U1DTR = 11,
5560 I2S_MCLK = 12,
5561 I2SO_BCK = 13,
5562 I2SO_WS = 14,
5563 I2SO_SD = 15,
5564 I2SI_BCK = 16,
5565 I2SI_WS = 17,
5566 I2SO_SD1 = 18,
5567 CPU_GPIO_0 = 27,
5568 CPU_GPIO_1 = 28,
5569 CPU_GPIO_2 = 29,
5570 CPU_GPIO_3 = 30,
5571 CPU_GPIO_4 = 31,
5572 CPU_GPIO_5 = 32,
5573 CPU_GPIO_6 = 33,
5574 CPU_GPIO_7 = 34,
5575 I2CEXT0_SCL = 46,
5576 I2CEXT0_SDA = 47,
5577 FSPICLK = 64,
5578 FSPIQ = 65,
5579 FSPID = 66,
5580 FSPIHD = 67,
5581 FSPIWP = 68,
5582 FSPICS0 = 69,
5583 U2TXD = 72,
5584 U2RTS = 73,
5585 U2DTR = 74,
5586 FSPICS1 = 102,
5587 FSPICS2 = 103,
5588 FSPICS3 = 104,
5589 FSPICS4 = 105,
5590 FSPICS5 = 106,
5591 SDIO_TOHOST_INT = 124,
5592 GPIO = 256,
5593 }
5594 };
5595}
5596#[macro_export]
5603#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5604macro_rules! define_lp_functions {
5605 () => {
5606 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5611 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5612 #[doc(hidden)]
5613 pub enum LpFunction {
5614 _1 = 1,
5616 }
5617 impl LpFunction {
5618 pub const LP_GPIO: Self = Self::_1;
5620 }
5621 };
5622}
5623#[macro_export]
5636#[expect(clippy::crate_in_macro_def)]
5637#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5638macro_rules! define_io_mux_reg {
5639 () => {
5640 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
5641 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
5642 }
5643 };
5644}