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