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.default_clock_source") => {
239 2
240 };
241 ("i2s.default_clock_source", str) => {
242 stringify!(2)
243 };
244 ("i2s.mclk_divider_bit_width") => {
245 9
246 };
247 ("i2s.mclk_divider_bit_width", str) => {
248 stringify!(9)
249 };
250 ("i2s.max_ws_width") => {
251 512
252 };
253 ("i2s.max_ws_width", str) => {
254 stringify!(512)
255 };
256 ("i2s.clock_configured_by_pcr") => {
257 true
258 };
259 ("i2s.clock_configured_by_hp_sys_clkrst") => {
260 false
261 };
262 ("i2s.supports_pdm_rx_hp_filter") => {
263 false
264 };
265 ("i2s.supports_pdm_tx") => {
266 true
267 };
268 ("i2s.supports_pdm_rx") => {
269 true
270 };
271 ("i2s.supports_pcm2pdm") => {
272 true
273 };
274 ("i2s.supports_pdm2pcm") => {
275 false
276 };
277 ("bt.controller") => {
278 "npl"
279 };
280 ("wifi.has_wifi6") => {
281 true
282 };
283 ("wifi.mac_version") => {
284 3
285 };
286 ("wifi.mac_version", str) => {
287 stringify!(3)
288 };
289 ("wifi.has_5g") => {
290 false
291 };
292 ("wifi.csi_supported") => {
293 true
294 };
295 ("phy.combo_module") => {
296 true
297 };
298 ("timergroup.timg_has_timer1") => {
299 false
300 };
301 ("timergroup.timg_has_divcnt_rst") => {
302 true
303 };
304 ("timergroup.rc_fast_calibration_divider_min_rev") => {
305 0
306 };
307 ("timergroup.rc_fast_calibration_divider") => {
308 32
309 };
310 ("timergroup.rc_fast_calibration_tick_enable") => {
311 false
312 };
313 ("ecc.zero_extend_writes") => {
314 true
315 };
316 ("ecc.separate_jacobian_point_memory") => {
317 true
318 };
319 ("ecc.has_memory_clock_gate") => {
320 true
321 };
322 ("ecc.supports_enhanced_security") => {
323 true
324 };
325 ("ecc.mem_block_size") => {
326 32
327 };
328 ("rng.apb_cycle_wait_num") => {
329 16
330 };
331 ("rng.apb_cycle_wait_num", str) => {
332 stringify!(16)
333 };
334 ("rng.trng_supported") => {
335 false
336 };
337 ("rng.is_lp_sys") => {
338 true
339 };
340 ("sleep.light_sleep") => {
341 true
342 };
343 ("sleep.deep_sleep") => {
344 true
345 };
346 ("sleep.rejectable_mask") => {
347 4094
348 };
349 ("sleep.ext1_version") => {
350 2
351 };
352 ("sleep.ext1_version", str) => {
353 stringify!(2)
354 };
355 ("sleep.pin_wakeup_version") => {
356 3
357 };
358 ("sleep.pin_wakeup_version", str) => {
359 stringify!(3)
360 };
361 ("sleep.deep_sleep_needs_gpio_isolation") => {
362 false
363 };
364 ("assist_debug.has_sp_monitor") => {
365 true
366 };
367 ("assist_debug.has_region_monitor") => {
368 true
369 };
370 ("dma.mem2mem_requires_peripheral") => {
371 false
372 };
373 ("dma.ext_mem_configurable_block_size") => {
374 false
375 };
376 ("dma.separate_in_out_interrupts") => {
377 true
378 };
379 ("dma.gdma_version") => {
380 2
381 };
382 ("dma.gdma_version", str) => {
383 stringify!(2)
384 };
385 ("interrupts.status_registers") => {
386 3
387 };
388 ("interrupts.status_registers", str) => {
389 stringify!(3)
390 };
391 ("interrupts.disabled_interrupt") => {
392 0
393 };
394 ("mmu.page_size") => {
395 65536
396 };
397 ("mmu.page_size", str) => {
398 stringify!(65536)
399 };
400 ("mmu.entry_num") => {
401 512
402 };
403 ("mmu.entry_num", str) => {
404 stringify!(512)
405 };
406 ("psram.octal_spi") => {
407 false
408 };
409 ("psram.hex_spi") => {
410 false
411 };
412 ("psram.extmem_origin") => {
413 1107296256
414 };
415 ("psram.extmem_origin", str) => {
416 stringify!(1107296256)
417 };
418 ("rom.has_crc_le") => {
419 true
420 };
421 ("rom.has_crc_be") => {
422 true
423 };
424 ("rom.has_md5_bsd") => {
425 true
426 };
427 ("rom.has_md5_mbedtls") => {
428 false
429 };
430 ("soc.cpu_has_branch_predictor") => {
431 true
432 };
433 ("soc.cpu_has_csr_pc") => {
434 false
435 };
436 ("soc.multi_core_enabled") => {
437 false
438 };
439 ("soc.cpu_csr_prv_mode") => {
440 2064
441 };
442 ("soc.cpu_csr_prv_mode", str) => {
443 stringify!(2064)
444 };
445 ("soc.internal_memory_cached") => {
446 false
447 };
448 ("soc.has_swd_watchdog") => {
449 true
450 };
451 ("soc.cpu_mcause_mask") => {
452 31
453 };
454 ("soc.cpu_mcause_mask", str) => {
455 stringify!(31)
456 };
457 ("clock_tree.hp_root_clk") => {
458 [crate ::soc::clocks::HpRootClkConfig::Xtal, crate
459 ::soc::clocks::HpRootClkConfig::RcFast, crate
460 ::soc::clocks::HpRootClkConfig::PllF160m]
461 };
462 ("clock_tree.cpu_clk.divisor") => {
463 (0, 255)
464 };
465 ("clock_tree.ahb_clk.divisor") => {
466 (0, 255)
467 };
468 ("clock_tree.apb_clk.divisor") => {
469 (0, 255)
470 };
471 ("clock_tree.lp_fast_clk") => {
472 [crate ::soc::clocks::LpFastClkConfig::RcFast, crate
473 ::soc::clocks::LpFastClkConfig::XtalD2, crate
474 ::soc::clocks::LpFastClkConfig::Xtal]
475 };
476 ("clock_tree.lp_slow_clk") => {
477 [crate ::soc::clocks::LpSlowClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
478 ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
479 ::soc::clocks::LpSlowClkConfig::OscSlow]
480 };
481 ("clock_tree.timg_calibration_clock") => {
482 [crate ::soc::clocks::TimgCalibrationClockConfig::OscSlowClk, crate
483 ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
484 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
485 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
486 };
487 ("clock_tree.uart.function_clock.sclk") => {
488 [crate ::soc::clocks::UartFunctionClockSclk::Xtal, crate
489 ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
490 ::soc::clocks::UartFunctionClockSclk::RcFast]
491 };
492 ("clock_tree.uart.function_clock.div_num") => {
493 (0, 255)
494 };
495 ("clock_tree.uart.baud_rate_generator.fractional") => {
496 (0, 15)
497 };
498 ("clock_tree.uart.baud_rate_generator.integral") => {
499 (0, 4095)
500 };
501 ("clock_tree.timg.function_clock") => {
502 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
503 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
504 ::soc::clocks::TimgFunctionClockConfig::PllF80m]
505 };
506 ("clock_tree.timg.wdt_clock") => {
507 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
508 ::soc::clocks::TimgWdtClockConfig::RcFastClk, crate
509 ::soc::clocks::TimgWdtClockConfig::PllF80m]
510 };
511 ("clock_tree.i2c.function_clock.sclk") => {
512 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
513 ::soc::clocks::I2cFunctionClockSclk::RcFast]
514 };
515 ("clock_tree.i2c.function_clock.div_num") => {
516 (0, 255)
517 };
518 ("clock_tree.spi.function_clock") => {
519 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
520 ::soc::clocks::SpiFunctionClockConfig::PllF160m, crate
521 ::soc::clocks::SpiFunctionClockConfig::RcFast]
522 };
523}
524#[macro_export]
525#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
526macro_rules! for_each_dedicated_gpio {
527 ($($pattern:tt => $code:tt;)*) => {
528 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
529 tt) => {} } _for_each_inner_dedicated_gpio!((0));
530 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
531 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
532 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
533 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
534 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
535 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
536 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
537 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
538 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
539 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
540 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
541 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
542 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
543 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
544 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
545 };
546}
547#[macro_export]
551#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
552macro_rules! define_lp_io_signals {
553 () => {};
554}
555#[macro_export]
556#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
557macro_rules! for_each_ecc_working_mode {
558 ($($pattern:tt => $code:tt;)*) => {
559 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
560 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
561 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
562 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
563 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
564 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
565 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
566 _for_each_inner_ecc_working_mode!((7,
567 AffinePointVerificationAndJacobianPointMultiplication));
568 _for_each_inner_ecc_working_mode!((8, ModularAddition));
569 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
570 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
571 _for_each_inner_ecc_working_mode!((11, ModularDivision));
572 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
573 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
574 JacobianPointMultiplication), (5, AffinePointAddition), (6,
575 JacobianPointVerification), (7,
576 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
577 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
578 };
579}
580#[macro_export]
581#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
582macro_rules! for_each_ecc_curve {
583 ($($pattern:tt => $code:tt;)*) => {
584 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
585 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
586 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
587 P192, 192), (1, P256, 256)));
588 };
589}
590#[macro_export]
591#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
592macro_rules! for_each_sha_algorithm {
593 ($($pattern:tt => $code:tt;)*) => {
594 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
595 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
596 (insecure_against : "collision", "length extension"), 0));
597 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
598 (insecure_against : "length extension"), 1));
599 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
600 (insecure_against : "length extension"), 2));
601 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
602 (insecure_against : "collision", "length extension"), 0), (Sha224,
603 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
604 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
605 2)));
606 };
607}
608#[macro_export]
609#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
610macro_rules! for_each_wakeup_source {
611 ($($pattern:tt => $code:tt;)*) => {
612 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
613 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
614 _for_each_inner_wakeup_source!((Gpio, 2));
615 _for_each_inner_wakeup_source!((WifiBeacon, 3));
616 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
617 5)); _for_each_inner_wakeup_source!((Uart0, 6));
618 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
619 8)); _for_each_inner_wakeup_source!((Uart2, 9));
620 _for_each_inner_wakeup_source!((Bt, 10)); _for_each_inner_wakeup_source!((LpCore,
621 11)); _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3),
622 (Timer, 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Uart2, 9), (Bt, 10),
623 (LpCore, 11)));
624 };
625}
626#[macro_export]
627#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
628macro_rules! for_each_dma_engine {
629 ($($pattern:tt => $code:tt;)*) => {
630 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
631 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
632 _for_each_inner_dma_engine!((all("AHB_GDMA")));
633 };
634}
635#[macro_export]
636#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
637macro_rules! for_each_dma_channel {
638 ($($pattern:tt => $code:tt;)*) => {
639 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
640 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
641 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
642 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
643 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
644 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, I2S0, SHA]));
645 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
646 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, I2S0, SHA]));
647 _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0), ("AHB_GDMA",
648 DMA_CH1))); _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA",
649 any_channel = AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
650 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
651 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, I2S0, SHA]),
652 ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1,
653 compatible = [SPI2, I2S0, SHA])));
654 _for_each_inner_dma_channel!((no_own_interrupt));
655 };
656}
657#[macro_export]
658#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
659macro_rules! for_each_dma_channel_peri_pair {
660 ($($pattern:tt => $code:tt;)*) => {
661 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
662 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
663 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
664 I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
665 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
666 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
667 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
668 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
669 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
670 AhbGdmaChannel, I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
671 any_channel = AhbGdmaChannel, SHA));
672 _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0, SPI2),
673 ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH1,
674 SPI2), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, SHA)));
675 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
676 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0),
677 ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA)));
678 };
679}
680#[macro_export]
681#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
682macro_rules! for_each_mem2mem_channel {
683 ($($pattern:tt => $code:tt;)*) => {
684 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
685 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
686 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
687 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
688 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0, 4, 1,
689 5)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel));
690 _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma, AhbGdmaChannel,
691 DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5)));
692 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
693 4, 1, 5))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
694 AhbGdmaChannel)));
695 };
696}
697#[macro_export]
698#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
699macro_rules! with_i2s_dma_engine {
700 ($($pattern:tt => $code:tt;)*) => {
701 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
702 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
703 };
704}
705#[macro_export]
706#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
707macro_rules! with_sha_dma_engine {
708 ($($pattern:tt => $code:tt;)*) => {
709 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
710 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
711 };
712}
713#[macro_export]
714#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
715macro_rules! with_spi_master_dma_engine {
716 ($($pattern:tt => $code:tt;)*) => {
717 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
718 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
719 };
720}
721#[macro_export]
722#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
723macro_rules! with_spi_slave_dma_engine {
724 ($($pattern:tt => $code:tt;)*) => {
725 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
726 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
727 };
728}
729#[macro_export]
730#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
731macro_rules! for_each_interrupt {
732 ($($pattern:tt => $code:tt;)*) => {
733 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
734 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
735 _for_each_inner_interrupt!(([reserved 0] 1));
736 _for_each_inner_interrupt!(([reserved 1] 2));
737 _for_each_inner_interrupt!(([reserved 2] 3));
738 _for_each_inner_interrupt!(([reserved 3] 4));
739 _for_each_inner_interrupt!(([reserved 4] 5));
740 _for_each_inner_interrupt!(([reserved 5] 6));
741 _for_each_inner_interrupt!(([reserved 6] 7));
742 _for_each_inner_interrupt!(([reserved 7] 8));
743 _for_each_inner_interrupt!(([reserved 8] 9));
744 _for_each_inner_interrupt!(([reserved 9] 10));
745 _for_each_inner_interrupt!(([reserved 10] 11));
746 _for_each_inner_interrupt!(([reserved 11] 12));
747 _for_each_inner_interrupt!(([reserved 12] 13));
748 _for_each_inner_interrupt!(([reserved 13] 14));
749 _for_each_inner_interrupt!(([reserved 14] 15));
750 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
751 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
752 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
753 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
754 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
755 7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
756 _for_each_inner_interrupt!(([direct_bindable 1] 25));
757 _for_each_inner_interrupt!(([direct_bindable 2] 26));
758 _for_each_inner_interrupt!(([direct_bindable 3] 27));
759 _for_each_inner_interrupt!(([direct_bindable 4] 28));
760 _for_each_inner_interrupt!(([direct_bindable 5] 29));
761 _for_each_inner_interrupt!(([direct_bindable 6] 30));
762 _for_each_inner_interrupt!(([direct_bindable 7] 31));
763 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
764 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
765 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
766 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
767 ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
768 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
769 ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
770 ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
771 ([direct_bindable 6] 30), ([direct_bindable 7] 31)));
772 };
773}
774#[macro_export]
775#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
776macro_rules! for_each_classified_interrupt {
777 ($($pattern:tt => $code:tt;)*) => {
778 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
779 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
780 24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
781 _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
782 _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
783 _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
784 _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
785 _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
786 _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
787 _for_each_inner_classified_interrupt!(([vector 0] 16));
788 _for_each_inner_classified_interrupt!(([vector 1] 17));
789 _for_each_inner_classified_interrupt!(([vector 2] 18));
790 _for_each_inner_classified_interrupt!(([vector 3] 19));
791 _for_each_inner_classified_interrupt!(([vector 4] 20));
792 _for_each_inner_classified_interrupt!(([vector 5] 21));
793 _for_each_inner_classified_interrupt!(([vector 6] 22));
794 _for_each_inner_classified_interrupt!(([vector 7] 23));
795 _for_each_inner_classified_interrupt!(([reserved 0] 1));
796 _for_each_inner_classified_interrupt!(([reserved 1] 2));
797 _for_each_inner_classified_interrupt!(([reserved 2] 3));
798 _for_each_inner_classified_interrupt!(([reserved 3] 4));
799 _for_each_inner_classified_interrupt!(([reserved 4] 5));
800 _for_each_inner_classified_interrupt!(([reserved 5] 6));
801 _for_each_inner_classified_interrupt!(([reserved 6] 7));
802 _for_each_inner_classified_interrupt!(([reserved 7] 8));
803 _for_each_inner_classified_interrupt!(([reserved 8] 9));
804 _for_each_inner_classified_interrupt!(([reserved 9] 10));
805 _for_each_inner_classified_interrupt!(([reserved 10] 11));
806 _for_each_inner_classified_interrupt!(([reserved 11] 12));
807 _for_each_inner_classified_interrupt!(([reserved 12] 13));
808 _for_each_inner_classified_interrupt!(([reserved 13] 14));
809 _for_each_inner_classified_interrupt!(([reserved 14] 15));
810 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
811 ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
812 ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
813 ([direct_bindable 7] 31))); _for_each_inner_classified_interrupt!((vector([vector
814 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector 3] 19), ([vector 4] 20),
815 ([vector 5] 21), ([vector 6] 22), ([vector 7] 23)));
816 _for_each_inner_classified_interrupt!((reserved([reserved 0] 1), ([reserved 1]
817 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
818 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
819 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
820 ([reserved 14] 15)));
821 };
822}
823#[macro_export]
824#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
825macro_rules! for_each_interrupt_priority {
826 ($($pattern:tt => $code:tt;)*) => {
827 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
828 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
829 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
830 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
831 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
832 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
833 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
834 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
835 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
836 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
837 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
838 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
839 Priority8, Level8)));
840 };
841}
842#[macro_export]
843#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
844macro_rules! for_each_sw_interrupt {
845 ($($pattern:tt => $code:tt;)*) => {
846 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
847 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
848 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
849 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
850 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
851 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
852 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
853 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
854 };
855}
856#[macro_export]
857macro_rules! define_clock_tree_types {
1142 () => {
1143 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1144 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1145 pub enum I2cInstance {
1146 I2c0 = 0,
1147 }
1148 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1149 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1150 pub enum SpiInstance {
1151 Spi2 = 0,
1152 }
1153 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1154 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1155 pub enum TimgInstance {
1156 Timg0 = 0,
1157 Timg1 = 1,
1158 }
1159 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1160 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1161 pub enum UartInstance {
1162 Uart0 = 0,
1163 Uart1 = 1,
1164 Uart2 = 2,
1165 }
1166 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1168 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1169 pub enum XtalClkConfig {
1170 _40,
1172 }
1173 impl XtalClkConfig {
1174 pub fn value(&self) -> u32 {
1175 match self {
1176 XtalClkConfig::_40 => 40000000,
1177 }
1178 }
1179 }
1180 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1182 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1183 pub enum HpRootClkConfig {
1184 Xtal,
1186 RcFast,
1188 PllF160m,
1190 }
1191 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1195 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1196 pub struct CpuClkConfig {
1197 divisor: u32,
1198 }
1199 impl CpuClkConfig {
1200 pub const fn new(divisor: u32) -> Self {
1207 ::core::assert!(
1208 divisor <= 255,
1209 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1210 );
1211 Self { divisor }
1212 }
1213 pub(crate) fn divisor(self) -> u32 {
1214 self.divisor as u32
1215 }
1216 }
1217 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1221 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1222 pub struct AhbClkConfig {
1223 divisor: u32,
1224 }
1225 impl AhbClkConfig {
1226 pub const fn new(divisor: u32) -> Self {
1233 ::core::assert!(
1234 divisor <= 255,
1235 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1236 );
1237 Self { divisor }
1238 }
1239 pub(crate) fn divisor(self) -> u32 {
1240 self.divisor as u32
1241 }
1242 }
1243 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1247 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1248 pub struct ApbClkConfig {
1249 divisor: u32,
1250 }
1251 impl ApbClkConfig {
1252 pub const fn new(divisor: u32) -> Self {
1259 ::core::assert!(
1260 divisor <= 255,
1261 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1262 );
1263 Self { divisor }
1264 }
1265 pub(crate) fn divisor(self) -> u32 {
1266 self.divisor as u32
1267 }
1268 }
1269 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1271 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1272 pub enum LpFastClkConfig {
1273 RcFast,
1275 XtalD2,
1277 Xtal,
1279 }
1280 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1282 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1283 pub enum LpSlowClkConfig {
1284 RcSlow,
1286 #[cfg(use_xtal32k)]
1287 Xtal32k,
1289 OscSlow,
1291 }
1292 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1294 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1295 pub enum TimgCalibrationClockConfig {
1296 OscSlowClk,
1298 RcSlowClk,
1300 RcFastDivClk,
1302 #[cfg(use_xtal32k)]
1303 Xtal32kClk,
1305 }
1306 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1307 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1308 pub enum I2cFunctionClockSclk {
1309 #[default]
1310 Xtal,
1312 RcFast,
1314 }
1315 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1319 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1320 pub struct I2cFunctionClockConfig {
1321 sclk: I2cFunctionClockSclk,
1322 div_num: u32,
1323 }
1324 impl I2cFunctionClockConfig {
1325 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1332 ::core::assert!(
1333 div_num <= 255,
1334 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1335 );
1336 Self { sclk, div_num }
1337 }
1338 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1339 self.sclk
1340 }
1341 pub(crate) fn div_num(self) -> u32 {
1342 self.div_num as u32
1343 }
1344 }
1345 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1347 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1348 pub enum SpiFunctionClockConfig {
1349 Xtal,
1351 #[default]
1352 PllF160m,
1354 RcFast,
1356 }
1357 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1359 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1360 pub enum TimgFunctionClockConfig {
1361 #[default]
1362 XtalClk,
1364 RcFastClk,
1366 PllF80m,
1368 }
1369 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1371 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1372 pub enum TimgWdtClockConfig {
1373 #[default]
1374 XtalClk,
1376 RcFastClk,
1378 PllF80m,
1380 }
1381 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1382 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1383 pub enum UartFunctionClockSclk {
1384 #[default]
1385 Xtal,
1387 PllF80m,
1389 RcFast,
1391 }
1392 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1396 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1397 pub struct UartFunctionClockConfig {
1398 sclk: UartFunctionClockSclk,
1399 div_num: u32,
1400 }
1401 impl UartFunctionClockConfig {
1402 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1409 ::core::assert!(
1410 div_num <= 255,
1411 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1412 );
1413 Self { sclk, div_num }
1414 }
1415 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
1416 self.sclk
1417 }
1418 pub(crate) fn div_num(self) -> u32 {
1419 self.div_num as u32
1420 }
1421 }
1422 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1427 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1428 pub struct UartBaudRateGeneratorConfig {
1429 fractional: u32,
1430 integral: u32,
1431 }
1432 impl UartBaudRateGeneratorConfig {
1433 pub const fn new(fractional: u32, integral: u32) -> Self {
1443 ::core::assert!(
1444 fractional <= 15,
1445 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1446 );
1447 ::core::assert!(
1448 integral <= 4095,
1449 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1450 );
1451 Self {
1452 fractional,
1453 integral,
1454 }
1455 }
1456 pub(crate) fn fractional(self) -> u32 {
1457 self.fractional as u32
1458 }
1459 pub(crate) fn integral(self) -> u32 {
1460 self.integral as u32
1461 }
1462 }
1463 pub struct ClockTree {
1465 xtal_clk: Option<XtalClkConfig>,
1466 hp_root_clk: Option<HpRootClkConfig>,
1467 cpu_clk: Option<CpuClkConfig>,
1468 ahb_clk: Option<AhbClkConfig>,
1469 apb_clk: Option<ApbClkConfig>,
1470 lp_fast_clk: Option<LpFastClkConfig>,
1471 lp_slow_clk: Option<LpSlowClkConfig>,
1472 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1473 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
1474 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
1475 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1476 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1477 uart_function_clock: [Option<UartFunctionClockConfig>; 3],
1478 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 3],
1479 rc_fast_clk_refcount: u32,
1480 pll_clk_refcount: u32,
1481 #[cfg(use_xtal32k)]
1482 xtal32k_clk_refcount: u32,
1483 osc_slow_clk_refcount: u32,
1484 rc_slow_clk_refcount: u32,
1485 pll_f20m_refcount: u32,
1486 pll_f40m_refcount: u32,
1487 pll_f48m_refcount: u32,
1488 pll_f60m_refcount: u32,
1489 pll_f80m_refcount: u32,
1490 pll_f120m_refcount: u32,
1491 pll_f160m_refcount: u32,
1492 hp_root_clk_refcount: u32,
1493 cpu_clk_refcount: u32,
1494 apb_clk_refcount: u32,
1495 lp_fast_clk_refcount: u32,
1496 lp_slow_clk_refcount: u32,
1497 timg_calibration_clock_refcount: u32,
1498 i2c_function_clock_refcount: [u32; 1],
1499 spi_function_clock_refcount: [u32; 1],
1500 timg_function_clock_refcount: [u32; 2],
1501 timg_wdt_clock_refcount: [u32; 2],
1502 uart_function_clock_refcount: [u32; 3],
1503 uart_baud_rate_generator_refcount: [u32; 3],
1504 }
1505 impl ClockTree {
1506 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1508 CLOCK_TREE.with(f)
1509 }
1510 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1512 self.xtal_clk
1513 }
1514 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
1516 self.hp_root_clk
1517 }
1518 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1520 self.cpu_clk
1521 }
1522 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
1524 self.ahb_clk
1525 }
1526 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1528 self.apb_clk
1529 }
1530 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
1532 self.lp_fast_clk
1533 }
1534 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
1536 self.lp_slow_clk
1537 }
1538 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1540 self.timg_calibration_clock
1541 }
1542 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1544 self.i2c_function_clock[I2cInstance::I2c0 as usize]
1545 }
1546 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
1548 self.spi_function_clock[SpiInstance::Spi2 as usize]
1549 }
1550 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1552 self.timg_function_clock[TimgInstance::Timg0 as usize]
1553 }
1554 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1556 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
1557 }
1558 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1560 self.timg_function_clock[TimgInstance::Timg1 as usize]
1561 }
1562 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1564 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
1565 }
1566 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1568 self.uart_function_clock[UartInstance::Uart0 as usize]
1569 }
1570 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1572 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1573 }
1574 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1576 self.uart_function_clock[UartInstance::Uart1 as usize]
1577 }
1578 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1580 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
1581 }
1582 pub fn uart2_function_clock(&self) -> Option<UartFunctionClockConfig> {
1584 self.uart_function_clock[UartInstance::Uart2 as usize]
1585 }
1586 pub fn uart2_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1588 self.uart_baud_rate_generator[UartInstance::Uart2 as usize]
1589 }
1590 }
1591 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
1592 ::esp_sync::NonReentrantMutex::new(ClockTree {
1593 xtal_clk: None,
1594 hp_root_clk: None,
1595 cpu_clk: None,
1596 ahb_clk: None,
1597 apb_clk: None,
1598 lp_fast_clk: None,
1599 lp_slow_clk: None,
1600 timg_calibration_clock: None,
1601 i2c_function_clock: [None; 1],
1602 spi_function_clock: [None; 1],
1603 timg_function_clock: [None; 2],
1604 timg_wdt_clock: [None; 2],
1605 uart_function_clock: [None; 3],
1606 uart_baud_rate_generator: [None; 3],
1607 rc_fast_clk_refcount: 0,
1608 pll_clk_refcount: 0,
1609 #[cfg(use_xtal32k)]
1610 xtal32k_clk_refcount: 0,
1611 osc_slow_clk_refcount: 0,
1612 rc_slow_clk_refcount: 0,
1613 pll_f20m_refcount: 0,
1614 pll_f40m_refcount: 0,
1615 pll_f48m_refcount: 0,
1616 pll_f60m_refcount: 0,
1617 pll_f80m_refcount: 0,
1618 pll_f120m_refcount: 0,
1619 pll_f160m_refcount: 0,
1620 hp_root_clk_refcount: 0,
1621 cpu_clk_refcount: 0,
1622 apb_clk_refcount: 0,
1623 lp_fast_clk_refcount: 0,
1624 lp_slow_clk_refcount: 0,
1625 timg_calibration_clock_refcount: 0,
1626 i2c_function_clock_refcount: [0; 1],
1627 spi_function_clock_refcount: [0; 1],
1628 timg_function_clock_refcount: [0; 2],
1629 timg_wdt_clock_refcount: [0; 2],
1630 uart_function_clock_refcount: [0; 3],
1631 uart_baud_rate_generator_refcount: [0; 3],
1632 });
1633 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1634 ::core::sync::atomic::AtomicU32::new(0);
1635 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1636 ::core::sync::atomic::AtomicU32::new(0);
1637 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1638 ::core::sync::atomic::AtomicU32::new(0);
1639 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1640 ::core::sync::atomic::AtomicU32::new(0);
1641 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1642 ::core::sync::atomic::AtomicU32::new(0);
1643 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1644 ::core::sync::atomic::AtomicU32::new(0);
1645 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1646 ::core::sync::atomic::AtomicU32::new(0);
1647 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
1648 ::core::sync::atomic::AtomicU32::new(0);
1649 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1650 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1651 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
1652 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
1653 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
1654 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
1655 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
1656 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
1657 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
1658 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
1659 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 3] =
1660 [const { ::core::sync::atomic::AtomicU32::new(0) }; 3];
1661 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
1662 let old_config = clocks.xtal_clk.replace(config);
1663 refresh_xtal_clk_downstream(clocks);
1664 configure_xtal_clk_impl(clocks, old_config, config);
1665 }
1666 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
1667 clocks.xtal_clk
1668 }
1669 fn request_xtal_clk(_clocks: &mut ClockTree) {}
1670 fn release_xtal_clk(_clocks: &mut ClockTree) {}
1671 #[allow(unused_variables)]
1672 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
1673 config.value()
1674 }
1675 pub fn xtal_clk_frequency() -> u32 {
1676 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
1677 }
1678 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
1679 trace!("Requesting RC_FAST_CLK");
1680 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
1681 trace!("Enabling RC_FAST_CLK");
1682 enable_rc_fast_clk_impl(clocks, true);
1683 }
1684 }
1685 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
1686 trace!("Releasing RC_FAST_CLK");
1687 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
1688 trace!("Disabling RC_FAST_CLK");
1689 enable_rc_fast_clk_impl(clocks, false);
1690 }
1691 }
1692 pub fn rc_fast_clk_frequency() -> u32 {
1693 17500000
1694 }
1695 pub fn request_pll_clk(clocks: &mut ClockTree) {
1696 trace!("Requesting PLL_CLK");
1697 if increment_reference_count(&mut clocks.pll_clk_refcount) {
1698 trace!("Enabling PLL_CLK");
1699 request_xtal_clk(clocks);
1700 enable_pll_clk_impl(clocks, true);
1701 }
1702 }
1703 pub fn release_pll_clk(clocks: &mut ClockTree) {
1704 trace!("Releasing PLL_CLK");
1705 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
1706 trace!("Disabling PLL_CLK");
1707 enable_pll_clk_impl(clocks, false);
1708 release_xtal_clk(clocks);
1709 }
1710 }
1711 pub fn pll_clk_frequency() -> u32 {
1712 480000000
1713 }
1714 pub fn pll_clk_source_frequency() -> u32 {
1715 xtal_clk_frequency()
1716 }
1717 #[cfg(use_xtal32k)]
1718 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
1719 trace!("Requesting XTAL32K_CLK");
1720 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
1721 trace!("Enabling XTAL32K_CLK");
1722 enable_xtal32k_clk_impl(clocks, true);
1723 }
1724 }
1725 #[cfg(use_xtal32k)]
1726 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
1727 trace!("Releasing XTAL32K_CLK");
1728 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
1729 trace!("Disabling XTAL32K_CLK");
1730 enable_xtal32k_clk_impl(clocks, false);
1731 }
1732 }
1733 #[cfg(use_xtal32k)]
1734 pub fn xtal32k_clk_frequency() -> u32 {
1735 32768
1736 }
1737 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
1738 trace!("Requesting OSC_SLOW_CLK");
1739 if increment_reference_count(&mut clocks.osc_slow_clk_refcount) {
1740 trace!("Enabling OSC_SLOW_CLK");
1741 enable_osc_slow_clk_impl(clocks, true);
1742 }
1743 }
1744 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
1745 trace!("Releasing OSC_SLOW_CLK");
1746 if decrement_reference_count(&mut clocks.osc_slow_clk_refcount) {
1747 trace!("Disabling OSC_SLOW_CLK");
1748 enable_osc_slow_clk_impl(clocks, false);
1749 }
1750 }
1751 pub fn osc_slow_clk_frequency() -> u32 {
1752 32768
1753 }
1754 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
1755 trace!("Requesting RC_SLOW_CLK");
1756 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
1757 trace!("Enabling RC_SLOW_CLK");
1758 enable_rc_slow_clk_impl(clocks, true);
1759 }
1760 }
1761 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
1762 trace!("Releasing RC_SLOW_CLK");
1763 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
1764 trace!("Disabling RC_SLOW_CLK");
1765 enable_rc_slow_clk_impl(clocks, false);
1766 }
1767 }
1768 pub fn rc_slow_clk_frequency() -> u32 {
1769 136000
1770 }
1771 pub fn request_pll_f20m(clocks: &mut ClockTree) {
1772 trace!("Requesting PLL_F20M");
1773 if increment_reference_count(&mut clocks.pll_f20m_refcount) {
1774 trace!("Enabling PLL_F20M");
1775 request_pll_clk(clocks);
1776 enable_pll_f20m_impl(clocks, true);
1777 }
1778 }
1779 pub fn release_pll_f20m(clocks: &mut ClockTree) {
1780 trace!("Releasing PLL_F20M");
1781 if decrement_reference_count(&mut clocks.pll_f20m_refcount) {
1782 trace!("Disabling PLL_F20M");
1783 enable_pll_f20m_impl(clocks, false);
1784 release_pll_clk(clocks);
1785 }
1786 }
1787 pub fn pll_f20m_frequency() -> u32 {
1788 (pll_clk_frequency() / 24)
1789 }
1790 pub fn pll_f20m_source_frequency() -> u32 {
1791 pll_clk_frequency()
1792 }
1793 pub fn request_pll_f40m(clocks: &mut ClockTree) {
1794 trace!("Requesting PLL_F40M");
1795 if increment_reference_count(&mut clocks.pll_f40m_refcount) {
1796 trace!("Enabling PLL_F40M");
1797 request_pll_clk(clocks);
1798 enable_pll_f40m_impl(clocks, true);
1799 }
1800 }
1801 pub fn release_pll_f40m(clocks: &mut ClockTree) {
1802 trace!("Releasing PLL_F40M");
1803 if decrement_reference_count(&mut clocks.pll_f40m_refcount) {
1804 trace!("Disabling PLL_F40M");
1805 enable_pll_f40m_impl(clocks, false);
1806 release_pll_clk(clocks);
1807 }
1808 }
1809 pub fn pll_f40m_frequency() -> u32 {
1810 (pll_clk_frequency() / 12)
1811 }
1812 pub fn pll_f40m_source_frequency() -> u32 {
1813 pll_clk_frequency()
1814 }
1815 pub fn request_pll_f48m(clocks: &mut ClockTree) {
1816 trace!("Requesting PLL_F48M");
1817 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
1818 trace!("Enabling PLL_F48M");
1819 request_pll_clk(clocks);
1820 enable_pll_f48m_impl(clocks, true);
1821 }
1822 }
1823 pub fn release_pll_f48m(clocks: &mut ClockTree) {
1824 trace!("Releasing PLL_F48M");
1825 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
1826 trace!("Disabling PLL_F48M");
1827 enable_pll_f48m_impl(clocks, false);
1828 release_pll_clk(clocks);
1829 }
1830 }
1831 pub fn pll_f48m_frequency() -> u32 {
1832 (pll_clk_frequency() / 10)
1833 }
1834 pub fn pll_f48m_source_frequency() -> u32 {
1835 pll_clk_frequency()
1836 }
1837 pub fn request_pll_f60m(clocks: &mut ClockTree) {
1838 trace!("Requesting PLL_F60M");
1839 if increment_reference_count(&mut clocks.pll_f60m_refcount) {
1840 trace!("Enabling PLL_F60M");
1841 request_pll_clk(clocks);
1842 enable_pll_f60m_impl(clocks, true);
1843 }
1844 }
1845 pub fn release_pll_f60m(clocks: &mut ClockTree) {
1846 trace!("Releasing PLL_F60M");
1847 if decrement_reference_count(&mut clocks.pll_f60m_refcount) {
1848 trace!("Disabling PLL_F60M");
1849 enable_pll_f60m_impl(clocks, false);
1850 release_pll_clk(clocks);
1851 }
1852 }
1853 pub fn pll_f60m_frequency() -> u32 {
1854 (pll_clk_frequency() / 8)
1855 }
1856 pub fn pll_f60m_source_frequency() -> u32 {
1857 pll_clk_frequency()
1858 }
1859 pub fn request_pll_f80m(clocks: &mut ClockTree) {
1860 trace!("Requesting PLL_F80M");
1861 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
1862 trace!("Enabling PLL_F80M");
1863 request_pll_clk(clocks);
1864 enable_pll_f80m_impl(clocks, true);
1865 }
1866 }
1867 pub fn release_pll_f80m(clocks: &mut ClockTree) {
1868 trace!("Releasing PLL_F80M");
1869 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
1870 trace!("Disabling PLL_F80M");
1871 enable_pll_f80m_impl(clocks, false);
1872 release_pll_clk(clocks);
1873 }
1874 }
1875 pub fn pll_f80m_frequency() -> u32 {
1876 (pll_clk_frequency() / 6)
1877 }
1878 pub fn pll_f80m_source_frequency() -> u32 {
1879 pll_clk_frequency()
1880 }
1881 pub fn request_pll_f120m(clocks: &mut ClockTree) {
1882 trace!("Requesting PLL_F120M");
1883 if increment_reference_count(&mut clocks.pll_f120m_refcount) {
1884 trace!("Enabling PLL_F120M");
1885 request_pll_clk(clocks);
1886 enable_pll_f120m_impl(clocks, true);
1887 }
1888 }
1889 pub fn release_pll_f120m(clocks: &mut ClockTree) {
1890 trace!("Releasing PLL_F120M");
1891 if decrement_reference_count(&mut clocks.pll_f120m_refcount) {
1892 trace!("Disabling PLL_F120M");
1893 enable_pll_f120m_impl(clocks, false);
1894 release_pll_clk(clocks);
1895 }
1896 }
1897 pub fn pll_f120m_frequency() -> u32 {
1898 (pll_clk_frequency() / 4)
1899 }
1900 pub fn pll_f120m_source_frequency() -> u32 {
1901 pll_clk_frequency()
1902 }
1903 pub fn request_pll_f160m(clocks: &mut ClockTree) {
1904 trace!("Requesting PLL_F160M");
1905 if increment_reference_count(&mut clocks.pll_f160m_refcount) {
1906 trace!("Enabling PLL_F160M");
1907 request_pll_clk(clocks);
1908 enable_pll_f160m_impl(clocks, true);
1909 }
1910 }
1911 pub fn release_pll_f160m(clocks: &mut ClockTree) {
1912 trace!("Releasing PLL_F160M");
1913 if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
1914 trace!("Disabling PLL_F160M");
1915 enable_pll_f160m_impl(clocks, false);
1916 release_pll_clk(clocks);
1917 }
1918 }
1919 pub fn pll_f160m_frequency() -> u32 {
1920 (pll_clk_frequency() / 3)
1921 }
1922 pub fn pll_f160m_source_frequency() -> u32 {
1923 pll_clk_frequency()
1924 }
1925 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
1926 let old_selector = clocks.hp_root_clk.replace(new_selector);
1927 refresh_hp_root_clk_downstream(clocks);
1928 if clocks.hp_root_clk_refcount > 0 {
1929 match new_selector {
1930 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
1931 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
1932 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
1933 }
1934 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
1935 if let Some(old_selector) = old_selector {
1936 match old_selector {
1937 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
1938 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
1939 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
1940 }
1941 }
1942 } else {
1943 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
1944 }
1945 }
1946 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
1947 clocks.hp_root_clk
1948 }
1949 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
1950 trace!("Requesting HP_ROOT_CLK");
1951 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
1952 trace!("Enabling HP_ROOT_CLK");
1953 match unwrap!(clocks.hp_root_clk) {
1954 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
1955 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
1956 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
1957 }
1958 enable_hp_root_clk_impl(clocks, true);
1959 }
1960 }
1961 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
1962 trace!("Releasing HP_ROOT_CLK");
1963 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
1964 trace!("Disabling HP_ROOT_CLK");
1965 enable_hp_root_clk_impl(clocks, false);
1966 match unwrap!(clocks.hp_root_clk) {
1967 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
1968 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
1969 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
1970 }
1971 }
1972 }
1973 #[allow(unused_variables)]
1974 pub fn hp_root_clk_config_frequency(
1975 clocks: &mut ClockTree,
1976 config: HpRootClkConfig,
1977 ) -> u32 {
1978 match config {
1979 HpRootClkConfig::Xtal => xtal_clk_frequency(),
1980 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
1981 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
1982 }
1983 }
1984 pub fn hp_root_clk_frequency() -> u32 {
1985 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
1986 }
1987 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
1988 match source {
1989 HpRootClkConfig::Xtal => xtal_clk_frequency(),
1990 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
1991 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
1992 }
1993 }
1994 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
1995 let old_config = clocks.cpu_clk.replace(config);
1996 refresh_cpu_clk_downstream(clocks);
1997 configure_cpu_clk_impl(clocks, old_config, config);
1998 }
1999 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2000 clocks.cpu_clk
2001 }
2002 pub fn request_cpu_clk(clocks: &mut ClockTree) {
2003 trace!("Requesting CPU_CLK");
2004 if increment_reference_count(&mut clocks.cpu_clk_refcount) {
2005 trace!("Enabling CPU_CLK");
2006 request_hp_root_clk(clocks);
2007 enable_cpu_clk_impl(clocks, true);
2008 }
2009 }
2010 pub fn release_cpu_clk(clocks: &mut ClockTree) {
2011 trace!("Releasing CPU_CLK");
2012 if decrement_reference_count(&mut clocks.cpu_clk_refcount) {
2013 trace!("Disabling CPU_CLK");
2014 enable_cpu_clk_impl(clocks, false);
2015 release_hp_root_clk(clocks);
2016 }
2017 }
2018 #[allow(unused_variables)]
2019 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2020 (hp_root_clk_frequency() / (config.divisor() + 1))
2021 }
2022 pub fn cpu_clk_frequency() -> u32 {
2023 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2024 }
2025 pub fn cpu_clk_source_frequency() -> u32 {
2026 hp_root_clk_frequency()
2027 }
2028 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
2029 let old_config = clocks.ahb_clk.replace(config);
2030 refresh_ahb_clk_downstream(clocks);
2031 configure_ahb_clk_impl(clocks, old_config, config);
2032 }
2033 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
2034 clocks.ahb_clk
2035 }
2036 pub fn request_ahb_clk(clocks: &mut ClockTree) {
2037 trace!("Requesting AHB_CLK");
2038 trace!("Enabling AHB_CLK");
2039 request_hp_root_clk(clocks);
2040 enable_ahb_clk_impl(clocks, true);
2041 }
2042 pub fn release_ahb_clk(clocks: &mut ClockTree) {
2043 trace!("Releasing AHB_CLK");
2044 trace!("Disabling AHB_CLK");
2045 enable_ahb_clk_impl(clocks, false);
2046 release_hp_root_clk(clocks);
2047 }
2048 #[allow(unused_variables)]
2049 pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
2050 (hp_root_clk_frequency() / (config.divisor() + 1))
2051 }
2052 pub fn ahb_clk_frequency() -> u32 {
2053 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2054 }
2055 pub fn ahb_clk_source_frequency() -> u32 {
2056 hp_root_clk_frequency()
2057 }
2058 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
2059 let old_config = clocks.apb_clk.replace(config);
2060 refresh_apb_clk_downstream(clocks);
2061 configure_apb_clk_impl(clocks, old_config, config);
2062 }
2063 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2064 clocks.apb_clk
2065 }
2066 pub fn request_apb_clk(clocks: &mut ClockTree) {
2067 trace!("Requesting APB_CLK");
2068 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2069 trace!("Enabling APB_CLK");
2070 request_ahb_clk(clocks);
2071 enable_apb_clk_impl(clocks, true);
2072 }
2073 }
2074 pub fn release_apb_clk(clocks: &mut ClockTree) {
2075 trace!("Releasing APB_CLK");
2076 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2077 trace!("Disabling APB_CLK");
2078 enable_apb_clk_impl(clocks, false);
2079 release_ahb_clk(clocks);
2080 }
2081 }
2082 #[allow(unused_variables)]
2083 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2084 (ahb_clk_frequency() / (config.divisor() + 1))
2085 }
2086 pub fn apb_clk_frequency() -> u32 {
2087 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2088 }
2089 pub fn apb_clk_source_frequency() -> u32 {
2090 ahb_clk_frequency()
2091 }
2092 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
2093 trace!("Requesting XTAL_D2_CLK");
2094 trace!("Enabling XTAL_D2_CLK");
2095 request_xtal_clk(clocks);
2096 enable_xtal_d2_clk_impl(clocks, true);
2097 }
2098 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
2099 trace!("Releasing XTAL_D2_CLK");
2100 trace!("Disabling XTAL_D2_CLK");
2101 enable_xtal_d2_clk_impl(clocks, false);
2102 release_xtal_clk(clocks);
2103 }
2104 pub fn xtal_d2_clk_frequency() -> u32 {
2105 (xtal_clk_frequency() / 2)
2106 }
2107 pub fn xtal_d2_clk_source_frequency() -> u32 {
2108 xtal_clk_frequency()
2109 }
2110 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
2111 let old_selector = clocks.lp_fast_clk.replace(new_selector);
2112 refresh_lp_fast_clk_downstream(clocks);
2113 if clocks.lp_fast_clk_refcount > 0 {
2114 match new_selector {
2115 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2116 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2117 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2118 }
2119 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2120 if let Some(old_selector) = old_selector {
2121 match old_selector {
2122 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2123 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2124 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2125 }
2126 }
2127 } else {
2128 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2129 }
2130 }
2131 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
2132 clocks.lp_fast_clk
2133 }
2134 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
2135 trace!("Requesting LP_FAST_CLK");
2136 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
2137 trace!("Enabling LP_FAST_CLK");
2138 match unwrap!(clocks.lp_fast_clk) {
2139 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2140 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2141 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2142 }
2143 enable_lp_fast_clk_impl(clocks, true);
2144 }
2145 }
2146 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
2147 trace!("Releasing LP_FAST_CLK");
2148 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
2149 trace!("Disabling LP_FAST_CLK");
2150 enable_lp_fast_clk_impl(clocks, false);
2151 match unwrap!(clocks.lp_fast_clk) {
2152 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2153 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2154 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2155 }
2156 }
2157 }
2158 #[allow(unused_variables)]
2159 pub fn lp_fast_clk_config_frequency(
2160 clocks: &mut ClockTree,
2161 config: LpFastClkConfig,
2162 ) -> u32 {
2163 match config {
2164 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2165 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2166 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2167 }
2168 }
2169 pub fn lp_fast_clk_frequency() -> u32 {
2170 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2171 }
2172 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
2173 match source {
2174 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2175 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2176 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2177 }
2178 }
2179 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
2180 let old_selector = clocks.lp_slow_clk.replace(new_selector);
2181 refresh_lp_slow_clk_downstream(clocks);
2182 if clocks.lp_slow_clk_refcount > 0 {
2183 match new_selector {
2184 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2185 #[cfg(use_xtal32k)]
2186 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2187 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2188 }
2189 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2190 if let Some(old_selector) = old_selector {
2191 match old_selector {
2192 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2193 #[cfg(use_xtal32k)]
2194 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2195 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2196 }
2197 }
2198 } else {
2199 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2200 }
2201 }
2202 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
2203 clocks.lp_slow_clk
2204 }
2205 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
2206 trace!("Requesting LP_SLOW_CLK");
2207 if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
2208 trace!("Enabling LP_SLOW_CLK");
2209 match unwrap!(clocks.lp_slow_clk) {
2210 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2211 #[cfg(use_xtal32k)]
2212 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2213 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2214 }
2215 enable_lp_slow_clk_impl(clocks, true);
2216 }
2217 }
2218 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2219 trace!("Releasing LP_SLOW_CLK");
2220 if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
2221 trace!("Disabling LP_SLOW_CLK");
2222 enable_lp_slow_clk_impl(clocks, false);
2223 match unwrap!(clocks.lp_slow_clk) {
2224 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2225 #[cfg(use_xtal32k)]
2226 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2227 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2228 }
2229 }
2230 }
2231 #[allow(unused_variables)]
2232 pub fn lp_slow_clk_config_frequency(
2233 clocks: &mut ClockTree,
2234 config: LpSlowClkConfig,
2235 ) -> u32 {
2236 match config {
2237 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2238 #[cfg(use_xtal32k)]
2239 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2240 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2241 }
2242 }
2243 pub fn lp_slow_clk_frequency() -> u32 {
2244 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2245 }
2246 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
2247 match source {
2248 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2249 #[cfg(use_xtal32k)]
2250 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2251 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2252 }
2253 }
2254 pub fn configure_timg_calibration_clock(
2255 clocks: &mut ClockTree,
2256 new_selector: TimgCalibrationClockConfig,
2257 ) {
2258 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2259 refresh_timg_calibration_clock_downstream(clocks);
2260 if clocks.timg_calibration_clock_refcount > 0 {
2261 match new_selector {
2262 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
2263 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2264 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2265 #[cfg(use_xtal32k)]
2266 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2267 }
2268 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2269 if let Some(old_selector) = old_selector {
2270 match old_selector {
2271 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
2272 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2273 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2274 #[cfg(use_xtal32k)]
2275 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2276 }
2277 }
2278 } else {
2279 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2280 }
2281 }
2282 pub fn timg_calibration_clock_config(
2283 clocks: &mut ClockTree,
2284 ) -> Option<TimgCalibrationClockConfig> {
2285 clocks.timg_calibration_clock
2286 }
2287 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2288 trace!("Requesting TIMG_CALIBRATION_CLOCK");
2289 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2290 trace!("Enabling TIMG_CALIBRATION_CLOCK");
2291 crate::rtc_cntl::WakeLock::acquire();
2292 match unwrap!(clocks.timg_calibration_clock) {
2293 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
2294 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2295 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2296 #[cfg(use_xtal32k)]
2297 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2298 }
2299 enable_timg_calibration_clock_impl(clocks, true);
2300 }
2301 }
2302 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2303 trace!("Releasing TIMG_CALIBRATION_CLOCK");
2304 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2305 trace!("Disabling TIMG_CALIBRATION_CLOCK");
2306 crate::rtc_cntl::WakeLock::release();
2307 enable_timg_calibration_clock_impl(clocks, false);
2308 match unwrap!(clocks.timg_calibration_clock) {
2309 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
2310 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2311 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2312 #[cfg(use_xtal32k)]
2313 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2314 }
2315 }
2316 }
2317 #[allow(unused_variables)]
2318 pub fn timg_calibration_clock_config_frequency(
2319 clocks: &mut ClockTree,
2320 config: TimgCalibrationClockConfig,
2321 ) -> u32 {
2322 match config {
2323 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
2324 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
2325 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2326 #[cfg(use_xtal32k)]
2327 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2328 }
2329 }
2330 pub fn timg_calibration_clock_frequency() -> u32 {
2331 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2332 }
2333 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
2334 match source {
2335 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
2336 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
2337 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2338 #[cfg(use_xtal32k)]
2339 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2340 }
2341 }
2342 impl I2cInstance {
2343 pub fn configure_function_clock(
2344 self,
2345 clocks: &mut ClockTree,
2346 config: I2cFunctionClockConfig,
2347 ) {
2348 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
2349 refresh_i2c_function_clock_downstream(clocks, self);
2350 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
2351 match config.sclk {
2352 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2353 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2354 }
2355 self.configure_function_clock_impl(clocks, old_config, config);
2356 if let Some(old_config) = old_config {
2357 match old_config.sclk {
2358 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2359 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2360 }
2361 }
2362 } else {
2363 self.configure_function_clock_impl(clocks, old_config, config);
2364 }
2365 }
2366 pub fn function_clock_config(
2367 self,
2368 clocks: &mut ClockTree,
2369 ) -> Option<I2cFunctionClockConfig> {
2370 clocks.i2c_function_clock[self as usize]
2371 }
2372 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2373 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2374 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
2375 {
2376 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2377 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
2378 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2379 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2380 }
2381 self.enable_function_clock_impl(clocks, true);
2382 }
2383 }
2384 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2385 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2386 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
2387 {
2388 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2389 self.enable_function_clock_impl(clocks, false);
2390 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
2391 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2392 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2393 }
2394 }
2395 }
2396 #[allow(unused_variables)]
2397 pub fn function_clock_config_frequency(
2398 clocks: &mut ClockTree,
2399 config: I2cFunctionClockConfig,
2400 ) -> u32 {
2401 (match config.sclk {
2402 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
2403 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2404 } / (config.div_num() + 1))
2405 }
2406 pub fn function_clock_frequency(self) -> u32 {
2407 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2408 .load(::core::sync::atomic::Ordering::Acquire)
2409 }
2410 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
2411 match sclk {
2412 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
2413 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2414 }
2415 }
2416 }
2417 impl SpiInstance {
2418 pub fn configure_function_clock(
2419 self,
2420 clocks: &mut ClockTree,
2421 new_selector: SpiFunctionClockConfig,
2422 ) {
2423 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
2424 refresh_spi_function_clock_downstream(clocks, self);
2425 if clocks.spi_function_clock_refcount[self as usize] > 0 {
2426 match new_selector {
2427 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
2428 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
2429 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
2430 }
2431 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2432 if let Some(old_selector) = old_selector {
2433 match old_selector {
2434 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
2435 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
2436 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
2437 }
2438 }
2439 } else {
2440 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2441 }
2442 }
2443 pub fn function_clock_config(
2444 self,
2445 clocks: &mut ClockTree,
2446 ) -> Option<SpiFunctionClockConfig> {
2447 clocks.spi_function_clock[self as usize]
2448 }
2449 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2450 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2451 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
2452 {
2453 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2454 match unwrap!(clocks.spi_function_clock[self as usize]) {
2455 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
2456 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
2457 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
2458 }
2459 self.enable_function_clock_impl(clocks, true);
2460 }
2461 }
2462 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2463 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2464 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
2465 {
2466 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2467 self.enable_function_clock_impl(clocks, false);
2468 match unwrap!(clocks.spi_function_clock[self as usize]) {
2469 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
2470 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
2471 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
2472 }
2473 }
2474 }
2475 #[allow(unused_variables)]
2476 pub fn function_clock_config_frequency(
2477 clocks: &mut ClockTree,
2478 config: SpiFunctionClockConfig,
2479 ) -> u32 {
2480 match config {
2481 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
2482 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
2483 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
2484 }
2485 }
2486 pub fn function_clock_frequency(self) -> u32 {
2487 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2488 .load(::core::sync::atomic::Ordering::Acquire)
2489 }
2490 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
2491 match source {
2492 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
2493 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
2494 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
2495 }
2496 }
2497 }
2498 impl TimgInstance {
2499 pub fn configure_function_clock(
2500 self,
2501 clocks: &mut ClockTree,
2502 new_selector: TimgFunctionClockConfig,
2503 ) {
2504 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
2505 refresh_timg_function_clock_downstream(clocks, self);
2506 if clocks.timg_function_clock_refcount[self as usize] > 0 {
2507 match new_selector {
2508 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2509 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2510 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
2511 }
2512 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2513 if let Some(old_selector) = old_selector {
2514 match old_selector {
2515 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2516 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2517 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
2518 }
2519 }
2520 } else {
2521 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2522 }
2523 }
2524 pub fn function_clock_config(
2525 self,
2526 clocks: &mut ClockTree,
2527 ) -> Option<TimgFunctionClockConfig> {
2528 clocks.timg_function_clock[self as usize]
2529 }
2530 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2531 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2532 if increment_reference_count(
2533 &mut clocks.timg_function_clock_refcount[self as usize],
2534 ) {
2535 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2536 match unwrap!(clocks.timg_function_clock[self as usize]) {
2537 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2538 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2539 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
2540 }
2541 self.enable_function_clock_impl(clocks, true);
2542 }
2543 }
2544 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2545 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2546 if decrement_reference_count(
2547 &mut clocks.timg_function_clock_refcount[self as usize],
2548 ) {
2549 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2550 self.enable_function_clock_impl(clocks, false);
2551 match unwrap!(clocks.timg_function_clock[self as usize]) {
2552 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2553 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2554 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
2555 }
2556 }
2557 }
2558 #[allow(unused_variables)]
2559 pub fn function_clock_config_frequency(
2560 clocks: &mut ClockTree,
2561 config: TimgFunctionClockConfig,
2562 ) -> u32 {
2563 match config {
2564 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2565 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
2566 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
2567 }
2568 }
2569 pub fn function_clock_frequency(self) -> u32 {
2570 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2571 .load(::core::sync::atomic::Ordering::Acquire)
2572 }
2573 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
2574 match source {
2575 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2576 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
2577 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
2578 }
2579 }
2580 pub fn configure_wdt_clock(
2581 self,
2582 clocks: &mut ClockTree,
2583 new_selector: TimgWdtClockConfig,
2584 ) {
2585 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
2586 refresh_timg_wdt_clock_downstream(clocks, self);
2587 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
2588 match new_selector {
2589 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
2590 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2591 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
2592 }
2593 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
2594 if let Some(old_selector) = old_selector {
2595 match old_selector {
2596 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
2597 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2598 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
2599 }
2600 }
2601 } else {
2602 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
2603 }
2604 }
2605 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
2606 clocks.timg_wdt_clock[self as usize]
2607 }
2608 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
2609 trace!("Requesting {:?}::WDT_CLOCK", self);
2610 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
2611 trace!("Enabling {:?}::WDT_CLOCK", self);
2612 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
2613 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
2614 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2615 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
2616 }
2617 self.enable_wdt_clock_impl(clocks, true);
2618 }
2619 }
2620 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
2621 trace!("Releasing {:?}::WDT_CLOCK", self);
2622 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
2623 trace!("Disabling {:?}::WDT_CLOCK", self);
2624 self.enable_wdt_clock_impl(clocks, false);
2625 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
2626 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
2627 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2628 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
2629 }
2630 }
2631 }
2632 #[allow(unused_variables)]
2633 pub fn wdt_clock_config_frequency(
2634 clocks: &mut ClockTree,
2635 config: TimgWdtClockConfig,
2636 ) -> u32 {
2637 match config {
2638 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
2639 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
2640 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
2641 }
2642 }
2643 pub fn wdt_clock_frequency(self) -> u32 {
2644 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
2645 .load(::core::sync::atomic::Ordering::Acquire)
2646 }
2647 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
2648 match source {
2649 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
2650 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
2651 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
2652 }
2653 }
2654 }
2655 impl UartInstance {
2656 pub fn configure_function_clock(
2657 self,
2658 clocks: &mut ClockTree,
2659 config: UartFunctionClockConfig,
2660 ) {
2661 let old_config = clocks.uart_function_clock[self as usize].replace(config);
2662 refresh_uart_function_clock_downstream(clocks, self);
2663 if clocks.uart_function_clock_refcount[self as usize] > 0 {
2664 match config.sclk {
2665 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2666 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
2667 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2668 }
2669 self.configure_function_clock_impl(clocks, old_config, config);
2670 if let Some(old_config) = old_config {
2671 match old_config.sclk {
2672 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2673 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
2674 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2675 }
2676 }
2677 } else {
2678 self.configure_function_clock_impl(clocks, old_config, config);
2679 }
2680 }
2681 pub fn function_clock_config(
2682 self,
2683 clocks: &mut ClockTree,
2684 ) -> Option<UartFunctionClockConfig> {
2685 clocks.uart_function_clock[self as usize]
2686 }
2687 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2688 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2689 if increment_reference_count(
2690 &mut clocks.uart_function_clock_refcount[self as usize],
2691 ) {
2692 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2693 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
2694 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2695 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
2696 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2697 }
2698 self.enable_function_clock_impl(clocks, true);
2699 }
2700 }
2701 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2702 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2703 if decrement_reference_count(
2704 &mut clocks.uart_function_clock_refcount[self as usize],
2705 ) {
2706 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2707 self.enable_function_clock_impl(clocks, false);
2708 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
2709 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2710 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
2711 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2712 }
2713 }
2714 }
2715 #[allow(unused_variables)]
2716 pub fn function_clock_config_frequency(
2717 clocks: &mut ClockTree,
2718 config: UartFunctionClockConfig,
2719 ) -> u32 {
2720 (match config.sclk {
2721 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
2722 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
2723 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2724 } / (config.div_num() + 1))
2725 }
2726 pub fn function_clock_frequency(self) -> u32 {
2727 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2728 .load(::core::sync::atomic::Ordering::Acquire)
2729 }
2730 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
2731 match sclk {
2732 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
2733 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
2734 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2735 }
2736 }
2737 pub fn configure_baud_rate_generator(
2738 self,
2739 clocks: &mut ClockTree,
2740 config: UartBaudRateGeneratorConfig,
2741 ) {
2742 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
2743 refresh_uart_baud_rate_generator_downstream(clocks, self);
2744 self.configure_baud_rate_generator_impl(clocks, old_config, config);
2745 }
2746 pub fn baud_rate_generator_config(
2747 self,
2748 clocks: &mut ClockTree,
2749 ) -> Option<UartBaudRateGeneratorConfig> {
2750 clocks.uart_baud_rate_generator[self as usize]
2751 }
2752 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
2753 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
2754 if increment_reference_count(
2755 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
2756 ) {
2757 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
2758 self.request_function_clock(clocks);
2759 self.enable_baud_rate_generator_impl(clocks, true);
2760 }
2761 }
2762 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
2763 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
2764 if decrement_reference_count(
2765 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
2766 ) {
2767 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
2768 self.enable_baud_rate_generator_impl(clocks, false);
2769 self.release_function_clock(clocks);
2770 }
2771 }
2772 #[allow(unused_variables)]
2773 pub fn baud_rate_generator_config_frequency(
2774 self,
2775 clocks: &mut ClockTree,
2776 config: UartBaudRateGeneratorConfig,
2777 ) -> u32 {
2778 ((self.function_clock_frequency() * 16)
2779 / ((config.integral() * 16) + config.fractional()))
2780 }
2781 pub fn baud_rate_generator_frequency(self) -> u32 {
2782 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
2783 .load(::core::sync::atomic::Ordering::Acquire)
2784 }
2785 }
2786 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2794 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2795 #[instability::unstable]
2796 pub struct ClockConfig {
2797 pub xtal_clk: Option<XtalClkConfig>,
2799 pub hp_root_clk: Option<HpRootClkConfig>,
2801 pub cpu_clk: Option<CpuClkConfig>,
2803 pub ahb_clk: Option<AhbClkConfig>,
2805 pub apb_clk: Option<ApbClkConfig>,
2807 pub lp_fast_clk: Option<LpFastClkConfig>,
2809 pub lp_slow_clk: Option<LpSlowClkConfig>,
2811 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2813 }
2814 impl ClockConfig {
2815 fn apply(&self, clocks: &mut ClockTree) {
2816 if let Some(config) = self.xtal_clk {
2817 configure_xtal_clk(clocks, config);
2818 }
2819 if let Some(config) = self.hp_root_clk {
2820 configure_hp_root_clk(clocks, config);
2821 }
2822 if let Some(config) = self.cpu_clk {
2823 configure_cpu_clk(clocks, config);
2824 }
2825 if let Some(config) = self.ahb_clk {
2826 configure_ahb_clk(clocks, config);
2827 }
2828 if let Some(config) = self.apb_clk {
2829 configure_apb_clk(clocks, config);
2830 }
2831 if let Some(config) = self.lp_fast_clk {
2832 configure_lp_fast_clk(clocks, config);
2833 }
2834 if let Some(config) = self.lp_slow_clk {
2835 configure_lp_slow_clk(clocks, config);
2836 }
2837 if let Some(config) = self.timg_calibration_clock {
2838 configure_timg_calibration_clock(clocks, config);
2839 }
2840 }
2841 }
2842 fn increment_reference_count(refcount: &mut u32) -> bool {
2843 let first = *refcount == 0;
2844 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
2845 first
2846 }
2847 fn decrement_reference_count(refcount: &mut u32) -> bool {
2848 *refcount = refcount.saturating_sub(1);
2849 let last = *refcount == 0;
2850 last
2851 }
2852 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
2853 if let Some(config) = clocks.xtal_clk {
2854 XTAL_CLK_FREQ_CACHE.store(
2855 xtal_clk_config_frequency(clocks, config),
2856 ::core::sync::atomic::Ordering::Release,
2857 );
2858 }
2859 refresh_hp_root_clk_downstream(clocks);
2860 refresh_lp_fast_clk_downstream(clocks);
2861 for child_instance in [I2cInstance::I2c0] {
2862 refresh_i2c_function_clock_downstream(clocks, child_instance);
2863 }
2864 for child_instance in [SpiInstance::Spi2] {
2865 refresh_spi_function_clock_downstream(clocks, child_instance);
2866 }
2867 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
2868 refresh_timg_function_clock_downstream(clocks, child_instance);
2869 refresh_timg_wdt_clock_downstream(clocks, child_instance);
2870 }
2871 for child_instance in [
2872 UartInstance::Uart0,
2873 UartInstance::Uart1,
2874 UartInstance::Uart2,
2875 ] {
2876 refresh_uart_function_clock_downstream(clocks, child_instance);
2877 }
2878 }
2879 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
2880 if let Some(config) = clocks.hp_root_clk {
2881 HP_ROOT_CLK_FREQ_CACHE.store(
2882 hp_root_clk_config_frequency(clocks, config),
2883 ::core::sync::atomic::Ordering::Release,
2884 );
2885 }
2886 refresh_cpu_clk_downstream(clocks);
2887 refresh_ahb_clk_downstream(clocks);
2888 }
2889 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
2890 if let Some(config) = clocks.cpu_clk {
2891 CPU_CLK_FREQ_CACHE.store(
2892 cpu_clk_config_frequency(clocks, config),
2893 ::core::sync::atomic::Ordering::Release,
2894 );
2895 }
2896 }
2897 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
2898 if let Some(config) = clocks.ahb_clk {
2899 AHB_CLK_FREQ_CACHE.store(
2900 ahb_clk_config_frequency(clocks, config),
2901 ::core::sync::atomic::Ordering::Release,
2902 );
2903 }
2904 refresh_apb_clk_downstream(clocks);
2905 }
2906 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
2907 if let Some(config) = clocks.apb_clk {
2908 APB_CLK_FREQ_CACHE.store(
2909 apb_clk_config_frequency(clocks, config),
2910 ::core::sync::atomic::Ordering::Release,
2911 );
2912 }
2913 }
2914 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
2915 if let Some(config) = clocks.lp_fast_clk {
2916 LP_FAST_CLK_FREQ_CACHE.store(
2917 lp_fast_clk_config_frequency(clocks, config),
2918 ::core::sync::atomic::Ordering::Release,
2919 );
2920 }
2921 }
2922 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
2923 if let Some(config) = clocks.lp_slow_clk {
2924 LP_SLOW_CLK_FREQ_CACHE.store(
2925 lp_slow_clk_config_frequency(clocks, config),
2926 ::core::sync::atomic::Ordering::Release,
2927 );
2928 }
2929 }
2930 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
2931 if let Some(config) = clocks.timg_calibration_clock {
2932 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
2933 timg_calibration_clock_config_frequency(clocks, config),
2934 ::core::sync::atomic::Ordering::Release,
2935 );
2936 }
2937 }
2938 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
2939 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
2940 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
2941 I2cInstance::function_clock_config_frequency(clocks, config),
2942 ::core::sync::atomic::Ordering::Release,
2943 );
2944 }
2945 }
2946 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
2947 if let Some(config) = clocks.spi_function_clock[instance as usize] {
2948 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
2949 SpiInstance::function_clock_config_frequency(clocks, config),
2950 ::core::sync::atomic::Ordering::Release,
2951 );
2952 }
2953 }
2954 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
2955 if let Some(config) = clocks.timg_function_clock[instance as usize] {
2956 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
2957 TimgInstance::function_clock_config_frequency(clocks, config),
2958 ::core::sync::atomic::Ordering::Release,
2959 );
2960 }
2961 }
2962 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
2963 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
2964 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
2965 TimgInstance::wdt_clock_config_frequency(clocks, config),
2966 ::core::sync::atomic::Ordering::Release,
2967 );
2968 }
2969 }
2970 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
2971 if let Some(config) = clocks.uart_function_clock[instance as usize] {
2972 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
2973 UartInstance::function_clock_config_frequency(clocks, config),
2974 ::core::sync::atomic::Ordering::Release,
2975 );
2976 }
2977 refresh_uart_baud_rate_generator_downstream(clocks, instance);
2978 }
2979 fn refresh_uart_baud_rate_generator_downstream(
2980 clocks: &mut ClockTree,
2981 instance: UartInstance,
2982 ) {
2983 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
2984 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
2985 instance.baud_rate_generator_config_frequency(clocks, config),
2986 ::core::sync::atomic::Ordering::Release,
2987 );
2988 }
2989 }
2990 };
2991}
2992#[macro_export]
2996#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2997macro_rules! implement_peripheral_clocks {
2998 () => {
2999 #[doc(hidden)]
3000 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3001 #[repr(u8)]
3002 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3003 pub enum Peripheral {
3004 AhbGdma,
3006 ApbSarAdc,
3008 Ecc,
3010 I2cExt0,
3012 I2s0,
3014 Sha,
3016 Spi2,
3018 Systimer,
3020 Timg0,
3022 Timg1,
3024 Uart0,
3026 Uart1,
3028 Uart2,
3030 UsbDevice,
3032 }
3033 impl Peripheral {
3034 const KEEP_ENABLED: &[Peripheral] =
3035 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
3036 const COUNT: usize = Self::ALL.len();
3037 const ALL: &[Self] = &[
3038 Self::AhbGdma,
3039 Self::ApbSarAdc,
3040 Self::Ecc,
3041 Self::I2cExt0,
3042 Self::I2s0,
3043 Self::Sha,
3044 Self::Spi2,
3045 Self::Systimer,
3046 Self::Timg0,
3047 Self::Timg1,
3048 Self::Uart0,
3049 Self::Uart1,
3050 Self::Uart2,
3051 Self::UsbDevice,
3052 ];
3053 }
3054 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
3055 match peripheral {
3056 Peripheral::AhbGdma => {
3057 crate::peripherals::SYSTEM::regs()
3058 .gdma_conf()
3059 .modify(|_, w| w.gdma_clk_en().bit(enable));
3060 }
3061 Peripheral::ApbSarAdc => {
3062 crate::peripherals::SYSTEM::regs()
3063 .saradc_conf()
3064 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
3065 }
3066 Peripheral::Ecc => {
3067 crate::peripherals::SYSTEM::regs()
3068 .ecc_conf()
3069 .modify(|_, w| w.ecc_clk_en().bit(enable));
3070 }
3071 Peripheral::I2cExt0 => {
3072 crate::peripherals::SYSTEM::regs()
3073 .i2c0_conf()
3074 .modify(|_, w| w.i2c0_clk_en().bit(enable));
3075 }
3076 Peripheral::I2s0 => {
3077 crate::peripherals::SYSTEM::regs()
3078 .i2s_conf()
3079 .modify(|_, w| w.i2s_clk_en().bit(enable));
3080 }
3081 Peripheral::Sha => {
3082 crate::peripherals::SYSTEM::regs()
3083 .sha_conf()
3084 .modify(|_, w| w.sha_clk_en().bit(enable));
3085 }
3086 Peripheral::Spi2 => {
3087 crate::peripherals::SYSTEM::regs()
3088 .spi2_conf()
3089 .modify(|_, w| w.spi2_clk_en().bit(enable));
3090 }
3091 Peripheral::Systimer => {
3092 crate::peripherals::SYSTEM::regs()
3093 .systimer_conf()
3094 .modify(|_, w| w.systimer_clk_en().bit(enable));
3095 }
3096 Peripheral::Timg0 => {
3097 crate::peripherals::SYSTEM::regs()
3098 .timergroup(0)
3099 .conf()
3100 .modify(|_, w| w.clk_en().bit(enable));
3101 }
3102 Peripheral::Timg1 => {
3103 crate::peripherals::SYSTEM::regs()
3104 .timergroup(1)
3105 .conf()
3106 .modify(|_, w| w.clk_en().bit(enable));
3107 }
3108 Peripheral::Uart0 => {
3109 crate::peripherals::SYSTEM::regs()
3110 .uart(0)
3111 .conf()
3112 .modify(|_, w| w.clk_en().bit(enable));
3113 }
3114 Peripheral::Uart1 => {
3115 crate::peripherals::SYSTEM::regs()
3116 .uart(1)
3117 .conf()
3118 .modify(|_, w| w.clk_en().bit(enable));
3119 }
3120 Peripheral::Uart2 => {
3121 crate::peripherals::SYSTEM::regs()
3122 .uart(2)
3123 .conf()
3124 .modify(|_, w| w.clk_en().bit(enable));
3125 }
3126 Peripheral::UsbDevice => {
3127 crate::peripherals::SYSTEM::regs()
3128 .usb_device_conf()
3129 .modify(|_, w| w.usb_device_clk_en().bit(enable));
3130 }
3131 }
3132 }
3133 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
3134 match peripheral {
3135 Peripheral::AhbGdma => {
3136 crate::peripherals::SYSTEM::regs()
3137 .gdma_conf()
3138 .modify(|_, w| w.gdma_rst_en().bit(reset));
3139 }
3140 Peripheral::ApbSarAdc => {
3141 crate::peripherals::SYSTEM::regs()
3142 .saradc_conf()
3143 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
3144 }
3145 Peripheral::Ecc => {
3146 crate::peripherals::SYSTEM::regs()
3147 .ecc_conf()
3148 .modify(|_, w| w.ecc_rst_en().bit(reset));
3149 }
3150 Peripheral::I2cExt0 => {
3151 crate::peripherals::SYSTEM::regs()
3152 .i2c0_conf()
3153 .modify(|_, w| w.i2c0_rst_en().bit(reset));
3154 }
3155 Peripheral::I2s0 => {
3156 crate::peripherals::SYSTEM::regs()
3157 .i2s_conf()
3158 .modify(|_, w| w.i2s_rst_en().bit(reset));
3159 }
3160 Peripheral::Sha => {
3161 crate::peripherals::SYSTEM::regs()
3162 .sha_conf()
3163 .modify(|_, w| w.sha_rst_en().bit(reset));
3164 }
3165 Peripheral::Spi2 => {
3166 crate::peripherals::SYSTEM::regs()
3167 .spi2_conf()
3168 .modify(|_, w| w.spi2_rst_en().bit(reset));
3169 }
3170 Peripheral::Systimer => {
3171 crate::peripherals::SYSTEM::regs()
3172 .systimer_conf()
3173 .modify(|_, w| w.systimer_rst_en().bit(reset));
3174 }
3175 Peripheral::Timg0 => {
3176 crate::peripherals::SYSTEM::regs()
3177 .timergroup(0)
3178 .conf()
3179 .modify(|_, w| w.rst_en().bit(reset));
3180 }
3181 Peripheral::Timg1 => {
3182 crate::peripherals::SYSTEM::regs()
3183 .timergroup(1)
3184 .conf()
3185 .modify(|_, w| w.rst_en().bit(reset));
3186 }
3187 Peripheral::Uart0 => {
3188 crate::peripherals::SYSTEM::regs()
3189 .uart(0)
3190 .conf()
3191 .modify(|_, w| w.rst_en().bit(reset));
3192 }
3193 Peripheral::Uart1 => {
3194 crate::peripherals::SYSTEM::regs()
3195 .uart(1)
3196 .conf()
3197 .modify(|_, w| w.rst_en().bit(reset));
3198 }
3199 Peripheral::Uart2 => {
3200 crate::peripherals::SYSTEM::regs()
3201 .uart(2)
3202 .conf()
3203 .modify(|_, w| w.rst_en().bit(reset));
3204 }
3205 Peripheral::UsbDevice => {
3206 crate::peripherals::SYSTEM::regs()
3207 .usb_device_conf()
3208 .modify(|_, w| w.usb_device_rst_en().bit(reset));
3209 }
3210 }
3211 }
3212 };
3213}
3214#[macro_export]
3222#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3223macro_rules! memory_range {
3224 ("DRAM") => {
3225 0x40800000..0x40850000
3226 };
3227 (size as str, "DRAM") => {
3228 "327680"
3229 };
3230 ("DRAM2_UNINIT") => {
3231 0x4083EA70..0x4084EA70
3232 };
3233 (size as str, "DRAM2_UNINIT") => {
3234 "65536"
3235 };
3236 ("IROM") => {
3237 0x42000000..0x44000000
3238 };
3239 (size as str, "IROM") => {
3240 "33554432"
3241 };
3242 ("DROM") => {
3243 0x42000000..0x44000000
3244 };
3245 (size as str, "DROM") => {
3246 "33554432"
3247 };
3248}
3249#[macro_export]
3266#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3267macro_rules! for_each_i2c_master {
3268 ($($pattern:tt => $code:tt;)*) => {
3269 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
3270 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
3271 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
3272 I2CEXT0_SDA)));
3273 };
3274}
3275#[macro_export]
3302#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3303macro_rules! for_each_i2s {
3304 ($($pattern:tt => $code:tt;)*) => {
3305 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
3306 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
3307 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
3308 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
3309 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
3310 true, true, false)));
3311 };
3312}
3313#[macro_export]
3332#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3333macro_rules! for_each_uart {
3334 ($($pattern:tt => $code:tt;)*) => {
3335 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
3336 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
3337 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
3338 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((2, UART2, Uart2,
3339 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = true)); _for_each_inner_uart!((all(0,
3340 UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1,
3341 Uart1, U1RXD, U1TXD, U1CTS, U1RTS, wakeup_source = true), (2, UART2, Uart2,
3342 U2RXD, U2TXD, U2CTS, U2RTS, wakeup_source = true)));
3343 };
3344}
3345#[macro_export]
3367#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3368macro_rules! for_each_spi_master {
3369 ($($pattern:tt => $code:tt;)*) => {
3370 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
3371 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
3372 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
3373 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
3374 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
3375 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
3376 };
3377}
3378#[macro_export]
3395#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3396macro_rules! for_each_spi_slave {
3397 ($($pattern:tt => $code:tt;)*) => {
3398 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
3399 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
3400 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
3401 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
3402 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
3403 };
3404}
3405#[macro_export]
3406#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3407macro_rules! for_each_peripheral {
3408 ($($pattern:tt => $code:tt;)*) => {
3409 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
3410 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
3411 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
3412 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
3413 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3414 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
3415 _for_each_inner_peripheral!((@ peri_type #[doc =
3416 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3417 "<section class=\"warning\">"] #[doc =
3418 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3419 #[doc = "<ul>"] #[doc =
3420 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3421 =
3422 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3423 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
3424 _for_each_inner_peripheral!((@ peri_type #[doc =
3425 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3426 "<section class=\"warning\">"] #[doc =
3427 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3428 #[doc = "<ul>"] #[doc =
3429 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3430 =
3431 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3432 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
3433 _for_each_inner_peripheral!((@ peri_type #[doc =
3434 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3435 "<section class=\"warning\">"] #[doc =
3436 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3437 #[doc = "<ul>"] #[doc =
3438 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3439 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
3440 _for_each_inner_peripheral!((@ peri_type #[doc =
3441 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3442 "<section class=\"warning\">"] #[doc =
3443 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3444 #[doc = "<ul>"] #[doc =
3445 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3446 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
3447 _for_each_inner_peripheral!((@ peri_type #[doc =
3448 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3449 "<section class=\"warning\">"] #[doc =
3450 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3451 #[doc = "<ul>"] #[doc =
3452 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3453 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
3454 _for_each_inner_peripheral!((@ peri_type #[doc =
3455 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3456 "<section class=\"warning\">"] #[doc =
3457 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3458 #[doc = "<ul>"] #[doc =
3459 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3460 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
3461 _for_each_inner_peripheral!((@ peri_type #[doc =
3462 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3463 "<section class=\"warning\">"] #[doc =
3464 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3465 #[doc = "<ul>"] #[doc =
3466 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3467 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
3468 _for_each_inner_peripheral!((@ peri_type #[doc =
3469 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3470 "<section class=\"warning\">"] #[doc =
3471 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3472 #[doc = "<ul>"] #[doc =
3473 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3474 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
3475 _for_each_inner_peripheral!((@ peri_type #[doc =
3476 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3477 "<section class=\"warning\">"] #[doc =
3478 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3479 #[doc = "<ul>"] #[doc =
3480 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3481 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
3482 _for_each_inner_peripheral!((@ peri_type #[doc =
3483 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3484 "<section class=\"warning\">"] #[doc =
3485 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3486 #[doc = "<ul>"] #[doc =
3487 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3488 #[doc = "</section>"] GPIO12 <= virtual())); _for_each_inner_peripheral!((@
3489 peri_type #[doc = "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""]
3490 #[doc = "<section class=\"warning\">"] #[doc =
3491 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3492 #[doc = "<ul>"] #[doc =
3493 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3494 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
3495 peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
3496 #[doc = "<section class=\"warning\">"] #[doc =
3497 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3498 #[doc = "<ul>"] #[doc =
3499 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3500 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
3501 _for_each_inner_peripheral!((@ peri_type #[doc =
3502 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3503 "<section class=\"warning\">"] #[doc =
3504 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3505 #[doc = "<ul>"] #[doc =
3506 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3507 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
3508 _for_each_inner_peripheral!((@ peri_type #[doc =
3509 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3510 "<section class=\"warning\">"] #[doc =
3511 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3512 #[doc = "<ul>"] #[doc =
3513 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3514 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3515 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
3516 _for_each_inner_peripheral!((@ peri_type #[doc =
3517 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3518 "<section class=\"warning\">"] #[doc =
3519 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3520 #[doc = "<ul>"] #[doc =
3521 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3522 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3523 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
3524 _for_each_inner_peripheral!((@ peri_type #[doc =
3525 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3526 "<section class=\"warning\">"] #[doc =
3527 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3528 #[doc = "<ul>"] #[doc =
3529 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3530 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3531 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()));
3532 _for_each_inner_peripheral!((@ peri_type #[doc =
3533 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3534 "<section class=\"warning\">"] #[doc =
3535 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3536 #[doc = "<ul>"] #[doc =
3537 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3538 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3539 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()));
3540 _for_each_inner_peripheral!((@ peri_type #[doc =
3541 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3542 "<section class=\"warning\">"] #[doc =
3543 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3544 #[doc = "<ul>"] #[doc =
3545 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3546 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3547 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
3548 _for_each_inner_peripheral!((@ peri_type #[doc =
3549 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3550 "<section class=\"warning\">"] #[doc =
3551 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3552 #[doc = "<ul>"] #[doc =
3553 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3554 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3555 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
3556 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
3557 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3558 "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
3559 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO24 peripheral singleton"]
3560 GPIO24 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3561 "GPIO25 peripheral singleton"] GPIO25 <= virtual()));
3562 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
3563 GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3564 "GPIO27 peripheral singleton"] GPIO27 <= virtual()));
3565 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO28 peripheral singleton"]
3566 GPIO28 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
3567 "GPIO29 peripheral singleton"] GPIO29 <= virtual()));
3568 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
3569 DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
3570 disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
3571 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
3572 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
3573 DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
3574 disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
3575 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
3576 _for_each_inner_peripheral!((@ peri_type #[doc =
3577 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
3578 _for_each_inner_peripheral!((@ peri_type #[doc =
3579 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
3580 _for_each_inner_peripheral!((@ peri_type #[doc = "CLINT peripheral singleton"]
3581 CLINT <= CLINT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3582 "CACHE peripheral singleton"] CACHE <= CACHE() (unstable)));
3583 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
3584 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3585 "ECC peripheral singleton"] ECC <= ECC() (unstable)));
3586 _for_each_inner_peripheral!((@ peri_type #[doc = "ECDSA peripheral singleton"]
3587 ECDSA <= ECDSA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3588 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
3589 _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
3590 <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3591 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
3592 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
3593 GPIO_SD <= GPIO_EXT() (unstable))); _for_each_inner_peripheral!((@ peri_type
3594 #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
3595 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
3596 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3597 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
3598 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
3599 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
3600 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3601 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
3602 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
3603 _for_each_inner_peripheral!((@ peri_type #[doc =
3604 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
3605 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3606 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
3607 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
3608 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3609 "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
3610 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
3611 LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3612 "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
3613 _for_each_inner_peripheral!((@ peri_type #[doc =
3614 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
3615 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
3616 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3617 = "LP_GPIO peripheral singleton"] LP_GPIO <= LP_GPIO() (unstable)));
3618 _for_each_inner_peripheral!((@ peri_type #[doc =
3619 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
3620 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
3621 LP_PERI <= LPPERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
3622 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
3623 _for_each_inner_peripheral!((@ peri_type #[doc =
3624 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
3625 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
3626 LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3627 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
3628 _for_each_inner_peripheral!((@ peri_type #[doc =
3629 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
3630 _for_each_inner_peripheral!((@ peri_type #[doc =
3631 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
3632 _for_each_inner_peripheral!((@ peri_type #[doc = "PAU peripheral singleton"] PAU
3633 <= PAU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3634 "PCR peripheral singleton"] PCR <= PCR() (unstable)));
3635 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
3636 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3637 "RNG peripheral singleton"] RNG <= LPPERI() (unstable)));
3638 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
3639 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
3640 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3641 "SLC peripheral singleton"] SLC <= SLC() (unstable)));
3642 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
3643 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3644 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
3645 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
3646 SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
3647 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3648 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)));
3649 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
3650 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
3651 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)));
3652 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
3653 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3654 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
3655 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
3656 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
3657 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3658 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
3659 enable_peri_interrupt, disable_peri_interrupt })));
3660 _for_each_inner_peripheral!((@ peri_type #[doc = "UART2 peripheral singleton"]
3661 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
3662 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3663 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
3664 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
3665 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3666 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
3667 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
3668 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
3669 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
3670 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
3671 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
3672 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
3673 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
3674 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
3675 WIFI <= virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt,
3676 disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
3677 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
3678 disable_pwr_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
3679 "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
3680 _for_each_inner_peripheral!((@ peri_type #[doc =
3681 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
3682 _for_each_inner_peripheral!((@ peri_type #[doc =
3683 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
3684 _for_each_inner_peripheral!((@ peri_type #[doc =
3685 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
3686 _for_each_inner_peripheral!((@ peri_type #[doc =
3687 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
3688 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
3689 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
3690 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
3691 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
3692 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
3693 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
3694 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
3695 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
3696 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
3697 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
3698 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
3699 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
3700 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
3701 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
3702 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
3703 _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
3704 _for_each_inner_peripheral!((DMA_CH0(unstable)));
3705 _for_each_inner_peripheral!((DMA_CH1(unstable)));
3706 _for_each_inner_peripheral!((APB_SARADC(unstable)));
3707 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
3708 _for_each_inner_peripheral!((CLINT(unstable)));
3709 _for_each_inner_peripheral!((CACHE(unstable)));
3710 _for_each_inner_peripheral!((DMA(unstable)));
3711 _for_each_inner_peripheral!((ECC(unstable)));
3712 _for_each_inner_peripheral!((ECDSA(unstable)));
3713 _for_each_inner_peripheral!((EFUSE(unstable)));
3714 _for_each_inner_peripheral!((ETM(unstable)));
3715 _for_each_inner_peripheral!((GPIO(unstable)));
3716 _for_each_inner_peripheral!((GPIO_SD(unstable)));
3717 _for_each_inner_peripheral!((HP_APM(unstable)));
3718 _for_each_inner_peripheral!((HP_SYS(unstable)));
3719 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
3720 _for_each_inner_peripheral!((I2C0));
3721 _for_each_inner_peripheral!((I2S0(unstable)));
3722 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
3723 _for_each_inner_peripheral!((INTPRI(unstable)));
3724 _for_each_inner_peripheral!((IO_MUX(unstable)));
3725 _for_each_inner_peripheral!((LP_ANA(unstable)));
3726 _for_each_inner_peripheral!((LP_AON(unstable)));
3727 _for_each_inner_peripheral!((LP_APM(unstable)));
3728 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
3729 _for_each_inner_peripheral!((LPWR(unstable)));
3730 _for_each_inner_peripheral!((LP_GPIO(unstable)));
3731 _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
3732 _for_each_inner_peripheral!((LP_PERI(unstable)));
3733 _for_each_inner_peripheral!((LP_TEE(unstable)));
3734 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
3735 _for_each_inner_peripheral!((LP_WDT(unstable)));
3736 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
3737 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
3738 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
3739 _for_each_inner_peripheral!((PAU(unstable)));
3740 _for_each_inner_peripheral!((PCR(unstable)));
3741 _for_each_inner_peripheral!((PMU(unstable)));
3742 _for_each_inner_peripheral!((RNG(unstable)));
3743 _for_each_inner_peripheral!((SHA(unstable)));
3744 _for_each_inner_peripheral!((SLC(unstable)));
3745 _for_each_inner_peripheral!((SPI0(unstable)));
3746 _for_each_inner_peripheral!((SPI1(unstable)));
3747 _for_each_inner_peripheral!((SPI2));
3748 _for_each_inner_peripheral!((SYSTEM(unstable)));
3749 _for_each_inner_peripheral!((SYSTIMER(unstable)));
3750 _for_each_inner_peripheral!((TEE(unstable)));
3751 _for_each_inner_peripheral!((TIMG0(unstable)));
3752 _for_each_inner_peripheral!((TIMG1(unstable)));
3753 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
3754 _for_each_inner_peripheral!((UART2));
3755 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
3756 _for_each_inner_peripheral!((ADC1(unstable)));
3757 _for_each_inner_peripheral!((BT(unstable)));
3758 _for_each_inner_peripheral!((FLASH(unstable)));
3759 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
3760 _for_each_inner_peripheral!((WIFI));
3761 _for_each_inner_peripheral!((PSRAM(unstable)));
3762 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
3763 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
3764 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
3765 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
3766 _for_each_inner_peripheral!((SPI2, Spi2, 1, AhbGdmaChannel));
3767 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
3768 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
3769 _for_each_inner_peripheral!((all(@ peri_type #[doc =
3770 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
3771 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
3772 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
3773 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3774 "<section class=\"warning\">"] #[doc =
3775 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3776 #[doc = "<ul>"] #[doc =
3777 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3778 =
3779 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3780 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
3781 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3782 "<section class=\"warning\">"] #[doc =
3783 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3784 #[doc = "<ul>"] #[doc =
3785 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3786 =
3787 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3788 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
3789 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3790 "<section class=\"warning\">"] #[doc =
3791 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3792 #[doc = "<ul>"] #[doc =
3793 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3794 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
3795 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3796 "<section class=\"warning\">"] #[doc =
3797 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3798 #[doc = "<ul>"] #[doc =
3799 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
3800 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
3801 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3802 "<section class=\"warning\">"] #[doc =
3803 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3804 #[doc = "<ul>"] #[doc =
3805 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3806 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
3807 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3808 "<section class=\"warning\">"] #[doc =
3809 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3810 #[doc = "<ul>"] #[doc =
3811 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3812 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
3813 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3814 "<section class=\"warning\">"] #[doc =
3815 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3816 #[doc = "<ul>"] #[doc =
3817 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
3818 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
3819 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3820 "<section class=\"warning\">"] #[doc =
3821 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3822 #[doc = "<ul>"] #[doc =
3823 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3824 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
3825 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3826 "<section class=\"warning\">"] #[doc =
3827 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3828 #[doc = "<ul>"] #[doc =
3829 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
3830 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
3831 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3832 "<section class=\"warning\">"] #[doc =
3833 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3834 #[doc = "<ul>"] #[doc =
3835 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3836 #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
3837 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3838 "<section class=\"warning\">"] #[doc =
3839 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3840 #[doc = "<ul>"] #[doc =
3841 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
3842 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
3843 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3844 "<section class=\"warning\">"] #[doc =
3845 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3846 #[doc = "<ul>"] #[doc =
3847 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3848 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
3849 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3850 "<section class=\"warning\">"] #[doc =
3851 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3852 #[doc = "<ul>"] #[doc =
3853 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3854 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
3855 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3856 "<section class=\"warning\">"] #[doc =
3857 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3858 #[doc = "<ul>"] #[doc =
3859 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3860 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3861 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
3862 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3863 "<section class=\"warning\">"] #[doc =
3864 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3865 #[doc = "<ul>"] #[doc =
3866 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3867 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3868 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
3869 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3870 "<section class=\"warning\">"] #[doc =
3871 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3872 #[doc = "<ul>"] #[doc =
3873 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3874 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3875 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
3876 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3877 "<section class=\"warning\">"] #[doc =
3878 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3879 #[doc = "<ul>"] #[doc =
3880 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3881 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3882 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
3883 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3884 "<section class=\"warning\">"] #[doc =
3885 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3886 #[doc = "<ul>"] #[doc =
3887 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3888 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3889 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
3890 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
3891 "<section class=\"warning\">"] #[doc =
3892 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
3893 #[doc = "<ul>"] #[doc =
3894 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
3895 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
3896 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
3897 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
3898 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
3899 "GPIO24 peripheral singleton"] GPIO24 <= virtual()), (@ peri_type #[doc =
3900 "GPIO25 peripheral singleton"] GPIO25 <= virtual()), (@ peri_type #[doc =
3901 "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
3902 "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
3903 "GPIO28 peripheral singleton"] GPIO28 <= virtual()), (@ peri_type #[doc =
3904 "GPIO29 peripheral singleton"] GPIO29 <= virtual()), (@ peri_type #[doc =
3905 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
3906 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
3907 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
3908 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
3909 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
3910 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
3911 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
3912 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
3913 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
3914 peri_type #[doc = "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <=
3915 ASSIST_DEBUG() (unstable)), (@ peri_type #[doc = "CLINT peripheral singleton"]
3916 CLINT <= CLINT() (unstable)), (@ peri_type #[doc = "CACHE peripheral singleton"]
3917 CACHE <= CACHE() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"]
3918 DMA <= DMA() (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <=
3919 ECC() (unstable)), (@ peri_type #[doc = "ECDSA peripheral singleton"] ECDSA <=
3920 ECDSA() (unstable)), (@ peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <=
3921 EFUSE() (unstable)), (@ peri_type #[doc = "ETM peripheral singleton"] ETM <=
3922 SOC_ETM() (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <=
3923 GPIO() (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD
3924 <= GPIO_EXT() (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"]
3925 HP_APM <= HP_APM() (unstable)), (@ peri_type #[doc =
3926 "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)), (@ peri_type #[doc
3927 = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)),
3928 (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : {
3929 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
3930 peri_type #[doc = "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : {
3931 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
3932 (unstable)), (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"]
3933 INTERRUPT_CORE0 <= INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
3934 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
3935 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
3936 #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)), (@
3937 peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)),
3938 (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <= LP_APM()
3939 (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"] LP_CLKRST <=
3940 LP_CLKRST() (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR
3941 <= LP_CLKRST() (unstable)), (@ peri_type #[doc = "LP_GPIO peripheral singleton"]
3942 LP_GPIO <= LP_GPIO() (unstable)), (@ peri_type #[doc =
3943 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)), (@
3944 peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LPPERI()
3945 (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE <=
3946 LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
3947 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
3948 "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc
3949 = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)),
3950 (@ peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON <=
3951 MODEM_LPCON() (unstable)), (@ peri_type #[doc =
3952 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
3953 (@ peri_type #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@
3954 peri_type #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@
3955 peri_type #[doc = "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@
3956 peri_type #[doc = "RNG peripheral singleton"] RNG <= LPPERI() (unstable)), (@
3957 peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
3958 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
3959 (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <= SLC()
3960 (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
3961 (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
3962 (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
3963 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
3964 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
3965 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
3966 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
3967 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
3968 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
3969 (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
3970 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
3971 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
3972 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
3973 disable_peri_interrupt })), (@ peri_type #[doc = "UART2 peripheral singleton"]
3974 UART2 <= UART2(UART2 : { bind_peri_interrupt, enable_peri_interrupt,
3975 disable_peri_interrupt })), (@ peri_type #[doc =
3976 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
3977 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
3978 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
3979 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
3980 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
3981 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
3982 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
3983 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
3984 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
3985 (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <= virtual(WIFI_BB : {
3986 bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt }, WIFI_MAC : {
3987 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : {
3988 bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt })), (@ peri_type
3989 #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)), (@
3990 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
3991 virtual() (unstable)), (@ peri_type #[doc =
3992 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
3993 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
3994 virtual() (unstable)), (@ peri_type #[doc =
3995 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
3996 _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
3997 (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
3998 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
3999 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
4000 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (GPIO29),
4001 (DMA_CH0(unstable)), (DMA_CH1(unstable)), (APB_SARADC(unstable)),
4002 (ASSIST_DEBUG(unstable)), (CLINT(unstable)), (CACHE(unstable)), (DMA(unstable)),
4003 (ECC(unstable)), (ECDSA(unstable)), (EFUSE(unstable)), (ETM(unstable)),
4004 (GPIO(unstable)), (GPIO_SD(unstable)), (HP_APM(unstable)), (HP_SYS(unstable)),
4005 (I2C_ANA_MST(unstable)), (I2C0), (I2S0(unstable)), (INTERRUPT_CORE0(unstable)),
4006 (INTPRI(unstable)), (IO_MUX(unstable)), (LP_ANA(unstable)), (LP_AON(unstable)),
4007 (LP_APM(unstable)), (LP_CLKRST(unstable)), (LPWR(unstable)), (LP_GPIO(unstable)),
4008 (LP_IO_MUX(unstable)), (LP_PERI(unstable)), (LP_TEE(unstable)),
4009 (RTC_TIMER(unstable)), (LP_WDT(unstable)), (MEM_MONITOR(unstable)),
4010 (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)), (PAU(unstable)),
4011 (PCR(unstable)), (PMU(unstable)), (RNG(unstable)), (SHA(unstable)),
4012 (SLC(unstable)), (SPI0(unstable)), (SPI1(unstable)), (SPI2), (SYSTEM(unstable)),
4013 (SYSTIMER(unstable)), (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
4014 (UART0), (UART1), (UART2), (USB_DEVICE(unstable)), (ADC1(unstable)),
4015 (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (WIFI),
4016 (PSRAM(unstable)), (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
4017 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
4018 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 1, AhbGdmaChannel), (I2S0,
4019 I2s0, 3, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel)));
4020 };
4021}
4022#[macro_export]
4049#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4050macro_rules! for_each_gpio {
4051 ($($pattern:tt => $code:tt;)*) => {
4052 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
4053 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
4054 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
4055 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
4056 _for_each_inner_gpio!((3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
4057 [Output]))); _for_each_inner_gpio!((4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 =>
4058 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTCK) ()
4059 ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTDO _2 => FSPICLK)
4060 (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2 =>
4061 FSPID) (_2 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((8, GPIO8(_2 =>
4062 FSPICS0) (_2 => FSPICS0) ([Input] [Output]))); _for_each_inner_gpio!((9, GPIO9()
4063 () ([Input] [Output]))); _for_each_inner_gpio!((10, GPIO10(_0 => U0RXD) ()
4064 ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11() (_0 => U0TXD) ([Input]
4065 [Output]))); _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
4066 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
4067 _for_each_inner_gpio!((14, GPIO14() (_0 => FSPICS1) ([Input] [Output])));
4068 _for_each_inner_gpio!((15, GPIO15(_0 => FSPICS0) (_0 => FSPICS0) ([Input]
4069 [Output]))); _for_each_inner_gpio!((16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ)
4070 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => FSPIWP) (_0 =>
4071 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18() () ([Input]
4072 [Output]))); _for_each_inner_gpio!((19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
4073 ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_0 => FSPICLK) (_0 =>
4074 FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21(_0 => FSPID) (_0
4075 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22(_0 =>
4076 SDIO_DATA2) () ([Input] [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 =>
4077 SDIO_DATA3) () ([Input] [Output]))); _for_each_inner_gpio!((24, GPIO24() ()
4078 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_0 => SDIO_CMD) ()
4079 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_0 => SDIO_CLK) ()
4080 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27(_0 => SDIO_DATA0) ()
4081 ([Input] [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SDIO_DATA1) ()
4082 ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() () ([Input]
4083 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
4084 GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
4085 [Output])), (3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
4086 [Output])), (4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) ([Input]
4087 [Output])), (5, GPIO5(_0 => MTCK) () ([Input] [Output])), (6, GPIO6(_0 => MTDO _2
4088 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_2 =>
4089 FSPID) ([Input] [Output])), (8, GPIO8(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
4090 [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10(_0 => U0RXD) ()
4091 ([Input] [Output])), (11, GPIO11() (_0 => U0TXD) ([Input] [Output])), (12,
4092 GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14,
4093 GPIO14() (_0 => FSPICS1) ([Input] [Output])), (15, GPIO15(_0 => FSPICS0) (_0 =>
4094 FSPICS0) ([Input] [Output])), (16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ) ([Input]
4095 [Output])), (17, GPIO17(_0 => FSPIWP) (_0 => FSPIWP) ([Input] [Output])), (18,
4096 GPIO18() () ([Input] [Output])), (19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
4097 ([Input] [Output])), (20, GPIO20(_0 => FSPICLK) (_0 => FSPICLK) ([Input]
4098 [Output])), (21, GPIO21(_0 => FSPID) (_0 => FSPID) ([Input] [Output])), (22,
4099 GPIO22(_0 => SDIO_DATA2) () ([Input] [Output])), (23, GPIO23(_0 => SDIO_DATA3) ()
4100 ([Input] [Output])), (24, GPIO24() () ([Input] [Output])), (25, GPIO25(_0 =>
4101 SDIO_CMD) () ([Input] [Output])), (26, GPIO26(_0 => SDIO_CLK) () ([Input]
4102 [Output])), (27, GPIO27(_0 => SDIO_DATA0) () ([Input] [Output])), (28, GPIO28(_0
4103 => SDIO_DATA1) () ([Input] [Output])), (29, GPIO29() () ([Input] [Output]))));
4104 };
4105}
4106#[macro_export]
4133#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4134macro_rules! for_each_analog_function {
4135 ($($pattern:tt => $code:tt;)*) => {
4136 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
4137 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
4138 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
4139 _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
4140 _for_each_inner_analog_function!((ADC1_CH1, GPIO3));
4141 _for_each_inner_analog_function!((ADC1_CH2, GPIO4));
4142 _for_each_inner_analog_function!((ADC1_CH3, GPIO5));
4143 _for_each_inner_analog_function!((ZCD0, GPIO8));
4144 _for_each_inner_analog_function!((ZCD1, GPIO9));
4145 _for_each_inner_analog_function!((USJ_DM, GPIO12));
4146 _for_each_inner_analog_function!((USJ_DP, GPIO13));
4147 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
4148 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO3));
4149 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO4));
4150 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO5));
4151 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO8));
4152 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO9));
4153 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (XTAL_32K_N, GPIO1),
4154 (ADC1_CH0, GPIO1), (ADC1_CH1, GPIO3), (ADC1_CH2, GPIO4), (ADC1_CH3, GPIO5),
4155 (ZCD0, GPIO8), (ZCD1, GPIO9), (USJ_DM, GPIO12), (USJ_DP, GPIO13)));
4156 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1),
4157 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO3), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO4),
4158 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO5)));
4159 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO8), ((ZCD1, ZCDn, 1),
4160 GPIO9)));
4161 };
4162}
4163#[macro_export]
4201#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4202macro_rules! for_each_lp_function {
4203 ($($pattern:tt => $code:tt;)*) => {
4204 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
4205 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
4206 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
4207 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
4208 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
4209 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
4210 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
4211 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _1));
4212 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
4213 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
4214 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
4215 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
4216 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
4217 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
4218 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()));
4219 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _1), (LP_GPIO1, GPIO1, _1),
4220 (LP_GPIO2, GPIO2, _1), (LP_GPIO3, GPIO3, _1), (LP_GPIO4, GPIO4, _1), (LP_GPIO5,
4221 GPIO5, _1), (LP_GPIO6, GPIO6, _1)));
4222 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, ()
4223 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()), ((LP_GPIO2, LP_GPIOn, 2),
4224 GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()), ((LP_GPIO4,
4225 LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()),
4226 ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ())));
4227 };
4228}
4229#[macro_export]
4260#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4261macro_rules! for_each_iomux_function {
4262 ($($pattern:tt => $code:tt;)*) => {
4263 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
4264 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
4265 _for_each_inner_iomux_function!((MTMS, GPIO3, _0));
4266 _for_each_inner_iomux_function!((FSPIHD, GPIO3, _2));
4267 _for_each_inner_iomux_function!((MTDI, GPIO4, _0));
4268 _for_each_inner_iomux_function!((FSPIWP, GPIO4, _2));
4269 _for_each_inner_iomux_function!((MTCK, GPIO5, _0));
4270 _for_each_inner_iomux_function!((MTDO, GPIO6, _0));
4271 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
4272 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
4273 _for_each_inner_iomux_function!((FSPICS0, GPIO8, _2));
4274 _for_each_inner_iomux_function!((U0RXD, GPIO10, _0));
4275 _for_each_inner_iomux_function!((U0TXD, GPIO11, _0));
4276 _for_each_inner_iomux_function!((FSPICS1, GPIO14, _0));
4277 _for_each_inner_iomux_function!((FSPICS0, GPIO15, _0));
4278 _for_each_inner_iomux_function!((FSPIQ, GPIO16, _0));
4279 _for_each_inner_iomux_function!((FSPIWP, GPIO17, _0));
4280 _for_each_inner_iomux_function!((FSPIHD, GPIO19, _0));
4281 _for_each_inner_iomux_function!((FSPICLK, GPIO20, _0));
4282 _for_each_inner_iomux_function!((FSPID, GPIO21, _0));
4283 _for_each_inner_iomux_function!((SDIO_DATA2, GPIO22, _0));
4284 _for_each_inner_iomux_function!((SDIO_DATA3, GPIO23, _0));
4285 _for_each_inner_iomux_function!((SDIO_CMD, GPIO25, _0));
4286 _for_each_inner_iomux_function!((SDIO_CLK, GPIO26, _0));
4287 _for_each_inner_iomux_function!((SDIO_DATA0, GPIO27, _0));
4288 _for_each_inner_iomux_function!((SDIO_DATA1, GPIO28, _0));
4289 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO8, _2));
4290 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO14, _0));
4291 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO15, _0));
4292 _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO22, _0));
4293 _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0));
4294 _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO27, _0));
4295 _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO28, _0));
4296 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO3, _0),
4297 (FSPIHD, GPIO3, _2), (MTDI, GPIO4, _0), (FSPIWP, GPIO4, _2), (MTCK, GPIO5, _0),
4298 (MTDO, GPIO6, _0), (FSPICLK, GPIO6, _2), (FSPID, GPIO7, _2), (FSPICS0, GPIO8,
4299 _2), (U0RXD, GPIO10, _0), (U0TXD, GPIO11, _0), (FSPICS1, GPIO14, _0), (FSPICS0,
4300 GPIO15, _0), (FSPIQ, GPIO16, _0), (FSPIWP, GPIO17, _0), (FSPIHD, GPIO19, _0),
4301 (FSPICLK, GPIO20, _0), (FSPID, GPIO21, _0), (SDIO_DATA2, GPIO22, _0),
4302 (SDIO_DATA3, GPIO23, _0), (SDIO_CMD, GPIO25, _0), (SDIO_CLK, GPIO26, _0),
4303 (SDIO_DATA0, GPIO27, _0), (SDIO_DATA1, GPIO28, _0)));
4304 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO8, _2),
4305 ((FSPICS1, FSPICSn, 1), GPIO14, _0), ((FSPICS0, FSPICSn, 0), GPIO15, _0)));
4306 _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA2, SDIO_DATAn, 2), GPIO22,
4307 _0), ((SDIO_DATA3, SDIO_DATAn, 3), GPIO23, _0), ((SDIO_DATA0, SDIO_DATAn, 0),
4308 GPIO27, _0), ((SDIO_DATA1, SDIO_DATAn, 1), GPIO28, _0)));
4309 };
4310}
4311#[macro_export]
4328#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4329macro_rules! gpio_for_signal {
4330 (XTAL_32K_P $(, $_fallback:literal)?) => {
4331 "GPIO0"
4332 };
4333 (LP_GPIO0 $(, $_fallback:literal)?) => {
4334 "GPIO0"
4335 };
4336 (XTAL_32K_N $(, $_fallback:literal)?) => {
4337 "GPIO1"
4338 };
4339 (ADC1_CH0 $(, $_fallback:literal)?) => {
4340 "GPIO1"
4341 };
4342 (LP_GPIO1 $(, $_fallback:literal)?) => {
4343 "GPIO1"
4344 };
4345 (FSPIQ $(, $_fallback:literal)?) => {
4346 "GPIO2"
4347 };
4348 (LP_GPIO2 $(, $_fallback:literal)?) => {
4349 "GPIO2"
4350 };
4351 (MTMS $(, $_fallback:literal)?) => {
4352 "GPIO3"
4353 };
4354 (FSPIHD $(, $_fallback:literal)?) => {
4355 "GPIO3"
4356 };
4357 (ADC1_CH1 $(, $_fallback:literal)?) => {
4358 "GPIO3"
4359 };
4360 (LP_GPIO3 $(, $_fallback:literal)?) => {
4361 "GPIO3"
4362 };
4363 (MTDI $(, $_fallback:literal)?) => {
4364 "GPIO4"
4365 };
4366 (FSPIWP $(, $_fallback:literal)?) => {
4367 "GPIO4"
4368 };
4369 (ADC1_CH2 $(, $_fallback:literal)?) => {
4370 "GPIO4"
4371 };
4372 (LP_GPIO4 $(, $_fallback:literal)?) => {
4373 "GPIO4"
4374 };
4375 (MTCK $(, $_fallback:literal)?) => {
4376 "GPIO5"
4377 };
4378 (ADC1_CH3 $(, $_fallback:literal)?) => {
4379 "GPIO5"
4380 };
4381 (LP_GPIO5 $(, $_fallback:literal)?) => {
4382 "GPIO5"
4383 };
4384 (MTDO $(, $_fallback:literal)?) => {
4385 "GPIO6"
4386 };
4387 (FSPICLK $(, $_fallback:literal)?) => {
4388 "GPIO6"
4389 };
4390 (LP_GPIO6 $(, $_fallback:literal)?) => {
4391 "GPIO6"
4392 };
4393 (FSPID $(, $_fallback:literal)?) => {
4394 "GPIO7"
4395 };
4396 (FSPICS0 $(, $_fallback:literal)?) => {
4397 "GPIO8"
4398 };
4399 (ZCD0 $(, $_fallback:literal)?) => {
4400 "GPIO8"
4401 };
4402 (ZCD1 $(, $_fallback:literal)?) => {
4403 "GPIO9"
4404 };
4405 (U0RXD $(, $_fallback:literal)?) => {
4406 "GPIO10"
4407 };
4408 (U0TXD $(, $_fallback:literal)?) => {
4409 "GPIO11"
4410 };
4411 (USJ_DM $(, $_fallback:literal)?) => {
4412 "GPIO12"
4413 };
4414 (USJ_DP $(, $_fallback:literal)?) => {
4415 "GPIO13"
4416 };
4417 (FSPICS1 $(, $_fallback:literal)?) => {
4418 "GPIO14"
4419 };
4420 (SDIO_DATA2 $(, $_fallback:literal)?) => {
4421 "GPIO22"
4422 };
4423 (SDIO_DATA3 $(, $_fallback:literal)?) => {
4424 "GPIO23"
4425 };
4426 (SDIO_CMD $(, $_fallback:literal)?) => {
4427 "GPIO25"
4428 };
4429 (SDIO_CLK $(, $_fallback:literal)?) => {
4430 "GPIO26"
4431 };
4432 (SDIO_DATA0 $(, $_fallback:literal)?) => {
4433 "GPIO27"
4434 };
4435 (SDIO_DATA1 $(, $_fallback:literal)?) => {
4436 "GPIO28"
4437 };
4438 ($_signal:ident, $fallback:literal) => {
4439 $fallback
4440 };
4441}
4442#[macro_export]
4446#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4447macro_rules! define_io_mux_signals {
4448 () => {
4449 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
4450 #[derive(Debug, PartialEq, Copy, Clone)]
4451 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4452 #[doc(hidden)]
4453 pub enum InputSignal {
4454 U0RXD = 6,
4455 U0CTS = 7,
4456 U0DSR = 8,
4457 U1RXD = 9,
4458 U1CTS = 10,
4459 U1DSR = 11,
4460 I2S_MCLK = 12,
4461 I2SO_BCK = 13,
4462 I2SO_WS = 14,
4463 I2SI_SD = 15,
4464 I2SI_BCK = 16,
4465 I2SI_WS = 17,
4466 CPU_GPIO_0 = 27,
4467 CPU_GPIO_1 = 28,
4468 CPU_GPIO_2 = 29,
4469 CPU_GPIO_3 = 30,
4470 CPU_GPIO_4 = 31,
4471 CPU_GPIO_5 = 32,
4472 CPU_GPIO_6 = 33,
4473 CPU_GPIO_7 = 34,
4474 USB_JTAG_TDO_BRIDGE = 35,
4475 I2CEXT0_SCL = 46,
4476 I2CEXT0_SDA = 47,
4477 FSPICLK = 64,
4478 FSPIQ = 65,
4479 FSPID = 66,
4480 FSPIHD = 67,
4481 FSPIWP = 68,
4482 FSPICS0 = 69,
4483 U2RXD = 72,
4484 U2CTS = 73,
4485 U2DSR = 74,
4486 SIG_IN_FUNC97 = 97,
4487 SIG_IN_FUNC98 = 98,
4488 SIG_IN_FUNC99 = 99,
4489 SIG_IN_FUNC100 = 100,
4490 SDIO_CLK,
4491 SDIO_CMD,
4492 SDIO_DATA0,
4493 SDIO_DATA1,
4494 SDIO_DATA2,
4495 SDIO_DATA3,
4496 MTDI,
4497 MTDO,
4498 MTCK,
4499 MTMS,
4500 }
4501 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
4502 #[derive(Debug, PartialEq, Copy, Clone)]
4503 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4504 #[doc(hidden)]
4505 pub enum OutputSignal {
4506 LEDC_LS_SIG0 = 0,
4507 LEDC_LS_SIG1 = 1,
4508 LEDC_LS_SIG2 = 2,
4509 LEDC_LS_SIG3 = 3,
4510 LEDC_LS_SIG4 = 4,
4511 LEDC_LS_SIG5 = 5,
4512 U0TXD = 6,
4513 U0RTS = 7,
4514 U0DTR = 8,
4515 U1TXD = 9,
4516 U1RTS = 10,
4517 U1DTR = 11,
4518 I2S_MCLK = 12,
4519 I2SO_BCK = 13,
4520 I2SO_WS = 14,
4521 I2SO_SD = 15,
4522 I2SI_BCK = 16,
4523 I2SI_WS = 17,
4524 I2SO_SD1 = 18,
4525 CPU_GPIO_0 = 27,
4526 CPU_GPIO_1 = 28,
4527 CPU_GPIO_2 = 29,
4528 CPU_GPIO_3 = 30,
4529 CPU_GPIO_4 = 31,
4530 CPU_GPIO_5 = 32,
4531 CPU_GPIO_6 = 33,
4532 CPU_GPIO_7 = 34,
4533 I2CEXT0_SCL = 46,
4534 I2CEXT0_SDA = 47,
4535 FSPICLK = 64,
4536 FSPIQ = 65,
4537 FSPID = 66,
4538 FSPIHD = 67,
4539 FSPIWP = 68,
4540 FSPICS0 = 69,
4541 U2TXD = 72,
4542 U2RTS = 73,
4543 U2DTR = 74,
4544 FSPICS1 = 102,
4545 FSPICS2 = 103,
4546 FSPICS3 = 104,
4547 FSPICS4 = 105,
4548 FSPICS5 = 106,
4549 SDIO_TOHOST_INT = 124,
4550 GPIO = 256,
4551 }
4552 };
4553}
4554#[macro_export]
4561#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4562macro_rules! define_lp_functions {
4563 () => {
4564 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
4569 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4570 #[doc(hidden)]
4571 pub enum LpFunction {
4572 _1 = 1,
4574 }
4575 impl LpFunction {
4576 pub const LP_GPIO: Self = Self::_1;
4578 }
4579 };
4580}
4581#[macro_export]
4594#[expect(clippy::crate_in_macro_def)]
4595#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4596macro_rules! define_io_mux_reg {
4597 () => {
4598 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
4599 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
4600 }
4601 };
4602}