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 "esp32c3"
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-C3"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32c3"
42 };
43 ("arch") => {
44 "riscv"
45 };
46 ("cores") => {
47 1
48 };
49 ("cores", str) => {
50 stringify!(1)
51 };
52 ("trm") => {
53 "https://www.espressif.com/sites/default/files/documentation/esp32-c3_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 31
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(31)
75 };
76 ("gpio.constant_1_input") => {
77 30
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(30)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 false
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.has_bank_1") => {
92 false
93 };
94 ("gpio.input_signal_max") => {
95 100
96 };
97 ("gpio.input_signal_max", str) => {
98 stringify!(100)
99 };
100 ("gpio.output_signal_max") => {
101 128
102 };
103 ("gpio.output_signal_max", str) => {
104 stringify!(128)
105 };
106 ("dedicated_gpio.version") => {
107 "riscv_v1"
108 };
109 ("dedicated_gpio.needs_initialization") => {
110 false
111 };
112 ("dedicated_gpio.channel_count") => {
113 8
114 };
115 ("dedicated_gpio.channel_count", str) => {
116 stringify!(8)
117 };
118 ("lp_io.version") => {
119 "v3"
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 true
141 };
142 ("uart.has_sclk_enable") => {
143 true
144 };
145 ("uhci.combined_uart_selector_field") => {
146 false
147 };
148 ("i2c_master.version") => {
149 3
150 };
151 ("i2c_master.version", str) => {
152 stringify!(3)
153 };
154 ("i2c_master.has_fsm_timeouts") => {
155 true
156 };
157 ("i2c_master.has_hw_bus_clear") => {
158 true
159 };
160 ("i2c_master.has_bus_timeout_enable") => {
161 true
162 };
163 ("i2c_master.separate_filter_config_registers") => {
164 false
165 };
166 ("i2c_master.can_estimate_nack_reason") => {
167 false
168 };
169 ("i2c_master.has_conf_update") => {
170 true
171 };
172 ("i2c_master.has_reliable_fsm_reset") => {
173 false
174 };
175 ("i2c_master.has_arbitration_en") => {
176 true
177 };
178 ("i2c_master.has_tx_fifo_watermark") => {
179 true
180 };
181 ("i2c_master.bus_timeout_is_exponential") => {
182 true
183 };
184 ("i2c_master.has_pd_en") => {
185 true
186 };
187 ("i2c_master.max_bus_timeout") => {
188 31
189 };
190 ("i2c_master.max_bus_timeout", str) => {
191 stringify!(31)
192 };
193 ("i2c_master.ll_intr_mask") => {
194 262143
195 };
196 ("i2c_master.ll_intr_mask", str) => {
197 stringify!(262143)
198 };
199 ("i2c_master.fifo_size") => {
200 32
201 };
202 ("i2c_master.fifo_size", str) => {
203 stringify!(32)
204 };
205 ("spi_master.version") => {
206 3
207 };
208 ("spi_master.version", str) => {
209 stringify!(3)
210 };
211 ("spi_master.fifo_size") => {
212 64
213 };
214 ("spi_master.fifo_size", str) => {
215 stringify!(64)
216 };
217 ("spi_master.bit_order_is_bool") => {
218 true
219 };
220 ("spi_master.has_octal") => {
221 false
222 };
223 ("spi_master.has_app_interrupts") => {
224 true
225 };
226 ("spi_master.has_dma_segmented_transfer") => {
227 true
228 };
229 ("spi_master.has_clk_pre_div") => {
230 false
231 };
232 ("spi_master.dma_can_access_flash") => {
233 false
234 };
235 ("i2s.version") => {
236 2
237 };
238 ("i2s.version", str) => {
239 stringify!(2)
240 };
241 ("i2s.default_clock_source") => {
242 2
243 };
244 ("i2s.default_clock_source", str) => {
245 stringify!(2)
246 };
247 ("i2s.mclk_divider_bit_width") => {
248 9
249 };
250 ("i2s.mclk_divider_bit_width", str) => {
251 stringify!(9)
252 };
253 ("i2s.max_ws_width") => {
254 128
255 };
256 ("i2s.max_ws_width", str) => {
257 stringify!(128)
258 };
259 ("i2s.clock_configured_by_pcr") => {
260 false
261 };
262 ("i2s.clock_configured_by_hp_sys_clkrst") => {
263 false
264 };
265 ("i2s.supports_pdm_rx_hp_filter") => {
266 false
267 };
268 ("i2s.supports_pdm_tx") => {
269 true
270 };
271 ("i2s.supports_pdm_rx") => {
272 true
273 };
274 ("i2s.supports_pcm2pdm") => {
275 true
276 };
277 ("i2s.supports_pdm2pcm") => {
278 false
279 };
280 ("rmt.ram_start") => {
281 1610703872
282 };
283 ("rmt.ram_start", str) => {
284 stringify!(1610703872)
285 };
286 ("rmt.channel_ram_size") => {
287 48
288 };
289 ("rmt.channel_ram_size", str) => {
290 stringify!(48)
291 };
292 ("rmt.has_tx_immediate_stop") => {
293 true
294 };
295 ("rmt.has_tx_loop_count") => {
296 true
297 };
298 ("rmt.has_tx_loop_auto_stop") => {
299 false
300 };
301 ("rmt.has_tx_carrier_data_only") => {
302 true
303 };
304 ("rmt.has_tx_sync") => {
305 true
306 };
307 ("rmt.has_rx_wrap") => {
308 true
309 };
310 ("rmt.has_rx_demodulation") => {
311 true
312 };
313 ("rmt.has_per_channel_clock") => {
314 false
315 };
316 ("bt.controller") => {
317 "btdm"
318 };
319 ("wifi.has_wifi6") => {
320 false
321 };
322 ("wifi.mac_version") => {
323 1
324 };
325 ("wifi.mac_version", str) => {
326 stringify!(1)
327 };
328 ("wifi.has_5g") => {
329 false
330 };
331 ("wifi.csi_supported") => {
332 true
333 };
334 ("phy.combo_module") => {
335 true
336 };
337 ("phy.backed_up_digital_register_count") => {
338 21
339 };
340 ("phy.backed_up_digital_register_count", str) => {
341 stringify!(21)
342 };
343 ("ledc.version") => {
344 2
345 };
346 ("ledc.version", str) => {
347 stringify!(2)
348 };
349 ("ledc.channel_count") => {
350 6
351 };
352 ("ledc.channel_count", str) => {
353 stringify!(6)
354 };
355 ("sdm.channel_count") => {
356 4
357 };
358 ("sdm.channel_count", str) => {
359 stringify!(4)
360 };
361 ("timergroup.timg_has_timer1") => {
362 false
363 };
364 ("timergroup.timg_has_divcnt_rst") => {
365 true
366 };
367 ("aes.has_split_text_registers") => {
368 true
369 };
370 ("aes.endianness_configurable") => {
371 false
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 3
387 };
388 ("rsa.version", str) => {
389 stringify!(3)
390 };
391 ("rsa.size_increment") => {
392 32
393 };
394 ("rsa.size_increment", str) => {
395 stringify!(32)
396 };
397 ("rsa.memory_size_bytes") => {
398 384
399 };
400 ("rsa.memory_size_bytes", str) => {
401 stringify!(384)
402 };
403 ("sleep.light_sleep") => {
404 true
405 };
406 ("sleep.deep_sleep") => {
407 true
408 };
409 ("sleep.rejectable_mask") => {
410 1852
411 };
412 ("sleep.pin_wakeup_version") => {
413 2
414 };
415 ("sleep.pin_wakeup_version", str) => {
416 stringify!(2)
417 };
418 ("sleep.deep_sleep_needs_gpio_isolation") => {
419 true
420 };
421 ("assist_debug.has_sp_monitor") => {
422 true
423 };
424 ("assist_debug.has_region_monitor") => {
425 true
426 };
427 ("dma.mem2mem_requires_peripheral") => {
428 true
429 };
430 ("dma.ext_mem_configurable_block_size") => {
431 false
432 };
433 ("dma.separate_in_out_interrupts") => {
434 false
435 };
436 ("dma.gdma_version") => {
437 1
438 };
439 ("dma.gdma_version", str) => {
440 stringify!(1)
441 };
442 ("interrupts.status_registers") => {
443 2
444 };
445 ("interrupts.status_registers", str) => {
446 stringify!(2)
447 };
448 ("interrupts.disabled_interrupt") => {
449 0
450 };
451 ("mmu.page_size") => {
452 65536
453 };
454 ("mmu.page_size", str) => {
455 stringify!(65536)
456 };
457 ("mmu.entry_num") => {
458 128
459 };
460 ("mmu.entry_num", str) => {
461 stringify!(128)
462 };
463 ("rom.has_crc_le") => {
464 true
465 };
466 ("rom.has_crc_be") => {
467 true
468 };
469 ("rom.has_md5_bsd") => {
470 true
471 };
472 ("rom.has_md5_mbedtls") => {
473 false
474 };
475 ("soc.cpu_has_branch_predictor") => {
476 false
477 };
478 ("soc.cpu_has_csr_pc") => {
479 true
480 };
481 ("soc.multi_core_enabled") => {
482 false
483 };
484 ("soc.internal_memory_cached") => {
485 false
486 };
487 ("soc.has_swd_watchdog") => {
488 true
489 };
490 ("soc.cpu_mcause_mask") => {
491 31
492 };
493 ("soc.cpu_mcause_mask", str) => {
494 stringify!(31)
495 };
496 ("clock_tree.system_pre_div_in") => {
497 [crate ::soc::clocks::SystemPreDivInConfig::Xtal, crate
498 ::soc::clocks::SystemPreDivInConfig::RcFast]
499 };
500 ("clock_tree.system_pre_div.divisor") => {
501 (0, 1023)
502 };
503 ("clock_tree.cpu_clk") => {
504 [crate ::soc::clocks::CpuClkConfig::Xtal, crate
505 ::soc::clocks::CpuClkConfig::RcFast, crate ::soc::clocks::CpuClkConfig::Pll]
506 };
507 ("clock_tree.apb_clk") => {
508 [crate ::soc::clocks::ApbClkConfig::Pll80m, crate
509 ::soc::clocks::ApbClkConfig::Cpu]
510 };
511 ("clock_tree.crypto_clk") => {
512 [crate ::soc::clocks::CryptoClkConfig::Pll160m, crate
513 ::soc::clocks::CryptoClkConfig::Cpu]
514 };
515 ("clock_tree.rc_fast_clk_div_n.divisor") => {
516 (0, 3)
517 };
518 ("clock_tree.rtc_slow_clk") => {
519 [#[cfg(use_xtal32k)] crate ::soc::clocks::RtcSlowClkConfig::Xtal32k, crate
520 ::soc::clocks::RtcSlowClkConfig::RcSlow, crate
521 ::soc::clocks::RtcSlowClkConfig::RcFast]
522 };
523 ("clock_tree.rtc_fast_clk") => {
524 [crate ::soc::clocks::RtcFastClkConfig::Xtal, crate
525 ::soc::clocks::RtcFastClkConfig::Rc]
526 };
527 ("clock_tree.low_power_clk") => {
528 [crate ::soc::clocks::LowPowerClkConfig::Xtal, crate
529 ::soc::clocks::LowPowerClkConfig::RcFast, #[cfg(use_xtal32k)] crate
530 ::soc::clocks::LowPowerClkConfig::Xtal32k, crate
531 ::soc::clocks::LowPowerClkConfig::RtcSlow]
532 };
533 ("clock_tree.timg_calibration_clock") => {
534 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
535 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
536 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
537 };
538 ("clock_tree.timg.function_clock") => {
539 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
540 ::soc::clocks::TimgFunctionClockConfig::ApbClk]
541 };
542 ("clock_tree.timg.wdt_clock") => {
543 [crate ::soc::clocks::TimgWdtClockConfig::ApbClk, crate
544 ::soc::clocks::TimgWdtClockConfig::XtalClk]
545 };
546 ("clock_tree.rmt.sclk") => {
547 [crate ::soc::clocks::RmtSclkConfig::ApbClk, crate
548 ::soc::clocks::RmtSclkConfig::RcFastClk, crate
549 ::soc::clocks::RmtSclkConfig::XtalClk]
550 };
551 ("clock_tree.uart.function_clock.sclk") => {
552 [crate ::soc::clocks::UartFunctionClockSclk::Apb, crate
553 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
554 ::soc::clocks::UartFunctionClockSclk::Xtal]
555 };
556 ("clock_tree.uart.function_clock.div_num") => {
557 (0, 255)
558 };
559 ("clock_tree.uart.baud_rate_generator.fractional") => {
560 (0, 15)
561 };
562 ("clock_tree.uart.baud_rate_generator.integral") => {
563 (0, 4095)
564 };
565 ("clock_tree.i2c.function_clock.sclk") => {
566 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
567 ::soc::clocks::I2cFunctionClockSclk::RcFast]
568 };
569 ("clock_tree.i2c.function_clock.div_num") => {
570 (0, 255)
571 };
572 ("clock_tree.spi.function_clock") => {
573 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
574 ::soc::clocks::SpiFunctionClockConfig::Pll80m]
575 };
576}
577#[macro_export]
578#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
579macro_rules! for_each_dedicated_gpio {
580 ($($pattern:tt => $code:tt;)*) => {
581 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
582 tt) => {} } _for_each_inner_dedicated_gpio!((0));
583 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
584 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
585 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
586 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
587 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
588 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
589 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
590 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
591 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
592 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
593 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
594 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
595 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
596 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
597 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
598 };
599}
600#[macro_export]
604#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
605macro_rules! define_lp_io_signals {
606 () => {};
607}
608#[macro_export]
630#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
631macro_rules! for_each_rmt_channel {
632 ($($pattern:tt => $code:tt;)*) => {
633 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
634 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
635 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
636 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
637 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
638 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
639 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
640 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
641 };
642}
643#[macro_export]
644#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
645macro_rules! for_each_sdm_channel {
646 ($($pattern:tt => $code:tt;)*) => {
647 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
648 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
649 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
650 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
651 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
652 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
653 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
654 GPIO_SD3)));
655 };
656}
657#[macro_export]
658#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
659macro_rules! for_each_aes_key_length {
660 ($($pattern:tt => $code:tt;)*) => {
661 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
662 tt) => {} } _for_each_inner_aes_key_length!((128));
663 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
664 4)); _for_each_inner_aes_key_length!((256, 2, 6));
665 _for_each_inner_aes_key_length!((bits(128), (256)));
666 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
667 };
668}
669#[macro_export]
670#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
671macro_rules! for_each_rsa_exponentiation {
672 ($($pattern:tt => $code:tt;)*) => {
673 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
674 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
675 _for_each_inner_rsa_exponentiation!((64));
676 _for_each_inner_rsa_exponentiation!((96));
677 _for_each_inner_rsa_exponentiation!((128));
678 _for_each_inner_rsa_exponentiation!((160));
679 _for_each_inner_rsa_exponentiation!((192));
680 _for_each_inner_rsa_exponentiation!((224));
681 _for_each_inner_rsa_exponentiation!((256));
682 _for_each_inner_rsa_exponentiation!((288));
683 _for_each_inner_rsa_exponentiation!((320));
684 _for_each_inner_rsa_exponentiation!((352));
685 _for_each_inner_rsa_exponentiation!((384));
686 _for_each_inner_rsa_exponentiation!((416));
687 _for_each_inner_rsa_exponentiation!((448));
688 _for_each_inner_rsa_exponentiation!((480));
689 _for_each_inner_rsa_exponentiation!((512));
690 _for_each_inner_rsa_exponentiation!((544));
691 _for_each_inner_rsa_exponentiation!((576));
692 _for_each_inner_rsa_exponentiation!((608));
693 _for_each_inner_rsa_exponentiation!((640));
694 _for_each_inner_rsa_exponentiation!((672));
695 _for_each_inner_rsa_exponentiation!((704));
696 _for_each_inner_rsa_exponentiation!((736));
697 _for_each_inner_rsa_exponentiation!((768));
698 _for_each_inner_rsa_exponentiation!((800));
699 _for_each_inner_rsa_exponentiation!((832));
700 _for_each_inner_rsa_exponentiation!((864));
701 _for_each_inner_rsa_exponentiation!((896));
702 _for_each_inner_rsa_exponentiation!((928));
703 _for_each_inner_rsa_exponentiation!((960));
704 _for_each_inner_rsa_exponentiation!((992));
705 _for_each_inner_rsa_exponentiation!((1024));
706 _for_each_inner_rsa_exponentiation!((1056));
707 _for_each_inner_rsa_exponentiation!((1088));
708 _for_each_inner_rsa_exponentiation!((1120));
709 _for_each_inner_rsa_exponentiation!((1152));
710 _for_each_inner_rsa_exponentiation!((1184));
711 _for_each_inner_rsa_exponentiation!((1216));
712 _for_each_inner_rsa_exponentiation!((1248));
713 _for_each_inner_rsa_exponentiation!((1280));
714 _for_each_inner_rsa_exponentiation!((1312));
715 _for_each_inner_rsa_exponentiation!((1344));
716 _for_each_inner_rsa_exponentiation!((1376));
717 _for_each_inner_rsa_exponentiation!((1408));
718 _for_each_inner_rsa_exponentiation!((1440));
719 _for_each_inner_rsa_exponentiation!((1472));
720 _for_each_inner_rsa_exponentiation!((1504));
721 _for_each_inner_rsa_exponentiation!((1536));
722 _for_each_inner_rsa_exponentiation!((1568));
723 _for_each_inner_rsa_exponentiation!((1600));
724 _for_each_inner_rsa_exponentiation!((1632));
725 _for_each_inner_rsa_exponentiation!((1664));
726 _for_each_inner_rsa_exponentiation!((1696));
727 _for_each_inner_rsa_exponentiation!((1728));
728 _for_each_inner_rsa_exponentiation!((1760));
729 _for_each_inner_rsa_exponentiation!((1792));
730 _for_each_inner_rsa_exponentiation!((1824));
731 _for_each_inner_rsa_exponentiation!((1856));
732 _for_each_inner_rsa_exponentiation!((1888));
733 _for_each_inner_rsa_exponentiation!((1920));
734 _for_each_inner_rsa_exponentiation!((1952));
735 _for_each_inner_rsa_exponentiation!((1984));
736 _for_each_inner_rsa_exponentiation!((2016));
737 _for_each_inner_rsa_exponentiation!((2048));
738 _for_each_inner_rsa_exponentiation!((2080));
739 _for_each_inner_rsa_exponentiation!((2112));
740 _for_each_inner_rsa_exponentiation!((2144));
741 _for_each_inner_rsa_exponentiation!((2176));
742 _for_each_inner_rsa_exponentiation!((2208));
743 _for_each_inner_rsa_exponentiation!((2240));
744 _for_each_inner_rsa_exponentiation!((2272));
745 _for_each_inner_rsa_exponentiation!((2304));
746 _for_each_inner_rsa_exponentiation!((2336));
747 _for_each_inner_rsa_exponentiation!((2368));
748 _for_each_inner_rsa_exponentiation!((2400));
749 _for_each_inner_rsa_exponentiation!((2432));
750 _for_each_inner_rsa_exponentiation!((2464));
751 _for_each_inner_rsa_exponentiation!((2496));
752 _for_each_inner_rsa_exponentiation!((2528));
753 _for_each_inner_rsa_exponentiation!((2560));
754 _for_each_inner_rsa_exponentiation!((2592));
755 _for_each_inner_rsa_exponentiation!((2624));
756 _for_each_inner_rsa_exponentiation!((2656));
757 _for_each_inner_rsa_exponentiation!((2688));
758 _for_each_inner_rsa_exponentiation!((2720));
759 _for_each_inner_rsa_exponentiation!((2752));
760 _for_each_inner_rsa_exponentiation!((2784));
761 _for_each_inner_rsa_exponentiation!((2816));
762 _for_each_inner_rsa_exponentiation!((2848));
763 _for_each_inner_rsa_exponentiation!((2880));
764 _for_each_inner_rsa_exponentiation!((2912));
765 _for_each_inner_rsa_exponentiation!((2944));
766 _for_each_inner_rsa_exponentiation!((2976));
767 _for_each_inner_rsa_exponentiation!((3008));
768 _for_each_inner_rsa_exponentiation!((3040));
769 _for_each_inner_rsa_exponentiation!((3072));
770 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
771 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
772 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
773 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
774 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
775 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
776 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
777 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
778 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
779 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
780 };
781}
782#[macro_export]
783#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
784macro_rules! for_each_rsa_multiplication {
785 ($($pattern:tt => $code:tt;)*) => {
786 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
787 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
788 _for_each_inner_rsa_multiplication!((64));
789 _for_each_inner_rsa_multiplication!((96));
790 _for_each_inner_rsa_multiplication!((128));
791 _for_each_inner_rsa_multiplication!((160));
792 _for_each_inner_rsa_multiplication!((192));
793 _for_each_inner_rsa_multiplication!((224));
794 _for_each_inner_rsa_multiplication!((256));
795 _for_each_inner_rsa_multiplication!((288));
796 _for_each_inner_rsa_multiplication!((320));
797 _for_each_inner_rsa_multiplication!((352));
798 _for_each_inner_rsa_multiplication!((384));
799 _for_each_inner_rsa_multiplication!((416));
800 _for_each_inner_rsa_multiplication!((448));
801 _for_each_inner_rsa_multiplication!((480));
802 _for_each_inner_rsa_multiplication!((512));
803 _for_each_inner_rsa_multiplication!((544));
804 _for_each_inner_rsa_multiplication!((576));
805 _for_each_inner_rsa_multiplication!((608));
806 _for_each_inner_rsa_multiplication!((640));
807 _for_each_inner_rsa_multiplication!((672));
808 _for_each_inner_rsa_multiplication!((704));
809 _for_each_inner_rsa_multiplication!((736));
810 _for_each_inner_rsa_multiplication!((768));
811 _for_each_inner_rsa_multiplication!((800));
812 _for_each_inner_rsa_multiplication!((832));
813 _for_each_inner_rsa_multiplication!((864));
814 _for_each_inner_rsa_multiplication!((896));
815 _for_each_inner_rsa_multiplication!((928));
816 _for_each_inner_rsa_multiplication!((960));
817 _for_each_inner_rsa_multiplication!((992));
818 _for_each_inner_rsa_multiplication!((1024));
819 _for_each_inner_rsa_multiplication!((1056));
820 _for_each_inner_rsa_multiplication!((1088));
821 _for_each_inner_rsa_multiplication!((1120));
822 _for_each_inner_rsa_multiplication!((1152));
823 _for_each_inner_rsa_multiplication!((1184));
824 _for_each_inner_rsa_multiplication!((1216));
825 _for_each_inner_rsa_multiplication!((1248));
826 _for_each_inner_rsa_multiplication!((1280));
827 _for_each_inner_rsa_multiplication!((1312));
828 _for_each_inner_rsa_multiplication!((1344));
829 _for_each_inner_rsa_multiplication!((1376));
830 _for_each_inner_rsa_multiplication!((1408));
831 _for_each_inner_rsa_multiplication!((1440));
832 _for_each_inner_rsa_multiplication!((1472));
833 _for_each_inner_rsa_multiplication!((1504));
834 _for_each_inner_rsa_multiplication!((1536));
835 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
836 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
837 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
838 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
839 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
840 };
841}
842#[macro_export]
843#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
844macro_rules! for_each_sha_algorithm {
845 ($($pattern:tt => $code:tt;)*) => {
846 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
847 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
848 (insecure_against : "collision", "length extension"), 0));
849 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
850 (insecure_against : "length extension"), 1));
851 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
852 (insecure_against : "length extension"), 2));
853 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
854 (insecure_against : "collision", "length extension"), 0), (Sha224,
855 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
856 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
857 2)));
858 };
859}
860#[macro_export]
861#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
862macro_rules! for_each_wakeup_source {
863 ($($pattern:tt => $code:tt;)*) => {
864 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
865 tt) => {} } _for_each_inner_wakeup_source!((Gpio, 2));
866 _for_each_inner_wakeup_source!((Timer, 3)); _for_each_inner_wakeup_source!((Sdio,
867 4)); _for_each_inner_wakeup_source!((Wifi, 5));
868 _for_each_inner_wakeup_source!((Uart0, 6));
869 _for_each_inner_wakeup_source!((Uart1, 7));
870 _for_each_inner_wakeup_source!((Touch, 8)); _for_each_inner_wakeup_source!((Ulp,
871 9)); _for_each_inner_wakeup_source!((Bt, 10));
872 _for_each_inner_wakeup_source!((all(Gpio, 2), (Timer, 3), (Sdio, 4), (Wifi, 5),
873 (Uart0, 6), (Uart1, 7), (Touch, 8), (Ulp, 9), (Bt, 10)));
874 };
875}
876#[macro_export]
877#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
878macro_rules! for_each_dma_engine {
879 ($($pattern:tt => $code:tt;)*) => {
880 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
881 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
882 _for_each_inner_dma_engine!((all("AHB_GDMA")));
883 };
884}
885#[macro_export]
886#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
887macro_rules! for_each_dma_channel {
888 ($($pattern:tt => $code:tt;)*) => {
889 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
890 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
891 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
892 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
893 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
894 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt = DMA_CH0,
895 compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]));
896 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt = DMA_CH1,
897 compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]));
898 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt = DMA_CH2,
899 compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]));
900 _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0), ("AHB_GDMA", DMA_CH1),
901 ("AHB_GDMA", DMA_CH2)));
902 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
903 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared("AHB_GDMA", DMA_CH0, 0,
904 interrupt = DMA_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]),
905 ("AHB_GDMA", DMA_CH1, 1, interrupt = DMA_CH1, compatible = [SPI2, UHCI0, I2S0,
906 AES, SHA, APB_SARADC]), ("AHB_GDMA", DMA_CH2, 2, interrupt = DMA_CH2, compatible
907 = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC])));
908 _for_each_inner_dma_channel!((split));
909 _for_each_inner_dma_channel!((no_own_interrupt));
910 };
911}
912#[macro_export]
913#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
914macro_rules! for_each_dma_channel_peri_pair {
915 ($($pattern:tt => $code:tt;)*) => {
916 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
917 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
918 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
919 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
920 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
921 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
922 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
923 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
924 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
925 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
926 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
927 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
928 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
929 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
930 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
931 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
932 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
933 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
934 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
935 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
936 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
937 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
938 any_channel = AhbGdmaChannel, I2S0));
939 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
940 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
941 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
942 any_channel = AhbGdmaChannel, APB_SARADC));
943 _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0, SPI2),
944 ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0,
945 AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC), ("AHB_GDMA",
946 DMA_CH1, SPI2), ("AHB_GDMA", DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0),
947 ("AHB_GDMA", DMA_CH1, AES), ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1,
948 APB_SARADC), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
949 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
950 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC)));
951 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
952 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
953 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
954 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
955 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC)));
956 };
957}
958#[macro_export]
959#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
960macro_rules! for_each_mem2mem_channel {
961 ($($pattern:tt => $code:tt;)*) => {
962 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
963 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
964 AhbGdmaChannel, DMA_CH0, 0)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
965 AhbGdma, AhbGdmaChannel, DMA_CH1, 0));
966 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
967 0)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0, 0,
968 1, 0, 2, 0)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
969 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
970 AhbGdmaChannel, DMA_CH0, 0), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 0),
971 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 0)));
972 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
973 0, 1, 0, 2, 0))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
974 AhbGdmaChannel)));
975 };
976}
977#[macro_export]
978#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
979macro_rules! with_aes_dma_engine {
980 ($($pattern:tt => $code:tt;)*) => {
981 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
982 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
983 };
984}
985#[macro_export]
986#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
987macro_rules! with_i2s_dma_engine {
988 ($($pattern:tt => $code:tt;)*) => {
989 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
990 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
991 };
992}
993#[macro_export]
994#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
995macro_rules! with_sha_dma_engine {
996 ($($pattern:tt => $code:tt;)*) => {
997 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
998 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
999 };
1000}
1001#[macro_export]
1002#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1003macro_rules! with_spi_master_dma_engine {
1004 ($($pattern:tt => $code:tt;)*) => {
1005 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1006 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1007 };
1008}
1009#[macro_export]
1010#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1011macro_rules! with_spi_slave_dma_engine {
1012 ($($pattern:tt => $code:tt;)*) => {
1013 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1014 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1015 };
1016}
1017#[macro_export]
1018#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1019macro_rules! with_uhci_dma_engine {
1020 ($($pattern:tt => $code:tt;)*) => {
1021 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1022 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1023 };
1024}
1025#[macro_export]
1026#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1027macro_rules! for_each_interrupt {
1028 ($($pattern:tt => $code:tt;)*) => {
1029 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1030 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
1031 _for_each_inner_interrupt!(([reserved 0] 1));
1032 _for_each_inner_interrupt!(([direct_bindable 0] 2));
1033 _for_each_inner_interrupt!(([direct_bindable 1] 3));
1034 _for_each_inner_interrupt!(([direct_bindable 2] 4));
1035 _for_each_inner_interrupt!(([direct_bindable 3] 5));
1036 _for_each_inner_interrupt!(([direct_bindable 4] 6));
1037 _for_each_inner_interrupt!(([direct_bindable 5] 7));
1038 _for_each_inner_interrupt!(([direct_bindable 6] 8));
1039 _for_each_inner_interrupt!(([direct_bindable 7] 9));
1040 _for_each_inner_interrupt!(([direct_bindable 8] 10));
1041 _for_each_inner_interrupt!(([direct_bindable 9] 11));
1042 _for_each_inner_interrupt!(([direct_bindable 10] 12));
1043 _for_each_inner_interrupt!(([direct_bindable 11] 13));
1044 _for_each_inner_interrupt!(([direct_bindable 12] 14));
1045 _for_each_inner_interrupt!(([direct_bindable 13] 15));
1046 _for_each_inner_interrupt!(([direct_bindable 14] 16));
1047 _for_each_inner_interrupt!(([vector 0] 17)); _for_each_inner_interrupt!(([vector
1048 1] 18)); _for_each_inner_interrupt!(([vector 2] 19));
1049 _for_each_inner_interrupt!(([vector 3] 20)); _for_each_inner_interrupt!(([vector
1050 4] 21)); _for_each_inner_interrupt!(([vector 5] 22));
1051 _for_each_inner_interrupt!(([vector 6] 23)); _for_each_inner_interrupt!(([vector
1052 7] 24)); _for_each_inner_interrupt!(([vector 8] 25));
1053 _for_each_inner_interrupt!(([vector 9] 26)); _for_each_inner_interrupt!(([vector
1054 10] 27)); _for_each_inner_interrupt!(([vector 11] 28));
1055 _for_each_inner_interrupt!(([vector 12] 29)); _for_each_inner_interrupt!(([vector
1056 13] 30)); _for_each_inner_interrupt!(([vector 14] 31));
1057 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1),
1058 ([direct_bindable 0] 2), ([direct_bindable 1] 3), ([direct_bindable 2] 4),
1059 ([direct_bindable 3] 5), ([direct_bindable 4] 6), ([direct_bindable 5] 7),
1060 ([direct_bindable 6] 8), ([direct_bindable 7] 9), ([direct_bindable 8] 10),
1061 ([direct_bindable 9] 11), ([direct_bindable 10] 12), ([direct_bindable 11] 13),
1062 ([direct_bindable 12] 14), ([direct_bindable 13] 15), ([direct_bindable 14] 16),
1063 ([vector 0] 17), ([vector 1] 18), ([vector 2] 19), ([vector 3] 20), ([vector 4]
1064 21), ([vector 5] 22), ([vector 6] 23), ([vector 7] 24), ([vector 8] 25), ([vector
1065 9] 26), ([vector 10] 27), ([vector 11] 28), ([vector 12] 29), ([vector 13] 30),
1066 ([vector 14] 31)));
1067 };
1068}
1069#[macro_export]
1070#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1071macro_rules! for_each_classified_interrupt {
1072 ($($pattern:tt => $code:tt;)*) => {
1073 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1074 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1075 2)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 3));
1076 _for_each_inner_classified_interrupt!(([direct_bindable 2] 4));
1077 _for_each_inner_classified_interrupt!(([direct_bindable 3] 5));
1078 _for_each_inner_classified_interrupt!(([direct_bindable 4] 6));
1079 _for_each_inner_classified_interrupt!(([direct_bindable 5] 7));
1080 _for_each_inner_classified_interrupt!(([direct_bindable 6] 8));
1081 _for_each_inner_classified_interrupt!(([direct_bindable 7] 9));
1082 _for_each_inner_classified_interrupt!(([direct_bindable 8] 10));
1083 _for_each_inner_classified_interrupt!(([direct_bindable 9] 11));
1084 _for_each_inner_classified_interrupt!(([direct_bindable 10] 12));
1085 _for_each_inner_classified_interrupt!(([direct_bindable 11] 13));
1086 _for_each_inner_classified_interrupt!(([direct_bindable 12] 14));
1087 _for_each_inner_classified_interrupt!(([direct_bindable 13] 15));
1088 _for_each_inner_classified_interrupt!(([direct_bindable 14] 16));
1089 _for_each_inner_classified_interrupt!(([vector 0] 17));
1090 _for_each_inner_classified_interrupt!(([vector 1] 18));
1091 _for_each_inner_classified_interrupt!(([vector 2] 19));
1092 _for_each_inner_classified_interrupt!(([vector 3] 20));
1093 _for_each_inner_classified_interrupt!(([vector 4] 21));
1094 _for_each_inner_classified_interrupt!(([vector 5] 22));
1095 _for_each_inner_classified_interrupt!(([vector 6] 23));
1096 _for_each_inner_classified_interrupt!(([vector 7] 24));
1097 _for_each_inner_classified_interrupt!(([vector 8] 25));
1098 _for_each_inner_classified_interrupt!(([vector 9] 26));
1099 _for_each_inner_classified_interrupt!(([vector 10] 27));
1100 _for_each_inner_classified_interrupt!(([vector 11] 28));
1101 _for_each_inner_classified_interrupt!(([vector 12] 29));
1102 _for_each_inner_classified_interrupt!(([vector 13] 30));
1103 _for_each_inner_classified_interrupt!(([vector 14] 31));
1104 _for_each_inner_classified_interrupt!(([reserved 0] 1));
1105 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 2),
1106 ([direct_bindable 1] 3), ([direct_bindable 2] 4), ([direct_bindable 3] 5),
1107 ([direct_bindable 4] 6), ([direct_bindable 5] 7), ([direct_bindable 6] 8),
1108 ([direct_bindable 7] 9), ([direct_bindable 8] 10), ([direct_bindable 9] 11),
1109 ([direct_bindable 10] 12), ([direct_bindable 11] 13), ([direct_bindable 12] 14),
1110 ([direct_bindable 13] 15), ([direct_bindable 14] 16)));
1111 _for_each_inner_classified_interrupt!((vector([vector 0] 17), ([vector 1] 18),
1112 ([vector 2] 19), ([vector 3] 20), ([vector 4] 21), ([vector 5] 22), ([vector 6]
1113 23), ([vector 7] 24), ([vector 8] 25), ([vector 9] 26), ([vector 10] 27),
1114 ([vector 11] 28), ([vector 12] 29), ([vector 13] 30), ([vector 14] 31)));
1115 _for_each_inner_classified_interrupt!((reserved([reserved 0] 1)));
1116 };
1117}
1118#[macro_export]
1119#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1120macro_rules! for_each_interrupt_priority {
1121 ($($pattern:tt => $code:tt;)*) => {
1122 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1123 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1124 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1125 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1126 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1127 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1128 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1129 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1130 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1131 _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
1132 _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
1133 _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
1134 _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
1135 _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
1136 _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
1137 _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
1138 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1139 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1140 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1141 Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
1142 11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
1143 Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
1144 };
1145}
1146#[macro_export]
1147#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1148macro_rules! for_each_sw_interrupt {
1149 ($($pattern:tt => $code:tt;)*) => {
1150 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1151 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1152 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1153 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1154 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1155 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1156 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1157 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1158 };
1159}
1160#[macro_export]
1161macro_rules! define_clock_tree_types {
1511 () => {
1512 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1513 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1514 pub enum SdmInstance {
1515 GpioSd = 0,
1516 }
1517 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1518 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1519 pub enum I2cInstance {
1520 I2c0 = 0,
1521 }
1522 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1523 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1524 pub enum RmtInstance {
1525 Rmt = 0,
1526 }
1527 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1528 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1529 pub enum SpiInstance {
1530 Spi2 = 0,
1531 }
1532 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1533 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1534 pub enum TimgInstance {
1535 Timg0 = 0,
1536 Timg1 = 1,
1537 }
1538 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1539 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1540 pub enum UartInstance {
1541 Uart0 = 0,
1542 Uart1 = 1,
1543 }
1544 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1546 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1547 pub enum XtalClkConfig {
1548 _40,
1550 }
1551 impl XtalClkConfig {
1552 pub fn value(&self) -> u32 {
1553 match self {
1554 XtalClkConfig::_40 => 40000000,
1555 }
1556 }
1557 }
1558 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1560 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1561 pub enum PllClkConfig {
1562 _320,
1564 _480,
1566 }
1567 impl PllClkConfig {
1568 pub fn value(&self) -> u32 {
1569 match self {
1570 PllClkConfig::_320 => 320000000,
1571 PllClkConfig::_480 => 480000000,
1572 }
1573 }
1574 }
1575 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1577 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1578 pub enum SystemPreDivInConfig {
1579 Xtal,
1581 RcFast,
1583 }
1584 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1588 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1589 pub struct SystemPreDivConfig {
1590 divisor: u32,
1591 }
1592 impl SystemPreDivConfig {
1593 pub const fn new(divisor: u32) -> Self {
1600 ::core::assert!(
1601 divisor <= 1023,
1602 "`SYSTEM_PRE_DIV` divisor must be between 0 and 1023 (inclusive)."
1603 );
1604 Self { divisor }
1605 }
1606 pub(crate) fn divisor(self) -> u32 {
1607 self.divisor as u32
1608 }
1609 }
1610 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1612 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1613 pub enum CpuPllDivOutConfig {
1614 _80,
1616 _160,
1618 }
1619 impl CpuPllDivOutConfig {
1620 pub fn value(&self) -> u32 {
1621 match self {
1622 CpuPllDivOutConfig::_80 => 80000000,
1623 CpuPllDivOutConfig::_160 => 160000000,
1624 }
1625 }
1626 }
1627 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1629 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1630 pub enum ApbClkConfig {
1631 Pll80m,
1633 Cpu,
1635 }
1636 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1638 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1639 pub enum CryptoClkConfig {
1640 Pll160m,
1642 Cpu,
1644 }
1645 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1647 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1648 pub enum CpuClkConfig {
1649 Xtal,
1651 RcFast,
1653 Pll,
1655 }
1656 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1660 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1661 pub struct RcFastClkDivNConfig {
1662 divisor: u32,
1663 }
1664 impl RcFastClkDivNConfig {
1665 pub const fn new(divisor: u32) -> Self {
1672 ::core::assert!(
1673 divisor <= 3,
1674 "`RC_FAST_CLK_DIV_N` divisor must be between 0 and 3 (inclusive)."
1675 );
1676 Self { divisor }
1677 }
1678 pub(crate) fn divisor(self) -> u32 {
1679 self.divisor as u32
1680 }
1681 }
1682 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1684 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1685 pub enum RtcSlowClkConfig {
1686 #[cfg(use_xtal32k)]
1687 Xtal32k,
1689 RcSlow,
1691 RcFast,
1693 }
1694 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1696 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1697 pub enum RtcFastClkConfig {
1698 Xtal,
1700 Rc,
1702 }
1703 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1705 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1706 pub enum LowPowerClkConfig {
1707 Xtal,
1709 RcFast,
1711 #[cfg(use_xtal32k)]
1712 Xtal32k,
1714 RtcSlow,
1716 }
1717 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1719 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1720 pub enum UartMemClkConfig {
1721 #[default]
1722 Xtal,
1724 }
1725 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1727 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1728 pub enum TimgCalibrationClockConfig {
1729 RcSlowClk,
1731 RcFastDivClk,
1733 #[cfg(use_xtal32k)]
1734 Xtal32kClk,
1736 }
1737 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1738 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1739 pub enum I2cFunctionClockSclk {
1740 #[default]
1741 Xtal,
1743 RcFast,
1745 }
1746 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1750 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1751 pub struct I2cFunctionClockConfig {
1752 sclk: I2cFunctionClockSclk,
1753 div_num: u32,
1754 }
1755 impl I2cFunctionClockConfig {
1756 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1763 ::core::assert!(
1764 div_num <= 255,
1765 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1766 );
1767 Self { sclk, div_num }
1768 }
1769 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1770 self.sclk
1771 }
1772 pub(crate) fn div_num(self) -> u32 {
1773 self.div_num as u32
1774 }
1775 }
1776 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1778 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1779 pub enum RmtSclkConfig {
1780 #[default]
1781 ApbClk,
1783 RcFastClk,
1785 XtalClk,
1787 }
1788 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1790 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1791 pub enum SpiFunctionClockConfig {
1792 Xtal,
1794 #[default]
1795 Pll80m,
1797 }
1798 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1800 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1801 pub enum TimgFunctionClockConfig {
1802 #[default]
1803 XtalClk,
1805 ApbClk,
1807 }
1808 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1810 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1811 pub enum TimgWdtClockConfig {
1812 #[default]
1813 ApbClk,
1815 XtalClk,
1817 }
1818 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1819 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1820 pub enum UartFunctionClockSclk {
1821 Apb,
1823 RcFast,
1825 #[default]
1826 Xtal,
1828 }
1829 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1833 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1834 pub struct UartFunctionClockConfig {
1835 sclk: UartFunctionClockSclk,
1836 div_num: u32,
1837 }
1838 impl UartFunctionClockConfig {
1839 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1846 ::core::assert!(
1847 div_num <= 255,
1848 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1849 );
1850 Self { sclk, div_num }
1851 }
1852 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
1853 self.sclk
1854 }
1855 pub(crate) fn div_num(self) -> u32 {
1856 self.div_num as u32
1857 }
1858 }
1859 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1864 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1865 pub struct UartBaudRateGeneratorConfig {
1866 fractional: u32,
1867 integral: u32,
1868 }
1869 impl UartBaudRateGeneratorConfig {
1870 pub const fn new(fractional: u32, integral: u32) -> Self {
1880 ::core::assert!(
1881 fractional <= 15,
1882 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1883 );
1884 ::core::assert!(
1885 integral <= 4095,
1886 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1887 );
1888 Self {
1889 fractional,
1890 integral,
1891 }
1892 }
1893 pub(crate) fn fractional(self) -> u32 {
1894 self.fractional as u32
1895 }
1896 pub(crate) fn integral(self) -> u32 {
1897 self.integral as u32
1898 }
1899 }
1900 pub struct ClockTree {
1902 xtal_clk: Option<XtalClkConfig>,
1903 pll_clk: Option<PllClkConfig>,
1904 system_pre_div_in: Option<SystemPreDivInConfig>,
1905 system_pre_div: Option<SystemPreDivConfig>,
1906 cpu_pll_div_out: Option<CpuPllDivOutConfig>,
1907 apb_clk: Option<ApbClkConfig>,
1908 crypto_clk: Option<CryptoClkConfig>,
1909 cpu_clk: Option<CpuClkConfig>,
1910 rc_fast_clk_div_n: Option<RcFastClkDivNConfig>,
1911 rtc_slow_clk: Option<RtcSlowClkConfig>,
1912 rtc_fast_clk: Option<RtcFastClkConfig>,
1913 low_power_clk: Option<LowPowerClkConfig>,
1914 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1915 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
1916 rmt_sclk: [Option<RmtSclkConfig>; 1],
1917 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
1918 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1919 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1920 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
1921 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
1922 rc_fast_clk_refcount: u32,
1923 #[cfg(use_xtal32k)]
1924 xtal32k_clk_refcount: u32,
1925 rc_slow_clk_refcount: u32,
1926 rc_fast_div_clk_refcount: u32,
1927 apb_clk_refcount: u32,
1928 crypto_clk_refcount: u32,
1929 pll_80m_refcount: u32,
1930 rtc_fast_clk_refcount: u32,
1931 low_power_clk_refcount: u32,
1932 uart_mem_clk_refcount: u32,
1933 timg_calibration_clock_refcount: u32,
1934 sdm_function_clock_refcount: [u32; 1],
1935 i2c_function_clock_refcount: [u32; 1],
1936 rmt_sclk_refcount: [u32; 1],
1937 spi_function_clock_refcount: [u32; 1],
1938 timg_function_clock_refcount: [u32; 2],
1939 timg_wdt_clock_refcount: [u32; 2],
1940 uart_function_clock_refcount: [u32; 2],
1941 uart_mem_clock_refcount: [u32; 2],
1942 uart_baud_rate_generator_refcount: [u32; 2],
1943 }
1944 impl ClockTree {
1945 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1947 CLOCK_TREE.with(f)
1948 }
1949 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1951 self.xtal_clk
1952 }
1953 pub fn pll_clk(&self) -> Option<PllClkConfig> {
1955 self.pll_clk
1956 }
1957 pub fn system_pre_div_in(&self) -> Option<SystemPreDivInConfig> {
1959 self.system_pre_div_in
1960 }
1961 pub fn system_pre_div(&self) -> Option<SystemPreDivConfig> {
1963 self.system_pre_div
1964 }
1965 pub fn cpu_pll_div_out(&self) -> Option<CpuPllDivOutConfig> {
1967 self.cpu_pll_div_out
1968 }
1969 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1971 self.apb_clk
1972 }
1973 pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
1975 self.crypto_clk
1976 }
1977 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1979 self.cpu_clk
1980 }
1981 pub fn rc_fast_clk_div_n(&self) -> Option<RcFastClkDivNConfig> {
1983 self.rc_fast_clk_div_n
1984 }
1985 pub fn rtc_slow_clk(&self) -> Option<RtcSlowClkConfig> {
1987 self.rtc_slow_clk
1988 }
1989 pub fn rtc_fast_clk(&self) -> Option<RtcFastClkConfig> {
1991 self.rtc_fast_clk
1992 }
1993 pub fn low_power_clk(&self) -> Option<LowPowerClkConfig> {
1995 self.low_power_clk
1996 }
1997 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1999 self.timg_calibration_clock
2000 }
2001 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2003 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2004 }
2005 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2007 self.rmt_sclk[RmtInstance::Rmt as usize]
2008 }
2009 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2011 self.spi_function_clock[SpiInstance::Spi2 as usize]
2012 }
2013 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2015 self.timg_function_clock[TimgInstance::Timg0 as usize]
2016 }
2017 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2019 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2020 }
2021 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2023 self.timg_function_clock[TimgInstance::Timg1 as usize]
2024 }
2025 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2027 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2028 }
2029 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2031 self.uart_function_clock[UartInstance::Uart0 as usize]
2032 }
2033 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2035 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2036 }
2037 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2039 self.uart_function_clock[UartInstance::Uart1 as usize]
2040 }
2041 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2043 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2044 }
2045 }
2046 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2047 ::esp_sync::NonReentrantMutex::new(ClockTree {
2048 xtal_clk: None,
2049 pll_clk: None,
2050 system_pre_div_in: None,
2051 system_pre_div: None,
2052 cpu_pll_div_out: None,
2053 apb_clk: None,
2054 crypto_clk: None,
2055 cpu_clk: None,
2056 rc_fast_clk_div_n: None,
2057 rtc_slow_clk: None,
2058 rtc_fast_clk: None,
2059 low_power_clk: None,
2060 timg_calibration_clock: None,
2061 i2c_function_clock: [None; 1],
2062 rmt_sclk: [None; 1],
2063 spi_function_clock: [None; 1],
2064 timg_function_clock: [None; 2],
2065 timg_wdt_clock: [None; 2],
2066 uart_function_clock: [None; 2],
2067 uart_baud_rate_generator: [None; 2],
2068 rc_fast_clk_refcount: 0,
2069 #[cfg(use_xtal32k)]
2070 xtal32k_clk_refcount: 0,
2071 rc_slow_clk_refcount: 0,
2072 rc_fast_div_clk_refcount: 0,
2073 apb_clk_refcount: 0,
2074 crypto_clk_refcount: 0,
2075 pll_80m_refcount: 0,
2076 rtc_fast_clk_refcount: 0,
2077 low_power_clk_refcount: 0,
2078 uart_mem_clk_refcount: 0,
2079 timg_calibration_clock_refcount: 0,
2080 sdm_function_clock_refcount: [0; 1],
2081 i2c_function_clock_refcount: [0; 1],
2082 rmt_sclk_refcount: [0; 1],
2083 spi_function_clock_refcount: [0; 1],
2084 timg_function_clock_refcount: [0; 2],
2085 timg_wdt_clock_refcount: [0; 2],
2086 uart_function_clock_refcount: [0; 2],
2087 uart_mem_clock_refcount: [0; 2],
2088 uart_baud_rate_generator_refcount: [0; 2],
2089 });
2090 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2091 ::core::sync::atomic::AtomicU32::new(0);
2092 static PLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2093 ::core::sync::atomic::AtomicU32::new(0);
2094 static SYSTEM_PRE_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2095 ::core::sync::atomic::AtomicU32::new(0);
2096 static SYSTEM_PRE_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2097 ::core::sync::atomic::AtomicU32::new(0);
2098 static CPU_PLL_DIV_OUT_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2099 ::core::sync::atomic::AtomicU32::new(0);
2100 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2101 ::core::sync::atomic::AtomicU32::new(0);
2102 static RC_FAST_CLK_DIV_N_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2103 ::core::sync::atomic::AtomicU32::new(0);
2104 static RTC_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2105 ::core::sync::atomic::AtomicU32::new(0);
2106 static RTC_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2107 ::core::sync::atomic::AtomicU32::new(0);
2108 static LOW_POWER_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2109 ::core::sync::atomic::AtomicU32::new(0);
2110 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2111 ::core::sync::atomic::AtomicU32::new(0);
2112 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2113 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2114 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2115 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2116 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2117 ::core::sync::atomic::AtomicU32::new(0);
2118 static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2119 ::core::sync::atomic::AtomicU32::new(0);
2120 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2121 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2122 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2123 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2124 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2125 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2126 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2127 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2128 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2129 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2130 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2131 let old_config = clocks.xtal_clk.replace(config);
2132 refresh_xtal_clk_downstream(clocks);
2133 configure_xtal_clk_impl(clocks, old_config, config);
2134 }
2135 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2136 clocks.xtal_clk
2137 }
2138 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2139 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2140 #[allow(unused_variables)]
2141 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
2142 config.value()
2143 }
2144 pub fn xtal_clk_frequency() -> u32 {
2145 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2146 }
2147 pub fn configure_pll_clk(clocks: &mut ClockTree, config: PllClkConfig) {
2148 let old_config = clocks.pll_clk.replace(config);
2149 refresh_pll_clk_downstream(clocks);
2150 configure_pll_clk_impl(clocks, old_config, config);
2151 }
2152 pub fn pll_clk_config(clocks: &mut ClockTree) -> Option<PllClkConfig> {
2153 clocks.pll_clk
2154 }
2155 pub fn request_pll_clk(clocks: &mut ClockTree) {
2156 trace!("Requesting PLL_CLK");
2157 trace!("Enabling PLL_CLK");
2158 request_xtal_clk(clocks);
2159 enable_pll_clk_impl(clocks, true);
2160 }
2161 pub fn release_pll_clk(clocks: &mut ClockTree) {
2162 trace!("Releasing PLL_CLK");
2163 trace!("Disabling PLL_CLK");
2164 enable_pll_clk_impl(clocks, false);
2165 release_xtal_clk(clocks);
2166 }
2167 #[allow(unused_variables)]
2168 pub fn pll_clk_config_frequency(clocks: &mut ClockTree, config: PllClkConfig) -> u32 {
2169 config.value()
2170 }
2171 pub fn pll_clk_frequency() -> u32 {
2172 PLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2173 }
2174 pub fn pll_clk_source_frequency() -> u32 {
2175 xtal_clk_frequency()
2176 }
2177 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2178 trace!("Requesting RC_FAST_CLK");
2179 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2180 trace!("Enabling RC_FAST_CLK");
2181 enable_rc_fast_clk_impl(clocks, true);
2182 }
2183 }
2184 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2185 trace!("Releasing RC_FAST_CLK");
2186 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2187 trace!("Disabling RC_FAST_CLK");
2188 enable_rc_fast_clk_impl(clocks, false);
2189 }
2190 }
2191 pub fn rc_fast_clk_frequency() -> u32 {
2192 17500000
2193 }
2194 #[cfg(use_xtal32k)]
2195 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2196 trace!("Requesting XTAL32K_CLK");
2197 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2198 trace!("Enabling XTAL32K_CLK");
2199 enable_xtal32k_clk_impl(clocks, true);
2200 }
2201 }
2202 #[cfg(use_xtal32k)]
2203 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2204 trace!("Releasing XTAL32K_CLK");
2205 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2206 trace!("Disabling XTAL32K_CLK");
2207 enable_xtal32k_clk_impl(clocks, false);
2208 }
2209 }
2210 #[cfg(use_xtal32k)]
2211 pub fn xtal32k_clk_frequency() -> u32 {
2212 32768
2213 }
2214 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2215 trace!("Requesting RC_SLOW_CLK");
2216 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
2217 trace!("Enabling RC_SLOW_CLK");
2218 enable_rc_slow_clk_impl(clocks, true);
2219 }
2220 }
2221 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2222 trace!("Releasing RC_SLOW_CLK");
2223 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
2224 trace!("Disabling RC_SLOW_CLK");
2225 enable_rc_slow_clk_impl(clocks, false);
2226 }
2227 }
2228 pub fn rc_slow_clk_frequency() -> u32 {
2229 136000
2230 }
2231 pub fn request_rc_fast_div_clk(clocks: &mut ClockTree) {
2232 trace!("Requesting RC_FAST_DIV_CLK");
2233 if increment_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
2234 trace!("Enabling RC_FAST_DIV_CLK");
2235 request_rc_fast_clk(clocks);
2236 enable_rc_fast_div_clk_impl(clocks, true);
2237 }
2238 }
2239 pub fn release_rc_fast_div_clk(clocks: &mut ClockTree) {
2240 trace!("Releasing RC_FAST_DIV_CLK");
2241 if decrement_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
2242 trace!("Disabling RC_FAST_DIV_CLK");
2243 enable_rc_fast_div_clk_impl(clocks, false);
2244 release_rc_fast_clk(clocks);
2245 }
2246 }
2247 pub fn rc_fast_div_clk_frequency() -> u32 {
2248 (rc_fast_clk_frequency() / 256)
2249 }
2250 pub fn rc_fast_div_clk_source_frequency() -> u32 {
2251 rc_fast_clk_frequency()
2252 }
2253 pub fn configure_system_pre_div_in(
2254 clocks: &mut ClockTree,
2255 new_selector: SystemPreDivInConfig,
2256 ) {
2257 let old_selector = clocks.system_pre_div_in.replace(new_selector);
2258 refresh_system_pre_div_in_downstream(clocks);
2259 match new_selector {
2260 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2261 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2262 }
2263 configure_system_pre_div_in_impl(clocks, old_selector, new_selector);
2264 if let Some(old_selector) = old_selector {
2265 match old_selector {
2266 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2267 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2268 }
2269 }
2270 }
2271 pub fn system_pre_div_in_config(clocks: &mut ClockTree) -> Option<SystemPreDivInConfig> {
2272 clocks.system_pre_div_in
2273 }
2274 pub fn request_system_pre_div_in(clocks: &mut ClockTree) {
2275 trace!("Requesting SYSTEM_PRE_DIV_IN");
2276 trace!("Enabling SYSTEM_PRE_DIV_IN");
2277 match unwrap!(clocks.system_pre_div_in) {
2278 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2279 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2280 }
2281 enable_system_pre_div_in_impl(clocks, true);
2282 }
2283 pub fn release_system_pre_div_in(clocks: &mut ClockTree) {
2284 trace!("Releasing SYSTEM_PRE_DIV_IN");
2285 trace!("Disabling SYSTEM_PRE_DIV_IN");
2286 enable_system_pre_div_in_impl(clocks, false);
2287 match unwrap!(clocks.system_pre_div_in) {
2288 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2289 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2290 }
2291 }
2292 #[allow(unused_variables)]
2293 pub fn system_pre_div_in_config_frequency(
2294 clocks: &mut ClockTree,
2295 config: SystemPreDivInConfig,
2296 ) -> u32 {
2297 match config {
2298 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2299 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2300 }
2301 }
2302 pub fn system_pre_div_in_frequency() -> u32 {
2303 SYSTEM_PRE_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2304 }
2305 pub fn system_pre_div_in_source_frequency(source: SystemPreDivInConfig) -> u32 {
2306 match source {
2307 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2308 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2309 }
2310 }
2311 pub fn configure_system_pre_div(clocks: &mut ClockTree, config: SystemPreDivConfig) {
2312 let old_config = clocks.system_pre_div.replace(config);
2313 refresh_system_pre_div_downstream(clocks);
2314 configure_system_pre_div_impl(clocks, old_config, config);
2315 }
2316 pub fn system_pre_div_config(clocks: &mut ClockTree) -> Option<SystemPreDivConfig> {
2317 clocks.system_pre_div
2318 }
2319 pub fn request_system_pre_div(clocks: &mut ClockTree) {
2320 trace!("Requesting SYSTEM_PRE_DIV");
2321 trace!("Enabling SYSTEM_PRE_DIV");
2322 request_system_pre_div_in(clocks);
2323 enable_system_pre_div_impl(clocks, true);
2324 }
2325 pub fn release_system_pre_div(clocks: &mut ClockTree) {
2326 trace!("Releasing SYSTEM_PRE_DIV");
2327 trace!("Disabling SYSTEM_PRE_DIV");
2328 enable_system_pre_div_impl(clocks, false);
2329 release_system_pre_div_in(clocks);
2330 }
2331 #[allow(unused_variables)]
2332 pub fn system_pre_div_config_frequency(
2333 clocks: &mut ClockTree,
2334 config: SystemPreDivConfig,
2335 ) -> u32 {
2336 (system_pre_div_in_frequency() / (config.divisor() + 1))
2337 }
2338 pub fn system_pre_div_frequency() -> u32 {
2339 SYSTEM_PRE_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2340 }
2341 pub fn system_pre_div_source_frequency() -> u32 {
2342 system_pre_div_in_frequency()
2343 }
2344 pub fn configure_cpu_pll_div_out(clocks: &mut ClockTree, config: CpuPllDivOutConfig) {
2345 let old_config = clocks.cpu_pll_div_out.replace(config);
2346 refresh_cpu_pll_div_out_downstream(clocks);
2347 configure_cpu_pll_div_out_impl(clocks, old_config, config);
2348 }
2349 pub fn cpu_pll_div_out_config(clocks: &mut ClockTree) -> Option<CpuPllDivOutConfig> {
2350 clocks.cpu_pll_div_out
2351 }
2352 pub fn request_cpu_pll_div_out(clocks: &mut ClockTree) {
2353 trace!("Requesting CPU_PLL_DIV_OUT");
2354 trace!("Enabling CPU_PLL_DIV_OUT");
2355 request_pll_clk(clocks);
2356 enable_cpu_pll_div_out_impl(clocks, true);
2357 }
2358 pub fn release_cpu_pll_div_out(clocks: &mut ClockTree) {
2359 trace!("Releasing CPU_PLL_DIV_OUT");
2360 trace!("Disabling CPU_PLL_DIV_OUT");
2361 enable_cpu_pll_div_out_impl(clocks, false);
2362 release_pll_clk(clocks);
2363 }
2364 #[allow(unused_variables)]
2365 pub fn cpu_pll_div_out_config_frequency(
2366 clocks: &mut ClockTree,
2367 config: CpuPllDivOutConfig,
2368 ) -> u32 {
2369 config.value()
2370 }
2371 pub fn cpu_pll_div_out_frequency() -> u32 {
2372 CPU_PLL_DIV_OUT_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2373 }
2374 pub fn cpu_pll_div_out_source_frequency() -> u32 {
2375 pll_clk_frequency()
2376 }
2377 pub fn configure_apb_clk(clocks: &mut ClockTree, new_selector: ApbClkConfig) {
2378 let old_selector = clocks.apb_clk.replace(new_selector);
2379 refresh_apb_clk_downstream(clocks);
2380 if clocks.apb_clk_refcount > 0 {
2381 match new_selector {
2382 ApbClkConfig::Pll80m => request_pll_80m(clocks),
2383 ApbClkConfig::Cpu => request_cpu_clk(clocks),
2384 }
2385 configure_apb_clk_impl(clocks, old_selector, new_selector);
2386 if let Some(old_selector) = old_selector {
2387 match old_selector {
2388 ApbClkConfig::Pll80m => release_pll_80m(clocks),
2389 ApbClkConfig::Cpu => release_cpu_clk(clocks),
2390 }
2391 }
2392 } else {
2393 configure_apb_clk_impl(clocks, old_selector, new_selector);
2394 }
2395 }
2396 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2397 clocks.apb_clk
2398 }
2399 pub fn request_apb_clk(clocks: &mut ClockTree) {
2400 trace!("Requesting APB_CLK");
2401 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2402 trace!("Enabling APB_CLK");
2403 match unwrap!(clocks.apb_clk) {
2404 ApbClkConfig::Pll80m => request_pll_80m(clocks),
2405 ApbClkConfig::Cpu => request_cpu_clk(clocks),
2406 }
2407 enable_apb_clk_impl(clocks, true);
2408 }
2409 }
2410 pub fn release_apb_clk(clocks: &mut ClockTree) {
2411 trace!("Releasing APB_CLK");
2412 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2413 trace!("Disabling APB_CLK");
2414 enable_apb_clk_impl(clocks, false);
2415 match unwrap!(clocks.apb_clk) {
2416 ApbClkConfig::Pll80m => release_pll_80m(clocks),
2417 ApbClkConfig::Cpu => release_cpu_clk(clocks),
2418 }
2419 }
2420 }
2421 #[allow(unused_variables)]
2422 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2423 match config {
2424 ApbClkConfig::Pll80m => pll_80m_frequency(),
2425 ApbClkConfig::Cpu => cpu_clk_frequency(),
2426 }
2427 }
2428 pub fn apb_clk_frequency() -> u32 {
2429 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2430 }
2431 pub fn apb_clk_source_frequency(source: ApbClkConfig) -> u32 {
2432 match source {
2433 ApbClkConfig::Pll80m => pll_80m_frequency(),
2434 ApbClkConfig::Cpu => cpu_clk_frequency(),
2435 }
2436 }
2437 pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
2438 let old_selector = clocks.crypto_clk.replace(new_selector);
2439 refresh_crypto_clk_downstream(clocks);
2440 if clocks.crypto_clk_refcount > 0 {
2441 match new_selector {
2442 CryptoClkConfig::Pll160m => request_pll_160m(clocks),
2443 CryptoClkConfig::Cpu => request_cpu_clk(clocks),
2444 }
2445 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2446 if let Some(old_selector) = old_selector {
2447 match old_selector {
2448 CryptoClkConfig::Pll160m => release_pll_160m(clocks),
2449 CryptoClkConfig::Cpu => release_cpu_clk(clocks),
2450 }
2451 }
2452 } else {
2453 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2454 }
2455 }
2456 pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
2457 clocks.crypto_clk
2458 }
2459 pub fn request_crypto_clk(clocks: &mut ClockTree) {
2460 trace!("Requesting CRYPTO_CLK");
2461 if increment_reference_count(&mut clocks.crypto_clk_refcount) {
2462 trace!("Enabling CRYPTO_CLK");
2463 match unwrap!(clocks.crypto_clk) {
2464 CryptoClkConfig::Pll160m => request_pll_160m(clocks),
2465 CryptoClkConfig::Cpu => request_cpu_clk(clocks),
2466 }
2467 enable_crypto_clk_impl(clocks, true);
2468 }
2469 }
2470 pub fn release_crypto_clk(clocks: &mut ClockTree) {
2471 trace!("Releasing CRYPTO_CLK");
2472 if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
2473 trace!("Disabling CRYPTO_CLK");
2474 enable_crypto_clk_impl(clocks, false);
2475 match unwrap!(clocks.crypto_clk) {
2476 CryptoClkConfig::Pll160m => release_pll_160m(clocks),
2477 CryptoClkConfig::Cpu => release_cpu_clk(clocks),
2478 }
2479 }
2480 }
2481 #[allow(unused_variables)]
2482 pub fn crypto_clk_config_frequency(clocks: &mut ClockTree, config: CryptoClkConfig) -> u32 {
2483 match config {
2484 CryptoClkConfig::Pll160m => pll_160m_frequency(),
2485 CryptoClkConfig::Cpu => cpu_clk_frequency(),
2486 }
2487 }
2488 pub fn crypto_clk_frequency() -> u32 {
2489 CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2490 }
2491 pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
2492 match source {
2493 CryptoClkConfig::Pll160m => pll_160m_frequency(),
2494 CryptoClkConfig::Cpu => cpu_clk_frequency(),
2495 }
2496 }
2497 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
2498 let old_selector = clocks.cpu_clk.replace(new_selector);
2499 refresh_cpu_clk_downstream(clocks);
2500 match new_selector {
2501 CpuClkConfig::Xtal => {
2502 configure_apb_clk(clocks, ApbClkConfig::Cpu);
2503 configure_crypto_clk(clocks, CryptoClkConfig::Cpu);
2504 configure_system_pre_div_in(clocks, SystemPreDivInConfig::Xtal);
2505 }
2506 CpuClkConfig::RcFast => {
2507 configure_apb_clk(clocks, ApbClkConfig::Cpu);
2508 configure_crypto_clk(clocks, CryptoClkConfig::Cpu);
2509 configure_system_pre_div_in(clocks, SystemPreDivInConfig::RcFast);
2510 }
2511 CpuClkConfig::Pll => {
2512 configure_apb_clk(clocks, ApbClkConfig::Pll80m);
2513 configure_crypto_clk(clocks, CryptoClkConfig::Pll160m);
2514 }
2515 }
2516 match new_selector {
2517 CpuClkConfig::Xtal => request_system_pre_div(clocks),
2518 CpuClkConfig::RcFast => request_system_pre_div(clocks),
2519 CpuClkConfig::Pll => request_cpu_pll_div_out(clocks),
2520 }
2521 configure_cpu_clk_impl(clocks, old_selector, new_selector);
2522 if let Some(old_selector) = old_selector {
2523 match old_selector {
2524 CpuClkConfig::Xtal => release_system_pre_div(clocks),
2525 CpuClkConfig::RcFast => release_system_pre_div(clocks),
2526 CpuClkConfig::Pll => release_cpu_pll_div_out(clocks),
2527 }
2528 }
2529 }
2530 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2531 clocks.cpu_clk
2532 }
2533 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2534 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2535 #[allow(unused_variables)]
2536 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2537 match config {
2538 CpuClkConfig::Xtal => system_pre_div_frequency(),
2539 CpuClkConfig::RcFast => system_pre_div_frequency(),
2540 CpuClkConfig::Pll => cpu_pll_div_out_frequency(),
2541 }
2542 }
2543 pub fn cpu_clk_frequency() -> u32 {
2544 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2545 }
2546 pub fn request_pll_80m(clocks: &mut ClockTree) {
2547 trace!("Requesting PLL_80M");
2548 if increment_reference_count(&mut clocks.pll_80m_refcount) {
2549 trace!("Enabling PLL_80M");
2550 request_cpu_clk(clocks);
2551 enable_pll_80m_impl(clocks, true);
2552 }
2553 }
2554 pub fn release_pll_80m(clocks: &mut ClockTree) {
2555 trace!("Releasing PLL_80M");
2556 if decrement_reference_count(&mut clocks.pll_80m_refcount) {
2557 trace!("Disabling PLL_80M");
2558 enable_pll_80m_impl(clocks, false);
2559 release_cpu_clk(clocks);
2560 }
2561 }
2562 pub fn pll_80m_frequency() -> u32 {
2563 80000000
2564 }
2565 pub fn pll_80m_source_frequency() -> u32 {
2566 cpu_clk_frequency()
2567 }
2568 pub fn request_pll_160m(clocks: &mut ClockTree) {
2569 trace!("Requesting PLL_160M");
2570 trace!("Enabling PLL_160M");
2571 request_cpu_clk(clocks);
2572 enable_pll_160m_impl(clocks, true);
2573 }
2574 pub fn release_pll_160m(clocks: &mut ClockTree) {
2575 trace!("Releasing PLL_160M");
2576 trace!("Disabling PLL_160M");
2577 enable_pll_160m_impl(clocks, false);
2578 release_cpu_clk(clocks);
2579 }
2580 pub fn pll_160m_frequency() -> u32 {
2581 160000000
2582 }
2583 pub fn pll_160m_source_frequency() -> u32 {
2584 cpu_clk_frequency()
2585 }
2586 pub fn configure_rc_fast_clk_div_n(clocks: &mut ClockTree, config: RcFastClkDivNConfig) {
2587 let old_config = clocks.rc_fast_clk_div_n.replace(config);
2588 refresh_rc_fast_clk_div_n_downstream(clocks);
2589 configure_rc_fast_clk_div_n_impl(clocks, old_config, config);
2590 }
2591 pub fn rc_fast_clk_div_n_config(clocks: &mut ClockTree) -> Option<RcFastClkDivNConfig> {
2592 clocks.rc_fast_clk_div_n
2593 }
2594 pub fn request_rc_fast_clk_div_n(clocks: &mut ClockTree) {
2595 trace!("Requesting RC_FAST_CLK_DIV_N");
2596 trace!("Enabling RC_FAST_CLK_DIV_N");
2597 request_rc_fast_clk(clocks);
2598 enable_rc_fast_clk_div_n_impl(clocks, true);
2599 }
2600 pub fn release_rc_fast_clk_div_n(clocks: &mut ClockTree) {
2601 trace!("Releasing RC_FAST_CLK_DIV_N");
2602 trace!("Disabling RC_FAST_CLK_DIV_N");
2603 enable_rc_fast_clk_div_n_impl(clocks, false);
2604 release_rc_fast_clk(clocks);
2605 }
2606 #[allow(unused_variables)]
2607 pub fn rc_fast_clk_div_n_config_frequency(
2608 clocks: &mut ClockTree,
2609 config: RcFastClkDivNConfig,
2610 ) -> u32 {
2611 (rc_fast_clk_frequency() / (config.divisor() + 1))
2612 }
2613 pub fn rc_fast_clk_div_n_frequency() -> u32 {
2614 RC_FAST_CLK_DIV_N_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2615 }
2616 pub fn rc_fast_clk_div_n_source_frequency() -> u32 {
2617 rc_fast_clk_frequency()
2618 }
2619 pub fn request_xtal_div_clk(clocks: &mut ClockTree) {
2620 trace!("Requesting XTAL_DIV_CLK");
2621 trace!("Enabling XTAL_DIV_CLK");
2622 request_xtal_clk(clocks);
2623 enable_xtal_div_clk_impl(clocks, true);
2624 }
2625 pub fn release_xtal_div_clk(clocks: &mut ClockTree) {
2626 trace!("Releasing XTAL_DIV_CLK");
2627 trace!("Disabling XTAL_DIV_CLK");
2628 enable_xtal_div_clk_impl(clocks, false);
2629 release_xtal_clk(clocks);
2630 }
2631 pub fn xtal_div_clk_frequency() -> u32 {
2632 (xtal_clk_frequency() / 2)
2633 }
2634 pub fn xtal_div_clk_source_frequency() -> u32 {
2635 xtal_clk_frequency()
2636 }
2637 pub fn configure_rtc_slow_clk(clocks: &mut ClockTree, new_selector: RtcSlowClkConfig) {
2638 let old_selector = clocks.rtc_slow_clk.replace(new_selector);
2639 refresh_rtc_slow_clk_downstream(clocks);
2640 match new_selector {
2641 #[cfg(use_xtal32k)]
2642 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2643 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2644 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
2645 }
2646 configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
2647 if let Some(old_selector) = old_selector {
2648 match old_selector {
2649 #[cfg(use_xtal32k)]
2650 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2651 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2652 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
2653 }
2654 }
2655 }
2656 pub fn rtc_slow_clk_config(clocks: &mut ClockTree) -> Option<RtcSlowClkConfig> {
2657 clocks.rtc_slow_clk
2658 }
2659 pub fn request_rtc_slow_clk(clocks: &mut ClockTree) {
2660 trace!("Requesting RTC_SLOW_CLK");
2661 trace!("Enabling RTC_SLOW_CLK");
2662 match unwrap!(clocks.rtc_slow_clk) {
2663 #[cfg(use_xtal32k)]
2664 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2665 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2666 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
2667 }
2668 enable_rtc_slow_clk_impl(clocks, true);
2669 }
2670 pub fn release_rtc_slow_clk(clocks: &mut ClockTree) {
2671 trace!("Releasing RTC_SLOW_CLK");
2672 trace!("Disabling RTC_SLOW_CLK");
2673 enable_rtc_slow_clk_impl(clocks, false);
2674 match unwrap!(clocks.rtc_slow_clk) {
2675 #[cfg(use_xtal32k)]
2676 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2677 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2678 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
2679 }
2680 }
2681 #[allow(unused_variables)]
2682 pub fn rtc_slow_clk_config_frequency(
2683 clocks: &mut ClockTree,
2684 config: RtcSlowClkConfig,
2685 ) -> u32 {
2686 match config {
2687 #[cfg(use_xtal32k)]
2688 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2689 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2690 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
2691 }
2692 }
2693 pub fn rtc_slow_clk_frequency() -> u32 {
2694 RTC_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2695 }
2696 pub fn rtc_slow_clk_source_frequency(source: RtcSlowClkConfig) -> u32 {
2697 match source {
2698 #[cfg(use_xtal32k)]
2699 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2700 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2701 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
2702 }
2703 }
2704 pub fn configure_rtc_fast_clk(clocks: &mut ClockTree, new_selector: RtcFastClkConfig) {
2705 let old_selector = clocks.rtc_fast_clk.replace(new_selector);
2706 refresh_rtc_fast_clk_downstream(clocks);
2707 if clocks.rtc_fast_clk_refcount > 0 {
2708 match new_selector {
2709 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
2710 RtcFastClkConfig::Rc => request_rc_fast_clk_div_n(clocks),
2711 }
2712 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
2713 if let Some(old_selector) = old_selector {
2714 match old_selector {
2715 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
2716 RtcFastClkConfig::Rc => release_rc_fast_clk_div_n(clocks),
2717 }
2718 }
2719 } else {
2720 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
2721 }
2722 }
2723 pub fn rtc_fast_clk_config(clocks: &mut ClockTree) -> Option<RtcFastClkConfig> {
2724 clocks.rtc_fast_clk
2725 }
2726 pub fn request_rtc_fast_clk(clocks: &mut ClockTree) {
2727 trace!("Requesting RTC_FAST_CLK");
2728 if increment_reference_count(&mut clocks.rtc_fast_clk_refcount) {
2729 trace!("Enabling RTC_FAST_CLK");
2730 match unwrap!(clocks.rtc_fast_clk) {
2731 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
2732 RtcFastClkConfig::Rc => request_rc_fast_clk_div_n(clocks),
2733 }
2734 enable_rtc_fast_clk_impl(clocks, true);
2735 }
2736 }
2737 pub fn release_rtc_fast_clk(clocks: &mut ClockTree) {
2738 trace!("Releasing RTC_FAST_CLK");
2739 if decrement_reference_count(&mut clocks.rtc_fast_clk_refcount) {
2740 trace!("Disabling RTC_FAST_CLK");
2741 enable_rtc_fast_clk_impl(clocks, false);
2742 match unwrap!(clocks.rtc_fast_clk) {
2743 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
2744 RtcFastClkConfig::Rc => release_rc_fast_clk_div_n(clocks),
2745 }
2746 }
2747 }
2748 #[allow(unused_variables)]
2749 pub fn rtc_fast_clk_config_frequency(
2750 clocks: &mut ClockTree,
2751 config: RtcFastClkConfig,
2752 ) -> u32 {
2753 match config {
2754 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
2755 RtcFastClkConfig::Rc => rc_fast_clk_div_n_frequency(),
2756 }
2757 }
2758 pub fn rtc_fast_clk_frequency() -> u32 {
2759 RTC_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2760 }
2761 pub fn rtc_fast_clk_source_frequency(source: RtcFastClkConfig) -> u32 {
2762 match source {
2763 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
2764 RtcFastClkConfig::Rc => rc_fast_clk_div_n_frequency(),
2765 }
2766 }
2767 pub fn configure_low_power_clk(clocks: &mut ClockTree, new_selector: LowPowerClkConfig) {
2768 let old_selector = clocks.low_power_clk.replace(new_selector);
2769 refresh_low_power_clk_downstream(clocks);
2770 if clocks.low_power_clk_refcount > 0 {
2771 match new_selector {
2772 LowPowerClkConfig::Xtal => request_xtal_clk(clocks),
2773 LowPowerClkConfig::RcFast => request_rc_fast_clk(clocks),
2774 #[cfg(use_xtal32k)]
2775 LowPowerClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2776 LowPowerClkConfig::RtcSlow => request_rtc_slow_clk(clocks),
2777 }
2778 configure_low_power_clk_impl(clocks, old_selector, new_selector);
2779 if let Some(old_selector) = old_selector {
2780 match old_selector {
2781 LowPowerClkConfig::Xtal => release_xtal_clk(clocks),
2782 LowPowerClkConfig::RcFast => release_rc_fast_clk(clocks),
2783 #[cfg(use_xtal32k)]
2784 LowPowerClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2785 LowPowerClkConfig::RtcSlow => release_rtc_slow_clk(clocks),
2786 }
2787 }
2788 } else {
2789 configure_low_power_clk_impl(clocks, old_selector, new_selector);
2790 }
2791 }
2792 pub fn low_power_clk_config(clocks: &mut ClockTree) -> Option<LowPowerClkConfig> {
2793 clocks.low_power_clk
2794 }
2795 pub fn request_low_power_clk(clocks: &mut ClockTree) {
2796 trace!("Requesting LOW_POWER_CLK");
2797 if increment_reference_count(&mut clocks.low_power_clk_refcount) {
2798 trace!("Enabling LOW_POWER_CLK");
2799 match unwrap!(clocks.low_power_clk) {
2800 LowPowerClkConfig::Xtal => request_xtal_clk(clocks),
2801 LowPowerClkConfig::RcFast => request_rc_fast_clk(clocks),
2802 #[cfg(use_xtal32k)]
2803 LowPowerClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2804 LowPowerClkConfig::RtcSlow => request_rtc_slow_clk(clocks),
2805 }
2806 enable_low_power_clk_impl(clocks, true);
2807 }
2808 }
2809 pub fn release_low_power_clk(clocks: &mut ClockTree) {
2810 trace!("Releasing LOW_POWER_CLK");
2811 if decrement_reference_count(&mut clocks.low_power_clk_refcount) {
2812 trace!("Disabling LOW_POWER_CLK");
2813 enable_low_power_clk_impl(clocks, false);
2814 match unwrap!(clocks.low_power_clk) {
2815 LowPowerClkConfig::Xtal => release_xtal_clk(clocks),
2816 LowPowerClkConfig::RcFast => release_rc_fast_clk(clocks),
2817 #[cfg(use_xtal32k)]
2818 LowPowerClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2819 LowPowerClkConfig::RtcSlow => release_rtc_slow_clk(clocks),
2820 }
2821 }
2822 }
2823 #[allow(unused_variables)]
2824 pub fn low_power_clk_config_frequency(
2825 clocks: &mut ClockTree,
2826 config: LowPowerClkConfig,
2827 ) -> u32 {
2828 match config {
2829 LowPowerClkConfig::Xtal => xtal_clk_frequency(),
2830 LowPowerClkConfig::RcFast => rc_fast_clk_frequency(),
2831 #[cfg(use_xtal32k)]
2832 LowPowerClkConfig::Xtal32k => xtal32k_clk_frequency(),
2833 LowPowerClkConfig::RtcSlow => rtc_slow_clk_frequency(),
2834 }
2835 }
2836 pub fn low_power_clk_frequency() -> u32 {
2837 LOW_POWER_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2838 }
2839 pub fn low_power_clk_source_frequency(source: LowPowerClkConfig) -> u32 {
2840 match source {
2841 LowPowerClkConfig::Xtal => xtal_clk_frequency(),
2842 LowPowerClkConfig::RcFast => rc_fast_clk_frequency(),
2843 #[cfg(use_xtal32k)]
2844 LowPowerClkConfig::Xtal32k => xtal32k_clk_frequency(),
2845 LowPowerClkConfig::RtcSlow => rtc_slow_clk_frequency(),
2846 }
2847 }
2848 pub fn request_uart_mem_clk(clocks: &mut ClockTree) {
2849 trace!("Requesting UART_MEM_CLK");
2850 if increment_reference_count(&mut clocks.uart_mem_clk_refcount) {
2851 trace!("Enabling UART_MEM_CLK");
2852 request_xtal_clk(clocks);
2853 enable_uart_mem_clk_impl(clocks, true);
2854 }
2855 }
2856 pub fn release_uart_mem_clk(clocks: &mut ClockTree) {
2857 trace!("Releasing UART_MEM_CLK");
2858 if decrement_reference_count(&mut clocks.uart_mem_clk_refcount) {
2859 trace!("Disabling UART_MEM_CLK");
2860 enable_uart_mem_clk_impl(clocks, false);
2861 release_xtal_clk(clocks);
2862 }
2863 }
2864 pub fn uart_mem_clk_frequency() -> u32 {
2865 xtal_clk_frequency()
2866 }
2867 pub fn uart_mem_clk_source_frequency(source: UartMemClkConfig) -> u32 {
2868 match source {
2869 UartMemClkConfig::Xtal => xtal_clk_frequency(),
2870 }
2871 }
2872 pub fn configure_timg_calibration_clock(
2873 clocks: &mut ClockTree,
2874 new_selector: TimgCalibrationClockConfig,
2875 ) {
2876 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2877 refresh_timg_calibration_clock_downstream(clocks);
2878 if clocks.timg_calibration_clock_refcount > 0 {
2879 match new_selector {
2880 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2881 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
2882 #[cfg(use_xtal32k)]
2883 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2884 }
2885 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2886 if let Some(old_selector) = old_selector {
2887 match old_selector {
2888 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2889 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
2890 #[cfg(use_xtal32k)]
2891 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2892 }
2893 }
2894 } else {
2895 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2896 }
2897 }
2898 pub fn timg_calibration_clock_config(
2899 clocks: &mut ClockTree,
2900 ) -> Option<TimgCalibrationClockConfig> {
2901 clocks.timg_calibration_clock
2902 }
2903 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2904 trace!("Requesting TIMG_CALIBRATION_CLOCK");
2905 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2906 trace!("Enabling TIMG_CALIBRATION_CLOCK");
2907 crate::rtc_cntl::WakeLock::acquire();
2908 match unwrap!(clocks.timg_calibration_clock) {
2909 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
2910 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
2911 #[cfg(use_xtal32k)]
2912 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2913 }
2914 enable_timg_calibration_clock_impl(clocks, true);
2915 }
2916 }
2917 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2918 trace!("Releasing TIMG_CALIBRATION_CLOCK");
2919 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2920 trace!("Disabling TIMG_CALIBRATION_CLOCK");
2921 crate::rtc_cntl::WakeLock::release();
2922 enable_timg_calibration_clock_impl(clocks, false);
2923 match unwrap!(clocks.timg_calibration_clock) {
2924 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
2925 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
2926 #[cfg(use_xtal32k)]
2927 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2928 }
2929 }
2930 }
2931 #[allow(unused_variables)]
2932 pub fn timg_calibration_clock_config_frequency(
2933 clocks: &mut ClockTree,
2934 config: TimgCalibrationClockConfig,
2935 ) -> u32 {
2936 match config {
2937 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
2938 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
2939 #[cfg(use_xtal32k)]
2940 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2941 }
2942 }
2943 pub fn timg_calibration_clock_frequency() -> u32 {
2944 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2945 }
2946 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
2947 match source {
2948 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
2949 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
2950 #[cfg(use_xtal32k)]
2951 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2952 }
2953 }
2954 impl SdmInstance {
2955 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2956 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2957 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
2958 {
2959 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2960 request_apb_clk(clocks);
2961 self.enable_function_clock_impl(clocks, true);
2962 }
2963 }
2964 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2965 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2966 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
2967 {
2968 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2969 self.enable_function_clock_impl(clocks, false);
2970 release_apb_clk(clocks);
2971 }
2972 }
2973 pub fn function_clock_frequency(self) -> u32 {
2974 apb_clk_frequency()
2975 }
2976 pub fn function_clock_source_frequency() -> u32 {
2977 apb_clk_frequency()
2978 }
2979 }
2980 impl I2cInstance {
2981 pub fn configure_function_clock(
2982 self,
2983 clocks: &mut ClockTree,
2984 config: I2cFunctionClockConfig,
2985 ) {
2986 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
2987 refresh_i2c_function_clock_downstream(clocks, self);
2988 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
2989 match config.sclk {
2990 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2991 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2992 }
2993 self.configure_function_clock_impl(clocks, old_config, config);
2994 if let Some(old_config) = old_config {
2995 match old_config.sclk {
2996 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2997 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2998 }
2999 }
3000 } else {
3001 self.configure_function_clock_impl(clocks, old_config, config);
3002 }
3003 }
3004 pub fn function_clock_config(
3005 self,
3006 clocks: &mut ClockTree,
3007 ) -> Option<I2cFunctionClockConfig> {
3008 clocks.i2c_function_clock[self as usize]
3009 }
3010 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3011 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3012 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3013 {
3014 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3015 crate::rtc_cntl::WakeLock::acquire();
3016 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3017 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3018 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3019 }
3020 self.enable_function_clock_impl(clocks, true);
3021 }
3022 }
3023 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3024 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3025 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3026 {
3027 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3028 crate::rtc_cntl::WakeLock::release();
3029 self.enable_function_clock_impl(clocks, false);
3030 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3031 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3032 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3033 }
3034 }
3035 }
3036 #[allow(unused_variables)]
3037 pub fn function_clock_config_frequency(
3038 clocks: &mut ClockTree,
3039 config: I2cFunctionClockConfig,
3040 ) -> u32 {
3041 (match config.sclk {
3042 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3043 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3044 } / (config.div_num() + 1))
3045 }
3046 pub fn function_clock_frequency(self) -> u32 {
3047 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3048 .load(::core::sync::atomic::Ordering::Acquire)
3049 }
3050 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3051 match sclk {
3052 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3053 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3054 }
3055 }
3056 }
3057 impl RmtInstance {
3058 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3059 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3060 refresh_rmt_sclk_downstream(clocks, self);
3061 if clocks.rmt_sclk_refcount[self as usize] > 0 {
3062 match new_selector {
3063 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3064 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3065 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3066 }
3067 self.configure_sclk_impl(clocks, old_selector, new_selector);
3068 if let Some(old_selector) = old_selector {
3069 match old_selector {
3070 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3071 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3072 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3073 }
3074 }
3075 } else {
3076 self.configure_sclk_impl(clocks, old_selector, new_selector);
3077 }
3078 }
3079 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3080 clocks.rmt_sclk[self as usize]
3081 }
3082 pub fn request_sclk(self, clocks: &mut ClockTree) {
3083 trace!("Requesting {:?}::SCLK", self);
3084 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3085 trace!("Enabling {:?}::SCLK", self);
3086 crate::rtc_cntl::WakeLock::acquire();
3087 match unwrap!(clocks.rmt_sclk[self as usize]) {
3088 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3089 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3090 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3091 }
3092 self.enable_sclk_impl(clocks, true);
3093 }
3094 }
3095 pub fn release_sclk(self, clocks: &mut ClockTree) {
3096 trace!("Releasing {:?}::SCLK", self);
3097 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3098 trace!("Disabling {:?}::SCLK", self);
3099 crate::rtc_cntl::WakeLock::release();
3100 self.enable_sclk_impl(clocks, false);
3101 match unwrap!(clocks.rmt_sclk[self as usize]) {
3102 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3103 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3104 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3105 }
3106 }
3107 }
3108 #[allow(unused_variables)]
3109 pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
3110 match config {
3111 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3112 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3113 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3114 }
3115 }
3116 pub fn sclk_frequency(self) -> u32 {
3117 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3118 }
3119 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3120 match source {
3121 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3122 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3123 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3124 }
3125 }
3126 }
3127 impl SpiInstance {
3128 pub fn configure_function_clock(
3129 self,
3130 clocks: &mut ClockTree,
3131 new_selector: SpiFunctionClockConfig,
3132 ) {
3133 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3134 refresh_spi_function_clock_downstream(clocks, self);
3135 if clocks.spi_function_clock_refcount[self as usize] > 0 {
3136 match new_selector {
3137 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3138 SpiFunctionClockConfig::Pll80m => request_pll_80m(clocks),
3139 }
3140 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3141 if let Some(old_selector) = old_selector {
3142 match old_selector {
3143 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3144 SpiFunctionClockConfig::Pll80m => release_pll_80m(clocks),
3145 }
3146 }
3147 } else {
3148 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3149 }
3150 }
3151 pub fn function_clock_config(
3152 self,
3153 clocks: &mut ClockTree,
3154 ) -> Option<SpiFunctionClockConfig> {
3155 clocks.spi_function_clock[self as usize]
3156 }
3157 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3158 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3159 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3160 {
3161 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3162 crate::rtc_cntl::WakeLock::acquire();
3163 match unwrap!(clocks.spi_function_clock[self as usize]) {
3164 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3165 SpiFunctionClockConfig::Pll80m => request_pll_80m(clocks),
3166 }
3167 self.enable_function_clock_impl(clocks, true);
3168 }
3169 }
3170 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3171 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3172 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3173 {
3174 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3175 crate::rtc_cntl::WakeLock::release();
3176 self.enable_function_clock_impl(clocks, false);
3177 match unwrap!(clocks.spi_function_clock[self as usize]) {
3178 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3179 SpiFunctionClockConfig::Pll80m => release_pll_80m(clocks),
3180 }
3181 }
3182 }
3183 #[allow(unused_variables)]
3184 pub fn function_clock_config_frequency(
3185 clocks: &mut ClockTree,
3186 config: SpiFunctionClockConfig,
3187 ) -> u32 {
3188 match config {
3189 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3190 SpiFunctionClockConfig::Pll80m => pll_80m_frequency(),
3191 }
3192 }
3193 pub fn function_clock_frequency(self) -> u32 {
3194 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3195 .load(::core::sync::atomic::Ordering::Acquire)
3196 }
3197 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3198 match source {
3199 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3200 SpiFunctionClockConfig::Pll80m => pll_80m_frequency(),
3201 }
3202 }
3203 }
3204 impl TimgInstance {
3205 pub fn configure_function_clock(
3206 self,
3207 clocks: &mut ClockTree,
3208 new_selector: TimgFunctionClockConfig,
3209 ) {
3210 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3211 refresh_timg_function_clock_downstream(clocks, self);
3212 if clocks.timg_function_clock_refcount[self as usize] > 0 {
3213 match new_selector {
3214 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3215 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3216 }
3217 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3218 if let Some(old_selector) = old_selector {
3219 match old_selector {
3220 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3221 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3222 }
3223 }
3224 } else {
3225 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3226 }
3227 }
3228 pub fn function_clock_config(
3229 self,
3230 clocks: &mut ClockTree,
3231 ) -> Option<TimgFunctionClockConfig> {
3232 clocks.timg_function_clock[self as usize]
3233 }
3234 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3235 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3236 if increment_reference_count(
3237 &mut clocks.timg_function_clock_refcount[self as usize],
3238 ) {
3239 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3240 match unwrap!(clocks.timg_function_clock[self as usize]) {
3241 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3242 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3243 }
3244 self.enable_function_clock_impl(clocks, true);
3245 }
3246 }
3247 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3248 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3249 if decrement_reference_count(
3250 &mut clocks.timg_function_clock_refcount[self as usize],
3251 ) {
3252 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3253 self.enable_function_clock_impl(clocks, false);
3254 match unwrap!(clocks.timg_function_clock[self as usize]) {
3255 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3256 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3257 }
3258 }
3259 }
3260 #[allow(unused_variables)]
3261 pub fn function_clock_config_frequency(
3262 clocks: &mut ClockTree,
3263 config: TimgFunctionClockConfig,
3264 ) -> u32 {
3265 match config {
3266 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3267 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3268 }
3269 }
3270 pub fn function_clock_frequency(self) -> u32 {
3271 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3272 .load(::core::sync::atomic::Ordering::Acquire)
3273 }
3274 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3275 match source {
3276 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3277 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3278 }
3279 }
3280 pub fn configure_wdt_clock(
3281 self,
3282 clocks: &mut ClockTree,
3283 new_selector: TimgWdtClockConfig,
3284 ) {
3285 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3286 refresh_timg_wdt_clock_downstream(clocks, self);
3287 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
3288 match new_selector {
3289 TimgWdtClockConfig::ApbClk => request_apb_clk(clocks),
3290 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3291 }
3292 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3293 if let Some(old_selector) = old_selector {
3294 match old_selector {
3295 TimgWdtClockConfig::ApbClk => release_apb_clk(clocks),
3296 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3297 }
3298 }
3299 } else {
3300 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3301 }
3302 }
3303 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3304 clocks.timg_wdt_clock[self as usize]
3305 }
3306 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3307 trace!("Requesting {:?}::WDT_CLOCK", self);
3308 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3309 trace!("Enabling {:?}::WDT_CLOCK", self);
3310 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3311 TimgWdtClockConfig::ApbClk => request_apb_clk(clocks),
3312 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3313 }
3314 self.enable_wdt_clock_impl(clocks, true);
3315 }
3316 }
3317 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3318 trace!("Releasing {:?}::WDT_CLOCK", self);
3319 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3320 trace!("Disabling {:?}::WDT_CLOCK", self);
3321 self.enable_wdt_clock_impl(clocks, false);
3322 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3323 TimgWdtClockConfig::ApbClk => release_apb_clk(clocks),
3324 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3325 }
3326 }
3327 }
3328 #[allow(unused_variables)]
3329 pub fn wdt_clock_config_frequency(
3330 clocks: &mut ClockTree,
3331 config: TimgWdtClockConfig,
3332 ) -> u32 {
3333 match config {
3334 TimgWdtClockConfig::ApbClk => apb_clk_frequency(),
3335 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3336 }
3337 }
3338 pub fn wdt_clock_frequency(self) -> u32 {
3339 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3340 .load(::core::sync::atomic::Ordering::Acquire)
3341 }
3342 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3343 match source {
3344 TimgWdtClockConfig::ApbClk => apb_clk_frequency(),
3345 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3346 }
3347 }
3348 }
3349 impl UartInstance {
3350 pub fn configure_function_clock(
3351 self,
3352 clocks: &mut ClockTree,
3353 config: UartFunctionClockConfig,
3354 ) {
3355 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3356 refresh_uart_function_clock_downstream(clocks, self);
3357 if clocks.uart_function_clock_refcount[self as usize] > 0 {
3358 match config.sclk {
3359 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3360 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3361 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3362 }
3363 self.configure_function_clock_impl(clocks, old_config, config);
3364 if let Some(old_config) = old_config {
3365 match old_config.sclk {
3366 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3367 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3368 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3369 }
3370 }
3371 } else {
3372 self.configure_function_clock_impl(clocks, old_config, config);
3373 }
3374 }
3375 pub fn function_clock_config(
3376 self,
3377 clocks: &mut ClockTree,
3378 ) -> Option<UartFunctionClockConfig> {
3379 clocks.uart_function_clock[self as usize]
3380 }
3381 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3382 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3383 if increment_reference_count(
3384 &mut clocks.uart_function_clock_refcount[self as usize],
3385 ) {
3386 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3387 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3388 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3389 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3390 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3391 }
3392 self.enable_function_clock_impl(clocks, true);
3393 }
3394 }
3395 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3396 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3397 if decrement_reference_count(
3398 &mut clocks.uart_function_clock_refcount[self as usize],
3399 ) {
3400 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3401 self.enable_function_clock_impl(clocks, false);
3402 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3403 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3404 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3405 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3406 }
3407 }
3408 }
3409 #[allow(unused_variables)]
3410 pub fn function_clock_config_frequency(
3411 clocks: &mut ClockTree,
3412 config: UartFunctionClockConfig,
3413 ) -> u32 {
3414 (match config.sclk {
3415 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3416 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3417 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3418 } / (config.div_num() + 1))
3419 }
3420 pub fn function_clock_frequency(self) -> u32 {
3421 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3422 .load(::core::sync::atomic::Ordering::Acquire)
3423 }
3424 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3425 match sclk {
3426 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3427 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3428 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3429 }
3430 }
3431 pub fn request_mem_clock(self, clocks: &mut ClockTree) {
3432 trace!("Requesting {:?}::MEM_CLOCK", self);
3433 if increment_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3434 trace!("Enabling {:?}::MEM_CLOCK", self);
3435 request_uart_mem_clk(clocks);
3436 self.enable_mem_clock_impl(clocks, true);
3437 }
3438 }
3439 pub fn release_mem_clock(self, clocks: &mut ClockTree) {
3440 trace!("Releasing {:?}::MEM_CLOCK", self);
3441 if decrement_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3442 trace!("Disabling {:?}::MEM_CLOCK", self);
3443 self.enable_mem_clock_impl(clocks, false);
3444 release_uart_mem_clk(clocks);
3445 }
3446 }
3447 pub fn mem_clock_frequency(self) -> u32 {
3448 uart_mem_clk_frequency()
3449 }
3450 pub fn mem_clock_source_frequency() -> u32 {
3451 uart_mem_clk_frequency()
3452 }
3453 pub fn configure_baud_rate_generator(
3454 self,
3455 clocks: &mut ClockTree,
3456 config: UartBaudRateGeneratorConfig,
3457 ) {
3458 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3459 refresh_uart_baud_rate_generator_downstream(clocks, self);
3460 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3461 }
3462 pub fn baud_rate_generator_config(
3463 self,
3464 clocks: &mut ClockTree,
3465 ) -> Option<UartBaudRateGeneratorConfig> {
3466 clocks.uart_baud_rate_generator[self as usize]
3467 }
3468 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3469 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3470 if increment_reference_count(
3471 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3472 ) {
3473 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3474 self.request_function_clock(clocks);
3475 self.enable_baud_rate_generator_impl(clocks, true);
3476 }
3477 }
3478 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3479 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3480 if decrement_reference_count(
3481 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3482 ) {
3483 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3484 self.enable_baud_rate_generator_impl(clocks, false);
3485 self.release_function_clock(clocks);
3486 }
3487 }
3488 #[allow(unused_variables)]
3489 pub fn baud_rate_generator_config_frequency(
3490 self,
3491 clocks: &mut ClockTree,
3492 config: UartBaudRateGeneratorConfig,
3493 ) -> u32 {
3494 ((self.function_clock_frequency() * 16)
3495 / ((config.integral() * 16) + config.fractional()))
3496 }
3497 pub fn baud_rate_generator_frequency(self) -> u32 {
3498 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3499 .load(::core::sync::atomic::Ordering::Acquire)
3500 }
3501 }
3502 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3510 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3511 #[instability::unstable]
3512 pub struct ClockConfig {
3513 pub xtal_clk: Option<XtalClkConfig>,
3515 pub pll_clk: Option<PllClkConfig>,
3517 pub system_pre_div: Option<SystemPreDivConfig>,
3519 pub cpu_pll_div_out: Option<CpuPllDivOutConfig>,
3521 pub cpu_clk: Option<CpuClkConfig>,
3523 pub rc_fast_clk_div_n: Option<RcFastClkDivNConfig>,
3525 pub rtc_slow_clk: Option<RtcSlowClkConfig>,
3527 pub rtc_fast_clk: Option<RtcFastClkConfig>,
3529 pub low_power_clk: Option<LowPowerClkConfig>,
3531 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3533 }
3534 impl ClockConfig {
3535 fn apply(&self, clocks: &mut ClockTree) {
3536 if let Some(config) = self.xtal_clk {
3537 configure_xtal_clk(clocks, config);
3538 }
3539 if let Some(config) = self.pll_clk {
3540 configure_pll_clk(clocks, config);
3541 }
3542 if let Some(config) = self.system_pre_div {
3543 configure_system_pre_div(clocks, config);
3544 }
3545 if let Some(config) = self.cpu_pll_div_out {
3546 configure_cpu_pll_div_out(clocks, config);
3547 }
3548 if let Some(config) = self.cpu_clk {
3549 configure_cpu_clk(clocks, config);
3550 }
3551 if let Some(config) = self.rc_fast_clk_div_n {
3552 configure_rc_fast_clk_div_n(clocks, config);
3553 }
3554 if let Some(config) = self.rtc_slow_clk {
3555 configure_rtc_slow_clk(clocks, config);
3556 }
3557 if let Some(config) = self.rtc_fast_clk {
3558 configure_rtc_fast_clk(clocks, config);
3559 }
3560 if let Some(config) = self.low_power_clk {
3561 configure_low_power_clk(clocks, config);
3562 }
3563 if let Some(config) = self.timg_calibration_clock {
3564 configure_timg_calibration_clock(clocks, config);
3565 }
3566 }
3567 }
3568 fn increment_reference_count(refcount: &mut u32) -> bool {
3569 let first = *refcount == 0;
3570 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3571 first
3572 }
3573 fn decrement_reference_count(refcount: &mut u32) -> bool {
3574 *refcount = refcount.saturating_sub(1);
3575 let last = *refcount == 0;
3576 last
3577 }
3578 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3579 if let Some(config) = clocks.xtal_clk {
3580 XTAL_CLK_FREQ_CACHE.store(
3581 xtal_clk_config_frequency(clocks, config),
3582 ::core::sync::atomic::Ordering::Release,
3583 );
3584 }
3585 refresh_pll_clk_downstream(clocks);
3586 refresh_system_pre_div_in_downstream(clocks);
3587 refresh_rtc_fast_clk_downstream(clocks);
3588 refresh_low_power_clk_downstream(clocks);
3589 for child_instance in [I2cInstance::I2c0] {
3590 refresh_i2c_function_clock_downstream(clocks, child_instance);
3591 }
3592 for child_instance in [SpiInstance::Spi2] {
3593 refresh_spi_function_clock_downstream(clocks, child_instance);
3594 }
3595 for child_instance in [RmtInstance::Rmt] {
3596 refresh_rmt_sclk_downstream(clocks, child_instance);
3597 }
3598 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3599 refresh_timg_function_clock_downstream(clocks, child_instance);
3600 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3601 }
3602 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3603 refresh_uart_function_clock_downstream(clocks, child_instance);
3604 }
3605 }
3606 fn refresh_pll_clk_downstream(clocks: &mut ClockTree) {
3607 if let Some(config) = clocks.pll_clk {
3608 PLL_CLK_FREQ_CACHE.store(
3609 pll_clk_config_frequency(clocks, config),
3610 ::core::sync::atomic::Ordering::Release,
3611 );
3612 }
3613 refresh_cpu_pll_div_out_downstream(clocks);
3614 }
3615 fn refresh_system_pre_div_in_downstream(clocks: &mut ClockTree) {
3616 if let Some(config) = clocks.system_pre_div_in {
3617 SYSTEM_PRE_DIV_IN_FREQ_CACHE.store(
3618 system_pre_div_in_config_frequency(clocks, config),
3619 ::core::sync::atomic::Ordering::Release,
3620 );
3621 }
3622 refresh_system_pre_div_downstream(clocks);
3623 }
3624 fn refresh_system_pre_div_downstream(clocks: &mut ClockTree) {
3625 if let Some(config) = clocks.system_pre_div {
3626 SYSTEM_PRE_DIV_FREQ_CACHE.store(
3627 system_pre_div_config_frequency(clocks, config),
3628 ::core::sync::atomic::Ordering::Release,
3629 );
3630 }
3631 refresh_cpu_clk_downstream(clocks);
3632 }
3633 fn refresh_cpu_pll_div_out_downstream(clocks: &mut ClockTree) {
3634 if let Some(config) = clocks.cpu_pll_div_out {
3635 CPU_PLL_DIV_OUT_FREQ_CACHE.store(
3636 cpu_pll_div_out_config_frequency(clocks, config),
3637 ::core::sync::atomic::Ordering::Release,
3638 );
3639 }
3640 refresh_cpu_clk_downstream(clocks);
3641 }
3642 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3643 if let Some(config) = clocks.cpu_clk {
3644 CPU_CLK_FREQ_CACHE.store(
3645 cpu_clk_config_frequency(clocks, config),
3646 ::core::sync::atomic::Ordering::Release,
3647 );
3648 }
3649 refresh_apb_clk_downstream(clocks);
3650 refresh_crypto_clk_downstream(clocks);
3651 for child_instance in [SpiInstance::Spi2] {
3652 refresh_spi_function_clock_downstream(clocks, child_instance);
3653 }
3654 }
3655 fn refresh_rc_fast_clk_div_n_downstream(clocks: &mut ClockTree) {
3656 if let Some(config) = clocks.rc_fast_clk_div_n {
3657 RC_FAST_CLK_DIV_N_FREQ_CACHE.store(
3658 rc_fast_clk_div_n_config_frequency(clocks, config),
3659 ::core::sync::atomic::Ordering::Release,
3660 );
3661 }
3662 refresh_rtc_fast_clk_downstream(clocks);
3663 }
3664 fn refresh_rtc_slow_clk_downstream(clocks: &mut ClockTree) {
3665 if let Some(config) = clocks.rtc_slow_clk {
3666 RTC_SLOW_CLK_FREQ_CACHE.store(
3667 rtc_slow_clk_config_frequency(clocks, config),
3668 ::core::sync::atomic::Ordering::Release,
3669 );
3670 }
3671 refresh_low_power_clk_downstream(clocks);
3672 }
3673 fn refresh_rtc_fast_clk_downstream(clocks: &mut ClockTree) {
3674 if let Some(config) = clocks.rtc_fast_clk {
3675 RTC_FAST_CLK_FREQ_CACHE.store(
3676 rtc_fast_clk_config_frequency(clocks, config),
3677 ::core::sync::atomic::Ordering::Release,
3678 );
3679 }
3680 }
3681 fn refresh_low_power_clk_downstream(clocks: &mut ClockTree) {
3682 if let Some(config) = clocks.low_power_clk {
3683 LOW_POWER_CLK_FREQ_CACHE.store(
3684 low_power_clk_config_frequency(clocks, config),
3685 ::core::sync::atomic::Ordering::Release,
3686 );
3687 }
3688 }
3689 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3690 if let Some(config) = clocks.timg_calibration_clock {
3691 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3692 timg_calibration_clock_config_frequency(clocks, config),
3693 ::core::sync::atomic::Ordering::Release,
3694 );
3695 }
3696 }
3697 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
3698 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
3699 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3700 I2cInstance::function_clock_config_frequency(clocks, config),
3701 ::core::sync::atomic::Ordering::Release,
3702 );
3703 }
3704 }
3705 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
3706 if let Some(config) = clocks.spi_function_clock[instance as usize] {
3707 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3708 SpiInstance::function_clock_config_frequency(clocks, config),
3709 ::core::sync::atomic::Ordering::Release,
3710 );
3711 }
3712 }
3713 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3714 if let Some(config) = clocks.apb_clk {
3715 APB_CLK_FREQ_CACHE.store(
3716 apb_clk_config_frequency(clocks, config),
3717 ::core::sync::atomic::Ordering::Release,
3718 );
3719 }
3720 for child_instance in [RmtInstance::Rmt] {
3721 refresh_rmt_sclk_downstream(clocks, child_instance);
3722 }
3723 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3724 refresh_timg_function_clock_downstream(clocks, child_instance);
3725 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3726 }
3727 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3728 refresh_uart_function_clock_downstream(clocks, child_instance);
3729 }
3730 }
3731 fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
3732 if let Some(config) = clocks.crypto_clk {
3733 CRYPTO_CLK_FREQ_CACHE.store(
3734 crypto_clk_config_frequency(clocks, config),
3735 ::core::sync::atomic::Ordering::Release,
3736 );
3737 }
3738 }
3739 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
3740 if let Some(config) = clocks.rmt_sclk[instance as usize] {
3741 RMT_SCLK_FREQ_CACHE[instance as usize].store(
3742 RmtInstance::sclk_config_frequency(clocks, config),
3743 ::core::sync::atomic::Ordering::Release,
3744 );
3745 }
3746 }
3747 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3748 if let Some(config) = clocks.timg_function_clock[instance as usize] {
3749 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3750 TimgInstance::function_clock_config_frequency(clocks, config),
3751 ::core::sync::atomic::Ordering::Release,
3752 );
3753 }
3754 }
3755 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3756 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
3757 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
3758 TimgInstance::wdt_clock_config_frequency(clocks, config),
3759 ::core::sync::atomic::Ordering::Release,
3760 );
3761 }
3762 }
3763 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
3764 if let Some(config) = clocks.uart_function_clock[instance as usize] {
3765 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3766 UartInstance::function_clock_config_frequency(clocks, config),
3767 ::core::sync::atomic::Ordering::Release,
3768 );
3769 }
3770 refresh_uart_baud_rate_generator_downstream(clocks, instance);
3771 }
3772 fn refresh_uart_baud_rate_generator_downstream(
3773 clocks: &mut ClockTree,
3774 instance: UartInstance,
3775 ) {
3776 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
3777 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
3778 instance.baud_rate_generator_config_frequency(clocks, config),
3779 ::core::sync::atomic::Ordering::Release,
3780 );
3781 }
3782 }
3783 };
3784}
3785#[macro_export]
3789#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3790macro_rules! implement_peripheral_clocks {
3791 () => {
3792 #[doc(hidden)]
3793 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3794 #[repr(u8)]
3795 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3796 pub enum Peripheral {
3797 Aes,
3799 AhbGdma,
3801 ApbSarAdc,
3803 Ds,
3805 GpioSd,
3807 Hmac,
3809 I2cExt0,
3811 I2s0,
3813 Ledc,
3815 Rmt,
3817 Rsa,
3819 Sha,
3821 Spi2,
3823 Systimer,
3825 Timg0,
3827 Timg1,
3829 Tsens,
3831 Twai0,
3833 Uart0,
3835 Uart1,
3837 UartMem,
3839 Uhci0,
3841 UsbDevice,
3843 }
3844 impl Peripheral {
3845 const KEEP_ENABLED: &[Peripheral] = &[
3846 Self::Systimer,
3847 Self::Timg0,
3848 Self::Uart0,
3849 Self::UartMem,
3850 Self::UsbDevice,
3851 ];
3852 const COUNT: usize = Self::ALL.len();
3853 const ALL: &[Self] = &[
3854 Self::Aes,
3855 Self::AhbGdma,
3856 Self::ApbSarAdc,
3857 Self::Ds,
3858 Self::GpioSd,
3859 Self::Hmac,
3860 Self::I2cExt0,
3861 Self::I2s0,
3862 Self::Ledc,
3863 Self::Rmt,
3864 Self::Rsa,
3865 Self::Sha,
3866 Self::Spi2,
3867 Self::Systimer,
3868 Self::Timg0,
3869 Self::Timg1,
3870 Self::Tsens,
3871 Self::Twai0,
3872 Self::Uart0,
3873 Self::Uart1,
3874 Self::UartMem,
3875 Self::Uhci0,
3876 Self::UsbDevice,
3877 ];
3878 }
3879 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
3880 match peripheral {
3881 Peripheral::Aes => {
3882 crate::peripherals::SYSTEM::regs()
3883 .perip_clk_en1()
3884 .modify(|_, w| w.crypto_aes_clk_en().bit(enable));
3885 }
3886 Peripheral::AhbGdma => {
3887 crate::peripherals::SYSTEM::regs()
3888 .perip_clk_en1()
3889 .modify(|_, w| w.dma_clk_en().bit(enable));
3890 }
3891 Peripheral::ApbSarAdc => {
3892 crate::peripherals::SYSTEM::regs()
3893 .perip_clk_en0()
3894 .modify(|_, w| w.apb_saradc_clk_en().bit(enable));
3895 }
3896 Peripheral::Ds => {
3897 crate::peripherals::SYSTEM::regs()
3898 .perip_clk_en1()
3899 .modify(|_, w| w.crypto_ds_clk_en().bit(enable));
3900 }
3901 Peripheral::GpioSd => {
3902 crate::peripherals::GPIO_SD::regs()
3903 .clock_gate()
3904 .modify(|_, w| w.clk_en().bit(enable));
3905 }
3906 Peripheral::Hmac => {
3907 crate::peripherals::SYSTEM::regs()
3908 .perip_clk_en1()
3909 .modify(|_, w| w.crypto_hmac_clk_en().bit(enable));
3910 }
3911 Peripheral::I2cExt0 => {
3912 crate::peripherals::SYSTEM::regs()
3913 .perip_clk_en0()
3914 .modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
3915 }
3916 Peripheral::I2s0 => {
3917 crate::peripherals::SYSTEM::regs()
3918 .perip_clk_en0()
3919 .modify(|_, w| w.i2s0_clk_en().bit(enable));
3920 }
3921 Peripheral::Ledc => {
3922 crate::peripherals::SYSTEM::regs()
3923 .perip_clk_en0()
3924 .modify(|_, w| w.ledc_clk_en().bit(enable));
3925 }
3926 Peripheral::Rmt => {
3927 crate::peripherals::SYSTEM::regs()
3928 .perip_clk_en0()
3929 .modify(|_, w| w.rmt_clk_en().bit(enable));
3930 }
3931 Peripheral::Rsa => {
3932 crate::peripherals::SYSTEM::regs()
3933 .perip_clk_en1()
3934 .modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
3935 }
3936 Peripheral::Sha => {
3937 crate::peripherals::SYSTEM::regs()
3938 .perip_clk_en1()
3939 .modify(|_, w| w.crypto_sha_clk_en().bit(enable));
3940 }
3941 Peripheral::Spi2 => {
3942 crate::peripherals::SYSTEM::regs()
3943 .perip_clk_en0()
3944 .modify(|_, w| w.spi2_clk_en().bit(enable));
3945 }
3946 Peripheral::Systimer => {
3947 crate::peripherals::SYSTEM::regs()
3948 .perip_clk_en0()
3949 .modify(|_, w| w.systimer_clk_en().bit(enable));
3950 }
3951 Peripheral::Timg0 => {
3952 crate::peripherals::SYSTEM::regs()
3953 .perip_clk_en0()
3954 .modify(|_, w| w.timergroup_clk_en().bit(enable));
3955 }
3956 Peripheral::Timg1 => {
3957 crate::peripherals::SYSTEM::regs()
3958 .perip_clk_en0()
3959 .modify(|_, w| w.timergroup1_clk_en().bit(enable));
3960 }
3961 Peripheral::Tsens => {
3962 crate::peripherals::SYSTEM::regs()
3963 .perip_clk_en1()
3964 .modify(|_, w| w.tsens_clk_en().bit(enable));
3965 }
3966 Peripheral::Twai0 => {
3967 crate::peripherals::SYSTEM::regs()
3968 .perip_clk_en0()
3969 .modify(|_, w| w.twai_clk_en().bit(enable));
3970 }
3971 Peripheral::Uart0 => {
3972 crate::peripherals::SYSTEM::regs()
3973 .perip_clk_en0()
3974 .modify(|_, w| w.uart_clk_en().bit(enable));
3975 }
3976 Peripheral::Uart1 => {
3977 crate::peripherals::SYSTEM::regs()
3978 .perip_clk_en0()
3979 .modify(|_, w| w.uart1_clk_en().bit(enable));
3980 }
3981 Peripheral::UartMem => {
3982 crate::peripherals::SYSTEM::regs()
3983 .perip_clk_en0()
3984 .modify(|_, w| w.uart_mem_clk_en().bit(enable));
3985 }
3986 Peripheral::Uhci0 => {
3987 crate::peripherals::SYSTEM::regs()
3988 .perip_clk_en0()
3989 .modify(|_, w| w.uhci0_clk_en().bit(enable));
3990 }
3991 Peripheral::UsbDevice => {
3992 crate::peripherals::SYSTEM::regs()
3993 .perip_clk_en0()
3994 .modify(|_, w| w.usb_device_clk_en().bit(enable));
3995 }
3996 }
3997 }
3998 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
3999 match peripheral {
4000 Peripheral::Aes => {
4001 crate::peripherals::SYSTEM::regs()
4002 .perip_rst_en1()
4003 .modify(|_, w| w.crypto_aes_rst().bit(reset));
4004 }
4005 Peripheral::AhbGdma => {
4006 crate::peripherals::SYSTEM::regs()
4007 .perip_rst_en1()
4008 .modify(|_, w| w.dma_rst().bit(reset));
4009 }
4010 Peripheral::ApbSarAdc => {
4011 crate::peripherals::SYSTEM::regs()
4012 .perip_rst_en0()
4013 .modify(|_, w| w.apb_saradc_rst().bit(reset));
4014 }
4015 Peripheral::Ds => {
4016 crate::peripherals::SYSTEM::regs()
4017 .perip_rst_en1()
4018 .modify(|_, w| w.crypto_ds_rst().bit(reset));
4019 }
4020 Peripheral::GpioSd => {
4021 let _ = reset;
4022 }
4023 Peripheral::Hmac => {
4024 crate::peripherals::SYSTEM::regs()
4025 .perip_rst_en1()
4026 .modify(|_, w| w.crypto_hmac_rst().bit(reset));
4027 }
4028 Peripheral::I2cExt0 => {
4029 crate::peripherals::SYSTEM::regs()
4030 .perip_rst_en0()
4031 .modify(|_, w| w.i2c_ext0_rst().bit(reset));
4032 }
4033 Peripheral::I2s0 => {
4034 crate::peripherals::SYSTEM::regs()
4035 .perip_rst_en0()
4036 .modify(|_, w| w.i2s0_rst().bit(reset));
4037 }
4038 Peripheral::Ledc => {
4039 crate::peripherals::SYSTEM::regs()
4040 .perip_rst_en0()
4041 .modify(|_, w| w.ledc_rst().bit(reset));
4042 }
4043 Peripheral::Rmt => {
4044 crate::peripherals::SYSTEM::regs()
4045 .perip_rst_en0()
4046 .modify(|_, w| w.rmt_rst().bit(reset));
4047 }
4048 Peripheral::Rsa => {
4049 crate::peripherals::SYSTEM::regs()
4050 .perip_rst_en1()
4051 .modify(|_, w| w.crypto_rsa_rst().bit(reset));
4052 }
4053 Peripheral::Sha => {
4054 crate::peripherals::SYSTEM::regs()
4055 .perip_rst_en1()
4056 .modify(|_, w| w.crypto_sha_rst().bit(reset));
4057 }
4058 Peripheral::Spi2 => {
4059 crate::peripherals::SYSTEM::regs()
4060 .perip_rst_en0()
4061 .modify(|_, w| w.spi2_rst().bit(reset));
4062 }
4063 Peripheral::Systimer => {
4064 crate::peripherals::SYSTEM::regs()
4065 .perip_rst_en0()
4066 .modify(|_, w| w.systimer_rst().bit(reset));
4067 }
4068 Peripheral::Timg0 => {
4069 crate::peripherals::SYSTEM::regs()
4070 .perip_rst_en0()
4071 .modify(|_, w| w.timergroup_rst().bit(reset));
4072 }
4073 Peripheral::Timg1 => {
4074 crate::peripherals::SYSTEM::regs()
4075 .perip_rst_en0()
4076 .modify(|_, w| w.timergroup1_rst().bit(reset));
4077 }
4078 Peripheral::Tsens => {
4079 crate::peripherals::SYSTEM::regs()
4080 .perip_rst_en1()
4081 .modify(|_, w| w.tsens_rst().bit(reset));
4082 }
4083 Peripheral::Twai0 => {
4084 crate::peripherals::SYSTEM::regs()
4085 .perip_rst_en0()
4086 .modify(|_, w| w.twai_rst().bit(reset));
4087 }
4088 Peripheral::Uart0 => {
4089 crate::peripherals::SYSTEM::regs()
4090 .perip_rst_en0()
4091 .modify(|_, w| w.uart_rst().bit(reset));
4092 }
4093 Peripheral::Uart1 => {
4094 crate::peripherals::SYSTEM::regs()
4095 .perip_rst_en0()
4096 .modify(|_, w| w.uart1_rst().bit(reset));
4097 }
4098 Peripheral::UartMem => {
4099 crate::peripherals::SYSTEM::regs()
4100 .perip_rst_en0()
4101 .modify(|_, w| w.uart_mem_rst().bit(reset));
4102 }
4103 Peripheral::Uhci0 => {
4104 crate::peripherals::SYSTEM::regs()
4105 .perip_rst_en0()
4106 .modify(|_, w| w.uhci0_rst().bit(reset));
4107 }
4108 Peripheral::UsbDevice => {
4109 crate::peripherals::SYSTEM::regs()
4110 .perip_rst_en0()
4111 .modify(|_, w| w.usb_device_rst().bit(reset));
4112 }
4113 }
4114 }
4115 };
4116}
4117#[macro_export]
4125#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4126macro_rules! memory_range {
4127 ("DRAM") => {
4128 0x3FC80000..0x3FCE0000
4129 };
4130 (size as str, "DRAM") => {
4131 "393216"
4132 };
4133 ("DRAM2_UNINIT") => {
4134 0x3FCCE400..0x3FCDE710
4135 };
4136 (size as str, "DRAM2_UNINIT") => {
4137 "66320"
4138 };
4139 ("IROM") => {
4140 0x42000000..0x42800000
4141 };
4142 (size as str, "IROM") => {
4143 "8388608"
4144 };
4145 ("DROM") => {
4146 0x3C000000..0x3C800000
4147 };
4148 (size as str, "DROM") => {
4149 "8388608"
4150 };
4151}
4152#[macro_export]
4169#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4170macro_rules! for_each_i2c_master {
4171 ($($pattern:tt => $code:tt;)*) => {
4172 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4173 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4174 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4175 I2CEXT0_SDA)));
4176 };
4177}
4178#[macro_export]
4205#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4206macro_rules! for_each_i2s {
4207 ($($pattern:tt => $code:tt;)*) => {
4208 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4209 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
4210 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
4211 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
4212 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
4213 true, true, false)));
4214 };
4215}
4216#[macro_export]
4235#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4236macro_rules! for_each_uart {
4237 ($($pattern:tt => $code:tt;)*) => {
4238 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4239 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4240 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4241 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4242 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4243 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4244 };
4245}
4246#[macro_export]
4268#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4269macro_rules! for_each_spi_master {
4270 ($($pattern:tt => $code:tt;)*) => {
4271 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4272 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
4273 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
4274 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
4275 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4276 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
4277 };
4278}
4279#[macro_export]
4296#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4297macro_rules! for_each_spi_slave {
4298 ($($pattern:tt => $code:tt;)*) => {
4299 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4300 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
4301 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4302 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
4303 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
4304 };
4305}
4306#[macro_export]
4307#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4308macro_rules! for_each_peripheral {
4309 ($($pattern:tt => $code:tt;)*) => {
4310 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4311 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4312 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
4313 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4314 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4315 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4316 "<section class=\"warning\">"] #[doc =
4317 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4318 #[doc = "<ul>"] #[doc =
4319 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4320 = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
4321 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
4322 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4323 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4324 "<section class=\"warning\">"] #[doc =
4325 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4326 #[doc = "<ul>"] #[doc =
4327 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4328 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
4329 _for_each_inner_peripheral!((@ peri_type #[doc =
4330 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4331 "<section class=\"warning\">"] #[doc =
4332 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4333 #[doc = "<ul>"] #[doc =
4334 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4335 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4336 _for_each_inner_peripheral!((@ peri_type #[doc =
4337 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4338 "<section class=\"warning\">"] #[doc =
4339 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4340 #[doc = "<ul>"] #[doc =
4341 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4342 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4343 _for_each_inner_peripheral!((@ peri_type #[doc =
4344 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4345 "<section class=\"warning\">"] #[doc =
4346 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4347 #[doc = "<ul>"] #[doc =
4348 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4349 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4350 _for_each_inner_peripheral!((@ peri_type #[doc =
4351 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4352 "<section class=\"warning\">"] #[doc =
4353 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4354 #[doc = "<ul>"] #[doc =
4355 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4356 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4357 _for_each_inner_peripheral!((@ peri_type #[doc =
4358 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4359 "<section class=\"warning\">"] #[doc =
4360 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4361 #[doc = "<ul>"] #[doc =
4362 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4363 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4364 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
4365 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4366 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4367 "<section class=\"warning\">"] #[doc =
4368 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4369 #[doc = "<ul>"] #[doc =
4370 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4371 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4372 _for_each_inner_peripheral!((@ peri_type #[doc =
4373 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4374 "<section class=\"warning\">"] #[doc =
4375 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4376 #[doc = "<ul>"] #[doc =
4377 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4378 "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
4379 _for_each_inner_peripheral!((@ peri_type #[doc =
4380 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4381 "<section class=\"warning\">"] #[doc =
4382 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4383 #[doc = "<ul>"] #[doc =
4384 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4385 "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()));
4386 _for_each_inner_peripheral!((@ peri_type #[doc =
4387 "GPIO14 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 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
4393 _for_each_inner_peripheral!((@ peri_type #[doc =
4394 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4395 "<section class=\"warning\">"] #[doc =
4396 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4397 #[doc = "<ul>"] #[doc =
4398 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4399 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
4400 _for_each_inner_peripheral!((@ peri_type #[doc =
4401 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4402 "<section class=\"warning\">"] #[doc =
4403 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4404 #[doc = "<ul>"] #[doc =
4405 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4406 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
4407 _for_each_inner_peripheral!((@ peri_type #[doc =
4408 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4409 "<section class=\"warning\">"] #[doc =
4410 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4411 #[doc = "<ul>"] #[doc =
4412 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4413 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
4414 _for_each_inner_peripheral!((@ peri_type #[doc =
4415 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4416 "<section class=\"warning\">"] #[doc =
4417 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4418 #[doc = "<ul>"] #[doc =
4419 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4420 #[doc = "</section>"] GPIO18 <= virtual())); _for_each_inner_peripheral!((@
4421 peri_type #[doc = "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""]
4422 #[doc = "<section class=\"warning\">"] #[doc =
4423 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4424 #[doc = "<ul>"] #[doc =
4425 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4426 #[doc = "</section>"] GPIO19 <= virtual())); _for_each_inner_peripheral!((@
4427 peri_type #[doc = "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""]
4428 #[doc = "<section class=\"warning\">"] #[doc =
4429 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4430 #[doc = "<ul>"] #[doc =
4431 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4432 = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
4433 _for_each_inner_peripheral!((@ peri_type #[doc =
4434 "GPIO21 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>By default, this pin is used by the UART programming interface.</li>"] #[doc
4439 = "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
4440 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
4441 DMA_CH0 <= virtual(DMA_CH0 : { bind_dma_interrupt, enable_dma_interrupt,
4442 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4443 #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_CH1 : {
4444 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4445 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH2 peripheral singleton"]
4446 DMA_CH2 <= virtual(DMA_CH2 : { bind_dma_interrupt, enable_dma_interrupt,
4447 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4448 #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual() (unstable)));
4449 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH1 peripheral singleton"]
4450 SDM_CH1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4451 = "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual() (unstable)));
4452 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH3 peripheral singleton"]
4453 SDM_CH3 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4454 = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
4455 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4456 _for_each_inner_peripheral!((@ peri_type #[doc = "APB_CTRL peripheral singleton"]
4457 APB_CTRL <= APB_CTRL() (unstable))); _for_each_inner_peripheral!((@ peri_type
4458 #[doc = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC()
4459 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4460 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
4461 _for_each_inner_peripheral!((@ peri_type #[doc = "BB peripheral singleton"] BB <=
4462 BB() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4463 "DMA peripheral singleton"] DMA <= DMA() (unstable)));
4464 _for_each_inner_peripheral!((@ peri_type #[doc = "DS peripheral singleton"] DS <=
4465 DS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4466 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
4467 _for_each_inner_peripheral!((@ peri_type #[doc = "EXTMEM peripheral singleton"]
4468 EXTMEM <= EXTMEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4469 "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)));
4470 _for_each_inner_peripheral!((@ peri_type #[doc = "FE peripheral singleton"] FE <=
4471 FE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4472 "FE2 peripheral singleton"] FE2 <= FE2() (unstable)));
4473 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
4474 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4475 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
4476 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
4477 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4478 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4479 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4480 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4481 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4482 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
4483 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4484 _for_each_inner_peripheral!((@ peri_type #[doc =
4485 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4486 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4487 "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)));
4488 _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
4489 LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4490 "NRX peripheral singleton"] NRX <= NRX() (unstable)));
4491 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
4492 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4493 "RNG peripheral singleton"] RNG <= RNG() (unstable)));
4494 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
4495 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4496 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4497 "LPWR peripheral singleton"] LPWR <= RTC_CNTL() (unstable)));
4498 _for_each_inner_peripheral!((@ peri_type #[doc =
4499 "RTC_TIMER peripheral singleton"] RTC_TIMER <= RTC_CNTL() (unstable)));
4500 _for_each_inner_peripheral!((@ peri_type #[doc =
4501 "SENSITIVE peripheral singleton"] SENSITIVE <= SENSITIVE() (unstable)));
4502 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
4503 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4504 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4505 "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
4506 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
4507 SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4508 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
4509 enable_peri_interrupt, disable_peri_interrupt })));
4510 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
4511 SYSTEM <= SYSTEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4512 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
4513 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
4514 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4515 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
4516 _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
4517 TWAI0 <= TWAI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4518 "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
4519 enable_peri_interrupt, disable_peri_interrupt })));
4520 _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
4521 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
4522 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4523 "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
4524 _for_each_inner_peripheral!((@ peri_type #[doc =
4525 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4526 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4527 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4528 "XTS_AES peripheral singleton"] XTS_AES <= XTS_AES() (unstable)));
4529 _for_each_inner_peripheral!((@ peri_type #[doc = "ADC1 peripheral singleton"]
4530 ADC1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4531 "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)));
4532 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4533 virtual(BT_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt },
4534 RWBLE : { bind_rwble_interrupt, enable_rwble_interrupt, disable_rwble_interrupt
4535 }, RWBT : { bind_rwbt_interrupt, enable_rwbt_interrupt, disable_rwbt_interrupt })
4536 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4537 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
4538 _for_each_inner_peripheral!((@ peri_type #[doc =
4539 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4540 _for_each_inner_peripheral!((@ peri_type #[doc = "TSENS peripheral singleton"]
4541 TSENS <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4542 "WIFI peripheral singleton"] WIFI <= virtual(WIFI_MAC : { bind_mac_interrupt,
4543 enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
4544 enable_pwr_interrupt, disable_pwr_interrupt }))); _for_each_inner_peripheral!((@
4545 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
4546 virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4547 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4548 _for_each_inner_peripheral!((@ peri_type #[doc =
4549 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4550 _for_each_inner_peripheral!((@ peri_type #[doc =
4551 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4552 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
4553 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4554 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4555 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4556 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4557 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4558 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4559 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
4560 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
4561 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
4562 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
4563 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4564 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4565 _for_each_inner_peripheral!((DMA_CH2(unstable)));
4566 _for_each_inner_peripheral!((SDM_CH0(unstable)));
4567 _for_each_inner_peripheral!((SDM_CH1(unstable)));
4568 _for_each_inner_peripheral!((SDM_CH2(unstable)));
4569 _for_each_inner_peripheral!((SDM_CH3(unstable)));
4570 _for_each_inner_peripheral!((AES(unstable)));
4571 _for_each_inner_peripheral!((APB_CTRL(unstable)));
4572 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4573 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
4574 _for_each_inner_peripheral!((BB(unstable)));
4575 _for_each_inner_peripheral!((DMA(unstable)));
4576 _for_each_inner_peripheral!((DS(unstable)));
4577 _for_each_inner_peripheral!((EXTMEM(unstable)));
4578 _for_each_inner_peripheral!((FE(unstable)));
4579 _for_each_inner_peripheral!((FE2(unstable)));
4580 _for_each_inner_peripheral!((GPIO(unstable)));
4581 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4582 _for_each_inner_peripheral!((HMAC(unstable)));
4583 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4584 _for_each_inner_peripheral!((I2C0));
4585 _for_each_inner_peripheral!((I2S0(unstable)));
4586 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4587 _for_each_inner_peripheral!((IO_MUX(unstable)));
4588 _for_each_inner_peripheral!((LEDC(unstable)));
4589 _for_each_inner_peripheral!((NRX(unstable)));
4590 _for_each_inner_peripheral!((RMT(unstable)));
4591 _for_each_inner_peripheral!((RNG(unstable)));
4592 _for_each_inner_peripheral!((RSA(unstable)));
4593 _for_each_inner_peripheral!((LPWR(unstable)));
4594 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4595 _for_each_inner_peripheral!((SENSITIVE(unstable)));
4596 _for_each_inner_peripheral!((SHA(unstable)));
4597 _for_each_inner_peripheral!((SPI0(unstable)));
4598 _for_each_inner_peripheral!((SPI1(unstable)));
4599 _for_each_inner_peripheral!((SPI2));
4600 _for_each_inner_peripheral!((SYSTEM(unstable)));
4601 _for_each_inner_peripheral!((SYSTIMER(unstable)));
4602 _for_each_inner_peripheral!((TIMG0(unstable)));
4603 _for_each_inner_peripheral!((TIMG1(unstable)));
4604 _for_each_inner_peripheral!((TWAI0(unstable)));
4605 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
4606 _for_each_inner_peripheral!((UHCI0(unstable)));
4607 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
4608 _for_each_inner_peripheral!((XTS_AES(unstable)));
4609 _for_each_inner_peripheral!((ADC1(unstable)));
4610 _for_each_inner_peripheral!((ADC2(unstable)));
4611 _for_each_inner_peripheral!((BT(unstable)));
4612 _for_each_inner_peripheral!((FLASH(unstable)));
4613 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
4614 _for_each_inner_peripheral!((TSENS(unstable)));
4615 _for_each_inner_peripheral!((WIFI));
4616 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
4617 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
4618 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
4619 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
4620 _for_each_inner_peripheral!((SPI2, Spi2, 0, AhbGdmaChannel));
4621 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
4622 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
4623 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
4624 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
4625 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
4626 _for_each_inner_peripheral!((all(@ peri_type #[doc =
4627 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
4628 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
4629 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4630 "<section class=\"warning\">"] #[doc =
4631 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4632 #[doc = "<ul>"] #[doc =
4633 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4634 = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
4635 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
4636 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4637 "<section class=\"warning\">"] #[doc =
4638 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4639 #[doc = "<ul>"] #[doc =
4640 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4641 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
4642 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4643 "<section class=\"warning\">"] #[doc =
4644 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4645 #[doc = "<ul>"] #[doc =
4646 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4647 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
4648 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4649 "<section class=\"warning\">"] #[doc =
4650 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4651 #[doc = "<ul>"] #[doc =
4652 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4653 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
4654 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4655 "<section class=\"warning\">"] #[doc =
4656 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4657 #[doc = "<ul>"] #[doc =
4658 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4659 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
4660 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4661 "<section class=\"warning\">"] #[doc =
4662 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4663 #[doc = "<ul>"] #[doc =
4664 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4665 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
4666 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4667 "<section class=\"warning\">"] #[doc =
4668 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4669 #[doc = "<ul>"] #[doc =
4670 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4671 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
4672 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
4673 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4674 "<section class=\"warning\">"] #[doc =
4675 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4676 #[doc = "<ul>"] #[doc =
4677 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4678 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
4679 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4680 "<section class=\"warning\">"] #[doc =
4681 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4682 #[doc = "<ul>"] #[doc =
4683 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4684 "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
4685 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4686 "<section class=\"warning\">"] #[doc =
4687 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4688 #[doc = "<ul>"] #[doc =
4689 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4690 "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
4691 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4692 "<section class=\"warning\">"] #[doc =
4693 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4694 #[doc = "<ul>"] #[doc =
4695 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4696 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
4697 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4698 "<section class=\"warning\">"] #[doc =
4699 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4700 #[doc = "<ul>"] #[doc =
4701 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4702 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
4703 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4704 "<section class=\"warning\">"] #[doc =
4705 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4706 #[doc = "<ul>"] #[doc =
4707 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4708 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
4709 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4710 "<section class=\"warning\">"] #[doc =
4711 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4712 #[doc = "<ul>"] #[doc =
4713 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4714 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
4715 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4716 "<section class=\"warning\">"] #[doc =
4717 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4718 #[doc = "<ul>"] #[doc =
4719 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4720 #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
4721 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4722 "<section class=\"warning\">"] #[doc =
4723 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4724 #[doc = "<ul>"] #[doc =
4725 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4726 #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
4727 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4728 "<section class=\"warning\">"] #[doc =
4729 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4730 #[doc = "<ul>"] #[doc =
4731 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4732 = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
4733 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4734 "<section class=\"warning\">"] #[doc =
4735 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4736 #[doc = "<ul>"] #[doc =
4737 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4738 = "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
4739 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_CH0 : {
4740 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4741 (@ peri_type #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_CH1 :
4742 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4743 (@ peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_CH2 :
4744 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
4745 (@ peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
4746 (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
4747 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
4748 SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
4749 "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
4750 #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
4751 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4752 = "APB_CTRL peripheral singleton"] APB_CTRL <= APB_CTRL() (unstable)), (@
4753 peri_type #[doc = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC()
4754 (unstable)), (@ peri_type #[doc = "ASSIST_DEBUG peripheral singleton"]
4755 ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)), (@ peri_type #[doc =
4756 "BB peripheral singleton"] BB <= BB() (unstable)), (@ peri_type #[doc =
4757 "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@ peri_type #[doc =
4758 "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type #[doc =
4759 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc =
4760 "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)), (@ peri_type #[doc
4761 = "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)), (@
4762 peri_type #[doc = "FE peripheral singleton"] FE <= FE() (unstable)), (@ peri_type
4763 #[doc = "FE2 peripheral singleton"] FE2 <= FE2() (unstable)), (@ peri_type #[doc
4764 = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
4765 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)), (@ peri_type
4766 #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)), (@ peri_type
4767 #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST()
4768 (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <=
4769 I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4770 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
4771 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
4772 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
4773 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4774 (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX <=
4775 IO_MUX() (unstable)), (@ peri_type #[doc = "LEDC peripheral singleton"] LEDC <=
4776 LEDC() (unstable)), (@ peri_type #[doc = "NRX peripheral singleton"] NRX <= NRX()
4777 (unstable)), (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT()
4778 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG()
4779 (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
4780 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4781 (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= RTC_CNTL()
4782 (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
4783 RTC_CNTL() (unstable)), (@ peri_type #[doc = "SENSITIVE peripheral singleton"]
4784 SENSITIVE <= SENSITIVE() (unstable)), (@ peri_type #[doc =
4785 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4786 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4787 = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
4788 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
4789 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
4790 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
4791 "SYSTEM peripheral singleton"] SYSTEM <= SYSTEM() (unstable)), (@ peri_type #[doc
4792 = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@
4793 peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@
4794 peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@
4795 peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@
4796 peri_type #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
4797 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4798 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
4799 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4800 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
4801 peri_type #[doc = "USB_DEVICE peripheral singleton"] USB_DEVICE <=
4802 USB_DEVICE(USB_DEVICE : { bind_peri_interrupt, enable_peri_interrupt,
4803 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
4804 "XTS_AES peripheral singleton"] XTS_AES <= XTS_AES() (unstable)), (@ peri_type
4805 #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type
4806 #[doc = "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)), (@ peri_type
4807 #[doc = "BT peripheral singleton"] BT <= virtual(BT_BB : { bind_bb_interrupt,
4808 enable_bb_interrupt, disable_bb_interrupt }, RWBLE : { bind_rwble_interrupt,
4809 enable_rwble_interrupt, disable_rwble_interrupt }, RWBT : { bind_rwbt_interrupt,
4810 enable_rwbt_interrupt, disable_rwbt_interrupt }) (unstable)), (@ peri_type #[doc
4811 = "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type
4812 #[doc = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual()
4813 (unstable)), (@ peri_type #[doc = "TSENS peripheral singleton"] TSENS <=
4814 virtual() (unstable)), (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <=
4815 virtual(WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
4816 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
4817 disable_pwr_interrupt })), (@ peri_type #[doc =
4818 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)),
4819 (@ peri_type #[doc = "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <=
4820 virtual() (unstable)), (@ peri_type #[doc =
4821 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)),
4822 (@ peri_type #[doc = "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <=
4823 virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1),
4824 (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
4825 (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO15), (GPIO16), (GPIO17), (GPIO18),
4826 (GPIO19), (GPIO20), (GPIO21), (DMA_CH0(unstable)), (DMA_CH1(unstable)),
4827 (DMA_CH2(unstable)), (SDM_CH0(unstable)), (SDM_CH1(unstable)),
4828 (SDM_CH2(unstable)), (SDM_CH3(unstable)), (AES(unstable)), (APB_CTRL(unstable)),
4829 (APB_SARADC(unstable)), (ASSIST_DEBUG(unstable)), (BB(unstable)),
4830 (DMA(unstable)), (DS(unstable)), (EXTMEM(unstable)), (FE(unstable)),
4831 (FE2(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)),
4832 (I2C_ANA_MST(unstable)), (I2C0), (I2S0(unstable)), (INTERRUPT_CORE0(unstable)),
4833 (IO_MUX(unstable)), (LEDC(unstable)), (NRX(unstable)), (RMT(unstable)),
4834 (RNG(unstable)), (RSA(unstable)), (LPWR(unstable)), (RTC_TIMER(unstable)),
4835 (SENSITIVE(unstable)), (SHA(unstable)), (SPI0(unstable)), (SPI1(unstable)),
4836 (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)), (TIMG0(unstable)),
4837 (TIMG1(unstable)), (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)),
4838 (USB_DEVICE(unstable)), (XTS_AES(unstable)), (ADC1(unstable)), (ADC2(unstable)),
4839 (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (TSENS(unstable)),
4840 (WIFI), (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
4841 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
4842 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 0, AhbGdmaChannel), (UHCI0,
4843 Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3, AhbGdmaChannel), (AES, Aes, 6,
4844 AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel), (APB_SARADC, ApbSaradc, 8,
4845 AhbGdmaChannel)));
4846 };
4847}
4848#[macro_export]
4875#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4876macro_rules! for_each_gpio {
4877 ($($pattern:tt => $code:tt;)*) => {
4878 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
4879 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
4880 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
4881 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
4882 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
4883 _for_each_inner_gpio!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
4884 [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
4885 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTCK _2 =>
4886 FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2
4887 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])));
4888 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
4889 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
4890 _for_each_inner_gpio!((10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
4891 [Output]))); _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
4892 _for_each_inner_gpio!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input]
4893 [Output]))); _for_each_inner_gpio!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP)
4894 ([Input] [Output]))); _for_each_inner_gpio!((14, GPIO14() (_0 => SPICS0) ([Input]
4895 [Output]))); _for_each_inner_gpio!((15, GPIO15() (_0 => SPICLK) ([Input]
4896 [Output]))); _for_each_inner_gpio!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input]
4897 [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input]
4898 [Output]))); _for_each_inner_gpio!((18, GPIO18() () ([Input] [Output])));
4899 _for_each_inner_gpio!((19, GPIO19() () ([Input] [Output])));
4900 _for_each_inner_gpio!((20, GPIO20(_0 => U0RXD) () ([Input] [Output])));
4901 _for_each_inner_gpio!((21, GPIO21() (_0 => U0TXD) ([Input] [Output])));
4902 _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() ()
4903 ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
4904 (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 =>
4905 FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP)
4906 ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
4907 [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
4908 (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10,
4909 GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (11, GPIO11() ()
4910 ([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
4911 (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (14, GPIO14() (_0 =>
4912 SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK) ([Input] [Output])),
4913 (16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])), (17, GPIO17(_0 => SPIQ)
4914 (_0 => SPIQ) ([Input] [Output])), (18, GPIO18() () ([Input] [Output])), (19,
4915 GPIO19() () ([Input] [Output])), (20, GPIO20(_0 => U0RXD) () ([Input] [Output])),
4916 (21, GPIO21() (_0 => U0TXD) ([Input] [Output]))));
4917 };
4918}
4919#[macro_export]
4946#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4947macro_rules! for_each_analog_function {
4948 ($($pattern:tt => $code:tt;)*) => {
4949 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
4950 tt) => {} } _for_each_inner_analog_function!((ADC1_CH0, GPIO0));
4951 _for_each_inner_analog_function!((ADC1_CH1, GPIO1));
4952 _for_each_inner_analog_function!((ADC1_CH2, GPIO2));
4953 _for_each_inner_analog_function!((ADC1_CH3, GPIO3));
4954 _for_each_inner_analog_function!((ADC1_CH4, GPIO4));
4955 _for_each_inner_analog_function!((ADC2_CH0, GPIO5));
4956 _for_each_inner_analog_function!((USJ_DM, GPIO18));
4957 _for_each_inner_analog_function!((USJ_DP, GPIO19));
4958 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0));
4959 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1));
4960 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2));
4961 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3));
4962 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4));
4963 _for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO5));
4964 _for_each_inner_analog_function!((all(ADC1_CH0, GPIO0), (ADC1_CH1, GPIO1),
4965 (ADC1_CH2, GPIO2), (ADC1_CH3, GPIO3), (ADC1_CH4, GPIO4), (ADC2_CH0, GPIO5),
4966 (USJ_DM, GPIO18), (USJ_DP, GPIO19)));
4967 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0),
4968 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2),
4969 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4),
4970 ((ADC2_CH0, ADCn_CHm, 2, 0), GPIO5)));
4971 };
4972}
4973#[macro_export]
5011#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5012macro_rules! for_each_lp_function {
5013 ($($pattern:tt => $code:tt;)*) => {
5014 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5015 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _0));
5016 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _0));
5017 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _0));
5018 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _0));
5019 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _0));
5020 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _0));
5021 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, () ()));
5022 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()));
5023 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()));
5024 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()));
5025 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()));
5026 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()));
5027 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _0), (LP_GPIO1, GPIO1, _0),
5028 (LP_GPIO2, GPIO2, _0), (LP_GPIO3, GPIO3, _0), (LP_GPIO4, GPIO4, _0), (LP_GPIO5,
5029 GPIO5, _0))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0),
5030 GPIO0, _0, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()), ((LP_GPIO2,
5031 LP_GPIOn, 2), GPIO2, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()),
5032 ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0,
5033 () ())));
5034 };
5035}
5036#[macro_export]
5067#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5068macro_rules! for_each_iomux_function {
5069 ($($pattern:tt => $code:tt;)*) => {
5070 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5071 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
5072 _for_each_inner_iomux_function!((MTMS, GPIO4, _0));
5073 _for_each_inner_iomux_function!((FSPIHD, GPIO4, _2));
5074 _for_each_inner_iomux_function!((MTDI, GPIO5, _0));
5075 _for_each_inner_iomux_function!((FSPIWP, GPIO5, _2));
5076 _for_each_inner_iomux_function!((MTCK, GPIO6, _0));
5077 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
5078 _for_each_inner_iomux_function!((MTDO, GPIO7, _0));
5079 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
5080 _for_each_inner_iomux_function!((FSPICS0, GPIO10, _2));
5081 _for_each_inner_iomux_function!((SPIHD, GPIO12, _0));
5082 _for_each_inner_iomux_function!((SPIWP, GPIO13, _0));
5083 _for_each_inner_iomux_function!((SPICS0, GPIO14, _0));
5084 _for_each_inner_iomux_function!((SPICLK, GPIO15, _0));
5085 _for_each_inner_iomux_function!((SPID, GPIO16, _0));
5086 _for_each_inner_iomux_function!((SPIQ, GPIO17, _0));
5087 _for_each_inner_iomux_function!((U0RXD, GPIO20, _0));
5088 _for_each_inner_iomux_function!((U0TXD, GPIO21, _0));
5089 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO10, _2));
5090 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO14, _0));
5091 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO4, _0),
5092 (FSPIHD, GPIO4, _2), (MTDI, GPIO5, _0), (FSPIWP, GPIO5, _2), (MTCK, GPIO6, _0),
5093 (FSPICLK, GPIO6, _2), (MTDO, GPIO7, _0), (FSPID, GPIO7, _2), (FSPICS0, GPIO10,
5094 _2), (SPIHD, GPIO12, _0), (SPIWP, GPIO13, _0), (SPICS0, GPIO14, _0), (SPICLK,
5095 GPIO15, _0), (SPID, GPIO16, _0), (SPIQ, GPIO17, _0), (U0RXD, GPIO20, _0), (U0TXD,
5096 GPIO21, _0))); _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0),
5097 GPIO10, _2))); _for_each_inner_iomux_function!((SPICSn((SPICS0, SPICSn, 0),
5098 GPIO14, _0)));
5099 };
5100}
5101#[macro_export]
5118#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5119macro_rules! gpio_for_signal {
5120 (ADC1_CH0 $(, $_fallback:literal)?) => {
5121 "GPIO0"
5122 };
5123 (LP_GPIO0 $(, $_fallback:literal)?) => {
5124 "GPIO0"
5125 };
5126 (ADC1_CH1 $(, $_fallback:literal)?) => {
5127 "GPIO1"
5128 };
5129 (LP_GPIO1 $(, $_fallback:literal)?) => {
5130 "GPIO1"
5131 };
5132 (FSPIQ $(, $_fallback:literal)?) => {
5133 "GPIO2"
5134 };
5135 (ADC1_CH2 $(, $_fallback:literal)?) => {
5136 "GPIO2"
5137 };
5138 (LP_GPIO2 $(, $_fallback:literal)?) => {
5139 "GPIO2"
5140 };
5141 (ADC1_CH3 $(, $_fallback:literal)?) => {
5142 "GPIO3"
5143 };
5144 (LP_GPIO3 $(, $_fallback:literal)?) => {
5145 "GPIO3"
5146 };
5147 (MTMS $(, $_fallback:literal)?) => {
5148 "GPIO4"
5149 };
5150 (FSPIHD $(, $_fallback:literal)?) => {
5151 "GPIO4"
5152 };
5153 (ADC1_CH4 $(, $_fallback:literal)?) => {
5154 "GPIO4"
5155 };
5156 (LP_GPIO4 $(, $_fallback:literal)?) => {
5157 "GPIO4"
5158 };
5159 (MTDI $(, $_fallback:literal)?) => {
5160 "GPIO5"
5161 };
5162 (FSPIWP $(, $_fallback:literal)?) => {
5163 "GPIO5"
5164 };
5165 (ADC2_CH0 $(, $_fallback:literal)?) => {
5166 "GPIO5"
5167 };
5168 (LP_GPIO5 $(, $_fallback:literal)?) => {
5169 "GPIO5"
5170 };
5171 (MTCK $(, $_fallback:literal)?) => {
5172 "GPIO6"
5173 };
5174 (FSPICLK $(, $_fallback:literal)?) => {
5175 "GPIO6"
5176 };
5177 (MTDO $(, $_fallback:literal)?) => {
5178 "GPIO7"
5179 };
5180 (FSPID $(, $_fallback:literal)?) => {
5181 "GPIO7"
5182 };
5183 (FSPICS0 $(, $_fallback:literal)?) => {
5184 "GPIO10"
5185 };
5186 (SPIHD $(, $_fallback:literal)?) => {
5187 "GPIO12"
5188 };
5189 (SPIWP $(, $_fallback:literal)?) => {
5190 "GPIO13"
5191 };
5192 (SPICS0 $(, $_fallback:literal)?) => {
5193 "GPIO14"
5194 };
5195 (SPICLK $(, $_fallback:literal)?) => {
5196 "GPIO15"
5197 };
5198 (SPID $(, $_fallback:literal)?) => {
5199 "GPIO16"
5200 };
5201 (SPIQ $(, $_fallback:literal)?) => {
5202 "GPIO17"
5203 };
5204 (USJ_DM $(, $_fallback:literal)?) => {
5205 "GPIO18"
5206 };
5207 (USJ_DP $(, $_fallback:literal)?) => {
5208 "GPIO19"
5209 };
5210 (U0RXD $(, $_fallback:literal)?) => {
5211 "GPIO20"
5212 };
5213 (U0TXD $(, $_fallback:literal)?) => {
5214 "GPIO21"
5215 };
5216 ($_signal:ident, $fallback:literal) => {
5217 $fallback
5218 };
5219}
5220#[macro_export]
5224#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5225macro_rules! define_io_mux_signals {
5226 () => {
5227 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5228 #[derive(Debug, PartialEq, Copy, Clone)]
5229 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5230 #[doc(hidden)]
5231 pub enum InputSignal {
5232 SPIQ = 0,
5233 SPID = 1,
5234 SPIHD = 2,
5235 SPIWP = 3,
5236 U0RXD = 6,
5237 U0CTS = 7,
5238 U0DSR = 8,
5239 U1RXD = 9,
5240 U1CTS = 10,
5241 U1DSR = 11,
5242 I2S_MCLK = 12,
5243 I2SO_BCK = 13,
5244 I2SO_WS = 14,
5245 I2SI_SD = 15,
5246 I2SI_BCK = 16,
5247 I2SI_WS = 17,
5248 GPIO_BT_PRIORITY = 18,
5249 GPIO_BT_ACTIVE = 19,
5250 CPU_GPIO_0 = 28,
5251 CPU_GPIO_1 = 29,
5252 CPU_GPIO_2 = 30,
5253 CPU_GPIO_3 = 31,
5254 CPU_GPIO_4 = 32,
5255 CPU_GPIO_5 = 33,
5256 CPU_GPIO_6 = 34,
5257 CPU_GPIO_7 = 35,
5258 EXT_ADC_START = 45,
5259 RMT_SIG_0 = 51,
5260 RMT_SIG_1 = 52,
5261 I2CEXT0_SCL = 53,
5262 I2CEXT0_SDA = 54,
5263 FSPICLK = 63,
5264 FSPIQ = 64,
5265 FSPID = 65,
5266 FSPIHD = 66,
5267 FSPIWP = 67,
5268 FSPICS0 = 68,
5269 TWAI_RX = 74,
5270 SIG_FUNC_97 = 97,
5271 SIG_FUNC_98 = 98,
5272 SIG_FUNC_99 = 99,
5273 SIG_FUNC_100 = 100,
5274 MTCK,
5275 MTMS,
5276 MTDI,
5277 }
5278 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5279 #[derive(Debug, PartialEq, Copy, Clone)]
5280 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5281 #[doc(hidden)]
5282 pub enum OutputSignal {
5283 SPIQ = 0,
5284 SPID = 1,
5285 SPIHD = 2,
5286 SPIWP = 3,
5287 SPICLK = 4,
5288 SPICS0 = 5,
5289 U0TXD = 6,
5290 U0RTS = 7,
5291 U0DTR = 8,
5292 U1TXD = 9,
5293 U1RTS = 10,
5294 U1DTR = 11,
5295 I2S_MCLK = 12,
5296 I2SO_BCK = 13,
5297 I2SO_WS = 14,
5298 I2SO_SD = 15,
5299 I2SI_BCK = 16,
5300 I2SI_WS = 17,
5301 GPIO_WLAN_PRIO = 18,
5302 GPIO_WLAN_ACTIVE = 19,
5303 CPU_GPIO_0 = 28,
5304 CPU_GPIO_1 = 29,
5305 CPU_GPIO_2 = 30,
5306 CPU_GPIO_3 = 31,
5307 CPU_GPIO_4 = 32,
5308 CPU_GPIO_5 = 33,
5309 CPU_GPIO_6 = 34,
5310 CPU_GPIO_7 = 35,
5311 USB_JTAG_TCK = 36,
5312 USB_JTAG_TMS = 37,
5313 USB_JTAG_TDI = 38,
5314 USB_JTAG_TDO = 39,
5315 LEDC_LS_SIG0 = 45,
5316 LEDC_LS_SIG1 = 46,
5317 LEDC_LS_SIG2 = 47,
5318 LEDC_LS_SIG3 = 48,
5319 LEDC_LS_SIG4 = 49,
5320 LEDC_LS_SIG5 = 50,
5321 RMT_SIG_0 = 51,
5322 RMT_SIG_1 = 52,
5323 I2CEXT0_SCL = 53,
5324 I2CEXT0_SDA = 54,
5325 GPIO_SD0 = 55,
5326 GPIO_SD1 = 56,
5327 GPIO_SD2 = 57,
5328 GPIO_SD3 = 58,
5329 I2SO_SD1 = 59,
5330 FSPICLK = 63,
5331 FSPIQ = 64,
5332 FSPID = 65,
5333 FSPIHD = 66,
5334 FSPIWP = 67,
5335 FSPICS0 = 68,
5336 FSPICS1 = 69,
5337 FSPICS3 = 70,
5338 FSPICS2 = 71,
5339 FSPICS4 = 72,
5340 FSPICS5 = 73,
5341 TWAI_TX = 74,
5342 TWAI_BUS_OFF_ON = 75,
5343 TWAI_CLKOUT = 76,
5344 ANT_SEL0 = 89,
5345 ANT_SEL1 = 90,
5346 ANT_SEL2 = 91,
5347 ANT_SEL3 = 92,
5348 ANT_SEL4 = 93,
5349 ANT_SEL5 = 94,
5350 ANT_SEL6 = 95,
5351 ANT_SEL7 = 96,
5352 SIG_FUNC_97 = 97,
5353 SIG_FUNC_98 = 98,
5354 SIG_FUNC_99 = 99,
5355 SIG_FUNC_100 = 100,
5356 CLK_OUT1 = 123,
5357 CLK_OUT2 = 124,
5358 CLK_OUT3 = 125,
5359 SPICS1 = 126,
5360 USB_JTAG_TRST = 127,
5361 GPIO = 128,
5362 MTDO,
5363 }
5364 };
5365}
5366#[macro_export]
5373#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5374macro_rules! define_lp_functions {
5375 () => {
5376 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5381 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5382 #[doc(hidden)]
5383 pub enum LpFunction {
5384 _0 = 0,
5386 }
5387 impl LpFunction {
5388 pub const LP_GPIO: Self = Self::_0;
5390 }
5391 };
5392}
5393#[macro_export]
5406#[expect(clippy::crate_in_macro_def)]
5407#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5408macro_rules! define_io_mux_reg {
5409 () => {
5410 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
5411 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
5412 }
5413 };
5414}