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.mclk_divider_bit_width") => {
242 9
243 };
244 ("i2s.mclk_divider_bit_width", str) => {
245 stringify!(9)
246 };
247 ("i2s.max_ws_width") => {
248 128
249 };
250 ("i2s.max_ws_width", str) => {
251 stringify!(128)
252 };
253 ("i2s.clock_configured_by_pcr") => {
254 false
255 };
256 ("i2s.clock_configured_by_hp_sys_clkrst") => {
257 false
258 };
259 ("i2s.supports_pdm_rx_hp_filter") => {
260 false
261 };
262 ("i2s.supports_pdm_tx") => {
263 true
264 };
265 ("i2s.supports_pdm_rx") => {
266 true
267 };
268 ("i2s.supports_pcm2pdm") => {
269 true
270 };
271 ("i2s.supports_pdm2pcm") => {
272 false
273 };
274 ("rmt.ram_start") => {
275 1610703872
276 };
277 ("rmt.ram_start", str) => {
278 stringify!(1610703872)
279 };
280 ("rmt.channel_ram_size") => {
281 48
282 };
283 ("rmt.channel_ram_size", str) => {
284 stringify!(48)
285 };
286 ("rmt.has_tx_immediate_stop") => {
287 true
288 };
289 ("rmt.has_tx_loop_count") => {
290 true
291 };
292 ("rmt.has_tx_loop_auto_stop") => {
293 false
294 };
295 ("rmt.has_tx_carrier_data_only") => {
296 true
297 };
298 ("rmt.has_tx_sync") => {
299 true
300 };
301 ("rmt.has_rx_wrap") => {
302 true
303 };
304 ("rmt.has_rx_demodulation") => {
305 true
306 };
307 ("rmt.has_per_channel_clock") => {
308 false
309 };
310 ("bt.controller") => {
311 "btdm"
312 };
313 ("wifi.has_wifi6") => {
314 false
315 };
316 ("wifi.mac_version") => {
317 1
318 };
319 ("wifi.mac_version", str) => {
320 stringify!(1)
321 };
322 ("wifi.has_5g") => {
323 false
324 };
325 ("wifi.csi_supported") => {
326 true
327 };
328 ("phy.combo_module") => {
329 true
330 };
331 ("phy.backed_up_digital_register_count") => {
332 21
333 };
334 ("phy.backed_up_digital_register_count", str) => {
335 stringify!(21)
336 };
337 ("ledc.version") => {
338 2
339 };
340 ("ledc.version", str) => {
341 stringify!(2)
342 };
343 ("ledc.channel_count") => {
344 6
345 };
346 ("ledc.channel_count", str) => {
347 stringify!(6)
348 };
349 ("sdm.channel_count") => {
350 4
351 };
352 ("sdm.channel_count", str) => {
353 stringify!(4)
354 };
355 ("timergroup.timg_has_timer1") => {
356 false
357 };
358 ("timergroup.timg_has_divcnt_rst") => {
359 true
360 };
361 ("aes.has_split_text_registers") => {
362 true
363 };
364 ("aes.endianness_configurable") => {
365 false
366 };
367 ("rng.apb_cycle_wait_num") => {
368 16
369 };
370 ("rng.apb_cycle_wait_num", str) => {
371 stringify!(16)
372 };
373 ("rng.trng_supported") => {
374 true
375 };
376 ("rng.is_lp_sys") => {
377 false
378 };
379 ("rsa.version") => {
380 3
381 };
382 ("rsa.version", str) => {
383 stringify!(3)
384 };
385 ("rsa.size_increment") => {
386 32
387 };
388 ("rsa.size_increment", str) => {
389 stringify!(32)
390 };
391 ("rsa.memory_size_bytes") => {
392 384
393 };
394 ("rsa.memory_size_bytes", str) => {
395 stringify!(384)
396 };
397 ("sleep.light_sleep") => {
398 true
399 };
400 ("sleep.deep_sleep") => {
401 true
402 };
403 ("sleep.rejectable_mask") => {
404 1852
405 };
406 ("sleep.pin_wakeup_version") => {
407 2
408 };
409 ("sleep.pin_wakeup_version", str) => {
410 stringify!(2)
411 };
412 ("sleep.deep_sleep_needs_gpio_isolation") => {
413 true
414 };
415 ("assist_debug.has_sp_monitor") => {
416 true
417 };
418 ("assist_debug.has_region_monitor") => {
419 true
420 };
421 ("dma.mem2mem_requires_peripheral") => {
422 true
423 };
424 ("dma.ext_mem_configurable_block_size") => {
425 false
426 };
427 ("dma.separate_in_out_interrupts") => {
428 false
429 };
430 ("dma.gdma_version") => {
431 1
432 };
433 ("dma.gdma_version", str) => {
434 stringify!(1)
435 };
436 ("interrupts.status_registers") => {
437 2
438 };
439 ("interrupts.status_registers", str) => {
440 stringify!(2)
441 };
442 ("interrupts.disabled_interrupt") => {
443 0
444 };
445 ("mmu.page_size") => {
446 65536
447 };
448 ("mmu.page_size", str) => {
449 stringify!(65536)
450 };
451 ("mmu.entry_num") => {
452 128
453 };
454 ("mmu.entry_num", str) => {
455 stringify!(128)
456 };
457 ("rom.has_crc_le") => {
458 true
459 };
460 ("rom.has_crc_be") => {
461 true
462 };
463 ("rom.has_md5_bsd") => {
464 true
465 };
466 ("rom.has_md5_mbedtls") => {
467 false
468 };
469 ("soc.cpu_has_branch_predictor") => {
470 false
471 };
472 ("soc.cpu_has_csr_pc") => {
473 true
474 };
475 ("soc.multi_core_enabled") => {
476 false
477 };
478 ("soc.internal_memory_cached") => {
479 false
480 };
481 ("soc.has_swd_watchdog") => {
482 true
483 };
484 ("soc.cpu_mcause_mask") => {
485 31
486 };
487 ("soc.cpu_mcause_mask", str) => {
488 stringify!(31)
489 };
490 ("clock_tree.system_pre_div_in") => {
491 [crate ::soc::clocks::SystemPreDivInConfig::Xtal, crate
492 ::soc::clocks::SystemPreDivInConfig::RcFast]
493 };
494 ("clock_tree.system_pre_div.divisor") => {
495 (0, 1023)
496 };
497 ("clock_tree.cpu_clk") => {
498 [crate ::soc::clocks::CpuClkConfig::Xtal, crate
499 ::soc::clocks::CpuClkConfig::RcFast, crate ::soc::clocks::CpuClkConfig::Pll]
500 };
501 ("clock_tree.apb_clk") => {
502 [crate ::soc::clocks::ApbClkConfig::Pll80m, crate
503 ::soc::clocks::ApbClkConfig::Cpu]
504 };
505 ("clock_tree.crypto_clk") => {
506 [crate ::soc::clocks::CryptoClkConfig::Pll160m, crate
507 ::soc::clocks::CryptoClkConfig::Cpu]
508 };
509 ("clock_tree.rc_fast_clk_div_n.divisor") => {
510 (0, 3)
511 };
512 ("clock_tree.rtc_slow_clk") => {
513 [#[cfg(use_xtal32k)] crate ::soc::clocks::RtcSlowClkConfig::Xtal32k, crate
514 ::soc::clocks::RtcSlowClkConfig::RcSlow, crate
515 ::soc::clocks::RtcSlowClkConfig::RcFast]
516 };
517 ("clock_tree.rtc_fast_clk") => {
518 [crate ::soc::clocks::RtcFastClkConfig::Xtal, crate
519 ::soc::clocks::RtcFastClkConfig::Rc]
520 };
521 ("clock_tree.low_power_clk") => {
522 [crate ::soc::clocks::LowPowerClkConfig::Xtal, crate
523 ::soc::clocks::LowPowerClkConfig::RcFast, #[cfg(use_xtal32k)] crate
524 ::soc::clocks::LowPowerClkConfig::Xtal32k, crate
525 ::soc::clocks::LowPowerClkConfig::RtcSlow]
526 };
527 ("clock_tree.timg_calibration_clock") => {
528 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
529 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
530 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
531 };
532 ("clock_tree.timg.function_clock") => {
533 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
534 ::soc::clocks::TimgFunctionClockConfig::ApbClk]
535 };
536 ("clock_tree.timg.wdt_clock") => {
537 [crate ::soc::clocks::TimgWdtClockConfig::ApbClk, crate
538 ::soc::clocks::TimgWdtClockConfig::XtalClk]
539 };
540 ("clock_tree.rmt.sclk") => {
541 [crate ::soc::clocks::RmtSclkConfig::ApbClk, crate
542 ::soc::clocks::RmtSclkConfig::RcFastClk, crate
543 ::soc::clocks::RmtSclkConfig::XtalClk]
544 };
545 ("clock_tree.uart.function_clock.sclk") => {
546 [crate ::soc::clocks::UartFunctionClockSclk::Apb, crate
547 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
548 ::soc::clocks::UartFunctionClockSclk::Xtal]
549 };
550 ("clock_tree.uart.function_clock.div_num") => {
551 (0, 255)
552 };
553 ("clock_tree.uart.baud_rate_generator.fractional") => {
554 (0, 15)
555 };
556 ("clock_tree.uart.baud_rate_generator.integral") => {
557 (0, 4095)
558 };
559 ("clock_tree.i2c.function_clock.sclk") => {
560 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
561 ::soc::clocks::I2cFunctionClockSclk::RcFast]
562 };
563 ("clock_tree.i2c.function_clock.div_num") => {
564 (0, 255)
565 };
566 ("clock_tree.spi.function_clock") => {
567 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
568 ::soc::clocks::SpiFunctionClockConfig::Pll80m]
569 };
570 ("clock_tree.i2s.tx_clk.sclk") => {
571 [crate ::soc::clocks::I2sClkSclk::Xtal, crate ::soc::clocks::I2sClkSclk::Pll160m]
572 };
573 ("clock_tree.i2s.tx_clk.div_num") => {
574 (1, 255)
575 };
576 ("clock_tree.i2s.tx_clk.div_a") => {
577 (1, 511)
578 };
579 ("clock_tree.i2s.tx_clk.div_b") => {
580 (0, 511)
581 };
582 ("clock_tree.i2s.rx_clk.sclk") => {
583 [crate ::soc::clocks::I2sClkSclk::Xtal, crate ::soc::clocks::I2sClkSclk::Pll160m]
584 };
585 ("clock_tree.i2s.rx_clk.div_num") => {
586 (1, 255)
587 };
588 ("clock_tree.i2s.rx_clk.div_a") => {
589 (1, 511)
590 };
591 ("clock_tree.i2s.rx_clk.div_b") => {
592 (0, 511)
593 };
594 ("clock_tree.i2s.mclk_out") => {
595 [crate ::soc::clocks::I2sMclkOutConfig::Tx, crate
596 ::soc::clocks::I2sMclkOutConfig::Rx]
597 };
598}
599#[macro_export]
600#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
601macro_rules! for_each_dedicated_gpio {
602 ($($pattern:tt => $code:tt;)*) => {
603 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
604 tt) => {} } _for_each_inner_dedicated_gpio!((0));
605 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
606 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
607 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
608 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
609 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
610 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
611 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
612 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
613 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
614 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
615 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
616 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
617 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
618 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
619 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
620 };
621}
622#[macro_export]
626#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
627macro_rules! define_lp_io_signals {
628 () => {};
629}
630#[macro_export]
652#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
653macro_rules! for_each_rmt_channel {
654 ($($pattern:tt => $code:tt;)*) => {
655 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
656 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
657 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
658 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
659 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
660 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
661 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
662 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
663 };
664}
665#[macro_export]
666#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
667macro_rules! for_each_sdm_channel {
668 ($($pattern:tt => $code:tt;)*) => {
669 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
670 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
671 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
672 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
673 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
674 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
675 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
676 GPIO_SD3)));
677 };
678}
679#[macro_export]
680#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
681macro_rules! for_each_aes_key_length {
682 ($($pattern:tt => $code:tt;)*) => {
683 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
684 tt) => {} } _for_each_inner_aes_key_length!((128));
685 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
686 4)); _for_each_inner_aes_key_length!((256, 2, 6));
687 _for_each_inner_aes_key_length!((bits(128), (256)));
688 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
689 };
690}
691#[macro_export]
692#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
693macro_rules! for_each_rsa_exponentiation {
694 ($($pattern:tt => $code:tt;)*) => {
695 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
696 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
697 _for_each_inner_rsa_exponentiation!((64));
698 _for_each_inner_rsa_exponentiation!((96));
699 _for_each_inner_rsa_exponentiation!((128));
700 _for_each_inner_rsa_exponentiation!((160));
701 _for_each_inner_rsa_exponentiation!((192));
702 _for_each_inner_rsa_exponentiation!((224));
703 _for_each_inner_rsa_exponentiation!((256));
704 _for_each_inner_rsa_exponentiation!((288));
705 _for_each_inner_rsa_exponentiation!((320));
706 _for_each_inner_rsa_exponentiation!((352));
707 _for_each_inner_rsa_exponentiation!((384));
708 _for_each_inner_rsa_exponentiation!((416));
709 _for_each_inner_rsa_exponentiation!((448));
710 _for_each_inner_rsa_exponentiation!((480));
711 _for_each_inner_rsa_exponentiation!((512));
712 _for_each_inner_rsa_exponentiation!((544));
713 _for_each_inner_rsa_exponentiation!((576));
714 _for_each_inner_rsa_exponentiation!((608));
715 _for_each_inner_rsa_exponentiation!((640));
716 _for_each_inner_rsa_exponentiation!((672));
717 _for_each_inner_rsa_exponentiation!((704));
718 _for_each_inner_rsa_exponentiation!((736));
719 _for_each_inner_rsa_exponentiation!((768));
720 _for_each_inner_rsa_exponentiation!((800));
721 _for_each_inner_rsa_exponentiation!((832));
722 _for_each_inner_rsa_exponentiation!((864));
723 _for_each_inner_rsa_exponentiation!((896));
724 _for_each_inner_rsa_exponentiation!((928));
725 _for_each_inner_rsa_exponentiation!((960));
726 _for_each_inner_rsa_exponentiation!((992));
727 _for_each_inner_rsa_exponentiation!((1024));
728 _for_each_inner_rsa_exponentiation!((1056));
729 _for_each_inner_rsa_exponentiation!((1088));
730 _for_each_inner_rsa_exponentiation!((1120));
731 _for_each_inner_rsa_exponentiation!((1152));
732 _for_each_inner_rsa_exponentiation!((1184));
733 _for_each_inner_rsa_exponentiation!((1216));
734 _for_each_inner_rsa_exponentiation!((1248));
735 _for_each_inner_rsa_exponentiation!((1280));
736 _for_each_inner_rsa_exponentiation!((1312));
737 _for_each_inner_rsa_exponentiation!((1344));
738 _for_each_inner_rsa_exponentiation!((1376));
739 _for_each_inner_rsa_exponentiation!((1408));
740 _for_each_inner_rsa_exponentiation!((1440));
741 _for_each_inner_rsa_exponentiation!((1472));
742 _for_each_inner_rsa_exponentiation!((1504));
743 _for_each_inner_rsa_exponentiation!((1536));
744 _for_each_inner_rsa_exponentiation!((1568));
745 _for_each_inner_rsa_exponentiation!((1600));
746 _for_each_inner_rsa_exponentiation!((1632));
747 _for_each_inner_rsa_exponentiation!((1664));
748 _for_each_inner_rsa_exponentiation!((1696));
749 _for_each_inner_rsa_exponentiation!((1728));
750 _for_each_inner_rsa_exponentiation!((1760));
751 _for_each_inner_rsa_exponentiation!((1792));
752 _for_each_inner_rsa_exponentiation!((1824));
753 _for_each_inner_rsa_exponentiation!((1856));
754 _for_each_inner_rsa_exponentiation!((1888));
755 _for_each_inner_rsa_exponentiation!((1920));
756 _for_each_inner_rsa_exponentiation!((1952));
757 _for_each_inner_rsa_exponentiation!((1984));
758 _for_each_inner_rsa_exponentiation!((2016));
759 _for_each_inner_rsa_exponentiation!((2048));
760 _for_each_inner_rsa_exponentiation!((2080));
761 _for_each_inner_rsa_exponentiation!((2112));
762 _for_each_inner_rsa_exponentiation!((2144));
763 _for_each_inner_rsa_exponentiation!((2176));
764 _for_each_inner_rsa_exponentiation!((2208));
765 _for_each_inner_rsa_exponentiation!((2240));
766 _for_each_inner_rsa_exponentiation!((2272));
767 _for_each_inner_rsa_exponentiation!((2304));
768 _for_each_inner_rsa_exponentiation!((2336));
769 _for_each_inner_rsa_exponentiation!((2368));
770 _for_each_inner_rsa_exponentiation!((2400));
771 _for_each_inner_rsa_exponentiation!((2432));
772 _for_each_inner_rsa_exponentiation!((2464));
773 _for_each_inner_rsa_exponentiation!((2496));
774 _for_each_inner_rsa_exponentiation!((2528));
775 _for_each_inner_rsa_exponentiation!((2560));
776 _for_each_inner_rsa_exponentiation!((2592));
777 _for_each_inner_rsa_exponentiation!((2624));
778 _for_each_inner_rsa_exponentiation!((2656));
779 _for_each_inner_rsa_exponentiation!((2688));
780 _for_each_inner_rsa_exponentiation!((2720));
781 _for_each_inner_rsa_exponentiation!((2752));
782 _for_each_inner_rsa_exponentiation!((2784));
783 _for_each_inner_rsa_exponentiation!((2816));
784 _for_each_inner_rsa_exponentiation!((2848));
785 _for_each_inner_rsa_exponentiation!((2880));
786 _for_each_inner_rsa_exponentiation!((2912));
787 _for_each_inner_rsa_exponentiation!((2944));
788 _for_each_inner_rsa_exponentiation!((2976));
789 _for_each_inner_rsa_exponentiation!((3008));
790 _for_each_inner_rsa_exponentiation!((3040));
791 _for_each_inner_rsa_exponentiation!((3072));
792 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
793 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
794 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
795 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
796 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
797 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
798 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
799 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
800 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
801 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
802 };
803}
804#[macro_export]
805#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
806macro_rules! for_each_rsa_multiplication {
807 ($($pattern:tt => $code:tt;)*) => {
808 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
809 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
810 _for_each_inner_rsa_multiplication!((64));
811 _for_each_inner_rsa_multiplication!((96));
812 _for_each_inner_rsa_multiplication!((128));
813 _for_each_inner_rsa_multiplication!((160));
814 _for_each_inner_rsa_multiplication!((192));
815 _for_each_inner_rsa_multiplication!((224));
816 _for_each_inner_rsa_multiplication!((256));
817 _for_each_inner_rsa_multiplication!((288));
818 _for_each_inner_rsa_multiplication!((320));
819 _for_each_inner_rsa_multiplication!((352));
820 _for_each_inner_rsa_multiplication!((384));
821 _for_each_inner_rsa_multiplication!((416));
822 _for_each_inner_rsa_multiplication!((448));
823 _for_each_inner_rsa_multiplication!((480));
824 _for_each_inner_rsa_multiplication!((512));
825 _for_each_inner_rsa_multiplication!((544));
826 _for_each_inner_rsa_multiplication!((576));
827 _for_each_inner_rsa_multiplication!((608));
828 _for_each_inner_rsa_multiplication!((640));
829 _for_each_inner_rsa_multiplication!((672));
830 _for_each_inner_rsa_multiplication!((704));
831 _for_each_inner_rsa_multiplication!((736));
832 _for_each_inner_rsa_multiplication!((768));
833 _for_each_inner_rsa_multiplication!((800));
834 _for_each_inner_rsa_multiplication!((832));
835 _for_each_inner_rsa_multiplication!((864));
836 _for_each_inner_rsa_multiplication!((896));
837 _for_each_inner_rsa_multiplication!((928));
838 _for_each_inner_rsa_multiplication!((960));
839 _for_each_inner_rsa_multiplication!((992));
840 _for_each_inner_rsa_multiplication!((1024));
841 _for_each_inner_rsa_multiplication!((1056));
842 _for_each_inner_rsa_multiplication!((1088));
843 _for_each_inner_rsa_multiplication!((1120));
844 _for_each_inner_rsa_multiplication!((1152));
845 _for_each_inner_rsa_multiplication!((1184));
846 _for_each_inner_rsa_multiplication!((1216));
847 _for_each_inner_rsa_multiplication!((1248));
848 _for_each_inner_rsa_multiplication!((1280));
849 _for_each_inner_rsa_multiplication!((1312));
850 _for_each_inner_rsa_multiplication!((1344));
851 _for_each_inner_rsa_multiplication!((1376));
852 _for_each_inner_rsa_multiplication!((1408));
853 _for_each_inner_rsa_multiplication!((1440));
854 _for_each_inner_rsa_multiplication!((1472));
855 _for_each_inner_rsa_multiplication!((1504));
856 _for_each_inner_rsa_multiplication!((1536));
857 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
858 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
859 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
860 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
861 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
862 };
863}
864#[macro_export]
865#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
866macro_rules! for_each_sha_algorithm {
867 ($($pattern:tt => $code:tt;)*) => {
868 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
869 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
870 (insecure_against : "collision", "length extension"), 0));
871 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
872 (insecure_against : "length extension"), 1));
873 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
874 (insecure_against : "length extension"), 2));
875 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
876 (insecure_against : "collision", "length extension"), 0), (Sha224,
877 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
878 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
879 2)));
880 };
881}
882#[macro_export]
883#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
884macro_rules! for_each_wakeup_source {
885 ($($pattern:tt => $code:tt;)*) => {
886 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
887 tt) => {} } _for_each_inner_wakeup_source!((Gpio, 2));
888 _for_each_inner_wakeup_source!((Timer, 3)); _for_each_inner_wakeup_source!((Sdio,
889 4)); _for_each_inner_wakeup_source!((Wifi, 5));
890 _for_each_inner_wakeup_source!((Uart0, 6));
891 _for_each_inner_wakeup_source!((Uart1, 7));
892 _for_each_inner_wakeup_source!((Touch, 8)); _for_each_inner_wakeup_source!((Ulp,
893 9)); _for_each_inner_wakeup_source!((Bt, 10));
894 _for_each_inner_wakeup_source!((all(Gpio, 2), (Timer, 3), (Sdio, 4), (Wifi, 5),
895 (Uart0, 6), (Uart1, 7), (Touch, 8), (Ulp, 9), (Bt, 10)));
896 };
897}
898#[macro_export]
899#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
900macro_rules! for_each_dma_engine {
901 ($($pattern:tt => $code:tt;)*) => {
902 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
903 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
904 _for_each_inner_dma_engine!((all("AHB_GDMA")));
905 };
906}
907#[macro_export]
908#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
909macro_rules! for_each_dma_channel {
910 ($($pattern:tt => $code:tt;)*) => {
911 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
912 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
913 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
914 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
915 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
916 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt = DMA_CH0,
917 compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]));
918 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1, interrupt = DMA_CH1,
919 compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]));
920 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt = DMA_CH2,
921 compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]));
922 _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0), ("AHB_GDMA", DMA_CH1),
923 ("AHB_GDMA", DMA_CH2)));
924 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
925 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared("AHB_GDMA", DMA_CH0, 0,
926 interrupt = DMA_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC]),
927 ("AHB_GDMA", DMA_CH1, 1, interrupt = DMA_CH1, compatible = [SPI2, UHCI0, I2S0,
928 AES, SHA, APB_SARADC]), ("AHB_GDMA", DMA_CH2, 2, interrupt = DMA_CH2, compatible
929 = [SPI2, UHCI0, I2S0, AES, SHA, APB_SARADC])));
930 _for_each_inner_dma_channel!((split));
931 _for_each_inner_dma_channel!((no_own_interrupt));
932 };
933}
934#[macro_export]
935#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
936macro_rules! for_each_dma_channel_peri_pair {
937 ($($pattern:tt => $code:tt;)*) => {
938 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
939 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
940 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
941 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
942 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
943 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
944 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
945 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
946 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
947 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
948 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
949 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
950 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
951 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
952 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
953 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
954 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
955 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
956 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
957 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
958 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
959 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
960 any_channel = AhbGdmaChannel, I2S0));
961 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
962 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
963 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
964 any_channel = AhbGdmaChannel, APB_SARADC));
965 _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0, SPI2),
966 ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA", DMA_CH0,
967 AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC), ("AHB_GDMA",
968 DMA_CH1, SPI2), ("AHB_GDMA", DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0),
969 ("AHB_GDMA", DMA_CH1, AES), ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1,
970 APB_SARADC), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
971 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
972 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC)));
973 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
974 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
975 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
976 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
977 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC)));
978 };
979}
980#[macro_export]
981#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
982macro_rules! for_each_mem2mem_channel {
983 ($($pattern:tt => $code:tt;)*) => {
984 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
985 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
986 AhbGdmaChannel, DMA_CH0, 0)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
987 AhbGdma, AhbGdmaChannel, DMA_CH1, 0));
988 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
989 0)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0, 0,
990 1, 0, 2, 0)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
991 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
992 AhbGdmaChannel, DMA_CH0, 0), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 0),
993 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 0)));
994 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
995 0, 1, 0, 2, 0))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
996 AhbGdmaChannel)));
997 };
998}
999#[macro_export]
1000#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1001macro_rules! with_aes_dma_engine {
1002 ($($pattern:tt => $code:tt;)*) => {
1003 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1004 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1005 };
1006}
1007#[macro_export]
1008#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1009macro_rules! with_i2s_dma_engine {
1010 ($($pattern:tt => $code:tt;)*) => {
1011 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1012 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1013 };
1014}
1015#[macro_export]
1016#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1017macro_rules! with_sha_dma_engine {
1018 ($($pattern:tt => $code:tt;)*) => {
1019 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1020 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1021 };
1022}
1023#[macro_export]
1024#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1025macro_rules! with_spi_master_dma_engine {
1026 ($($pattern:tt => $code:tt;)*) => {
1027 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1028 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1029 };
1030}
1031#[macro_export]
1032#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1033macro_rules! with_spi_slave_dma_engine {
1034 ($($pattern:tt => $code:tt;)*) => {
1035 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1036 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1037 };
1038}
1039#[macro_export]
1040#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1041macro_rules! with_uhci_dma_engine {
1042 ($($pattern:tt => $code:tt;)*) => {
1043 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1044 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1045 };
1046}
1047#[macro_export]
1048#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1049macro_rules! for_each_interrupt {
1050 ($($pattern:tt => $code:tt;)*) => {
1051 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1052 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
1053 _for_each_inner_interrupt!(([reserved 0] 1));
1054 _for_each_inner_interrupt!(([context_switch 0] 2));
1055 _for_each_inner_interrupt!(([direct_bindable 0] 3));
1056 _for_each_inner_interrupt!(([direct_bindable 1] 4));
1057 _for_each_inner_interrupt!(([direct_bindable 2] 5));
1058 _for_each_inner_interrupt!(([direct_bindable 3] 6));
1059 _for_each_inner_interrupt!(([direct_bindable 4] 7));
1060 _for_each_inner_interrupt!(([direct_bindable 5] 8));
1061 _for_each_inner_interrupt!(([direct_bindable 6] 9));
1062 _for_each_inner_interrupt!(([direct_bindable 7] 10));
1063 _for_each_inner_interrupt!(([direct_bindable 8] 11));
1064 _for_each_inner_interrupt!(([direct_bindable 9] 12));
1065 _for_each_inner_interrupt!(([direct_bindable 10] 13));
1066 _for_each_inner_interrupt!(([direct_bindable 11] 14));
1067 _for_each_inner_interrupt!(([direct_bindable 12] 15));
1068 _for_each_inner_interrupt!(([direct_bindable 13] 16));
1069 _for_each_inner_interrupt!(([vector 0] 17)); _for_each_inner_interrupt!(([vector
1070 1] 18)); _for_each_inner_interrupt!(([vector 2] 19));
1071 _for_each_inner_interrupt!(([vector 3] 20)); _for_each_inner_interrupt!(([vector
1072 4] 21)); _for_each_inner_interrupt!(([vector 5] 22));
1073 _for_each_inner_interrupt!(([vector 6] 23)); _for_each_inner_interrupt!(([vector
1074 7] 24)); _for_each_inner_interrupt!(([vector 8] 25));
1075 _for_each_inner_interrupt!(([vector 9] 26)); _for_each_inner_interrupt!(([vector
1076 10] 27)); _for_each_inner_interrupt!(([vector 11] 28));
1077 _for_each_inner_interrupt!(([vector 12] 29)); _for_each_inner_interrupt!(([vector
1078 13] 30)); _for_each_inner_interrupt!(([vector 14] 31));
1079 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1),
1080 ([context_switch 0] 2), ([direct_bindable 0] 3), ([direct_bindable 1] 4),
1081 ([direct_bindable 2] 5), ([direct_bindable 3] 6), ([direct_bindable 4] 7),
1082 ([direct_bindable 5] 8), ([direct_bindable 6] 9), ([direct_bindable 7] 10),
1083 ([direct_bindable 8] 11), ([direct_bindable 9] 12), ([direct_bindable 10] 13),
1084 ([direct_bindable 11] 14), ([direct_bindable 12] 15), ([direct_bindable 13] 16),
1085 ([vector 0] 17), ([vector 1] 18), ([vector 2] 19), ([vector 3] 20), ([vector 4]
1086 21), ([vector 5] 22), ([vector 6] 23), ([vector 7] 24), ([vector 8] 25), ([vector
1087 9] 26), ([vector 10] 27), ([vector 11] 28), ([vector 12] 29), ([vector 13] 30),
1088 ([vector 14] 31)));
1089 };
1090}
1091#[macro_export]
1092#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1093macro_rules! for_each_classified_interrupt {
1094 ($($pattern:tt => $code:tt;)*) => {
1095 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1096 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1097 3)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 4));
1098 _for_each_inner_classified_interrupt!(([direct_bindable 2] 5));
1099 _for_each_inner_classified_interrupt!(([direct_bindable 3] 6));
1100 _for_each_inner_classified_interrupt!(([direct_bindable 4] 7));
1101 _for_each_inner_classified_interrupt!(([direct_bindable 5] 8));
1102 _for_each_inner_classified_interrupt!(([direct_bindable 6] 9));
1103 _for_each_inner_classified_interrupt!(([direct_bindable 7] 10));
1104 _for_each_inner_classified_interrupt!(([direct_bindable 8] 11));
1105 _for_each_inner_classified_interrupt!(([direct_bindable 9] 12));
1106 _for_each_inner_classified_interrupt!(([direct_bindable 10] 13));
1107 _for_each_inner_classified_interrupt!(([direct_bindable 11] 14));
1108 _for_each_inner_classified_interrupt!(([direct_bindable 12] 15));
1109 _for_each_inner_classified_interrupt!(([direct_bindable 13] 16));
1110 _for_each_inner_classified_interrupt!(([vector 0] 17));
1111 _for_each_inner_classified_interrupt!(([vector 1] 18));
1112 _for_each_inner_classified_interrupt!(([vector 2] 19));
1113 _for_each_inner_classified_interrupt!(([vector 3] 20));
1114 _for_each_inner_classified_interrupt!(([vector 4] 21));
1115 _for_each_inner_classified_interrupt!(([vector 5] 22));
1116 _for_each_inner_classified_interrupt!(([vector 6] 23));
1117 _for_each_inner_classified_interrupt!(([vector 7] 24));
1118 _for_each_inner_classified_interrupt!(([vector 8] 25));
1119 _for_each_inner_classified_interrupt!(([vector 9] 26));
1120 _for_each_inner_classified_interrupt!(([vector 10] 27));
1121 _for_each_inner_classified_interrupt!(([vector 11] 28));
1122 _for_each_inner_classified_interrupt!(([vector 12] 29));
1123 _for_each_inner_classified_interrupt!(([vector 13] 30));
1124 _for_each_inner_classified_interrupt!(([vector 14] 31));
1125 _for_each_inner_classified_interrupt!(([reserved 0] 1));
1126 _for_each_inner_classified_interrupt!(([context_switch 0] 2));
1127 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 3),
1128 ([direct_bindable 1] 4), ([direct_bindable 2] 5), ([direct_bindable 3] 6),
1129 ([direct_bindable 4] 7), ([direct_bindable 5] 8), ([direct_bindable 6] 9),
1130 ([direct_bindable 7] 10), ([direct_bindable 8] 11), ([direct_bindable 9] 12),
1131 ([direct_bindable 10] 13), ([direct_bindable 11] 14), ([direct_bindable 12] 15),
1132 ([direct_bindable 13] 16)));
1133 _for_each_inner_classified_interrupt!((vector([vector 0] 17), ([vector 1] 18),
1134 ([vector 2] 19), ([vector 3] 20), ([vector 4] 21), ([vector 5] 22), ([vector 6]
1135 23), ([vector 7] 24), ([vector 8] 25), ([vector 9] 26), ([vector 10] 27),
1136 ([vector 11] 28), ([vector 12] 29), ([vector 13] 30), ([vector 14] 31)));
1137 _for_each_inner_classified_interrupt!((reserved([reserved 0] 1)));
1138 _for_each_inner_classified_interrupt!((context_switch([context_switch 0] 2)));
1139 };
1140}
1141#[macro_export]
1142#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1143macro_rules! for_each_interrupt_priority {
1144 ($($pattern:tt => $code:tt;)*) => {
1145 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1146 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1147 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1148 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1149 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1150 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1151 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1152 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1153 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1154 _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
1155 _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
1156 _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
1157 _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
1158 _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
1159 _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
1160 _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
1161 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1162 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1163 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1164 Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
1165 11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
1166 Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
1167 };
1168}
1169#[macro_export]
1170#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1171macro_rules! for_each_sw_interrupt {
1172 ($($pattern:tt => $code:tt;)*) => {
1173 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1174 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1175 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1176 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1177 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1178 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1179 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1180 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1181 };
1182}
1183#[macro_export]
1184macro_rules! define_clock_tree_types {
1580 () => {
1581 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1582 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1583 pub enum SdmInstance {
1584 GpioSd = 0,
1585 }
1586 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1587 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1588 pub enum I2cInstance {
1589 I2c0 = 0,
1590 }
1591 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1592 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1593 pub enum I2sInstance {
1594 I2s0 = 0,
1595 }
1596 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1597 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1598 pub enum RmtInstance {
1599 Rmt = 0,
1600 }
1601 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1602 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1603 pub enum SpiInstance {
1604 Spi2 = 0,
1605 }
1606 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1607 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1608 pub enum TimgInstance {
1609 Timg0 = 0,
1610 Timg1 = 1,
1611 }
1612 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1613 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1614 pub enum UartInstance {
1615 Uart0 = 0,
1616 Uart1 = 1,
1617 }
1618 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1620 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1621 pub enum XtalClkConfig {
1622 _40,
1624 }
1625 impl XtalClkConfig {
1626 pub fn value(&self) -> u32 {
1627 match self {
1628 XtalClkConfig::_40 => 40000000,
1629 }
1630 }
1631 }
1632 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1634 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1635 pub enum PllClkConfig {
1636 _320,
1638 _480,
1640 }
1641 impl PllClkConfig {
1642 pub fn value(&self) -> u32 {
1643 match self {
1644 PllClkConfig::_320 => 320000000,
1645 PllClkConfig::_480 => 480000000,
1646 }
1647 }
1648 }
1649 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1651 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1652 pub enum SystemPreDivInConfig {
1653 Xtal,
1655 RcFast,
1657 }
1658 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1662 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1663 pub struct SystemPreDivConfig {
1664 divisor: u32,
1665 }
1666 impl SystemPreDivConfig {
1667 pub const fn new(divisor: u32) -> Self {
1674 ::core::assert!(
1675 divisor <= 1023,
1676 "`SYSTEM_PRE_DIV` divisor must be between 0 and 1023 (inclusive)."
1677 );
1678 Self { divisor }
1679 }
1680 pub(crate) fn divisor(self) -> u32 {
1681 self.divisor as u32
1682 }
1683 }
1684 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1686 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1687 pub enum CpuPllDivOutConfig {
1688 _80,
1690 _160,
1692 }
1693 impl CpuPllDivOutConfig {
1694 pub fn value(&self) -> u32 {
1695 match self {
1696 CpuPllDivOutConfig::_80 => 80000000,
1697 CpuPllDivOutConfig::_160 => 160000000,
1698 }
1699 }
1700 }
1701 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1703 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1704 pub enum ApbClkConfig {
1705 Pll80m,
1707 Cpu,
1709 }
1710 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1712 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1713 pub enum CryptoClkConfig {
1714 Pll160m,
1716 Cpu,
1718 }
1719 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1721 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1722 pub enum CpuClkConfig {
1723 Xtal,
1725 RcFast,
1727 Pll,
1729 }
1730 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1734 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1735 pub struct RcFastClkDivNConfig {
1736 divisor: u32,
1737 }
1738 impl RcFastClkDivNConfig {
1739 pub const fn new(divisor: u32) -> Self {
1746 ::core::assert!(
1747 divisor <= 3,
1748 "`RC_FAST_CLK_DIV_N` divisor must be between 0 and 3 (inclusive)."
1749 );
1750 Self { divisor }
1751 }
1752 pub(crate) fn divisor(self) -> u32 {
1753 self.divisor as u32
1754 }
1755 }
1756 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1758 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1759 pub enum RtcSlowClkConfig {
1760 #[cfg(use_xtal32k)]
1761 Xtal32k,
1763 RcSlow,
1765 RcFast,
1767 }
1768 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1770 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1771 pub enum RtcFastClkConfig {
1772 Xtal,
1774 Rc,
1776 }
1777 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1779 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1780 pub enum LowPowerClkConfig {
1781 Xtal,
1783 RcFast,
1785 #[cfg(use_xtal32k)]
1786 Xtal32k,
1788 RtcSlow,
1790 }
1791 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1793 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1794 pub enum UartMemClkConfig {
1795 #[default]
1796 Xtal,
1798 }
1799 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1801 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1802 pub enum TimgCalibrationClockConfig {
1803 RcSlowClk,
1805 RcFastDivClk,
1807 #[cfg(use_xtal32k)]
1808 Xtal32kClk,
1810 }
1811 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1812 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1813 pub enum I2cFunctionClockSclk {
1814 #[default]
1815 Xtal,
1817 RcFast,
1819 }
1820 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1824 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1825 pub struct I2cFunctionClockConfig {
1826 sclk: I2cFunctionClockSclk,
1827 div_num: u32,
1828 }
1829 impl I2cFunctionClockConfig {
1830 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1837 ::core::assert!(
1838 div_num <= 255,
1839 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1840 );
1841 Self { sclk, div_num }
1842 }
1843 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1844 self.sclk
1845 }
1846 pub(crate) fn div_num(self) -> u32 {
1847 self.div_num as u32
1848 }
1849 }
1850 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1851 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1852 pub enum I2sClkSclk {
1853 Xtal,
1855 #[default]
1856 Pll160m,
1858 }
1859 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1863 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1864 pub struct I2sClkConfig {
1865 sclk: I2sClkSclk,
1866 div_num: u32,
1867 div_a: u32,
1868 div_b: u32,
1869 }
1870 impl I2sClkConfig {
1871 pub const fn new(sclk: I2sClkSclk, div_num: u32, div_a: u32, div_b: u32) -> Self {
1884 ::core::assert!(
1885 div_num >= 1 && div_num <= 255,
1886 "`I2S0_TX_CLK` div_num must be between 1 and 255 (inclusive)."
1887 );
1888 ::core::assert!(
1889 div_a >= 1 && div_a <= 511,
1890 "`I2S0_TX_CLK` div_a must be between 1 and 511 (inclusive)."
1891 );
1892 ::core::assert!(
1893 div_b <= 511,
1894 "`I2S0_TX_CLK` div_b must be between 0 and 511 (inclusive)."
1895 );
1896 Self {
1897 sclk,
1898 div_num,
1899 div_a,
1900 div_b,
1901 }
1902 }
1903 pub(crate) fn sclk(self) -> I2sClkSclk {
1904 self.sclk
1905 }
1906 pub(crate) fn div_num(self) -> u32 {
1907 self.div_num as u32
1908 }
1909 pub(crate) fn div_a(self) -> u32 {
1910 self.div_a as u32
1911 }
1912 pub(crate) fn div_b(self) -> u32 {
1913 self.div_b as u32
1914 }
1915 }
1916 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1918 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1919 pub enum I2sMclkOutConfig {
1920 Tx,
1922 #[default]
1923 Rx,
1925 }
1926 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1928 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1929 pub enum RmtSclkConfig {
1930 #[default]
1931 ApbClk,
1933 RcFastClk,
1935 XtalClk,
1937 }
1938 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1940 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1941 pub enum SpiFunctionClockConfig {
1942 Xtal,
1944 #[default]
1945 Pll80m,
1947 }
1948 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1950 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1951 pub enum TimgFunctionClockConfig {
1952 #[default]
1953 XtalClk,
1955 ApbClk,
1957 }
1958 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1960 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1961 pub enum TimgWdtClockConfig {
1962 #[default]
1963 ApbClk,
1965 XtalClk,
1967 }
1968 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1969 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1970 pub enum UartFunctionClockSclk {
1971 Apb,
1973 RcFast,
1975 #[default]
1976 Xtal,
1978 }
1979 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1983 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1984 pub struct UartFunctionClockConfig {
1985 sclk: UartFunctionClockSclk,
1986 div_num: u32,
1987 }
1988 impl UartFunctionClockConfig {
1989 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1996 ::core::assert!(
1997 div_num <= 255,
1998 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1999 );
2000 Self { sclk, div_num }
2001 }
2002 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
2003 self.sclk
2004 }
2005 pub(crate) fn div_num(self) -> u32 {
2006 self.div_num as u32
2007 }
2008 }
2009 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2014 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2015 pub struct UartBaudRateGeneratorConfig {
2016 fractional: u32,
2017 integral: u32,
2018 }
2019 impl UartBaudRateGeneratorConfig {
2020 pub const fn new(fractional: u32, integral: u32) -> Self {
2030 ::core::assert!(
2031 fractional <= 15,
2032 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2033 );
2034 ::core::assert!(
2035 integral <= 4095,
2036 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2037 );
2038 Self {
2039 fractional,
2040 integral,
2041 }
2042 }
2043 pub(crate) fn fractional(self) -> u32 {
2044 self.fractional as u32
2045 }
2046 pub(crate) fn integral(self) -> u32 {
2047 self.integral as u32
2048 }
2049 }
2050 pub struct ClockTree {
2052 xtal_clk: Option<XtalClkConfig>,
2053 pll_clk: Option<PllClkConfig>,
2054 system_pre_div_in: Option<SystemPreDivInConfig>,
2055 system_pre_div: Option<SystemPreDivConfig>,
2056 cpu_pll_div_out: Option<CpuPllDivOutConfig>,
2057 apb_clk: Option<ApbClkConfig>,
2058 crypto_clk: Option<CryptoClkConfig>,
2059 cpu_clk: Option<CpuClkConfig>,
2060 rc_fast_clk_div_n: Option<RcFastClkDivNConfig>,
2061 rtc_slow_clk: Option<RtcSlowClkConfig>,
2062 rtc_fast_clk: Option<RtcFastClkConfig>,
2063 low_power_clk: Option<LowPowerClkConfig>,
2064 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2065 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
2066 i2s_tx_clk: [Option<I2sClkConfig>; 1],
2067 i2s_rx_clk: [Option<I2sClkConfig>; 1],
2068 i2s_mclk_out: [Option<I2sMclkOutConfig>; 1],
2069 rmt_sclk: [Option<RmtSclkConfig>; 1],
2070 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
2071 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2072 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2073 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2074 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2075 rc_fast_clk_refcount: u32,
2076 #[cfg(use_xtal32k)]
2077 xtal32k_clk_refcount: u32,
2078 rc_slow_clk_refcount: u32,
2079 rc_fast_div_clk_refcount: u32,
2080 apb_clk_refcount: u32,
2081 crypto_clk_refcount: u32,
2082 pll_80m_refcount: u32,
2083 pll_160m_refcount: u32,
2084 rtc_fast_clk_refcount: u32,
2085 low_power_clk_refcount: u32,
2086 uart_mem_clk_refcount: u32,
2087 timg_calibration_clock_refcount: u32,
2088 sdm_function_clock_refcount: [u32; 1],
2089 i2c_function_clock_refcount: [u32; 1],
2090 i2s_tx_clk_refcount: [u32; 1],
2091 i2s_rx_clk_refcount: [u32; 1],
2092 i2s_mclk_out_refcount: [u32; 1],
2093 rmt_sclk_refcount: [u32; 1],
2094 spi_function_clock_refcount: [u32; 1],
2095 timg_function_clock_refcount: [u32; 2],
2096 timg_wdt_clock_refcount: [u32; 2],
2097 uart_function_clock_refcount: [u32; 2],
2098 uart_mem_clock_refcount: [u32; 2],
2099 uart_baud_rate_generator_refcount: [u32; 2],
2100 }
2101 impl ClockTree {
2102 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2104 CLOCK_TREE.with(f)
2105 }
2106 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2108 self.xtal_clk
2109 }
2110 pub fn pll_clk(&self) -> Option<PllClkConfig> {
2112 self.pll_clk
2113 }
2114 pub fn system_pre_div_in(&self) -> Option<SystemPreDivInConfig> {
2116 self.system_pre_div_in
2117 }
2118 pub fn system_pre_div(&self) -> Option<SystemPreDivConfig> {
2120 self.system_pre_div
2121 }
2122 pub fn cpu_pll_div_out(&self) -> Option<CpuPllDivOutConfig> {
2124 self.cpu_pll_div_out
2125 }
2126 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2128 self.apb_clk
2129 }
2130 pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
2132 self.crypto_clk
2133 }
2134 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2136 self.cpu_clk
2137 }
2138 pub fn rc_fast_clk_div_n(&self) -> Option<RcFastClkDivNConfig> {
2140 self.rc_fast_clk_div_n
2141 }
2142 pub fn rtc_slow_clk(&self) -> Option<RtcSlowClkConfig> {
2144 self.rtc_slow_clk
2145 }
2146 pub fn rtc_fast_clk(&self) -> Option<RtcFastClkConfig> {
2148 self.rtc_fast_clk
2149 }
2150 pub fn low_power_clk(&self) -> Option<LowPowerClkConfig> {
2152 self.low_power_clk
2153 }
2154 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2156 self.timg_calibration_clock
2157 }
2158 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2160 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2161 }
2162 pub fn i2s0_tx_clk(&self) -> Option<I2sClkConfig> {
2164 self.i2s_tx_clk[I2sInstance::I2s0 as usize]
2165 }
2166 pub fn i2s0_rx_clk(&self) -> Option<I2sClkConfig> {
2168 self.i2s_rx_clk[I2sInstance::I2s0 as usize]
2169 }
2170 pub fn i2s0_mclk_out(&self) -> Option<I2sMclkOutConfig> {
2172 self.i2s_mclk_out[I2sInstance::I2s0 as usize]
2173 }
2174 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2176 self.rmt_sclk[RmtInstance::Rmt as usize]
2177 }
2178 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2180 self.spi_function_clock[SpiInstance::Spi2 as usize]
2181 }
2182 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2184 self.timg_function_clock[TimgInstance::Timg0 as usize]
2185 }
2186 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2188 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2189 }
2190 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2192 self.timg_function_clock[TimgInstance::Timg1 as usize]
2193 }
2194 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2196 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2197 }
2198 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2200 self.uart_function_clock[UartInstance::Uart0 as usize]
2201 }
2202 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2204 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2205 }
2206 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2208 self.uart_function_clock[UartInstance::Uart1 as usize]
2209 }
2210 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2212 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2213 }
2214 }
2215 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2216 ::esp_sync::NonReentrantMutex::new(ClockTree {
2217 xtal_clk: None,
2218 pll_clk: None,
2219 system_pre_div_in: None,
2220 system_pre_div: None,
2221 cpu_pll_div_out: None,
2222 apb_clk: None,
2223 crypto_clk: None,
2224 cpu_clk: None,
2225 rc_fast_clk_div_n: None,
2226 rtc_slow_clk: None,
2227 rtc_fast_clk: None,
2228 low_power_clk: None,
2229 timg_calibration_clock: None,
2230 i2c_function_clock: [None; 1],
2231 i2s_tx_clk: [None; 1],
2232 i2s_rx_clk: [None; 1],
2233 i2s_mclk_out: [None; 1],
2234 rmt_sclk: [None; 1],
2235 spi_function_clock: [None; 1],
2236 timg_function_clock: [None; 2],
2237 timg_wdt_clock: [None; 2],
2238 uart_function_clock: [None; 2],
2239 uart_baud_rate_generator: [None; 2],
2240 rc_fast_clk_refcount: 0,
2241 #[cfg(use_xtal32k)]
2242 xtal32k_clk_refcount: 0,
2243 rc_slow_clk_refcount: 0,
2244 rc_fast_div_clk_refcount: 0,
2245 apb_clk_refcount: 0,
2246 crypto_clk_refcount: 0,
2247 pll_80m_refcount: 0,
2248 pll_160m_refcount: 0,
2249 rtc_fast_clk_refcount: 0,
2250 low_power_clk_refcount: 0,
2251 uart_mem_clk_refcount: 0,
2252 timg_calibration_clock_refcount: 0,
2253 sdm_function_clock_refcount: [0; 1],
2254 i2c_function_clock_refcount: [0; 1],
2255 i2s_tx_clk_refcount: [0; 1],
2256 i2s_rx_clk_refcount: [0; 1],
2257 i2s_mclk_out_refcount: [0; 1],
2258 rmt_sclk_refcount: [0; 1],
2259 spi_function_clock_refcount: [0; 1],
2260 timg_function_clock_refcount: [0; 2],
2261 timg_wdt_clock_refcount: [0; 2],
2262 uart_function_clock_refcount: [0; 2],
2263 uart_mem_clock_refcount: [0; 2],
2264 uart_baud_rate_generator_refcount: [0; 2],
2265 });
2266 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2267 ::core::sync::atomic::AtomicU32::new(0);
2268 static PLL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2269 ::core::sync::atomic::AtomicU32::new(0);
2270 static SYSTEM_PRE_DIV_IN_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2271 ::core::sync::atomic::AtomicU32::new(0);
2272 static SYSTEM_PRE_DIV_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2273 ::core::sync::atomic::AtomicU32::new(0);
2274 static CPU_PLL_DIV_OUT_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2275 ::core::sync::atomic::AtomicU32::new(0);
2276 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2277 ::core::sync::atomic::AtomicU32::new(0);
2278 static RC_FAST_CLK_DIV_N_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2279 ::core::sync::atomic::AtomicU32::new(0);
2280 static RTC_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2281 ::core::sync::atomic::AtomicU32::new(0);
2282 static RTC_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2283 ::core::sync::atomic::AtomicU32::new(0);
2284 static LOW_POWER_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2285 ::core::sync::atomic::AtomicU32::new(0);
2286 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2287 ::core::sync::atomic::AtomicU32::new(0);
2288 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2289 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2290 static I2S_TX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2291 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2292 static I2S_RX_CLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2293 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2294 static I2S_MCLK_OUT_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2295 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2296 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2297 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2298 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2299 ::core::sync::atomic::AtomicU32::new(0);
2300 static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2301 ::core::sync::atomic::AtomicU32::new(0);
2302 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2303 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2304 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2305 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2306 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2307 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2308 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2309 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2310 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2311 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2312 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2313 let old_config = clocks.xtal_clk.replace(config);
2314 refresh_xtal_clk_downstream(clocks);
2315 configure_xtal_clk_impl(clocks, old_config, config);
2316 }
2317 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2318 clocks.xtal_clk
2319 }
2320 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2321 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2322 #[allow(unused_variables)]
2323 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
2324 config.value()
2325 }
2326 pub fn xtal_clk_frequency() -> u32 {
2327 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2328 }
2329 pub fn configure_pll_clk(clocks: &mut ClockTree, config: PllClkConfig) {
2330 let old_config = clocks.pll_clk.replace(config);
2331 refresh_pll_clk_downstream(clocks);
2332 configure_pll_clk_impl(clocks, old_config, config);
2333 }
2334 pub fn pll_clk_config(clocks: &mut ClockTree) -> Option<PllClkConfig> {
2335 clocks.pll_clk
2336 }
2337 pub fn request_pll_clk(clocks: &mut ClockTree) {
2338 trace!("Requesting PLL_CLK");
2339 trace!("Enabling PLL_CLK");
2340 request_xtal_clk(clocks);
2341 enable_pll_clk_impl(clocks, true);
2342 }
2343 pub fn release_pll_clk(clocks: &mut ClockTree) {
2344 trace!("Releasing PLL_CLK");
2345 trace!("Disabling PLL_CLK");
2346 enable_pll_clk_impl(clocks, false);
2347 release_xtal_clk(clocks);
2348 }
2349 #[allow(unused_variables)]
2350 pub fn pll_clk_config_frequency(clocks: &mut ClockTree, config: PllClkConfig) -> u32 {
2351 config.value()
2352 }
2353 pub fn pll_clk_frequency() -> u32 {
2354 PLL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2355 }
2356 pub fn pll_clk_source_frequency() -> u32 {
2357 xtal_clk_frequency()
2358 }
2359 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2360 trace!("Requesting RC_FAST_CLK");
2361 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2362 trace!("Enabling RC_FAST_CLK");
2363 enable_rc_fast_clk_impl(clocks, true);
2364 }
2365 }
2366 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2367 trace!("Releasing RC_FAST_CLK");
2368 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2369 trace!("Disabling RC_FAST_CLK");
2370 enable_rc_fast_clk_impl(clocks, false);
2371 }
2372 }
2373 pub fn rc_fast_clk_frequency() -> u32 {
2374 17500000
2375 }
2376 #[cfg(use_xtal32k)]
2377 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2378 trace!("Requesting XTAL32K_CLK");
2379 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2380 trace!("Enabling XTAL32K_CLK");
2381 enable_xtal32k_clk_impl(clocks, true);
2382 }
2383 }
2384 #[cfg(use_xtal32k)]
2385 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2386 trace!("Releasing XTAL32K_CLK");
2387 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2388 trace!("Disabling XTAL32K_CLK");
2389 enable_xtal32k_clk_impl(clocks, false);
2390 }
2391 }
2392 #[cfg(use_xtal32k)]
2393 pub fn xtal32k_clk_frequency() -> u32 {
2394 32768
2395 }
2396 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2397 trace!("Requesting RC_SLOW_CLK");
2398 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
2399 trace!("Enabling RC_SLOW_CLK");
2400 enable_rc_slow_clk_impl(clocks, true);
2401 }
2402 }
2403 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2404 trace!("Releasing RC_SLOW_CLK");
2405 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
2406 trace!("Disabling RC_SLOW_CLK");
2407 enable_rc_slow_clk_impl(clocks, false);
2408 }
2409 }
2410 pub fn rc_slow_clk_frequency() -> u32 {
2411 136000
2412 }
2413 pub fn request_rc_fast_div_clk(clocks: &mut ClockTree) {
2414 trace!("Requesting RC_FAST_DIV_CLK");
2415 if increment_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
2416 trace!("Enabling RC_FAST_DIV_CLK");
2417 request_rc_fast_clk(clocks);
2418 enable_rc_fast_div_clk_impl(clocks, true);
2419 }
2420 }
2421 pub fn release_rc_fast_div_clk(clocks: &mut ClockTree) {
2422 trace!("Releasing RC_FAST_DIV_CLK");
2423 if decrement_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
2424 trace!("Disabling RC_FAST_DIV_CLK");
2425 enable_rc_fast_div_clk_impl(clocks, false);
2426 release_rc_fast_clk(clocks);
2427 }
2428 }
2429 pub fn rc_fast_div_clk_frequency() -> u32 {
2430 (rc_fast_clk_frequency() / 256)
2431 }
2432 pub fn rc_fast_div_clk_source_frequency() -> u32 {
2433 rc_fast_clk_frequency()
2434 }
2435 pub fn configure_system_pre_div_in(
2436 clocks: &mut ClockTree,
2437 new_selector: SystemPreDivInConfig,
2438 ) {
2439 let old_selector = clocks.system_pre_div_in.replace(new_selector);
2440 refresh_system_pre_div_in_downstream(clocks);
2441 match new_selector {
2442 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2443 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2444 }
2445 configure_system_pre_div_in_impl(clocks, old_selector, new_selector);
2446 if let Some(old_selector) = old_selector {
2447 match old_selector {
2448 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2449 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2450 }
2451 }
2452 }
2453 pub fn system_pre_div_in_config(clocks: &mut ClockTree) -> Option<SystemPreDivInConfig> {
2454 clocks.system_pre_div_in
2455 }
2456 pub fn request_system_pre_div_in(clocks: &mut ClockTree) {
2457 trace!("Requesting SYSTEM_PRE_DIV_IN");
2458 trace!("Enabling SYSTEM_PRE_DIV_IN");
2459 match unwrap!(clocks.system_pre_div_in) {
2460 SystemPreDivInConfig::Xtal => request_xtal_clk(clocks),
2461 SystemPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
2462 }
2463 enable_system_pre_div_in_impl(clocks, true);
2464 }
2465 pub fn release_system_pre_div_in(clocks: &mut ClockTree) {
2466 trace!("Releasing SYSTEM_PRE_DIV_IN");
2467 trace!("Disabling SYSTEM_PRE_DIV_IN");
2468 enable_system_pre_div_in_impl(clocks, false);
2469 match unwrap!(clocks.system_pre_div_in) {
2470 SystemPreDivInConfig::Xtal => release_xtal_clk(clocks),
2471 SystemPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
2472 }
2473 }
2474 #[allow(unused_variables)]
2475 pub fn system_pre_div_in_config_frequency(
2476 clocks: &mut ClockTree,
2477 config: SystemPreDivInConfig,
2478 ) -> u32 {
2479 match config {
2480 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2481 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2482 }
2483 }
2484 pub fn system_pre_div_in_frequency() -> u32 {
2485 SYSTEM_PRE_DIV_IN_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2486 }
2487 pub fn system_pre_div_in_source_frequency(source: SystemPreDivInConfig) -> u32 {
2488 match source {
2489 SystemPreDivInConfig::Xtal => xtal_clk_frequency(),
2490 SystemPreDivInConfig::RcFast => rc_fast_clk_frequency(),
2491 }
2492 }
2493 pub fn configure_system_pre_div(clocks: &mut ClockTree, config: SystemPreDivConfig) {
2494 let old_config = clocks.system_pre_div.replace(config);
2495 refresh_system_pre_div_downstream(clocks);
2496 configure_system_pre_div_impl(clocks, old_config, config);
2497 }
2498 pub fn system_pre_div_config(clocks: &mut ClockTree) -> Option<SystemPreDivConfig> {
2499 clocks.system_pre_div
2500 }
2501 pub fn request_system_pre_div(clocks: &mut ClockTree) {
2502 trace!("Requesting SYSTEM_PRE_DIV");
2503 trace!("Enabling SYSTEM_PRE_DIV");
2504 request_system_pre_div_in(clocks);
2505 enable_system_pre_div_impl(clocks, true);
2506 }
2507 pub fn release_system_pre_div(clocks: &mut ClockTree) {
2508 trace!("Releasing SYSTEM_PRE_DIV");
2509 trace!("Disabling SYSTEM_PRE_DIV");
2510 enable_system_pre_div_impl(clocks, false);
2511 release_system_pre_div_in(clocks);
2512 }
2513 #[allow(unused_variables)]
2514 pub fn system_pre_div_config_frequency(
2515 clocks: &mut ClockTree,
2516 config: SystemPreDivConfig,
2517 ) -> u32 {
2518 (system_pre_div_in_frequency() / (config.divisor() + 1))
2519 }
2520 pub fn system_pre_div_frequency() -> u32 {
2521 SYSTEM_PRE_DIV_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2522 }
2523 pub fn system_pre_div_source_frequency() -> u32 {
2524 system_pre_div_in_frequency()
2525 }
2526 pub fn configure_cpu_pll_div_out(clocks: &mut ClockTree, config: CpuPllDivOutConfig) {
2527 let old_config = clocks.cpu_pll_div_out.replace(config);
2528 refresh_cpu_pll_div_out_downstream(clocks);
2529 configure_cpu_pll_div_out_impl(clocks, old_config, config);
2530 }
2531 pub fn cpu_pll_div_out_config(clocks: &mut ClockTree) -> Option<CpuPllDivOutConfig> {
2532 clocks.cpu_pll_div_out
2533 }
2534 pub fn request_cpu_pll_div_out(clocks: &mut ClockTree) {
2535 trace!("Requesting CPU_PLL_DIV_OUT");
2536 trace!("Enabling CPU_PLL_DIV_OUT");
2537 request_pll_clk(clocks);
2538 enable_cpu_pll_div_out_impl(clocks, true);
2539 }
2540 pub fn release_cpu_pll_div_out(clocks: &mut ClockTree) {
2541 trace!("Releasing CPU_PLL_DIV_OUT");
2542 trace!("Disabling CPU_PLL_DIV_OUT");
2543 enable_cpu_pll_div_out_impl(clocks, false);
2544 release_pll_clk(clocks);
2545 }
2546 #[allow(unused_variables)]
2547 pub fn cpu_pll_div_out_config_frequency(
2548 clocks: &mut ClockTree,
2549 config: CpuPllDivOutConfig,
2550 ) -> u32 {
2551 config.value()
2552 }
2553 pub fn cpu_pll_div_out_frequency() -> u32 {
2554 CPU_PLL_DIV_OUT_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2555 }
2556 pub fn cpu_pll_div_out_source_frequency() -> u32 {
2557 pll_clk_frequency()
2558 }
2559 pub fn configure_apb_clk(clocks: &mut ClockTree, new_selector: ApbClkConfig) {
2560 let old_selector = clocks.apb_clk.replace(new_selector);
2561 refresh_apb_clk_downstream(clocks);
2562 if clocks.apb_clk_refcount > 0 {
2563 match new_selector {
2564 ApbClkConfig::Pll80m => request_pll_80m(clocks),
2565 ApbClkConfig::Cpu => request_cpu_clk(clocks),
2566 }
2567 configure_apb_clk_impl(clocks, old_selector, new_selector);
2568 if let Some(old_selector) = old_selector {
2569 match old_selector {
2570 ApbClkConfig::Pll80m => release_pll_80m(clocks),
2571 ApbClkConfig::Cpu => release_cpu_clk(clocks),
2572 }
2573 }
2574 } else {
2575 configure_apb_clk_impl(clocks, old_selector, new_selector);
2576 }
2577 }
2578 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2579 clocks.apb_clk
2580 }
2581 pub fn request_apb_clk(clocks: &mut ClockTree) {
2582 trace!("Requesting APB_CLK");
2583 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2584 trace!("Enabling APB_CLK");
2585 match unwrap!(clocks.apb_clk) {
2586 ApbClkConfig::Pll80m => request_pll_80m(clocks),
2587 ApbClkConfig::Cpu => request_cpu_clk(clocks),
2588 }
2589 enable_apb_clk_impl(clocks, true);
2590 }
2591 }
2592 pub fn release_apb_clk(clocks: &mut ClockTree) {
2593 trace!("Releasing APB_CLK");
2594 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2595 trace!("Disabling APB_CLK");
2596 enable_apb_clk_impl(clocks, false);
2597 match unwrap!(clocks.apb_clk) {
2598 ApbClkConfig::Pll80m => release_pll_80m(clocks),
2599 ApbClkConfig::Cpu => release_cpu_clk(clocks),
2600 }
2601 }
2602 }
2603 #[allow(unused_variables)]
2604 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2605 match config {
2606 ApbClkConfig::Pll80m => pll_80m_frequency(),
2607 ApbClkConfig::Cpu => cpu_clk_frequency(),
2608 }
2609 }
2610 pub fn apb_clk_frequency() -> u32 {
2611 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2612 }
2613 pub fn apb_clk_source_frequency(source: ApbClkConfig) -> u32 {
2614 match source {
2615 ApbClkConfig::Pll80m => pll_80m_frequency(),
2616 ApbClkConfig::Cpu => cpu_clk_frequency(),
2617 }
2618 }
2619 pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
2620 let old_selector = clocks.crypto_clk.replace(new_selector);
2621 refresh_crypto_clk_downstream(clocks);
2622 if clocks.crypto_clk_refcount > 0 {
2623 match new_selector {
2624 CryptoClkConfig::Pll160m => request_pll_160m(clocks),
2625 CryptoClkConfig::Cpu => request_cpu_clk(clocks),
2626 }
2627 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2628 if let Some(old_selector) = old_selector {
2629 match old_selector {
2630 CryptoClkConfig::Pll160m => release_pll_160m(clocks),
2631 CryptoClkConfig::Cpu => release_cpu_clk(clocks),
2632 }
2633 }
2634 } else {
2635 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2636 }
2637 }
2638 pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
2639 clocks.crypto_clk
2640 }
2641 pub fn request_crypto_clk(clocks: &mut ClockTree) {
2642 trace!("Requesting CRYPTO_CLK");
2643 if increment_reference_count(&mut clocks.crypto_clk_refcount) {
2644 trace!("Enabling CRYPTO_CLK");
2645 match unwrap!(clocks.crypto_clk) {
2646 CryptoClkConfig::Pll160m => request_pll_160m(clocks),
2647 CryptoClkConfig::Cpu => request_cpu_clk(clocks),
2648 }
2649 enable_crypto_clk_impl(clocks, true);
2650 }
2651 }
2652 pub fn release_crypto_clk(clocks: &mut ClockTree) {
2653 trace!("Releasing CRYPTO_CLK");
2654 if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
2655 trace!("Disabling CRYPTO_CLK");
2656 enable_crypto_clk_impl(clocks, false);
2657 match unwrap!(clocks.crypto_clk) {
2658 CryptoClkConfig::Pll160m => release_pll_160m(clocks),
2659 CryptoClkConfig::Cpu => release_cpu_clk(clocks),
2660 }
2661 }
2662 }
2663 #[allow(unused_variables)]
2664 pub fn crypto_clk_config_frequency(clocks: &mut ClockTree, config: CryptoClkConfig) -> u32 {
2665 match config {
2666 CryptoClkConfig::Pll160m => pll_160m_frequency(),
2667 CryptoClkConfig::Cpu => cpu_clk_frequency(),
2668 }
2669 }
2670 pub fn crypto_clk_frequency() -> u32 {
2671 CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2672 }
2673 pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
2674 match source {
2675 CryptoClkConfig::Pll160m => pll_160m_frequency(),
2676 CryptoClkConfig::Cpu => cpu_clk_frequency(),
2677 }
2678 }
2679 pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
2680 let old_selector = clocks.cpu_clk.replace(new_selector);
2681 refresh_cpu_clk_downstream(clocks);
2682 match new_selector {
2683 CpuClkConfig::Xtal => {
2684 configure_apb_clk(clocks, ApbClkConfig::Cpu);
2685 configure_crypto_clk(clocks, CryptoClkConfig::Cpu);
2686 configure_system_pre_div_in(clocks, SystemPreDivInConfig::Xtal);
2687 }
2688 CpuClkConfig::RcFast => {
2689 configure_apb_clk(clocks, ApbClkConfig::Cpu);
2690 configure_crypto_clk(clocks, CryptoClkConfig::Cpu);
2691 configure_system_pre_div_in(clocks, SystemPreDivInConfig::RcFast);
2692 }
2693 CpuClkConfig::Pll => {
2694 configure_apb_clk(clocks, ApbClkConfig::Pll80m);
2695 configure_crypto_clk(clocks, CryptoClkConfig::Pll160m);
2696 }
2697 }
2698 match new_selector {
2699 CpuClkConfig::Xtal => request_system_pre_div(clocks),
2700 CpuClkConfig::RcFast => request_system_pre_div(clocks),
2701 CpuClkConfig::Pll => request_cpu_pll_div_out(clocks),
2702 }
2703 configure_cpu_clk_impl(clocks, old_selector, new_selector);
2704 if let Some(old_selector) = old_selector {
2705 match old_selector {
2706 CpuClkConfig::Xtal => release_system_pre_div(clocks),
2707 CpuClkConfig::RcFast => release_system_pre_div(clocks),
2708 CpuClkConfig::Pll => release_cpu_pll_div_out(clocks),
2709 }
2710 }
2711 }
2712 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2713 clocks.cpu_clk
2714 }
2715 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2716 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2717 #[allow(unused_variables)]
2718 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2719 match config {
2720 CpuClkConfig::Xtal => system_pre_div_frequency(),
2721 CpuClkConfig::RcFast => system_pre_div_frequency(),
2722 CpuClkConfig::Pll => cpu_pll_div_out_frequency(),
2723 }
2724 }
2725 pub fn cpu_clk_frequency() -> u32 {
2726 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2727 }
2728 pub fn request_pll_80m(clocks: &mut ClockTree) {
2729 trace!("Requesting PLL_80M");
2730 if increment_reference_count(&mut clocks.pll_80m_refcount) {
2731 trace!("Enabling PLL_80M");
2732 request_cpu_clk(clocks);
2733 enable_pll_80m_impl(clocks, true);
2734 }
2735 }
2736 pub fn release_pll_80m(clocks: &mut ClockTree) {
2737 trace!("Releasing PLL_80M");
2738 if decrement_reference_count(&mut clocks.pll_80m_refcount) {
2739 trace!("Disabling PLL_80M");
2740 enable_pll_80m_impl(clocks, false);
2741 release_cpu_clk(clocks);
2742 }
2743 }
2744 pub fn pll_80m_frequency() -> u32 {
2745 80000000
2746 }
2747 pub fn pll_80m_source_frequency() -> u32 {
2748 cpu_clk_frequency()
2749 }
2750 pub fn request_pll_160m(clocks: &mut ClockTree) {
2751 trace!("Requesting PLL_160M");
2752 if increment_reference_count(&mut clocks.pll_160m_refcount) {
2753 trace!("Enabling PLL_160M");
2754 request_cpu_clk(clocks);
2755 enable_pll_160m_impl(clocks, true);
2756 }
2757 }
2758 pub fn release_pll_160m(clocks: &mut ClockTree) {
2759 trace!("Releasing PLL_160M");
2760 if decrement_reference_count(&mut clocks.pll_160m_refcount) {
2761 trace!("Disabling PLL_160M");
2762 enable_pll_160m_impl(clocks, false);
2763 release_cpu_clk(clocks);
2764 }
2765 }
2766 pub fn pll_160m_frequency() -> u32 {
2767 160000000
2768 }
2769 pub fn pll_160m_source_frequency() -> u32 {
2770 cpu_clk_frequency()
2771 }
2772 pub fn configure_rc_fast_clk_div_n(clocks: &mut ClockTree, config: RcFastClkDivNConfig) {
2773 let old_config = clocks.rc_fast_clk_div_n.replace(config);
2774 refresh_rc_fast_clk_div_n_downstream(clocks);
2775 configure_rc_fast_clk_div_n_impl(clocks, old_config, config);
2776 }
2777 pub fn rc_fast_clk_div_n_config(clocks: &mut ClockTree) -> Option<RcFastClkDivNConfig> {
2778 clocks.rc_fast_clk_div_n
2779 }
2780 pub fn request_rc_fast_clk_div_n(clocks: &mut ClockTree) {
2781 trace!("Requesting RC_FAST_CLK_DIV_N");
2782 trace!("Enabling RC_FAST_CLK_DIV_N");
2783 request_rc_fast_clk(clocks);
2784 enable_rc_fast_clk_div_n_impl(clocks, true);
2785 }
2786 pub fn release_rc_fast_clk_div_n(clocks: &mut ClockTree) {
2787 trace!("Releasing RC_FAST_CLK_DIV_N");
2788 trace!("Disabling RC_FAST_CLK_DIV_N");
2789 enable_rc_fast_clk_div_n_impl(clocks, false);
2790 release_rc_fast_clk(clocks);
2791 }
2792 #[allow(unused_variables)]
2793 pub fn rc_fast_clk_div_n_config_frequency(
2794 clocks: &mut ClockTree,
2795 config: RcFastClkDivNConfig,
2796 ) -> u32 {
2797 (rc_fast_clk_frequency() / (config.divisor() + 1))
2798 }
2799 pub fn rc_fast_clk_div_n_frequency() -> u32 {
2800 RC_FAST_CLK_DIV_N_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2801 }
2802 pub fn rc_fast_clk_div_n_source_frequency() -> u32 {
2803 rc_fast_clk_frequency()
2804 }
2805 pub fn request_xtal_div_clk(clocks: &mut ClockTree) {
2806 trace!("Requesting XTAL_DIV_CLK");
2807 trace!("Enabling XTAL_DIV_CLK");
2808 request_xtal_clk(clocks);
2809 enable_xtal_div_clk_impl(clocks, true);
2810 }
2811 pub fn release_xtal_div_clk(clocks: &mut ClockTree) {
2812 trace!("Releasing XTAL_DIV_CLK");
2813 trace!("Disabling XTAL_DIV_CLK");
2814 enable_xtal_div_clk_impl(clocks, false);
2815 release_xtal_clk(clocks);
2816 }
2817 pub fn xtal_div_clk_frequency() -> u32 {
2818 (xtal_clk_frequency() / 2)
2819 }
2820 pub fn xtal_div_clk_source_frequency() -> u32 {
2821 xtal_clk_frequency()
2822 }
2823 pub fn configure_rtc_slow_clk(clocks: &mut ClockTree, new_selector: RtcSlowClkConfig) {
2824 let old_selector = clocks.rtc_slow_clk.replace(new_selector);
2825 refresh_rtc_slow_clk_downstream(clocks);
2826 match new_selector {
2827 #[cfg(use_xtal32k)]
2828 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2829 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2830 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
2831 }
2832 configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
2833 if let Some(old_selector) = old_selector {
2834 match old_selector {
2835 #[cfg(use_xtal32k)]
2836 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2837 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2838 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
2839 }
2840 }
2841 }
2842 pub fn rtc_slow_clk_config(clocks: &mut ClockTree) -> Option<RtcSlowClkConfig> {
2843 clocks.rtc_slow_clk
2844 }
2845 pub fn request_rtc_slow_clk(clocks: &mut ClockTree) {
2846 trace!("Requesting RTC_SLOW_CLK");
2847 trace!("Enabling RTC_SLOW_CLK");
2848 match unwrap!(clocks.rtc_slow_clk) {
2849 #[cfg(use_xtal32k)]
2850 RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2851 RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2852 RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
2853 }
2854 enable_rtc_slow_clk_impl(clocks, true);
2855 }
2856 pub fn release_rtc_slow_clk(clocks: &mut ClockTree) {
2857 trace!("Releasing RTC_SLOW_CLK");
2858 trace!("Disabling RTC_SLOW_CLK");
2859 enable_rtc_slow_clk_impl(clocks, false);
2860 match unwrap!(clocks.rtc_slow_clk) {
2861 #[cfg(use_xtal32k)]
2862 RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2863 RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2864 RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
2865 }
2866 }
2867 #[allow(unused_variables)]
2868 pub fn rtc_slow_clk_config_frequency(
2869 clocks: &mut ClockTree,
2870 config: RtcSlowClkConfig,
2871 ) -> u32 {
2872 match config {
2873 #[cfg(use_xtal32k)]
2874 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2875 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2876 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
2877 }
2878 }
2879 pub fn rtc_slow_clk_frequency() -> u32 {
2880 RTC_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2881 }
2882 pub fn rtc_slow_clk_source_frequency(source: RtcSlowClkConfig) -> u32 {
2883 match source {
2884 #[cfg(use_xtal32k)]
2885 RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2886 RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2887 RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(),
2888 }
2889 }
2890 pub fn configure_rtc_fast_clk(clocks: &mut ClockTree, new_selector: RtcFastClkConfig) {
2891 let old_selector = clocks.rtc_fast_clk.replace(new_selector);
2892 refresh_rtc_fast_clk_downstream(clocks);
2893 if clocks.rtc_fast_clk_refcount > 0 {
2894 match new_selector {
2895 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
2896 RtcFastClkConfig::Rc => request_rc_fast_clk_div_n(clocks),
2897 }
2898 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
2899 if let Some(old_selector) = old_selector {
2900 match old_selector {
2901 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
2902 RtcFastClkConfig::Rc => release_rc_fast_clk_div_n(clocks),
2903 }
2904 }
2905 } else {
2906 configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
2907 }
2908 }
2909 pub fn rtc_fast_clk_config(clocks: &mut ClockTree) -> Option<RtcFastClkConfig> {
2910 clocks.rtc_fast_clk
2911 }
2912 pub fn request_rtc_fast_clk(clocks: &mut ClockTree) {
2913 trace!("Requesting RTC_FAST_CLK");
2914 if increment_reference_count(&mut clocks.rtc_fast_clk_refcount) {
2915 trace!("Enabling RTC_FAST_CLK");
2916 match unwrap!(clocks.rtc_fast_clk) {
2917 RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
2918 RtcFastClkConfig::Rc => request_rc_fast_clk_div_n(clocks),
2919 }
2920 enable_rtc_fast_clk_impl(clocks, true);
2921 }
2922 }
2923 pub fn release_rtc_fast_clk(clocks: &mut ClockTree) {
2924 trace!("Releasing RTC_FAST_CLK");
2925 if decrement_reference_count(&mut clocks.rtc_fast_clk_refcount) {
2926 trace!("Disabling RTC_FAST_CLK");
2927 enable_rtc_fast_clk_impl(clocks, false);
2928 match unwrap!(clocks.rtc_fast_clk) {
2929 RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
2930 RtcFastClkConfig::Rc => release_rc_fast_clk_div_n(clocks),
2931 }
2932 }
2933 }
2934 #[allow(unused_variables)]
2935 pub fn rtc_fast_clk_config_frequency(
2936 clocks: &mut ClockTree,
2937 config: RtcFastClkConfig,
2938 ) -> u32 {
2939 match config {
2940 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
2941 RtcFastClkConfig::Rc => rc_fast_clk_div_n_frequency(),
2942 }
2943 }
2944 pub fn rtc_fast_clk_frequency() -> u32 {
2945 RTC_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2946 }
2947 pub fn rtc_fast_clk_source_frequency(source: RtcFastClkConfig) -> u32 {
2948 match source {
2949 RtcFastClkConfig::Xtal => xtal_div_clk_frequency(),
2950 RtcFastClkConfig::Rc => rc_fast_clk_div_n_frequency(),
2951 }
2952 }
2953 pub fn configure_low_power_clk(clocks: &mut ClockTree, new_selector: LowPowerClkConfig) {
2954 let old_selector = clocks.low_power_clk.replace(new_selector);
2955 refresh_low_power_clk_downstream(clocks);
2956 if clocks.low_power_clk_refcount > 0 {
2957 match new_selector {
2958 LowPowerClkConfig::Xtal => request_xtal_clk(clocks),
2959 LowPowerClkConfig::RcFast => request_rc_fast_clk(clocks),
2960 #[cfg(use_xtal32k)]
2961 LowPowerClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2962 LowPowerClkConfig::RtcSlow => request_rtc_slow_clk(clocks),
2963 }
2964 configure_low_power_clk_impl(clocks, old_selector, new_selector);
2965 if let Some(old_selector) = old_selector {
2966 match old_selector {
2967 LowPowerClkConfig::Xtal => release_xtal_clk(clocks),
2968 LowPowerClkConfig::RcFast => release_rc_fast_clk(clocks),
2969 #[cfg(use_xtal32k)]
2970 LowPowerClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2971 LowPowerClkConfig::RtcSlow => release_rtc_slow_clk(clocks),
2972 }
2973 }
2974 } else {
2975 configure_low_power_clk_impl(clocks, old_selector, new_selector);
2976 }
2977 }
2978 pub fn low_power_clk_config(clocks: &mut ClockTree) -> Option<LowPowerClkConfig> {
2979 clocks.low_power_clk
2980 }
2981 pub fn request_low_power_clk(clocks: &mut ClockTree) {
2982 trace!("Requesting LOW_POWER_CLK");
2983 if increment_reference_count(&mut clocks.low_power_clk_refcount) {
2984 trace!("Enabling LOW_POWER_CLK");
2985 match unwrap!(clocks.low_power_clk) {
2986 LowPowerClkConfig::Xtal => request_xtal_clk(clocks),
2987 LowPowerClkConfig::RcFast => request_rc_fast_clk(clocks),
2988 #[cfg(use_xtal32k)]
2989 LowPowerClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2990 LowPowerClkConfig::RtcSlow => request_rtc_slow_clk(clocks),
2991 }
2992 enable_low_power_clk_impl(clocks, true);
2993 }
2994 }
2995 pub fn release_low_power_clk(clocks: &mut ClockTree) {
2996 trace!("Releasing LOW_POWER_CLK");
2997 if decrement_reference_count(&mut clocks.low_power_clk_refcount) {
2998 trace!("Disabling LOW_POWER_CLK");
2999 enable_low_power_clk_impl(clocks, false);
3000 match unwrap!(clocks.low_power_clk) {
3001 LowPowerClkConfig::Xtal => release_xtal_clk(clocks),
3002 LowPowerClkConfig::RcFast => release_rc_fast_clk(clocks),
3003 #[cfg(use_xtal32k)]
3004 LowPowerClkConfig::Xtal32k => release_xtal32k_clk(clocks),
3005 LowPowerClkConfig::RtcSlow => release_rtc_slow_clk(clocks),
3006 }
3007 }
3008 }
3009 #[allow(unused_variables)]
3010 pub fn low_power_clk_config_frequency(
3011 clocks: &mut ClockTree,
3012 config: LowPowerClkConfig,
3013 ) -> u32 {
3014 match config {
3015 LowPowerClkConfig::Xtal => xtal_clk_frequency(),
3016 LowPowerClkConfig::RcFast => rc_fast_clk_frequency(),
3017 #[cfg(use_xtal32k)]
3018 LowPowerClkConfig::Xtal32k => xtal32k_clk_frequency(),
3019 LowPowerClkConfig::RtcSlow => rtc_slow_clk_frequency(),
3020 }
3021 }
3022 pub fn low_power_clk_frequency() -> u32 {
3023 LOW_POWER_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3024 }
3025 pub fn low_power_clk_source_frequency(source: LowPowerClkConfig) -> u32 {
3026 match source {
3027 LowPowerClkConfig::Xtal => xtal_clk_frequency(),
3028 LowPowerClkConfig::RcFast => rc_fast_clk_frequency(),
3029 #[cfg(use_xtal32k)]
3030 LowPowerClkConfig::Xtal32k => xtal32k_clk_frequency(),
3031 LowPowerClkConfig::RtcSlow => rtc_slow_clk_frequency(),
3032 }
3033 }
3034 pub fn request_uart_mem_clk(clocks: &mut ClockTree) {
3035 trace!("Requesting UART_MEM_CLK");
3036 if increment_reference_count(&mut clocks.uart_mem_clk_refcount) {
3037 trace!("Enabling UART_MEM_CLK");
3038 request_xtal_clk(clocks);
3039 enable_uart_mem_clk_impl(clocks, true);
3040 }
3041 }
3042 pub fn release_uart_mem_clk(clocks: &mut ClockTree) {
3043 trace!("Releasing UART_MEM_CLK");
3044 if decrement_reference_count(&mut clocks.uart_mem_clk_refcount) {
3045 trace!("Disabling UART_MEM_CLK");
3046 enable_uart_mem_clk_impl(clocks, false);
3047 release_xtal_clk(clocks);
3048 }
3049 }
3050 pub fn uart_mem_clk_frequency() -> u32 {
3051 xtal_clk_frequency()
3052 }
3053 pub fn uart_mem_clk_source_frequency(source: UartMemClkConfig) -> u32 {
3054 match source {
3055 UartMemClkConfig::Xtal => xtal_clk_frequency(),
3056 }
3057 }
3058 pub fn configure_timg_calibration_clock(
3059 clocks: &mut ClockTree,
3060 new_selector: TimgCalibrationClockConfig,
3061 ) {
3062 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3063 refresh_timg_calibration_clock_downstream(clocks);
3064 if clocks.timg_calibration_clock_refcount > 0 {
3065 match new_selector {
3066 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3067 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
3068 #[cfg(use_xtal32k)]
3069 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3070 }
3071 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3072 if let Some(old_selector) = old_selector {
3073 match old_selector {
3074 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3075 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
3076 #[cfg(use_xtal32k)]
3077 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3078 }
3079 }
3080 } else {
3081 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3082 }
3083 }
3084 pub fn timg_calibration_clock_config(
3085 clocks: &mut ClockTree,
3086 ) -> Option<TimgCalibrationClockConfig> {
3087 clocks.timg_calibration_clock
3088 }
3089 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3090 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3091 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3092 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3093 crate::rtc_cntl::WakeLock::acquire();
3094 match unwrap!(clocks.timg_calibration_clock) {
3095 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3096 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
3097 #[cfg(use_xtal32k)]
3098 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3099 }
3100 enable_timg_calibration_clock_impl(clocks, true);
3101 }
3102 }
3103 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3104 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3105 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3106 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3107 crate::rtc_cntl::WakeLock::release();
3108 enable_timg_calibration_clock_impl(clocks, false);
3109 match unwrap!(clocks.timg_calibration_clock) {
3110 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3111 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
3112 #[cfg(use_xtal32k)]
3113 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3114 }
3115 }
3116 }
3117 #[allow(unused_variables)]
3118 pub fn timg_calibration_clock_config_frequency(
3119 clocks: &mut ClockTree,
3120 config: TimgCalibrationClockConfig,
3121 ) -> u32 {
3122 match config {
3123 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3124 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
3125 #[cfg(use_xtal32k)]
3126 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3127 }
3128 }
3129 pub fn timg_calibration_clock_frequency() -> u32 {
3130 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3131 }
3132 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3133 match source {
3134 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3135 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(),
3136 #[cfg(use_xtal32k)]
3137 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3138 }
3139 }
3140 impl SdmInstance {
3141 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3142 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3143 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3144 {
3145 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3146 request_apb_clk(clocks);
3147 self.enable_function_clock_impl(clocks, true);
3148 }
3149 }
3150 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3151 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3152 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3153 {
3154 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3155 self.enable_function_clock_impl(clocks, false);
3156 release_apb_clk(clocks);
3157 }
3158 }
3159 pub fn function_clock_frequency(self) -> u32 {
3160 apb_clk_frequency()
3161 }
3162 pub fn function_clock_source_frequency() -> u32 {
3163 apb_clk_frequency()
3164 }
3165 }
3166 impl I2cInstance {
3167 pub fn configure_function_clock(
3168 self,
3169 clocks: &mut ClockTree,
3170 config: I2cFunctionClockConfig,
3171 ) {
3172 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3173 refresh_i2c_function_clock_downstream(clocks, self);
3174 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
3175 match config.sclk {
3176 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3177 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3178 }
3179 self.configure_function_clock_impl(clocks, old_config, config);
3180 if let Some(old_config) = old_config {
3181 match old_config.sclk {
3182 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3183 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3184 }
3185 }
3186 } else {
3187 self.configure_function_clock_impl(clocks, old_config, config);
3188 }
3189 }
3190 pub fn function_clock_config(
3191 self,
3192 clocks: &mut ClockTree,
3193 ) -> Option<I2cFunctionClockConfig> {
3194 clocks.i2c_function_clock[self as usize]
3195 }
3196 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3197 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3198 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3199 {
3200 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3201 crate::rtc_cntl::WakeLock::acquire();
3202 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3203 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3204 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3205 }
3206 self.enable_function_clock_impl(clocks, true);
3207 }
3208 }
3209 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3210 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3211 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3212 {
3213 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3214 crate::rtc_cntl::WakeLock::release();
3215 self.enable_function_clock_impl(clocks, false);
3216 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3217 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3218 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3219 }
3220 }
3221 }
3222 #[allow(unused_variables)]
3223 pub fn function_clock_config_frequency(
3224 clocks: &mut ClockTree,
3225 config: I2cFunctionClockConfig,
3226 ) -> u32 {
3227 (match config.sclk {
3228 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3229 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3230 } / (config.div_num() + 1))
3231 }
3232 pub fn function_clock_frequency(self) -> u32 {
3233 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3234 .load(::core::sync::atomic::Ordering::Acquire)
3235 }
3236 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3237 match sclk {
3238 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3239 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3240 }
3241 }
3242 }
3243 impl I2sInstance {
3244 pub fn configure_tx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
3245 let old_config = clocks.i2s_tx_clk[self as usize].replace(config);
3246 refresh_i2s_tx_clk_downstream(clocks, self);
3247 if clocks.i2s_tx_clk_refcount[self as usize] > 0 {
3248 match config.sclk {
3249 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3250 I2sClkSclk::Pll160m => request_pll_160m(clocks),
3251 }
3252 self.configure_tx_clk_impl(clocks, old_config, config);
3253 if let Some(old_config) = old_config {
3254 match old_config.sclk {
3255 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3256 I2sClkSclk::Pll160m => release_pll_160m(clocks),
3257 }
3258 }
3259 } else {
3260 self.configure_tx_clk_impl(clocks, old_config, config);
3261 }
3262 }
3263 pub fn tx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
3264 clocks.i2s_tx_clk[self as usize]
3265 }
3266 pub fn request_tx_clk(self, clocks: &mut ClockTree) {
3267 trace!("Requesting {:?}::TX_CLK", self);
3268 if increment_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
3269 trace!("Enabling {:?}::TX_CLK", self);
3270 crate::rtc_cntl::WakeLock::acquire();
3271 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
3272 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3273 I2sClkSclk::Pll160m => request_pll_160m(clocks),
3274 }
3275 self.enable_tx_clk_impl(clocks, true);
3276 }
3277 }
3278 pub fn release_tx_clk(self, clocks: &mut ClockTree) {
3279 trace!("Releasing {:?}::TX_CLK", self);
3280 if decrement_reference_count(&mut clocks.i2s_tx_clk_refcount[self as usize]) {
3281 trace!("Disabling {:?}::TX_CLK", self);
3282 crate::rtc_cntl::WakeLock::release();
3283 self.enable_tx_clk_impl(clocks, false);
3284 match unwrap!(clocks.i2s_tx_clk[self as usize]).sclk {
3285 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3286 I2sClkSclk::Pll160m => release_pll_160m(clocks),
3287 }
3288 }
3289 }
3290 #[allow(unused_variables)]
3291 pub fn tx_clk_config_frequency(clocks: &mut ClockTree, config: I2sClkConfig) -> u32 {
3292 (((match config.sclk {
3293 I2sClkSclk::Xtal => xtal_clk_frequency(),
3294 I2sClkSclk::Pll160m => pll_160m_frequency(),
3295 } as u64)
3296 * (config.div_a() as u64))
3297 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3298 as u32
3299 }
3300 pub fn tx_clk_frequency(self) -> u32 {
3301 I2S_TX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3302 }
3303 pub fn tx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
3304 match sclk {
3305 I2sClkSclk::Xtal => xtal_clk_frequency(),
3306 I2sClkSclk::Pll160m => pll_160m_frequency(),
3307 }
3308 }
3309 pub fn configure_rx_clk(self, clocks: &mut ClockTree, config: I2sClkConfig) {
3310 let old_config = clocks.i2s_rx_clk[self as usize].replace(config);
3311 refresh_i2s_rx_clk_downstream(clocks, self);
3312 if clocks.i2s_rx_clk_refcount[self as usize] > 0 {
3313 match config.sclk {
3314 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3315 I2sClkSclk::Pll160m => request_pll_160m(clocks),
3316 }
3317 self.configure_rx_clk_impl(clocks, old_config, config);
3318 if let Some(old_config) = old_config {
3319 match old_config.sclk {
3320 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3321 I2sClkSclk::Pll160m => release_pll_160m(clocks),
3322 }
3323 }
3324 } else {
3325 self.configure_rx_clk_impl(clocks, old_config, config);
3326 }
3327 }
3328 pub fn rx_clk_config(self, clocks: &mut ClockTree) -> Option<I2sClkConfig> {
3329 clocks.i2s_rx_clk[self as usize]
3330 }
3331 pub fn request_rx_clk(self, clocks: &mut ClockTree) {
3332 trace!("Requesting {:?}::RX_CLK", self);
3333 if increment_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
3334 trace!("Enabling {:?}::RX_CLK", self);
3335 crate::rtc_cntl::WakeLock::acquire();
3336 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
3337 I2sClkSclk::Xtal => request_xtal_clk(clocks),
3338 I2sClkSclk::Pll160m => request_pll_160m(clocks),
3339 }
3340 self.enable_rx_clk_impl(clocks, true);
3341 }
3342 }
3343 pub fn release_rx_clk(self, clocks: &mut ClockTree) {
3344 trace!("Releasing {:?}::RX_CLK", self);
3345 if decrement_reference_count(&mut clocks.i2s_rx_clk_refcount[self as usize]) {
3346 trace!("Disabling {:?}::RX_CLK", self);
3347 crate::rtc_cntl::WakeLock::release();
3348 self.enable_rx_clk_impl(clocks, false);
3349 match unwrap!(clocks.i2s_rx_clk[self as usize]).sclk {
3350 I2sClkSclk::Xtal => release_xtal_clk(clocks),
3351 I2sClkSclk::Pll160m => release_pll_160m(clocks),
3352 }
3353 }
3354 }
3355 #[allow(unused_variables)]
3356 pub fn rx_clk_config_frequency(clocks: &mut ClockTree, config: I2sClkConfig) -> u32 {
3357 (((match config.sclk {
3358 I2sClkSclk::Xtal => xtal_clk_frequency(),
3359 I2sClkSclk::Pll160m => pll_160m_frequency(),
3360 } as u64)
3361 * (config.div_a() as u64))
3362 / (((config.div_num() * config.div_a()) + config.div_b()) as u64))
3363 as u32
3364 }
3365 pub fn rx_clk_frequency(self) -> u32 {
3366 I2S_RX_CLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3367 }
3368 pub fn rx_clk_source_frequency(sclk: I2sClkSclk) -> u32 {
3369 match sclk {
3370 I2sClkSclk::Xtal => xtal_clk_frequency(),
3371 I2sClkSclk::Pll160m => pll_160m_frequency(),
3372 }
3373 }
3374 pub fn configure_mclk_out(
3375 self,
3376 clocks: &mut ClockTree,
3377 new_selector: I2sMclkOutConfig,
3378 ) {
3379 let old_selector = clocks.i2s_mclk_out[self as usize].replace(new_selector);
3380 refresh_i2s_mclk_out_downstream(clocks, self);
3381 if clocks.i2s_mclk_out_refcount[self as usize] > 0 {
3382 match new_selector {
3383 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
3384 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3385 }
3386 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
3387 if let Some(old_selector) = old_selector {
3388 match old_selector {
3389 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3390 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3391 }
3392 }
3393 } else {
3394 self.configure_mclk_out_impl(clocks, old_selector, new_selector);
3395 }
3396 }
3397 pub fn mclk_out_config(self, clocks: &mut ClockTree) -> Option<I2sMclkOutConfig> {
3398 clocks.i2s_mclk_out[self as usize]
3399 }
3400 pub fn request_mclk_out(self, clocks: &mut ClockTree) {
3401 trace!("Requesting {:?}::MCLK_OUT", self);
3402 if increment_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3403 trace!("Enabling {:?}::MCLK_OUT", self);
3404 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3405 I2sMclkOutConfig::Tx => self.request_tx_clk(clocks),
3406 I2sMclkOutConfig::Rx => self.request_rx_clk(clocks),
3407 }
3408 self.enable_mclk_out_impl(clocks, true);
3409 }
3410 }
3411 pub fn release_mclk_out(self, clocks: &mut ClockTree) {
3412 trace!("Releasing {:?}::MCLK_OUT", self);
3413 if decrement_reference_count(&mut clocks.i2s_mclk_out_refcount[self as usize]) {
3414 trace!("Disabling {:?}::MCLK_OUT", self);
3415 self.enable_mclk_out_impl(clocks, false);
3416 match unwrap!(clocks.i2s_mclk_out[self as usize]) {
3417 I2sMclkOutConfig::Tx => self.release_tx_clk(clocks),
3418 I2sMclkOutConfig::Rx => self.release_rx_clk(clocks),
3419 }
3420 }
3421 }
3422 #[allow(unused_variables)]
3423 pub fn mclk_out_config_frequency(
3424 self,
3425 clocks: &mut ClockTree,
3426 config: I2sMclkOutConfig,
3427 ) -> u32 {
3428 match config {
3429 I2sMclkOutConfig::Tx => self.tx_clk_frequency(),
3430 I2sMclkOutConfig::Rx => self.rx_clk_frequency(),
3431 }
3432 }
3433 pub fn mclk_out_frequency(self) -> u32 {
3434 I2S_MCLK_OUT_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3435 }
3436 }
3437 impl RmtInstance {
3438 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3439 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3440 refresh_rmt_sclk_downstream(clocks, self);
3441 if clocks.rmt_sclk_refcount[self as usize] > 0 {
3442 match new_selector {
3443 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3444 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3445 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3446 }
3447 self.configure_sclk_impl(clocks, old_selector, new_selector);
3448 if let Some(old_selector) = old_selector {
3449 match old_selector {
3450 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3451 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3452 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3453 }
3454 }
3455 } else {
3456 self.configure_sclk_impl(clocks, old_selector, new_selector);
3457 }
3458 }
3459 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3460 clocks.rmt_sclk[self as usize]
3461 }
3462 pub fn request_sclk(self, clocks: &mut ClockTree) {
3463 trace!("Requesting {:?}::SCLK", self);
3464 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3465 trace!("Enabling {:?}::SCLK", self);
3466 crate::rtc_cntl::WakeLock::acquire();
3467 match unwrap!(clocks.rmt_sclk[self as usize]) {
3468 RmtSclkConfig::ApbClk => request_apb_clk(clocks),
3469 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3470 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3471 }
3472 self.enable_sclk_impl(clocks, true);
3473 }
3474 }
3475 pub fn release_sclk(self, clocks: &mut ClockTree) {
3476 trace!("Releasing {:?}::SCLK", self);
3477 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3478 trace!("Disabling {:?}::SCLK", self);
3479 crate::rtc_cntl::WakeLock::release();
3480 self.enable_sclk_impl(clocks, false);
3481 match unwrap!(clocks.rmt_sclk[self as usize]) {
3482 RmtSclkConfig::ApbClk => release_apb_clk(clocks),
3483 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3484 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3485 }
3486 }
3487 }
3488 #[allow(unused_variables)]
3489 pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
3490 match config {
3491 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3492 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3493 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3494 }
3495 }
3496 pub fn sclk_frequency(self) -> u32 {
3497 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3498 }
3499 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3500 match source {
3501 RmtSclkConfig::ApbClk => apb_clk_frequency(),
3502 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3503 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3504 }
3505 }
3506 }
3507 impl SpiInstance {
3508 pub fn configure_function_clock(
3509 self,
3510 clocks: &mut ClockTree,
3511 new_selector: SpiFunctionClockConfig,
3512 ) {
3513 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3514 refresh_spi_function_clock_downstream(clocks, self);
3515 if clocks.spi_function_clock_refcount[self as usize] > 0 {
3516 match new_selector {
3517 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3518 SpiFunctionClockConfig::Pll80m => request_pll_80m(clocks),
3519 }
3520 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3521 if let Some(old_selector) = old_selector {
3522 match old_selector {
3523 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3524 SpiFunctionClockConfig::Pll80m => release_pll_80m(clocks),
3525 }
3526 }
3527 } else {
3528 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3529 }
3530 }
3531 pub fn function_clock_config(
3532 self,
3533 clocks: &mut ClockTree,
3534 ) -> Option<SpiFunctionClockConfig> {
3535 clocks.spi_function_clock[self as usize]
3536 }
3537 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3538 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3539 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3540 {
3541 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3542 crate::rtc_cntl::WakeLock::acquire();
3543 match unwrap!(clocks.spi_function_clock[self as usize]) {
3544 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3545 SpiFunctionClockConfig::Pll80m => request_pll_80m(clocks),
3546 }
3547 self.enable_function_clock_impl(clocks, true);
3548 }
3549 }
3550 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3551 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3552 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3553 {
3554 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3555 crate::rtc_cntl::WakeLock::release();
3556 self.enable_function_clock_impl(clocks, false);
3557 match unwrap!(clocks.spi_function_clock[self as usize]) {
3558 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3559 SpiFunctionClockConfig::Pll80m => release_pll_80m(clocks),
3560 }
3561 }
3562 }
3563 #[allow(unused_variables)]
3564 pub fn function_clock_config_frequency(
3565 clocks: &mut ClockTree,
3566 config: SpiFunctionClockConfig,
3567 ) -> u32 {
3568 match config {
3569 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3570 SpiFunctionClockConfig::Pll80m => pll_80m_frequency(),
3571 }
3572 }
3573 pub fn function_clock_frequency(self) -> u32 {
3574 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3575 .load(::core::sync::atomic::Ordering::Acquire)
3576 }
3577 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3578 match source {
3579 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3580 SpiFunctionClockConfig::Pll80m => pll_80m_frequency(),
3581 }
3582 }
3583 }
3584 impl TimgInstance {
3585 pub fn configure_function_clock(
3586 self,
3587 clocks: &mut ClockTree,
3588 new_selector: TimgFunctionClockConfig,
3589 ) {
3590 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3591 refresh_timg_function_clock_downstream(clocks, self);
3592 if clocks.timg_function_clock_refcount[self as usize] > 0 {
3593 match new_selector {
3594 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3595 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3596 }
3597 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3598 if let Some(old_selector) = old_selector {
3599 match old_selector {
3600 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3601 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3602 }
3603 }
3604 } else {
3605 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3606 }
3607 }
3608 pub fn function_clock_config(
3609 self,
3610 clocks: &mut ClockTree,
3611 ) -> Option<TimgFunctionClockConfig> {
3612 clocks.timg_function_clock[self as usize]
3613 }
3614 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3615 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3616 if increment_reference_count(
3617 &mut clocks.timg_function_clock_refcount[self as usize],
3618 ) {
3619 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3620 match unwrap!(clocks.timg_function_clock[self as usize]) {
3621 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3622 TimgFunctionClockConfig::ApbClk => request_apb_clk(clocks),
3623 }
3624 self.enable_function_clock_impl(clocks, true);
3625 }
3626 }
3627 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3628 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3629 if decrement_reference_count(
3630 &mut clocks.timg_function_clock_refcount[self as usize],
3631 ) {
3632 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3633 self.enable_function_clock_impl(clocks, false);
3634 match unwrap!(clocks.timg_function_clock[self as usize]) {
3635 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3636 TimgFunctionClockConfig::ApbClk => release_apb_clk(clocks),
3637 }
3638 }
3639 }
3640 #[allow(unused_variables)]
3641 pub fn function_clock_config_frequency(
3642 clocks: &mut ClockTree,
3643 config: TimgFunctionClockConfig,
3644 ) -> u32 {
3645 match config {
3646 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3647 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3648 }
3649 }
3650 pub fn function_clock_frequency(self) -> u32 {
3651 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3652 .load(::core::sync::atomic::Ordering::Acquire)
3653 }
3654 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3655 match source {
3656 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3657 TimgFunctionClockConfig::ApbClk => apb_clk_frequency(),
3658 }
3659 }
3660 pub fn configure_wdt_clock(
3661 self,
3662 clocks: &mut ClockTree,
3663 new_selector: TimgWdtClockConfig,
3664 ) {
3665 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3666 refresh_timg_wdt_clock_downstream(clocks, self);
3667 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
3668 match new_selector {
3669 TimgWdtClockConfig::ApbClk => request_apb_clk(clocks),
3670 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3671 }
3672 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3673 if let Some(old_selector) = old_selector {
3674 match old_selector {
3675 TimgWdtClockConfig::ApbClk => release_apb_clk(clocks),
3676 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3677 }
3678 }
3679 } else {
3680 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3681 }
3682 }
3683 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3684 clocks.timg_wdt_clock[self as usize]
3685 }
3686 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3687 trace!("Requesting {:?}::WDT_CLOCK", self);
3688 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3689 trace!("Enabling {:?}::WDT_CLOCK", self);
3690 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3691 TimgWdtClockConfig::ApbClk => request_apb_clk(clocks),
3692 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3693 }
3694 self.enable_wdt_clock_impl(clocks, true);
3695 }
3696 }
3697 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3698 trace!("Releasing {:?}::WDT_CLOCK", self);
3699 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3700 trace!("Disabling {:?}::WDT_CLOCK", self);
3701 self.enable_wdt_clock_impl(clocks, false);
3702 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3703 TimgWdtClockConfig::ApbClk => release_apb_clk(clocks),
3704 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3705 }
3706 }
3707 }
3708 #[allow(unused_variables)]
3709 pub fn wdt_clock_config_frequency(
3710 clocks: &mut ClockTree,
3711 config: TimgWdtClockConfig,
3712 ) -> u32 {
3713 match config {
3714 TimgWdtClockConfig::ApbClk => apb_clk_frequency(),
3715 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3716 }
3717 }
3718 pub fn wdt_clock_frequency(self) -> u32 {
3719 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3720 .load(::core::sync::atomic::Ordering::Acquire)
3721 }
3722 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3723 match source {
3724 TimgWdtClockConfig::ApbClk => apb_clk_frequency(),
3725 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3726 }
3727 }
3728 }
3729 impl UartInstance {
3730 pub fn configure_function_clock(
3731 self,
3732 clocks: &mut ClockTree,
3733 config: UartFunctionClockConfig,
3734 ) {
3735 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3736 refresh_uart_function_clock_downstream(clocks, self);
3737 if clocks.uart_function_clock_refcount[self as usize] > 0 {
3738 match config.sclk {
3739 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3740 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3741 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3742 }
3743 self.configure_function_clock_impl(clocks, old_config, config);
3744 if let Some(old_config) = old_config {
3745 match old_config.sclk {
3746 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3747 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3748 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3749 }
3750 }
3751 } else {
3752 self.configure_function_clock_impl(clocks, old_config, config);
3753 }
3754 }
3755 pub fn function_clock_config(
3756 self,
3757 clocks: &mut ClockTree,
3758 ) -> Option<UartFunctionClockConfig> {
3759 clocks.uart_function_clock[self as usize]
3760 }
3761 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3762 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3763 if increment_reference_count(
3764 &mut clocks.uart_function_clock_refcount[self as usize],
3765 ) {
3766 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3767 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3768 UartFunctionClockSclk::Apb => request_apb_clk(clocks),
3769 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3770 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3771 }
3772 self.enable_function_clock_impl(clocks, true);
3773 }
3774 }
3775 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3776 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3777 if decrement_reference_count(
3778 &mut clocks.uart_function_clock_refcount[self as usize],
3779 ) {
3780 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3781 self.enable_function_clock_impl(clocks, false);
3782 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3783 UartFunctionClockSclk::Apb => release_apb_clk(clocks),
3784 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3785 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3786 }
3787 }
3788 }
3789 #[allow(unused_variables)]
3790 pub fn function_clock_config_frequency(
3791 clocks: &mut ClockTree,
3792 config: UartFunctionClockConfig,
3793 ) -> u32 {
3794 (match config.sclk {
3795 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3796 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3797 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3798 } / (config.div_num() + 1))
3799 }
3800 pub fn function_clock_frequency(self) -> u32 {
3801 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3802 .load(::core::sync::atomic::Ordering::Acquire)
3803 }
3804 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3805 match sclk {
3806 UartFunctionClockSclk::Apb => apb_clk_frequency(),
3807 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3808 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3809 }
3810 }
3811 pub fn request_mem_clock(self, clocks: &mut ClockTree) {
3812 trace!("Requesting {:?}::MEM_CLOCK", self);
3813 if increment_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3814 trace!("Enabling {:?}::MEM_CLOCK", self);
3815 request_uart_mem_clk(clocks);
3816 self.enable_mem_clock_impl(clocks, true);
3817 }
3818 }
3819 pub fn release_mem_clock(self, clocks: &mut ClockTree) {
3820 trace!("Releasing {:?}::MEM_CLOCK", self);
3821 if decrement_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
3822 trace!("Disabling {:?}::MEM_CLOCK", self);
3823 self.enable_mem_clock_impl(clocks, false);
3824 release_uart_mem_clk(clocks);
3825 }
3826 }
3827 pub fn mem_clock_frequency(self) -> u32 {
3828 uart_mem_clk_frequency()
3829 }
3830 pub fn mem_clock_source_frequency() -> u32 {
3831 uart_mem_clk_frequency()
3832 }
3833 pub fn configure_baud_rate_generator(
3834 self,
3835 clocks: &mut ClockTree,
3836 config: UartBaudRateGeneratorConfig,
3837 ) {
3838 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3839 refresh_uart_baud_rate_generator_downstream(clocks, self);
3840 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3841 }
3842 pub fn baud_rate_generator_config(
3843 self,
3844 clocks: &mut ClockTree,
3845 ) -> Option<UartBaudRateGeneratorConfig> {
3846 clocks.uart_baud_rate_generator[self as usize]
3847 }
3848 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3849 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3850 if increment_reference_count(
3851 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3852 ) {
3853 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3854 self.request_function_clock(clocks);
3855 self.enable_baud_rate_generator_impl(clocks, true);
3856 }
3857 }
3858 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3859 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3860 if decrement_reference_count(
3861 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3862 ) {
3863 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3864 self.enable_baud_rate_generator_impl(clocks, false);
3865 self.release_function_clock(clocks);
3866 }
3867 }
3868 #[allow(unused_variables)]
3869 pub fn baud_rate_generator_config_frequency(
3870 self,
3871 clocks: &mut ClockTree,
3872 config: UartBaudRateGeneratorConfig,
3873 ) -> u32 {
3874 ((self.function_clock_frequency() * 16)
3875 / ((config.integral() * 16) + config.fractional()))
3876 }
3877 pub fn baud_rate_generator_frequency(self) -> u32 {
3878 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3879 .load(::core::sync::atomic::Ordering::Acquire)
3880 }
3881 }
3882 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3890 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3891 #[instability::unstable]
3892 pub struct ClockConfig {
3893 pub xtal_clk: Option<XtalClkConfig>,
3895 pub pll_clk: Option<PllClkConfig>,
3897 pub system_pre_div: Option<SystemPreDivConfig>,
3899 pub cpu_pll_div_out: Option<CpuPllDivOutConfig>,
3901 pub cpu_clk: Option<CpuClkConfig>,
3903 pub rc_fast_clk_div_n: Option<RcFastClkDivNConfig>,
3905 pub rtc_slow_clk: Option<RtcSlowClkConfig>,
3907 pub rtc_fast_clk: Option<RtcFastClkConfig>,
3909 pub low_power_clk: Option<LowPowerClkConfig>,
3911 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3913 }
3914 impl ClockConfig {
3915 fn apply(&self, clocks: &mut ClockTree) {
3916 if let Some(config) = self.xtal_clk {
3917 configure_xtal_clk(clocks, config);
3918 }
3919 if let Some(config) = self.pll_clk {
3920 configure_pll_clk(clocks, config);
3921 }
3922 if let Some(config) = self.system_pre_div {
3923 configure_system_pre_div(clocks, config);
3924 }
3925 if let Some(config) = self.cpu_pll_div_out {
3926 configure_cpu_pll_div_out(clocks, config);
3927 }
3928 if let Some(config) = self.cpu_clk {
3929 configure_cpu_clk(clocks, config);
3930 }
3931 if let Some(config) = self.rc_fast_clk_div_n {
3932 configure_rc_fast_clk_div_n(clocks, config);
3933 }
3934 if let Some(config) = self.rtc_slow_clk {
3935 configure_rtc_slow_clk(clocks, config);
3936 }
3937 if let Some(config) = self.rtc_fast_clk {
3938 configure_rtc_fast_clk(clocks, config);
3939 }
3940 if let Some(config) = self.low_power_clk {
3941 configure_low_power_clk(clocks, config);
3942 }
3943 if let Some(config) = self.timg_calibration_clock {
3944 configure_timg_calibration_clock(clocks, config);
3945 }
3946 }
3947 }
3948 fn increment_reference_count(refcount: &mut u32) -> bool {
3949 let first = *refcount == 0;
3950 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3951 first
3952 }
3953 fn decrement_reference_count(refcount: &mut u32) -> bool {
3954 *refcount = refcount.saturating_sub(1);
3955 let last = *refcount == 0;
3956 last
3957 }
3958 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3959 if let Some(config) = clocks.xtal_clk {
3960 XTAL_CLK_FREQ_CACHE.store(
3961 xtal_clk_config_frequency(clocks, config),
3962 ::core::sync::atomic::Ordering::Release,
3963 );
3964 }
3965 refresh_pll_clk_downstream(clocks);
3966 refresh_system_pre_div_in_downstream(clocks);
3967 refresh_rtc_fast_clk_downstream(clocks);
3968 refresh_low_power_clk_downstream(clocks);
3969 for child_instance in [I2cInstance::I2c0] {
3970 refresh_i2c_function_clock_downstream(clocks, child_instance);
3971 }
3972 for child_instance in [I2sInstance::I2s0] {
3973 refresh_i2s_tx_clk_downstream(clocks, child_instance);
3974 refresh_i2s_rx_clk_downstream(clocks, child_instance);
3975 }
3976 for child_instance in [SpiInstance::Spi2] {
3977 refresh_spi_function_clock_downstream(clocks, child_instance);
3978 }
3979 for child_instance in [RmtInstance::Rmt] {
3980 refresh_rmt_sclk_downstream(clocks, child_instance);
3981 }
3982 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3983 refresh_timg_function_clock_downstream(clocks, child_instance);
3984 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3985 }
3986 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3987 refresh_uart_function_clock_downstream(clocks, child_instance);
3988 }
3989 }
3990 fn refresh_pll_clk_downstream(clocks: &mut ClockTree) {
3991 if let Some(config) = clocks.pll_clk {
3992 PLL_CLK_FREQ_CACHE.store(
3993 pll_clk_config_frequency(clocks, config),
3994 ::core::sync::atomic::Ordering::Release,
3995 );
3996 }
3997 refresh_cpu_pll_div_out_downstream(clocks);
3998 }
3999 fn refresh_system_pre_div_in_downstream(clocks: &mut ClockTree) {
4000 if let Some(config) = clocks.system_pre_div_in {
4001 SYSTEM_PRE_DIV_IN_FREQ_CACHE.store(
4002 system_pre_div_in_config_frequency(clocks, config),
4003 ::core::sync::atomic::Ordering::Release,
4004 );
4005 }
4006 refresh_system_pre_div_downstream(clocks);
4007 }
4008 fn refresh_system_pre_div_downstream(clocks: &mut ClockTree) {
4009 if let Some(config) = clocks.system_pre_div {
4010 SYSTEM_PRE_DIV_FREQ_CACHE.store(
4011 system_pre_div_config_frequency(clocks, config),
4012 ::core::sync::atomic::Ordering::Release,
4013 );
4014 }
4015 refresh_cpu_clk_downstream(clocks);
4016 }
4017 fn refresh_cpu_pll_div_out_downstream(clocks: &mut ClockTree) {
4018 if let Some(config) = clocks.cpu_pll_div_out {
4019 CPU_PLL_DIV_OUT_FREQ_CACHE.store(
4020 cpu_pll_div_out_config_frequency(clocks, config),
4021 ::core::sync::atomic::Ordering::Release,
4022 );
4023 }
4024 refresh_cpu_clk_downstream(clocks);
4025 }
4026 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
4027 if let Some(config) = clocks.cpu_clk {
4028 CPU_CLK_FREQ_CACHE.store(
4029 cpu_clk_config_frequency(clocks, config),
4030 ::core::sync::atomic::Ordering::Release,
4031 );
4032 }
4033 refresh_apb_clk_downstream(clocks);
4034 refresh_crypto_clk_downstream(clocks);
4035 for child_instance in [I2sInstance::I2s0] {
4036 refresh_i2s_tx_clk_downstream(clocks, child_instance);
4037 refresh_i2s_rx_clk_downstream(clocks, child_instance);
4038 }
4039 for child_instance in [SpiInstance::Spi2] {
4040 refresh_spi_function_clock_downstream(clocks, child_instance);
4041 }
4042 }
4043 fn refresh_rc_fast_clk_div_n_downstream(clocks: &mut ClockTree) {
4044 if let Some(config) = clocks.rc_fast_clk_div_n {
4045 RC_FAST_CLK_DIV_N_FREQ_CACHE.store(
4046 rc_fast_clk_div_n_config_frequency(clocks, config),
4047 ::core::sync::atomic::Ordering::Release,
4048 );
4049 }
4050 refresh_rtc_fast_clk_downstream(clocks);
4051 }
4052 fn refresh_rtc_slow_clk_downstream(clocks: &mut ClockTree) {
4053 if let Some(config) = clocks.rtc_slow_clk {
4054 RTC_SLOW_CLK_FREQ_CACHE.store(
4055 rtc_slow_clk_config_frequency(clocks, config),
4056 ::core::sync::atomic::Ordering::Release,
4057 );
4058 }
4059 refresh_low_power_clk_downstream(clocks);
4060 }
4061 fn refresh_rtc_fast_clk_downstream(clocks: &mut ClockTree) {
4062 if let Some(config) = clocks.rtc_fast_clk {
4063 RTC_FAST_CLK_FREQ_CACHE.store(
4064 rtc_fast_clk_config_frequency(clocks, config),
4065 ::core::sync::atomic::Ordering::Release,
4066 );
4067 }
4068 }
4069 fn refresh_low_power_clk_downstream(clocks: &mut ClockTree) {
4070 if let Some(config) = clocks.low_power_clk {
4071 LOW_POWER_CLK_FREQ_CACHE.store(
4072 low_power_clk_config_frequency(clocks, config),
4073 ::core::sync::atomic::Ordering::Release,
4074 );
4075 }
4076 }
4077 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
4078 if let Some(config) = clocks.timg_calibration_clock {
4079 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
4080 timg_calibration_clock_config_frequency(clocks, config),
4081 ::core::sync::atomic::Ordering::Release,
4082 );
4083 }
4084 }
4085 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
4086 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
4087 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4088 I2cInstance::function_clock_config_frequency(clocks, config),
4089 ::core::sync::atomic::Ordering::Release,
4090 );
4091 }
4092 }
4093 fn refresh_i2s_tx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
4094 if let Some(config) = clocks.i2s_tx_clk[instance as usize] {
4095 I2S_TX_CLK_FREQ_CACHE[instance as usize].store(
4096 I2sInstance::tx_clk_config_frequency(clocks, config),
4097 ::core::sync::atomic::Ordering::Release,
4098 );
4099 }
4100 refresh_i2s_mclk_out_downstream(clocks, instance);
4101 }
4102 fn refresh_i2s_rx_clk_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
4103 if let Some(config) = clocks.i2s_rx_clk[instance as usize] {
4104 I2S_RX_CLK_FREQ_CACHE[instance as usize].store(
4105 I2sInstance::rx_clk_config_frequency(clocks, config),
4106 ::core::sync::atomic::Ordering::Release,
4107 );
4108 }
4109 refresh_i2s_mclk_out_downstream(clocks, instance);
4110 }
4111 fn refresh_i2s_mclk_out_downstream(clocks: &mut ClockTree, instance: I2sInstance) {
4112 if let Some(config) = clocks.i2s_mclk_out[instance as usize] {
4113 I2S_MCLK_OUT_FREQ_CACHE[instance as usize].store(
4114 instance.mclk_out_config_frequency(clocks, config),
4115 ::core::sync::atomic::Ordering::Release,
4116 );
4117 }
4118 }
4119 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
4120 if let Some(config) = clocks.spi_function_clock[instance as usize] {
4121 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4122 SpiInstance::function_clock_config_frequency(clocks, config),
4123 ::core::sync::atomic::Ordering::Release,
4124 );
4125 }
4126 }
4127 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
4128 if let Some(config) = clocks.apb_clk {
4129 APB_CLK_FREQ_CACHE.store(
4130 apb_clk_config_frequency(clocks, config),
4131 ::core::sync::atomic::Ordering::Release,
4132 );
4133 }
4134 for child_instance in [RmtInstance::Rmt] {
4135 refresh_rmt_sclk_downstream(clocks, child_instance);
4136 }
4137 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
4138 refresh_timg_function_clock_downstream(clocks, child_instance);
4139 refresh_timg_wdt_clock_downstream(clocks, child_instance);
4140 }
4141 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
4142 refresh_uart_function_clock_downstream(clocks, child_instance);
4143 }
4144 }
4145 fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
4146 if let Some(config) = clocks.crypto_clk {
4147 CRYPTO_CLK_FREQ_CACHE.store(
4148 crypto_clk_config_frequency(clocks, config),
4149 ::core::sync::atomic::Ordering::Release,
4150 );
4151 }
4152 }
4153 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
4154 if let Some(config) = clocks.rmt_sclk[instance as usize] {
4155 RMT_SCLK_FREQ_CACHE[instance as usize].store(
4156 RmtInstance::sclk_config_frequency(clocks, config),
4157 ::core::sync::atomic::Ordering::Release,
4158 );
4159 }
4160 }
4161 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4162 if let Some(config) = clocks.timg_function_clock[instance as usize] {
4163 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4164 TimgInstance::function_clock_config_frequency(clocks, config),
4165 ::core::sync::atomic::Ordering::Release,
4166 );
4167 }
4168 }
4169 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4170 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
4171 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
4172 TimgInstance::wdt_clock_config_frequency(clocks, config),
4173 ::core::sync::atomic::Ordering::Release,
4174 );
4175 }
4176 }
4177 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4178 if let Some(config) = clocks.uart_function_clock[instance as usize] {
4179 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4180 UartInstance::function_clock_config_frequency(clocks, config),
4181 ::core::sync::atomic::Ordering::Release,
4182 );
4183 }
4184 refresh_uart_baud_rate_generator_downstream(clocks, instance);
4185 }
4186 fn refresh_uart_baud_rate_generator_downstream(
4187 clocks: &mut ClockTree,
4188 instance: UartInstance,
4189 ) {
4190 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4191 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4192 instance.baud_rate_generator_config_frequency(clocks, config),
4193 ::core::sync::atomic::Ordering::Release,
4194 );
4195 }
4196 }
4197 };
4198}
4199#[macro_export]
4203#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4204macro_rules! implement_peripheral_clocks {
4205 () => {
4206 #[doc(hidden)]
4207 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4208 #[repr(u8)]
4209 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4210 pub enum Peripheral {
4211 Aes,
4213 AhbGdma,
4215 ApbSarAdc,
4217 Ds,
4219 GpioSd,
4221 Hmac,
4223 I2cExt0,
4225 I2s0,
4227 Ledc,
4229 Rmt,
4231 Rsa,
4233 Sha,
4235 Spi2,
4237 Systimer,
4239 Timg0,
4241 Timg1,
4243 Tsens,
4245 Twai0,
4247 Uart0,
4249 Uart1,
4251 UartMem,
4253 Uhci0,
4255 UsbDevice,
4257 }
4258 impl Peripheral {
4259 const KEEP_ENABLED: &[Peripheral] = &[
4260 Self::Systimer,
4261 Self::Timg0,
4262 Self::Uart0,
4263 Self::UartMem,
4264 Self::UsbDevice,
4265 ];
4266 const COUNT: usize = Self::ALL.len();
4267 const ALL: &[Self] = &[
4268 Self::Aes,
4269 Self::AhbGdma,
4270 Self::ApbSarAdc,
4271 Self::Ds,
4272 Self::GpioSd,
4273 Self::Hmac,
4274 Self::I2cExt0,
4275 Self::I2s0,
4276 Self::Ledc,
4277 Self::Rmt,
4278 Self::Rsa,
4279 Self::Sha,
4280 Self::Spi2,
4281 Self::Systimer,
4282 Self::Timg0,
4283 Self::Timg1,
4284 Self::Tsens,
4285 Self::Twai0,
4286 Self::Uart0,
4287 Self::Uart1,
4288 Self::UartMem,
4289 Self::Uhci0,
4290 Self::UsbDevice,
4291 ];
4292 }
4293 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4294 match peripheral {
4295 Peripheral::Aes => {
4296 crate::peripherals::SYSTEM::regs()
4297 .perip_clk_en1()
4298 .modify(|_, w| w.crypto_aes_clk_en().bit(enable));
4299 }
4300 Peripheral::AhbGdma => {
4301 crate::peripherals::SYSTEM::regs()
4302 .perip_clk_en1()
4303 .modify(|_, w| w.dma_clk_en().bit(enable));
4304 }
4305 Peripheral::ApbSarAdc => {
4306 crate::peripherals::SYSTEM::regs()
4307 .perip_clk_en0()
4308 .modify(|_, w| w.apb_saradc_clk_en().bit(enable));
4309 }
4310 Peripheral::Ds => {
4311 crate::peripherals::SYSTEM::regs()
4312 .perip_clk_en1()
4313 .modify(|_, w| w.crypto_ds_clk_en().bit(enable));
4314 }
4315 Peripheral::GpioSd => {
4316 crate::peripherals::GPIO_SD::regs()
4317 .clock_gate()
4318 .modify(|_, w| w.clk_en().bit(enable));
4319 }
4320 Peripheral::Hmac => {
4321 crate::peripherals::SYSTEM::regs()
4322 .perip_clk_en1()
4323 .modify(|_, w| w.crypto_hmac_clk_en().bit(enable));
4324 }
4325 Peripheral::I2cExt0 => {
4326 crate::peripherals::SYSTEM::regs()
4327 .perip_clk_en0()
4328 .modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
4329 }
4330 Peripheral::I2s0 => {
4331 crate::peripherals::SYSTEM::regs()
4332 .perip_clk_en0()
4333 .modify(|_, w| w.i2s0_clk_en().bit(enable));
4334 }
4335 Peripheral::Ledc => {
4336 crate::peripherals::SYSTEM::regs()
4337 .perip_clk_en0()
4338 .modify(|_, w| w.ledc_clk_en().bit(enable));
4339 }
4340 Peripheral::Rmt => {
4341 crate::peripherals::SYSTEM::regs()
4342 .perip_clk_en0()
4343 .modify(|_, w| w.rmt_clk_en().bit(enable));
4344 }
4345 Peripheral::Rsa => {
4346 crate::peripherals::SYSTEM::regs()
4347 .perip_clk_en1()
4348 .modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
4349 }
4350 Peripheral::Sha => {
4351 crate::peripherals::SYSTEM::regs()
4352 .perip_clk_en1()
4353 .modify(|_, w| w.crypto_sha_clk_en().bit(enable));
4354 }
4355 Peripheral::Spi2 => {
4356 crate::peripherals::SYSTEM::regs()
4357 .perip_clk_en0()
4358 .modify(|_, w| w.spi2_clk_en().bit(enable));
4359 }
4360 Peripheral::Systimer => {
4361 crate::peripherals::SYSTEM::regs()
4362 .perip_clk_en0()
4363 .modify(|_, w| w.systimer_clk_en().bit(enable));
4364 }
4365 Peripheral::Timg0 => {
4366 crate::peripherals::SYSTEM::regs()
4367 .perip_clk_en0()
4368 .modify(|_, w| w.timergroup_clk_en().bit(enable));
4369 }
4370 Peripheral::Timg1 => {
4371 crate::peripherals::SYSTEM::regs()
4372 .perip_clk_en0()
4373 .modify(|_, w| w.timergroup1_clk_en().bit(enable));
4374 }
4375 Peripheral::Tsens => {
4376 crate::peripherals::SYSTEM::regs()
4377 .perip_clk_en1()
4378 .modify(|_, w| w.tsens_clk_en().bit(enable));
4379 }
4380 Peripheral::Twai0 => {
4381 crate::peripherals::SYSTEM::regs()
4382 .perip_clk_en0()
4383 .modify(|_, w| w.twai_clk_en().bit(enable));
4384 }
4385 Peripheral::Uart0 => {
4386 crate::peripherals::SYSTEM::regs()
4387 .perip_clk_en0()
4388 .modify(|_, w| w.uart_clk_en().bit(enable));
4389 }
4390 Peripheral::Uart1 => {
4391 crate::peripherals::SYSTEM::regs()
4392 .perip_clk_en0()
4393 .modify(|_, w| w.uart1_clk_en().bit(enable));
4394 }
4395 Peripheral::UartMem => {
4396 crate::peripherals::SYSTEM::regs()
4397 .perip_clk_en0()
4398 .modify(|_, w| w.uart_mem_clk_en().bit(enable));
4399 }
4400 Peripheral::Uhci0 => {
4401 crate::peripherals::SYSTEM::regs()
4402 .perip_clk_en0()
4403 .modify(|_, w| w.uhci0_clk_en().bit(enable));
4404 }
4405 Peripheral::UsbDevice => {
4406 crate::peripherals::SYSTEM::regs()
4407 .perip_clk_en0()
4408 .modify(|_, w| w.usb_device_clk_en().bit(enable));
4409 }
4410 }
4411 }
4412 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4413 match peripheral {
4414 Peripheral::Aes => {
4415 crate::peripherals::SYSTEM::regs()
4416 .perip_rst_en1()
4417 .modify(|_, w| w.crypto_aes_rst().bit(reset));
4418 }
4419 Peripheral::AhbGdma => {
4420 crate::peripherals::SYSTEM::regs()
4421 .perip_rst_en1()
4422 .modify(|_, w| w.dma_rst().bit(reset));
4423 }
4424 Peripheral::ApbSarAdc => {
4425 crate::peripherals::SYSTEM::regs()
4426 .perip_rst_en0()
4427 .modify(|_, w| w.apb_saradc_rst().bit(reset));
4428 }
4429 Peripheral::Ds => {
4430 crate::peripherals::SYSTEM::regs()
4431 .perip_rst_en1()
4432 .modify(|_, w| w.crypto_ds_rst().bit(reset));
4433 }
4434 Peripheral::GpioSd => {
4435 let _ = reset;
4436 }
4437 Peripheral::Hmac => {
4438 crate::peripherals::SYSTEM::regs()
4439 .perip_rst_en1()
4440 .modify(|_, w| w.crypto_hmac_rst().bit(reset));
4441 }
4442 Peripheral::I2cExt0 => {
4443 crate::peripherals::SYSTEM::regs()
4444 .perip_rst_en0()
4445 .modify(|_, w| w.i2c_ext0_rst().bit(reset));
4446 }
4447 Peripheral::I2s0 => {
4448 crate::peripherals::SYSTEM::regs()
4449 .perip_rst_en0()
4450 .modify(|_, w| w.i2s0_rst().bit(reset));
4451 }
4452 Peripheral::Ledc => {
4453 crate::peripherals::SYSTEM::regs()
4454 .perip_rst_en0()
4455 .modify(|_, w| w.ledc_rst().bit(reset));
4456 }
4457 Peripheral::Rmt => {
4458 crate::peripherals::SYSTEM::regs()
4459 .perip_rst_en0()
4460 .modify(|_, w| w.rmt_rst().bit(reset));
4461 }
4462 Peripheral::Rsa => {
4463 crate::peripherals::SYSTEM::regs()
4464 .perip_rst_en1()
4465 .modify(|_, w| w.crypto_rsa_rst().bit(reset));
4466 }
4467 Peripheral::Sha => {
4468 crate::peripherals::SYSTEM::regs()
4469 .perip_rst_en1()
4470 .modify(|_, w| w.crypto_sha_rst().bit(reset));
4471 }
4472 Peripheral::Spi2 => {
4473 crate::peripherals::SYSTEM::regs()
4474 .perip_rst_en0()
4475 .modify(|_, w| w.spi2_rst().bit(reset));
4476 }
4477 Peripheral::Systimer => {
4478 crate::peripherals::SYSTEM::regs()
4479 .perip_rst_en0()
4480 .modify(|_, w| w.systimer_rst().bit(reset));
4481 }
4482 Peripheral::Timg0 => {
4483 crate::peripherals::SYSTEM::regs()
4484 .perip_rst_en0()
4485 .modify(|_, w| w.timergroup_rst().bit(reset));
4486 }
4487 Peripheral::Timg1 => {
4488 crate::peripherals::SYSTEM::regs()
4489 .perip_rst_en0()
4490 .modify(|_, w| w.timergroup1_rst().bit(reset));
4491 }
4492 Peripheral::Tsens => {
4493 crate::peripherals::SYSTEM::regs()
4494 .perip_rst_en1()
4495 .modify(|_, w| w.tsens_rst().bit(reset));
4496 }
4497 Peripheral::Twai0 => {
4498 crate::peripherals::SYSTEM::regs()
4499 .perip_rst_en0()
4500 .modify(|_, w| w.twai_rst().bit(reset));
4501 }
4502 Peripheral::Uart0 => {
4503 crate::peripherals::SYSTEM::regs()
4504 .perip_rst_en0()
4505 .modify(|_, w| w.uart_rst().bit(reset));
4506 }
4507 Peripheral::Uart1 => {
4508 crate::peripherals::SYSTEM::regs()
4509 .perip_rst_en0()
4510 .modify(|_, w| w.uart1_rst().bit(reset));
4511 }
4512 Peripheral::UartMem => {
4513 crate::peripherals::SYSTEM::regs()
4514 .perip_rst_en0()
4515 .modify(|_, w| w.uart_mem_rst().bit(reset));
4516 }
4517 Peripheral::Uhci0 => {
4518 crate::peripherals::SYSTEM::regs()
4519 .perip_rst_en0()
4520 .modify(|_, w| w.uhci0_rst().bit(reset));
4521 }
4522 Peripheral::UsbDevice => {
4523 crate::peripherals::SYSTEM::regs()
4524 .perip_rst_en0()
4525 .modify(|_, w| w.usb_device_rst().bit(reset));
4526 }
4527 }
4528 }
4529 };
4530}
4531#[macro_export]
4539#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4540macro_rules! memory_range {
4541 ("DRAM") => {
4542 0x3FC80000..0x3FCE0000
4543 };
4544 (size as str, "DRAM") => {
4545 "393216"
4546 };
4547 ("DRAM2_UNINIT") => {
4548 0x3FCCE400..0x3FCDE710
4549 };
4550 (size as str, "DRAM2_UNINIT") => {
4551 "66320"
4552 };
4553 ("IROM") => {
4554 0x42000000..0x42800000
4555 };
4556 (size as str, "IROM") => {
4557 "8388608"
4558 };
4559 ("DROM") => {
4560 0x3C000000..0x3C800000
4561 };
4562 (size as str, "DROM") => {
4563 "8388608"
4564 };
4565}
4566#[macro_export]
4583#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4584macro_rules! for_each_i2c_master {
4585 ($($pattern:tt => $code:tt;)*) => {
4586 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4587 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4588 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4589 I2CEXT0_SDA)));
4590 };
4591}
4592#[macro_export]
4619#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4620macro_rules! for_each_i2s {
4621 ($($pattern:tt => $code:tt;)*) => {
4622 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4623 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
4624 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
4625 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
4626 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
4627 true, true, false)));
4628 };
4629}
4630#[macro_export]
4649#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4650macro_rules! for_each_uart {
4651 ($($pattern:tt => $code:tt;)*) => {
4652 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4653 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4654 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4655 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4656 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4657 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4658 };
4659}
4660#[macro_export]
4682#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4683macro_rules! for_each_spi_master {
4684 ($($pattern:tt => $code:tt;)*) => {
4685 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4686 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
4687 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
4688 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
4689 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4690 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
4691 };
4692}
4693#[macro_export]
4710#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4711macro_rules! for_each_spi_slave {
4712 ($($pattern:tt => $code:tt;)*) => {
4713 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4714 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
4715 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4716 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
4717 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
4718 };
4719}
4720#[macro_export]
4721#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4722macro_rules! for_each_peripheral {
4723 ($($pattern:tt => $code:tt;)*) => {
4724 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4725 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4726 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
4727 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4728 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4729 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4730 "<section class=\"warning\">"] #[doc =
4731 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4732 #[doc = "<ul>"] #[doc =
4733 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4734 = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
4735 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO3 peripheral singleton"]
4736 GPIO3 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4737 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4738 "<section class=\"warning\">"] #[doc =
4739 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4740 #[doc = "<ul>"] #[doc =
4741 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4742 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
4743 _for_each_inner_peripheral!((@ peri_type #[doc =
4744 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4745 "<section class=\"warning\">"] #[doc =
4746 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4747 #[doc = "<ul>"] #[doc =
4748 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4749 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4750 _for_each_inner_peripheral!((@ peri_type #[doc =
4751 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4752 "<section class=\"warning\">"] #[doc =
4753 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4754 #[doc = "<ul>"] #[doc =
4755 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4756 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4757 _for_each_inner_peripheral!((@ peri_type #[doc =
4758 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4759 "<section class=\"warning\">"] #[doc =
4760 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4761 #[doc = "<ul>"] #[doc =
4762 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4763 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4764 _for_each_inner_peripheral!((@ peri_type #[doc =
4765 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4766 "<section class=\"warning\">"] #[doc =
4767 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4768 #[doc = "<ul>"] #[doc =
4769 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4770 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4771 _for_each_inner_peripheral!((@ peri_type #[doc =
4772 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4773 "<section class=\"warning\">"] #[doc =
4774 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4775 #[doc = "<ul>"] #[doc =
4776 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4777 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4778 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
4779 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4780 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4781 "<section class=\"warning\">"] #[doc =
4782 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4783 #[doc = "<ul>"] #[doc =
4784 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4785 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4786 _for_each_inner_peripheral!((@ peri_type #[doc =
4787 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4788 "<section class=\"warning\">"] #[doc =
4789 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4790 #[doc = "<ul>"] #[doc =
4791 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4792 "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
4793 _for_each_inner_peripheral!((@ peri_type #[doc =
4794 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4795 "<section class=\"warning\">"] #[doc =
4796 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4797 #[doc = "<ul>"] #[doc =
4798 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4799 "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()));
4800 _for_each_inner_peripheral!((@ peri_type #[doc =
4801 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4802 "<section class=\"warning\">"] #[doc =
4803 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4804 #[doc = "<ul>"] #[doc =
4805 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4806 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
4807 _for_each_inner_peripheral!((@ peri_type #[doc =
4808 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4809 "<section class=\"warning\">"] #[doc =
4810 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4811 #[doc = "<ul>"] #[doc =
4812 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4813 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
4814 _for_each_inner_peripheral!((@ peri_type #[doc =
4815 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4816 "<section class=\"warning\">"] #[doc =
4817 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4818 #[doc = "<ul>"] #[doc =
4819 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4820 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
4821 _for_each_inner_peripheral!((@ peri_type #[doc =
4822 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4823 "<section class=\"warning\">"] #[doc =
4824 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4825 #[doc = "<ul>"] #[doc =
4826 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4827 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
4828 _for_each_inner_peripheral!((@ peri_type #[doc =
4829 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4830 "<section class=\"warning\">"] #[doc =
4831 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4832 #[doc = "<ul>"] #[doc =
4833 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4834 #[doc = "</section>"] GPIO18 <= virtual())); _for_each_inner_peripheral!((@
4835 peri_type #[doc = "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""]
4836 #[doc = "<section class=\"warning\">"] #[doc =
4837 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4838 #[doc = "<ul>"] #[doc =
4839 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4840 #[doc = "</section>"] GPIO19 <= virtual())); _for_each_inner_peripheral!((@
4841 peri_type #[doc = "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""]
4842 #[doc = "<section class=\"warning\">"] #[doc =
4843 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4844 #[doc = "<ul>"] #[doc =
4845 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4846 = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
4847 _for_each_inner_peripheral!((@ peri_type #[doc =
4848 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4849 "<section class=\"warning\">"] #[doc =
4850 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4851 #[doc = "<ul>"] #[doc =
4852 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4853 = "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
4854 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
4855 DMA_CH0 <= virtual(DMA_CH0 : { bind_dma_interrupt, enable_dma_interrupt,
4856 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4857 #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_CH1 : {
4858 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)));
4859 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH2 peripheral singleton"]
4860 DMA_CH2 <= virtual(DMA_CH2 : { bind_dma_interrupt, enable_dma_interrupt,
4861 disable_dma_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4862 #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual() (unstable)));
4863 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH1 peripheral singleton"]
4864 SDM_CH1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4865 = "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual() (unstable)));
4866 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH3 peripheral singleton"]
4867 SDM_CH3 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4868 = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
4869 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4870 _for_each_inner_peripheral!((@ peri_type #[doc = "APB_CTRL peripheral singleton"]
4871 APB_CTRL <= APB_CTRL() (unstable))); _for_each_inner_peripheral!((@ peri_type
4872 #[doc = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC()
4873 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4874 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
4875 _for_each_inner_peripheral!((@ peri_type #[doc = "BB peripheral singleton"] BB <=
4876 BB() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4877 "DMA peripheral singleton"] DMA <= DMA() (unstable)));
4878 _for_each_inner_peripheral!((@ peri_type #[doc = "DS peripheral singleton"] DS <=
4879 DS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4880 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
4881 _for_each_inner_peripheral!((@ peri_type #[doc = "EXTMEM peripheral singleton"]
4882 EXTMEM <= EXTMEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4883 "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)));
4884 _for_each_inner_peripheral!((@ peri_type #[doc = "FE peripheral singleton"] FE <=
4885 FE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4886 "FE2 peripheral singleton"] FE2 <= FE2() (unstable)));
4887 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
4888 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4889 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
4890 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
4891 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4892 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4893 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4894 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4895 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4896 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
4897 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4898 _for_each_inner_peripheral!((@ peri_type #[doc =
4899 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4900 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4901 "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)));
4902 _for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
4903 LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4904 "NRX peripheral singleton"] NRX <= NRX() (unstable)));
4905 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
4906 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4907 "RNG peripheral singleton"] RNG <= RNG() (unstable)));
4908 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
4909 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4910 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4911 "LPWR peripheral singleton"] LPWR <= RTC_CNTL() (unstable)));
4912 _for_each_inner_peripheral!((@ peri_type #[doc =
4913 "RTC_TIMER peripheral singleton"] RTC_TIMER <= RTC_CNTL() (unstable)));
4914 _for_each_inner_peripheral!((@ peri_type #[doc =
4915 "SENSITIVE peripheral singleton"] SENSITIVE <= SENSITIVE() (unstable)));
4916 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
4917 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4918 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4919 "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
4920 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
4921 SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4922 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
4923 enable_peri_interrupt, disable_peri_interrupt })));
4924 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
4925 SYSTEM <= SYSTEM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4926 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
4927 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
4928 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4929 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
4930 _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
4931 TWAI0 <= TWAI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4932 "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
4933 enable_peri_interrupt, disable_peri_interrupt })));
4934 _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
4935 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
4936 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4937 "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
4938 _for_each_inner_peripheral!((@ peri_type #[doc =
4939 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4940 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4941 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4942 "XTS_AES peripheral singleton"] XTS_AES <= XTS_AES() (unstable)));
4943 _for_each_inner_peripheral!((@ peri_type #[doc = "ADC1 peripheral singleton"]
4944 ADC1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4945 "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)));
4946 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4947 virtual(BT_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt },
4948 RWBLE : { bind_rwble_interrupt, enable_rwble_interrupt, disable_rwble_interrupt
4949 }, RWBT : { bind_rwbt_interrupt, enable_rwbt_interrupt, disable_rwbt_interrupt })
4950 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4951 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
4952 _for_each_inner_peripheral!((@ peri_type #[doc =
4953 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4954 _for_each_inner_peripheral!((@ peri_type #[doc = "TSENS peripheral singleton"]
4955 TSENS <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4956 "WIFI peripheral singleton"] WIFI <= virtual(WIFI_MAC : { bind_mac_interrupt,
4957 enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
4958 enable_pwr_interrupt, disable_pwr_interrupt }))); _for_each_inner_peripheral!((@
4959 peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
4960 virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4961 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4962 _for_each_inner_peripheral!((@ peri_type #[doc =
4963 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4964 _for_each_inner_peripheral!((@ peri_type #[doc =
4965 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4966 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
4967 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4968 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4969 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4970 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4971 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4972 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4973 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
4974 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
4975 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
4976 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
4977 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4978 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4979 _for_each_inner_peripheral!((DMA_CH2(unstable)));
4980 _for_each_inner_peripheral!((SDM_CH0(unstable)));
4981 _for_each_inner_peripheral!((SDM_CH1(unstable)));
4982 _for_each_inner_peripheral!((SDM_CH2(unstable)));
4983 _for_each_inner_peripheral!((SDM_CH3(unstable)));
4984 _for_each_inner_peripheral!((AES(unstable)));
4985 _for_each_inner_peripheral!((APB_CTRL(unstable)));
4986 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4987 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
4988 _for_each_inner_peripheral!((BB(unstable)));
4989 _for_each_inner_peripheral!((DMA(unstable)));
4990 _for_each_inner_peripheral!((DS(unstable)));
4991 _for_each_inner_peripheral!((EXTMEM(unstable)));
4992 _for_each_inner_peripheral!((FE(unstable)));
4993 _for_each_inner_peripheral!((FE2(unstable)));
4994 _for_each_inner_peripheral!((GPIO(unstable)));
4995 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4996 _for_each_inner_peripheral!((HMAC(unstable)));
4997 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4998 _for_each_inner_peripheral!((I2C0));
4999 _for_each_inner_peripheral!((I2S0(unstable)));
5000 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
5001 _for_each_inner_peripheral!((IO_MUX(unstable)));
5002 _for_each_inner_peripheral!((LEDC(unstable)));
5003 _for_each_inner_peripheral!((NRX(unstable)));
5004 _for_each_inner_peripheral!((RMT(unstable)));
5005 _for_each_inner_peripheral!((RNG(unstable)));
5006 _for_each_inner_peripheral!((RSA(unstable)));
5007 _for_each_inner_peripheral!((LPWR(unstable)));
5008 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
5009 _for_each_inner_peripheral!((SENSITIVE(unstable)));
5010 _for_each_inner_peripheral!((SHA(unstable)));
5011 _for_each_inner_peripheral!((SPI0(unstable)));
5012 _for_each_inner_peripheral!((SPI1(unstable)));
5013 _for_each_inner_peripheral!((SPI2));
5014 _for_each_inner_peripheral!((SYSTEM(unstable)));
5015 _for_each_inner_peripheral!((SYSTIMER(unstable)));
5016 _for_each_inner_peripheral!((TIMG0(unstable)));
5017 _for_each_inner_peripheral!((TIMG1(unstable)));
5018 _for_each_inner_peripheral!((TWAI0(unstable)));
5019 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
5020 _for_each_inner_peripheral!((UHCI0(unstable)));
5021 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
5022 _for_each_inner_peripheral!((XTS_AES(unstable)));
5023 _for_each_inner_peripheral!((ADC1(unstable)));
5024 _for_each_inner_peripheral!((ADC2(unstable)));
5025 _for_each_inner_peripheral!((BT(unstable)));
5026 _for_each_inner_peripheral!((FLASH(unstable)));
5027 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
5028 _for_each_inner_peripheral!((TSENS(unstable)));
5029 _for_each_inner_peripheral!((WIFI));
5030 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
5031 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
5032 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
5033 _for_each_inner_peripheral!((SPI2, Spi2, 0, AhbGdmaChannel));
5034 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
5035 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
5036 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
5037 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
5038 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
5039 _for_each_inner_peripheral!((all(@ peri_type #[doc =
5040 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
5041 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
5042 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5043 "<section class=\"warning\">"] #[doc =
5044 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5045 #[doc = "<ul>"] #[doc =
5046 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5047 = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
5048 "GPIO3 peripheral singleton"] GPIO3 <= virtual()), (@ peri_type #[doc =
5049 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5050 "<section class=\"warning\">"] #[doc =
5051 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5052 #[doc = "<ul>"] #[doc =
5053 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5054 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
5055 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5056 "<section class=\"warning\">"] #[doc =
5057 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5058 #[doc = "<ul>"] #[doc =
5059 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5060 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
5061 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5062 "<section class=\"warning\">"] #[doc =
5063 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5064 #[doc = "<ul>"] #[doc =
5065 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5066 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
5067 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5068 "<section class=\"warning\">"] #[doc =
5069 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5070 #[doc = "<ul>"] #[doc =
5071 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5072 #[doc = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
5073 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5074 "<section class=\"warning\">"] #[doc =
5075 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5076 #[doc = "<ul>"] #[doc =
5077 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5078 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
5079 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5080 "<section class=\"warning\">"] #[doc =
5081 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5082 #[doc = "<ul>"] #[doc =
5083 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5084 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
5085 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
5086 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5087 "<section class=\"warning\">"] #[doc =
5088 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5089 #[doc = "<ul>"] #[doc =
5090 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5091 "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
5092 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5093 "<section class=\"warning\">"] #[doc =
5094 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5095 #[doc = "<ul>"] #[doc =
5096 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5097 "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
5098 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5099 "<section class=\"warning\">"] #[doc =
5100 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5101 #[doc = "<ul>"] #[doc =
5102 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5103 "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
5104 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5105 "<section class=\"warning\">"] #[doc =
5106 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5107 #[doc = "<ul>"] #[doc =
5108 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5109 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
5110 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5111 "<section class=\"warning\">"] #[doc =
5112 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5113 #[doc = "<ul>"] #[doc =
5114 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5115 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
5116 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5117 "<section class=\"warning\">"] #[doc =
5118 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5119 #[doc = "<ul>"] #[doc =
5120 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5121 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
5122 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5123 "<section class=\"warning\">"] #[doc =
5124 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5125 #[doc = "<ul>"] #[doc =
5126 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5127 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
5128 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5129 "<section class=\"warning\">"] #[doc =
5130 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5131 #[doc = "<ul>"] #[doc =
5132 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5133 #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
5134 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5135 "<section class=\"warning\">"] #[doc =
5136 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5137 #[doc = "<ul>"] #[doc =
5138 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5139 #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
5140 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5141 "<section class=\"warning\">"] #[doc =
5142 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5143 #[doc = "<ul>"] #[doc =
5144 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5145 = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
5146 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5147 "<section class=\"warning\">"] #[doc =
5148 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5149 #[doc = "<ul>"] #[doc =
5150 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5151 = "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
5152 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_CH0 : {
5153 bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5154 (@ peri_type #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_CH1 :
5155 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5156 (@ peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_CH2 :
5157 { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }) (unstable)),
5158 (@ peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
5159 (unstable)), (@ peri_type #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <=
5160 virtual() (unstable)), (@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
5161 SDM_CH2 <= virtual() (unstable)), (@ peri_type #[doc =
5162 "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)), (@ peri_type
5163 #[doc = "AES peripheral singleton"] AES <= AES(AES : { bind_peri_interrupt,
5164 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5165 = "APB_CTRL peripheral singleton"] APB_CTRL <= APB_CTRL() (unstable)), (@
5166 peri_type #[doc = "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC()
5167 (unstable)), (@ peri_type #[doc = "ASSIST_DEBUG peripheral singleton"]
5168 ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)), (@ peri_type #[doc =
5169 "BB peripheral singleton"] BB <= BB() (unstable)), (@ peri_type #[doc =
5170 "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@ peri_type #[doc =
5171 "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type #[doc =
5172 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc =
5173 "EXTMEM peripheral singleton"] EXTMEM <= EXTMEM() (unstable)), (@ peri_type #[doc
5174 = "MMU_TABLE peripheral singleton"] MMU_TABLE <= MMU_TABLE() (unstable)), (@
5175 peri_type #[doc = "FE peripheral singleton"] FE <= FE() (unstable)), (@ peri_type
5176 #[doc = "FE2 peripheral singleton"] FE2 <= FE2() (unstable)), (@ peri_type #[doc
5177 = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
5178 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)), (@ peri_type
5179 #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)), (@ peri_type
5180 #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST()
5181 (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0 <=
5182 I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
5183 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
5184 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
5185 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5186 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
5187 (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX <=
5188 IO_MUX() (unstable)), (@ peri_type #[doc = "LEDC peripheral singleton"] LEDC <=
5189 LEDC() (unstable)), (@ peri_type #[doc = "NRX peripheral singleton"] NRX <= NRX()
5190 (unstable)), (@ peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT()
5191 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG()
5192 (unstable)), (@ peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
5193 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5194 (unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= RTC_CNTL()
5195 (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
5196 RTC_CNTL() (unstable)), (@ peri_type #[doc = "SENSITIVE peripheral singleton"]
5197 SENSITIVE <= SENSITIVE() (unstable)), (@ peri_type #[doc =
5198 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
5199 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
5200 = "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
5201 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
5202 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
5203 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
5204 "SYSTEM peripheral singleton"] SYSTEM <= SYSTEM() (unstable)), (@ peri_type #[doc
5205 = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@
5206 peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@
5207 peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@
5208 peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@
5209 peri_type #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
5210 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5211 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
5212 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5213 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
5214 peri_type #[doc = "USB_DEVICE peripheral singleton"] USB_DEVICE <=
5215 USB_DEVICE(USB_DEVICE : { bind_peri_interrupt, enable_peri_interrupt,
5216 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5217 "XTS_AES peripheral singleton"] XTS_AES <= XTS_AES() (unstable)), (@ peri_type
5218 #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type
5219 #[doc = "ADC2 peripheral singleton"] ADC2 <= virtual() (unstable)), (@ peri_type
5220 #[doc = "BT peripheral singleton"] BT <= virtual(BT_BB : { bind_bb_interrupt,
5221 enable_bb_interrupt, disable_bb_interrupt }, RWBLE : { bind_rwble_interrupt,
5222 enable_rwble_interrupt, disable_rwble_interrupt }, RWBT : { bind_rwbt_interrupt,
5223 enable_rwbt_interrupt, disable_rwbt_interrupt }) (unstable)), (@ peri_type #[doc
5224 = "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type
5225 #[doc = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual()
5226 (unstable)), (@ peri_type #[doc = "TSENS peripheral singleton"] TSENS <=
5227 virtual() (unstable)), (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <=
5228 virtual(WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
5229 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
5230 disable_pwr_interrupt })), (@ peri_type #[doc =
5231 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)),
5232 (@ peri_type #[doc = "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <=
5233 virtual() (unstable)), (@ peri_type #[doc =
5234 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)),
5235 (@ peri_type #[doc = "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <=
5236 virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1),
5237 (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10),
5238 (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO15), (GPIO16), (GPIO17), (GPIO18),
5239 (GPIO19), (GPIO20), (GPIO21), (DMA_CH0(unstable)), (DMA_CH1(unstable)),
5240 (DMA_CH2(unstable)), (SDM_CH0(unstable)), (SDM_CH1(unstable)),
5241 (SDM_CH2(unstable)), (SDM_CH3(unstable)), (AES(unstable)), (APB_CTRL(unstable)),
5242 (APB_SARADC(unstable)), (ASSIST_DEBUG(unstable)), (BB(unstable)),
5243 (DMA(unstable)), (DS(unstable)), (EXTMEM(unstable)), (FE(unstable)),
5244 (FE2(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)), (HMAC(unstable)),
5245 (I2C_ANA_MST(unstable)), (I2C0), (I2S0(unstable)), (INTERRUPT_CORE0(unstable)),
5246 (IO_MUX(unstable)), (LEDC(unstable)), (NRX(unstable)), (RMT(unstable)),
5247 (RNG(unstable)), (RSA(unstable)), (LPWR(unstable)), (RTC_TIMER(unstable)),
5248 (SENSITIVE(unstable)), (SHA(unstable)), (SPI0(unstable)), (SPI1(unstable)),
5249 (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)), (TIMG0(unstable)),
5250 (TIMG1(unstable)), (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)),
5251 (USB_DEVICE(unstable)), (XTS_AES(unstable)), (ADC1(unstable)), (ADC2(unstable)),
5252 (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (TSENS(unstable)),
5253 (WIFI), (FROM_CPU_INTR1(unstable)), (FROM_CPU_INTR2(unstable)),
5254 (FROM_CPU_INTR3(unstable)))); _for_each_inner_peripheral!((dma_eligible(SPI2,
5255 Spi2, 0, AhbGdmaChannel), (UHCI0, Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3,
5256 AhbGdmaChannel), (AES, Aes, 6, AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel),
5257 (APB_SARADC, ApbSaradc, 8, AhbGdmaChannel)));
5258 };
5259}
5260#[macro_export]
5287#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5288macro_rules! for_each_gpio {
5289 ($($pattern:tt => $code:tt;)*) => {
5290 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5291 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
5292 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
5293 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
5294 _for_each_inner_gpio!((3, GPIO3() () ([Input] [Output])));
5295 _for_each_inner_gpio!((4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
5296 [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 =>
5297 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTCK _2 =>
5298 FSPICLK) (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2
5299 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])));
5300 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
5301 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
5302 _for_each_inner_gpio!((10, GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
5303 [Output]))); _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
5304 _for_each_inner_gpio!((12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input]
5305 [Output]))); _for_each_inner_gpio!((13, GPIO13(_0 => SPIWP) (_0 => SPIWP)
5306 ([Input] [Output]))); _for_each_inner_gpio!((14, GPIO14() (_0 => SPICS0) ([Input]
5307 [Output]))); _for_each_inner_gpio!((15, GPIO15() (_0 => SPICLK) ([Input]
5308 [Output]))); _for_each_inner_gpio!((16, GPIO16(_0 => SPID) (_0 => SPID) ([Input]
5309 [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => SPIQ) (_0 => SPIQ) ([Input]
5310 [Output]))); _for_each_inner_gpio!((18, GPIO18() () ([Input] [Output])));
5311 _for_each_inner_gpio!((19, GPIO19() () ([Input] [Output])));
5312 _for_each_inner_gpio!((20, GPIO20(_0 => U0RXD) () ([Input] [Output])));
5313 _for_each_inner_gpio!((21, GPIO21() (_0 => U0TXD) ([Input] [Output])));
5314 _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() ()
5315 ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])),
5316 (3, GPIO3() () ([Input] [Output])), (4, GPIO4(_0 => MTMS _2 => FSPIHD) (_2 =>
5317 FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP)
5318 ([Input] [Output])), (6, GPIO6(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
5319 [Output])), (7, GPIO7(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
5320 (8, GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10,
5321 GPIO10(_2 => FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (11, GPIO11() ()
5322 ([Input] [Output])), (12, GPIO12(_0 => SPIHD) (_0 => SPIHD) ([Input] [Output])),
5323 (13, GPIO13(_0 => SPIWP) (_0 => SPIWP) ([Input] [Output])), (14, GPIO14() (_0 =>
5324 SPICS0) ([Input] [Output])), (15, GPIO15() (_0 => SPICLK) ([Input] [Output])),
5325 (16, GPIO16(_0 => SPID) (_0 => SPID) ([Input] [Output])), (17, GPIO17(_0 => SPIQ)
5326 (_0 => SPIQ) ([Input] [Output])), (18, GPIO18() () ([Input] [Output])), (19,
5327 GPIO19() () ([Input] [Output])), (20, GPIO20(_0 => U0RXD) () ([Input] [Output])),
5328 (21, GPIO21() (_0 => U0TXD) ([Input] [Output]))));
5329 };
5330}
5331#[macro_export]
5358#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5359macro_rules! for_each_analog_function {
5360 ($($pattern:tt => $code:tt;)*) => {
5361 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5362 tt) => {} } _for_each_inner_analog_function!((ADC1_CH0, GPIO0));
5363 _for_each_inner_analog_function!((ADC1_CH1, GPIO1));
5364 _for_each_inner_analog_function!((ADC1_CH2, GPIO2));
5365 _for_each_inner_analog_function!((ADC1_CH3, GPIO3));
5366 _for_each_inner_analog_function!((ADC1_CH4, GPIO4));
5367 _for_each_inner_analog_function!((ADC2_CH0, GPIO5));
5368 _for_each_inner_analog_function!((USJ_DM, GPIO18));
5369 _for_each_inner_analog_function!((USJ_DP, GPIO19));
5370 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0));
5371 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1));
5372 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2));
5373 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3));
5374 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4));
5375 _for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO5));
5376 _for_each_inner_analog_function!((all(ADC1_CH0, GPIO0), (ADC1_CH1, GPIO1),
5377 (ADC1_CH2, GPIO2), (ADC1_CH3, GPIO3), (ADC1_CH4, GPIO4), (ADC2_CH0, GPIO5),
5378 (USJ_DM, GPIO18), (USJ_DP, GPIO19)));
5379 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO0),
5380 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO1), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO2),
5381 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO3), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO4),
5382 ((ADC2_CH0, ADCn_CHm, 2, 0), GPIO5)));
5383 };
5384}
5385#[macro_export]
5423#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5424macro_rules! for_each_lp_function {
5425 ($($pattern:tt => $code:tt;)*) => {
5426 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5427 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _0));
5428 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _0));
5429 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _0));
5430 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _0));
5431 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _0));
5432 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _0));
5433 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _0, () ()));
5434 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()));
5435 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _0, () ()));
5436 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()));
5437 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()));
5438 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0, () ()));
5439 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO0, _0), (LP_GPIO1, GPIO1, _0),
5440 (LP_GPIO2, GPIO2, _0), (LP_GPIO3, GPIO3, _0), (LP_GPIO4, GPIO4, _0), (LP_GPIO5,
5441 GPIO5, _0))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0),
5442 GPIO0, _0, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _0, () ()), ((LP_GPIO2,
5443 LP_GPIOn, 2), GPIO2, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _0, () ()),
5444 ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO5, _0,
5445 () ())));
5446 };
5447}
5448#[macro_export]
5479#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5480macro_rules! for_each_iomux_function {
5481 ($($pattern:tt => $code:tt;)*) => {
5482 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5483 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
5484 _for_each_inner_iomux_function!((MTMS, GPIO4, _0));
5485 _for_each_inner_iomux_function!((FSPIHD, GPIO4, _2));
5486 _for_each_inner_iomux_function!((MTDI, GPIO5, _0));
5487 _for_each_inner_iomux_function!((FSPIWP, GPIO5, _2));
5488 _for_each_inner_iomux_function!((MTCK, GPIO6, _0));
5489 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
5490 _for_each_inner_iomux_function!((MTDO, GPIO7, _0));
5491 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
5492 _for_each_inner_iomux_function!((FSPICS0, GPIO10, _2));
5493 _for_each_inner_iomux_function!((SPIHD, GPIO12, _0));
5494 _for_each_inner_iomux_function!((SPIWP, GPIO13, _0));
5495 _for_each_inner_iomux_function!((SPICS0, GPIO14, _0));
5496 _for_each_inner_iomux_function!((SPICLK, GPIO15, _0));
5497 _for_each_inner_iomux_function!((SPID, GPIO16, _0));
5498 _for_each_inner_iomux_function!((SPIQ, GPIO17, _0));
5499 _for_each_inner_iomux_function!((U0RXD, GPIO20, _0));
5500 _for_each_inner_iomux_function!((U0TXD, GPIO21, _0));
5501 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO10, _2));
5502 _for_each_inner_iomux_function!(((SPICS0, SPICSn, 0), GPIO14, _0));
5503 _for_each_inner_iomux_function!((all(FSPIQ, GPIO2, _2), (MTMS, GPIO4, _0),
5504 (FSPIHD, GPIO4, _2), (MTDI, GPIO5, _0), (FSPIWP, GPIO5, _2), (MTCK, GPIO6, _0),
5505 (FSPICLK, GPIO6, _2), (MTDO, GPIO7, _0), (FSPID, GPIO7, _2), (FSPICS0, GPIO10,
5506 _2), (SPIHD, GPIO12, _0), (SPIWP, GPIO13, _0), (SPICS0, GPIO14, _0), (SPICLK,
5507 GPIO15, _0), (SPID, GPIO16, _0), (SPIQ, GPIO17, _0), (U0RXD, GPIO20, _0), (U0TXD,
5508 GPIO21, _0))); _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0),
5509 GPIO10, _2))); _for_each_inner_iomux_function!((SPICSn((SPICS0, SPICSn, 0),
5510 GPIO14, _0)));
5511 };
5512}
5513#[macro_export]
5530#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5531macro_rules! gpio_for_signal {
5532 (ADC1_CH0 $(, $_fallback:literal)?) => {
5533 "GPIO0"
5534 };
5535 (LP_GPIO0 $(, $_fallback:literal)?) => {
5536 "GPIO0"
5537 };
5538 (ADC1_CH1 $(, $_fallback:literal)?) => {
5539 "GPIO1"
5540 };
5541 (LP_GPIO1 $(, $_fallback:literal)?) => {
5542 "GPIO1"
5543 };
5544 (FSPIQ $(, $_fallback:literal)?) => {
5545 "GPIO2"
5546 };
5547 (ADC1_CH2 $(, $_fallback:literal)?) => {
5548 "GPIO2"
5549 };
5550 (LP_GPIO2 $(, $_fallback:literal)?) => {
5551 "GPIO2"
5552 };
5553 (ADC1_CH3 $(, $_fallback:literal)?) => {
5554 "GPIO3"
5555 };
5556 (LP_GPIO3 $(, $_fallback:literal)?) => {
5557 "GPIO3"
5558 };
5559 (MTMS $(, $_fallback:literal)?) => {
5560 "GPIO4"
5561 };
5562 (FSPIHD $(, $_fallback:literal)?) => {
5563 "GPIO4"
5564 };
5565 (ADC1_CH4 $(, $_fallback:literal)?) => {
5566 "GPIO4"
5567 };
5568 (LP_GPIO4 $(, $_fallback:literal)?) => {
5569 "GPIO4"
5570 };
5571 (MTDI $(, $_fallback:literal)?) => {
5572 "GPIO5"
5573 };
5574 (FSPIWP $(, $_fallback:literal)?) => {
5575 "GPIO5"
5576 };
5577 (ADC2_CH0 $(, $_fallback:literal)?) => {
5578 "GPIO5"
5579 };
5580 (LP_GPIO5 $(, $_fallback:literal)?) => {
5581 "GPIO5"
5582 };
5583 (MTCK $(, $_fallback:literal)?) => {
5584 "GPIO6"
5585 };
5586 (FSPICLK $(, $_fallback:literal)?) => {
5587 "GPIO6"
5588 };
5589 (MTDO $(, $_fallback:literal)?) => {
5590 "GPIO7"
5591 };
5592 (FSPID $(, $_fallback:literal)?) => {
5593 "GPIO7"
5594 };
5595 (FSPICS0 $(, $_fallback:literal)?) => {
5596 "GPIO10"
5597 };
5598 (SPIHD $(, $_fallback:literal)?) => {
5599 "GPIO12"
5600 };
5601 (SPIWP $(, $_fallback:literal)?) => {
5602 "GPIO13"
5603 };
5604 (SPICS0 $(, $_fallback:literal)?) => {
5605 "GPIO14"
5606 };
5607 (SPICLK $(, $_fallback:literal)?) => {
5608 "GPIO15"
5609 };
5610 (SPID $(, $_fallback:literal)?) => {
5611 "GPIO16"
5612 };
5613 (SPIQ $(, $_fallback:literal)?) => {
5614 "GPIO17"
5615 };
5616 (USJ_DM $(, $_fallback:literal)?) => {
5617 "GPIO18"
5618 };
5619 (USJ_DP $(, $_fallback:literal)?) => {
5620 "GPIO19"
5621 };
5622 (U0RXD $(, $_fallback:literal)?) => {
5623 "GPIO20"
5624 };
5625 (U0TXD $(, $_fallback:literal)?) => {
5626 "GPIO21"
5627 };
5628 ($_signal:ident, $fallback:literal) => {
5629 $fallback
5630 };
5631}
5632#[macro_export]
5636#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5637macro_rules! define_io_mux_signals {
5638 () => {
5639 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5640 #[derive(Debug, PartialEq, Copy, Clone)]
5641 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5642 #[doc(hidden)]
5643 pub enum InputSignal {
5644 SPIQ = 0,
5645 SPID = 1,
5646 SPIHD = 2,
5647 SPIWP = 3,
5648 U0RXD = 6,
5649 U0CTS = 7,
5650 U0DSR = 8,
5651 U1RXD = 9,
5652 U1CTS = 10,
5653 U1DSR = 11,
5654 I2S_MCLK = 12,
5655 I2SO_BCK = 13,
5656 I2SO_WS = 14,
5657 I2SI_SD = 15,
5658 I2SI_BCK = 16,
5659 I2SI_WS = 17,
5660 GPIO_BT_PRIORITY = 18,
5661 GPIO_BT_ACTIVE = 19,
5662 CPU_GPIO_0 = 28,
5663 CPU_GPIO_1 = 29,
5664 CPU_GPIO_2 = 30,
5665 CPU_GPIO_3 = 31,
5666 CPU_GPIO_4 = 32,
5667 CPU_GPIO_5 = 33,
5668 CPU_GPIO_6 = 34,
5669 CPU_GPIO_7 = 35,
5670 EXT_ADC_START = 45,
5671 RMT_SIG_0 = 51,
5672 RMT_SIG_1 = 52,
5673 I2CEXT0_SCL = 53,
5674 I2CEXT0_SDA = 54,
5675 FSPICLK = 63,
5676 FSPIQ = 64,
5677 FSPID = 65,
5678 FSPIHD = 66,
5679 FSPIWP = 67,
5680 FSPICS0 = 68,
5681 TWAI_RX = 74,
5682 SIG_FUNC_97 = 97,
5683 SIG_FUNC_98 = 98,
5684 SIG_FUNC_99 = 99,
5685 SIG_FUNC_100 = 100,
5686 MTCK,
5687 MTMS,
5688 MTDI,
5689 }
5690 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5691 #[derive(Debug, PartialEq, Copy, Clone)]
5692 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5693 #[doc(hidden)]
5694 pub enum OutputSignal {
5695 SPIQ = 0,
5696 SPID = 1,
5697 SPIHD = 2,
5698 SPIWP = 3,
5699 SPICLK = 4,
5700 SPICS0 = 5,
5701 U0TXD = 6,
5702 U0RTS = 7,
5703 U0DTR = 8,
5704 U1TXD = 9,
5705 U1RTS = 10,
5706 U1DTR = 11,
5707 I2S_MCLK = 12,
5708 I2SO_BCK = 13,
5709 I2SO_WS = 14,
5710 I2SO_SD = 15,
5711 I2SI_BCK = 16,
5712 I2SI_WS = 17,
5713 GPIO_WLAN_PRIO = 18,
5714 GPIO_WLAN_ACTIVE = 19,
5715 CPU_GPIO_0 = 28,
5716 CPU_GPIO_1 = 29,
5717 CPU_GPIO_2 = 30,
5718 CPU_GPIO_3 = 31,
5719 CPU_GPIO_4 = 32,
5720 CPU_GPIO_5 = 33,
5721 CPU_GPIO_6 = 34,
5722 CPU_GPIO_7 = 35,
5723 USB_JTAG_TCK = 36,
5724 USB_JTAG_TMS = 37,
5725 USB_JTAG_TDI = 38,
5726 USB_JTAG_TDO = 39,
5727 LEDC_LS_SIG0 = 45,
5728 LEDC_LS_SIG1 = 46,
5729 LEDC_LS_SIG2 = 47,
5730 LEDC_LS_SIG3 = 48,
5731 LEDC_LS_SIG4 = 49,
5732 LEDC_LS_SIG5 = 50,
5733 RMT_SIG_0 = 51,
5734 RMT_SIG_1 = 52,
5735 I2CEXT0_SCL = 53,
5736 I2CEXT0_SDA = 54,
5737 GPIO_SD0 = 55,
5738 GPIO_SD1 = 56,
5739 GPIO_SD2 = 57,
5740 GPIO_SD3 = 58,
5741 I2SO_SD1 = 59,
5742 FSPICLK = 63,
5743 FSPIQ = 64,
5744 FSPID = 65,
5745 FSPIHD = 66,
5746 FSPIWP = 67,
5747 FSPICS0 = 68,
5748 FSPICS1 = 69,
5749 FSPICS3 = 70,
5750 FSPICS2 = 71,
5751 FSPICS4 = 72,
5752 FSPICS5 = 73,
5753 TWAI_TX = 74,
5754 TWAI_BUS_OFF_ON = 75,
5755 TWAI_CLKOUT = 76,
5756 ANT_SEL0 = 89,
5757 ANT_SEL1 = 90,
5758 ANT_SEL2 = 91,
5759 ANT_SEL3 = 92,
5760 ANT_SEL4 = 93,
5761 ANT_SEL5 = 94,
5762 ANT_SEL6 = 95,
5763 ANT_SEL7 = 96,
5764 SIG_FUNC_97 = 97,
5765 SIG_FUNC_98 = 98,
5766 SIG_FUNC_99 = 99,
5767 SIG_FUNC_100 = 100,
5768 CLK_OUT1 = 123,
5769 CLK_OUT2 = 124,
5770 CLK_OUT3 = 125,
5771 SPICS1 = 126,
5772 USB_JTAG_TRST = 127,
5773 GPIO = 128,
5774 MTDO,
5775 }
5776 };
5777}
5778#[macro_export]
5785#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5786macro_rules! define_lp_functions {
5787 () => {
5788 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5793 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5794 #[doc(hidden)]
5795 pub enum LpFunction {
5796 _0 = 0,
5798 }
5799 impl LpFunction {
5800 pub const LP_GPIO: Self = Self::_0;
5802 }
5803 };
5804}
5805#[macro_export]
5818#[expect(clippy::crate_in_macro_def)]
5819#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5820macro_rules! define_io_mux_reg {
5821 () => {
5822 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
5823 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
5824 }
5825 };
5826}