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.has_bank_1") => {
92 false
93 };
94 ("gpio.input_signal_max") => {
95 100
96 };
97 ("gpio.input_signal_max", str) => {
98 stringify!(100)
99 };
100 ("gpio.output_signal_max") => {
101 256
102 };
103 ("gpio.output_signal_max", str) => {
104 stringify!(256)
105 };
106 ("dedicated_gpio.version") => {
107 "riscv_v1"
108 };
109 ("dedicated_gpio.needs_initialization") => {
110 false
111 };
112 ("dedicated_gpio.channel_count") => {
113 8
114 };
115 ("dedicated_gpio.channel_count", str) => {
116 stringify!(8)
117 };
118 ("lp_io.version") => {
119 "v4"
120 };
121 ("lp_io.has_gpio_matrix") => {
122 false
123 };
124 ("uart.ram_size") => {
125 128
126 };
127 ("uart.ram_size", str) => {
128 stringify!(128)
129 };
130 ("uart.version") => {
131 2
132 };
133 ("uart.version", str) => {
134 stringify!(2)
135 };
136 ("uart.peripheral_controls_mem_clk") => {
137 true
138 };
139 ("uart.has_sclk_divider") => {
140 false
141 };
142 ("uart.has_sclk_enable") => {
143 true
144 };
145 ("i2c_master.version") => {
146 4
147 };
148 ("i2c_master.version", str) => {
149 stringify!(4)
150 };
151 ("i2c_master.has_fsm_timeouts") => {
152 true
153 };
154 ("i2c_master.has_hw_bus_clear") => {
155 true
156 };
157 ("i2c_master.has_bus_timeout_enable") => {
158 true
159 };
160 ("i2c_master.separate_filter_config_registers") => {
161 false
162 };
163 ("i2c_master.can_estimate_nack_reason") => {
164 true
165 };
166 ("i2c_master.has_conf_update") => {
167 true
168 };
169 ("i2c_master.has_reliable_fsm_reset") => {
170 true
171 };
172 ("i2c_master.has_arbitration_en") => {
173 true
174 };
175 ("i2c_master.has_tx_fifo_watermark") => {
176 true
177 };
178 ("i2c_master.bus_timeout_is_exponential") => {
179 true
180 };
181 ("i2c_master.has_pd_en") => {
182 true
183 };
184 ("i2c_master.max_bus_timeout") => {
185 31
186 };
187 ("i2c_master.max_bus_timeout", str) => {
188 stringify!(31)
189 };
190 ("i2c_master.ll_intr_mask") => {
191 262143
192 };
193 ("i2c_master.ll_intr_mask", str) => {
194 stringify!(262143)
195 };
196 ("i2c_master.fifo_size") => {
197 32
198 };
199 ("i2c_master.fifo_size", str) => {
200 stringify!(32)
201 };
202 ("spi_master.version") => {
203 3
204 };
205 ("spi_master.version", str) => {
206 stringify!(3)
207 };
208 ("spi_master.fifo_size") => {
209 64
210 };
211 ("spi_master.fifo_size", str) => {
212 stringify!(64)
213 };
214 ("spi_master.bit_order_is_bool") => {
215 false
216 };
217 ("spi_master.has_octal") => {
218 false
219 };
220 ("spi_master.has_app_interrupts") => {
221 true
222 };
223 ("spi_master.has_dma_segmented_transfer") => {
224 true
225 };
226 ("spi_master.has_clk_pre_div") => {
227 true
228 };
229 ("spi_master.dma_can_access_flash") => {
230 true
231 };
232 ("i2s.version") => {
233 3
234 };
235 ("i2s.version", str) => {
236 stringify!(3)
237 };
238 ("i2s.mclk_divider_bit_width") => {
239 9
240 };
241 ("i2s.mclk_divider_bit_width", str) => {
242 stringify!(9)
243 };
244 ("i2s.max_ws_width") => {
245 512
246 };
247 ("i2s.max_ws_width", str) => {
248 stringify!(512)
249 };
250 ("i2s.clock_configured_by_pcr") => {
251 true
252 };
253 ("i2s.clock_configured_by_hp_sys_clkrst") => {
254 false
255 };
256 ("i2s.supports_pdm_rx_hp_filter") => {
257 false
258 };
259 ("i2s.supports_pdm_tx") => {
260 true
261 };
262 ("i2s.supports_pdm_rx") => {
263 true
264 };
265 ("i2s.supports_pcm2pdm") => {
266 true
267 };
268 ("i2s.supports_pdm2pcm") => {
269 false
270 };
271 ("bt.controller") => {
272 "npl"
273 };
274 ("wifi.has_wifi6") => {
275 true
276 };
277 ("wifi.mac_version") => {
278 3
279 };
280 ("wifi.mac_version", str) => {
281 stringify!(3)
282 };
283 ("wifi.has_5g") => {
284 false
285 };
286 ("wifi.csi_supported") => {
287 true
288 };
289 ("phy.combo_module") => {
290 true
291 };
292 ("timergroup.timg_has_timer1") => {
293 false
294 };
295 ("timergroup.timg_has_divcnt_rst") => {
296 true
297 };
298 ("timergroup.rc_fast_calibration_divider_min_rev") => {
299 0
300 };
301 ("timergroup.rc_fast_calibration_divider") => {
302 32
303 };
304 ("timergroup.rc_fast_calibration_tick_enable") => {
305 false
306 };
307 ("ecc.zero_extend_writes") => {
308 true
309 };
310 ("ecc.separate_jacobian_point_memory") => {
311 true
312 };
313 ("ecc.has_memory_clock_gate") => {
314 true
315 };
316 ("ecc.supports_enhanced_security") => {
317 true
318 };
319 ("ecc.mem_block_size") => {
320 32
321 };
322 ("rng.apb_cycle_wait_num") => {
323 16
324 };
325 ("rng.apb_cycle_wait_num", str) => {
326 stringify!(16)
327 };
328 ("rng.trng_supported") => {
329 false
330 };
331 ("rng.is_lp_sys") => {
332 true
333 };
334 ("sleep.light_sleep") => {
335 true
336 };
337 ("sleep.deep_sleep") => {
338 true
339 };
340 ("sleep.rejectable_mask") => {
341 4094
342 };
343 ("sleep.ext1_version") => {
344 2
345 };
346 ("sleep.ext1_version", str) => {
347 stringify!(2)
348 };
349 ("sleep.pin_wakeup_version") => {
350 3
351 };
352 ("sleep.pin_wakeup_version", str) => {
353 stringify!(3)
354 };
355 ("sleep.deep_sleep_needs_gpio_isolation") => {
356 false
357 };
358 ("assist_debug.has_sp_monitor") => {
359 true
360 };
361 ("assist_debug.has_region_monitor") => {
362 true
363 };
364 ("dma.mem2mem_requires_peripheral") => {
365 false
366 };
367 ("dma.ext_mem_configurable_block_size") => {
368 false
369 };
370 ("dma.separate_in_out_interrupts") => {
371 true
372 };
373 ("dma.gdma_version") => {
374 2
375 };
376 ("dma.gdma_version", str) => {
377 stringify!(2)
378 };
379 ("interrupts.status_registers") => {
380 3
381 };
382 ("interrupts.status_registers", str) => {
383 stringify!(3)
384 };
385 ("interrupts.disabled_interrupt") => {
386 0
387 };
388 ("mmu.page_size") => {
389 65536
390 };
391 ("mmu.page_size", str) => {
392 stringify!(65536)
393 };
394 ("mmu.entry_num") => {
395 512
396 };
397 ("mmu.entry_num", str) => {
398 stringify!(512)
399 };
400 ("psram.octal_spi") => {
401 false
402 };
403 ("psram.hex_spi") => {
404 false
405 };
406 ("psram.extmem_origin") => {
407 1107296256
408 };
409 ("psram.extmem_origin", str) => {
410 stringify!(1107296256)
411 };
412 ("rom.has_crc_le") => {
413 true
414 };
415 ("rom.has_crc_be") => {
416 true
417 };
418 ("rom.has_md5_bsd") => {
419 true
420 };
421 ("rom.has_md5_mbedtls") => {
422 false
423 };
424 ("soc.cpu_has_branch_predictor") => {
425 true
426 };
427 ("soc.cpu_has_csr_pc") => {
428 false
429 };
430 ("soc.multi_core_enabled") => {
431 false
432 };
433 ("soc.cpu_csr_prv_mode") => {
434 2064
435 };
436 ("soc.cpu_csr_prv_mode", str) => {
437 stringify!(2064)
438 };
439 ("soc.internal_memory_cached") => {
440 false
441 };
442 ("soc.has_swd_watchdog") => {
443 true
444 };
445 ("soc.cpu_mcause_mask") => {
446 31
447 };
448 ("soc.cpu_mcause_mask", str) => {
449 stringify!(31)
450 };
451 ("clock_tree.hp_root_clk") => {
452 [crate ::soc::clocks::HpRootClkConfig::Xtal, crate
453 ::soc::clocks::HpRootClkConfig::RcFast, crate
454 ::soc::clocks::HpRootClkConfig::PllF160m]
455 };
456 ("clock_tree.cpu_clk.divisor") => {
457 (0, 255)
458 };
459 ("clock_tree.ahb_clk.divisor") => {
460 (0, 255)
461 };
462 ("clock_tree.apb_clk.divisor") => {
463 (0, 255)
464 };
465 ("clock_tree.lp_fast_clk") => {
466 [crate ::soc::clocks::LpFastClkConfig::RcFast, crate
467 ::soc::clocks::LpFastClkConfig::XtalD2, crate
468 ::soc::clocks::LpFastClkConfig::Xtal]
469 };
470 ("clock_tree.lp_slow_clk") => {
471 [crate ::soc::clocks::LpSlowClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
472 ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
473 ::soc::clocks::LpSlowClkConfig::OscSlow]
474 };
475 ("clock_tree.crypto_clk") => {
476 [crate ::soc::clocks::CryptoClkConfig::Xtal, crate
477 ::soc::clocks::CryptoClkConfig::RcFast, crate
478 ::soc::clocks::CryptoClkConfig::PllF480m]
479 };
480 ("clock_tree.timg_calibration_clock") => {
481 [crate ::soc::clocks::TimgCalibrationClockConfig::OscSlowClk, crate
482 ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
483 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
484 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
485 };
486 ("clock_tree.uart.function_clock.sclk") => {
487 [crate ::soc::clocks::UartFunctionClockSclk::Xtal, crate
488 ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
489 ::soc::clocks::UartFunctionClockSclk::RcFast]
490 };
491 ("clock_tree.uart.function_clock.div_num") => {
492 (0, 255)
493 };
494 ("clock_tree.uart.baud_rate_generator.fractional") => {
495 (0, 15)
496 };
497 ("clock_tree.uart.baud_rate_generator.integral") => {
498 (0, 4095)
499 };
500 ("clock_tree.timg.function_clock") => {
501 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
502 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
503 ::soc::clocks::TimgFunctionClockConfig::PllF80m]
504 };
505 ("clock_tree.timg.wdt_clock") => {
506 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
507 ::soc::clocks::TimgWdtClockConfig::RcFastClk, crate
508 ::soc::clocks::TimgWdtClockConfig::PllF80m]
509 };
510 ("clock_tree.i2c.function_clock.sclk") => {
511 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
512 ::soc::clocks::I2cFunctionClockSclk::RcFast]
513 };
514 ("clock_tree.i2c.function_clock.div_num") => {
515 (0, 255)
516 };
517 ("clock_tree.spi.function_clock") => {
518 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
519 ::soc::clocks::SpiFunctionClockConfig::PllF160m, crate
520 ::soc::clocks::SpiFunctionClockConfig::RcFast]
521 };
522 ("clock_tree.i2s.tx_clk.sclk") => {
523 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
524 ::soc::clocks::I2sClkSclk::PllF120m, crate ::soc::clocks::I2sClkSclk::PllF160m]
525 };
526 ("clock_tree.i2s.tx_clk.div_num") => {
527 (1, 255)
528 };
529 ("clock_tree.i2s.tx_clk.div_a") => {
530 (1, 511)
531 };
532 ("clock_tree.i2s.tx_clk.div_b") => {
533 (0, 511)
534 };
535 ("clock_tree.i2s.rx_clk.sclk") => {
536 [crate ::soc::clocks::I2sClkSclk::Xtal, crate
537 ::soc::clocks::I2sClkSclk::PllF120m, crate ::soc::clocks::I2sClkSclk::PllF160m]
538 };
539 ("clock_tree.i2s.rx_clk.div_num") => {
540 (1, 255)
541 };
542 ("clock_tree.i2s.rx_clk.div_a") => {
543 (1, 511)
544 };
545 ("clock_tree.i2s.rx_clk.div_b") => {
546 (0, 511)
547 };
548 ("clock_tree.i2s.mclk_out") => {
549 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
550 ::soc::clocks::I2sMclkOutConfig::Rx]
551 };
552}
553#[macro_export]
554#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
555macro_rules! for_each_dedicated_gpio {
556 ($($pattern:tt => $code:tt;)*) => {
557 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
558 tt) => {} } _for_each_inner_dedicated_gpio!((0));
559 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
560 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
561 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
562 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
563 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
564 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
565 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
566 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
567 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
568 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
569 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
570 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
571 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
572 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
573 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
574 };
575}
576#[macro_export]
580#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
581macro_rules! define_lp_io_signals {
582 () => {};
583}
584#[macro_export]
585#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
586macro_rules! for_each_ecc_working_mode {
587 ($($pattern:tt => $code:tt;)*) => {
588 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
589 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
590 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
591 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
592 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
593 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
594 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
595 _for_each_inner_ecc_working_mode!((7,
596 AffinePointVerificationAndJacobianPointMultiplication));
597 _for_each_inner_ecc_working_mode!((8, ModularAddition));
598 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
599 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
600 _for_each_inner_ecc_working_mode!((11, ModularDivision));
601 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
602 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
603 JacobianPointMultiplication), (5, AffinePointAddition), (6,
604 JacobianPointVerification), (7,
605 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
606 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
607 };
608}
609#[macro_export]
610#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
611macro_rules! for_each_ecc_curve {
612 ($($pattern:tt => $code:tt;)*) => {
613 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
614 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
615 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
616 P192, 192), (1, P256, 256)));
617 };
618}
619#[macro_export]
620#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
621macro_rules! for_each_sha_algorithm {
622 ($($pattern:tt => $code:tt;)*) => {
623 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
624 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
625 (insecure_against : "collision", "length extension"), 0));
626 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
627 (insecure_against : "length extension"), 1));
628 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
629 (insecure_against : "length extension"), 2));
630 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
631 (insecure_against : "collision", "length extension"), 0), (Sha224,
632 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
633 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
634 2)));
635 };
636}
637#[macro_export]
638#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
639macro_rules! for_each_wakeup_source {
640 ($($pattern:tt => $code:tt;)*) => {
641 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
642 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
643 _for_each_inner_wakeup_source!((Gpio, 2));
644 _for_each_inner_wakeup_source!((WifiBeacon, 3));
645 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
646 5)); _for_each_inner_wakeup_source!((Uart0, 6));
647 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
648 8)); _for_each_inner_wakeup_source!((Uart2, 9));
649 _for_each_inner_wakeup_source!((Bt, 10)); _for_each_inner_wakeup_source!((LpCore,
650 11)); _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3),
651 (Timer, 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Uart2, 9), (Bt, 10),
652 (LpCore, 11)));
653 };
654}
655#[macro_export]
656#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
657macro_rules! for_each_dma_engine {
658 ($($pattern:tt => $code:tt;)*) => {
659 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
660 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
661 _for_each_inner_dma_engine!((all("AHB_GDMA")));
662 };
663}
664#[macro_export]
665#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
666macro_rules! for_each_dma_channel {
667 ($($pattern:tt => $code:tt;)*) => {
668 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
669 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
670 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
671 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
672 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
673 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, I2S0, SHA]));
674 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
675 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, I2S0, SHA]));
676 _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0), ("AHB_GDMA",
677 DMA_CH1))); _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA",
678 any_channel = AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
679 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
680 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, I2S0, SHA]),
681 ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1,
682 compatible = [SPI2, I2S0, SHA])));
683 _for_each_inner_dma_channel!((no_own_interrupt));
684 };
685}
686#[macro_export]
687#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
688macro_rules! for_each_dma_channel_peri_pair {
689 ($($pattern:tt => $code:tt;)*) => {
690 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
691 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
692 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
693 I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
694 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
695 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
696 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
697 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
698 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
699 AhbGdmaChannel, I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
700 any_channel = AhbGdmaChannel, SHA));
701 _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0, SPI2),
702 ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH1,
703 SPI2), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, SHA)));
704 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
705 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0),
706 ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA)));
707 };
708}
709#[macro_export]
710#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
711macro_rules! for_each_mem2mem_channel {
712 ($($pattern:tt => $code:tt;)*) => {
713 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
714 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
715 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
716 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
717 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0, 4, 1,
718 5)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel));
719 _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma, AhbGdmaChannel,
720 DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5)));
721 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
722 4, 1, 5))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
723 AhbGdmaChannel)));
724 };
725}
726#[macro_export]
727#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
728macro_rules! with_i2s_dma_engine {
729 ($($pattern:tt => $code:tt;)*) => {
730 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
731 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
732 };
733}
734#[macro_export]
735#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
736macro_rules! with_sha_dma_engine {
737 ($($pattern:tt => $code:tt;)*) => {
738 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
739 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
740 };
741}
742#[macro_export]
743#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
744macro_rules! with_spi_master_dma_engine {
745 ($($pattern:tt => $code:tt;)*) => {
746 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
747 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
748 };
749}
750#[macro_export]
751#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
752macro_rules! with_spi_slave_dma_engine {
753 ($($pattern:tt => $code:tt;)*) => {
754 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
755 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
756 };
757}
758#[macro_export]
759#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
760macro_rules! for_each_interrupt {
761 ($($pattern:tt => $code:tt;)*) => {
762 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
763 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
764 _for_each_inner_interrupt!(([reserved 0] 1));
765 _for_each_inner_interrupt!(([reserved 1] 2));
766 _for_each_inner_interrupt!(([reserved 2] 3));
767 _for_each_inner_interrupt!(([reserved 3] 4));
768 _for_each_inner_interrupt!(([reserved 4] 5));
769 _for_each_inner_interrupt!(([reserved 5] 6));
770 _for_each_inner_interrupt!(([reserved 6] 7));
771 _for_each_inner_interrupt!(([reserved 7] 8));
772 _for_each_inner_interrupt!(([reserved 8] 9));
773 _for_each_inner_interrupt!(([reserved 9] 10));
774 _for_each_inner_interrupt!(([reserved 10] 11));
775 _for_each_inner_interrupt!(([reserved 11] 12));
776 _for_each_inner_interrupt!(([reserved 12] 13));
777 _for_each_inner_interrupt!(([reserved 13] 14));
778 _for_each_inner_interrupt!(([reserved 14] 15));
779 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
780 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
781 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
782 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
783 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
784 7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
785 _for_each_inner_interrupt!(([direct_bindable 1] 25));
786 _for_each_inner_interrupt!(([direct_bindable 2] 26));
787 _for_each_inner_interrupt!(([direct_bindable 3] 27));
788 _for_each_inner_interrupt!(([direct_bindable 4] 28));
789 _for_each_inner_interrupt!(([direct_bindable 5] 29));
790 _for_each_inner_interrupt!(([direct_bindable 6] 30));
791 _for_each_inner_interrupt!(([direct_bindable 7] 31));
792 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
793 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
794 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
795 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
796 ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
797 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
798 ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
799 ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
800 ([direct_bindable 6] 30), ([direct_bindable 7] 31)));
801 };
802}
803#[macro_export]
804#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
805macro_rules! for_each_classified_interrupt {
806 ($($pattern:tt => $code:tt;)*) => {
807 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
808 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
809 24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
810 _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
811 _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
812 _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
813 _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
814 _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
815 _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
816 _for_each_inner_classified_interrupt!(([vector 0] 16));
817 _for_each_inner_classified_interrupt!(([vector 1] 17));
818 _for_each_inner_classified_interrupt!(([vector 2] 18));
819 _for_each_inner_classified_interrupt!(([vector 3] 19));
820 _for_each_inner_classified_interrupt!(([vector 4] 20));
821 _for_each_inner_classified_interrupt!(([vector 5] 21));
822 _for_each_inner_classified_interrupt!(([vector 6] 22));
823 _for_each_inner_classified_interrupt!(([vector 7] 23));
824 _for_each_inner_classified_interrupt!(([reserved 0] 1));
825 _for_each_inner_classified_interrupt!(([reserved 1] 2));
826 _for_each_inner_classified_interrupt!(([reserved 2] 3));
827 _for_each_inner_classified_interrupt!(([reserved 3] 4));
828 _for_each_inner_classified_interrupt!(([reserved 4] 5));
829 _for_each_inner_classified_interrupt!(([reserved 5] 6));
830 _for_each_inner_classified_interrupt!(([reserved 6] 7));
831 _for_each_inner_classified_interrupt!(([reserved 7] 8));
832 _for_each_inner_classified_interrupt!(([reserved 8] 9));
833 _for_each_inner_classified_interrupt!(([reserved 9] 10));
834 _for_each_inner_classified_interrupt!(([reserved 10] 11));
835 _for_each_inner_classified_interrupt!(([reserved 11] 12));
836 _for_each_inner_classified_interrupt!(([reserved 12] 13));
837 _for_each_inner_classified_interrupt!(([reserved 13] 14));
838 _for_each_inner_classified_interrupt!(([reserved 14] 15));
839 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
840 ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
841 ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
842 ([direct_bindable 7] 31))); _for_each_inner_classified_interrupt!((vector([vector
843 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector 3] 19), ([vector 4] 20),
844 ([vector 5] 21), ([vector 6] 22), ([vector 7] 23)));
845 _for_each_inner_classified_interrupt!((reserved([reserved 0] 1), ([reserved 1]
846 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
847 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
848 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
849 ([reserved 14] 15))); _for_each_inner_classified_interrupt!((context_switch));
850 };
851}
852#[macro_export]
853#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
854macro_rules! for_each_interrupt_priority {
855 ($($pattern:tt => $code:tt;)*) => {
856 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
857 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
858 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
859 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
860 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
861 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
862 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
863 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
864 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
865 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
866 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
867 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
868 Priority8, Level8)));
869 };
870}
871#[macro_export]
872#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
873macro_rules! for_each_sw_interrupt {
874 ($($pattern:tt => $code:tt;)*) => {
875 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
876 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
877 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
878 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
879 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
880 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
881 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
882 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
883 };
884}
885#[macro_export]
886macro_rules! define_clock_tree_types {
1237 () => {
1238 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1239 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1240 pub enum I2cInstance {
1241 I2c0 = 0,
1242 }
1243 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1244 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1245 pub enum I2sInstance {
1246 I2s0 = 0,
1247 }
1248 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1249 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1250 pub enum SpiInstance {
1251 Spi2 = 0,
1252 }
1253 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1254 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1255 pub enum TimgInstance {
1256 Timg0 = 0,
1257 Timg1 = 1,
1258 }
1259 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1260 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1261 pub enum UartInstance {
1262 Uart0 = 0,
1263 Uart1 = 1,
1264 Uart2 = 2,
1265 }
1266 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1268 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1269 pub enum XtalClkConfig {
1270 _40,
1272 }
1273 impl XtalClkConfig {
1274 pub fn value(&self) -> u32 {
1275 match self {
1276 XtalClkConfig::_40 => 40000000,
1277 }
1278 }
1279 }
1280 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1282 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1283 pub enum HpRootClkConfig {
1284 Xtal,
1286 RcFast,
1288 PllF160m,
1290 }
1291 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1295 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1296 pub struct CpuClkConfig {
1297 divisor: u32,
1298 }
1299 impl CpuClkConfig {
1300 pub const fn new(divisor: u32) -> Self {
1307 ::core::assert!(
1308 divisor <= 255,
1309 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1310 );
1311 Self { divisor }
1312 }
1313 pub(crate) fn divisor(self) -> u32 {
1314 self.divisor as u32
1315 }
1316 }
1317 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1321 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1322 pub struct AhbClkConfig {
1323 divisor: u32,
1324 }
1325 impl AhbClkConfig {
1326 pub const fn new(divisor: u32) -> Self {
1333 ::core::assert!(
1334 divisor <= 255,
1335 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1336 );
1337 Self { divisor }
1338 }
1339 pub(crate) fn divisor(self) -> u32 {
1340 self.divisor as u32
1341 }
1342 }
1343 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1347 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1348 pub struct ApbClkConfig {
1349 divisor: u32,
1350 }
1351 impl ApbClkConfig {
1352 pub const fn new(divisor: u32) -> Self {
1359 ::core::assert!(
1360 divisor <= 255,
1361 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1362 );
1363 Self { divisor }
1364 }
1365 pub(crate) fn divisor(self) -> u32 {
1366 self.divisor as u32
1367 }
1368 }
1369 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1371 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1372 pub enum LpFastClkConfig {
1373 RcFast,
1375 XtalD2,
1377 Xtal,
1379 }
1380 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1382 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1383 pub enum LpSlowClkConfig {
1384 RcSlow,
1386 #[cfg(use_xtal32k)]
1387 Xtal32k,
1389 OscSlow,
1391 }
1392 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1394 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1395 pub enum CryptoClkConfig {
1396 Xtal,
1398 RcFast,
1400 PllF480m,
1402 }
1403 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1405 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1406 pub enum TimgCalibrationClockConfig {
1407 OscSlowClk,
1409 RcSlowClk,
1411 RcFastDivClk,
1413 #[cfg(use_xtal32k)]
1414 Xtal32kClk,
1416 }
1417 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1418 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1419 pub enum I2cFunctionClockSclk {
1420 #[default]
1421 Xtal,
1423 RcFast,
1425 }
1426 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1430 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1431 pub struct I2cFunctionClockConfig {
1432 sclk: I2cFunctionClockSclk,
1433 div_num: u32,
1434 }
1435 impl I2cFunctionClockConfig {
1436 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1443 ::core::assert!(
1444 div_num <= 255,
1445 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1446 );
1447 Self { sclk, div_num }
1448 }
1449 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1450 self.sclk
1451 }
1452 pub(crate) fn div_num(self) -> u32 {
1453 self.div_num as u32
1454 }
1455 }
1456 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1457 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1458 pub enum I2sClkSclk {
1459 Xtal,
1461 PllF120m,
1463 #[default]
1464 PllF160m,
1466 }
1467 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1471 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1472 pub struct I2sClkConfig {
1473 sclk: I2sClkSclk,
1474 div_num: u32,
1475 div_a: u32,
1476 div_b: u32,
1477 }
1478 impl I2sClkConfig {
1479 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
1492 ::core::assert!(
1493 div_num >= 1 && div_num <= 255,
1494 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
1495 );
1496 ::core::assert!(
1497 div_a >= 1 && div_a <= 511,
1498 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
1499 );
1500 ::core::assert!(
1501 div_b <= 511,
1502 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
1503 );
1504 Self {
1505 sclk,
1506 div_num,
1507 div_a,
1508 div_b,
1509 }
1510 }
1511 pub(crate) fn sclk(self) -> I2sClkSclk {
1512 self.sclk
1513 }
1514 pub(crate) fn div_num(self) -> u32 {
1515 self.div_num as u32
1516 }
1517 pub(crate) fn div_a(self) -> u32 {
1518 self.div_a as u32
1519 }
1520 pub(crate) fn div_b(self) -> u32 {
1521 self.div_b as u32
1522 }
1523 }
1524 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1526 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1527 pub enum I2sMclkOutConfig {
1528 Tx,
1530 #[default]
1531 Rx,
1533 }
1534 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1536 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1537 pub enum SpiFunctionClockConfig {
1538 Xtal,
1540 #[default]
1541 PllF160m,
1543 RcFast,
1545 }
1546 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1548 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1549 pub enum TimgFunctionClockConfig {
1550 #[default]
1551 XtalClk,
1553 RcFastClk,
1555 PllF80m,
1557 }
1558 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1560 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1561 pub enum TimgWdtClockConfig {
1562 #[default]
1563 XtalClk,
1565 RcFastClk,
1567 PllF80m,
1569 }
1570 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1571 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1572 pub enum UartFunctionClockSclk {
1573 #[default]
1574 Xtal,
1576 PllF80m,
1578 RcFast,
1580 }
1581 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1585 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1586 pub struct UartFunctionClockConfig {
1587 sclk: UartFunctionClockSclk,
1588 div_num: u32,
1589 }
1590 impl UartFunctionClockConfig {
1591 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1598 ::core::assert!(
1599 div_num <= 255,
1600 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1601 );
1602 Self { sclk, div_num }
1603 }
1604 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
1605 self.sclk
1606 }
1607 pub(crate) fn div_num(self) -> u32 {
1608 self.div_num as u32
1609 }
1610 }
1611 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1616 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1617 pub struct UartBaudRateGeneratorConfig {
1618 fractional: u32,
1619 integral: u32,
1620 }
1621 impl UartBaudRateGeneratorConfig {
1622 pub const fn new(fractional: u32, integral: u32) -> Self {
1632 ::core::assert!(
1633 fractional <= 15,
1634 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1635 );
1636 ::core::assert!(
1637 integral <= 4095,
1638 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1639 );
1640 Self {
1641 fractional,
1642 integral,
1643 }
1644 }
1645 pub(crate) fn fractional(self) -> u32 {
1646 self.fractional as u32
1647 }
1648 pub(crate) fn integral(self) -> u32 {
1649 self.integral as u32
1650 }
1651 }
1652 pub struct ClockTree {
1654 xtal_clk: Option<XtalClkConfig>,
1655 hp_root_clk: Option<HpRootClkConfig>,
1656 cpu_clk: Option<CpuClkConfig>,
1657 ahb_clk: Option<AhbClkConfig>,
1658 apb_clk: Option<ApbClkConfig>,
1659 lp_fast_clk: Option<LpFastClkConfig>,
1660 lp_slow_clk: Option<LpSlowClkConfig>,
1661 crypto_clk: Option<CryptoClkConfig>,
1662 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1663 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
1664 i2s_tx_clk: [Option<I2sClkConfig>; 1],
1665 i2s_rx_clk: [Option<I2sClkConfig>; 1],
1666 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
1667 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
1668 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1669 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1670 uart_function_clock: [Option<UartFunctionClockConfig>; 3],
1671 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 3],
1672 rc_fast_clk_refcount: u32,
1673 pll_clk_refcount: u32,
1674 #[cfg(use_xtal32k)]
1675 xtal32k_clk_refcount: u32,
1676 osc_slow_clk_refcount: u32,
1677 rc_slow_clk_refcount: u32,
1678 pll_f20m_refcount: u32,
1679 pll_f40m_refcount: u32,
1680 pll_f48m_refcount: u32,
1681 pll_f60m_refcount: u32,
1682 pll_f80m_refcount: u32,
1683 pll_f120m_refcount: u32,
1684 pll_f160m_refcount: u32,
1685 hp_root_clk_refcount: u32,
1686 cpu_clk_refcount: u32,
1687 apb_clk_refcount: u32,
1688 lp_fast_clk_refcount: u32,
1689 lp_slow_clk_refcount: u32,
1690 crypto_clk_refcount: u32,
1691 timg_calibration_clock_refcount: u32,
1692 i2c_function_clock_refcount: [u32; 1],
1693 i2s_tx_clk_refcount: [u32; 1],
1694 i2s_rx_clk_refcount: [u32; 1],
1695 i2s_mclk_out_refcount: [u32; 1],
1696 spi_function_clock_refcount: [u32; 1],
1697 timg_function_clock_refcount: [u32; 2],
1698 timg_wdt_clock_refcount: [u32; 2],
1699 uart_function_clock_refcount: [u32; 3],
1700 uart_baud_rate_generator_refcount: [u32; 3],
1701 }
1702 impl ClockTree {
1703 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1705 CLOCK_TREE.with(f)
1706 }
1707 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1709 self.xtal_clk
1710 }
1711 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
1713 self.hp_root_clk
1714 }
1715 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1717 self.cpu_clk
1718 }
1719 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
1721 self.ahb_clk
1722 }
1723 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1725 self.apb_clk
1726 }
1727 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
1729 self.lp_fast_clk
1730 }
1731 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
1733 self.lp_slow_clk
1734 }
1735 pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
1737 self.crypto_clk
1738 }
1739 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1741 self.timg_calibration_clock
1742 }
1743 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1745 self.i2c_function_clock[I2cInstance::I2c0 as usize]
1746 }
1747 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
1749 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
1750 }
1751 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
1753 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
1754 }
1755 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
1757 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
1758 }
1759 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
1761 self.spi_function_clock[SpiInstance::Spi2 as usize]
1762 }
1763 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1765 self.timg_function_clock[TimgInstance::Timg0 as usize]
1766 }
1767 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1769 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
1770 }
1771 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1773 self.timg_function_clock[TimgInstance::Timg1 as usize]
1774 }
1775 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1777 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
1778 }
1779 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1781 self.uart_function_clock[UartInstance::Uart0 as usize]
1782 }
1783 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1785 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1786 }
1787 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1789 self.uart_function_clock[UartInstance::Uart1 as usize]
1790 }
1791 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1793 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
1794 }
1795 pub fn uart2_function_clock(&self) -> Option<UartFunctionClockConfig> {
1797 self.uart_function_clock[UartInstance::Uart2 as usize]
1798 }
1799 pub fn uart2_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1801 self.uart_baud_rate_generator[UartInstance::Uart2 as usize]
1802 }
1803 }
1804 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
1805 ::esp_sync::NonReentrantMutex::new(ClockTree {
1806 xtal_clk: None,
1807 hp_root_clk: None,
1808 cpu_clk: None,
1809 ahb_clk: None,
1810 apb_clk: None,
1811 lp_fast_clk: None,
1812 lp_slow_clk: None,
1813 crypto_clk: None,
1814 timg_calibration_clock: None,
1815 i2c_function_clock: [None; 1],
1816 i2s_tx_clk: [None; 1],
1817 i2s_rx_clk: [None; 1],
1818 i2s_mclk_out: [None; 1],
1819 spi_function_clock: [None; 1],
1820 timg_function_clock: [None; 2],
1821 timg_wdt_clock: [None; 2],
1822 uart_function_clock: [None; 3],
1823 uart_baud_rate_generator: [None; 3],
1824 rc_fast_clk_refcount: 0,
1825 pll_clk_refcount: 0,
1826 #[cfg(use_xtal32k)]
1827 xtal32k_clk_refcount: 0,
1828 osc_slow_clk_refcount: 0,
1829 rc_slow_clk_refcount: 0,
1830 pll_f20m_refcount: 0,
1831 pll_f40m_refcount: 0,
1832 pll_f48m_refcount: 0,
1833 pll_f60m_refcount: 0,
1834 pll_f80m_refcount: 0,
1835 pll_f120m_refcount: 0,
1836 pll_f160m_refcount: 0,
1837 hp_root_clk_refcount: 0,
1838 cpu_clk_refcount: 0,
1839 apb_clk_refcount: 0,
1840 lp_fast_clk_refcount: 0,
1841 lp_slow_clk_refcount: 0,
1842 crypto_clk_refcount: 0,
1843 timg_calibration_clock_refcount: 0,
1844 i2c_function_clock_refcount: [0; 1],
1845 i2s_tx_clk_refcount: [0; 1],
1846 i2s_rx_clk_refcount: [0; 1],
1847 i2s_mclk_out_refcount: [0; 1],
1848 spi_function_clock_refcount: [0; 1],
1849 timg_function_clock_refcount: [0; 2],
1850 timg_wdt_clock_refcount: [0; 2],
1851 uart_function_clock_refcount: [0; 3],
1852 uart_baud_rate_generator_refcount: [0; 3],
1853 });
1854 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1855 ::core::sync::atomic::AtomicU32::new(0);
1856 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1857 ::core::sync::atomic::AtomicU32::new(0);
1858 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1859 ::core::sync::atomic::AtomicU32::new(0);
1860 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1861 ::core::sync::atomic::AtomicU32::new(0);
1862 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1863 ::core::sync::atomic::AtomicU32::new(0);
1864 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1865 ::core::sync::atomic::AtomicU32::new(0);
1866 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1867 ::core::sync::atomic::AtomicU32::new(0);
1868 static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1869 ::core::sync::atomic::AtomicU32::new(0);
1870 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1871 ::core::sync::atomic::AtomicU32::new(0);
1872 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1873 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1874 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1875 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1876 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1877 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1878 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1879 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1880 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1881 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1882 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
1883 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
1884 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
1885 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
1886 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
1887 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
1888 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
1889 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
1890 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
1891 let old_config = clocks.xtal_clk.replace(config);
1892 refresh_xtal_clk_downstream(clocks);
1893 configure_xtal_clk_impl(clocks, old_config, config);
1894 }
1895 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
1896 clocks.xtal_clk
1897 }
1898 fn request_xtal_clk(_clocks: &mut ClockTree) {}
1899 fn release_xtal_clk(_clocks: &mut ClockTree) {}
1900 #[allow(unused_variables)]
1901 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
1902 config.value()
1903 }
1904 pub fn xtal_clk_frequency() -> u32 {
1905 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
1906 }
1907 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
1908 trace!("Requesting RC_FAST_CLK");
1909 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
1910 trace!("Enabling RC_FAST_CLK");
1911 enable_rc_fast_clk_impl(clocks, true);
1912 }
1913 }
1914 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
1915 trace!("Releasing RC_FAST_CLK");
1916 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
1917 trace!("Disabling RC_FAST_CLK");
1918 enable_rc_fast_clk_impl(clocks, false);
1919 }
1920 }
1921 pub fn rc_fast_clk_frequency() -> u32 {
1922 17500000
1923 }
1924 pub fn request_pll_clk(clocks: &mut ClockTree) {
1925 trace!("Requesting PLL_CLK");
1926 if increment_reference_count(&mut clocks.pll_clk_refcount) {
1927 trace!("Enabling PLL_CLK");
1928 request_xtal_clk(clocks);
1929 enable_pll_clk_impl(clocks, true);
1930 }
1931 }
1932 pub fn release_pll_clk(clocks: &mut ClockTree) {
1933 trace!("Releasing PLL_CLK");
1934 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
1935 trace!("Disabling PLL_CLK");
1936 enable_pll_clk_impl(clocks, false);
1937 release_xtal_clk(clocks);
1938 }
1939 }
1940 pub fn pll_clk_frequency() -> u32 {
1941 480000000
1942 }
1943 pub fn pll_clk_source_frequency() -> u32 {
1944 xtal_clk_frequency()
1945 }
1946 #[cfg(use_xtal32k)]
1947 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
1948 trace!("Requesting XTAL32K_CLK");
1949 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
1950 trace!("Enabling XTAL32K_CLK");
1951 enable_xtal32k_clk_impl(clocks, true);
1952 }
1953 }
1954 #[cfg(use_xtal32k)]
1955 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
1956 trace!("Releasing XTAL32K_CLK");
1957 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
1958 trace!("Disabling XTAL32K_CLK");
1959 enable_xtal32k_clk_impl(clocks, false);
1960 }
1961 }
1962 #[cfg(use_xtal32k)]
1963 pub fn xtal32k_clk_frequency() -> u32 {
1964 32768
1965 }
1966 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
1967 trace!("Requesting OSC_SLOW_CLK");
1968 if increment_reference_count(&mut clocks.osc_slow_clk_refcount) {
1969 trace!("Enabling OSC_SLOW_CLK");
1970 enable_osc_slow_clk_impl(clocks, true);
1971 }
1972 }
1973 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
1974 trace!("Releasing OSC_SLOW_CLK");
1975 if decrement_reference_count(&mut clocks.osc_slow_clk_refcount) {
1976 trace!("Disabling OSC_SLOW_CLK");
1977 enable_osc_slow_clk_impl(clocks, false);
1978 }
1979 }
1980 pub fn osc_slow_clk_frequency() -> u32 {
1981 32768
1982 }
1983 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
1984 trace!("Requesting RC_SLOW_CLK");
1985 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
1986 trace!("Enabling RC_SLOW_CLK");
1987 enable_rc_slow_clk_impl(clocks, true);
1988 }
1989 }
1990 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
1991 trace!("Releasing RC_SLOW_CLK");
1992 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
1993 trace!("Disabling RC_SLOW_CLK");
1994 enable_rc_slow_clk_impl(clocks, false);
1995 }
1996 }
1997 pub fn rc_slow_clk_frequency() -> u32 {
1998 136000
1999 }
2000 pub fn request_pll_f20m(clocks: &mut ClockTree) {
2001 trace!("Requesting PLL_F20M");
2002 if increment_reference_count(&mut clocks.pll_f20m_refcount) {
2003 trace!("Enabling PLL_F20M");
2004 request_pll_clk(clocks);
2005 enable_pll_f20m_impl(clocks, true);
2006 }
2007 }
2008 pub fn release_pll_f20m(clocks: &mut ClockTree) {
2009 trace!("Releasing PLL_F20M");
2010 if decrement_reference_count(&mut clocks.pll_f20m_refcount) {
2011 trace!("Disabling PLL_F20M");
2012 enable_pll_f20m_impl(clocks, false);
2013 release_pll_clk(clocks);
2014 }
2015 }
2016 pub fn pll_f20m_frequency() -> u32 {
2017 (pll_clk_frequency() / 24)
2018 }
2019 pub fn pll_f20m_source_frequency() -> u32 {
2020 pll_clk_frequency()
2021 }
2022 pub fn request_pll_f40m(clocks: &mut ClockTree) {
2023 trace!("Requesting PLL_F40M");
2024 if increment_reference_count(&mut clocks.pll_f40m_refcount) {
2025 trace!("Enabling PLL_F40M");
2026 request_pll_clk(clocks);
2027 enable_pll_f40m_impl(clocks, true);
2028 }
2029 }
2030 pub fn release_pll_f40m(clocks: &mut ClockTree) {
2031 trace!("Releasing PLL_F40M");
2032 if decrement_reference_count(&mut clocks.pll_f40m_refcount) {
2033 trace!("Disabling PLL_F40M");
2034 enable_pll_f40m_impl(clocks, false);
2035 release_pll_clk(clocks);
2036 }
2037 }
2038 pub fn pll_f40m_frequency() -> u32 {
2039 (pll_clk_frequency() / 12)
2040 }
2041 pub fn pll_f40m_source_frequency() -> u32 {
2042 pll_clk_frequency()
2043 }
2044 pub fn request_pll_f48m(clocks: &mut ClockTree) {
2045 trace!("Requesting PLL_F48M");
2046 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
2047 trace!("Enabling PLL_F48M");
2048 request_pll_clk(clocks);
2049 enable_pll_f48m_impl(clocks, true);
2050 }
2051 }
2052 pub fn release_pll_f48m(clocks: &mut ClockTree) {
2053 trace!("Releasing PLL_F48M");
2054 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
2055 trace!("Disabling PLL_F48M");
2056 enable_pll_f48m_impl(clocks, false);
2057 release_pll_clk(clocks);
2058 }
2059 }
2060 pub fn pll_f48m_frequency() -> u32 {
2061 (pll_clk_frequency() / 10)
2062 }
2063 pub fn pll_f48m_source_frequency() -> u32 {
2064 pll_clk_frequency()
2065 }
2066 pub fn request_pll_f60m(clocks: &mut ClockTree) {
2067 trace!("Requesting PLL_F60M");
2068 if increment_reference_count(&mut clocks.pll_f60m_refcount) {
2069 trace!("Enabling PLL_F60M");
2070 request_pll_clk(clocks);
2071 enable_pll_f60m_impl(clocks, true);
2072 }
2073 }
2074 pub fn release_pll_f60m(clocks: &mut ClockTree) {
2075 trace!("Releasing PLL_F60M");
2076 if decrement_reference_count(&mut clocks.pll_f60m_refcount) {
2077 trace!("Disabling PLL_F60M");
2078 enable_pll_f60m_impl(clocks, false);
2079 release_pll_clk(clocks);
2080 }
2081 }
2082 pub fn pll_f60m_frequency() -> u32 {
2083 (pll_clk_frequency() / 8)
2084 }
2085 pub fn pll_f60m_source_frequency() -> u32 {
2086 pll_clk_frequency()
2087 }
2088 pub fn request_pll_f80m(clocks: &mut ClockTree) {
2089 trace!("Requesting PLL_F80M");
2090 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
2091 trace!("Enabling PLL_F80M");
2092 request_pll_clk(clocks);
2093 enable_pll_f80m_impl(clocks, true);
2094 }
2095 }
2096 pub fn release_pll_f80m(clocks: &mut ClockTree) {
2097 trace!("Releasing PLL_F80M");
2098 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
2099 trace!("Disabling PLL_F80M");
2100 enable_pll_f80m_impl(clocks, false);
2101 release_pll_clk(clocks);
2102 }
2103 }
2104 pub fn pll_f80m_frequency() -> u32 {
2105 (pll_clk_frequency() / 6)
2106 }
2107 pub fn pll_f80m_source_frequency() -> u32 {
2108 pll_clk_frequency()
2109 }
2110 pub fn request_pll_f120m(clocks: &mut ClockTree) {
2111 trace!("Requesting PLL_F120M");
2112 if increment_reference_count(&mut clocks.pll_f120m_refcount) {
2113 trace!("Enabling PLL_F120M");
2114 request_pll_clk(clocks);
2115 enable_pll_f120m_impl(clocks, true);
2116 }
2117 }
2118 pub fn release_pll_f120m(clocks: &mut ClockTree) {
2119 trace!("Releasing PLL_F120M");
2120 if decrement_reference_count(&mut clocks.pll_f120m_refcount) {
2121 trace!("Disabling PLL_F120M");
2122 enable_pll_f120m_impl(clocks, false);
2123 release_pll_clk(clocks);
2124 }
2125 }
2126 pub fn pll_f120m_frequency() -> u32 {
2127 (pll_clk_frequency() / 4)
2128 }
2129 pub fn pll_f120m_source_frequency() -> u32 {
2130 pll_clk_frequency()
2131 }
2132 pub fn request_pll_f160m(clocks: &mut ClockTree) {
2133 trace!("Requesting PLL_F160M");
2134 if increment_reference_count(&mut clocks.pll_f160m_refcount) {
2135 trace!("Enabling PLL_F160M");
2136 request_pll_clk(clocks);
2137 enable_pll_f160m_impl(clocks, true);
2138 }
2139 }
2140 pub fn release_pll_f160m(clocks: &mut ClockTree) {
2141 trace!("Releasing PLL_F160M");
2142 if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
2143 trace!("Disabling PLL_F160M");
2144 enable_pll_f160m_impl(clocks, false);
2145 release_pll_clk(clocks);
2146 }
2147 }
2148 pub fn pll_f160m_frequency() -> u32 {
2149 (pll_clk_frequency() / 3)
2150 }
2151 pub fn pll_f160m_source_frequency() -> u32 {
2152 pll_clk_frequency()
2153 }
2154 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
2155 let old_selector = clocks.hp_root_clk.replace(new_selector);
2156 refresh_hp_root_clk_downstream(clocks);
2157 if clocks.hp_root_clk_refcount > 0 {
2158 match new_selector {
2159 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2160 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2161 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
2162 }
2163 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2164 if let Some(old_selector) = old_selector {
2165 match old_selector {
2166 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2167 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2168 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
2169 }
2170 }
2171 } else {
2172 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2173 }
2174 }
2175 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
2176 clocks.hp_root_clk
2177 }
2178 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
2179 trace!("Requesting HP_ROOT_CLK");
2180 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
2181 trace!("Enabling HP_ROOT_CLK");
2182 match unwrap!(clocks.hp_root_clk) {
2183 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2184 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2185 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
2186 }
2187 enable_hp_root_clk_impl(clocks, true);
2188 }
2189 }
2190 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
2191 trace!("Releasing HP_ROOT_CLK");
2192 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
2193 trace!("Disabling HP_ROOT_CLK");
2194 enable_hp_root_clk_impl(clocks, false);
2195 match unwrap!(clocks.hp_root_clk) {
2196 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2197 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2198 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
2199 }
2200 }
2201 }
2202 #[allow(unused_variables)]
2203 pub fn hp_root_clk_config_frequency(
2204 clocks: &mut ClockTree,
2205 config: HpRootClkConfig,
2206 ) -> u32 {
2207 match config {
2208 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2209 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2210 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
2211 }
2212 }
2213 pub fn hp_root_clk_frequency() -> u32 {
2214 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2215 }
2216 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
2217 match source {
2218 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2219 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2220 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
2221 }
2222 }
2223 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
2224 let old_config = clocks.cpu_clk.replace(config);
2225 refresh_cpu_clk_downstream(clocks);
2226 configure_cpu_clk_impl(clocks, old_config, config);
2227 }
2228 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2229 clocks.cpu_clk
2230 }
2231 pub fn request_cpu_clk(clocks: &mut ClockTree) {
2232 trace!("Requesting CPU_CLK");
2233 if increment_reference_count(&mut clocks.cpu_clk_refcount) {
2234 trace!("Enabling CPU_CLK");
2235 request_hp_root_clk(clocks);
2236 enable_cpu_clk_impl(clocks, true);
2237 }
2238 }
2239 pub fn release_cpu_clk(clocks: &mut ClockTree) {
2240 trace!("Releasing CPU_CLK");
2241 if decrement_reference_count(&mut clocks.cpu_clk_refcount) {
2242 trace!("Disabling CPU_CLK");
2243 enable_cpu_clk_impl(clocks, false);
2244 release_hp_root_clk(clocks);
2245 }
2246 }
2247 #[allow(unused_variables)]
2248 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2249 (hp_root_clk_frequency() / (config.divisor() + 1))
2250 }
2251 pub fn cpu_clk_frequency() -> u32 {
2252 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2253 }
2254 pub fn cpu_clk_source_frequency() -> u32 {
2255 hp_root_clk_frequency()
2256 }
2257 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
2258 let old_config = clocks.ahb_clk.replace(config);
2259 refresh_ahb_clk_downstream(clocks);
2260 configure_ahb_clk_impl(clocks, old_config, config);
2261 }
2262 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
2263 clocks.ahb_clk
2264 }
2265 pub fn request_ahb_clk(clocks: &mut ClockTree) {
2266 trace!("Requesting AHB_CLK");
2267 trace!("Enabling AHB_CLK");
2268 request_hp_root_clk(clocks);
2269 enable_ahb_clk_impl(clocks, true);
2270 }
2271 pub fn release_ahb_clk(clocks: &mut ClockTree) {
2272 trace!("Releasing AHB_CLK");
2273 trace!("Disabling AHB_CLK");
2274 enable_ahb_clk_impl(clocks, false);
2275 release_hp_root_clk(clocks);
2276 }
2277 #[allow(unused_variables)]
2278 pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
2279 (hp_root_clk_frequency() / (config.divisor() + 1))
2280 }
2281 pub fn ahb_clk_frequency() -> u32 {
2282 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2283 }
2284 pub fn ahb_clk_source_frequency() -> u32 {
2285 hp_root_clk_frequency()
2286 }
2287 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
2288 let old_config = clocks.apb_clk.replace(config);
2289 refresh_apb_clk_downstream(clocks);
2290 configure_apb_clk_impl(clocks, old_config, config);
2291 }
2292 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2293 clocks.apb_clk
2294 }
2295 pub fn request_apb_clk(clocks: &mut ClockTree) {
2296 trace!("Requesting APB_CLK");
2297 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2298 trace!("Enabling APB_CLK");
2299 request_ahb_clk(clocks);
2300 enable_apb_clk_impl(clocks, true);
2301 }
2302 }
2303 pub fn release_apb_clk(clocks: &mut ClockTree) {
2304 trace!("Releasing APB_CLK");
2305 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2306 trace!("Disabling APB_CLK");
2307 enable_apb_clk_impl(clocks, false);
2308 release_ahb_clk(clocks);
2309 }
2310 }
2311 #[allow(unused_variables)]
2312 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2313 (ahb_clk_frequency() / (config.divisor() + 1))
2314 }
2315 pub fn apb_clk_frequency() -> u32 {
2316 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2317 }
2318 pub fn apb_clk_source_frequency() -> u32 {
2319 ahb_clk_frequency()
2320 }
2321 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
2322 trace!("Requesting XTAL_D2_CLK");
2323 trace!("Enabling XTAL_D2_CLK");
2324 request_xtal_clk(clocks);
2325 enable_xtal_d2_clk_impl(clocks, true);
2326 }
2327 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
2328 trace!("Releasing XTAL_D2_CLK");
2329 trace!("Disabling XTAL_D2_CLK");
2330 enable_xtal_d2_clk_impl(clocks, false);
2331 release_xtal_clk(clocks);
2332 }
2333 pub fn xtal_d2_clk_frequency() -> u32 {
2334 (xtal_clk_frequency() / 2)
2335 }
2336 pub fn xtal_d2_clk_source_frequency() -> u32 {
2337 xtal_clk_frequency()
2338 }
2339 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
2340 let old_selector = clocks.lp_fast_clk.replace(new_selector);
2341 refresh_lp_fast_clk_downstream(clocks);
2342 if clocks.lp_fast_clk_refcount > 0 {
2343 match new_selector {
2344 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2345 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2346 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2347 }
2348 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2349 if let Some(old_selector) = old_selector {
2350 match old_selector {
2351 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2352 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2353 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2354 }
2355 }
2356 } else {
2357 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2358 }
2359 }
2360 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
2361 clocks.lp_fast_clk
2362 }
2363 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
2364 trace!("Requesting LP_FAST_CLK");
2365 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
2366 trace!("Enabling LP_FAST_CLK");
2367 match unwrap!(clocks.lp_fast_clk) {
2368 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2369 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2370 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2371 }
2372 enable_lp_fast_clk_impl(clocks, true);
2373 }
2374 }
2375 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
2376 trace!("Releasing LP_FAST_CLK");
2377 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
2378 trace!("Disabling LP_FAST_CLK");
2379 enable_lp_fast_clk_impl(clocks, false);
2380 match unwrap!(clocks.lp_fast_clk) {
2381 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2382 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2383 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2384 }
2385 }
2386 }
2387 #[allow(unused_variables)]
2388 pub fn lp_fast_clk_config_frequency(
2389 clocks: &mut ClockTree,
2390 config: LpFastClkConfig,
2391 ) -> u32 {
2392 match config {
2393 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2394 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2395 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2396 }
2397 }
2398 pub fn lp_fast_clk_frequency() -> u32 {
2399 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2400 }
2401 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
2402 match source {
2403 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2404 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2405 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2406 }
2407 }
2408 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
2409 let old_selector = clocks.lp_slow_clk.replace(new_selector);
2410 refresh_lp_slow_clk_downstream(clocks);
2411 if clocks.lp_slow_clk_refcount > 0 {
2412 match new_selector {
2413 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2414 #[cfg(use_xtal32k)]
2415 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2416 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2417 }
2418 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2419 if let Some(old_selector) = old_selector {
2420 match old_selector {
2421 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2422 #[cfg(use_xtal32k)]
2423 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2424 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2425 }
2426 }
2427 } else {
2428 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2429 }
2430 }
2431 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
2432 clocks.lp_slow_clk
2433 }
2434 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
2435 trace!("Requesting LP_SLOW_CLK");
2436 if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
2437 trace!("Enabling LP_SLOW_CLK");
2438 match unwrap!(clocks.lp_slow_clk) {
2439 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2440 #[cfg(use_xtal32k)]
2441 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2442 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2443 }
2444 enable_lp_slow_clk_impl(clocks, true);
2445 }
2446 }
2447 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2448 trace!("Releasing LP_SLOW_CLK");
2449 if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
2450 trace!("Disabling LP_SLOW_CLK");
2451 enable_lp_slow_clk_impl(clocks, false);
2452 match unwrap!(clocks.lp_slow_clk) {
2453 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2454 #[cfg(use_xtal32k)]
2455 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2456 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2457 }
2458 }
2459 }
2460 #[allow(unused_variables)]
2461 pub fn lp_slow_clk_config_frequency(
2462 clocks: &mut ClockTree,
2463 config: LpSlowClkConfig,
2464 ) -> u32 {
2465 match config {
2466 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2467 #[cfg(use_xtal32k)]
2468 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2469 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2470 }
2471 }
2472 pub fn lp_slow_clk_frequency() -> u32 {
2473 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2474 }
2475 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
2476 match source {
2477 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2478 #[cfg(use_xtal32k)]
2479 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2480 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2481 }
2482 }
2483 pub fn request_crypto_pll_div(clocks: &mut ClockTree) {
2484 trace!("Requesting CRYPTO_PLL_DIV");
2485 trace!("Enabling CRYPTO_PLL_DIV");
2486 request_pll_clk(clocks);
2487 enable_crypto_pll_div_impl(clocks, true);
2488 }
2489 pub fn release_crypto_pll_div(clocks: &mut ClockTree) {
2490 trace!("Releasing CRYPTO_PLL_DIV");
2491 trace!("Disabling CRYPTO_PLL_DIV");
2492 enable_crypto_pll_div_impl(clocks, false);
2493 release_pll_clk(clocks);
2494 }
2495 pub fn crypto_pll_div_frequency() -> u32 {
2496 (pll_clk_frequency() / 3)
2497 }
2498 pub fn crypto_pll_div_source_frequency() -> u32 {
2499 pll_clk_frequency()
2500 }
2501 pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
2502 let old_selector = clocks.crypto_clk.replace(new_selector);
2503 refresh_crypto_clk_downstream(clocks);
2504 if clocks.crypto_clk_refcount > 0 {
2505 match new_selector {
2506 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
2507 CryptoClkConfig::RcFast => request_rc_fast_clk(clocks),
2508 CryptoClkConfig::PllF480m => request_crypto_pll_div(clocks),
2509 }
2510 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2511 if let Some(old_selector) = old_selector {
2512 match old_selector {
2513 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
2514 CryptoClkConfig::RcFast => release_rc_fast_clk(clocks),
2515 CryptoClkConfig::PllF480m => release_crypto_pll_div(clocks),
2516 }
2517 }
2518 } else {
2519 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2520 }
2521 }
2522 pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
2523 clocks.crypto_clk
2524 }
2525 pub fn request_crypto_clk(clocks: &mut ClockTree) {
2526 trace!("Requesting CRYPTO_CLK");
2527 if increment_reference_count(&mut clocks.crypto_clk_refcount) {
2528 trace!("Enabling CRYPTO_CLK");
2529 match unwrap!(clocks.crypto_clk) {
2530 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
2531 CryptoClkConfig::RcFast => request_rc_fast_clk(clocks),
2532 CryptoClkConfig::PllF480m => request_crypto_pll_div(clocks),
2533 }
2534 enable_crypto_clk_impl(clocks, true);
2535 }
2536 }
2537 pub fn release_crypto_clk(clocks: &mut ClockTree) {
2538 trace!("Releasing CRYPTO_CLK");
2539 if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
2540 trace!("Disabling CRYPTO_CLK");
2541 enable_crypto_clk_impl(clocks, false);
2542 match unwrap!(clocks.crypto_clk) {
2543 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
2544 CryptoClkConfig::RcFast => release_rc_fast_clk(clocks),
2545 CryptoClkConfig::PllF480m => release_crypto_pll_div(clocks),
2546 }
2547 }
2548 }
2549 #[allow(unused_variables)]
2550 pub fn crypto_clk_config_frequency(clocks: &mut ClockTree, config: CryptoClkConfig) -> u32 {
2551 match config {
2552 CryptoClkConfig::Xtal => xtal_clk_frequency(),
2553 CryptoClkConfig::RcFast => rc_fast_clk_frequency(),
2554 CryptoClkConfig::PllF480m => crypto_pll_div_frequency(),
2555 }
2556 }
2557 pub fn crypto_clk_frequency() -> u32 {
2558 CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2559 }
2560 pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
2561 match source {
2562 CryptoClkConfig::Xtal => xtal_clk_frequency(),
2563 CryptoClkConfig::RcFast => rc_fast_clk_frequency(),
2564 CryptoClkConfig::PllF480m => crypto_pll_div_frequency(),
2565 }
2566 }
2567 pub fn configure_timg_calibration_clock(
2568 clocks: &mut ClockTree,
2569 new_selector: TimgCalibrationClockConfig,
2570 ) {
2571 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2572 refresh_timg_calibration_clock_downstream(clocks);
2573 if clocks.timg_calibration_clock_refcount > 0 {
2574 match new_selector {
2575 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
2576 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2577 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2578 #[cfg(use_xtal32k)]
2579 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2580 }
2581 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2582 if let Some(old_selector) = old_selector {
2583 match old_selector {
2584 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
2585 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2586 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2587 #[cfg(use_xtal32k)]
2588 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2589 }
2590 }
2591 } else {
2592 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2593 }
2594 }
2595 pub fn timg_calibration_clock_config(
2596 clocks: &mut ClockTree,
2597 ) -> Option<TimgCalibrationClockConfig> {
2598 clocks.timg_calibration_clock
2599 }
2600 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2601 trace!("Requesting TIMG_CALIBRATION_CLOCK");
2602 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2603 trace!("Enabling TIMG_CALIBRATION_CLOCK");
2604 crate::rtc_cntl::WakeLock::acquire();
2605 match unwrap!(clocks.timg_calibration_clock) {
2606 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
2607 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2608 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2609 #[cfg(use_xtal32k)]
2610 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2611 }
2612 enable_timg_calibration_clock_impl(clocks, true);
2613 }
2614 }
2615 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2616 trace!("Releasing TIMG_CALIBRATION_CLOCK");
2617 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2618 trace!("Disabling TIMG_CALIBRATION_CLOCK");
2619 crate::rtc_cntl::WakeLock::release();
2620 enable_timg_calibration_clock_impl(clocks, false);
2621 match unwrap!(clocks.timg_calibration_clock) {
2622 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
2623 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2624 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2625 #[cfg(use_xtal32k)]
2626 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2627 }
2628 }
2629 }
2630 #[allow(unused_variables)]
2631 pub fn timg_calibration_clock_config_frequency(
2632 clocks: &mut ClockTree,
2633 config: TimgCalibrationClockConfig,
2634 ) -> u32 {
2635 match config {
2636 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
2637 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
2638 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2639 #[cfg(use_xtal32k)]
2640 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2641 }
2642 }
2643 pub fn timg_calibration_clock_frequency() -> u32 {
2644 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2645 }
2646 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
2647 match source {
2648 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
2649 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
2650 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2651 #[cfg(use_xtal32k)]
2652 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2653 }
2654 }
2655 impl I2cInstance {
2656 pub fn configure_function_clock(
2657 self,
2658 clocks: &mut ClockTree,
2659 config: I2cFunctionClockConfig,
2660 ) {
2661 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
2662 refresh_i2c_function_clock_downstream(clocks, self);
2663 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
2664 match config.sclk {
2665 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2666 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2667 }
2668 self.configure_function_clock_impl(clocks, old_config, config);
2669 if let Some(old_config) = old_config {
2670 match old_config.sclk {
2671 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2672 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2673 }
2674 }
2675 } else {
2676 self.configure_function_clock_impl(clocks, old_config, config);
2677 }
2678 }
2679 pub fn function_clock_config(
2680 self,
2681 clocks: &mut ClockTree,
2682 ) -> Option<I2cFunctionClockConfig> {
2683 clocks.i2c_function_clock[self as usize]
2684 }
2685 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2686 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2687 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
2688 {
2689 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2690 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
2691 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2692 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2693 }
2694 self.enable_function_clock_impl(clocks, true);
2695 }
2696 }
2697 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2698 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2699 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
2700 {
2701 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2702 self.enable_function_clock_impl(clocks, false);
2703 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
2704 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2705 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2706 }
2707 }
2708 }
2709 #[allow(unused_variables)]
2710 pub fn function_clock_config_frequency(
2711 clocks: &mut ClockTree,
2712 config: I2cFunctionClockConfig,
2713 ) -> u32 {
2714 (match config.sclk {
2715 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
2716 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2717 } / (config.div_num() + 1))
2718 }
2719 pub fn function_clock_frequency(self) -> u32 {
2720 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2721 .load(::core::sync::atomic::Ordering::Acquire)
2722 }
2723 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
2724 match sclk {
2725 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
2726 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2727 }
2728 }
2729 }
2730 impl I2sInstance {
2731 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
2732 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
2733 refresh_i2s_tx_clk_downstream(clocks, self);
2734 if clocks.i2s_tx_clk_refcount[self as usize] > 0 {
2735 match config.sclk {
2736 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2737 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
2738 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
2739 }
2740 self.configure_tx_clk_impl(clocks, old_config, config);
2741 if let Some(old_config) = old_config {
2742 match old_config.sclk {
2743 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2744 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
2745 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
2746 }
2747 }
2748 } else {
2749 self.configure_tx_clk_impl(clocks, old_config, config);
2750 }
2751 }
2752 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
2753 clocks.i2s_tx_clk[self as usize]
2754 }
2755 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
2756 trace!("Requesting {:?}::TX_CLK", self);
2757 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
2758 trace!("Enabling {:?}::TX_CLK", self);
2759 crate::rtc_cntl::WakeLock::acquire();
2760 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
2761 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2762 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
2763 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
2764 }
2765 self.enable_tx_clk_impl(clocks, true);
2766 }
2767 }
2768 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
2769 trace!("Releasing {:?}::TX_CLK", self);
2770 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
2771 trace!("Disabling {:?}::TX_CLK", self);
2772 crate::rtc_cntl::WakeLock::release();
2773 self.enable_tx_clk_impl(clocks, false);
2774 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
2775 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2776 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
2777 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
2778 }
2779 }
2780 }
2781 #[allow(unused_variables)]
2782 pub fn tx_clk_config_frequency(clocks: &mut ClockTree, config: I2sClkConfig) -> u32 {
2783 (((match config.sclk {
2784 I2sClkSclk::Xtal => xtal_clk_frequency(),
2785 I2sClkSclk::PllF120m => pll_f120m_frequency(),
2786 I2sClkSclk::PllF160m => pll_f160m_frequency(),
2787 } as u64)
2788 * (config.div_a() as u64))
2789 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
2790 as u32
2791 }
2792 pub fn tx_clk_frequency(self) -> u32 {
2793 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
2794 }
2795 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
2796 match sclk {
2797 I2sClkSclk::Xtal => xtal_clk_frequency(),
2798 I2sClkSclk::PllF120m => pll_f120m_frequency(),
2799 I2sClkSclk::PllF160m => pll_f160m_frequency(),
2800 }
2801 }
2802 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
2803 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
2804 refresh_i2s_rx_clk_downstream(clocks, self);
2805 if clocks.i2s_rx_clk_refcount[self as usize] > 0 {
2806 match config.sclk {
2807 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2808 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
2809 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
2810 }
2811 self.configure_rx_clk_impl(clocks, old_config, config);
2812 if let Some(old_config) = old_config {
2813 match old_config.sclk {
2814 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2815 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
2816 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
2817 }
2818 }
2819 } else {
2820 self.configure_rx_clk_impl(clocks, old_config, config);
2821 }
2822 }
2823 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
2824 clocks.i2s_rx_clk[self as usize]
2825 }
2826 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
2827 trace!("Requesting {:?}::RX_CLK", self);
2828 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
2829 trace!("Enabling {:?}::RX_CLK", self);
2830 crate::rtc_cntl::WakeLock::acquire();
2831 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
2832 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2833 I2sClkSclk::PllF120m => request_pll_f120m(clocks),
2834 I2sClkSclk::PllF160m => request_pll_f160m(clocks),
2835 }
2836 self.enable_rx_clk_impl(clocks, true);
2837 }
2838 }
2839 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
2840 trace!("Releasing {:?}::RX_CLK", self);
2841 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
2842 trace!("Disabling {:?}::RX_CLK", self);
2843 crate::rtc_cntl::WakeLock::release();
2844 self.enable_rx_clk_impl(clocks, false);
2845 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
2846 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2847 I2sClkSclk::PllF120m => release_pll_f120m(clocks),
2848 I2sClkSclk::PllF160m => release_pll_f160m(clocks),
2849 }
2850 }
2851 }
2852 #[allow(unused_variables)]
2853 pub fn rx_clk_config_frequency(clocks: &mut ClockTree, config: I2sClkConfig) -> u32 {
2854 (((match config.sclk {
2855 I2sClkSclk::Xtal => xtal_clk_frequency(),
2856 I2sClkSclk::PllF120m => pll_f120m_frequency(),
2857 I2sClkSclk::PllF160m => pll_f160m_frequency(),
2858 } as u64)
2859 * (config.div_a() as u64))
2860 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
2861 as u32
2862 }
2863 pub fn rx_clk_frequency(self) -> u32 {
2864 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
2865 }
2866 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
2867 match sclk {
2868 I2sClkSclk::Xtal => xtal_clk_frequency(),
2869 I2sClkSclk::PllF120m => pll_f120m_frequency(),
2870 I2sClkSclk::PllF160m => pll_f160m_frequency(),
2871 }
2872 }
2873 pub fn configure_mclk_out(
2874 self,
2875 clocks: &mut ClockTree,
2876 new_selector: I2sMclkOutConfig,
2877 ) {
2878 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
2879 refresh_i2s_mclk_out_downstream(clocks, self);
2880 if clocks.i2s_mclk_out_refcount[self as usize] > 0 {
2881 match new_selector {
2882 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
2883 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
2884 }
2885 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
2886 if let Some(old_selector) = old_selector {
2887 match old_selector {
2888 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
2889 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
2890 }
2891 }
2892 } else {
2893 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
2894 }
2895 }
2896 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
2897 clocks.i2s_mclk_out[self as usize]
2898 }
2899 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
2900 trace!("Requesting {:?}::MCLK_OUT", self);
2901 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
2902 trace!("Enabling {:?}::MCLK_OUT", self);
2903 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
2904 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
2905 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
2906 }
2907 self.enable_mclk_out_impl(clocks, true);
2908 }
2909 }
2910 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
2911 trace!("Releasing {:?}::MCLK_OUT", self);
2912 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
2913 trace!("Disabling {:?}::MCLK_OUT", self);
2914 self.enable_mclk_out_impl(clocks, false);
2915 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
2916 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
2917 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
2918 }
2919 }
2920 }
2921 #[allow(unused_variables)]
2922 pub fn mclk_out_config_frequency(
2923 self,
2924 clocks: &mut ClockTree,
2925 config: I2sMclkOutConfig,
2926 ) -> u32 {
2927 match config {
2928 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
2929 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
2930 }
2931 }
2932 pub fn mclk_out_frequency(self) -> u32 {
2933 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
2934 }
2935 }
2936 impl SpiInstance {
2937 pub fn configure_function_clock(
2938 self,
2939 clocks: &mut ClockTree,
2940 new_selector: SpiFunctionClockConfig,
2941 ) {
2942 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
2943 refresh_spi_function_clock_downstream(clocks, self);
2944 if clocks.spi_function_clock_refcount[self as usize] > 0 {
2945 match new_selector {
2946 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
2947 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
2948 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
2949 }
2950 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2951 if let Some(old_selector) = old_selector {
2952 match old_selector {
2953 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
2954 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
2955 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
2956 }
2957 }
2958 } else {
2959 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2960 }
2961 }
2962 pub fn function_clock_config(
2963 self,
2964 clocks: &mut ClockTree,
2965 ) -> Option<SpiFunctionClockConfig> {
2966 clocks.spi_function_clock[self as usize]
2967 }
2968 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2969 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2970 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
2971 {
2972 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2973 match unwrap!(clocks.spi_function_clock[self as usize]) {
2974 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
2975 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
2976 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
2977 }
2978 self.enable_function_clock_impl(clocks, true);
2979 }
2980 }
2981 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2982 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2983 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
2984 {
2985 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2986 self.enable_function_clock_impl(clocks, false);
2987 match unwrap!(clocks.spi_function_clock[self as usize]) {
2988 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
2989 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
2990 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
2991 }
2992 }
2993 }
2994 #[allow(unused_variables)]
2995 pub fn function_clock_config_frequency(
2996 clocks: &mut ClockTree,
2997 config: SpiFunctionClockConfig,
2998 ) -> u32 {
2999 match config {
3000 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3001 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
3002 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3003 }
3004 }
3005 pub fn function_clock_frequency(self) -> u32 {
3006 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3007 .load(::core::sync::atomic::Ordering::Acquire)
3008 }
3009 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3010 match source {
3011 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3012 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
3013 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3014 }
3015 }
3016 }
3017 impl TimgInstance {
3018 pub fn configure_function_clock(
3019 self,
3020 clocks: &mut ClockTree,
3021 new_selector: TimgFunctionClockConfig,
3022 ) {
3023 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3024 refresh_timg_function_clock_downstream(clocks, self);
3025 if clocks.timg_function_clock_refcount[self as usize] > 0 {
3026 match new_selector {
3027 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3028 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3029 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3030 }
3031 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3032 if let Some(old_selector) = old_selector {
3033 match old_selector {
3034 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3035 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3036 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3037 }
3038 }
3039 } else {
3040 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3041 }
3042 }
3043 pub fn function_clock_config(
3044 self,
3045 clocks: &mut ClockTree,
3046 ) -> Option<TimgFunctionClockConfig> {
3047 clocks.timg_function_clock[self as usize]
3048 }
3049 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3050 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3051 if increment_reference_count(
3052 &mut clocks.timg_function_clock_refcount[self as usize],
3053 ) {
3054 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3055 match unwrap!(clocks.timg_function_clock[self as usize]) {
3056 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3057 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3058 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3059 }
3060 self.enable_function_clock_impl(clocks, true);
3061 }
3062 }
3063 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3064 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3065 if decrement_reference_count(
3066 &mut clocks.timg_function_clock_refcount[self as usize],
3067 ) {
3068 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3069 self.enable_function_clock_impl(clocks, false);
3070 match unwrap!(clocks.timg_function_clock[self as usize]) {
3071 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3072 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3073 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3074 }
3075 }
3076 }
3077 #[allow(unused_variables)]
3078 pub fn function_clock_config_frequency(
3079 clocks: &mut ClockTree,
3080 config: TimgFunctionClockConfig,
3081 ) -> u32 {
3082 match config {
3083 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3084 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3085 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3086 }
3087 }
3088 pub fn function_clock_frequency(self) -> u32 {
3089 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3090 .load(::core::sync::atomic::Ordering::Acquire)
3091 }
3092 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3093 match source {
3094 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3095 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3096 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3097 }
3098 }
3099 pub fn configure_wdt_clock(
3100 self,
3101 clocks: &mut ClockTree,
3102 new_selector: TimgWdtClockConfig,
3103 ) {
3104 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3105 refresh_timg_wdt_clock_downstream(clocks, self);
3106 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
3107 match new_selector {
3108 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3109 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3110 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3111 }
3112 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3113 if let Some(old_selector) = old_selector {
3114 match old_selector {
3115 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3116 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3117 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3118 }
3119 }
3120 } else {
3121 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3122 }
3123 }
3124 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3125 clocks.timg_wdt_clock[self as usize]
3126 }
3127 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3128 trace!("Requesting {:?}::WDT_CLOCK", self);
3129 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3130 trace!("Enabling {:?}::WDT_CLOCK", self);
3131 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3132 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3133 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3134 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3135 }
3136 self.enable_wdt_clock_impl(clocks, true);
3137 }
3138 }
3139 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3140 trace!("Releasing {:?}::WDT_CLOCK", self);
3141 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3142 trace!("Disabling {:?}::WDT_CLOCK", self);
3143 self.enable_wdt_clock_impl(clocks, false);
3144 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3145 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3146 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3147 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3148 }
3149 }
3150 }
3151 #[allow(unused_variables)]
3152 pub fn wdt_clock_config_frequency(
3153 clocks: &mut ClockTree,
3154 config: TimgWdtClockConfig,
3155 ) -> u32 {
3156 match config {
3157 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3158 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3159 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3160 }
3161 }
3162 pub fn wdt_clock_frequency(self) -> u32 {
3163 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3164 .load(::core::sync::atomic::Ordering::Acquire)
3165 }
3166 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3167 match source {
3168 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3169 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3170 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3171 }
3172 }
3173 }
3174 impl UartInstance {
3175 pub fn configure_function_clock(
3176 self,
3177 clocks: &mut ClockTree,
3178 config: UartFunctionClockConfig,
3179 ) {
3180 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3181 refresh_uart_function_clock_downstream(clocks, self);
3182 if clocks.uart_function_clock_refcount[self as usize] > 0 {
3183 match config.sclk {
3184 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3185 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3186 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3187 }
3188 self.configure_function_clock_impl(clocks, old_config, config);
3189 if let Some(old_config) = old_config {
3190 match old_config.sclk {
3191 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3192 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3193 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3194 }
3195 }
3196 } else {
3197 self.configure_function_clock_impl(clocks, old_config, config);
3198 }
3199 }
3200 pub fn function_clock_config(
3201 self,
3202 clocks: &mut ClockTree,
3203 ) -> Option<UartFunctionClockConfig> {
3204 clocks.uart_function_clock[self as usize]
3205 }
3206 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3207 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3208 if increment_reference_count(
3209 &mut clocks.uart_function_clock_refcount[self as usize],
3210 ) {
3211 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3212 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3213 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3214 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3215 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3216 }
3217 self.enable_function_clock_impl(clocks, true);
3218 }
3219 }
3220 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3221 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3222 if decrement_reference_count(
3223 &mut clocks.uart_function_clock_refcount[self as usize],
3224 ) {
3225 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3226 self.enable_function_clock_impl(clocks, false);
3227 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3228 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3229 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3230 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3231 }
3232 }
3233 }
3234 #[allow(unused_variables)]
3235 pub fn function_clock_config_frequency(
3236 clocks: &mut ClockTree,
3237 config: UartFunctionClockConfig,
3238 ) -> u32 {
3239 (match config.sclk {
3240 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3241 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3242 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3243 } / (config.div_num() + 1))
3244 }
3245 pub fn function_clock_frequency(self) -> u32 {
3246 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3247 .load(::core::sync::atomic::Ordering::Acquire)
3248 }
3249 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3250 match sclk {
3251 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3252 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3253 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3254 }
3255 }
3256 pub fn configure_baud_rate_generator(
3257 self,
3258 clocks: &mut ClockTree,
3259 config: UartBaudRateGeneratorConfig,
3260 ) {
3261 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3262 refresh_uart_baud_rate_generator_downstream(clocks, self);
3263 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3264 }
3265 pub fn baud_rate_generator_config(
3266 self,
3267 clocks: &mut ClockTree,
3268 ) -> Option<UartBaudRateGeneratorConfig> {
3269 clocks.uart_baud_rate_generator[self as usize]
3270 }
3271 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3272 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3273 if increment_reference_count(
3274 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3275 ) {
3276 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3277 self.request_function_clock(clocks);
3278 self.enable_baud_rate_generator_impl(clocks, true);
3279 }
3280 }
3281 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3282 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3283 if decrement_reference_count(
3284 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3285 ) {
3286 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3287 self.enable_baud_rate_generator_impl(clocks, false);
3288 self.release_function_clock(clocks);
3289 }
3290 }
3291 #[allow(unused_variables)]
3292 pub fn baud_rate_generator_config_frequency(
3293 self,
3294 clocks: &mut ClockTree,
3295 config: UartBaudRateGeneratorConfig,
3296 ) -> u32 {
3297 ((self.function_clock_frequency() * 16)
3298 / ((config.integral() * 16) + config.fractional()))
3299 }
3300 pub fn baud_rate_generator_frequency(self) -> u32 {
3301 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3302 .load(::core::sync::atomic::Ordering::Acquire)
3303 }
3304 }
3305 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3313 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3314 #[instability::unstable]
3315 pub struct ClockConfig {
3316 pub xtal_clk: Option<XtalClkConfig>,
3318 pub hp_root_clk: Option<HpRootClkConfig>,
3320 pub cpu_clk: Option<CpuClkConfig>,
3322 pub ahb_clk: Option<AhbClkConfig>,
3324 pub apb_clk: Option<ApbClkConfig>,
3326 pub lp_fast_clk: Option<LpFastClkConfig>,
3328 pub lp_slow_clk: Option<LpSlowClkConfig>,
3330 pub crypto_clk: Option<CryptoClkConfig>,
3332 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3334 }
3335 impl ClockConfig {
3336 fn apply(&self, clocks: &mut ClockTree) {
3337 if let Some(config) = self.xtal_clk {
3338 configure_xtal_clk(clocks, config);
3339 }
3340 if let Some(config) = self.hp_root_clk {
3341 configure_hp_root_clk(clocks, config);
3342 }
3343 if let Some(config) = self.cpu_clk {
3344 configure_cpu_clk(clocks, config);
3345 }
3346 if let Some(config) = self.ahb_clk {
3347 configure_ahb_clk(clocks, config);
3348 }
3349 if let Some(config) = self.apb_clk {
3350 configure_apb_clk(clocks, config);
3351 }
3352 if let Some(config) = self.lp_fast_clk {
3353 configure_lp_fast_clk(clocks, config);
3354 }
3355 if let Some(config) = self.lp_slow_clk {
3356 configure_lp_slow_clk(clocks, config);
3357 }
3358 if let Some(config) = self.crypto_clk {
3359 configure_crypto_clk(clocks, config);
3360 }
3361 if let Some(config) = self.timg_calibration_clock {
3362 configure_timg_calibration_clock(clocks, config);
3363 }
3364 }
3365 }
3366 fn increment_reference_count(refcount: &mut u32) -> bool {
3367 let first = *refcount == 0;
3368 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3369 first
3370 }
3371 fn decrement_reference_count(refcount: &mut u32) -> bool {
3372 *refcount = refcount.saturating_sub(1);
3373 let last = *refcount == 0;
3374 last
3375 }
3376 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3377 if let Some(config) = clocks.xtal_clk {
3378 XTAL_CLK_FREQ_CACHE.store(
3379 xtal_clk_config_frequency(clocks, config),
3380 ::core::sync::atomic::Ordering::Release,
3381 );
3382 }
3383 refresh_hp_root_clk_downstream(clocks);
3384 refresh_lp_fast_clk_downstream(clocks);
3385 refresh_crypto_clk_downstream(clocks);
3386 for child_instance in [I2cInstance::I2c0] {
3387 refresh_i2c_function_clock_downstream(clocks, child_instance);
3388 }
3389 for child_instance in [I2sInstance::I2s0] {
3390 refresh_i2s_tx_clk_downstream(clocks, child_instance);
3391 refresh_i2s_rx_clk_downstream(clocks, child_instance);
3392 }
3393 for child_instance in [SpiInstance::Spi2] {
3394 refresh_spi_function_clock_downstream(clocks, child_instance);
3395 }
3396 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3397 refresh_timg_function_clock_downstream(clocks, child_instance);
3398 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3399 }
3400 for child_instance in [
3401 UartInstance::Uart0,
3402 UartInstance::Uart1,
3403 UartInstance::Uart2,
3404 ] {
3405 refresh_uart_function_clock_downstream(clocks, child_instance);
3406 }
3407 }
3408 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
3409 if let Some(config) = clocks.hp_root_clk {
3410 HP_ROOT_CLK_FREQ_CACHE.store(
3411 hp_root_clk_config_frequency(clocks, config),
3412 ::core::sync::atomic::Ordering::Release,
3413 );
3414 }
3415 refresh_cpu_clk_downstream(clocks);
3416 refresh_ahb_clk_downstream(clocks);
3417 }
3418 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3419 if let Some(config) = clocks.cpu_clk {
3420 CPU_CLK_FREQ_CACHE.store(
3421 cpu_clk_config_frequency(clocks, config),
3422 ::core::sync::atomic::Ordering::Release,
3423 );
3424 }
3425 }
3426 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
3427 if let Some(config) = clocks.ahb_clk {
3428 AHB_CLK_FREQ_CACHE.store(
3429 ahb_clk_config_frequency(clocks, config),
3430 ::core::sync::atomic::Ordering::Release,
3431 );
3432 }
3433 refresh_apb_clk_downstream(clocks);
3434 }
3435 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3436 if let Some(config) = clocks.apb_clk {
3437 APB_CLK_FREQ_CACHE.store(
3438 apb_clk_config_frequency(clocks, config),
3439 ::core::sync::atomic::Ordering::Release,
3440 );
3441 }
3442 }
3443 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
3444 if let Some(config) = clocks.lp_fast_clk {
3445 LP_FAST_CLK_FREQ_CACHE.store(
3446 lp_fast_clk_config_frequency(clocks, config),
3447 ::core::sync::atomic::Ordering::Release,
3448 );
3449 }
3450 }
3451 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
3452 if let Some(config) = clocks.lp_slow_clk {
3453 LP_SLOW_CLK_FREQ_CACHE.store(
3454 lp_slow_clk_config_frequency(clocks, config),
3455 ::core::sync::atomic::Ordering::Release,
3456 );
3457 }
3458 }
3459 fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
3460 if let Some(config) = clocks.crypto_clk {
3461 CRYPTO_CLK_FREQ_CACHE.store(
3462 crypto_clk_config_frequency(clocks, config),
3463 ::core::sync::atomic::Ordering::Release,
3464 );
3465 }
3466 }
3467 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3468 if let Some(config) = clocks.timg_calibration_clock {
3469 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3470 timg_calibration_clock_config_frequency(clocks, config),
3471 ::core::sync::atomic::Ordering::Release,
3472 );
3473 }
3474 }
3475 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
3476 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
3477 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3478 I2cInstance::function_clock_config_frequency(clocks, config),
3479 ::core::sync::atomic::Ordering::Release,
3480 );
3481 }
3482 }
3483 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3484 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
3485 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
3486 I2sInstance::tx_clk_config_frequency(clocks, config),
3487 ::core::sync::atomic::Ordering::Release,
3488 );
3489 }
3490 refresh_i2s_mclk_out_downstream(clocks, instance);
3491 }
3492 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3493 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
3494 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
3495 I2sInstance::rx_clk_config_frequency(clocks, config),
3496 ::core::sync::atomic::Ordering::Release,
3497 );
3498 }
3499 refresh_i2s_mclk_out_downstream(clocks, instance);
3500 }
3501 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3502 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
3503 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
3504 instance.mclk_out_config_frequency(clocks, config),
3505 ::core::sync::atomic::Ordering::Release,
3506 );
3507 }
3508 }
3509 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
3510 if let Some(config) = clocks.spi_function_clock[instance as usize] {
3511 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3512 SpiInstance::function_clock_config_frequency(clocks, config),
3513 ::core::sync::atomic::Ordering::Release,
3514 );
3515 }
3516 }
3517 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3518 if let Some(config) = clocks.timg_function_clock[instance as usize] {
3519 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3520 TimgInstance::function_clock_config_frequency(clocks, config),
3521 ::core::sync::atomic::Ordering::Release,
3522 );
3523 }
3524 }
3525 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3526 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
3527 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
3528 TimgInstance::wdt_clock_config_frequency(clocks, config),
3529 ::core::sync::atomic::Ordering::Release,
3530 );
3531 }
3532 }
3533 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
3534 if let Some(config) = clocks.uart_function_clock[instance as usize] {
3535 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3536 UartInstance::function_clock_config_frequency(clocks, config),
3537 ::core::sync::atomic::Ordering::Release,
3538 );
3539 }
3540 refresh_uart_baud_rate_generator_downstream(clocks, instance);
3541 }
3542 fn refresh_uart_baud_rate_generator_downstream(
3543 clocks: &mut ClockTree,
3544 instance: UartInstance,
3545 ) {
3546 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
3547 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
3548 instance.baud_rate_generator_config_frequency(clocks, config),
3549 ::core::sync::atomic::Ordering::Release,
3550 );
3551 }
3552 }
3553 };
3554}
3555#[macro_export]
3559#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3560macro_rules! implement_peripheral_clocks {
3561 () => {
3562 #[doc(hidden)]
3563 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3564 #[repr(u8)]
3565 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3566 pub enum Peripheral {
3567 AhbGdma,
3569 ApbSarAdc,
3571 Ecc,
3573 I2cExt0,
3575 I2s0,
3577 Sha,
3579 Spi2,
3581 Systimer,
3583 Timg0,
3585 Timg1,
3587 Uart0,
3589 Uart1,
3591 Uart2,
3593 UsbDevice,
3595 }
3596 impl Peripheral {
3597 const KEEP_ENABLED: &[Peripheral] =
3598 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
3599 const COUNT: usize = Self::ALL.len();
3600 const ALL: &[Self] = &[
3601 Self::AhbGdma,
3602 Self::ApbSarAdc,
3603 Self::Ecc,
3604 Self::I2cExt0,
3605 Self::I2s0,
3606 Self::Sha,
3607 Self::Spi2,
3608 Self::Systimer,
3609 Self::Timg0,
3610 Self::Timg1,
3611 Self::Uart0,
3612 Self::Uart1,
3613 Self::Uart2,
3614 Self::UsbDevice,
3615 ];
3616 }
3617 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
3618 match peripheral {
3619 Peripheral::AhbGdma => {
3620 crate::peripherals::SYSTEM::regs()
3621 .gdma_conf()
3622 .modify(|_, w| w.gdma_clk_en().bit(enable));
3623 }
3624 Peripheral::ApbSarAdc => {
3625 crate::peripherals::SYSTEM::regs()
3626 .saradc_conf()
3627 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
3628 }
3629 Peripheral::Ecc => {
3630 crate::peripherals::SYSTEM::regs()
3631 .ecc_conf()
3632 .modify(|_, w| w.ecc_clk_en().bit(enable));
3633 }
3634 Peripheral::I2cExt0 => {
3635 crate::peripherals::SYSTEM::regs()
3636 .i2c0_conf()
3637 .modify(|_, w| w.i2c0_clk_en().bit(enable));
3638 }
3639 Peripheral::I2s0 => {
3640 crate::peripherals::SYSTEM::regs()
3641 .i2s_conf()
3642 .modify(|_, w| w.i2s_clk_en().bit(enable));
3643 }
3644 Peripheral::Sha => {
3645 crate::peripherals::SYSTEM::regs()
3646 .sha_conf()
3647 .modify(|_, w| w.sha_clk_en().bit(enable));
3648 }
3649 Peripheral::Spi2 => {
3650 crate::peripherals::SYSTEM::regs()
3651 .spi2_conf()
3652 .modify(|_, w| w.spi2_clk_en().bit(enable));
3653 }
3654 Peripheral::Systimer => {
3655 crate::peripherals::SYSTEM::regs()
3656 .systimer_conf()
3657 .modify(|_, w| w.systimer_clk_en().bit(enable));
3658 }
3659 Peripheral::Timg0 => {
3660 crate::peripherals::SYSTEM::regs()
3661 .timergroup(0)
3662 .conf()
3663 .modify(|_, w| w.clk_en().bit(enable));
3664 }
3665 Peripheral::Timg1 => {
3666 crate::peripherals::SYSTEM::regs()
3667 .timergroup(1)
3668 .conf()
3669 .modify(|_, w| w.clk_en().bit(enable));
3670 }
3671 Peripheral::Uart0 => {
3672 crate::peripherals::SYSTEM::regs()
3673 .uart(0)
3674 .conf()
3675 .modify(|_, w| w.clk_en().bit(enable));
3676 }
3677 Peripheral::Uart1 => {
3678 crate::peripherals::SYSTEM::regs()
3679 .uart(1)
3680 .conf()
3681 .modify(|_, w| w.clk_en().bit(enable));
3682 }
3683 Peripheral::Uart2 => {
3684 crate::peripherals::SYSTEM::regs()
3685 .uart(2)
3686 .conf()
3687 .modify(|_, w| w.clk_en().bit(enable));
3688 }
3689 Peripheral::UsbDevice => {
3690 crate::peripherals::SYSTEM::regs()
3691 .usb_device_conf()
3692 .modify(|_, w| w.usb_device_clk_en().bit(enable));
3693 }
3694 }
3695 }
3696 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
3697 match peripheral {
3698 Peripheral::AhbGdma => {
3699 crate::peripherals::SYSTEM::regs()
3700 .gdma_conf()
3701 .modify(|_, w| w.gdma_rst_en().bit(reset));
3702 }
3703 Peripheral::ApbSarAdc => {
3704 crate::peripherals::SYSTEM::regs()
3705 .saradc_conf()
3706 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
3707 }
3708 Peripheral::Ecc => {
3709 crate::peripherals::SYSTEM::regs()
3710 .ecc_conf()
3711 .modify(|_, w| w.ecc_rst_en().bit(reset));
3712 }
3713 Peripheral::I2cExt0 => {
3714 crate::peripherals::SYSTEM::regs()
3715 .i2c0_conf()
3716 .modify(|_, w| w.i2c0_rst_en().bit(reset));
3717 }
3718 Peripheral::I2s0 => {
3719 crate::peripherals::SYSTEM::regs()
3720 .i2s_conf()
3721 .modify(|_, w| w.i2s_rst_en().bit(reset));
3722 }
3723 Peripheral::Sha => {
3724 crate::peripherals::SYSTEM::regs()
3725 .sha_conf()
3726 .modify(|_, w| w.sha_rst_en().bit(reset));
3727 }
3728 Peripheral::Spi2 => {
3729 crate::peripherals::SYSTEM::regs()
3730 .spi2_conf()
3731 .modify(|_, w| w.spi2_rst_en().bit(reset));
3732 }
3733 Peripheral::Systimer => {
3734 crate::peripherals::SYSTEM::regs()
3735 .systimer_conf()
3736 .modify(|_, w| w.systimer_rst_en().bit(reset));
3737 }
3738 Peripheral::Timg0 => {
3739 crate::peripherals::SYSTEM::regs()
3740 .timergroup(0)
3741 .conf()
3742 .modify(|_, w| w.rst_en().bit(reset));
3743 }
3744 Peripheral::Timg1 => {
3745 crate::peripherals::SYSTEM::regs()
3746 .timergroup(1)
3747 .conf()
3748 .modify(|_, w| w.rst_en().bit(reset));
3749 }
3750 Peripheral::Uart0 => {
3751 crate::peripherals::SYSTEM::regs()
3752 .uart(0)
3753 .conf()
3754 .modify(|_, w| w.rst_en().bit(reset));
3755 }
3756 Peripheral::Uart1 => {
3757 crate::peripherals::SYSTEM::regs()
3758 .uart(1)
3759 .conf()
3760 .modify(|_, w| w.rst_en().bit(reset));
3761 }
3762 Peripheral::Uart2 => {
3763 crate::peripherals::SYSTEM::regs()
3764 .uart(2)
3765 .conf()
3766 .modify(|_, w| w.rst_en().bit(reset));
3767 }
3768 Peripheral::UsbDevice => {
3769 crate::peripherals::SYSTEM::regs()
3770 .usb_device_conf()
3771 .modify(|_, w| w.usb_device_rst_en().bit(reset));
3772 }
3773 }
3774 }
3775 };
3776}
3777#[macro_export]
3785#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3786macro_rules! memory_range {
3787 ("DRAM") => {
3788 0x40800000..0x40850000
3789 };
3790 (size as str, "DRAM") => {
3791 "327680"
3792 };
3793 ("DRAM2_UNINIT") => {
3794 0x4083EA70..0x4084EA70
3795 };
3796 (size as str, "DRAM2_UNINIT") => {
3797 "65536"
3798 };
3799 ("IROM") => {
3800 0x42000000..0x44000000
3801 };
3802 (size as str, "IROM") => {
3803 "33554432"
3804 };
3805 ("DROM") => {
3806 0x42000000..0x44000000
3807 };
3808 (size as str, "DROM") => {
3809 "33554432"
3810 };
3811}
3812#[macro_export]
3829#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3830macro_rules! for_each_i2c_master {
3831 ($($pattern:tt => $code:tt;)*) => {
3832 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
3833 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
3834 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
3835 I2CEXT0_SDA)));
3836 };
3837}
3838#[macro_export]
3865#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3866macro_rules! for_each_i2s {
3867 ($($pattern:tt => $code:tt;)*) => {
3868 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
3869 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
3870 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
3871 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
3872 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
3873 true, true, false)));
3874 };
3875}
3876#[macro_export]
3895#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3896macro_rules! for_each_uart {
3897 ($($pattern:tt => $code:tt;)*) => {
3898 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
3899 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
3900 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
3901 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((2, UART2, Uart2,
3902 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = true)); _for_each_inner_uart!((all(0,
3903 UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1,
3904 Uart1, U1RXD, U1TXD, U1CTS, U1RTS, wakeup_source = true), (2, UART2, Uart2,
3905 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = true)));
3906 };
3907}
3908#[macro_export]
3930#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3931macro_rules! for_each_spi_master {
3932 ($($pattern:tt => $code:tt;)*) => {
3933 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
3934 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
3935 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
3936 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
3937 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
3938 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
3939 };
3940}
3941#[macro_export]
3958#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3959macro_rules! for_each_spi_slave {
3960 ($($pattern:tt => $code:tt;)*) => {
3961 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
3962 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
3963 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
3964 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
3965 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
3966 };
3967}
3968#[macro_export]
3969#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3970macro_rules! for_each_peripheral {
3971 ($($pattern:tt => $code:tt;)*) => {
3972 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
3973 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
3974 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
3975 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
3976 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3977 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
3978 _for_each_inner_peripheral!((@ peri_type #[doc =
3979 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3980 "<section class=\"warning\">"] #[doc =
3981 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3982 #[doc = "<ul>"] #[doc =
3983 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3984 =
3985 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3986 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
3987 _for_each_inner_peripheral!((@ peri_type #[doc =
3988 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3989 "<section class=\"warning\">"] #[doc =
3990 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3991 #[doc = "<ul>"] #[doc =
3992 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3993 =
3994 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3995 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
3996 _for_each_inner_peripheral!((@ peri_type #[doc =
3997 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3998 "<section class=\"warning\">"] #[doc =
3999 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4000 #[doc = "<ul>"] #[doc =
4001 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4002 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4003 _for_each_inner_peripheral!((@ peri_type #[doc =
4004 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4005 "<section class=\"warning\">"] #[doc =
4006 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4007 #[doc = "<ul>"] #[doc =
4008 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4009 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4010 _for_each_inner_peripheral!((@ peri_type #[doc =
4011 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4012 "<section class=\"warning\">"] #[doc =
4013 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4014 #[doc = "<ul>"] #[doc =
4015 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4016 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4017 _for_each_inner_peripheral!((@ peri_type #[doc =
4018 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4019 "<section class=\"warning\">"] #[doc =
4020 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4021 #[doc = "<ul>"] #[doc =
4022 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4023 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4024 _for_each_inner_peripheral!((@ peri_type #[doc =
4025 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4026 "<section class=\"warning\">"] #[doc =
4027 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4028 #[doc = "<ul>"] #[doc =
4029 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4030 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4031 _for_each_inner_peripheral!((@ peri_type #[doc =
4032 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4033 "<section class=\"warning\">"] #[doc =
4034 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4035 #[doc = "<ul>"] #[doc =
4036 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4037 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
4038 _for_each_inner_peripheral!((@ peri_type #[doc =
4039 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4040 "<section class=\"warning\">"] #[doc =
4041 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4042 #[doc = "<ul>"] #[doc =
4043 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4044 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4045 _for_each_inner_peripheral!((@ peri_type #[doc =
4046 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4047 "<section class=\"warning\">"] #[doc =
4048 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4049 #[doc = "<ul>"] #[doc =
4050 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4051 #[doc = "</section>"] GPIO12 <= virtual())); _for_each_inner_peripheral!((@
4052 peri_type #[doc = "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""]
4053 #[doc = "<section class=\"warning\">"] #[doc =
4054 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4055 #[doc = "<ul>"] #[doc =
4056 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4057 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
4058 peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
4059 #[doc = "<section class=\"warning\">"] #[doc =
4060 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4061 #[doc = "<ul>"] #[doc =
4062 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4063 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
4064 _for_each_inner_peripheral!((@ peri_type #[doc =
4065 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4066 "<section class=\"warning\">"] #[doc =
4067 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4068 #[doc = "<ul>"] #[doc =
4069 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4070 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
4071 _for_each_inner_peripheral!((@ peri_type #[doc =
4072 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4073 "<section class=\"warning\">"] #[doc =
4074 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4075 #[doc = "<ul>"] #[doc =
4076 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4077 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4078 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
4079 _for_each_inner_peripheral!((@ peri_type #[doc =
4080 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4081 "<section class=\"warning\">"] #[doc =
4082 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4083 #[doc = "<ul>"] #[doc =
4084 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4085 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4086 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
4087 _for_each_inner_peripheral!((@ peri_type #[doc =
4088 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4089 "<section class=\"warning\">"] #[doc =
4090 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4091 #[doc = "<ul>"] #[doc =
4092 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4093 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4094 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()));
4095 _for_each_inner_peripheral!((@ peri_type #[doc =
4096 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4097 "<section class=\"warning\">"] #[doc =
4098 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4099 #[doc = "<ul>"] #[doc =
4100 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4101 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4102 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()));
4103 _for_each_inner_peripheral!((@ peri_type #[doc =
4104 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4105 "<section class=\"warning\">"] #[doc =
4106 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4107 #[doc = "<ul>"] #[doc =
4108 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4109 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4110 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
4111 _for_each_inner_peripheral!((@ peri_type #[doc =
4112 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4113 "<section class=\"warning\">"] #[doc =
4114 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4115 #[doc = "<ul>"] #[doc =
4116 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4117 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4118 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
4119 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
4120 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4121 "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
4122 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO24 peripheral singleton"]
4123 GPIO24 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4124 "GPIO25 peripheral singleton"] GPIO25 <= virtual()));
4125 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
4126 GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4127 "GPIO27 peripheral singleton"] GPIO27 <= virtual()));
4128 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO28 peripheral singleton"]
4129 GPIO28 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4130 "GPIO29 peripheral singleton"] GPIO29 <= virtual()));
4131 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
4132 DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4133 disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
4134 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4135 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
4136 DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4137 disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
4138 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4139 _for_each_inner_peripheral!((@ peri_type #[doc =
4140 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
4141 _for_each_inner_peripheral!((@ peri_type #[doc =
4142 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
4143 _for_each_inner_peripheral!((@ peri_type #[doc = "CLINT peripheral singleton"]
4144 CLINT <= CLINT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4145 "CACHE peripheral singleton"] CACHE <= CACHE() (unstable)));
4146 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
4147 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4148 "ECC peripheral singleton"] ECC <= ECC() (unstable)));
4149 _for_each_inner_peripheral!((@ peri_type #[doc = "ECDSA peripheral singleton"]
4150 ECDSA <= ECDSA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4151 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
4152 _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
4153 <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4154 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
4155 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
4156 GPIO_SD <= GPIO_EXT() (unstable))); _for_each_inner_peripheral!((@ peri_type
4157 #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
4158 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
4159 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4160 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4161 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4162 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4163 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4164 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
4165 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4166 _for_each_inner_peripheral!((@ peri_type #[doc =
4167 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4168 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4169 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
4170 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
4171 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4172 "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
4173 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
4174 LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4175 "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
4176 _for_each_inner_peripheral!((@ peri_type #[doc =
4177 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
4178 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
4179 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4180 = "LP_GPIO peripheral singleton"] LP_GPIO <= LP_GPIO() (unstable)));
4181 _for_each_inner_peripheral!((@ peri_type #[doc =
4182 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
4183 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
4184 LP_PERI <= LPPERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4185 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
4186 _for_each_inner_peripheral!((@ peri_type #[doc =
4187 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
4188 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
4189 LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4190 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
4191 _for_each_inner_peripheral!((@ peri_type #[doc =
4192 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
4193 _for_each_inner_peripheral!((@ peri_type #[doc =
4194 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
4195 _for_each_inner_peripheral!((@ peri_type #[doc = "PAU peripheral singleton"] PAU
4196 <= PAU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4197 "PCR peripheral singleton"] PCR <= PCR() (unstable)));
4198 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
4199 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4200 "RNG peripheral singleton"] RNG <= LPPERI() (unstable)));
4201 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
4202 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4203 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4204 "SLC peripheral singleton"] SLC <= SLC() (unstable)));
4205 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
4206 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4207 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
4208 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
4209 SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
4210 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4211 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)));
4212 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
4213 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
4214 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)));
4215 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
4216 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4217 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
4218 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
4219 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
4220 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4221 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
4222 enable_peri_interrupt, disable_peri_interrupt })));
4223 _for_each_inner_peripheral!((@ peri_type #[doc = "UART2 peripheral singleton"]
4224 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
4225 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4226 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4227 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4228 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4229 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
4230 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4231 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
4232 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
4233 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4234 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
4235 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4236 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4237 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
4238 WIFI <= virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt,
4239 disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
4240 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
4241 disable_pwr_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4242 "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
4243 _for_each_inner_peripheral!((@ peri_type #[doc =
4244 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
4245 _for_each_inner_peripheral!((@ peri_type #[doc =
4246 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4247 _for_each_inner_peripheral!((@ peri_type #[doc =
4248 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4249 _for_each_inner_peripheral!((@ peri_type #[doc =
4250 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4251 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
4252 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
4253 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4254 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4255 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4256 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4257 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4258 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4259 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
4260 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
4261 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
4262 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
4263 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
4264 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
4265 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
4266 _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
4267 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4268 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4269 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4270 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
4271 _for_each_inner_peripheral!((CLINT(unstable)));
4272 _for_each_inner_peripheral!((CACHE(unstable)));
4273 _for_each_inner_peripheral!((DMA(unstable)));
4274 _for_each_inner_peripheral!((ECC(unstable)));
4275 _for_each_inner_peripheral!((ECDSA(unstable)));
4276 _for_each_inner_peripheral!((EFUSE(unstable)));
4277 _for_each_inner_peripheral!((ETM(unstable)));
4278 _for_each_inner_peripheral!((GPIO(unstable)));
4279 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4280 _for_each_inner_peripheral!((HP_APM(unstable)));
4281 _for_each_inner_peripheral!((HP_SYS(unstable)));
4282 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4283 _for_each_inner_peripheral!((I2C0));
4284 _for_each_inner_peripheral!((I2S0(unstable)));
4285 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4286 _for_each_inner_peripheral!((INTPRI(unstable)));
4287 _for_each_inner_peripheral!((IO_MUX(unstable)));
4288 _for_each_inner_peripheral!((LP_ANA(unstable)));
4289 _for_each_inner_peripheral!((LP_AON(unstable)));
4290 _for_each_inner_peripheral!((LP_APM(unstable)));
4291 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
4292 _for_each_inner_peripheral!((LPWR(unstable)));
4293 _for_each_inner_peripheral!((LP_GPIO(unstable)));
4294 _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
4295 _for_each_inner_peripheral!((LP_PERI(unstable)));
4296 _for_each_inner_peripheral!((LP_TEE(unstable)));
4297 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4298 _for_each_inner_peripheral!((LP_WDT(unstable)));
4299 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
4300 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
4301 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
4302 _for_each_inner_peripheral!((PAU(unstable)));
4303 _for_each_inner_peripheral!((PCR(unstable)));
4304 _for_each_inner_peripheral!((PMU(unstable)));
4305 _for_each_inner_peripheral!((RNG(unstable)));
4306 _for_each_inner_peripheral!((SHA(unstable)));
4307 _for_each_inner_peripheral!((SLC(unstable)));
4308 _for_each_inner_peripheral!((SPI0(unstable)));
4309 _for_each_inner_peripheral!((SPI1(unstable)));
4310 _for_each_inner_peripheral!((SPI2));
4311 _for_each_inner_peripheral!((SYSTEM(unstable)));
4312 _for_each_inner_peripheral!((SYSTIMER(unstable)));
4313 _for_each_inner_peripheral!((TEE(unstable)));
4314 _for_each_inner_peripheral!((TIMG0(unstable)));
4315 _for_each_inner_peripheral!((TIMG1(unstable)));
4316 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
4317 _for_each_inner_peripheral!((UART2));
4318 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
4319 _for_each_inner_peripheral!((ADC1(unstable)));
4320 _for_each_inner_peripheral!((BT(unstable)));
4321 _for_each_inner_peripheral!((FLASH(unstable)));
4322 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
4323 _for_each_inner_peripheral!((WIFI));
4324 _for_each_inner_peripheral!((PSRAM(unstable)));
4325 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
4326 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
4327 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
4328 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
4329 _for_each_inner_peripheral!((SPI2, Spi2, 1, AhbGdmaChannel));
4330 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
4331 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
4332 _for_each_inner_peripheral!((all(@ peri_type #[doc =
4333 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
4334 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
4335 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
4336 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4337 "<section class=\"warning\">"] #[doc =
4338 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4339 #[doc = "<ul>"] #[doc =
4340 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4341 =
4342 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4343 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
4344 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4345 "<section class=\"warning\">"] #[doc =
4346 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4347 #[doc = "<ul>"] #[doc =
4348 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4349 =
4350 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4351 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
4352 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4353 "<section class=\"warning\">"] #[doc =
4354 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4355 #[doc = "<ul>"] #[doc =
4356 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4357 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
4358 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4359 "<section class=\"warning\">"] #[doc =
4360 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4361 #[doc = "<ul>"] #[doc =
4362 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4363 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
4364 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4365 "<section class=\"warning\">"] #[doc =
4366 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4367 #[doc = "<ul>"] #[doc =
4368 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4369 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
4370 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4371 "<section class=\"warning\">"] #[doc =
4372 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4373 #[doc = "<ul>"] #[doc =
4374 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4375 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
4376 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4377 "<section class=\"warning\">"] #[doc =
4378 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4379 #[doc = "<ul>"] #[doc =
4380 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4381 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
4382 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4383 "<section class=\"warning\">"] #[doc =
4384 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4385 #[doc = "<ul>"] #[doc =
4386 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4387 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
4388 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4389 "<section class=\"warning\">"] #[doc =
4390 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4391 #[doc = "<ul>"] #[doc =
4392 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4393 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
4394 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4395 "<section class=\"warning\">"] #[doc =
4396 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4397 #[doc = "<ul>"] #[doc =
4398 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4399 #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
4400 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4401 "<section class=\"warning\">"] #[doc =
4402 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4403 #[doc = "<ul>"] #[doc =
4404 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4405 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
4406 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4407 "<section class=\"warning\">"] #[doc =
4408 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4409 #[doc = "<ul>"] #[doc =
4410 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4411 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
4412 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4413 "<section class=\"warning\">"] #[doc =
4414 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4415 #[doc = "<ul>"] #[doc =
4416 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4417 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
4418 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4419 "<section class=\"warning\">"] #[doc =
4420 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4421 #[doc = "<ul>"] #[doc =
4422 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4423 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4424 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
4425 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4426 "<section class=\"warning\">"] #[doc =
4427 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4428 #[doc = "<ul>"] #[doc =
4429 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4430 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4431 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
4432 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4433 "<section class=\"warning\">"] #[doc =
4434 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4435 #[doc = "<ul>"] #[doc =
4436 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4437 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4438 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
4439 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4440 "<section class=\"warning\">"] #[doc =
4441 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4442 #[doc = "<ul>"] #[doc =
4443 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4444 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4445 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
4446 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4447 "<section class=\"warning\">"] #[doc =
4448 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4449 #[doc = "<ul>"] #[doc =
4450 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4451 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4452 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
4453 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4454 "<section class=\"warning\">"] #[doc =
4455 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4456 #[doc = "<ul>"] #[doc =
4457 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4458 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4459 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
4460 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
4461 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
4462 "GPIO24 peripheral singleton"] GPIO24 <= virtual()), (@ peri_type #[doc =
4463 "GPIO25 peripheral singleton"] GPIO25 <= virtual()), (@ peri_type #[doc =
4464 "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
4465 "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
4466 "GPIO28 peripheral singleton"] GPIO28 <= virtual()), (@ peri_type #[doc =
4467 "GPIO29 peripheral singleton"] GPIO29 <= virtual()), (@ peri_type #[doc =
4468 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
4469 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4470 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4471 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4472 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
4473 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4474 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4475 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4476 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
4477 peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
4478 ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "CLINT peripheral singleton"]
4479 CLINT <= CLINT() (unstable)), (@ peri_type #[doc = "CACHE peripheral singleton"]
4480 CACHE <= CACHE() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"]
4481 DMA <= DMA() (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <=
4482 ECC() (unstable)), (@ peri_type #[doc = "ECDSA peripheral singleton"] ECDSA <=
4483 ECDSA() (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <=
4484 EFUSE() (unstable)), (@ peri_type #[doc = "ETM peripheral singleton"] ETM <=
4485 SOC_ETM() (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <=
4486 GPIO() (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD
4487 <= GPIO_EXT() (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"]
4488 HP_APM <= HP_APM() (unstable)), (@ peri_type #[doc =
4489 "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)), (@ peri_type #[doc
4490 = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)),
4491 (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : {
4492 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4493 peri_type #[doc = "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : {
4494 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4495 (unstable)), (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"]
4496 INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
4497 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
4498 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
4499 #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)), (@
4500 peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)),
4501 (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <= LP_APM()
4502 (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"] LP_CLKRST <=
4503 LP_CLKRST() (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR
4504 <= LP_CLKRST() (unstable)), (@ peri_type #[doc = "LP_GPIO peripheral singleton"]
4505 LP_GPIO <= LP_GPIO() (unstable)), (@ peri_type #[doc =
4506 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)), (@
4507 peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LPPERI()
4508 (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE <=
4509 LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
4510 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
4511 "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc
4512 = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)),
4513 (@ peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON <=
4514 MODEM_LPCON() (unstable)), (@ peri_type #[doc =
4515 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
4516 (@ peri_type #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@
4517 peri_type #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@
4518 peri_type #[doc = "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@
4519 peri_type #[doc = "RNG peripheral singleton"] RNG <= LPPERI() (unstable)), (@
4520 peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
4521 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4522 (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <= SLC()
4523 (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
4524 (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
4525 (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
4526 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4527 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
4528 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
4529 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
4530 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
4531 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
4532 (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
4533 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
4534 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
4535 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
4536 disable_peri_interrupt })), (@ peri_type #[doc = "UART2 peripheral singleton"]
4537 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
4538 disable_peri_interrupt })), (@ peri_type #[doc =
4539 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4540 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4541 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
4542 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
4543 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
4544 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
4545 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
4546 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
4547 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
4548 (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <= virtual(WIFI_BB : {
4549 bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt }, WIFI_MAC : {
4550 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : {
4551 bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt })), (@ peri_type
4552 #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)), (@
4553 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
4554 virtual() (unstable)), (@ peri_type #[doc =
4555 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
4556 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
4557 virtual() (unstable)), (@ peri_type #[doc =
4558 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
4559 _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
4560 (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
4561 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
4562 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
4563 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (GPIO29),
4564 (DMA_CH0(unstable)), (DMA_CH1(unstable)), (APB_SARADC(unstable)),
4565 (ASSIST_DEBUG(unstable)), (CLINT(unstable)), (CACHE(unstable)), (DMA(unstable)),
4566 (ECC(unstable)), (ECDSA(unstable)), (EFUSE(unstable)), (ETM(unstable)),
4567 (GPIO(unstable)), (GPIO_SD(unstable)), (HP_APM(unstable)), (HP_SYS(unstable)),
4568 (I2C_ANA_MST(unstable)), (I2C0), (I2S0(unstable)), (INTERRUPT_CORE0(unstable)),
4569 (INTPRI(unstable)), (IO_MUX(unstable)), (LP_ANA(unstable)), (LP_AON(unstable)),
4570 (LP_APM(unstable)), (LP_CLKRST(unstable)), (LPWR(unstable)), (LP_GPIO(unstable)),
4571 (LP_IO_MUX(unstable)), (LP_PERI(unstable)), (LP_TEE(unstable)),
4572 (RTC_TIMER(unstable)), (LP_WDT(unstable)), (MEM_MONITOR(unstable)),
4573 (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)), (PAU(unstable)),
4574 (PCR(unstable)), (PMU(unstable)), (RNG(unstable)), (SHA(unstable)),
4575 (SLC(unstable)), (SPI0(unstable)), (SPI1(unstable)), (SPI2), (SYSTEM(unstable)),
4576 (SYSTIMER(unstable)), (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
4577 (UART0), (UART1), (UART2), (USB_DEVICE(unstable)), (ADC1(unstable)),
4578 (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (WIFI),
4579 (PSRAM(unstable)), (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
4580 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
4581 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 1, AhbGdmaChannel), (I2S0,
4582 I2s0, 3, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel)));
4583 };
4584}
4585#[macro_export]
4612#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4613macro_rules! for_each_gpio {
4614 ($($pattern:tt => $code:tt;)*) => {
4615 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
4616 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
4617 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
4618 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
4619 _for_each_inner_gpio!((3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
4620 [Output]))); _for_each_inner_gpio!((4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 =>
4621 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTCK) ()
4622 ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTDO _2 => FSPICLK)
4623 (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2 =>
4624 FSPID) (_2 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((8, GPIO8(_2 =>
4625 FSPICS0) (_2 => FSPICS0) ([Input] [Output]))); _for_each_inner_gpio!((9, GPIO9()
4626 () ([Input] [Output]))); _for_each_inner_gpio!((10, GPIO10(_0 => U0RXD) ()
4627 ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11() (_0 => U0TXD) ([Input]
4628 [Output]))); _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
4629 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
4630 _for_each_inner_gpio!((14, GPIO14() (_0 => FSPICS1) ([Input] [Output])));
4631 _for_each_inner_gpio!((15, GPIO15(_0 => FSPICS0) (_0 => FSPICS0) ([Input]
4632 [Output]))); _for_each_inner_gpio!((16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ)
4633 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => FSPIWP) (_0 =>
4634 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18() () ([Input]
4635 [Output]))); _for_each_inner_gpio!((19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
4636 ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_0 => FSPICLK) (_0 =>
4637 FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21(_0 => FSPID) (_0
4638 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22(_0 =>
4639 SDIO_DATA2) () ([Input] [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 =>
4640 SDIO_DATA3) () ([Input] [Output]))); _for_each_inner_gpio!((24, GPIO24() ()
4641 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_0 => SDIO_CMD) ()
4642 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_0 => SDIO_CLK) ()
4643 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27(_0 => SDIO_DATA0) ()
4644 ([Input] [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SDIO_DATA1) ()
4645 ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() () ([Input]
4646 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
4647 GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
4648 [Output])), (3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
4649 [Output])), (4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) ([Input]
4650 [Output])), (5, GPIO5(_0 => MTCK) () ([Input] [Output])), (6, GPIO6(_0 => MTDO _2
4651 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_2 =>
4652 FSPID) ([Input] [Output])), (8, GPIO8(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
4653 [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10(_0 => U0RXD) ()
4654 ([Input] [Output])), (11, GPIO11() (_0 => U0TXD) ([Input] [Output])), (12,
4655 GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14,
4656 GPIO14() (_0 => FSPICS1) ([Input] [Output])), (15, GPIO15(_0 => FSPICS0) (_0 =>
4657 FSPICS0) ([Input] [Output])), (16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ) ([Input]
4658 [Output])), (17, GPIO17(_0 => FSPIWP) (_0 => FSPIWP) ([Input] [Output])), (18,
4659 GPIO18() () ([Input] [Output])), (19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
4660 ([Input] [Output])), (20, GPIO20(_0 => FSPICLK) (_0 => FSPICLK) ([Input]
4661 [Output])), (21, GPIO21(_0 => FSPID) (_0 => FSPID) ([Input] [Output])), (22,
4662 GPIO22(_0 => SDIO_DATA2) () ([Input] [Output])), (23, GPIO23(_0 => SDIO_DATA3) ()
4663 ([Input] [Output])), (24, GPIO24() () ([Input] [Output])), (25, GPIO25(_0 =>
4664 SDIO_CMD) () ([Input] [Output])), (26, GPIO26(_0 => SDIO_CLK) () ([Input]
4665 [Output])), (27, GPIO27(_0 => SDIO_DATA0) () ([Input] [Output])), (28, GPIO28(_0
4666 => SDIO_DATA1) () ([Input] [Output])), (29, GPIO29() () ([Input] [Output]))));
4667 };
4668}
4669#[macro_export]
4696#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4697macro_rules! for_each_analog_function {
4698 ($($pattern:tt => $code:tt;)*) => {
4699 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
4700 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
4701 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
4702 _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
4703 _for_each_inner_analog_function!((ADC1_CH1, GPIO3));
4704 _for_each_inner_analog_function!((ADC1_CH2, GPIO4));
4705 _for_each_inner_analog_function!((ADC1_CH3, GPIO5));
4706 _for_each_inner_analog_function!((ZCD0, GPIO8));
4707 _for_each_inner_analog_function!((ZCD1, GPIO9));
4708 _for_each_inner_analog_function!((USJ_DM, GPIO12));
4709 _for_each_inner_analog_function!((USJ_DP, GPIO13));
4710 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
4711 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO3));
4712 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO4));
4713 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO5));
4714 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO8));
4715 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO9));
4716 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (XTAL_32K_N, GPIO1),
4717 (ADC1_CH0, GPIO1), (ADC1_CH1, GPIO3), (ADC1_CH2, GPIO4), (ADC1_CH3, GPIO5),
4718 (ZCD0, GPIO8), (ZCD1, GPIO9), (USJ_DM, GPIO12), (USJ_DP, GPIO13)));
4719 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1),
4720 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO3), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO4),
4721 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO5)));
4722 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO8), ((ZCD1, ZCDn, 1),
4723 GPIO9)));
4724 };
4725}
4726#[macro_export]
4764#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4765macro_rules! for_each_lp_function {
4766 ($($pattern:tt => $code:tt;)*) => {
4767 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
4768 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
4769 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
4770 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
4771 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
4772 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
4773 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
4774 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _1));
4775 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
4776 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
4777 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
4778 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
4779 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
4780 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
4781 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()));
4782 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _1), (LP_GPIO1, GPIO1, _1),
4783 (LP_GPIO2, GPIO2, _1), (LP_GPIO3, GPIO3, _1), (LP_GPIO4, GPIO4, _1), (LP_GPIO5,
4784 GPIO5, _1), (LP_GPIO6, GPIO6, _1)));
4785 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, ()
4786 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()), ((LP_GPIO2, LP_GPIOn, 2),
4787 GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()), ((LP_GPIO4,
4788 LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()),
4789 ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ())));
4790 };
4791}
4792#[macro_export]
4823#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4824macro_rules! for_each_iomux_function {
4825 ($($pattern:tt => $code:tt;)*) => {
4826 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
4827 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
4828 _for_each_inner_iomux_function!((MTMS, GPIO3, _0));
4829 _for_each_inner_iomux_function!((FSPIHD, GPIO3, _2));
4830 _for_each_inner_iomux_function!((MTDI, GPIO4, _0));
4831 _for_each_inner_iomux_function!((FSPIWP, GPIO4, _2));
4832 _for_each_inner_iomux_function!((MTCK, GPIO5, _0));
4833 _for_each_inner_iomux_function!((MTDO, GPIO6, _0));
4834 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
4835 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
4836 _for_each_inner_iomux_function!((FSPICS0, GPIO8, _2));
4837 _for_each_inner_iomux_function!((U0RXD, GPIO10, _0));
4838 _for_each_inner_iomux_function!((U0TXD, GPIO11, _0));
4839 _for_each_inner_iomux_function!((FSPICS1, GPIO14, _0));
4840 _for_each_inner_iomux_function!((FSPICS0, GPIO15, _0));
4841 _for_each_inner_iomux_function!((FSPIQ, GPIO16, _0));
4842 _for_each_inner_iomux_function!((FSPIWP, GPIO17, _0));
4843 _for_each_inner_iomux_function!((FSPIHD, GPIO19, _0));
4844 _for_each_inner_iomux_function!((FSPICLK, GPIO20, _0));
4845 _for_each_inner_iomux_function!((FSPID, GPIO21, _0));
4846 _for_each_inner_iomux_function!((SDIO_DATA2, GPIO22, _0));
4847 _for_each_inner_iomux_function!((SDIO_DATA3, GPIO23, _0));
4848 _for_each_inner_iomux_function!((SDIO_CMD, GPIO25, _0));
4849 _for_each_inner_iomux_function!((SDIO_CLK, GPIO26, _0));
4850 _for_each_inner_iomux_function!((SDIO_DATA0, GPIO27, _0));
4851 _for_each_inner_iomux_function!((SDIO_DATA1, GPIO28, _0));
4852 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO8, _2));
4853 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO14, _0));
4854 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO15, _0));
4855 _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO22, _0));
4856 _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0));
4857 _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO27, _0));
4858 _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO28, _0));
4859 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO3, _0),
4860 (FSPIHD, GPIO3, _2), (MTDI, GPIO4, _0), (FSPIWP, GPIO4, _2), (MTCK, GPIO5, _0),
4861 (MTDO, GPIO6, _0), (FSPICLK, GPIO6, _2), (FSPID, GPIO7, _2), (FSPICS0, GPIO8,
4862 _2), (U0RXD, GPIO10, _0), (U0TXD, GPIO11, _0), (FSPICS1, GPIO14, _0), (FSPICS0,
4863 GPIO15, _0), (FSPIQ, GPIO16, _0), (FSPIWP, GPIO17, _0), (FSPIHD, GPIO19, _0),
4864 (FSPICLK, GPIO20, _0), (FSPID, GPIO21, _0), (SDIO_DATA2, GPIO22, _0),
4865 (SDIO_DATA3, GPIO23, _0), (SDIO_CMD, GPIO25, _0), (SDIO_CLK, GPIO26, _0),
4866 (SDIO_DATA0, GPIO27, _0), (SDIO_DATA1, GPIO28, _0)));
4867 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO8, _2),
4868 ((FSPICS1, FSPICSn, 1), GPIO14, _0), ((FSPICS0, FSPICSn, 0), GPIO15, _0)));
4869 _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA2, SDIO_DATAn, 2), GPIO22,
4870 _0), ((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0), ((SDIO_DATA0, SDIO_DATAn, 0),
4871 GPIO27, _0), ((SDIO_DATA1, SDIO_DATAn, 1), GPIO28, _0)));
4872 };
4873}
4874#[macro_export]
4891#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4892macro_rules! gpio_for_signal {
4893 (XTAL_32K_P $(, $_fallback:literal)?) => {
4894 "GPIO0"
4895 };
4896 (LP_GPIO0 $(, $_fallback:literal)?) => {
4897 "GPIO0"
4898 };
4899 (XTAL_32K_N $(, $_fallback:literal)?) => {
4900 "GPIO1"
4901 };
4902 (ADC1_CH0 $(, $_fallback:literal)?) => {
4903 "GPIO1"
4904 };
4905 (LP_GPIO1 $(, $_fallback:literal)?) => {
4906 "GPIO1"
4907 };
4908 (FSPIQ $(, $_fallback:literal)?) => {
4909 "GPIO2"
4910 };
4911 (LP_GPIO2 $(, $_fallback:literal)?) => {
4912 "GPIO2"
4913 };
4914 (MTMS $(, $_fallback:literal)?) => {
4915 "GPIO3"
4916 };
4917 (FSPIHD $(, $_fallback:literal)?) => {
4918 "GPIO3"
4919 };
4920 (ADC1_CH1 $(, $_fallback:literal)?) => {
4921 "GPIO3"
4922 };
4923 (LP_GPIO3 $(, $_fallback:literal)?) => {
4924 "GPIO3"
4925 };
4926 (MTDI $(, $_fallback:literal)?) => {
4927 "GPIO4"
4928 };
4929 (FSPIWP $(, $_fallback:literal)?) => {
4930 "GPIO4"
4931 };
4932 (ADC1_CH2 $(, $_fallback:literal)?) => {
4933 "GPIO4"
4934 };
4935 (LP_GPIO4 $(, $_fallback:literal)?) => {
4936 "GPIO4"
4937 };
4938 (MTCK $(, $_fallback:literal)?) => {
4939 "GPIO5"
4940 };
4941 (ADC1_CH3 $(, $_fallback:literal)?) => {
4942 "GPIO5"
4943 };
4944 (LP_GPIO5 $(, $_fallback:literal)?) => {
4945 "GPIO5"
4946 };
4947 (MTDO $(, $_fallback:literal)?) => {
4948 "GPIO6"
4949 };
4950 (FSPICLK $(, $_fallback:literal)?) => {
4951 "GPIO6"
4952 };
4953 (LP_GPIO6 $(, $_fallback:literal)?) => {
4954 "GPIO6"
4955 };
4956 (FSPID $(, $_fallback:literal)?) => {
4957 "GPIO7"
4958 };
4959 (FSPICS0 $(, $_fallback:literal)?) => {
4960 "GPIO8"
4961 };
4962 (ZCD0 $(, $_fallback:literal)?) => {
4963 "GPIO8"
4964 };
4965 (ZCD1 $(, $_fallback:literal)?) => {
4966 "GPIO9"
4967 };
4968 (U0RXD $(, $_fallback:literal)?) => {
4969 "GPIO10"
4970 };
4971 (U0TXD $(, $_fallback:literal)?) => {
4972 "GPIO11"
4973 };
4974 (USJ_DM $(, $_fallback:literal)?) => {
4975 "GPIO12"
4976 };
4977 (USJ_DP $(, $_fallback:literal)?) => {
4978 "GPIO13"
4979 };
4980 (FSPICS1 $(, $_fallback:literal)?) => {
4981 "GPIO14"
4982 };
4983 (SDIO_DATA2 $(, $_fallback:literal)?) => {
4984 "GPIO22"
4985 };
4986 (SDIO_DATA3 $(, $_fallback:literal)?) => {
4987 "GPIO23"
4988 };
4989 (SDIO_CMD $(, $_fallback:literal)?) => {
4990 "GPIO25"
4991 };
4992 (SDIO_CLK $(, $_fallback:literal)?) => {
4993 "GPIO26"
4994 };
4995 (SDIO_DATA0 $(, $_fallback:literal)?) => {
4996 "GPIO27"
4997 };
4998 (SDIO_DATA1 $(, $_fallback:literal)?) => {
4999 "GPIO28"
5000 };
5001 ($_signal:ident, $fallback:literal) => {
5002 $fallback
5003 };
5004}
5005#[macro_export]
5009#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5010macro_rules! define_io_mux_signals {
5011 () => {
5012 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5013 #[derive(Debug, PartialEq, Copy, Clone)]
5014 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5015 #[doc(hidden)]
5016 pub enum InputSignal {
5017 U0RXD = 6,
5018 U0CTS = 7,
5019 U0DSR = 8,
5020 U1RXD = 9,
5021 U1CTS = 10,
5022 U1DSR = 11,
5023 I2S_MCLK = 12,
5024 I2SO_BCK = 13,
5025 I2SO_WS = 14,
5026 I2SI_SD = 15,
5027 I2SI_BCK = 16,
5028 I2SI_WS = 17,
5029 CPU_GPIO_0 = 27,
5030 CPU_GPIO_1 = 28,
5031 CPU_GPIO_2 = 29,
5032 CPU_GPIO_3 = 30,
5033 CPU_GPIO_4 = 31,
5034 CPU_GPIO_5 = 32,
5035 CPU_GPIO_6 = 33,
5036 CPU_GPIO_7 = 34,
5037 USB_JTAG_TDO_BRIDGE = 35,
5038 I2CEXT0_SCL = 46,
5039 I2CEXT0_SDA = 47,
5040 FSPICLK = 64,
5041 FSPIQ = 65,
5042 FSPID = 66,
5043 FSPIHD = 67,
5044 FSPIWP = 68,
5045 FSPICS0 = 69,
5046 U2RXD = 72,
5047 U2CTS = 73,
5048 U2DSR = 74,
5049 SIG_IN_FUNC97 = 97,
5050 SIG_IN_FUNC98 = 98,
5051 SIG_IN_FUNC99 = 99,
5052 SIG_IN_FUNC100 = 100,
5053 SDIO_CLK,
5054 SDIO_CMD,
5055 SDIO_DATA0,
5056 SDIO_DATA1,
5057 SDIO_DATA2,
5058 SDIO_DATA3,
5059 MTDI,
5060 MTDO,
5061 MTCK,
5062 MTMS,
5063 }
5064 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5065 #[derive(Debug, PartialEq, Copy, Clone)]
5066 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5067 #[doc(hidden)]
5068 pub enum OutputSignal {
5069 LEDC_LS_SIG0 = 0,
5070 LEDC_LS_SIG1 = 1,
5071 LEDC_LS_SIG2 = 2,
5072 LEDC_LS_SIG3 = 3,
5073 LEDC_LS_SIG4 = 4,
5074 LEDC_LS_SIG5 = 5,
5075 U0TXD = 6,
5076 U0RTS = 7,
5077 U0DTR = 8,
5078 U1TXD = 9,
5079 U1RTS = 10,
5080 U1DTR = 11,
5081 I2S_MCLK = 12,
5082 I2SO_BCK = 13,
5083 I2SO_WS = 14,
5084 I2SO_SD = 15,
5085 I2SI_BCK = 16,
5086 I2SI_WS = 17,
5087 I2SO_SD1 = 18,
5088 CPU_GPIO_0 = 27,
5089 CPU_GPIO_1 = 28,
5090 CPU_GPIO_2 = 29,
5091 CPU_GPIO_3 = 30,
5092 CPU_GPIO_4 = 31,
5093 CPU_GPIO_5 = 32,
5094 CPU_GPIO_6 = 33,
5095 CPU_GPIO_7 = 34,
5096 I2CEXT0_SCL = 46,
5097 I2CEXT0_SDA = 47,
5098 FSPICLK = 64,
5099 FSPIQ = 65,
5100 FSPID = 66,
5101 FSPIHD = 67,
5102 FSPIWP = 68,
5103 FSPICS0 = 69,
5104 U2TXD = 72,
5105 U2RTS = 73,
5106 U2DTR = 74,
5107 FSPICS1 = 102,
5108 FSPICS2 = 103,
5109 FSPICS3 = 104,
5110 FSPICS4 = 105,
5111 FSPICS5 = 106,
5112 SDIO_TOHOST_INT = 124,
5113 GPIO = 256,
5114 }
5115 };
5116}
5117#[macro_export]
5124#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5125macro_rules! define_lp_functions {
5126 () => {
5127 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5132 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5133 #[doc(hidden)]
5134 pub enum LpFunction {
5135 _1 = 1,
5137 }
5138 impl LpFunction {
5139 pub const LP_GPIO: Self = Self::_1;
5141 }
5142 };
5143}
5144#[macro_export]
5157#[expect(clippy::crate_in_macro_def)]
5158#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5159macro_rules! define_io_mux_reg {
5160 () => {
5161 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
5162 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
5163 }
5164 };
5165}