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 "esp32c5"
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-C5"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32c5"
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-c5_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 96
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(96)
75 };
76 ("gpio.constant_1_input") => {
77 64
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(64)
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 116
96 };
97 ("gpio.input_signal_max", str) => {
98 stringify!(116)
99 };
100 ("gpio.output_signal_max") => {
101 256
102 };
103 ("gpio.output_signal_max", str) => {
104 stringify!(256)
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 "v4"
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 2
132 };
133 ("uart.version", str) => {
134 stringify!(2)
135 };
136 ("uart.peripheral_controls_mem_clk") => {
137 true
138 };
139 ("uart.has_sclk_divider") => {
140 false
141 };
142 ("uart.has_sclk_enable") => {
143 true
144 };
145 ("uhci.combined_uart_selector_field") => {
146 true
147 };
148 ("i2c_master.version") => {
149 4
150 };
151 ("i2c_master.version", str) => {
152 stringify!(4)
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 true
168 };
169 ("i2c_master.has_conf_update") => {
170 true
171 };
172 ("i2c_master.has_reliable_fsm_reset") => {
173 true
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 ("lp_i2c_master.version") => {
206 "lp_i2c"
207 };
208 ("lp_i2c_master.fifo_size") => {
209 16
210 };
211 ("lp_i2c_master.fifo_size", str) => {
212 stringify!(16)
213 };
214 ("spi_master.version") => {
215 3
216 };
217 ("spi_master.version", str) => {
218 stringify!(3)
219 };
220 ("spi_master.fifo_size") => {
221 64
222 };
223 ("spi_master.fifo_size", str) => {
224 stringify!(64)
225 };
226 ("spi_master.bit_order_is_bool") => {
227 false
228 };
229 ("spi_master.has_octal") => {
230 false
231 };
232 ("spi_master.has_app_interrupts") => {
233 true
234 };
235 ("spi_master.has_dma_segmented_transfer") => {
236 true
237 };
238 ("spi_master.has_clk_pre_div") => {
239 true
240 };
241 ("spi_master.dma_can_access_flash") => {
242 true
243 };
244 ("i2s.version") => {
245 3
246 };
247 ("i2s.version", str) => {
248 stringify!(3)
249 };
250 ("i2s.default_clock_source") => {
251 2
252 };
253 ("i2s.default_clock_source", str) => {
254 stringify!(2)
255 };
256 ("i2s.mclk_divider_bit_width") => {
257 9
258 };
259 ("i2s.mclk_divider_bit_width", str) => {
260 stringify!(9)
261 };
262 ("i2s.max_ws_width") => {
263 512
264 };
265 ("i2s.max_ws_width", str) => {
266 stringify!(512)
267 };
268 ("i2s.clock_configured_by_pcr") => {
269 true
270 };
271 ("i2s.clock_configured_by_hp_sys_clkrst") => {
272 false
273 };
274 ("i2s.supports_pdm_rx_hp_filter") => {
275 false
276 };
277 ("i2s.supports_pdm_tx") => {
278 true
279 };
280 ("i2s.supports_pdm_rx") => {
281 true
282 };
283 ("i2s.supports_pcm2pdm") => {
284 true
285 };
286 ("i2s.supports_pdm2pcm") => {
287 false
288 };
289 ("parl_io.version") => {
290 2
291 };
292 ("parl_io.version", str) => {
293 stringify!(2)
294 };
295 ("rmt.ram_start") => {
296 1610638336
297 };
298 ("rmt.ram_start", str) => {
299 stringify!(1610638336)
300 };
301 ("rmt.channel_ram_size") => {
302 48
303 };
304 ("rmt.channel_ram_size", str) => {
305 stringify!(48)
306 };
307 ("rmt.has_tx_immediate_stop") => {
308 true
309 };
310 ("rmt.has_tx_loop_count") => {
311 true
312 };
313 ("rmt.has_tx_loop_auto_stop") => {
314 true
315 };
316 ("rmt.has_tx_carrier_data_only") => {
317 true
318 };
319 ("rmt.has_tx_sync") => {
320 true
321 };
322 ("rmt.has_rx_wrap") => {
323 true
324 };
325 ("rmt.has_rx_demodulation") => {
326 true
327 };
328 ("rmt.has_per_channel_clock") => {
329 false
330 };
331 ("bt.controller") => {
332 "npl"
333 };
334 ("wifi.has_wifi6") => {
335 false
336 };
337 ("wifi.mac_version") => {
338 3
339 };
340 ("wifi.mac_version", str) => {
341 stringify!(3)
342 };
343 ("wifi.has_5g") => {
344 true
345 };
346 ("wifi.csi_supported") => {
347 true
348 };
349 ("phy.combo_module") => {
350 true
351 };
352 ("sdm.channel_count") => {
353 4
354 };
355 ("sdm.channel_count", str) => {
356 stringify!(4)
357 };
358 ("timergroup.timg_has_timer1") => {
359 false
360 };
361 ("timergroup.timg_has_divcnt_rst") => {
362 true
363 };
364 ("timergroup.rc_fast_calibration_divider_min_rev") => {
365 0
366 };
367 ("timergroup.rc_fast_calibration_divider") => {
368 32
369 };
370 ("timergroup.rc_fast_calibration_tick_enable") => {
371 false
372 };
373 ("aes.has_split_text_registers") => {
374 true
375 };
376 ("aes.endianness_configurable") => {
377 false
378 };
379 ("ecc.zero_extend_writes") => {
380 false
381 };
382 ("ecc.separate_jacobian_point_memory") => {
383 true
384 };
385 ("ecc.has_memory_clock_gate") => {
386 true
387 };
388 ("ecc.supports_enhanced_security") => {
389 true
390 };
391 ("ecc.mem_block_size") => {
392 48
393 };
394 ("rng.apb_cycle_wait_num") => {
395 16
396 };
397 ("rng.apb_cycle_wait_num", str) => {
398 stringify!(16)
399 };
400 ("rng.trng_supported") => {
401 false
402 };
403 ("rng.is_lp_sys") => {
404 true
405 };
406 ("rsa.version") => {
407 3
408 };
409 ("rsa.version", str) => {
410 stringify!(3)
411 };
412 ("rsa.size_increment") => {
413 32
414 };
415 ("rsa.size_increment", str) => {
416 stringify!(32)
417 };
418 ("rsa.memory_size_bytes") => {
419 384
420 };
421 ("rsa.memory_size_bytes", str) => {
422 stringify!(384)
423 };
424 ("sleep.light_sleep") => {
425 true
426 };
427 ("sleep.deep_sleep") => {
428 true
429 };
430 ("sleep.rejectable_mask") => {
431 3582
432 };
433 ("sleep.ext1_version") => {
434 2
435 };
436 ("sleep.ext1_version", str) => {
437 stringify!(2)
438 };
439 ("sleep.pin_wakeup_version") => {
440 3
441 };
442 ("sleep.pin_wakeup_version", str) => {
443 stringify!(3)
444 };
445 ("sleep.deep_sleep_needs_gpio_isolation") => {
446 false
447 };
448 ("assist_debug.has_sp_monitor") => {
449 true
450 };
451 ("assist_debug.has_region_monitor") => {
452 true
453 };
454 ("dma.mem2mem_requires_peripheral") => {
455 false
456 };
457 ("dma.ext_mem_configurable_block_size") => {
458 false
459 };
460 ("dma.separate_in_out_interrupts") => {
461 true
462 };
463 ("dma.gdma_version") => {
464 2
465 };
466 ("dma.gdma_version", str) => {
467 stringify!(2)
468 };
469 ("interrupts.status_registers") => {
470 3
471 };
472 ("interrupts.status_registers", str) => {
473 stringify!(3)
474 };
475 ("interrupts.disabled_interrupt") => {
476 0
477 };
478 ("mmu.page_size") => {
479 65536
480 };
481 ("mmu.page_size", str) => {
482 stringify!(65536)
483 };
484 ("mmu.entry_num") => {
485 512
486 };
487 ("mmu.entry_num", str) => {
488 stringify!(512)
489 };
490 ("psram.octal_spi") => {
491 false
492 };
493 ("psram.hex_spi") => {
494 false
495 };
496 ("psram.extmem_origin") => {
497 1107296256
498 };
499 ("psram.extmem_origin", str) => {
500 stringify!(1107296256)
501 };
502 ("rom.has_crc_le") => {
503 true
504 };
505 ("rom.has_crc_be") => {
506 true
507 };
508 ("rom.has_md5_bsd") => {
509 true
510 };
511 ("rom.has_md5_mbedtls") => {
512 false
513 };
514 ("soc.cpu_has_branch_predictor") => {
515 true
516 };
517 ("soc.cpu_has_csr_pc") => {
518 false
519 };
520 ("soc.multi_core_enabled") => {
521 false
522 };
523 ("soc.cpu_csr_prv_mode") => {
524 2064
525 };
526 ("soc.cpu_csr_prv_mode", str) => {
527 stringify!(2064)
528 };
529 ("soc.internal_memory_cached") => {
530 false
531 };
532 ("soc.has_swd_watchdog") => {
533 true
534 };
535 ("soc.cpu_mcause_mask") => {
536 31
537 };
538 ("soc.cpu_mcause_mask", str) => {
539 stringify!(31)
540 };
541 ("clock_tree.hp_root_clk") => {
542 [crate ::soc::clocks::HpRootClkConfig::Xtal, crate
543 ::soc::clocks::HpRootClkConfig::RcFast, crate
544 ::soc::clocks::HpRootClkConfig::PllF160m, crate
545 ::soc::clocks::HpRootClkConfig::PllF240m]
546 };
547 ("clock_tree.cpu_clk.divisor") => {
548 (0, 255)
549 };
550 ("clock_tree.ahb_clk.divisor") => {
551 (0, 255)
552 };
553 ("clock_tree.apb_clk.divisor") => {
554 (0, 255)
555 };
556 ("clock_tree.lp_fast_clk") => {
557 [crate ::soc::clocks::LpFastClkConfig::RcFast, crate
558 ::soc::clocks::LpFastClkConfig::XtalD2, crate
559 ::soc::clocks::LpFastClkConfig::Xtal]
560 };
561 ("clock_tree.lp_slow_clk") => {
562 [crate ::soc::clocks::LpSlowClkConfig::RcSlow, #[cfg(use_xtal32k)] crate
563 ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
564 ::soc::clocks::LpSlowClkConfig::OscSlow]
565 };
566 ("clock_tree.crypto_clk") => {
567 [crate ::soc::clocks::CryptoClkConfig::Xtal, crate
568 ::soc::clocks::CryptoClkConfig::Fosc, crate
569 ::soc::clocks::CryptoClkConfig::PllF480m]
570 };
571 ("clock_tree.iomux_function_clock") => {
572 [crate ::soc::clocks::IomuxFunctionClockConfig::XtalClk, crate
573 ::soc::clocks::IomuxFunctionClockConfig::RcFastClk, crate
574 ::soc::clocks::IomuxFunctionClockConfig::PllF80m]
575 };
576 ("clock_tree.timg_calibration_clock") => {
577 [crate ::soc::clocks::TimgCalibrationClockConfig::OscSlowClk, crate
578 ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
579 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, #[cfg(use_xtal32k)]
580 crate ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
581 };
582 ("clock_tree.uart.function_clock.sclk") => {
583 [crate ::soc::clocks::UartFunctionClockSclk::Xtal, crate
584 ::soc::clocks::UartFunctionClockSclk::PllF80m, crate
585 ::soc::clocks::UartFunctionClockSclk::RcFast]
586 };
587 ("clock_tree.uart.function_clock.div_num") => {
588 (0, 255)
589 };
590 ("clock_tree.uart.baud_rate_generator.fractional") => {
591 (0, 15)
592 };
593 ("clock_tree.uart.baud_rate_generator.integral") => {
594 (0, 4095)
595 };
596 ("clock_tree.timg.function_clock") => {
597 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
598 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
599 ::soc::clocks::TimgFunctionClockConfig::PllF80m]
600 };
601 ("clock_tree.timg.wdt_clock") => {
602 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
603 ::soc::clocks::TimgWdtClockConfig::PllF80m, crate
604 ::soc::clocks::TimgWdtClockConfig::RcFastClk]
605 };
606 ("clock_tree.rmt.sclk") => {
607 [crate ::soc::clocks::RmtSclkConfig::XtalClk, crate
608 ::soc::clocks::RmtSclkConfig::RcFastClk, crate
609 ::soc::clocks::RmtSclkConfig::PllF80m]
610 };
611 ("clock_tree.parl_io.rx_clock") => {
612 [crate ::soc::clocks::ParlIoRxClockConfig::XtalClk, crate
613 ::soc::clocks::ParlIoRxClockConfig::RcFastClk, crate
614 ::soc::clocks::ParlIoRxClockConfig::PllF240m]
615 };
616 ("clock_tree.parl_io.tx_clock") => {
617 [crate ::soc::clocks::ParlIoTxClockConfig::XtalClk, crate
618 ::soc::clocks::ParlIoTxClockConfig::RcFastClk, crate
619 ::soc::clocks::ParlIoTxClockConfig::PllF240m]
620 };
621 ("clock_tree.i2c.function_clock.sclk") => {
622 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
623 ::soc::clocks::I2cFunctionClockSclk::RcFast]
624 };
625 ("clock_tree.i2c.function_clock.div_num") => {
626 (0, 255)
627 };
628 ("clock_tree.spi.function_clock") => {
629 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
630 ::soc::clocks::SpiFunctionClockConfig::PllF160m, crate
631 ::soc::clocks::SpiFunctionClockConfig::PllF120m, crate
632 ::soc::clocks::SpiFunctionClockConfig::RcFast]
633 };
634}
635#[macro_export]
636#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
637macro_rules! for_each_dedicated_gpio {
638 ($($pattern:tt => $code:tt;)*) => {
639 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
640 tt) => {} } _for_each_inner_dedicated_gpio!((0));
641 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
642 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
643 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
644 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
645 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
646 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
647 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
648 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
649 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
650 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
651 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
652 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
653 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
654 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
655 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
656 };
657}
658#[macro_export]
662#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
663macro_rules! define_lp_io_signals {
664 () => {};
665}
666#[macro_export]
688#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
689macro_rules! for_each_rmt_channel {
690 ($($pattern:tt => $code:tt;)*) => {
691 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
692 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
693 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
694 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
695 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
696 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
697 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
698 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
699 };
700}
701#[macro_export]
702#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
703macro_rules! for_each_sdm_channel {
704 ($($pattern:tt => $code:tt;)*) => {
705 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
706 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
707 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
708 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
709 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
710 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
711 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
712 GPIO_SD3)));
713 };
714}
715#[macro_export]
716#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
717macro_rules! for_each_aes_key_length {
718 ($($pattern:tt => $code:tt;)*) => {
719 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
720 tt) => {} } _for_each_inner_aes_key_length!((128));
721 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
722 4)); _for_each_inner_aes_key_length!((256, 2, 6));
723 _for_each_inner_aes_key_length!((bits(128), (256)));
724 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
725 };
726}
727#[macro_export]
728#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
729macro_rules! for_each_ecc_working_mode {
730 ($($pattern:tt => $code:tt;)*) => {
731 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
732 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
733 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
734 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
735 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
736 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
737 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
738 _for_each_inner_ecc_working_mode!((7,
739 AffinePointVerificationAndJacobianPointMultiplication));
740 _for_each_inner_ecc_working_mode!((8, ModularAddition));
741 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
742 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
743 _for_each_inner_ecc_working_mode!((11, ModularDivision));
744 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
745 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
746 JacobianPointMultiplication), (5, AffinePointAddition), (6,
747 JacobianPointVerification), (7,
748 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
749 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
750 };
751}
752#[macro_export]
753#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
754macro_rules! for_each_ecc_curve {
755 ($($pattern:tt => $code:tt;)*) => {
756 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
757 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
758 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((2, P384,
759 384)); _for_each_inner_ecc_curve!((all(0, P192, 192), (1, P256, 256), (2, P384,
760 384)));
761 };
762}
763#[macro_export]
764#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
765macro_rules! for_each_rsa_exponentiation {
766 ($($pattern:tt => $code:tt;)*) => {
767 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
768 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
769 _for_each_inner_rsa_exponentiation!((64));
770 _for_each_inner_rsa_exponentiation!((96));
771 _for_each_inner_rsa_exponentiation!((128));
772 _for_each_inner_rsa_exponentiation!((160));
773 _for_each_inner_rsa_exponentiation!((192));
774 _for_each_inner_rsa_exponentiation!((224));
775 _for_each_inner_rsa_exponentiation!((256));
776 _for_each_inner_rsa_exponentiation!((288));
777 _for_each_inner_rsa_exponentiation!((320));
778 _for_each_inner_rsa_exponentiation!((352));
779 _for_each_inner_rsa_exponentiation!((384));
780 _for_each_inner_rsa_exponentiation!((416));
781 _for_each_inner_rsa_exponentiation!((448));
782 _for_each_inner_rsa_exponentiation!((480));
783 _for_each_inner_rsa_exponentiation!((512));
784 _for_each_inner_rsa_exponentiation!((544));
785 _for_each_inner_rsa_exponentiation!((576));
786 _for_each_inner_rsa_exponentiation!((608));
787 _for_each_inner_rsa_exponentiation!((640));
788 _for_each_inner_rsa_exponentiation!((672));
789 _for_each_inner_rsa_exponentiation!((704));
790 _for_each_inner_rsa_exponentiation!((736));
791 _for_each_inner_rsa_exponentiation!((768));
792 _for_each_inner_rsa_exponentiation!((800));
793 _for_each_inner_rsa_exponentiation!((832));
794 _for_each_inner_rsa_exponentiation!((864));
795 _for_each_inner_rsa_exponentiation!((896));
796 _for_each_inner_rsa_exponentiation!((928));
797 _for_each_inner_rsa_exponentiation!((960));
798 _for_each_inner_rsa_exponentiation!((992));
799 _for_each_inner_rsa_exponentiation!((1024));
800 _for_each_inner_rsa_exponentiation!((1056));
801 _for_each_inner_rsa_exponentiation!((1088));
802 _for_each_inner_rsa_exponentiation!((1120));
803 _for_each_inner_rsa_exponentiation!((1152));
804 _for_each_inner_rsa_exponentiation!((1184));
805 _for_each_inner_rsa_exponentiation!((1216));
806 _for_each_inner_rsa_exponentiation!((1248));
807 _for_each_inner_rsa_exponentiation!((1280));
808 _for_each_inner_rsa_exponentiation!((1312));
809 _for_each_inner_rsa_exponentiation!((1344));
810 _for_each_inner_rsa_exponentiation!((1376));
811 _for_each_inner_rsa_exponentiation!((1408));
812 _for_each_inner_rsa_exponentiation!((1440));
813 _for_each_inner_rsa_exponentiation!((1472));
814 _for_each_inner_rsa_exponentiation!((1504));
815 _for_each_inner_rsa_exponentiation!((1536));
816 _for_each_inner_rsa_exponentiation!((1568));
817 _for_each_inner_rsa_exponentiation!((1600));
818 _for_each_inner_rsa_exponentiation!((1632));
819 _for_each_inner_rsa_exponentiation!((1664));
820 _for_each_inner_rsa_exponentiation!((1696));
821 _for_each_inner_rsa_exponentiation!((1728));
822 _for_each_inner_rsa_exponentiation!((1760));
823 _for_each_inner_rsa_exponentiation!((1792));
824 _for_each_inner_rsa_exponentiation!((1824));
825 _for_each_inner_rsa_exponentiation!((1856));
826 _for_each_inner_rsa_exponentiation!((1888));
827 _for_each_inner_rsa_exponentiation!((1920));
828 _for_each_inner_rsa_exponentiation!((1952));
829 _for_each_inner_rsa_exponentiation!((1984));
830 _for_each_inner_rsa_exponentiation!((2016));
831 _for_each_inner_rsa_exponentiation!((2048));
832 _for_each_inner_rsa_exponentiation!((2080));
833 _for_each_inner_rsa_exponentiation!((2112));
834 _for_each_inner_rsa_exponentiation!((2144));
835 _for_each_inner_rsa_exponentiation!((2176));
836 _for_each_inner_rsa_exponentiation!((2208));
837 _for_each_inner_rsa_exponentiation!((2240));
838 _for_each_inner_rsa_exponentiation!((2272));
839 _for_each_inner_rsa_exponentiation!((2304));
840 _for_each_inner_rsa_exponentiation!((2336));
841 _for_each_inner_rsa_exponentiation!((2368));
842 _for_each_inner_rsa_exponentiation!((2400));
843 _for_each_inner_rsa_exponentiation!((2432));
844 _for_each_inner_rsa_exponentiation!((2464));
845 _for_each_inner_rsa_exponentiation!((2496));
846 _for_each_inner_rsa_exponentiation!((2528));
847 _for_each_inner_rsa_exponentiation!((2560));
848 _for_each_inner_rsa_exponentiation!((2592));
849 _for_each_inner_rsa_exponentiation!((2624));
850 _for_each_inner_rsa_exponentiation!((2656));
851 _for_each_inner_rsa_exponentiation!((2688));
852 _for_each_inner_rsa_exponentiation!((2720));
853 _for_each_inner_rsa_exponentiation!((2752));
854 _for_each_inner_rsa_exponentiation!((2784));
855 _for_each_inner_rsa_exponentiation!((2816));
856 _for_each_inner_rsa_exponentiation!((2848));
857 _for_each_inner_rsa_exponentiation!((2880));
858 _for_each_inner_rsa_exponentiation!((2912));
859 _for_each_inner_rsa_exponentiation!((2944));
860 _for_each_inner_rsa_exponentiation!((2976));
861 _for_each_inner_rsa_exponentiation!((3008));
862 _for_each_inner_rsa_exponentiation!((3040));
863 _for_each_inner_rsa_exponentiation!((3072));
864 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
865 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
866 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
867 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
868 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
869 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
870 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
871 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
872 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
873 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
874 };
875}
876#[macro_export]
877#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
878macro_rules! for_each_rsa_multiplication {
879 ($($pattern:tt => $code:tt;)*) => {
880 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
881 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
882 _for_each_inner_rsa_multiplication!((64));
883 _for_each_inner_rsa_multiplication!((96));
884 _for_each_inner_rsa_multiplication!((128));
885 _for_each_inner_rsa_multiplication!((160));
886 _for_each_inner_rsa_multiplication!((192));
887 _for_each_inner_rsa_multiplication!((224));
888 _for_each_inner_rsa_multiplication!((256));
889 _for_each_inner_rsa_multiplication!((288));
890 _for_each_inner_rsa_multiplication!((320));
891 _for_each_inner_rsa_multiplication!((352));
892 _for_each_inner_rsa_multiplication!((384));
893 _for_each_inner_rsa_multiplication!((416));
894 _for_each_inner_rsa_multiplication!((448));
895 _for_each_inner_rsa_multiplication!((480));
896 _for_each_inner_rsa_multiplication!((512));
897 _for_each_inner_rsa_multiplication!((544));
898 _for_each_inner_rsa_multiplication!((576));
899 _for_each_inner_rsa_multiplication!((608));
900 _for_each_inner_rsa_multiplication!((640));
901 _for_each_inner_rsa_multiplication!((672));
902 _for_each_inner_rsa_multiplication!((704));
903 _for_each_inner_rsa_multiplication!((736));
904 _for_each_inner_rsa_multiplication!((768));
905 _for_each_inner_rsa_multiplication!((800));
906 _for_each_inner_rsa_multiplication!((832));
907 _for_each_inner_rsa_multiplication!((864));
908 _for_each_inner_rsa_multiplication!((896));
909 _for_each_inner_rsa_multiplication!((928));
910 _for_each_inner_rsa_multiplication!((960));
911 _for_each_inner_rsa_multiplication!((992));
912 _for_each_inner_rsa_multiplication!((1024));
913 _for_each_inner_rsa_multiplication!((1056));
914 _for_each_inner_rsa_multiplication!((1088));
915 _for_each_inner_rsa_multiplication!((1120));
916 _for_each_inner_rsa_multiplication!((1152));
917 _for_each_inner_rsa_multiplication!((1184));
918 _for_each_inner_rsa_multiplication!((1216));
919 _for_each_inner_rsa_multiplication!((1248));
920 _for_each_inner_rsa_multiplication!((1280));
921 _for_each_inner_rsa_multiplication!((1312));
922 _for_each_inner_rsa_multiplication!((1344));
923 _for_each_inner_rsa_multiplication!((1376));
924 _for_each_inner_rsa_multiplication!((1408));
925 _for_each_inner_rsa_multiplication!((1440));
926 _for_each_inner_rsa_multiplication!((1472));
927 _for_each_inner_rsa_multiplication!((1504));
928 _for_each_inner_rsa_multiplication!((1536));
929 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
930 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
931 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
932 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
933 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
934 };
935}
936#[macro_export]
937#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
938macro_rules! for_each_sha_algorithm {
939 ($($pattern:tt => $code:tt;)*) => {
940 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
941 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
942 (insecure_against : "collision", "length extension"), 0));
943 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
944 (insecure_against : "length extension"), 1));
945 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
946 (insecure_against : "length extension"), 2));
947 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
948 (insecure_against : "collision", "length extension"), 0), (Sha224,
949 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
950 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
951 2)));
952 };
953}
954#[macro_export]
955#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
956macro_rules! for_each_wakeup_source {
957 ($($pattern:tt => $code:tt;)*) => {
958 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
959 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
960 _for_each_inner_wakeup_source!((Gpio, 2));
961 _for_each_inner_wakeup_source!((WifiBeacon, 3));
962 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
963 5)); _for_each_inner_wakeup_source!((Uart0, 6));
964 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
965 8)); _for_each_inner_wakeup_source!((Bt, 10));
966 _for_each_inner_wakeup_source!((LpCore, 11));
967 _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3), (Timer,
968 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Bt, 10), (LpCore, 11)));
969 };
970}
971#[macro_export]
972#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
973macro_rules! for_each_dma_engine {
974 ($($pattern:tt => $code:tt;)*) => {
975 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
976 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
977 _for_each_inner_dma_engine!((all("AHB_GDMA")));
978 };
979}
980#[macro_export]
981#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
982macro_rules! for_each_dma_channel {
983 ($($pattern:tt => $code:tt;)*) => {
984 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
985 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
986 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
987 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
988 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
989 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
990 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
991 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1,
992 interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI2,
993 UHCI0, I2S0, AES, SHA, APB_SARADC, PARL_IO]));
994 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
995 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
996 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
997 ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2)));
998 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
999 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
1000 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
1001 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES,
1002 SHA, APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
1003 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1004 APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
1005 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
1006 APB_SARADC, PARL_IO]))); _for_each_inner_dma_channel!((no_own_interrupt));
1007 };
1008}
1009#[macro_export]
1010#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1011macro_rules! for_each_dma_channel_peri_pair {
1012 ($($pattern:tt => $code:tt;)*) => {
1013 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
1014 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1015 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
1016 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
1017 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
1018 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
1019 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
1020 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
1021 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
1022 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
1023 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
1024 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
1025 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
1026 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
1027 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
1028 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
1029 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
1030 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
1031 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
1032 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
1033 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
1034 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
1035 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1036 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1037 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1038 any_channel = AhbGdmaChannel, I2S0));
1039 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1040 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1041 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1042 any_channel = AhbGdmaChannel, APB_SARADC));
1043 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1044 PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
1045 SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA",
1046 DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC),
1047 ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI2), ("AHB_GDMA",
1048 DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, AES),
1049 ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1, APB_SARADC), ("AHB_GDMA",
1050 DMA_CH1, PARL_IO), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
1051 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
1052 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC), ("AHB_GDMA", DMA_CH2, PARL_IO)));
1053 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1054 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
1055 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
1056 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
1057 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC), ("AHB_GDMA", any_channel
1058 = AhbGdmaChannel, PARL_IO)));
1059 };
1060}
1061#[macro_export]
1062#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1063macro_rules! for_each_mem2mem_channel {
1064 ($($pattern:tt => $code:tt;)*) => {
1065 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1066 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1067 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1068 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
1069 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
1070 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1071 4, 1, 5, 2, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1072 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1073 AhbGdmaChannel, DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5),
1074 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 10)));
1075 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1076 4, 1, 5, 2, 10))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1077 AhbGdmaChannel)));
1078 };
1079}
1080#[macro_export]
1081#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1082macro_rules! with_aes_dma_engine {
1083 ($($pattern:tt => $code:tt;)*) => {
1084 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1085 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1086 };
1087}
1088#[macro_export]
1089#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1090macro_rules! with_i2s_dma_engine {
1091 ($($pattern:tt => $code:tt;)*) => {
1092 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1093 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1094 };
1095}
1096#[macro_export]
1097#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1098macro_rules! with_parl_io_dma_engine {
1099 ($($pattern:tt => $code:tt;)*) => {
1100 macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
1101 tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1102 };
1103}
1104#[macro_export]
1105#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1106macro_rules! with_sha_dma_engine {
1107 ($($pattern:tt => $code:tt;)*) => {
1108 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1109 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1110 };
1111}
1112#[macro_export]
1113#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1114macro_rules! with_spi_master_dma_engine {
1115 ($($pattern:tt => $code:tt;)*) => {
1116 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1117 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1118 };
1119}
1120#[macro_export]
1121#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1122macro_rules! with_spi_slave_dma_engine {
1123 ($($pattern:tt => $code:tt;)*) => {
1124 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1125 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1126 };
1127}
1128#[macro_export]
1129#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1130macro_rules! with_uhci_dma_engine {
1131 ($($pattern:tt => $code:tt;)*) => {
1132 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1133 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1134 };
1135}
1136#[macro_export]
1137#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1138macro_rules! for_each_interrupt {
1139 ($($pattern:tt => $code:tt;)*) => {
1140 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1141 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
1142 _for_each_inner_interrupt!(([reserved 0] 1));
1143 _for_each_inner_interrupt!(([reserved 1] 2));
1144 _for_each_inner_interrupt!(([reserved 2] 3));
1145 _for_each_inner_interrupt!(([reserved 3] 4));
1146 _for_each_inner_interrupt!(([reserved 4] 5));
1147 _for_each_inner_interrupt!(([reserved 5] 6));
1148 _for_each_inner_interrupt!(([reserved 6] 7));
1149 _for_each_inner_interrupt!(([reserved 7] 8));
1150 _for_each_inner_interrupt!(([reserved 8] 9));
1151 _for_each_inner_interrupt!(([reserved 9] 10));
1152 _for_each_inner_interrupt!(([reserved 10] 11));
1153 _for_each_inner_interrupt!(([reserved 11] 12));
1154 _for_each_inner_interrupt!(([reserved 12] 13));
1155 _for_each_inner_interrupt!(([reserved 13] 14));
1156 _for_each_inner_interrupt!(([reserved 14] 15));
1157 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1158 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1159 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1160 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1161 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1162 7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
1163 _for_each_inner_interrupt!(([direct_bindable 1] 25));
1164 _for_each_inner_interrupt!(([direct_bindable 2] 26));
1165 _for_each_inner_interrupt!(([direct_bindable 3] 27));
1166 _for_each_inner_interrupt!(([direct_bindable 4] 28));
1167 _for_each_inner_interrupt!(([direct_bindable 5] 29));
1168 _for_each_inner_interrupt!(([direct_bindable 6] 30));
1169 _for_each_inner_interrupt!(([direct_bindable 7] 31));
1170 _for_each_inner_interrupt!(([direct_bindable 8] 32));
1171 _for_each_inner_interrupt!(([direct_bindable 9] 33));
1172 _for_each_inner_interrupt!(([direct_bindable 10] 34));
1173 _for_each_inner_interrupt!(([direct_bindable 11] 35));
1174 _for_each_inner_interrupt!(([direct_bindable 12] 36));
1175 _for_each_inner_interrupt!(([direct_bindable 13] 37));
1176 _for_each_inner_interrupt!(([direct_bindable 14] 38));
1177 _for_each_inner_interrupt!(([direct_bindable 15] 39));
1178 _for_each_inner_interrupt!(([direct_bindable 16] 40));
1179 _for_each_inner_interrupt!(([direct_bindable 17] 41));
1180 _for_each_inner_interrupt!(([direct_bindable 18] 42));
1181 _for_each_inner_interrupt!(([direct_bindable 19] 43));
1182 _for_each_inner_interrupt!(([direct_bindable 20] 44));
1183 _for_each_inner_interrupt!(([direct_bindable 21] 45));
1184 _for_each_inner_interrupt!(([direct_bindable 22] 46));
1185 _for_each_inner_interrupt!(([direct_bindable 23] 47));
1186 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
1187 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
1188 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
1189 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
1190 ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
1191 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
1192 ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
1193 ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
1194 ([direct_bindable 6] 30), ([direct_bindable 7] 31), ([direct_bindable 8] 32),
1195 ([direct_bindable 9] 33), ([direct_bindable 10] 34), ([direct_bindable 11] 35),
1196 ([direct_bindable 12] 36), ([direct_bindable 13] 37), ([direct_bindable 14] 38),
1197 ([direct_bindable 15] 39), ([direct_bindable 16] 40), ([direct_bindable 17] 41),
1198 ([direct_bindable 18] 42), ([direct_bindable 19] 43), ([direct_bindable 20] 44),
1199 ([direct_bindable 21] 45), ([direct_bindable 22] 46), ([direct_bindable 23]
1200 47)));
1201 };
1202}
1203#[macro_export]
1204#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1205macro_rules! for_each_classified_interrupt {
1206 ($($pattern:tt => $code:tt;)*) => {
1207 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1208 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1209 24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
1210 _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
1211 _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
1212 _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
1213 _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
1214 _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
1215 _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
1216 _for_each_inner_classified_interrupt!(([direct_bindable 8] 32));
1217 _for_each_inner_classified_interrupt!(([direct_bindable 9] 33));
1218 _for_each_inner_classified_interrupt!(([direct_bindable 10] 34));
1219 _for_each_inner_classified_interrupt!(([direct_bindable 11] 35));
1220 _for_each_inner_classified_interrupt!(([direct_bindable 12] 36));
1221 _for_each_inner_classified_interrupt!(([direct_bindable 13] 37));
1222 _for_each_inner_classified_interrupt!(([direct_bindable 14] 38));
1223 _for_each_inner_classified_interrupt!(([direct_bindable 15] 39));
1224 _for_each_inner_classified_interrupt!(([direct_bindable 16] 40));
1225 _for_each_inner_classified_interrupt!(([direct_bindable 17] 41));
1226 _for_each_inner_classified_interrupt!(([direct_bindable 18] 42));
1227 _for_each_inner_classified_interrupt!(([direct_bindable 19] 43));
1228 _for_each_inner_classified_interrupt!(([direct_bindable 20] 44));
1229 _for_each_inner_classified_interrupt!(([direct_bindable 21] 45));
1230 _for_each_inner_classified_interrupt!(([direct_bindable 22] 46));
1231 _for_each_inner_classified_interrupt!(([direct_bindable 23] 47));
1232 _for_each_inner_classified_interrupt!(([vector 0] 16));
1233 _for_each_inner_classified_interrupt!(([vector 1] 17));
1234 _for_each_inner_classified_interrupt!(([vector 2] 18));
1235 _for_each_inner_classified_interrupt!(([vector 3] 19));
1236 _for_each_inner_classified_interrupt!(([vector 4] 20));
1237 _for_each_inner_classified_interrupt!(([vector 5] 21));
1238 _for_each_inner_classified_interrupt!(([vector 6] 22));
1239 _for_each_inner_classified_interrupt!(([vector 7] 23));
1240 _for_each_inner_classified_interrupt!(([reserved 0] 1));
1241 _for_each_inner_classified_interrupt!(([reserved 1] 2));
1242 _for_each_inner_classified_interrupt!(([reserved 2] 3));
1243 _for_each_inner_classified_interrupt!(([reserved 3] 4));
1244 _for_each_inner_classified_interrupt!(([reserved 4] 5));
1245 _for_each_inner_classified_interrupt!(([reserved 5] 6));
1246 _for_each_inner_classified_interrupt!(([reserved 6] 7));
1247 _for_each_inner_classified_interrupt!(([reserved 7] 8));
1248 _for_each_inner_classified_interrupt!(([reserved 8] 9));
1249 _for_each_inner_classified_interrupt!(([reserved 9] 10));
1250 _for_each_inner_classified_interrupt!(([reserved 10] 11));
1251 _for_each_inner_classified_interrupt!(([reserved 11] 12));
1252 _for_each_inner_classified_interrupt!(([reserved 12] 13));
1253 _for_each_inner_classified_interrupt!(([reserved 13] 14));
1254 _for_each_inner_classified_interrupt!(([reserved 14] 15));
1255 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
1256 ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
1257 ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
1258 ([direct_bindable 7] 31), ([direct_bindable 8] 32), ([direct_bindable 9] 33),
1259 ([direct_bindable 10] 34), ([direct_bindable 11] 35), ([direct_bindable 12] 36),
1260 ([direct_bindable 13] 37), ([direct_bindable 14] 38), ([direct_bindable 15] 39),
1261 ([direct_bindable 16] 40), ([direct_bindable 17] 41), ([direct_bindable 18] 42),
1262 ([direct_bindable 19] 43), ([direct_bindable 20] 44), ([direct_bindable 21] 45),
1263 ([direct_bindable 22] 46), ([direct_bindable 23] 47)));
1264 _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1265 ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1266 22), ([vector 7] 23))); _for_each_inner_classified_interrupt!((reserved([reserved
1267 0] 1), ([reserved 1] 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5),
1268 ([reserved 5] 6), ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9),
1269 ([reserved 9] 10), ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13),
1270 ([reserved 13] 14), ([reserved 14] 15)));
1271 };
1272}
1273#[macro_export]
1274#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1275macro_rules! for_each_interrupt_priority {
1276 ($($pattern:tt => $code:tt;)*) => {
1277 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1278 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1279 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1280 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1281 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1282 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1283 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1284 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1285 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1286 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1287 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1288 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1289 Priority8, Level8)));
1290 };
1291}
1292#[macro_export]
1293#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1294macro_rules! for_each_sw_interrupt {
1295 ($($pattern:tt => $code:tt;)*) => {
1296 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1297 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1298 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1299 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1300 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1301 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1302 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1303 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1304 };
1305}
1306#[macro_export]
1307macro_rules! define_clock_tree_types {
1682 () => {
1683 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1684 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1685 pub enum SdmInstance {
1686 GpioSd = 0,
1687 }
1688 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1689 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1690 pub enum I2cInstance {
1691 I2c0 = 0,
1692 }
1693 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1694 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1695 pub enum ParlIoInstance {
1696 ParlIo = 0,
1697 }
1698 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1699 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1700 pub enum RmtInstance {
1701 Rmt = 0,
1702 }
1703 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1704 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1705 pub enum SpiInstance {
1706 Spi2 = 0,
1707 }
1708 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1709 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1710 pub enum TimgInstance {
1711 Timg0 = 0,
1712 Timg1 = 1,
1713 }
1714 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1715 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1716 pub enum UartInstance {
1717 Uart0 = 0,
1718 Uart1 = 1,
1719 }
1720 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1722 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1723 pub enum XtalClkConfig {
1724 _40,
1726 _48,
1728 }
1729 impl XtalClkConfig {
1730 pub fn value(&self) -> u32 {
1731 match self {
1732 XtalClkConfig::_40 => 40000000,
1733 XtalClkConfig::_48 => 48000000,
1734 }
1735 }
1736 }
1737 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1739 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1740 pub enum HpRootClkConfig {
1741 Xtal,
1743 RcFast,
1745 PllF160m,
1747 PllF240m,
1749 }
1750 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1754 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1755 pub struct CpuClkConfig {
1756 divisor: u32,
1757 }
1758 impl CpuClkConfig {
1759 pub const fn new(divisor: u32) -> Self {
1766 ::core::assert!(
1767 divisor <= 255,
1768 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1769 );
1770 Self { divisor }
1771 }
1772 pub(crate) fn divisor(self) -> u32 {
1773 self.divisor as u32
1774 }
1775 }
1776 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1780 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1781 pub struct AhbClkConfig {
1782 divisor: u32,
1783 }
1784 impl AhbClkConfig {
1785 pub const fn new(divisor: u32) -> Self {
1792 ::core::assert!(
1793 divisor <= 255,
1794 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1795 );
1796 Self { divisor }
1797 }
1798 pub(crate) fn divisor(self) -> u32 {
1799 self.divisor as u32
1800 }
1801 }
1802 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1806 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1807 pub struct ApbClkConfig {
1808 divisor: u32,
1809 }
1810 impl ApbClkConfig {
1811 pub const fn new(divisor: u32) -> Self {
1818 ::core::assert!(
1819 divisor <= 255,
1820 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1821 );
1822 Self { divisor }
1823 }
1824 pub(crate) fn divisor(self) -> u32 {
1825 self.divisor as u32
1826 }
1827 }
1828 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1830 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1831 pub enum LpFastClkConfig {
1832 RcFast,
1834 XtalD2,
1836 Xtal,
1838 }
1839 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1841 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1842 pub enum LpSlowClkConfig {
1843 RcSlow,
1845 #[cfg(use_xtal32k)]
1846 Xtal32k,
1848 OscSlow,
1850 }
1851 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1853 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1854 pub enum CryptoClkConfig {
1855 Xtal,
1857 Fosc,
1859 PllF480m,
1861 }
1862 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1864 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1865 pub enum IomuxFunctionClockConfig {
1866 XtalClk,
1868 RcFastClk,
1870 #[default]
1871 PllF80m,
1873 }
1874 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1876 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1877 pub enum TimgCalibrationClockConfig {
1878 OscSlowClk,
1880 RcSlowClk,
1882 RcFastDivClk,
1884 #[cfg(use_xtal32k)]
1885 Xtal32kClk,
1887 }
1888 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1889 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1890 pub enum I2cFunctionClockSclk {
1891 #[default]
1892 Xtal,
1894 RcFast,
1896 }
1897 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1901 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1902 pub struct I2cFunctionClockConfig {
1903 sclk: I2cFunctionClockSclk,
1904 div_num: u32,
1905 }
1906 impl I2cFunctionClockConfig {
1907 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1914 ::core::assert!(
1915 div_num <= 255,
1916 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1917 );
1918 Self { sclk, div_num }
1919 }
1920 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1921 self.sclk
1922 }
1923 pub(crate) fn div_num(self) -> u32 {
1924 self.div_num as u32
1925 }
1926 }
1927 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1929 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1930 pub enum ParlIoRxClockConfig {
1931 XtalClk,
1933 RcFastClk,
1935 #[default]
1936 PllF240m,
1938 }
1939 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1941 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1942 pub enum ParlIoTxClockConfig {
1943 XtalClk,
1945 RcFastClk,
1947 #[default]
1948 PllF240m,
1950 }
1951 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1953 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1954 pub enum RmtSclkConfig {
1955 XtalClk,
1957 RcFastClk,
1959 #[default]
1960 PllF80m,
1962 }
1963 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1965 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1966 pub enum SpiFunctionClockConfig {
1967 Xtal,
1969 #[default]
1970 PllF160m,
1972 PllF120m,
1974 RcFast,
1976 }
1977 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1979 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1980 pub enum TimgFunctionClockConfig {
1981 #[default]
1982 XtalClk,
1984 RcFastClk,
1986 PllF80m,
1988 }
1989 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1991 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1992 pub enum TimgWdtClockConfig {
1993 #[default]
1994 XtalClk,
1996 PllF80m,
1998 RcFastClk,
2000 }
2001 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
2002 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2003 pub enum UartFunctionClockSclk {
2004 #[default]
2005 Xtal,
2007 PllF80m,
2009 RcFast,
2011 }
2012 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2016 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2017 pub struct UartFunctionClockConfig {
2018 sclk: UartFunctionClockSclk,
2019 div_num: u32,
2020 }
2021 impl UartFunctionClockConfig {
2022 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
2029 ::core::assert!(
2030 div_num <= 255,
2031 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
2032 );
2033 Self { sclk, div_num }
2034 }
2035 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
2036 self.sclk
2037 }
2038 pub(crate) fn div_num(self) -> u32 {
2039 self.div_num as u32
2040 }
2041 }
2042 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2047 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2048 pub struct UartBaudRateGeneratorConfig {
2049 fractional: u32,
2050 integral: u32,
2051 }
2052 impl UartBaudRateGeneratorConfig {
2053 pub const fn new(fractional: u32, integral: u32) -> Self {
2063 ::core::assert!(
2064 fractional <= 15,
2065 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
2066 );
2067 ::core::assert!(
2068 integral <= 4095,
2069 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
2070 );
2071 Self {
2072 fractional,
2073 integral,
2074 }
2075 }
2076 pub(crate) fn fractional(self) -> u32 {
2077 self.fractional as u32
2078 }
2079 pub(crate) fn integral(self) -> u32 {
2080 self.integral as u32
2081 }
2082 }
2083 pub struct ClockTree {
2085 xtal_clk: Option<XtalClkConfig>,
2086 hp_root_clk: Option<HpRootClkConfig>,
2087 cpu_clk: Option<CpuClkConfig>,
2088 ahb_clk: Option<AhbClkConfig>,
2089 apb_clk: Option<ApbClkConfig>,
2090 lp_fast_clk: Option<LpFastClkConfig>,
2091 lp_slow_clk: Option<LpSlowClkConfig>,
2092 crypto_clk: Option<CryptoClkConfig>,
2093 iomux_function_clock: Option<IomuxFunctionClockConfig>,
2094 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2095 i2c_function_clock: [Option<I2cFunctionClockConfig>; 1],
2096 parl_io_rx_clock: [Option<ParlIoRxClockConfig>; 1],
2097 parl_io_tx_clock: [Option<ParlIoTxClockConfig>; 1],
2098 rmt_sclk: [Option<RmtSclkConfig>; 1],
2099 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
2100 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
2101 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
2102 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
2103 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
2104 pll_clk_refcount: u32,
2105 rc_fast_clk_refcount: u32,
2106 #[cfg(use_xtal32k)]
2107 xtal32k_clk_refcount: u32,
2108 osc_slow_clk_refcount: u32,
2109 rc_slow_clk_refcount: u32,
2110 pll_f12m_refcount: u32,
2111 pll_f20m_refcount: u32,
2112 pll_f40m_refcount: u32,
2113 pll_f48m_refcount: u32,
2114 pll_f60m_refcount: u32,
2115 pll_f80m_refcount: u32,
2116 pll_f160m_refcount: u32,
2117 pll_f240m_refcount: u32,
2118 hp_root_clk_refcount: u32,
2119 cpu_clk_refcount: u32,
2120 apb_clk_refcount: u32,
2121 lp_fast_clk_refcount: u32,
2122 lp_slow_clk_refcount: u32,
2123 crypto_clk_refcount: u32,
2124 timg_calibration_clock_refcount: u32,
2125 sdm_function_clock_refcount: [u32; 1],
2126 i2c_function_clock_refcount: [u32; 1],
2127 parl_io_rx_clock_refcount: [u32; 1],
2128 parl_io_tx_clock_refcount: [u32; 1],
2129 rmt_sclk_refcount: [u32; 1],
2130 spi_function_clock_refcount: [u32; 1],
2131 timg_function_clock_refcount: [u32; 2],
2132 timg_wdt_clock_refcount: [u32; 2],
2133 uart_function_clock_refcount: [u32; 2],
2134 uart_baud_rate_generator_refcount: [u32; 2],
2135 }
2136 impl ClockTree {
2137 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2139 CLOCK_TREE.with(f)
2140 }
2141 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2143 self.xtal_clk
2144 }
2145 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
2147 self.hp_root_clk
2148 }
2149 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2151 self.cpu_clk
2152 }
2153 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
2155 self.ahb_clk
2156 }
2157 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2159 self.apb_clk
2160 }
2161 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2163 self.lp_fast_clk
2164 }
2165 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2167 self.lp_slow_clk
2168 }
2169 pub fn crypto_clk(&self) -> Option<CryptoClkConfig> {
2171 self.crypto_clk
2172 }
2173 pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2175 self.iomux_function_clock
2176 }
2177 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2179 self.timg_calibration_clock
2180 }
2181 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2183 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2184 }
2185 pub fn parl_io_rx_clock(&self) -> Option<ParlIoRxClockConfig> {
2187 self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
2188 }
2189 pub fn parl_io_tx_clock(&self) -> Option<ParlIoTxClockConfig> {
2191 self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
2192 }
2193 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2195 self.rmt_sclk[RmtInstance::Rmt as usize]
2196 }
2197 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2199 self.spi_function_clock[SpiInstance::Spi2 as usize]
2200 }
2201 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2203 self.timg_function_clock[TimgInstance::Timg0 as usize]
2204 }
2205 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2207 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2208 }
2209 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2211 self.timg_function_clock[TimgInstance::Timg1 as usize]
2212 }
2213 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2215 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2216 }
2217 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2219 self.uart_function_clock[UartInstance::Uart0 as usize]
2220 }
2221 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2223 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2224 }
2225 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2227 self.uart_function_clock[UartInstance::Uart1 as usize]
2228 }
2229 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2231 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2232 }
2233 }
2234 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2235 ::esp_sync::NonReentrantMutex::new(ClockTree {
2236 xtal_clk: None,
2237 hp_root_clk: None,
2238 cpu_clk: None,
2239 ahb_clk: None,
2240 apb_clk: None,
2241 lp_fast_clk: None,
2242 lp_slow_clk: None,
2243 crypto_clk: None,
2244 iomux_function_clock: None,
2245 timg_calibration_clock: None,
2246 i2c_function_clock: [None; 1],
2247 parl_io_rx_clock: [None; 1],
2248 parl_io_tx_clock: [None; 1],
2249 rmt_sclk: [None; 1],
2250 spi_function_clock: [None; 1],
2251 timg_function_clock: [None; 2],
2252 timg_wdt_clock: [None; 2],
2253 uart_function_clock: [None; 2],
2254 uart_baud_rate_generator: [None; 2],
2255 pll_clk_refcount: 0,
2256 rc_fast_clk_refcount: 0,
2257 #[cfg(use_xtal32k)]
2258 xtal32k_clk_refcount: 0,
2259 osc_slow_clk_refcount: 0,
2260 rc_slow_clk_refcount: 0,
2261 pll_f12m_refcount: 0,
2262 pll_f20m_refcount: 0,
2263 pll_f40m_refcount: 0,
2264 pll_f48m_refcount: 0,
2265 pll_f60m_refcount: 0,
2266 pll_f80m_refcount: 0,
2267 pll_f160m_refcount: 0,
2268 pll_f240m_refcount: 0,
2269 hp_root_clk_refcount: 0,
2270 cpu_clk_refcount: 0,
2271 apb_clk_refcount: 0,
2272 lp_fast_clk_refcount: 0,
2273 lp_slow_clk_refcount: 0,
2274 crypto_clk_refcount: 0,
2275 timg_calibration_clock_refcount: 0,
2276 sdm_function_clock_refcount: [0; 1],
2277 i2c_function_clock_refcount: [0; 1],
2278 parl_io_rx_clock_refcount: [0; 1],
2279 parl_io_tx_clock_refcount: [0; 1],
2280 rmt_sclk_refcount: [0; 1],
2281 spi_function_clock_refcount: [0; 1],
2282 timg_function_clock_refcount: [0; 2],
2283 timg_wdt_clock_refcount: [0; 2],
2284 uart_function_clock_refcount: [0; 2],
2285 uart_baud_rate_generator_refcount: [0; 2],
2286 });
2287 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2288 ::core::sync::atomic::AtomicU32::new(0);
2289 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2290 ::core::sync::atomic::AtomicU32::new(0);
2291 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2292 ::core::sync::atomic::AtomicU32::new(0);
2293 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2294 ::core::sync::atomic::AtomicU32::new(0);
2295 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2296 ::core::sync::atomic::AtomicU32::new(0);
2297 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2298 ::core::sync::atomic::AtomicU32::new(0);
2299 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2300 ::core::sync::atomic::AtomicU32::new(0);
2301 static CRYPTO_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2302 ::core::sync::atomic::AtomicU32::new(0);
2303 static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2304 ::core::sync::atomic::AtomicU32::new(0);
2305 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2306 ::core::sync::atomic::AtomicU32::new(0);
2307 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2308 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2309 static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2310 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2311 static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2312 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2313 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2314 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2315 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2316 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2317 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2318 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2319 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2320 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2321 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2322 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2323 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2324 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2325 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2326 let old_config = clocks.xtal_clk.replace(config);
2327 refresh_xtal_clk_downstream(clocks);
2328 configure_xtal_clk_impl(clocks, old_config, config);
2329 }
2330 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2331 clocks.xtal_clk
2332 }
2333 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2334 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2335 #[allow(unused_variables)]
2336 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
2337 config.value()
2338 }
2339 pub fn xtal_clk_frequency() -> u32 {
2340 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2341 }
2342 pub fn request_pll_clk(clocks: &mut ClockTree) {
2343 trace!("Requesting PLL_CLK");
2344 if increment_reference_count(&mut clocks.pll_clk_refcount) {
2345 trace!("Enabling PLL_CLK");
2346 request_xtal_clk(clocks);
2347 enable_pll_clk_impl(clocks, true);
2348 }
2349 }
2350 pub fn release_pll_clk(clocks: &mut ClockTree) {
2351 trace!("Releasing PLL_CLK");
2352 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
2353 trace!("Disabling PLL_CLK");
2354 enable_pll_clk_impl(clocks, false);
2355 release_xtal_clk(clocks);
2356 }
2357 }
2358 pub fn pll_clk_frequency() -> u32 {
2359 480000000
2360 }
2361 pub fn pll_clk_source_frequency() -> u32 {
2362 xtal_clk_frequency()
2363 }
2364 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2365 trace!("Requesting RC_FAST_CLK");
2366 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2367 trace!("Enabling RC_FAST_CLK");
2368 enable_rc_fast_clk_impl(clocks, true);
2369 }
2370 }
2371 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2372 trace!("Releasing RC_FAST_CLK");
2373 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2374 trace!("Disabling RC_FAST_CLK");
2375 enable_rc_fast_clk_impl(clocks, false);
2376 }
2377 }
2378 pub fn rc_fast_clk_frequency() -> u32 {
2379 20000000
2380 }
2381 #[cfg(use_xtal32k)]
2382 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2383 trace!("Requesting XTAL32K_CLK");
2384 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2385 trace!("Enabling XTAL32K_CLK");
2386 enable_xtal32k_clk_impl(clocks, true);
2387 }
2388 }
2389 #[cfg(use_xtal32k)]
2390 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2391 trace!("Releasing XTAL32K_CLK");
2392 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2393 trace!("Disabling XTAL32K_CLK");
2394 enable_xtal32k_clk_impl(clocks, false);
2395 }
2396 }
2397 #[cfg(use_xtal32k)]
2398 pub fn xtal32k_clk_frequency() -> u32 {
2399 32768
2400 }
2401 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2402 trace!("Requesting OSC_SLOW_CLK");
2403 if increment_reference_count(&mut clocks.osc_slow_clk_refcount) {
2404 trace!("Enabling OSC_SLOW_CLK");
2405 enable_osc_slow_clk_impl(clocks, true);
2406 }
2407 }
2408 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2409 trace!("Releasing OSC_SLOW_CLK");
2410 if decrement_reference_count(&mut clocks.osc_slow_clk_refcount) {
2411 trace!("Disabling OSC_SLOW_CLK");
2412 enable_osc_slow_clk_impl(clocks, false);
2413 }
2414 }
2415 pub fn osc_slow_clk_frequency() -> u32 {
2416 32768
2417 }
2418 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2419 trace!("Requesting RC_SLOW_CLK");
2420 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
2421 trace!("Enabling RC_SLOW_CLK");
2422 enable_rc_slow_clk_impl(clocks, true);
2423 }
2424 }
2425 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2426 trace!("Releasing RC_SLOW_CLK");
2427 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
2428 trace!("Disabling RC_SLOW_CLK");
2429 enable_rc_slow_clk_impl(clocks, false);
2430 }
2431 }
2432 pub fn rc_slow_clk_frequency() -> u32 {
2433 130000
2434 }
2435 pub fn request_pll_f12m(clocks: &mut ClockTree) {
2436 trace!("Requesting PLL_F12M");
2437 if increment_reference_count(&mut clocks.pll_f12m_refcount) {
2438 trace!("Enabling PLL_F12M");
2439 request_pll_clk(clocks);
2440 enable_pll_f12m_impl(clocks, true);
2441 }
2442 }
2443 pub fn release_pll_f12m(clocks: &mut ClockTree) {
2444 trace!("Releasing PLL_F12M");
2445 if decrement_reference_count(&mut clocks.pll_f12m_refcount) {
2446 trace!("Disabling PLL_F12M");
2447 enable_pll_f12m_impl(clocks, false);
2448 release_pll_clk(clocks);
2449 }
2450 }
2451 pub fn pll_f12m_frequency() -> u32 {
2452 (pll_clk_frequency() / 40)
2453 }
2454 pub fn pll_f12m_source_frequency() -> u32 {
2455 pll_clk_frequency()
2456 }
2457 pub fn request_pll_f20m(clocks: &mut ClockTree) {
2458 trace!("Requesting PLL_F20M");
2459 if increment_reference_count(&mut clocks.pll_f20m_refcount) {
2460 trace!("Enabling PLL_F20M");
2461 request_pll_clk(clocks);
2462 enable_pll_f20m_impl(clocks, true);
2463 }
2464 }
2465 pub fn release_pll_f20m(clocks: &mut ClockTree) {
2466 trace!("Releasing PLL_F20M");
2467 if decrement_reference_count(&mut clocks.pll_f20m_refcount) {
2468 trace!("Disabling PLL_F20M");
2469 enable_pll_f20m_impl(clocks, false);
2470 release_pll_clk(clocks);
2471 }
2472 }
2473 pub fn pll_f20m_frequency() -> u32 {
2474 (pll_clk_frequency() / 24)
2475 }
2476 pub fn pll_f20m_source_frequency() -> u32 {
2477 pll_clk_frequency()
2478 }
2479 pub fn request_pll_f40m(clocks: &mut ClockTree) {
2480 trace!("Requesting PLL_F40M");
2481 if increment_reference_count(&mut clocks.pll_f40m_refcount) {
2482 trace!("Enabling PLL_F40M");
2483 request_pll_clk(clocks);
2484 enable_pll_f40m_impl(clocks, true);
2485 }
2486 }
2487 pub fn release_pll_f40m(clocks: &mut ClockTree) {
2488 trace!("Releasing PLL_F40M");
2489 if decrement_reference_count(&mut clocks.pll_f40m_refcount) {
2490 trace!("Disabling PLL_F40M");
2491 enable_pll_f40m_impl(clocks, false);
2492 release_pll_clk(clocks);
2493 }
2494 }
2495 pub fn pll_f40m_frequency() -> u32 {
2496 (pll_clk_frequency() / 12)
2497 }
2498 pub fn pll_f40m_source_frequency() -> u32 {
2499 pll_clk_frequency()
2500 }
2501 pub fn request_pll_f48m(clocks: &mut ClockTree) {
2502 trace!("Requesting PLL_F48M");
2503 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
2504 trace!("Enabling PLL_F48M");
2505 request_pll_clk(clocks);
2506 enable_pll_f48m_impl(clocks, true);
2507 }
2508 }
2509 pub fn release_pll_f48m(clocks: &mut ClockTree) {
2510 trace!("Releasing PLL_F48M");
2511 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
2512 trace!("Disabling PLL_F48M");
2513 enable_pll_f48m_impl(clocks, false);
2514 release_pll_clk(clocks);
2515 }
2516 }
2517 pub fn pll_f48m_frequency() -> u32 {
2518 (pll_clk_frequency() / 10)
2519 }
2520 pub fn pll_f48m_source_frequency() -> u32 {
2521 pll_clk_frequency()
2522 }
2523 pub fn request_pll_f60m(clocks: &mut ClockTree) {
2524 trace!("Requesting PLL_F60M");
2525 if increment_reference_count(&mut clocks.pll_f60m_refcount) {
2526 trace!("Enabling PLL_F60M");
2527 request_pll_clk(clocks);
2528 enable_pll_f60m_impl(clocks, true);
2529 }
2530 }
2531 pub fn release_pll_f60m(clocks: &mut ClockTree) {
2532 trace!("Releasing PLL_F60M");
2533 if decrement_reference_count(&mut clocks.pll_f60m_refcount) {
2534 trace!("Disabling PLL_F60M");
2535 enable_pll_f60m_impl(clocks, false);
2536 release_pll_clk(clocks);
2537 }
2538 }
2539 pub fn pll_f60m_frequency() -> u32 {
2540 (pll_clk_frequency() / 8)
2541 }
2542 pub fn pll_f60m_source_frequency() -> u32 {
2543 pll_clk_frequency()
2544 }
2545 pub fn request_pll_f80m(clocks: &mut ClockTree) {
2546 trace!("Requesting PLL_F80M");
2547 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
2548 trace!("Enabling PLL_F80M");
2549 request_pll_clk(clocks);
2550 enable_pll_f80m_impl(clocks, true);
2551 }
2552 }
2553 pub fn release_pll_f80m(clocks: &mut ClockTree) {
2554 trace!("Releasing PLL_F80M");
2555 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
2556 trace!("Disabling PLL_F80M");
2557 enable_pll_f80m_impl(clocks, false);
2558 release_pll_clk(clocks);
2559 }
2560 }
2561 pub fn pll_f80m_frequency() -> u32 {
2562 (pll_clk_frequency() / 6)
2563 }
2564 pub fn pll_f80m_source_frequency() -> u32 {
2565 pll_clk_frequency()
2566 }
2567 pub fn request_pll_f120m(clocks: &mut ClockTree) {
2568 trace!("Requesting PLL_F120M");
2569 trace!("Enabling PLL_F120M");
2570 request_pll_clk(clocks);
2571 enable_pll_f120m_impl(clocks, true);
2572 }
2573 pub fn release_pll_f120m(clocks: &mut ClockTree) {
2574 trace!("Releasing PLL_F120M");
2575 trace!("Disabling PLL_F120M");
2576 enable_pll_f120m_impl(clocks, false);
2577 release_pll_clk(clocks);
2578 }
2579 pub fn pll_f120m_frequency() -> u32 {
2580 (pll_clk_frequency() / 4)
2581 }
2582 pub fn pll_f120m_source_frequency() -> u32 {
2583 pll_clk_frequency()
2584 }
2585 pub fn request_pll_f160m(clocks: &mut ClockTree) {
2586 trace!("Requesting PLL_F160M");
2587 if increment_reference_count(&mut clocks.pll_f160m_refcount) {
2588 trace!("Enabling PLL_F160M");
2589 request_pll_clk(clocks);
2590 enable_pll_f160m_impl(clocks, true);
2591 }
2592 }
2593 pub fn release_pll_f160m(clocks: &mut ClockTree) {
2594 trace!("Releasing PLL_F160M");
2595 if decrement_reference_count(&mut clocks.pll_f160m_refcount) {
2596 trace!("Disabling PLL_F160M");
2597 enable_pll_f160m_impl(clocks, false);
2598 release_pll_clk(clocks);
2599 }
2600 }
2601 pub fn pll_f160m_frequency() -> u32 {
2602 (pll_clk_frequency() / 3)
2603 }
2604 pub fn pll_f160m_source_frequency() -> u32 {
2605 pll_clk_frequency()
2606 }
2607 pub fn request_pll_f240m(clocks: &mut ClockTree) {
2608 trace!("Requesting PLL_F240M");
2609 if increment_reference_count(&mut clocks.pll_f240m_refcount) {
2610 trace!("Enabling PLL_F240M");
2611 request_pll_clk(clocks);
2612 enable_pll_f240m_impl(clocks, true);
2613 }
2614 }
2615 pub fn release_pll_f240m(clocks: &mut ClockTree) {
2616 trace!("Releasing PLL_F240M");
2617 if decrement_reference_count(&mut clocks.pll_f240m_refcount) {
2618 trace!("Disabling PLL_F240M");
2619 enable_pll_f240m_impl(clocks, false);
2620 release_pll_clk(clocks);
2621 }
2622 }
2623 pub fn pll_f240m_frequency() -> u32 {
2624 (pll_clk_frequency() / 2)
2625 }
2626 pub fn pll_f240m_source_frequency() -> u32 {
2627 pll_clk_frequency()
2628 }
2629 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
2630 let old_selector = clocks.hp_root_clk.replace(new_selector);
2631 refresh_hp_root_clk_downstream(clocks);
2632 if clocks.hp_root_clk_refcount > 0 {
2633 match new_selector {
2634 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2635 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2636 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
2637 HpRootClkConfig::PllF240m => request_pll_f240m(clocks),
2638 }
2639 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2640 if let Some(old_selector) = old_selector {
2641 match old_selector {
2642 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2643 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2644 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
2645 HpRootClkConfig::PllF240m => release_pll_f240m(clocks),
2646 }
2647 }
2648 } else {
2649 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2650 }
2651 }
2652 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
2653 clocks.hp_root_clk
2654 }
2655 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
2656 trace!("Requesting HP_ROOT_CLK");
2657 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
2658 trace!("Enabling HP_ROOT_CLK");
2659 match unwrap!(clocks.hp_root_clk) {
2660 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2661 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2662 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
2663 HpRootClkConfig::PllF240m => request_pll_f240m(clocks),
2664 }
2665 enable_hp_root_clk_impl(clocks, true);
2666 }
2667 }
2668 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
2669 trace!("Releasing HP_ROOT_CLK");
2670 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
2671 trace!("Disabling HP_ROOT_CLK");
2672 enable_hp_root_clk_impl(clocks, false);
2673 match unwrap!(clocks.hp_root_clk) {
2674 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2675 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2676 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
2677 HpRootClkConfig::PllF240m => release_pll_f240m(clocks),
2678 }
2679 }
2680 }
2681 #[allow(unused_variables)]
2682 pub fn hp_root_clk_config_frequency(
2683 clocks: &mut ClockTree,
2684 config: HpRootClkConfig,
2685 ) -> u32 {
2686 match config {
2687 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2688 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2689 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
2690 HpRootClkConfig::PllF240m => pll_f240m_frequency(),
2691 }
2692 }
2693 pub fn hp_root_clk_frequency() -> u32 {
2694 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2695 }
2696 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
2697 match source {
2698 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2699 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2700 HpRootClkConfig::PllF160m => pll_f160m_frequency(),
2701 HpRootClkConfig::PllF240m => pll_f240m_frequency(),
2702 }
2703 }
2704 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
2705 let old_config = clocks.cpu_clk.replace(config);
2706 refresh_cpu_clk_downstream(clocks);
2707 configure_cpu_clk_impl(clocks, old_config, config);
2708 }
2709 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2710 clocks.cpu_clk
2711 }
2712 pub fn request_cpu_clk(clocks: &mut ClockTree) {
2713 trace!("Requesting CPU_CLK");
2714 if increment_reference_count(&mut clocks.cpu_clk_refcount) {
2715 trace!("Enabling CPU_CLK");
2716 request_hp_root_clk(clocks);
2717 enable_cpu_clk_impl(clocks, true);
2718 }
2719 }
2720 pub fn release_cpu_clk(clocks: &mut ClockTree) {
2721 trace!("Releasing CPU_CLK");
2722 if decrement_reference_count(&mut clocks.cpu_clk_refcount) {
2723 trace!("Disabling CPU_CLK");
2724 enable_cpu_clk_impl(clocks, false);
2725 release_hp_root_clk(clocks);
2726 }
2727 }
2728 #[allow(unused_variables)]
2729 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2730 (hp_root_clk_frequency() / (config.divisor() + 1))
2731 }
2732 pub fn cpu_clk_frequency() -> u32 {
2733 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2734 }
2735 pub fn cpu_clk_source_frequency() -> u32 {
2736 hp_root_clk_frequency()
2737 }
2738 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
2739 let old_config = clocks.ahb_clk.replace(config);
2740 refresh_ahb_clk_downstream(clocks);
2741 configure_ahb_clk_impl(clocks, old_config, config);
2742 }
2743 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
2744 clocks.ahb_clk
2745 }
2746 pub fn request_ahb_clk(clocks: &mut ClockTree) {
2747 trace!("Requesting AHB_CLK");
2748 trace!("Enabling AHB_CLK");
2749 request_hp_root_clk(clocks);
2750 enable_ahb_clk_impl(clocks, true);
2751 }
2752 pub fn release_ahb_clk(clocks: &mut ClockTree) {
2753 trace!("Releasing AHB_CLK");
2754 trace!("Disabling AHB_CLK");
2755 enable_ahb_clk_impl(clocks, false);
2756 release_hp_root_clk(clocks);
2757 }
2758 #[allow(unused_variables)]
2759 pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
2760 (hp_root_clk_frequency() / (config.divisor() + 1))
2761 }
2762 pub fn ahb_clk_frequency() -> u32 {
2763 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2764 }
2765 pub fn ahb_clk_source_frequency() -> u32 {
2766 hp_root_clk_frequency()
2767 }
2768 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
2769 let old_config = clocks.apb_clk.replace(config);
2770 refresh_apb_clk_downstream(clocks);
2771 configure_apb_clk_impl(clocks, old_config, config);
2772 }
2773 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2774 clocks.apb_clk
2775 }
2776 pub fn request_apb_clk(clocks: &mut ClockTree) {
2777 trace!("Requesting APB_CLK");
2778 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2779 trace!("Enabling APB_CLK");
2780 request_ahb_clk(clocks);
2781 enable_apb_clk_impl(clocks, true);
2782 }
2783 }
2784 pub fn release_apb_clk(clocks: &mut ClockTree) {
2785 trace!("Releasing APB_CLK");
2786 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2787 trace!("Disabling APB_CLK");
2788 enable_apb_clk_impl(clocks, false);
2789 release_ahb_clk(clocks);
2790 }
2791 }
2792 #[allow(unused_variables)]
2793 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2794 (ahb_clk_frequency() / (config.divisor() + 1))
2795 }
2796 pub fn apb_clk_frequency() -> u32 {
2797 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2798 }
2799 pub fn apb_clk_source_frequency() -> u32 {
2800 ahb_clk_frequency()
2801 }
2802 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
2803 trace!("Requesting XTAL_D2_CLK");
2804 trace!("Enabling XTAL_D2_CLK");
2805 request_xtal_clk(clocks);
2806 enable_xtal_d2_clk_impl(clocks, true);
2807 }
2808 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
2809 trace!("Releasing XTAL_D2_CLK");
2810 trace!("Disabling XTAL_D2_CLK");
2811 enable_xtal_d2_clk_impl(clocks, false);
2812 release_xtal_clk(clocks);
2813 }
2814 pub fn xtal_d2_clk_frequency() -> u32 {
2815 (xtal_clk_frequency() / 2)
2816 }
2817 pub fn xtal_d2_clk_source_frequency() -> u32 {
2818 xtal_clk_frequency()
2819 }
2820 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
2821 let old_selector = clocks.lp_fast_clk.replace(new_selector);
2822 refresh_lp_fast_clk_downstream(clocks);
2823 if clocks.lp_fast_clk_refcount > 0 {
2824 match new_selector {
2825 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2826 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2827 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2828 }
2829 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2830 if let Some(old_selector) = old_selector {
2831 match old_selector {
2832 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2833 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2834 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2835 }
2836 }
2837 } else {
2838 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2839 }
2840 }
2841 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
2842 clocks.lp_fast_clk
2843 }
2844 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
2845 trace!("Requesting LP_FAST_CLK");
2846 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
2847 trace!("Enabling LP_FAST_CLK");
2848 match unwrap!(clocks.lp_fast_clk) {
2849 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
2850 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
2851 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
2852 }
2853 enable_lp_fast_clk_impl(clocks, true);
2854 }
2855 }
2856 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
2857 trace!("Releasing LP_FAST_CLK");
2858 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
2859 trace!("Disabling LP_FAST_CLK");
2860 enable_lp_fast_clk_impl(clocks, false);
2861 match unwrap!(clocks.lp_fast_clk) {
2862 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
2863 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
2864 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
2865 }
2866 }
2867 }
2868 #[allow(unused_variables)]
2869 pub fn lp_fast_clk_config_frequency(
2870 clocks: &mut ClockTree,
2871 config: LpFastClkConfig,
2872 ) -> u32 {
2873 match config {
2874 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2875 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2876 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2877 }
2878 }
2879 pub fn lp_fast_clk_frequency() -> u32 {
2880 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2881 }
2882 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
2883 match source {
2884 LpFastClkConfig::RcFast => rc_fast_clk_frequency(),
2885 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(),
2886 LpFastClkConfig::Xtal => xtal_clk_frequency(),
2887 }
2888 }
2889 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
2890 let old_selector = clocks.lp_slow_clk.replace(new_selector);
2891 refresh_lp_slow_clk_downstream(clocks);
2892 if clocks.lp_slow_clk_refcount > 0 {
2893 match new_selector {
2894 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2895 #[cfg(use_xtal32k)]
2896 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2897 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2898 }
2899 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2900 if let Some(old_selector) = old_selector {
2901 match old_selector {
2902 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2903 #[cfg(use_xtal32k)]
2904 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2905 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2906 }
2907 }
2908 } else {
2909 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2910 }
2911 }
2912 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
2913 clocks.lp_slow_clk
2914 }
2915 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
2916 trace!("Requesting LP_SLOW_CLK");
2917 if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
2918 trace!("Enabling LP_SLOW_CLK");
2919 match unwrap!(clocks.lp_slow_clk) {
2920 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2921 #[cfg(use_xtal32k)]
2922 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2923 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2924 }
2925 enable_lp_slow_clk_impl(clocks, true);
2926 }
2927 }
2928 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2929 trace!("Releasing LP_SLOW_CLK");
2930 if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
2931 trace!("Disabling LP_SLOW_CLK");
2932 enable_lp_slow_clk_impl(clocks, false);
2933 match unwrap!(clocks.lp_slow_clk) {
2934 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2935 #[cfg(use_xtal32k)]
2936 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2937 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2938 }
2939 }
2940 }
2941 #[allow(unused_variables)]
2942 pub fn lp_slow_clk_config_frequency(
2943 clocks: &mut ClockTree,
2944 config: LpSlowClkConfig,
2945 ) -> u32 {
2946 match config {
2947 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2948 #[cfg(use_xtal32k)]
2949 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2950 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2951 }
2952 }
2953 pub fn lp_slow_clk_frequency() -> u32 {
2954 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2955 }
2956 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
2957 match source {
2958 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2959 #[cfg(use_xtal32k)]
2960 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2961 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2962 }
2963 }
2964 pub fn configure_crypto_clk(clocks: &mut ClockTree, new_selector: CryptoClkConfig) {
2965 let old_selector = clocks.crypto_clk.replace(new_selector);
2966 refresh_crypto_clk_downstream(clocks);
2967 if clocks.crypto_clk_refcount > 0 {
2968 match new_selector {
2969 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
2970 CryptoClkConfig::Fosc => request_rc_fast_clk(clocks),
2971 CryptoClkConfig::PllF480m => request_pll_clk(clocks),
2972 }
2973 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2974 if let Some(old_selector) = old_selector {
2975 match old_selector {
2976 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
2977 CryptoClkConfig::Fosc => release_rc_fast_clk(clocks),
2978 CryptoClkConfig::PllF480m => release_pll_clk(clocks),
2979 }
2980 }
2981 } else {
2982 configure_crypto_clk_impl(clocks, old_selector, new_selector);
2983 }
2984 }
2985 pub fn crypto_clk_config(clocks: &mut ClockTree) -> Option<CryptoClkConfig> {
2986 clocks.crypto_clk
2987 }
2988 pub fn request_crypto_clk(clocks: &mut ClockTree) {
2989 trace!("Requesting CRYPTO_CLK");
2990 if increment_reference_count(&mut clocks.crypto_clk_refcount) {
2991 trace!("Enabling CRYPTO_CLK");
2992 match unwrap!(clocks.crypto_clk) {
2993 CryptoClkConfig::Xtal => request_xtal_clk(clocks),
2994 CryptoClkConfig::Fosc => request_rc_fast_clk(clocks),
2995 CryptoClkConfig::PllF480m => request_pll_clk(clocks),
2996 }
2997 enable_crypto_clk_impl(clocks, true);
2998 }
2999 }
3000 pub fn release_crypto_clk(clocks: &mut ClockTree) {
3001 trace!("Releasing CRYPTO_CLK");
3002 if decrement_reference_count(&mut clocks.crypto_clk_refcount) {
3003 trace!("Disabling CRYPTO_CLK");
3004 enable_crypto_clk_impl(clocks, false);
3005 match unwrap!(clocks.crypto_clk) {
3006 CryptoClkConfig::Xtal => release_xtal_clk(clocks),
3007 CryptoClkConfig::Fosc => release_rc_fast_clk(clocks),
3008 CryptoClkConfig::PllF480m => release_pll_clk(clocks),
3009 }
3010 }
3011 }
3012 #[allow(unused_variables)]
3013 pub fn crypto_clk_config_frequency(clocks: &mut ClockTree, config: CryptoClkConfig) -> u32 {
3014 match config {
3015 CryptoClkConfig::Xtal => xtal_clk_frequency(),
3016 CryptoClkConfig::Fosc => rc_fast_clk_frequency(),
3017 CryptoClkConfig::PllF480m => pll_clk_frequency(),
3018 }
3019 }
3020 pub fn crypto_clk_frequency() -> u32 {
3021 CRYPTO_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3022 }
3023 pub fn crypto_clk_source_frequency(source: CryptoClkConfig) -> u32 {
3024 match source {
3025 CryptoClkConfig::Xtal => xtal_clk_frequency(),
3026 CryptoClkConfig::Fosc => rc_fast_clk_frequency(),
3027 CryptoClkConfig::PllF480m => pll_clk_frequency(),
3028 }
3029 }
3030 pub fn configure_iomux_function_clock(
3031 clocks: &mut ClockTree,
3032 new_selector: IomuxFunctionClockConfig,
3033 ) {
3034 let old_selector = clocks.iomux_function_clock.replace(new_selector);
3035 refresh_iomux_function_clock_downstream(clocks);
3036 match new_selector {
3037 IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3038 IomuxFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3039 IomuxFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3040 }
3041 configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
3042 if let Some(old_selector) = old_selector {
3043 match old_selector {
3044 IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3045 IomuxFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3046 IomuxFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3047 }
3048 }
3049 }
3050 pub fn iomux_function_clock_config(
3051 clocks: &mut ClockTree,
3052 ) -> Option<IomuxFunctionClockConfig> {
3053 clocks.iomux_function_clock
3054 }
3055 fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
3056 fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
3057 #[allow(unused_variables)]
3058 pub fn iomux_function_clock_config_frequency(
3059 clocks: &mut ClockTree,
3060 config: IomuxFunctionClockConfig,
3061 ) -> u32 {
3062 match config {
3063 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3064 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3065 IomuxFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3066 }
3067 }
3068 pub fn iomux_function_clock_frequency() -> u32 {
3069 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3070 }
3071 pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
3072 match source {
3073 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3074 IomuxFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3075 IomuxFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3076 }
3077 }
3078 pub fn configure_timg_calibration_clock(
3079 clocks: &mut ClockTree,
3080 new_selector: TimgCalibrationClockConfig,
3081 ) {
3082 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
3083 refresh_timg_calibration_clock_downstream(clocks);
3084 if clocks.timg_calibration_clock_refcount > 0 {
3085 match new_selector {
3086 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
3087 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3088 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3089 #[cfg(use_xtal32k)]
3090 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3091 }
3092 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3093 if let Some(old_selector) = old_selector {
3094 match old_selector {
3095 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
3096 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3097 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3098 #[cfg(use_xtal32k)]
3099 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3100 }
3101 }
3102 } else {
3103 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
3104 }
3105 }
3106 pub fn timg_calibration_clock_config(
3107 clocks: &mut ClockTree,
3108 ) -> Option<TimgCalibrationClockConfig> {
3109 clocks.timg_calibration_clock
3110 }
3111 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
3112 trace!("Requesting TIMG_CALIBRATION_CLOCK");
3113 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3114 trace!("Enabling TIMG_CALIBRATION_CLOCK");
3115 crate::rtc_cntl::WakeLock::acquire();
3116 match unwrap!(clocks.timg_calibration_clock) {
3117 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
3118 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
3119 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
3120 #[cfg(use_xtal32k)]
3121 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
3122 }
3123 enable_timg_calibration_clock_impl(clocks, true);
3124 }
3125 }
3126 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
3127 trace!("Releasing TIMG_CALIBRATION_CLOCK");
3128 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
3129 trace!("Disabling TIMG_CALIBRATION_CLOCK");
3130 crate::rtc_cntl::WakeLock::release();
3131 enable_timg_calibration_clock_impl(clocks, false);
3132 match unwrap!(clocks.timg_calibration_clock) {
3133 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
3134 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
3135 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
3136 #[cfg(use_xtal32k)]
3137 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
3138 }
3139 }
3140 }
3141 #[allow(unused_variables)]
3142 pub fn timg_calibration_clock_config_frequency(
3143 clocks: &mut ClockTree,
3144 config: TimgCalibrationClockConfig,
3145 ) -> u32 {
3146 match config {
3147 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
3148 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3149 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3150 #[cfg(use_xtal32k)]
3151 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3152 }
3153 }
3154 pub fn timg_calibration_clock_frequency() -> u32 {
3155 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
3156 }
3157 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
3158 match source {
3159 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(),
3160 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(),
3161 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
3162 #[cfg(use_xtal32k)]
3163 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
3164 }
3165 }
3166 impl SdmInstance {
3167 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3168 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3169 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3170 {
3171 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3172 request_iomux_function_clock(clocks);
3173 self.enable_function_clock_impl(clocks, true);
3174 }
3175 }
3176 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3177 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3178 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
3179 {
3180 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3181 self.enable_function_clock_impl(clocks, false);
3182 release_iomux_function_clock(clocks);
3183 }
3184 }
3185 pub fn function_clock_frequency(self) -> u32 {
3186 iomux_function_clock_frequency()
3187 }
3188 pub fn function_clock_source_frequency() -> u32 {
3189 iomux_function_clock_frequency()
3190 }
3191 }
3192 impl I2cInstance {
3193 pub fn configure_function_clock(
3194 self,
3195 clocks: &mut ClockTree,
3196 config: I2cFunctionClockConfig,
3197 ) {
3198 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
3199 refresh_i2c_function_clock_downstream(clocks, self);
3200 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
3201 match config.sclk {
3202 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3203 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3204 }
3205 self.configure_function_clock_impl(clocks, old_config, config);
3206 if let Some(old_config) = old_config {
3207 match old_config.sclk {
3208 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3209 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3210 }
3211 }
3212 } else {
3213 self.configure_function_clock_impl(clocks, old_config, config);
3214 }
3215 }
3216 pub fn function_clock_config(
3217 self,
3218 clocks: &mut ClockTree,
3219 ) -> Option<I2cFunctionClockConfig> {
3220 clocks.i2c_function_clock[self as usize]
3221 }
3222 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3223 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3224 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3225 {
3226 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3227 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3228 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3229 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3230 }
3231 self.enable_function_clock_impl(clocks, true);
3232 }
3233 }
3234 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3235 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3236 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
3237 {
3238 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3239 self.enable_function_clock_impl(clocks, false);
3240 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
3241 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3242 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3243 }
3244 }
3245 }
3246 #[allow(unused_variables)]
3247 pub fn function_clock_config_frequency(
3248 clocks: &mut ClockTree,
3249 config: I2cFunctionClockConfig,
3250 ) -> u32 {
3251 (match config.sclk {
3252 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3253 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3254 } / (config.div_num() + 1))
3255 }
3256 pub fn function_clock_frequency(self) -> u32 {
3257 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3258 .load(::core::sync::atomic::Ordering::Acquire)
3259 }
3260 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
3261 match sclk {
3262 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
3263 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3264 }
3265 }
3266 }
3267 impl ParlIoInstance {
3268 pub fn configure_rx_clock(
3269 self,
3270 clocks: &mut ClockTree,
3271 new_selector: ParlIoRxClockConfig,
3272 ) {
3273 let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
3274 refresh_parl_io_rx_clock_downstream(clocks, self);
3275 if clocks.parl_io_rx_clock_refcount[self as usize] > 0 {
3276 match new_selector {
3277 ParlIoRxClockConfig::XtalClk => request_xtal_clk(clocks),
3278 ParlIoRxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3279 ParlIoRxClockConfig::PllF240m => request_pll_f240m(clocks),
3280 }
3281 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
3282 if let Some(old_selector) = old_selector {
3283 match old_selector {
3284 ParlIoRxClockConfig::XtalClk => release_xtal_clk(clocks),
3285 ParlIoRxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3286 ParlIoRxClockConfig::PllF240m => release_pll_f240m(clocks),
3287 }
3288 }
3289 } else {
3290 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
3291 }
3292 }
3293 pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoRxClockConfig> {
3294 clocks.parl_io_rx_clock[self as usize]
3295 }
3296 pub fn request_rx_clock(self, clocks: &mut ClockTree) {
3297 trace!("Requesting {:?}::RX_CLOCK", self);
3298 if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
3299 trace!("Enabling {:?}::RX_CLOCK", self);
3300 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
3301 ParlIoRxClockConfig::XtalClk => request_xtal_clk(clocks),
3302 ParlIoRxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3303 ParlIoRxClockConfig::PllF240m => request_pll_f240m(clocks),
3304 }
3305 self.enable_rx_clock_impl(clocks, true);
3306 }
3307 }
3308 pub fn release_rx_clock(self, clocks: &mut ClockTree) {
3309 trace!("Releasing {:?}::RX_CLOCK", self);
3310 if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
3311 trace!("Disabling {:?}::RX_CLOCK", self);
3312 self.enable_rx_clock_impl(clocks, false);
3313 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
3314 ParlIoRxClockConfig::XtalClk => release_xtal_clk(clocks),
3315 ParlIoRxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3316 ParlIoRxClockConfig::PllF240m => release_pll_f240m(clocks),
3317 }
3318 }
3319 }
3320 #[allow(unused_variables)]
3321 pub fn rx_clock_config_frequency(
3322 clocks: &mut ClockTree,
3323 config: ParlIoRxClockConfig,
3324 ) -> u32 {
3325 match config {
3326 ParlIoRxClockConfig::XtalClk => xtal_clk_frequency(),
3327 ParlIoRxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3328 ParlIoRxClockConfig::PllF240m => pll_f240m_frequency(),
3329 }
3330 }
3331 pub fn rx_clock_frequency(self) -> u32 {
3332 PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
3333 .load(::core::sync::atomic::Ordering::Acquire)
3334 }
3335 pub fn rx_clock_source_frequency(source: ParlIoRxClockConfig) -> u32 {
3336 match source {
3337 ParlIoRxClockConfig::XtalClk => xtal_clk_frequency(),
3338 ParlIoRxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3339 ParlIoRxClockConfig::PllF240m => pll_f240m_frequency(),
3340 }
3341 }
3342 pub fn configure_tx_clock(
3343 self,
3344 clocks: &mut ClockTree,
3345 new_selector: ParlIoTxClockConfig,
3346 ) {
3347 let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
3348 refresh_parl_io_tx_clock_downstream(clocks, self);
3349 if clocks.parl_io_tx_clock_refcount[self as usize] > 0 {
3350 match new_selector {
3351 ParlIoTxClockConfig::XtalClk => request_xtal_clk(clocks),
3352 ParlIoTxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3353 ParlIoTxClockConfig::PllF240m => request_pll_f240m(clocks),
3354 }
3355 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
3356 if let Some(old_selector) = old_selector {
3357 match old_selector {
3358 ParlIoTxClockConfig::XtalClk => release_xtal_clk(clocks),
3359 ParlIoTxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3360 ParlIoTxClockConfig::PllF240m => release_pll_f240m(clocks),
3361 }
3362 }
3363 } else {
3364 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
3365 }
3366 }
3367 pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoTxClockConfig> {
3368 clocks.parl_io_tx_clock[self as usize]
3369 }
3370 pub fn request_tx_clock(self, clocks: &mut ClockTree) {
3371 trace!("Requesting {:?}::TX_CLOCK", self);
3372 if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
3373 trace!("Enabling {:?}::TX_CLOCK", self);
3374 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
3375 ParlIoTxClockConfig::XtalClk => request_xtal_clk(clocks),
3376 ParlIoTxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3377 ParlIoTxClockConfig::PllF240m => request_pll_f240m(clocks),
3378 }
3379 self.enable_tx_clock_impl(clocks, true);
3380 }
3381 }
3382 pub fn release_tx_clock(self, clocks: &mut ClockTree) {
3383 trace!("Releasing {:?}::TX_CLOCK", self);
3384 if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
3385 trace!("Disabling {:?}::TX_CLOCK", self);
3386 self.enable_tx_clock_impl(clocks, false);
3387 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
3388 ParlIoTxClockConfig::XtalClk => release_xtal_clk(clocks),
3389 ParlIoTxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3390 ParlIoTxClockConfig::PllF240m => release_pll_f240m(clocks),
3391 }
3392 }
3393 }
3394 #[allow(unused_variables)]
3395 pub fn tx_clock_config_frequency(
3396 clocks: &mut ClockTree,
3397 config: ParlIoTxClockConfig,
3398 ) -> u32 {
3399 match config {
3400 ParlIoTxClockConfig::XtalClk => xtal_clk_frequency(),
3401 ParlIoTxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3402 ParlIoTxClockConfig::PllF240m => pll_f240m_frequency(),
3403 }
3404 }
3405 pub fn tx_clock_frequency(self) -> u32 {
3406 PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
3407 .load(::core::sync::atomic::Ordering::Acquire)
3408 }
3409 pub fn tx_clock_source_frequency(source: ParlIoTxClockConfig) -> u32 {
3410 match source {
3411 ParlIoTxClockConfig::XtalClk => xtal_clk_frequency(),
3412 ParlIoTxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3413 ParlIoTxClockConfig::PllF240m => pll_f240m_frequency(),
3414 }
3415 }
3416 }
3417 impl RmtInstance {
3418 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3419 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3420 refresh_rmt_sclk_downstream(clocks, self);
3421 if clocks.rmt_sclk_refcount[self as usize] > 0 {
3422 match new_selector {
3423 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3424 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3425 RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
3426 }
3427 self.configure_sclk_impl(clocks, old_selector, new_selector);
3428 if let Some(old_selector) = old_selector {
3429 match old_selector {
3430 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3431 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3432 RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
3433 }
3434 }
3435 } else {
3436 self.configure_sclk_impl(clocks, old_selector, new_selector);
3437 }
3438 }
3439 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3440 clocks.rmt_sclk[self as usize]
3441 }
3442 pub fn request_sclk(self, clocks: &mut ClockTree) {
3443 trace!("Requesting {:?}::SCLK", self);
3444 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3445 trace!("Enabling {:?}::SCLK", self);
3446 match unwrap!(clocks.rmt_sclk[self as usize]) {
3447 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3448 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3449 RmtSclkConfig::PllF80m => request_pll_f80m(clocks),
3450 }
3451 self.enable_sclk_impl(clocks, true);
3452 }
3453 }
3454 pub fn release_sclk(self, clocks: &mut ClockTree) {
3455 trace!("Releasing {:?}::SCLK", self);
3456 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3457 trace!("Disabling {:?}::SCLK", self);
3458 self.enable_sclk_impl(clocks, false);
3459 match unwrap!(clocks.rmt_sclk[self as usize]) {
3460 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3461 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3462 RmtSclkConfig::PllF80m => release_pll_f80m(clocks),
3463 }
3464 }
3465 }
3466 #[allow(unused_variables)]
3467 pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
3468 match config {
3469 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3470 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3471 RmtSclkConfig::PllF80m => pll_f80m_frequency(),
3472 }
3473 }
3474 pub fn sclk_frequency(self) -> u32 {
3475 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3476 }
3477 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3478 match source {
3479 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3480 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3481 RmtSclkConfig::PllF80m => pll_f80m_frequency(),
3482 }
3483 }
3484 }
3485 impl SpiInstance {
3486 pub fn configure_function_clock(
3487 self,
3488 clocks: &mut ClockTree,
3489 new_selector: SpiFunctionClockConfig,
3490 ) {
3491 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3492 refresh_spi_function_clock_downstream(clocks, self);
3493 if clocks.spi_function_clock_refcount[self as usize] > 0 {
3494 match new_selector {
3495 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3496 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
3497 SpiFunctionClockConfig::PllF120m => request_pll_f120m(clocks),
3498 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3499 }
3500 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3501 if let Some(old_selector) = old_selector {
3502 match old_selector {
3503 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3504 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
3505 SpiFunctionClockConfig::PllF120m => release_pll_f120m(clocks),
3506 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3507 }
3508 }
3509 } else {
3510 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3511 }
3512 }
3513 pub fn function_clock_config(
3514 self,
3515 clocks: &mut ClockTree,
3516 ) -> Option<SpiFunctionClockConfig> {
3517 clocks.spi_function_clock[self as usize]
3518 }
3519 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3520 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3521 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3522 {
3523 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3524 match unwrap!(clocks.spi_function_clock[self as usize]) {
3525 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3526 SpiFunctionClockConfig::PllF160m => request_pll_f160m(clocks),
3527 SpiFunctionClockConfig::PllF120m => request_pll_f120m(clocks),
3528 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3529 }
3530 self.enable_function_clock_impl(clocks, true);
3531 }
3532 }
3533 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3534 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3535 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3536 {
3537 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3538 self.enable_function_clock_impl(clocks, false);
3539 match unwrap!(clocks.spi_function_clock[self as usize]) {
3540 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3541 SpiFunctionClockConfig::PllF160m => release_pll_f160m(clocks),
3542 SpiFunctionClockConfig::PllF120m => release_pll_f120m(clocks),
3543 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3544 }
3545 }
3546 }
3547 #[allow(unused_variables)]
3548 pub fn function_clock_config_frequency(
3549 clocks: &mut ClockTree,
3550 config: SpiFunctionClockConfig,
3551 ) -> u32 {
3552 match config {
3553 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3554 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
3555 SpiFunctionClockConfig::PllF120m => pll_f120m_frequency(),
3556 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3557 }
3558 }
3559 pub fn function_clock_frequency(self) -> u32 {
3560 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3561 .load(::core::sync::atomic::Ordering::Acquire)
3562 }
3563 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3564 match source {
3565 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3566 SpiFunctionClockConfig::PllF160m => pll_f160m_frequency(),
3567 SpiFunctionClockConfig::PllF120m => pll_f120m_frequency(),
3568 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3569 }
3570 }
3571 }
3572 impl TimgInstance {
3573 pub fn configure_function_clock(
3574 self,
3575 clocks: &mut ClockTree,
3576 new_selector: TimgFunctionClockConfig,
3577 ) {
3578 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3579 refresh_timg_function_clock_downstream(clocks, self);
3580 if clocks.timg_function_clock_refcount[self as usize] > 0 {
3581 match new_selector {
3582 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3583 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3584 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3585 }
3586 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3587 if let Some(old_selector) = old_selector {
3588 match old_selector {
3589 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3590 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3591 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3592 }
3593 }
3594 } else {
3595 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3596 }
3597 }
3598 pub fn function_clock_config(
3599 self,
3600 clocks: &mut ClockTree,
3601 ) -> Option<TimgFunctionClockConfig> {
3602 clocks.timg_function_clock[self as usize]
3603 }
3604 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3605 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3606 if increment_reference_count(
3607 &mut clocks.timg_function_clock_refcount[self as usize],
3608 ) {
3609 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3610 match unwrap!(clocks.timg_function_clock[self as usize]) {
3611 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3612 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3613 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
3614 }
3615 self.enable_function_clock_impl(clocks, true);
3616 }
3617 }
3618 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3619 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3620 if decrement_reference_count(
3621 &mut clocks.timg_function_clock_refcount[self as usize],
3622 ) {
3623 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3624 self.enable_function_clock_impl(clocks, false);
3625 match unwrap!(clocks.timg_function_clock[self as usize]) {
3626 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3627 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3628 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
3629 }
3630 }
3631 }
3632 #[allow(unused_variables)]
3633 pub fn function_clock_config_frequency(
3634 clocks: &mut ClockTree,
3635 config: TimgFunctionClockConfig,
3636 ) -> u32 {
3637 match config {
3638 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3639 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3640 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3641 }
3642 }
3643 pub fn function_clock_frequency(self) -> u32 {
3644 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3645 .load(::core::sync::atomic::Ordering::Acquire)
3646 }
3647 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3648 match source {
3649 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3650 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3651 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(),
3652 }
3653 }
3654 pub fn configure_wdt_clock(
3655 self,
3656 clocks: &mut ClockTree,
3657 new_selector: TimgWdtClockConfig,
3658 ) {
3659 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3660 refresh_timg_wdt_clock_downstream(clocks, self);
3661 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
3662 match new_selector {
3663 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3664 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3665 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3666 }
3667 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3668 if let Some(old_selector) = old_selector {
3669 match old_selector {
3670 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3671 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3672 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3673 }
3674 }
3675 } else {
3676 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3677 }
3678 }
3679 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3680 clocks.timg_wdt_clock[self as usize]
3681 }
3682 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3683 trace!("Requesting {:?}::WDT_CLOCK", self);
3684 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3685 trace!("Enabling {:?}::WDT_CLOCK", self);
3686 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3687 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3688 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
3689 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3690 }
3691 self.enable_wdt_clock_impl(clocks, true);
3692 }
3693 }
3694 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3695 trace!("Releasing {:?}::WDT_CLOCK", self);
3696 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3697 trace!("Disabling {:?}::WDT_CLOCK", self);
3698 self.enable_wdt_clock_impl(clocks, false);
3699 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3700 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3701 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
3702 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3703 }
3704 }
3705 }
3706 #[allow(unused_variables)]
3707 pub fn wdt_clock_config_frequency(
3708 clocks: &mut ClockTree,
3709 config: TimgWdtClockConfig,
3710 ) -> u32 {
3711 match config {
3712 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3713 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3714 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3715 }
3716 }
3717 pub fn wdt_clock_frequency(self) -> u32 {
3718 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3719 .load(::core::sync::atomic::Ordering::Acquire)
3720 }
3721 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3722 match source {
3723 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3724 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(),
3725 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3726 }
3727 }
3728 }
3729 impl UartInstance {
3730 pub fn configure_function_clock(
3731 self,
3732 clocks: &mut ClockTree,
3733 config: UartFunctionClockConfig,
3734 ) {
3735 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3736 refresh_uart_function_clock_downstream(clocks, self);
3737 if clocks.uart_function_clock_refcount[self as usize] > 0 {
3738 match config.sclk {
3739 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3740 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3741 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3742 }
3743 self.configure_function_clock_impl(clocks, old_config, config);
3744 if let Some(old_config) = old_config {
3745 match old_config.sclk {
3746 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3747 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3748 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3749 }
3750 }
3751 } else {
3752 self.configure_function_clock_impl(clocks, old_config, config);
3753 }
3754 }
3755 pub fn function_clock_config(
3756 self,
3757 clocks: &mut ClockTree,
3758 ) -> Option<UartFunctionClockConfig> {
3759 clocks.uart_function_clock[self as usize]
3760 }
3761 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3762 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3763 if increment_reference_count(
3764 &mut clocks.uart_function_clock_refcount[self as usize],
3765 ) {
3766 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3767 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3768 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3769 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
3770 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3771 }
3772 self.enable_function_clock_impl(clocks, true);
3773 }
3774 }
3775 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3776 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3777 if decrement_reference_count(
3778 &mut clocks.uart_function_clock_refcount[self as usize],
3779 ) {
3780 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3781 self.enable_function_clock_impl(clocks, false);
3782 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3783 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3784 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
3785 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3786 }
3787 }
3788 }
3789 #[allow(unused_variables)]
3790 pub fn function_clock_config_frequency(
3791 clocks: &mut ClockTree,
3792 config: UartFunctionClockConfig,
3793 ) -> u32 {
3794 (match config.sclk {
3795 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3796 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3797 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3798 } / (config.div_num() + 1))
3799 }
3800 pub fn function_clock_frequency(self) -> u32 {
3801 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3802 .load(::core::sync::atomic::Ordering::Acquire)
3803 }
3804 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3805 match sclk {
3806 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3807 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(),
3808 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3809 }
3810 }
3811 pub fn configure_baud_rate_generator(
3812 self,
3813 clocks: &mut ClockTree,
3814 config: UartBaudRateGeneratorConfig,
3815 ) {
3816 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3817 refresh_uart_baud_rate_generator_downstream(clocks, self);
3818 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3819 }
3820 pub fn baud_rate_generator_config(
3821 self,
3822 clocks: &mut ClockTree,
3823 ) -> Option<UartBaudRateGeneratorConfig> {
3824 clocks.uart_baud_rate_generator[self as usize]
3825 }
3826 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3827 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3828 if increment_reference_count(
3829 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3830 ) {
3831 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3832 self.request_function_clock(clocks);
3833 self.enable_baud_rate_generator_impl(clocks, true);
3834 }
3835 }
3836 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3837 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3838 if decrement_reference_count(
3839 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3840 ) {
3841 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3842 self.enable_baud_rate_generator_impl(clocks, false);
3843 self.release_function_clock(clocks);
3844 }
3845 }
3846 #[allow(unused_variables)]
3847 pub fn baud_rate_generator_config_frequency(
3848 self,
3849 clocks: &mut ClockTree,
3850 config: UartBaudRateGeneratorConfig,
3851 ) -> u32 {
3852 ((self.function_clock_frequency() * 16)
3853 / ((config.integral() * 16) + config.fractional()))
3854 }
3855 pub fn baud_rate_generator_frequency(self) -> u32 {
3856 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3857 .load(::core::sync::atomic::Ordering::Acquire)
3858 }
3859 }
3860 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3868 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3869 #[instability::unstable]
3870 pub struct ClockConfig {
3871 pub xtal_clk: Option<XtalClkConfig>,
3873 pub hp_root_clk: Option<HpRootClkConfig>,
3875 pub cpu_clk: Option<CpuClkConfig>,
3877 pub ahb_clk: Option<AhbClkConfig>,
3879 pub apb_clk: Option<ApbClkConfig>,
3881 pub lp_fast_clk: Option<LpFastClkConfig>,
3883 pub lp_slow_clk: Option<LpSlowClkConfig>,
3885 pub crypto_clk: Option<CryptoClkConfig>,
3887 pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
3889 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3891 }
3892 impl ClockConfig {
3893 fn apply(&self, clocks: &mut ClockTree) {
3894 if let Some(config) = self.xtal_clk {
3895 configure_xtal_clk(clocks, config);
3896 }
3897 if let Some(config) = self.hp_root_clk {
3898 configure_hp_root_clk(clocks, config);
3899 }
3900 if let Some(config) = self.cpu_clk {
3901 configure_cpu_clk(clocks, config);
3902 }
3903 if let Some(config) = self.ahb_clk {
3904 configure_ahb_clk(clocks, config);
3905 }
3906 if let Some(config) = self.apb_clk {
3907 configure_apb_clk(clocks, config);
3908 }
3909 if let Some(config) = self.lp_fast_clk {
3910 configure_lp_fast_clk(clocks, config);
3911 }
3912 if let Some(config) = self.lp_slow_clk {
3913 configure_lp_slow_clk(clocks, config);
3914 }
3915 if let Some(config) = self.crypto_clk {
3916 configure_crypto_clk(clocks, config);
3917 }
3918 if let Some(config) = self.iomux_function_clock {
3919 configure_iomux_function_clock(clocks, config);
3920 }
3921 if let Some(config) = self.timg_calibration_clock {
3922 configure_timg_calibration_clock(clocks, config);
3923 }
3924 }
3925 }
3926 fn increment_reference_count(refcount: &mut u32) -> bool {
3927 let first = *refcount == 0;
3928 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3929 first
3930 }
3931 fn decrement_reference_count(refcount: &mut u32) -> bool {
3932 *refcount = refcount.saturating_sub(1);
3933 let last = *refcount == 0;
3934 last
3935 }
3936 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3937 if let Some(config) = clocks.xtal_clk {
3938 XTAL_CLK_FREQ_CACHE.store(
3939 xtal_clk_config_frequency(clocks, config),
3940 ::core::sync::atomic::Ordering::Release,
3941 );
3942 }
3943 refresh_hp_root_clk_downstream(clocks);
3944 refresh_lp_fast_clk_downstream(clocks);
3945 refresh_crypto_clk_downstream(clocks);
3946 refresh_iomux_function_clock_downstream(clocks);
3947 for child_instance in [I2cInstance::I2c0] {
3948 refresh_i2c_function_clock_downstream(clocks, child_instance);
3949 }
3950 for child_instance in [ParlIoInstance::ParlIo] {
3951 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
3952 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
3953 }
3954 for child_instance in [RmtInstance::Rmt] {
3955 refresh_rmt_sclk_downstream(clocks, child_instance);
3956 }
3957 for child_instance in [SpiInstance::Spi2] {
3958 refresh_spi_function_clock_downstream(clocks, child_instance);
3959 }
3960 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3961 refresh_timg_function_clock_downstream(clocks, child_instance);
3962 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3963 }
3964 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3965 refresh_uart_function_clock_downstream(clocks, child_instance);
3966 }
3967 }
3968 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
3969 if let Some(config) = clocks.hp_root_clk {
3970 HP_ROOT_CLK_FREQ_CACHE.store(
3971 hp_root_clk_config_frequency(clocks, config),
3972 ::core::sync::atomic::Ordering::Release,
3973 );
3974 }
3975 refresh_cpu_clk_downstream(clocks);
3976 refresh_ahb_clk_downstream(clocks);
3977 }
3978 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3979 if let Some(config) = clocks.cpu_clk {
3980 CPU_CLK_FREQ_CACHE.store(
3981 cpu_clk_config_frequency(clocks, config),
3982 ::core::sync::atomic::Ordering::Release,
3983 );
3984 }
3985 }
3986 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
3987 if let Some(config) = clocks.ahb_clk {
3988 AHB_CLK_FREQ_CACHE.store(
3989 ahb_clk_config_frequency(clocks, config),
3990 ::core::sync::atomic::Ordering::Release,
3991 );
3992 }
3993 refresh_apb_clk_downstream(clocks);
3994 }
3995 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3996 if let Some(config) = clocks.apb_clk {
3997 APB_CLK_FREQ_CACHE.store(
3998 apb_clk_config_frequency(clocks, config),
3999 ::core::sync::atomic::Ordering::Release,
4000 );
4001 }
4002 }
4003 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
4004 if let Some(config) = clocks.lp_fast_clk {
4005 LP_FAST_CLK_FREQ_CACHE.store(
4006 lp_fast_clk_config_frequency(clocks, config),
4007 ::core::sync::atomic::Ordering::Release,
4008 );
4009 }
4010 }
4011 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
4012 if let Some(config) = clocks.lp_slow_clk {
4013 LP_SLOW_CLK_FREQ_CACHE.store(
4014 lp_slow_clk_config_frequency(clocks, config),
4015 ::core::sync::atomic::Ordering::Release,
4016 );
4017 }
4018 }
4019 fn refresh_crypto_clk_downstream(clocks: &mut ClockTree) {
4020 if let Some(config) = clocks.crypto_clk {
4021 CRYPTO_CLK_FREQ_CACHE.store(
4022 crypto_clk_config_frequency(clocks, config),
4023 ::core::sync::atomic::Ordering::Release,
4024 );
4025 }
4026 }
4027 fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
4028 if let Some(config) = clocks.iomux_function_clock {
4029 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
4030 iomux_function_clock_config_frequency(clocks, config),
4031 ::core::sync::atomic::Ordering::Release,
4032 );
4033 }
4034 }
4035 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
4036 if let Some(config) = clocks.timg_calibration_clock {
4037 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
4038 timg_calibration_clock_config_frequency(clocks, config),
4039 ::core::sync::atomic::Ordering::Release,
4040 );
4041 }
4042 }
4043 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
4044 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
4045 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4046 I2cInstance::function_clock_config_frequency(clocks, config),
4047 ::core::sync::atomic::Ordering::Release,
4048 );
4049 }
4050 }
4051 fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
4052 if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
4053 PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
4054 ParlIoInstance::rx_clock_config_frequency(clocks, config),
4055 ::core::sync::atomic::Ordering::Release,
4056 );
4057 }
4058 }
4059 fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
4060 if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
4061 PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
4062 ParlIoInstance::tx_clock_config_frequency(clocks, config),
4063 ::core::sync::atomic::Ordering::Release,
4064 );
4065 }
4066 }
4067 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
4068 if let Some(config) = clocks.rmt_sclk[instance as usize] {
4069 RMT_SCLK_FREQ_CACHE[instance as usize].store(
4070 RmtInstance::sclk_config_frequency(clocks, config),
4071 ::core::sync::atomic::Ordering::Release,
4072 );
4073 }
4074 }
4075 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
4076 if let Some(config) = clocks.spi_function_clock[instance as usize] {
4077 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4078 SpiInstance::function_clock_config_frequency(clocks, config),
4079 ::core::sync::atomic::Ordering::Release,
4080 );
4081 }
4082 }
4083 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4084 if let Some(config) = clocks.timg_function_clock[instance as usize] {
4085 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4086 TimgInstance::function_clock_config_frequency(clocks, config),
4087 ::core::sync::atomic::Ordering::Release,
4088 );
4089 }
4090 }
4091 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
4092 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
4093 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
4094 TimgInstance::wdt_clock_config_frequency(clocks, config),
4095 ::core::sync::atomic::Ordering::Release,
4096 );
4097 }
4098 }
4099 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
4100 if let Some(config) = clocks.uart_function_clock[instance as usize] {
4101 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
4102 UartInstance::function_clock_config_frequency(clocks, config),
4103 ::core::sync::atomic::Ordering::Release,
4104 );
4105 }
4106 refresh_uart_baud_rate_generator_downstream(clocks, instance);
4107 }
4108 fn refresh_uart_baud_rate_generator_downstream(
4109 clocks: &mut ClockTree,
4110 instance: UartInstance,
4111 ) {
4112 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
4113 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
4114 instance.baud_rate_generator_config_frequency(clocks, config),
4115 ::core::sync::atomic::Ordering::Release,
4116 );
4117 }
4118 }
4119 };
4120}
4121#[macro_export]
4125#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4126macro_rules! implement_peripheral_clocks {
4127 () => {
4128 #[doc(hidden)]
4129 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4130 #[repr(u8)]
4131 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
4132 pub enum Peripheral {
4133 Aes,
4135 AhbGdma,
4137 ApbSarAdc,
4139 Ecc,
4141 GpioSd,
4143 I2cExt0,
4145 I2s0,
4147 ParlIo,
4149 Pcnt,
4151 Rmt,
4153 Rsa,
4155 Sha,
4157 Spi2,
4159 Systimer,
4161 Timg0,
4163 Timg1,
4165 Uart0,
4167 Uart1,
4169 Uhci0,
4171 UsbDevice,
4173 }
4174 impl Peripheral {
4175 const KEEP_ENABLED: &[Peripheral] = &[
4176 Self::ApbSarAdc,
4177 Self::Systimer,
4178 Self::Timg0,
4179 Self::Uart0,
4180 Self::UsbDevice,
4181 ];
4182 const COUNT: usize = Self::ALL.len();
4183 const ALL: &[Self] = &[
4184 Self::Aes,
4185 Self::AhbGdma,
4186 Self::ApbSarAdc,
4187 Self::Ecc,
4188 Self::GpioSd,
4189 Self::I2cExt0,
4190 Self::I2s0,
4191 Self::ParlIo,
4192 Self::Pcnt,
4193 Self::Rmt,
4194 Self::Rsa,
4195 Self::Sha,
4196 Self::Spi2,
4197 Self::Systimer,
4198 Self::Timg0,
4199 Self::Timg1,
4200 Self::Uart0,
4201 Self::Uart1,
4202 Self::Uhci0,
4203 Self::UsbDevice,
4204 ];
4205 }
4206 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
4207 match peripheral {
4208 Peripheral::Aes => {
4209 crate::peripherals::SYSTEM::regs()
4210 .aes_conf()
4211 .modify(|_, w| w.aes_clk_en().bit(enable));
4212 }
4213 Peripheral::AhbGdma => {
4214 crate::peripherals::SYSTEM::regs()
4215 .gdma_conf()
4216 .modify(|_, w| w.gdma_clk_en().bit(enable));
4217 }
4218 Peripheral::ApbSarAdc => {
4219 crate::peripherals::SYSTEM::regs()
4220 .saradc_conf()
4221 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
4222 }
4223 Peripheral::Ecc => {
4224 crate::peripherals::SYSTEM::regs()
4225 .ecc_conf()
4226 .modify(|_, w| w.ecc_clk_en().bit(enable));
4227 }
4228 Peripheral::GpioSd => {
4229 crate::peripherals::GPIO_SD::regs()
4230 .clock_gate()
4231 .modify(|_, w| w.clk_en().bit(enable));
4232 }
4233 Peripheral::I2cExt0 => {
4234 crate::peripherals::SYSTEM::regs()
4235 .i2c0_conf()
4236 .modify(|_, w| w.i2c0_clk_en().bit(enable));
4237 }
4238 Peripheral::I2s0 => {
4239 crate::peripherals::SYSTEM::regs()
4240 .i2s_conf()
4241 .modify(|_, w| w.i2s_clk_en().bit(enable));
4242 }
4243 Peripheral::ParlIo => {
4244 crate::peripherals::SYSTEM::regs()
4245 .parl_io_conf()
4246 .modify(|_, w| w.parl_clk_en().bit(enable));
4247 }
4248 Peripheral::Pcnt => {
4249 crate::peripherals::SYSTEM::regs()
4250 .pcnt_conf()
4251 .modify(|_, w| w.pcnt_clk_en().bit(enable));
4252 }
4253 Peripheral::Rmt => {
4254 crate::peripherals::SYSTEM::regs()
4255 .rmt_conf()
4256 .modify(|_, w| w.rmt_clk_en().bit(enable));
4257 }
4258 Peripheral::Rsa => {
4259 crate::peripherals::SYSTEM::regs()
4260 .rsa_conf()
4261 .modify(|_, w| w.rsa_clk_en().bit(enable));
4262 }
4263 Peripheral::Sha => {
4264 crate::peripherals::SYSTEM::regs()
4265 .sha_conf()
4266 .modify(|_, w| w.sha_clk_en().bit(enable));
4267 }
4268 Peripheral::Spi2 => {
4269 crate::peripherals::SYSTEM::regs()
4270 .spi2_conf()
4271 .modify(|_, w| w.spi2_clk_en().bit(enable));
4272 }
4273 Peripheral::Systimer => {
4274 crate::peripherals::SYSTEM::regs()
4275 .systimer_conf()
4276 .modify(|_, w| w.systimer_clk_en().bit(enable));
4277 }
4278 Peripheral::Timg0 => {
4279 crate::peripherals::SYSTEM::regs()
4280 .timergroup(0)
4281 .conf()
4282 .modify(|_, w| w.clk_en().bit(enable));
4283 }
4284 Peripheral::Timg1 => {
4285 crate::peripherals::SYSTEM::regs()
4286 .timergroup(1)
4287 .conf()
4288 .modify(|_, w| w.clk_en().bit(enable));
4289 }
4290 Peripheral::Uart0 => {
4291 crate::peripherals::SYSTEM::regs()
4292 .uart(0)
4293 .conf()
4294 .modify(|_, w| w.clk_en().bit(enable));
4295 }
4296 Peripheral::Uart1 => {
4297 crate::peripherals::SYSTEM::regs()
4298 .uart(1)
4299 .conf()
4300 .modify(|_, w| w.clk_en().bit(enable));
4301 }
4302 Peripheral::Uhci0 => {
4303 crate::peripherals::SYSTEM::regs()
4304 .uhci_conf()
4305 .modify(|_, w| w.uhci_clk_en().bit(enable));
4306 }
4307 Peripheral::UsbDevice => {
4308 crate::peripherals::SYSTEM::regs()
4309 .usb_device_conf()
4310 .modify(|_, w| w.usb_device_clk_en().bit(enable));
4311 }
4312 }
4313 }
4314 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4315 match peripheral {
4316 Peripheral::Aes => {
4317 crate::peripherals::SYSTEM::regs()
4318 .aes_conf()
4319 .modify(|_, w| w.aes_rst_en().bit(reset));
4320 }
4321 Peripheral::AhbGdma => {
4322 crate::peripherals::SYSTEM::regs()
4323 .gdma_conf()
4324 .modify(|_, w| w.gdma_rst_en().bit(reset));
4325 }
4326 Peripheral::ApbSarAdc => {
4327 crate::peripherals::SYSTEM::regs()
4328 .saradc_conf()
4329 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
4330 }
4331 Peripheral::Ecc => {
4332 crate::peripherals::SYSTEM::regs()
4333 .ecc_conf()
4334 .modify(|_, w| w.ecc_rst_en().bit(reset));
4335 }
4336 Peripheral::GpioSd => {
4337 let _ = reset;
4338 }
4339 Peripheral::I2cExt0 => {
4340 crate::peripherals::SYSTEM::regs()
4341 .i2c0_conf()
4342 .modify(|_, w| w.i2c0_rst_en().bit(reset));
4343 }
4344 Peripheral::I2s0 => {
4345 crate::peripherals::SYSTEM::regs()
4346 .i2s_conf()
4347 .modify(|_, w| w.i2s_rst_en().bit(reset));
4348 }
4349 Peripheral::ParlIo => {
4350 crate::peripherals::SYSTEM::regs()
4351 .parl_io_conf()
4352 .modify(|_, w| w.parl_rst_en().bit(reset));
4353 }
4354 Peripheral::Pcnt => {
4355 crate::peripherals::SYSTEM::regs()
4356 .pcnt_conf()
4357 .modify(|_, w| w.pcnt_rst_en().bit(reset));
4358 }
4359 Peripheral::Rmt => {
4360 crate::peripherals::SYSTEM::regs()
4361 .rmt_conf()
4362 .modify(|_, w| w.rmt_rst_en().bit(reset));
4363 }
4364 Peripheral::Rsa => {
4365 crate::peripherals::SYSTEM::regs()
4366 .rsa_conf()
4367 .modify(|_, w| w.rsa_rst_en().bit(reset));
4368 }
4369 Peripheral::Sha => {
4370 crate::peripherals::SYSTEM::regs()
4371 .sha_conf()
4372 .modify(|_, w| w.sha_rst_en().bit(reset));
4373 }
4374 Peripheral::Spi2 => {
4375 crate::peripherals::SYSTEM::regs()
4376 .spi2_conf()
4377 .modify(|_, w| w.spi2_rst_en().bit(reset));
4378 }
4379 Peripheral::Systimer => {
4380 crate::peripherals::SYSTEM::regs()
4381 .systimer_conf()
4382 .modify(|_, w| w.systimer_rst_en().bit(reset));
4383 }
4384 Peripheral::Timg0 => {
4385 crate::peripherals::SYSTEM::regs()
4386 .timergroup(0)
4387 .conf()
4388 .modify(|_, w| w.rst_en().bit(reset));
4389 }
4390 Peripheral::Timg1 => {
4391 crate::peripherals::SYSTEM::regs()
4392 .timergroup(1)
4393 .conf()
4394 .modify(|_, w| w.rst_en().bit(reset));
4395 }
4396 Peripheral::Uart0 => {
4397 crate::peripherals::SYSTEM::regs()
4398 .uart(0)
4399 .conf()
4400 .modify(|_, w| w.rst_en().bit(reset));
4401 }
4402 Peripheral::Uart1 => {
4403 crate::peripherals::SYSTEM::regs()
4404 .uart(1)
4405 .conf()
4406 .modify(|_, w| w.rst_en().bit(reset));
4407 }
4408 Peripheral::Uhci0 => {
4409 crate::peripherals::SYSTEM::regs()
4410 .uhci_conf()
4411 .modify(|_, w| w.uhci_rst_en().bit(reset));
4412 }
4413 Peripheral::UsbDevice => {
4414 crate::peripherals::SYSTEM::regs()
4415 .usb_device_conf()
4416 .modify(|_, w| w.usb_device_rst_en().bit(reset));
4417 }
4418 }
4419 }
4420 };
4421}
4422#[macro_export]
4430#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4431macro_rules! memory_range {
4432 ("DRAM") => {
4433 0x40800000..0x40860000
4434 };
4435 (size as str, "DRAM") => {
4436 "393216"
4437 };
4438 ("DRAM2_UNINIT") => {
4439 0x4084E5A0..0x4085E5A0
4440 };
4441 (size as str, "DRAM2_UNINIT") => {
4442 "65536"
4443 };
4444 ("IROM") => {
4445 0x42000000..0x44000000
4446 };
4447 (size as str, "IROM") => {
4448 "33554432"
4449 };
4450 ("DROM") => {
4451 0x42000000..0x44000000
4452 };
4453 (size as str, "DROM") => {
4454 "33554432"
4455 };
4456}
4457#[macro_export]
4474#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4475macro_rules! for_each_i2c_master {
4476 ($($pattern:tt => $code:tt;)*) => {
4477 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4478 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4479 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4480 I2CEXT0_SDA)));
4481 };
4482}
4483#[macro_export]
4510#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4511macro_rules! for_each_i2s {
4512 ($($pattern:tt => $code:tt;)*) => {
4513 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4514 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
4515 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
4516 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
4517 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
4518 true, true, false)));
4519 };
4520}
4521#[macro_export]
4540#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4541macro_rules! for_each_uart {
4542 ($($pattern:tt => $code:tt;)*) => {
4543 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4544 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4545 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4546 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4547 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4548 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4549 };
4550}
4551#[macro_export]
4573#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4574macro_rules! for_each_spi_master {
4575 ($($pattern:tt => $code:tt;)*) => {
4576 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4577 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
4578 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
4579 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
4580 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4581 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
4582 };
4583}
4584#[macro_export]
4601#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4602macro_rules! for_each_spi_slave {
4603 ($($pattern:tt => $code:tt;)*) => {
4604 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4605 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
4606 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4607 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
4608 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
4609 };
4610}
4611#[macro_export]
4612#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4613macro_rules! for_each_peripheral {
4614 ($($pattern:tt => $code:tt;)*) => {
4615 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4616 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4617 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
4618 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4619 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4620 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4621 "<section class=\"warning\">"] #[doc =
4622 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4623 #[doc = "<ul>"] #[doc =
4624 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4625 =
4626 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4627 #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
4628 _for_each_inner_peripheral!((@ peri_type #[doc =
4629 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4630 "<section class=\"warning\">"] #[doc =
4631 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4632 #[doc = "<ul>"] #[doc =
4633 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4634 =
4635 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4636 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
4637 _for_each_inner_peripheral!((@ peri_type #[doc =
4638 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4639 "<section class=\"warning\">"] #[doc =
4640 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4641 #[doc = "<ul>"] #[doc =
4642 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4643 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
4644 _for_each_inner_peripheral!((@ peri_type #[doc =
4645 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4646 "<section class=\"warning\">"] #[doc =
4647 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4648 #[doc = "<ul>"] #[doc =
4649 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4650 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4651 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO6 peripheral singleton"]
4652 GPIO6 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4653 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4654 "<section class=\"warning\">"] #[doc =
4655 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4656 #[doc = "<ul>"] #[doc =
4657 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4658 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4659 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO8 peripheral singleton"]
4660 GPIO8 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4661 "GPIO9 peripheral singleton"] GPIO9 <= virtual()));
4662 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
4663 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4664 "GPIO11 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>By default, this pin is used by the UART programming interface.</li>"] #[doc
4669 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
4670 _for_each_inner_peripheral!((@ peri_type #[doc =
4671 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4672 "<section class=\"warning\">"] #[doc =
4673 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4674 #[doc = "<ul>"] #[doc =
4675 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4676 = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
4677 _for_each_inner_peripheral!((@ peri_type #[doc =
4678 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4679 "<section class=\"warning\">"] #[doc =
4680 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4681 #[doc = "<ul>"] #[doc =
4682 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4683 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
4684 peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
4685 #[doc = "<section class=\"warning\">"] #[doc =
4686 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4687 #[doc = "<ul>"] #[doc =
4688 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4689 #[doc = "</section>"] GPIO14 <= virtual())); _for_each_inner_peripheral!((@
4690 peri_type #[doc = "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""]
4691 #[doc = "<section class=\"warning\">"] #[doc =
4692 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4693 #[doc = "<ul>"] #[doc =
4694 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4695 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
4696 _for_each_inner_peripheral!((@ peri_type #[doc =
4697 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4698 "<section class=\"warning\">"] #[doc =
4699 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4700 #[doc = "<ul>"] #[doc =
4701 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4702 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
4703 _for_each_inner_peripheral!((@ peri_type #[doc =
4704 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4705 "<section class=\"warning\">"] #[doc =
4706 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4707 #[doc = "<ul>"] #[doc =
4708 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4709 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4710 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
4711 _for_each_inner_peripheral!((@ peri_type #[doc =
4712 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4713 "<section class=\"warning\">"] #[doc =
4714 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4715 #[doc = "<ul>"] #[doc =
4716 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4717 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4718 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()));
4719 _for_each_inner_peripheral!((@ peri_type #[doc =
4720 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4721 "<section class=\"warning\">"] #[doc =
4722 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4723 #[doc = "<ul>"] #[doc =
4724 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4725 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4726 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()));
4727 _for_each_inner_peripheral!((@ peri_type #[doc =
4728 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4729 "<section class=\"warning\">"] #[doc =
4730 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4731 #[doc = "<ul>"] #[doc =
4732 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4733 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4734 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
4735 _for_each_inner_peripheral!((@ peri_type #[doc =
4736 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4737 "<section class=\"warning\">"] #[doc =
4738 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4739 #[doc = "<ul>"] #[doc =
4740 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4741 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4742 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
4743 _for_each_inner_peripheral!((@ peri_type #[doc =
4744 "GPIO22 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4745 "<section class=\"warning\">"] #[doc =
4746 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4747 #[doc = "<ul>"] #[doc =
4748 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4749 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
4750 "</ul>"] #[doc = "</section>"] GPIO22 <= virtual()));
4751 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO23 peripheral singleton"]
4752 GPIO23 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4753 "GPIO24 peripheral singleton"] GPIO24 <= virtual()));
4754 _for_each_inner_peripheral!((@ peri_type #[doc =
4755 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4756 "<section class=\"warning\">"] #[doc =
4757 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4758 #[doc = "<ul>"] #[doc =
4759 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4760 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
4761 _for_each_inner_peripheral!((@ peri_type #[doc =
4762 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4763 "<section class=\"warning\">"] #[doc =
4764 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4765 #[doc = "<ul>"] #[doc =
4766 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4767 = "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()));
4768 _for_each_inner_peripheral!((@ peri_type #[doc =
4769 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4770 "<section class=\"warning\">"] #[doc =
4771 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4772 #[doc = "<ul>"] #[doc =
4773 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4774 = "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()));
4775 _for_each_inner_peripheral!((@ peri_type #[doc =
4776 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4777 "<section class=\"warning\">"] #[doc =
4778 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4779 #[doc = "<ul>"] #[doc =
4780 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4781 = "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()));
4782 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH0 peripheral singleton"]
4783 DMA_CH0 <= virtual(DMA_IN_CH0 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4784 disable_dma_in_interrupt }, DMA_OUT_CH0 : { bind_dma_out_interrupt,
4785 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4786 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
4787 DMA_CH1 <= virtual(DMA_IN_CH1 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4788 disable_dma_in_interrupt }, DMA_OUT_CH1 : { bind_dma_out_interrupt,
4789 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4790 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH2 peripheral singleton"]
4791 DMA_CH2 <= virtual(DMA_IN_CH2 : { bind_dma_in_interrupt, enable_dma_in_interrupt,
4792 disable_dma_in_interrupt }, DMA_OUT_CH2 : { bind_dma_out_interrupt,
4793 enable_dma_out_interrupt, disable_dma_out_interrupt }) (unstable)));
4794 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH0 peripheral singleton"]
4795 SDM_CH0 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4796 = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
4797 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
4798 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4799 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
4800 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
4801 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4802 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4803 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
4804 _for_each_inner_peripheral!((@ peri_type #[doc =
4805 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
4806 _for_each_inner_peripheral!((@ peri_type #[doc = "CACHE peripheral singleton"]
4807 CACHE <= CACHE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4808 "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)));
4809 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
4810 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4811 "DS peripheral singleton"] DS <= DS() (unstable)));
4812 _for_each_inner_peripheral!((@ peri_type #[doc = "ECC peripheral singleton"] ECC
4813 <= ECC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4814 "ECDSA peripheral singleton"] ECDSA <= ECDSA() (unstable)));
4815 _for_each_inner_peripheral!((@ peri_type #[doc = "EFUSE peripheral singleton"]
4816 EFUSE <= EFUSE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4817 "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)));
4818 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
4819 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4820 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_EXT() (unstable)));
4821 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
4822 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4823 "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
4824 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
4825 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4826 "HUK peripheral singleton"] HUK <= HUK() (unstable)));
4827 _for_each_inner_peripheral!((@ peri_type #[doc =
4828 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4829 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4830 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4831 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4832 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
4833 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4834 _for_each_inner_peripheral!((@ peri_type #[doc =
4835 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
4836 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4837 _for_each_inner_peripheral!((@ peri_type #[doc =
4838 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4839 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4840 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
4841 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
4842 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4843 "KEYMNG peripheral singleton"] KEYMNG <= KEYMNG() (unstable)));
4844 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_ANA peripheral singleton"]
4845 LP_ANA <= LP_ANA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4846 "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)));
4847 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM0 peripheral singleton"]
4848 LP_APM0 <= LP_APM0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4849 = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
4850 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_GPIO peripheral singleton"]
4851 LP_GPIO <= LP_IO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4852 "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)));
4853 _for_each_inner_peripheral!((@ peri_type #[doc =
4854 "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <= LP_I2C_ANA_MST()
4855 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4856 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
4857 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
4858 LP_PERI <= LPPERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4859 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
4860 _for_each_inner_peripheral!((@ peri_type #[doc =
4861 "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
4862 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_UART peripheral singleton"]
4863 LP_UART <= LP_UART() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4864 = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)));
4865 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
4866 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4867 = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
4868 _for_each_inner_peripheral!((@ peri_type #[doc =
4869 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
4870 _for_each_inner_peripheral!((@ peri_type #[doc =
4871 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
4872 _for_each_inner_peripheral!((@ peri_type #[doc =
4873 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
4874 _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
4875 PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
4876 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
4877 disable_tx_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4878 #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
4879 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
4880 PCNT <= PCNT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4881 "PCR peripheral singleton"] PCR <= PCR() (unstable)));
4882 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
4883 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4884 "PVT_MONITOR peripheral singleton"] PVT_MONITOR <= PVT() (unstable)));
4885 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
4886 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4887 "RNG peripheral singleton"] RNG <= LPPERI() (unstable)));
4888 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
4889 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4890 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4891 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4892 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4893 _for_each_inner_peripheral!((@ peri_type #[doc = "SLC peripheral singleton"] SLC
4894 <= SLC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4895 "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
4896 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
4897 SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4898 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
4899 enable_peri_interrupt, disable_peri_interrupt })));
4900 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
4901 SYSTEM <= PCR() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4902 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
4903 _for_each_inner_peripheral!((@ peri_type #[doc = "TEE peripheral singleton"] TEE
4904 <= TEE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4905 "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
4906 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
4907 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4908 "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
4909 enable_peri_interrupt, disable_peri_interrupt })));
4910 _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
4911 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
4912 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4913 "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
4914 _for_each_inner_peripheral!((@ peri_type #[doc =
4915 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4916 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4917 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4918 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
4919 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4920 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
4921 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
4922 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4923 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
4924 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4925 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4926 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_CORE peripheral singleton"]
4927 LP_CORE <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4928 = "WIFI peripheral singleton"] WIFI <= virtual(WIFI_BB : { bind_bb_interrupt,
4929 enable_bb_interrupt, disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt,
4930 enable_mac_interrupt, disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt,
4931 enable_pwr_interrupt, disable_pwr_interrupt }))); _for_each_inner_peripheral!((@
4932 peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)));
4933 _for_each_inner_peripheral!((@ peri_type #[doc =
4934 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
4935 _for_each_inner_peripheral!((@ peri_type #[doc =
4936 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4937 _for_each_inner_peripheral!((@ peri_type #[doc =
4938 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4939 _for_each_inner_peripheral!((@ peri_type #[doc =
4940 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4941 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO0));
4942 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO1));
4943 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4944 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4945 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4946 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4947 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4948 _for_each_inner_peripheral!((GPIO12)); _for_each_inner_peripheral!((GPIO13));
4949 _for_each_inner_peripheral!((GPIO14)); _for_each_inner_peripheral!((GPIO15));
4950 _for_each_inner_peripheral!((GPIO16)); _for_each_inner_peripheral!((GPIO17));
4951 _for_each_inner_peripheral!((GPIO18)); _for_each_inner_peripheral!((GPIO19));
4952 _for_each_inner_peripheral!((GPIO20)); _for_each_inner_peripheral!((GPIO21));
4953 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
4954 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
4955 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
4956 _for_each_inner_peripheral!((GPIO28));
4957 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4958 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4959 _for_each_inner_peripheral!((DMA_CH2(unstable)));
4960 _for_each_inner_peripheral!((SDM_CH0(unstable)));
4961 _for_each_inner_peripheral!((SDM_CH1(unstable)));
4962 _for_each_inner_peripheral!((SDM_CH2(unstable)));
4963 _for_each_inner_peripheral!((SDM_CH3(unstable)));
4964 _for_each_inner_peripheral!((AES(unstable)));
4965 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
4966 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4967 _for_each_inner_peripheral!((CACHE(unstable)));
4968 _for_each_inner_peripheral!((CLINT(unstable)));
4969 _for_each_inner_peripheral!((DMA(unstable)));
4970 _for_each_inner_peripheral!((DS(unstable)));
4971 _for_each_inner_peripheral!((ECC(unstable)));
4972 _for_each_inner_peripheral!((ECDSA(unstable)));
4973 _for_each_inner_peripheral!((ETM(unstable)));
4974 _for_each_inner_peripheral!((GPIO(unstable)));
4975 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4976 _for_each_inner_peripheral!((HMAC(unstable)));
4977 _for_each_inner_peripheral!((HP_APM(unstable)));
4978 _for_each_inner_peripheral!((HP_SYS(unstable)));
4979 _for_each_inner_peripheral!((HUK(unstable)));
4980 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4981 _for_each_inner_peripheral!((I2C0));
4982 _for_each_inner_peripheral!((I2S0(unstable)));
4983 _for_each_inner_peripheral!((IEEE802154(unstable)));
4984 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4985 _for_each_inner_peripheral!((INTPRI(unstable)));
4986 _for_each_inner_peripheral!((IO_MUX(unstable)));
4987 _for_each_inner_peripheral!((KEYMNG(unstable)));
4988 _for_each_inner_peripheral!((LP_ANA(unstable)));
4989 _for_each_inner_peripheral!((LP_AON(unstable)));
4990 _for_each_inner_peripheral!((LP_APM0(unstable)));
4991 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
4992 _for_each_inner_peripheral!((LP_GPIO(unstable)));
4993 _for_each_inner_peripheral!((LP_I2C0(unstable)));
4994 _for_each_inner_peripheral!((LP_I2C_ANA_MST(unstable)));
4995 _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
4996 _for_each_inner_peripheral!((LP_PERI(unstable)));
4997 _for_each_inner_peripheral!((LP_TEE(unstable)));
4998 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4999 _for_each_inner_peripheral!((LP_UART(unstable)));
5000 _for_each_inner_peripheral!((LP_WDT(unstable)));
5001 _for_each_inner_peripheral!((LPWR(unstable)));
5002 _for_each_inner_peripheral!((MCPWM0(unstable)));
5003 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
5004 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
5005 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
5006 _for_each_inner_peripheral!((PARL_IO(unstable)));
5007 _for_each_inner_peripheral!((PAU(unstable)));
5008 _for_each_inner_peripheral!((PCNT(unstable)));
5009 _for_each_inner_peripheral!((PCR(unstable)));
5010 _for_each_inner_peripheral!((PMU(unstable)));
5011 _for_each_inner_peripheral!((PVT_MONITOR(unstable)));
5012 _for_each_inner_peripheral!((RMT(unstable)));
5013 _for_each_inner_peripheral!((RNG(unstable)));
5014 _for_each_inner_peripheral!((RSA(unstable)));
5015 _for_each_inner_peripheral!((SHA(unstable)));
5016 _for_each_inner_peripheral!((SLC(unstable)));
5017 _for_each_inner_peripheral!((SPI0(unstable)));
5018 _for_each_inner_peripheral!((SPI1(unstable)));
5019 _for_each_inner_peripheral!((SPI2));
5020 _for_each_inner_peripheral!((SYSTEM(unstable)));
5021 _for_each_inner_peripheral!((SYSTIMER(unstable)));
5022 _for_each_inner_peripheral!((TEE(unstable)));
5023 _for_each_inner_peripheral!((TIMG0(unstable)));
5024 _for_each_inner_peripheral!((TIMG1(unstable)));
5025 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
5026 _for_each_inner_peripheral!((UHCI0(unstable)));
5027 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
5028 _for_each_inner_peripheral!((ADC1(unstable)));
5029 _for_each_inner_peripheral!((BT(unstable)));
5030 _for_each_inner_peripheral!((FLASH(unstable)));
5031 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
5032 _for_each_inner_peripheral!((LP_CORE(unstable)));
5033 _for_each_inner_peripheral!((WIFI));
5034 _for_each_inner_peripheral!((PSRAM(unstable)));
5035 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
5036 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
5037 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
5038 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
5039 _for_each_inner_peripheral!((SPI2, Spi2, 1, AhbGdmaChannel));
5040 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
5041 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
5042 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
5043 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
5044 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
5045 _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
5046 _for_each_inner_peripheral!((all(@ peri_type #[doc =
5047 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
5048 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
5049 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5050 "<section class=\"warning\">"] #[doc =
5051 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5052 #[doc = "<ul>"] #[doc =
5053 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5054 =
5055 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5056 #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
5057 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5058 "<section class=\"warning\">"] #[doc =
5059 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5060 #[doc = "<ul>"] #[doc =
5061 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5062 =
5063 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5064 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
5065 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5066 "<section class=\"warning\">"] #[doc =
5067 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5068 #[doc = "<ul>"] #[doc =
5069 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5070 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
5071 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5072 "<section class=\"warning\">"] #[doc =
5073 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5074 #[doc = "<ul>"] #[doc =
5075 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
5076 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
5077 "GPIO6 peripheral singleton"] GPIO6 <= virtual()), (@ peri_type #[doc =
5078 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5079 "<section class=\"warning\">"] #[doc =
5080 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5081 #[doc = "<ul>"] #[doc =
5082 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5083 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
5084 "GPIO8 peripheral singleton"] GPIO8 <= virtual()), (@ peri_type #[doc =
5085 "GPIO9 peripheral singleton"] GPIO9 <= virtual()), (@ peri_type #[doc =
5086 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
5087 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5088 "<section class=\"warning\">"] #[doc =
5089 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5090 #[doc = "<ul>"] #[doc =
5091 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5092 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
5093 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5094 "<section class=\"warning\">"] #[doc =
5095 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5096 #[doc = "<ul>"] #[doc =
5097 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
5098 = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
5099 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5100 "<section class=\"warning\">"] #[doc =
5101 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5102 #[doc = "<ul>"] #[doc =
5103 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5104 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
5105 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5106 "<section class=\"warning\">"] #[doc =
5107 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5108 #[doc = "<ul>"] #[doc =
5109 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
5110 #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
5111 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5112 "<section class=\"warning\">"] #[doc =
5113 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5114 #[doc = "<ul>"] #[doc =
5115 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5116 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
5117 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5118 "<section class=\"warning\">"] #[doc =
5119 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5120 #[doc = "<ul>"] #[doc =
5121 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5122 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
5123 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5124 "<section class=\"warning\">"] #[doc =
5125 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5126 #[doc = "<ul>"] #[doc =
5127 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5128 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5129 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
5130 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5131 "<section class=\"warning\">"] #[doc =
5132 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5133 #[doc = "<ul>"] #[doc =
5134 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5135 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5136 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
5137 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5138 "<section class=\"warning\">"] #[doc =
5139 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5140 #[doc = "<ul>"] #[doc =
5141 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5142 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5143 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
5144 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5145 "<section class=\"warning\">"] #[doc =
5146 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5147 #[doc = "<ul>"] #[doc =
5148 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5149 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5150 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
5151 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5152 "<section class=\"warning\">"] #[doc =
5153 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5154 #[doc = "<ul>"] #[doc =
5155 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5156 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5157 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
5158 "GPIO22 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5159 "<section class=\"warning\">"] #[doc =
5160 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5161 #[doc = "<ul>"] #[doc =
5162 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
5163 "<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
5164 "</ul>"] #[doc = "</section>"] GPIO22 <= virtual()), (@ peri_type #[doc =
5165 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
5166 "GPIO24 peripheral singleton"] GPIO24 <= virtual()), (@ peri_type #[doc =
5167 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5168 "<section class=\"warning\">"] #[doc =
5169 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5170 #[doc = "<ul>"] #[doc =
5171 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5172 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
5173 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5174 "<section class=\"warning\">"] #[doc =
5175 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5176 #[doc = "<ul>"] #[doc =
5177 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5178 = "</ul>"] #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
5179 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5180 "<section class=\"warning\">"] #[doc =
5181 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5182 #[doc = "<ul>"] #[doc =
5183 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5184 = "</ul>"] #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
5185 "GPIO28 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
5186 "<section class=\"warning\">"] #[doc =
5187 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
5188 #[doc = "<ul>"] #[doc =
5189 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
5190 = "</ul>"] #[doc = "</section>"] GPIO28 <= virtual()), (@ peri_type #[doc =
5191 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
5192 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5193 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5194 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5195 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
5196 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5197 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5198 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5199 "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
5200 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
5201 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
5202 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
5203 "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual() (unstable)), (@ peri_type
5204 #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)), (@
5205 peri_type #[doc = "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual()
5206 (unstable)), (@ peri_type #[doc = "SDM_CH3 peripheral singleton"] SDM_CH3 <=
5207 virtual() (unstable)), (@ peri_type #[doc = "AES peripheral singleton"] AES <=
5208 AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5209 (unstable)), (@ peri_type #[doc = "ASSIST_DEBUG peripheral singleton"]
5210 ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)), (@ peri_type #[doc =
5211 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)), (@
5212 peri_type #[doc = "CACHE peripheral singleton"] CACHE <= CACHE() (unstable)), (@
5213 peri_type #[doc = "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)), (@
5214 peri_type #[doc = "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@
5215 peri_type #[doc = "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type
5216 #[doc = "ECC peripheral singleton"] ECC <= ECC() (unstable)), (@ peri_type #[doc
5217 = "ECDSA peripheral singleton"] ECDSA <= ECDSA() (unstable)), (@ peri_type #[doc
5218 = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc
5219 = "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)), (@ peri_type #[doc =
5220 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
5221 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_EXT() (unstable)), (@ peri_type
5222 #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)), (@ peri_type
5223 #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)), (@
5224 peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)),
5225 (@ peri_type #[doc = "HUK peripheral singleton"] HUK <= HUK() (unstable)), (@
5226 peri_type #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <=
5227 I2C_ANA_MST() (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0
5228 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
5229 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
5230 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
5231 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
5232 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
5233 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
5234 (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
5235 INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
5236 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
5237 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
5238 #[doc = "KEYMNG peripheral singleton"] KEYMNG <= KEYMNG() (unstable)), (@
5239 peri_type #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)),
5240 (@ peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON()
5241 (unstable)), (@ peri_type #[doc = "LP_APM0 peripheral singleton"] LP_APM0 <=
5242 LP_APM0() (unstable)), (@ peri_type #[doc = "LP_CLKRST peripheral singleton"]
5243 LP_CLKRST <= LP_CLKRST() (unstable)), (@ peri_type #[doc =
5244 "LP_GPIO peripheral singleton"] LP_GPIO <= LP_IO() (unstable)), (@ peri_type
5245 #[doc = "LP_I2C0 peripheral singleton"] LP_I2C0 <= LP_I2C0() (unstable)), (@
5246 peri_type #[doc = "LP_I2C_ANA_MST peripheral singleton"] LP_I2C_ANA_MST <=
5247 LP_I2C_ANA_MST() (unstable)), (@ peri_type #[doc =
5248 "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)), (@
5249 peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LPPERI()
5250 (unstable)), (@ peri_type #[doc = "LP_TEE peripheral singleton"] LP_TEE <=
5251 LP_TEE() (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"]
5252 RTC_TIMER <= LP_TIMER() (unstable)), (@ peri_type #[doc =
5253 "LP_UART peripheral singleton"] LP_UART <= LP_UART() (unstable)), (@ peri_type
5254 #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)), (@
5255 peri_type #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)),
5256 (@ peri_type #[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0()
5257 (unstable)), (@ peri_type #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR
5258 <= MEM_MONITOR() (unstable)), (@ peri_type #[doc =
5259 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)), (@
5260 peri_type #[doc = "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <=
5261 MODEM_SYSCON() (unstable)), (@ peri_type #[doc = "PARL_IO peripheral singleton"]
5262 PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
5263 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
5264 disable_tx_interrupt }) (unstable)), (@ peri_type #[doc =
5265 "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@ peri_type #[doc =
5266 "PCNT peripheral singleton"] PCNT <= PCNT() (unstable)), (@ peri_type #[doc =
5267 "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@ peri_type #[doc =
5268 "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@ peri_type #[doc =
5269 "PVT_MONITOR peripheral singleton"] PVT_MONITOR <= PVT() (unstable)), (@
5270 peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@
5271 peri_type #[doc = "RNG peripheral singleton"] RNG <= LPPERI() (unstable)), (@
5272 peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
5273 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5274 (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
5275 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5276 (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <= SLC()
5277 (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
5278 (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
5279 (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
5280 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
5281 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
5282 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
5283 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
5284 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
5285 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
5286 (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
5287 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
5288 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
5289 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
5290 disable_peri_interrupt })), (@ peri_type #[doc = "UHCI0 peripheral singleton"]
5291 UHCI0 <= UHCI0() (unstable)), (@ peri_type #[doc =
5292 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
5293 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
5294 (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"] ADC1 <= virtual()
5295 (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT <=
5296 virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
5297 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
5298 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
5299 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
5300 = "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
5301 (@ peri_type #[doc = "LP_CORE peripheral singleton"] LP_CORE <= virtual()
5302 (unstable)), (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <=
5303 virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt
5304 }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt
5305 }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt
5306 })), (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual()
5307 (unstable)), (@ peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"]
5308 FROM_CPU_INTR0 <= virtual() (unstable)), (@ peri_type #[doc =
5309 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
5310 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
5311 virtual() (unstable)), (@ peri_type #[doc =
5312 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
5313 _for_each_inner_peripheral!((singletons(#[cfg(not(use_xtal32k))] GPIO0),
5314 (#[cfg(not(use_xtal32k))] GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6),
5315 (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14),
5316 (GPIO15), (GPIO16), (GPIO17), (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22),
5317 (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (GPIO28), (DMA_CH0(unstable)),
5318 (DMA_CH1(unstable)), (DMA_CH2(unstable)), (SDM_CH0(unstable)),
5319 (SDM_CH1(unstable)), (SDM_CH2(unstable)), (SDM_CH3(unstable)), (AES(unstable)),
5320 (ASSIST_DEBUG(unstable)), (APB_SARADC(unstable)), (CACHE(unstable)),
5321 (CLINT(unstable)), (DMA(unstable)), (DS(unstable)), (ECC(unstable)),
5322 (ECDSA(unstable)), (ETM(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)),
5323 (HMAC(unstable)), (HP_APM(unstable)), (HP_SYS(unstable)), (HUK(unstable)),
5324 (I2C_ANA_MST(unstable)), (I2C0), (I2S0(unstable)), (IEEE802154(unstable)),
5325 (INTERRUPT_CORE0(unstable)), (INTPRI(unstable)), (IO_MUX(unstable)),
5326 (KEYMNG(unstable)), (LP_ANA(unstable)), (LP_AON(unstable)), (LP_APM0(unstable)),
5327 (LP_CLKRST(unstable)), (LP_GPIO(unstable)), (LP_I2C0(unstable)),
5328 (LP_I2C_ANA_MST(unstable)), (LP_IO_MUX(unstable)), (LP_PERI(unstable)),
5329 (LP_TEE(unstable)), (RTC_TIMER(unstable)), (LP_UART(unstable)),
5330 (LP_WDT(unstable)), (LPWR(unstable)), (MCPWM0(unstable)),
5331 (MEM_MONITOR(unstable)), (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)),
5332 (PARL_IO(unstable)), (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)),
5333 (PMU(unstable)), (PVT_MONITOR(unstable)), (RMT(unstable)), (RNG(unstable)),
5334 (RSA(unstable)), (SHA(unstable)), (SLC(unstable)), (SPI0(unstable)),
5335 (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
5336 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (UART0), (UART1),
5337 (UHCI0(unstable)), (USB_DEVICE(unstable)), (ADC1(unstable)), (BT(unstable)),
5338 (FLASH(unstable)), (GPIO_DEDICATED(unstable)), (LP_CORE(unstable)), (WIFI),
5339 (PSRAM(unstable)), (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
5340 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
5341 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 1, AhbGdmaChannel), (UHCI0,
5342 Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3, AhbGdmaChannel), (AES, Aes, 6,
5343 AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel), (APB_SARADC, ApbSaradc, 8,
5344 AhbGdmaChannel), (PARL_IO, ParlIo, 9, AhbGdmaChannel)));
5345 };
5346}
5347#[macro_export]
5374#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5375macro_rules! for_each_gpio {
5376 ($($pattern:tt => $code:tt;)*) => {
5377 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5378 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
5379 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
5380 _for_each_inner_gpio!((2, GPIO2(_0 => MTMS _2 => FSPIQ) (_2 => FSPIQ) ([Input]
5381 [Output]))); _for_each_inner_gpio!((3, GPIO3(_0 => MTDI) () ([Input] [Output])));
5382 _for_each_inner_gpio!((4, GPIO4(_0 => MTCK _2 => FSPIHD) (_2 => FSPIHD) ([Input]
5383 [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTDO _2 => FSPIWP) (_2 =>
5384 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_2 => FSPICLK) (_2
5385 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_0 =>
5386 SDIO_DATA1 _2 => FSPID) (_2 => FSPID) ([Input] [Output])));
5387 _for_each_inner_gpio!((8, GPIO8(_0 => SDIO_DATA0) () ([Input] [Output])));
5388 _for_each_inner_gpio!((9, GPIO9(_0 => SDIO_CLK) () ([Input] [Output])));
5389 _for_each_inner_gpio!((10, GPIO10(_0 => SDIO_CMD _2 => FSPICS0) (_2 => FSPICS0)
5390 ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11() (_0 => U0TXD) ([Input]
5391 [Output]))); _for_each_inner_gpio!((12, GPIO12(_0 => U0RXD) () ([Input]
5392 [Output]))); _for_each_inner_gpio!((13, GPIO13(_0 => SDIO_DATA3) () ([Input]
5393 [Output]))); _for_each_inner_gpio!((14, GPIO14(_0 => SDIO_DATA2) () ([Input]
5394 [Output]))); _for_each_inner_gpio!((15, GPIO15() () ([Input] [Output])));
5395 _for_each_inner_gpio!((16, GPIO16() () ([Input] [Output])));
5396 _for_each_inner_gpio!((17, GPIO17() () ([Input] [Output])));
5397 _for_each_inner_gpio!((18, GPIO18() () ([Input] [Output])));
5398 _for_each_inner_gpio!((19, GPIO19() () ([Input] [Output])));
5399 _for_each_inner_gpio!((20, GPIO20() () ([Input] [Output])));
5400 _for_each_inner_gpio!((21, GPIO21() () ([Input] [Output])));
5401 _for_each_inner_gpio!((22, GPIO22() () ([Input] [Output])));
5402 _for_each_inner_gpio!((23, GPIO23() () ([Input] [Output])));
5403 _for_each_inner_gpio!((24, GPIO24() () ([Input] [Output])));
5404 _for_each_inner_gpio!((25, GPIO25() () ([Input] [Output])));
5405 _for_each_inner_gpio!((26, GPIO26() () ([Input] [Output])));
5406 _for_each_inner_gpio!((27, GPIO27() () ([Input] [Output])));
5407 _for_each_inner_gpio!((28, GPIO28() () ([Input] [Output])));
5408 _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1, GPIO1() ()
5409 ([Input] [Output])), (2, GPIO2(_0 => MTMS _2 => FSPIQ) (_2 => FSPIQ) ([Input]
5410 [Output])), (3, GPIO3(_0 => MTDI) () ([Input] [Output])), (4, GPIO4(_0 => MTCK _2
5411 => FSPIHD) (_2 => FSPIHD) ([Input] [Output])), (5, GPIO5(_0 => MTDO _2 => FSPIWP)
5412 (_2 => FSPIWP) ([Input] [Output])), (6, GPIO6(_2 => FSPICLK) (_2 => FSPICLK)
5413 ([Input] [Output])), (7, GPIO7(_0 => SDIO_DATA1 _2 => FSPID) (_2 => FSPID)
5414 ([Input] [Output])), (8, GPIO8(_0 => SDIO_DATA0) () ([Input] [Output])), (9,
5415 GPIO9(_0 => SDIO_CLK) () ([Input] [Output])), (10, GPIO10(_0 => SDIO_CMD _2 =>
5416 FSPICS0) (_2 => FSPICS0) ([Input] [Output])), (11, GPIO11() (_0 => U0TXD)
5417 ([Input] [Output])), (12, GPIO12(_0 => U0RXD) () ([Input] [Output])), (13,
5418 GPIO13(_0 => SDIO_DATA3) () ([Input] [Output])), (14, GPIO14(_0 => SDIO_DATA2) ()
5419 ([Input] [Output])), (15, GPIO15() () ([Input] [Output])), (16, GPIO16() ()
5420 ([Input] [Output])), (17, GPIO17() () ([Input] [Output])), (18, GPIO18() ()
5421 ([Input] [Output])), (19, GPIO19() () ([Input] [Output])), (20, GPIO20() ()
5422 ([Input] [Output])), (21, GPIO21() () ([Input] [Output])), (22, GPIO22() ()
5423 ([Input] [Output])), (23, GPIO23() () ([Input] [Output])), (24, GPIO24() ()
5424 ([Input] [Output])), (25, GPIO25() () ([Input] [Output])), (26, GPIO26() ()
5425 ([Input] [Output])), (27, GPIO27() () ([Input] [Output])), (28, GPIO28() ()
5426 ([Input] [Output]))));
5427 };
5428}
5429#[macro_export]
5456#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5457macro_rules! for_each_analog_function {
5458 ($($pattern:tt => $code:tt;)*) => {
5459 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5460 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
5461 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
5462 _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
5463 _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
5464 _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
5465 _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
5466 _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
5467 _for_each_inner_analog_function!((ADC1_CH5, GPIO6));
5468 _for_each_inner_analog_function!((ZCD0, GPIO8));
5469 _for_each_inner_analog_function!((ZCD1, GPIO9));
5470 _for_each_inner_analog_function!((USJ_DM, GPIO13));
5471 _for_each_inner_analog_function!((USJ_DP, GPIO14));
5472 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
5473 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
5474 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
5475 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
5476 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
5477 _for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6));
5478 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO8));
5479 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO9));
5480 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (XTAL_32K_N, GPIO1),
5481 (ADC1_CH0, GPIO1), (ADC1_CH1, GPIO2), (ADC1_CH2, GPIO3), (ADC1_CH3, GPIO4),
5482 (ADC1_CH4, GPIO5), (ADC1_CH5, GPIO6), (ZCD0, GPIO8), (ZCD1, GPIO9), (USJ_DM,
5483 GPIO13), (USJ_DP, GPIO14)));
5484 _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1),
5485 ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3),
5486 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5),
5487 ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO6)));
5488 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO8), ((ZCD1, ZCDn, 1),
5489 GPIO9)));
5490 };
5491}
5492#[macro_export]
5530#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5531macro_rules! for_each_lp_function {
5532 ($($pattern:tt => $code:tt;)*) => {
5533 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5534 => {} } _for_each_inner_lp_function!((LP_UART_DTRN, GPIO0, _0));
5535 _for_each_inner_lp_function!((LP_GPIO0, GPIO0, _1));
5536 _for_each_inner_lp_function!((LP_UART_DSRN, GPIO1, _0));
5537 _for_each_inner_lp_function!((LP_GPIO1, GPIO1, _1));
5538 _for_each_inner_lp_function!((LP_UART_RTSN, GPIO2, _0));
5539 _for_each_inner_lp_function!((LP_GPIO2, GPIO2, _1));
5540 _for_each_inner_lp_function!((LP_I2C_SDA, GPIO2, _3));
5541 _for_each_inner_lp_function!((LP_UART_CTSN, GPIO3, _0));
5542 _for_each_inner_lp_function!((LP_GPIO3, GPIO3, _1));
5543 _for_each_inner_lp_function!((LP_I2C_SCL, GPIO3, _3));
5544 _for_each_inner_lp_function!((LP_UART_RXD, GPIO4, _0));
5545 _for_each_inner_lp_function!((LP_GPIO4, GPIO4, _1));
5546 _for_each_inner_lp_function!((LP_UART_TXD, GPIO5, _0));
5547 _for_each_inner_lp_function!((LP_GPIO5, GPIO5, _1));
5548 _for_each_inner_lp_function!((LP_GPIO6, GPIO6, _1));
5549 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO0, _1, () ()));
5550 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()));
5551 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()));
5552 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1, () ()));
5553 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()));
5554 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO5, _1, () ()));
5555 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ()));
5556 _for_each_inner_lp_function!((all(LP_UART_DTRN, GPIO0, _0), (LP_GPIO0, GPIO0,
5557 _1), (LP_UART_DSRN, GPIO1, _0), (LP_GPIO1, GPIO1, _1), (LP_UART_RTSN, GPIO2, _0),
5558 (LP_GPIO2, GPIO2, _1), (LP_I2C_SDA, GPIO2, _3), (LP_UART_CTSN, GPIO3, _0),
5559 (LP_GPIO3, GPIO3, _1), (LP_I2C_SCL, GPIO3, _3), (LP_UART_RXD, GPIO4, _0),
5560 (LP_GPIO4, GPIO4, _1), (LP_UART_TXD, GPIO5, _0), (LP_GPIO5, GPIO5, _1),
5561 (LP_GPIO6, GPIO6, _1))); _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0,
5562 LP_GPIOn, 0), GPIO0, _1, () ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO1, _1, () ()),
5563 ((LP_GPIO2, LP_GPIOn, 2), GPIO2, _1, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO3, _1,
5564 () ()), ((LP_GPIO4, LP_GPIOn, 4), GPIO4, _1, () ()), ((LP_GPIO5, LP_GPIOn, 5),
5565 GPIO5, _1, () ()), ((LP_GPIO6, LP_GPIOn, 6), GPIO6, _1, () ())));
5566 };
5567}
5568#[macro_export]
5599#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5600macro_rules! for_each_iomux_function {
5601 ($($pattern:tt => $code:tt;)*) => {
5602 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5603 tt) => {} } _for_each_inner_iomux_function!((MTMS, GPIO2, _0));
5604 _for_each_inner_iomux_function!((FSPIQ, GPIO2, _2));
5605 _for_each_inner_iomux_function!((MTDI, GPIO3, _0));
5606 _for_each_inner_iomux_function!((MTCK, GPIO4, _0));
5607 _for_each_inner_iomux_function!((FSPIHD, GPIO4, _2));
5608 _for_each_inner_iomux_function!((MTDO, GPIO5, _0));
5609 _for_each_inner_iomux_function!((FSPIWP, GPIO5, _2));
5610 _for_each_inner_iomux_function!((FSPICLK, GPIO6, _2));
5611 _for_each_inner_iomux_function!((SDIO_DATA1, GPIO7, _0));
5612 _for_each_inner_iomux_function!((FSPID, GPIO7, _2));
5613 _for_each_inner_iomux_function!((SDIO_DATA0, GPIO8, _0));
5614 _for_each_inner_iomux_function!((SDIO_CLK, GPIO9, _0));
5615 _for_each_inner_iomux_function!((SDIO_CMD, GPIO10, _0));
5616 _for_each_inner_iomux_function!((FSPICS0, GPIO10, _2));
5617 _for_each_inner_iomux_function!((U0TXD, GPIO11, _0));
5618 _for_each_inner_iomux_function!((U0RXD, GPIO12, _0));
5619 _for_each_inner_iomux_function!((SDIO_DATA3, GPIO13, _0));
5620 _for_each_inner_iomux_function!((SDIO_DATA2, GPIO14, _0));
5621 _for_each_inner_iomux_function!(((SDIO_DATA1, SDIO_DATAn, 1), GPIO7, _0));
5622 _for_each_inner_iomux_function!(((SDIO_DATA0, SDIO_DATAn, 0), GPIO8, _0));
5623 _for_each_inner_iomux_function!(((SDIO_DATA3, SDIO_DATAn, 3), GPIO13, _0));
5624 _for_each_inner_iomux_function!(((SDIO_DATA2, SDIO_DATAn, 2), GPIO14, _0));
5625 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO10, _2));
5626 _for_each_inner_iomux_function!((all(MTMS, GPIO2, _0), (FSPIQ, GPIO2, _2), (MTDI,
5627 GPIO3, _0), (MTCK, GPIO4, _0), (FSPIHD, GPIO4, _2), (MTDO, GPIO5, _0), (FSPIWP,
5628 GPIO5, _2), (FSPICLK, GPIO6, _2), (SDIO_DATA1, GPIO7, _0), (FSPID, GPIO7, _2),
5629 (SDIO_DATA0, GPIO8, _0), (SDIO_CLK, GPIO9, _0), (SDIO_CMD, GPIO10, _0), (FSPICS0,
5630 GPIO10, _2), (U0TXD, GPIO11, _0), (U0RXD, GPIO12, _0), (SDIO_DATA3, GPIO13, _0),
5631 (SDIO_DATA2, GPIO14, _0)));
5632 _for_each_inner_iomux_function!((SDIO_DATAn((SDIO_DATA1, SDIO_DATAn, 1), GPIO7,
5633 _0), ((SDIO_DATA0, SDIO_DATAn, 0), GPIO8, _0), ((SDIO_DATA3, SDIO_DATAn, 3),
5634 GPIO13, _0), ((SDIO_DATA2, SDIO_DATAn, 2), GPIO14, _0)));
5635 _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO10, _2)));
5636 };
5637}
5638#[macro_export]
5655#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5656macro_rules! gpio_for_signal {
5657 (XTAL_32K_P $(, $_fallback:literal)?) => {
5658 "GPIO0"
5659 };
5660 (LP_UART_DTRN $(, $_fallback:literal)?) => {
5661 "GPIO0"
5662 };
5663 (LP_GPIO0 $(, $_fallback:literal)?) => {
5664 "GPIO0"
5665 };
5666 (XTAL_32K_N $(, $_fallback:literal)?) => {
5667 "GPIO1"
5668 };
5669 (ADC1_CH0 $(, $_fallback:literal)?) => {
5670 "GPIO1"
5671 };
5672 (LP_UART_DSRN $(, $_fallback:literal)?) => {
5673 "GPIO1"
5674 };
5675 (LP_GPIO1 $(, $_fallback:literal)?) => {
5676 "GPIO1"
5677 };
5678 (MTMS $(, $_fallback:literal)?) => {
5679 "GPIO2"
5680 };
5681 (FSPIQ $(, $_fallback:literal)?) => {
5682 "GPIO2"
5683 };
5684 (ADC1_CH1 $(, $_fallback:literal)?) => {
5685 "GPIO2"
5686 };
5687 (LP_UART_RTSN $(, $_fallback:literal)?) => {
5688 "GPIO2"
5689 };
5690 (LP_GPIO2 $(, $_fallback:literal)?) => {
5691 "GPIO2"
5692 };
5693 (LP_I2C_SDA $(, $_fallback:literal)?) => {
5694 "GPIO2"
5695 };
5696 (MTDI $(, $_fallback:literal)?) => {
5697 "GPIO3"
5698 };
5699 (ADC1_CH2 $(, $_fallback:literal)?) => {
5700 "GPIO3"
5701 };
5702 (LP_UART_CTSN $(, $_fallback:literal)?) => {
5703 "GPIO3"
5704 };
5705 (LP_GPIO3 $(, $_fallback:literal)?) => {
5706 "GPIO3"
5707 };
5708 (LP_I2C_SCL $(, $_fallback:literal)?) => {
5709 "GPIO3"
5710 };
5711 (MTCK $(, $_fallback:literal)?) => {
5712 "GPIO4"
5713 };
5714 (FSPIHD $(, $_fallback:literal)?) => {
5715 "GPIO4"
5716 };
5717 (ADC1_CH3 $(, $_fallback:literal)?) => {
5718 "GPIO4"
5719 };
5720 (LP_UART_RXD $(, $_fallback:literal)?) => {
5721 "GPIO4"
5722 };
5723 (LP_GPIO4 $(, $_fallback:literal)?) => {
5724 "GPIO4"
5725 };
5726 (MTDO $(, $_fallback:literal)?) => {
5727 "GPIO5"
5728 };
5729 (FSPIWP $(, $_fallback:literal)?) => {
5730 "GPIO5"
5731 };
5732 (ADC1_CH4 $(, $_fallback:literal)?) => {
5733 "GPIO5"
5734 };
5735 (LP_UART_TXD $(, $_fallback:literal)?) => {
5736 "GPIO5"
5737 };
5738 (LP_GPIO5 $(, $_fallback:literal)?) => {
5739 "GPIO5"
5740 };
5741 (FSPICLK $(, $_fallback:literal)?) => {
5742 "GPIO6"
5743 };
5744 (ADC1_CH5 $(, $_fallback:literal)?) => {
5745 "GPIO6"
5746 };
5747 (LP_GPIO6 $(, $_fallback:literal)?) => {
5748 "GPIO6"
5749 };
5750 (SDIO_DATA1 $(, $_fallback:literal)?) => {
5751 "GPIO7"
5752 };
5753 (FSPID $(, $_fallback:literal)?) => {
5754 "GPIO7"
5755 };
5756 (SDIO_DATA0 $(, $_fallback:literal)?) => {
5757 "GPIO8"
5758 };
5759 (ZCD0 $(, $_fallback:literal)?) => {
5760 "GPIO8"
5761 };
5762 (SDIO_CLK $(, $_fallback:literal)?) => {
5763 "GPIO9"
5764 };
5765 (ZCD1 $(, $_fallback:literal)?) => {
5766 "GPIO9"
5767 };
5768 (SDIO_CMD $(, $_fallback:literal)?) => {
5769 "GPIO10"
5770 };
5771 (FSPICS0 $(, $_fallback:literal)?) => {
5772 "GPIO10"
5773 };
5774 (U0TXD $(, $_fallback:literal)?) => {
5775 "GPIO11"
5776 };
5777 (U0RXD $(, $_fallback:literal)?) => {
5778 "GPIO12"
5779 };
5780 (SDIO_DATA3 $(, $_fallback:literal)?) => {
5781 "GPIO13"
5782 };
5783 (USJ_DM $(, $_fallback:literal)?) => {
5784 "GPIO13"
5785 };
5786 (SDIO_DATA2 $(, $_fallback:literal)?) => {
5787 "GPIO14"
5788 };
5789 (USJ_DP $(, $_fallback:literal)?) => {
5790 "GPIO14"
5791 };
5792 ($_signal:ident, $fallback:literal) => {
5793 $fallback
5794 };
5795}
5796#[macro_export]
5800#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5801macro_rules! define_io_mux_signals {
5802 () => {
5803 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5804 #[derive(Debug, PartialEq, Copy, Clone)]
5805 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5806 #[doc(hidden)]
5807 pub enum InputSignal {
5808 U0RXD = 6,
5809 U0CTS = 7,
5810 U0DSR = 8,
5811 U1RXD = 9,
5812 U1CTS = 10,
5813 U1DSR = 11,
5814 I2S_MCLK = 12,
5815 I2SO_BCK = 13,
5816 I2SO_WS = 14,
5817 I2SI_SD = 15,
5818 I2SI_BCK = 16,
5819 I2SI_WS = 17,
5820 CPU_GPIO_0 = 27,
5821 CPU_GPIO_1 = 28,
5822 CPU_GPIO_2 = 29,
5823 CPU_GPIO_3 = 30,
5824 CPU_GPIO_4 = 31,
5825 CPU_GPIO_5 = 32,
5826 CPU_GPIO_6 = 33,
5827 CPU_GPIO_7 = 34,
5828 USB_JTAG_TDO_BRIDGE = 35,
5829 I2CEXT0_SCL = 46,
5830 I2CEXT0_SDA = 47,
5831 PARL_RX_DATA0 = 48,
5832 PARL_RX_DATA1 = 49,
5833 PARL_RX_DATA2 = 50,
5834 PARL_RX_DATA3 = 51,
5835 PARL_RX_DATA4 = 52,
5836 PARL_RX_DATA5 = 53,
5837 PARL_RX_DATA6 = 54,
5838 PARL_RX_DATA7 = 55,
5839 FSPICLK = 56,
5840 FSPIQ = 57,
5841 FSPID = 58,
5842 FSPIHD = 59,
5843 FSPIWP = 60,
5844 FSPICS0 = 61,
5845 PARL_RX_CLK = 62,
5846 PARL_TX_CLK = 63,
5847 RMT_SIG_0 = 64,
5848 RMT_SIG_1 = 65,
5849 TWAI0_RX = 66,
5850 TWAI1_RX = 70,
5851 PCNT0_RST = 76,
5852 PCNT1_RST = 77,
5853 PCNT2_RST = 78,
5854 PCNT3_RST = 79,
5855 PWM0_SYNC0 = 80,
5856 PWM0_SYNC1 = 81,
5857 PWM0_SYNC2 = 82,
5858 PWM0_F0 = 83,
5859 PWM0_F1 = 84,
5860 PWM0_F2 = 85,
5861 PWM0_CAP0 = 86,
5862 PWM0_CAP1 = 87,
5863 PWM0_CAP2 = 88,
5864 SIG_IN_FUNC97 = 97,
5865 SIG_IN_FUNC98 = 98,
5866 SIG_IN_FUNC99 = 99,
5867 SIG_IN_FUNC100 = 100,
5868 PCNT0_SIG_CH0 = 101,
5869 PCNT0_SIG_CH1 = 102,
5870 PCNT0_CTRL_CH0 = 103,
5871 PCNT0_CTRL_CH1 = 104,
5872 PCNT1_SIG_CH0 = 105,
5873 PCNT1_SIG_CH1 = 106,
5874 PCNT1_CTRL_CH0 = 107,
5875 PCNT1_CTRL_CH1 = 108,
5876 PCNT2_SIG_CH0 = 109,
5877 PCNT2_SIG_CH1 = 110,
5878 PCNT2_CTRL_CH0 = 111,
5879 PCNT2_CTRL_CH1 = 112,
5880 PCNT3_SIG_CH0 = 113,
5881 PCNT3_SIG_CH1 = 114,
5882 PCNT3_CTRL_CH0 = 115,
5883 PCNT3_CTRL_CH1 = 116,
5884 SDIO_CLK,
5885 SDIO_CMD,
5886 SDIO_DATA0,
5887 SDIO_DATA1,
5888 SDIO_DATA2,
5889 SDIO_DATA3,
5890 MTDI,
5891 MTDO,
5892 MTCK,
5893 MTMS,
5894 }
5895 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5896 #[derive(Debug, PartialEq, Copy, Clone)]
5897 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5898 #[doc(hidden)]
5899 pub enum OutputSignal {
5900 LEDC_LS_SIG0 = 0,
5901 LEDC_LS_SIG1 = 1,
5902 LEDC_LS_SIG2 = 2,
5903 LEDC_LS_SIG3 = 3,
5904 LEDC_LS_SIG4 = 4,
5905 LEDC_LS_SIG5 = 5,
5906 U0TXD = 6,
5907 U0RTS = 7,
5908 U0DTR = 8,
5909 U1TXD = 9,
5910 U1RTS = 10,
5911 U1DTR = 11,
5912 I2S_MCLK = 12,
5913 I2SO_BCK = 13,
5914 I2SO_WS = 14,
5915 I2SO_SD = 15,
5916 I2SI_BCK = 16,
5917 I2SI_WS = 17,
5918 I2SO_SD1 = 18,
5919 CPU_GPIO_0 = 27,
5920 CPU_GPIO_1 = 28,
5921 CPU_GPIO_2 = 29,
5922 CPU_GPIO_3 = 30,
5923 CPU_GPIO_4 = 31,
5924 CPU_GPIO_5 = 32,
5925 CPU_GPIO_6 = 33,
5926 CPU_GPIO_7 = 34,
5927 I2CEXT0_SCL = 46,
5928 I2CEXT0_SDA = 47,
5929 PARL_TX_DATA0 = 48,
5930 PARL_TX_DATA1 = 49,
5931 PARL_TX_DATA2 = 50,
5932 PARL_TX_DATA3 = 51,
5933 PARL_TX_DATA4 = 52,
5934 PARL_TX_DATA5 = 53,
5935 PARL_TX_DATA6 = 54,
5936 PARL_TX_DATA7 = 55,
5937 FSPICLK = 56,
5938 FSPIQ = 57,
5939 FSPID = 58,
5940 FSPIHD = 59,
5941 FSPIWP = 60,
5942 FSPICS0 = 61,
5943 PARL_RX_CLK = 62,
5944 PARL_TX_CLK = 63,
5945 RMT_SIG_0 = 64,
5946 RMT_SIG_1 = 65,
5947 TWAI0_TX = 66,
5948 TWAI0_BUS_OFF_ON = 67,
5949 TWAI0_CLKOUT = 68,
5950 TWAI0_STANDBY = 69,
5951 TWAI1_TX = 70,
5952 TWAI1_BUS_OFF_ON = 71,
5953 TWAI1_CLKOUT = 72,
5954 TWAI1_STANDBY = 73,
5955 GPIO_SD0 = 76,
5956 GPIO_SD1 = 77,
5957 GPIO_SD2 = 78,
5958 GPIO_SD3 = 79,
5959 PWM0_0A = 80,
5960 PWM0_0B = 81,
5961 PWM0_1A = 82,
5962 PWM0_1B = 83,
5963 PWM0_2A = 84,
5964 PWM0_2B = 85,
5965 PARL_TX_CS = 86,
5966 SIG_IN_FUNC97 = 97,
5967 SIG_IN_FUNC98 = 98,
5968 SIG_IN_FUNC99 = 99,
5969 SIG_IN_FUNC100 = 100,
5970 FSPICS1 = 101,
5971 FSPICS2 = 102,
5972 FSPICS3 = 103,
5973 FSPICS4 = 104,
5974 FSPICS5 = 105,
5975 GPIO = 256,
5976 }
5977 };
5978}
5979#[macro_export]
5986#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5987macro_rules! define_lp_functions {
5988 () => {
5989 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5994 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5995 #[doc(hidden)]
5996 pub enum LpFunction {
5997 _0 = 0,
5999 _1 = 1,
6001 _3 = 3,
6003 }
6004 impl LpFunction {
6005 pub const LP_GPIO: Self = Self::_1;
6007 }
6008 };
6009}
6010#[macro_export]
6023#[expect(clippy::crate_in_macro_def)]
6024#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
6025macro_rules! define_io_mux_reg {
6026 () => {
6027 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
6028 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
6029 }
6030 };
6031}