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 "esp32h4"
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-H4"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32h4"
42 };
43 ("arch") => {
44 "riscv"
45 };
46 ("cores") => {
47 2
48 };
49 ("cores", str) => {
50 stringify!(2)
51 };
52 ("trm") => {
53 "https://www.espressif.com/sites/default/files/documentation/esp32-h4_technical_reference_manual_en.pdf"
54 };
55 ("gpio.version") => {
56 3
57 };
58 ("gpio.version", str) => {
59 stringify!(3)
60 };
61 ("gpio.has_input_sync") => {
62 true
63 };
64 ("gpio.gpio_function") => {
65 1
66 };
67 ("gpio.gpio_function", str) => {
68 stringify!(1)
69 };
70 ("gpio.constant_0_input") => {
71 96
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(96)
75 };
76 ("gpio.constant_1_input") => {
77 64
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(64)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 false
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.need_soft_isolate_during_pd") => {
92 false
93 };
94 ("gpio.has_bank_1") => {
95 true
96 };
97 ("gpio.input_signal_max") => {
98 189
99 };
100 ("gpio.input_signal_max", str) => {
101 stringify!(189)
102 };
103 ("gpio.output_signal_max") => {
104 256
105 };
106 ("gpio.output_signal_max", str) => {
107 stringify!(256)
108 };
109 ("dedicated_gpio.version") => {
110 "riscv_v1"
111 };
112 ("dedicated_gpio.needs_initialization") => {
113 false
114 };
115 ("dedicated_gpio.channel_count") => {
116 8
117 };
118 ("dedicated_gpio.channel_count", str) => {
119 stringify!(8)
120 };
121 ("lp_io.version") => {
122 "v4"
123 };
124 ("lp_io.has_gpio_matrix") => {
125 false
126 };
127 ("uart.ram_size") => {
128 128
129 };
130 ("uart.ram_size", str) => {
131 stringify!(128)
132 };
133 ("uart.version") => {
134 2
135 };
136 ("uart.version", str) => {
137 stringify!(2)
138 };
139 ("uart.peripheral_controls_mem_clk") => {
140 true
141 };
142 ("uart.has_sclk_divider") => {
143 false
144 };
145 ("uart.has_sclk_enable") => {
146 true
147 };
148 ("i2c_master.version") => {
149 4
150 };
151 ("i2c_master.version", str) => {
152 stringify!(4)
153 };
154 ("i2c_master.has_fsm_timeouts") => {
155 true
156 };
157 ("i2c_master.has_hw_bus_clear") => {
158 true
159 };
160 ("i2c_master.has_bus_timeout_enable") => {
161 true
162 };
163 ("i2c_master.separate_filter_config_registers") => {
164 false
165 };
166 ("i2c_master.can_estimate_nack_reason") => {
167 true
168 };
169 ("i2c_master.has_conf_update") => {
170 true
171 };
172 ("i2c_master.has_reliable_fsm_reset") => {
173 true
174 };
175 ("i2c_master.has_arbitration_en") => {
176 true
177 };
178 ("i2c_master.has_tx_fifo_watermark") => {
179 true
180 };
181 ("i2c_master.bus_timeout_is_exponential") => {
182 true
183 };
184 ("i2c_master.has_pd_en") => {
185 true
186 };
187 ("i2c_master.max_bus_timeout") => {
188 31
189 };
190 ("i2c_master.max_bus_timeout", str) => {
191 stringify!(31)
192 };
193 ("i2c_master.ll_intr_mask") => {
194 262143
195 };
196 ("i2c_master.ll_intr_mask", str) => {
197 stringify!(262143)
198 };
199 ("i2c_master.fifo_size") => {
200 32
201 };
202 ("i2c_master.fifo_size", str) => {
203 stringify!(32)
204 };
205 ("spi_master.version") => {
206 3
207 };
208 ("spi_master.version", str) => {
209 stringify!(3)
210 };
211 ("spi_master.fifo_size") => {
212 64
213 };
214 ("spi_master.fifo_size", str) => {
215 stringify!(64)
216 };
217 ("spi_master.bit_order_is_bool") => {
218 false
219 };
220 ("spi_master.has_octal") => {
221 false
222 };
223 ("spi_master.has_app_interrupts") => {
224 true
225 };
226 ("spi_master.has_dma_segmented_transfer") => {
227 true
228 };
229 ("spi_master.has_clk_pre_div") => {
230 false
231 };
232 ("spi_master.dma_can_access_flash") => {
233 false
234 };
235 ("i2s.version") => {
236 3
237 };
238 ("i2s.version", str) => {
239 stringify!(3)
240 };
241 ("i2s.mclk_divider_bit_width") => {
242 9
243 };
244 ("i2s.mclk_divider_bit_width", str) => {
245 stringify!(9)
246 };
247 ("i2s.max_ws_width") => {
248 512
249 };
250 ("i2s.max_ws_width", str) => {
251 stringify!(512)
252 };
253 ("i2s.clock_configured_by_pcr") => {
254 true
255 };
256 ("i2s.clock_configured_by_hp_sys_clkrst") => {
257 false
258 };
259 ("i2s.supports_pdm_rx_hp_filter") => {
260 false
261 };
262 ("i2s.supports_pdm_tx") => {
263 true
264 };
265 ("i2s.supports_pdm_rx") => {
266 true
267 };
268 ("i2s.supports_pcm2pdm") => {
269 true
270 };
271 ("i2s.supports_pdm2pcm") => {
272 false
273 };
274 ("parl_io.version") => {
275 2
276 };
277 ("parl_io.version", str) => {
278 stringify!(2)
279 };
280 ("parl_io.max_data_width") => {
281 8
282 };
283 ("parl_io.max_data_width", str) => {
284 stringify!(8)
285 };
286 ("parl_io.has_tx_cs") => {
287 true
288 };
289 ("bt.controller") => {
290 "btdm2"
291 };
292 ("bt.requires_fast_cpu") => {
293 false
294 };
295 ("ieee802154.requires_fast_cpu") => {
296 false
297 };
298 ("phy.combo_module") => {
299 false
300 };
301 ("timergroup.timg_has_timer1") => {
302 false
303 };
304 ("timergroup.timg_has_divcnt_rst") => {
305 true
306 };
307 ("timergroup.wdt_has_conf_update") => {
308 true
309 };
310 ("timergroup.rc_fast_calibration_divider_min_rev") => {
311 0
312 };
313 ("timergroup.rc_fast_calibration_divider") => {
314 32
315 };
316 ("timergroup.rc_fast_calibration_tick_enable") => {
317 false
318 };
319 ("timergroup.rc_slow_calibration_multiplier") => {
320 4
321 };
322 ("rng.apb_cycle_wait_num") => {
323 16
324 };
325 ("rng.apb_cycle_wait_num", str) => {
326 stringify!(16)
327 };
328 ("rng.trng_supported") => {
329 false
330 };
331 ("rng.is_lp_sys") => {
332 false
333 };
334 ("sleep.light_sleep") => {
335 true
336 };
337 ("sleep.deep_sleep") => {
338 true
339 };
340 ("sleep.rejectable_mask") => {
341 17622
342 };
343 ("sleep.ext1_version") => {
344 2
345 };
346 ("sleep.ext1_version", str) => {
347 stringify!(2)
348 };
349 ("sleep.pin_wakeup_version") => {
350 3
351 };
352 ("sleep.pin_wakeup_version", str) => {
353 stringify!(3)
354 };
355 ("sleep.deep_sleep_needs_gpio_isolation") => {
356 false
357 };
358 ("sleep.idle_frequency_scaling") => {
359 false
360 };
361 ("dma.mem2mem_requires_peripheral") => {
362 false
363 };
364 ("dma.ext_mem_configurable_block_size") => {
365 false
366 };
367 ("dma.separate_in_out_interrupts") => {
368 true
369 };
370 ("dma.gdma_version") => {
371 3
372 };
373 ("dma.gdma_version", str) => {
374 stringify!(3)
375 };
376 ("interrupts.status_registers") => {
377 4
378 };
379 ("interrupts.status_registers", str) => {
380 stringify!(4)
381 };
382 ("interrupts.disabled_interrupt") => {
383 0
384 };
385 ("mmu.page_size") => {
386 65536
387 };
388 ("mmu.page_size", str) => {
389 stringify!(65536)
390 };
391 ("mmu.entry_num") => {
392 512
393 };
394 ("mmu.entry_num", str) => {
395 stringify!(512)
396 };
397 ("psram.octal_spi") => {
398 false
399 };
400 ("psram.hex_spi") => {
401 false
402 };
403 ("psram.has_timing_tuning") => {
404 false
405 };
406 ("psram.extmem_origin") => {
407 1107296256
408 };
409 ("psram.extmem_origin", str) => {
410 stringify!(1107296256)
411 };
412 ("psram.idle_low_speed_switch") => {
413 false
414 };
415 ("rom.has_crc_le") => {
416 true
417 };
418 ("rom.has_crc_be") => {
419 true
420 };
421 ("rom.has_md5_bsd") => {
422 true
423 };
424 ("rom.has_md5_mbedtls") => {
425 false
426 };
427 ("rom.no_libgcc") => {
428 true
429 };
430 ("soc.cpu_has_branch_predictor") => {
431 true
432 };
433 ("soc.cpu_has_csr_pc") => {
434 false
435 };
436 ("soc.cpu_has_zcmp_workaround") => {
437 true
438 };
439 ("soc.multi_core_enabled") => {
440 true
441 };
442 ("soc.cpu_pma_needs_core1_setup") => {
443 true
444 };
445 ("soc.cpu_csr_prv_mode") => {
446 2064
447 };
448 ("soc.cpu_csr_prv_mode", str) => {
449 stringify!(2064)
450 };
451 ("soc.internal_memory_cached") => {
452 false
453 };
454 ("soc.cpu_powers_down_cache") => {
455 true
456 };
457 ("soc.has_swd_watchdog") => {
458 true
459 };
460 ("soc.has_bus_clock_update") => {
461 true
462 };
463 ("soc.has_apb_frequency_reduction") => {
464 true
465 };
466 ("soc.cpu_mcause_mask") => {
467 63
468 };
469 ("soc.cpu_mcause_mask", str) => {
470 stringify!(63)
471 };
472 ("soc.cpu_pmp_granularity") => {
473 128
474 };
475 ("soc.cpu_pmp_granularity", str) => {
476 stringify!(128)
477 };
478 ("clock_tree.iomux_function_clock") => {
479 [crate ::soc::clocks::IomuxFunctionClockConfig::XtalClk, crate
480 ::soc::clocks::IomuxFunctionClockConfig::RcFastClk, crate
481 ::soc::clocks::IomuxFunctionClockConfig::PllF48m]
482 };
483 ("clock_tree.hp_root_clk") => {
484 [crate ::soc::clocks::HpRootClkConfig::Xtal, crate
485 ::soc::clocks::HpRootClkConfig::RcFast, crate
486 ::soc::clocks::HpRootClkConfig::XtalX2, crate
487 ::soc::clocks::HpRootClkConfig::Pll]
488 };
489 ("clock_tree.cpu_clk.divisor") => {
490 [0, 1, 3, 7, 15, 31, 63, 127]
491 };
492 ("clock_tree.ahb_clk.divisor") => {
493 (0, 255)
494 };
495 ("clock_tree.apb_clk.divisor") => {
496 [0, 1, 3]
497 };
498 ("clock_tree.lp_fast_clk") => {
499 [crate ::soc::clocks::LpFastClkConfig::RcFastClk, crate
500 ::soc::clocks::LpFastClkConfig::XtalD2Clk]
501 };
502 ("clock_tree.lp_slow_clk") => {
503 [#[cfg(use_xtal32k)] crate ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
504 ::soc::clocks::LpSlowClkConfig::RcSlow, crate
505 ::soc::clocks::LpSlowClkConfig::OscSlow]
506 };
507 ("clock_tree.ble_lp_clk") => {
508 [crate ::soc::clocks::BleLpClkConfig::Xtal, #[cfg(use_xtal32k)] crate
509 ::soc::clocks::BleLpClkConfig::Xtal32k]
510 };
511 ("clock_tree.timg_calibration_clock") => {
512 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
513 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
514 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
515 };
516 ("clock_tree.uart.function_clock.sclk") => {
517 [crate ::soc::clocks::UartFunctionClockSclk::PllF48m, crate
518 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
519 ::soc::clocks::UartFunctionClockSclk::Xtal]
520 };
521 ("clock_tree.uart.function_clock.div_num") => {
522 (0, 255)
523 };
524 ("clock_tree.uart.baud_rate_generator.fractional") => {
525 (0, 15)
526 };
527 ("clock_tree.uart.baud_rate_generator.integral") => {
528 (0, 4095)
529 };
530 ("clock_tree.spi.function_clock") => {
531 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
532 ::soc::clocks::SpiFunctionClockConfig::PllF48m, crate
533 ::soc::clocks::SpiFunctionClockConfig::RcFast]
534 };
535 ("clock_tree.i2s.tx_clk.sclk") => {
536 [crate ::soc::clocks::I2sClkSclk::Xtal, crate ::soc::clocks::I2sClkSclk::PllF96m,
537 crate ::soc::clocks::I2sClkSclk::XtalX2]
538 };
539 ("clock_tree.i2s.tx_clk.div_num") => {
540 (1, 255)
541 };
542 ("clock_tree.i2s.tx_clk.div_a") => {
543 (1, 511)
544 };
545 ("clock_tree.i2s.tx_clk.div_b") => {
546 (0, 511)
547 };
548 ("clock_tree.i2s.rx_clk.sclk") => {
549 [crate ::soc::clocks::I2sClkSclk::Xtal, crate ::soc::clocks::I2sClkSclk::PllF96m,
550 crate ::soc::clocks::I2sClkSclk::XtalX2]
551 };
552 ("clock_tree.i2s.rx_clk.div_num") => {
553 (1, 255)
554 };
555 ("clock_tree.i2s.rx_clk.div_a") => {
556 (1, 511)
557 };
558 ("clock_tree.i2s.rx_clk.div_b") => {
559 (0, 511)
560 };
561 ("clock_tree.i2s.mclk_out") => {
562 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
563 ::soc::clocks::I2sMclkOutConfig::Rx]
564 };
565 ("clock_tree.parl_io.rx_clock") => {
566 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
567 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
568 ::soc::clocks::ParlIoClkConfig::PllF96m]
569 };
570 ("clock_tree.parl_io.tx_clock") => {
571 [crate ::soc::clocks::ParlIoClkConfig::XtalClk, crate
572 ::soc::clocks::ParlIoClkConfig::RcFastClk, crate
573 ::soc::clocks::ParlIoClkConfig::PllF96m]
574 };
575 ("clock_tree.i2c.function_clock.sclk") => {
576 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
577 ::soc::clocks::I2cFunctionClockSclk::RcFast]
578 };
579 ("clock_tree.i2c.function_clock.div_num") => {
580 (0, 255)
581 };
582 ("clock_tree.timg.function_clock") => {
583 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
584 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
585 ::soc::clocks::TimgFunctionClockConfig::PllF48m]
586 };
587 ("clock_tree.timg.wdt_clock") => {
588 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
589 ::soc::clocks::TimgWdtClockConfig::RcFastClk, crate
590 ::soc::clocks::TimgWdtClockConfig::PllF48m]
591 };
592}
593#[macro_export]
594#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
595macro_rules! for_each_dedicated_gpio {
596 ($($pattern:tt => $code:tt;)*) => {
597 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
598 tt) => {} } _for_each_inner_dedicated_gpio!((0));
599 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
600 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
601 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
602 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
603 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
604 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
605 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
606 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
607 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
608 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
609 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
610 _for_each_inner_dedicated_gpio!((1, 0, CPU_GPIO_8));
611 _for_each_inner_dedicated_gpio!((1, 1, CPU_GPIO_9));
612 _for_each_inner_dedicated_gpio!((1, 2, CPU_GPIO_10));
613 _for_each_inner_dedicated_gpio!((1, 3, CPU_GPIO_11));
614 _for_each_inner_dedicated_gpio!((1, 4, CPU_GPIO_12));
615 _for_each_inner_dedicated_gpio!((1, 5, CPU_GPIO_13));
616 _for_each_inner_dedicated_gpio!((1, 6, CPU_GPIO_14));
617 _for_each_inner_dedicated_gpio!((1, 7, CPU_GPIO_15));
618 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
619 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
620 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
621 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7), (1, 0, CPU_GPIO_8), (1, 1,
622 CPU_GPIO_9), (1, 2, CPU_GPIO_10), (1, 3, CPU_GPIO_11), (1, 4, CPU_GPIO_12), (1,
623 5, CPU_GPIO_13), (1, 6, CPU_GPIO_14), (1, 7, CPU_GPIO_15)));
624 };
625}
626#[macro_export]
630#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
631macro_rules! define_lp_io_signals {
632 () => {};
633}
634#[macro_export]
635#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
636macro_rules! for_each_wakeup_source {
637 ($($pattern:tt => $code:tt;)*) => {
638 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
639 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
640 _for_each_inner_wakeup_source!((Gpio, 2)); _for_each_inner_wakeup_source!((Timer,
641 4)); _for_each_inner_wakeup_source!((Uart0, 6));
642 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Bt,
643 10)); _for_each_inner_wakeup_source!((Usb, 14));
644 _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (Timer, 4), (Uart0, 6),
645 (Uart1, 7), (Bt, 10), (Usb, 14)));
646 };
647}
648#[macro_export]
649#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
650macro_rules! for_each_dma_engine {
651 ($($pattern:tt => $code:tt;)*) => {
652 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
653 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
654 _for_each_inner_dma_engine!((all("AHB_GDMA")));
655 };
656}
657#[macro_export]
658#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
659macro_rules! for_each_dma_channel {
660 ($($pattern:tt => $code:tt;)*) => {
661 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
662 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
663 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
664 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
665 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH3));
666 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH4));
667 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
668 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
669 interrupt_out = DMA_OUT_CH0, compatible = [SPI3, SPI2, UHCI0, I2S0, AES, SHA,
670 PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt_in =
671 DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI3, SPI2, UHCI0, I2S0,
672 AES, SHA, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2,
673 interrupt_in = DMA_IN_CH2, interrupt_out = DMA_OUT_CH2, compatible = [SPI3, SPI2,
674 UHCI0, I2S0, AES, SHA, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA",
675 DMA_CH3, 3, interrupt_in = DMA_IN_CH3, interrupt_out = DMA_OUT_CH3, compatible =
676 [SPI3, SPI2, UHCI0, I2S0, AES, SHA, PARL_IO]));
677 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH4, 4, interrupt_in = DMA_IN_CH4,
678 interrupt_out = DMA_OUT_CH4, compatible = [SPI3, SPI2, UHCI0, I2S0, AES, SHA,
679 PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
680 ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2), ("AHB_GDMA", DMA_CH3), ("AHB_GDMA",
681 DMA_CH4))); _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA",
682 any_channel = AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
683 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
684 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI3, SPI2, UHCI0, I2S0,
685 AES, SHA, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
686 interrupt_out = DMA_OUT_CH1, compatible = [SPI3, SPI2, UHCI0, I2S0, AES, SHA,
687 PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2, interrupt_out =
688 DMA_OUT_CH2, compatible = [SPI3, SPI2, UHCI0, I2S0, AES, SHA, PARL_IO]),
689 ("AHB_GDMA", DMA_CH3, 3, interrupt_in = DMA_IN_CH3, interrupt_out = DMA_OUT_CH3,
690 compatible = [SPI3, SPI2, UHCI0, I2S0, AES, SHA, PARL_IO]), ("AHB_GDMA", DMA_CH4,
691 4, interrupt_in = DMA_IN_CH4, interrupt_out = DMA_OUT_CH4, compatible = [SPI3,
692 SPI2, UHCI0, I2S0, AES, SHA, PARL_IO])));
693 _for_each_inner_dma_channel!((no_own_interrupt));
694 };
695}
696#[macro_export]
697#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
698macro_rules! for_each_dma_channel_peri_pair {
699 ($($pattern:tt => $code:tt;)*) => {
700 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
701 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
702 DMA_CH0, SPI3)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
703 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, UHCI0));
704 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
705 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
706 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
707 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
708 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI3));
709 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
710 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
711 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
712 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
713 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
714 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
715 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI3));
716 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
717 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
718 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
719 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
720 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
721 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
722 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, SPI3));
723 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, SPI2));
724 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, UHCI0));
725 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, I2S0));
726 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, AES));
727 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, SHA));
728 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH3, PARL_IO));
729 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, SPI3));
730 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, SPI2));
731 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, UHCI0));
732 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, I2S0));
733 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, AES));
734 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, SHA));
735 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH4, PARL_IO));
736 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
737 SPI3)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
738 AhbGdmaChannel, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
739 any_channel = AhbGdmaChannel, UHCI0));
740 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
741 I2S0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
742 AhbGdmaChannel, AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
743 any_channel = AhbGdmaChannel, SHA));
744 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
745 PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
746 SPI3), ("AHB_GDMA", DMA_CH0, SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA",
747 DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA),
748 ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI3), ("AHB_GDMA",
749 DMA_CH1, SPI2), ("AHB_GDMA", DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0),
750 ("AHB_GDMA", DMA_CH1, AES), ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1,
751 PARL_IO), ("AHB_GDMA", DMA_CH2, SPI3), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA",
752 DMA_CH2, UHCI0), ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES),
753 ("AHB_GDMA", DMA_CH2, SHA), ("AHB_GDMA", DMA_CH2, PARL_IO), ("AHB_GDMA", DMA_CH3,
754 SPI3), ("AHB_GDMA", DMA_CH3, SPI2), ("AHB_GDMA", DMA_CH3, UHCI0), ("AHB_GDMA",
755 DMA_CH3, I2S0), ("AHB_GDMA", DMA_CH3, AES), ("AHB_GDMA", DMA_CH3, SHA),
756 ("AHB_GDMA", DMA_CH3, PARL_IO), ("AHB_GDMA", DMA_CH4, SPI3), ("AHB_GDMA",
757 DMA_CH4, SPI2), ("AHB_GDMA", DMA_CH4, UHCI0), ("AHB_GDMA", DMA_CH4, I2S0),
758 ("AHB_GDMA", DMA_CH4, AES), ("AHB_GDMA", DMA_CH4, SHA), ("AHB_GDMA", DMA_CH4,
759 PARL_IO))); _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA",
760 any_channel = AhbGdmaChannel, SPI3), ("AHB_GDMA", any_channel = AhbGdmaChannel,
761 SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0), ("AHB_GDMA",
762 any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel = AhbGdmaChannel,
763 AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA), ("AHB_GDMA", any_channel =
764 AhbGdmaChannel, PARL_IO)));
765 };
766}
767#[macro_export]
768#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
769macro_rules! for_each_mem2mem_channel {
770 ($($pattern:tt => $code:tt;)*) => {
771 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
772 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
773 AhbGdmaChannel, DMA_CH0, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
774 AhbGdma, AhbGdmaChannel, DMA_CH1, 11));
775 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
776 12)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel,
777 DMA_CH3, 13)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
778 AhbGdmaChannel, DMA_CH4, 14)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
779 AhbGdma, AhbGdmaChannel, 0, 10, 1, 11, 2, 12, 3, 13, 4, 14));
780 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel));
781 _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma, AhbGdmaChannel,
782 DMA_CH0, 10), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 11), ("AHB_GDMA",
783 AhbGdma, AhbGdmaChannel, DMA_CH2, 12), ("AHB_GDMA", AhbGdma, AhbGdmaChannel,
784 DMA_CH3, 13), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH4, 14)));
785 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
786 10, 1, 11, 2, 12, 3, 13, 4, 14)));
787 _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma, AhbGdmaChannel)));
788 };
789}
790#[macro_export]
791#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
792macro_rules! with_i2s_dma_engine {
793 ($($pattern:tt => $code:tt;)*) => {
794 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
795 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
796 };
797}
798#[macro_export]
799#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
800macro_rules! with_parl_io_dma_engine {
801 ($($pattern:tt => $code:tt;)*) => {
802 macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
803 tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
804 };
805}
806#[macro_export]
807#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
808macro_rules! with_spi_master_dma_engine {
809 ($($pattern:tt => $code:tt;)*) => {
810 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
811 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
812 };
813}
814#[macro_export]
815#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
816macro_rules! for_each_interrupt {
817 ($($pattern:tt => $code:tt;)*) => {
818 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
819 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
820 _for_each_inner_interrupt!(([reserved 0] 1));
821 _for_each_inner_interrupt!(([reserved 1] 2));
822 _for_each_inner_interrupt!(([reserved 2] 3));
823 _for_each_inner_interrupt!(([reserved 3] 4));
824 _for_each_inner_interrupt!(([reserved 4] 5));
825 _for_each_inner_interrupt!(([reserved 5] 6));
826 _for_each_inner_interrupt!(([reserved 6] 7));
827 _for_each_inner_interrupt!(([reserved 7] 8));
828 _for_each_inner_interrupt!(([reserved 8] 9));
829 _for_each_inner_interrupt!(([reserved 9] 10));
830 _for_each_inner_interrupt!(([reserved 10] 11));
831 _for_each_inner_interrupt!(([reserved 11] 12));
832 _for_each_inner_interrupt!(([reserved 12] 13));
833 _for_each_inner_interrupt!(([reserved 13] 14));
834 _for_each_inner_interrupt!(([reserved 14] 15));
835 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
836 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
837 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
838 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
839 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
840 7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
841 _for_each_inner_interrupt!(([direct_bindable 1] 25));
842 _for_each_inner_interrupt!(([direct_bindable 2] 26));
843 _for_each_inner_interrupt!(([direct_bindable 3] 27));
844 _for_each_inner_interrupt!(([direct_bindable 4] 28));
845 _for_each_inner_interrupt!(([direct_bindable 5] 29));
846 _for_each_inner_interrupt!(([direct_bindable 6] 30));
847 _for_each_inner_interrupt!(([direct_bindable 7] 31));
848 _for_each_inner_interrupt!(([direct_bindable 8] 32));
849 _for_each_inner_interrupt!(([direct_bindable 9] 33));
850 _for_each_inner_interrupt!(([direct_bindable 10] 34));
851 _for_each_inner_interrupt!(([direct_bindable 11] 35));
852 _for_each_inner_interrupt!(([direct_bindable 12] 36));
853 _for_each_inner_interrupt!(([direct_bindable 13] 37));
854 _for_each_inner_interrupt!(([direct_bindable 14] 38));
855 _for_each_inner_interrupt!(([direct_bindable 15] 39));
856 _for_each_inner_interrupt!(([direct_bindable 16] 40));
857 _for_each_inner_interrupt!(([direct_bindable 17] 41));
858 _for_each_inner_interrupt!(([direct_bindable 18] 42));
859 _for_each_inner_interrupt!(([direct_bindable 19] 43));
860 _for_each_inner_interrupt!(([direct_bindable 20] 44));
861 _for_each_inner_interrupt!(([direct_bindable 21] 45));
862 _for_each_inner_interrupt!(([direct_bindable 22] 46));
863 _for_each_inner_interrupt!(([direct_bindable 23] 47));
864 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
865 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
866 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
867 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
868 ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
869 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
870 ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
871 ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
872 ([direct_bindable 6] 30), ([direct_bindable 7] 31), ([direct_bindable 8] 32),
873 ([direct_bindable 9] 33), ([direct_bindable 10] 34), ([direct_bindable 11] 35),
874 ([direct_bindable 12] 36), ([direct_bindable 13] 37), ([direct_bindable 14] 38),
875 ([direct_bindable 15] 39), ([direct_bindable 16] 40), ([direct_bindable 17] 41),
876 ([direct_bindable 18] 42), ([direct_bindable 19] 43), ([direct_bindable 20] 44),
877 ([direct_bindable 21] 45), ([direct_bindable 22] 46), ([direct_bindable 23]
878 47)));
879 };
880}
881#[macro_export]
882#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
883macro_rules! for_each_classified_interrupt {
884 ($($pattern:tt => $code:tt;)*) => {
885 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
886 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
887 24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
888 _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
889 _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
890 _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
891 _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
892 _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
893 _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
894 _for_each_inner_classified_interrupt!(([direct_bindable 8] 32));
895 _for_each_inner_classified_interrupt!(([direct_bindable 9] 33));
896 _for_each_inner_classified_interrupt!(([direct_bindable 10] 34));
897 _for_each_inner_classified_interrupt!(([direct_bindable 11] 35));
898 _for_each_inner_classified_interrupt!(([direct_bindable 12] 36));
899 _for_each_inner_classified_interrupt!(([direct_bindable 13] 37));
900 _for_each_inner_classified_interrupt!(([direct_bindable 14] 38));
901 _for_each_inner_classified_interrupt!(([direct_bindable 15] 39));
902 _for_each_inner_classified_interrupt!(([direct_bindable 16] 40));
903 _for_each_inner_classified_interrupt!(([direct_bindable 17] 41));
904 _for_each_inner_classified_interrupt!(([direct_bindable 18] 42));
905 _for_each_inner_classified_interrupt!(([direct_bindable 19] 43));
906 _for_each_inner_classified_interrupt!(([direct_bindable 20] 44));
907 _for_each_inner_classified_interrupt!(([direct_bindable 21] 45));
908 _for_each_inner_classified_interrupt!(([direct_bindable 22] 46));
909 _for_each_inner_classified_interrupt!(([direct_bindable 23] 47));
910 _for_each_inner_classified_interrupt!(([vector 0] 16));
911 _for_each_inner_classified_interrupt!(([vector 1] 17));
912 _for_each_inner_classified_interrupt!(([vector 2] 18));
913 _for_each_inner_classified_interrupt!(([vector 3] 19));
914 _for_each_inner_classified_interrupt!(([vector 4] 20));
915 _for_each_inner_classified_interrupt!(([vector 5] 21));
916 _for_each_inner_classified_interrupt!(([vector 6] 22));
917 _for_each_inner_classified_interrupt!(([vector 7] 23));
918 _for_each_inner_classified_interrupt!(([reserved 0] 1));
919 _for_each_inner_classified_interrupt!(([reserved 1] 2));
920 _for_each_inner_classified_interrupt!(([reserved 2] 3));
921 _for_each_inner_classified_interrupt!(([reserved 3] 4));
922 _for_each_inner_classified_interrupt!(([reserved 4] 5));
923 _for_each_inner_classified_interrupt!(([reserved 5] 6));
924 _for_each_inner_classified_interrupt!(([reserved 6] 7));
925 _for_each_inner_classified_interrupt!(([reserved 7] 8));
926 _for_each_inner_classified_interrupt!(([reserved 8] 9));
927 _for_each_inner_classified_interrupt!(([reserved 9] 10));
928 _for_each_inner_classified_interrupt!(([reserved 10] 11));
929 _for_each_inner_classified_interrupt!(([reserved 11] 12));
930 _for_each_inner_classified_interrupt!(([reserved 12] 13));
931 _for_each_inner_classified_interrupt!(([reserved 13] 14));
932 _for_each_inner_classified_interrupt!(([reserved 14] 15));
933 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
934 ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
935 ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
936 ([direct_bindable 7] 31), ([direct_bindable 8] 32), ([direct_bindable 9] 33),
937 ([direct_bindable 10] 34), ([direct_bindable 11] 35), ([direct_bindable 12] 36),
938 ([direct_bindable 13] 37), ([direct_bindable 14] 38), ([direct_bindable 15] 39),
939 ([direct_bindable 16] 40), ([direct_bindable 17] 41), ([direct_bindable 18] 42),
940 ([direct_bindable 19] 43), ([direct_bindable 20] 44), ([direct_bindable 21] 45),
941 ([direct_bindable 22] 46), ([direct_bindable 23] 47)));
942 _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
943 ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
944 22), ([vector 7] 23))); _for_each_inner_classified_interrupt!((reserved([reserved
945 0] 1), ([reserved 1] 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5),
946 ([reserved 5] 6), ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9),
947 ([reserved 9] 10), ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13),
948 ([reserved 13] 14), ([reserved 14] 15)));
949 _for_each_inner_classified_interrupt!((context_switch));
950 };
951}
952#[macro_export]
953#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
954macro_rules! for_each_interrupt_priority {
955 ($($pattern:tt => $code:tt;)*) => {
956 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
957 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
958 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
959 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
960 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
961 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
962 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
963 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
964 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
965 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
966 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
967 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
968 Priority8, Level8)));
969 };
970}
971#[macro_export]
972#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
973macro_rules! for_each_sw_interrupt {
974 ($($pattern:tt => $code:tt;)*) => {
975 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
976 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
977 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
978 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
979 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
980 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
981 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
982 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
983 };
984}
985#[macro_export]
986macro_rules! define_clock_tree_types {
1338 () => {
1339 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1340 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1341 pub enum I2sInstance {
1342 I2s0 = 0,
1343 }
1344 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1345 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1346 pub enum I2cInstance {
1347 I2c0 = 0,
1348 I2c1 = 1,
1349 }
1350 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1351 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1352 pub enum ParlIoInstance {
1353 ParlIo = 0,
1354 }
1355 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1356 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1357 pub enum SpiInstance {
1358 Spi2 = 0,
1359 Spi3 = 1,
1360 }
1361 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1362 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1363 pub enum TimgInstance {
1364 Timg0 = 0,
1365 Timg1 = 1,
1366 }
1367 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1368 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1369 pub enum UartInstance {
1370 Uart0 = 0,
1371 Uart1 = 1,
1372 }
1373 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1375 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1376 pub enum IomuxFunctionClockConfig {
1377 XtalClk,
1379 RcFastClk,
1381 #[default]
1382 PllF48m,
1384 }
1385 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1387 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1388 pub enum HpRootClkConfig {
1389 Xtal,
1391 RcFast,
1393 XtalX2,
1395 Pll,
1397 }
1398 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1399 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1400 pub enum CpuClkDivisor {
1401 _0 = 0,
1403 _1 = 1,
1405 _3 = 3,
1407 _7 = 7,
1409 _15 = 15,
1411 _31 = 31,
1413 _63 = 63,
1415 _127 = 127,
1417 }
1418 impl CpuClkDivisor {
1419 pub const fn new(raw: u32) -> Self {
1421 match raw {
1422 0 => Self::_0,
1423 1 => Self::_1,
1424 3 => Self::_3,
1425 7 => Self::_7,
1426 15 => Self::_15,
1427 31 => Self::_31,
1428 63 => Self::_63,
1429 127 => Self::_127,
1430 _ => ::core::panic!("Invalid CPU_CLK divisor value"),
1431 }
1432 }
1433 }
1434 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1438 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1439 pub struct CpuClkConfig {
1440 divisor: CpuClkDivisor,
1441 }
1442 impl CpuClkConfig {
1443 pub const fn new(divisor: CpuClkDivisor) -> Self {
1445 Self { divisor }
1446 }
1447 pub fn divisor(self) -> u32 {
1448 self.divisor as u32
1449 }
1450 }
1451 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1455 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1456 pub struct AhbClkConfig {
1457 divisor: u32,
1458 }
1459 impl AhbClkConfig {
1460 pub const fn new(divisor: u32) -> Self {
1467 ::core::assert!(
1468 divisor <= 255,
1469 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1470 );
1471 Self { divisor }
1472 }
1473 pub fn divisor(self) -> u32 {
1474 self.divisor as u32
1475 }
1476 }
1477 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1478 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1479 pub enum ApbClkDivisor {
1480 _0 = 0,
1482 _1 = 1,
1484 _3 = 3,
1486 }
1487 impl ApbClkDivisor {
1488 pub const fn new(raw: u32) -> Self {
1490 match raw {
1491 0 => Self::_0,
1492 1 => Self::_1,
1493 3 => Self::_3,
1494 _ => ::core::panic!("Invalid APB_CLK divisor value"),
1495 }
1496 }
1497 }
1498 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1502 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1503 pub struct ApbClkConfig {
1504 divisor: ApbClkDivisor,
1505 }
1506 impl ApbClkConfig {
1507 pub const fn new(divisor: ApbClkDivisor) -> Self {
1509 Self { divisor }
1510 }
1511 pub fn divisor(self) -> u32 {
1512 self.divisor as u32
1513 }
1514 }
1515 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1517 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1518 pub enum LpFastClkConfig {
1519 RcFastClk,
1521 XtalD2Clk,
1523 }
1524 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1526 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1527 pub enum LpSlowClkConfig {
1528 #[cfg(use_xtal32k)]
1529 Xtal32k,
1531 RcSlow,
1533 OscSlow,
1535 }
1536 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1538 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1539 pub enum BleLpClkConfig {
1540 Xtal,
1542 #[cfg(use_xtal32k)]
1543 Xtal32k,
1545 }
1546 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1548 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1549 pub enum TimgCalibrationClockConfig {
1550 RcSlowClk,
1552 RcFastDivClk,
1554 #[cfg(use_xtal32k)]
1555 Xtal32kClk,
1557 }
1558 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1559 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1560 pub enum I2sClkSclk {
1561 Xtal,
1563 #[default]
1564 PllF96m,
1566 XtalX2,
1568 }
1569 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1573 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1574 pub struct I2sClkConfig {
1575 sclk: I2sClkSclk,
1576 div_num: u32,
1577 div_a: u32,
1578 div_b: u32,
1579 }
1580 impl I2sClkConfig {
1581 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
1594 ::core::assert!(
1595 div_num >= 1 && div_num <= 255,
1596 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
1597 );
1598 ::core::assert!(
1599 div_a >= 1 && div_a <= 511,
1600 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
1601 );
1602 ::core::assert!(
1603 div_b <= 511,
1604 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
1605 );
1606 Self {
1607 sclk,
1608 div_num,
1609 div_a,
1610 div_b,
1611 }
1612 }
1613 pub fn sclk(self) -> I2sClkSclk {
1614 self.sclk
1615 }
1616 pub fn div_num(self) -> u32 {
1617 self.div_num as u32
1618 }
1619 pub fn div_a(self) -> u32 {
1620 self.div_a as u32
1621 }
1622 pub fn div_b(self) -> u32 {
1623 self.div_b as u32
1624 }
1625 }
1626 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1628 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1629 pub enum I2sMclkOutConfig {
1630 Tx,
1632 #[default]
1633 Rx,
1635 }
1636 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1637 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1638 pub enum I2cFunctionClockSclk {
1639 #[default]
1640 Xtal,
1642 RcFast,
1644 }
1645 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1649 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1650 pub struct I2cFunctionClockConfig {
1651 sclk: I2cFunctionClockSclk,
1652 div_num: u32,
1653 }
1654 impl I2cFunctionClockConfig {
1655 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1662 ::core::assert!(
1663 div_num <= 255,
1664 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1665 );
1666 Self { sclk, div_num }
1667 }
1668 pub fn sclk(self) -> I2cFunctionClockSclk {
1669 self.sclk
1670 }
1671 pub fn div_num(self) -> u32 {
1672 self.div_num as u32
1673 }
1674 }
1675 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1677 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1678 pub enum ParlIoClkConfig {
1679 XtalClk,
1681 RcFastClk,
1683 #[default]
1684 PllF96m,
1686 }
1687 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1689 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1690 pub enum SpiFunctionClockConfig {
1691 Xtal,
1693 #[default]
1694 PllF48m,
1696 RcFast,
1698 }
1699 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1701 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1702 pub enum TimgFunctionClockConfig {
1703 #[default]
1704 XtalClk,
1706 RcFastClk,
1708 PllF48m,
1710 }
1711 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1713 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1714 pub enum TimgWdtClockConfig {
1715 #[default]
1716 XtalClk,
1718 RcFastClk,
1720 PllF48m,
1722 }
1723 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1724 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1725 pub enum UartFunctionClockSclk {
1726 #[default]
1727 PllF48m,
1729 RcFast,
1731 Xtal,
1733 }
1734 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1738 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1739 pub struct UartFunctionClockConfig {
1740 sclk: UartFunctionClockSclk,
1741 div_num: u32,
1742 }
1743 impl UartFunctionClockConfig {
1744 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1751 ::core::assert!(
1752 div_num <= 255,
1753 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1754 );
1755 Self { sclk, div_num }
1756 }
1757 pub fn sclk(self) -> UartFunctionClockSclk {
1758 self.sclk
1759 }
1760 pub fn div_num(self) -> u32 {
1761 self.div_num as u32
1762 }
1763 }
1764 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1769 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1770 pub struct UartBaudRateGeneratorConfig {
1771 fractional: u32,
1772 integral: u32,
1773 }
1774 impl UartBaudRateGeneratorConfig {
1775 pub const fn new(fractional: u32, integral: u32) -> Self {
1785 ::core::assert!(
1786 fractional <= 15,
1787 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1788 );
1789 ::core::assert!(
1790 integral <= 4095,
1791 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1792 );
1793 Self {
1794 fractional,
1795 integral,
1796 }
1797 }
1798 pub fn fractional(self) -> u32 {
1799 self.fractional as u32
1800 }
1801 pub fn integral(self) -> u32 {
1802 self.integral as u32
1803 }
1804 }
1805 pub struct ClockTree {
1807 iomux_function_clock: Option<IomuxFunctionClockConfig>,
1808 hp_root_clk: Option<HpRootClkConfig>,
1809 cpu_clk: Option<CpuClkConfig>,
1810 ahb_clk: Option<AhbClkConfig>,
1811 apb_clk: Option<ApbClkConfig>,
1812 lp_fast_clk: Option<LpFastClkConfig>,
1813 lp_slow_clk: Option<LpSlowClkConfig>,
1814 ble_lp_clk: Option<BleLpClkConfig>,
1815 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1816 i2s_tx_clk: [Option<I2sClkConfig>; 1],
1817 i2s_rx_clk: [Option<I2sClkConfig>; 1],
1818 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
1819 i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
1820 parl_io_rx_clock: [Option<ParlIoClkConfig>; 1],
1821 parl_io_tx_clock: [Option<ParlIoClkConfig>; 1],
1822 spi_function_clock: [Option<SpiFunctionClockConfig>; 2],
1823 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1824 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1825 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
1826 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
1827 pub(crate) pll_f96m_clk_refcount: u32,
1828 pub(crate) pll_f48m_clk_refcount: u32,
1829 pub(crate) xtal_x2_clk_refcount: u32,
1830 pub(crate) rc_fast_clk_refcount: u32,
1831 #[cfg(use_xtal32k)]
1832 pub(crate) xtal32k_clk_refcount: u32,
1833 pub(crate) rc_slow_d4_clk_refcount: u32,
1834 pub(crate) apb_clk_refcount: u32,
1835 pub(crate) lp_fast_clk_refcount: u32,
1836 pub(crate) lp_slow_clk_refcount: u32,
1837 pub(crate) ble_lp_clk_refcount: u32,
1838 pub(crate) timg_calibration_clock_refcount: u32,
1839 pub(crate) i2s_tx_clk_refcount: [u32; 1],
1840 pub(crate) i2s_rx_clk_refcount: [u32; 1],
1841 pub(crate) i2s_mclk_out_refcount: [u32; 1],
1842 pub(crate) i2c_function_clock_refcount: [u32; 2],
1843 pub(crate) parl_io_rx_clock_refcount: [u32; 1],
1844 pub(crate) parl_io_tx_clock_refcount: [u32; 1],
1845 pub(crate) spi_function_clock_refcount: [u32; 2],
1846 pub(crate) timg_function_clock_refcount: [u32; 2],
1847 pub(crate) timg_wdt_clock_refcount: [u32; 2],
1848 pub(crate) uart_function_clock_refcount: [u32; 2],
1849 pub(crate) uart_baud_rate_generator_refcount: [u32; 2],
1850 }
1851 impl ClockTree {
1852 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1854 CLOCK_TREE.with(f)
1855 }
1856 pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
1858 self.iomux_function_clock
1859 }
1860 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
1862 self.hp_root_clk
1863 }
1864 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1866 self.cpu_clk
1867 }
1868 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
1870 self.ahb_clk
1871 }
1872 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1874 self.apb_clk
1875 }
1876 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
1878 self.lp_fast_clk
1879 }
1880 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
1882 self.lp_slow_clk
1883 }
1884 pub fn ble_lp_clk(&self) -> Option<BleLpClkConfig> {
1886 self.ble_lp_clk
1887 }
1888 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1890 self.timg_calibration_clock
1891 }
1892 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
1894 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
1895 }
1896 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
1898 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
1899 }
1900 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
1902 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
1903 }
1904 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1906 self.i2c_function_clock[I2cInstance::I2c0 as usize]
1907 }
1908 pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1910 self.i2c_function_clock[I2cInstance::I2c1 as usize]
1911 }
1912 pub fn parl_io_rx_clock(&self) -> Option<ParlIoClkConfig> {
1914 self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
1915 }
1916 pub fn parl_io_tx_clock(&self) -> Option<ParlIoClkConfig> {
1918 self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
1919 }
1920 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
1922 self.spi_function_clock[SpiInstance::Spi2 as usize]
1923 }
1924 pub fn spi3_function_clock(&self) -> Option<SpiFunctionClockConfig> {
1926 self.spi_function_clock[SpiInstance::Spi3 as usize]
1927 }
1928 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1930 self.timg_function_clock[TimgInstance::Timg0 as usize]
1931 }
1932 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1934 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
1935 }
1936 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1938 self.timg_function_clock[TimgInstance::Timg1 as usize]
1939 }
1940 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1942 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
1943 }
1944 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1946 self.uart_function_clock[UartInstance::Uart0 as usize]
1947 }
1948 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1950 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1951 }
1952 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1954 self.uart_function_clock[UartInstance::Uart1 as usize]
1955 }
1956 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1958 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
1959 }
1960 }
1961 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
1962 ::esp_sync::NonReentrantMutex::new(ClockTree {
1963 iomux_function_clock: None,
1964 hp_root_clk: None,
1965 cpu_clk: None,
1966 ahb_clk: None,
1967 apb_clk: None,
1968 lp_fast_clk: None,
1969 lp_slow_clk: None,
1970 ble_lp_clk: None,
1971 timg_calibration_clock: None,
1972 i2s_tx_clk: [None; 1],
1973 i2s_rx_clk: [None; 1],
1974 i2s_mclk_out: [None; 1],
1975 i2c_function_clock: [None; 2],
1976 parl_io_rx_clock: [None; 1],
1977 parl_io_tx_clock: [None; 1],
1978 spi_function_clock: [None; 2],
1979 timg_function_clock: [None; 2],
1980 timg_wdt_clock: [None; 2],
1981 uart_function_clock: [None; 2],
1982 uart_baud_rate_generator: [None; 2],
1983 pll_f96m_clk_refcount: 0,
1984 pll_f48m_clk_refcount: 0,
1985 xtal_x2_clk_refcount: 0,
1986 rc_fast_clk_refcount: 0,
1987 #[cfg(use_xtal32k)]
1988 xtal32k_clk_refcount: 0,
1989 rc_slow_d4_clk_refcount: 0,
1990 apb_clk_refcount: 0,
1991 lp_fast_clk_refcount: 0,
1992 lp_slow_clk_refcount: 0,
1993 ble_lp_clk_refcount: 0,
1994 timg_calibration_clock_refcount: 0,
1995 i2s_tx_clk_refcount: [0; 1],
1996 i2s_rx_clk_refcount: [0; 1],
1997 i2s_mclk_out_refcount: [0; 1],
1998 i2c_function_clock_refcount: [0; 2],
1999 parl_io_rx_clock_refcount: [0; 1],
2000 parl_io_tx_clock_refcount: [0; 1],
2001 spi_function_clock_refcount: [0; 2],
2002 timg_function_clock_refcount: [0; 2],
2003 timg_wdt_clock_refcount: [0; 2],
2004 uart_function_clock_refcount: [0; 2],
2005 uart_baud_rate_generator_refcount: [0; 2],
2006 });
2007 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2008 ::core::sync::atomic::AtomicU32::new(0);
2009 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2010 ::core::sync::atomic::AtomicU32::new(0);
2011 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2012 ::core::sync::atomic::AtomicU32::new(0);
2013 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2014 ::core::sync::atomic::AtomicU32::new(0);
2015 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2016 ::core::sync::atomic::AtomicU32::new(0);
2017 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2018 ::core::sync::atomic::AtomicU32::new(0);
2019 static BLE_LP_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2020 ::core::sync::atomic::AtomicU32::new(0);
2021 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2022 ::core::sync::atomic::AtomicU32::new(0);
2023 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2024 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2025 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2026 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2027 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2028 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2029 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2030 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2031 static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2032 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2033 static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2034 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2035 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2036 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2037 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2038 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2039 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2040 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2041 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2042 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2043 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2044 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2045 static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2046 ::core::sync::atomic::AtomicU32::new(0);
2047 #[derive(Debug, enumset::EnumSetType)]
2052 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2053 pub enum ClockSource {
2054 XtalClk,
2056 RcFastClk,
2058 #[cfg(use_xtal32k)]
2059 Xtal32kClk,
2061 OscSlowClk,
2063 RcSlowClk,
2065 }
2066 pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2068 Some(ClockSource::XtalClk)
2069 }
2070 pub fn pll_f96m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2072 xtal_clk_root_source(clocks)
2073 }
2074 pub fn pll_f48m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2076 pll_f96m_clk_root_source(clocks)
2077 }
2078 pub fn xtal_x2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2080 xtal_clk_root_source(clocks)
2081 }
2082 pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2084 Some(ClockSource::RcFastClk)
2085 }
2086 #[cfg(use_xtal32k)]
2087 pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2089 Some(ClockSource::Xtal32kClk)
2090 }
2091 pub fn osc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2093 Some(ClockSource::OscSlowClk)
2094 }
2095 pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2097 Some(ClockSource::RcSlowClk)
2098 }
2099 pub fn rc_slow_d4_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2101 rc_slow_clk_root_source(clocks)
2102 }
2103 pub fn hp_root_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2105 let config = clocks.hp_root_clk?;
2106 match config {
2107 HpRootClkConfig::Xtal => xtal_clk_root_source(clocks),
2108 HpRootClkConfig::RcFast => rc_fast_clk_root_source(clocks),
2109 HpRootClkConfig::XtalX2 => xtal_x2_clk_root_source(clocks),
2110 HpRootClkConfig::Pll => pll_f96m_clk_root_source(clocks),
2111 }
2112 }
2113 pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2115 hp_root_clk_root_source(clocks)
2116 }
2117 pub fn ahb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2119 cpu_clk_root_source(clocks)
2120 }
2121 pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2123 ahb_clk_root_source(clocks)
2124 }
2125 pub fn xtal_d2_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2127 xtal_clk_root_source(clocks)
2128 }
2129 pub fn lp_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2131 let config = clocks.lp_fast_clk?;
2132 match config {
2133 LpFastClkConfig::RcFastClk => rc_fast_clk_root_source(clocks),
2134 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_root_source(clocks),
2135 }
2136 }
2137 pub fn lp_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2139 let config = clocks.lp_slow_clk?;
2140 match config {
2141 #[cfg(use_xtal32k)]
2142 LpSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2143 LpSlowClkConfig::RcSlow => rc_slow_d4_clk_root_source(clocks),
2144 LpSlowClkConfig::OscSlow => osc_slow_clk_root_source(clocks),
2145 }
2146 }
2147 pub fn ble_lp_xtal_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2149 xtal_clk_root_source(clocks)
2150 }
2151 pub fn ble_lp_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2153 let config = clocks.ble_lp_clk?;
2154 match config {
2155 BleLpClkConfig::Xtal => ble_lp_xtal_clk_root_source(clocks),
2156 #[cfg(use_xtal32k)]
2157 BleLpClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2158 }
2159 }
2160 pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2162 let config = clocks.timg_calibration_clock?;
2163 match config {
2164 TimgCalibrationClockConfig::RcSlowClk => rc_slow_d4_clk_root_source(clocks),
2165 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_root_source(clocks),
2166 #[cfg(use_xtal32k)]
2167 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
2168 }
2169 }
2170 pub fn iomux_function_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2172 let config = clocks.iomux_function_clock?;
2173 match config {
2174 IomuxFunctionClockConfig::XtalClk => xtal_clk_root_source(clocks),
2175 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_root_source(clocks),
2176 IomuxFunctionClockConfig::PllF48m => pll_f48m_clk_root_source(clocks),
2177 }
2178 }
2179 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2180 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2181 pub fn xtal_clk_frequency() -> u32 {
2182 (32 * 1000000)
2183 }
2184 pub fn request_pll_f96m_clk(clocks: &mut ClockTree) {
2185 trace!("Requesting PLL_F96M_CLK");
2186 if increment_reference_count(&mut clocks.pll_f96m_clk_refcount) {
2187 trace!("Enabling PLL_F96M_CLK");
2188 request_xtal_clk(clocks);
2189 enable_pll_f96m_clk_impl(clocks, true);
2190 }
2191 }
2192 pub fn release_pll_f96m_clk(clocks: &mut ClockTree) {
2193 trace!("Releasing PLL_F96M_CLK");
2194 if decrement_reference_count(&mut clocks.pll_f96m_clk_refcount) {
2195 trace!("Disabling PLL_F96M_CLK");
2196 enable_pll_f96m_clk_impl(clocks, false);
2197 release_xtal_clk(clocks);
2198 }
2199 }
2200 pub fn pll_f96m_clk_frequency() -> u32 {
2201 96000000
2202 }
2203 pub fn pll_f96m_clk_source_frequency() -> u32 {
2204 xtal_clk_frequency()
2205 }
2206 pub fn request_pll_f48m_clk(clocks: &mut ClockTree) {
2207 trace!("Requesting PLL_F48M_CLK");
2208 if increment_reference_count(&mut clocks.pll_f48m_clk_refcount) {
2209 trace!("Enabling PLL_F48M_CLK");
2210 request_pll_f96m_clk(clocks);
2211 enable_pll_f48m_clk_impl(clocks, true);
2212 }
2213 }
2214 pub fn release_pll_f48m_clk(clocks: &mut ClockTree) {
2215 trace!("Releasing PLL_F48M_CLK");
2216 if decrement_reference_count(&mut clocks.pll_f48m_clk_refcount) {
2217 trace!("Disabling PLL_F48M_CLK");
2218 enable_pll_f48m_clk_impl(clocks, false);
2219 release_pll_f96m_clk(clocks);
2220 }
2221 }
2222 pub fn pll_f48m_clk_frequency() -> u32 {
2223 (pll_f96m_clk_frequency() / 2)
2224 }
2225 pub fn pll_f48m_clk_source_frequency() -> u32 {
2226 pll_f96m_clk_frequency()
2227 }
2228 pub fn configure_iomux_function_clock(
2229 clocks: &mut ClockTree,
2230 new_selector: IomuxFunctionClockConfig,
2231 ) {
2232 let old_selector = clocks.iomux_function_clock.replace(new_selector);
2233 refresh_iomux_function_clock_downstream(clocks);
2234 match new_selector {
2235 IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2236 IomuxFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2237 IomuxFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2238 }
2239 configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
2240 if let Some(old_selector) = old_selector {
2241 match old_selector {
2242 IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2243 IomuxFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2244 IomuxFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2245 }
2246 }
2247 }
2248 pub fn iomux_function_clock_config(
2249 clocks: &mut ClockTree,
2250 ) -> Option<IomuxFunctionClockConfig> {
2251 clocks.iomux_function_clock
2252 }
2253 fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
2254 fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
2255 pub fn iomux_function_clock_config_frequency(config: IomuxFunctionClockConfig) -> u32 {
2256 match config {
2257 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2258 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
2259 IomuxFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
2260 }
2261 }
2262 pub fn iomux_function_clock_frequency() -> u32 {
2263 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2264 }
2265 pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
2266 iomux_function_clock_config_frequency(source)
2267 }
2268 pub fn request_xtal_x2_clk(clocks: &mut ClockTree) {
2269 trace!("Requesting XTAL_X2_CLK");
2270 if increment_reference_count(&mut clocks.xtal_x2_clk_refcount) {
2271 trace!("Enabling XTAL_X2_CLK");
2272 request_xtal_clk(clocks);
2273 enable_xtal_x2_clk_impl(clocks, true);
2274 }
2275 }
2276 pub fn release_xtal_x2_clk(clocks: &mut ClockTree) {
2277 trace!("Releasing XTAL_X2_CLK");
2278 if decrement_reference_count(&mut clocks.xtal_x2_clk_refcount) {
2279 trace!("Disabling XTAL_X2_CLK");
2280 enable_xtal_x2_clk_impl(clocks, false);
2281 release_xtal_clk(clocks);
2282 }
2283 }
2284 pub fn xtal_x2_clk_frequency() -> u32 {
2285 64000000
2286 }
2287 pub fn xtal_x2_clk_source_frequency() -> u32 {
2288 xtal_clk_frequency()
2289 }
2290 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2291 trace!("Requesting RC_FAST_CLK");
2292 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2293 trace!("Enabling RC_FAST_CLK");
2294 enable_rc_fast_clk_impl(clocks, true);
2295 }
2296 }
2297 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2298 trace!("Releasing RC_FAST_CLK");
2299 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2300 trace!("Disabling RC_FAST_CLK");
2301 enable_rc_fast_clk_impl(clocks, false);
2302 }
2303 }
2304 static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2305 ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
2306 pub const fn rc_fast_clk_nominal_frequency() -> u32 {
2307 20000000
2308 }
2309 pub fn rc_fast_clk_frequency() -> u32 {
2310 RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2311 }
2312 pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2313 if !(10000000..=30000000).contains(&frequency) {
2314 warn!(
2315 "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
2316 frequency
2317 );
2318 return;
2319 }
2320 debug!(
2321 "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
2322 frequency,
2323 rc_fast_clk_nominal_frequency()
2324 );
2325 RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2326 refresh_rc_fast_clk_downstream(clocks);
2327 }
2328 #[cfg(use_xtal32k)]
2329 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2330 trace!("Requesting XTAL32K_CLK");
2331 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2332 trace!("Enabling XTAL32K_CLK");
2333 enable_xtal32k_clk_impl(clocks, true);
2334 }
2335 }
2336 #[cfg(use_xtal32k)]
2337 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2338 trace!("Releasing XTAL32K_CLK");
2339 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2340 trace!("Disabling XTAL32K_CLK");
2341 enable_xtal32k_clk_impl(clocks, false);
2342 }
2343 }
2344 #[cfg(use_xtal32k)]
2345 pub fn xtal32k_clk_frequency() -> u32 {
2346 32768
2347 }
2348 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2349 trace!("Enabling OSC_SLOW_CLK");
2350 enable_osc_slow_clk_impl(clocks, true);
2351 }
2352 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2353 trace!("Disabling OSC_SLOW_CLK");
2354 enable_osc_slow_clk_impl(clocks, false);
2355 }
2356 pub fn osc_slow_clk_frequency() -> u32 {
2357 32768
2358 }
2359 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2360 trace!("Enabling RC_SLOW_CLK");
2361 enable_rc_slow_clk_impl(clocks, true);
2362 }
2363 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2364 trace!("Disabling RC_SLOW_CLK");
2365 enable_rc_slow_clk_impl(clocks, false);
2366 }
2367 static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2368 ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
2369 pub const fn rc_slow_clk_nominal_frequency() -> u32 {
2370 600000
2371 }
2372 pub fn rc_slow_clk_frequency() -> u32 {
2373 RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2374 }
2375 pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2376 if !(300000..=900000).contains(&frequency) {
2377 warn!(
2378 "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
2379 frequency
2380 );
2381 return;
2382 }
2383 debug!(
2384 "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
2385 frequency,
2386 rc_slow_clk_nominal_frequency()
2387 );
2388 RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2389 refresh_rc_slow_clk_downstream(clocks);
2390 }
2391 pub fn request_rc_slow_d4_clk(clocks: &mut ClockTree) {
2392 trace!("Requesting RC_SLOW_D4_CLK");
2393 if increment_reference_count(&mut clocks.rc_slow_d4_clk_refcount) {
2394 trace!("Enabling RC_SLOW_D4_CLK");
2395 request_rc_slow_clk(clocks);
2396 enable_rc_slow_d4_clk_impl(clocks, true);
2397 }
2398 }
2399 pub fn release_rc_slow_d4_clk(clocks: &mut ClockTree) {
2400 trace!("Releasing RC_SLOW_D4_CLK");
2401 if decrement_reference_count(&mut clocks.rc_slow_d4_clk_refcount) {
2402 trace!("Disabling RC_SLOW_D4_CLK");
2403 enable_rc_slow_d4_clk_impl(clocks, false);
2404 release_rc_slow_clk(clocks);
2405 }
2406 }
2407 pub fn rc_slow_d4_clk_frequency() -> u32 {
2408 (rc_slow_clk_frequency() / 4)
2409 }
2410 pub fn rc_slow_d4_clk_source_frequency() -> u32 {
2411 rc_slow_clk_frequency()
2412 }
2413 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
2414 let old_selector = clocks.hp_root_clk.replace(new_selector);
2415 refresh_hp_root_clk_downstream(clocks);
2416 match new_selector {
2417 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2418 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2419 HpRootClkConfig::XtalX2 => request_xtal_x2_clk(clocks),
2420 HpRootClkConfig::Pll => request_pll_f96m_clk(clocks),
2421 }
2422 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2423 if let Some(old_selector) = old_selector {
2424 match old_selector {
2425 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2426 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2427 HpRootClkConfig::XtalX2 => release_xtal_x2_clk(clocks),
2428 HpRootClkConfig::Pll => release_pll_f96m_clk(clocks),
2429 }
2430 }
2431 }
2432 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
2433 clocks.hp_root_clk
2434 }
2435 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
2436 trace!("Enabling HP_ROOT_CLK");
2437 match unwrap!(clocks.hp_root_clk) {
2438 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2439 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2440 HpRootClkConfig::XtalX2 => request_xtal_x2_clk(clocks),
2441 HpRootClkConfig::Pll => request_pll_f96m_clk(clocks),
2442 }
2443 enable_hp_root_clk_impl(clocks, true);
2444 }
2445 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
2446 trace!("Disabling HP_ROOT_CLK");
2447 enable_hp_root_clk_impl(clocks, false);
2448 match unwrap!(clocks.hp_root_clk) {
2449 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2450 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2451 HpRootClkConfig::XtalX2 => release_xtal_x2_clk(clocks),
2452 HpRootClkConfig::Pll => release_pll_f96m_clk(clocks),
2453 }
2454 }
2455 pub fn hp_root_clk_config_frequency(config: HpRootClkConfig) -> u32 {
2456 match config {
2457 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2458 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2459 HpRootClkConfig::XtalX2 => xtal_x2_clk_frequency(),
2460 HpRootClkConfig::Pll => pll_f96m_clk_frequency(),
2461 }
2462 }
2463 pub fn hp_root_clk_frequency() -> u32 {
2464 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2465 }
2466 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
2467 hp_root_clk_config_frequency(source)
2468 }
2469 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
2470 let old_config = clocks.cpu_clk.replace(config);
2471 refresh_cpu_clk_downstream(clocks);
2472 if old_config.is_none() {
2473 request_hp_root_clk(clocks);
2474 }
2475 configure_cpu_clk_impl(clocks, old_config, config);
2476 }
2477 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2478 clocks.cpu_clk
2479 }
2480 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2481 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2482 pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
2483 (hp_root_clk_frequency() / (config.divisor() + 1))
2484 }
2485 pub fn cpu_clk_frequency() -> u32 {
2486 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2487 }
2488 pub fn cpu_clk_source_frequency() -> u32 {
2489 hp_root_clk_frequency()
2490 }
2491 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
2492 let old_config = clocks.ahb_clk.replace(config);
2493 refresh_ahb_clk_downstream(clocks);
2494 if old_config.is_none() {
2495 request_cpu_clk(clocks);
2496 }
2497 configure_ahb_clk_impl(clocks, old_config, config);
2498 }
2499 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
2500 clocks.ahb_clk
2501 }
2502 fn request_ahb_clk(_clocks: &mut ClockTree) {}
2503 fn release_ahb_clk(_clocks: &mut ClockTree) {}
2504 pub fn ahb_clk_config_frequency(config: AhbClkConfig) -> u32 {
2505 (cpu_clk_frequency() / (config.divisor() + 1))
2506 }
2507 pub fn ahb_clk_frequency() -> u32 {
2508 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2509 }
2510 pub fn ahb_clk_source_frequency() -> u32 {
2511 cpu_clk_frequency()
2512 }
2513 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
2514 let old_config = clocks.apb_clk.replace(config);
2515 refresh_apb_clk_downstream(clocks);
2516 if old_config.is_none() {
2517 request_ahb_clk(clocks);
2518 }
2519 configure_apb_clk_impl(clocks, old_config, config);
2520 }
2521 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2522 clocks.apb_clk
2523 }
2524 pub fn request_apb_clk(clocks: &mut ClockTree) {
2525 trace!("Requesting APB_CLK");
2526 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2527 enable_apb_clk_impl(clocks, true);
2528 }
2529 }
2530 pub fn release_apb_clk(clocks: &mut ClockTree) {
2531 trace!("Releasing APB_CLK");
2532 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2533 enable_apb_clk_impl(clocks, false);
2534 }
2535 }
2536 pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
2537 (ahb_clk_frequency() / (config.divisor() + 1))
2538 }
2539 pub fn apb_clk_frequency() -> u32 {
2540 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2541 }
2542 pub fn apb_clk_source_frequency() -> u32 {
2543 ahb_clk_frequency()
2544 }
2545 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
2546 trace!("Enabling XTAL_D2_CLK");
2547 request_xtal_clk(clocks);
2548 enable_xtal_d2_clk_impl(clocks, true);
2549 }
2550 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
2551 trace!("Disabling XTAL_D2_CLK");
2552 enable_xtal_d2_clk_impl(clocks, false);
2553 release_xtal_clk(clocks);
2554 }
2555 pub fn xtal_d2_clk_frequency() -> u32 {
2556 (xtal_clk_frequency() / 2)
2557 }
2558 pub fn xtal_d2_clk_source_frequency() -> u32 {
2559 xtal_clk_frequency()
2560 }
2561 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
2562 let old_selector = clocks.lp_fast_clk.replace(new_selector);
2563 refresh_lp_fast_clk_downstream(clocks);
2564 let active = clocks.lp_fast_clk_refcount > 0;
2565 if active {
2566 match new_selector {
2567 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
2568 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
2569 }
2570 }
2571 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2572 if active && let Some(old_selector) = old_selector {
2573 match old_selector {
2574 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
2575 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
2576 }
2577 }
2578 }
2579 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
2580 clocks.lp_fast_clk
2581 }
2582 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
2583 trace!("Requesting LP_FAST_CLK");
2584 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
2585 trace!("Enabling LP_FAST_CLK");
2586 match unwrap!(clocks.lp_fast_clk) {
2587 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
2588 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
2589 }
2590 enable_lp_fast_clk_impl(clocks, true);
2591 }
2592 }
2593 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
2594 trace!("Releasing LP_FAST_CLK");
2595 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
2596 trace!("Disabling LP_FAST_CLK");
2597 enable_lp_fast_clk_impl(clocks, false);
2598 match unwrap!(clocks.lp_fast_clk) {
2599 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
2600 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
2601 }
2602 }
2603 }
2604 pub fn lp_fast_clk_config_frequency(config: LpFastClkConfig) -> u32 {
2605 match config {
2606 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
2607 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
2608 }
2609 }
2610 pub fn lp_fast_clk_frequency() -> u32 {
2611 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2612 }
2613 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
2614 lp_fast_clk_config_frequency(source)
2615 }
2616 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
2617 let old_selector = clocks.lp_slow_clk.replace(new_selector);
2618 refresh_lp_slow_clk_downstream(clocks);
2619 let active = clocks.lp_slow_clk_refcount > 0;
2620 if active {
2621 match new_selector {
2622 #[cfg(use_xtal32k)]
2623 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2624 LpSlowClkConfig::RcSlow => request_rc_slow_d4_clk(clocks),
2625 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2626 }
2627 }
2628 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2629 if active && let Some(old_selector) = old_selector {
2630 match old_selector {
2631 #[cfg(use_xtal32k)]
2632 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2633 LpSlowClkConfig::RcSlow => release_rc_slow_d4_clk(clocks),
2634 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2635 }
2636 }
2637 }
2638 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
2639 clocks.lp_slow_clk
2640 }
2641 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
2642 trace!("Requesting LP_SLOW_CLK");
2643 if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
2644 trace!("Enabling LP_SLOW_CLK");
2645 match unwrap!(clocks.lp_slow_clk) {
2646 #[cfg(use_xtal32k)]
2647 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2648 LpSlowClkConfig::RcSlow => request_rc_slow_d4_clk(clocks),
2649 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2650 }
2651 enable_lp_slow_clk_impl(clocks, true);
2652 }
2653 }
2654 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2655 trace!("Releasing LP_SLOW_CLK");
2656 if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
2657 trace!("Disabling LP_SLOW_CLK");
2658 enable_lp_slow_clk_impl(clocks, false);
2659 match unwrap!(clocks.lp_slow_clk) {
2660 #[cfg(use_xtal32k)]
2661 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2662 LpSlowClkConfig::RcSlow => release_rc_slow_d4_clk(clocks),
2663 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2664 }
2665 }
2666 }
2667 pub fn lp_slow_clk_config_frequency(config: LpSlowClkConfig) -> u32 {
2668 match config {
2669 #[cfg(use_xtal32k)]
2670 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2671 LpSlowClkConfig::RcSlow => rc_slow_d4_clk_frequency(),
2672 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2673 }
2674 }
2675 pub fn lp_slow_clk_frequency() -> u32 {
2676 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2677 }
2678 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
2679 lp_slow_clk_config_frequency(source)
2680 }
2681 pub fn request_ble_lp_xtal_clk(clocks: &mut ClockTree) {
2682 trace!("Enabling BLE_LP_XTAL_CLK");
2683 request_xtal_clk(clocks);
2684 enable_ble_lp_xtal_clk_impl(clocks, true);
2685 }
2686 pub fn release_ble_lp_xtal_clk(clocks: &mut ClockTree) {
2687 trace!("Disabling BLE_LP_XTAL_CLK");
2688 enable_ble_lp_xtal_clk_impl(clocks, false);
2689 release_xtal_clk(clocks);
2690 }
2691 pub fn ble_lp_xtal_clk_frequency() -> u32 {
2692 100000
2693 }
2694 pub fn ble_lp_xtal_clk_source_frequency() -> u32 {
2695 xtal_clk_frequency()
2696 }
2697 pub fn configure_ble_lp_clk(clocks: &mut ClockTree, new_selector: BleLpClkConfig) {
2698 let old_selector = clocks.ble_lp_clk.replace(new_selector);
2699 refresh_ble_lp_clk_downstream(clocks);
2700 let active = clocks.ble_lp_clk_refcount > 0;
2701 if active {
2702 match new_selector {
2703 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
2704 #[cfg(use_xtal32k)]
2705 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2706 }
2707 }
2708 configure_ble_lp_clk_impl(clocks, old_selector, new_selector);
2709 if active && let Some(old_selector) = old_selector {
2710 match old_selector {
2711 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
2712 #[cfg(use_xtal32k)]
2713 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2714 }
2715 }
2716 }
2717 pub fn ble_lp_clk_config(clocks: &mut ClockTree) -> Option<BleLpClkConfig> {
2718 clocks.ble_lp_clk
2719 }
2720 pub fn request_ble_lp_clk(clocks: &mut ClockTree) {
2721 trace!("Requesting BLE_LP_CLK");
2722 if increment_reference_count(&mut clocks.ble_lp_clk_refcount) {
2723 trace!("Enabling BLE_LP_CLK");
2724 match unwrap!(clocks.ble_lp_clk) {
2725 BleLpClkConfig::Xtal => request_ble_lp_xtal_clk(clocks),
2726 #[cfg(use_xtal32k)]
2727 BleLpClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2728 }
2729 enable_ble_lp_clk_impl(clocks, true);
2730 }
2731 }
2732 pub fn release_ble_lp_clk(clocks: &mut ClockTree) {
2733 trace!("Releasing BLE_LP_CLK");
2734 if decrement_reference_count(&mut clocks.ble_lp_clk_refcount) {
2735 trace!("Disabling BLE_LP_CLK");
2736 enable_ble_lp_clk_impl(clocks, false);
2737 match unwrap!(clocks.ble_lp_clk) {
2738 BleLpClkConfig::Xtal => release_ble_lp_xtal_clk(clocks),
2739 #[cfg(use_xtal32k)]
2740 BleLpClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2741 }
2742 }
2743 }
2744 pub fn ble_lp_clk_config_frequency(config: BleLpClkConfig) -> u32 {
2745 match config {
2746 BleLpClkConfig::Xtal => ble_lp_xtal_clk_frequency(),
2747 #[cfg(use_xtal32k)]
2748 BleLpClkConfig::Xtal32k => xtal32k_clk_frequency(),
2749 }
2750 }
2751 pub fn ble_lp_clk_frequency() -> u32 {
2752 BLE_LP_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2753 }
2754 pub fn ble_lp_clk_source_frequency(source: BleLpClkConfig) -> u32 {
2755 ble_lp_clk_config_frequency(source)
2756 }
2757 pub fn configure_timg_calibration_clock(
2758 clocks: &mut ClockTree,
2759 new_selector: TimgCalibrationClockConfig,
2760 ) {
2761 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2762 refresh_timg_calibration_clock_downstream(clocks);
2763 let active = clocks.timg_calibration_clock_refcount > 0;
2764 if active {
2765 match new_selector {
2766 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_d4_clk(clocks),
2767 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2768 #[cfg(use_xtal32k)]
2769 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2770 }
2771 }
2772 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2773 if active && let Some(old_selector) = old_selector {
2774 match old_selector {
2775 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_d4_clk(clocks),
2776 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2777 #[cfg(use_xtal32k)]
2778 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2779 }
2780 }
2781 }
2782 pub fn timg_calibration_clock_config(
2783 clocks: &mut ClockTree,
2784 ) -> Option<TimgCalibrationClockConfig> {
2785 clocks.timg_calibration_clock
2786 }
2787 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2788 trace!("Requesting TIMG_CALIBRATION_CLOCK");
2789 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2790 trace!("Enabling TIMG_CALIBRATION_CLOCK");
2791 crate::rtc_cntl::WakeLock::acquire();
2792 match unwrap!(clocks.timg_calibration_clock) {
2793 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_d4_clk(clocks),
2794 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2795 #[cfg(use_xtal32k)]
2796 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2797 }
2798 enable_timg_calibration_clock_impl(clocks, true);
2799 }
2800 }
2801 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2802 trace!("Releasing TIMG_CALIBRATION_CLOCK");
2803 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2804 trace!("Disabling TIMG_CALIBRATION_CLOCK");
2805 crate::rtc_cntl::WakeLock::release();
2806 enable_timg_calibration_clock_impl(clocks, false);
2807 match unwrap!(clocks.timg_calibration_clock) {
2808 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_d4_clk(clocks),
2809 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2810 #[cfg(use_xtal32k)]
2811 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2812 }
2813 }
2814 }
2815 pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
2816 match config {
2817 TimgCalibrationClockConfig::RcSlowClk => rc_slow_d4_clk_frequency(),
2818 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2819 #[cfg(use_xtal32k)]
2820 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2821 }
2822 }
2823 pub fn timg_calibration_clock_frequency() -> u32 {
2824 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2825 }
2826 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
2827 timg_calibration_clock_config_frequency(source)
2828 }
2829 impl I2sInstance {
2830 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
2831 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
2832 refresh_i2s_tx_clk_downstream(clocks, self);
2833 let active = clocks.i2s_tx_clk_refcount[self as usize] > 0;
2834 if active {
2835 match config.sclk {
2836 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2837 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
2838 I2sClkSclk::XtalX2 => request_xtal_x2_clk(clocks),
2839 }
2840 }
2841 self.configure_tx_clk_impl(clocks, old_config, config);
2842 if active && let Some(old_config) = old_config {
2843 match old_config.sclk {
2844 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2845 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
2846 I2sClkSclk::XtalX2 => release_xtal_x2_clk(clocks),
2847 }
2848 }
2849 }
2850 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
2851 clocks.i2s_tx_clk[self as usize]
2852 }
2853 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
2854 trace!("Requesting {:?}::TX_CLK", self);
2855 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
2856 trace!("Enabling {:?}::TX_CLK", self);
2857 crate::rtc_cntl::WakeLock::acquire();
2858 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
2859 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2860 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
2861 I2sClkSclk::XtalX2 => request_xtal_x2_clk(clocks),
2862 }
2863 self.enable_tx_clk_impl(clocks, true);
2864 }
2865 }
2866 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
2867 trace!("Releasing {:?}::TX_CLK", self);
2868 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
2869 trace!("Disabling {:?}::TX_CLK", self);
2870 crate::rtc_cntl::WakeLock::release();
2871 self.enable_tx_clk_impl(clocks, false);
2872 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
2873 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2874 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
2875 I2sClkSclk::XtalX2 => release_xtal_x2_clk(clocks),
2876 }
2877 }
2878 }
2879 pub fn tx_clk_config_frequency(config: I2sClkConfig) -> u32 {
2880 (((match config.sclk {
2881 I2sClkSclk::Xtal => xtal_clk_frequency(),
2882 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
2883 I2sClkSclk::XtalX2 => xtal_x2_clk_frequency(),
2884 } as u64)
2885 * (config.div_a() as u64))
2886 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
2887 as u32
2888 }
2889 pub fn tx_clk_frequency(self) -> u32 {
2890 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
2891 }
2892 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
2893 match sclk {
2894 I2sClkSclk::Xtal => xtal_clk_frequency(),
2895 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
2896 I2sClkSclk::XtalX2 => xtal_x2_clk_frequency(),
2897 }
2898 }
2899 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
2900 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
2901 refresh_i2s_rx_clk_downstream(clocks, self);
2902 let active = clocks.i2s_rx_clk_refcount[self as usize] > 0;
2903 if active {
2904 match config.sclk {
2905 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2906 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
2907 I2sClkSclk::XtalX2 => request_xtal_x2_clk(clocks),
2908 }
2909 }
2910 self.configure_rx_clk_impl(clocks, old_config, config);
2911 if active && let Some(old_config) = old_config {
2912 match old_config.sclk {
2913 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2914 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
2915 I2sClkSclk::XtalX2 => release_xtal_x2_clk(clocks),
2916 }
2917 }
2918 }
2919 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
2920 clocks.i2s_rx_clk[self as usize]
2921 }
2922 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
2923 trace!("Requesting {:?}::RX_CLK", self);
2924 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
2925 trace!("Enabling {:?}::RX_CLK", self);
2926 crate::rtc_cntl::WakeLock::acquire();
2927 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
2928 I2sClkSclk::Xtal => request_xtal_clk(clocks),
2929 I2sClkSclk::PllF96m => request_pll_f96m_clk(clocks),
2930 I2sClkSclk::XtalX2 => request_xtal_x2_clk(clocks),
2931 }
2932 self.enable_rx_clk_impl(clocks, true);
2933 }
2934 }
2935 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
2936 trace!("Releasing {:?}::RX_CLK", self);
2937 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
2938 trace!("Disabling {:?}::RX_CLK", self);
2939 crate::rtc_cntl::WakeLock::release();
2940 self.enable_rx_clk_impl(clocks, false);
2941 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
2942 I2sClkSclk::Xtal => release_xtal_clk(clocks),
2943 I2sClkSclk::PllF96m => release_pll_f96m_clk(clocks),
2944 I2sClkSclk::XtalX2 => release_xtal_x2_clk(clocks),
2945 }
2946 }
2947 }
2948 pub fn rx_clk_config_frequency(config: I2sClkConfig) -> u32 {
2949 (((match config.sclk {
2950 I2sClkSclk::Xtal => xtal_clk_frequency(),
2951 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
2952 I2sClkSclk::XtalX2 => xtal_x2_clk_frequency(),
2953 } as u64)
2954 * (config.div_a() as u64))
2955 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
2956 as u32
2957 }
2958 pub fn rx_clk_frequency(self) -> u32 {
2959 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
2960 }
2961 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
2962 match sclk {
2963 I2sClkSclk::Xtal => xtal_clk_frequency(),
2964 I2sClkSclk::PllF96m => pll_f96m_clk_frequency(),
2965 I2sClkSclk::XtalX2 => xtal_x2_clk_frequency(),
2966 }
2967 }
2968 pub fn configure_mclk_out(
2969 self,
2970 clocks: &mut ClockTree,
2971 new_selector: I2sMclkOutConfig,
2972 ) {
2973 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
2974 refresh_i2s_mclk_out_downstream(clocks, self);
2975 let active = clocks.i2s_mclk_out_refcount[self as usize] > 0;
2976 if active {
2977 match new_selector {
2978 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
2979 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
2980 }
2981 }
2982 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
2983 if active && let Some(old_selector) = old_selector {
2984 match old_selector {
2985 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
2986 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
2987 }
2988 }
2989 }
2990 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
2991 clocks.i2s_mclk_out[self as usize]
2992 }
2993 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
2994 trace!("Requesting {:?}::MCLK_OUT", self);
2995 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
2996 trace!("Enabling {:?}::MCLK_OUT", self);
2997 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
2998 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
2999 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3000 }
3001 self.enable_mclk_out_impl(clocks, true);
3002 }
3003 }
3004 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
3005 trace!("Releasing {:?}::MCLK_OUT", self);
3006 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3007 trace!("Disabling {:?}::MCLK_OUT", self);
3008 self.enable_mclk_out_impl(clocks, false);
3009 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3010 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3011 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3012 }
3013 }
3014 }
3015 pub fn mclk_out_config_frequency(self, config: I2sMclkOutConfig) -> u32 {
3016 match config {
3017 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
3018 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
3019 }
3020 }
3021 pub fn mclk_out_frequency(self) -> u32 {
3022 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3023 }
3024 }
3025 impl I2cInstance {
3026 pub fn configure_function_clock(
3027 self,
3028 clocks: &mut ClockTree,
3029 config: I2cFunctionClockConfig,
3030 ) {
3031 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3032 refresh_i2c_function_clock_downstream(clocks, self);
3033 let active = clocks.i2c_function_clock_refcount[self as usize] > 0;
3034 if active {
3035 match config.sclk {
3036 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3037 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3038 }
3039 }
3040 self.configure_function_clock_impl(clocks, old_config, config);
3041 if active && let Some(old_config) = old_config {
3042 match old_config.sclk {
3043 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3044 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3045 }
3046 }
3047 }
3048 pub fn function_clock_config(
3049 self,
3050 clocks: &mut ClockTree,
3051 ) -> Option<I2cFunctionClockConfig> {
3052 clocks.i2c_function_clock[self as usize]
3053 }
3054 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3055 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3056 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3057 {
3058 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3059 crate::rtc_cntl::WakeLock::acquire();
3060 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3061 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3062 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3063 }
3064 self.enable_function_clock_impl(clocks, true);
3065 }
3066 }
3067 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3068 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3069 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3070 {
3071 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3072 crate::rtc_cntl::WakeLock::release();
3073 self.enable_function_clock_impl(clocks, false);
3074 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3075 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3076 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3077 }
3078 }
3079 }
3080 pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
3081 (match config.sclk {
3082 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3083 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3084 } / (config.div_num() + 1))
3085 }
3086 pub fn function_clock_frequency(self) -> u32 {
3087 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3088 .load(::core::sync::atomic::Ordering::Acquire)
3089 }
3090 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3091 match sclk {
3092 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3093 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3094 }
3095 }
3096 }
3097 impl ParlIoInstance {
3098 pub fn configure_rx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
3099 let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
3100 refresh_parl_io_rx_clock_downstream(clocks, self);
3101 let active = clocks.parl_io_rx_clock_refcount[self as usize] > 0;
3102 if active {
3103 match new_selector {
3104 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
3105 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3106 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3107 }
3108 }
3109 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
3110 if active && let Some(old_selector) = old_selector {
3111 match old_selector {
3112 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
3113 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3114 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3115 }
3116 }
3117 }
3118 pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
3119 clocks.parl_io_rx_clock[self as usize]
3120 }
3121 pub fn request_rx_clock(self, clocks: &mut ClockTree) {
3122 trace!("Requesting {:?}::RX_CLOCK", self);
3123 if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
3124 trace!("Enabling {:?}::RX_CLOCK", self);
3125 crate::rtc_cntl::WakeLock::acquire();
3126 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
3127 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
3128 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3129 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3130 }
3131 self.enable_rx_clock_impl(clocks, true);
3132 }
3133 }
3134 pub fn release_rx_clock(self, clocks: &mut ClockTree) {
3135 trace!("Releasing {:?}::RX_CLOCK", self);
3136 if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
3137 trace!("Disabling {:?}::RX_CLOCK", self);
3138 crate::rtc_cntl::WakeLock::release();
3139 self.enable_rx_clock_impl(clocks, false);
3140 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
3141 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
3142 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3143 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3144 }
3145 }
3146 }
3147 pub fn rx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
3148 match config {
3149 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
3150 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
3151 ParlIoClkConfig::PllF96m => pll_f96m_clk_frequency(),
3152 }
3153 }
3154 pub fn rx_clock_frequency(self) -> u32 {
3155 PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
3156 .load(::core::sync::atomic::Ordering::Acquire)
3157 }
3158 pub fn rx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
3159 Self::rx_clock_config_frequency(source)
3160 }
3161 pub fn configure_tx_clock(self, clocks: &mut ClockTree, new_selector: ParlIoClkConfig) {
3162 let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
3163 refresh_parl_io_tx_clock_downstream(clocks, self);
3164 let active = clocks.parl_io_tx_clock_refcount[self as usize] > 0;
3165 if active {
3166 match new_selector {
3167 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
3168 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3169 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3170 }
3171 }
3172 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
3173 if active && let Some(old_selector) = old_selector {
3174 match old_selector {
3175 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
3176 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3177 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3178 }
3179 }
3180 }
3181 pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoClkConfig> {
3182 clocks.parl_io_tx_clock[self as usize]
3183 }
3184 pub fn request_tx_clock(self, clocks: &mut ClockTree) {
3185 trace!("Requesting {:?}::TX_CLOCK", self);
3186 if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
3187 trace!("Enabling {:?}::TX_CLOCK", self);
3188 crate::rtc_cntl::WakeLock::acquire();
3189 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
3190 ParlIoClkConfig::XtalClk => request_xtal_clk(clocks),
3191 ParlIoClkConfig::RcFastClk => request_rc_fast_clk(clocks),
3192 ParlIoClkConfig::PllF96m => request_pll_f96m_clk(clocks),
3193 }
3194 self.enable_tx_clock_impl(clocks, true);
3195 }
3196 }
3197 pub fn release_tx_clock(self, clocks: &mut ClockTree) {
3198 trace!("Releasing {:?}::TX_CLOCK", self);
3199 if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
3200 trace!("Disabling {:?}::TX_CLOCK", self);
3201 crate::rtc_cntl::WakeLock::release();
3202 self.enable_tx_clock_impl(clocks, false);
3203 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
3204 ParlIoClkConfig::XtalClk => release_xtal_clk(clocks),
3205 ParlIoClkConfig::RcFastClk => release_rc_fast_clk(clocks),
3206 ParlIoClkConfig::PllF96m => release_pll_f96m_clk(clocks),
3207 }
3208 }
3209 }
3210 pub fn tx_clock_config_frequency(config: ParlIoClkConfig) -> u32 {
3211 match config {
3212 ParlIoClkConfig::XtalClk => xtal_clk_frequency(),
3213 ParlIoClkConfig::RcFastClk => rc_fast_clk_frequency(),
3214 ParlIoClkConfig::PllF96m => pll_f96m_clk_frequency(),
3215 }
3216 }
3217 pub fn tx_clock_frequency(self) -> u32 {
3218 PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
3219 .load(::core::sync::atomic::Ordering::Acquire)
3220 }
3221 pub fn tx_clock_source_frequency(source: ParlIoClkConfig) -> u32 {
3222 Self::tx_clock_config_frequency(source)
3223 }
3224 }
3225 impl SpiInstance {
3226 pub fn configure_function_clock(
3227 self,
3228 clocks: &mut ClockTree,
3229 new_selector: SpiFunctionClockConfig,
3230 ) {
3231 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3232 refresh_spi_function_clock_downstream(clocks, self);
3233 let active = clocks.spi_function_clock_refcount[self as usize] > 0;
3234 if active {
3235 match new_selector {
3236 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3237 SpiFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3238 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3239 }
3240 }
3241 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3242 if active && let Some(old_selector) = old_selector {
3243 match old_selector {
3244 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3245 SpiFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3246 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3247 }
3248 }
3249 }
3250 pub fn function_clock_config(
3251 self,
3252 clocks: &mut ClockTree,
3253 ) -> Option<SpiFunctionClockConfig> {
3254 clocks.spi_function_clock[self as usize]
3255 }
3256 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3257 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3258 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3259 {
3260 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3261 crate::rtc_cntl::WakeLock::acquire();
3262 match unwrap!(clocks.spi_function_clock[self as usize]) {
3263 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3264 SpiFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3265 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3266 }
3267 self.enable_function_clock_impl(clocks, true);
3268 }
3269 }
3270 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3271 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3272 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3273 {
3274 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3275 crate::rtc_cntl::WakeLock::release();
3276 self.enable_function_clock_impl(clocks, false);
3277 match unwrap!(clocks.spi_function_clock[self as usize]) {
3278 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3279 SpiFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3280 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3281 }
3282 }
3283 }
3284 pub fn function_clock_config_frequency(config: SpiFunctionClockConfig) -> u32 {
3285 match config {
3286 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3287 SpiFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
3288 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3289 }
3290 }
3291 pub fn function_clock_frequency(self) -> u32 {
3292 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3293 .load(::core::sync::atomic::Ordering::Acquire)
3294 }
3295 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3296 Self::function_clock_config_frequency(source)
3297 }
3298 }
3299 impl TimgInstance {
3300 pub fn configure_function_clock(
3301 self,
3302 clocks: &mut ClockTree,
3303 new_selector: TimgFunctionClockConfig,
3304 ) {
3305 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3306 refresh_timg_function_clock_downstream(clocks, self);
3307 let active = clocks.timg_function_clock_refcount[self as usize] > 0;
3308 if active {
3309 match new_selector {
3310 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3311 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3312 TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3313 }
3314 }
3315 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3316 if active && let Some(old_selector) = old_selector {
3317 match old_selector {
3318 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3319 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3320 TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3321 }
3322 }
3323 }
3324 pub fn function_clock_config(
3325 self,
3326 clocks: &mut ClockTree,
3327 ) -> Option<TimgFunctionClockConfig> {
3328 clocks.timg_function_clock[self as usize]
3329 }
3330 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3331 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3332 if increment_reference_count(
3333 &mut clocks.timg_function_clock_refcount[self as usize],
3334 ) {
3335 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3336 match unwrap!(clocks.timg_function_clock[self as usize]) {
3337 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3338 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3339 TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3340 }
3341 self.enable_function_clock_impl(clocks, true);
3342 }
3343 }
3344 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3345 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3346 if decrement_reference_count(
3347 &mut clocks.timg_function_clock_refcount[self as usize],
3348 ) {
3349 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3350 self.enable_function_clock_impl(clocks, false);
3351 match unwrap!(clocks.timg_function_clock[self as usize]) {
3352 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3353 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3354 TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3355 }
3356 }
3357 }
3358 pub fn function_clock_config_frequency(config: TimgFunctionClockConfig) -> u32 {
3359 match config {
3360 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3361 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3362 TimgFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
3363 }
3364 }
3365 pub fn function_clock_frequency(self) -> u32 {
3366 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3367 .load(::core::sync::atomic::Ordering::Acquire)
3368 }
3369 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3370 Self::function_clock_config_frequency(source)
3371 }
3372 pub fn configure_wdt_clock(
3373 self,
3374 clocks: &mut ClockTree,
3375 new_selector: TimgWdtClockConfig,
3376 ) {
3377 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3378 refresh_timg_wdt_clock_downstream(clocks, self);
3379 let active = clocks.timg_wdt_clock_refcount[self as usize] > 0;
3380 if active {
3381 match new_selector {
3382 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3383 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3384 TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3385 }
3386 }
3387 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3388 if active && let Some(old_selector) = old_selector {
3389 match old_selector {
3390 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3391 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3392 TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3393 }
3394 }
3395 }
3396 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3397 clocks.timg_wdt_clock[self as usize]
3398 }
3399 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3400 trace!("Requesting {:?}::WDT_CLOCK", self);
3401 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3402 trace!("Enabling {:?}::WDT_CLOCK", self);
3403 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3404 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3405 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3406 TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3407 }
3408 self.enable_wdt_clock_impl(clocks, true);
3409 }
3410 }
3411 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3412 trace!("Releasing {:?}::WDT_CLOCK", self);
3413 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3414 trace!("Disabling {:?}::WDT_CLOCK", self);
3415 self.enable_wdt_clock_impl(clocks, false);
3416 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3417 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3418 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3419 TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3420 }
3421 }
3422 }
3423 pub fn wdt_clock_config_frequency(config: TimgWdtClockConfig) -> u32 {
3424 match config {
3425 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3426 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3427 TimgWdtClockConfig::PllF48m => pll_f48m_clk_frequency(),
3428 }
3429 }
3430 pub fn wdt_clock_frequency(self) -> u32 {
3431 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3432 .load(::core::sync::atomic::Ordering::Acquire)
3433 }
3434 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3435 Self::wdt_clock_config_frequency(source)
3436 }
3437 }
3438 impl UartInstance {
3439 pub fn configure_function_clock(
3440 self,
3441 clocks: &mut ClockTree,
3442 config: UartFunctionClockConfig,
3443 ) {
3444 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3445 refresh_uart_function_clock_downstream(clocks, self);
3446 let active = clocks.uart_function_clock_refcount[self as usize] > 0;
3447 if active {
3448 match config.sclk {
3449 UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
3450 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3451 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3452 }
3453 }
3454 self.configure_function_clock_impl(clocks, old_config, config);
3455 if active && let Some(old_config) = old_config {
3456 match old_config.sclk {
3457 UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
3458 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3459 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3460 }
3461 }
3462 }
3463 pub fn function_clock_config(
3464 self,
3465 clocks: &mut ClockTree,
3466 ) -> Option<UartFunctionClockConfig> {
3467 clocks.uart_function_clock[self as usize]
3468 }
3469 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3470 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3471 if increment_reference_count(
3472 &mut clocks.uart_function_clock_refcount[self as usize],
3473 ) {
3474 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3475 crate::rtc_cntl::WakeLock::acquire();
3476 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3477 UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
3478 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3479 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3480 }
3481 self.enable_function_clock_impl(clocks, true);
3482 }
3483 }
3484 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3485 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3486 if decrement_reference_count(
3487 &mut clocks.uart_function_clock_refcount[self as usize],
3488 ) {
3489 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3490 crate::rtc_cntl::WakeLock::release();
3491 self.enable_function_clock_impl(clocks, false);
3492 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3493 UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
3494 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3495 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3496 }
3497 }
3498 }
3499 pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
3500 (match config.sclk {
3501 UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(),
3502 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3503 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3504 } / (config.div_num() + 1))
3505 }
3506 pub fn function_clock_frequency(self) -> u32 {
3507 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3508 .load(::core::sync::atomic::Ordering::Acquire)
3509 }
3510 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3511 match sclk {
3512 UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(),
3513 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3514 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3515 }
3516 }
3517 pub fn configure_baud_rate_generator(
3518 self,
3519 clocks: &mut ClockTree,
3520 config: UartBaudRateGeneratorConfig,
3521 ) {
3522 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3523 refresh_uart_baud_rate_generator_downstream(clocks, self);
3524 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3525 }
3526 pub fn baud_rate_generator_config(
3527 self,
3528 clocks: &mut ClockTree,
3529 ) -> Option<UartBaudRateGeneratorConfig> {
3530 clocks.uart_baud_rate_generator[self as usize]
3531 }
3532 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3533 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3534 if increment_reference_count(
3535 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3536 ) {
3537 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3538 self.request_function_clock(clocks);
3539 self.enable_baud_rate_generator_impl(clocks, true);
3540 }
3541 }
3542 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3543 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3544 if decrement_reference_count(
3545 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3546 ) {
3547 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3548 self.enable_baud_rate_generator_impl(clocks, false);
3549 self.release_function_clock(clocks);
3550 }
3551 }
3552 pub fn baud_rate_generator_config_frequency(
3553 self,
3554 config: UartBaudRateGeneratorConfig,
3555 ) -> u32 {
3556 ((self.function_clock_frequency() * 16)
3557 / ((config.integral() * 16) + config.fractional()))
3558 }
3559 pub fn baud_rate_generator_frequency(self) -> u32 {
3560 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3561 .load(::core::sync::atomic::Ordering::Acquire)
3562 }
3563 }
3564 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3572 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3573 #[instability::unstable]
3574 pub struct ClockConfig {
3575 pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
3577 pub hp_root_clk: Option<HpRootClkConfig>,
3579 pub cpu_clk: Option<CpuClkConfig>,
3581 pub ahb_clk: Option<AhbClkConfig>,
3583 pub apb_clk: Option<ApbClkConfig>,
3585 pub lp_fast_clk: Option<LpFastClkConfig>,
3587 pub lp_slow_clk: Option<LpSlowClkConfig>,
3589 pub ble_lp_clk: Option<BleLpClkConfig>,
3591 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3593 }
3594 impl ClockConfig {
3595 fn apply(&self, clocks: &mut ClockTree) {
3596 if let Some(config) = self.hp_root_clk {
3597 configure_hp_root_clk(clocks, config);
3598 }
3599 if let Some(config) = self.cpu_clk {
3600 configure_cpu_clk(clocks, config);
3601 }
3602 if let Some(config) = self.ahb_clk {
3603 configure_ahb_clk(clocks, config);
3604 }
3605 if let Some(config) = self.apb_clk {
3606 configure_apb_clk(clocks, config);
3607 }
3608 if let Some(config) = self.lp_fast_clk {
3609 configure_lp_fast_clk(clocks, config);
3610 }
3611 if let Some(config) = self.lp_slow_clk {
3612 configure_lp_slow_clk(clocks, config);
3613 }
3614 if let Some(config) = self.ble_lp_clk {
3615 configure_ble_lp_clk(clocks, config);
3616 }
3617 if let Some(config) = self.timg_calibration_clock {
3618 configure_timg_calibration_clock(clocks, config);
3619 }
3620 if let Some(config) = self.iomux_function_clock {
3621 configure_iomux_function_clock(clocks, config);
3622 }
3623 }
3624 }
3625 fn increment_reference_count(refcount: &mut u32) -> bool {
3626 let first = *refcount == 0;
3627 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3628 first
3629 }
3630 fn decrement_reference_count(refcount: &mut u32) -> bool {
3631 *refcount = refcount.saturating_sub(1);
3632 let last = *refcount == 0;
3633 last
3634 }
3635 fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
3636 refresh_hp_root_clk_downstream(clocks);
3637 refresh_lp_fast_clk_downstream(clocks);
3638 refresh_timg_calibration_clock_downstream(clocks);
3639 refresh_iomux_function_clock_downstream(clocks);
3640 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
3641 refresh_i2c_function_clock_downstream(clocks, child_instance);
3642 }
3643 for child_instance in [ParlIoInstance::ParlIo] {
3644 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
3645 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
3646 }
3647 for child_instance in [SpiInstance::Spi2, SpiInstance::Spi3] {
3648 refresh_spi_function_clock_downstream(clocks, child_instance);
3649 }
3650 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3651 refresh_timg_function_clock_downstream(clocks, child_instance);
3652 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3653 }
3654 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3655 refresh_uart_function_clock_downstream(clocks, child_instance);
3656 }
3657 }
3658 fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
3659 refresh_lp_slow_clk_downstream(clocks);
3660 refresh_timg_calibration_clock_downstream(clocks);
3661 }
3662 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
3663 if let Some(config) = clocks.hp_root_clk {
3664 HP_ROOT_CLK_FREQ_CACHE.store(
3665 hp_root_clk_config_frequency(config),
3666 ::core::sync::atomic::Ordering::Release,
3667 );
3668 }
3669 refresh_cpu_clk_downstream(clocks);
3670 }
3671 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3672 if let Some(config) = clocks.cpu_clk {
3673 CPU_CLK_FREQ_CACHE.store(
3674 cpu_clk_config_frequency(config),
3675 ::core::sync::atomic::Ordering::Release,
3676 );
3677 }
3678 refresh_ahb_clk_downstream(clocks);
3679 }
3680 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
3681 if let Some(config) = clocks.ahb_clk {
3682 AHB_CLK_FREQ_CACHE.store(
3683 ahb_clk_config_frequency(config),
3684 ::core::sync::atomic::Ordering::Release,
3685 );
3686 }
3687 refresh_apb_clk_downstream(clocks);
3688 }
3689 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3690 if let Some(config) = clocks.apb_clk {
3691 APB_CLK_FREQ_CACHE.store(
3692 apb_clk_config_frequency(config),
3693 ::core::sync::atomic::Ordering::Release,
3694 );
3695 }
3696 }
3697 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
3698 if let Some(config) = clocks.lp_fast_clk {
3699 LP_FAST_CLK_FREQ_CACHE.store(
3700 lp_fast_clk_config_frequency(config),
3701 ::core::sync::atomic::Ordering::Release,
3702 );
3703 }
3704 }
3705 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
3706 if let Some(config) = clocks.lp_slow_clk {
3707 LP_SLOW_CLK_FREQ_CACHE.store(
3708 lp_slow_clk_config_frequency(config),
3709 ::core::sync::atomic::Ordering::Release,
3710 );
3711 }
3712 }
3713 fn refresh_ble_lp_clk_downstream(clocks: &mut ClockTree) {
3714 if let Some(config) = clocks.ble_lp_clk {
3715 BLE_LP_CLK_FREQ_CACHE.store(
3716 ble_lp_clk_config_frequency(config),
3717 ::core::sync::atomic::Ordering::Release,
3718 );
3719 }
3720 }
3721 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3722 if let Some(config) = clocks.timg_calibration_clock {
3723 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3724 timg_calibration_clock_config_frequency(config),
3725 ::core::sync::atomic::Ordering::Release,
3726 );
3727 }
3728 }
3729 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3730 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
3731 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
3732 I2sInstance::tx_clk_config_frequency(config),
3733 ::core::sync::atomic::Ordering::Release,
3734 );
3735 }
3736 refresh_i2s_mclk_out_downstream(clocks, instance);
3737 }
3738 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3739 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
3740 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
3741 I2sInstance::rx_clk_config_frequency(config),
3742 ::core::sync::atomic::Ordering::Release,
3743 );
3744 }
3745 refresh_i2s_mclk_out_downstream(clocks, instance);
3746 }
3747 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3748 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
3749 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
3750 instance.mclk_out_config_frequency(config),
3751 ::core::sync::atomic::Ordering::Release,
3752 );
3753 }
3754 }
3755 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
3756 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
3757 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3758 I2cInstance::function_clock_config_frequency(config),
3759 ::core::sync::atomic::Ordering::Release,
3760 );
3761 }
3762 }
3763 fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
3764 if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
3765 PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
3766 ParlIoInstance::rx_clock_config_frequency(config),
3767 ::core::sync::atomic::Ordering::Release,
3768 );
3769 }
3770 }
3771 fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
3772 if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
3773 PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
3774 ParlIoInstance::tx_clock_config_frequency(config),
3775 ::core::sync::atomic::Ordering::Release,
3776 );
3777 }
3778 }
3779 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
3780 if let Some(config) = clocks.spi_function_clock[instance as usize] {
3781 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3782 SpiInstance::function_clock_config_frequency(config),
3783 ::core::sync::atomic::Ordering::Release,
3784 );
3785 }
3786 }
3787 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3788 if let Some(config) = clocks.timg_function_clock[instance as usize] {
3789 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3790 TimgInstance::function_clock_config_frequency(config),
3791 ::core::sync::atomic::Ordering::Release,
3792 );
3793 }
3794 }
3795 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3796 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
3797 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
3798 TimgInstance::wdt_clock_config_frequency(config),
3799 ::core::sync::atomic::Ordering::Release,
3800 );
3801 }
3802 }
3803 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
3804 if let Some(config) = clocks.uart_function_clock[instance as usize] {
3805 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3806 UartInstance::function_clock_config_frequency(config),
3807 ::core::sync::atomic::Ordering::Release,
3808 );
3809 }
3810 refresh_uart_baud_rate_generator_downstream(clocks, instance);
3811 }
3812 fn refresh_uart_baud_rate_generator_downstream(
3813 clocks: &mut ClockTree,
3814 instance: UartInstance,
3815 ) {
3816 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
3817 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
3818 instance.baud_rate_generator_config_frequency(config),
3819 ::core::sync::atomic::Ordering::Release,
3820 );
3821 }
3822 }
3823 fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
3824 if let Some(config) = clocks.iomux_function_clock {
3825 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
3826 iomux_function_clock_config_frequency(config),
3827 ::core::sync::atomic::Ordering::Release,
3828 );
3829 }
3830 }
3831 };
3832}
3833#[macro_export]
3837#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3838macro_rules! implement_peripheral_clocks {
3839 () => {
3840 #[doc(hidden)]
3841 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3842 #[repr(u8)]
3843 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3844 pub enum Peripheral {
3845 Aes,
3847 AhbGdma,
3849 Ecc,
3851 GpioSd,
3853 I2cExt0,
3855 I2cExt1,
3857 I2s0,
3859 Ledc,
3861 ParlIo,
3863 Pcnt,
3865 Rmt,
3867 Sha,
3869 Spi2,
3871 Spi3,
3873 Systimer,
3875 Timg0,
3877 Timg1,
3879 Uart0,
3881 Uart1,
3883 Uhci0,
3885 UsbDevice,
3887 }
3888 impl Peripheral {
3889 const KEEP_ENABLED: &[Peripheral] =
3890 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
3891 const COUNT: usize = Self::ALL.len();
3892 const ALL: &[Self] = &[
3893 Self::Aes,
3894 Self::AhbGdma,
3895 Self::Ecc,
3896 Self::GpioSd,
3897 Self::I2cExt0,
3898 Self::I2cExt1,
3899 Self::I2s0,
3900 Self::Ledc,
3901 Self::ParlIo,
3902 Self::Pcnt,
3903 Self::Rmt,
3904 Self::Sha,
3905 Self::Spi2,
3906 Self::Spi3,
3907 Self::Systimer,
3908 Self::Timg0,
3909 Self::Timg1,
3910 Self::Uart0,
3911 Self::Uart1,
3912 Self::Uhci0,
3913 Self::UsbDevice,
3914 ];
3915 }
3916 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
3917 match peripheral {
3918 Peripheral::Aes => {
3919 crate::peripherals::SYSTEM::regs()
3920 .aes_conf()
3921 .modify(|_, w| w.aes_clk_en().bit(enable));
3922 }
3923 Peripheral::AhbGdma => {
3924 crate::peripherals::SYSTEM::regs()
3925 .gdma_conf()
3926 .modify(|_, w| w.gdma_clk_en().bit(enable));
3927 }
3928 Peripheral::Ecc => {
3929 crate::peripherals::SYSTEM::regs()
3930 .ecc_conf()
3931 .modify(|_, w| w.ecc_clk_en().bit(enable));
3932 }
3933 Peripheral::GpioSd => {
3934 crate::peripherals::GPIO_SD::regs()
3935 .clock_gate()
3936 .modify(|_, w| w.clk_en().bit(enable));
3937 }
3938 Peripheral::I2cExt0 => {
3939 crate::peripherals::SYSTEM::regs()
3940 .i2c0_conf()
3941 .modify(|_, w| w.i2c0_clk_en().bit(enable));
3942 }
3943 Peripheral::I2cExt1 => {
3944 crate::peripherals::SYSTEM::regs()
3945 .i2c1_conf()
3946 .modify(|_, w| w.i2c1_clk_en().bit(enable));
3947 }
3948 Peripheral::I2s0 => {
3949 crate::peripherals::SYSTEM::regs()
3950 .i2s_conf()
3951 .modify(|_, w| w.i2s_clk_en().bit(enable));
3952 }
3953 Peripheral::Ledc => {
3954 crate::peripherals::SYSTEM::regs()
3955 .ledc_conf()
3956 .modify(|_, w| w.ledc_clk_en().bit(enable));
3957 }
3958 Peripheral::ParlIo => {
3959 crate::peripherals::SYSTEM::regs()
3960 .parl_io_conf()
3961 .modify(|_, w| w.parl_clk_en().bit(enable));
3962 }
3963 Peripheral::Pcnt => {
3964 crate::peripherals::SYSTEM::regs()
3965 .pcnt_conf()
3966 .modify(|_, w| w.pcnt_clk_en().bit(enable));
3967 crate::peripherals::SYSTEM::regs()
3968 .pcnt_conf()
3969 .modify(|_, w| w.pcnt_reg_clk_en().bit(enable));
3970 }
3971 Peripheral::Rmt => {
3972 crate::peripherals::SYSTEM::regs()
3973 .rmt_conf()
3974 .modify(|_, w| w.rmt_clk_en().bit(enable));
3975 crate::peripherals::SYSTEM::regs()
3976 .rmt_mem_lp_ctrl()
3977 .modify(|_, w| w.rmt_mem_lp_en().bit(!enable));
3978 }
3979 Peripheral::Sha => {
3980 crate::peripherals::SYSTEM::regs()
3981 .sha_conf()
3982 .modify(|_, w| w.sha_clk_en().bit(enable));
3983 }
3984 Peripheral::Spi2 => {
3985 crate::peripherals::SYSTEM::regs()
3986 .spi2_conf()
3987 .modify(|_, w| w.spi2_clk_en().bit(enable));
3988 }
3989 Peripheral::Spi3 => {
3990 crate::peripherals::SYSTEM::regs()
3991 .spi3_conf()
3992 .modify(|_, w| w.spi3_clk_en().bit(enable));
3993 }
3994 Peripheral::Systimer => {
3995 crate::peripherals::SYSTEM::regs()
3996 .systimer_conf()
3997 .modify(|_, w| w.systimer_clk_en().bit(enable));
3998 }
3999 Peripheral::Timg0 => {
4000 crate::peripherals::SYSTEM::regs()
4001 .timergroup0_conf()
4002 .modify(|_, w| w.tg0_clk_en().bit(enable));
4003 }
4004 Peripheral::Timg1 => {
4005 crate::peripherals::SYSTEM::regs()
4006 .timergroup1_conf()
4007 .modify(|_, w| w.tg1_clk_en().bit(enable));
4008 }
4009 Peripheral::Uart0 => {
4010 crate::peripherals::SYSTEM::regs()
4011 .uart(0)
4012 .conf()
4013 .modify(|_, w| w.clk_en().bit(enable));
4014 }
4015 Peripheral::Uart1 => {
4016 crate::peripherals::SYSTEM::regs()
4017 .uart(1)
4018 .conf()
4019 .modify(|_, w| w.clk_en().bit(enable));
4020 }
4021 Peripheral::Uhci0 => {
4022 crate::peripherals::SYSTEM::regs()
4023 .uhci_conf()
4024 .modify(|_, w| w.uhci_clk_en().bit(enable));
4025 }
4026 Peripheral::UsbDevice => {
4027 crate::peripherals::SYSTEM::regs()
4028 .usb_device_conf()
4029 .modify(|_, w| w.usb_device_clk_en().bit(enable));
4030 }
4031 }
4032 }
4033 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4034 match peripheral {
4035 Peripheral::Aes => {
4036 crate::peripherals::SYSTEM::regs()
4037 .aes_conf()
4038 .modify(|_, w| w.aes_rst_en().bit(reset));
4039 }
4040 Peripheral::AhbGdma => {
4041 crate::peripherals::SYSTEM::regs()
4042 .gdma_conf()
4043 .modify(|_, w| w.gdma_rst_en().bit(reset));
4044 }
4045 Peripheral::Ecc => {
4046 crate::peripherals::SYSTEM::regs()
4047 .ecc_conf()
4048 .modify(|_, w| w.ecc_rst_en().bit(reset));
4049 }
4050 Peripheral::GpioSd => {
4051 let _ = reset;
4052 }
4053 Peripheral::I2cExt0 => {
4054 crate::peripherals::SYSTEM::regs()
4055 .i2c0_conf()
4056 .modify(|_, w| w.i2c0_rst_en().bit(reset));
4057 }
4058 Peripheral::I2cExt1 => {
4059 crate::peripherals::SYSTEM::regs()
4060 .i2c1_conf()
4061 .modify(|_, w| w.i2c1_rst_en().bit(reset));
4062 }
4063 Peripheral::I2s0 => {
4064 crate::peripherals::SYSTEM::regs()
4065 .i2s_conf()
4066 .modify(|_, w| w.i2s_rst_en().bit(reset));
4067 }
4068 Peripheral::Ledc => {
4069 crate::peripherals::SYSTEM::regs()
4070 .ledc_conf()
4071 .modify(|_, w| w.ledc_rst_en().bit(reset));
4072 }
4073 Peripheral::ParlIo => {
4074 crate::peripherals::SYSTEM::regs()
4075 .parl_io_conf()
4076 .modify(|_, w| w.parl_rst_en().bit(reset));
4077 }
4078 Peripheral::Pcnt => {
4079 crate::peripherals::SYSTEM::regs()
4080 .pcnt_conf()
4081 .modify(|_, w| {
4082 w.pcnt_rst_en().bit(reset);
4083 w.pcnt_reg_rst_en().bit(reset)
4084 });
4085 }
4086 Peripheral::Rmt => {
4087 crate::peripherals::SYSTEM::regs()
4088 .rmt_conf()
4089 .modify(|_, w| w.rmt_rst_en().bit(reset));
4090 }
4091 Peripheral::Sha => {
4092 crate::peripherals::SYSTEM::regs()
4093 .sha_conf()
4094 .modify(|_, w| w.sha_rst_en().bit(reset));
4095 }
4096 Peripheral::Spi2 => {
4097 crate::peripherals::SYSTEM::regs()
4098 .spi2_conf()
4099 .modify(|_, w| w.spi2_rst_en().bit(reset));
4100 }
4101 Peripheral::Spi3 => {
4102 crate::peripherals::SYSTEM::regs()
4103 .spi3_conf()
4104 .modify(|_, w| w.spi3_rst_en().bit(reset));
4105 }
4106 Peripheral::Systimer => {
4107 crate::peripherals::SYSTEM::regs()
4108 .systimer_conf()
4109 .modify(|_, w| w.systimer_rst_en().bit(reset));
4110 }
4111 Peripheral::Timg0 => {
4112 crate::peripherals::SYSTEM::regs()
4113 .timergroup0_conf()
4114 .modify(|_, w| w.tg0_rst_en().bit(reset));
4115 }
4116 Peripheral::Timg1 => {
4117 crate::peripherals::SYSTEM::regs()
4118 .timergroup1_conf()
4119 .modify(|_, w| w.tg1_rst_en().bit(reset));
4120 }
4121 Peripheral::Uart0 => {
4122 crate::peripherals::SYSTEM::regs()
4123 .uart(0)
4124 .conf()
4125 .modify(|_, w| w.rst_en().bit(reset));
4126 }
4127 Peripheral::Uart1 => {
4128 crate::peripherals::SYSTEM::regs()
4129 .uart(1)
4130 .conf()
4131 .modify(|_, w| w.rst_en().bit(reset));
4132 }
4133 Peripheral::Uhci0 => {
4134 crate::peripherals::SYSTEM::regs()
4135 .uhci_conf()
4136 .modify(|_, w| w.uhci_rst_en().bit(reset));
4137 }
4138 Peripheral::UsbDevice => {
4139 crate::peripherals::SYSTEM::regs()
4140 .usb_device_conf()
4141 .modify(|_, w| w.usb_device_rst_en().bit(reset));
4142 }
4143 }
4144 }
4145 };
4146}
4147#[macro_export]
4155#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4156macro_rules! memory_range {
4157 ("DRAM") => {
4158 0x40810000..0x4084F350
4159 };
4160 (size as str, "DRAM") => {
4161 "258896"
4162 };
4163 ("DRAM2_UNINIT") => {
4164 0x4084F350..0x4085D350
4165 };
4166 (size as str, "DRAM2_UNINIT") => {
4167 "57344"
4168 };
4169 ("IROM") => {
4170 0x42000000..0x44000000
4171 };
4172 (size as str, "IROM") => {
4173 "33554432"
4174 };
4175 ("DROM") => {
4176 0x42000000..0x44000000
4177 };
4178 (size as str, "DROM") => {
4179 "33554432"
4180 };
4181}
4182#[macro_export]
4199#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4200macro_rules! for_each_i2c_master {
4201 ($($pattern:tt => $code:tt;)*) => {
4202 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4203 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4204 I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
4205 I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4206 I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
4207 };
4208}
4209#[macro_export]
4236#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4237macro_rules! for_each_i2s {
4238 ($($pattern:tt => $code:tt;)*) => {
4239 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4240 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
4241 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD, I2SO_SD1], [I2SI_SD], true, true,
4242 true, false)); _for_each_inner_i2s!((names(I2S0)));
4243 _for_each_inner_i2s!((all(I2S0, I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK,
4244 I2SI_WS, [I2SO_SD, I2SO_SD1], [I2SI_SD], true, true, true, false)));
4245 };
4246}
4247#[macro_export]
4266#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4267macro_rules! for_each_uart {
4268 ($($pattern:tt => $code:tt;)*) => {
4269 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4270 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4271 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4272 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4273 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4274 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4275 };
4276}
4277#[macro_export]
4299#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4300macro_rules! for_each_spi_master {
4301 ($($pattern:tt => $code:tt;)*) => {
4302 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4303 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI3));
4304 _for_each_inner_spi_master!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4305 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true));
4306 _for_each_inner_spi_master!((SPI3, Spi3, FSPI3CLK[FSPI3CS0, FSPI3CS1, FSPI3CS2]
4307 [FSPI3D, FSPI3Q, FSPI3WP, FSPI3HD], true));
4308 _for_each_inner_spi_master!((names(SPI2), (SPI3)));
4309 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4310 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true), (SPI3, Spi3,
4311 FSPI3CLK[FSPI3CS0, FSPI3CS1, FSPI3CS2] [FSPI3D, FSPI3Q, FSPI3WP, FSPI3HD],
4312 true)));
4313 };
4314}
4315#[macro_export]
4332#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4333macro_rules! for_each_spi_slave {
4334 ($($pattern:tt => $code:tt;)*) => {
4335 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4336 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI3));
4337 _for_each_inner_spi_slave!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4338 _for_each_inner_spi_slave!((SPI3, Spi3, FSPI3CLK, FSPI3D, FSPI3Q, FSPI3CS0));
4339 _for_each_inner_spi_slave!((names(SPI2), (SPI3)));
4340 _for_each_inner_spi_slave!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0),
4341 (SPI3, Spi3, FSPI3CLK, FSPI3D, FSPI3Q, FSPI3CS0)));
4342 };
4343}
4344#[macro_export]
4367#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4368macro_rules! for_each_pcnt_unit {
4369 ($($pattern:tt => $code:tt;)*) => {
4370 macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
4371 => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
4372 _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
4373 _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
4374 _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
4375 _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
4376 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
4377 _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
4378 PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
4379 _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
4380 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
4381 _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
4382 PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
4383 _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
4384 _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
4385 (PCNT0_UNIT3))); _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt,
4386 PCNT, 0, PCNT, PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1),
4387 (PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1,
4388 PCNT1_CTRL_CH0, PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
4389 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3,
4390 Pcnt0Unit3, Pcnt, PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0,
4391 PCNT3_CTRL_CH1))); _for_each_inner_pcnt_unit!((interrupt(PCNT)));
4392 _for_each_inner_pcnt_unit!((regs(PCNT)));
4393 };
4394}
4395#[macro_export]
4412#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4413macro_rules! for_each_canfd {
4414 ($($pattern:tt => $code:tt;)*) => {
4415 macro_rules! _for_each_inner_canfd { $(($pattern) => $code;)* ($other : tt) => {}
4416 } _for_each_inner_canfd!((all));
4417 };
4418}
4419#[macro_export]
4420#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4421macro_rules! for_each_peripheral {
4422 ($($pattern:tt => $code:tt;)*) => {
4423 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4424 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4425 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
4426 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4427 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4428 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
4429 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
4430 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4431 "GPIO4 peripheral singleton"] GPIO4 <= virtual()));
4432 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO5 peripheral singleton"]
4433 GPIO5 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4434 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4435 "<section class=\"warning\">"] #[doc =
4436 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4437 #[doc = "<ul>"] #[doc =
4438 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4439 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4440 _for_each_inner_peripheral!((@ peri_type #[doc =
4441 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4442 "<section class=\"warning\">"] #[doc =
4443 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4444 #[doc = "<ul>"] #[doc =
4445 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4446 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4447 _for_each_inner_peripheral!((@ peri_type #[doc =
4448 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4449 "<section class=\"warning\">"] #[doc =
4450 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4451 #[doc = "<ul>"] #[doc =
4452 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4453 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4454 "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4455 _for_each_inner_peripheral!((@ peri_type #[doc =
4456 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4457 "<section class=\"warning\">"] #[doc =
4458 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4459 #[doc = "<ul>"] #[doc =
4460 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4461 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4462 "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4463 _for_each_inner_peripheral!((@ peri_type #[doc =
4464 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4465 "<section class=\"warning\">"] #[doc =
4466 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4467 #[doc = "<ul>"] #[doc =
4468 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4469 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4470 "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
4471 _for_each_inner_peripheral!((@ peri_type #[doc =
4472 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4473 "<section class=\"warning\">"] #[doc =
4474 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4475 #[doc = "<ul>"] #[doc =
4476 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4477 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4478 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4479 _for_each_inner_peripheral!((@ peri_type #[doc =
4480 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4481 "<section class=\"warning\">"] #[doc =
4482 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4483 #[doc = "<ul>"] #[doc =
4484 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4485 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4486 "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
4487 _for_each_inner_peripheral!((@ peri_type #[doc =
4488 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4489 "<section class=\"warning\">"] #[doc =
4490 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4491 #[doc = "<ul>"] #[doc =
4492 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4493 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
4494 peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
4495 #[doc = "<section class=\"warning\">"] #[doc =
4496 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4497 #[doc = "<ul>"] #[doc =
4498 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4499 #[doc = "</section>"] GPIO14 <= virtual())); _for_each_inner_peripheral!((@
4500 peri_type #[doc = "GPIO15 peripheral singleton"] GPIO15 <= virtual()));
4501 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO16 peripheral singleton"]
4502 GPIO16 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4503 "GPIO17 peripheral singleton"] GPIO17 <= virtual()));
4504 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO18 peripheral singleton"]
4505 GPIO18 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4506 "GPIO19 peripheral singleton"] GPIO19 <= virtual()));
4507 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO20 peripheral singleton"]
4508 GPIO20 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4509 "GPIO21 peripheral singleton"] GPIO21 <= virtual()));
4510 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
4511 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4512 "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4513 "<section class=\"warning\">"] #[doc =
4514 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4515 #[doc = "<ul>"] #[doc =
4516 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4517 = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()));
4518 _for_each_inner_peripheral!((@ peri_type #[doc =
4519 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4520 "<section class=\"warning\">"] #[doc =
4521 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4522 #[doc = "<ul>"] #[doc =
4523 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4524 = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()));
4525 _for_each_inner_peripheral!((@ peri_type #[doc =
4526 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4527 "<section class=\"warning\">"] #[doc =
4528 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4529 #[doc = "<ul>"] #[doc =
4530 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4531 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
4532 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
4533 GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4534 "GPIO27 peripheral singleton"] GPIO27 <= virtual()));
4535 _for_each_inner_peripheral!((@ peri_type #[doc =
4536 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4537 "<section class=\"warning\">"] #[doc =
4538 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4539 #[doc = "<ul>"] #[doc =
4540 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4541 #[doc = "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
4542 _for_each_inner_peripheral!((@ peri_type #[doc =
4543 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4544 "<section class=\"warning\">"] #[doc =
4545 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4546 #[doc = "<ul>"] #[doc =
4547 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4548 #[doc = "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()));
4549 _for_each_inner_peripheral!((@ peri_type #[doc =
4550 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4551 "<section class=\"warning\">"] #[doc =
4552 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4553 #[doc = "<ul>"] #[doc =
4554 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4555 #[doc = "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()));
4556 _for_each_inner_peripheral!((@ peri_type #[doc =
4557 "GPIO31 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4558 "<section class=\"warning\">"] #[doc =
4559 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4560 #[doc = "<ul>"] #[doc =
4561 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4562 #[doc = "</ul>"] #[doc = "</section>"] GPIO31 <= virtual()));
4563 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO32 peripheral singleton"]
4564 GPIO32 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4565 "GPIO33 peripheral singleton"] GPIO33 <= virtual()));
4566 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO34 peripheral singleton"]
4567 GPIO34 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4568 "GPIO35 peripheral singleton"] GPIO35 <= virtual()));
4569 _for_each_inner_peripheral!((@ peri_type #[doc =
4570 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4571 "<section class=\"warning\">"] #[doc =
4572 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4573 #[doc = "<ul>"] #[doc =
4574 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4575 = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()));
4576 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO37 peripheral singleton"]
4577 GPIO37 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4578 "GPIO38 peripheral singleton"] GPIO38 <= virtual()));
4579 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO39 peripheral singleton"]
4580 GPIO39 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4581 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
4582 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4583 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4584 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4585 peri_type #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 :
4586 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4587 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4588 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4589 peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 :
4590 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4591 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4592 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4593 peri_type #[doc = "DMA_CH3 peripheral singleton"] DMA_CH3 <= virtual(DMA_IN_CH3 :
4594 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4595 DMA_OUT_CH3 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4596 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4597 peri_type #[doc = "DMA_CH4 peripheral singleton"] DMA_CH4 <= virtual(DMA_IN_CH4 :
4598 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4599 DMA_OUT_CH4 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4600 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4601 peri_type #[doc = "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual()
4602 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4603 "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
4604 _for_each_inner_peripheral!((@ peri_type #[doc =
4605 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
4606 _for_each_inner_peripheral!((@ peri_type #[doc =
4607 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
4608 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
4609 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4610 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4611 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC(APB_ADC : {
4612 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4613 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4614 "ASRC peripheral singleton"] ASRC <= ASRC(ASRC_CHNL0 : { bind_chnl0_interrupt,
4615 enable_chnl0_interrupt, disable_chnl0_interrupt }, ASRC_CHNL1 : {
4616 bind_chnl1_interrupt, enable_chnl1_interrupt, disable_chnl1_interrupt })
4617 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4618 "BUS_MONITOR peripheral singleton"] BUS_MONITOR <= BUS_MONITOR(BUS_MONITOR : {
4619 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4620 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4621 "CACHE peripheral singleton"] CACHE <= CACHE(CACHE : { bind_peri_interrupt,
4622 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4623 _for_each_inner_peripheral!((@ peri_type #[doc = "CLIC peripheral singleton"]
4624 CLIC <= CLIC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4625 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)));
4626 _for_each_inner_peripheral!((@ peri_type #[doc =
4627 "CLINT_OTHER_CORE peripheral singleton"] CLINT_OTHER_CORE <= CLINT_OTHER_CORE()
4628 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4629 "CPU_APM peripheral singleton"] CPU_APM <= CPU_APM() (unstable)));
4630 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
4631 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4632 "ECC peripheral singleton"] ECC <= ECC(ECC : { bind_peri_interrupt,
4633 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4634 _for_each_inner_peripheral!((@ peri_type #[doc = "ECDSA peripheral singleton"]
4635 ECDSA <= ECDSA(ECDSA : { bind_peri_interrupt, enable_peri_interrupt,
4636 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4637 #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
4638 _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
4639 <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4640 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
4641 _for_each_inner_peripheral!((@ peri_type #[doc =
4642 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4643 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO_SD peripheral singleton"]
4644 GPIO_SD <= GPIO_SD() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4645 = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)));
4646 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_APM peripheral singleton"]
4647 HP_APM <= HP_APM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4648 "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)));
4649 _for_each_inner_peripheral!((@ peri_type #[doc = "HUK peripheral singleton"] HUK
4650 <= HUK(HUK : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4651 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4652 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4653 _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
4654 I2S0 <= I2S0(I2S : { bind_peri_interrupt, enable_peri_interrupt,
4655 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4656 #[doc = "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : {
4657 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })));
4658 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C1 peripheral singleton"]
4659 I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt, enable_peri_interrupt,
4660 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4661 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
4662 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4663 _for_each_inner_peripheral!((@ peri_type #[doc =
4664 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4665 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4666 "INTERRUPT_CORE1 peripheral singleton"] INTERRUPT_CORE1 <= INTERRUPT_CORE1()
4667 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4668 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
4669 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
4670 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4671 "KEYMNG peripheral singleton"] KEYMNG <= KEYMNG(KM : { bind_peri_interrupt,
4672 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4673 _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
4674 LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4675 "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)));
4676 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_ANA peripheral singleton"]
4677 LP_ANA <= LP_ANA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4678 "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)));
4679 _for_each_inner_peripheral!((@ peri_type #[doc =
4680 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
4681 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_GPIO peripheral singleton"]
4682 LP_GPIO <= LP_GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4683 = "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
4684 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
4685 LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4686 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
4687 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
4688 LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4689 "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0(MCPWM0 : { bind_peri_interrupt,
4690 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4691 _for_each_inner_peripheral!((@ peri_type #[doc = "MCPWM1 peripheral singleton"]
4692 MCPWM1 <= MCPWM1(MCPWM1 : { bind_peri_interrupt, enable_peri_interrupt,
4693 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4694 #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR()
4695 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4696 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
4697 _for_each_inner_peripheral!((@ peri_type #[doc =
4698 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
4699 _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
4700 PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
4701 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
4702 disable_tx_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4703 #[doc = "PAU peripheral singleton"] PAU <= PAU(PAU : { bind_peri_interrupt,
4704 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4705 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
4706 PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
4707 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4708 #[doc = "PCR peripheral singleton"] PCR <= PCR() (unstable)));
4709 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
4710 <= PMU(PMU : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4711 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4712 "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
4713 _for_each_inner_peripheral!((@ peri_type #[doc = "PVT peripheral singleton"] PVT
4714 <= PVT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4715 "RMT peripheral singleton"] RMT <= RMT(RMT : { bind_peri_interrupt,
4716 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4717 _for_each_inner_peripheral!((@ peri_type #[doc = "RNG peripheral singleton"] RNG
4718 <= RNG() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4719 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4720 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4721 _for_each_inner_peripheral!((@ peri_type #[doc =
4722 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
4723 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
4724 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4725 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
4726 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
4727 SPI2 <= SPI2(GPSPI2 : { bind_peri_interrupt, enable_peri_interrupt,
4728 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4729 "SPI3 peripheral singleton"] SPI3 <= SPI3(GPSPI3 : { bind_peri_interrupt,
4730 enable_peri_interrupt, disable_peri_interrupt })));
4731 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
4732 SYSTEM <= PCR() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4733 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
4734 _for_each_inner_peripheral!((@ peri_type #[doc = "TEE peripheral singleton"] TEE
4735 <= TEE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4736 "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
4737 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
4738 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4739 "TOUCH peripheral singleton"] TOUCH <= TOUCH(TOUCH : { bind_peri_interrupt,
4740 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4741 _for_each_inner_peripheral!((@ peri_type #[doc =
4742 "TOUCH_AON peripheral singleton"] TOUCH_AON <= TOUCH_AON() (unstable)));
4743 _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
4744 TWAI0 <= TWAI0(TWAI0 : { bind_peri_interrupt, enable_peri_interrupt,
4745 disable_peri_interrupt }, TWAI0_TIMER : { bind_timer_interrupt,
4746 enable_timer_interrupt, disable_timer_interrupt }) (unstable)));
4747 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
4748 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
4749 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4750 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
4751 enable_peri_interrupt, disable_peri_interrupt })));
4752 _for_each_inner_peripheral!((@ peri_type #[doc = "UHCI0 peripheral singleton"]
4753 UHCI0 <= UHCI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4754 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4755 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4756 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4757 "USB_FS peripheral singleton"] USB_FS <= USB0(USB_OTG11 : { bind_peri_interrupt,
4758 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4759 _for_each_inner_peripheral!((@ peri_type #[doc = "USB_WRAP peripheral singleton"]
4760 USB_WRAP <= USB_WRAP() (unstable))); _for_each_inner_peripheral!((@ peri_type
4761 #[doc = "ZERO_DET peripheral singleton"] ZERO_DET <= ZERO_DET(ZERO_DET : {
4762 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4763 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4764 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
4765 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4766 virtual(BT_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt },
4767 LP_RTC_BLE_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
4768 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
4769 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4770 _for_each_inner_peripheral!((@ peri_type #[doc = "CPU_CTRL peripheral singleton"]
4771 CPU_CTRL <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
4772 #[doc = "IPC peripheral singleton"] IPC <= virtual() (unstable)));
4773 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
4774 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4775 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
4776 _for_each_inner_peripheral!((@ peri_type #[doc =
4777 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4778 _for_each_inner_peripheral!((@ peri_type #[doc =
4779 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4780 _for_each_inner_peripheral!((@ peri_type #[doc =
4781 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4782 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
4783 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4784 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO4));
4785 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO5));
4786 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4787 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4788 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4789 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4790 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
4791 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
4792 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
4793 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
4794 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
4795 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
4796 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
4797 _for_each_inner_peripheral!((GPIO28)); _for_each_inner_peripheral!((GPIO29));
4798 _for_each_inner_peripheral!((GPIO30)); _for_each_inner_peripheral!((GPIO31));
4799 _for_each_inner_peripheral!((GPIO32)); _for_each_inner_peripheral!((GPIO33));
4800 _for_each_inner_peripheral!((GPIO34)); _for_each_inner_peripheral!((GPIO35));
4801 _for_each_inner_peripheral!((GPIO36)); _for_each_inner_peripheral!((GPIO37));
4802 _for_each_inner_peripheral!((GPIO38)); _for_each_inner_peripheral!((GPIO39));
4803 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4804 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4805 _for_each_inner_peripheral!((DMA_CH2(unstable)));
4806 _for_each_inner_peripheral!((DMA_CH3(unstable)));
4807 _for_each_inner_peripheral!((DMA_CH4(unstable)));
4808 _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
4809 _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
4810 _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
4811 _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
4812 _for_each_inner_peripheral!((AES(unstable)));
4813 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4814 _for_each_inner_peripheral!((ASRC(unstable)));
4815 _for_each_inner_peripheral!((BUS_MONITOR(unstable)));
4816 _for_each_inner_peripheral!((CACHE(unstable)));
4817 _for_each_inner_peripheral!((CLIC(unstable)));
4818 _for_each_inner_peripheral!((CLINT(unstable)));
4819 _for_each_inner_peripheral!((CLINT_OTHER_CORE(unstable)));
4820 _for_each_inner_peripheral!((CPU_APM(unstable)));
4821 _for_each_inner_peripheral!((DMA(unstable)));
4822 _for_each_inner_peripheral!((ECC(unstable)));
4823 _for_each_inner_peripheral!((ECDSA(unstable)));
4824 _for_each_inner_peripheral!((ETM(unstable)));
4825 _for_each_inner_peripheral!((GPIO(unstable)));
4826 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
4827 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4828 _for_each_inner_peripheral!((HMAC(unstable)));
4829 _for_each_inner_peripheral!((HP_APM(unstable)));
4830 _for_each_inner_peripheral!((HP_SYS(unstable)));
4831 _for_each_inner_peripheral!((HUK(unstable)));
4832 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4833 _for_each_inner_peripheral!((I2S0(unstable)));
4834 _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
4835 _for_each_inner_peripheral!((IEEE802154(unstable)));
4836 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4837 _for_each_inner_peripheral!((INTERRUPT_CORE1(unstable)));
4838 _for_each_inner_peripheral!((INTPRI(unstable)));
4839 _for_each_inner_peripheral!((IO_MUX(unstable)));
4840 _for_each_inner_peripheral!((KEYMNG(unstable)));
4841 _for_each_inner_peripheral!((LEDC(unstable)));
4842 _for_each_inner_peripheral!((LPWR(unstable)));
4843 _for_each_inner_peripheral!((LP_ANA(unstable)));
4844 _for_each_inner_peripheral!((LP_AON(unstable)));
4845 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
4846 _for_each_inner_peripheral!((LP_GPIO(unstable)));
4847 _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
4848 _for_each_inner_peripheral!((LP_PERI(unstable)));
4849 _for_each_inner_peripheral!((LP_TEE(unstable)));
4850 _for_each_inner_peripheral!((LP_WDT(unstable)));
4851 _for_each_inner_peripheral!((MCPWM0(unstable)));
4852 _for_each_inner_peripheral!((MCPWM1(unstable)));
4853 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
4854 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
4855 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
4856 _for_each_inner_peripheral!((PARL_IO(unstable)));
4857 _for_each_inner_peripheral!((PAU(unstable)));
4858 _for_each_inner_peripheral!((PCNT(unstable)));
4859 _for_each_inner_peripheral!((PCR(unstable)));
4860 _for_each_inner_peripheral!((PMU(unstable)));
4861 _for_each_inner_peripheral!((PSRAM(unstable)));
4862 _for_each_inner_peripheral!((PVT(unstable)));
4863 _for_each_inner_peripheral!((RMT(unstable)));
4864 _for_each_inner_peripheral!((RNG(unstable)));
4865 _for_each_inner_peripheral!((SHA(unstable)));
4866 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4867 _for_each_inner_peripheral!((SPI0(unstable)));
4868 _for_each_inner_peripheral!((SPI1(unstable)));
4869 _for_each_inner_peripheral!((SPI2)); _for_each_inner_peripheral!((SPI3));
4870 _for_each_inner_peripheral!((SYSTEM(unstable)));
4871 _for_each_inner_peripheral!((SYSTIMER(unstable)));
4872 _for_each_inner_peripheral!((TEE(unstable)));
4873 _for_each_inner_peripheral!((TIMG0(unstable)));
4874 _for_each_inner_peripheral!((TIMG1(unstable)));
4875 _for_each_inner_peripheral!((TOUCH(unstable)));
4876 _for_each_inner_peripheral!((TOUCH_AON(unstable)));
4877 _for_each_inner_peripheral!((TWAI0(unstable)));
4878 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
4879 _for_each_inner_peripheral!((UHCI0(unstable)));
4880 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
4881 _for_each_inner_peripheral!((USB_FS(unstable)));
4882 _for_each_inner_peripheral!((ZERO_DET(unstable)));
4883 _for_each_inner_peripheral!((ADC1(unstable)));
4884 _for_each_inner_peripheral!((BT(unstable)));
4885 _for_each_inner_peripheral!((CPU_CTRL(unstable)));
4886 _for_each_inner_peripheral!((IPC(unstable)));
4887 _for_each_inner_peripheral!((FLASH(unstable)));
4888 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
4889 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
4890 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
4891 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
4892 _for_each_inner_peripheral!((SPI3, Spi3, 0, AhbGdmaChannel));
4893 _for_each_inner_peripheral!((SPI2, Spi2, 1, AhbGdmaChannel));
4894 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
4895 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
4896 _for_each_inner_peripheral!((AES, Aes, 4, AhbGdmaChannel));
4897 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
4898 _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
4899 _for_each_inner_peripheral!((all(@ peri_type #[doc =
4900 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
4901 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
4902 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
4903 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
4904 "GPIO4 peripheral singleton"] GPIO4 <= virtual()), (@ peri_type #[doc =
4905 "GPIO5 peripheral singleton"] GPIO5 <= virtual()), (@ peri_type #[doc =
4906 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4907 "<section class=\"warning\">"] #[doc =
4908 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4909 #[doc = "<ul>"] #[doc =
4910 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4911 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
4912 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4913 "<section class=\"warning\">"] #[doc =
4914 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4915 #[doc = "<ul>"] #[doc =
4916 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4917 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
4918 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4919 "<section class=\"warning\">"] #[doc =
4920 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4921 #[doc = "<ul>"] #[doc =
4922 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4923 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4924 "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
4925 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4926 "<section class=\"warning\">"] #[doc =
4927 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4928 #[doc = "<ul>"] #[doc =
4929 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4930 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4931 "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
4932 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4933 "<section class=\"warning\">"] #[doc =
4934 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4935 #[doc = "<ul>"] #[doc =
4936 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4937 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4938 "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
4939 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4940 "<section class=\"warning\">"] #[doc =
4941 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4942 #[doc = "<ul>"] #[doc =
4943 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4944 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4945 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
4946 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4947 "<section class=\"warning\">"] #[doc =
4948 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4949 #[doc = "<ul>"] #[doc =
4950 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4951 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4952 "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
4953 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4954 "<section class=\"warning\">"] #[doc =
4955 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4956 #[doc = "<ul>"] #[doc =
4957 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4958 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
4959 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4960 "<section class=\"warning\">"] #[doc =
4961 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4962 #[doc = "<ul>"] #[doc =
4963 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4964 #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
4965 "GPIO15 peripheral singleton"] GPIO15 <= virtual()), (@ peri_type #[doc =
4966 "GPIO16 peripheral singleton"] GPIO16 <= virtual()), (@ peri_type #[doc =
4967 "GPIO17 peripheral singleton"] GPIO17 <= virtual()), (@ peri_type #[doc =
4968 "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
4969 "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
4970 "GPIO20 peripheral singleton"] GPIO20 <= virtual()), (@ peri_type #[doc =
4971 "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
4972 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
4973 "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4974 "<section class=\"warning\">"] #[doc =
4975 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4976 #[doc = "<ul>"] #[doc =
4977 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4978 = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()), (@ peri_type #[doc =
4979 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4980 "<section class=\"warning\">"] #[doc =
4981 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4982 #[doc = "<ul>"] #[doc =
4983 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4984 = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
4985 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4986 "<section class=\"warning\">"] #[doc =
4987 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4988 #[doc = "<ul>"] #[doc =
4989 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4990 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
4991 "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
4992 "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
4993 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4994 "<section class=\"warning\">"] #[doc =
4995 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4996 #[doc = "<ul>"] #[doc =
4997 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4998 #[doc = "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
4999 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5000 "<section class=\"warning\">"] #[doc =
5001 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5002 #[doc = "<ul>"] #[doc =
5003 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5004 #[doc = "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()), (@ peri_type #[doc =
5005 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5006 "<section class=\"warning\">"] #[doc =
5007 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5008 #[doc = "<ul>"] #[doc =
5009 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5010 #[doc = "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()), (@ peri_type #[doc =
5011 "GPIO31 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5012 "<section class=\"warning\">"] #[doc =
5013 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5014 #[doc = "<ul>"] #[doc =
5015 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5016 #[doc = "</ul>"] #[doc = "</section>"] GPIO31 <= virtual()), (@ peri_type #[doc =
5017 "GPIO32 peripheral singleton"] GPIO32 <= virtual()), (@ peri_type #[doc =
5018 "GPIO33 peripheral singleton"] GPIO33 <= virtual()), (@ peri_type #[doc =
5019 "GPIO34 peripheral singleton"] GPIO34 <= virtual()), (@ peri_type #[doc =
5020 "GPIO35 peripheral singleton"] GPIO35 <= virtual()), (@ peri_type #[doc =
5021 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5022 "<section class=\"warning\">"] #[doc =
5023 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5024 #[doc = "<ul>"] #[doc =
5025 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5026 = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()), (@ peri_type #[doc =
5027 "GPIO37 peripheral singleton"] GPIO37 <= virtual()), (@ peri_type #[doc =
5028 "GPIO38 peripheral singleton"] GPIO38 <= virtual()), (@ peri_type #[doc =
5029 "GPIO39 peripheral singleton"] GPIO39 <= virtual()), (@ peri_type #[doc =
5030 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
5031 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5032 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5033 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5034 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
5035 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5036 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5037 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5038 "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
5039 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5040 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5041 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5042 "DMA_CH3 peripheral singleton"] DMA_CH3 <= virtual(DMA_IN_CH3 : {
5043 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5044 DMA_OUT_CH3 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5045 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5046 "DMA_CH4 peripheral singleton"] DMA_CH4 <= virtual(DMA_IN_CH4 : {
5047 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5048 DMA_OUT_CH4 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5049 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5050 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)), (@
5051 peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual()
5052 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2
5053 <= virtual() (unstable)), (@ peri_type #[doc =
5054 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)), (@
5055 peri_type #[doc = "AES peripheral singleton"] AES <= AES(AES : {
5056 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5057 (unstable)), (@ peri_type #[doc = "APB_SARADC peripheral singleton"] APB_SARADC
5058 <= APB_SARADC(APB_ADC : { bind_peri_interrupt, enable_peri_interrupt,
5059 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5060 "ASRC peripheral singleton"] ASRC <= ASRC(ASRC_CHNL0 : { bind_chnl0_interrupt,
5061 enable_chnl0_interrupt, disable_chnl0_interrupt }, ASRC_CHNL1 : {
5062 bind_chnl1_interrupt, enable_chnl1_interrupt, disable_chnl1_interrupt })
5063 (unstable)), (@ peri_type #[doc = "BUS_MONITOR peripheral singleton"] BUS_MONITOR
5064 <= BUS_MONITOR(BUS_MONITOR : { bind_peri_interrupt, enable_peri_interrupt,
5065 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5066 "CACHE peripheral singleton"] CACHE <= CACHE(CACHE : { bind_peri_interrupt,
5067 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5068 = "CLIC peripheral singleton"] CLIC <= CLIC() (unstable)), (@ peri_type #[doc =
5069 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)), (@ peri_type #[doc =
5070 "CLINT_OTHER_CORE peripheral singleton"] CLINT_OTHER_CORE <= CLINT_OTHER_CORE()
5071 (unstable)), (@ peri_type #[doc = "CPU_APM peripheral singleton"] CPU_APM <=
5072 CPU_APM() (unstable)), (@ peri_type #[doc = "DMA peripheral singleton"] DMA <=
5073 DMA() (unstable)), (@ peri_type #[doc = "ECC peripheral singleton"] ECC <=
5074 ECC(ECC : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5075 (unstable)), (@ peri_type #[doc = "ECDSA peripheral singleton"] ECDSA <=
5076 ECDSA(ECDSA : { bind_peri_interrupt, enable_peri_interrupt,
5077 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5078 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc =
5079 "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)), (@ peri_type #[doc =
5080 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
5081 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
5082 (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD()
5083 (unstable)), (@ peri_type #[doc = "HMAC peripheral singleton"] HMAC <= HMAC()
5084 (unstable)), (@ peri_type #[doc = "HP_APM peripheral singleton"] HP_APM <=
5085 HP_APM() (unstable)), (@ peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS
5086 <= HP_SYS() (unstable)), (@ peri_type #[doc = "HUK peripheral singleton"] HUK <=
5087 HUK(HUK : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5088 (unstable)), (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST
5089 <= I2C_ANA_MST() (unstable)), (@ peri_type #[doc = "I2S0 peripheral singleton"]
5090 I2S0 <= I2S0(I2S : { bind_peri_interrupt, enable_peri_interrupt,
5091 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5092 "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
5093 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5094 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
5095 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5096 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
5097 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
5098 (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
5099 INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
5100 "INTERRUPT_CORE1 peripheral singleton"] INTERRUPT_CORE1 <= INTERRUPT_CORE1()
5101 (unstable)), (@ peri_type #[doc = "INTPRI peripheral singleton"] INTPRI <=
5102 INTPRI() (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX
5103 <= IO_MUX() (unstable)), (@ peri_type #[doc = "KEYMNG peripheral singleton"]
5104 KEYMNG <= KEYMNG(KM : { bind_peri_interrupt, enable_peri_interrupt,
5105 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5106 "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type #[doc =
5107 "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)), (@ peri_type #[doc
5108 = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)), (@ peri_type
5109 #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)), (@
5110 peri_type #[doc = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST()
5111 (unstable)), (@ peri_type #[doc = "LP_GPIO peripheral singleton"] LP_GPIO <=
5112 LP_GPIO() (unstable)), (@ peri_type #[doc = "LP_IO_MUX peripheral singleton"]
5113 LP_IO_MUX <= LP_IO_MUX() (unstable)), (@ peri_type #[doc =
5114 "LP_PERI peripheral singleton"] LP_PERI <= LP_PERI() (unstable)), (@ peri_type
5115 #[doc = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)), (@
5116 peri_type #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)),
5117 (@ peri_type #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0(MCPWM0 : {
5118 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5119 (unstable)), (@ peri_type #[doc = "MCPWM1 peripheral singleton"] MCPWM1 <=
5120 MCPWM1(MCPWM1 : { bind_peri_interrupt, enable_peri_interrupt,
5121 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5122 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)), (@
5123 peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON <=
5124 MODEM_LPCON() (unstable)), (@ peri_type #[doc =
5125 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
5126 (@ peri_type #[doc = "PARL_IO peripheral singleton"] PARL_IO <=
5127 PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
5128 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
5129 disable_tx_interrupt }) (unstable)), (@ peri_type #[doc =
5130 "PAU peripheral singleton"] PAU <= PAU(PAU : { bind_peri_interrupt,
5131 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5132 = "PCNT peripheral singleton"] PCNT <= PCNT(PCNT : { bind_peri_interrupt,
5133 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5134 = "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@ peri_type #[doc =
5135 "PMU peripheral singleton"] PMU <= PMU(PMU : { bind_peri_interrupt,
5136 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5137 = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)), (@ peri_type
5138 #[doc = "PVT peripheral singleton"] PVT <= PVT() (unstable)), (@ peri_type #[doc
5139 = "RMT peripheral singleton"] RMT <= RMT(RMT : { bind_peri_interrupt,
5140 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5141 = "RNG peripheral singleton"] RNG <= RNG() (unstable)), (@ peri_type #[doc =
5142 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
5143 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5144 = "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)), (@
5145 peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@
5146 peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@
5147 peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(GPSPI2 : {
5148 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5149 peri_type #[doc = "SPI3 peripheral singleton"] SPI3 <= SPI3(GPSPI3 : {
5150 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5151 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
5152 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
5153 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
5154 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
5155 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
5156 (unstable)), (@ peri_type #[doc = "TOUCH peripheral singleton"] TOUCH <=
5157 TOUCH(TOUCH : { bind_peri_interrupt, enable_peri_interrupt,
5158 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5159 "TOUCH_AON peripheral singleton"] TOUCH_AON <= TOUCH_AON() (unstable)), (@
5160 peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0(TWAI0 : {
5161 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt }, TWAI0_TIMER
5162 : { bind_timer_interrupt, enable_timer_interrupt, disable_timer_interrupt })
5163 (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
5164 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5165 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
5166 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
5167 disable_peri_interrupt })), (@ peri_type #[doc = "UHCI0 peripheral singleton"]
5168 UHCI0 <= UHCI0() (unstable)), (@ peri_type #[doc =
5169 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
5170 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5171 (unstable)), (@ peri_type #[doc = "USB_FS peripheral singleton"] USB_FS <=
5172 USB0(USB_OTG11 : { bind_peri_interrupt, enable_peri_interrupt,
5173 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5174 "USB_WRAP peripheral singleton"] USB_WRAP <= USB_WRAP() (unstable)), (@ peri_type
5175 #[doc = "ZERO_DET peripheral singleton"] ZERO_DET <= ZERO_DET(ZERO_DET : {
5176 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5177 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
5178 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <= virtual(BT_BB
5179 : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt },
5180 LP_RTC_BLE_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
5181 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
5182 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
5183 "CPU_CTRL peripheral singleton"] CPU_CTRL <= virtual() (unstable)), (@ peri_type
5184 #[doc = "IPC peripheral singleton"] IPC <= virtual() (unstable)), (@ peri_type
5185 #[doc = "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@
5186 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
5187 virtual() (unstable)), (@ peri_type #[doc =
5188 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
5189 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
5190 virtual() (unstable)), (@ peri_type #[doc =
5191 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
5192 _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1), (GPIO2), (GPIO3),
5193 (#[cfg(not(use_xtal32k))] GPIO4), (#[cfg(not(use_xtal32k))] GPIO5), (GPIO6),
5194 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
5195 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
5196 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (GPIO29), (GPIO30),
5197 (GPIO31), (GPIO32), (GPIO33), (GPIO34), (GPIO35), (GPIO36), (GPIO37), (GPIO38),
5198 (GPIO39), (DMA_CH0(unstable)), (DMA_CH1(unstable)), (DMA_CH2(unstable)),
5199 (DMA_CH3(unstable)), (DMA_CH4(unstable)), (PCNT0_UNIT0(unstable)),
5200 (PCNT0_UNIT1(unstable)), (PCNT0_UNIT2(unstable)), (PCNT0_UNIT3(unstable)),
5201 (AES(unstable)), (APB_SARADC(unstable)), (ASRC(unstable)),
5202 (BUS_MONITOR(unstable)), (CACHE(unstable)), (CLIC(unstable)), (CLINT(unstable)),
5203 (CLINT_OTHER_CORE(unstable)), (CPU_APM(unstable)), (DMA(unstable)),
5204 (ECC(unstable)), (ECDSA(unstable)), (ETM(unstable)), (GPIO(unstable)),
5205 (GPIO_DEDICATED(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)),
5206 (HP_APM(unstable)), (HP_SYS(unstable)), (HUK(unstable)), (I2C_ANA_MST(unstable)),
5207 (I2S0(unstable)), (I2C0), (I2C1), (IEEE802154(unstable)),
5208 (INTERRUPT_CORE0(unstable)), (INTERRUPT_CORE1(unstable)), (INTPRI(unstable)),
5209 (IO_MUX(unstable)), (KEYMNG(unstable)), (LEDC(unstable)), (LPWR(unstable)),
5210 (LP_ANA(unstable)), (LP_AON(unstable)), (LP_CLKRST(unstable)),
5211 (LP_GPIO(unstable)), (LP_IO_MUX(unstable)), (LP_PERI(unstable)),
5212 (LP_TEE(unstable)), (LP_WDT(unstable)), (MCPWM0(unstable)), (MCPWM1(unstable)),
5213 (MEM_MONITOR(unstable)), (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)),
5214 (PARL_IO(unstable)), (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)),
5215 (PMU(unstable)), (PSRAM(unstable)), (PVT(unstable)), (RMT(unstable)),
5216 (RNG(unstable)), (SHA(unstable)), (RTC_TIMER(unstable)), (SPI0(unstable)),
5217 (SPI1(unstable)), (SPI2), (SPI3), (SYSTEM(unstable)), (SYSTIMER(unstable)),
5218 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (TOUCH(unstable)),
5219 (TOUCH_AON(unstable)), (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)),
5220 (USB_DEVICE(unstable)), (USB_FS(unstable)), (ZERO_DET(unstable)),
5221 (ADC1(unstable)), (BT(unstable)), (CPU_CTRL(unstable)), (IPC(unstable)),
5222 (FLASH(unstable)), (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
5223 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
5224 _for_each_inner_peripheral!((dma_eligible(SPI3, Spi3, 0, AhbGdmaChannel), (SPI2,
5225 Spi2, 1, AhbGdmaChannel), (UHCI0, Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3,
5226 AhbGdmaChannel), (AES, Aes, 4, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel),
5227 (PARL_IO, ParlIo, 9, AhbGdmaChannel)));
5228 };
5229}
5230#[macro_export]
5257#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5258macro_rules! for_each_gpio {
5259 ($($pattern:tt => $code:tt;)*) => {
5260 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5261 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
5262 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
5263 _for_each_inner_gpio!((2, GPIO2() () ([Input] [Output])));
5264 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
5265 _for_each_inner_gpio!((4, GPIO4() () ([Input] [Output])));
5266 _for_each_inner_gpio!((5, GPIO5() () ([Input] [Output])));
5267 _for_each_inner_gpio!((6, GPIO6() () ([Input] [Output])));
5268 _for_each_inner_gpio!((7, GPIO7() () ([Input] [Output])));
5269 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
5270 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
5271 _for_each_inner_gpio!((10, GPIO10() () ([Input] [Output])));
5272 _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
5273 _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
5274 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
5275 _for_each_inner_gpio!((14, GPIO14() () ([Input] [Output])));
5276 _for_each_inner_gpio!((15, GPIO15(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
5277 [Output]))); _for_each_inner_gpio!((16, GPIO16(_2 => FSPICLK) (_2 => FSPICLK)
5278 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_2 => FSPID) (_2 =>
5279 FSPID) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18(_2 => FSPIWP) (_2
5280 => FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((19, GPIO19(_2 => FSPIHD)
5281 (_2 => FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_2 =>
5282 FSPICS0) (_2 => FSPICS0) ([Input] [Output]))); _for_each_inner_gpio!((21,
5283 GPIO21() () ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22() () ([Input]
5284 [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 => U0RXD) () ([Input]
5285 [Output]))); _for_each_inner_gpio!((24, GPIO24() (_0 => U0TXD) ([Input]
5286 [Output]))); _for_each_inner_gpio!((25, GPIO25() () ([Input] [Output])));
5287 _for_each_inner_gpio!((26, GPIO26() () ([Input] [Output])));
5288 _for_each_inner_gpio!((27, GPIO27() () ([Input] [Output])));
5289 _for_each_inner_gpio!((28, GPIO28(_0 => MTMS) () ([Input] [Output])));
5290 _for_each_inner_gpio!((29, GPIO29(_0 => MTDI) () ([Input] [Output])));
5291 _for_each_inner_gpio!((30, GPIO30(_0 => MTCK) () ([Input] [Output])));
5292 _for_each_inner_gpio!((31, GPIO31() (_0 => MTDO) ([Input] [Output])));
5293 _for_each_inner_gpio!((32, GPIO32(_2 => FSPICLK) (_2 => FSPICLK) ([Input]
5294 [Output]))); _for_each_inner_gpio!((33, GPIO33(_2 => FSPID) (_2 => FSPID)
5295 ([Input] [Output]))); _for_each_inner_gpio!((34, GPIO34() () ([Input]
5296 [Output]))); _for_each_inner_gpio!((35, GPIO35() () ([Input] [Output])));
5297 _for_each_inner_gpio!((36, GPIO36(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
5298 [Output]))); _for_each_inner_gpio!((37, GPIO37(_2 => FSPIWP) (_2 => FSPIWP)
5299 ([Input] [Output]))); _for_each_inner_gpio!((38, GPIO38(_2 => FSPIHD) (_2 =>
5300 FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((39, GPIO39(_2 => FSPICS0)
5301 (_2 => FSPICS0) ([Input] [Output]))); _for_each_inner_gpio!((all(0, GPIO0() ()
5302 ([Input] [Output])), (1, GPIO1() () ([Input] [Output])), (2, GPIO2() () ([Input]
5303 [Output])), (3, GPIO3() () ([Input] [Output])), (4, GPIO4() () ([Input]
5304 [Output])), (5, GPIO5() () ([Input] [Output])), (6, GPIO6() () ([Input]
5305 [Output])), (7, GPIO7() () ([Input] [Output])), (8, GPIO8() () ([Input]
5306 [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10() () ([Input]
5307 [Output])), (11, GPIO11() () ([Input] [Output])), (12, GPIO12() () ([Input]
5308 [Output])), (13, GPIO13() () ([Input] [Output])), (14, GPIO14() () ([Input]
5309 [Output])), (15, GPIO15(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])), (16,
5310 GPIO16(_2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (17, GPIO17(_2 =>
5311 FSPID) (_2 => FSPID) ([Input] [Output])), (18, GPIO18(_2 => FSPIWP) (_2 =>
5312 FSPIWP) ([Input] [Output])), (19, GPIO19(_2 => FSPIHD) (_2 => FSPIHD) ([Input]
5313 [Output])), (20, GPIO20(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (21,
5314 GPIO21() () ([Input] [Output])), (22, GPIO22() () ([Input] [Output])), (23,
5315 GPIO23(_0 => U0RXD) () ([Input] [Output])), (24, GPIO24() (_0 => U0TXD) ([Input]
5316 [Output])), (25, GPIO25() () ([Input] [Output])), (26, GPIO26() () ([Input]
5317 [Output])), (27, GPIO27() () ([Input] [Output])), (28, GPIO28(_0 => MTMS) ()
5318 ([Input] [Output])), (29, GPIO29(_0 => MTDI) () ([Input] [Output])), (30,
5319 GPIO30(_0 => MTCK) () ([Input] [Output])), (31, GPIO31() (_0 => MTDO) ([Input]
5320 [Output])), (32, GPIO32(_2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (33,
5321 GPIO33(_2 => FSPID) (_2 => FSPID) ([Input] [Output])), (34, GPIO34() () ([Input]
5322 [Output])), (35, GPIO35() () ([Input] [Output])), (36, GPIO36(_2 => FSPIQ) (_2 =>
5323 FSPIQ) ([Input] [Output])), (37, GPIO37(_2 => FSPIWP) (_2 => FSPIWP) ([Input]
5324 [Output])), (38, GPIO38(_2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (39,
5325 GPIO39(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output]))));
5326 };
5327}
5328#[macro_export]
5355#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5356macro_rules! for_each_analog_function {
5357 ($($pattern:tt => $code:tt;)*) => {
5358 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5359 tt) => {} } _for_each_inner_analog_function!((ZCD0, GPIO0));
5360 _for_each_inner_analog_function!((ZCD1, GPIO1));
5361 _for_each_inner_analog_function!((ZCD2, GPIO2));
5362 _for_each_inner_analog_function!((ZCD3, GPIO3));
5363 _for_each_inner_analog_function!((XTAL_32K_N, GPIO4));
5364 _for_each_inner_analog_function!((XTAL_32K_P, GPIO5));
5365 _for_each_inner_analog_function!((USJ_DM, GPIO13));
5366 _for_each_inner_analog_function!((USJ_DP, GPIO14));
5367 _for_each_inner_analog_function!((USB_FS_DM, GPIO21));
5368 _for_each_inner_analog_function!((USB_FS_DP, GPIO22));
5369 _for_each_inner_analog_function!((ADC1_CH0, GPIO28));
5370 _for_each_inner_analog_function!((ADC1_CH1, GPIO29));
5371 _for_each_inner_analog_function!((ADC1_CH2, GPIO30));
5372 _for_each_inner_analog_function!((ADC1_CH3, GPIO31));
5373 _for_each_inner_analog_function!((ADC1_CH4, GPIO32));
5374 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO0));
5375 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO1));
5376 _for_each_inner_analog_function!(((ZCD2, ZCDn, 2), GPIO2));
5377 _for_each_inner_analog_function!(((ZCD3, ZCDn, 3), GPIO3));
5378 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO28));
5379 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO29));
5380 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO30));
5381 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO31));
5382 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO32));
5383 _for_each_inner_analog_function!((all(ZCD0, GPIO0), (ZCD1, GPIO1), (ZCD2, GPIO2),
5384 (ZCD3, GPIO3), (XTAL_32K_N, GPIO4), (XTAL_32K_P, GPIO5), (USJ_DM, GPIO13),
5385 (USJ_DP, GPIO14), (USB_FS_DM, GPIO21), (USB_FS_DP, GPIO22), (ADC1_CH0, GPIO28),
5386 (ADC1_CH1, GPIO29), (ADC1_CH2, GPIO30), (ADC1_CH3, GPIO31), (ADC1_CH4, GPIO32)));
5387 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO0), ((ZCD1, ZCDn, 1),
5388 GPIO1), ((ZCD2, ZCDn, 2), GPIO2), ((ZCD3, ZCDn, 3), GPIO3)));
5389 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO28),
5390 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO29), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO30),
5391 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO31), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO32)));
5392 };
5393}
5394#[macro_export]
5432#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5433macro_rules! for_each_lp_function {
5434 ($($pattern:tt => $code:tt;)*) => {
5435 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5436 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
5437 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
5438 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
5439 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
5440 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
5441 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
5442 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
5443 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
5444 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
5445 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
5446 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
5447 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
5448 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _1), (LP_GPIO1, GPIO1, _1),
5449 (LP_GPIO2, GPIO2, _1), (LP_GPIO3, GPIO3, _1), (LP_GPIO4, GPIO4, _1), (LP_GPIO5,
5450 GPIO5, _1))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0),
5451 GPIO0, _1, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()), ((LP_GPIO2,
5452 LP_GPIOn, 2), GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()),
5453 ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1,
5454 () ())));
5455 };
5456}
5457#[macro_export]
5488#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5489macro_rules! for_each_iomux_function {
5490 ($($pattern:tt => $code:tt;)*) => {
5491 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5492 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO15, _2));
5493 _for_each_inner_iomux_function!((FSPICLK, GPIO16, _2));
5494 _for_each_inner_iomux_function!((FSPID, GPIO17, _2));
5495 _for_each_inner_iomux_function!((FSPIWP, GPIO18, _2));
5496 _for_each_inner_iomux_function!((FSPIHD, GPIO19, _2));
5497 _for_each_inner_iomux_function!((FSPICS0, GPIO20, _2));
5498 _for_each_inner_iomux_function!((U0RXD, GPIO23, _0));
5499 _for_each_inner_iomux_function!((U0TXD, GPIO24, _0));
5500 _for_each_inner_iomux_function!((MTMS, GPIO28, _0));
5501 _for_each_inner_iomux_function!((MTDI, GPIO29, _0));
5502 _for_each_inner_iomux_function!((MTCK, GPIO30, _0));
5503 _for_each_inner_iomux_function!((MTDO, GPIO31, _0));
5504 _for_each_inner_iomux_function!((FSPICLK, GPIO32, _2));
5505 _for_each_inner_iomux_function!((FSPID, GPIO33, _2));
5506 _for_each_inner_iomux_function!((FSPIQ, GPIO36, _2));
5507 _for_each_inner_iomux_function!((FSPIWP, GPIO37, _2));
5508 _for_each_inner_iomux_function!((FSPIHD, GPIO38, _2));
5509 _for_each_inner_iomux_function!((FSPICS0, GPIO39, _2));
5510 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO20, _2));
5511 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO39, _2));
5512 _for_each_inner_iomux_function!((all(FSPIQ, GPIO15, _2), (FSPICLK, GPIO16, _2),
5513 (FSPID, GPIO17, _2), (FSPIWP, GPIO18, _2), (FSPIHD, GPIO19, _2), (FSPICS0,
5514 GPIO20, _2), (U0RXD, GPIO23, _0), (U0TXD, GPIO24, _0), (MTMS, GPIO28, _0), (MTDI,
5515 GPIO29, _0), (MTCK, GPIO30, _0), (MTDO, GPIO31, _0), (FSPICLK, GPIO32, _2),
5516 (FSPID, GPIO33, _2), (FSPIQ, GPIO36, _2), (FSPIWP, GPIO37, _2), (FSPIHD, GPIO38,
5517 _2), (FSPICS0, GPIO39, _2))); _for_each_inner_iomux_function!((FSPICSn((FSPICS0,
5518 FSPICSn, 0), GPIO20, _2), ((FSPICS0, FSPICSn, 0), GPIO39, _2)));
5519 };
5520}
5521#[macro_export]
5538#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5539macro_rules! gpio_for_signal {
5540 (ZCD0 $(, $_fallback:literal)?) => {
5541 "GPIO0"
5542 };
5543 (LP_GPIO0 $(, $_fallback:literal)?) => {
5544 "GPIO0"
5545 };
5546 (ZCD1 $(, $_fallback:literal)?) => {
5547 "GPIO1"
5548 };
5549 (LP_GPIO1 $(, $_fallback:literal)?) => {
5550 "GPIO1"
5551 };
5552 (ZCD2 $(, $_fallback:literal)?) => {
5553 "GPIO2"
5554 };
5555 (LP_GPIO2 $(, $_fallback:literal)?) => {
5556 "GPIO2"
5557 };
5558 (ZCD3 $(, $_fallback:literal)?) => {
5559 "GPIO3"
5560 };
5561 (LP_GPIO3 $(, $_fallback:literal)?) => {
5562 "GPIO3"
5563 };
5564 (XTAL_32K_N $(, $_fallback:literal)?) => {
5565 "GPIO4"
5566 };
5567 (LP_GPIO4 $(, $_fallback:literal)?) => {
5568 "GPIO4"
5569 };
5570 (XTAL_32K_P $(, $_fallback:literal)?) => {
5571 "GPIO5"
5572 };
5573 (LP_GPIO5 $(, $_fallback:literal)?) => {
5574 "GPIO5"
5575 };
5576 (USJ_DM $(, $_fallback:literal)?) => {
5577 "GPIO13"
5578 };
5579 (USJ_DP $(, $_fallback:literal)?) => {
5580 "GPIO14"
5581 };
5582 (FSPIQ $(, $_fallback:literal)?) => {
5583 "GPIO15"
5584 };
5585 (FSPICLK $(, $_fallback:literal)?) => {
5586 "GPIO16"
5587 };
5588 (FSPID $(, $_fallback:literal)?) => {
5589 "GPIO17"
5590 };
5591 (FSPIWP $(, $_fallback:literal)?) => {
5592 "GPIO18"
5593 };
5594 (FSPIHD $(, $_fallback:literal)?) => {
5595 "GPIO19"
5596 };
5597 (FSPICS0 $(, $_fallback:literal)?) => {
5598 "GPIO20"
5599 };
5600 (USB_FS_DM $(, $_fallback:literal)?) => {
5601 "GPIO21"
5602 };
5603 (USB_FS_DP $(, $_fallback:literal)?) => {
5604 "GPIO22"
5605 };
5606 (U0RXD $(, $_fallback:literal)?) => {
5607 "GPIO23"
5608 };
5609 (U0TXD $(, $_fallback:literal)?) => {
5610 "GPIO24"
5611 };
5612 (MTMS $(, $_fallback:literal)?) => {
5613 "GPIO28"
5614 };
5615 (ADC1_CH0 $(, $_fallback:literal)?) => {
5616 "GPIO28"
5617 };
5618 (MTDI $(, $_fallback:literal)?) => {
5619 "GPIO29"
5620 };
5621 (ADC1_CH1 $(, $_fallback:literal)?) => {
5622 "GPIO29"
5623 };
5624 (MTCK $(, $_fallback:literal)?) => {
5625 "GPIO30"
5626 };
5627 (ADC1_CH2 $(, $_fallback:literal)?) => {
5628 "GPIO30"
5629 };
5630 (MTDO $(, $_fallback:literal)?) => {
5631 "GPIO31"
5632 };
5633 (ADC1_CH3 $(, $_fallback:literal)?) => {
5634 "GPIO31"
5635 };
5636 (ADC1_CH4 $(, $_fallback:literal)?) => {
5637 "GPIO32"
5638 };
5639 ($_signal:ident, $fallback:literal) => {
5640 $fallback
5641 };
5642}
5643#[macro_export]
5647#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5648macro_rules! define_io_mux_signals {
5649 () => {
5650 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5651 #[derive(Debug, PartialEq, Copy, Clone)]
5652 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5653 #[doc(hidden)]
5654 pub enum InputSignal {
5655 EXT_ADC_START = 0,
5656 U0RXD = 8,
5657 U0CTS = 9,
5658 U0DSR = 10,
5659 U1RXD = 11,
5660 U1CTS = 12,
5661 U1DSR = 13,
5662 I2S_MCLK = 14,
5663 I2SO_BCK = 15,
5664 I2SO_WS = 16,
5665 I2SI_SD = 17,
5666 I2SI_BCK = 18,
5667 I2SI_WS = 19,
5668 CPU_GPIO_0 = 29,
5669 CPU_GPIO_1 = 30,
5670 CPU_GPIO_2 = 31,
5671 CPU_GPIO_3 = 32,
5672 CPU_GPIO_4 = 33,
5673 CPU_GPIO_5 = 34,
5674 CPU_GPIO_6 = 35,
5675 CPU_GPIO_7 = 36,
5676 USB_JTAG_TDO_BRIDGE = 37,
5677 USB_FS_IDDIG = 43,
5678 USB_FS_AVALID = 44,
5679 USB_FS_SRP_BVALID = 45,
5680 USB_FS_VBUSVALID = 46,
5681 USB_FS_SRP_SESSEND = 47,
5682 I2CEXT0_SCL = 49,
5683 I2CEXT0_SDA = 50,
5684 PARL_RX_DATA0 = 51,
5685 PARL_RX_DATA1 = 52,
5686 PARL_RX_DATA2 = 53,
5687 PARL_RX_DATA3 = 54,
5688 PARL_RX_DATA4 = 55,
5689 PARL_RX_DATA5 = 56,
5690 PARL_RX_DATA6 = 57,
5691 PARL_RX_DATA7 = 58,
5692 FSPICLK = 59,
5693 FSPIQ = 60,
5694 FSPID = 61,
5695 FSPIHD = 62,
5696 FSPIWP = 63,
5697 FSPICS0 = 64,
5698 PARL_RX_CLK = 65,
5699 PARL_TX_CLK = 66,
5700 RMT_SIG_0 = 67,
5701 RMT_SIG_1 = 68,
5702 TWAI0_RX = 69,
5703 PCNT0_RST = 77,
5704 PCNT1_RST = 78,
5705 PCNT2_RST = 79,
5706 PCNT3_RST = 80,
5707 PWM0_SYNC0 = 81,
5708 PWM0_SYNC1 = 82,
5709 PWM0_SYNC2 = 83,
5710 PWM0_F0 = 84,
5711 PWM0_F1 = 85,
5712 PWM0_F2 = 86,
5713 PWM0_CAP0 = 87,
5714 PWM0_CAP1 = 88,
5715 PWM0_CAP2 = 89,
5716 SIG_IN_FUNC97 = 97,
5717 SIG_IN_FUNC98 = 98,
5718 SIG_IN_FUNC99 = 99,
5719 SIG_IN_FUNC100 = 100,
5720 PCNT0_SIG_CH0 = 102,
5721 PCNT0_SIG_CH1 = 103,
5722 PCNT0_CTRL_CH0 = 104,
5723 PCNT0_CTRL_CH1 = 105,
5724 PCNT1_SIG_CH0 = 106,
5725 PCNT1_SIG_CH1 = 107,
5726 PCNT1_CTRL_CH0 = 108,
5727 PCNT1_CTRL_CH1 = 109,
5728 PCNT2_SIG_CH0 = 110,
5729 PCNT2_SIG_CH1 = 111,
5730 PCNT2_CTRL_CH0 = 112,
5731 PCNT2_CTRL_CH1 = 113,
5732 PCNT3_SIG_CH0 = 114,
5733 PCNT3_SIG_CH1 = 115,
5734 PCNT3_CTRL_CH0 = 116,
5735 PCNT3_CTRL_CH1 = 117,
5736 PWM1_SYNC0 = 155,
5737 PWM1_SYNC1 = 156,
5738 PWM1_SYNC2 = 157,
5739 PWM1_F0 = 158,
5740 PWM1_F1 = 159,
5741 PWM1_F2 = 160,
5742 PWM1_CAP0 = 161,
5743 PWM1_CAP1 = 162,
5744 PWM1_CAP2 = 163,
5745 I2CEXT1_SCL = 164,
5746 I2CEXT1_SDA = 165,
5747 FSPI3CLK = 166,
5748 FSPI3Q = 167,
5749 FSPI3D = 168,
5750 FSPI3HD = 169,
5751 FSPI3WP = 170,
5752 FSPI3CS0 = 171,
5753 CPU_GPIO_8 = 182,
5754 CPU_GPIO_9 = 183,
5755 CPU_GPIO_10 = 184,
5756 CPU_GPIO_11 = 185,
5757 CPU_GPIO_12 = 186,
5758 CPU_GPIO_13 = 187,
5759 CPU_GPIO_14 = 188,
5760 CPU_GPIO_15 = 189,
5761 MTDI,
5762 MTCK,
5763 MTMS,
5764 }
5765 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5766 #[derive(Debug, PartialEq, Copy, Clone)]
5767 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5768 #[doc(hidden)]
5769 pub enum OutputSignal {
5770 LEDC_LS_SIG0 = 0,
5771 LEDC_LS_SIG1 = 1,
5772 LEDC_LS_SIG2 = 2,
5773 LEDC_LS_SIG3 = 3,
5774 LEDC_LS_SIG4 = 4,
5775 LEDC_LS_SIG5 = 5,
5776 LEDC_LS_SIG6 = 6,
5777 LEDC_LS_SIG7 = 7,
5778 U0TXD = 8,
5779 U0RTS = 9,
5780 U0DTR = 10,
5781 U1TXD = 11,
5782 U1RTS = 12,
5783 U1DTR = 13,
5784 I2S_MCLK = 14,
5785 I2SO_BCK = 15,
5786 I2SO_WS = 16,
5787 I2SO_SD = 17,
5788 I2SI_BCK = 18,
5789 I2SI_WS = 19,
5790 I2SO_SD1 = 20,
5791 CPU_GPIO_0 = 29,
5792 CPU_GPIO_1 = 30,
5793 CPU_GPIO_2 = 31,
5794 CPU_GPIO_3 = 32,
5795 CPU_GPIO_4 = 33,
5796 CPU_GPIO_5 = 34,
5797 CPU_GPIO_6 = 35,
5798 CPU_GPIO_7 = 36,
5799 USB_JTAG_TRST = 37,
5800 USB_SRP_DISCHRGVBUS = 43,
5801 USB_OTG_IDPULLUP = 44,
5802 USB_OTG_DPPULLDOWN = 45,
5803 USB_OTG_DMPULLDOWN = 46,
5804 USB_OTG_DRVVBUS = 47,
5805 USB_SRP_CHRGVBUS = 48,
5806 I2CEXT0_SCL = 49,
5807 I2CEXT0_SDA = 50,
5808 PARL_TX_DATA0 = 51,
5809 PARL_TX_DATA1 = 52,
5810 PARL_TX_DATA2 = 53,
5811 PARL_TX_DATA3 = 54,
5812 PARL_TX_DATA4 = 55,
5813 PARL_TX_DATA5 = 56,
5814 PARL_TX_DATA6 = 57,
5815 PARL_TX_DATA7 = 58,
5816 FSPICLK = 59,
5817 FSPIQ = 60,
5818 FSPID = 61,
5819 FSPIHD = 62,
5820 FSPIWP = 63,
5821 FSPICS0 = 64,
5822 PARL_RX_CLK = 65,
5823 PARL_TX_CLK = 66,
5824 RMT_SIG_0 = 67,
5825 RMT_SIG_1 = 68,
5826 TWAI0_TX = 69,
5827 PARL_TX_CS = 70,
5828 GPIO_SD0 = 77,
5829 GPIO_SD1 = 78,
5830 GPIO_SD2 = 79,
5831 GPIO_SD3 = 80,
5832 PWM0_0A = 81,
5833 PWM0_0B = 82,
5834 PWM0_1A = 83,
5835 PWM0_1B = 84,
5836 PWM0_2A = 85,
5837 PWM0_2B = 86,
5838 CLK_OUT_OUT1 = 94,
5839 CLK_OUT_OUT2 = 95,
5840 CLK_OUT_OUT3 = 96,
5841 SIG_IN_FUNC97 = 97,
5842 SIG_IN_FUNC98 = 98,
5843 SIG_IN_FUNC99 = 99,
5844 SIG_IN_FUNC100 = 100,
5845 FSPICS1 = 102,
5846 FSPICS2 = 103,
5847 FSPICS3 = 104,
5848 FSPICS4 = 105,
5849 FSPICS5 = 106,
5850 ANT_SEL0 = 139,
5851 ANT_SEL1 = 140,
5852 ANT_SEL2 = 141,
5853 ANT_SEL3 = 142,
5854 ANT_SEL4 = 143,
5855 ANT_SEL5 = 144,
5856 ANT_SEL6 = 145,
5857 ANT_SEL7 = 146,
5858 ANT_SEL8 = 147,
5859 ANT_SEL9 = 148,
5860 ANT_SEL10 = 149,
5861 ANT_SEL11 = 150,
5862 ANT_SEL12 = 151,
5863 ANT_SEL13 = 152,
5864 ANT_SEL14 = 153,
5865 ANT_SEL15 = 154,
5866 PWM1_0A = 155,
5867 PWM1_0B = 156,
5868 PWM1_1A = 157,
5869 PWM1_1B = 158,
5870 PWM1_2A = 159,
5871 PWM1_2B = 160,
5872 I2CEXT1_SCL = 164,
5873 I2CEXT1_SDA = 165,
5874 FSPI3CLK = 166,
5875 FSPI3Q = 167,
5876 FSPI3D = 168,
5877 FSPI3HD = 169,
5878 FSPI3WP = 170,
5879 FSPI3CS0 = 171,
5880 FSPI3CS1 = 172,
5881 FSPI3CS2 = 173,
5882 CPU_GPIO_8 = 182,
5883 CPU_GPIO_9 = 183,
5884 CPU_GPIO_10 = 184,
5885 CPU_GPIO_11 = 185,
5886 CPU_GPIO_12 = 186,
5887 CPU_GPIO_13 = 187,
5888 CPU_GPIO_14 = 188,
5889 CPU_GPIO_15 = 189,
5890 GPIO = 256,
5891 MTDO,
5892 }
5893 };
5894}
5895#[macro_export]
5902#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5903macro_rules! define_lp_functions {
5904 () => {
5905 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5910 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5911 #[doc(hidden)]
5912 pub enum LpFunction {
5913 _1 = 1,
5915 }
5916 impl LpFunction {
5917 pub const LP_GPIO: Self = Self::_1;
5919 }
5920 };
5921}
5922#[macro_export]
5935#[expect(clippy::crate_in_macro_def)]
5936#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5937macro_rules! define_io_mux_reg {
5938 () => {
5939 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
5940 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
5941 }
5942 };
5943}