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.has_bank_1") => {
92 true
93 };
94 ("gpio.input_signal_max") => {
95 242
96 };
97 ("gpio.input_signal_max", str) => {
98 stringify!(242)
99 };
100 ("gpio.output_signal_max") => {
101 256
102 };
103 ("gpio.output_signal_max", str) => {
104 stringify!(256)
105 };
106 ("dedicated_gpio.version") => {
107 "esp32s2"
108 };
109 ("dedicated_gpio.needs_initialization") => {
110 true
111 };
112 ("dedicated_gpio.channel_count") => {
113 8
114 };
115 ("dedicated_gpio.channel_count", str) => {
116 stringify!(8)
117 };
118 ("lp_io.version") => {
119 "v2"
120 };
121 ("lp_io.has_gpio_matrix") => {
122 false
123 };
124 ("uart.ram_size") => {
125 128
126 };
127 ("uart.ram_size", str) => {
128 stringify!(128)
129 };
130 ("uart.version") => {
131 1
132 };
133 ("uart.version", str) => {
134 stringify!(1)
135 };
136 ("uart.peripheral_controls_mem_clk") => {
137 false
138 };
139 ("uart.has_sclk_divider") => {
140 false
141 };
142 ("uart.has_sclk_enable") => {
143 false
144 };
145 ("i2c_master.version") => {
146 2
147 };
148 ("i2c_master.version", str) => {
149 stringify!(2)
150 };
151 ("i2c_master.has_fsm_timeouts") => {
152 false
153 };
154 ("i2c_master.has_hw_bus_clear") => {
155 false
156 };
157 ("i2c_master.has_bus_timeout_enable") => {
158 true
159 };
160 ("i2c_master.separate_filter_config_registers") => {
161 true
162 };
163 ("i2c_master.can_estimate_nack_reason") => {
164 false
165 };
166 ("i2c_master.has_conf_update") => {
167 false
168 };
169 ("i2c_master.has_reliable_fsm_reset") => {
170 false
171 };
172 ("i2c_master.has_arbitration_en") => {
173 true
174 };
175 ("i2c_master.has_tx_fifo_watermark") => {
176 false
177 };
178 ("i2c_master.bus_timeout_is_exponential") => {
179 false
180 };
181 ("i2c_master.has_pd_en") => {
182 true
183 };
184 ("i2c_master.i2c0_data_register_ahb_address") => {
185 1610690588
186 };
187 ("i2c_master.i2c0_data_register_ahb_address", str) => {
188 stringify!(1610690588)
189 };
190 ("i2c_master.max_bus_timeout") => {
191 16777215
192 };
193 ("i2c_master.max_bus_timeout", str) => {
194 stringify!(16777215)
195 };
196 ("i2c_master.ll_intr_mask") => {
197 131071
198 };
199 ("i2c_master.ll_intr_mask", str) => {
200 stringify!(131071)
201 };
202 ("i2c_master.fifo_size") => {
203 32
204 };
205 ("i2c_master.fifo_size", str) => {
206 stringify!(32)
207 };
208 ("spi_master.version") => {
209 2
210 };
211 ("spi_master.version", str) => {
212 stringify!(2)
213 };
214 ("spi_master.fifo_size") => {
215 72
216 };
217 ("spi_master.fifo_size", str) => {
218 stringify!(72)
219 };
220 ("spi_master.bit_order_is_bool") => {
221 true
222 };
223 ("spi_master.has_octal") => {
224 true
225 };
226 ("spi_master.has_app_interrupts") => {
227 false
228 };
229 ("spi_master.has_dma_segmented_transfer") => {
230 true
231 };
232 ("spi_master.has_clk_pre_div") => {
233 false
234 };
235 ("spi_master.dma_can_access_flash") => {
236 false
237 };
238 ("i2s.version") => {
239 1
240 };
241 ("i2s.version", str) => {
242 stringify!(1)
243 };
244 ("i2s.default_clock_source") => {
245 2
246 };
247 ("i2s.default_clock_source", str) => {
248 stringify!(2)
249 };
250 ("i2s.mclk_divider_bit_width") => {
251 6
252 };
253 ("i2s.mclk_divider_bit_width", str) => {
254 stringify!(6)
255 };
256 ("i2s.max_ws_width") => {
257 128
258 };
259 ("i2s.max_ws_width", str) => {
260 stringify!(128)
261 };
262 ("i2s.clock_configured_by_pcr") => {
263 false
264 };
265 ("i2s.clock_configured_by_hp_sys_clkrst") => {
266 false
267 };
268 ("i2s.supports_pdm_rx_hp_filter") => {
269 false
270 };
271 ("i2s.supports_pdm_tx") => {
272 false
273 };
274 ("i2s.supports_pdm_rx") => {
275 false
276 };
277 ("i2s.supports_pcm2pdm") => {
278 false
279 };
280 ("i2s.supports_pdm2pcm") => {
281 false
282 };
283 ("rmt.ram_start") => {
284 1061250048
285 };
286 ("rmt.ram_start", str) => {
287 stringify!(1061250048)
288 };
289 ("rmt.channel_ram_size") => {
290 64
291 };
292 ("rmt.channel_ram_size", str) => {
293 stringify!(64)
294 };
295 ("rmt.has_tx_immediate_stop") => {
296 true
297 };
298 ("rmt.has_tx_loop_count") => {
299 true
300 };
301 ("rmt.has_tx_loop_auto_stop") => {
302 false
303 };
304 ("rmt.has_tx_carrier_data_only") => {
305 true
306 };
307 ("rmt.has_tx_sync") => {
308 true
309 };
310 ("rmt.has_rx_wrap") => {
311 false
312 };
313 ("rmt.has_rx_demodulation") => {
314 true
315 };
316 ("rmt.has_per_channel_clock") => {
317 true
318 };
319 ("usb_otg.fifo_depth_words") => {
320 256
321 };
322 ("usb_otg.fifo_depth_words", str) => {
323 stringify!(256)
324 };
325 ("wifi.has_wifi6") => {
326 false
327 };
328 ("wifi.mac_version") => {
329 1
330 };
331 ("wifi.mac_version", str) => {
332 stringify!(1)
333 };
334 ("wifi.has_5g") => {
335 false
336 };
337 ("wifi.csi_supported") => {
338 true
339 };
340 ("phy.combo_module") => {
341 false
342 };
343 ("ledc.version") => {
344 2
345 };
346 ("ledc.version", str) => {
347 stringify!(2)
348 };
349 ("ledc.channel_count") => {
350 8
351 };
352 ("ledc.channel_count", str) => {
353 stringify!(8)
354 };
355 ("sdm.channel_count") => {
356 8
357 };
358 ("sdm.channel_count", str) => {
359 stringify!(8)
360 };
361 ("timergroup.timg_has_timer1") => {
362 true
363 };
364 ("timergroup.timg_has_divcnt_rst") => {
365 false
366 };
367 ("aes.has_split_text_registers") => {
368 true
369 };
370 ("aes.endianness_configurable") => {
371 true
372 };
373 ("rng.apb_cycle_wait_num") => {
374 16
375 };
376 ("rng.apb_cycle_wait_num", str) => {
377 stringify!(16)
378 };
379 ("rng.trng_supported") => {
380 true
381 };
382 ("rng.is_lp_sys") => {
383 false
384 };
385 ("rsa.version") => {
386 2
387 };
388 ("rsa.version", str) => {
389 stringify!(2)
390 };
391 ("rsa.size_increment") => {
392 32
393 };
394 ("rsa.size_increment", str) => {
395 stringify!(32)
396 };
397 ("rsa.memory_size_bytes") => {
398 512
399 };
400 ("rsa.memory_size_bytes", str) => {
401 stringify!(512)
402 };
403 ("sleep.light_sleep") => {
404 true
405 };
406 ("sleep.deep_sleep") => {
407 true
408 };
409 ("sleep.rejectable_mask") => {
410 10543
411 };
412 ("sleep.ext1_version") => {
413 1
414 };
415 ("sleep.ext1_version", str) => {
416 stringify!(1)
417 };
418 ("sleep.pin_wakeup_version") => {
419 1
420 };
421 ("sleep.pin_wakeup_version", str) => {
422 stringify!(1)
423 };
424 ("sleep.deep_sleep_needs_gpio_isolation") => {
425 true
426 };
427 ("dma.mem2mem_requires_peripheral") => {
428 false
429 };
430 ("dma.ext_mem_configurable_block_size") => {
431 true
432 };
433 ("dma.separate_in_out_interrupts") => {
434 false
435 };
436 ("interrupts.status_registers") => {
437 3
438 };
439 ("interrupts.status_registers", str) => {
440 stringify!(3)
441 };
442 ("mmu.page_size") => {
443 65536
444 };
445 ("mmu.page_size", str) => {
446 stringify!(65536)
447 };
448 ("mmu.entry_num") => {
449 256
450 };
451 ("mmu.entry_num", str) => {
452 stringify!(256)
453 };
454 ("psram.octal_spi") => {
455 false
456 };
457 ("psram.hex_spi") => {
458 false
459 };
460 ("psram.extmem_origin") => {
461 1062207488
462 };
463 ("psram.extmem_origin", str) => {
464 stringify!(1062207488)
465 };
466 ("rom.has_crc_le") => {
467 true
468 };
469 ("rom.has_crc_be") => {
470 false
471 };
472 ("rom.has_md5_bsd") => {
473 true
474 };
475 ("rom.has_md5_mbedtls") => {
476 false
477 };
478 ("soc.cpu_has_branch_predictor") => {
479 false
480 };
481 ("soc.cpu_has_csr_pc") => {
482 false
483 };
484 ("soc.multi_core_enabled") => {
485 false
486 };
487 ("soc.internal_memory_cached") => {
488 false
489 };
490 ("soc.has_swd_watchdog") => {
491 true
492 };
493 ("soc.cpu_mcause_mask") => {
494 0
495 };
496 ("soc.cpu_mcause_mask", str) => {
497 stringify!(0)
498 };
499 ("clock_tree.cpu_pll_div_in") => {
500 [crate ::soc::clocks::CpuPllDivInConfig::Pll, crate
501 ::soc::clocks::CpuPllDivInConfig::Apll]
502 };
503 ("clock_tree.cpu_pll_div.divisor") => {
504 [2, 3, 4, 6]
505 };
506 ("clock_tree.system_pre_div_in") => {
507 [crate ::soc::clocks::SystemPreDivInConfig::Xtal, crate
508 ::soc::clocks::SystemPreDivInConfig::RcFast]
509 };
510 ("clock_tree.system_pre_div.divisor") => {
511 (0, 1023)
512 };
513 ("clock_tree.cpu_clk") => {
514 [crate ::soc::clocks::CpuClkConfig::Xtal, crate
515 ::soc::clocks::CpuClkConfig::RcFast, crate ::soc::clocks::CpuClkConfig::Apll,
516 crate ::soc::clocks::CpuClkConfig::Pll]
517 };
518 ("clock_tree.apb_clk") => {
519 [crate ::soc::clocks::ApbClkConfig::Pll, crate ::soc::clocks::ApbClkConfig::Apll,
520 crate ::soc::clocks::ApbClkConfig::Xtal, crate
521 ::soc::clocks::ApbClkConfig::RcFast]
522 };
523 ("clock_tree.ref_tick_xtal.divisor") => {
524 (0, 255)
525 };
526 ("clock_tree.ref_tick_ck8m.divisor") => {
527 (0, 255)
528 };
529 ("clock_tree.ref_tick") => {
530 [crate ::soc::clocks::RefTickConfig::Pll, crate
531 ::soc::clocks::RefTickConfig::Apll, crate ::soc::clocks::RefTickConfig::Xtal,
532 crate ::soc::clocks::RefTickConfig::RcFast]
533 };
534 ("clock_tree.rtc_slow_clk") => {
535 [crate ::soc::clocks::RtcSlowClkConfig::Xtal32k, crate
536 ::soc::clocks::RtcSlowClkConfig::RcSlow, crate
537 ::soc::clocks::RtcSlowClkConfig::RcFast]
538 };
539 ("clock_tree.rtc_fast_clk") => {
540 [crate ::soc::clocks::RtcFastClkConfig::Xtal, crate
541 ::soc::clocks::RtcFastClkConfig::Rc]
542 };
543 ("clock_tree.timg_calibration_clock") => {
544 [crate ::soc::clocks::TimgCalibrationClockConfig::RtcClk, crate
545 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, crate
546 ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
547 };
548 ("clock_tree.timg.function_clock") => {
549 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
550 ::soc::clocks::TimgFunctionClockConfig::ApbClk]
551 };
552 ("clock_tree.uart.function_clock.sclk") => {
553 [crate ::soc::clocks::UartFunctionClockSclk::Apb, crate
554 ::soc::clocks::UartFunctionClockSclk::RefTick]
555 };
556 ("clock_tree.uart.baud_rate_generator.fractional") => {
557 (0, 15)
558 };
559 ("clock_tree.uart.baud_rate_generator.integral") => {
560 (0, 1048575)
561 };
562 ("clock_tree.rmt.sclk") => {
563 [crate ::soc::clocks::RmtSclkConfig::RefTick, crate
564 ::soc::clocks::RmtSclkConfig::ApbClk]
565 };
566 ("clock_tree.i2c.function_clock.sclk") => {
567 [crate ::soc::clocks::I2cFunctionClockSclk::Apb, crate
568 ::soc::clocks::I2cFunctionClockSclk::RefTick]
569 };
570}
571#[macro_export]
572#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
573macro_rules! for_each_dedicated_gpio {
574 ($($pattern:tt => $code:tt;)*) => {
575 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
576 tt) => {} } _for_each_inner_dedicated_gpio!((0));
577 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
578 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
579 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
580 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
581 PRO_ALONEGPIO0)); _for_each_inner_dedicated_gpio!((0, 1, PRO_ALONEGPIO1));
582 _for_each_inner_dedicated_gpio!((0, 2, PRO_ALONEGPIO2));
583 _for_each_inner_dedicated_gpio!((0, 3, PRO_ALONEGPIO3));
584 _for_each_inner_dedicated_gpio!((0, 4, PRO_ALONEGPIO4));
585 _for_each_inner_dedicated_gpio!((0, 5, PRO_ALONEGPIO5));
586 _for_each_inner_dedicated_gpio!((0, 6, PRO_ALONEGPIO6));
587 _for_each_inner_dedicated_gpio!((0, 7, PRO_ALONEGPIO7));
588 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
589 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, PRO_ALONEGPIO0), (0, 1,
590 PRO_ALONEGPIO1), (0, 2, PRO_ALONEGPIO2), (0, 3, PRO_ALONEGPIO3), (0, 4,
591 PRO_ALONEGPIO4), (0, 5, PRO_ALONEGPIO5), (0, 6, PRO_ALONEGPIO6), (0, 7,
592 PRO_ALONEGPIO7)));
593 };
594}
595#[macro_export]
599#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
600macro_rules! define_lp_io_signals {
601 () => {};
602}
603#[macro_export]
625#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
626macro_rules! for_each_rmt_channel {
627 ($($pattern:tt => $code:tt;)*) => {
628 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
629 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
630 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
631 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
632 _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
633 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
634 _for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
635 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
636 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1), (2, 2), (3, 3)));
637 _for_each_inner_rmt_channel!((rx(0, 0), (1, 1), (2, 2), (3, 3)));
638 };
639}
640#[macro_export]
641#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
642macro_rules! for_each_sdm_channel {
643 ($($pattern:tt => $code:tt;)*) => {
644 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
645 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
646 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
647 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
648 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
649 _for_each_inner_sdm_channel!((4, SDM_CH4, SdmCh4, GPIO_SD4));
650 _for_each_inner_sdm_channel!((5, SDM_CH5, SdmCh5, GPIO_SD5));
651 _for_each_inner_sdm_channel!((6, SDM_CH6, SdmCh6, GPIO_SD6));
652 _for_each_inner_sdm_channel!((7, SDM_CH7, SdmCh7, GPIO_SD7));
653 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
654 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
655 GPIO_SD3), (4, SDM_CH4, SdmCh4, GPIO_SD4), (5, SDM_CH5, SdmCh5, GPIO_SD5), (6,
656 SDM_CH6, SdmCh6, GPIO_SD6), (7, SDM_CH7, SdmCh7, GPIO_SD7)));
657 };
658}
659#[macro_export]
660#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
661macro_rules! for_each_aes_key_length {
662 ($($pattern:tt => $code:tt;)*) => {
663 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
664 tt) => {} } _for_each_inner_aes_key_length!((128));
665 _for_each_inner_aes_key_length!((192)); _for_each_inner_aes_key_length!((256));
666 _for_each_inner_aes_key_length!((128, 0, 4));
667 _for_each_inner_aes_key_length!((192, 1, 5));
668 _for_each_inner_aes_key_length!((256, 2, 6));
669 _for_each_inner_aes_key_length!((bits(128), (192), (256)));
670 _for_each_inner_aes_key_length!((modes(128, 0, 4), (192, 1, 5), (256, 2, 6)));
671 };
672}
673#[macro_export]
674#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
675macro_rules! for_each_rsa_exponentiation {
676 ($($pattern:tt => $code:tt;)*) => {
677 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
678 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
679 _for_each_inner_rsa_exponentiation!((64));
680 _for_each_inner_rsa_exponentiation!((96));
681 _for_each_inner_rsa_exponentiation!((128));
682 _for_each_inner_rsa_exponentiation!((160));
683 _for_each_inner_rsa_exponentiation!((192));
684 _for_each_inner_rsa_exponentiation!((224));
685 _for_each_inner_rsa_exponentiation!((256));
686 _for_each_inner_rsa_exponentiation!((288));
687 _for_each_inner_rsa_exponentiation!((320));
688 _for_each_inner_rsa_exponentiation!((352));
689 _for_each_inner_rsa_exponentiation!((384));
690 _for_each_inner_rsa_exponentiation!((416));
691 _for_each_inner_rsa_exponentiation!((448));
692 _for_each_inner_rsa_exponentiation!((480));
693 _for_each_inner_rsa_exponentiation!((512));
694 _for_each_inner_rsa_exponentiation!((544));
695 _for_each_inner_rsa_exponentiation!((576));
696 _for_each_inner_rsa_exponentiation!((608));
697 _for_each_inner_rsa_exponentiation!((640));
698 _for_each_inner_rsa_exponentiation!((672));
699 _for_each_inner_rsa_exponentiation!((704));
700 _for_each_inner_rsa_exponentiation!((736));
701 _for_each_inner_rsa_exponentiation!((768));
702 _for_each_inner_rsa_exponentiation!((800));
703 _for_each_inner_rsa_exponentiation!((832));
704 _for_each_inner_rsa_exponentiation!((864));
705 _for_each_inner_rsa_exponentiation!((896));
706 _for_each_inner_rsa_exponentiation!((928));
707 _for_each_inner_rsa_exponentiation!((960));
708 _for_each_inner_rsa_exponentiation!((992));
709 _for_each_inner_rsa_exponentiation!((1024));
710 _for_each_inner_rsa_exponentiation!((1056));
711 _for_each_inner_rsa_exponentiation!((1088));
712 _for_each_inner_rsa_exponentiation!((1120));
713 _for_each_inner_rsa_exponentiation!((1152));
714 _for_each_inner_rsa_exponentiation!((1184));
715 _for_each_inner_rsa_exponentiation!((1216));
716 _for_each_inner_rsa_exponentiation!((1248));
717 _for_each_inner_rsa_exponentiation!((1280));
718 _for_each_inner_rsa_exponentiation!((1312));
719 _for_each_inner_rsa_exponentiation!((1344));
720 _for_each_inner_rsa_exponentiation!((1376));
721 _for_each_inner_rsa_exponentiation!((1408));
722 _for_each_inner_rsa_exponentiation!((1440));
723 _for_each_inner_rsa_exponentiation!((1472));
724 _for_each_inner_rsa_exponentiation!((1504));
725 _for_each_inner_rsa_exponentiation!((1536));
726 _for_each_inner_rsa_exponentiation!((1568));
727 _for_each_inner_rsa_exponentiation!((1600));
728 _for_each_inner_rsa_exponentiation!((1632));
729 _for_each_inner_rsa_exponentiation!((1664));
730 _for_each_inner_rsa_exponentiation!((1696));
731 _for_each_inner_rsa_exponentiation!((1728));
732 _for_each_inner_rsa_exponentiation!((1760));
733 _for_each_inner_rsa_exponentiation!((1792));
734 _for_each_inner_rsa_exponentiation!((1824));
735 _for_each_inner_rsa_exponentiation!((1856));
736 _for_each_inner_rsa_exponentiation!((1888));
737 _for_each_inner_rsa_exponentiation!((1920));
738 _for_each_inner_rsa_exponentiation!((1952));
739 _for_each_inner_rsa_exponentiation!((1984));
740 _for_each_inner_rsa_exponentiation!((2016));
741 _for_each_inner_rsa_exponentiation!((2048));
742 _for_each_inner_rsa_exponentiation!((2080));
743 _for_each_inner_rsa_exponentiation!((2112));
744 _for_each_inner_rsa_exponentiation!((2144));
745 _for_each_inner_rsa_exponentiation!((2176));
746 _for_each_inner_rsa_exponentiation!((2208));
747 _for_each_inner_rsa_exponentiation!((2240));
748 _for_each_inner_rsa_exponentiation!((2272));
749 _for_each_inner_rsa_exponentiation!((2304));
750 _for_each_inner_rsa_exponentiation!((2336));
751 _for_each_inner_rsa_exponentiation!((2368));
752 _for_each_inner_rsa_exponentiation!((2400));
753 _for_each_inner_rsa_exponentiation!((2432));
754 _for_each_inner_rsa_exponentiation!((2464));
755 _for_each_inner_rsa_exponentiation!((2496));
756 _for_each_inner_rsa_exponentiation!((2528));
757 _for_each_inner_rsa_exponentiation!((2560));
758 _for_each_inner_rsa_exponentiation!((2592));
759 _for_each_inner_rsa_exponentiation!((2624));
760 _for_each_inner_rsa_exponentiation!((2656));
761 _for_each_inner_rsa_exponentiation!((2688));
762 _for_each_inner_rsa_exponentiation!((2720));
763 _for_each_inner_rsa_exponentiation!((2752));
764 _for_each_inner_rsa_exponentiation!((2784));
765 _for_each_inner_rsa_exponentiation!((2816));
766 _for_each_inner_rsa_exponentiation!((2848));
767 _for_each_inner_rsa_exponentiation!((2880));
768 _for_each_inner_rsa_exponentiation!((2912));
769 _for_each_inner_rsa_exponentiation!((2944));
770 _for_each_inner_rsa_exponentiation!((2976));
771 _for_each_inner_rsa_exponentiation!((3008));
772 _for_each_inner_rsa_exponentiation!((3040));
773 _for_each_inner_rsa_exponentiation!((3072));
774 _for_each_inner_rsa_exponentiation!((3104));
775 _for_each_inner_rsa_exponentiation!((3136));
776 _for_each_inner_rsa_exponentiation!((3168));
777 _for_each_inner_rsa_exponentiation!((3200));
778 _for_each_inner_rsa_exponentiation!((3232));
779 _for_each_inner_rsa_exponentiation!((3264));
780 _for_each_inner_rsa_exponentiation!((3296));
781 _for_each_inner_rsa_exponentiation!((3328));
782 _for_each_inner_rsa_exponentiation!((3360));
783 _for_each_inner_rsa_exponentiation!((3392));
784 _for_each_inner_rsa_exponentiation!((3424));
785 _for_each_inner_rsa_exponentiation!((3456));
786 _for_each_inner_rsa_exponentiation!((3488));
787 _for_each_inner_rsa_exponentiation!((3520));
788 _for_each_inner_rsa_exponentiation!((3552));
789 _for_each_inner_rsa_exponentiation!((3584));
790 _for_each_inner_rsa_exponentiation!((3616));
791 _for_each_inner_rsa_exponentiation!((3648));
792 _for_each_inner_rsa_exponentiation!((3680));
793 _for_each_inner_rsa_exponentiation!((3712));
794 _for_each_inner_rsa_exponentiation!((3744));
795 _for_each_inner_rsa_exponentiation!((3776));
796 _for_each_inner_rsa_exponentiation!((3808));
797 _for_each_inner_rsa_exponentiation!((3840));
798 _for_each_inner_rsa_exponentiation!((3872));
799 _for_each_inner_rsa_exponentiation!((3904));
800 _for_each_inner_rsa_exponentiation!((3936));
801 _for_each_inner_rsa_exponentiation!((3968));
802 _for_each_inner_rsa_exponentiation!((4000));
803 _for_each_inner_rsa_exponentiation!((4032));
804 _for_each_inner_rsa_exponentiation!((4064));
805 _for_each_inner_rsa_exponentiation!((4096));
806 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
807 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
808 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
809 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
810 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
811 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
812 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
813 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
814 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
815 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072), (3104), (3136),
816 (3168), (3200), (3232), (3264), (3296), (3328), (3360), (3392), (3424), (3456),
817 (3488), (3520), (3552), (3584), (3616), (3648), (3680), (3712), (3744), (3776),
818 (3808), (3840), (3872), (3904), (3936), (3968), (4000), (4032), (4064), (4096)));
819 };
820}
821#[macro_export]
822#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
823macro_rules! for_each_rsa_multiplication {
824 ($($pattern:tt => $code:tt;)*) => {
825 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
826 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
827 _for_each_inner_rsa_multiplication!((64));
828 _for_each_inner_rsa_multiplication!((96));
829 _for_each_inner_rsa_multiplication!((128));
830 _for_each_inner_rsa_multiplication!((160));
831 _for_each_inner_rsa_multiplication!((192));
832 _for_each_inner_rsa_multiplication!((224));
833 _for_each_inner_rsa_multiplication!((256));
834 _for_each_inner_rsa_multiplication!((288));
835 _for_each_inner_rsa_multiplication!((320));
836 _for_each_inner_rsa_multiplication!((352));
837 _for_each_inner_rsa_multiplication!((384));
838 _for_each_inner_rsa_multiplication!((416));
839 _for_each_inner_rsa_multiplication!((448));
840 _for_each_inner_rsa_multiplication!((480));
841 _for_each_inner_rsa_multiplication!((512));
842 _for_each_inner_rsa_multiplication!((544));
843 _for_each_inner_rsa_multiplication!((576));
844 _for_each_inner_rsa_multiplication!((608));
845 _for_each_inner_rsa_multiplication!((640));
846 _for_each_inner_rsa_multiplication!((672));
847 _for_each_inner_rsa_multiplication!((704));
848 _for_each_inner_rsa_multiplication!((736));
849 _for_each_inner_rsa_multiplication!((768));
850 _for_each_inner_rsa_multiplication!((800));
851 _for_each_inner_rsa_multiplication!((832));
852 _for_each_inner_rsa_multiplication!((864));
853 _for_each_inner_rsa_multiplication!((896));
854 _for_each_inner_rsa_multiplication!((928));
855 _for_each_inner_rsa_multiplication!((960));
856 _for_each_inner_rsa_multiplication!((992));
857 _for_each_inner_rsa_multiplication!((1024));
858 _for_each_inner_rsa_multiplication!((1056));
859 _for_each_inner_rsa_multiplication!((1088));
860 _for_each_inner_rsa_multiplication!((1120));
861 _for_each_inner_rsa_multiplication!((1152));
862 _for_each_inner_rsa_multiplication!((1184));
863 _for_each_inner_rsa_multiplication!((1216));
864 _for_each_inner_rsa_multiplication!((1248));
865 _for_each_inner_rsa_multiplication!((1280));
866 _for_each_inner_rsa_multiplication!((1312));
867 _for_each_inner_rsa_multiplication!((1344));
868 _for_each_inner_rsa_multiplication!((1376));
869 _for_each_inner_rsa_multiplication!((1408));
870 _for_each_inner_rsa_multiplication!((1440));
871 _for_each_inner_rsa_multiplication!((1472));
872 _for_each_inner_rsa_multiplication!((1504));
873 _for_each_inner_rsa_multiplication!((1536));
874 _for_each_inner_rsa_multiplication!((1568));
875 _for_each_inner_rsa_multiplication!((1600));
876 _for_each_inner_rsa_multiplication!((1632));
877 _for_each_inner_rsa_multiplication!((1664));
878 _for_each_inner_rsa_multiplication!((1696));
879 _for_each_inner_rsa_multiplication!((1728));
880 _for_each_inner_rsa_multiplication!((1760));
881 _for_each_inner_rsa_multiplication!((1792));
882 _for_each_inner_rsa_multiplication!((1824));
883 _for_each_inner_rsa_multiplication!((1856));
884 _for_each_inner_rsa_multiplication!((1888));
885 _for_each_inner_rsa_multiplication!((1920));
886 _for_each_inner_rsa_multiplication!((1952));
887 _for_each_inner_rsa_multiplication!((1984));
888 _for_each_inner_rsa_multiplication!((2016));
889 _for_each_inner_rsa_multiplication!((2048));
890 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
891 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
892 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
893 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
894 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
895 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
896 (1888), (1920), (1952), (1984), (2016), (2048)));
897 };
898}
899#[macro_export]
900#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
901macro_rules! for_each_sha_algorithm {
902 ($($pattern:tt => $code:tt;)*) => {
903 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
904 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
905 (insecure_against : "collision", "length extension"), 0));
906 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
907 (insecure_against : "length extension"), 1));
908 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
909 (insecure_against : "length extension"), 2));
910 _for_each_inner_sha_algorithm!((Sha384, "SHA-384"(sizes : 128, 48, 16)
911 (insecure_against :), 3)); _for_each_inner_sha_algorithm!((Sha512,
912 "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 4));
913 _for_each_inner_sha_algorithm!((Sha512_224, "SHA-512/224"(sizes : 128, 28, 16)
914 (insecure_against :), 5)); _for_each_inner_sha_algorithm!((Sha512_256,
915 "SHA-512/256"(sizes : 128, 32, 16) (insecure_against :), 6));
916 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
917 (insecure_against : "collision", "length extension"), 0), (Sha224,
918 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
919 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
920 2), (Sha384, "SHA-384"(sizes : 128, 48, 16) (insecure_against :), 3), (Sha512,
921 "SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 4),
922 (Sha512_224, "SHA-512/224"(sizes : 128, 28, 16) (insecure_against :), 5),
923 (Sha512_256, "SHA-512/256"(sizes : 128, 32, 16) (insecure_against :), 6)));
924 };
925}
926#[macro_export]
927#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
928macro_rules! for_each_wakeup_source {
929 ($($pattern:tt => $code:tt;)*) => {
930 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
931 tt) => {} } _for_each_inner_wakeup_source!((Ext0, 0));
932 _for_each_inner_wakeup_source!((Ext1, 1)); _for_each_inner_wakeup_source!((Gpio,
933 2)); _for_each_inner_wakeup_source!((Timer, 3));
934 _for_each_inner_wakeup_source!((Wifi, 5)); _for_each_inner_wakeup_source!((Uart0,
935 6)); _for_each_inner_wakeup_source!((Uart1, 7));
936 _for_each_inner_wakeup_source!((Touch, 8));
937 _for_each_inner_wakeup_source!((UlpRiscv, 11));
938 _for_each_inner_wakeup_source!((UlpRiscvTrap, 13));
939 _for_each_inner_wakeup_source!((all(Ext0, 0), (Ext1, 1), (Gpio, 2), (Timer, 3),
940 (Wifi, 5), (Uart0, 6), (Uart1, 7), (Touch, 8), (UlpRiscv, 11), (UlpRiscvTrap,
941 13)));
942 };
943}
944#[macro_export]
945#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
946macro_rules! for_each_dma_engine {
947 ($($pattern:tt => $code:tt;)*) => {
948 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
949 => {} } _for_each_inner_dma_engine!(("SPI_DMA"));
950 _for_each_inner_dma_engine!(("I2S_DMA"));
951 _for_each_inner_dma_engine!(("CRYPTO_DMA"));
952 _for_each_inner_dma_engine!(("COPY_DMA"));
953 _for_each_inner_dma_engine!((all("SPI_DMA"), ("I2S_DMA"), ("CRYPTO_DMA"),
954 ("COPY_DMA")));
955 };
956}
957#[macro_export]
958#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
959macro_rules! for_each_dma_channel {
960 ($($pattern:tt => $code:tt;)*) => {
961 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
962 => {} } _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI2));
963 _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI3));
964 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S0));
965 _for_each_inner_dma_channel!(("CRYPTO_DMA", DMA_CRYPTO));
966 _for_each_inner_dma_channel!(("COPY_DMA", DMA_COPY));
967 _for_each_inner_dma_channel!(("SPI_DMA", any_channel = SpiDmaChannel));
968 _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI2, 0, interrupt = SPI2_DMA,
969 compatible = [SPI2])); _for_each_inner_dma_channel!(("SPI_DMA", DMA_SPI3, 1,
970 interrupt = SPI3_DMA, compatible = [SPI3]));
971 _for_each_inner_dma_channel!(("I2S_DMA", DMA_I2S0, 0, interrupt = I2S0,
972 compatible = [I2S0])); _for_each_inner_dma_channel!(("CRYPTO_DMA", DMA_CRYPTO, 0,
973 interrupt = CRYPTO_DMA, compatible = [AES, SHA]));
974 _for_each_inner_dma_channel!(("COPY_DMA", DMA_COPY, 0, interrupt = DMA_COPY,
975 compatible = [])); _for_each_inner_dma_channel!((names("SPI_DMA", DMA_SPI2),
976 ("SPI_DMA", DMA_SPI3), ("I2S_DMA", DMA_I2S0), ("CRYPTO_DMA", DMA_CRYPTO),
977 ("COPY_DMA", DMA_COPY)));
978 _for_each_inner_dma_channel!((separate_any_type("SPI_DMA", any_channel =
979 SpiDmaChannel))); _for_each_inner_dma_channel!((shared("SPI_DMA", DMA_SPI2, 0,
980 interrupt = SPI2_DMA, compatible = [SPI2]), ("SPI_DMA", DMA_SPI3, 1, interrupt =
981 SPI3_DMA, compatible = [SPI3]), ("I2S_DMA", DMA_I2S0, 0, interrupt = I2S0,
982 compatible = [I2S0]), ("CRYPTO_DMA", DMA_CRYPTO, 0, interrupt = CRYPTO_DMA,
983 compatible = [AES, SHA]), ("COPY_DMA", DMA_COPY, 0, interrupt = DMA_COPY,
984 compatible = []))); _for_each_inner_dma_channel!((split));
985 _for_each_inner_dma_channel!((no_own_interrupt));
986 };
987}
988#[macro_export]
989#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
990macro_rules! for_each_dma_channel_peri_pair {
991 ($($pattern:tt => $code:tt;)*) => {
992 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
993 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("SPI_DMA",
994 DMA_SPI2, SPI2)); _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", DMA_SPI3,
995 SPI3)); _for_each_inner_dma_channel_peri_pair!(("I2S_DMA", DMA_I2S0, I2S0));
996 _for_each_inner_dma_channel_peri_pair!(("CRYPTO_DMA", DMA_CRYPTO, AES));
997 _for_each_inner_dma_channel_peri_pair!(("CRYPTO_DMA", DMA_CRYPTO, SHA));
998 _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", any_channel = SpiDmaChannel,
999 SPI2)); _for_each_inner_dma_channel_peri_pair!(("SPI_DMA", any_channel =
1000 SpiDmaChannel, SPI3));
1001 _for_each_inner_dma_channel_peri_pair!((channels("SPI_DMA", DMA_SPI2, SPI2),
1002 ("SPI_DMA", DMA_SPI3, SPI3), ("I2S_DMA", DMA_I2S0, I2S0), ("CRYPTO_DMA",
1003 DMA_CRYPTO, AES), ("CRYPTO_DMA", DMA_CRYPTO, SHA)));
1004 _for_each_inner_dma_channel_peri_pair!((any_channels("SPI_DMA", any_channel =
1005 SpiDmaChannel, SPI2), ("SPI_DMA", any_channel = SpiDmaChannel, SPI3)));
1006 };
1007}
1008#[macro_export]
1009#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1010macro_rules! for_each_mem2mem_channel {
1011 ($($pattern:tt => $code:tt;)*) => {
1012 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1013 tt) => {} } _for_each_inner_mem2mem_channel!(("CRYPTO_DMA", CryptoDma,
1014 CryptoDmaChannel, DMA_CRYPTO, 0)); _for_each_inner_mem2mem_channel!(("COPY_DMA",
1015 CopyDma, CopyDmaChannel, DMA_COPY, 0));
1016 _for_each_inner_mem2mem_channel!(("CRYPTO_DMA", CryptoDma, CryptoDmaChannel));
1017 _for_each_inner_mem2mem_channel!(("COPY_DMA", CopyDma, CopyDmaChannel));
1018 _for_each_inner_mem2mem_channel!((channels("CRYPTO_DMA", CryptoDma,
1019 CryptoDmaChannel, DMA_CRYPTO, 0), ("COPY_DMA", CopyDma, CopyDmaChannel, DMA_COPY,
1020 0))); _for_each_inner_mem2mem_channel!((erased));
1021 _for_each_inner_mem2mem_channel!((engines("CRYPTO_DMA", CryptoDma,
1022 CryptoDmaChannel), ("COPY_DMA", CopyDma, CopyDmaChannel)));
1023 };
1024}
1025#[macro_export]
1026#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1027macro_rules! with_aes_dma_engine {
1028 ($($pattern:tt => $code:tt;)*) => {
1029 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1030 => {} } _with_inner_aes_dma_engine!(("CRYPTO_DMA", CryptoDmaChannel));
1031 };
1032}
1033#[macro_export]
1034#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1035macro_rules! with_i2s_dma_engine {
1036 ($($pattern:tt => $code:tt;)*) => {
1037 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1038 => {} } _with_inner_i2s_dma_engine!(("I2S_DMA", I2sDmaChannel));
1039 };
1040}
1041#[macro_export]
1042#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1043macro_rules! with_sha_dma_engine {
1044 ($($pattern:tt => $code:tt;)*) => {
1045 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1046 => {} } _with_inner_sha_dma_engine!(("CRYPTO_DMA", CryptoDmaChannel));
1047 };
1048}
1049#[macro_export]
1050#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1051macro_rules! with_spi_master_dma_engine {
1052 ($($pattern:tt => $code:tt;)*) => {
1053 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1054 : tt) => {} } _with_inner_spi_master_dma_engine!(("SPI_DMA", SpiDmaChannel));
1055 };
1056}
1057#[macro_export]
1058#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1059macro_rules! with_spi_slave_dma_engine {
1060 ($($pattern:tt => $code:tt;)*) => {
1061 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1062 : tt) => {} } _with_inner_spi_slave_dma_engine!(("SPI_DMA", SpiDmaChannel));
1063 };
1064}
1065#[macro_export]
1066#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1067macro_rules! for_each_sw_interrupt {
1068 ($($pattern:tt => $code:tt;)*) => {
1069 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1070 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1071 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1072 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1073 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1074 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1075 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1076 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1077 };
1078}
1079#[macro_export]
1080macro_rules! define_clock_tree_types {
1433 () => {
1434 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1435 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1436 pub enum SdmInstance {
1437 GpioSd = 0,
1438 }
1439 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1440 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1441 pub enum I2cInstance {
1442 I2c0 = 0,
1443 I2c1 = 1,
1444 }
1445 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1446 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1447 pub enum RmtInstance {
1448 Rmt = 0,
1449 }
1450 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1451 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1452 pub enum SpiInstance {
1453 Spi2 = 0,
1454 Spi3 = 1,
1455 }
1456 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1457 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1458 pub enum TimgInstance {
1459 Timg0 = 0,
1460 Timg1 = 1,
1461 }
1462 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1463 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1464 pub enum UartInstance {
1465 Uart0 = 0,
1466 Uart1 = 1,
1467 }
1468 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1470 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1471 pub enum XtalClkConfig {
1472 _40,
1474 }
1475 impl XtalClkConfig {
1476 pub fn value(&self) -> u32 {
1477 match self {
1478 XtalClkConfig::_40 => 40000000,
1479 }
1480 }
1481 }
1482 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1484 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1485 pub enum PllClkConfig {
1486 _320,
1488 _480,
1490 }
1491 impl PllClkConfig {
1492 pub fn value(&self) -> u32 {
1493 match self {
1494 PllClkConfig::_320 => 320000000,
1495 PllClkConfig::_480 => 480000000,
1496 }
1497 }
1498 }
1499 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1501 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1502 pub struct ApllClkConfig(u32);
1503 impl ApllClkConfig {
1504 pub const fn new(frequency: u32) -> Self {
1511 ::core::assert!(
1512 frequency >= 16000000u32 && frequency <= 128000000u32,
1513 "`APLL_CLK` output frequency value must be between 16000000 and 128000000 \
1514 (inclusive)."
1515 );
1516 Self(frequency)
1517 }
1518 }
1519 impl ApllClkConfig {
1520 pub fn value(&self) -> u32 {
1521 self.0
1522 }
1523 }
1524 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1526 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1527 pub enum CpuPllDivInConfig {
1528 Pll,
1530 Apll,
1532 }
1533 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1534 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1535 pub enum CpuPllDivDivisor {
1536 _2 = 2,
1538 _3 = 3,
1540 _4 = 4,
1542 _6 = 6,
1544 }
1545 impl CpuPllDivDivisor {
1546 pub const fn new(raw: u32) -> Self {
1548 match raw {
1549 2 => Self::_2,
1550 3 => Self::_3,
1551 4 => Self::_4,
1552 6 => Self::_6,
1553 _ => ::core::panic!("Invalid CPU_PLL_DIV divisor value"),
1554 }
1555 }
1556 }
1557 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1561 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1562 pub struct CpuPllDivConfig {
1563 divisor: CpuPllDivDivisor,
1564 }
1565 impl CpuPllDivConfig {
1566 pub const fn new(divisor: CpuPllDivDivisor) -> Self {
1568 Self { divisor }
1569 }
1570 pub(crate) fn divisor(self) -> u32 {
1571 self.divisor as u32
1572 }
1573 }
1574 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1576 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1577 pub enum SystemPreDivInConfig {
1578 Xtal,
1580 RcFast,
1582 }
1583 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1587 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1588 pub struct SystemPreDivConfig {
1589 divisor: u32,
1590 }
1591 impl SystemPreDivConfig {
1592 pub const fn new(divisor: u32) -> Self {
1599 ::core::assert!(
1600 divisor <= 1023,
1601 "`SYSTEM_PRE_DIV` divisor must be between 0 and 1023 (inclusive)."
1602 );
1603 Self { divisor }
1604 }
1605 pub(crate) fn divisor(self) -> u32 {
1606 self.divisor as u32
1607 }
1608 }
1609 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1611 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1612 pub enum ApbClkConfig {
1613 Pll,
1615 Apll,
1617 Xtal,
1619 RcFast,
1621 }
1622 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1624 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1625 pub enum RefTickConfig {
1626 Pll,
1628 Apll,
1630 Xtal,
1632 RcFast,
1634 }
1635 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1639 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1640 pub struct RefTickXtalConfig {
1641 divisor: u32,
1642 }
1643 impl RefTickXtalConfig {
1644 pub const fn new(divisor: u32) -> Self {
1651 ::core::assert!(
1652 divisor <= 255,
1653 "`REF_TICK_XTAL` divisor must be between 0 and 255 (inclusive)."
1654 );
1655 Self { divisor }
1656 }
1657 pub(crate) fn divisor(self) -> u32 {
1658 self.divisor as u32
1659 }
1660 }
1661 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1665 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1666 pub struct RefTickCk8mConfig {
1667 divisor: u32,
1668 }
1669 impl RefTickCk8mConfig {
1670 pub const fn new(divisor: u32) -> Self {
1677 ::core::assert!(
1678 divisor <= 255,
1679 "`REF_TICK_CK8M` divisor must be between 0 and 255 (inclusive)."
1680 );
1681 Self { divisor }
1682 }
1683 pub(crate) fn divisor(self) -> u32 {
1684 self.divisor as u32
1685 }
1686 }
1687 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1689 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1690 pub enum CpuClkConfig {
1691 Xtal,
1693 RcFast,
1695 Apll,
1697 Pll,
1699 }
1700 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1702 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1703 pub enum RtcSlowClkConfig {
1704 Xtal32k,
1706 RcSlow,
1708 RcFast,
1710 }
1711 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1713 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1714 pub enum RtcFastClkConfig {
1715 Xtal,
1717 Rc,
1719 }
1720 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1722 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1723 pub enum UartMemClkConfig {
1724 #[default]
1725 Xtal,
1727 }
1728 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1730 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1731 pub enum TimgCalibrationClockConfig {
1732 RtcClk,
1734 RcFastDivClk,
1736 Xtal32kClk,
1738 }
1739 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1740 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1741 pub enum I2cFunctionClockSclk {
1742 #[default]
1743 Apb,
1745 RefTick,
1747 }
1748 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1752 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1753 pub struct I2cFunctionClockConfig {
1754 sclk: I2cFunctionClockSclk,
1755 }
1756 impl I2cFunctionClockConfig {
1757 pub const fn new(sclk: I2cFunctionClockSclk) -> Self {
1759 Self { sclk }
1760 }
1761 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1762 self.sclk
1763 }
1764 }
1765 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1767 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1768 pub enum RmtSclkConfig {
1769 RefTick,
1771 #[default]
1772 ApbClk,
1774 }
1775 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1777 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1778 pub enum SpiFunctionClockConfig {
1779 #[default]
1780 Apb,
1782 }
1783 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1785 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1786 pub enum TimgFunctionClockConfig {
1787 #[default]
1788 XtalClk,
1790 ApbClk,
1792 }
1793 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1794 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1795 pub enum UartFunctionClockSclk {
1796 #[default]
1797 Apb,
1799 RefTick,
1801 }
1802 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1806 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1807 pub struct UartFunctionClockConfig {
1808 sclk: UartFunctionClockSclk,
1809 }
1810 impl UartFunctionClockConfig {
1811 pub const fn new(sclk: UartFunctionClockSclk) -> Self {
1813 Self { sclk }
1814 }
1815 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
1816 self.sclk
1817 }
1818 }
1819 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1824 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1825 pub struct UartBaudRateGeneratorConfig {
1826 fractional: u32,
1827 integral: u32,
1828 }
1829 impl UartBaudRateGeneratorConfig {
1830 pub const fn new(fractional: u32, integral: u32) -> Self {
1840 ::core::assert!(
1841 fractional <= 15,
1842 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1843 );
1844 ::core::assert!(
1845 integral <= 1048575,
1846 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 1048575 \
1847 (inclusive)."
1848 );
1849 Self {
1850 fractional,
1851 integral,
1852 }
1853 }
1854 pub(crate) fn fractional(self) -> u32 {
1855 self.fractional as u32
1856 }
1857 pub(crate) fn integral(self) -> u32 {
1858 self.integral as u32
1859 }
1860 }
1861 pub struct ClockTree {
1863 xtal_clk: Option<XtalClkConfig>,
1864 pll_clk: Option<PllClkConfig>,
1865 apll_clk: Option<ApllClkConfig>,
1866 cpu_pll_div_in: Option<CpuPllDivInConfig>,
1867 cpu_pll_div: Option<CpuPllDivConfig>,
1868 system_pre_div_in: Option<SystemPreDivInConfig>,
1869 system_pre_div: Option<SystemPreDivConfig>,
1870 apb_clk: Option<ApbClkConfig>,
1871 ref_tick: Option<RefTickConfig>,
1872 ref_tick_xtal: Option<RefTickXtalConfig>,
1873 ref_tick_ck8m: Option<RefTickCk8mConfig>,
1874 cpu_clk: Option<CpuClkConfig>,
1875 rtc_slow_clk: Option<RtcSlowClkConfig>,
1876 rtc_fast_clk: Option<RtcFastClkConfig>,
1877 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1878 i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
1879 rmt_sclk: [Option<RmtSclkConfig>; 1],
1880 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1881 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
1882 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
1883 pll_clk_refcount: u32,
1884 rc_fast_clk_refcount: u32,
1885 apb_clk_refcount: u32,
1886 ref_tick_refcount: u32,
1887 xtal32k_clk_refcount: u32,
1888 rc_fast_div_clk_refcount: u32,
1889 rtc_fast_clk_refcount: u32,
1890 uart_mem_clk_refcount: u32,
1891 timg_calibration_clock_refcount: u32,
1892 sdm_function_clock_refcount: [u32; 1],
1893 i2c_function_clock_refcount: [u32; 2],
1894 rmt_sclk_refcount: [u32; 1],
1895 spi_function_clock_refcount: [u32; 2],
1896 timg_function_clock_refcount: [u32; 2],
1897 uart_function_clock_refcount: [u32; 2],
1898 uart_baud_rate_generator_refcount: [u32; 2],
1899 uart_mem_clock_refcount: [u32; 2],
1900 }
1901 impl ClockTree {
1902 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1904 CLOCK_TREE.with(f)
1905 }
1906 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1908 self.xtal_clk
1909 }
1910 pub fn pll_clk(&self) -> Option<PllClkConfig> {
1912 self.pll_clk
1913 }
1914 pub fn apll_clk(&self) -> Option<ApllClkConfig> {
1916 self.apll_clk
1917 }
1918 pub fn cpu_pll_div_in(&self) -> Option<CpuPllDivInConfig> {
1920 self.cpu_pll_div_in
1921 }
1922 pub fn cpu_pll_div(&self) -> Option<CpuPllDivConfig> {
1924 self.cpu_pll_div
1925 }
1926 pub fn system_pre_div_in(&self) -> Option<SystemPreDivInConfig> {
1928 self.system_pre_div_in
1929 }
1930 pub fn system_pre_div(&self) -> Option<SystemPreDivConfig> {
1932 self.system_pre_div
1933 }
1934 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1936 self.apb_clk
1937 }
1938 pub fn ref_tick(&self) -> Option<RefTickConfig> {
1940 self.ref_tick
1941 }
1942 pub fn ref_tick_xtal(&self) -> Option<RefTickXtalConfig> {
1944 self.ref_tick_xtal
1945 }
1946 pub fn ref_tick_ck8m(&self) -> Option<RefTickCk8mConfig> {
1948 self.ref_tick_ck8m
1949 }
1950 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1952 self.cpu_clk
1953 }
1954 pub fn rtc_slow_clk(&self) -> Option<RtcSlowClkConfig> {
1956 self.rtc_slow_clk
1957 }
1958 pub fn rtc_fast_clk(&self) -> Option<RtcFastClkConfig> {
1960 self.rtc_fast_clk
1961 }
1962 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1964 self.timg_calibration_clock
1965 }
1966 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1968 self.i2c_function_clock[I2cInstance::I2c0 as usize]
1969 }
1970 pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
1972 self.i2c_function_clock[I2cInstance::I2c1 as usize]
1973 }
1974 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
1976 self.rmt_sclk[RmtInstance::Rmt as usize]
1977 }
1978 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1980 self.timg_function_clock[TimgInstance::Timg0 as usize]
1981 }
1982 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1984 self.timg_function_clock[TimgInstance::Timg1 as usize]
1985 }
1986 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1988 self.uart_function_clock[UartInstance::Uart0 as usize]
1989 }
1990 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1992 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1993 }
1994 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1996 self.uart_function_clock[UartInstance::Uart1 as usize]
1997 }
1998 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2000 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2001 }
2002 }
2003 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2004 ::esp_sync::NonReentrantMutex::new(ClockTree {
2005 xtal_clk: None,
2006 pll_clk: None,
2007 apll_clk: None,
2008 cpu_pll_div_in: None,
2009 cpu_pll_div: None,
2010 system_pre_div_in: None,
2011 system_pre_div: None,
2012 apb_clk: None,
2013 ref_tick: None,
2014 ref_tick_xtal: None,
2015 ref_tick_ck8m: None,
2016 cpu_clk: None,
2017 rtc_slow_clk: None,
2018 rtc_fast_clk: None,
2019 timg_calibration_clock: None,
2020 i2c_function_clock: [None; 2],
2021 rmt_sclk: [None; 1],
2022 timg_function_clock: [None; 2],
2023 uart_function_clock: [None; 2],
2024 uart_baud_rate_generator: [None; 2],
2025 pll_clk_refcount: 0,
2026 rc_fast_clk_refcount: 0,
2027 apb_clk_refcount: 0,
2028 ref_tick_refcount: 0,
2029 xtal32k_clk_refcount: 0,
2030 rc_fast_div_clk_refcount: 0,
2031 rtc_fast_clk_refcount: 0,
2032 uart_mem_clk_refcount: 0,
2033 timg_calibration_clock_refcount: 0,
2034 sdm_function_clock_refcount: [0; 1],
2035 i2c_function_clock_refcount: [0; 2],
2036 rmt_sclk_refcount: [0; 1],
2037 spi_function_clock_refcount: [0; 2],
2038 timg_function_clock_refcount: [0; 2],
2039 uart_function_clock_refcount: [0; 2],
2040 uart_baud_rate_generator_refcount: [0; 2],
2041 uart_mem_clock_refcount: [0; 2],
2042 });
2043 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2044 ::core::sync::atomic::AtomicU32::new(0);
2045 static PLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2046 ::core::sync::atomic::AtomicU32::new(0);
2047 static APLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2048 ::core::sync::atomic::AtomicU32::new(0);
2049 static CPU_PLL_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2050 ::core::sync::atomic::AtomicU32::new(0);
2051 static CPU_PLL_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2052 ::core::sync::atomic::AtomicU32::new(0);
2053 static SYSTEM_PRE_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2054 ::core::sync::atomic::AtomicU32::new(0);
2055 static SYSTEM_PRE_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2056 ::core::sync::atomic::AtomicU32::new(0);
2057 static REF_TICK_XTAL_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2058 ::core::sync::atomic::AtomicU32::new(0);
2059 static REF_TICK_CK8M_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2060 ::core::sync::atomic::AtomicU32::new(0);
2061 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2062 ::core::sync::atomic::AtomicU32::new(0);
2063 static RTC_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2064 ::core::sync::atomic::AtomicU32::new(0);
2065 static RTC_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2066 ::core::sync::atomic::AtomicU32::new(0);
2067 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2068 ::core::sync::atomic::AtomicU32::new(0);
2069 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2070 ::core::sync::atomic::AtomicU32::new(0);
2071 static REF_TICK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2072 ::core::sync::atomic::AtomicU32::new(0);
2073 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2074 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2075 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2076 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2077 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2078 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2079 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2080 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2081 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2082 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2083 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2084 let old_config = clocks.xtal_clk.replace(config);
2085 refresh_xtal_clk_downstream(clocks);
2086 configure_xtal_clk_impl(clocks, old_config, config);
2087 }
2088 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2089 clocks.xtal_clk
2090 }
2091 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2092 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2093 #[allow(unused_variables)]
2094 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
2095 config.value()
2096 }
2097 pub fn xtal_clk_frequency() -> u32 {
2098 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2099 }
2100 pub fn configure_pll_clk(clocks: &mut ClockTree, config: PllClkConfig) {
2101 let old_config = clocks.pll_clk.replace(config);
2102 refresh_pll_clk_downstream(clocks);
2103 configure_pll_clk_impl(clocks, old_config, config);
2104 }
2105 pub fn pll_clk_config(clocks: &mut ClockTree) -> Option<PllClkConfig> {
2106 clocks.pll_clk
2107 }
2108 pub fn request_pll_clk(clocks: &mut ClockTree) {
2109 trace!("Requesting PLL_CLK");
2110 if increment_reference_count(&mut clocks.pll_clk_refcount) {
2111 trace!("Enabling PLL_CLK");
2112 request_xtal_clk(clocks);
2113 enable_pll_clk_impl(clocks, true);
2114 }
2115 }
2116 pub fn release_pll_clk(clocks: &mut ClockTree) {
2117 trace!("Releasing PLL_CLK");
2118 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2119 trace!("Disabling PLL_CLK");
2120 enable_pll_clk_impl(clocks, false);
2121 release_xtal_clk(clocks);
2122 }
2123 }
2124 #[allow(unused_variables)]
2125 pub fn pll_clk_config_frequency(clocks: &mut ClockTree, config: PllClkConfig) -> u32 {
2126 config.value()
2127 }
2128 pub fn pll_clk_frequency() -> u32 {
2129 PLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2130 }
2131 pub fn pll_clk_source_frequency() -> u32 {
2132 xtal_clk_frequency()
2133 }
2134 pub fn configure_apll_clk(clocks: &mut ClockTree, config: ApllClkConfig) {
2135 let old_config = clocks.apll_clk.replace(config);
2136 refresh_apll_clk_downstream(clocks);
2137 configure_apll_clk_impl(clocks, old_config, config);
2138 }
2139 pub fn apll_clk_config(clocks: &mut ClockTree) -> Option<ApllClkConfig> {
2140 clocks.apll_clk
2141 }
2142 pub fn request_apll_clk(clocks: &mut ClockTree) {
2143 trace!("Requesting APLL_CLK");
2144 trace!("Enabling APLL_CLK");
2145 request_pll_clk(clocks);
2146 enable_apll_clk_impl(clocks, true);
2147 }
2148 pub fn release_apll_clk(clocks: &mut ClockTree) {
2149 trace!("Releasing APLL_CLK");
2150 trace!("Disabling APLL_CLK");
2151 enable_apll_clk_impl(clocks, false);
2152 release_pll_clk(clocks);
2153 }
2154 #[allow(unused_variables)]
2155 pub fn apll_clk_config_frequency(clocks: &mut ClockTree, config: ApllClkConfig) -> u32 {
2156 config.value()
2157 }
2158 pub fn apll_clk_frequency() -> u32 {
2159 APLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2160 }
2161 pub fn apll_clk_source_frequency() -> u32 {
2162 pll_clk_frequency()
2163 }
2164 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2165 trace!("Requesting RC_FAST_CLK");
2166 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2167 trace!("Enabling RC_FAST_CLK");
2168 enable_rc_fast_clk_impl(clocks, true);
2169 }
2170 }
2171 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2172 trace!("Releasing RC_FAST_CLK");
2173 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2174 trace!("Disabling RC_FAST_CLK");
2175 enable_rc_fast_clk_impl(clocks, false);
2176 }
2177 }
2178 pub fn rc_fast_clk_frequency() -> u32 {
2179 8000000
2180 }
2181 pub fn configure_cpu_pll_div_in(clocks: &mut ClockTree, new_selector: CpuPllDivInConfig) {
2182 let old_selector = clocks.cpu_pll_div_in.replace(new_selector);
2183 refresh_cpu_pll_div_in_downstream(clocks);
2184 match new_selector {
2185 CpuPllDivInConfig::Pll => request_pll_clk(clocks),
2186 CpuPllDivInConfig::Apll => request_apll_clk(clocks),
2187 }
2188 configure_cpu_pll_div_in_impl(clocks, old_selector, new_selector);
2189 if let Some(old_selector) = old_selector {
2190 match old_selector {
2191 CpuPllDivInConfig::Pll => release_pll_clk(clocks),
2192 CpuPllDivInConfig::Apll => release_apll_clk(clocks),
2193 }
2194 }
2195 }
2196 pub fn cpu_pll_div_in_config(clocks: &mut ClockTree) -> Option<CpuPllDivInConfig> {
2197 clocks.cpu_pll_div_in
2198 }
2199 pub fn request_cpu_pll_div_in(clocks: &mut ClockTree) {
2200 trace!("Requesting CPU_PLL_DIV_IN");
2201 trace!("Enabling CPU_PLL_DIV_IN");
2202 match unwrap!(clocks.cpu_pll_div_in) {
2203 CpuPllDivInConfig::Pll => request_pll_clk(clocks),
2204 CpuPllDivInConfig::Apll => request_apll_clk(clocks),
2205 }
2206 enable_cpu_pll_div_in_impl(clocks, true);
2207 }
2208 pub fn release_cpu_pll_div_in(clocks: &mut ClockTree) {
2209 trace!("Releasing CPU_PLL_DIV_IN");
2210 trace!("Disabling CPU_PLL_DIV_IN");
2211 enable_cpu_pll_div_in_impl(clocks, false);
2212 match unwrap!(clocks.cpu_pll_div_in) {
2213 CpuPllDivInConfig::Pll => release_pll_clk(clocks),
2214 CpuPllDivInConfig::Apll => release_apll_clk(clocks),
2215 }
2216 }
2217 #[allow(unused_variables)]
2218 pub fn cpu_pll_div_in_config_frequency(
2219 clocks: &mut ClockTree,
2220 config: CpuPllDivInConfig,
2221 ) -> u32 {
2222 match config {
2223 CpuPllDivInConfig::Pll => pll_clk_frequency(),
2224 CpuPllDivInConfig::Apll => apll_clk_frequency(),
2225 }
2226 }
2227 pub fn cpu_pll_div_in_frequency() -> u32 {
2228 CPU_PLL_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2229 }
2230 pub fn cpu_pll_div_in_source_frequency(source: CpuPllDivInConfig) -> u32 {
2231 match source {
2232 CpuPllDivInConfig::Pll => pll_clk_frequency(),
2233 CpuPllDivInConfig::Apll => apll_clk_frequency(),
2234 }
2235 }
2236 pub fn configure_cpu_pll_div(clocks: &mut ClockTree, config: CpuPllDivConfig) {
2237 let old_config = clocks.cpu_pll_div.replace(config);
2238 refresh_cpu_pll_div_downstream(clocks);
2239 configure_cpu_pll_div_impl(clocks, old_config, config);
2240 }
2241 pub fn cpu_pll_div_config(clocks: &mut ClockTree) -> Option<CpuPllDivConfig> {
2242 clocks.cpu_pll_div
2243 }
2244 pub fn request_cpu_pll_div(clocks: &mut ClockTree) {
2245 trace!("Requesting CPU_PLL_DIV");
2246 trace!("Enabling CPU_PLL_DIV");
2247 request_cpu_pll_div_in(clocks);
2248 enable_cpu_pll_div_impl(clocks, true);
2249 }
2250 pub fn release_cpu_pll_div(clocks: &mut ClockTree) {
2251 trace!("Releasing CPU_PLL_DIV");
2252 trace!("Disabling CPU_PLL_DIV");
2253 enable_cpu_pll_div_impl(clocks, false);
2254 release_cpu_pll_div_in(clocks);
2255 }
2256 #[allow(unused_variables)]
2257 pub fn cpu_pll_div_config_frequency(
2258 clocks: &mut ClockTree,
2259 config: CpuPllDivConfig,
2260 ) -> u32 {
2261 (cpu_pll_div_in_frequency() / config.divisor())
2262 }
2263 pub fn cpu_pll_div_frequency() -> u32 {
2264 CPU_PLL_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2265 }
2266 pub fn cpu_pll_div_source_frequency() -> u32 {
2267 cpu_pll_div_in_frequency()
2268 }
2269 pub fn configure_system_pre_div_in(
2270 clocks: &mut ClockTree,
2271 new_selector: SystemPreDivInConfig,
2272 ) {
2273 let old_selector = clocks.system_pre_div_in.replace(new_selector);
2274 refresh_system_pre_div_in_downstream(clocks);
2275 match new_selector {
2276 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2277 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2278 }
2279 configure_system_pre_div_in_impl(clocks, old_selector, new_selector);
2280 if let Some(old_selector) = old_selector {
2281 match old_selector {
2282 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2283 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2284 }
2285 }
2286 }
2287 pub fn system_pre_div_in_config(clocks: &mut ClockTree) -> Option<SystemPreDivInConfig> {
2288 clocks.system_pre_div_in
2289 }
2290 pub fn request_system_pre_div_in(clocks: &mut ClockTree) {
2291 trace!("Requesting SYSTEM_PRE_DIV_IN");
2292 trace!("Enabling SYSTEM_PRE_DIV_IN");
2293 match unwrap!(clocks.system_pre_div_in) {
2294 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2295 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2296 }
2297 enable_system_pre_div_in_impl(clocks, true);
2298 }
2299 pub fn release_system_pre_div_in(clocks: &mut ClockTree) {
2300 trace!("Releasing SYSTEM_PRE_DIV_IN");
2301 trace!("Disabling SYSTEM_PRE_DIV_IN");
2302 enable_system_pre_div_in_impl(clocks, false);
2303 match unwrap!(clocks.system_pre_div_in) {
2304 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2305 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2306 }
2307 }
2308 #[allow(unused_variables)]
2309 pub fn system_pre_div_in_config_frequency(
2310 clocks: &mut ClockTree,
2311 config: SystemPreDivInConfig,
2312 ) -> u32 {
2313 match config {
2314 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2315 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2316 }
2317 }
2318 pub fn system_pre_div_in_frequency() -> u32 {
2319 SYSTEM_PRE_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2320 }
2321 pub fn system_pre_div_in_source_frequency(source: SystemPreDivInConfig) -> u32 {
2322 match source {
2323 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2324 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2325 }
2326 }
2327 pub fn configure_system_pre_div(clocks: &mut ClockTree, config: SystemPreDivConfig) {
2328 let old_config = clocks.system_pre_div.replace(config);
2329 refresh_system_pre_div_downstream(clocks);
2330 configure_system_pre_div_impl(clocks, old_config, config);
2331 }
2332 pub fn system_pre_div_config(clocks: &mut ClockTree) -> Option<SystemPreDivConfig> {
2333 clocks.system_pre_div
2334 }
2335 pub fn request_system_pre_div(clocks: &mut ClockTree) {
2336 trace!("Requesting SYSTEM_PRE_DIV");
2337 trace!("Enabling SYSTEM_PRE_DIV");
2338 request_system_pre_div_in(clocks);
2339 enable_system_pre_div_impl(clocks, true);
2340 }
2341 pub fn release_system_pre_div(clocks: &mut ClockTree) {
2342 trace!("Releasing SYSTEM_PRE_DIV");
2343 trace!("Disabling SYSTEM_PRE_DIV");
2344 enable_system_pre_div_impl(clocks, false);
2345 release_system_pre_div_in(clocks);
2346 }
2347 #[allow(unused_variables)]
2348 pub fn system_pre_div_config_frequency(
2349 clocks: &mut ClockTree,
2350 config: SystemPreDivConfig,
2351 ) -> u32 {
2352 (system_pre_div_in_frequency() / (config.divisor() + 1))
2353 }
2354 pub fn system_pre_div_frequency() -> u32 {
2355 SYSTEM_PRE_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2356 }
2357 pub fn system_pre_div_source_frequency() -> u32 {
2358 system_pre_div_in_frequency()
2359 }
2360 pub fn configure_apb_clk(clocks: &mut ClockTree, new_selector: ApbClkConfig) {
2361 let old_selector = clocks.apb_clk.replace(new_selector);
2362 refresh_apb_clk_downstream(clocks);
2363 if clocks.apb_clk_refcount > 0 {
2364 match new_selector {
2365 ApbClkConfig::Pll => request_apb_clk_80m(clocks),
2366 ApbClkConfig::Apll => request_apb_clk_cpu_div2(clocks),
2367 ApbClkConfig::Xtal => request_cpu_clk(clocks),
2368 ApbClkConfig::RcFast => request_cpu_clk(clocks),
2369 }
2370 configure_apb_clk_impl(clocks, old_selector, new_selector);
2371 if let Some(old_selector) = old_selector {
2372 match old_selector {
2373 ApbClkConfig::Pll => release_apb_clk_80m(clocks),
2374 ApbClkConfig::Apll => release_apb_clk_cpu_div2(clocks),
2375 ApbClkConfig::Xtal => release_cpu_clk(clocks),
2376 ApbClkConfig::RcFast => release_cpu_clk(clocks),
2377 }
2378 }
2379 } else {
2380 configure_apb_clk_impl(clocks, old_selector, new_selector);
2381 }
2382 }
2383 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2384 clocks.apb_clk
2385 }
2386 pub fn request_apb_clk(clocks: &mut ClockTree) {
2387 trace!("Requesting APB_CLK");
2388 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2389 trace!("Enabling APB_CLK");
2390 match unwrap!(clocks.apb_clk) {
2391 ApbClkConfig::Pll => request_apb_clk_80m(clocks),
2392 ApbClkConfig::Apll => request_apb_clk_cpu_div2(clocks),
2393 ApbClkConfig::Xtal => request_cpu_clk(clocks),
2394 ApbClkConfig::RcFast => request_cpu_clk(clocks),
2395 }
2396 enable_apb_clk_impl(clocks, true);
2397 }
2398 }
2399 pub fn release_apb_clk(clocks: &mut ClockTree) {
2400 trace!("Releasing APB_CLK");
2401 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2402 trace!("Disabling APB_CLK");
2403 enable_apb_clk_impl(clocks, false);
2404 match unwrap!(clocks.apb_clk) {
2405 ApbClkConfig::Pll => release_apb_clk_80m(clocks),
2406 ApbClkConfig::Apll => release_apb_clk_cpu_div2(clocks),
2407 ApbClkConfig::Xtal => release_cpu_clk(clocks),
2408 ApbClkConfig::RcFast => release_cpu_clk(clocks),
2409 }
2410 }
2411 }
2412 #[allow(unused_variables)]
2413 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2414 match config {
2415 ApbClkConfig::Pll => apb_clk_80m_frequency(),
2416 ApbClkConfig::Apll => apb_clk_cpu_div2_frequency(),
2417 ApbClkConfig::Xtal => cpu_clk_frequency(),
2418 ApbClkConfig::RcFast => cpu_clk_frequency(),
2419 }
2420 }
2421 pub fn apb_clk_frequency() -> u32 {
2422 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2423 }
2424 pub fn apb_clk_source_frequency(source: ApbClkConfig) -> u32 {
2425 match source {
2426 ApbClkConfig::Pll => apb_clk_80m_frequency(),
2427 ApbClkConfig::Apll => apb_clk_cpu_div2_frequency(),
2428 ApbClkConfig::Xtal => cpu_clk_frequency(),
2429 ApbClkConfig::RcFast => cpu_clk_frequency(),
2430 }
2431 }
2432 pub fn configure_ref_tick(clocks: &mut ClockTree, new_selector: RefTickConfig) {
2433 let old_selector = clocks.ref_tick.replace(new_selector);
2434 refresh_ref_tick_downstream(clocks);
2435 if clocks.ref_tick_refcount > 0 {
2436 match new_selector {
2437 RefTickConfig::Pll => request_ref_tick_xtal(clocks),
2438 RefTickConfig::Apll => request_ref_tick_xtal(clocks),
2439 RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
2440 RefTickConfig::RcFast => request_ref_tick_ck8m(clocks),
2441 }
2442 configure_ref_tick_impl(clocks, old_selector, new_selector);
2443 if let Some(old_selector) = old_selector {
2444 match old_selector {
2445 RefTickConfig::Pll => release_ref_tick_xtal(clocks),
2446 RefTickConfig::Apll => release_ref_tick_xtal(clocks),
2447 RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
2448 RefTickConfig::RcFast => release_ref_tick_ck8m(clocks),
2449 }
2450 }
2451 } else {
2452 configure_ref_tick_impl(clocks, old_selector, new_selector);
2453 }
2454 }
2455 pub fn ref_tick_config(clocks: &mut ClockTree) -> Option<RefTickConfig> {
2456 clocks.ref_tick
2457 }
2458 pub fn request_ref_tick(clocks: &mut ClockTree) {
2459 trace!("Requesting REF_TICK");
2460 if increment_reference_count(&mut clocks.ref_tick_refcount) {
2461 trace!("Enabling REF_TICK");
2462 match unwrap!(clocks.ref_tick) {
2463 RefTickConfig::Pll => request_ref_tick_xtal(clocks),
2464 RefTickConfig::Apll => request_ref_tick_xtal(clocks),
2465 RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
2466 RefTickConfig::RcFast => request_ref_tick_ck8m(clocks),
2467 }
2468 enable_ref_tick_impl(clocks, true);
2469 }
2470 }
2471 pub fn release_ref_tick(clocks: &mut ClockTree) {
2472 trace!("Releasing REF_TICK");
2473 if decrement_reference_count(&mut clocks.ref_tick_refcount) {
2474 trace!("Disabling REF_TICK");
2475 enable_ref_tick_impl(clocks, false);
2476 match unwrap!(clocks.ref_tick) {
2477 RefTickConfig::Pll => release_ref_tick_xtal(clocks),
2478 RefTickConfig::Apll => release_ref_tick_xtal(clocks),
2479 RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
2480 RefTickConfig::RcFast => release_ref_tick_ck8m(clocks),
2481 }
2482 }
2483 }
2484 #[allow(unused_variables)]
2485 pub fn ref_tick_config_frequency(clocks: &mut ClockTree, config: RefTickConfig) -> u32 {
2486 match config {
2487 RefTickConfig::Pll => ref_tick_xtal_frequency(),
2488 RefTickConfig::Apll => ref_tick_xtal_frequency(),
2489 RefTickConfig::Xtal => ref_tick_xtal_frequency(),
2490 RefTickConfig::RcFast => ref_tick_ck8m_frequency(),
2491 }
2492 }
2493 pub fn ref_tick_frequency() -> u32 {
2494 REF_TICK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2495 }
2496 pub fn ref_tick_source_frequency(source: RefTickConfig) -> u32 {
2497 match source {
2498 RefTickConfig::Pll => ref_tick_xtal_frequency(),
2499 RefTickConfig::Apll => ref_tick_xtal_frequency(),
2500 RefTickConfig::Xtal => ref_tick_xtal_frequency(),
2501 RefTickConfig::RcFast => ref_tick_ck8m_frequency(),
2502 }
2503 }
2504 pub fn configure_ref_tick_xtal(clocks: &mut ClockTree, config: RefTickXtalConfig) {
2505 let old_config = clocks.ref_tick_xtal.replace(config);
2506 refresh_ref_tick_xtal_downstream(clocks);
2507 configure_ref_tick_xtal_impl(clocks, old_config, config);
2508 }
2509 pub fn ref_tick_xtal_config(clocks: &mut ClockTree) -> Option<RefTickXtalConfig> {
2510 clocks.ref_tick_xtal
2511 }
2512 pub fn request_ref_tick_xtal(clocks: &mut ClockTree) {
2513 trace!("Requesting REF_TICK_XTAL");
2514 trace!("Enabling REF_TICK_XTAL");
2515 request_xtal_clk(clocks);
2516 enable_ref_tick_xtal_impl(clocks, true);
2517 }
2518 pub fn release_ref_tick_xtal(clocks: &mut ClockTree) {
2519 trace!("Releasing REF_TICK_XTAL");
2520 trace!("Disabling REF_TICK_XTAL");
2521 enable_ref_tick_xtal_impl(clocks, false);
2522 release_xtal_clk(clocks);
2523 }
2524 #[allow(unused_variables)]
2525 pub fn ref_tick_xtal_config_frequency(
2526 clocks: &mut ClockTree,
2527 config: RefTickXtalConfig,
2528 ) -> u32 {
2529 (xtal_clk_frequency() / (config.divisor() + 1))
2530 }
2531 pub fn ref_tick_xtal_frequency() -> u32 {
2532 REF_TICK_XTAL_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2533 }
2534 pub fn ref_tick_xtal_source_frequency() -> u32 {
2535 xtal_clk_frequency()
2536 }
2537 pub fn configure_ref_tick_ck8m(clocks: &mut ClockTree, config: RefTickCk8mConfig) {
2538 let old_config = clocks.ref_tick_ck8m.replace(config);
2539 refresh_ref_tick_ck8m_downstream(clocks);
2540 configure_ref_tick_ck8m_impl(clocks, old_config, config);
2541 }
2542 pub fn ref_tick_ck8m_config(clocks: &mut ClockTree) -> Option<RefTickCk8mConfig> {
2543 clocks.ref_tick_ck8m
2544 }
2545 pub fn request_ref_tick_ck8m(clocks: &mut ClockTree) {
2546 trace!("Requesting REF_TICK_CK8M");
2547 trace!("Enabling REF_TICK_CK8M");
2548 request_rc_fast_clk(clocks);
2549 enable_ref_tick_ck8m_impl(clocks, true);
2550 }
2551 pub fn release_ref_tick_ck8m(clocks: &mut ClockTree) {
2552 trace!("Releasing REF_TICK_CK8M");
2553 trace!("Disabling REF_TICK_CK8M");
2554 enable_ref_tick_ck8m_impl(clocks, false);
2555 release_rc_fast_clk(clocks);
2556 }
2557 #[allow(unused_variables)]
2558 pub fn ref_tick_ck8m_config_frequency(
2559 clocks: &mut ClockTree,
2560 config: RefTickCk8mConfig,
2561 ) -> u32 {
2562 (rc_fast_clk_frequency() / (config.divisor() + 1))
2563 }
2564 pub fn ref_tick_ck8m_frequency() -> u32 {
2565 REF_TICK_CK8M_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2566 }
2567 pub fn ref_tick_ck8m_source_frequency() -> u32 {
2568 rc_fast_clk_frequency()
2569 }
2570 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
2571 let old_selector = clocks.cpu_clk.replace(new_selector);
2572 refresh_cpu_clk_downstream(clocks);
2573 match new_selector {
2574 CpuClkConfig::Xtal => {
2575 configure_system_pre_div_in(clocks, SystemPreDivInConfig::Xtal);
2576 configure_apb_clk(clocks, ApbClkConfig::Xtal);
2577 configure_ref_tick(clocks, RefTickConfig::Xtal);
2578 let config_value =
2579 RefTickXtalConfig::new(((xtal_clk_frequency() / 1000000) - 1));
2580 configure_ref_tick_xtal(clocks, config_value);
2581 }
2582 CpuClkConfig::RcFast => {
2583 configure_system_pre_div_in(clocks, SystemPreDivInConfig::RcFast);
2584 configure_apb_clk(clocks, ApbClkConfig::RcFast);
2585 configure_ref_tick(clocks, RefTickConfig::RcFast);
2586 let config_value =
2587 RefTickCk8mConfig::new(((rc_fast_clk_frequency() / 1000000) - 1));
2588 configure_ref_tick_ck8m(clocks, config_value);
2589 }
2590 CpuClkConfig::Apll => {
2591 configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Apll);
2592 configure_apb_clk(clocks, ApbClkConfig::Apll);
2593 configure_ref_tick(clocks, RefTickConfig::Apll);
2594 let config_value =
2595 RefTickXtalConfig::new(((xtal_clk_frequency() / 1000000) - 1));
2596 configure_ref_tick_xtal(clocks, config_value);
2597 }
2598 CpuClkConfig::Pll => {
2599 configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Pll);
2600 configure_apb_clk(clocks, ApbClkConfig::Pll);
2601 configure_ref_tick(clocks, RefTickConfig::Pll);
2602 let config_value =
2603 RefTickXtalConfig::new(((xtal_clk_frequency() / 1000000) - 1));
2604 configure_ref_tick_xtal(clocks, config_value);
2605 }
2606 }
2607 match new_selector {
2608 CpuClkConfig::Xtal => request_system_pre_div(clocks),
2609 CpuClkConfig::RcFast => request_system_pre_div(clocks),
2610 CpuClkConfig::Apll => request_cpu_pll_div(clocks),
2611 CpuClkConfig::Pll => request_cpu_pll_div(clocks),
2612 }
2613 configure_cpu_clk_impl(clocks, old_selector, new_selector);
2614 if let Some(old_selector) = old_selector {
2615 match old_selector {
2616 CpuClkConfig::Xtal => release_system_pre_div(clocks),
2617 CpuClkConfig::RcFast => release_system_pre_div(clocks),
2618 CpuClkConfig::Apll => release_cpu_pll_div(clocks),
2619 CpuClkConfig::Pll => release_cpu_pll_div(clocks),
2620 }
2621 }
2622 }
2623 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2624 clocks.cpu_clk
2625 }
2626 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2627 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2628 #[allow(unused_variables)]
2629 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2630 match config {
2631 CpuClkConfig::Xtal => system_pre_div_frequency(),
2632 CpuClkConfig::RcFast => system_pre_div_frequency(),
2633 CpuClkConfig::Apll => cpu_pll_div_frequency(),
2634 CpuClkConfig::Pll => cpu_pll_div_frequency(),
2635 }
2636 }
2637 pub fn cpu_clk_frequency() -> u32 {
2638 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2639 }
2640 pub fn request_apb_clk_cpu_div2(clocks: &mut ClockTree) {
2641 trace!("Requesting APB_CLK_CPU_DIV2");
2642 trace!("Enabling APB_CLK_CPU_DIV2");
2643 request_cpu_clk(clocks);
2644 enable_apb_clk_cpu_div2_impl(clocks, true);
2645 }
2646 pub fn release_apb_clk_cpu_div2(clocks: &mut ClockTree) {
2647 trace!("Releasing APB_CLK_CPU_DIV2");
2648 trace!("Disabling APB_CLK_CPU_DIV2");
2649 enable_apb_clk_cpu_div2_impl(clocks, false);
2650 release_cpu_clk(clocks);
2651 }
2652 pub fn apb_clk_cpu_div2_frequency() -> u32 {
2653 (cpu_clk_frequency() / 2)
2654 }
2655 pub fn apb_clk_cpu_div2_source_frequency() -> u32 {
2656 cpu_clk_frequency()
2657 }
2658 pub fn request_apb_clk_80m(clocks: &mut ClockTree) {
2659 trace!("Requesting APB_CLK_80M");
2660 trace!("Enabling APB_CLK_80M");
2661 request_cpu_clk(clocks);
2662 enable_apb_clk_80m_impl(clocks, true);
2663 }
2664 pub fn release_apb_clk_80m(clocks: &mut ClockTree) {
2665 trace!("Releasing APB_CLK_80M");
2666 trace!("Disabling APB_CLK_80M");
2667 enable_apb_clk_80m_impl(clocks, false);
2668 release_cpu_clk(clocks);
2669 }
2670 pub fn apb_clk_80m_frequency() -> u32 {
2671 80000000
2672 }
2673 pub fn apb_clk_80m_source_frequency() -> u32 {
2674 cpu_clk_frequency()
2675 }
2676 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2677 trace!("Requesting XTAL32K_CLK");
2678 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2679 trace!("Enabling XTAL32K_CLK");
2680 enable_xtal32k_clk_impl(clocks, true);
2681 }
2682 }
2683 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2684 trace!("Releasing XTAL32K_CLK");
2685 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2686 trace!("Disabling XTAL32K_CLK");
2687 enable_xtal32k_clk_impl(clocks, false);
2688 }
2689 }
2690 pub fn xtal32k_clk_frequency() -> u32 {
2691 32768
2692 }
2693 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2694 trace!("Requesting RC_SLOW_CLK");
2695 trace!("Enabling RC_SLOW_CLK");
2696 enable_rc_slow_clk_impl(clocks, true);
2697 }
2698 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2699 trace!("Releasing RC_SLOW_CLK");
2700 trace!("Disabling RC_SLOW_CLK");
2701 enable_rc_slow_clk_impl(clocks, false);
2702 }
2703 pub fn rc_slow_clk_frequency() -> u32 {
2704 90000
2705 }
2706 pub fn request_rc_fast_div_clk(clocks: &mut ClockTree) {
2707 trace!("Requesting RC_FAST_DIV_CLK");
2708 if increment_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
2709 trace!("Enabling RC_FAST_DIV_CLK");
2710 request_rc_fast_clk(clocks);
2711 enable_rc_fast_div_clk_impl(clocks, true);
2712 }
2713 }
2714 pub fn release_rc_fast_div_clk(clocks: &mut ClockTree) {
2715 trace!("Releasing RC_FAST_DIV_CLK");
2716 if decrement_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
2717 trace!("Disabling RC_FAST_DIV_CLK");
2718 enable_rc_fast_div_clk_impl(clocks, false);
2719 release_rc_fast_clk(clocks);
2720 }
2721 }
2722 pub fn rc_fast_div_clk_frequency() -> u32 {
2723 (rc_fast_clk_frequency() / 256)
2724 }
2725 pub fn rc_fast_div_clk_source_frequency() -> u32 {
2726 rc_fast_clk_frequency()
2727 }
2728 pub fn request_xtal_div_clk(clocks: &mut ClockTree) {
2729 trace!("Requesting XTAL_DIV_CLK");
2730 trace!("Enabling XTAL_DIV_CLK");
2731 request_xtal_clk(clocks);
2732 enable_xtal_div_clk_impl(clocks, true);
2733 }
2734 pub fn release_xtal_div_clk(clocks: &mut ClockTree) {
2735 trace!("Releasing XTAL_DIV_CLK");
2736 trace!("Disabling XTAL_DIV_CLK");
2737 enable_xtal_div_clk_impl(clocks, false);
2738 release_xtal_clk(clocks);
2739 }
2740 pub fn xtal_div_clk_frequency() -> u32 {
2741 (xtal_clk_frequency() / 4)
2742 }
2743 pub fn xtal_div_clk_source_frequency() -> u32 {
2744 xtal_clk_frequency()
2745 }
2746 pub fn configure_rtc_slow_clk(clocks: &mut ClockTree, new_selector: RtcSlowClkConfig) {
2747 let old_selector = clocks.rtc_slow_clk.replace(new_selector);
2748 refresh_rtc_slow_clk_downstream(clocks);
2749 match new_selector {
2750 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2751 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2752 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
2753 }
2754 configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
2755 if let Some(old_selector) = old_selector {
2756 match old_selector {
2757 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2758 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2759 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
2760 }
2761 }
2762 }
2763 pub fn rtc_slow_clk_config(clocks: &mut ClockTree) -> Option<RtcSlowClkConfig> {
2764 clocks.rtc_slow_clk
2765 }
2766 pub fn request_rtc_slow_clk(clocks: &mut ClockTree) {
2767 trace!("Requesting RTC_SLOW_CLK");
2768 trace!("Enabling RTC_SLOW_CLK");
2769 match unwrap!(clocks.rtc_slow_clk) {
2770 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2771 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2772 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
2773 }
2774 enable_rtc_slow_clk_impl(clocks, true);
2775 }
2776 pub fn release_rtc_slow_clk(clocks: &mut ClockTree) {
2777 trace!("Releasing RTC_SLOW_CLK");
2778 trace!("Disabling RTC_SLOW_CLK");
2779 enable_rtc_slow_clk_impl(clocks, false);
2780 match unwrap!(clocks.rtc_slow_clk) {
2781 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2782 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2783 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
2784 }
2785 }
2786 #[allow(unused_variables)]
2787 pub fn rtc_slow_clk_config_frequency(
2788 clocks: &mut ClockTree,
2789 config: RtcSlowClkConfig,
2790 ) -> u32 {
2791 match config {
2792 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2793 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2794 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
2795 }
2796 }
2797 pub fn rtc_slow_clk_frequency() -> u32 {
2798 RTC_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2799 }
2800 pub fn rtc_slow_clk_source_frequency(source: RtcSlowClkConfig) -> u32 {
2801 match source {
2802 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2803 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2804 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
2805 }
2806 }
2807 pub fn configure_rtc_fast_clk(clocks: &mut ClockTree, new_selector: RtcFastClkConfig) {
2808 let old_selector = clocks.rtc_fast_clk.replace(new_selector);
2809 refresh_rtc_fast_clk_downstream(clocks);
2810 if clocks.rtc_fast_clk_refcount > 0 {
2811 match new_selector {
2812 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
2813 RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
2814 }
2815 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
2816 if let Some(old_selector) = old_selector {
2817 match old_selector {
2818 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
2819 RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
2820 }
2821 }
2822 } else {
2823 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
2824 }
2825 }
2826 pub fn rtc_fast_clk_config(clocks: &mut ClockTree) -> Option<RtcFastClkConfig> {
2827 clocks.rtc_fast_clk
2828 }
2829 pub fn request_rtc_fast_clk(clocks: &mut ClockTree) {
2830 trace!("Requesting RTC_FAST_CLK");
2831 if increment_reference_count(&mut clocks.rtc_fast_clk_refcount) {
2832 trace!("Enabling RTC_FAST_CLK");
2833 match unwrap!(clocks.rtc_fast_clk) {
2834 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
2835 RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
2836 }
2837 enable_rtc_fast_clk_impl(clocks, true);
2838 }
2839 }
2840 pub fn release_rtc_fast_clk(clocks: &mut ClockTree) {
2841 trace!("Releasing RTC_FAST_CLK");
2842 if decrement_reference_count(&mut clocks.rtc_fast_clk_refcount) {
2843 trace!("Disabling RTC_FAST_CLK");
2844 enable_rtc_fast_clk_impl(clocks, false);
2845 match unwrap!(clocks.rtc_fast_clk) {
2846 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
2847 RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
2848 }
2849 }
2850 }
2851 #[allow(unused_variables)]
2852 pub fn rtc_fast_clk_config_frequency(
2853 clocks: &mut ClockTree,
2854 config: RtcFastClkConfig,
2855 ) -> u32 {
2856 match config {
2857 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
2858 RtcFastClkConfig::Rc => rc_fast_clk_frequency(),
2859 }
2860 }
2861 pub fn rtc_fast_clk_frequency() -> u32 {
2862 RTC_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2863 }
2864 pub fn rtc_fast_clk_source_frequency(source: RtcFastClkConfig) -> u32 {
2865 match source {
2866 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
2867 RtcFastClkConfig::Rc => rc_fast_clk_frequency(),
2868 }
2869 }
2870 pub fn request_uart_mem_clk(clocks: &mut ClockTree) {
2871 trace!("Requesting UART_MEM_CLK");
2872 if increment_reference_count(&mut clocks.uart_mem_clk_refcount) {
2873 trace!("Enabling UART_MEM_CLK");
2874 request_xtal_clk(clocks);
2875 enable_uart_mem_clk_impl(clocks, true);
2876 }
2877 }
2878 pub fn release_uart_mem_clk(clocks: &mut ClockTree) {
2879 trace!("Releasing UART_MEM_CLK");
2880 if decrement_reference_count(&mut clocks.uart_mem_clk_refcount) {
2881 trace!("Disabling UART_MEM_CLK");
2882 enable_uart_mem_clk_impl(clocks, false);
2883 release_xtal_clk(clocks);
2884 }
2885 }
2886 pub fn uart_mem_clk_frequency() -> u32 {
2887 xtal_clk_frequency()
2888 }
2889 pub fn uart_mem_clk_source_frequency(source: UartMemClkConfig) -> u32 {
2890 match source {
2891 UartMemClkConfig::Xtal => xtal_clk_frequency(),
2892 }
2893 }
2894 pub fn configure_timg_calibration_clock(
2895 clocks: &mut ClockTree,
2896 new_selector: TimgCalibrationClockConfig,
2897 ) {
2898 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2899 refresh_timg_calibration_clock_downstream(clocks);
2900 if clocks.timg_calibration_clock_refcount > 0 {
2901 match new_selector {
2902 TimgCalibrationClockConfig::RtcClk => request_rtc_slow_clk(clocks),
2903 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
2904 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2905 }
2906 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2907 if let Some(old_selector) = old_selector {
2908 match old_selector {
2909 TimgCalibrationClockConfig::RtcClk => release_rtc_slow_clk(clocks),
2910 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
2911 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2912 }
2913 }
2914 } else {
2915 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2916 }
2917 }
2918 pub fn timg_calibration_clock_config(
2919 clocks: &mut ClockTree,
2920 ) -> Option<TimgCalibrationClockConfig> {
2921 clocks.timg_calibration_clock
2922 }
2923 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2924 trace!("Requesting TIMG_CALIBRATION_CLOCK");
2925 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2926 trace!("Enabling TIMG_CALIBRATION_CLOCK");
2927 crate::rtc_cntl::WakeLock::acquire();
2928 match unwrap!(clocks.timg_calibration_clock) {
2929 TimgCalibrationClockConfig::RtcClk => request_rtc_slow_clk(clocks),
2930 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
2931 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2932 }
2933 enable_timg_calibration_clock_impl(clocks, true);
2934 }
2935 }
2936 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2937 trace!("Releasing TIMG_CALIBRATION_CLOCK");
2938 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2939 trace!("Disabling TIMG_CALIBRATION_CLOCK");
2940 crate::rtc_cntl::WakeLock::release();
2941 enable_timg_calibration_clock_impl(clocks, false);
2942 match unwrap!(clocks.timg_calibration_clock) {
2943 TimgCalibrationClockConfig::RtcClk => release_rtc_slow_clk(clocks),
2944 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
2945 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2946 }
2947 }
2948 }
2949 #[allow(unused_variables)]
2950 pub fn timg_calibration_clock_config_frequency(
2951 clocks: &mut ClockTree,
2952 config: TimgCalibrationClockConfig,
2953 ) -> u32 {
2954 match config {
2955 TimgCalibrationClockConfig::RtcClk => rtc_slow_clk_frequency(),
2956 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
2957 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2958 }
2959 }
2960 pub fn timg_calibration_clock_frequency() -> u32 {
2961 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2962 }
2963 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
2964 match source {
2965 TimgCalibrationClockConfig::RtcClk => rtc_slow_clk_frequency(),
2966 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
2967 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2968 }
2969 }
2970 impl SdmInstance {
2971 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2972 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2973 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
2974 {
2975 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2976 request_apb_clk(clocks);
2977 self.enable_function_clock_impl(clocks, true);
2978 }
2979 }
2980 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2981 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2982 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
2983 {
2984 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2985 self.enable_function_clock_impl(clocks, false);
2986 release_apb_clk(clocks);
2987 }
2988 }
2989 pub fn function_clock_frequency(self) -> u32 {
2990 apb_clk_frequency()
2991 }
2992 pub fn function_clock_source_frequency() -> u32 {
2993 apb_clk_frequency()
2994 }
2995 }
2996 impl I2cInstance {
2997 pub fn configure_function_clock(
2998 self,
2999 clocks: &mut ClockTree,
3000 config: I2cFunctionClockConfig,
3001 ) {
3002 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3003 refresh_i2c_function_clock_downstream(clocks, self);
3004 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
3005 match config.sclk {
3006 I2cFunctionClockSclk::Apb => request_apb_clk(clocks),
3007 I2cFunctionClockSclk::RefTick => request_ref_tick(clocks),
3008 }
3009 self.configure_function_clock_impl(clocks, old_config, config);
3010 if let Some(old_config) = old_config {
3011 match old_config.sclk {
3012 I2cFunctionClockSclk::Apb => release_apb_clk(clocks),
3013 I2cFunctionClockSclk::RefTick => release_ref_tick(clocks),
3014 }
3015 }
3016 } else {
3017 self.configure_function_clock_impl(clocks, old_config, config);
3018 }
3019 }
3020 pub fn function_clock_config(
3021 self,
3022 clocks: &mut ClockTree,
3023 ) -> Option<I2cFunctionClockConfig> {
3024 clocks.i2c_function_clock[self as usize]
3025 }
3026 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3027 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3028 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3029 {
3030 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3031 crate::rtc_cntl::WakeLock::acquire();
3032 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3033 I2cFunctionClockSclk::Apb => request_apb_clk(clocks),
3034 I2cFunctionClockSclk::RefTick => request_ref_tick(clocks),
3035 }
3036 self.enable_function_clock_impl(clocks, true);
3037 }
3038 }
3039 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3040 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3041 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3042 {
3043 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3044 crate::rtc_cntl::WakeLock::release();
3045 self.enable_function_clock_impl(clocks, false);
3046 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3047 I2cFunctionClockSclk::Apb => release_apb_clk(clocks),
3048 I2cFunctionClockSclk::RefTick => release_ref_tick(clocks),
3049 }
3050 }
3051 }
3052 #[allow(unused_variables)]
3053 pub fn function_clock_config_frequency(
3054 clocks: &mut ClockTree,
3055 config: I2cFunctionClockConfig,
3056 ) -> u32 {
3057 match config.sclk {
3058 I2cFunctionClockSclk::Apb => apb_clk_frequency(),
3059 I2cFunctionClockSclk::RefTick => ref_tick_frequency(),
3060 }
3061 }
3062 pub fn function_clock_frequency(self) -> u32 {
3063 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3064 .load(::core::sync::atomic::Ordering::Acquire)
3065 }
3066 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3067 match sclk {
3068 I2cFunctionClockSclk::Apb => apb_clk_frequency(),
3069 I2cFunctionClockSclk::RefTick => ref_tick_frequency(),
3070 }
3071 }
3072 }
3073 impl RmtInstance {
3074 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3075 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3076 refresh_rmt_sclk_downstream(clocks, self);
3077 if clocks.rmt_sclk_refcount[self as usize] > 0 {
3078 match new_selector {
3079 RmtSclkConfig::RefTick => request_ref_tick(clocks),
3080 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3081 }
3082 self.configure_sclk_impl(clocks, old_selector, new_selector);
3083 if let Some(old_selector) = old_selector {
3084 match old_selector {
3085 RmtSclkConfig::RefTick => release_ref_tick(clocks),
3086 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3087 }
3088 }
3089 } else {
3090 self.configure_sclk_impl(clocks, old_selector, new_selector);
3091 }
3092 }
3093 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3094 clocks.rmt_sclk[self as usize]
3095 }
3096 pub fn request_sclk(self, clocks: &mut ClockTree) {
3097 trace!("Requesting {:?}::SCLK", self);
3098 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3099 trace!("Enabling {:?}::SCLK", self);
3100 crate::rtc_cntl::WakeLock::acquire();
3101 match unwrap!(clocks.rmt_sclk[self as usize]) {
3102 RmtSclkConfig::RefTick => request_ref_tick(clocks),
3103 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3104 }
3105 self.enable_sclk_impl(clocks, true);
3106 }
3107 }
3108 pub fn release_sclk(self, clocks: &mut ClockTree) {
3109 trace!("Releasing {:?}::SCLK", self);
3110 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3111 trace!("Disabling {:?}::SCLK", self);
3112 crate::rtc_cntl::WakeLock::release();
3113 self.enable_sclk_impl(clocks, false);
3114 match unwrap!(clocks.rmt_sclk[self as usize]) {
3115 RmtSclkConfig::RefTick => release_ref_tick(clocks),
3116 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3117 }
3118 }
3119 }
3120 #[allow(unused_variables)]
3121 pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
3122 match config {
3123 RmtSclkConfig::RefTick => ref_tick_frequency(),
3124 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3125 }
3126 }
3127 pub fn sclk_frequency(self) -> u32 {
3128 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3129 }
3130 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3131 match source {
3132 RmtSclkConfig::RefTick => ref_tick_frequency(),
3133 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3134 }
3135 }
3136 }
3137 impl SpiInstance {
3138 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3139 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3140 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3141 {
3142 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3143 crate::rtc_cntl::WakeLock::acquire();
3144 request_apb_clk(clocks);
3145 self.enable_function_clock_impl(clocks, true);
3146 }
3147 }
3148 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3149 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3150 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3151 {
3152 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3153 crate::rtc_cntl::WakeLock::release();
3154 self.enable_function_clock_impl(clocks, false);
3155 release_apb_clk(clocks);
3156 }
3157 }
3158 pub fn function_clock_frequency(self) -> u32 {
3159 apb_clk_frequency()
3160 }
3161 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3162 match source {
3163 SpiFunctionClockConfig::Apb => apb_clk_frequency(),
3164 }
3165 }
3166 }
3167 impl TimgInstance {
3168 pub fn configure_function_clock(
3169 self,
3170 clocks: &mut ClockTree,
3171 new_selector: TimgFunctionClockConfig,
3172 ) {
3173 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3174 refresh_timg_function_clock_downstream(clocks, self);
3175 if clocks.timg_function_clock_refcount[self as usize] > 0 {
3176 match new_selector {
3177 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3178 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3179 }
3180 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3181 if let Some(old_selector) = old_selector {
3182 match old_selector {
3183 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3184 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3185 }
3186 }
3187 } else {
3188 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3189 }
3190 }
3191 pub fn function_clock_config(
3192 self,
3193 clocks: &mut ClockTree,
3194 ) -> Option<TimgFunctionClockConfig> {
3195 clocks.timg_function_clock[self as usize]
3196 }
3197 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3198 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3199 if increment_reference_count(
3200 &mut clocks.timg_function_clock_refcount[self as usize],
3201 ) {
3202 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3203 match unwrap!(clocks.timg_function_clock[self as usize]) {
3204 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3205 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3206 }
3207 self.enable_function_clock_impl(clocks, true);
3208 }
3209 }
3210 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3211 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3212 if decrement_reference_count(
3213 &mut clocks.timg_function_clock_refcount[self as usize],
3214 ) {
3215 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3216 self.enable_function_clock_impl(clocks, false);
3217 match unwrap!(clocks.timg_function_clock[self as usize]) {
3218 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3219 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3220 }
3221 }
3222 }
3223 #[allow(unused_variables)]
3224 pub fn function_clock_config_frequency(
3225 clocks: &mut ClockTree,
3226 config: TimgFunctionClockConfig,
3227 ) -> u32 {
3228 match config {
3229 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3230 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3231 }
3232 }
3233 pub fn function_clock_frequency(self) -> u32 {
3234 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3235 .load(::core::sync::atomic::Ordering::Acquire)
3236 }
3237 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3238 match source {
3239 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3240 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3241 }
3242 }
3243 }
3244 impl UartInstance {
3245 pub fn configure_function_clock(
3246 self,
3247 clocks: &mut ClockTree,
3248 config: UartFunctionClockConfig,
3249 ) {
3250 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3251 refresh_uart_function_clock_downstream(clocks, self);
3252 if clocks.uart_function_clock_refcount[self as usize] > 0 {
3253 match config.sclk {
3254 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3255 UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
3256 }
3257 self.configure_function_clock_impl(clocks, old_config, config);
3258 if let Some(old_config) = old_config {
3259 match old_config.sclk {
3260 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3261 UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
3262 }
3263 }
3264 } else {
3265 self.configure_function_clock_impl(clocks, old_config, config);
3266 }
3267 }
3268 pub fn function_clock_config(
3269 self,
3270 clocks: &mut ClockTree,
3271 ) -> Option<UartFunctionClockConfig> {
3272 clocks.uart_function_clock[self as usize]
3273 }
3274 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3275 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3276 if increment_reference_count(
3277 &mut clocks.uart_function_clock_refcount[self as usize],
3278 ) {
3279 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3280 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3281 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3282 UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
3283 }
3284 self.enable_function_clock_impl(clocks, true);
3285 }
3286 }
3287 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3288 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3289 if decrement_reference_count(
3290 &mut clocks.uart_function_clock_refcount[self as usize],
3291 ) {
3292 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3293 self.enable_function_clock_impl(clocks, false);
3294 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3295 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3296 UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
3297 }
3298 }
3299 }
3300 #[allow(unused_variables)]
3301 pub fn function_clock_config_frequency(
3302 clocks: &mut ClockTree,
3303 config: UartFunctionClockConfig,
3304 ) -> u32 {
3305 match config.sclk {
3306 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3307 UartFunctionClockSclk::RefTick => ref_tick_frequency(),
3308 }
3309 }
3310 pub fn function_clock_frequency(self) -> u32 {
3311 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3312 .load(::core::sync::atomic::Ordering::Acquire)
3313 }
3314 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3315 match sclk {
3316 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3317 UartFunctionClockSclk::RefTick => ref_tick_frequency(),
3318 }
3319 }
3320 pub fn configure_baud_rate_generator(
3321 self,
3322 clocks: &mut ClockTree,
3323 config: UartBaudRateGeneratorConfig,
3324 ) {
3325 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3326 refresh_uart_baud_rate_generator_downstream(clocks, self);
3327 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3328 }
3329 pub fn baud_rate_generator_config(
3330 self,
3331 clocks: &mut ClockTree,
3332 ) -> Option<UartBaudRateGeneratorConfig> {
3333 clocks.uart_baud_rate_generator[self as usize]
3334 }
3335 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3336 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3337 if increment_reference_count(
3338 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3339 ) {
3340 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3341 self.request_function_clock(clocks);
3342 self.enable_baud_rate_generator_impl(clocks, true);
3343 }
3344 }
3345 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3346 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3347 if decrement_reference_count(
3348 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3349 ) {
3350 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3351 self.enable_baud_rate_generator_impl(clocks, false);
3352 self.release_function_clock(clocks);
3353 }
3354 }
3355 #[allow(unused_variables)]
3356 pub fn baud_rate_generator_config_frequency(
3357 self,
3358 clocks: &mut ClockTree,
3359 config: UartBaudRateGeneratorConfig,
3360 ) -> u32 {
3361 ((self.function_clock_frequency() * 16)
3362 / ((config.integral() * 16) + config.fractional()))
3363 }
3364 pub fn baud_rate_generator_frequency(self) -> u32 {
3365 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3366 .load(::core::sync::atomic::Ordering::Acquire)
3367 }
3368 pub fn request_mem_clock(self, clocks: &mut ClockTree) {
3369 trace!("Requesting {:?}::MEM_CLOCK", self);
3370 if increment_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3371 trace!("Enabling {:?}::MEM_CLOCK", self);
3372 request_uart_mem_clk(clocks);
3373 self.enable_mem_clock_impl(clocks, true);
3374 }
3375 }
3376 pub fn release_mem_clock(self, clocks: &mut ClockTree) {
3377 trace!("Releasing {:?}::MEM_CLOCK", self);
3378 if decrement_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3379 trace!("Disabling {:?}::MEM_CLOCK", self);
3380 self.enable_mem_clock_impl(clocks, false);
3381 release_uart_mem_clk(clocks);
3382 }
3383 }
3384 pub fn mem_clock_frequency(self) -> u32 {
3385 uart_mem_clk_frequency()
3386 }
3387 pub fn mem_clock_source_frequency() -> u32 {
3388 uart_mem_clk_frequency()
3389 }
3390 }
3391 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3399 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3400 #[instability::unstable]
3401 pub struct ClockConfig {
3402 pub xtal_clk: Option<XtalClkConfig>,
3404 pub pll_clk: Option<PllClkConfig>,
3406 pub apll_clk: Option<ApllClkConfig>,
3408 pub cpu_pll_div: Option<CpuPllDivConfig>,
3410 pub system_pre_div: Option<SystemPreDivConfig>,
3412 pub cpu_clk: Option<CpuClkConfig>,
3414 pub rtc_slow_clk: Option<RtcSlowClkConfig>,
3416 pub rtc_fast_clk: Option<RtcFastClkConfig>,
3418 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3420 }
3421 impl ClockConfig {
3422 fn apply(&self, clocks: &mut ClockTree) {
3423 if let Some(config) = self.xtal_clk {
3424 configure_xtal_clk(clocks, config);
3425 }
3426 if let Some(config) = self.pll_clk {
3427 configure_pll_clk(clocks, config);
3428 }
3429 if let Some(config) = self.apll_clk {
3430 configure_apll_clk(clocks, config);
3431 }
3432 if let Some(config) = self.cpu_pll_div {
3433 configure_cpu_pll_div(clocks, config);
3434 }
3435 if let Some(config) = self.system_pre_div {
3436 configure_system_pre_div(clocks, config);
3437 }
3438 if let Some(config) = self.cpu_clk {
3439 configure_cpu_clk(clocks, config);
3440 }
3441 if let Some(config) = self.rtc_slow_clk {
3442 configure_rtc_slow_clk(clocks, config);
3443 }
3444 if let Some(config) = self.rtc_fast_clk {
3445 configure_rtc_fast_clk(clocks, config);
3446 }
3447 if let Some(config) = self.timg_calibration_clock {
3448 configure_timg_calibration_clock(clocks, config);
3449 }
3450 }
3451 }
3452 fn increment_reference_count(refcount: &mut u32) -> bool {
3453 let first = *refcount == 0;
3454 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3455 first
3456 }
3457 fn decrement_reference_count(refcount: &mut u32) -> bool {
3458 *refcount = refcount.saturating_sub(1);
3459 let last = *refcount == 0;
3460 last
3461 }
3462 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3463 if let Some(config) = clocks.xtal_clk {
3464 XTAL_CLK_FREQ_CACHE.store(
3465 xtal_clk_config_frequency(clocks, config),
3466 ::core::sync::atomic::Ordering::Release,
3467 );
3468 }
3469 refresh_pll_clk_downstream(clocks);
3470 refresh_system_pre_div_in_downstream(clocks);
3471 refresh_ref_tick_xtal_downstream(clocks);
3472 refresh_rtc_fast_clk_downstream(clocks);
3473 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3474 refresh_timg_function_clock_downstream(clocks, child_instance);
3475 }
3476 }
3477 fn refresh_pll_clk_downstream(clocks: &mut ClockTree) {
3478 if let Some(config) = clocks.pll_clk {
3479 PLL_CLK_FREQ_CACHE.store(
3480 pll_clk_config_frequency(clocks, config),
3481 ::core::sync::atomic::Ordering::Release,
3482 );
3483 }
3484 refresh_apll_clk_downstream(clocks);
3485 refresh_cpu_pll_div_in_downstream(clocks);
3486 }
3487 fn refresh_apll_clk_downstream(clocks: &mut ClockTree) {
3488 if let Some(config) = clocks.apll_clk {
3489 APLL_CLK_FREQ_CACHE.store(
3490 apll_clk_config_frequency(clocks, config),
3491 ::core::sync::atomic::Ordering::Release,
3492 );
3493 }
3494 refresh_cpu_pll_div_in_downstream(clocks);
3495 }
3496 fn refresh_cpu_pll_div_in_downstream(clocks: &mut ClockTree) {
3497 if let Some(config) = clocks.cpu_pll_div_in {
3498 CPU_PLL_DIV_IN_FREQ_CACHE.store(
3499 cpu_pll_div_in_config_frequency(clocks, config),
3500 ::core::sync::atomic::Ordering::Release,
3501 );
3502 }
3503 refresh_cpu_pll_div_downstream(clocks);
3504 }
3505 fn refresh_cpu_pll_div_downstream(clocks: &mut ClockTree) {
3506 if let Some(config) = clocks.cpu_pll_div {
3507 CPU_PLL_DIV_FREQ_CACHE.store(
3508 cpu_pll_div_config_frequency(clocks, config),
3509 ::core::sync::atomic::Ordering::Release,
3510 );
3511 }
3512 refresh_cpu_clk_downstream(clocks);
3513 }
3514 fn refresh_system_pre_div_in_downstream(clocks: &mut ClockTree) {
3515 if let Some(config) = clocks.system_pre_div_in {
3516 SYSTEM_PRE_DIV_IN_FREQ_CACHE.store(
3517 system_pre_div_in_config_frequency(clocks, config),
3518 ::core::sync::atomic::Ordering::Release,
3519 );
3520 }
3521 refresh_system_pre_div_downstream(clocks);
3522 }
3523 fn refresh_system_pre_div_downstream(clocks: &mut ClockTree) {
3524 if let Some(config) = clocks.system_pre_div {
3525 SYSTEM_PRE_DIV_FREQ_CACHE.store(
3526 system_pre_div_config_frequency(clocks, config),
3527 ::core::sync::atomic::Ordering::Release,
3528 );
3529 }
3530 refresh_cpu_clk_downstream(clocks);
3531 }
3532 fn refresh_ref_tick_xtal_downstream(clocks: &mut ClockTree) {
3533 if let Some(config) = clocks.ref_tick_xtal {
3534 REF_TICK_XTAL_FREQ_CACHE.store(
3535 ref_tick_xtal_config_frequency(clocks, config),
3536 ::core::sync::atomic::Ordering::Release,
3537 );
3538 }
3539 refresh_ref_tick_downstream(clocks);
3540 }
3541 fn refresh_ref_tick_ck8m_downstream(clocks: &mut ClockTree) {
3542 if let Some(config) = clocks.ref_tick_ck8m {
3543 REF_TICK_CK8M_FREQ_CACHE.store(
3544 ref_tick_ck8m_config_frequency(clocks, config),
3545 ::core::sync::atomic::Ordering::Release,
3546 );
3547 }
3548 refresh_ref_tick_downstream(clocks);
3549 }
3550 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3551 if let Some(config) = clocks.cpu_clk {
3552 CPU_CLK_FREQ_CACHE.store(
3553 cpu_clk_config_frequency(clocks, config),
3554 ::core::sync::atomic::Ordering::Release,
3555 );
3556 }
3557 refresh_apb_clk_downstream(clocks);
3558 }
3559 fn refresh_rtc_slow_clk_downstream(clocks: &mut ClockTree) {
3560 if let Some(config) = clocks.rtc_slow_clk {
3561 RTC_SLOW_CLK_FREQ_CACHE.store(
3562 rtc_slow_clk_config_frequency(clocks, config),
3563 ::core::sync::atomic::Ordering::Release,
3564 );
3565 }
3566 refresh_timg_calibration_clock_downstream(clocks);
3567 }
3568 fn refresh_rtc_fast_clk_downstream(clocks: &mut ClockTree) {
3569 if let Some(config) = clocks.rtc_fast_clk {
3570 RTC_FAST_CLK_FREQ_CACHE.store(
3571 rtc_fast_clk_config_frequency(clocks, config),
3572 ::core::sync::atomic::Ordering::Release,
3573 );
3574 }
3575 }
3576 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3577 if let Some(config) = clocks.timg_calibration_clock {
3578 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3579 timg_calibration_clock_config_frequency(clocks, config),
3580 ::core::sync::atomic::Ordering::Release,
3581 );
3582 }
3583 }
3584 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3585 if let Some(config) = clocks.apb_clk {
3586 APB_CLK_FREQ_CACHE.store(
3587 apb_clk_config_frequency(clocks, config),
3588 ::core::sync::atomic::Ordering::Release,
3589 );
3590 }
3591 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
3592 refresh_i2c_function_clock_downstream(clocks, child_instance);
3593 }
3594 for child_instance in [RmtInstance::Rmt] {
3595 refresh_rmt_sclk_downstream(clocks, child_instance);
3596 }
3597 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3598 refresh_timg_function_clock_downstream(clocks, child_instance);
3599 }
3600 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3601 refresh_uart_function_clock_downstream(clocks, child_instance);
3602 }
3603 }
3604 fn refresh_ref_tick_downstream(clocks: &mut ClockTree) {
3605 if let Some(config) = clocks.ref_tick {
3606 REF_TICK_FREQ_CACHE.store(
3607 ref_tick_config_frequency(clocks, config),
3608 ::core::sync::atomic::Ordering::Release,
3609 );
3610 }
3611 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
3612 refresh_i2c_function_clock_downstream(clocks, child_instance);
3613 }
3614 for child_instance in [RmtInstance::Rmt] {
3615 refresh_rmt_sclk_downstream(clocks, child_instance);
3616 }
3617 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3618 refresh_uart_function_clock_downstream(clocks, child_instance);
3619 }
3620 }
3621 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
3622 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
3623 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3624 I2cInstance::function_clock_config_frequency(clocks, config),
3625 ::core::sync::atomic::Ordering::Release,
3626 );
3627 }
3628 }
3629 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
3630 if let Some(config) = clocks.rmt_sclk[instance as usize] {
3631 RMT_SCLK_FREQ_CACHE[instance as usize].store(
3632 RmtInstance::sclk_config_frequency(clocks, config),
3633 ::core::sync::atomic::Ordering::Release,
3634 );
3635 }
3636 }
3637 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3638 if let Some(config) = clocks.timg_function_clock[instance as usize] {
3639 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3640 TimgInstance::function_clock_config_frequency(clocks, config),
3641 ::core::sync::atomic::Ordering::Release,
3642 );
3643 }
3644 }
3645 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
3646 if let Some(config) = clocks.uart_function_clock[instance as usize] {
3647 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3648 UartInstance::function_clock_config_frequency(clocks, config),
3649 ::core::sync::atomic::Ordering::Release,
3650 );
3651 }
3652 refresh_uart_baud_rate_generator_downstream(clocks, instance);
3653 }
3654 fn refresh_uart_baud_rate_generator_downstream(
3655 clocks: &mut ClockTree,
3656 instance: UartInstance,
3657 ) {
3658 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
3659 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
3660 instance.baud_rate_generator_config_frequency(clocks, config),
3661 ::core::sync::atomic::Ordering::Release,
3662 );
3663 }
3664 }
3665 };
3666}
3667#[macro_export]
3671#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3672macro_rules! implement_peripheral_clocks {
3673 () => {
3674 #[doc(hidden)]
3675 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3676 #[repr(u8)]
3677 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3678 pub enum Peripheral {
3679 Aes,
3681 ApbSarAdc,
3683 CopyDma,
3685 CryptoDma,
3687 DedicatedGpio,
3689 Ds,
3691 GpioSd,
3693 Hmac,
3695 I2cExt0,
3697 I2cExt1,
3699 I2s0,
3701 Ledc,
3703 Mcpwm0,
3705 Mcpwm1,
3707 Pcnt,
3709 Rmt,
3711 Rsa,
3713 Sha,
3715 Spi2,
3717 Spi2Dma,
3719 Spi3,
3721 Spi3Dma,
3723 Systimer,
3725 Timg0,
3727 Timg1,
3729 Twai0,
3731 Uart0,
3733 Uart1,
3735 UartMem,
3737 Uhci0,
3739 Uhci1,
3741 UsbFs,
3743 Wdg,
3745 }
3746 impl Peripheral {
3747 const KEEP_ENABLED: &[Peripheral] =
3748 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UartMem];
3749 const COUNT: usize = Self::ALL.len();
3750 const ALL: &[Self] = &[
3751 Self::Aes,
3752 Self::ApbSarAdc,
3753 Self::CopyDma,
3754 Self::CryptoDma,
3755 Self::DedicatedGpio,
3756 Self::Ds,
3757 Self::GpioSd,
3758 Self::Hmac,
3759 Self::I2cExt0,
3760 Self::I2cExt1,
3761 Self::I2s0,
3762 Self::Ledc,
3763 Self::Mcpwm0,
3764 Self::Mcpwm1,
3765 Self::Pcnt,
3766 Self::Rmt,
3767 Self::Rsa,
3768 Self::Sha,
3769 Self::Spi2,
3770 Self::Spi2Dma,
3771 Self::Spi3,
3772 Self::Spi3Dma,
3773 Self::Systimer,
3774 Self::Timg0,
3775 Self::Timg1,
3776 Self::Twai0,
3777 Self::Uart0,
3778 Self::Uart1,
3779 Self::UartMem,
3780 Self::Uhci0,
3781 Self::Uhci1,
3782 Self::UsbFs,
3783 Self::Wdg,
3784 ];
3785 }
3786 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
3787 match peripheral {
3788 Peripheral::Aes => {
3789 crate::peripherals::SYSTEM::regs()
3790 .perip_clk_en1()
3791 .modify(|_, w| w.crypto_aes_clk_en().bit(enable));
3792 }
3793 Peripheral::ApbSarAdc => {
3794 crate::peripherals::SYSTEM::regs()
3795 .perip_clk_en0()
3796 .modify(|_, w| w.apb_saradc_clk_en().bit(enable));
3797 }
3798 Peripheral::CopyDma => {
3799 crate::peripherals::DMA_COPY::regs()
3800 .conf()
3801 .modify(|_, w| w.clk_en().bit(enable));
3802 }
3803 Peripheral::CryptoDma => {
3804 crate::peripherals::SYSTEM::regs()
3805 .perip_clk_en1()
3806 .modify(|_, w| w.crypto_dma_clk_en().bit(enable));
3807 }
3808 Peripheral::DedicatedGpio => {
3809 crate::peripherals::SYSTEM::regs()
3810 .cpu_peri_clk_en()
3811 .modify(|_, w| w.dedicated_gpio_clk_en().bit(enable));
3812 }
3813 Peripheral::Ds => {
3814 crate::peripherals::SYSTEM::regs()
3815 .perip_clk_en1()
3816 .modify(|_, w| w.crypto_ds_clk_en().bit(enable));
3817 }
3818 Peripheral::GpioSd => {
3819 crate::peripherals::GPIO_SD::regs()
3820 .clock_gate()
3821 .modify(|_, w| w.clk_en().bit(enable));
3822 }
3823 Peripheral::Hmac => {
3824 crate::peripherals::SYSTEM::regs()
3825 .perip_clk_en1()
3826 .modify(|_, w| w.crypto_hmac_clk_en().bit(enable));
3827 }
3828 Peripheral::I2cExt0 => {
3829 crate::peripherals::SYSTEM::regs()
3830 .perip_clk_en0()
3831 .modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
3832 }
3833 Peripheral::I2cExt1 => {
3834 crate::peripherals::SYSTEM::regs()
3835 .perip_clk_en0()
3836 .modify(|_, w| w.i2c_ext1_clk_en().bit(enable));
3837 }
3838 Peripheral::I2s0 => {
3839 crate::peripherals::SYSTEM::regs()
3840 .perip_clk_en0()
3841 .modify(|_, w| w.i2s0_clk_en().bit(enable));
3842 }
3843 Peripheral::Ledc => {
3844 crate::peripherals::SYSTEM::regs()
3845 .perip_clk_en0()
3846 .modify(|_, w| w.ledc_clk_en().bit(enable));
3847 }
3848 Peripheral::Mcpwm0 => {
3849 crate::peripherals::SYSTEM::regs()
3850 .perip_clk_en0()
3851 .modify(|_, w| w.pwm0_clk_en().bit(enable));
3852 }
3853 Peripheral::Mcpwm1 => {
3854 crate::peripherals::SYSTEM::regs()
3855 .perip_clk_en0()
3856 .modify(|_, w| w.pwm1_clk_en().bit(enable));
3857 }
3858 Peripheral::Pcnt => {
3859 crate::peripherals::SYSTEM::regs()
3860 .perip_clk_en0()
3861 .modify(|_, w| w.pcnt_clk_en().bit(enable));
3862 }
3863 Peripheral::Rmt => {
3864 crate::peripherals::SYSTEM::regs()
3865 .perip_clk_en0()
3866 .modify(|_, w| w.rmt_clk_en().bit(enable));
3867 }
3868 Peripheral::Rsa => {
3869 crate::peripherals::SYSTEM::regs()
3870 .perip_clk_en1()
3871 .modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
3872 }
3873 Peripheral::Sha => {
3874 crate::peripherals::SYSTEM::regs()
3875 .perip_clk_en1()
3876 .modify(|_, w| w.crypto_sha_clk_en().bit(enable));
3877 }
3878 Peripheral::Spi2 => {
3879 crate::peripherals::SYSTEM::regs()
3880 .perip_clk_en0()
3881 .modify(|_, w| w.spi2_clk_en().bit(enable));
3882 }
3883 Peripheral::Spi2Dma => {
3884 crate::peripherals::SYSTEM::regs()
3885 .perip_clk_en0()
3886 .modify(|_, w| w.spi2_dma_clk_en().bit(enable));
3887 }
3888 Peripheral::Spi3 => {
3889 crate::peripherals::SYSTEM::regs()
3890 .perip_clk_en0()
3891 .modify(|_, w| w.spi3_clk_en().bit(enable));
3892 }
3893 Peripheral::Spi3Dma => {
3894 crate::peripherals::SYSTEM::regs()
3895 .perip_clk_en0()
3896 .modify(|_, w| w.spi3_dma_clk_en().bit(enable));
3897 }
3898 Peripheral::Systimer => {
3899 crate::peripherals::SYSTEM::regs()
3900 .perip_clk_en0()
3901 .modify(|_, w| w.systimer_clk_en().bit(enable));
3902 }
3903 Peripheral::Timg0 => {
3904 crate::peripherals::SYSTEM::regs()
3905 .perip_clk_en0()
3906 .modify(|_, w| w.timergroup_clk_en().bit(enable));
3907 }
3908 Peripheral::Timg1 => {
3909 crate::peripherals::SYSTEM::regs()
3910 .perip_clk_en0()
3911 .modify(|_, w| w.timergroup1_clk_en().bit(enable));
3912 }
3913 Peripheral::Twai0 => {
3914 crate::peripherals::SYSTEM::regs()
3915 .perip_clk_en0()
3916 .modify(|_, w| w.twai_clk_en().bit(enable));
3917 }
3918 Peripheral::Uart0 => {
3919 crate::peripherals::SYSTEM::regs()
3920 .perip_clk_en0()
3921 .modify(|_, w| w.uart_clk_en().bit(enable));
3922 }
3923 Peripheral::Uart1 => {
3924 crate::peripherals::SYSTEM::regs()
3925 .perip_clk_en0()
3926 .modify(|_, w| w.uart1_clk_en().bit(enable));
3927 }
3928 Peripheral::UartMem => {
3929 crate::peripherals::SYSTEM::regs()
3930 .perip_clk_en0()
3931 .modify(|_, w| w.uart_mem_clk_en().bit(enable));
3932 }
3933 Peripheral::Uhci0 => {
3934 crate::peripherals::SYSTEM::regs()
3935 .perip_clk_en0()
3936 .modify(|_, w| w.uhci0_clk_en().bit(enable));
3937 }
3938 Peripheral::Uhci1 => {
3939 crate::peripherals::SYSTEM::regs()
3940 .perip_clk_en0()
3941 .modify(|_, w| w.uhci1_clk_en().bit(enable));
3942 }
3943 Peripheral::UsbFs => {
3944 crate::peripherals::SYSTEM::regs()
3945 .perip_clk_en0()
3946 .modify(|_, w| w.usb_clk_en().bit(enable));
3947 }
3948 Peripheral::Wdg => {
3949 crate::peripherals::SYSTEM::regs()
3950 .perip_clk_en0()
3951 .modify(|_, w| w.wdg_clk_en().bit(enable));
3952 }
3953 }
3954 }
3955 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
3956 match peripheral {
3957 Peripheral::Aes => {
3958 crate::peripherals::SYSTEM::regs()
3959 .perip_rst_en1()
3960 .modify(|_, w| w.crypto_aes_rst().bit(reset));
3961 }
3962 Peripheral::ApbSarAdc => {
3963 crate::peripherals::SYSTEM::regs()
3964 .perip_rst_en0()
3965 .modify(|_, w| w.apb_saradc_rst().bit(reset));
3966 }
3967 Peripheral::CopyDma => {
3968 crate::peripherals::DMA_COPY::regs().conf().modify(|_, w| {
3969 w.in_rst()
3970 .bit(reset)
3971 .out_rst()
3972 .bit(reset)
3973 .cmdfifo_rst()
3974 .bit(reset)
3975 .fifo_rst()
3976 .bit(reset)
3977 });
3978 }
3979 Peripheral::CryptoDma => {
3980 crate::peripherals::SYSTEM::regs()
3981 .perip_rst_en1()
3982 .modify(|_, w| w.crypto_dma_rst().bit(reset));
3983 }
3984 Peripheral::DedicatedGpio => {
3985 crate::peripherals::SYSTEM::regs()
3986 .cpu_peri_rst_en()
3987 .modify(|_, w| w.dedicated_gpio_rst().bit(reset));
3988 }
3989 Peripheral::Ds => {
3990 crate::peripherals::SYSTEM::regs()
3991 .perip_rst_en1()
3992 .modify(|_, w| w.crypto_ds_rst().bit(reset));
3993 }
3994 Peripheral::GpioSd => {
3995 let _ = reset;
3996 }
3997 Peripheral::Hmac => {
3998 crate::peripherals::SYSTEM::regs()
3999 .perip_rst_en1()
4000 .modify(|_, w| w.crypto_hmac_rst().bit(reset));
4001 }
4002 Peripheral::I2cExt0 => {
4003 crate::peripherals::SYSTEM::regs()
4004 .perip_rst_en0()
4005 .modify(|_, w| w.i2c_ext0_rst().bit(reset));
4006 }
4007 Peripheral::I2cExt1 => {
4008 crate::peripherals::SYSTEM::regs()
4009 .perip_rst_en0()
4010 .modify(|_, w| w.i2c_ext1_rst().bit(reset));
4011 }
4012 Peripheral::I2s0 => {
4013 crate::peripherals::SYSTEM::regs()
4014 .perip_rst_en0()
4015 .modify(|_, w| w.i2s0_rst().bit(reset));
4016 }
4017 Peripheral::Ledc => {
4018 crate::peripherals::SYSTEM::regs()
4019 .perip_rst_en0()
4020 .modify(|_, w| w.ledc_rst().bit(reset));
4021 }
4022 Peripheral::Mcpwm0 => {
4023 crate::peripherals::SYSTEM::regs()
4024 .perip_rst_en0()
4025 .modify(|_, w| w.pwm0_rst().bit(reset));
4026 }
4027 Peripheral::Mcpwm1 => {
4028 crate::peripherals::SYSTEM::regs()
4029 .perip_rst_en0()
4030 .modify(|_, w| w.pwm1_rst().bit(reset));
4031 }
4032 Peripheral::Pcnt => {
4033 crate::peripherals::SYSTEM::regs()
4034 .perip_rst_en0()
4035 .modify(|_, w| w.pcnt_rst().bit(reset));
4036 }
4037 Peripheral::Rmt => {
4038 crate::peripherals::SYSTEM::regs()
4039 .perip_rst_en0()
4040 .modify(|_, w| w.rmt_rst().bit(reset));
4041 }
4042 Peripheral::Rsa => {
4043 crate::peripherals::SYSTEM::regs()
4044 .perip_rst_en1()
4045 .modify(|_, w| w.crypto_rsa_rst().bit(reset));
4046 }
4047 Peripheral::Sha => {
4048 crate::peripherals::SYSTEM::regs()
4049 .perip_rst_en1()
4050 .modify(|_, w| w.crypto_sha_rst().bit(reset));
4051 }
4052 Peripheral::Spi2 => {
4053 crate::peripherals::SYSTEM::regs()
4054 .perip_rst_en0()
4055 .modify(|_, w| w.spi2_rst().bit(reset));
4056 }
4057 Peripheral::Spi2Dma => {
4058 crate::peripherals::SYSTEM::regs()
4059 .perip_rst_en0()
4060 .modify(|_, w| w.spi2_dma_rst().bit(reset));
4061 }
4062 Peripheral::Spi3 => {
4063 crate::peripherals::SYSTEM::regs()
4064 .perip_rst_en0()
4065 .modify(|_, w| w.spi3_rst().bit(reset));
4066 }
4067 Peripheral::Spi3Dma => {
4068 crate::peripherals::SYSTEM::regs()
4069 .perip_rst_en0()
4070 .modify(|_, w| w.spi3_dma_rst().bit(reset));
4071 }
4072 Peripheral::Systimer => {
4073 crate::peripherals::SYSTEM::regs()
4074 .perip_rst_en0()
4075 .modify(|_, w| w.systimer_rst().bit(reset));
4076 }
4077 Peripheral::Timg0 => {
4078 crate::peripherals::SYSTEM::regs()
4079 .perip_rst_en0()
4080 .modify(|_, w| w.timergroup_rst().bit(reset));
4081 }
4082 Peripheral::Timg1 => {
4083 crate::peripherals::SYSTEM::regs()
4084 .perip_rst_en0()
4085 .modify(|_, w| w.timergroup1_rst().bit(reset));
4086 }
4087 Peripheral::Twai0 => {
4088 crate::peripherals::SYSTEM::regs()
4089 .perip_rst_en0()
4090 .modify(|_, w| w.twai_rst().bit(reset));
4091 }
4092 Peripheral::Uart0 => {
4093 crate::peripherals::SYSTEM::regs()
4094 .perip_rst_en0()
4095 .modify(|_, w| w.uart_rst().bit(reset));
4096 }
4097 Peripheral::Uart1 => {
4098 crate::peripherals::SYSTEM::regs()
4099 .perip_rst_en0()
4100 .modify(|_, w| w.uart1_rst().bit(reset));
4101 }
4102 Peripheral::UartMem => {
4103 crate::peripherals::SYSTEM::regs()
4104 .perip_rst_en0()
4105 .modify(|_, w| w.uart_mem_rst().bit(reset));
4106 }
4107 Peripheral::Uhci0 => {
4108 crate::peripherals::SYSTEM::regs()
4109 .perip_rst_en0()
4110 .modify(|_, w| w.uhci0_rst().bit(reset));
4111 }
4112 Peripheral::Uhci1 => {
4113 crate::peripherals::SYSTEM::regs()
4114 .perip_rst_en0()
4115 .modify(|_, w| w.uhci1_rst().bit(reset));
4116 }
4117 Peripheral::UsbFs => {
4118 crate::peripherals::SYSTEM::regs()
4119 .perip_rst_en0()
4120 .modify(|_, w| w.usb_rst().bit(reset));
4121 }
4122 Peripheral::Wdg => {
4123 crate::peripherals::SYSTEM::regs()
4124 .perip_rst_en0()
4125 .modify(|_, w| w.wdg_rst().bit(reset));
4126 }
4127 }
4128 }
4129 };
4130}
4131#[macro_export]
4139#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4140macro_rules! memory_range {
4141 ("DRAM") => {
4142 0x3FFB0000..0x40000000
4143 };
4144 (size as str, "DRAM") => {
4145 "327680"
4146 };
4147 ("DRAM2_UNINIT") => {
4148 0x3FFDE000..0x40000000
4149 };
4150 (size as str, "DRAM2_UNINIT") => {
4151 "139264"
4152 };
4153 ("IROM") => {
4154 0x40080000..0x40800000
4155 };
4156 (size as str, "IROM") => {
4157 "7864320"
4158 };
4159 ("DROM") => {
4160 0x3F000000..0x3F400000
4161 };
4162 (size as str, "DROM") => {
4163 "4194304"
4164 };
4165}
4166#[macro_export]
4183#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4184macro_rules! for_each_i2c_master {
4185 ($($pattern:tt => $code:tt;)*) => {
4186 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4187 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4188 I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
4189 I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4190 I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
4191 };
4192}
4193#[macro_export]
4220#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4221macro_rules! for_each_i2s {
4222 ($($pattern:tt => $code:tt;)*) => {
4223 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4224 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, CLK_I2S,
4225 I2S0O_BCK, I2S0O_WS, I2S0I_BCK, I2S0I_WS, [I2S0O_DATA_OUT23], [I2S0I_DATA_IN15],
4226 false, false, false, false)); _for_each_inner_i2s!((names(I2S0)));
4227 _for_each_inner_i2s!((all(I2S0, I2s0, CLK_I2S, I2S0O_BCK, I2S0O_WS, I2S0I_BCK,
4228 I2S0I_WS, [I2S0O_DATA_OUT23], [I2S0I_DATA_IN15], false, false, false, false)));
4229 };
4230}
4231#[macro_export]
4250#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4251macro_rules! for_each_uart {
4252 ($($pattern:tt => $code:tt;)*) => {
4253 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4254 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4255 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4256 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4257 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4258 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4259 };
4260}
4261#[macro_export]
4283#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4284macro_rules! for_each_spi_master {
4285 ($($pattern:tt => $code:tt;)*) => {
4286 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4287 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI3));
4288 _for_each_inner_spi_master!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4289 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD, FSPIIO4, FSPIIO5,
4290 FSPIIO6, FSPIIO7], true)); _for_each_inner_spi_master!((SPI3, Spi3,
4291 SPI3_CLK[SPI3_CS0, SPI3_CS1, SPI3_CS2] [SPI3_D, SPI3_Q]));
4292 _for_each_inner_spi_master!((names(SPI2), (SPI3)));
4293 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4294 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD, FSPIIO4, FSPIIO5,
4295 FSPIIO6, FSPIIO7], true), (SPI3, Spi3, SPI3_CLK[SPI3_CS0, SPI3_CS1, SPI3_CS2]
4296 [SPI3_D, SPI3_Q])));
4297 };
4298}
4299#[macro_export]
4316#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4317macro_rules! for_each_spi_slave {
4318 ($($pattern:tt => $code:tt;)*) => {
4319 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4320 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI3));
4321 _for_each_inner_spi_slave!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4322 _for_each_inner_spi_slave!((SPI3, Spi3, SPI3_CLK, SPI3_D, SPI3_Q, SPI3_CS0));
4323 _for_each_inner_spi_slave!((names(SPI2), (SPI3)));
4324 _for_each_inner_spi_slave!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0),
4325 (SPI3, Spi3, SPI3_CLK, SPI3_D, SPI3_Q, SPI3_CS0)));
4326 };
4327}
4328#[macro_export]
4329#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4330macro_rules! for_each_peripheral {
4331 ($($pattern:tt => $code:tt;)*) => {
4332 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4333 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4334 "GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4335 "<section class=\"warning\">"] #[doc =
4336 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4337 #[doc = "<ul>"] #[doc =
4338 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4339 = "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()));
4340 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4341 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4342 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
4343 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
4344 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4345 "GPIO4 peripheral singleton"] GPIO4 <= virtual()));
4346 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO5 peripheral singleton"]
4347 GPIO5 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4348 "GPIO6 peripheral singleton"] GPIO6 <= virtual()));
4349 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO7 peripheral singleton"]
4350 GPIO7 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4351 "GPIO8 peripheral singleton"] GPIO8 <= virtual()));
4352 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO9 peripheral singleton"]
4353 GPIO9 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4354 "GPIO10 peripheral singleton"] GPIO10 <= virtual()));
4355 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO11 peripheral singleton"]
4356 GPIO11 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4357 "GPIO12 peripheral singleton"] GPIO12 <= virtual()));
4358 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO13 peripheral singleton"]
4359 GPIO13 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4360 "GPIO14 peripheral singleton"] GPIO14 <= virtual()));
4361 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO15 peripheral singleton"]
4362 GPIO15 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4363 "GPIO16 peripheral singleton"] GPIO16 <= virtual()));
4364 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO17 peripheral singleton"]
4365 GPIO17 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4366 "GPIO18 peripheral singleton"] GPIO18 <= virtual()));
4367 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO19 peripheral singleton"]
4368 GPIO19 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4369 "GPIO20 peripheral singleton"] GPIO20 <= virtual()));
4370 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO21 peripheral singleton"]
4371 GPIO21 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4372 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4373 "<section class=\"warning\">"] #[doc =
4374 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4375 #[doc = "<ul>"] #[doc =
4376 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4377 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()));
4378 _for_each_inner_peripheral!((@ peri_type #[doc =
4379 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4380 "<section class=\"warning\">"] #[doc =
4381 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4382 #[doc = "<ul>"] #[doc =
4383 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4384 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4385 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()));
4386 _for_each_inner_peripheral!((@ peri_type #[doc =
4387 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4388 "<section class=\"warning\">"] #[doc =
4389 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4390 #[doc = "<ul>"] #[doc =
4391 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4392 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4393 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
4394 _for_each_inner_peripheral!((@ peri_type #[doc =
4395 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4396 "<section class=\"warning\">"] #[doc =
4397 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4398 #[doc = "<ul>"] #[doc =
4399 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4400 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()));
4401 _for_each_inner_peripheral!((@ peri_type #[doc =
4402 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4403 "<section class=\"warning\">"] #[doc =
4404 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4405 #[doc = "<ul>"] #[doc =
4406 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4407 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4408 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()));
4409 _for_each_inner_peripheral!((@ peri_type #[doc =
4410 "GPIO31 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4411 "<section class=\"warning\">"] #[doc =
4412 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4413 #[doc = "<ul>"] #[doc =
4414 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4415 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4416 "</ul>"] #[doc = "</section>"] GPIO31 <= virtual()));
4417 _for_each_inner_peripheral!((@ peri_type #[doc =
4418 "GPIO32 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4419 "<section class=\"warning\">"] #[doc =
4420 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4421 #[doc = "<ul>"] #[doc =
4422 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4423 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4424 "</ul>"] #[doc = "</section>"] GPIO32 <= virtual()));
4425 _for_each_inner_peripheral!((@ peri_type #[doc =
4426 "GPIO33 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4427 "<section class=\"warning\">"] #[doc =
4428 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4429 #[doc = "<ul>"] #[doc =
4430 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4431 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4432 #[doc = "</ul>"] #[doc = "</section>"] GPIO33 <= virtual()));
4433 _for_each_inner_peripheral!((@ peri_type #[doc =
4434 "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4435 "<section class=\"warning\">"] #[doc =
4436 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4437 #[doc = "<ul>"] #[doc =
4438 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4439 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4440 #[doc = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()));
4441 _for_each_inner_peripheral!((@ peri_type #[doc =
4442 "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4443 "<section class=\"warning\">"] #[doc =
4444 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4445 #[doc = "<ul>"] #[doc =
4446 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4447 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4448 #[doc = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()));
4449 _for_each_inner_peripheral!((@ peri_type #[doc =
4450 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4451 "<section class=\"warning\">"] #[doc =
4452 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4453 #[doc = "<ul>"] #[doc =
4454 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4455 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4456 #[doc = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()));
4457 _for_each_inner_peripheral!((@ peri_type #[doc =
4458 "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4459 "<section class=\"warning\">"] #[doc =
4460 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4461 #[doc = "<ul>"] #[doc =
4462 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4463 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4464 #[doc = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()));
4465 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO38 peripheral singleton"]
4466 GPIO38 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4467 "GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4468 "<section class=\"warning\">"] #[doc =
4469 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4470 #[doc = "<ul>"] #[doc =
4471 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4472 #[doc = "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()));
4473 _for_each_inner_peripheral!((@ peri_type #[doc =
4474 "GPIO40 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4475 "<section class=\"warning\">"] #[doc =
4476 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4477 #[doc = "<ul>"] #[doc =
4478 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4479 #[doc = "</ul>"] #[doc = "</section>"] GPIO40 <= virtual()));
4480 _for_each_inner_peripheral!((@ peri_type #[doc =
4481 "GPIO41 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4482 "<section class=\"warning\">"] #[doc =
4483 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4484 #[doc = "<ul>"] #[doc =
4485 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4486 #[doc = "</ul>"] #[doc = "</section>"] GPIO41 <= virtual()));
4487 _for_each_inner_peripheral!((@ peri_type #[doc =
4488 "GPIO42 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4489 "<section class=\"warning\">"] #[doc =
4490 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4491 #[doc = "<ul>"] #[doc =
4492 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4493 #[doc = "</ul>"] #[doc = "</section>"] GPIO42 <= virtual()));
4494 _for_each_inner_peripheral!((@ peri_type #[doc =
4495 "GPIO43 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4496 "<section class=\"warning\">"] #[doc =
4497 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4498 #[doc = "<ul>"] #[doc =
4499 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4500 = "</ul>"] #[doc = "</section>"] GPIO43 <= virtual()));
4501 _for_each_inner_peripheral!((@ peri_type #[doc =
4502 "GPIO44 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4503 "<section class=\"warning\">"] #[doc =
4504 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4505 #[doc = "<ul>"] #[doc =
4506 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4507 = "</ul>"] #[doc = "</section>"] GPIO44 <= virtual()));
4508 _for_each_inner_peripheral!((@ peri_type #[doc =
4509 "GPIO45 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4510 "<section class=\"warning\">"] #[doc =
4511 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4512 #[doc = "<ul>"] #[doc =
4513 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4514 = "</ul>"] #[doc = "</section>"] GPIO45 <= virtual()));
4515 _for_each_inner_peripheral!((@ peri_type #[doc =
4516 "GPIO46 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4517 "<section class=\"warning\">"] #[doc =
4518 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4519 #[doc = "<ul>"] #[doc =
4520 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4521 = "</ul>"] #[doc = "</section>"] GPIO46 <= virtual()));
4522 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_SPI2 peripheral singleton"]
4523 DMA_SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt,
4524 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4525 #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3(SPI3_DMA : {
4526 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4527 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_I2S0 peripheral singleton"]
4528 DMA_I2S0 <= I2S0(I2S0 : { bind_dma_interrupt, enable_dma_interrupt,
4529 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4530 #[doc = "DMA_CRYPTO peripheral singleton"] DMA_CRYPTO <= CRYPTO_DMA(CRYPTO_DMA :
4531 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt })
4532 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4533 "DMA_COPY peripheral singleton"] DMA_COPY <= COPY_DMA(DMA_COPY : {
4534 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4535 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
4536 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4537 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
4538 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
4539 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4540 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
4541 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH4 peripheral singleton"]
4542 SDM_CH4 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4543 = "SDM_CH5 peripheral singleton"] SDM_CH5 <= virtual() (unstable)));
4544 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH6 peripheral singleton"]
4545 SDM_CH6 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4546 = "SDM_CH7 peripheral singleton"] SDM_CH7 <= virtual() (unstable)));
4547 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
4548 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4549 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4550 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
4551 _for_each_inner_peripheral!((@ peri_type #[doc = "DS peripheral singleton"] DS <=
4552 DS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4553 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
4554 _for_each_inner_peripheral!((@ peri_type #[doc = "EXTMEM peripheral singleton"]
4555 EXTMEM <= EXTMEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4556 "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)));
4557 _for_each_inner_peripheral!((@ peri_type #[doc = "FE peripheral singleton"] FE <=
4558 FE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4559 "FE2 peripheral singleton"] FE2 <= FE2() (unstable)));
4560 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
4561 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4562 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
4563 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
4564 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4565 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4566 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4567 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4568 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4569 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
4570 enable_peri_interrupt, disable_peri_interrupt })));
4571 _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
4572 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
4573 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4574 #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
4575 INTERRUPT_CORE0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4576 "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)));
4577 _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
4578 LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4579 "NRX peripheral singleton"] NRX <= NRX() (unstable)));
4580 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
4581 PCNT <= PCNT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4582 "PMS peripheral singleton"] PMS <= PMS() (unstable)));
4583 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
4584 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4585 "RNG peripheral singleton"] RNG <= RNG() (unstable)));
4586 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
4587 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4588 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4589 "LPWR peripheral singleton"] LPWR <= RTC_CNTL() (unstable)));
4590 _for_each_inner_peripheral!((@ peri_type #[doc =
4591 "RTC_TIMER peripheral singleton"] RTC_TIMER <= RTC_CNTL() (unstable)));
4592 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
4593 LP_I2C0 <= RTC_I2C() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4594 = "RTC_IO peripheral singleton"] RTC_IO <= RTC_IO() (unstable)));
4595 _for_each_inner_peripheral!((@ peri_type #[doc = "SENS peripheral singleton"]
4596 SENS <= SENS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4597 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4598 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4599 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
4600 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4601 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
4602 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
4603 SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt,
4604 disable_dma_interrupt }, SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
4605 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4606 "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : { bind_dma_interrupt,
4607 enable_dma_interrupt, disable_dma_interrupt }, SPI3 : { bind_peri_interrupt,
4608 enable_peri_interrupt, disable_peri_interrupt })));
4609 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSCON peripheral singleton"]
4610 SYSCON <= SYSCON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4611 "SYSTEM peripheral singleton"] SYSTEM <= SYSTEM() (unstable)));
4612 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
4613 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
4614 #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
4615 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
4616 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4617 "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)));
4618 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
4619 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
4620 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4621 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
4622 enable_peri_interrupt, disable_peri_interrupt })));
4623 _for_each_inner_peripheral!((@ peri_type #[doc = "UHCI0 peripheral singleton"]
4624 UHCI0 <= UHCI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4625 "USB_FS peripheral singleton"] USB_FS <= USB_FS(USB : { bind_peri_interrupt,
4626 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4627 _for_each_inner_peripheral!((@ peri_type #[doc = "USB_WRAP peripheral singleton"]
4628 USB_WRAP <= USB_WRAP() (unstable))); _for_each_inner_peripheral!((@ peri_type
4629 #[doc = "XTS_AES peripheral singleton"] XTS_AES <= XTS_AES() (unstable)));
4630 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
4631 WIFI <= WIFI(WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
4632 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
4633 disable_pwr_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4634 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
4635 _for_each_inner_peripheral!((@ peri_type #[doc = "ADC2 peripheral singleton"]
4636 ADC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4637 "DAC1 peripheral singleton"] DAC1 <= virtual() (unstable)));
4638 _for_each_inner_peripheral!((@ peri_type #[doc = "DAC2 peripheral singleton"]
4639 DAC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4640 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
4641 _for_each_inner_peripheral!((@ peri_type #[doc =
4642 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4643 _for_each_inner_peripheral!((@ peri_type #[doc = "PSRAM peripheral singleton"]
4644 PSRAM <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4645 "ULP_RISCV_CORE peripheral singleton"] ULP_RISCV_CORE <= virtual() (unstable)));
4646 _for_each_inner_peripheral!((@ peri_type #[doc =
4647 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
4648 _for_each_inner_peripheral!((@ peri_type #[doc =
4649 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4650 _for_each_inner_peripheral!((@ peri_type #[doc =
4651 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4652 _for_each_inner_peripheral!((@ peri_type #[doc =
4653 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4654 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
4655 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4656 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4657 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4658 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4659 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4660 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4661 _for_each_inner_peripheral!((GPIO14));
4662 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO15));
4663 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO16));
4664 _for_each_inner_peripheral!((GPIO17)); _for_each_inner_peripheral!((GPIO18));
4665 _for_each_inner_peripheral!((GPIO19)); _for_each_inner_peripheral!((GPIO20));
4666 _for_each_inner_peripheral!((GPIO21)); _for_each_inner_peripheral!((GPIO26));
4667 _for_each_inner_peripheral!((GPIO27)); _for_each_inner_peripheral!((GPIO28));
4668 _for_each_inner_peripheral!((GPIO29)); _for_each_inner_peripheral!((GPIO30));
4669 _for_each_inner_peripheral!((GPIO31)); _for_each_inner_peripheral!((GPIO32));
4670 _for_each_inner_peripheral!((GPIO33)); _for_each_inner_peripheral!((GPIO34));
4671 _for_each_inner_peripheral!((GPIO35)); _for_each_inner_peripheral!((GPIO36));
4672 _for_each_inner_peripheral!((GPIO37)); _for_each_inner_peripheral!((GPIO38));
4673 _for_each_inner_peripheral!((GPIO39)); _for_each_inner_peripheral!((GPIO40));
4674 _for_each_inner_peripheral!((GPIO41)); _for_each_inner_peripheral!((GPIO42));
4675 _for_each_inner_peripheral!((GPIO43)); _for_each_inner_peripheral!((GPIO44));
4676 _for_each_inner_peripheral!((GPIO45)); _for_each_inner_peripheral!((GPIO46));
4677 _for_each_inner_peripheral!((DMA_SPI2(unstable)));
4678 _for_each_inner_peripheral!((DMA_SPI3(unstable)));
4679 _for_each_inner_peripheral!((DMA_I2S0(unstable)));
4680 _for_each_inner_peripheral!((DMA_CRYPTO(unstable)));
4681 _for_each_inner_peripheral!((DMA_COPY(unstable)));
4682 _for_each_inner_peripheral!((SDM_CH0(unstable)));
4683 _for_each_inner_peripheral!((SDM_CH1(unstable)));
4684 _for_each_inner_peripheral!((SDM_CH2(unstable)));
4685 _for_each_inner_peripheral!((SDM_CH3(unstable)));
4686 _for_each_inner_peripheral!((SDM_CH4(unstable)));
4687 _for_each_inner_peripheral!((SDM_CH5(unstable)));
4688 _for_each_inner_peripheral!((SDM_CH6(unstable)));
4689 _for_each_inner_peripheral!((SDM_CH7(unstable)));
4690 _for_each_inner_peripheral!((AES(unstable)));
4691 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4692 _for_each_inner_peripheral!((DS(unstable)));
4693 _for_each_inner_peripheral!((EXTMEM(unstable)));
4694 _for_each_inner_peripheral!((FE(unstable)));
4695 _for_each_inner_peripheral!((FE2(unstable)));
4696 _for_each_inner_peripheral!((GPIO(unstable)));
4697 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4698 _for_each_inner_peripheral!((HMAC(unstable)));
4699 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4700 _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
4701 _for_each_inner_peripheral!((I2S0(unstable)));
4702 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4703 _for_each_inner_peripheral!((IO_MUX(unstable)));
4704 _for_each_inner_peripheral!((LEDC(unstable)));
4705 _for_each_inner_peripheral!((NRX(unstable)));
4706 _for_each_inner_peripheral!((PCNT(unstable)));
4707 _for_each_inner_peripheral!((PMS(unstable)));
4708 _for_each_inner_peripheral!((RMT(unstable)));
4709 _for_each_inner_peripheral!((RNG(unstable)));
4710 _for_each_inner_peripheral!((RSA(unstable)));
4711 _for_each_inner_peripheral!((LPWR(unstable)));
4712 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4713 _for_each_inner_peripheral!((LP_I2C0(unstable)));
4714 _for_each_inner_peripheral!((RTC_IO(unstable)));
4715 _for_each_inner_peripheral!((SENS(unstable)));
4716 _for_each_inner_peripheral!((SHA(unstable)));
4717 _for_each_inner_peripheral!((SPI0(unstable)));
4718 _for_each_inner_peripheral!((SPI1(unstable)));
4719 _for_each_inner_peripheral!((SPI2)); _for_each_inner_peripheral!((SPI3));
4720 _for_each_inner_peripheral!((SYSCON(unstable)));
4721 _for_each_inner_peripheral!((SYSTEM(unstable)));
4722 _for_each_inner_peripheral!((SYSTIMER(unstable)));
4723 _for_each_inner_peripheral!((TIMG0(unstable)));
4724 _for_each_inner_peripheral!((TIMG1(unstable)));
4725 _for_each_inner_peripheral!((TWAI0(unstable)));
4726 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
4727 _for_each_inner_peripheral!((UHCI0(unstable)));
4728 _for_each_inner_peripheral!((USB_FS(unstable)));
4729 _for_each_inner_peripheral!((XTS_AES(unstable)));
4730 _for_each_inner_peripheral!((WIFI));
4731 _for_each_inner_peripheral!((ADC1(unstable)));
4732 _for_each_inner_peripheral!((ADC2(unstable)));
4733 _for_each_inner_peripheral!((DAC1(unstable)));
4734 _for_each_inner_peripheral!((DAC2(unstable)));
4735 _for_each_inner_peripheral!((FLASH(unstable)));
4736 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
4737 _for_each_inner_peripheral!((PSRAM(unstable)));
4738 _for_each_inner_peripheral!((ULP_RISCV_CORE(unstable)));
4739 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
4740 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
4741 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
4742 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
4743 _for_each_inner_peripheral!((SPI2, Spi2, 0, SpiDmaChannel));
4744 _for_each_inner_peripheral!((I2S0, I2s0, 0, I2sDmaChannel));
4745 _for_each_inner_peripheral!((AES, Aes, 0, CryptoDmaChannel));
4746 _for_each_inner_peripheral!((SPI3, Spi3, 1, SpiDmaChannel));
4747 _for_each_inner_peripheral!((SHA, Sha, 1, CryptoDmaChannel));
4748 _for_each_inner_peripheral!((all(@ peri_type #[doc =
4749 "GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4750 "<section class=\"warning\">"] #[doc =
4751 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4752 #[doc = "<ul>"] #[doc =
4753 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4754 = "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()), (@ peri_type #[doc =
4755 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
4756 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
4757 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
4758 "GPIO4 peripheral singleton"] GPIO4 <= virtual()), (@ peri_type #[doc =
4759 "GPIO5 peripheral singleton"] GPIO5 <= virtual()), (@ peri_type #[doc =
4760 "GPIO6 peripheral singleton"] GPIO6 <= virtual()), (@ peri_type #[doc =
4761 "GPIO7 peripheral singleton"] GPIO7 <= virtual()), (@ peri_type #[doc =
4762 "GPIO8 peripheral singleton"] GPIO8 <= virtual()), (@ peri_type #[doc =
4763 "GPIO9 peripheral singleton"] GPIO9 <= virtual()), (@ peri_type #[doc =
4764 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
4765 "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
4766 "GPIO12 peripheral singleton"] GPIO12 <= virtual()), (@ peri_type #[doc =
4767 "GPIO13 peripheral singleton"] GPIO13 <= virtual()), (@ peri_type #[doc =
4768 "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
4769 "GPIO15 peripheral singleton"] GPIO15 <= virtual()), (@ peri_type #[doc =
4770 "GPIO16 peripheral singleton"] GPIO16 <= virtual()), (@ peri_type #[doc =
4771 "GPIO17 peripheral singleton"] GPIO17 <= virtual()), (@ peri_type #[doc =
4772 "GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
4773 "GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
4774 "GPIO20 peripheral singleton"] GPIO20 <= virtual()), (@ peri_type #[doc =
4775 "GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
4776 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4777 "<section class=\"warning\">"] #[doc =
4778 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4779 #[doc = "<ul>"] #[doc =
4780 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4781 "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
4782 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4783 "<section class=\"warning\">"] #[doc =
4784 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4785 #[doc = "<ul>"] #[doc =
4786 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4787 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4788 "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
4789 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4790 "<section class=\"warning\">"] #[doc =
4791 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4792 #[doc = "<ul>"] #[doc =
4793 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4794 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4795 "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
4796 "GPIO29 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4797 "<section class=\"warning\">"] #[doc =
4798 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4799 #[doc = "<ul>"] #[doc =
4800 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4801 "</ul>"] #[doc = "</section>"] GPIO29 <= virtual()), (@ peri_type #[doc =
4802 "GPIO30 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4803 "<section class=\"warning\">"] #[doc =
4804 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4805 #[doc = "<ul>"] #[doc =
4806 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4807 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4808 "</ul>"] #[doc = "</section>"] GPIO30 <= virtual()), (@ peri_type #[doc =
4809 "GPIO31 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4810 "<section class=\"warning\">"] #[doc =
4811 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4812 #[doc = "<ul>"] #[doc =
4813 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4814 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4815 "</ul>"] #[doc = "</section>"] GPIO31 <= virtual()), (@ peri_type #[doc =
4816 "GPIO32 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4817 "<section class=\"warning\">"] #[doc =
4818 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4819 #[doc = "<ul>"] #[doc =
4820 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4821 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4822 "</ul>"] #[doc = "</section>"] GPIO32 <= virtual()), (@ peri_type #[doc =
4823 "GPIO33 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4824 "<section class=\"warning\">"] #[doc =
4825 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4826 #[doc = "<ul>"] #[doc =
4827 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4828 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4829 #[doc = "</ul>"] #[doc = "</section>"] GPIO33 <= virtual()), (@ peri_type #[doc =
4830 "GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4831 "<section class=\"warning\">"] #[doc =
4832 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4833 #[doc = "<ul>"] #[doc =
4834 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4835 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4836 #[doc = "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()), (@ peri_type #[doc =
4837 "GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4838 "<section class=\"warning\">"] #[doc =
4839 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4840 #[doc = "<ul>"] #[doc =
4841 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4842 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4843 #[doc = "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()), (@ peri_type #[doc =
4844 "GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4845 "<section class=\"warning\">"] #[doc =
4846 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4847 #[doc = "<ul>"] #[doc =
4848 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4849 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4850 #[doc = "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()), (@ peri_type #[doc =
4851 "GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4852 "<section class=\"warning\">"] #[doc =
4853 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4854 #[doc = "<ul>"] #[doc =
4855 "<li>This pin may be reserved for interfacing with Octal SPI flash.</li>"] #[doc
4856 = "<li>This pin may be reserved for interfacing with Octal SPI PSRAM.</li>"]
4857 #[doc = "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()), (@ peri_type #[doc =
4858 "GPIO38 peripheral singleton"] GPIO38 <= virtual()), (@ peri_type #[doc =
4859 "GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4860 "<section class=\"warning\">"] #[doc =
4861 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4862 #[doc = "<ul>"] #[doc =
4863 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4864 #[doc = "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()), (@ peri_type #[doc =
4865 "GPIO40 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4866 "<section class=\"warning\">"] #[doc =
4867 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4868 #[doc = "<ul>"] #[doc =
4869 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4870 #[doc = "</ul>"] #[doc = "</section>"] GPIO40 <= virtual()), (@ peri_type #[doc =
4871 "GPIO41 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>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4876 #[doc = "</ul>"] #[doc = "</section>"] GPIO41 <= virtual()), (@ peri_type #[doc =
4877 "GPIO42 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4878 "<section class=\"warning\">"] #[doc =
4879 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4880 #[doc = "<ul>"] #[doc =
4881 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4882 #[doc = "</ul>"] #[doc = "</section>"] GPIO42 <= virtual()), (@ peri_type #[doc =
4883 "GPIO43 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4884 "<section class=\"warning\">"] #[doc =
4885 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4886 #[doc = "<ul>"] #[doc =
4887 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4888 = "</ul>"] #[doc = "</section>"] GPIO43 <= virtual()), (@ peri_type #[doc =
4889 "GPIO44 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4890 "<section class=\"warning\">"] #[doc =
4891 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4892 #[doc = "<ul>"] #[doc =
4893 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4894 = "</ul>"] #[doc = "</section>"] GPIO44 <= virtual()), (@ peri_type #[doc =
4895 "GPIO45 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 is a strapping pin, it determines how the chip boots.</li>"] #[doc
4900 = "</ul>"] #[doc = "</section>"] GPIO45 <= virtual()), (@ peri_type #[doc =
4901 "GPIO46 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4902 "<section class=\"warning\">"] #[doc =
4903 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4904 #[doc = "<ul>"] #[doc =
4905 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4906 = "</ul>"] #[doc = "</section>"] GPIO46 <= virtual()), (@ peri_type #[doc =
4907 "DMA_SPI2 peripheral singleton"] DMA_SPI2 <= SPI2(SPI2_DMA : {
4908 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4909 (@ peri_type #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3(SPI3_DMA :
4910 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4911 (@ peri_type #[doc = "DMA_I2S0 peripheral singleton"] DMA_I2S0 <= I2S0(I2S0 : {
4912 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4913 (@ peri_type #[doc = "DMA_CRYPTO peripheral singleton"] DMA_CRYPTO <=
4914 CRYPTO_DMA(CRYPTO_DMA : { bind_dma_interrupt, enable_dma_interrupt,
4915 disable_dma_interrupt }) (unstable)), (@ peri_type #[doc =
4916 "DMA_COPY peripheral singleton"] DMA_COPY <= COPY_DMA(DMA_COPY : {
4917 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4918 (@ peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
4919 (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
4920 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
4921 SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
4922 "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
4923 #[doc = "SDM_CH4 peripheral singleton"] SDM_CH4 <= virtual() (unstable)), (@
4924 peri_type #[doc = "SDM_CH5 peripheral singleton"] SDM_CH5 <= virtual()
4925 (unstable)), (@ peri_type #[doc = "SDM_CH6 peripheral singleton"] SDM_CH6 <=
4926 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH7 peripheral singleton"]
4927 SDM_CH7 <= virtual() (unstable)), (@ peri_type #[doc =
4928 "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
4929 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4930 = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
4931 peri_type #[doc = "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type
4932 #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type
4933 #[doc = "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)), (@
4934 peri_type #[doc = "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE()
4935 (unstable)), (@ peri_type #[doc = "FE peripheral singleton"] FE <= FE()
4936 (unstable)), (@ peri_type #[doc = "FE2 peripheral singleton"] FE2 <= FE2()
4937 (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO()
4938 (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"] GPIO_SD <=
4939 GPIO_SD() (unstable)), (@ peri_type #[doc = "HMAC peripheral singleton"] HMAC <=
4940 HMAC() (unstable)), (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"]
4941 I2C_ANA_MST <= I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
4942 "I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
4943 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
4944 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
4945 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
4946 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
4947 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4948 = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4949 (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX <=
4950 IO_MUX() (unstable)), (@ peri_type #[doc = "LEDC peripheral singleton"] LEDC <=
4951 LEDC() (unstable)), (@ peri_type #[doc = "NRX peripheral singleton"] NRX <= NRX()
4952 (unstable)), (@ peri_type #[doc = "PCNT peripheral singleton"] PCNT <= PCNT()
4953 (unstable)), (@ peri_type #[doc = "PMS peripheral singleton"] PMS <= PMS()
4954 (unstable)), (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT()
4955 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG()
4956 (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
4957 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4958 (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= RTC_CNTL()
4959 (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
4960 RTC_CNTL() (unstable)), (@ peri_type #[doc = "LP_I2C0 peripheral singleton"]
4961 LP_I2C0 <= RTC_I2C() (unstable)), (@ peri_type #[doc =
4962 "RTC_IO peripheral singleton"] RTC_IO <= RTC_IO() (unstable)), (@ peri_type #[doc
4963 = "SENS peripheral singleton"] SENS <= SENS() (unstable)), (@ peri_type #[doc =
4964 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4965 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4966 = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
4967 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
4968 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt,
4969 enable_dma_interrupt, disable_dma_interrupt }, SPI2 : { bind_peri_interrupt,
4970 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
4971 "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : { bind_dma_interrupt,
4972 enable_dma_interrupt, disable_dma_interrupt }, SPI3 : { bind_peri_interrupt,
4973 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
4974 "SYSCON peripheral singleton"] SYSCON <= SYSCON() (unstable)), (@ peri_type #[doc
4975 = "SYSTEM peripheral singleton"] SYSTEM <= SYSTEM() (unstable)), (@ peri_type
4976 #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@
4977 peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@
4978 peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@
4979 peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@
4980 peri_type #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
4981 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4982 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
4983 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4984 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
4985 peri_type #[doc = "USB_FS peripheral singleton"] USB_FS <= USB_FS(USB : {
4986 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4987 (unstable)), (@ peri_type #[doc = "USB_WRAP peripheral singleton"] USB_WRAP <=
4988 USB_WRAP() (unstable)), (@ peri_type #[doc = "XTS_AES peripheral singleton"]
4989 XTS_AES <= XTS_AES() (unstable)), (@ peri_type #[doc =
4990 "WIFI peripheral singleton"] WIFI <= WIFI(WIFI_MAC : { bind_mac_interrupt,
4991 enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
4992 enable_pwr_interrupt, disable_pwr_interrupt })), (@ peri_type #[doc =
4993 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type #[doc =
4994 "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)), (@ peri_type #[doc =
4995 "DAC1 peripheral singleton"] DAC1 <= virtual() (unstable)), (@ peri_type #[doc =
4996 "DAC2 peripheral singleton"] DAC2 <= virtual() (unstable)), (@ peri_type #[doc =
4997 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
4998 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
4999 (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual()
5000 (unstable)), (@ peri_type #[doc = "ULP_RISCV_CORE peripheral singleton"]
5001 ULP_RISCV_CORE <= virtual() (unstable)), (@ peri_type #[doc =
5002 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)),
5003 (@ peri_type #[doc = "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <=
5004 virtual() (unstable)), (@ peri_type #[doc =
5005 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)),
5006 (@ peri_type #[doc = "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <=
5007 virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1),
5008 (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
5009 (GPIO11), (GPIO12), (GPIO13), (GPIO14), (#[cfg(not(use_xtal32k))] GPIO15),
5010 (#[cfg(not(use_xtal32k))] GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20),
5011 (GPIO21), (GPIO26), (GPIO27), (GPIO28), (GPIO29), (GPIO30), (GPIO31), (GPIO32),
5012 (GPIO33), (GPIO34), (GPIO35), (GPIO36), (GPIO37), (GPIO38), (GPIO39), (GPIO40),
5013 (GPIO41), (GPIO42), (GPIO43), (GPIO44), (GPIO45), (GPIO46), (DMA_SPI2(unstable)),
5014 (DMA_SPI3(unstable)), (DMA_I2S0(unstable)), (DMA_CRYPTO(unstable)),
5015 (DMA_COPY(unstable)), (SDM_CH0(unstable)), (SDM_CH1(unstable)),
5016 (SDM_CH2(unstable)), (SDM_CH3(unstable)), (SDM_CH4(unstable)),
5017 (SDM_CH5(unstable)), (SDM_CH6(unstable)), (SDM_CH7(unstable)), (AES(unstable)),
5018 (APB_SARADC(unstable)), (DS(unstable)), (EXTMEM(unstable)), (FE(unstable)),
5019 (FE2(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)),
5020 (I2C_ANA_MST(unstable)), (I2C0), (I2C1), (I2S0(unstable)),
5021 (INTERRUPT_CORE0(unstable)), (IO_MUX(unstable)), (LEDC(unstable)),
5022 (NRX(unstable)), (PCNT(unstable)), (PMS(unstable)), (RMT(unstable)),
5023 (RNG(unstable)), (RSA(unstable)), (LPWR(unstable)), (RTC_TIMER(unstable)),
5024 (LP_I2C0(unstable)), (RTC_IO(unstable)), (SENS(unstable)), (SHA(unstable)),
5025 (SPI0(unstable)), (SPI1(unstable)), (SPI2), (SPI3), (SYSCON(unstable)),
5026 (SYSTEM(unstable)), (SYSTIMER(unstable)), (TIMG0(unstable)), (TIMG1(unstable)),
5027 (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)), (USB_FS(unstable)),
5028 (XTS_AES(unstable)), (WIFI), (ADC1(unstable)), (ADC2(unstable)),
5029 (DAC1(unstable)), (DAC2(unstable)), (FLASH(unstable)),
5030 (GPIO_DEDICATED(unstable)), (PSRAM(unstable)), (ULP_RISCV_CORE(unstable)),
5031 (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
5032 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
5033 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 0, SpiDmaChannel), (I2S0,
5034 I2s0, 0, I2sDmaChannel), (AES, Aes, 0, CryptoDmaChannel), (SPI3, Spi3, 1,
5035 SpiDmaChannel), (SHA, Sha, 1, CryptoDmaChannel)));
5036 };
5037}
5038#[macro_export]
5065#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5066macro_rules! for_each_gpio {
5067 ($($pattern:tt => $code:tt;)*) => {
5068 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5069 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
5070 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
5071 _for_each_inner_gpio!((2, GPIO2() () ([Input] [Output])));
5072 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
5073 _for_each_inner_gpio!((4, GPIO4() () ([Input] [Output])));
5074 _for_each_inner_gpio!((5, GPIO5() () ([Input] [Output])));
5075 _for_each_inner_gpio!((6, GPIO6() () ([Input] [Output])));
5076 _for_each_inner_gpio!((7, GPIO7() () ([Input] [Output])));
5077 _for_each_inner_gpio!((8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])));
5078 _for_each_inner_gpio!((9, GPIO9(_3 => SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4
5079 => FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((10, GPIO10(_2 => FSPIIO4
5080 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0) ([Input]
5081 [Output]))); _for_each_inner_gpio!((11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 =>
5082 FSPID) (_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])));
5083 _for_each_inner_gpio!((12, GPIO12(_2 => FSPIIO6 _4 => FSPICLK) (_2 => FSPIIO6 _3
5084 => SUBSPICLK _4 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((13,
5085 GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ _4
5086 => FSPIQ) ([Input] [Output]))); _for_each_inner_gpio!((14, GPIO14(_3 => SUBSPIWP
5087 _4 => FSPIWP) (_2 => FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])));
5088 _for_each_inner_gpio!((15, GPIO15() (_2 => U0RTS) ([Input] [Output])));
5089 _for_each_inner_gpio!((16, GPIO16(_2 => U0CTS) () ([Input] [Output])));
5090 _for_each_inner_gpio!((17, GPIO17() (_2 => U1TXD) ([Input] [Output])));
5091 _for_each_inner_gpio!((18, GPIO18(_2 => U1RXD) (_3 => CLK_OUT3) ([Input]
5092 [Output]))); _for_each_inner_gpio!((19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
5093 ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_2 => U1CTS) (_3 =>
5094 CLK_OUT1) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21() () ([Input]
5095 [Output]))); _for_each_inner_gpio!((26, GPIO26() (_0 => SPICS1) ([Input]
5096 [Output]))); _for_each_inner_gpio!((27, GPIO27(_0 => SPIHD) (_0 => SPIHD)
5097 ([Input] [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SPIWP) (_0 =>
5098 SPIWP) ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() (_0 => SPICS0)
5099 ([Input] [Output]))); _for_each_inner_gpio!((30, GPIO30() (_0 => SPICLK) ([Input]
5100 [Output]))); _for_each_inner_gpio!((31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input]
5101 [Output]))); _for_each_inner_gpio!((32, GPIO32(_0 => SPID) (_0 => SPID) ([Input]
5102 [Output]))); _for_each_inner_gpio!((33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2
5103 => FSPIHD _3 => SUBSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((34,
5104 GPIO34(_2 => FSPICS0) (_2 => FSPICS0 _3 => SUBSPICS0) ([Input] [Output])));
5105 _for_each_inner_gpio!((35, GPIO35(_2 => FSPID _3 => SUBSPID) (_2 => FSPID _3 =>
5106 SUBSPID) ([Input] [Output]))); _for_each_inner_gpio!((36, GPIO36(_2 => FSPICLK)
5107 (_2 => FSPICLK _3 => SUBSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((37,
5108 GPIO37(_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 =>
5109 SPIDQS) ([Input] [Output]))); _for_each_inner_gpio!((38, GPIO38(_2 => FSPIWP _3
5110 => SUBSPIWP) (_2 => FSPIWP _3 => SUBSPIWP) ([Input] [Output])));
5111 _for_each_inner_gpio!((39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 => SUBSPICS1)
5112 ([Input] [Output]))); _for_each_inner_gpio!((40, GPIO40() (_0 => MTDO _2 =>
5113 CLK_OUT2) ([Input] [Output]))); _for_each_inner_gpio!((41, GPIO41(_0 => MTDI) (_2
5114 => CLK_OUT1) ([Input] [Output]))); _for_each_inner_gpio!((42, GPIO42(_0 => MTMS)
5115 () ([Input] [Output]))); _for_each_inner_gpio!((43, GPIO43() (_0 => U0TXD _2 =>
5116 CLK_OUT1) ([Input] [Output]))); _for_each_inner_gpio!((44, GPIO44(_0 => U0RXD)
5117 (_2 => CLK_OUT2) ([Input] [Output]))); _for_each_inner_gpio!((45, GPIO45() ()
5118 ([Input] [Output]))); _for_each_inner_gpio!((46, GPIO46() () ([Input]
5119 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
5120 GPIO1() () ([Input] [Output])), (2, GPIO2() () ([Input] [Output])), (3, GPIO3()
5121 () ([Input] [Output])), (4, GPIO4() () ([Input] [Output])), (5, GPIO5() ()
5122 ([Input] [Output])), (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input]
5123 [Output])), (8, GPIO8() (_3 => SUBSPICS1) ([Input] [Output])), (9, GPIO9(_3 =>
5124 SUBSPIHD _4 => FSPIHD) (_3 => SUBSPIHD _4 => FSPIHD) ([Input] [Output])), (10,
5125 GPIO10(_2 => FSPIIO4 _4 => FSPICS0) (_2 => FSPIIO4 _3 => SUBSPICS0 _4 => FSPICS0)
5126 ([Input] [Output])), (11, GPIO11(_2 => FSPIIO5 _3 => SUBSPID _4 => FSPID) (_2 =>
5127 FSPIIO5 _3 => SUBSPID _4 => FSPID) ([Input] [Output])), (12, GPIO12(_2 => FSPIIO6
5128 _4 => FSPICLK) (_2 => FSPIIO6 _3 => SUBSPICLK _4 => FSPICLK) ([Input] [Output])),
5129 (13, GPIO13(_2 => FSPIIO7 _3 => SUBSPIQ _4 => FSPIQ) (_2 => FSPIIO7 _3 => SUBSPIQ
5130 _4 => FSPIQ) ([Input] [Output])), (14, GPIO14(_3 => SUBSPIWP _4 => FSPIWP) (_2 =>
5131 FSPIDQS _3 => SUBSPIWP _4 => FSPIWP) ([Input] [Output])), (15, GPIO15() (_2 =>
5132 U0RTS) ([Input] [Output])), (16, GPIO16(_2 => U0CTS) () ([Input] [Output])), (17,
5133 GPIO17() (_2 => U1TXD) ([Input] [Output])), (18, GPIO18(_2 => U1RXD) (_3 =>
5134 CLK_OUT3) ([Input] [Output])), (19, GPIO19() (_2 => U1RTS _3 => CLK_OUT2)
5135 ([Input] [Output])), (20, GPIO20(_2 => U1CTS) (_3 => CLK_OUT1) ([Input]
5136 [Output])), (21, GPIO21() () ([Input] [Output])), (26, GPIO26() (_0 => SPICS1)
5137 ([Input] [Output])), (27, GPIO27(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
5138 (28, GPIO28(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (29, GPIO29() (_0 =>
5139 SPICS0) ([Input] [Output])), (30, GPIO30() (_0 => SPICLK) ([Input] [Output])),
5140 (31, GPIO31(_0 => SPIQ) (_0 => SPIQ) ([Input] [Output])), (32, GPIO32(_0 => SPID)
5141 (_0 => SPID) ([Input] [Output])), (33, GPIO33(_2 => FSPIHD _3 => SUBSPIHD) (_2 =>
5142 FSPIHD _3 => SUBSPIHD) ([Input] [Output])), (34, GPIO34(_2 => FSPICS0) (_2 =>
5143 FSPICS0 _3 => SUBSPICS0) ([Input] [Output])), (35, GPIO35(_2 => FSPID _3 =>
5144 SUBSPID) (_2 => FSPID _3 => SUBSPID) ([Input] [Output])), (36, GPIO36(_2 =>
5145 FSPICLK) (_2 => FSPICLK _3 => SUBSPICLK) ([Input] [Output])), (37, GPIO37(_2 =>
5146 FSPIQ _3 => SUBSPIQ _4 => SPIDQS) (_2 => FSPIQ _3 => SUBSPIQ _4 => SPIDQS)
5147 ([Input] [Output])), (38, GPIO38(_2 => FSPIWP _3 => SUBSPIWP) (_2 => FSPIWP _3 =>
5148 SUBSPIWP) ([Input] [Output])), (39, GPIO39(_0 => MTCK) (_2 => CLK_OUT3 _3 =>
5149 SUBSPICS1) ([Input] [Output])), (40, GPIO40() (_0 => MTDO _2 => CLK_OUT2)
5150 ([Input] [Output])), (41, GPIO41(_0 => MTDI) (_2 => CLK_OUT1) ([Input]
5151 [Output])), (42, GPIO42(_0 => MTMS) () ([Input] [Output])), (43, GPIO43() (_0 =>
5152 U0TXD _2 => CLK_OUT1) ([Input] [Output])), (44, GPIO44(_0 => U0RXD) (_2 =>
5153 CLK_OUT2) ([Input] [Output])), (45, GPIO45() () ([Input] [Output])), (46,
5154 GPIO46() () ([Input] [Output]))));
5155 };
5156}
5157#[macro_export]
5184#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5185macro_rules! for_each_analog_function {
5186 ($($pattern:tt => $code:tt;)*) => {
5187 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5188 tt) => {} } _for_each_inner_analog_function!((TOUCH1, GPIO1));
5189 _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
5190 _for_each_inner_analog_function!((TOUCH2, GPIO2));
5191 _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
5192 _for_each_inner_analog_function!((TOUCH3, GPIO3));
5193 _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
5194 _for_each_inner_analog_function!((TOUCH4, GPIO4));
5195 _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
5196 _for_each_inner_analog_function!((TOUCH5, GPIO5));
5197 _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
5198 _for_each_inner_analog_function!((TOUCH6, GPIO6));
5199 _for_each_inner_analog_function!((ADC1_CH5, GPIO6));
5200 _for_each_inner_analog_function!((TOUCH7, GPIO7));
5201 _for_each_inner_analog_function!((ADC1_CH6, GPIO7));
5202 _for_each_inner_analog_function!((TOUCH8, GPIO8));
5203 _for_each_inner_analog_function!((ADC1_CH7, GPIO8));
5204 _for_each_inner_analog_function!((TOUCH9, GPIO9));
5205 _for_each_inner_analog_function!((ADC1_CH8, GPIO9));
5206 _for_each_inner_analog_function!((TOUCH10, GPIO10));
5207 _for_each_inner_analog_function!((ADC1_CH9, GPIO10));
5208 _for_each_inner_analog_function!((TOUCH11, GPIO11));
5209 _for_each_inner_analog_function!((ADC2_CH0, GPIO11));
5210 _for_each_inner_analog_function!((TOUCH12, GPIO12));
5211 _for_each_inner_analog_function!((ADC2_CH1, GPIO12));
5212 _for_each_inner_analog_function!((TOUCH13, GPIO13));
5213 _for_each_inner_analog_function!((ADC2_CH2, GPIO13));
5214 _for_each_inner_analog_function!((TOUCH14, GPIO14));
5215 _for_each_inner_analog_function!((ADC2_CH3, GPIO14));
5216 _for_each_inner_analog_function!((XTAL_32K_P, GPIO15));
5217 _for_each_inner_analog_function!((ADC2_CH4, GPIO15));
5218 _for_each_inner_analog_function!((XTAL_32K_N, GPIO16));
5219 _for_each_inner_analog_function!((ADC2_CH5, GPIO16));
5220 _for_each_inner_analog_function!((DAC1, GPIO17));
5221 _for_each_inner_analog_function!((ADC2_CH6, GPIO17));
5222 _for_each_inner_analog_function!((DAC2, GPIO18));
5223 _for_each_inner_analog_function!((ADC2_CH7, GPIO18));
5224 _for_each_inner_analog_function!((USB_FS_DM, GPIO19));
5225 _for_each_inner_analog_function!((ADC2_CH8, GPIO19));
5226 _for_each_inner_analog_function!((USB_FS_DP, GPIO20));
5227 _for_each_inner_analog_function!((ADC2_CH9, GPIO20));
5228 _for_each_inner_analog_function!(((TOUCH1, TOUCHn, 1), GPIO1));
5229 _for_each_inner_analog_function!(((TOUCH2, TOUCHn, 2), GPIO2));
5230 _for_each_inner_analog_function!(((TOUCH3, TOUCHn, 3), GPIO3));
5231 _for_each_inner_analog_function!(((TOUCH4, TOUCHn, 4), GPIO4));
5232 _for_each_inner_analog_function!(((TOUCH5, TOUCHn, 5), GPIO5));
5233 _for_each_inner_analog_function!(((TOUCH6, TOUCHn, 6), GPIO6));
5234 _for_each_inner_analog_function!(((TOUCH7, TOUCHn, 7), GPIO7));
5235 _for_each_inner_analog_function!(((TOUCH8, TOUCHn, 8), GPIO8));
5236 _for_each_inner_analog_function!(((TOUCH9, TOUCHn, 9), GPIO9));
5237 _for_each_inner_analog_function!(((TOUCH10, TOUCHn, 10), GPIO10));
5238 _for_each_inner_analog_function!(((TOUCH11, TOUCHn, 11), GPIO11));
5239 _for_each_inner_analog_function!(((TOUCH12, TOUCHn, 12), GPIO12));
5240 _for_each_inner_analog_function!(((TOUCH13, TOUCHn, 13), GPIO13));
5241 _for_each_inner_analog_function!(((TOUCH14, TOUCHn, 14), GPIO14));
5242 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
5243 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
5244 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
5245 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
5246 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
5247 _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6));
5248 _for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO7));
5249 _for_each_inner_analog_function!(((ADC1_CH7, ADCn_CHm, 1, 7), GPIO8));
5250 _for_each_inner_analog_function!(((ADC1_CH8, ADCn_CHm, 1, 8), GPIO9));
5251 _for_each_inner_analog_function!(((ADC1_CH9, ADCn_CHm, 1, 9), GPIO10));
5252 _for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO11));
5253 _for_each_inner_analog_function!(((ADC2_CH1, ADCn_CHm, 2, 1), GPIO12));
5254 _for_each_inner_analog_function!(((ADC2_CH2, ADCn_CHm, 2, 2), GPIO13));
5255 _for_each_inner_analog_function!(((ADC2_CH3, ADCn_CHm, 2, 3), GPIO14));
5256 _for_each_inner_analog_function!(((ADC2_CH4, ADCn_CHm, 2, 4), GPIO15));
5257 _for_each_inner_analog_function!(((ADC2_CH5, ADCn_CHm, 2, 5), GPIO16));
5258 _for_each_inner_analog_function!(((ADC2_CH6, ADCn_CHm, 2, 6), GPIO17));
5259 _for_each_inner_analog_function!(((ADC2_CH7, ADCn_CHm, 2, 7), GPIO18));
5260 _for_each_inner_analog_function!(((ADC2_CH8, ADCn_CHm, 2, 8), GPIO19));
5261 _for_each_inner_analog_function!(((ADC2_CH9, ADCn_CHm, 2, 9), GPIO20));
5262 _for_each_inner_analog_function!(((DAC1, DACn, 1), GPIO17));
5263 _for_each_inner_analog_function!(((DAC2, DACn, 2), GPIO18));
5264 _for_each_inner_analog_function!((all(TOUCH1, GPIO1), (ADC1_CH0, GPIO1), (TOUCH2,
5265 GPIO2), (ADC1_CH1, GPIO2), (TOUCH3, GPIO3), (ADC1_CH2, GPIO3), (TOUCH4, GPIO4),
5266 (ADC1_CH3, GPIO4), (TOUCH5, GPIO5), (ADC1_CH4, GPIO5), (TOUCH6, GPIO6),
5267 (ADC1_CH5, GPIO6), (TOUCH7, GPIO7), (ADC1_CH6, GPIO7), (TOUCH8, GPIO8),
5268 (ADC1_CH7, GPIO8), (TOUCH9, GPIO9), (ADC1_CH8, GPIO9), (TOUCH10, GPIO10),
5269 (ADC1_CH9, GPIO10), (TOUCH11, GPIO11), (ADC2_CH0, GPIO11), (TOUCH12, GPIO12),
5270 (ADC2_CH1, GPIO12), (TOUCH13, GPIO13), (ADC2_CH2, GPIO13), (TOUCH14, GPIO14),
5271 (ADC2_CH3, GPIO14), (XTAL_32K_P, GPIO15), (ADC2_CH4, GPIO15), (XTAL_32K_N,
5272 GPIO16), (ADC2_CH5, GPIO16), (DAC1, GPIO17), (ADC2_CH6, GPIO17), (DAC2, GPIO18),
5273 (ADC2_CH7, GPIO18), (USB_FS_DM, GPIO19), (ADC2_CH8, GPIO19), (USB_FS_DP, GPIO20),
5274 (ADC2_CH9, GPIO20))); _for_each_inner_analog_function!((TOUCHn((TOUCH1, TOUCHn,
5275 1), GPIO1), ((TOUCH2, TOUCHn, 2), GPIO2), ((TOUCH3, TOUCHn, 3), GPIO3), ((TOUCH4,
5276 TOUCHn, 4), GPIO4), ((TOUCH5, TOUCHn, 5), GPIO5), ((TOUCH6, TOUCHn, 6), GPIO6),
5277 ((TOUCH7, TOUCHn, 7), GPIO7), ((TOUCH8, TOUCHn, 8), GPIO8), ((TOUCH9, TOUCHn, 9),
5278 GPIO9), ((TOUCH10, TOUCHn, 10), GPIO10), ((TOUCH11, TOUCHn, 11), GPIO11),
5279 ((TOUCH12, TOUCHn, 12), GPIO12), ((TOUCH13, TOUCHn, 13), GPIO13), ((TOUCH14,
5280 TOUCHn, 14), GPIO14))); _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0,
5281 ADCn_CHm, 1, 0), GPIO1), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2,
5282 ADCn_CHm, 1, 2), GPIO3), ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4,
5283 ADCn_CHm, 1, 4), GPIO5), ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6), ((ADC1_CH6,
5284 ADCn_CHm, 1, 6), GPIO7), ((ADC1_CH7, ADCn_CHm, 1, 7), GPIO8), ((ADC1_CH8,
5285 ADCn_CHm, 1, 8), GPIO9), ((ADC1_CH9, ADCn_CHm, 1, 9), GPIO10), ((ADC2_CH0,
5286 ADCn_CHm, 2, 0), GPIO11), ((ADC2_CH1, ADCn_CHm, 2, 1), GPIO12), ((ADC2_CH2,
5287 ADCn_CHm, 2, 2), GPIO13), ((ADC2_CH3, ADCn_CHm, 2, 3), GPIO14), ((ADC2_CH4,
5288 ADCn_CHm, 2, 4), GPIO15), ((ADC2_CH5, ADCn_CHm, 2, 5), GPIO16), ((ADC2_CH6,
5289 ADCn_CHm, 2, 6), GPIO17), ((ADC2_CH7, ADCn_CHm, 2, 7), GPIO18), ((ADC2_CH8,
5290 ADCn_CHm, 2, 8), GPIO19), ((ADC2_CH9, ADCn_CHm, 2, 9), GPIO20)));
5291 _for_each_inner_analog_function!((DACn((DAC1, DACn, 1), GPIO17), ((DAC2, DACn,
5292 2), GPIO18)));
5293 };
5294}
5295#[macro_export]
5333#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5334macro_rules! for_each_lp_function {
5335 ($($pattern:tt => $code:tt;)*) => {
5336 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5337 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _0));
5338 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _0));
5339 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _0));
5340 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _0));
5341 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _0));
5342 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _0));
5343 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _0));
5344 _for_each_inner_lp_function!((LP_GPIO7, GPIO7, _0));
5345 _for_each_inner_lp_function!((LP_GPIO8, GPIO8, _0));
5346 _for_each_inner_lp_function!((LP_GPIO9, GPIO9, _0));
5347 _for_each_inner_lp_function!((LP_GPIO10, GPIO10, _0));
5348 _for_each_inner_lp_function!((LP_GPIO11, GPIO11, _0));
5349 _for_each_inner_lp_function!((LP_GPIO12, GPIO12, _0));
5350 _for_each_inner_lp_function!((LP_GPIO13, GPIO13, _0));
5351 _for_each_inner_lp_function!((LP_GPIO14, GPIO14, _0));
5352 _for_each_inner_lp_function!((LP_GPIO15, GPIO15, _0));
5353 _for_each_inner_lp_function!((LP_GPIO16, GPIO16, _0));
5354 _for_each_inner_lp_function!((LP_GPIO17, GPIO17, _0));
5355 _for_each_inner_lp_function!((LP_GPIO18, GPIO18, _0));
5356 _for_each_inner_lp_function!((LP_GPIO19, GPIO19, _0));
5357 _for_each_inner_lp_function!((LP_GPIO20, GPIO20, _0));
5358 _for_each_inner_lp_function!((LP_GPIO21, GPIO21, _0));
5359 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, () ()));
5360 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()));
5361 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()));
5362 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()));
5363 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()));
5364 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()));
5365 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()));
5366 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO7, _0, () ()));
5367 _for_each_inner_lp_function!(((LP_GPIO8, LP_GPIOn, 8), GPIO8, _0, () ()));
5368 _for_each_inner_lp_function!(((LP_GPIO9, LP_GPIOn, 9), GPIO9, _0, () ()));
5369 _for_each_inner_lp_function!(((LP_GPIO10, LP_GPIOn, 10), GPIO10, _0, () ()));
5370 _for_each_inner_lp_function!(((LP_GPIO11, LP_GPIOn, 11), GPIO11, _0, () ()));
5371 _for_each_inner_lp_function!(((LP_GPIO12, LP_GPIOn, 12), GPIO12, _0, () ()));
5372 _for_each_inner_lp_function!(((LP_GPIO13, LP_GPIOn, 13), GPIO13, _0, () ()));
5373 _for_each_inner_lp_function!(((LP_GPIO14, LP_GPIOn, 14), GPIO14, _0, () ()));
5374 _for_each_inner_lp_function!(((LP_GPIO15, LP_GPIOn, 15), GPIO15, _0, () ()));
5375 _for_each_inner_lp_function!(((LP_GPIO16, LP_GPIOn, 16), GPIO16, _0, () ()));
5376 _for_each_inner_lp_function!(((LP_GPIO17, LP_GPIOn, 17), GPIO17, _0, () ()));
5377 _for_each_inner_lp_function!(((LP_GPIO18, LP_GPIOn, 18), GPIO18, _0, () ()));
5378 _for_each_inner_lp_function!(((LP_GPIO19, LP_GPIOn, 19), GPIO19, _0, () ()));
5379 _for_each_inner_lp_function!(((LP_GPIO20, LP_GPIOn, 20), GPIO20, _0, () ()));
5380 _for_each_inner_lp_function!(((LP_GPIO21, LP_GPIOn, 21), GPIO21, _0, () ()));
5381 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _0), (LP_GPIO1, GPIO1, _0),
5382 (LP_GPIO2, GPIO2, _0), (LP_GPIO3, GPIO3, _0), (LP_GPIO4, GPIO4, _0), (LP_GPIO5,
5383 GPIO5, _0), (LP_GPIO6, GPIO6, _0), (LP_GPIO7, GPIO7, _0), (LP_GPIO8, GPIO8, _0),
5384 (LP_GPIO9, GPIO9, _0), (LP_GPIO10, GPIO10, _0), (LP_GPIO11, GPIO11, _0),
5385 (LP_GPIO12, GPIO12, _0), (LP_GPIO13, GPIO13, _0), (LP_GPIO14, GPIO14, _0),
5386 (LP_GPIO15, GPIO15, _0), (LP_GPIO16, GPIO16, _0), (LP_GPIO17, GPIO17, _0),
5387 (LP_GPIO18, GPIO18, _0), (LP_GPIO19, GPIO19, _0), (LP_GPIO20, GPIO20, _0),
5388 (LP_GPIO21, GPIO21, _0))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0,
5389 LP_GPIOn, 0), GPIO0, _0, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()),
5390 ((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0,
5391 () ()), ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5),
5392 GPIO5, _0, () ()), ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _0, () ()), ((LP_GPIO7,
5393 LP_GPIOn, 7), GPIO7, _0, () ()), ((LP_GPIO8, LP_GPIOn, 8), GPIO8, _0, () ()),
5394 ((LP_GPIO9, LP_GPIOn, 9), GPIO9, _0, () ()), ((LP_GPIO10, LP_GPIOn, 10), GPIO10,
5395 _0, () ()), ((LP_GPIO11, LP_GPIOn, 11), GPIO11, _0, () ()), ((LP_GPIO12,
5396 LP_GPIOn, 12), GPIO12, _0, () ()), ((LP_GPIO13, LP_GPIOn, 13), GPIO13, _0, ()
5397 ()), ((LP_GPIO14, LP_GPIOn, 14), GPIO14, _0, () ()), ((LP_GPIO15, LP_GPIOn, 15),
5398 GPIO15, _0, () ()), ((LP_GPIO16, LP_GPIOn, 16), GPIO16, _0, () ()), ((LP_GPIO17,
5399 LP_GPIOn, 17), GPIO17, _0, () ()), ((LP_GPIO18, LP_GPIOn, 18), GPIO18, _0, ()
5400 ()), ((LP_GPIO19, LP_GPIOn, 19), GPIO19, _0, () ()), ((LP_GPIO20, LP_GPIOn, 20),
5401 GPIO20, _0, () ()), ((LP_GPIO21, LP_GPIOn, 21), GPIO21, _0, () ())));
5402 };
5403}
5404#[macro_export]
5435#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5436macro_rules! for_each_iomux_function {
5437 ($($pattern:tt => $code:tt;)*) => {
5438 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5439 tt) => {} } _for_each_inner_iomux_function!((SUBSPICS1, GPIO8, _3));
5440 _for_each_inner_iomux_function!((SUBSPIHD, GPIO9, _3));
5441 _for_each_inner_iomux_function!((FSPIHD, GPIO9, _4));
5442 _for_each_inner_iomux_function!((FSPIIO4, GPIO10, _2));
5443 _for_each_inner_iomux_function!((SUBSPICS0, GPIO10, _3));
5444 _for_each_inner_iomux_function!((FSPICS0, GPIO10, _4));
5445 _for_each_inner_iomux_function!((FSPIIO5, GPIO11, _2));
5446 _for_each_inner_iomux_function!((SUBSPID, GPIO11, _3));
5447 _for_each_inner_iomux_function!((FSPID, GPIO11, _4));
5448 _for_each_inner_iomux_function!((FSPIIO6, GPIO12, _2));
5449 _for_each_inner_iomux_function!((SUBSPICLK, GPIO12, _3));
5450 _for_each_inner_iomux_function!((FSPICLK, GPIO12, _4));
5451 _for_each_inner_iomux_function!((FSPIIO7, GPIO13, _2));
5452 _for_each_inner_iomux_function!((SUBSPIQ, GPIO13, _3));
5453 _for_each_inner_iomux_function!((FSPIQ, GPIO13, _4));
5454 _for_each_inner_iomux_function!((FSPIDQS, GPIO14, _2));
5455 _for_each_inner_iomux_function!((SUBSPIWP, GPIO14, _3));
5456 _for_each_inner_iomux_function!((FSPIWP, GPIO14, _4));
5457 _for_each_inner_iomux_function!((U0RTS, GPIO15, _2));
5458 _for_each_inner_iomux_function!((U0CTS, GPIO16, _2));
5459 _for_each_inner_iomux_function!((U1TXD, GPIO17, _2));
5460 _for_each_inner_iomux_function!((U1RXD, GPIO18, _2));
5461 _for_each_inner_iomux_function!((CLK_OUT3, GPIO18, _3));
5462 _for_each_inner_iomux_function!((U1RTS, GPIO19, _2));
5463 _for_each_inner_iomux_function!((CLK_OUT2, GPIO19, _3));
5464 _for_each_inner_iomux_function!((U1CTS, GPIO20, _2));
5465 _for_each_inner_iomux_function!((CLK_OUT1, GPIO20, _3));
5466 _for_each_inner_iomux_function!((SPICS1, GPIO26, _0));
5467 _for_each_inner_iomux_function!((SPIHD, GPIO27, _0));
5468 _for_each_inner_iomux_function!((SPIWP, GPIO28, _0));
5469 _for_each_inner_iomux_function!((SPICS0, GPIO29, _0));
5470 _for_each_inner_iomux_function!((SPICLK, GPIO30, _0));
5471 _for_each_inner_iomux_function!((SPIQ, GPIO31, _0));
5472 _for_each_inner_iomux_function!((SPID, GPIO32, _0));
5473 _for_each_inner_iomux_function!((FSPIHD, GPIO33, _2));
5474 _for_each_inner_iomux_function!((SUBSPIHD, GPIO33, _3));
5475 _for_each_inner_iomux_function!((FSPICS0, GPIO34, _2));
5476 _for_each_inner_iomux_function!((SUBSPICS0, GPIO34, _3));
5477 _for_each_inner_iomux_function!((FSPID, GPIO35, _2));
5478 _for_each_inner_iomux_function!((SUBSPID, GPIO35, _3));
5479 _for_each_inner_iomux_function!((FSPICLK, GPIO36, _2));
5480 _for_each_inner_iomux_function!((SUBSPICLK, GPIO36, _3));
5481 _for_each_inner_iomux_function!((FSPIQ, GPIO37, _2));
5482 _for_each_inner_iomux_function!((SUBSPIQ, GPIO37, _3));
5483 _for_each_inner_iomux_function!((SPIDQS, GPIO37, _4));
5484 _for_each_inner_iomux_function!((FSPIWP, GPIO38, _2));
5485 _for_each_inner_iomux_function!((SUBSPIWP, GPIO38, _3));
5486 _for_each_inner_iomux_function!((MTCK, GPIO39, _0));
5487 _for_each_inner_iomux_function!((CLK_OUT3, GPIO39, _2));
5488 _for_each_inner_iomux_function!((SUBSPICS1, GPIO39, _3));
5489 _for_each_inner_iomux_function!((MTDO, GPIO40, _0));
5490 _for_each_inner_iomux_function!((CLK_OUT2, GPIO40, _2));
5491 _for_each_inner_iomux_function!((MTDI, GPIO41, _0));
5492 _for_each_inner_iomux_function!((CLK_OUT1, GPIO41, _2));
5493 _for_each_inner_iomux_function!((MTMS, GPIO42, _0));
5494 _for_each_inner_iomux_function!((U0TXD, GPIO43, _0));
5495 _for_each_inner_iomux_function!((CLK_OUT1, GPIO43, _2));
5496 _for_each_inner_iomux_function!((U0RXD, GPIO44, _0));
5497 _for_each_inner_iomux_function!((CLK_OUT2, GPIO44, _2));
5498 _for_each_inner_iomux_function!(((SUBSPICS1, SUBSPICSn, 1), GPIO8, _3));
5499 _for_each_inner_iomux_function!(((SUBSPICS0, SUBSPICSn, 0), GPIO10, _3));
5500 _for_each_inner_iomux_function!(((SUBSPICS0, SUBSPICSn, 0), GPIO34, _3));
5501 _for_each_inner_iomux_function!(((SUBSPICS1, SUBSPICSn, 1), GPIO39, _3));
5502 _for_each_inner_iomux_function!(((FSPIIO4, FSPIIOn, 4), GPIO10, _2));
5503 _for_each_inner_iomux_function!(((FSPIIO5, FSPIIOn, 5), GPIO11, _2));
5504 _for_each_inner_iomux_function!(((FSPIIO6, FSPIIOn, 6), GPIO12, _2));
5505 _for_each_inner_iomux_function!(((FSPIIO7, FSPIIOn, 7), GPIO13, _2));
5506 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO10, _4));
5507 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO34, _2));
5508 _for_each_inner_iomux_function!(((CLK_OUT3, CLK_OUTn, 3), GPIO18, _3));
5509 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO19, _3));
5510 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO20, _3));
5511 _for_each_inner_iomux_function!(((CLK_OUT3, CLK_OUTn, 3), GPIO39, _2));
5512 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO40, _2));
5513 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO41, _2));
5514 _for_each_inner_iomux_function!(((CLK_OUT1, CLK_OUTn, 1), GPIO43, _2));
5515 _for_each_inner_iomux_function!(((CLK_OUT2, CLK_OUTn, 2), GPIO44, _2));
5516 _for_each_inner_iomux_function!(((SPICS1, SPICSn, 1), GPIO26, _0));
5517 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO29, _0));
5518 _for_each_inner_iomux_function!((all(SUBSPICS1, GPIO8, _3), (SUBSPIHD, GPIO9,
5519 _3), (FSPIHD, GPIO9, _4), (FSPIIO4, GPIO10, _2), (SUBSPICS0, GPIO10, _3),
5520 (FSPICS0, GPIO10, _4), (FSPIIO5, GPIO11, _2), (SUBSPID, GPIO11, _3), (FSPID,
5521 GPIO11, _4), (FSPIIO6, GPIO12, _2), (SUBSPICLK, GPIO12, _3), (FSPICLK, GPIO12,
5522 _4), (FSPIIO7, GPIO13, _2), (SUBSPIQ, GPIO13, _3), (FSPIQ, GPIO13, _4), (FSPIDQS,
5523 GPIO14, _2), (SUBSPIWP, GPIO14, _3), (FSPIWP, GPIO14, _4), (U0RTS, GPIO15, _2),
5524 (U0CTS, GPIO16, _2), (U1TXD, GPIO17, _2), (U1RXD, GPIO18, _2), (CLK_OUT3, GPIO18,
5525 _3), (U1RTS, GPIO19, _2), (CLK_OUT2, GPIO19, _3), (U1CTS, GPIO20, _2), (CLK_OUT1,
5526 GPIO20, _3), (SPICS1, GPIO26, _0), (SPIHD, GPIO27, _0), (SPIWP, GPIO28, _0),
5527 (SPICS0, GPIO29, _0), (SPICLK, GPIO30, _0), (SPIQ, GPIO31, _0), (SPID, GPIO32,
5528 _0), (FSPIHD, GPIO33, _2), (SUBSPIHD, GPIO33, _3), (FSPICS0, GPIO34, _2),
5529 (SUBSPICS0, GPIO34, _3), (FSPID, GPIO35, _2), (SUBSPID, GPIO35, _3), (FSPICLK,
5530 GPIO36, _2), (SUBSPICLK, GPIO36, _3), (FSPIQ, GPIO37, _2), (SUBSPIQ, GPIO37, _3),
5531 (SPIDQS, GPIO37, _4), (FSPIWP, GPIO38, _2), (SUBSPIWP, GPIO38, _3), (MTCK,
5532 GPIO39, _0), (CLK_OUT3, GPIO39, _2), (SUBSPICS1, GPIO39, _3), (MTDO, GPIO40, _0),
5533 (CLK_OUT2, GPIO40, _2), (MTDI, GPIO41, _0), (CLK_OUT1, GPIO41, _2), (MTMS,
5534 GPIO42, _0), (U0TXD, GPIO43, _0), (CLK_OUT1, GPIO43, _2), (U0RXD, GPIO44, _0),
5535 (CLK_OUT2, GPIO44, _2))); _for_each_inner_iomux_function!((SUBSPICSn((SUBSPICS1,
5536 SUBSPICSn, 1), GPIO8, _3), ((SUBSPICS0, SUBSPICSn, 0), GPIO10, _3), ((SUBSPICS0,
5537 SUBSPICSn, 0), GPIO34, _3), ((SUBSPICS1, SUBSPICSn, 1), GPIO39, _3)));
5538 _for_each_inner_iomux_function!((FSPIIOn((FSPIIO4, FSPIIOn, 4), GPIO10, _2),
5539 ((FSPIIO5, FSPIIOn, 5), GPIO11, _2), ((FSPIIO6, FSPIIOn, 6), GPIO12, _2),
5540 ((FSPIIO7, FSPIIOn, 7), GPIO13, _2)));
5541 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO10, _4),
5542 ((FSPICS0, FSPICSn, 0), GPIO34, _2)));
5543 _for_each_inner_iomux_function!((CLK_OUTn((CLK_OUT3, CLK_OUTn, 3), GPIO18, _3),
5544 ((CLK_OUT2, CLK_OUTn, 2), GPIO19, _3), ((CLK_OUT1, CLK_OUTn, 1), GPIO20, _3),
5545 ((CLK_OUT3, CLK_OUTn, 3), GPIO39, _2), ((CLK_OUT2, CLK_OUTn, 2), GPIO40, _2),
5546 ((CLK_OUT1, CLK_OUTn, 1), GPIO41, _2), ((CLK_OUT1, CLK_OUTn, 1), GPIO43, _2),
5547 ((CLK_OUT2, CLK_OUTn, 2), GPIO44, _2)));
5548 _for_each_inner_iomux_function!((SPICSn((SPICS1, SPICSn, 1), GPIO26, _0),
5549 ((SPICS0, SPICSn, 0), GPIO29, _0)));
5550 };
5551}
5552#[macro_export]
5569#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5570macro_rules! gpio_for_signal {
5571 (LP_GPIO0 $(, $_fallback:literal)?) => {
5572 "GPIO0"
5573 };
5574 (TOUCH1 $(, $_fallback:literal)?) => {
5575 "GPIO1"
5576 };
5577 (ADC1_CH0 $(, $_fallback:literal)?) => {
5578 "GPIO1"
5579 };
5580 (LP_GPIO1 $(, $_fallback:literal)?) => {
5581 "GPIO1"
5582 };
5583 (TOUCH2 $(, $_fallback:literal)?) => {
5584 "GPIO2"
5585 };
5586 (ADC1_CH1 $(, $_fallback:literal)?) => {
5587 "GPIO2"
5588 };
5589 (LP_GPIO2 $(, $_fallback:literal)?) => {
5590 "GPIO2"
5591 };
5592 (TOUCH3 $(, $_fallback:literal)?) => {
5593 "GPIO3"
5594 };
5595 (ADC1_CH2 $(, $_fallback:literal)?) => {
5596 "GPIO3"
5597 };
5598 (LP_GPIO3 $(, $_fallback:literal)?) => {
5599 "GPIO3"
5600 };
5601 (TOUCH4 $(, $_fallback:literal)?) => {
5602 "GPIO4"
5603 };
5604 (ADC1_CH3 $(, $_fallback:literal)?) => {
5605 "GPIO4"
5606 };
5607 (LP_GPIO4 $(, $_fallback:literal)?) => {
5608 "GPIO4"
5609 };
5610 (TOUCH5 $(, $_fallback:literal)?) => {
5611 "GPIO5"
5612 };
5613 (ADC1_CH4 $(, $_fallback:literal)?) => {
5614 "GPIO5"
5615 };
5616 (LP_GPIO5 $(, $_fallback:literal)?) => {
5617 "GPIO5"
5618 };
5619 (TOUCH6 $(, $_fallback:literal)?) => {
5620 "GPIO6"
5621 };
5622 (ADC1_CH5 $(, $_fallback:literal)?) => {
5623 "GPIO6"
5624 };
5625 (LP_GPIO6 $(, $_fallback:literal)?) => {
5626 "GPIO6"
5627 };
5628 (TOUCH7 $(, $_fallback:literal)?) => {
5629 "GPIO7"
5630 };
5631 (ADC1_CH6 $(, $_fallback:literal)?) => {
5632 "GPIO7"
5633 };
5634 (LP_GPIO7 $(, $_fallback:literal)?) => {
5635 "GPIO7"
5636 };
5637 (SUBSPICS1 $(, $_fallback:literal)?) => {
5638 "GPIO8"
5639 };
5640 (TOUCH8 $(, $_fallback:literal)?) => {
5641 "GPIO8"
5642 };
5643 (ADC1_CH7 $(, $_fallback:literal)?) => {
5644 "GPIO8"
5645 };
5646 (LP_GPIO8 $(, $_fallback:literal)?) => {
5647 "GPIO8"
5648 };
5649 (SUBSPIHD $(, $_fallback:literal)?) => {
5650 "GPIO9"
5651 };
5652 (FSPIHD $(, $_fallback:literal)?) => {
5653 "GPIO9"
5654 };
5655 (TOUCH9 $(, $_fallback:literal)?) => {
5656 "GPIO9"
5657 };
5658 (ADC1_CH8 $(, $_fallback:literal)?) => {
5659 "GPIO9"
5660 };
5661 (LP_GPIO9 $(, $_fallback:literal)?) => {
5662 "GPIO9"
5663 };
5664 (FSPIIO4 $(, $_fallback:literal)?) => {
5665 "GPIO10"
5666 };
5667 (SUBSPICS0 $(, $_fallback:literal)?) => {
5668 "GPIO10"
5669 };
5670 (FSPICS0 $(, $_fallback:literal)?) => {
5671 "GPIO10"
5672 };
5673 (TOUCH10 $(, $_fallback:literal)?) => {
5674 "GPIO10"
5675 };
5676 (ADC1_CH9 $(, $_fallback:literal)?) => {
5677 "GPIO10"
5678 };
5679 (LP_GPIO10 $(, $_fallback:literal)?) => {
5680 "GPIO10"
5681 };
5682 (FSPIIO5 $(, $_fallback:literal)?) => {
5683 "GPIO11"
5684 };
5685 (SUBSPID $(, $_fallback:literal)?) => {
5686 "GPIO11"
5687 };
5688 (FSPID $(, $_fallback:literal)?) => {
5689 "GPIO11"
5690 };
5691 (TOUCH11 $(, $_fallback:literal)?) => {
5692 "GPIO11"
5693 };
5694 (ADC2_CH0 $(, $_fallback:literal)?) => {
5695 "GPIO11"
5696 };
5697 (LP_GPIO11 $(, $_fallback:literal)?) => {
5698 "GPIO11"
5699 };
5700 (FSPIIO6 $(, $_fallback:literal)?) => {
5701 "GPIO12"
5702 };
5703 (SUBSPICLK $(, $_fallback:literal)?) => {
5704 "GPIO12"
5705 };
5706 (FSPICLK $(, $_fallback:literal)?) => {
5707 "GPIO12"
5708 };
5709 (TOUCH12 $(, $_fallback:literal)?) => {
5710 "GPIO12"
5711 };
5712 (ADC2_CH1 $(, $_fallback:literal)?) => {
5713 "GPIO12"
5714 };
5715 (LP_GPIO12 $(, $_fallback:literal)?) => {
5716 "GPIO12"
5717 };
5718 (FSPIIO7 $(, $_fallback:literal)?) => {
5719 "GPIO13"
5720 };
5721 (SUBSPIQ $(, $_fallback:literal)?) => {
5722 "GPIO13"
5723 };
5724 (FSPIQ $(, $_fallback:literal)?) => {
5725 "GPIO13"
5726 };
5727 (TOUCH13 $(, $_fallback:literal)?) => {
5728 "GPIO13"
5729 };
5730 (ADC2_CH2 $(, $_fallback:literal)?) => {
5731 "GPIO13"
5732 };
5733 (LP_GPIO13 $(, $_fallback:literal)?) => {
5734 "GPIO13"
5735 };
5736 (FSPIDQS $(, $_fallback:literal)?) => {
5737 "GPIO14"
5738 };
5739 (SUBSPIWP $(, $_fallback:literal)?) => {
5740 "GPIO14"
5741 };
5742 (FSPIWP $(, $_fallback:literal)?) => {
5743 "GPIO14"
5744 };
5745 (TOUCH14 $(, $_fallback:literal)?) => {
5746 "GPIO14"
5747 };
5748 (ADC2_CH3 $(, $_fallback:literal)?) => {
5749 "GPIO14"
5750 };
5751 (LP_GPIO14 $(, $_fallback:literal)?) => {
5752 "GPIO14"
5753 };
5754 (U0RTS $(, $_fallback:literal)?) => {
5755 "GPIO15"
5756 };
5757 (XTAL_32K_P $(, $_fallback:literal)?) => {
5758 "GPIO15"
5759 };
5760 (ADC2_CH4 $(, $_fallback:literal)?) => {
5761 "GPIO15"
5762 };
5763 (LP_GPIO15 $(, $_fallback:literal)?) => {
5764 "GPIO15"
5765 };
5766 (U0CTS $(, $_fallback:literal)?) => {
5767 "GPIO16"
5768 };
5769 (XTAL_32K_N $(, $_fallback:literal)?) => {
5770 "GPIO16"
5771 };
5772 (ADC2_CH5 $(, $_fallback:literal)?) => {
5773 "GPIO16"
5774 };
5775 (LP_GPIO16 $(, $_fallback:literal)?) => {
5776 "GPIO16"
5777 };
5778 (U1TXD $(, $_fallback:literal)?) => {
5779 "GPIO17"
5780 };
5781 (DAC1 $(, $_fallback:literal)?) => {
5782 "GPIO17"
5783 };
5784 (ADC2_CH6 $(, $_fallback:literal)?) => {
5785 "GPIO17"
5786 };
5787 (LP_GPIO17 $(, $_fallback:literal)?) => {
5788 "GPIO17"
5789 };
5790 (U1RXD $(, $_fallback:literal)?) => {
5791 "GPIO18"
5792 };
5793 (CLK_OUT3 $(, $_fallback:literal)?) => {
5794 "GPIO18"
5795 };
5796 (DAC2 $(, $_fallback:literal)?) => {
5797 "GPIO18"
5798 };
5799 (ADC2_CH7 $(, $_fallback:literal)?) => {
5800 "GPIO18"
5801 };
5802 (LP_GPIO18 $(, $_fallback:literal)?) => {
5803 "GPIO18"
5804 };
5805 (U1RTS $(, $_fallback:literal)?) => {
5806 "GPIO19"
5807 };
5808 (CLK_OUT2 $(, $_fallback:literal)?) => {
5809 "GPIO19"
5810 };
5811 (USB_FS_DM $(, $_fallback:literal)?) => {
5812 "GPIO19"
5813 };
5814 (ADC2_CH8 $(, $_fallback:literal)?) => {
5815 "GPIO19"
5816 };
5817 (LP_GPIO19 $(, $_fallback:literal)?) => {
5818 "GPIO19"
5819 };
5820 (U1CTS $(, $_fallback:literal)?) => {
5821 "GPIO20"
5822 };
5823 (CLK_OUT1 $(, $_fallback:literal)?) => {
5824 "GPIO20"
5825 };
5826 (USB_FS_DP $(, $_fallback:literal)?) => {
5827 "GPIO20"
5828 };
5829 (ADC2_CH9 $(, $_fallback:literal)?) => {
5830 "GPIO20"
5831 };
5832 (LP_GPIO20 $(, $_fallback:literal)?) => {
5833 "GPIO20"
5834 };
5835 (LP_GPIO21 $(, $_fallback:literal)?) => {
5836 "GPIO21"
5837 };
5838 (SPICS1 $(, $_fallback:literal)?) => {
5839 "GPIO26"
5840 };
5841 (SPIHD $(, $_fallback:literal)?) => {
5842 "GPIO27"
5843 };
5844 (SPIWP $(, $_fallback:literal)?) => {
5845 "GPIO28"
5846 };
5847 (SPICS0 $(, $_fallback:literal)?) => {
5848 "GPIO29"
5849 };
5850 (SPICLK $(, $_fallback:literal)?) => {
5851 "GPIO30"
5852 };
5853 (SPIQ $(, $_fallback:literal)?) => {
5854 "GPIO31"
5855 };
5856 (SPID $(, $_fallback:literal)?) => {
5857 "GPIO32"
5858 };
5859 (SPIDQS $(, $_fallback:literal)?) => {
5860 "GPIO37"
5861 };
5862 (MTCK $(, $_fallback:literal)?) => {
5863 "GPIO39"
5864 };
5865 (MTDO $(, $_fallback:literal)?) => {
5866 "GPIO40"
5867 };
5868 (MTDI $(, $_fallback:literal)?) => {
5869 "GPIO41"
5870 };
5871 (MTMS $(, $_fallback:literal)?) => {
5872 "GPIO42"
5873 };
5874 (U0TXD $(, $_fallback:literal)?) => {
5875 "GPIO43"
5876 };
5877 (U0RXD $(, $_fallback:literal)?) => {
5878 "GPIO44"
5879 };
5880 ($_signal:ident, $fallback:literal) => {
5881 $fallback
5882 };
5883}
5884#[macro_export]
5888#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5889macro_rules! define_io_mux_signals {
5890 () => {
5891 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5892 #[derive(Debug, PartialEq, Copy, Clone)]
5893 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5894 #[doc(hidden)]
5895 pub enum InputSignal {
5896 SPIQ = 0,
5897 SPID = 1,
5898 SPIHD = 2,
5899 SPIWP = 3,
5900 SPID4 = 7,
5901 SPID5 = 8,
5902 SPID6 = 9,
5903 SPID7 = 10,
5904 SPIDQS = 11,
5905 U0RXD = 14,
5906 U0CTS = 15,
5907 U0DSR = 16,
5908 U1RXD = 17,
5909 U1CTS = 18,
5910 U1DSR = 21,
5911 I2S0O_BCK = 23,
5912 I2S0O_WS = 25,
5913 I2S0I_BCK = 27,
5914 I2S0I_WS = 28,
5915 I2CEXT0_SCL = 29,
5916 I2CEXT0_SDA = 30,
5917 PCNT0_SIG_CH0 = 39,
5918 PCNT0_SIG_CH1 = 40,
5919 PCNT0_CTRL_CH0 = 41,
5920 PCNT0_CTRL_CH1 = 42,
5921 PCNT1_SIG_CH0 = 43,
5922 PCNT1_SIG_CH1 = 44,
5923 PCNT1_CTRL_CH0 = 45,
5924 PCNT1_CTRL_CH1 = 46,
5925 PCNT2_SIG_CH0 = 47,
5926 PCNT2_SIG_CH1 = 48,
5927 PCNT2_CTRL_CH0 = 49,
5928 PCNT2_CTRL_CH1 = 50,
5929 PCNT3_SIG_CH0 = 51,
5930 PCNT3_SIG_CH1 = 52,
5931 PCNT3_CTRL_CH0 = 53,
5932 PCNT3_CTRL_CH1 = 54,
5933 USB_EXTPHY_VP = 61,
5934 USB_EXTPHY_VM = 62,
5935 USB_EXTPHY_RCV = 63,
5936 USB_FS_IDDIG = 64,
5937 USB_FS_AVALID = 65,
5938 USB_FS_SRP_BVALID = 66,
5939 USB_FS_VBUSVALID = 67,
5940 USB_SRP_SESSEND = 68,
5941 SPI3_CLK = 72,
5942 SPI3_Q = 73,
5943 SPI3_D = 74,
5944 SPI3_HD = 75,
5945 SPI3_CS0 = 76,
5946 RMT_SIG_0 = 83,
5947 RMT_SIG_1 = 84,
5948 RMT_SIG_2 = 85,
5949 RMT_SIG_3 = 86,
5950 I2CEXT1_SCL = 95,
5951 I2CEXT1_SDA = 96,
5952 FSPICLK = 108,
5953 FSPIQ = 109,
5954 FSPID = 110,
5955 FSPIHD = 111,
5956 FSPIWP = 112,
5957 FSPIIO4 = 113,
5958 FSPIIO5 = 114,
5959 FSPIIO6 = 115,
5960 FSPIIO7 = 116,
5961 FSPICS0 = 117,
5962 TWAI_RX = 123,
5963 SUBSPIQ = 127,
5964 SUBSPID = 128,
5965 SUBSPIHD = 129,
5966 SUBSPIWP = 130,
5967 I2S0I_DATA_IN15 = 158,
5968 SUBSPID4 = 167,
5969 SUBSPID5 = 168,
5970 SUBSPID6 = 169,
5971 SUBSPID7 = 170,
5972 SUBSPIDQS = 171,
5973 PCMFSYNC = 203,
5974 PCMCLK = 204,
5975 PRO_ALONEGPIO0 = 235,
5976 PRO_ALONEGPIO1 = 236,
5977 PRO_ALONEGPIO2 = 237,
5978 PRO_ALONEGPIO3 = 238,
5979 PRO_ALONEGPIO4 = 239,
5980 PRO_ALONEGPIO5 = 240,
5981 PRO_ALONEGPIO6 = 241,
5982 PRO_ALONEGPIO7 = 242,
5983 MTDI,
5984 MTCK,
5985 MTMS,
5986 }
5987 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5988 #[derive(Debug, PartialEq, Copy, Clone)]
5989 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5990 #[doc(hidden)]
5991 pub enum OutputSignal {
5992 SPIQ = 0,
5993 SPID = 1,
5994 SPIHD = 2,
5995 SPIWP = 3,
5996 SPICLK = 4,
5997 SPICS0 = 5,
5998 SPICS1 = 6,
5999 SPID4 = 7,
6000 SPID5 = 8,
6001 SPID6 = 9,
6002 SPID7 = 10,
6003 SPIDQS = 11,
6004 U0TXD = 14,
6005 U0RTS = 15,
6006 U0DTR = 16,
6007 U1TXD = 17,
6008 U1RTS = 18,
6009 U1DTR = 21,
6010 I2S0O_BCK = 23,
6011 I2S0O_WS = 25,
6012 I2S0I_BCK = 27,
6013 I2S0I_WS = 28,
6014 I2CEXT0_SCL = 29,
6015 I2CEXT0_SDA = 30,
6016 SDIO_TOHOST_INT = 31,
6017 USB_EXTPHY_OEN = 61,
6018 USB_EXTPHY_VPO = 63,
6019 USB_EXTPHY_VMO = 64,
6020 SPI3_CLK = 72,
6021 SPI3_Q = 73,
6022 SPI3_D = 74,
6023 SPI3_HD = 75,
6024 SPI3_CS0 = 76,
6025 SPI3_CS1 = 77,
6026 SPI3_CS2 = 78,
6027 LEDC_LS_SIG0 = 79,
6028 LEDC_LS_SIG1 = 80,
6029 LEDC_LS_SIG2 = 81,
6030 LEDC_LS_SIG3 = 82,
6031 LEDC_LS_SIG4 = 83,
6032 LEDC_LS_SIG5 = 84,
6033 LEDC_LS_SIG6 = 85,
6034 LEDC_LS_SIG7 = 86,
6035 RMT_SIG_0 = 87,
6036 RMT_SIG_1 = 88,
6037 RMT_SIG_2 = 89,
6038 RMT_SIG_3 = 90,
6039 I2CEXT1_SCL = 95,
6040 I2CEXT1_SDA = 96,
6041 GPIO_SD0 = 100,
6042 GPIO_SD1 = 101,
6043 GPIO_SD2 = 102,
6044 GPIO_SD3 = 103,
6045 GPIO_SD4 = 104,
6046 GPIO_SD5 = 105,
6047 GPIO_SD6 = 106,
6048 GPIO_SD7 = 107,
6049 FSPICLK = 108,
6050 FSPIQ = 109,
6051 FSPID = 110,
6052 FSPIHD = 111,
6053 FSPIWP = 112,
6054 FSPIIO4 = 113,
6055 FSPIIO5 = 114,
6056 FSPIIO6 = 115,
6057 FSPIIO7 = 116,
6058 FSPICS0 = 117,
6059 FSPICS1 = 118,
6060 FSPICS2 = 119,
6061 FSPICS3 = 120,
6062 FSPICS4 = 121,
6063 FSPICS5 = 122,
6064 TWAI_TX = 123,
6065 SUBSPICLK = 126,
6066 SUBSPIQ = 127,
6067 SUBSPID = 128,
6068 SUBSPIHD = 129,
6069 SUBSPIWP = 130,
6070 SUBSPICS0 = 131,
6071 SUBSPICS1 = 132,
6072 FSPIDQS = 133,
6073 FSPI_HSYNC = 134,
6074 FSPI_VSYNC = 135,
6075 FSPI_DE = 136,
6076 FSPICD = 137,
6077 SPI3_CD = 139,
6078 SPI3_DQS = 140,
6079 I2S0O_DATA_OUT23 = 166,
6080 SUBSPID4 = 167,
6081 SUBSPID5 = 168,
6082 SUBSPID6 = 169,
6083 SUBSPID7 = 170,
6084 SUBSPIDQS = 171,
6085 PCMFSYNC = 209,
6086 PCMCLK = 210,
6087 PRO_ALONEGPIO0 = 235,
6088 PRO_ALONEGPIO1 = 236,
6089 PRO_ALONEGPIO2 = 237,
6090 PRO_ALONEGPIO3 = 238,
6091 PRO_ALONEGPIO4 = 239,
6092 PRO_ALONEGPIO5 = 240,
6093 PRO_ALONEGPIO6 = 241,
6094 PRO_ALONEGPIO7 = 242,
6095 CLK_I2S = 251,
6096 GPIO = 256,
6097 CLK_OUT1,
6098 CLK_OUT2,
6099 CLK_OUT3,
6100 MTDO,
6101 }
6102 };
6103}
6104#[macro_export]
6111#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6112macro_rules! define_lp_functions {
6113 () => {
6114 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
6119 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
6120 #[doc(hidden)]
6121 pub enum LpFunction {
6122 _0 = 0,
6124 }
6125 impl LpFunction {
6126 pub const LP_GPIO: Self = Self::_0;
6128 }
6129 };
6130}
6131#[macro_export]
6144#[expect(clippy::crate_in_macro_def)]
6145#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6146macro_rules! define_io_mux_reg {
6147 () => {
6148 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
6149 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
6150 }
6151 };
6152}