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 "esp32s2"
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-S2"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32s2"
42 };
43 ("arch") => {
44 "xtensa"
45 };
46 ("cores") => {
47 1
48 };
49 ("cores", str) => {
50 stringify!(1)
51 };
52 ("trm") => {
53 "https://www.espressif.com/sites/default/files/documentation/esp32-s2_technical_reference_manual_en.pdf"
54 };
55 ("gpio.version") => {
56 2
57 };
58 ("gpio.version", str) => {
59 stringify!(2)
60 };
61 ("gpio.has_input_sync") => {
62 true
63 };
64 ("gpio.gpio_function") => {
65 1
66 };
67 ("gpio.gpio_function", str) => {
68 stringify!(1)
69 };
70 ("gpio.constant_0_input") => {
71 60
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(60)
75 };
76 ("gpio.constant_1_input") => {
77 56
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(56)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 false
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.need_soft_isolate_during_pd") => {
92 false
93 };
94 ("gpio.has_bank_1") => {
95 true
96 };
97 ("gpio.input_signal_max") => {
98 242
99 };
100 ("gpio.input_signal_max", str) => {
101 stringify!(242)
102 };
103 ("gpio.output_signal_max") => {
104 256
105 };
106 ("gpio.output_signal_max", str) => {
107 stringify!(256)
108 };
109 ("dedicated_gpio.version") => {
110 "esp32s2"
111 };
112 ("dedicated_gpio.needs_initialization") => {
113 true
114 };
115 ("dedicated_gpio.channel_count") => {
116 8
117 };
118 ("dedicated_gpio.channel_count", str) => {
119 stringify!(8)
120 };
121 ("lp_io.version") => {
122 "v2"
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 1
135 };
136 ("uart.version", str) => {
137 stringify!(1)
138 };
139 ("uart.peripheral_controls_mem_clk") => {
140 false
141 };
142 ("uart.has_sclk_divider") => {
143 false
144 };
145 ("uart.has_sclk_enable") => {
146 false
147 };
148 ("i2c_master.version") => {
149 2
150 };
151 ("i2c_master.version", str) => {
152 stringify!(2)
153 };
154 ("i2c_master.has_fsm_timeouts") => {
155 false
156 };
157 ("i2c_master.has_hw_bus_clear") => {
158 false
159 };
160 ("i2c_master.has_bus_timeout_enable") => {
161 true
162 };
163 ("i2c_master.separate_filter_config_registers") => {
164 true
165 };
166 ("i2c_master.can_estimate_nack_reason") => {
167 false
168 };
169 ("i2c_master.has_conf_update") => {
170 false
171 };
172 ("i2c_master.has_reliable_fsm_reset") => {
173 false
174 };
175 ("i2c_master.has_arbitration_en") => {
176 true
177 };
178 ("i2c_master.has_tx_fifo_watermark") => {
179 false
180 };
181 ("i2c_master.bus_timeout_is_exponential") => {
182 false
183 };
184 ("i2c_master.has_pd_en") => {
185 true
186 };
187 ("i2c_master.i2c0_data_register_ahb_address") => {
188 1610690588
189 };
190 ("i2c_master.i2c0_data_register_ahb_address", str) => {
191 stringify!(1610690588)
192 };
193 ("i2c_master.max_bus_timeout") => {
194 16777215
195 };
196 ("i2c_master.max_bus_timeout", str) => {
197 stringify!(16777215)
198 };
199 ("i2c_master.ll_intr_mask") => {
200 131071
201 };
202 ("i2c_master.ll_intr_mask", str) => {
203 stringify!(131071)
204 };
205 ("i2c_master.fifo_size") => {
206 32
207 };
208 ("i2c_master.fifo_size", str) => {
209 stringify!(32)
210 };
211 ("spi_master.version") => {
212 2
213 };
214 ("spi_master.version", str) => {
215 stringify!(2)
216 };
217 ("spi_master.fifo_size") => {
218 72
219 };
220 ("spi_master.fifo_size", str) => {
221 stringify!(72)
222 };
223 ("spi_master.bit_order_is_bool") => {
224 true
225 };
226 ("spi_master.has_octal") => {
227 true
228 };
229 ("spi_master.has_app_interrupts") => {
230 false
231 };
232 ("spi_master.has_dma_segmented_transfer") => {
233 true
234 };
235 ("spi_master.has_clk_pre_div") => {
236 false
237 };
238 ("spi_master.dma_can_access_flash") => {
239 false
240 };
241 ("i2s.version") => {
242 1
243 };
244 ("i2s.version", str) => {
245 stringify!(1)
246 };
247 ("i2s.mclk_divider_bit_width") => {
248 6
249 };
250 ("i2s.mclk_divider_bit_width", str) => {
251 stringify!(6)
252 };
253 ("i2s.max_ws_width") => {
254 128
255 };
256 ("i2s.max_ws_width", str) => {
257 stringify!(128)
258 };
259 ("i2s.clock_configured_by_pcr") => {
260 false
261 };
262 ("i2s.clock_configured_by_hp_sys_clkrst") => {
263 false
264 };
265 ("i2s.supports_pdm_rx_hp_filter") => {
266 false
267 };
268 ("i2s.supports_pdm_tx") => {
269 false
270 };
271 ("i2s.supports_pdm_rx") => {
272 false
273 };
274 ("i2s.supports_pcm2pdm") => {
275 false
276 };
277 ("i2s.supports_pdm2pcm") => {
278 false
279 };
280 ("rmt.ram_start") => {
281 1061250048
282 };
283 ("rmt.ram_start", str) => {
284 stringify!(1061250048)
285 };
286 ("rmt.channel_ram_size") => {
287 64
288 };
289 ("rmt.channel_ram_size", str) => {
290 stringify!(64)
291 };
292 ("rmt.has_tx_immediate_stop") => {
293 true
294 };
295 ("rmt.has_tx_loop_count") => {
296 true
297 };
298 ("rmt.has_tx_loop_auto_stop") => {
299 false
300 };
301 ("rmt.has_tx_carrier_data_only") => {
302 true
303 };
304 ("rmt.has_tx_sync") => {
305 true
306 };
307 ("rmt.has_rx_wrap") => {
308 false
309 };
310 ("rmt.has_rx_demodulation") => {
311 true
312 };
313 ("rmt.has_per_channel_clock") => {
314 true
315 };
316 ("usb_otg.fifo_depth_words") => {
317 256
318 };
319 ("usb_otg.fifo_depth_words", str) => {
320 stringify!(256)
321 };
322 ("wifi.has_wifi6") => {
323 false
324 };
325 ("wifi.mac_version") => {
326 1
327 };
328 ("wifi.mac_version", str) => {
329 stringify!(1)
330 };
331 ("wifi.has_5g") => {
332 false
333 };
334 ("wifi.csi_supported") => {
335 true
336 };
337 ("wifi.has_nan") => {
338 true
339 };
340 ("wifi.has_ftm") => {
341 true
342 };
343 ("wifi.requires_fast_cpu") => {
344 false
345 };
346 ("phy.combo_module") => {
347 false
348 };
349 ("adc.controller") => {
350 "rtc"
351 };
352 ("adc.line_calibration") => {
353 true
354 };
355 ("adc.curve_calibration") => {
356 false
357 };
358 ("adc.basic_calibration") => {
359 true
360 };
361 ("adc.calibration_v1_scheme_supported") => {
362 true
363 };
364 ("adc.channel_compensation") => {
365 false
366 };
367 ("adc.pcr_clock") => {
368 false
369 };
370 ("adc.pcr_sar_clk_div") => {
371 false
372 };
373 ("adc.sar_power_override") => {
374 false
375 };
376 ("dac.version") => {
377 1
378 };
379 ("dac.version", str) => {
380 stringify!(1)
381 };
382 ("dac.channel_count") => {
383 2
384 };
385 ("dac.channel_count", str) => {
386 stringify!(2)
387 };
388 ("dac.resolution") => {
389 8
390 };
391 ("dac.resolution", str) => {
392 stringify!(8)
393 };
394 ("ledc.version") => {
395 2
396 };
397 ("ledc.version", str) => {
398 stringify!(2)
399 };
400 ("ledc.channel_count") => {
401 8
402 };
403 ("ledc.channel_count", str) => {
404 stringify!(8)
405 };
406 ("sdm.channel_count") => {
407 8
408 };
409 ("sdm.channel_count", str) => {
410 stringify!(8)
411 };
412 ("timergroup.timg_has_timer1") => {
413 true
414 };
415 ("timergroup.timg_has_divcnt_rst") => {
416 false
417 };
418 ("timergroup.wdt_has_conf_update") => {
419 false
420 };
421 ("aes.has_split_text_registers") => {
422 true
423 };
424 ("aes.endianness_configurable") => {
425 true
426 };
427 ("rng.apb_cycle_wait_num") => {
428 16
429 };
430 ("rng.apb_cycle_wait_num", str) => {
431 stringify!(16)
432 };
433 ("rng.trng_supported") => {
434 true
435 };
436 ("rng.is_lp_sys") => {
437 false
438 };
439 ("rsa.version") => {
440 2
441 };
442 ("rsa.version", str) => {
443 stringify!(2)
444 };
445 ("rsa.size_increment") => {
446 32
447 };
448 ("rsa.size_increment", str) => {
449 stringify!(32)
450 };
451 ("rsa.memory_size_bytes") => {
452 512
453 };
454 ("rsa.memory_size_bytes", str) => {
455 stringify!(512)
456 };
457 ("sleep.light_sleep") => {
458 true
459 };
460 ("sleep.deep_sleep") => {
461 true
462 };
463 ("sleep.rejectable_mask") => {
464 10543
465 };
466 ("sleep.ext1_version") => {
467 1
468 };
469 ("sleep.ext1_version", str) => {
470 stringify!(1)
471 };
472 ("sleep.pin_wakeup_version") => {
473 1
474 };
475 ("sleep.pin_wakeup_version", str) => {
476 stringify!(1)
477 };
478 ("sleep.deep_sleep_needs_gpio_isolation") => {
479 true
480 };
481 ("sleep.idle_frequency_scaling") => {
482 false
483 };
484 ("dma.mem2mem_requires_peripheral") => {
485 false
486 };
487 ("dma.ext_mem_configurable_block_size") => {
488 true
489 };
490 ("dma.separate_in_out_interrupts") => {
491 false
492 };
493 ("interrupts.status_registers") => {
494 3
495 };
496 ("interrupts.status_registers", str) => {
497 stringify!(3)
498 };
499 ("mmu.page_size") => {
500 65536
501 };
502 ("mmu.page_size", str) => {
503 stringify!(65536)
504 };
505 ("mmu.entry_num") => {
506 256
507 };
508 ("mmu.entry_num", str) => {
509 stringify!(256)
510 };
511 ("psram.octal_spi") => {
512 false
513 };
514 ("psram.hex_spi") => {
515 false
516 };
517 ("psram.has_timing_tuning") => {
518 false
519 };
520 ("psram.extmem_origin") => {
521 1062207488
522 };
523 ("psram.extmem_origin", str) => {
524 stringify!(1062207488)
525 };
526 ("psram.idle_low_speed_switch") => {
527 false
528 };
529 ("rom.has_crc_le") => {
530 true
531 };
532 ("rom.has_crc_be") => {
533 false
534 };
535 ("rom.has_md5_bsd") => {
536 true
537 };
538 ("rom.has_md5_mbedtls") => {
539 false
540 };
541 ("rom.no_libgcc") => {
542 false
543 };
544 ("soc.cpu_has_branch_predictor") => {
545 false
546 };
547 ("soc.cpu_has_csr_pc") => {
548 false
549 };
550 ("soc.cpu_has_zcmp_workaround") => {
551 false
552 };
553 ("soc.multi_core_enabled") => {
554 false
555 };
556 ("soc.cpu_pma_needs_core1_setup") => {
557 false
558 };
559 ("soc.internal_memory_cached") => {
560 false
561 };
562 ("soc.cpu_powers_down_cache") => {
563 false
564 };
565 ("soc.has_swd_watchdog") => {
566 true
567 };
568 ("soc.has_bus_clock_update") => {
569 false
570 };
571 ("soc.has_apb_frequency_reduction") => {
572 false
573 };
574 ("soc.cpu_mcause_mask") => {
575 0
576 };
577 ("soc.cpu_mcause_mask", str) => {
578 stringify!(0)
579 };
580 ("soc.cpu_pmp_granularity") => {
581 4
582 };
583 ("soc.cpu_pmp_granularity", str) => {
584 stringify!(4)
585 };
586 ("clock_tree.cpu_pll_div_in") => {
587 [crate ::soc::clocks::CpuPllDivInConfig::Pll, crate
588 ::soc::clocks::CpuPllDivInConfig::Apll]
589 };
590 ("clock_tree.cpu_pll_div.divisor") => {
591 [2, 3, 4, 6]
592 };
593 ("clock_tree.system_pre_div_in") => {
594 [crate ::soc::clocks::SystemPreDivInConfig::Xtal, crate
595 ::soc::clocks::SystemPreDivInConfig::RcFast]
596 };
597 ("clock_tree.system_pre_div.divisor") => {
598 (0, 1023)
599 };
600 ("clock_tree.cpu_clk") => {
601 [crate ::soc::clocks::CpuClkConfig::Xtal, crate
602 ::soc::clocks::CpuClkConfig::RcFast, crate ::soc::clocks::CpuClkConfig::Apll,
603 crate ::soc::clocks::CpuClkConfig::Pll]
604 };
605 ("clock_tree.apb_clk") => {
606 [crate ::soc::clocks::ApbClkConfig::Pll, crate ::soc::clocks::ApbClkConfig::Apll,
607 crate ::soc::clocks::ApbClkConfig::Xtal, crate
608 ::soc::clocks::ApbClkConfig::RcFast]
609 };
610 ("clock_tree.ref_tick_xtal.divisor") => {
611 (0, 255)
612 };
613 ("clock_tree.ref_tick_ck8m.divisor") => {
614 (0, 255)
615 };
616 ("clock_tree.ref_tick") => {
617 [crate ::soc::clocks::RefTickConfig::Pll, crate
618 ::soc::clocks::RefTickConfig::Apll, crate ::soc::clocks::RefTickConfig::Xtal,
619 crate ::soc::clocks::RefTickConfig::RcFast]
620 };
621 ("clock_tree.rtc_slow_clk") => {
622 [#[cfg(use_xtal32k)] crate ::soc::clocks::RtcSlowClkConfig::Xtal32k, crate
623 ::soc::clocks::RtcSlowClkConfig::RcSlow, crate
624 ::soc::clocks::RtcSlowClkConfig::RcFast]
625 };
626 ("clock_tree.rtc_fast_clk") => {
627 [crate ::soc::clocks::RtcFastClkConfig::Xtal, crate
628 ::soc::clocks::RtcFastClkConfig::Rc]
629 };
630 ("clock_tree.timg_calibration_clock") => {
631 [crate ::soc::clocks::TimgCalibrationClockConfig::RtcClk, crate
632 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
633 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
634 };
635 ("clock_tree.timg.function_clock") => {
636 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
637 ::soc::clocks::TimgFunctionClockConfig::ApbClk]
638 };
639 ("clock_tree.uart.function_clock.sclk") => {
640 [crate ::soc::clocks::UartFunctionClockSclk::Apb, crate
641 ::soc::clocks::UartFunctionClockSclk::RefTick]
642 };
643 ("clock_tree.uart.baud_rate_generator.fractional") => {
644 (0, 15)
645 };
646 ("clock_tree.uart.baud_rate_generator.integral") => {
647 (0, 1048575)
648 };
649 ("clock_tree.rmt.sclk") => {
650 [crate ::soc::clocks::RmtSclkConfig::RefTick, crate
651 ::soc::clocks::RmtSclkConfig::ApbClk]
652 };
653 ("clock_tree.i2c.function_clock.sclk") => {
654 [crate ::soc::clocks::I2cFunctionClockSclk::Apb, crate
655 ::soc::clocks::I2cFunctionClockSclk::RefTick]
656 };
657 ("clock_tree.i2s.mclk.sclk") => {
658 [crate ::soc::clocks::I2sMclkSclk::PllF160m, crate
659 ::soc::clocks::I2sMclkSclk::Apll]
660 };
661 ("clock_tree.i2s.mclk.div_num") => {
662 (1, 255)
663 };
664 ("clock_tree.i2s.mclk.div_a") => {
665 (1, 63)
666 };
667 ("clock_tree.i2s.mclk.div_b") => {
668 (0, 63)
669 };
670}
671#[macro_export]
672#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
673macro_rules! for_each_dedicated_gpio {
674 ($($pattern:tt => $code:tt;)*) => {
675 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
676 tt) => {} } _for_each_inner_dedicated_gpio!((0));
677 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
678 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
679 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
680 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
681 PRO_ALONEGPIO0)); _for_each_inner_dedicated_gpio!((0, 1, PRO_ALONEGPIO1));
682 _for_each_inner_dedicated_gpio!((0, 2, PRO_ALONEGPIO2));
683 _for_each_inner_dedicated_gpio!((0, 3, PRO_ALONEGPIO3));
684 _for_each_inner_dedicated_gpio!((0, 4, PRO_ALONEGPIO4));
685 _for_each_inner_dedicated_gpio!((0, 5, PRO_ALONEGPIO5));
686 _for_each_inner_dedicated_gpio!((0, 6, PRO_ALONEGPIO6));
687 _for_each_inner_dedicated_gpio!((0, 7, PRO_ALONEGPIO7));
688 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
689 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, PRO_ALONEGPIO0), (0, 1,
690 PRO_ALONEGPIO1), (0, 2, PRO_ALONEGPIO2), (0, 3, PRO_ALONEGPIO3), (0, 4,
691 PRO_ALONEGPIO4), (0, 5, PRO_ALONEGPIO5), (0, 6, PRO_ALONEGPIO6), (0, 7,
692 PRO_ALONEGPIO7)));
693 };
694}
695#[macro_export]
699#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
700macro_rules! define_lp_io_signals {
701 () => {};
702}
703#[macro_export]
725#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
726macro_rules! for_each_rmt_channel {
727 ($($pattern:tt => $code:tt;)*) => {
728 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
729 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
730 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
731 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
732 _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
733 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
734 _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
735 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
736 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1), (2, 2), (3, 3)));
737 _for_each_inner_rmt_channel!((rx(0, 0), (1, 1), (2, 2), (3, 3)));
738 };
739}
740#[macro_export]
741#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
742macro_rules! for_each_sdm_channel {
743 ($($pattern:tt => $code:tt;)*) => {
744 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
745 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
746 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
747 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
748 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
749 _for_each_inner_sdm_channel!((4, SDM_CH4, SdmCh4, GPIO_SD4));
750 _for_each_inner_sdm_channel!((5, SDM_CH5, SdmCh5, GPIO_SD5));
751 _for_each_inner_sdm_channel!((6, SDM_CH6, SdmCh6, GPIO_SD6));
752 _for_each_inner_sdm_channel!((7, SDM_CH7, SdmCh7, GPIO_SD7));
753 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
754 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
755 GPIO_SD3), (4, SDM_CH4, SdmCh4, GPIO_SD4), (5, SDM_CH5, SdmCh5, GPIO_SD5), (6,
756 SDM_CH6, SdmCh6, GPIO_SD6), (7, SDM_CH7, SdmCh7, GPIO_SD7)));
757 };
758}
759#[macro_export]
760#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
761macro_rules! for_each_aes_key_length {
762 ($($pattern:tt => $code:tt;)*) => {
763 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
764 tt) => {} } _for_each_inner_aes_key_length!((128));
765 _for_each_inner_aes_key_length!((192)); _for_each_inner_aes_key_length!((256));
766 _for_each_inner_aes_key_length!((128, 0, 4));
767 _for_each_inner_aes_key_length!((192, 1, 5));
768 _for_each_inner_aes_key_length!((256, 2, 6));
769 _for_each_inner_aes_key_length!((bits(128), (192), (256)));
770 _for_each_inner_aes_key_length!((modes(128, 0, 4), (192, 1, 5), (256, 2, 6)));
771 };
772}
773#[macro_export]
774#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
775macro_rules! for_each_rsa_exponentiation {
776 ($($pattern:tt => $code:tt;)*) => {
777 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
778 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
779 _for_each_inner_rsa_exponentiation!((64));
780 _for_each_inner_rsa_exponentiation!((96));
781 _for_each_inner_rsa_exponentiation!((128));
782 _for_each_inner_rsa_exponentiation!((160));
783 _for_each_inner_rsa_exponentiation!((192));
784 _for_each_inner_rsa_exponentiation!((224));
785 _for_each_inner_rsa_exponentiation!((256));
786 _for_each_inner_rsa_exponentiation!((288));
787 _for_each_inner_rsa_exponentiation!((320));
788 _for_each_inner_rsa_exponentiation!((352));
789 _for_each_inner_rsa_exponentiation!((384));
790 _for_each_inner_rsa_exponentiation!((416));
791 _for_each_inner_rsa_exponentiation!((448));
792 _for_each_inner_rsa_exponentiation!((480));
793 _for_each_inner_rsa_exponentiation!((512));
794 _for_each_inner_rsa_exponentiation!((544));
795 _for_each_inner_rsa_exponentiation!((576));
796 _for_each_inner_rsa_exponentiation!((608));
797 _for_each_inner_rsa_exponentiation!((640));
798 _for_each_inner_rsa_exponentiation!((672));
799 _for_each_inner_rsa_exponentiation!((704));
800 _for_each_inner_rsa_exponentiation!((736));
801 _for_each_inner_rsa_exponentiation!((768));
802 _for_each_inner_rsa_exponentiation!((800));
803 _for_each_inner_rsa_exponentiation!((832));
804 _for_each_inner_rsa_exponentiation!((864));
805 _for_each_inner_rsa_exponentiation!((896));
806 _for_each_inner_rsa_exponentiation!((928));
807 _for_each_inner_rsa_exponentiation!((960));
808 _for_each_inner_rsa_exponentiation!((992));
809 _for_each_inner_rsa_exponentiation!((1024));
810 _for_each_inner_rsa_exponentiation!((1056));
811 _for_each_inner_rsa_exponentiation!((1088));
812 _for_each_inner_rsa_exponentiation!((1120));
813 _for_each_inner_rsa_exponentiation!((1152));
814 _for_each_inner_rsa_exponentiation!((1184));
815 _for_each_inner_rsa_exponentiation!((1216));
816 _for_each_inner_rsa_exponentiation!((1248));
817 _for_each_inner_rsa_exponentiation!((1280));
818 _for_each_inner_rsa_exponentiation!((1312));
819 _for_each_inner_rsa_exponentiation!((1344));
820 _for_each_inner_rsa_exponentiation!((1376));
821 _for_each_inner_rsa_exponentiation!((1408));
822 _for_each_inner_rsa_exponentiation!((1440));
823 _for_each_inner_rsa_exponentiation!((1472));
824 _for_each_inner_rsa_exponentiation!((1504));
825 _for_each_inner_rsa_exponentiation!((1536));
826 _for_each_inner_rsa_exponentiation!((1568));
827 _for_each_inner_rsa_exponentiation!((1600));
828 _for_each_inner_rsa_exponentiation!((1632));
829 _for_each_inner_rsa_exponentiation!((1664));
830 _for_each_inner_rsa_exponentiation!((1696));
831 _for_each_inner_rsa_exponentiation!((1728));
832 _for_each_inner_rsa_exponentiation!((1760));
833 _for_each_inner_rsa_exponentiation!((1792));
834 _for_each_inner_rsa_exponentiation!((1824));
835 _for_each_inner_rsa_exponentiation!((1856));
836 _for_each_inner_rsa_exponentiation!((1888));
837 _for_each_inner_rsa_exponentiation!((1920));
838 _for_each_inner_rsa_exponentiation!((1952));
839 _for_each_inner_rsa_exponentiation!((1984));
840 _for_each_inner_rsa_exponentiation!((2016));
841 _for_each_inner_rsa_exponentiation!((2048));
842 _for_each_inner_rsa_exponentiation!((2080));
843 _for_each_inner_rsa_exponentiation!((2112));
844 _for_each_inner_rsa_exponentiation!((2144));
845 _for_each_inner_rsa_exponentiation!((2176));
846 _for_each_inner_rsa_exponentiation!((2208));
847 _for_each_inner_rsa_exponentiation!((2240));
848 _for_each_inner_rsa_exponentiation!((2272));
849 _for_each_inner_rsa_exponentiation!((2304));
850 _for_each_inner_rsa_exponentiation!((2336));
851 _for_each_inner_rsa_exponentiation!((2368));
852 _for_each_inner_rsa_exponentiation!((2400));
853 _for_each_inner_rsa_exponentiation!((2432));
854 _for_each_inner_rsa_exponentiation!((2464));
855 _for_each_inner_rsa_exponentiation!((2496));
856 _for_each_inner_rsa_exponentiation!((2528));
857 _for_each_inner_rsa_exponentiation!((2560));
858 _for_each_inner_rsa_exponentiation!((2592));
859 _for_each_inner_rsa_exponentiation!((2624));
860 _for_each_inner_rsa_exponentiation!((2656));
861 _for_each_inner_rsa_exponentiation!((2688));
862 _for_each_inner_rsa_exponentiation!((2720));
863 _for_each_inner_rsa_exponentiation!((2752));
864 _for_each_inner_rsa_exponentiation!((2784));
865 _for_each_inner_rsa_exponentiation!((2816));
866 _for_each_inner_rsa_exponentiation!((2848));
867 _for_each_inner_rsa_exponentiation!((2880));
868 _for_each_inner_rsa_exponentiation!((2912));
869 _for_each_inner_rsa_exponentiation!((2944));
870 _for_each_inner_rsa_exponentiation!((2976));
871 _for_each_inner_rsa_exponentiation!((3008));
872 _for_each_inner_rsa_exponentiation!((3040));
873 _for_each_inner_rsa_exponentiation!((3072));
874 _for_each_inner_rsa_exponentiation!((3104));
875 _for_each_inner_rsa_exponentiation!((3136));
876 _for_each_inner_rsa_exponentiation!((3168));
877 _for_each_inner_rsa_exponentiation!((3200));
878 _for_each_inner_rsa_exponentiation!((3232));
879 _for_each_inner_rsa_exponentiation!((3264));
880 _for_each_inner_rsa_exponentiation!((3296));
881 _for_each_inner_rsa_exponentiation!((3328));
882 _for_each_inner_rsa_exponentiation!((3360));
883 _for_each_inner_rsa_exponentiation!((3392));
884 _for_each_inner_rsa_exponentiation!((3424));
885 _for_each_inner_rsa_exponentiation!((3456));
886 _for_each_inner_rsa_exponentiation!((3488));
887 _for_each_inner_rsa_exponentiation!((3520));
888 _for_each_inner_rsa_exponentiation!((3552));
889 _for_each_inner_rsa_exponentiation!((3584));
890 _for_each_inner_rsa_exponentiation!((3616));
891 _for_each_inner_rsa_exponentiation!((3648));
892 _for_each_inner_rsa_exponentiation!((3680));
893 _for_each_inner_rsa_exponentiation!((3712));
894 _for_each_inner_rsa_exponentiation!((3744));
895 _for_each_inner_rsa_exponentiation!((3776));
896 _for_each_inner_rsa_exponentiation!((3808));
897 _for_each_inner_rsa_exponentiation!((3840));
898 _for_each_inner_rsa_exponentiation!((3872));
899 _for_each_inner_rsa_exponentiation!((3904));
900 _for_each_inner_rsa_exponentiation!((3936));
901 _for_each_inner_rsa_exponentiation!((3968));
902 _for_each_inner_rsa_exponentiation!((4000));
903 _for_each_inner_rsa_exponentiation!((4032));
904 _for_each_inner_rsa_exponentiation!((4064));
905 _for_each_inner_rsa_exponentiation!((4096));
906 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
907 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
908 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
909 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
910 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
911 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
912 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
913 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
914 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
915 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072), (3104), (3136),
916 (3168), (3200), (3232), (3264), (3296), (3328), (3360), (3392), (3424), (3456),
917 (3488), (3520), (3552), (3584), (3616), (3648), (3680), (3712), (3744), (3776),
918 (3808), (3840), (3872), (3904), (3936), (3968), (4000), (4032), (4064), (4096)));
919 };
920}
921#[macro_export]
922#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
923macro_rules! for_each_rsa_multiplication {
924 ($($pattern:tt => $code:tt;)*) => {
925 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
926 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
927 _for_each_inner_rsa_multiplication!((64));
928 _for_each_inner_rsa_multiplication!((96));
929 _for_each_inner_rsa_multiplication!((128));
930 _for_each_inner_rsa_multiplication!((160));
931 _for_each_inner_rsa_multiplication!((192));
932 _for_each_inner_rsa_multiplication!((224));
933 _for_each_inner_rsa_multiplication!((256));
934 _for_each_inner_rsa_multiplication!((288));
935 _for_each_inner_rsa_multiplication!((320));
936 _for_each_inner_rsa_multiplication!((352));
937 _for_each_inner_rsa_multiplication!((384));
938 _for_each_inner_rsa_multiplication!((416));
939 _for_each_inner_rsa_multiplication!((448));
940 _for_each_inner_rsa_multiplication!((480));
941 _for_each_inner_rsa_multiplication!((512));
942 _for_each_inner_rsa_multiplication!((544));
943 _for_each_inner_rsa_multiplication!((576));
944 _for_each_inner_rsa_multiplication!((608));
945 _for_each_inner_rsa_multiplication!((640));
946 _for_each_inner_rsa_multiplication!((672));
947 _for_each_inner_rsa_multiplication!((704));
948 _for_each_inner_rsa_multiplication!((736));
949 _for_each_inner_rsa_multiplication!((768));
950 _for_each_inner_rsa_multiplication!((800));
951 _for_each_inner_rsa_multiplication!((832));
952 _for_each_inner_rsa_multiplication!((864));
953 _for_each_inner_rsa_multiplication!((896));
954 _for_each_inner_rsa_multiplication!((928));
955 _for_each_inner_rsa_multiplication!((960));
956 _for_each_inner_rsa_multiplication!((992));
957 _for_each_inner_rsa_multiplication!((1024));
958 _for_each_inner_rsa_multiplication!((1056));
959 _for_each_inner_rsa_multiplication!((1088));
960 _for_each_inner_rsa_multiplication!((1120));
961 _for_each_inner_rsa_multiplication!((1152));
962 _for_each_inner_rsa_multiplication!((1184));
963 _for_each_inner_rsa_multiplication!((1216));
964 _for_each_inner_rsa_multiplication!((1248));
965 _for_each_inner_rsa_multiplication!((1280));
966 _for_each_inner_rsa_multiplication!((1312));
967 _for_each_inner_rsa_multiplication!((1344));
968 _for_each_inner_rsa_multiplication!((1376));
969 _for_each_inner_rsa_multiplication!((1408));
970 _for_each_inner_rsa_multiplication!((1440));
971 _for_each_inner_rsa_multiplication!((1472));
972 _for_each_inner_rsa_multiplication!((1504));
973 _for_each_inner_rsa_multiplication!((1536));
974 _for_each_inner_rsa_multiplication!((1568));
975 _for_each_inner_rsa_multiplication!((1600));
976 _for_each_inner_rsa_multiplication!((1632));
977 _for_each_inner_rsa_multiplication!((1664));
978 _for_each_inner_rsa_multiplication!((1696));
979 _for_each_inner_rsa_multiplication!((1728));
980 _for_each_inner_rsa_multiplication!((1760));
981 _for_each_inner_rsa_multiplication!((1792));
982 _for_each_inner_rsa_multiplication!((1824));
983 _for_each_inner_rsa_multiplication!((1856));
984 _for_each_inner_rsa_multiplication!((1888));
985 _for_each_inner_rsa_multiplication!((1920));
986 _for_each_inner_rsa_multiplication!((1952));
987 _for_each_inner_rsa_multiplication!((1984));
988 _for_each_inner_rsa_multiplication!((2016));
989 _for_each_inner_rsa_multiplication!((2048));
990 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
991 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
992 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
993 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
994 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
995 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
996 (1888), (1920), (1952), (1984), (2016), (2048)));
997 };
998}
999#[macro_export]
1000#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1001macro_rules! for_each_sha_algorithm {
1002 ($($pattern:tt => $code:tt;)*) => {
1003 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
1004 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
1005 (insecure_against : "collision", "length extension"), 0));
1006 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
1007 (insecure_against : "length extension"), 1));
1008 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
1009 (insecure_against : "length extension"), 2));
1010 _for_each_inner_sha_algorithm!((Sha384, "SHA-384"(sizes : 128, 48, 16)
1011 (insecure_against :), 3)); _for_each_inner_sha_algorithm!((Sha512,
1012 "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 4));
1013 _for_each_inner_sha_algorithm!((Sha512_224, "SHA-512/224"(sizes : 128, 28, 16)
1014 (insecure_against :), 5)); _for_each_inner_sha_algorithm!((Sha512_256,
1015 "SHA-512/256"(sizes : 128, 32, 16) (insecure_against :), 6));
1016 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
1017 (insecure_against : "collision", "length extension"), 0), (Sha224,
1018 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
1019 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
1020 2), (Sha384, "SHA-384"(sizes : 128, 48, 16) (insecure_against :), 3), (Sha512,
1021 "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 4),
1022 (Sha512_224, "SHA-512/224"(sizes : 128, 28, 16) (insecure_against :), 5),
1023 (Sha512_256, "SHA-512/256"(sizes : 128, 32, 16) (insecure_against :), 6)));
1024 };
1025}
1026#[macro_export]
1027#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1028macro_rules! for_each_wakeup_source {
1029 ($($pattern:tt => $code:tt;)*) => {
1030 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
1031 tt) => {} } _for_each_inner_wakeup_source!((Ext0, 0));
1032 _for_each_inner_wakeup_source!((Ext1, 1)); _for_each_inner_wakeup_source!((Gpio,
1033 2)); _for_each_inner_wakeup_source!((Timer, 3));
1034 _for_each_inner_wakeup_source!((Wifi, 5)); _for_each_inner_wakeup_source!((Uart0,
1035 6)); _for_each_inner_wakeup_source!((Uart1, 7));
1036 _for_each_inner_wakeup_source!((Touch, 8));
1037 _for_each_inner_wakeup_source!((UlpRiscv, 11));
1038 _for_each_inner_wakeup_source!((UlpRiscvTrap, 13));
1039 _for_each_inner_wakeup_source!((all(Ext0, 0), (Ext1, 1), (Gpio, 2), (Timer, 3),
1040 (Wifi, 5), (Uart0, 6), (Uart1, 7), (Touch, 8), (UlpRiscv, 11), (UlpRiscvTrap,
1041 13)));
1042 };
1043}
1044#[macro_export]
1045#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1046macro_rules! for_each_dma_engine {
1047 ($($pattern:tt => $code:tt;)*) => {
1048 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
1049 => {} } _for_each_inner_dma_engine!(("SPI_DMA"));
1050 _for_each_inner_dma_engine!(("I2S_DMA"));
1051 _for_each_inner_dma_engine!(("CRYPTO_DMA"));
1052 _for_each_inner_dma_engine!(("COPY_DMA"));
1053 _for_each_inner_dma_engine!((all("SPI_DMA"), ("I2S_DMA"), ("CRYPTO_DMA"),
1054 ("COPY_DMA")));
1055 };
1056}
1057#[macro_export]
1058#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1059macro_rules! for_each_dma_channel {
1060 ($($pattern:tt => $code:tt;)*) => {
1061 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
1062 => {} } _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI2));
1063 _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI3));
1064 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S0));
1065 _for_each_inner_dma_channel!(("CRYPTO_DMA", DMA_CRYPTO));
1066 _for_each_inner_dma_channel!(("COPY_DMA", DMA_COPY));
1067 _for_each_inner_dma_channel!(("SPI_DMA", any_channel = SpiDmaChannel));
1068 _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI2, 0, interrupt = SPI2_DMA,
1069 compatible = [SPI2])); _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI3, 1,
1070 interrupt = SPI3_DMA, compatible = [SPI3]));
1071 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S0, 0, interrupt = I2S0,
1072 compatible = [I2S0])); _for_each_inner_dma_channel!(("CRYPTO_DMA", DMA_CRYPTO, 0,
1073 interrupt = CRYPTO_DMA, compatible = [AES, SHA]));
1074 _for_each_inner_dma_channel!(("COPY_DMA", DMA_COPY, 0, interrupt = DMA_COPY,
1075 compatible = [])); _for_each_inner_dma_channel!((names("SPI_DMA", DMA_SPI2),
1076 ("SPI_DMA", DMA_SPI3), ("I2S_DMA", DMA_I2S0), ("CRYPTO_DMA", DMA_CRYPTO),
1077 ("COPY_DMA", DMA_COPY)));
1078 _for_each_inner_dma_channel!((separate_any_type("SPI_DMA", any_channel =
1079 SpiDmaChannel))); _for_each_inner_dma_channel!((shared("SPI_DMA", DMA_SPI2, 0,
1080 interrupt = SPI2_DMA, compatible = [SPI2]), ("SPI_DMA", DMA_SPI3, 1, interrupt =
1081 SPI3_DMA, compatible = [SPI3]), ("I2S_DMA", DMA_I2S0, 0, interrupt = I2S0,
1082 compatible = [I2S0]), ("CRYPTO_DMA", DMA_CRYPTO, 0, interrupt = CRYPTO_DMA,
1083 compatible = [AES, SHA]), ("COPY_DMA", DMA_COPY, 0, interrupt = DMA_COPY,
1084 compatible = []))); _for_each_inner_dma_channel!((split));
1085 _for_each_inner_dma_channel!((no_own_interrupt));
1086 };
1087}
1088#[macro_export]
1089#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1090macro_rules! for_each_dma_channel_peri_pair {
1091 ($($pattern:tt => $code:tt;)*) => {
1092 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1093 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("SPI_DMA",
1094 DMA_SPI2, SPI2)); _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", DMA_SPI3,
1095 SPI3)); _for_each_inner_dma_channel_peri_pair!(("I2S_DMA", DMA_I2S0, I2S0));
1096 _for_each_inner_dma_channel_peri_pair!(("CRYPTO_DMA", DMA_CRYPTO, AES));
1097 _for_each_inner_dma_channel_peri_pair!(("CRYPTO_DMA", DMA_CRYPTO, SHA));
1098 _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", any_channel = SpiDmaChannel,
1099 SPI2)); _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", any_channel =
1100 SpiDmaChannel, SPI3));
1101 _for_each_inner_dma_channel_peri_pair!((channels("SPI_DMA", DMA_SPI2, SPI2),
1102 ("SPI_DMA", DMA_SPI3, SPI3), ("I2S_DMA", DMA_I2S0, I2S0), ("CRYPTO_DMA",
1103 DMA_CRYPTO, AES), ("CRYPTO_DMA", DMA_CRYPTO, SHA)));
1104 _for_each_inner_dma_channel_peri_pair!((any_channels("SPI_DMA", any_channel =
1105 SpiDmaChannel, SPI2), ("SPI_DMA", any_channel = SpiDmaChannel, SPI3)));
1106 };
1107}
1108#[macro_export]
1109#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1110macro_rules! for_each_mem2mem_channel {
1111 ($($pattern:tt => $code:tt;)*) => {
1112 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1113 tt) => {} } _for_each_inner_mem2mem_channel!(("CRYPTO_DMA", CryptoDma,
1114 CryptoDmaChannel, DMA_CRYPTO, 0)); _for_each_inner_mem2mem_channel!(("COPY_DMA",
1115 CopyDma, CopyDmaChannel, DMA_COPY, 0));
1116 _for_each_inner_mem2mem_channel!(("CRYPTO_DMA", CryptoDma, CryptoDmaChannel));
1117 _for_each_inner_mem2mem_channel!(("COPY_DMA", CopyDma, CopyDmaChannel));
1118 _for_each_inner_mem2mem_channel!((channels("CRYPTO_DMA", CryptoDma,
1119 CryptoDmaChannel, DMA_CRYPTO, 0), ("COPY_DMA", CopyDma, CopyDmaChannel, DMA_COPY,
1120 0))); _for_each_inner_mem2mem_channel!((erased));
1121 _for_each_inner_mem2mem_channel!((engines("CRYPTO_DMA", CryptoDma,
1122 CryptoDmaChannel), ("COPY_DMA", CopyDma, CopyDmaChannel)));
1123 };
1124}
1125#[macro_export]
1126#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1127macro_rules! with_aes_dma_engine {
1128 ($($pattern:tt => $code:tt;)*) => {
1129 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1130 => {} } _with_inner_aes_dma_engine!(("CRYPTO_DMA", CryptoDmaChannel));
1131 };
1132}
1133#[macro_export]
1134#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1135macro_rules! with_i2s_dma_engine {
1136 ($($pattern:tt => $code:tt;)*) => {
1137 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1138 => {} } _with_inner_i2s_dma_engine!(("I2S_DMA", I2sDmaChannel));
1139 };
1140}
1141#[macro_export]
1142#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1143macro_rules! with_sha_dma_engine {
1144 ($($pattern:tt => $code:tt;)*) => {
1145 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1146 => {} } _with_inner_sha_dma_engine!(("CRYPTO_DMA", CryptoDmaChannel));
1147 };
1148}
1149#[macro_export]
1150#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1151macro_rules! with_spi_master_dma_engine {
1152 ($($pattern:tt => $code:tt;)*) => {
1153 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1154 : tt) => {} } _with_inner_spi_master_dma_engine!(("SPI_DMA", SpiDmaChannel));
1155 };
1156}
1157#[macro_export]
1158#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1159macro_rules! with_spi_slave_dma_engine {
1160 ($($pattern:tt => $code:tt;)*) => {
1161 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1162 : tt) => {} } _with_inner_spi_slave_dma_engine!(("SPI_DMA", SpiDmaChannel));
1163 };
1164}
1165#[macro_export]
1166#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1167macro_rules! for_each_sw_interrupt {
1168 ($($pattern:tt => $code:tt;)*) => {
1169 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1170 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1171 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1172 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1173 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1174 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1175 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1176 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1177 };
1178}
1179#[macro_export]
1180macro_rules! define_clock_tree_types {
1556 () => {
1557 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1558 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1559 pub enum SdmInstance {
1560 GpioSd = 0,
1561 }
1562 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1563 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1564 pub enum I2cInstance {
1565 I2c0 = 0,
1566 I2c1 = 1,
1567 }
1568 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1569 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1570 pub enum I2sInstance {
1571 I2s0 = 0,
1572 }
1573 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1574 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1575 pub enum RmtInstance {
1576 Rmt = 0,
1577 }
1578 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1579 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1580 pub enum SpiInstance {
1581 Spi2 = 0,
1582 Spi3 = 1,
1583 }
1584 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1585 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1586 pub enum TimgInstance {
1587 Timg0 = 0,
1588 Timg1 = 1,
1589 }
1590 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1591 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1592 pub enum UartInstance {
1593 Uart0 = 0,
1594 Uart1 = 1,
1595 }
1596 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1598 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1599 pub enum XtalClkConfig {
1600 _40,
1602 }
1603 impl XtalClkConfig {
1604 pub fn value(&self) -> u32 {
1605 match self {
1606 XtalClkConfig::_40 => 40000000,
1607 }
1608 }
1609 }
1610 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1612 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1613 pub enum PllClkConfig {
1614 _320,
1616 _480,
1618 }
1619 impl PllClkConfig {
1620 pub fn value(&self) -> u32 {
1621 match self {
1622 PllClkConfig::_320 => 320000000,
1623 PllClkConfig::_480 => 480000000,
1624 }
1625 }
1626 }
1627 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1629 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1630 pub struct ApllClkConfig(u32);
1631 impl ApllClkConfig {
1632 pub const fn new(frequency: u32) -> Self {
1639 ::core::assert!(
1640 frequency >= 16000000u32 && frequency <= 128000000u32,
1641 "`APLL_CLK` output frequency value must be between 16000000 and 128000000 \
1642 (inclusive)."
1643 );
1644 Self(frequency)
1645 }
1646 }
1647 impl ApllClkConfig {
1648 pub fn value(&self) -> u32 {
1649 self.0
1650 }
1651 }
1652 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1654 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1655 pub enum CpuPllDivInConfig {
1656 Pll,
1658 Apll,
1660 }
1661 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1662 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1663 pub enum CpuPllDivDivisor {
1664 _2 = 2,
1666 _3 = 3,
1668 _4 = 4,
1670 _6 = 6,
1672 }
1673 impl CpuPllDivDivisor {
1674 pub const fn new(raw: u32) -> Self {
1676 match raw {
1677 2 => Self::_2,
1678 3 => Self::_3,
1679 4 => Self::_4,
1680 6 => Self::_6,
1681 _ => ::core::panic!("Invalid CPU_PLL_DIV divisor value"),
1682 }
1683 }
1684 }
1685 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1689 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1690 pub struct CpuPllDivConfig {
1691 divisor: CpuPllDivDivisor,
1692 }
1693 impl CpuPllDivConfig {
1694 pub const fn new(divisor: CpuPllDivDivisor) -> Self {
1696 Self { divisor }
1697 }
1698 pub fn divisor(self) -> u32 {
1699 self.divisor as u32
1700 }
1701 }
1702 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1704 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1705 pub enum SystemPreDivInConfig {
1706 Xtal,
1708 RcFast,
1710 }
1711 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1715 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1716 pub struct SystemPreDivConfig {
1717 divisor: u32,
1718 }
1719 impl SystemPreDivConfig {
1720 pub const fn new(divisor: u32) -> Self {
1727 ::core::assert!(
1728 divisor <= 1023,
1729 "`SYSTEM_PRE_DIV` divisor must be between 0 and 1023 (inclusive)."
1730 );
1731 Self { divisor }
1732 }
1733 pub fn divisor(self) -> u32 {
1734 self.divisor as u32
1735 }
1736 }
1737 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1739 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1740 pub enum ApbClkConfig {
1741 Pll,
1743 Apll,
1745 Xtal,
1747 RcFast,
1749 }
1750 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1752 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1753 pub enum RefTickConfig {
1754 Pll,
1756 Apll,
1758 Xtal,
1760 RcFast,
1762 }
1763 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1767 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1768 pub struct RefTickXtalConfig {
1769 divisor: u32,
1770 }
1771 impl RefTickXtalConfig {
1772 pub const fn new(divisor: u32) -> Self {
1779 ::core::assert!(
1780 divisor <= 255,
1781 "`REF_TICK_XTAL` divisor must be between 0 and 255 (inclusive)."
1782 );
1783 Self { divisor }
1784 }
1785 pub fn divisor(self) -> u32 {
1786 self.divisor as u32
1787 }
1788 }
1789 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1793 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1794 pub struct RefTickCk8mConfig {
1795 divisor: u32,
1796 }
1797 impl RefTickCk8mConfig {
1798 pub const fn new(divisor: u32) -> Self {
1805 ::core::assert!(
1806 divisor <= 255,
1807 "`REF_TICK_CK8M` divisor must be between 0 and 255 (inclusive)."
1808 );
1809 Self { divisor }
1810 }
1811 pub fn divisor(self) -> u32 {
1812 self.divisor as u32
1813 }
1814 }
1815 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1817 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1818 pub enum CpuClkConfig {
1819 Xtal,
1821 RcFast,
1823 Apll,
1825 Pll,
1827 }
1828 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1830 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1831 pub enum RtcSlowClkConfig {
1832 #[cfg(use_xtal32k)]
1833 Xtal32k,
1835 RcSlow,
1837 RcFast,
1839 }
1840 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1842 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1843 pub enum RtcFastClkConfig {
1844 Xtal,
1846 Rc,
1848 }
1849 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1851 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1852 pub enum UartMemClkConfig {
1853 #[default]
1854 Xtal,
1856 }
1857 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1859 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1860 pub enum TimgCalibrationClockConfig {
1861 RtcClk,
1863 RcFastDivClk,
1865 #[cfg(use_xtal32k)]
1866 Xtal32kClk,
1868 }
1869 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1870 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1871 pub enum I2cFunctionClockSclk {
1872 #[default]
1873 Apb,
1875 RefTick,
1877 }
1878 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1882 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1883 pub struct I2cFunctionClockConfig {
1884 sclk: I2cFunctionClockSclk,
1885 }
1886 impl I2cFunctionClockConfig {
1887 pub const fn new(sclk: I2cFunctionClockSclk) -> Self {
1889 Self { sclk }
1890 }
1891 pub fn sclk(self) -> I2cFunctionClockSclk {
1892 self.sclk
1893 }
1894 }
1895 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1896 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1897 pub enum I2sMclkSclk {
1898 #[default]
1899 PllF160m,
1901 Apll,
1903 }
1904 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1908 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1909 pub struct I2sMclkConfig {
1910 sclk: I2sMclkSclk,
1911 div_num: u32,
1912 div_a: u32,
1913 div_b: u32,
1914 }
1915 impl I2sMclkConfig {
1916 pub const fn new(sclk: I2sMclkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
1929 ::core::assert!(
1930 div_num >= 1 && div_num <= 255,
1931 "`I2S0_MCLK` div_num must be between 1 and 255 (inclusive)."
1932 );
1933 ::core::assert!(
1934 div_a >= 1 && div_a <= 63,
1935 "`I2S0_MCLK` div_a must be between 1 and 63 (inclusive)."
1936 );
1937 ::core::assert!(
1938 div_b <= 63,
1939 "`I2S0_MCLK` div_b must be between 0 and 63 (inclusive)."
1940 );
1941 Self {
1942 sclk,
1943 div_num,
1944 div_a,
1945 div_b,
1946 }
1947 }
1948 pub fn sclk(self) -> I2sMclkSclk {
1949 self.sclk
1950 }
1951 pub fn div_num(self) -> u32 {
1952 self.div_num as u32
1953 }
1954 pub fn div_a(self) -> u32 {
1955 self.div_a as u32
1956 }
1957 pub fn div_b(self) -> u32 {
1958 self.div_b as u32
1959 }
1960 }
1961 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1963 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1964 pub enum RmtSclkConfig {
1965 RefTick,
1967 #[default]
1968 ApbClk,
1970 }
1971 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1973 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1974 pub enum SpiFunctionClockConfig {
1975 #[default]
1976 Apb,
1978 }
1979 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1981 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1982 pub enum TimgFunctionClockConfig {
1983 #[default]
1984 XtalClk,
1986 ApbClk,
1988 }
1989 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1990 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1991 pub enum UartFunctionClockSclk {
1992 #[default]
1993 Apb,
1995 RefTick,
1997 }
1998 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2002 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2003 pub struct UartFunctionClockConfig {
2004 sclk: UartFunctionClockSclk,
2005 }
2006 impl UartFunctionClockConfig {
2007 pub const fn new(sclk: UartFunctionClockSclk) -> Self {
2009 Self { sclk }
2010 }
2011 pub fn sclk(self) -> UartFunctionClockSclk {
2012 self.sclk
2013 }
2014 }
2015 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2020 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2021 pub struct UartBaudRateGeneratorConfig {
2022 fractional: u32,
2023 integral: u32,
2024 }
2025 impl UartBaudRateGeneratorConfig {
2026 pub const fn new(fractional: u32, integral: u32) -> Self {
2036 ::core::assert!(
2037 fractional <= 15,
2038 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2039 );
2040 ::core::assert!(
2041 integral <= 1048575,
2042 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 1048575 \
2043 (inclusive)."
2044 );
2045 Self {
2046 fractional,
2047 integral,
2048 }
2049 }
2050 pub fn fractional(self) -> u32 {
2051 self.fractional as u32
2052 }
2053 pub fn integral(self) -> u32 {
2054 self.integral as u32
2055 }
2056 }
2057 pub struct ClockTree {
2059 xtal_clk: Option<XtalClkConfig>,
2060 pll_clk: Option<PllClkConfig>,
2061 apll_clk: Option<ApllClkConfig>,
2062 cpu_pll_div_in: Option<CpuPllDivInConfig>,
2063 cpu_pll_div: Option<CpuPllDivConfig>,
2064 system_pre_div_in: Option<SystemPreDivInConfig>,
2065 system_pre_div: Option<SystemPreDivConfig>,
2066 apb_clk: Option<ApbClkConfig>,
2067 ref_tick: Option<RefTickConfig>,
2068 ref_tick_xtal: Option<RefTickXtalConfig>,
2069 ref_tick_ck8m: Option<RefTickCk8mConfig>,
2070 cpu_clk: Option<CpuClkConfig>,
2071 rtc_slow_clk: Option<RtcSlowClkConfig>,
2072 rtc_fast_clk: Option<RtcFastClkConfig>,
2073 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2074 i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
2075 i2s_mclk: [Option<I2sMclkConfig>; 1],
2076 rmt_sclk: [Option<RmtSclkConfig>; 1],
2077 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2078 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2079 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2080 pub(crate) pll_clk_refcount: u32,
2081 pub(crate) apll_clk_refcount: u32,
2082 pub(crate) rc_fast_clk_refcount: u32,
2083 pub(crate) apb_clk_refcount: u32,
2084 pub(crate) ref_tick_refcount: u32,
2085 #[cfg(use_xtal32k)]
2086 pub(crate) xtal32k_clk_refcount: u32,
2087 pub(crate) rc_fast_div_clk_refcount: u32,
2088 pub(crate) rtc_fast_clk_refcount: u32,
2089 pub(crate) uart_mem_clk_refcount: u32,
2090 pub(crate) timg_calibration_clock_refcount: u32,
2091 pub(crate) sdm_function_clock_refcount: [u32; 1],
2092 pub(crate) i2c_function_clock_refcount: [u32; 2],
2093 pub(crate) i2s_mclk_refcount: [u32; 1],
2094 pub(crate) rmt_sclk_refcount: [u32; 1],
2095 pub(crate) spi_function_clock_refcount: [u32; 2],
2096 pub(crate) timg_function_clock_refcount: [u32; 2],
2097 pub(crate) uart_function_clock_refcount: [u32; 2],
2098 pub(crate) uart_baud_rate_generator_refcount: [u32; 2],
2099 pub(crate) uart_mem_clock_refcount: [u32; 2],
2100 }
2101 impl ClockTree {
2102 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2104 CLOCK_TREE.with(f)
2105 }
2106 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2108 self.xtal_clk
2109 }
2110 pub fn pll_clk(&self) -> Option<PllClkConfig> {
2112 self.pll_clk
2113 }
2114 pub fn apll_clk(&self) -> Option<ApllClkConfig> {
2116 self.apll_clk
2117 }
2118 pub fn cpu_pll_div_in(&self) -> Option<CpuPllDivInConfig> {
2120 self.cpu_pll_div_in
2121 }
2122 pub fn cpu_pll_div(&self) -> Option<CpuPllDivConfig> {
2124 self.cpu_pll_div
2125 }
2126 pub fn system_pre_div_in(&self) -> Option<SystemPreDivInConfig> {
2128 self.system_pre_div_in
2129 }
2130 pub fn system_pre_div(&self) -> Option<SystemPreDivConfig> {
2132 self.system_pre_div
2133 }
2134 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2136 self.apb_clk
2137 }
2138 pub fn ref_tick(&self) -> Option<RefTickConfig> {
2140 self.ref_tick
2141 }
2142 pub fn ref_tick_xtal(&self) -> Option<RefTickXtalConfig> {
2144 self.ref_tick_xtal
2145 }
2146 pub fn ref_tick_ck8m(&self) -> Option<RefTickCk8mConfig> {
2148 self.ref_tick_ck8m
2149 }
2150 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2152 self.cpu_clk
2153 }
2154 pub fn rtc_slow_clk(&self) -> Option<RtcSlowClkConfig> {
2156 self.rtc_slow_clk
2157 }
2158 pub fn rtc_fast_clk(&self) -> Option<RtcFastClkConfig> {
2160 self.rtc_fast_clk
2161 }
2162 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2164 self.timg_calibration_clock
2165 }
2166 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2168 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2169 }
2170 pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2172 self.i2c_function_clock[I2cInstance::I2c1 as usize]
2173 }
2174 pub fn i2s0_mclk(&self) -> Option<I2sMclkConfig> {
2176 self.i2s_mclk[I2sInstance::I2s0 as usize]
2177 }
2178 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2180 self.rmt_sclk[RmtInstance::Rmt as usize]
2181 }
2182 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2184 self.timg_function_clock[TimgInstance::Timg0 as usize]
2185 }
2186 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2188 self.timg_function_clock[TimgInstance::Timg1 as usize]
2189 }
2190 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2192 self.uart_function_clock[UartInstance::Uart0 as usize]
2193 }
2194 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2196 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2197 }
2198 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2200 self.uart_function_clock[UartInstance::Uart1 as usize]
2201 }
2202 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2204 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2205 }
2206 }
2207 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2208 ::esp_sync::NonReentrantMutex::new(ClockTree {
2209 xtal_clk: None,
2210 pll_clk: None,
2211 apll_clk: None,
2212 cpu_pll_div_in: None,
2213 cpu_pll_div: None,
2214 system_pre_div_in: None,
2215 system_pre_div: None,
2216 apb_clk: None,
2217 ref_tick: None,
2218 ref_tick_xtal: None,
2219 ref_tick_ck8m: None,
2220 cpu_clk: None,
2221 rtc_slow_clk: None,
2222 rtc_fast_clk: None,
2223 timg_calibration_clock: None,
2224 i2c_function_clock: [None; 2],
2225 i2s_mclk: [None; 1],
2226 rmt_sclk: [None; 1],
2227 timg_function_clock: [None; 2],
2228 uart_function_clock: [None; 2],
2229 uart_baud_rate_generator: [None; 2],
2230 pll_clk_refcount: 0,
2231 apll_clk_refcount: 0,
2232 rc_fast_clk_refcount: 0,
2233 apb_clk_refcount: 0,
2234 ref_tick_refcount: 0,
2235 #[cfg(use_xtal32k)]
2236 xtal32k_clk_refcount: 0,
2237 rc_fast_div_clk_refcount: 0,
2238 rtc_fast_clk_refcount: 0,
2239 uart_mem_clk_refcount: 0,
2240 timg_calibration_clock_refcount: 0,
2241 sdm_function_clock_refcount: [0; 1],
2242 i2c_function_clock_refcount: [0; 2],
2243 i2s_mclk_refcount: [0; 1],
2244 rmt_sclk_refcount: [0; 1],
2245 spi_function_clock_refcount: [0; 2],
2246 timg_function_clock_refcount: [0; 2],
2247 uart_function_clock_refcount: [0; 2],
2248 uart_baud_rate_generator_refcount: [0; 2],
2249 uart_mem_clock_refcount: [0; 2],
2250 });
2251 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2252 ::core::sync::atomic::AtomicU32::new(0);
2253 static PLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2254 ::core::sync::atomic::AtomicU32::new(0);
2255 static APLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2256 ::core::sync::atomic::AtomicU32::new(0);
2257 static CPU_PLL_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2258 ::core::sync::atomic::AtomicU32::new(0);
2259 static CPU_PLL_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2260 ::core::sync::atomic::AtomicU32::new(0);
2261 static SYSTEM_PRE_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2262 ::core::sync::atomic::AtomicU32::new(0);
2263 static SYSTEM_PRE_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2264 ::core::sync::atomic::AtomicU32::new(0);
2265 static REF_TICK_XTAL_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2266 ::core::sync::atomic::AtomicU32::new(0);
2267 static REF_TICK_CK8M_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2268 ::core::sync::atomic::AtomicU32::new(0);
2269 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2270 ::core::sync::atomic::AtomicU32::new(0);
2271 static RTC_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2272 ::core::sync::atomic::AtomicU32::new(0);
2273 static RTC_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2274 ::core::sync::atomic::AtomicU32::new(0);
2275 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2276 ::core::sync::atomic::AtomicU32::new(0);
2277 static I2S_MCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2278 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2279 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2280 ::core::sync::atomic::AtomicU32::new(0);
2281 static REF_TICK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2282 ::core::sync::atomic::AtomicU32::new(0);
2283 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2284 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2285 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2286 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2287 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2288 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2289 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2290 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2291 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2292 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2293 #[derive(Debug, enumset::EnumSetType)]
2298 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2299 pub enum ClockSource {
2300 XtalClk,
2302 RcFastClk,
2304 #[cfg(use_xtal32k)]
2305 Xtal32kClk,
2307 RcSlowClk,
2309 }
2310 pub fn xtal_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2312 Some(ClockSource::XtalClk)
2313 }
2314 pub fn pll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2316 xtal_clk_root_source(clocks)
2317 }
2318 pub fn apll_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2320 pll_clk_root_source(clocks)
2321 }
2322 pub fn pll_f160m_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2324 pll_clk_root_source(clocks)
2325 }
2326 pub fn rc_fast_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2328 Some(ClockSource::RcFastClk)
2329 }
2330 pub fn cpu_pll_div_in_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2332 let config = clocks.cpu_pll_div_in?;
2333 match config {
2334 CpuPllDivInConfig::Pll => pll_clk_root_source(clocks),
2335 CpuPllDivInConfig::Apll => apll_clk_root_source(clocks),
2336 }
2337 }
2338 pub fn cpu_pll_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2340 cpu_pll_div_in_root_source(clocks)
2341 }
2342 pub fn system_pre_div_in_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2344 let config = clocks.system_pre_div_in?;
2345 match config {
2346 SystemPreDivInConfig::Xtal => xtal_clk_root_source(clocks),
2347 SystemPreDivInConfig::RcFast => rc_fast_clk_root_source(clocks),
2348 }
2349 }
2350 pub fn system_pre_div_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2352 system_pre_div_in_root_source(clocks)
2353 }
2354 pub fn ref_tick_xtal_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2356 xtal_clk_root_source(clocks)
2357 }
2358 pub fn ref_tick_ck8m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2360 rc_fast_clk_root_source(clocks)
2361 }
2362 pub fn cpu_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2364 let config = clocks.cpu_clk?;
2365 match config {
2366 CpuClkConfig::Xtal => system_pre_div_root_source(clocks),
2367 CpuClkConfig::RcFast => system_pre_div_root_source(clocks),
2368 CpuClkConfig::Apll => cpu_pll_div_root_source(clocks),
2369 CpuClkConfig::Pll => cpu_pll_div_root_source(clocks),
2370 }
2371 }
2372 pub fn apb_clk_cpu_div2_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2374 cpu_clk_root_source(clocks)
2375 }
2376 pub fn apb_clk_80m_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2378 cpu_clk_root_source(clocks)
2379 }
2380 #[cfg(use_xtal32k)]
2381 pub fn xtal32k_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2383 Some(ClockSource::Xtal32kClk)
2384 }
2385 pub fn rc_slow_clk_root_source(_clocks: &mut ClockTree) -> Option<ClockSource> {
2387 Some(ClockSource::RcSlowClk)
2388 }
2389 pub fn rc_fast_div_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2391 rc_fast_clk_root_source(clocks)
2392 }
2393 pub fn xtal_div_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2395 xtal_clk_root_source(clocks)
2396 }
2397 pub fn rtc_slow_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2399 let config = clocks.rtc_slow_clk?;
2400 match config {
2401 #[cfg(use_xtal32k)]
2402 RtcSlowClkConfig::Xtal32k => xtal32k_clk_root_source(clocks),
2403 RtcSlowClkConfig::RcSlow => rc_slow_clk_root_source(clocks),
2404 RtcSlowClkConfig::RcFast => rc_fast_div_clk_root_source(clocks),
2405 }
2406 }
2407 pub fn rtc_fast_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2409 let config = clocks.rtc_fast_clk?;
2410 match config {
2411 RtcFastClkConfig::Xtal => xtal_div_clk_root_source(clocks),
2412 RtcFastClkConfig::Rc => rc_fast_clk_root_source(clocks),
2413 }
2414 }
2415 pub fn uart_mem_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2417 xtal_clk_root_source(clocks)
2418 }
2419 pub fn timg_calibration_clock_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2421 let config = clocks.timg_calibration_clock?;
2422 match config {
2423 TimgCalibrationClockConfig::RtcClk => rtc_slow_clk_root_source(clocks),
2424 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_root_source(clocks),
2425 #[cfg(use_xtal32k)]
2426 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_root_source(clocks),
2427 }
2428 }
2429 pub fn apb_clk_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2431 let config = clocks.apb_clk?;
2432 match config {
2433 ApbClkConfig::Pll => apb_clk_80m_root_source(clocks),
2434 ApbClkConfig::Apll => apb_clk_cpu_div2_root_source(clocks),
2435 ApbClkConfig::Xtal => cpu_clk_root_source(clocks),
2436 ApbClkConfig::RcFast => cpu_clk_root_source(clocks),
2437 }
2438 }
2439 pub fn ref_tick_root_source(clocks: &mut ClockTree) -> Option<ClockSource> {
2441 let config = clocks.ref_tick?;
2442 match config {
2443 RefTickConfig::Pll => ref_tick_xtal_root_source(clocks),
2444 RefTickConfig::Apll => ref_tick_xtal_root_source(clocks),
2445 RefTickConfig::Xtal => ref_tick_xtal_root_source(clocks),
2446 RefTickConfig::RcFast => ref_tick_ck8m_root_source(clocks),
2447 }
2448 }
2449 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2450 let old_config = clocks.xtal_clk.replace(config);
2451 refresh_xtal_clk_downstream(clocks);
2452 configure_xtal_clk_impl(clocks, old_config, config);
2453 }
2454 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2455 clocks.xtal_clk
2456 }
2457 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2458 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2459 pub fn xtal_clk_config_frequency(config: XtalClkConfig) -> u32 {
2460 config.value()
2461 }
2462 pub fn xtal_clk_frequency() -> u32 {
2463 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2464 }
2465 pub fn configure_pll_clk(clocks: &mut ClockTree, config: PllClkConfig) {
2466 let old_config = clocks.pll_clk.replace(config);
2467 refresh_pll_clk_downstream(clocks);
2468 configure_pll_clk_impl(clocks, old_config, config);
2469 }
2470 pub fn pll_clk_config(clocks: &mut ClockTree) -> Option<PllClkConfig> {
2471 clocks.pll_clk
2472 }
2473 pub fn request_pll_clk(clocks: &mut ClockTree) {
2474 trace!("Requesting PLL_CLK");
2475 if increment_reference_count(&mut clocks.pll_clk_refcount) {
2476 trace!("Enabling PLL_CLK");
2477 request_xtal_clk(clocks);
2478 enable_pll_clk_impl(clocks, true);
2479 }
2480 }
2481 pub fn release_pll_clk(clocks: &mut ClockTree) {
2482 trace!("Releasing PLL_CLK");
2483 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2484 trace!("Disabling PLL_CLK");
2485 enable_pll_clk_impl(clocks, false);
2486 release_xtal_clk(clocks);
2487 }
2488 }
2489 pub fn pll_clk_config_frequency(config: PllClkConfig) -> u32 {
2490 config.value()
2491 }
2492 pub fn pll_clk_frequency() -> u32 {
2493 PLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2494 }
2495 pub fn pll_clk_source_frequency() -> u32 {
2496 xtal_clk_frequency()
2497 }
2498 pub fn configure_apll_clk(clocks: &mut ClockTree, config: ApllClkConfig) {
2499 let old_config = clocks.apll_clk.replace(config);
2500 refresh_apll_clk_downstream(clocks);
2501 configure_apll_clk_impl(clocks, old_config, config);
2502 }
2503 pub fn apll_clk_config(clocks: &mut ClockTree) -> Option<ApllClkConfig> {
2504 clocks.apll_clk
2505 }
2506 pub fn request_apll_clk(clocks: &mut ClockTree) {
2507 trace!("Requesting APLL_CLK");
2508 if increment_reference_count(&mut clocks.apll_clk_refcount) {
2509 trace!("Enabling APLL_CLK");
2510 request_pll_clk(clocks);
2511 enable_apll_clk_impl(clocks, true);
2512 }
2513 }
2514 pub fn release_apll_clk(clocks: &mut ClockTree) {
2515 trace!("Releasing APLL_CLK");
2516 if decrement_reference_count(&mut clocks.apll_clk_refcount) {
2517 trace!("Disabling APLL_CLK");
2518 enable_apll_clk_impl(clocks, false);
2519 release_pll_clk(clocks);
2520 }
2521 }
2522 pub fn apll_clk_config_frequency(config: ApllClkConfig) -> u32 {
2523 config.value()
2524 }
2525 pub fn apll_clk_frequency() -> u32 {
2526 APLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2527 }
2528 pub fn apll_clk_source_frequency() -> u32 {
2529 pll_clk_frequency()
2530 }
2531 pub fn request_pll_f160m_clk(clocks: &mut ClockTree) {
2532 trace!("Enabling PLL_F160M_CLK");
2533 request_pll_clk(clocks);
2534 enable_pll_f160m_clk_impl(clocks, true);
2535 }
2536 pub fn release_pll_f160m_clk(clocks: &mut ClockTree) {
2537 trace!("Disabling PLL_F160M_CLK");
2538 enable_pll_f160m_clk_impl(clocks, false);
2539 release_pll_clk(clocks);
2540 }
2541 pub fn pll_f160m_clk_frequency() -> u32 {
2542 160000000
2543 }
2544 pub fn pll_f160m_clk_source_frequency() -> u32 {
2545 pll_clk_frequency()
2546 }
2547 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2548 trace!("Requesting RC_FAST_CLK");
2549 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2550 trace!("Enabling RC_FAST_CLK");
2551 enable_rc_fast_clk_impl(clocks, true);
2552 }
2553 }
2554 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2555 trace!("Releasing RC_FAST_CLK");
2556 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2557 trace!("Disabling RC_FAST_CLK");
2558 enable_rc_fast_clk_impl(clocks, false);
2559 }
2560 }
2561 static RC_FAST_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
2562 ::core::sync::atomic::AtomicU32::new(rc_fast_clk_nominal_frequency());
2563 pub const fn rc_fast_clk_nominal_frequency() -> u32 {
2564 8000000
2565 }
2566 pub fn rc_fast_clk_frequency() -> u32 {
2567 RC_FAST_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
2568 }
2569 pub fn set_rc_fast_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
2570 if !(4000000..=12000000).contains(&frequency) {
2571 warn!(
2572 "Ignoring out-of-range RC_FAST_CLK frequency: {} Hz",
2573 frequency
2574 );
2575 return;
2576 }
2577 debug!(
2578 "Updating RC_FAST_CLK frequency to {} Hz (nominal {} Hz)",
2579 frequency,
2580 rc_fast_clk_nominal_frequency()
2581 );
2582 RC_FAST_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
2583 refresh_rc_fast_clk_downstream(clocks);
2584 }
2585 pub fn configure_cpu_pll_div_in(clocks: &mut ClockTree, new_selector: CpuPllDivInConfig) {
2586 let old_selector = clocks.cpu_pll_div_in.replace(new_selector);
2587 refresh_cpu_pll_div_in_downstream(clocks);
2588 match new_selector {
2589 CpuPllDivInConfig::Pll => request_pll_clk(clocks),
2590 CpuPllDivInConfig::Apll => request_apll_clk(clocks),
2591 }
2592 configure_cpu_pll_div_in_impl(clocks, old_selector, new_selector);
2593 if let Some(old_selector) = old_selector {
2594 match old_selector {
2595 CpuPllDivInConfig::Pll => release_pll_clk(clocks),
2596 CpuPllDivInConfig::Apll => release_apll_clk(clocks),
2597 }
2598 }
2599 }
2600 pub fn cpu_pll_div_in_config(clocks: &mut ClockTree) -> Option<CpuPllDivInConfig> {
2601 clocks.cpu_pll_div_in
2602 }
2603 pub fn request_cpu_pll_div_in(clocks: &mut ClockTree) {
2604 trace!("Enabling CPU_PLL_DIV_IN");
2605 match unwrap!(clocks.cpu_pll_div_in) {
2606 CpuPllDivInConfig::Pll => request_pll_clk(clocks),
2607 CpuPllDivInConfig::Apll => request_apll_clk(clocks),
2608 }
2609 enable_cpu_pll_div_in_impl(clocks, true);
2610 }
2611 pub fn release_cpu_pll_div_in(clocks: &mut ClockTree) {
2612 trace!("Disabling CPU_PLL_DIV_IN");
2613 enable_cpu_pll_div_in_impl(clocks, false);
2614 match unwrap!(clocks.cpu_pll_div_in) {
2615 CpuPllDivInConfig::Pll => release_pll_clk(clocks),
2616 CpuPllDivInConfig::Apll => release_apll_clk(clocks),
2617 }
2618 }
2619 pub fn cpu_pll_div_in_config_frequency(config: CpuPllDivInConfig) -> u32 {
2620 match config {
2621 CpuPllDivInConfig::Pll => pll_clk_frequency(),
2622 CpuPllDivInConfig::Apll => apll_clk_frequency(),
2623 }
2624 }
2625 pub fn cpu_pll_div_in_frequency() -> u32 {
2626 CPU_PLL_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2627 }
2628 pub fn cpu_pll_div_in_source_frequency(source: CpuPllDivInConfig) -> u32 {
2629 cpu_pll_div_in_config_frequency(source)
2630 }
2631 pub fn configure_cpu_pll_div(clocks: &mut ClockTree, config: CpuPllDivConfig) {
2632 let old_config = clocks.cpu_pll_div.replace(config);
2633 refresh_cpu_pll_div_downstream(clocks);
2634 configure_cpu_pll_div_impl(clocks, old_config, config);
2635 }
2636 pub fn cpu_pll_div_config(clocks: &mut ClockTree) -> Option<CpuPllDivConfig> {
2637 clocks.cpu_pll_div
2638 }
2639 pub fn request_cpu_pll_div(clocks: &mut ClockTree) {
2640 trace!("Enabling CPU_PLL_DIV");
2641 request_cpu_pll_div_in(clocks);
2642 enable_cpu_pll_div_impl(clocks, true);
2643 }
2644 pub fn release_cpu_pll_div(clocks: &mut ClockTree) {
2645 trace!("Disabling CPU_PLL_DIV");
2646 enable_cpu_pll_div_impl(clocks, false);
2647 release_cpu_pll_div_in(clocks);
2648 }
2649 pub fn cpu_pll_div_config_frequency(config: CpuPllDivConfig) -> u32 {
2650 (cpu_pll_div_in_frequency() / config.divisor())
2651 }
2652 pub fn cpu_pll_div_frequency() -> u32 {
2653 CPU_PLL_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2654 }
2655 pub fn cpu_pll_div_source_frequency() -> u32 {
2656 cpu_pll_div_in_frequency()
2657 }
2658 pub fn configure_system_pre_div_in(
2659 clocks: &mut ClockTree,
2660 new_selector: SystemPreDivInConfig,
2661 ) {
2662 let old_selector = clocks.system_pre_div_in.replace(new_selector);
2663 refresh_system_pre_div_in_downstream(clocks);
2664 match new_selector {
2665 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2666 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2667 }
2668 configure_system_pre_div_in_impl(clocks, old_selector, new_selector);
2669 if let Some(old_selector) = old_selector {
2670 match old_selector {
2671 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2672 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2673 }
2674 }
2675 }
2676 pub fn system_pre_div_in_config(clocks: &mut ClockTree) -> Option<SystemPreDivInConfig> {
2677 clocks.system_pre_div_in
2678 }
2679 pub fn request_system_pre_div_in(clocks: &mut ClockTree) {
2680 trace!("Enabling SYSTEM_PRE_DIV_IN");
2681 match unwrap!(clocks.system_pre_div_in) {
2682 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2683 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2684 }
2685 enable_system_pre_div_in_impl(clocks, true);
2686 }
2687 pub fn release_system_pre_div_in(clocks: &mut ClockTree) {
2688 trace!("Disabling SYSTEM_PRE_DIV_IN");
2689 enable_system_pre_div_in_impl(clocks, false);
2690 match unwrap!(clocks.system_pre_div_in) {
2691 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2692 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2693 }
2694 }
2695 pub fn system_pre_div_in_config_frequency(config: SystemPreDivInConfig) -> u32 {
2696 match config {
2697 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2698 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2699 }
2700 }
2701 pub fn system_pre_div_in_frequency() -> u32 {
2702 SYSTEM_PRE_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2703 }
2704 pub fn system_pre_div_in_source_frequency(source: SystemPreDivInConfig) -> u32 {
2705 system_pre_div_in_config_frequency(source)
2706 }
2707 pub fn configure_system_pre_div(clocks: &mut ClockTree, config: SystemPreDivConfig) {
2708 let old_config = clocks.system_pre_div.replace(config);
2709 refresh_system_pre_div_downstream(clocks);
2710 configure_system_pre_div_impl(clocks, old_config, config);
2711 }
2712 pub fn system_pre_div_config(clocks: &mut ClockTree) -> Option<SystemPreDivConfig> {
2713 clocks.system_pre_div
2714 }
2715 pub fn request_system_pre_div(clocks: &mut ClockTree) {
2716 trace!("Enabling SYSTEM_PRE_DIV");
2717 request_system_pre_div_in(clocks);
2718 enable_system_pre_div_impl(clocks, true);
2719 }
2720 pub fn release_system_pre_div(clocks: &mut ClockTree) {
2721 trace!("Disabling SYSTEM_PRE_DIV");
2722 enable_system_pre_div_impl(clocks, false);
2723 release_system_pre_div_in(clocks);
2724 }
2725 pub fn system_pre_div_config_frequency(config: SystemPreDivConfig) -> u32 {
2726 (system_pre_div_in_frequency() / (config.divisor() + 1))
2727 }
2728 pub fn system_pre_div_frequency() -> u32 {
2729 SYSTEM_PRE_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2730 }
2731 pub fn system_pre_div_source_frequency() -> u32 {
2732 system_pre_div_in_frequency()
2733 }
2734 pub fn configure_apb_clk(clocks: &mut ClockTree, new_selector: ApbClkConfig) {
2735 let old_selector = clocks.apb_clk.replace(new_selector);
2736 refresh_apb_clk_downstream(clocks);
2737 let active = clocks.apb_clk_refcount > 0;
2738 if active {
2739 match new_selector {
2740 ApbClkConfig::Pll => request_apb_clk_80m(clocks),
2741 ApbClkConfig::Apll => request_apb_clk_cpu_div2(clocks),
2742 ApbClkConfig::Xtal => request_cpu_clk(clocks),
2743 ApbClkConfig::RcFast => request_cpu_clk(clocks),
2744 }
2745 }
2746 configure_apb_clk_impl(clocks, old_selector, new_selector);
2747 if active && let Some(old_selector) = old_selector {
2748 match old_selector {
2749 ApbClkConfig::Pll => release_apb_clk_80m(clocks),
2750 ApbClkConfig::Apll => release_apb_clk_cpu_div2(clocks),
2751 ApbClkConfig::Xtal => release_cpu_clk(clocks),
2752 ApbClkConfig::RcFast => release_cpu_clk(clocks),
2753 }
2754 }
2755 }
2756 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2757 clocks.apb_clk
2758 }
2759 pub fn request_apb_clk(clocks: &mut ClockTree) {
2760 trace!("Requesting APB_CLK");
2761 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2762 trace!("Enabling APB_CLK");
2763 match unwrap!(clocks.apb_clk) {
2764 ApbClkConfig::Pll => request_apb_clk_80m(clocks),
2765 ApbClkConfig::Apll => request_apb_clk_cpu_div2(clocks),
2766 ApbClkConfig::Xtal => request_cpu_clk(clocks),
2767 ApbClkConfig::RcFast => request_cpu_clk(clocks),
2768 }
2769 enable_apb_clk_impl(clocks, true);
2770 }
2771 }
2772 pub fn release_apb_clk(clocks: &mut ClockTree) {
2773 trace!("Releasing APB_CLK");
2774 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2775 trace!("Disabling APB_CLK");
2776 enable_apb_clk_impl(clocks, false);
2777 match unwrap!(clocks.apb_clk) {
2778 ApbClkConfig::Pll => release_apb_clk_80m(clocks),
2779 ApbClkConfig::Apll => release_apb_clk_cpu_div2(clocks),
2780 ApbClkConfig::Xtal => release_cpu_clk(clocks),
2781 ApbClkConfig::RcFast => release_cpu_clk(clocks),
2782 }
2783 }
2784 }
2785 pub fn apb_clk_config_frequency(config: ApbClkConfig) -> u32 {
2786 match config {
2787 ApbClkConfig::Pll => apb_clk_80m_frequency(),
2788 ApbClkConfig::Apll => apb_clk_cpu_div2_frequency(),
2789 ApbClkConfig::Xtal => cpu_clk_frequency(),
2790 ApbClkConfig::RcFast => cpu_clk_frequency(),
2791 }
2792 }
2793 pub fn apb_clk_frequency() -> u32 {
2794 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2795 }
2796 pub fn apb_clk_source_frequency(source: ApbClkConfig) -> u32 {
2797 apb_clk_config_frequency(source)
2798 }
2799 pub fn configure_ref_tick(clocks: &mut ClockTree, new_selector: RefTickConfig) {
2800 let old_selector = clocks.ref_tick.replace(new_selector);
2801 refresh_ref_tick_downstream(clocks);
2802 let active = clocks.ref_tick_refcount > 0;
2803 if active {
2804 match new_selector {
2805 RefTickConfig::Pll => request_ref_tick_xtal(clocks),
2806 RefTickConfig::Apll => request_ref_tick_xtal(clocks),
2807 RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
2808 RefTickConfig::RcFast => request_ref_tick_ck8m(clocks),
2809 }
2810 }
2811 configure_ref_tick_impl(clocks, old_selector, new_selector);
2812 if active && let Some(old_selector) = old_selector {
2813 match old_selector {
2814 RefTickConfig::Pll => release_ref_tick_xtal(clocks),
2815 RefTickConfig::Apll => release_ref_tick_xtal(clocks),
2816 RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
2817 RefTickConfig::RcFast => release_ref_tick_ck8m(clocks),
2818 }
2819 }
2820 }
2821 pub fn ref_tick_config(clocks: &mut ClockTree) -> Option<RefTickConfig> {
2822 clocks.ref_tick
2823 }
2824 pub fn request_ref_tick(clocks: &mut ClockTree) {
2825 trace!("Requesting REF_TICK");
2826 if increment_reference_count(&mut clocks.ref_tick_refcount) {
2827 trace!("Enabling REF_TICK");
2828 match unwrap!(clocks.ref_tick) {
2829 RefTickConfig::Pll => request_ref_tick_xtal(clocks),
2830 RefTickConfig::Apll => request_ref_tick_xtal(clocks),
2831 RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
2832 RefTickConfig::RcFast => request_ref_tick_ck8m(clocks),
2833 }
2834 enable_ref_tick_impl(clocks, true);
2835 }
2836 }
2837 pub fn release_ref_tick(clocks: &mut ClockTree) {
2838 trace!("Releasing REF_TICK");
2839 if decrement_reference_count(&mut clocks.ref_tick_refcount) {
2840 trace!("Disabling REF_TICK");
2841 enable_ref_tick_impl(clocks, false);
2842 match unwrap!(clocks.ref_tick) {
2843 RefTickConfig::Pll => release_ref_tick_xtal(clocks),
2844 RefTickConfig::Apll => release_ref_tick_xtal(clocks),
2845 RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
2846 RefTickConfig::RcFast => release_ref_tick_ck8m(clocks),
2847 }
2848 }
2849 }
2850 pub fn ref_tick_config_frequency(config: RefTickConfig) -> u32 {
2851 match config {
2852 RefTickConfig::Pll => ref_tick_xtal_frequency(),
2853 RefTickConfig::Apll => ref_tick_xtal_frequency(),
2854 RefTickConfig::Xtal => ref_tick_xtal_frequency(),
2855 RefTickConfig::RcFast => ref_tick_ck8m_frequency(),
2856 }
2857 }
2858 pub fn ref_tick_frequency() -> u32 {
2859 REF_TICK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2860 }
2861 pub fn ref_tick_source_frequency(source: RefTickConfig) -> u32 {
2862 ref_tick_config_frequency(source)
2863 }
2864 pub fn configure_ref_tick_xtal(clocks: &mut ClockTree, config: RefTickXtalConfig) {
2865 let old_config = clocks.ref_tick_xtal.replace(config);
2866 refresh_ref_tick_xtal_downstream(clocks);
2867 configure_ref_tick_xtal_impl(clocks, old_config, config);
2868 }
2869 pub fn ref_tick_xtal_config(clocks: &mut ClockTree) -> Option<RefTickXtalConfig> {
2870 clocks.ref_tick_xtal
2871 }
2872 pub fn request_ref_tick_xtal(clocks: &mut ClockTree) {
2873 trace!("Enabling REF_TICK_XTAL");
2874 request_xtal_clk(clocks);
2875 enable_ref_tick_xtal_impl(clocks, true);
2876 }
2877 pub fn release_ref_tick_xtal(clocks: &mut ClockTree) {
2878 trace!("Disabling REF_TICK_XTAL");
2879 enable_ref_tick_xtal_impl(clocks, false);
2880 release_xtal_clk(clocks);
2881 }
2882 pub fn ref_tick_xtal_config_frequency(config: RefTickXtalConfig) -> u32 {
2883 (xtal_clk_frequency() / (config.divisor() + 1))
2884 }
2885 pub fn ref_tick_xtal_frequency() -> u32 {
2886 REF_TICK_XTAL_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2887 }
2888 pub fn ref_tick_xtal_source_frequency() -> u32 {
2889 xtal_clk_frequency()
2890 }
2891 pub fn configure_ref_tick_ck8m(clocks: &mut ClockTree, config: RefTickCk8mConfig) {
2892 let old_config = clocks.ref_tick_ck8m.replace(config);
2893 refresh_ref_tick_ck8m_downstream(clocks);
2894 configure_ref_tick_ck8m_impl(clocks, old_config, config);
2895 }
2896 pub fn ref_tick_ck8m_config(clocks: &mut ClockTree) -> Option<RefTickCk8mConfig> {
2897 clocks.ref_tick_ck8m
2898 }
2899 pub fn request_ref_tick_ck8m(clocks: &mut ClockTree) {
2900 trace!("Enabling REF_TICK_CK8M");
2901 request_rc_fast_clk(clocks);
2902 enable_ref_tick_ck8m_impl(clocks, true);
2903 }
2904 pub fn release_ref_tick_ck8m(clocks: &mut ClockTree) {
2905 trace!("Disabling REF_TICK_CK8M");
2906 enable_ref_tick_ck8m_impl(clocks, false);
2907 release_rc_fast_clk(clocks);
2908 }
2909 pub fn ref_tick_ck8m_config_frequency(config: RefTickCk8mConfig) -> u32 {
2910 (rc_fast_clk_frequency() / (config.divisor() + 1))
2911 }
2912 pub fn ref_tick_ck8m_frequency() -> u32 {
2913 REF_TICK_CK8M_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2914 }
2915 pub fn ref_tick_ck8m_source_frequency() -> u32 {
2916 rc_fast_clk_frequency()
2917 }
2918 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
2919 let old_selector = clocks.cpu_clk.replace(new_selector);
2920 refresh_cpu_clk_downstream(clocks);
2921 match new_selector {
2922 CpuClkConfig::Xtal => {
2923 configure_system_pre_div_in(clocks, SystemPreDivInConfig::Xtal);
2924 configure_apb_clk(clocks, ApbClkConfig::Xtal);
2925 configure_ref_tick(clocks, RefTickConfig::Xtal);
2926 let config_value =
2927 RefTickXtalConfig::new(((xtal_clk_frequency() / 1000000) - 1));
2928 configure_ref_tick_xtal(clocks, config_value);
2929 }
2930 CpuClkConfig::RcFast => {
2931 configure_system_pre_div_in(clocks, SystemPreDivInConfig::RcFast);
2932 configure_apb_clk(clocks, ApbClkConfig::RcFast);
2933 configure_ref_tick(clocks, RefTickConfig::RcFast);
2934 let config_value =
2935 RefTickCk8mConfig::new(((rc_fast_clk_frequency() / 1000000) - 1));
2936 configure_ref_tick_ck8m(clocks, config_value);
2937 }
2938 CpuClkConfig::Apll => {
2939 configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Apll);
2940 configure_apb_clk(clocks, ApbClkConfig::Apll);
2941 configure_ref_tick(clocks, RefTickConfig::Apll);
2942 let config_value =
2943 RefTickXtalConfig::new(((xtal_clk_frequency() / 1000000) - 1));
2944 configure_ref_tick_xtal(clocks, config_value);
2945 }
2946 CpuClkConfig::Pll => {
2947 configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Pll);
2948 configure_apb_clk(clocks, ApbClkConfig::Pll);
2949 configure_ref_tick(clocks, RefTickConfig::Pll);
2950 let config_value =
2951 RefTickXtalConfig::new(((xtal_clk_frequency() / 1000000) - 1));
2952 configure_ref_tick_xtal(clocks, config_value);
2953 }
2954 }
2955 match new_selector {
2956 CpuClkConfig::Xtal => request_system_pre_div(clocks),
2957 CpuClkConfig::RcFast => request_system_pre_div(clocks),
2958 CpuClkConfig::Apll => request_cpu_pll_div(clocks),
2959 CpuClkConfig::Pll => request_cpu_pll_div(clocks),
2960 }
2961 configure_cpu_clk_impl(clocks, old_selector, new_selector);
2962 if let Some(old_selector) = old_selector {
2963 match old_selector {
2964 CpuClkConfig::Xtal => release_system_pre_div(clocks),
2965 CpuClkConfig::RcFast => release_system_pre_div(clocks),
2966 CpuClkConfig::Apll => release_cpu_pll_div(clocks),
2967 CpuClkConfig::Pll => release_cpu_pll_div(clocks),
2968 }
2969 }
2970 }
2971 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2972 clocks.cpu_clk
2973 }
2974 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2975 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2976 pub fn cpu_clk_config_frequency(config: CpuClkConfig) -> u32 {
2977 match config {
2978 CpuClkConfig::Xtal => system_pre_div_frequency(),
2979 CpuClkConfig::RcFast => system_pre_div_frequency(),
2980 CpuClkConfig::Apll => cpu_pll_div_frequency(),
2981 CpuClkConfig::Pll => cpu_pll_div_frequency(),
2982 }
2983 }
2984 pub fn cpu_clk_frequency() -> u32 {
2985 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2986 }
2987 pub fn request_apb_clk_cpu_div2(clocks: &mut ClockTree) {
2988 trace!("Enabling APB_CLK_CPU_DIV2");
2989 request_cpu_clk(clocks);
2990 enable_apb_clk_cpu_div2_impl(clocks, true);
2991 }
2992 pub fn release_apb_clk_cpu_div2(clocks: &mut ClockTree) {
2993 trace!("Disabling APB_CLK_CPU_DIV2");
2994 enable_apb_clk_cpu_div2_impl(clocks, false);
2995 release_cpu_clk(clocks);
2996 }
2997 pub fn apb_clk_cpu_div2_frequency() -> u32 {
2998 (cpu_clk_frequency() / 2)
2999 }
3000 pub fn apb_clk_cpu_div2_source_frequency() -> u32 {
3001 cpu_clk_frequency()
3002 }
3003 pub fn request_apb_clk_80m(clocks: &mut ClockTree) {
3004 trace!("Enabling APB_CLK_80M");
3005 request_cpu_clk(clocks);
3006 enable_apb_clk_80m_impl(clocks, true);
3007 }
3008 pub fn release_apb_clk_80m(clocks: &mut ClockTree) {
3009 trace!("Disabling APB_CLK_80M");
3010 enable_apb_clk_80m_impl(clocks, false);
3011 release_cpu_clk(clocks);
3012 }
3013 pub fn apb_clk_80m_frequency() -> u32 {
3014 80000000
3015 }
3016 pub fn apb_clk_80m_source_frequency() -> u32 {
3017 cpu_clk_frequency()
3018 }
3019 #[cfg(use_xtal32k)]
3020 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
3021 trace!("Requesting XTAL32K_CLK");
3022 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
3023 trace!("Enabling XTAL32K_CLK");
3024 enable_xtal32k_clk_impl(clocks, true);
3025 }
3026 }
3027 #[cfg(use_xtal32k)]
3028 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
3029 trace!("Releasing XTAL32K_CLK");
3030 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
3031 trace!("Disabling XTAL32K_CLK");
3032 enable_xtal32k_clk_impl(clocks, false);
3033 }
3034 }
3035 #[cfg(use_xtal32k)]
3036 pub fn xtal32k_clk_frequency() -> u32 {
3037 32768
3038 }
3039 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
3040 trace!("Enabling RC_SLOW_CLK");
3041 enable_rc_slow_clk_impl(clocks, true);
3042 }
3043 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
3044 trace!("Disabling RC_SLOW_CLK");
3045 enable_rc_slow_clk_impl(clocks, false);
3046 }
3047 static RC_SLOW_CLK_FREQUENCY: ::core::sync::atomic::AtomicU32 =
3048 ::core::sync::atomic::AtomicU32::new(rc_slow_clk_nominal_frequency());
3049 pub const fn rc_slow_clk_nominal_frequency() -> u32 {
3050 90000
3051 }
3052 pub fn rc_slow_clk_frequency() -> u32 {
3053 RC_SLOW_CLK_FREQUENCY.load(::core::sync::atomic::Ordering::Acquire)
3054 }
3055 pub fn set_rc_slow_clk_frequency(clocks: &mut ClockTree, frequency: u32) {
3056 if !(45000..=135000).contains(&frequency) {
3057 warn!(
3058 "Ignoring out-of-range RC_SLOW_CLK frequency: {} Hz",
3059 frequency
3060 );
3061 return;
3062 }
3063 debug!(
3064 "Updating RC_SLOW_CLK frequency to {} Hz (nominal {} Hz)",
3065 frequency,
3066 rc_slow_clk_nominal_frequency()
3067 );
3068 RC_SLOW_CLK_FREQUENCY.store(frequency, ::core::sync::atomic::Ordering::Release);
3069 refresh_rc_slow_clk_downstream(clocks);
3070 }
3071 pub fn request_rc_fast_div_clk(clocks: &mut ClockTree) {
3072 trace!("Requesting RC_FAST_DIV_CLK");
3073 if increment_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
3074 trace!("Enabling RC_FAST_DIV_CLK");
3075 request_rc_fast_clk(clocks);
3076 enable_rc_fast_div_clk_impl(clocks, true);
3077 }
3078 }
3079 pub fn release_rc_fast_div_clk(clocks: &mut ClockTree) {
3080 trace!("Releasing RC_FAST_DIV_CLK");
3081 if decrement_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
3082 trace!("Disabling RC_FAST_DIV_CLK");
3083 enable_rc_fast_div_clk_impl(clocks, false);
3084 release_rc_fast_clk(clocks);
3085 }
3086 }
3087 pub fn rc_fast_div_clk_frequency() -> u32 {
3088 (rc_fast_clk_frequency() / 256)
3089 }
3090 pub fn rc_fast_div_clk_source_frequency() -> u32 {
3091 rc_fast_clk_frequency()
3092 }
3093 pub fn request_xtal_div_clk(clocks: &mut ClockTree) {
3094 trace!("Enabling XTAL_DIV_CLK");
3095 request_xtal_clk(clocks);
3096 enable_xtal_div_clk_impl(clocks, true);
3097 }
3098 pub fn release_xtal_div_clk(clocks: &mut ClockTree) {
3099 trace!("Disabling XTAL_DIV_CLK");
3100 enable_xtal_div_clk_impl(clocks, false);
3101 release_xtal_clk(clocks);
3102 }
3103 pub fn xtal_div_clk_frequency() -> u32 {
3104 (xtal_clk_frequency() / 4)
3105 }
3106 pub fn xtal_div_clk_source_frequency() -> u32 {
3107 xtal_clk_frequency()
3108 }
3109 pub fn configure_rtc_slow_clk(clocks: &mut ClockTree, new_selector: RtcSlowClkConfig) {
3110 let old_selector = clocks.rtc_slow_clk.replace(new_selector);
3111 refresh_rtc_slow_clk_downstream(clocks);
3112 match new_selector {
3113 #[cfg(use_xtal32k)]
3114 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3115 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3116 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
3117 }
3118 configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
3119 if let Some(old_selector) = old_selector {
3120 match old_selector {
3121 #[cfg(use_xtal32k)]
3122 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3123 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3124 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
3125 }
3126 }
3127 }
3128 pub fn rtc_slow_clk_config(clocks: &mut ClockTree) -> Option<RtcSlowClkConfig> {
3129 clocks.rtc_slow_clk
3130 }
3131 pub fn request_rtc_slow_clk(clocks: &mut ClockTree) {
3132 trace!("Enabling RTC_SLOW_CLK");
3133 match unwrap!(clocks.rtc_slow_clk) {
3134 #[cfg(use_xtal32k)]
3135 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
3136 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
3137 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
3138 }
3139 enable_rtc_slow_clk_impl(clocks, true);
3140 }
3141 pub fn release_rtc_slow_clk(clocks: &mut ClockTree) {
3142 trace!("Disabling RTC_SLOW_CLK");
3143 enable_rtc_slow_clk_impl(clocks, false);
3144 match unwrap!(clocks.rtc_slow_clk) {
3145 #[cfg(use_xtal32k)]
3146 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3147 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
3148 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
3149 }
3150 }
3151 pub fn rtc_slow_clk_config_frequency(config: RtcSlowClkConfig) -> u32 {
3152 match config {
3153 #[cfg(use_xtal32k)]
3154 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
3155 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
3156 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
3157 }
3158 }
3159 pub fn rtc_slow_clk_frequency() -> u32 {
3160 RTC_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3161 }
3162 pub fn rtc_slow_clk_source_frequency(source: RtcSlowClkConfig) -> u32 {
3163 rtc_slow_clk_config_frequency(source)
3164 }
3165 pub fn configure_rtc_fast_clk(clocks: &mut ClockTree, new_selector: RtcFastClkConfig) {
3166 let old_selector = clocks.rtc_fast_clk.replace(new_selector);
3167 refresh_rtc_fast_clk_downstream(clocks);
3168 let active = clocks.rtc_fast_clk_refcount > 0;
3169 if active {
3170 match new_selector {
3171 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
3172 RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
3173 }
3174 }
3175 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
3176 if active && let Some(old_selector) = old_selector {
3177 match old_selector {
3178 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
3179 RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
3180 }
3181 }
3182 }
3183 pub fn rtc_fast_clk_config(clocks: &mut ClockTree) -> Option<RtcFastClkConfig> {
3184 clocks.rtc_fast_clk
3185 }
3186 pub fn request_rtc_fast_clk(clocks: &mut ClockTree) {
3187 trace!("Requesting RTC_FAST_CLK");
3188 if increment_reference_count(&mut clocks.rtc_fast_clk_refcount) {
3189 trace!("Enabling RTC_FAST_CLK");
3190 match unwrap!(clocks.rtc_fast_clk) {
3191 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
3192 RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
3193 }
3194 enable_rtc_fast_clk_impl(clocks, true);
3195 }
3196 }
3197 pub fn release_rtc_fast_clk(clocks: &mut ClockTree) {
3198 trace!("Releasing RTC_FAST_CLK");
3199 if decrement_reference_count(&mut clocks.rtc_fast_clk_refcount) {
3200 trace!("Disabling RTC_FAST_CLK");
3201 enable_rtc_fast_clk_impl(clocks, false);
3202 match unwrap!(clocks.rtc_fast_clk) {
3203 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
3204 RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
3205 }
3206 }
3207 }
3208 pub fn rtc_fast_clk_config_frequency(config: RtcFastClkConfig) -> u32 {
3209 match config {
3210 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
3211 RtcFastClkConfig::Rc => rc_fast_clk_frequency(),
3212 }
3213 }
3214 pub fn rtc_fast_clk_frequency() -> u32 {
3215 RTC_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3216 }
3217 pub fn rtc_fast_clk_source_frequency(source: RtcFastClkConfig) -> u32 {
3218 rtc_fast_clk_config_frequency(source)
3219 }
3220 pub fn request_uart_mem_clk(clocks: &mut ClockTree) {
3221 trace!("Requesting UART_MEM_CLK");
3222 if increment_reference_count(&mut clocks.uart_mem_clk_refcount) {
3223 trace!("Enabling UART_MEM_CLK");
3224 request_xtal_clk(clocks);
3225 enable_uart_mem_clk_impl(clocks, true);
3226 }
3227 }
3228 pub fn release_uart_mem_clk(clocks: &mut ClockTree) {
3229 trace!("Releasing UART_MEM_CLK");
3230 if decrement_reference_count(&mut clocks.uart_mem_clk_refcount) {
3231 trace!("Disabling UART_MEM_CLK");
3232 enable_uart_mem_clk_impl(clocks, false);
3233 release_xtal_clk(clocks);
3234 }
3235 }
3236 pub fn uart_mem_clk_frequency() -> u32 {
3237 xtal_clk_frequency()
3238 }
3239 pub fn uart_mem_clk_source_frequency(source: UartMemClkConfig) -> u32 {
3240 match source {
3241 UartMemClkConfig::Xtal => xtal_clk_frequency(),
3242 }
3243 }
3244 pub fn configure_timg_calibration_clock(
3245 clocks: &mut ClockTree,
3246 new_selector: TimgCalibrationClockConfig,
3247 ) {
3248 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3249 refresh_timg_calibration_clock_downstream(clocks);
3250 let active = clocks.timg_calibration_clock_refcount > 0;
3251 if active {
3252 match new_selector {
3253 TimgCalibrationClockConfig::RtcClk => request_rtc_slow_clk(clocks),
3254 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
3255 #[cfg(use_xtal32k)]
3256 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3257 }
3258 }
3259 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3260 if active && let Some(old_selector) = old_selector {
3261 match old_selector {
3262 TimgCalibrationClockConfig::RtcClk => release_rtc_slow_clk(clocks),
3263 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
3264 #[cfg(use_xtal32k)]
3265 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3266 }
3267 }
3268 }
3269 pub fn timg_calibration_clock_config(
3270 clocks: &mut ClockTree,
3271 ) -> Option<TimgCalibrationClockConfig> {
3272 clocks.timg_calibration_clock
3273 }
3274 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3275 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3276 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3277 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3278 crate::rtc_cntl::WakeLock::acquire();
3279 match unwrap!(clocks.timg_calibration_clock) {
3280 TimgCalibrationClockConfig::RtcClk => request_rtc_slow_clk(clocks),
3281 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
3282 #[cfg(use_xtal32k)]
3283 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3284 }
3285 enable_timg_calibration_clock_impl(clocks, true);
3286 }
3287 }
3288 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3289 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3290 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3291 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3292 crate::rtc_cntl::WakeLock::release();
3293 enable_timg_calibration_clock_impl(clocks, false);
3294 match unwrap!(clocks.timg_calibration_clock) {
3295 TimgCalibrationClockConfig::RtcClk => release_rtc_slow_clk(clocks),
3296 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
3297 #[cfg(use_xtal32k)]
3298 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3299 }
3300 }
3301 }
3302 pub fn timg_calibration_clock_config_frequency(config: TimgCalibrationClockConfig) -> u32 {
3303 match config {
3304 TimgCalibrationClockConfig::RtcClk => rtc_slow_clk_frequency(),
3305 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
3306 #[cfg(use_xtal32k)]
3307 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3308 }
3309 }
3310 pub fn timg_calibration_clock_frequency() -> u32 {
3311 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3312 }
3313 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3314 timg_calibration_clock_config_frequency(source)
3315 }
3316 impl SdmInstance {
3317 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3318 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3319 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3320 {
3321 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3322 request_apb_clk(clocks);
3323 self.enable_function_clock_impl(clocks, true);
3324 }
3325 }
3326 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3327 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3328 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3329 {
3330 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3331 self.enable_function_clock_impl(clocks, false);
3332 release_apb_clk(clocks);
3333 }
3334 }
3335 pub fn function_clock_frequency(self) -> u32 {
3336 apb_clk_frequency()
3337 }
3338 pub fn function_clock_source_frequency() -> u32 {
3339 apb_clk_frequency()
3340 }
3341 }
3342 impl I2cInstance {
3343 pub fn configure_function_clock(
3344 self,
3345 clocks: &mut ClockTree,
3346 config: I2cFunctionClockConfig,
3347 ) {
3348 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3349 refresh_i2c_function_clock_downstream(clocks, self);
3350 let active = clocks.i2c_function_clock_refcount[self as usize] > 0;
3351 if active {
3352 match config.sclk {
3353 I2cFunctionClockSclk::Apb => request_apb_clk(clocks),
3354 I2cFunctionClockSclk::RefTick => request_ref_tick(clocks),
3355 }
3356 }
3357 self.configure_function_clock_impl(clocks, old_config, config);
3358 if active && let Some(old_config) = old_config {
3359 match old_config.sclk {
3360 I2cFunctionClockSclk::Apb => release_apb_clk(clocks),
3361 I2cFunctionClockSclk::RefTick => release_ref_tick(clocks),
3362 }
3363 }
3364 }
3365 pub fn function_clock_config(
3366 self,
3367 clocks: &mut ClockTree,
3368 ) -> Option<I2cFunctionClockConfig> {
3369 clocks.i2c_function_clock[self as usize]
3370 }
3371 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3372 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3373 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3374 {
3375 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3376 crate::rtc_cntl::WakeLock::acquire();
3377 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3378 I2cFunctionClockSclk::Apb => request_apb_clk(clocks),
3379 I2cFunctionClockSclk::RefTick => request_ref_tick(clocks),
3380 }
3381 self.enable_function_clock_impl(clocks, true);
3382 }
3383 }
3384 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3385 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3386 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3387 {
3388 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3389 crate::rtc_cntl::WakeLock::release();
3390 self.enable_function_clock_impl(clocks, false);
3391 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3392 I2cFunctionClockSclk::Apb => release_apb_clk(clocks),
3393 I2cFunctionClockSclk::RefTick => release_ref_tick(clocks),
3394 }
3395 }
3396 }
3397 pub fn function_clock_config_frequency(config: I2cFunctionClockConfig) -> u32 {
3398 match config.sclk {
3399 I2cFunctionClockSclk::Apb => apb_clk_frequency(),
3400 I2cFunctionClockSclk::RefTick => ref_tick_frequency(),
3401 }
3402 }
3403 pub fn function_clock_frequency(self) -> u32 {
3404 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3405 .load(::core::sync::atomic::Ordering::Acquire)
3406 }
3407 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3408 match sclk {
3409 I2cFunctionClockSclk::Apb => apb_clk_frequency(),
3410 I2cFunctionClockSclk::RefTick => ref_tick_frequency(),
3411 }
3412 }
3413 }
3414 impl I2sInstance {
3415 pub fn configure_mclk(self, clocks: &mut ClockTree, config: I2sMclkConfig) {
3416 let old_config = clocks.i2s_mclk[self as usize].replace(config);
3417 refresh_i2s_mclk_downstream(clocks, self);
3418 let active = clocks.i2s_mclk_refcount[self as usize] > 0;
3419 if active {
3420 match config.sclk {
3421 I2sMclkSclk::PllF160m => request_pll_f160m_clk(clocks),
3422 I2sMclkSclk::Apll => request_apll_clk(clocks),
3423 }
3424 }
3425 self.configure_mclk_impl(clocks, old_config, config);
3426 if active && let Some(old_config) = old_config {
3427 match old_config.sclk {
3428 I2sMclkSclk::PllF160m => release_pll_f160m_clk(clocks),
3429 I2sMclkSclk::Apll => release_apll_clk(clocks),
3430 }
3431 }
3432 }
3433 pub fn mclk_config(self, clocks: &mut ClockTree) -> Option<I2sMclkConfig> {
3434 clocks.i2s_mclk[self as usize]
3435 }
3436 pub fn request_mclk(self, clocks: &mut ClockTree) {
3437 trace!("Requesting {:?}::MCLK", self);
3438 if increment_reference_count(&mut clocks.i2s_mclk_refcount[self as usize]) {
3439 trace!("Enabling {:?}::MCLK", self);
3440 crate::rtc_cntl::WakeLock::acquire();
3441 match unwrap!(clocks.i2s_mclk[self as usize]).sclk {
3442 I2sMclkSclk::PllF160m => request_pll_f160m_clk(clocks),
3443 I2sMclkSclk::Apll => request_apll_clk(clocks),
3444 }
3445 self.enable_mclk_impl(clocks, true);
3446 }
3447 }
3448 pub fn release_mclk(self, clocks: &mut ClockTree) {
3449 trace!("Releasing {:?}::MCLK", self);
3450 if decrement_reference_count(&mut clocks.i2s_mclk_refcount[self as usize]) {
3451 trace!("Disabling {:?}::MCLK", self);
3452 crate::rtc_cntl::WakeLock::release();
3453 self.enable_mclk_impl(clocks, false);
3454 match unwrap!(clocks.i2s_mclk[self as usize]).sclk {
3455 I2sMclkSclk::PllF160m => release_pll_f160m_clk(clocks),
3456 I2sMclkSclk::Apll => release_apll_clk(clocks),
3457 }
3458 }
3459 }
3460 pub fn mclk_config_frequency(config: I2sMclkConfig) -> u32 {
3461 (((match config.sclk {
3462 I2sMclkSclk::PllF160m => pll_f160m_clk_frequency(),
3463 I2sMclkSclk::Apll => apll_clk_frequency(),
3464 } as u64)
3465 * (config.div_a() as u64))
3466 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3467 as u32
3468 }
3469 pub fn mclk_frequency(self) -> u32 {
3470 I2S_MCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3471 }
3472 pub fn mclk_source_frequency(sclk: I2sMclkSclk) -> u32 {
3473 match sclk {
3474 I2sMclkSclk::PllF160m => pll_f160m_clk_frequency(),
3475 I2sMclkSclk::Apll => apll_clk_frequency(),
3476 }
3477 }
3478 }
3479 impl RmtInstance {
3480 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3481 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3482 refresh_rmt_sclk_downstream(clocks, self);
3483 let active = clocks.rmt_sclk_refcount[self as usize] > 0;
3484 if active {
3485 match new_selector {
3486 RmtSclkConfig::RefTick => request_ref_tick(clocks),
3487 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3488 }
3489 }
3490 self.configure_sclk_impl(clocks, old_selector, new_selector);
3491 if active && let Some(old_selector) = old_selector {
3492 match old_selector {
3493 RmtSclkConfig::RefTick => release_ref_tick(clocks),
3494 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3495 }
3496 }
3497 }
3498 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3499 clocks.rmt_sclk[self as usize]
3500 }
3501 pub fn request_sclk(self, clocks: &mut ClockTree) {
3502 trace!("Requesting {:?}::SCLK", self);
3503 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3504 trace!("Enabling {:?}::SCLK", self);
3505 crate::rtc_cntl::WakeLock::acquire();
3506 match unwrap!(clocks.rmt_sclk[self as usize]) {
3507 RmtSclkConfig::RefTick => request_ref_tick(clocks),
3508 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3509 }
3510 self.enable_sclk_impl(clocks, true);
3511 }
3512 }
3513 pub fn release_sclk(self, clocks: &mut ClockTree) {
3514 trace!("Releasing {:?}::SCLK", self);
3515 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3516 trace!("Disabling {:?}::SCLK", self);
3517 crate::rtc_cntl::WakeLock::release();
3518 self.enable_sclk_impl(clocks, false);
3519 match unwrap!(clocks.rmt_sclk[self as usize]) {
3520 RmtSclkConfig::RefTick => release_ref_tick(clocks),
3521 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3522 }
3523 }
3524 }
3525 pub fn sclk_config_frequency(config: RmtSclkConfig) -> u32 {
3526 match config {
3527 RmtSclkConfig::RefTick => ref_tick_frequency(),
3528 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3529 }
3530 }
3531 pub fn sclk_frequency(self) -> u32 {
3532 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3533 }
3534 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3535 Self::sclk_config_frequency(source)
3536 }
3537 }
3538 impl SpiInstance {
3539 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3540 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3541 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3542 {
3543 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3544 crate::rtc_cntl::WakeLock::acquire();
3545 request_apb_clk(clocks);
3546 self.enable_function_clock_impl(clocks, true);
3547 }
3548 }
3549 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3550 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3551 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3552 {
3553 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3554 crate::rtc_cntl::WakeLock::release();
3555 self.enable_function_clock_impl(clocks, false);
3556 release_apb_clk(clocks);
3557 }
3558 }
3559 pub fn function_clock_frequency(self) -> u32 {
3560 apb_clk_frequency()
3561 }
3562 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3563 match source {
3564 SpiFunctionClockConfig::Apb => apb_clk_frequency(),
3565 }
3566 }
3567 }
3568 impl TimgInstance {
3569 pub fn configure_function_clock(
3570 self,
3571 clocks: &mut ClockTree,
3572 new_selector: TimgFunctionClockConfig,
3573 ) {
3574 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3575 refresh_timg_function_clock_downstream(clocks, self);
3576 let active = clocks.timg_function_clock_refcount[self as usize] > 0;
3577 if active {
3578 match new_selector {
3579 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3580 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3581 }
3582 }
3583 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3584 if active && let Some(old_selector) = old_selector {
3585 match old_selector {
3586 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3587 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3588 }
3589 }
3590 }
3591 pub fn function_clock_config(
3592 self,
3593 clocks: &mut ClockTree,
3594 ) -> Option<TimgFunctionClockConfig> {
3595 clocks.timg_function_clock[self as usize]
3596 }
3597 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3598 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3599 if increment_reference_count(
3600 &mut clocks.timg_function_clock_refcount[self as usize],
3601 ) {
3602 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3603 match unwrap!(clocks.timg_function_clock[self as usize]) {
3604 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3605 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3606 }
3607 self.enable_function_clock_impl(clocks, true);
3608 }
3609 }
3610 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3611 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3612 if decrement_reference_count(
3613 &mut clocks.timg_function_clock_refcount[self as usize],
3614 ) {
3615 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3616 self.enable_function_clock_impl(clocks, false);
3617 match unwrap!(clocks.timg_function_clock[self as usize]) {
3618 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3619 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3620 }
3621 }
3622 }
3623 pub fn function_clock_config_frequency(config: TimgFunctionClockConfig) -> u32 {
3624 match config {
3625 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3626 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3627 }
3628 }
3629 pub fn function_clock_frequency(self) -> u32 {
3630 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3631 .load(::core::sync::atomic::Ordering::Acquire)
3632 }
3633 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3634 Self::function_clock_config_frequency(source)
3635 }
3636 }
3637 impl UartInstance {
3638 pub fn configure_function_clock(
3639 self,
3640 clocks: &mut ClockTree,
3641 config: UartFunctionClockConfig,
3642 ) {
3643 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3644 refresh_uart_function_clock_downstream(clocks, self);
3645 let active = clocks.uart_function_clock_refcount[self as usize] > 0;
3646 if active {
3647 match config.sclk {
3648 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3649 UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
3650 }
3651 }
3652 self.configure_function_clock_impl(clocks, old_config, config);
3653 if active && let Some(old_config) = old_config {
3654 match old_config.sclk {
3655 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3656 UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
3657 }
3658 }
3659 }
3660 pub fn function_clock_config(
3661 self,
3662 clocks: &mut ClockTree,
3663 ) -> Option<UartFunctionClockConfig> {
3664 clocks.uart_function_clock[self as usize]
3665 }
3666 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3667 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3668 if increment_reference_count(
3669 &mut clocks.uart_function_clock_refcount[self as usize],
3670 ) {
3671 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3672 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3673 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3674 UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
3675 }
3676 self.enable_function_clock_impl(clocks, true);
3677 }
3678 }
3679 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3680 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3681 if decrement_reference_count(
3682 &mut clocks.uart_function_clock_refcount[self as usize],
3683 ) {
3684 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3685 self.enable_function_clock_impl(clocks, false);
3686 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3687 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3688 UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
3689 }
3690 }
3691 }
3692 pub fn function_clock_config_frequency(config: UartFunctionClockConfig) -> u32 {
3693 match config.sclk {
3694 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3695 UartFunctionClockSclk::RefTick => ref_tick_frequency(),
3696 }
3697 }
3698 pub fn function_clock_frequency(self) -> u32 {
3699 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3700 .load(::core::sync::atomic::Ordering::Acquire)
3701 }
3702 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3703 match sclk {
3704 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3705 UartFunctionClockSclk::RefTick => ref_tick_frequency(),
3706 }
3707 }
3708 pub fn configure_baud_rate_generator(
3709 self,
3710 clocks: &mut ClockTree,
3711 config: UartBaudRateGeneratorConfig,
3712 ) {
3713 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3714 refresh_uart_baud_rate_generator_downstream(clocks, self);
3715 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3716 }
3717 pub fn baud_rate_generator_config(
3718 self,
3719 clocks: &mut ClockTree,
3720 ) -> Option<UartBaudRateGeneratorConfig> {
3721 clocks.uart_baud_rate_generator[self as usize]
3722 }
3723 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3724 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3725 if increment_reference_count(
3726 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3727 ) {
3728 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3729 self.request_function_clock(clocks);
3730 self.enable_baud_rate_generator_impl(clocks, true);
3731 }
3732 }
3733 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3734 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3735 if decrement_reference_count(
3736 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3737 ) {
3738 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3739 self.enable_baud_rate_generator_impl(clocks, false);
3740 self.release_function_clock(clocks);
3741 }
3742 }
3743 pub fn baud_rate_generator_config_frequency(
3744 self,
3745 config: UartBaudRateGeneratorConfig,
3746 ) -> u32 {
3747 ((self.function_clock_frequency() * 16)
3748 / ((config.integral() * 16) + config.fractional()))
3749 }
3750 pub fn baud_rate_generator_frequency(self) -> u32 {
3751 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3752 .load(::core::sync::atomic::Ordering::Acquire)
3753 }
3754 pub fn request_mem_clock(self, clocks: &mut ClockTree) {
3755 trace!("Requesting {:?}::MEM_CLOCK", self);
3756 if increment_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3757 trace!("Enabling {:?}::MEM_CLOCK", self);
3758 request_uart_mem_clk(clocks);
3759 self.enable_mem_clock_impl(clocks, true);
3760 }
3761 }
3762 pub fn release_mem_clock(self, clocks: &mut ClockTree) {
3763 trace!("Releasing {:?}::MEM_CLOCK", self);
3764 if decrement_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3765 trace!("Disabling {:?}::MEM_CLOCK", self);
3766 self.enable_mem_clock_impl(clocks, false);
3767 release_uart_mem_clk(clocks);
3768 }
3769 }
3770 pub fn mem_clock_frequency(self) -> u32 {
3771 uart_mem_clk_frequency()
3772 }
3773 pub fn mem_clock_source_frequency() -> u32 {
3774 uart_mem_clk_frequency()
3775 }
3776 }
3777 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3785 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3786 #[instability::unstable]
3787 pub struct ClockConfig {
3788 pub xtal_clk: Option<XtalClkConfig>,
3790 pub pll_clk: Option<PllClkConfig>,
3792 pub apll_clk: Option<ApllClkConfig>,
3794 pub cpu_pll_div: Option<CpuPllDivConfig>,
3796 pub system_pre_div: Option<SystemPreDivConfig>,
3798 pub cpu_clk: Option<CpuClkConfig>,
3800 pub rtc_slow_clk: Option<RtcSlowClkConfig>,
3802 pub rtc_fast_clk: Option<RtcFastClkConfig>,
3804 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3806 }
3807 impl ClockConfig {
3808 fn apply(&self, clocks: &mut ClockTree) {
3809 if let Some(config) = self.xtal_clk {
3810 configure_xtal_clk(clocks, config);
3811 }
3812 if let Some(config) = self.pll_clk {
3813 configure_pll_clk(clocks, config);
3814 }
3815 if let Some(config) = self.apll_clk {
3816 configure_apll_clk(clocks, config);
3817 }
3818 if let Some(config) = self.cpu_pll_div {
3819 configure_cpu_pll_div(clocks, config);
3820 }
3821 if let Some(config) = self.system_pre_div {
3822 configure_system_pre_div(clocks, config);
3823 }
3824 if let Some(config) = self.cpu_clk {
3825 configure_cpu_clk(clocks, config);
3826 }
3827 if let Some(config) = self.rtc_slow_clk {
3828 configure_rtc_slow_clk(clocks, config);
3829 }
3830 if let Some(config) = self.rtc_fast_clk {
3831 configure_rtc_fast_clk(clocks, config);
3832 }
3833 if let Some(config) = self.timg_calibration_clock {
3834 configure_timg_calibration_clock(clocks, config);
3835 }
3836 }
3837 }
3838 fn increment_reference_count(refcount: &mut u32) -> bool {
3839 let first = *refcount == 0;
3840 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3841 first
3842 }
3843 fn decrement_reference_count(refcount: &mut u32) -> bool {
3844 *refcount = refcount.saturating_sub(1);
3845 let last = *refcount == 0;
3846 last
3847 }
3848 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3849 if let Some(config) = clocks.xtal_clk {
3850 XTAL_CLK_FREQ_CACHE.store(
3851 xtal_clk_config_frequency(config),
3852 ::core::sync::atomic::Ordering::Release,
3853 );
3854 }
3855 refresh_pll_clk_downstream(clocks);
3856 refresh_system_pre_div_in_downstream(clocks);
3857 refresh_ref_tick_xtal_downstream(clocks);
3858 refresh_rtc_fast_clk_downstream(clocks);
3859 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3860 refresh_timg_function_clock_downstream(clocks, child_instance);
3861 }
3862 }
3863 fn refresh_pll_clk_downstream(clocks: &mut ClockTree) {
3864 if let Some(config) = clocks.pll_clk {
3865 PLL_CLK_FREQ_CACHE.store(
3866 pll_clk_config_frequency(config),
3867 ::core::sync::atomic::Ordering::Release,
3868 );
3869 }
3870 refresh_apll_clk_downstream(clocks);
3871 refresh_cpu_pll_div_in_downstream(clocks);
3872 for child_instance in [I2sInstance::I2s0] {
3873 refresh_i2s_mclk_downstream(clocks, child_instance);
3874 }
3875 }
3876 fn refresh_apll_clk_downstream(clocks: &mut ClockTree) {
3877 if let Some(config) = clocks.apll_clk {
3878 APLL_CLK_FREQ_CACHE.store(
3879 apll_clk_config_frequency(config),
3880 ::core::sync::atomic::Ordering::Release,
3881 );
3882 }
3883 refresh_cpu_pll_div_in_downstream(clocks);
3884 for child_instance in [I2sInstance::I2s0] {
3885 refresh_i2s_mclk_downstream(clocks, child_instance);
3886 }
3887 }
3888 fn refresh_rc_fast_clk_downstream(clocks: &mut ClockTree) {
3889 refresh_system_pre_div_in_downstream(clocks);
3890 refresh_ref_tick_ck8m_downstream(clocks);
3891 refresh_rtc_slow_clk_downstream(clocks);
3892 refresh_rtc_fast_clk_downstream(clocks);
3893 refresh_timg_calibration_clock_downstream(clocks);
3894 }
3895 fn refresh_cpu_pll_div_in_downstream(clocks: &mut ClockTree) {
3896 if let Some(config) = clocks.cpu_pll_div_in {
3897 CPU_PLL_DIV_IN_FREQ_CACHE.store(
3898 cpu_pll_div_in_config_frequency(config),
3899 ::core::sync::atomic::Ordering::Release,
3900 );
3901 }
3902 refresh_cpu_pll_div_downstream(clocks);
3903 }
3904 fn refresh_cpu_pll_div_downstream(clocks: &mut ClockTree) {
3905 if let Some(config) = clocks.cpu_pll_div {
3906 CPU_PLL_DIV_FREQ_CACHE.store(
3907 cpu_pll_div_config_frequency(config),
3908 ::core::sync::atomic::Ordering::Release,
3909 );
3910 }
3911 refresh_cpu_clk_downstream(clocks);
3912 }
3913 fn refresh_system_pre_div_in_downstream(clocks: &mut ClockTree) {
3914 if let Some(config) = clocks.system_pre_div_in {
3915 SYSTEM_PRE_DIV_IN_FREQ_CACHE.store(
3916 system_pre_div_in_config_frequency(config),
3917 ::core::sync::atomic::Ordering::Release,
3918 );
3919 }
3920 refresh_system_pre_div_downstream(clocks);
3921 }
3922 fn refresh_system_pre_div_downstream(clocks: &mut ClockTree) {
3923 if let Some(config) = clocks.system_pre_div {
3924 SYSTEM_PRE_DIV_FREQ_CACHE.store(
3925 system_pre_div_config_frequency(config),
3926 ::core::sync::atomic::Ordering::Release,
3927 );
3928 }
3929 refresh_cpu_clk_downstream(clocks);
3930 }
3931 fn refresh_ref_tick_xtal_downstream(clocks: &mut ClockTree) {
3932 if let Some(config) = clocks.ref_tick_xtal {
3933 REF_TICK_XTAL_FREQ_CACHE.store(
3934 ref_tick_xtal_config_frequency(config),
3935 ::core::sync::atomic::Ordering::Release,
3936 );
3937 }
3938 refresh_ref_tick_downstream(clocks);
3939 }
3940 fn refresh_ref_tick_ck8m_downstream(clocks: &mut ClockTree) {
3941 if let Some(config) = clocks.ref_tick_ck8m {
3942 REF_TICK_CK8M_FREQ_CACHE.store(
3943 ref_tick_ck8m_config_frequency(config),
3944 ::core::sync::atomic::Ordering::Release,
3945 );
3946 }
3947 refresh_ref_tick_downstream(clocks);
3948 }
3949 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3950 if let Some(config) = clocks.cpu_clk {
3951 CPU_CLK_FREQ_CACHE.store(
3952 cpu_clk_config_frequency(config),
3953 ::core::sync::atomic::Ordering::Release,
3954 );
3955 }
3956 refresh_apb_clk_downstream(clocks);
3957 }
3958 fn refresh_rc_slow_clk_downstream(clocks: &mut ClockTree) {
3959 refresh_rtc_slow_clk_downstream(clocks);
3960 }
3961 fn refresh_rtc_slow_clk_downstream(clocks: &mut ClockTree) {
3962 if let Some(config) = clocks.rtc_slow_clk {
3963 RTC_SLOW_CLK_FREQ_CACHE.store(
3964 rtc_slow_clk_config_frequency(config),
3965 ::core::sync::atomic::Ordering::Release,
3966 );
3967 }
3968 refresh_timg_calibration_clock_downstream(clocks);
3969 }
3970 fn refresh_rtc_fast_clk_downstream(clocks: &mut ClockTree) {
3971 if let Some(config) = clocks.rtc_fast_clk {
3972 RTC_FAST_CLK_FREQ_CACHE.store(
3973 rtc_fast_clk_config_frequency(config),
3974 ::core::sync::atomic::Ordering::Release,
3975 );
3976 }
3977 }
3978 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3979 if let Some(config) = clocks.timg_calibration_clock {
3980 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3981 timg_calibration_clock_config_frequency(config),
3982 ::core::sync::atomic::Ordering::Release,
3983 );
3984 }
3985 }
3986 fn refresh_i2s_mclk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
3987 if let Some(config) = clocks.i2s_mclk[instance as usize] {
3988 I2S_MCLK_FREQ_CACHE[instance as usize].store(
3989 I2sInstance::mclk_config_frequency(config),
3990 ::core::sync::atomic::Ordering::Release,
3991 );
3992 }
3993 }
3994 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3995 if let Some(config) = clocks.apb_clk {
3996 APB_CLK_FREQ_CACHE.store(
3997 apb_clk_config_frequency(config),
3998 ::core::sync::atomic::Ordering::Release,
3999 );
4000 }
4001 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
4002 refresh_i2c_function_clock_downstream(clocks, child_instance);
4003 }
4004 for child_instance in [RmtInstance::Rmt] {
4005 refresh_rmt_sclk_downstream(clocks, child_instance);
4006 }
4007 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
4008 refresh_timg_function_clock_downstream(clocks, child_instance);
4009 }
4010 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4011 refresh_uart_function_clock_downstream(clocks, child_instance);
4012 }
4013 }
4014 fn refresh_ref_tick_downstream(clocks: &mut ClockTree) {
4015 if let Some(config) = clocks.ref_tick {
4016 REF_TICK_FREQ_CACHE.store(
4017 ref_tick_config_frequency(config),
4018 ::core::sync::atomic::Ordering::Release,
4019 );
4020 }
4021 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
4022 refresh_i2c_function_clock_downstream(clocks, child_instance);
4023 }
4024 for child_instance in [RmtInstance::Rmt] {
4025 refresh_rmt_sclk_downstream(clocks, child_instance);
4026 }
4027 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4028 refresh_uart_function_clock_downstream(clocks, child_instance);
4029 }
4030 }
4031 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
4032 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
4033 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4034 I2cInstance::function_clock_config_frequency(config),
4035 ::core::sync::atomic::Ordering::Release,
4036 );
4037 }
4038 }
4039 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
4040 if let Some(config) = clocks.rmt_sclk[instance as usize] {
4041 RMT_SCLK_FREQ_CACHE[instance as usize].store(
4042 RmtInstance::sclk_config_frequency(config),
4043 ::core::sync::atomic::Ordering::Release,
4044 );
4045 }
4046 }
4047 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4048 if let Some(config) = clocks.timg_function_clock[instance as usize] {
4049 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4050 TimgInstance::function_clock_config_frequency(config),
4051 ::core::sync::atomic::Ordering::Release,
4052 );
4053 }
4054 }
4055 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4056 if let Some(config) = clocks.uart_function_clock[instance as usize] {
4057 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4058 UartInstance::function_clock_config_frequency(config),
4059 ::core::sync::atomic::Ordering::Release,
4060 );
4061 }
4062 refresh_uart_baud_rate_generator_downstream(clocks, instance);
4063 }
4064 fn refresh_uart_baud_rate_generator_downstream(
4065 clocks: &mut ClockTree,
4066 instance: UartInstance,
4067 ) {
4068 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4069 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4070 instance.baud_rate_generator_config_frequency(config),
4071 ::core::sync::atomic::Ordering::Release,
4072 );
4073 }
4074 }
4075 };
4076}
4077#[macro_export]
4081#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4082macro_rules! implement_peripheral_clocks {
4083 () => {
4084 #[doc(hidden)]
4085 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4086 #[repr(u8)]
4087 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4088 pub enum Peripheral {
4089 Aes,
4091 ApbSarAdc,
4093 CopyDma,
4095 CryptoDma,
4097 DedicatedGpio,
4099 Ds,
4101 GpioSd,
4103 Hmac,
4105 I2cExt0,
4107 I2cExt1,
4109 I2s0,
4111 Ledc,
4113 Mcpwm0,
4115 Mcpwm1,
4117 Pcnt,
4119 Rmt,
4121 Rsa,
4123 Sha,
4125 Spi2,
4127 Spi2Dma,
4129 Spi3,
4131 Spi3Dma,
4133 Systimer,
4135 Timg0,
4137 Timg1,
4139 Twai0,
4141 Uart0,
4143 Uart1,
4145 UartMem,
4147 Uhci0,
4149 Uhci1,
4151 UsbFs,
4153 Wdg,
4155 }
4156 impl Peripheral {
4157 const KEEP_ENABLED: &[Peripheral] =
4158 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UartMem];
4159 const COUNT: usize = Self::ALL.len();
4160 const ALL: &[Self] = &[
4161 Self::Aes,
4162 Self::ApbSarAdc,
4163 Self::CopyDma,
4164 Self::CryptoDma,
4165 Self::DedicatedGpio,
4166 Self::Ds,
4167 Self::GpioSd,
4168 Self::Hmac,
4169 Self::I2cExt0,
4170 Self::I2cExt1,
4171 Self::I2s0,
4172 Self::Ledc,
4173 Self::Mcpwm0,
4174 Self::Mcpwm1,
4175 Self::Pcnt,
4176 Self::Rmt,
4177 Self::Rsa,
4178 Self::Sha,
4179 Self::Spi2,
4180 Self::Spi2Dma,
4181 Self::Spi3,
4182 Self::Spi3Dma,
4183 Self::Systimer,
4184 Self::Timg0,
4185 Self::Timg1,
4186 Self::Twai0,
4187 Self::Uart0,
4188 Self::Uart1,
4189 Self::UartMem,
4190 Self::Uhci0,
4191 Self::Uhci1,
4192 Self::UsbFs,
4193 Self::Wdg,
4194 ];
4195 }
4196 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4197 match peripheral {
4198 Peripheral::Aes => {
4199 crate::peripherals::SYSTEM::regs()
4200 .perip_clk_en1()
4201 .modify(|_, w| w.crypto_aes_clk_en().bit(enable));
4202 }
4203 Peripheral::ApbSarAdc => {
4204 crate::peripherals::SYSTEM::regs()
4205 .perip_clk_en0()
4206 .modify(|_, w| w.apb_saradc_clk_en().bit(enable));
4207 }
4208 Peripheral::CopyDma => {
4209 crate::peripherals::DMA_COPY::regs()
4210 .conf()
4211 .modify(|_, w| w.clk_en().bit(enable));
4212 }
4213 Peripheral::CryptoDma => {
4214 crate::peripherals::SYSTEM::regs()
4215 .perip_clk_en1()
4216 .modify(|_, w| w.crypto_dma_clk_en().bit(enable));
4217 }
4218 Peripheral::DedicatedGpio => {
4219 crate::peripherals::SYSTEM::regs()
4220 .cpu_peri_clk_en()
4221 .modify(|_, w| w.dedicated_gpio_clk_en().bit(enable));
4222 }
4223 Peripheral::Ds => {
4224 crate::peripherals::SYSTEM::regs()
4225 .perip_clk_en1()
4226 .modify(|_, w| w.crypto_ds_clk_en().bit(enable));
4227 }
4228 Peripheral::GpioSd => {
4229 crate::peripherals::GPIO_SD::regs()
4230 .clock_gate()
4231 .modify(|_, w| w.clk_en().bit(enable));
4232 }
4233 Peripheral::Hmac => {
4234 crate::peripherals::SYSTEM::regs()
4235 .perip_clk_en1()
4236 .modify(|_, w| w.crypto_hmac_clk_en().bit(enable));
4237 }
4238 Peripheral::I2cExt0 => {
4239 crate::peripherals::SYSTEM::regs()
4240 .perip_clk_en0()
4241 .modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
4242 }
4243 Peripheral::I2cExt1 => {
4244 crate::peripherals::SYSTEM::regs()
4245 .perip_clk_en0()
4246 .modify(|_, w| w.i2c_ext1_clk_en().bit(enable));
4247 }
4248 Peripheral::I2s0 => {
4249 crate::peripherals::SYSTEM::regs()
4250 .perip_clk_en0()
4251 .modify(|_, w| w.i2s0_clk_en().bit(enable));
4252 }
4253 Peripheral::Ledc => {
4254 crate::peripherals::SYSTEM::regs()
4255 .perip_clk_en0()
4256 .modify(|_, w| w.ledc_clk_en().bit(enable));
4257 }
4258 Peripheral::Mcpwm0 => {
4259 crate::peripherals::SYSTEM::regs()
4260 .perip_clk_en0()
4261 .modify(|_, w| w.pwm0_clk_en().bit(enable));
4262 }
4263 Peripheral::Mcpwm1 => {
4264 crate::peripherals::SYSTEM::regs()
4265 .perip_clk_en0()
4266 .modify(|_, w| w.pwm1_clk_en().bit(enable));
4267 }
4268 Peripheral::Pcnt => {
4269 crate::peripherals::SYSTEM::regs()
4270 .perip_clk_en0()
4271 .modify(|_, w| w.pcnt_clk_en().bit(enable));
4272 }
4273 Peripheral::Rmt => {
4274 crate::peripherals::SYSTEM::regs()
4275 .perip_clk_en0()
4276 .modify(|_, w| w.rmt_clk_en().bit(enable));
4277 }
4278 Peripheral::Rsa => {
4279 crate::peripherals::SYSTEM::regs()
4280 .perip_clk_en1()
4281 .modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
4282 }
4283 Peripheral::Sha => {
4284 crate::peripherals::SYSTEM::regs()
4285 .perip_clk_en1()
4286 .modify(|_, w| w.crypto_sha_clk_en().bit(enable));
4287 }
4288 Peripheral::Spi2 => {
4289 crate::peripherals::SYSTEM::regs()
4290 .perip_clk_en0()
4291 .modify(|_, w| w.spi2_clk_en().bit(enable));
4292 }
4293 Peripheral::Spi2Dma => {
4294 crate::peripherals::SYSTEM::regs()
4295 .perip_clk_en0()
4296 .modify(|_, w| w.spi2_dma_clk_en().bit(enable));
4297 }
4298 Peripheral::Spi3 => {
4299 crate::peripherals::SYSTEM::regs()
4300 .perip_clk_en0()
4301 .modify(|_, w| w.spi3_clk_en().bit(enable));
4302 }
4303 Peripheral::Spi3Dma => {
4304 crate::peripherals::SYSTEM::regs()
4305 .perip_clk_en0()
4306 .modify(|_, w| w.spi3_dma_clk_en().bit(enable));
4307 }
4308 Peripheral::Systimer => {
4309 crate::peripherals::SYSTEM::regs()
4310 .perip_clk_en0()
4311 .modify(|_, w| w.systimer_clk_en().bit(enable));
4312 }
4313 Peripheral::Timg0 => {
4314 crate::peripherals::SYSTEM::regs()
4315 .perip_clk_en0()
4316 .modify(|_, w| w.timergroup_clk_en().bit(enable));
4317 }
4318 Peripheral::Timg1 => {
4319 crate::peripherals::SYSTEM::regs()
4320 .perip_clk_en0()
4321 .modify(|_, w| w.timergroup1_clk_en().bit(enable));
4322 }
4323 Peripheral::Twai0 => {
4324 crate::peripherals::SYSTEM::regs()
4325 .perip_clk_en0()
4326 .modify(|_, w| w.twai_clk_en().bit(enable));
4327 }
4328 Peripheral::Uart0 => {
4329 crate::peripherals::SYSTEM::regs()
4330 .perip_clk_en0()
4331 .modify(|_, w| w.uart_clk_en().bit(enable));
4332 }
4333 Peripheral::Uart1 => {
4334 crate::peripherals::SYSTEM::regs()
4335 .perip_clk_en0()
4336 .modify(|_, w| w.uart1_clk_en().bit(enable));
4337 }
4338 Peripheral::UartMem => {
4339 crate::peripherals::SYSTEM::regs()
4340 .perip_clk_en0()
4341 .modify(|_, w| w.uart_mem_clk_en().bit(enable));
4342 }
4343 Peripheral::Uhci0 => {
4344 crate::peripherals::SYSTEM::regs()
4345 .perip_clk_en0()
4346 .modify(|_, w| w.uhci0_clk_en().bit(enable));
4347 }
4348 Peripheral::Uhci1 => {
4349 crate::peripherals::SYSTEM::regs()
4350 .perip_clk_en0()
4351 .modify(|_, w| w.uhci1_clk_en().bit(enable));
4352 }
4353 Peripheral::UsbFs => {
4354 crate::peripherals::SYSTEM::regs()
4355 .perip_clk_en0()
4356 .modify(|_, w| w.usb_clk_en().bit(enable));
4357 }
4358 Peripheral::Wdg => {
4359 crate::peripherals::SYSTEM::regs()
4360 .perip_clk_en0()
4361 .modify(|_, w| w.wdg_clk_en().bit(enable));
4362 }
4363 }
4364 }
4365 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4366 match peripheral {
4367 Peripheral::Aes => {
4368 crate::peripherals::SYSTEM::regs()
4369 .perip_rst_en1()
4370 .modify(|_, w| w.crypto_aes_rst().bit(reset));
4371 }
4372 Peripheral::ApbSarAdc => {
4373 crate::peripherals::SYSTEM::regs()
4374 .perip_rst_en0()
4375 .modify(|_, w| w.apb_saradc_rst().bit(reset));
4376 }
4377 Peripheral::CopyDma => {
4378 crate::peripherals::DMA_COPY::regs().conf().modify(|_, w| {
4379 w.in_rst()
4380 .bit(reset)
4381 .out_rst()
4382 .bit(reset)
4383 .cmdfifo_rst()
4384 .bit(reset)
4385 .fifo_rst()
4386 .bit(reset)
4387 });
4388 }
4389 Peripheral::CryptoDma => {
4390 crate::peripherals::SYSTEM::regs()
4391 .perip_rst_en1()
4392 .modify(|_, w| w.crypto_dma_rst().bit(reset));
4393 }
4394 Peripheral::DedicatedGpio => {
4395 crate::peripherals::SYSTEM::regs()
4396 .cpu_peri_rst_en()
4397 .modify(|_, w| w.dedicated_gpio_rst().bit(reset));
4398 }
4399 Peripheral::Ds => {
4400 crate::peripherals::SYSTEM::regs()
4401 .perip_rst_en1()
4402 .modify(|_, w| w.crypto_ds_rst().bit(reset));
4403 }
4404 Peripheral::GpioSd => {
4405 let _ = reset;
4406 }
4407 Peripheral::Hmac => {
4408 crate::peripherals::SYSTEM::regs()
4409 .perip_rst_en1()
4410 .modify(|_, w| w.crypto_hmac_rst().bit(reset));
4411 }
4412 Peripheral::I2cExt0 => {
4413 crate::peripherals::SYSTEM::regs()
4414 .perip_rst_en0()
4415 .modify(|_, w| w.i2c_ext0_rst().bit(reset));
4416 }
4417 Peripheral::I2cExt1 => {
4418 crate::peripherals::SYSTEM::regs()
4419 .perip_rst_en0()
4420 .modify(|_, w| w.i2c_ext1_rst().bit(reset));
4421 }
4422 Peripheral::I2s0 => {
4423 crate::peripherals::SYSTEM::regs()
4424 .perip_rst_en0()
4425 .modify(|_, w| w.i2s0_rst().bit(reset));
4426 }
4427 Peripheral::Ledc => {
4428 crate::peripherals::SYSTEM::regs()
4429 .perip_rst_en0()
4430 .modify(|_, w| w.ledc_rst().bit(reset));
4431 }
4432 Peripheral::Mcpwm0 => {
4433 crate::peripherals::SYSTEM::regs()
4434 .perip_rst_en0()
4435 .modify(|_, w| w.pwm0_rst().bit(reset));
4436 }
4437 Peripheral::Mcpwm1 => {
4438 crate::peripherals::SYSTEM::regs()
4439 .perip_rst_en0()
4440 .modify(|_, w| w.pwm1_rst().bit(reset));
4441 }
4442 Peripheral::Pcnt => {
4443 crate::peripherals::SYSTEM::regs()
4444 .perip_rst_en0()
4445 .modify(|_, w| w.pcnt_rst().bit(reset));
4446 }
4447 Peripheral::Rmt => {
4448 crate::peripherals::SYSTEM::regs()
4449 .perip_rst_en0()
4450 .modify(|_, w| w.rmt_rst().bit(reset));
4451 }
4452 Peripheral::Rsa => {
4453 crate::peripherals::SYSTEM::regs()
4454 .perip_rst_en1()
4455 .modify(|_, w| w.crypto_rsa_rst().bit(reset));
4456 }
4457 Peripheral::Sha => {
4458 crate::peripherals::SYSTEM::regs()
4459 .perip_rst_en1()
4460 .modify(|_, w| w.crypto_sha_rst().bit(reset));
4461 }
4462 Peripheral::Spi2 => {
4463 crate::peripherals::SYSTEM::regs()
4464 .perip_rst_en0()
4465 .modify(|_, w| w.spi2_rst().bit(reset));
4466 }
4467 Peripheral::Spi2Dma => {
4468 crate::peripherals::SYSTEM::regs()
4469 .perip_rst_en0()
4470 .modify(|_, w| w.spi2_dma_rst().bit(reset));
4471 }
4472 Peripheral::Spi3 => {
4473 crate::peripherals::SYSTEM::regs()
4474 .perip_rst_en0()
4475 .modify(|_, w| w.spi3_rst().bit(reset));
4476 }
4477 Peripheral::Spi3Dma => {
4478 crate::peripherals::SYSTEM::regs()
4479 .perip_rst_en0()
4480 .modify(|_, w| w.spi3_dma_rst().bit(reset));
4481 }
4482 Peripheral::Systimer => {
4483 crate::peripherals::SYSTEM::regs()
4484 .perip_rst_en0()
4485 .modify(|_, w| w.systimer_rst().bit(reset));
4486 }
4487 Peripheral::Timg0 => {
4488 crate::peripherals::SYSTEM::regs()
4489 .perip_rst_en0()
4490 .modify(|_, w| w.timergroup_rst().bit(reset));
4491 }
4492 Peripheral::Timg1 => {
4493 crate::peripherals::SYSTEM::regs()
4494 .perip_rst_en0()
4495 .modify(|_, w| w.timergroup1_rst().bit(reset));
4496 }
4497 Peripheral::Twai0 => {
4498 crate::peripherals::SYSTEM::regs()
4499 .perip_rst_en0()
4500 .modify(|_, w| w.twai_rst().bit(reset));
4501 }
4502 Peripheral::Uart0 => {
4503 crate::peripherals::SYSTEM::regs()
4504 .perip_rst_en0()
4505 .modify(|_, w| w.uart_rst().bit(reset));
4506 }
4507 Peripheral::Uart1 => {
4508 crate::peripherals::SYSTEM::regs()
4509 .perip_rst_en0()
4510 .modify(|_, w| w.uart1_rst().bit(reset));
4511 }
4512 Peripheral::UartMem => {
4513 crate::peripherals::SYSTEM::regs()
4514 .perip_rst_en0()
4515 .modify(|_, w| w.uart_mem_rst().bit(reset));
4516 }
4517 Peripheral::Uhci0 => {
4518 crate::peripherals::SYSTEM::regs()
4519 .perip_rst_en0()
4520 .modify(|_, w| w.uhci0_rst().bit(reset));
4521 }
4522 Peripheral::Uhci1 => {
4523 crate::peripherals::SYSTEM::regs()
4524 .perip_rst_en0()
4525 .modify(|_, w| w.uhci1_rst().bit(reset));
4526 }
4527 Peripheral::UsbFs => {
4528 crate::peripherals::SYSTEM::regs()
4529 .perip_rst_en0()
4530 .modify(|_, w| w.usb_rst().bit(reset));
4531 }
4532 Peripheral::Wdg => {
4533 crate::peripherals::SYSTEM::regs()
4534 .perip_rst_en0()
4535 .modify(|_, w| w.wdg_rst().bit(reset));
4536 }
4537 }
4538 }
4539 };
4540}
4541#[macro_export]
4549#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4550macro_rules! memory_range {
4551 ("DRAM") => {
4552 0x3FFB0000..0x40000000
4553 };
4554 (size as str, "DRAM") => {
4555 "327680"
4556 };
4557 ("DRAM2_UNINIT") => {
4558 0x3FFDE000..0x40000000
4559 };
4560 (size as str, "DRAM2_UNINIT") => {
4561 "139264"
4562 };
4563 ("IROM") => {
4564 0x40080000..0x40800000
4565 };
4566 (size as str, "IROM") => {
4567 "7864320"
4568 };
4569 ("DROM") => {
4570 0x3F000000..0x3F400000
4571 };
4572 (size as str, "DROM") => {
4573 "4194304"
4574 };
4575}
4576#[macro_export]
4593#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4594macro_rules! for_each_i2c_master {
4595 ($($pattern:tt => $code:tt;)*) => {
4596 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4597 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4598 I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
4599 I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4600 I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
4601 };
4602}
4603#[macro_export]
4630#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4631macro_rules! for_each_i2s {
4632 ($($pattern:tt => $code:tt;)*) => {
4633 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4634 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, CLK_I2S,
4635 I2S0O_BCK, I2S0O_WS, I2S0I_BCK, I2S0I_WS, [I2S0O_DATA_OUT23], [I2S0I_DATA_IN15],
4636 false, false, false, false)); _for_each_inner_i2s!((names(I2S0)));
4637 _for_each_inner_i2s!((all(I2S0, I2s0, CLK_I2S, I2S0O_BCK, I2S0O_WS, I2S0I_BCK,
4638 I2S0I_WS, [I2S0O_DATA_OUT23], [I2S0I_DATA_IN15], false, false, false, false)));
4639 };
4640}
4641#[macro_export]
4660#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4661macro_rules! for_each_uart {
4662 ($($pattern:tt => $code:tt;)*) => {
4663 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4664 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4665 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4666 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4667 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4668 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4669 };
4670}
4671#[macro_export]
4693#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4694macro_rules! for_each_spi_master {
4695 ($($pattern:tt => $code:tt;)*) => {
4696 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4697 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI3));
4698 _for_each_inner_spi_master!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4699 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD, FSPIIO4, FSPIIO5,
4700 FSPIIO6, FSPIIO7], true)); _for_each_inner_spi_master!((SPI3, Spi3,
4701 SPI3_CLK[SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q]));
4702 _for_each_inner_spi_master!((names(SPI2), (SPI3)));
4703 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4704 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD, FSPIIO4, FSPIIO5,
4705 FSPIIO6, FSPIIO7], true), (SPI3, Spi3, SPI3_CLK[SPI3_CS0, SPI3_CS1, SPI3_CS2]
4706 [SPI3_D, SPI3_Q])));
4707 };
4708}
4709#[macro_export]
4726#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4727macro_rules! for_each_spi_slave {
4728 ($($pattern:tt => $code:tt;)*) => {
4729 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4730 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI3));
4731 _for_each_inner_spi_slave!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4732 _for_each_inner_spi_slave!((SPI3, Spi3, SPI3_CLK, SPI3_D, SPI3_Q, SPI3_CS0));
4733 _for_each_inner_spi_slave!((names(SPI2), (SPI3)));
4734 _for_each_inner_spi_slave!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0),
4735 (SPI3, Spi3, SPI3_CLK, SPI3_D, SPI3_Q, SPI3_CS0)));
4736 };
4737}
4738#[macro_export]
4761#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4762macro_rules! for_each_pcnt_unit {
4763 ($($pattern:tt => $code:tt;)*) => {
4764 macro_rules! _for_each_inner_pcnt_unit { $(($pattern) => $code;)* ($other : tt)
4765 => {} } _for_each_inner_pcnt_unit!((PCNT0_UNIT0));
4766 _for_each_inner_pcnt_unit!((PCNT0_UNIT1));
4767 _for_each_inner_pcnt_unit!((PCNT0_UNIT2));
4768 _for_each_inner_pcnt_unit!((PCNT0_UNIT3));
4769 _for_each_inner_pcnt_unit!((PCNT0_UNIT0, Pcnt0Unit0, Pcnt, PCNT, 0, PCNT,
4770 PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1));
4771 _for_each_inner_pcnt_unit!((PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT,
4772 PCNT1_SIG_CH0, PCNT1_SIG_CH1, PCNT1_CTRL_CH0, PCNT1_CTRL_CH1));
4773 _for_each_inner_pcnt_unit!((PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
4774 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1));
4775 _for_each_inner_pcnt_unit!((PCNT0_UNIT3, Pcnt0Unit3, Pcnt, PCNT, 3, PCNT,
4776 PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0, PCNT3_CTRL_CH1));
4777 _for_each_inner_pcnt_unit!((PCNT)); _for_each_inner_pcnt_unit!((PCNT));
4778 _for_each_inner_pcnt_unit!((names(PCNT0_UNIT0), (PCNT0_UNIT1), (PCNT0_UNIT2),
4779 (PCNT0_UNIT3))); _for_each_inner_pcnt_unit!((all(PCNT0_UNIT0, Pcnt0Unit0, Pcnt,
4780 PCNT, 0, PCNT, PCNT0_SIG_CH0, PCNT0_SIG_CH1, PCNT0_CTRL_CH0, PCNT0_CTRL_CH1),
4781 (PCNT0_UNIT1, Pcnt0Unit1, Pcnt, PCNT, 1, PCNT, PCNT1_SIG_CH0, PCNT1_SIG_CH1,
4782 PCNT1_CTRL_CH0, PCNT1_CTRL_CH1), (PCNT0_UNIT2, Pcnt0Unit2, Pcnt, PCNT, 2, PCNT,
4783 PCNT2_SIG_CH0, PCNT2_SIG_CH1, PCNT2_CTRL_CH0, PCNT2_CTRL_CH1), (PCNT0_UNIT3,
4784 Pcnt0Unit3, Pcnt, PCNT, 3, PCNT, PCNT3_SIG_CH0, PCNT3_SIG_CH1, PCNT3_CTRL_CH0,
4785 PCNT3_CTRL_CH1))); _for_each_inner_pcnt_unit!((interrupt(PCNT)));
4786 _for_each_inner_pcnt_unit!((regs(PCNT)));
4787 };
4788}
4789#[macro_export]
4790#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4791macro_rules! for_each_peripheral {
4792 ($($pattern:tt => $code:tt;)*) => {
4793 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4794 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4795 "GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4796 "<section class=\"warning\">"] #[doc =
4797 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4798 #[doc = "<ul>"] #[doc =
4799 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4800 = "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()));
4801 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4802 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4803 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
4804 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
4805 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4806 "GPIO4 peripheral singleton"] GPIO4 <= virtual()));
4807 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO5 peripheral singleton"]
4808 GPIO5 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4809 "GPIO6 peripheral singleton"] GPIO6 <= virtual()));
4810 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO7 peripheral singleton"]
4811 GPIO7 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4812 "GPIO8 peripheral singleton"] GPIO8 <= virtual()));
4813 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO9 peripheral singleton"]
4814 GPIO9 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4815 "GPIO10 peripheral singleton"] GPIO10 <= virtual()));
4816 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO11 peripheral singleton"]
4817 GPIO11 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4818 "GPIO12 peripheral singleton"] GPIO12 <= virtual()));
4819 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO13 peripheral singleton"]
4820 GPIO13 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4821 "GPIO14 peripheral singleton"] GPIO14 <= virtual()));
4822 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO15 peripheral singleton"]
4823 GPIO15 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4824 "GPIO16 peripheral singleton"] GPIO16 <= virtual()));
4825 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO17 peripheral singleton"]
4826 GPIO17 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4827 "GPIO18 peripheral singleton"] GPIO18 <= virtual()));
4828 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO19 peripheral singleton"]
4829 GPIO19 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4830 "GPIO20 peripheral singleton"] GPIO20 <= virtual()));
4831 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO21 peripheral singleton"]
4832 GPIO21 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4833 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4834 "<section class=\"warning\">"] #[doc =
4835 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4836 #[doc = "<ul>"] #[doc =
4837 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4838 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()));
4839 _for_each_inner_peripheral!((@ peri_type #[doc =
4840 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4841 "<section class=\"warning\">"] #[doc =
4842 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4843 #[doc = "<ul>"] #[doc =
4844 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4845 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4846 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()));
4847 _for_each_inner_peripheral!((@ peri_type #[doc =
4848 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4849 "<section class=\"warning\">"] #[doc =
4850 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4851 #[doc = "<ul>"] #[doc =
4852 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4853 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4854 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
4855 _for_each_inner_peripheral!((@ peri_type #[doc =
4856 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4857 "<section class=\"warning\">"] #[doc =
4858 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4859 #[doc = "<ul>"] #[doc =
4860 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4861 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()));
4862 _for_each_inner_peripheral!((@ peri_type #[doc =
4863 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4864 "<section class=\"warning\">"] #[doc =
4865 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4866 #[doc = "<ul>"] #[doc =
4867 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4868 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4869 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()));
4870 _for_each_inner_peripheral!((@ peri_type #[doc =
4871 "GPIO31 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4872 "<section class=\"warning\">"] #[doc =
4873 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4874 #[doc = "<ul>"] #[doc =
4875 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4876 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4877 "</ul>"] #[doc = "</section>"] GPIO31 <= virtual()));
4878 _for_each_inner_peripheral!((@ peri_type #[doc =
4879 "GPIO32 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4880 "<section class=\"warning\">"] #[doc =
4881 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4882 #[doc = "<ul>"] #[doc =
4883 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4884 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4885 "</ul>"] #[doc = "</section>"] GPIO32 <= virtual()));
4886 _for_each_inner_peripheral!((@ peri_type #[doc =
4887 "GPIO33 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4888 "<section class=\"warning\">"] #[doc =
4889 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4890 #[doc = "<ul>"] #[doc =
4891 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4892 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4893 #[doc = "</ul>"] #[doc = "</section>"] GPIO33 <= virtual()));
4894 _for_each_inner_peripheral!((@ peri_type #[doc =
4895 "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4896 "<section class=\"warning\">"] #[doc =
4897 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4898 #[doc = "<ul>"] #[doc =
4899 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4900 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4901 #[doc = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()));
4902 _for_each_inner_peripheral!((@ peri_type #[doc =
4903 "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4904 "<section class=\"warning\">"] #[doc =
4905 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4906 #[doc = "<ul>"] #[doc =
4907 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4908 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4909 #[doc = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()));
4910 _for_each_inner_peripheral!((@ peri_type #[doc =
4911 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4912 "<section class=\"warning\">"] #[doc =
4913 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4914 #[doc = "<ul>"] #[doc =
4915 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4916 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4917 #[doc = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()));
4918 _for_each_inner_peripheral!((@ peri_type #[doc =
4919 "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4920 "<section class=\"warning\">"] #[doc =
4921 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4922 #[doc = "<ul>"] #[doc =
4923 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4924 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4925 #[doc = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()));
4926 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO38 peripheral singleton"]
4927 GPIO38 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4928 "GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4929 "<section class=\"warning\">"] #[doc =
4930 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4931 #[doc = "<ul>"] #[doc =
4932 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4933 #[doc = "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()));
4934 _for_each_inner_peripheral!((@ peri_type #[doc =
4935 "GPIO40 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4936 "<section class=\"warning\">"] #[doc =
4937 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4938 #[doc = "<ul>"] #[doc =
4939 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4940 #[doc = "</ul>"] #[doc = "</section>"] GPIO40 <= virtual()));
4941 _for_each_inner_peripheral!((@ peri_type #[doc =
4942 "GPIO41 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4943 "<section class=\"warning\">"] #[doc =
4944 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4945 #[doc = "<ul>"] #[doc =
4946 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4947 #[doc = "</ul>"] #[doc = "</section>"] GPIO41 <= virtual()));
4948 _for_each_inner_peripheral!((@ peri_type #[doc =
4949 "GPIO42 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4950 "<section class=\"warning\">"] #[doc =
4951 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4952 #[doc = "<ul>"] #[doc =
4953 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4954 #[doc = "</ul>"] #[doc = "</section>"] GPIO42 <= virtual()));
4955 _for_each_inner_peripheral!((@ peri_type #[doc =
4956 "GPIO43 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4957 "<section class=\"warning\">"] #[doc =
4958 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4959 #[doc = "<ul>"] #[doc =
4960 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4961 = "</ul>"] #[doc = "</section>"] GPIO43 <= virtual()));
4962 _for_each_inner_peripheral!((@ peri_type #[doc =
4963 "GPIO44 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4964 "<section class=\"warning\">"] #[doc =
4965 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4966 #[doc = "<ul>"] #[doc =
4967 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4968 = "</ul>"] #[doc = "</section>"] GPIO44 <= virtual()));
4969 _for_each_inner_peripheral!((@ peri_type #[doc =
4970 "GPIO45 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4971 "<section class=\"warning\">"] #[doc =
4972 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4973 #[doc = "<ul>"] #[doc =
4974 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4975 = "</ul>"] #[doc = "</section>"] GPIO45 <= virtual()));
4976 _for_each_inner_peripheral!((@ peri_type #[doc =
4977 "GPIO46 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4978 "<section class=\"warning\">"] #[doc =
4979 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4980 #[doc = "<ul>"] #[doc =
4981 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4982 = "</ul>"] #[doc = "</section>"] GPIO46 <= virtual()));
4983 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_SPI2 peripheral singleton"]
4984 DMA_SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt,
4985 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4986 #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3(SPI3_DMA : {
4987 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4988 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_I2S0 peripheral singleton"]
4989 DMA_I2S0 <= I2S0(I2S0 : { bind_dma_interrupt, enable_dma_interrupt,
4990 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4991 #[doc = "DMA_CRYPTO peripheral singleton"] DMA_CRYPTO <= CRYPTO_DMA(CRYPTO_DMA :
4992 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt })
4993 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4994 "DMA_COPY peripheral singleton"] DMA_COPY <= COPY_DMA(DMA_COPY : {
4995 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4996 _for_each_inner_peripheral!((@ peri_type #[doc =
4997 "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual() (unstable)));
4998 _for_each_inner_peripheral!((@ peri_type #[doc =
4999 "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1 <= virtual() (unstable)));
5000 _for_each_inner_peripheral!((@ peri_type #[doc =
5001 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)));
5002 _for_each_inner_peripheral!((@ peri_type #[doc =
5003 "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual() (unstable)));
5004 _for_each_inner_peripheral!((@ peri_type #[doc = "DAC1 peripheral singleton"]
5005 DAC1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5006 "DAC2 peripheral singleton"] DAC2 <= virtual() (unstable)));
5007 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
5008 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5009 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
5010 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
5011 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5012 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
5013 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH4 peripheral singleton"]
5014 SDM_CH4 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5015 = "SDM_CH5 peripheral singleton"] SDM_CH5 <= virtual() (unstable)));
5016 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH6 peripheral singleton"]
5017 SDM_CH6 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5018 = "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)));
5019 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
5020 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5021 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5022 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
5023 _for_each_inner_peripheral!((@ peri_type #[doc = "DS peripheral singleton"] DS <=
5024 DS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5025 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
5026 _for_each_inner_peripheral!((@ peri_type #[doc = "EXTMEM peripheral singleton"]
5027 EXTMEM <= EXTMEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5028 "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)));
5029 _for_each_inner_peripheral!((@ peri_type #[doc = "FE peripheral singleton"] FE <=
5030 FE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5031 "FE2 peripheral singleton"] FE2 <= FE2() (unstable)));
5032 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
5033 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5034 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
5035 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
5036 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5037 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
5038 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
5039 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
5040 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5041 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
5042 enable_peri_interrupt, disable_peri_interrupt })));
5043 _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
5044 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
5045 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5046 #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
5047 INTERRUPT_CORE0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5048 "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)));
5049 _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
5050 LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5051 "NRX peripheral singleton"] NRX <= NRX() (unstable)));
5052 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
5053 PCNT <= PCNT(PCNT : { bind_peri_interrupt, enable_peri_interrupt,
5054 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
5055 #[doc = "PMS peripheral singleton"] PMS <= PMS() (unstable)));
5056 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
5057 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5058 "RNG peripheral singleton"] RNG <= RNG() (unstable)));
5059 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
5060 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
5061 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5062 "LPWR peripheral singleton"] LPWR <= RTC_CNTL() (unstable)));
5063 _for_each_inner_peripheral!((@ peri_type #[doc =
5064 "RTC_TIMER peripheral singleton"] RTC_TIMER <= RTC_CNTL() (unstable)));
5065 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
5066 LP_I2C0 <= RTC_I2C() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
5067 = "RTC_IO peripheral singleton"] RTC_IO <= RTC_IO() (unstable)));
5068 _for_each_inner_peripheral!((@ peri_type #[doc = "SENS peripheral singleton"]
5069 SENS <= SENS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5070 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
5071 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5072 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
5073 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5074 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
5075 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
5076 SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt,
5077 disable_dma_interrupt }, SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
5078 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5079 "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : { bind_dma_interrupt,
5080 enable_dma_interrupt, disable_dma_interrupt }, SPI3 : { bind_peri_interrupt,
5081 enable_peri_interrupt, disable_peri_interrupt })));
5082 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSCON peripheral singleton"]
5083 SYSCON <= SYSCON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5084 "SYSTEM peripheral singleton"] SYSTEM <= SYSTEM() (unstable)));
5085 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
5086 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
5087 #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
5088 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
5089 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5090 "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)));
5091 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
5092 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5093 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5094 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
5095 enable_peri_interrupt, disable_peri_interrupt })));
5096 _for_each_inner_peripheral!((@ peri_type #[doc = "UHCI0 peripheral singleton"]
5097 UHCI0 <= UHCI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5098 "USB_FS peripheral singleton"] USB_FS <= USB_FS(USB : { bind_peri_interrupt,
5099 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
5100 _for_each_inner_peripheral!((@ peri_type #[doc = "USB_WRAP peripheral singleton"]
5101 USB_WRAP <= USB_WRAP() (unstable))); _for_each_inner_peripheral!((@ peri_type
5102 #[doc = "XTS_AES peripheral singleton"] XTS_AES <= XTS_AES() (unstable)));
5103 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
5104 WIFI <= WIFI(WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
5105 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
5106 disable_pwr_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
5107 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
5108 _for_each_inner_peripheral!((@ peri_type #[doc = "ADC2 peripheral singleton"]
5109 ADC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5110 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
5111 _for_each_inner_peripheral!((@ peri_type #[doc =
5112 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
5113 _for_each_inner_peripheral!((@ peri_type #[doc = "PSRAM peripheral singleton"]
5114 PSRAM <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
5115 "ULP_RISCV_CORE peripheral singleton"] ULP_RISCV_CORE <= virtual() (unstable)));
5116 _for_each_inner_peripheral!((@ peri_type #[doc =
5117 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
5118 _for_each_inner_peripheral!((@ peri_type #[doc =
5119 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
5120 _for_each_inner_peripheral!((@ peri_type #[doc =
5121 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
5122 _for_each_inner_peripheral!((@ peri_type #[doc =
5123 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
5124 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
5125 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
5126 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
5127 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
5128 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
5129 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
5130 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
5131 _for_each_inner_peripheral!((GPIO14));
5132 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO15));
5133 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO16));
5134 _for_each_inner_peripheral!((GPIO17)); _for_each_inner_peripheral!((GPIO18));
5135 _for_each_inner_peripheral!((GPIO19)); _for_each_inner_peripheral!((GPIO20));
5136 _for_each_inner_peripheral!((GPIO21)); _for_each_inner_peripheral!((GPIO26));
5137 _for_each_inner_peripheral!((GPIO27)); _for_each_inner_peripheral!((GPIO28));
5138 _for_each_inner_peripheral!((GPIO29)); _for_each_inner_peripheral!((GPIO30));
5139 _for_each_inner_peripheral!((GPIO31)); _for_each_inner_peripheral!((GPIO32));
5140 _for_each_inner_peripheral!((GPIO33)); _for_each_inner_peripheral!((GPIO34));
5141 _for_each_inner_peripheral!((GPIO35)); _for_each_inner_peripheral!((GPIO36));
5142 _for_each_inner_peripheral!((GPIO37)); _for_each_inner_peripheral!((GPIO38));
5143 _for_each_inner_peripheral!((GPIO39)); _for_each_inner_peripheral!((GPIO40));
5144 _for_each_inner_peripheral!((GPIO41)); _for_each_inner_peripheral!((GPIO42));
5145 _for_each_inner_peripheral!((GPIO43)); _for_each_inner_peripheral!((GPIO44));
5146 _for_each_inner_peripheral!((GPIO45)); _for_each_inner_peripheral!((GPIO46));
5147 _for_each_inner_peripheral!((DMA_SPI2(unstable)));
5148 _for_each_inner_peripheral!((DMA_SPI3(unstable)));
5149 _for_each_inner_peripheral!((DMA_I2S0(unstable)));
5150 _for_each_inner_peripheral!((DMA_CRYPTO(unstable)));
5151 _for_each_inner_peripheral!((DMA_COPY(unstable)));
5152 _for_each_inner_peripheral!((PCNT0_UNIT0(unstable)));
5153 _for_each_inner_peripheral!((PCNT0_UNIT1(unstable)));
5154 _for_each_inner_peripheral!((PCNT0_UNIT2(unstable)));
5155 _for_each_inner_peripheral!((PCNT0_UNIT3(unstable)));
5156 _for_each_inner_peripheral!((DAC1(unstable)));
5157 _for_each_inner_peripheral!((DAC2(unstable)));
5158 _for_each_inner_peripheral!((SDM_CH0(unstable)));
5159 _for_each_inner_peripheral!((SDM_CH1(unstable)));
5160 _for_each_inner_peripheral!((SDM_CH2(unstable)));
5161 _for_each_inner_peripheral!((SDM_CH3(unstable)));
5162 _for_each_inner_peripheral!((SDM_CH4(unstable)));
5163 _for_each_inner_peripheral!((SDM_CH5(unstable)));
5164 _for_each_inner_peripheral!((SDM_CH6(unstable)));
5165 _for_each_inner_peripheral!((SDM_CH7(unstable)));
5166 _for_each_inner_peripheral!((AES(unstable)));
5167 _for_each_inner_peripheral!((APB_SARADC(unstable)));
5168 _for_each_inner_peripheral!((DS(unstable)));
5169 _for_each_inner_peripheral!((EXTMEM(unstable)));
5170 _for_each_inner_peripheral!((FE(unstable)));
5171 _for_each_inner_peripheral!((FE2(unstable)));
5172 _for_each_inner_peripheral!((GPIO(unstable)));
5173 _for_each_inner_peripheral!((GPIO_SD(unstable)));
5174 _for_each_inner_peripheral!((HMAC(unstable)));
5175 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
5176 _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
5177 _for_each_inner_peripheral!((I2S0(unstable)));
5178 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
5179 _for_each_inner_peripheral!((IO_MUX(unstable)));
5180 _for_each_inner_peripheral!((LEDC(unstable)));
5181 _for_each_inner_peripheral!((NRX(unstable)));
5182 _for_each_inner_peripheral!((PCNT(unstable)));
5183 _for_each_inner_peripheral!((PMS(unstable)));
5184 _for_each_inner_peripheral!((RMT(unstable)));
5185 _for_each_inner_peripheral!((RNG(unstable)));
5186 _for_each_inner_peripheral!((RSA(unstable)));
5187 _for_each_inner_peripheral!((LPWR(unstable)));
5188 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
5189 _for_each_inner_peripheral!((LP_I2C0(unstable)));
5190 _for_each_inner_peripheral!((RTC_IO(unstable)));
5191 _for_each_inner_peripheral!((SENS(unstable)));
5192 _for_each_inner_peripheral!((SHA(unstable)));
5193 _for_each_inner_peripheral!((SPI0(unstable)));
5194 _for_each_inner_peripheral!((SPI1(unstable)));
5195 _for_each_inner_peripheral!((SPI2)); _for_each_inner_peripheral!((SPI3));
5196 _for_each_inner_peripheral!((SYSCON(unstable)));
5197 _for_each_inner_peripheral!((SYSTEM(unstable)));
5198 _for_each_inner_peripheral!((SYSTIMER(unstable)));
5199 _for_each_inner_peripheral!((TIMG0(unstable)));
5200 _for_each_inner_peripheral!((TIMG1(unstable)));
5201 _for_each_inner_peripheral!((TWAI0(unstable)));
5202 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
5203 _for_each_inner_peripheral!((UHCI0(unstable)));
5204 _for_each_inner_peripheral!((USB_FS(unstable)));
5205 _for_each_inner_peripheral!((XTS_AES(unstable)));
5206 _for_each_inner_peripheral!((WIFI));
5207 _for_each_inner_peripheral!((ADC1(unstable)));
5208 _for_each_inner_peripheral!((ADC2(unstable)));
5209 _for_each_inner_peripheral!((FLASH(unstable)));
5210 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
5211 _for_each_inner_peripheral!((PSRAM(unstable)));
5212 _for_each_inner_peripheral!((ULP_RISCV_CORE(unstable)));
5213 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
5214 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
5215 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
5216 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
5217 _for_each_inner_peripheral!((SPI2, Spi2, 0, SpiDmaChannel));
5218 _for_each_inner_peripheral!((I2S0, I2s0, 0, I2sDmaChannel));
5219 _for_each_inner_peripheral!((AES, Aes, 0, CryptoDmaChannel));
5220 _for_each_inner_peripheral!((SPI3, Spi3, 1, SpiDmaChannel));
5221 _for_each_inner_peripheral!((SHA, Sha, 1, CryptoDmaChannel));
5222 _for_each_inner_peripheral!((all(@ peri_type #[doc =
5223 "GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5224 "<section class=\"warning\">"] #[doc =
5225 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5226 #[doc = "<ul>"] #[doc =
5227 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5228 = "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()), (@ peri_type #[doc =
5229 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
5230 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
5231 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
5232 "GPIO4 peripheral singleton"] GPIO4 <= virtual()), (@ peri_type #[doc =
5233 "GPIO5 peripheral singleton"] GPIO5 <= virtual()), (@ peri_type #[doc =
5234 "GPIO6 peripheral singleton"] GPIO6 <= virtual()), (@ peri_type #[doc =
5235 "GPIO7 peripheral singleton"] GPIO7 <= virtual()), (@ peri_type #[doc =
5236 "GPIO8 peripheral singleton"] GPIO8 <= virtual()), (@ peri_type #[doc =
5237 "GPIO9 peripheral singleton"] GPIO9 <= virtual()), (@ peri_type #[doc =
5238 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
5239 "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
5240 "GPIO12 peripheral singleton"] GPIO12 <= virtual()), (@ peri_type #[doc =
5241 "GPIO13 peripheral singleton"] GPIO13 <= virtual()), (@ peri_type #[doc =
5242 "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
5243 "GPIO15 peripheral singleton"] GPIO15 <= virtual()), (@ peri_type #[doc =
5244 "GPIO16 peripheral singleton"] GPIO16 <= virtual()), (@ peri_type #[doc =
5245 "GPIO17 peripheral singleton"] GPIO17 <= virtual()), (@ peri_type #[doc =
5246 "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
5247 "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
5248 "GPIO20 peripheral singleton"] GPIO20 <= virtual()), (@ peri_type #[doc =
5249 "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
5250 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5251 "<section class=\"warning\">"] #[doc =
5252 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5253 #[doc = "<ul>"] #[doc =
5254 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5255 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
5256 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5257 "<section class=\"warning\">"] #[doc =
5258 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5259 #[doc = "<ul>"] #[doc =
5260 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5261 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5262 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
5263 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5264 "<section class=\"warning\">"] #[doc =
5265 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5266 #[doc = "<ul>"] #[doc =
5267 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5268 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5269 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
5270 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5271 "<section class=\"warning\">"] #[doc =
5272 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5273 #[doc = "<ul>"] #[doc =
5274 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5275 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()), (@ peri_type #[doc =
5276 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5277 "<section class=\"warning\">"] #[doc =
5278 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5279 #[doc = "<ul>"] #[doc =
5280 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5281 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5282 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()), (@ peri_type #[doc =
5283 "GPIO31 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5284 "<section class=\"warning\">"] #[doc =
5285 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5286 #[doc = "<ul>"] #[doc =
5287 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5288 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5289 "</ul>"] #[doc = "</section>"] GPIO31 <= virtual()), (@ peri_type #[doc =
5290 "GPIO32 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5291 "<section class=\"warning\">"] #[doc =
5292 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5293 #[doc = "<ul>"] #[doc =
5294 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5295 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5296 "</ul>"] #[doc = "</section>"] GPIO32 <= virtual()), (@ peri_type #[doc =
5297 "GPIO33 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5298 "<section class=\"warning\">"] #[doc =
5299 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5300 #[doc = "<ul>"] #[doc =
5301 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
5302 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
5303 #[doc = "</ul>"] #[doc = "</section>"] GPIO33 <= virtual()), (@ peri_type #[doc =
5304 "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5305 "<section class=\"warning\">"] #[doc =
5306 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5307 #[doc = "<ul>"] #[doc =
5308 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
5309 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
5310 #[doc = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()), (@ peri_type #[doc =
5311 "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5312 "<section class=\"warning\">"] #[doc =
5313 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5314 #[doc = "<ul>"] #[doc =
5315 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
5316 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
5317 #[doc = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()), (@ peri_type #[doc =
5318 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5319 "<section class=\"warning\">"] #[doc =
5320 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5321 #[doc = "<ul>"] #[doc =
5322 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
5323 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
5324 #[doc = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()), (@ peri_type #[doc =
5325 "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5326 "<section class=\"warning\">"] #[doc =
5327 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5328 #[doc = "<ul>"] #[doc =
5329 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
5330 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
5331 #[doc = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()), (@ peri_type #[doc =
5332 "GPIO38 peripheral singleton"] GPIO38 <= virtual()), (@ peri_type #[doc =
5333 "GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5334 "<section class=\"warning\">"] #[doc =
5335 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5336 #[doc = "<ul>"] #[doc =
5337 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5338 #[doc = "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()), (@ peri_type #[doc =
5339 "GPIO40 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5340 "<section class=\"warning\">"] #[doc =
5341 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5342 #[doc = "<ul>"] #[doc =
5343 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5344 #[doc = "</ul>"] #[doc = "</section>"] GPIO40 <= virtual()), (@ peri_type #[doc =
5345 "GPIO41 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5346 "<section class=\"warning\">"] #[doc =
5347 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5348 #[doc = "<ul>"] #[doc =
5349 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5350 #[doc = "</ul>"] #[doc = "</section>"] GPIO41 <= virtual()), (@ peri_type #[doc =
5351 "GPIO42 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5352 "<section class=\"warning\">"] #[doc =
5353 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5354 #[doc = "<ul>"] #[doc =
5355 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5356 #[doc = "</ul>"] #[doc = "</section>"] GPIO42 <= virtual()), (@ peri_type #[doc =
5357 "GPIO43 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5358 "<section class=\"warning\">"] #[doc =
5359 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5360 #[doc = "<ul>"] #[doc =
5361 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5362 = "</ul>"] #[doc = "</section>"] GPIO43 <= virtual()), (@ peri_type #[doc =
5363 "GPIO44 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5364 "<section class=\"warning\">"] #[doc =
5365 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5366 #[doc = "<ul>"] #[doc =
5367 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5368 = "</ul>"] #[doc = "</section>"] GPIO44 <= virtual()), (@ peri_type #[doc =
5369 "GPIO45 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5370 "<section class=\"warning\">"] #[doc =
5371 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5372 #[doc = "<ul>"] #[doc =
5373 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5374 = "</ul>"] #[doc = "</section>"] GPIO45 <= virtual()), (@ peri_type #[doc =
5375 "GPIO46 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5376 "<section class=\"warning\">"] #[doc =
5377 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5378 #[doc = "<ul>"] #[doc =
5379 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5380 = "</ul>"] #[doc = "</section>"] GPIO46 <= virtual()), (@ peri_type #[doc =
5381 "DMA_SPI2 peripheral singleton"] DMA_SPI2 <= SPI2(SPI2_DMA : {
5382 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5383 (@ peri_type #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3(SPI3_DMA :
5384 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5385 (@ peri_type #[doc = "DMA_I2S0 peripheral singleton"] DMA_I2S0 <= I2S0(I2S0 : {
5386 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5387 (@ peri_type #[doc = "DMA_CRYPTO peripheral singleton"] DMA_CRYPTO <=
5388 CRYPTO_DMA(CRYPTO_DMA : { bind_dma_interrupt, enable_dma_interrupt,
5389 disable_dma_interrupt }) (unstable)), (@ peri_type #[doc =
5390 "DMA_COPY peripheral singleton"] DMA_COPY <= COPY_DMA(DMA_COPY : {
5391 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5392 (@ peri_type #[doc = "PCNT0_UNIT0 peripheral singleton"] PCNT0_UNIT0 <= virtual()
5393 (unstable)), (@ peri_type #[doc = "PCNT0_UNIT1 peripheral singleton"] PCNT0_UNIT1
5394 <= virtual() (unstable)), (@ peri_type #[doc =
5395 "PCNT0_UNIT2 peripheral singleton"] PCNT0_UNIT2 <= virtual() (unstable)), (@
5396 peri_type #[doc = "PCNT0_UNIT3 peripheral singleton"] PCNT0_UNIT3 <= virtual()
5397 (unstable)), (@ peri_type #[doc = "DAC1 peripheral singleton"] DAC1 <= virtual()
5398 (unstable)), (@ peri_type #[doc = "DAC2 peripheral singleton"] DAC2 <= virtual()
5399 (unstable)), (@ peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <=
5400 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"]
5401 SDM_CH1 <= virtual() (unstable)), (@ peri_type #[doc =
5402 "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual() (unstable)), (@ peri_type
5403 #[doc = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@
5404 peri_type #[doc = "SDM_CH4 peripheral singleton"] SDM_CH4 <= virtual()
5405 (unstable)), (@ peri_type #[doc = "SDM_CH5 peripheral singleton"] SDM_CH5 <=
5406 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH6 peripheral singleton"]
5407 SDM_CH6 <= virtual() (unstable)), (@ peri_type #[doc =
5408 "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)), (@ peri_type
5409 #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
5410 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5411 = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
5412 peri_type #[doc = "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type
5413 #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type
5414 #[doc = "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)), (@
5415 peri_type #[doc = "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE()
5416 (unstable)), (@ peri_type #[doc = "FE peripheral singleton"] FE <= FE()
5417 (unstable)), (@ peri_type #[doc = "FE2 peripheral singleton"] FE2 <= FE2()
5418 (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO()
5419 (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <=
5420 GPIO_SD() (unstable)), (@ peri_type #[doc = "HMAC peripheral singleton"] HMAC <=
5421 HMAC() (unstable)), (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"]
5422 I2C_ANA_MST <= I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
5423 "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
5424 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5425 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
5426 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5427 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
5428 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5429 = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
5430 (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX <=
5431 IO_MUX() (unstable)), (@ peri_type #[doc = "LEDC peripheral singleton"] LEDC <=
5432 LEDC() (unstable)), (@ peri_type #[doc = "NRX peripheral singleton"] NRX <= NRX()
5433 (unstable)), (@ peri_type #[doc = "PCNT peripheral singleton"] PCNT <= PCNT(PCNT
5434 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5435 (unstable)), (@ peri_type #[doc = "PMS peripheral singleton"] PMS <= PMS()
5436 (unstable)), (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT()
5437 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG()
5438 (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
5439 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5440 (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= RTC_CNTL()
5441 (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
5442 RTC_CNTL() (unstable)), (@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
5443 LP_I2C0 <= RTC_I2C() (unstable)), (@ peri_type #[doc =
5444 "RTC_IO peripheral singleton"] RTC_IO <= RTC_IO() (unstable)), (@ peri_type #[doc
5445 = "SENS peripheral singleton"] SENS <= SENS() (unstable)), (@ peri_type #[doc =
5446 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
5447 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5448 = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
5449 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
5450 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt,
5451 enable_dma_interrupt, disable_dma_interrupt }, SPI2 : { bind_peri_interrupt,
5452 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5453 "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : { bind_dma_interrupt,
5454 enable_dma_interrupt, disable_dma_interrupt }, SPI3 : { bind_peri_interrupt,
5455 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5456 "SYSCON peripheral singleton"] SYSCON <= SYSCON() (unstable)), (@ peri_type #[doc
5457 = "SYSTEM peripheral singleton"] SYSTEM <= SYSTEM() (unstable)), (@ peri_type
5458 #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@
5459 peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@
5460 peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@
5461 peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@
5462 peri_type #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
5463 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5464 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
5465 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5466 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
5467 peri_type #[doc = "USB_FS peripheral singleton"] USB_FS <= USB_FS(USB : {
5468 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5469 (unstable)), (@ peri_type #[doc = "USB_WRAP peripheral singleton"] USB_WRAP <=
5470 USB_WRAP() (unstable)), (@ peri_type #[doc = "XTS_AES peripheral singleton"]
5471 XTS_AES <= XTS_AES() (unstable)), (@ peri_type #[doc =
5472 "WIFI peripheral singleton"] WIFI <= WIFI(WIFI_MAC : { bind_mac_interrupt,
5473 enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
5474 enable_pwr_interrupt, disable_pwr_interrupt })), (@ peri_type #[doc =
5475 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type #[doc =
5476 "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)), (@ peri_type #[doc =
5477 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
5478 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
5479 (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual()
5480 (unstable)), (@ peri_type #[doc = "ULP_RISCV_CORE peripheral singleton"]
5481 ULP_RISCV_CORE <= virtual() (unstable)), (@ peri_type #[doc =
5482 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)),
5483 (@ peri_type #[doc = "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <=
5484 virtual() (unstable)), (@ peri_type #[doc =
5485 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)),
5486 (@ peri_type #[doc = "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <=
5487 virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1),
5488 (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
5489 (GPIO11), (GPIO12), (GPIO13), (GPIO14), (#[cfg(not(use_xtal32k))] GPIO15),
5490 (#[cfg(not(use_xtal32k))] GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20),
5491 (GPIO21), (GPIO26), (GPIO27), (GPIO28), (GPIO29), (GPIO30), (GPIO31), (GPIO32),
5492 (GPIO33), (GPIO34), (GPIO35), (GPIO36), (GPIO37), (GPIO38), (GPIO39), (GPIO40),
5493 (GPIO41), (GPIO42), (GPIO43), (GPIO44), (GPIO45), (GPIO46), (DMA_SPI2(unstable)),
5494 (DMA_SPI3(unstable)), (DMA_I2S0(unstable)), (DMA_CRYPTO(unstable)),
5495 (DMA_COPY(unstable)), (PCNT0_UNIT0(unstable)), (PCNT0_UNIT1(unstable)),
5496 (PCNT0_UNIT2(unstable)), (PCNT0_UNIT3(unstable)), (DAC1(unstable)),
5497 (DAC2(unstable)), (SDM_CH0(unstable)), (SDM_CH1(unstable)), (SDM_CH2(unstable)),
5498 (SDM_CH3(unstable)), (SDM_CH4(unstable)), (SDM_CH5(unstable)),
5499 (SDM_CH6(unstable)), (SDM_CH7(unstable)), (AES(unstable)),
5500 (APB_SARADC(unstable)), (DS(unstable)), (EXTMEM(unstable)), (FE(unstable)),
5501 (FE2(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)),
5502 (I2C_ANA_MST(unstable)), (I2C0), (I2C1), (I2S0(unstable)),
5503 (INTERRUPT_CORE0(unstable)), (IO_MUX(unstable)), (LEDC(unstable)),
5504 (NRX(unstable)), (PCNT(unstable)), (PMS(unstable)), (RMT(unstable)),
5505 (RNG(unstable)), (RSA(unstable)), (LPWR(unstable)), (RTC_TIMER(unstable)),
5506 (LP_I2C0(unstable)), (RTC_IO(unstable)), (SENS(unstable)), (SHA(unstable)),
5507 (SPI0(unstable)), (SPI1(unstable)), (SPI2), (SPI3), (SYSCON(unstable)),
5508 (SYSTEM(unstable)), (SYSTIMER(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
5509 (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)), (USB_FS(unstable)),
5510 (XTS_AES(unstable)), (WIFI), (ADC1(unstable)), (ADC2(unstable)),
5511 (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (PSRAM(unstable)),
5512 (ULP_RISCV_CORE(unstable)), (FROM_CPU_INTR0(unstable)),
5513 (FROM_CPU_INTR1(unstable)), (FROM_CPU_INTR2(unstable)),
5514 (FROM_CPU_INTR3(unstable)))); _for_each_inner_peripheral!((dma_eligible(SPI2,
5515 Spi2, 0, SpiDmaChannel), (I2S0, I2s0, 0, I2sDmaChannel), (AES, Aes, 0,
5516 CryptoDmaChannel), (SPI3, Spi3, 1, SpiDmaChannel), (SHA, Sha, 1,
5517 CryptoDmaChannel)));
5518 };
5519}
5520#[macro_export]
5547#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5548macro_rules! for_each_gpio {
5549 ($($pattern:tt => $code:tt;)*) => {
5550 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5551 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
5552 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
5553 _for_each_inner_gpio!((2, GPIO2() () ([Input] [Output])));
5554 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
5555 _for_each_inner_gpio!((4, GPIO4() () ([Input] [Output])));
5556 _for_each_inner_gpio!((5, GPIO5() () ([Input] [Output])));
5557 _for_each_inner_gpio!((6, GPIO6() () ([Input] [Output])));
5558 _for_each_inner_gpio!((7, GPIO7() () ([Input] [Output])));
5559 _for_each_inner_gpio!((8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])));
5560 _for_each_inner_gpio!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4
5561 => FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((10, GPIO10(_2 => FSPIIO4
5562 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) ([Input]
5563 [Output]))); _for_each_inner_gpio!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 =>
5564 FSPID) (_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])));
5565 _for_each_inner_gpio!((12, GPIO12(_2 => FSPIIO6 _4 => FSPICLK) (_2 => FSPIIO6 _3
5566 => SUBSPICLK _4 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((13,
5567 GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4
5568 => FSPIQ) ([Input] [Output]))); _for_each_inner_gpio!((14, GPIO14(_3 => SUBSPIWP
5569 _4 => FSPIWP) (_2 => FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])));
5570 _for_each_inner_gpio!((15, GPIO15() (_2 => U0RTS) ([Input] [Output])));
5571 _for_each_inner_gpio!((16, GPIO16(_2 => U0CTS) () ([Input] [Output])));
5572 _for_each_inner_gpio!((17, GPIO17() (_2 => U1TXD) ([Input] [Output])));
5573 _for_each_inner_gpio!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) ([Input]
5574 [Output]))); _for_each_inner_gpio!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
5575 ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_2 => U1CTS) (_3 =>
5576 CLK_OUT1) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21() () ([Input]
5577 [Output]))); _for_each_inner_gpio!((26, GPIO26() (_0 => SPICS1) ([Input]
5578 [Output]))); _for_each_inner_gpio!((27, GPIO27(_0 => SPIHD) (_0 => SPIHD)
5579 ([Input] [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SPIWP) (_0 =>
5580 SPIWP) ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() (_0 => SPICS0)
5581 ([Input] [Output]))); _for_each_inner_gpio!((30, GPIO30() (_0 => SPICLK) ([Input]
5582 [Output]))); _for_each_inner_gpio!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input]
5583 [Output]))); _for_each_inner_gpio!((32, GPIO32(_0 => SPID) (_0 => SPID) ([Input]
5584 [Output]))); _for_each_inner_gpio!((33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2
5585 => FSPIHD _3 => SUBSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((34,
5586 GPIO34(_2 => FSPICS0) (_2 => FSPICS0 _3 => SUBSPICS0) ([Input] [Output])));
5587 _for_each_inner_gpio!((35, GPIO35(_2 => FSPID _3 => SUBSPID) (_2 => FSPID _3 =>
5588 SUBSPID) ([Input] [Output]))); _for_each_inner_gpio!((36, GPIO36(_2 => FSPICLK)
5589 (_2 => FSPICLK _3 => SUBSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((37,
5590 GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 =>
5591 SPIDQS) ([Input] [Output]))); _for_each_inner_gpio!((38, GPIO38(_2 => FSPIWP _3
5592 => SUBSPIWP) (_2 => FSPIWP _3 => SUBSPIWP) ([Input] [Output])));
5593 _for_each_inner_gpio!((39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 => SUBSPICS1)
5594 ([Input] [Output]))); _for_each_inner_gpio!((40, GPIO40() (_0 => MTDO _2 =>
5595 CLK_OUT2) ([Input] [Output]))); _for_each_inner_gpio!((41, GPIO41(_0 => MTDI) (_2
5596 => CLK_OUT1) ([Input] [Output]))); _for_each_inner_gpio!((42, GPIO42(_0 => MTMS)
5597 () ([Input] [Output]))); _for_each_inner_gpio!((43, GPIO43() (_0 => U0TXD _2 =>
5598 CLK_OUT1) ([Input] [Output]))); _for_each_inner_gpio!((44, GPIO44(_0 => U0RXD)
5599 (_2 => CLK_OUT2) ([Input] [Output]))); _for_each_inner_gpio!((45, GPIO45() ()
5600 ([Input] [Output]))); _for_each_inner_gpio!((46, GPIO46() () ([Input]
5601 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
5602 GPIO1() () ([Input] [Output])), (2, GPIO2() () ([Input] [Output])), (3, GPIO3()
5603 () ([Input] [Output])), (4, GPIO4() () ([Input] [Output])), (5, GPIO5() ()
5604 ([Input] [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input]
5605 [Output])), (8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])), (9, GPIO9(_3 =>
5606 SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) ([Input] [Output])), (10,
5607 GPIO10(_2 => FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0)
5608 ([Input] [Output])), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
5609 FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])), (12, GPIO12(_2 => FSPIIO6
5610 _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) ([Input] [Output])),
5611 (13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ
5612 _4 => FSPIQ) ([Input] [Output])), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 =>
5613 FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])), (15, GPIO15() (_2 =>
5614 U0RTS) ([Input] [Output])), (16, GPIO16(_2 => U0CTS) () ([Input] [Output])), (17,
5615 GPIO17() (_2 => U1TXD) ([Input] [Output])), (18, GPIO18(_2 => U1RXD) (_3 =>
5616 CLK_OUT3) ([Input] [Output])), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
5617 ([Input] [Output])), (20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
5618 [Output])), (21, GPIO21() () ([Input] [Output])), (26, GPIO26() (_0 => SPICS1)
5619 ([Input] [Output])), (27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
5620 (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (29, GPIO29() (_0 =>
5621 SPICS0) ([Input] [Output])), (30, GPIO30() (_0 => SPICLK) ([Input] [Output])),
5622 (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (32, GPIO32(_0 => SPID)
5623 (_0 => SPID) ([Input] [Output])), (33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2 =>
5624 FSPIHD _3 => SUBSPIHD) ([Input] [Output])), (34, GPIO34(_2 => FSPICS0) (_2 =>
5625 FSPICS0 _3 => SUBSPICS0) ([Input] [Output])), (35, GPIO35(_2 => FSPID _3 =>
5626 SUBSPID) (_2 => FSPID _3 => SUBSPID) ([Input] [Output])), (36, GPIO36(_2 =>
5627 FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) ([Input] [Output])), (37, GPIO37(_2 =>
5628 FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS)
5629 ([Input] [Output])), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 =>
5630 SUBSPIWP) ([Input] [Output])), (39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 =>
5631 SUBSPICS1) ([Input] [Output])), (40, GPIO40() (_0 => MTDO _2 => CLK_OUT2)
5632 ([Input] [Output])), (41, GPIO41(_0 => MTDI) (_2 => CLK_OUT1) ([Input]
5633 [Output])), (42, GPIO42(_0 => MTMS) () ([Input] [Output])), (43, GPIO43() (_0 =>
5634 U0TXD _2 => CLK_OUT1) ([Input] [Output])), (44, GPIO44(_0 => U0RXD) (_2 =>
5635 CLK_OUT2) ([Input] [Output])), (45, GPIO45() () ([Input] [Output])), (46,
5636 GPIO46() () ([Input] [Output]))));
5637 };
5638}
5639#[macro_export]
5666#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5667macro_rules! for_each_analog_function {
5668 ($($pattern:tt => $code:tt;)*) => {
5669 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5670 tt) => {} } _for_each_inner_analog_function!((TOUCH1, GPIO1));
5671 _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
5672 _for_each_inner_analog_function!((TOUCH2, GPIO2));
5673 _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
5674 _for_each_inner_analog_function!((TOUCH3, GPIO3));
5675 _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
5676 _for_each_inner_analog_function!((TOUCH4, GPIO4));
5677 _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
5678 _for_each_inner_analog_function!((TOUCH5, GPIO5));
5679 _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
5680 _for_each_inner_analog_function!((TOUCH6, GPIO6));
5681 _for_each_inner_analog_function!((ADC1_CH5, GPIO6));
5682 _for_each_inner_analog_function!((TOUCH7, GPIO7));
5683 _for_each_inner_analog_function!((ADC1_CH6, GPIO7));
5684 _for_each_inner_analog_function!((TOUCH8, GPIO8));
5685 _for_each_inner_analog_function!((ADC1_CH7, GPIO8));
5686 _for_each_inner_analog_function!((TOUCH9, GPIO9));
5687 _for_each_inner_analog_function!((ADC1_CH8, GPIO9));
5688 _for_each_inner_analog_function!((TOUCH10, GPIO10));
5689 _for_each_inner_analog_function!((ADC1_CH9, GPIO10));
5690 _for_each_inner_analog_function!((TOUCH11, GPIO11));
5691 _for_each_inner_analog_function!((ADC2_CH0, GPIO11));
5692 _for_each_inner_analog_function!((TOUCH12, GPIO12));
5693 _for_each_inner_analog_function!((ADC2_CH1, GPIO12));
5694 _for_each_inner_analog_function!((TOUCH13, GPIO13));
5695 _for_each_inner_analog_function!((ADC2_CH2, GPIO13));
5696 _for_each_inner_analog_function!((TOUCH14, GPIO14));
5697 _for_each_inner_analog_function!((ADC2_CH3, GPIO14));
5698 _for_each_inner_analog_function!((XTAL_32K_P, GPIO15));
5699 _for_each_inner_analog_function!((ADC2_CH4, GPIO15));
5700 _for_each_inner_analog_function!((XTAL_32K_N, GPIO16));
5701 _for_each_inner_analog_function!((ADC2_CH5, GPIO16));
5702 _for_each_inner_analog_function!((DAC1, GPIO17));
5703 _for_each_inner_analog_function!((ADC2_CH6, GPIO17));
5704 _for_each_inner_analog_function!((DAC2, GPIO18));
5705 _for_each_inner_analog_function!((ADC2_CH7, GPIO18));
5706 _for_each_inner_analog_function!((USB_FS_DM, GPIO19));
5707 _for_each_inner_analog_function!((ADC2_CH8, GPIO19));
5708 _for_each_inner_analog_function!((USB_FS_DP, GPIO20));
5709 _for_each_inner_analog_function!((ADC2_CH9, GPIO20));
5710 _for_each_inner_analog_function!(((TOUCH1, TOUCHn, 1), GPIO1));
5711 _for_each_inner_analog_function!(((TOUCH2, TOUCHn, 2), GPIO2));
5712 _for_each_inner_analog_function!(((TOUCH3, TOUCHn, 3), GPIO3));
5713 _for_each_inner_analog_function!(((TOUCH4, TOUCHn, 4), GPIO4));
5714 _for_each_inner_analog_function!(((TOUCH5, TOUCHn, 5), GPIO5));
5715 _for_each_inner_analog_function!(((TOUCH6, TOUCHn, 6), GPIO6));
5716 _for_each_inner_analog_function!(((TOUCH7, TOUCHn, 7), GPIO7));
5717 _for_each_inner_analog_function!(((TOUCH8, TOUCHn, 8), GPIO8));
5718 _for_each_inner_analog_function!(((TOUCH9, TOUCHn, 9), GPIO9));
5719 _for_each_inner_analog_function!(((TOUCH10, TOUCHn, 10), GPIO10));
5720 _for_each_inner_analog_function!(((TOUCH11, TOUCHn, 11), GPIO11));
5721 _for_each_inner_analog_function!(((TOUCH12, TOUCHn, 12), GPIO12));
5722 _for_each_inner_analog_function!(((TOUCH13, TOUCHn, 13), GPIO13));
5723 _for_each_inner_analog_function!(((TOUCH14, TOUCHn, 14), GPIO14));
5724 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
5725 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
5726 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
5727 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
5728 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
5729 _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6));
5730 _for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO7));
5731 _for_each_inner_analog_function!(((ADC1_CH7, ADCn_CHm, 1, 7), GPIO8));
5732 _for_each_inner_analog_function!(((ADC1_CH8, ADCn_CHm, 1, 8), GPIO9));
5733 _for_each_inner_analog_function!(((ADC1_CH9, ADCn_CHm, 1, 9), GPIO10));
5734 _for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO11));
5735 _for_each_inner_analog_function!(((ADC2_CH1, ADCn_CHm, 2, 1), GPIO12));
5736 _for_each_inner_analog_function!(((ADC2_CH2, ADCn_CHm, 2, 2), GPIO13));
5737 _for_each_inner_analog_function!(((ADC2_CH3, ADCn_CHm, 2, 3), GPIO14));
5738 _for_each_inner_analog_function!(((ADC2_CH4, ADCn_CHm, 2, 4), GPIO15));
5739 _for_each_inner_analog_function!(((ADC2_CH5, ADCn_CHm, 2, 5), GPIO16));
5740 _for_each_inner_analog_function!(((ADC2_CH6, ADCn_CHm, 2, 6), GPIO17));
5741 _for_each_inner_analog_function!(((ADC2_CH7, ADCn_CHm, 2, 7), GPIO18));
5742 _for_each_inner_analog_function!(((ADC2_CH8, ADCn_CHm, 2, 8), GPIO19));
5743 _for_each_inner_analog_function!(((ADC2_CH9, ADCn_CHm, 2, 9), GPIO20));
5744 _for_each_inner_analog_function!(((DAC1, DACn, 1), GPIO17));
5745 _for_each_inner_analog_function!(((DAC2, DACn, 2), GPIO18));
5746 _for_each_inner_analog_function!((all(TOUCH1, GPIO1), (ADC1_CH0, GPIO1), (TOUCH2,
5747 GPIO2), (ADC1_CH1, GPIO2), (TOUCH3, GPIO3), (ADC1_CH2, GPIO3), (TOUCH4, GPIO4),
5748 (ADC1_CH3, GPIO4), (TOUCH5, GPIO5), (ADC1_CH4, GPIO5), (TOUCH6, GPIO6),
5749 (ADC1_CH5, GPIO6), (TOUCH7, GPIO7), (ADC1_CH6, GPIO7), (TOUCH8, GPIO8),
5750 (ADC1_CH7, GPIO8), (TOUCH9, GPIO9), (ADC1_CH8, GPIO9), (TOUCH10, GPIO10),
5751 (ADC1_CH9, GPIO10), (TOUCH11, GPIO11), (ADC2_CH0, GPIO11), (TOUCH12, GPIO12),
5752 (ADC2_CH1, GPIO12), (TOUCH13, GPIO13), (ADC2_CH2, GPIO13), (TOUCH14, GPIO14),
5753 (ADC2_CH3, GPIO14), (XTAL_32K_P, GPIO15), (ADC2_CH4, GPIO15), (XTAL_32K_N,
5754 GPIO16), (ADC2_CH5, GPIO16), (DAC1, GPIO17), (ADC2_CH6, GPIO17), (DAC2, GPIO18),
5755 (ADC2_CH7, GPIO18), (USB_FS_DM, GPIO19), (ADC2_CH8, GPIO19), (USB_FS_DP, GPIO20),
5756 (ADC2_CH9, GPIO20))); _for_each_inner_analog_function!((TOUCHn((TOUCH1, TOUCHn,
5757 1), GPIO1), ((TOUCH2, TOUCHn, 2), GPIO2), ((TOUCH3, TOUCHn, 3), GPIO3), ((TOUCH4,
5758 TOUCHn, 4), GPIO4), ((TOUCH5, TOUCHn, 5), GPIO5), ((TOUCH6, TOUCHn, 6), GPIO6),
5759 ((TOUCH7, TOUCHn, 7), GPIO7), ((TOUCH8, TOUCHn, 8), GPIO8), ((TOUCH9, TOUCHn, 9),
5760 GPIO9), ((TOUCH10, TOUCHn, 10), GPIO10), ((TOUCH11, TOUCHn, 11), GPIO11),
5761 ((TOUCH12, TOUCHn, 12), GPIO12), ((TOUCH13, TOUCHn, 13), GPIO13), ((TOUCH14,
5762 TOUCHn, 14), GPIO14))); _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0,
5763 ADCn_CHm, 1, 0), GPIO1), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2,
5764 ADCn_CHm, 1, 2), GPIO3), ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4,
5765 ADCn_CHm, 1, 4), GPIO5), ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6), ((ADC1_CH6,
5766 ADCn_CHm, 1, 6), GPIO7), ((ADC1_CH7, ADCn_CHm, 1, 7), GPIO8), ((ADC1_CH8,
5767 ADCn_CHm, 1, 8), GPIO9), ((ADC1_CH9, ADCn_CHm, 1, 9), GPIO10), ((ADC2_CH0,
5768 ADCn_CHm, 2, 0), GPIO11), ((ADC2_CH1, ADCn_CHm, 2, 1), GPIO12), ((ADC2_CH2,
5769 ADCn_CHm, 2, 2), GPIO13), ((ADC2_CH3, ADCn_CHm, 2, 3), GPIO14), ((ADC2_CH4,
5770 ADCn_CHm, 2, 4), GPIO15), ((ADC2_CH5, ADCn_CHm, 2, 5), GPIO16), ((ADC2_CH6,
5771 ADCn_CHm, 2, 6), GPIO17), ((ADC2_CH7, ADCn_CHm, 2, 7), GPIO18), ((ADC2_CH8,
5772 ADCn_CHm, 2, 8), GPIO19), ((ADC2_CH9, ADCn_CHm, 2, 9), GPIO20)));
5773 _for_each_inner_analog_function!((DACn((DAC1, DACn, 1), GPIO17), ((DAC2, DACn,
5774 2), GPIO18)));
5775 };
5776}
5777#[macro_export]
5815#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5816macro_rules! for_each_lp_function {
5817 ($($pattern:tt => $code:tt;)*) => {
5818 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5819 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _0));
5820 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _0));
5821 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _0));
5822 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _0));
5823 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _0));
5824 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _0));
5825 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _0));
5826 _for_each_inner_lp_function!((LP_GPIO7, GPIO7, _0));
5827 _for_each_inner_lp_function!((LP_GPIO8, GPIO8, _0));
5828 _for_each_inner_lp_function!((LP_GPIO9, GPIO9, _0));
5829 _for_each_inner_lp_function!((LP_GPIO10, GPIO10, _0));
5830 _for_each_inner_lp_function!((LP_GPIO11, GPIO11, _0));
5831 _for_each_inner_lp_function!((LP_GPIO12, GPIO12, _0));
5832 _for_each_inner_lp_function!((LP_GPIO13, GPIO13, _0));
5833 _for_each_inner_lp_function!((LP_GPIO14, GPIO14, _0));
5834 _for_each_inner_lp_function!((LP_GPIO15, GPIO15, _0));
5835 _for_each_inner_lp_function!((LP_GPIO16, GPIO16, _0));
5836 _for_each_inner_lp_function!((LP_GPIO17, GPIO17, _0));
5837 _for_each_inner_lp_function!((LP_GPIO18, GPIO18, _0));
5838 _for_each_inner_lp_function!((LP_GPIO19, GPIO19, _0));
5839 _for_each_inner_lp_function!((LP_GPIO20, GPIO20, _0));
5840 _for_each_inner_lp_function!((LP_GPIO21, GPIO21, _0));
5841 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, () ()));
5842 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()));
5843 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()));
5844 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()));
5845 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()));
5846 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()));
5847 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()));
5848 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO7, _0, () ()));
5849 _for_each_inner_lp_function!(((LP_GPIO8, LP_GPIOn, 8), GPIO8, _0, () ()));
5850 _for_each_inner_lp_function!(((LP_GPIO9, LP_GPIOn, 9), GPIO9, _0, () ()));
5851 _for_each_inner_lp_function!(((LP_GPIO10, LP_GPIOn, 10), GPIO10, _0, () ()));
5852 _for_each_inner_lp_function!(((LP_GPIO11, LP_GPIOn, 11), GPIO11, _0, () ()));
5853 _for_each_inner_lp_function!(((LP_GPIO12, LP_GPIOn, 12), GPIO12, _0, () ()));
5854 _for_each_inner_lp_function!(((LP_GPIO13, LP_GPIOn, 13), GPIO13, _0, () ()));
5855 _for_each_inner_lp_function!(((LP_GPIO14, LP_GPIOn, 14), GPIO14, _0, () ()));
5856 _for_each_inner_lp_function!(((LP_GPIO15, LP_GPIOn, 15), GPIO15, _0, () ()));
5857 _for_each_inner_lp_function!(((LP_GPIO16, LP_GPIOn, 16), GPIO16, _0, () ()));
5858 _for_each_inner_lp_function!(((LP_GPIO17, LP_GPIOn, 17), GPIO17, _0, () ()));
5859 _for_each_inner_lp_function!(((LP_GPIO18, LP_GPIOn, 18), GPIO18, _0, () ()));
5860 _for_each_inner_lp_function!(((LP_GPIO19, LP_GPIOn, 19), GPIO19, _0, () ()));
5861 _for_each_inner_lp_function!(((LP_GPIO20, LP_GPIOn, 20), GPIO20, _0, () ()));
5862 _for_each_inner_lp_function!(((LP_GPIO21, LP_GPIOn, 21), GPIO21, _0, () ()));
5863 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _0), (LP_GPIO1, GPIO1, _0),
5864 (LP_GPIO2, GPIO2, _0), (LP_GPIO3, GPIO3, _0), (LP_GPIO4, GPIO4, _0), (LP_GPIO5,
5865 GPIO5, _0), (LP_GPIO6, GPIO6, _0), (LP_GPIO7, GPIO7, _0), (LP_GPIO8, GPIO8, _0),
5866 (LP_GPIO9, GPIO9, _0), (LP_GPIO10, GPIO10, _0), (LP_GPIO11, GPIO11, _0),
5867 (LP_GPIO12, GPIO12, _0), (LP_GPIO13, GPIO13, _0), (LP_GPIO14, GPIO14, _0),
5868 (LP_GPIO15, GPIO15, _0), (LP_GPIO16, GPIO16, _0), (LP_GPIO17, GPIO17, _0),
5869 (LP_GPIO18, GPIO18, _0), (LP_GPIO19, GPIO19, _0), (LP_GPIO20, GPIO20, _0),
5870 (LP_GPIO21, GPIO21, _0))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0,
5871 LP_GPIOn, 0), GPIO0, _0, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()),
5872 ((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0,
5873 () ()), ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5),
5874 GPIO5, _0, () ()), ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()), ((LP_GPIO7,
5875 LP_GPIOn, 7), GPIO7, _0, () ()), ((LP_GPIO8, LP_GPIOn, 8), GPIO8, _0, () ()),
5876 ((LP_GPIO9, LP_GPIOn, 9), GPIO9, _0, () ()), ((LP_GPIO10, LP_GPIOn, 10), GPIO10,
5877 _0, () ()), ((LP_GPIO11, LP_GPIOn, 11), GPIO11, _0, () ()), ((LP_GPIO12,
5878 LP_GPIOn, 12), GPIO12, _0, () ()), ((LP_GPIO13, LP_GPIOn, 13), GPIO13, _0, ()
5879 ()), ((LP_GPIO14, LP_GPIOn, 14), GPIO14, _0, () ()), ((LP_GPIO15, LP_GPIOn, 15),
5880 GPIO15, _0, () ()), ((LP_GPIO16, LP_GPIOn, 16), GPIO16, _0, () ()), ((LP_GPIO17,
5881 LP_GPIOn, 17), GPIO17, _0, () ()), ((LP_GPIO18, LP_GPIOn, 18), GPIO18, _0, ()
5882 ()), ((LP_GPIO19, LP_GPIOn, 19), GPIO19, _0, () ()), ((LP_GPIO20, LP_GPIOn, 20),
5883 GPIO20, _0, () ()), ((LP_GPIO21, LP_GPIOn, 21), GPIO21, _0, () ())));
5884 };
5885}
5886#[macro_export]
5917#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5918macro_rules! for_each_iomux_function {
5919 ($($pattern:tt => $code:tt;)*) => {
5920 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5921 tt) => {} } _for_each_inner_iomux_function!((SUBSPICS1, GPIO8, _3));
5922 _for_each_inner_iomux_function!((SUBSPIHD, GPIO9, _3));
5923 _for_each_inner_iomux_function!((FSPIHD, GPIO9, _4));
5924 _for_each_inner_iomux_function!((FSPIIO4, GPIO10, _2));
5925 _for_each_inner_iomux_function!((SUBSPICS0, GPIO10, _3));
5926 _for_each_inner_iomux_function!((FSPICS0, GPIO10, _4));
5927 _for_each_inner_iomux_function!((FSPIIO5, GPIO11, _2));
5928 _for_each_inner_iomux_function!((SUBSPID, GPIO11, _3));
5929 _for_each_inner_iomux_function!((FSPID, GPIO11, _4));
5930 _for_each_inner_iomux_function!((FSPIIO6, GPIO12, _2));
5931 _for_each_inner_iomux_function!((SUBSPICLK, GPIO12, _3));
5932 _for_each_inner_iomux_function!((FSPICLK, GPIO12, _4));
5933 _for_each_inner_iomux_function!((FSPIIO7, GPIO13, _2));
5934 _for_each_inner_iomux_function!((SUBSPIQ, GPIO13, _3));
5935 _for_each_inner_iomux_function!((FSPIQ, GPIO13, _4));
5936 _for_each_inner_iomux_function!((FSPIDQS, GPIO14, _2));
5937 _for_each_inner_iomux_function!((SUBSPIWP, GPIO14, _3));
5938 _for_each_inner_iomux_function!((FSPIWP, GPIO14, _4));
5939 _for_each_inner_iomux_function!((U0RTS, GPIO15, _2));
5940 _for_each_inner_iomux_function!((U0CTS, GPIO16, _2));
5941 _for_each_inner_iomux_function!((U1TXD, GPIO17, _2));
5942 _for_each_inner_iomux_function!((U1RXD, GPIO18, _2));
5943 _for_each_inner_iomux_function!((CLK_OUT3, GPIO18, _3));
5944 _for_each_inner_iomux_function!((U1RTS, GPIO19, _2));
5945 _for_each_inner_iomux_function!((CLK_OUT2, GPIO19, _3));
5946 _for_each_inner_iomux_function!((U1CTS, GPIO20, _2));
5947 _for_each_inner_iomux_function!((CLK_OUT1, GPIO20, _3));
5948 _for_each_inner_iomux_function!((SPICS1, GPIO26, _0));
5949 _for_each_inner_iomux_function!((SPIHD, GPIO27, _0));
5950 _for_each_inner_iomux_function!((SPIWP, GPIO28, _0));
5951 _for_each_inner_iomux_function!((SPICS0, GPIO29, _0));
5952 _for_each_inner_iomux_function!((SPICLK, GPIO30, _0));
5953 _for_each_inner_iomux_function!((SPIQ, GPIO31, _0));
5954 _for_each_inner_iomux_function!((SPID, GPIO32, _0));
5955 _for_each_inner_iomux_function!((FSPIHD, GPIO33, _2));
5956 _for_each_inner_iomux_function!((SUBSPIHD, GPIO33, _3));
5957 _for_each_inner_iomux_function!((FSPICS0, GPIO34, _2));
5958 _for_each_inner_iomux_function!((SUBSPICS0, GPIO34, _3));
5959 _for_each_inner_iomux_function!((FSPID, GPIO35, _2));
5960 _for_each_inner_iomux_function!((SUBSPID, GPIO35, _3));
5961 _for_each_inner_iomux_function!((FSPICLK, GPIO36, _2));
5962 _for_each_inner_iomux_function!((SUBSPICLK, GPIO36, _3));
5963 _for_each_inner_iomux_function!((FSPIQ, GPIO37, _2));
5964 _for_each_inner_iomux_function!((SUBSPIQ, GPIO37, _3));
5965 _for_each_inner_iomux_function!((SPIDQS, GPIO37, _4));
5966 _for_each_inner_iomux_function!((FSPIWP, GPIO38, _2));
5967 _for_each_inner_iomux_function!((SUBSPIWP, GPIO38, _3));
5968 _for_each_inner_iomux_function!((MTCK, GPIO39, _0));
5969 _for_each_inner_iomux_function!((CLK_OUT3, GPIO39, _2));
5970 _for_each_inner_iomux_function!((SUBSPICS1, GPIO39, _3));
5971 _for_each_inner_iomux_function!((MTDO, GPIO40, _0));
5972 _for_each_inner_iomux_function!((CLK_OUT2, GPIO40, _2));
5973 _for_each_inner_iomux_function!((MTDI, GPIO41, _0));
5974 _for_each_inner_iomux_function!((CLK_OUT1, GPIO41, _2));
5975 _for_each_inner_iomux_function!((MTMS, GPIO42, _0));
5976 _for_each_inner_iomux_function!((U0TXD, GPIO43, _0));
5977 _for_each_inner_iomux_function!((CLK_OUT1, GPIO43, _2));
5978 _for_each_inner_iomux_function!((U0RXD, GPIO44, _0));
5979 _for_each_inner_iomux_function!((CLK_OUT2, GPIO44, _2));
5980 _for_each_inner_iomux_function!(((SUBSPICS1, SUBSPICSn, 1), GPIO8, _3));
5981 _for_each_inner_iomux_function!(((SUBSPICS0, SUBSPICSn, 0), GPIO10, _3));
5982 _for_each_inner_iomux_function!(((SUBSPICS0, SUBSPICSn, 0), GPIO34, _3));
5983 _for_each_inner_iomux_function!(((SUBSPICS1, SUBSPICSn, 1), GPIO39, _3));
5984 _for_each_inner_iomux_function!(((FSPIIO4, FSPIIOn, 4), GPIO10, _2));
5985 _for_each_inner_iomux_function!(((FSPIIO5, FSPIIOn, 5), GPIO11, _2));
5986 _for_each_inner_iomux_function!(((FSPIIO6, FSPIIOn, 6), GPIO12, _2));
5987 _for_each_inner_iomux_function!(((FSPIIO7, FSPIIOn, 7), GPIO13, _2));
5988 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO10, _4));
5989 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO34, _2));
5990 _for_each_inner_iomux_function!(((CLK_OUT3, CLK_OUTn, 3), GPIO18, _3));
5991 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO19, _3));
5992 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO20, _3));
5993 _for_each_inner_iomux_function!(((CLK_OUT3, CLK_OUTn, 3), GPIO39, _2));
5994 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO40, _2));
5995 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO41, _2));
5996 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO43, _2));
5997 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO44, _2));
5998 _for_each_inner_iomux_function!(((SPICS1, SPICSn, 1), GPIO26, _0));
5999 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO29, _0));
6000 _for_each_inner_iomux_function!((all(SUBSPICS1, GPIO8, _3), (SUBSPIHD, GPIO9,
6001 _3), (FSPIHD, GPIO9, _4), (FSPIIO4, GPIO10, _2), (SUBSPICS0, GPIO10, _3),
6002 (FSPICS0, GPIO10, _4), (FSPIIO5, GPIO11, _2), (SUBSPID, GPIO11, _3), (FSPID,
6003 GPIO11, _4), (FSPIIO6, GPIO12, _2), (SUBSPICLK, GPIO12, _3), (FSPICLK, GPIO12,
6004 _4), (FSPIIO7, GPIO13, _2), (SUBSPIQ, GPIO13, _3), (FSPIQ, GPIO13, _4), (FSPIDQS,
6005 GPIO14, _2), (SUBSPIWP, GPIO14, _3), (FSPIWP, GPIO14, _4), (U0RTS, GPIO15, _2),
6006 (U0CTS, GPIO16, _2), (U1TXD, GPIO17, _2), (U1RXD, GPIO18, _2), (CLK_OUT3, GPIO18,
6007 _3), (U1RTS, GPIO19, _2), (CLK_OUT2, GPIO19, _3), (U1CTS, GPIO20, _2), (CLK_OUT1,
6008 GPIO20, _3), (SPICS1, GPIO26, _0), (SPIHD, GPIO27, _0), (SPIWP, GPIO28, _0),
6009 (SPICS0, GPIO29, _0), (SPICLK, GPIO30, _0), (SPIQ, GPIO31, _0), (SPID, GPIO32,
6010 _0), (FSPIHD, GPIO33, _2), (SUBSPIHD, GPIO33, _3), (FSPICS0, GPIO34, _2),
6011 (SUBSPICS0, GPIO34, _3), (FSPID, GPIO35, _2), (SUBSPID, GPIO35, _3), (FSPICLK,
6012 GPIO36, _2), (SUBSPICLK, GPIO36, _3), (FSPIQ, GPIO37, _2), (SUBSPIQ, GPIO37, _3),
6013 (SPIDQS, GPIO37, _4), (FSPIWP, GPIO38, _2), (SUBSPIWP, GPIO38, _3), (MTCK,
6014 GPIO39, _0), (CLK_OUT3, GPIO39, _2), (SUBSPICS1, GPIO39, _3), (MTDO, GPIO40, _0),
6015 (CLK_OUT2, GPIO40, _2), (MTDI, GPIO41, _0), (CLK_OUT1, GPIO41, _2), (MTMS,
6016 GPIO42, _0), (U0TXD, GPIO43, _0), (CLK_OUT1, GPIO43, _2), (U0RXD, GPIO44, _0),
6017 (CLK_OUT2, GPIO44, _2))); _for_each_inner_iomux_function!((SUBSPICSn((SUBSPICS1,
6018 SUBSPICSn, 1), GPIO8, _3), ((SUBSPICS0, SUBSPICSn, 0), GPIO10, _3), ((SUBSPICS0,
6019 SUBSPICSn, 0), GPIO34, _3), ((SUBSPICS1, SUBSPICSn, 1), GPIO39, _3)));
6020 _for_each_inner_iomux_function!((FSPIIOn((FSPIIO4, FSPIIOn, 4), GPIO10, _2),
6021 ((FSPIIO5, FSPIIOn, 5), GPIO11, _2), ((FSPIIO6, FSPIIOn, 6), GPIO12, _2),
6022 ((FSPIIO7, FSPIIOn, 7), GPIO13, _2)));
6023 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO10, _4),
6024 ((FSPICS0, FSPICSn, 0), GPIO34, _2)));
6025 _for_each_inner_iomux_function!((CLK_OUTn((CLK_OUT3, CLK_OUTn, 3), GPIO18, _3),
6026 ((CLK_OUT2, CLK_OUTn, 2), GPIO19, _3), ((CLK_OUT1, CLK_OUTn, 1), GPIO20, _3),
6027 ((CLK_OUT3, CLK_OUTn, 3), GPIO39, _2), ((CLK_OUT2, CLK_OUTn, 2), GPIO40, _2),
6028 ((CLK_OUT1, CLK_OUTn, 1), GPIO41, _2), ((CLK_OUT1, CLK_OUTn, 1), GPIO43, _2),
6029 ((CLK_OUT2, CLK_OUTn, 2), GPIO44, _2)));
6030 _for_each_inner_iomux_function!((SPICSn((SPICS1, SPICSn, 1), GPIO26, _0),
6031 ((SPICS0, SPICSn, 0), GPIO29, _0)));
6032 };
6033}
6034#[macro_export]
6051#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6052macro_rules! gpio_for_signal {
6053 (LP_GPIO0 $(, $_fallback:literal)?) => {
6054 "GPIO0"
6055 };
6056 (TOUCH1 $(, $_fallback:literal)?) => {
6057 "GPIO1"
6058 };
6059 (ADC1_CH0 $(, $_fallback:literal)?) => {
6060 "GPIO1"
6061 };
6062 (LP_GPIO1 $(, $_fallback:literal)?) => {
6063 "GPIO1"
6064 };
6065 (TOUCH2 $(, $_fallback:literal)?) => {
6066 "GPIO2"
6067 };
6068 (ADC1_CH1 $(, $_fallback:literal)?) => {
6069 "GPIO2"
6070 };
6071 (LP_GPIO2 $(, $_fallback:literal)?) => {
6072 "GPIO2"
6073 };
6074 (TOUCH3 $(, $_fallback:literal)?) => {
6075 "GPIO3"
6076 };
6077 (ADC1_CH2 $(, $_fallback:literal)?) => {
6078 "GPIO3"
6079 };
6080 (LP_GPIO3 $(, $_fallback:literal)?) => {
6081 "GPIO3"
6082 };
6083 (TOUCH4 $(, $_fallback:literal)?) => {
6084 "GPIO4"
6085 };
6086 (ADC1_CH3 $(, $_fallback:literal)?) => {
6087 "GPIO4"
6088 };
6089 (LP_GPIO4 $(, $_fallback:literal)?) => {
6090 "GPIO4"
6091 };
6092 (TOUCH5 $(, $_fallback:literal)?) => {
6093 "GPIO5"
6094 };
6095 (ADC1_CH4 $(, $_fallback:literal)?) => {
6096 "GPIO5"
6097 };
6098 (LP_GPIO5 $(, $_fallback:literal)?) => {
6099 "GPIO5"
6100 };
6101 (TOUCH6 $(, $_fallback:literal)?) => {
6102 "GPIO6"
6103 };
6104 (ADC1_CH5 $(, $_fallback:literal)?) => {
6105 "GPIO6"
6106 };
6107 (LP_GPIO6 $(, $_fallback:literal)?) => {
6108 "GPIO6"
6109 };
6110 (TOUCH7 $(, $_fallback:literal)?) => {
6111 "GPIO7"
6112 };
6113 (ADC1_CH6 $(, $_fallback:literal)?) => {
6114 "GPIO7"
6115 };
6116 (LP_GPIO7 $(, $_fallback:literal)?) => {
6117 "GPIO7"
6118 };
6119 (SUBSPICS1 $(, $_fallback:literal)?) => {
6120 "GPIO8"
6121 };
6122 (TOUCH8 $(, $_fallback:literal)?) => {
6123 "GPIO8"
6124 };
6125 (ADC1_CH7 $(, $_fallback:literal)?) => {
6126 "GPIO8"
6127 };
6128 (LP_GPIO8 $(, $_fallback:literal)?) => {
6129 "GPIO8"
6130 };
6131 (SUBSPIHD $(, $_fallback:literal)?) => {
6132 "GPIO9"
6133 };
6134 (FSPIHD $(, $_fallback:literal)?) => {
6135 "GPIO9"
6136 };
6137 (TOUCH9 $(, $_fallback:literal)?) => {
6138 "GPIO9"
6139 };
6140 (ADC1_CH8 $(, $_fallback:literal)?) => {
6141 "GPIO9"
6142 };
6143 (LP_GPIO9 $(, $_fallback:literal)?) => {
6144 "GPIO9"
6145 };
6146 (FSPIIO4 $(, $_fallback:literal)?) => {
6147 "GPIO10"
6148 };
6149 (SUBSPICS0 $(, $_fallback:literal)?) => {
6150 "GPIO10"
6151 };
6152 (FSPICS0 $(, $_fallback:literal)?) => {
6153 "GPIO10"
6154 };
6155 (TOUCH10 $(, $_fallback:literal)?) => {
6156 "GPIO10"
6157 };
6158 (ADC1_CH9 $(, $_fallback:literal)?) => {
6159 "GPIO10"
6160 };
6161 (LP_GPIO10 $(, $_fallback:literal)?) => {
6162 "GPIO10"
6163 };
6164 (FSPIIO5 $(, $_fallback:literal)?) => {
6165 "GPIO11"
6166 };
6167 (SUBSPID $(, $_fallback:literal)?) => {
6168 "GPIO11"
6169 };
6170 (FSPID $(, $_fallback:literal)?) => {
6171 "GPIO11"
6172 };
6173 (TOUCH11 $(, $_fallback:literal)?) => {
6174 "GPIO11"
6175 };
6176 (ADC2_CH0 $(, $_fallback:literal)?) => {
6177 "GPIO11"
6178 };
6179 (LP_GPIO11 $(, $_fallback:literal)?) => {
6180 "GPIO11"
6181 };
6182 (FSPIIO6 $(, $_fallback:literal)?) => {
6183 "GPIO12"
6184 };
6185 (SUBSPICLK $(, $_fallback:literal)?) => {
6186 "GPIO12"
6187 };
6188 (FSPICLK $(, $_fallback:literal)?) => {
6189 "GPIO12"
6190 };
6191 (TOUCH12 $(, $_fallback:literal)?) => {
6192 "GPIO12"
6193 };
6194 (ADC2_CH1 $(, $_fallback:literal)?) => {
6195 "GPIO12"
6196 };
6197 (LP_GPIO12 $(, $_fallback:literal)?) => {
6198 "GPIO12"
6199 };
6200 (FSPIIO7 $(, $_fallback:literal)?) => {
6201 "GPIO13"
6202 };
6203 (SUBSPIQ $(, $_fallback:literal)?) => {
6204 "GPIO13"
6205 };
6206 (FSPIQ $(, $_fallback:literal)?) => {
6207 "GPIO13"
6208 };
6209 (TOUCH13 $(, $_fallback:literal)?) => {
6210 "GPIO13"
6211 };
6212 (ADC2_CH2 $(, $_fallback:literal)?) => {
6213 "GPIO13"
6214 };
6215 (LP_GPIO13 $(, $_fallback:literal)?) => {
6216 "GPIO13"
6217 };
6218 (FSPIDQS $(, $_fallback:literal)?) => {
6219 "GPIO14"
6220 };
6221 (SUBSPIWP $(, $_fallback:literal)?) => {
6222 "GPIO14"
6223 };
6224 (FSPIWP $(, $_fallback:literal)?) => {
6225 "GPIO14"
6226 };
6227 (TOUCH14 $(, $_fallback:literal)?) => {
6228 "GPIO14"
6229 };
6230 (ADC2_CH3 $(, $_fallback:literal)?) => {
6231 "GPIO14"
6232 };
6233 (LP_GPIO14 $(, $_fallback:literal)?) => {
6234 "GPIO14"
6235 };
6236 (U0RTS $(, $_fallback:literal)?) => {
6237 "GPIO15"
6238 };
6239 (XTAL_32K_P $(, $_fallback:literal)?) => {
6240 "GPIO15"
6241 };
6242 (ADC2_CH4 $(, $_fallback:literal)?) => {
6243 "GPIO15"
6244 };
6245 (LP_GPIO15 $(, $_fallback:literal)?) => {
6246 "GPIO15"
6247 };
6248 (U0CTS $(, $_fallback:literal)?) => {
6249 "GPIO16"
6250 };
6251 (XTAL_32K_N $(, $_fallback:literal)?) => {
6252 "GPIO16"
6253 };
6254 (ADC2_CH5 $(, $_fallback:literal)?) => {
6255 "GPIO16"
6256 };
6257 (LP_GPIO16 $(, $_fallback:literal)?) => {
6258 "GPIO16"
6259 };
6260 (U1TXD $(, $_fallback:literal)?) => {
6261 "GPIO17"
6262 };
6263 (DAC1 $(, $_fallback:literal)?) => {
6264 "GPIO17"
6265 };
6266 (ADC2_CH6 $(, $_fallback:literal)?) => {
6267 "GPIO17"
6268 };
6269 (LP_GPIO17 $(, $_fallback:literal)?) => {
6270 "GPIO17"
6271 };
6272 (U1RXD $(, $_fallback:literal)?) => {
6273 "GPIO18"
6274 };
6275 (CLK_OUT3 $(, $_fallback:literal)?) => {
6276 "GPIO18"
6277 };
6278 (DAC2 $(, $_fallback:literal)?) => {
6279 "GPIO18"
6280 };
6281 (ADC2_CH7 $(, $_fallback:literal)?) => {
6282 "GPIO18"
6283 };
6284 (LP_GPIO18 $(, $_fallback:literal)?) => {
6285 "GPIO18"
6286 };
6287 (U1RTS $(, $_fallback:literal)?) => {
6288 "GPIO19"
6289 };
6290 (CLK_OUT2 $(, $_fallback:literal)?) => {
6291 "GPIO19"
6292 };
6293 (USB_FS_DM $(, $_fallback:literal)?) => {
6294 "GPIO19"
6295 };
6296 (ADC2_CH8 $(, $_fallback:literal)?) => {
6297 "GPIO19"
6298 };
6299 (LP_GPIO19 $(, $_fallback:literal)?) => {
6300 "GPIO19"
6301 };
6302 (U1CTS $(, $_fallback:literal)?) => {
6303 "GPIO20"
6304 };
6305 (CLK_OUT1 $(, $_fallback:literal)?) => {
6306 "GPIO20"
6307 };
6308 (USB_FS_DP $(, $_fallback:literal)?) => {
6309 "GPIO20"
6310 };
6311 (ADC2_CH9 $(, $_fallback:literal)?) => {
6312 "GPIO20"
6313 };
6314 (LP_GPIO20 $(, $_fallback:literal)?) => {
6315 "GPIO20"
6316 };
6317 (LP_GPIO21 $(, $_fallback:literal)?) => {
6318 "GPIO21"
6319 };
6320 (SPICS1 $(, $_fallback:literal)?) => {
6321 "GPIO26"
6322 };
6323 (SPIHD $(, $_fallback:literal)?) => {
6324 "GPIO27"
6325 };
6326 (SPIWP $(, $_fallback:literal)?) => {
6327 "GPIO28"
6328 };
6329 (SPICS0 $(, $_fallback:literal)?) => {
6330 "GPIO29"
6331 };
6332 (SPICLK $(, $_fallback:literal)?) => {
6333 "GPIO30"
6334 };
6335 (SPIQ $(, $_fallback:literal)?) => {
6336 "GPIO31"
6337 };
6338 (SPID $(, $_fallback:literal)?) => {
6339 "GPIO32"
6340 };
6341 (SPIDQS $(, $_fallback:literal)?) => {
6342 "GPIO37"
6343 };
6344 (MTCK $(, $_fallback:literal)?) => {
6345 "GPIO39"
6346 };
6347 (MTDO $(, $_fallback:literal)?) => {
6348 "GPIO40"
6349 };
6350 (MTDI $(, $_fallback:literal)?) => {
6351 "GPIO41"
6352 };
6353 (MTMS $(, $_fallback:literal)?) => {
6354 "GPIO42"
6355 };
6356 (U0TXD $(, $_fallback:literal)?) => {
6357 "GPIO43"
6358 };
6359 (U0RXD $(, $_fallback:literal)?) => {
6360 "GPIO44"
6361 };
6362 ($_signal:ident, $fallback:literal) => {
6363 $fallback
6364 };
6365}
6366#[macro_export]
6370#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6371macro_rules! define_io_mux_signals {
6372 () => {
6373 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
6374 #[derive(Debug, PartialEq, Copy, Clone)]
6375 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6376 #[doc(hidden)]
6377 pub enum InputSignal {
6378 SPIQ = 0,
6379 SPID = 1,
6380 SPIHD = 2,
6381 SPIWP = 3,
6382 SPID4 = 7,
6383 SPID5 = 8,
6384 SPID6 = 9,
6385 SPID7 = 10,
6386 SPIDQS = 11,
6387 U0RXD = 14,
6388 U0CTS = 15,
6389 U0DSR = 16,
6390 U1RXD = 17,
6391 U1CTS = 18,
6392 U1DSR = 21,
6393 I2S0O_BCK = 23,
6394 I2S0O_WS = 25,
6395 I2S0I_BCK = 27,
6396 I2S0I_WS = 28,
6397 I2CEXT0_SCL = 29,
6398 I2CEXT0_SDA = 30,
6399 PCNT0_SIG_CH0 = 39,
6400 PCNT0_SIG_CH1 = 40,
6401 PCNT0_CTRL_CH0 = 41,
6402 PCNT0_CTRL_CH1 = 42,
6403 PCNT1_SIG_CH0 = 43,
6404 PCNT1_SIG_CH1 = 44,
6405 PCNT1_CTRL_CH0 = 45,
6406 PCNT1_CTRL_CH1 = 46,
6407 PCNT2_SIG_CH0 = 47,
6408 PCNT2_SIG_CH1 = 48,
6409 PCNT2_CTRL_CH0 = 49,
6410 PCNT2_CTRL_CH1 = 50,
6411 PCNT3_SIG_CH0 = 51,
6412 PCNT3_SIG_CH1 = 52,
6413 PCNT3_CTRL_CH0 = 53,
6414 PCNT3_CTRL_CH1 = 54,
6415 USB_EXTPHY_VP = 61,
6416 USB_EXTPHY_VM = 62,
6417 USB_EXTPHY_RCV = 63,
6418 USB_FS_IDDIG = 64,
6419 USB_FS_AVALID = 65,
6420 USB_FS_SRP_BVALID = 66,
6421 USB_FS_VBUSVALID = 67,
6422 USB_SRP_SESSEND = 68,
6423 SPI3_CLK = 72,
6424 SPI3_Q = 73,
6425 SPI3_D = 74,
6426 SPI3_HD = 75,
6427 SPI3_CS0 = 76,
6428 RMT_SIG_0 = 83,
6429 RMT_SIG_1 = 84,
6430 RMT_SIG_2 = 85,
6431 RMT_SIG_3 = 86,
6432 I2CEXT1_SCL = 95,
6433 I2CEXT1_SDA = 96,
6434 FSPICLK = 108,
6435 FSPIQ = 109,
6436 FSPID = 110,
6437 FSPIHD = 111,
6438 FSPIWP = 112,
6439 FSPIIO4 = 113,
6440 FSPIIO5 = 114,
6441 FSPIIO6 = 115,
6442 FSPIIO7 = 116,
6443 FSPICS0 = 117,
6444 TWAI_RX = 123,
6445 SUBSPIQ = 127,
6446 SUBSPID = 128,
6447 SUBSPIHD = 129,
6448 SUBSPIWP = 130,
6449 I2S0I_DATA_IN15 = 158,
6450 SUBSPID4 = 167,
6451 SUBSPID5 = 168,
6452 SUBSPID6 = 169,
6453 SUBSPID7 = 170,
6454 SUBSPIDQS = 171,
6455 PCMFSYNC = 203,
6456 PCMCLK = 204,
6457 PRO_ALONEGPIO0 = 235,
6458 PRO_ALONEGPIO1 = 236,
6459 PRO_ALONEGPIO2 = 237,
6460 PRO_ALONEGPIO3 = 238,
6461 PRO_ALONEGPIO4 = 239,
6462 PRO_ALONEGPIO5 = 240,
6463 PRO_ALONEGPIO6 = 241,
6464 PRO_ALONEGPIO7 = 242,
6465 MTDI,
6466 MTCK,
6467 MTMS,
6468 }
6469 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
6470 #[derive(Debug, PartialEq, Copy, Clone)]
6471 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6472 #[doc(hidden)]
6473 pub enum OutputSignal {
6474 SPIQ = 0,
6475 SPID = 1,
6476 SPIHD = 2,
6477 SPIWP = 3,
6478 SPICLK = 4,
6479 SPICS0 = 5,
6480 SPICS1 = 6,
6481 SPID4 = 7,
6482 SPID5 = 8,
6483 SPID6 = 9,
6484 SPID7 = 10,
6485 SPIDQS = 11,
6486 U0TXD = 14,
6487 U0RTS = 15,
6488 U0DTR = 16,
6489 U1TXD = 17,
6490 U1RTS = 18,
6491 U1DTR = 21,
6492 I2S0O_BCK = 23,
6493 I2S0O_WS = 25,
6494 I2S0I_BCK = 27,
6495 I2S0I_WS = 28,
6496 I2CEXT0_SCL = 29,
6497 I2CEXT0_SDA = 30,
6498 SDIO_TOHOST_INT = 31,
6499 USB_EXTPHY_OEN = 61,
6500 USB_EXTPHY_VPO = 63,
6501 USB_EXTPHY_VMO = 64,
6502 SPI3_CLK = 72,
6503 SPI3_Q = 73,
6504 SPI3_D = 74,
6505 SPI3_HD = 75,
6506 SPI3_CS0 = 76,
6507 SPI3_CS1 = 77,
6508 SPI3_CS2 = 78,
6509 LEDC_LS_SIG0 = 79,
6510 LEDC_LS_SIG1 = 80,
6511 LEDC_LS_SIG2 = 81,
6512 LEDC_LS_SIG3 = 82,
6513 LEDC_LS_SIG4 = 83,
6514 LEDC_LS_SIG5 = 84,
6515 LEDC_LS_SIG6 = 85,
6516 LEDC_LS_SIG7 = 86,
6517 RMT_SIG_0 = 87,
6518 RMT_SIG_1 = 88,
6519 RMT_SIG_2 = 89,
6520 RMT_SIG_3 = 90,
6521 I2CEXT1_SCL = 95,
6522 I2CEXT1_SDA = 96,
6523 GPIO_SD0 = 100,
6524 GPIO_SD1 = 101,
6525 GPIO_SD2 = 102,
6526 GPIO_SD3 = 103,
6527 GPIO_SD4 = 104,
6528 GPIO_SD5 = 105,
6529 GPIO_SD6 = 106,
6530 GPIO_SD7 = 107,
6531 FSPICLK = 108,
6532 FSPIQ = 109,
6533 FSPID = 110,
6534 FSPIHD = 111,
6535 FSPIWP = 112,
6536 FSPIIO4 = 113,
6537 FSPIIO5 = 114,
6538 FSPIIO6 = 115,
6539 FSPIIO7 = 116,
6540 FSPICS0 = 117,
6541 FSPICS1 = 118,
6542 FSPICS2 = 119,
6543 FSPICS3 = 120,
6544 FSPICS4 = 121,
6545 FSPICS5 = 122,
6546 TWAI_TX = 123,
6547 SUBSPICLK = 126,
6548 SUBSPIQ = 127,
6549 SUBSPID = 128,
6550 SUBSPIHD = 129,
6551 SUBSPIWP = 130,
6552 SUBSPICS0 = 131,
6553 SUBSPICS1 = 132,
6554 FSPIDQS = 133,
6555 FSPI_HSYNC = 134,
6556 FSPI_VSYNC = 135,
6557 FSPI_DE = 136,
6558 FSPICD = 137,
6559 SPI3_CD = 139,
6560 SPI3_DQS = 140,
6561 I2S0O_DATA_OUT23 = 166,
6562 SUBSPID4 = 167,
6563 SUBSPID5 = 168,
6564 SUBSPID6 = 169,
6565 SUBSPID7 = 170,
6566 SUBSPIDQS = 171,
6567 PCMFSYNC = 209,
6568 PCMCLK = 210,
6569 PRO_ALONEGPIO0 = 235,
6570 PRO_ALONEGPIO1 = 236,
6571 PRO_ALONEGPIO2 = 237,
6572 PRO_ALONEGPIO3 = 238,
6573 PRO_ALONEGPIO4 = 239,
6574 PRO_ALONEGPIO5 = 240,
6575 PRO_ALONEGPIO6 = 241,
6576 PRO_ALONEGPIO7 = 242,
6577 CLK_I2S = 251,
6578 GPIO = 256,
6579 CLK_OUT1,
6580 CLK_OUT2,
6581 CLK_OUT3,
6582 MTDO,
6583 }
6584 };
6585}
6586#[macro_export]
6593#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6594macro_rules! define_lp_functions {
6595 () => {
6596 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
6601 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6602 #[doc(hidden)]
6603 pub enum LpFunction {
6604 _0 = 0,
6606 }
6607 impl LpFunction {
6608 pub const LP_GPIO: Self = Self::_0;
6610 }
6611 };
6612}
6613#[macro_export]
6626#[expect(clippy::crate_in_macro_def)]
6627#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6628macro_rules! define_io_mux_reg {
6629 () => {
6630 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
6631 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
6632 }
6633 };
6634}