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 "esp32h2"
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-H2"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32h2"
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-h2_technical_reference_manual_en.pdf"
54 };
55 ("gpio.version") => {
56 2
57 };
58 ("gpio.version", str) => {
59 stringify!(2)
60 };
61 ("gpio.has_input_sync") => {
62 true
63 };
64 ("gpio.gpio_function") => {
65 1
66 };
67 ("gpio.gpio_function", str) => {
68 stringify!(1)
69 };
70 ("gpio.constant_0_input") => {
71 60
72 };
73 ("gpio.constant_0_input", str) => {
74 stringify!(60)
75 };
76 ("gpio.constant_1_input") => {
77 56
78 };
79 ("gpio.constant_1_input", str) => {
80 stringify!(56)
81 };
82 ("gpio.remap_iomux_pin_registers") => {
83 false
84 };
85 ("gpio.func_in_sel_offset") => {
86 0
87 };
88 ("gpio.func_in_sel_offset", str) => {
89 stringify!(0)
90 };
91 ("gpio.has_bank_1") => {
92 false
93 };
94 ("gpio.input_signal_max") => {
95 124
96 };
97 ("gpio.input_signal_max", str) => {
98 stringify!(124)
99 };
100 ("gpio.output_signal_max") => {
101 128
102 };
103 ("gpio.output_signal_max", str) => {
104 stringify!(128)
105 };
106 ("dedicated_gpio.version") => {
107 "riscv_v1"
108 };
109 ("dedicated_gpio.needs_initialization") => {
110 false
111 };
112 ("dedicated_gpio.channel_count") => {
113 8
114 };
115 ("dedicated_gpio.channel_count", str) => {
116 stringify!(8)
117 };
118 ("lp_io.version") => {
119 "esp32h2"
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 false
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 ("spi_master.version") => {
206 3
207 };
208 ("spi_master.version", str) => {
209 stringify!(3)
210 };
211 ("spi_master.fifo_size") => {
212 64
213 };
214 ("spi_master.fifo_size", str) => {
215 stringify!(64)
216 };
217 ("spi_master.bit_order_is_bool") => {
218 false
219 };
220 ("spi_master.has_octal") => {
221 false
222 };
223 ("spi_master.has_app_interrupts") => {
224 true
225 };
226 ("spi_master.has_dma_segmented_transfer") => {
227 true
228 };
229 ("spi_master.has_clk_pre_div") => {
230 false
231 };
232 ("spi_master.dma_can_access_flash") => {
233 false
234 };
235 ("i2s.version") => {
236 3
237 };
238 ("i2s.version", str) => {
239 stringify!(3)
240 };
241 ("i2s.default_clock_source") => {
242 1
243 };
244 ("i2s.default_clock_source", str) => {
245 stringify!(1)
246 };
247 ("i2s.mclk_divider_bit_width") => {
248 9
249 };
250 ("i2s.mclk_divider_bit_width", str) => {
251 stringify!(9)
252 };
253 ("i2s.max_ws_width") => {
254 512
255 };
256 ("i2s.max_ws_width", str) => {
257 stringify!(512)
258 };
259 ("i2s.clock_configured_by_pcr") => {
260 true
261 };
262 ("i2s.clock_configured_by_hp_sys_clkrst") => {
263 false
264 };
265 ("i2s.supports_pdm_rx_hp_filter") => {
266 false
267 };
268 ("i2s.supports_pdm_tx") => {
269 true
270 };
271 ("i2s.supports_pdm_rx") => {
272 true
273 };
274 ("i2s.supports_pcm2pdm") => {
275 true
276 };
277 ("i2s.supports_pdm2pcm") => {
278 false
279 };
280 ("parl_io.version") => {
281 2
282 };
283 ("parl_io.version", str) => {
284 stringify!(2)
285 };
286 ("rmt.ram_start") => {
287 1610642432
288 };
289 ("rmt.ram_start", str) => {
290 stringify!(1610642432)
291 };
292 ("rmt.channel_ram_size") => {
293 48
294 };
295 ("rmt.channel_ram_size", str) => {
296 stringify!(48)
297 };
298 ("rmt.has_tx_immediate_stop") => {
299 true
300 };
301 ("rmt.has_tx_loop_count") => {
302 true
303 };
304 ("rmt.has_tx_loop_auto_stop") => {
305 true
306 };
307 ("rmt.has_tx_carrier_data_only") => {
308 true
309 };
310 ("rmt.has_tx_sync") => {
311 true
312 };
313 ("rmt.has_rx_wrap") => {
314 true
315 };
316 ("rmt.has_rx_demodulation") => {
317 true
318 };
319 ("rmt.has_per_channel_clock") => {
320 false
321 };
322 ("bt.controller") => {
323 "npl"
324 };
325 ("phy.combo_module") => {
326 false
327 };
328 ("ledc.version") => {
329 3
330 };
331 ("ledc.version", str) => {
332 stringify!(3)
333 };
334 ("ledc.channel_count") => {
335 6
336 };
337 ("ledc.channel_count", str) => {
338 stringify!(6)
339 };
340 ("sdm.channel_count") => {
341 4
342 };
343 ("sdm.channel_count", str) => {
344 stringify!(4)
345 };
346 ("timergroup.timg_has_timer1") => {
347 false
348 };
349 ("timergroup.timg_has_divcnt_rst") => {
350 true
351 };
352 ("timergroup.rc_fast_calibration_divider_min_rev") => {
353 2
354 };
355 ("timergroup.rc_fast_calibration_divider") => {
356 32
357 };
358 ("timergroup.rc_fast_calibration_tick_enable") => {
359 true
360 };
361 ("aes.has_split_text_registers") => {
362 true
363 };
364 ("aes.endianness_configurable") => {
365 false
366 };
367 ("ecc.zero_extend_writes") => {
368 true
369 };
370 ("ecc.separate_jacobian_point_memory") => {
371 true
372 };
373 ("ecc.has_memory_clock_gate") => {
374 true
375 };
376 ("ecc.supports_enhanced_security") => {
377 true
378 };
379 ("ecc.mem_block_size") => {
380 32
381 };
382 ("rng.apb_cycle_wait_num") => {
383 16
384 };
385 ("rng.apb_cycle_wait_num", str) => {
386 stringify!(16)
387 };
388 ("rng.trng_supported") => {
389 true
390 };
391 ("rng.is_lp_sys") => {
392 false
393 };
394 ("rsa.version") => {
395 3
396 };
397 ("rsa.version", str) => {
398 stringify!(3)
399 };
400 ("rsa.size_increment") => {
401 32
402 };
403 ("rsa.size_increment", str) => {
404 stringify!(32)
405 };
406 ("rsa.memory_size_bytes") => {
407 384
408 };
409 ("rsa.memory_size_bytes", str) => {
410 stringify!(384)
411 };
412 ("sleep.light_sleep") => {
413 true
414 };
415 ("sleep.deep_sleep") => {
416 true
417 };
418 ("sleep.rejectable_mask") => {
419 3582
420 };
421 ("sleep.ext1_version") => {
422 2
423 };
424 ("sleep.ext1_version", str) => {
425 stringify!(2)
426 };
427 ("sleep.deep_sleep_needs_gpio_isolation") => {
428 false
429 };
430 ("assist_debug.has_sp_monitor") => {
431 true
432 };
433 ("assist_debug.has_region_monitor") => {
434 true
435 };
436 ("dma.mem2mem_requires_peripheral") => {
437 false
438 };
439 ("dma.ext_mem_configurable_block_size") => {
440 false
441 };
442 ("dma.separate_in_out_interrupts") => {
443 true
444 };
445 ("dma.gdma_version") => {
446 1
447 };
448 ("dma.gdma_version", str) => {
449 stringify!(1)
450 };
451 ("interrupts.status_registers") => {
452 2
453 };
454 ("interrupts.status_registers", str) => {
455 stringify!(2)
456 };
457 ("interrupts.disabled_interrupt") => {
458 31
459 };
460 ("mmu.page_size") => {
461 65536
462 };
463 ("mmu.page_size", str) => {
464 stringify!(65536)
465 };
466 ("mmu.entry_num") => {
467 256
468 };
469 ("mmu.entry_num", str) => {
470 stringify!(256)
471 };
472 ("rom.has_crc_le") => {
473 true
474 };
475 ("rom.has_crc_be") => {
476 true
477 };
478 ("rom.has_md5_bsd") => {
479 true
480 };
481 ("rom.has_md5_mbedtls") => {
482 false
483 };
484 ("soc.cpu_has_branch_predictor") => {
485 false
486 };
487 ("soc.cpu_has_csr_pc") => {
488 true
489 };
490 ("soc.multi_core_enabled") => {
491 false
492 };
493 ("soc.cpu_csr_prv_mode") => {
494 3088
495 };
496 ("soc.cpu_csr_prv_mode", str) => {
497 stringify!(3088)
498 };
499 ("soc.internal_memory_cached") => {
500 false
501 };
502 ("soc.has_swd_watchdog") => {
503 true
504 };
505 ("soc.cpu_mcause_mask") => {
506 31
507 };
508 ("soc.cpu_mcause_mask", str) => {
509 stringify!(31)
510 };
511 ("clock_tree.iomux_function_clock") => {
512 [crate ::soc::clocks::IomuxFunctionClockConfig::XtalClk, crate
513 ::soc::clocks::IomuxFunctionClockConfig::PllF48m]
514 };
515 ("clock_tree.hp_root_clk") => {
516 [crate ::soc::clocks::HpRootClkConfig::Pll96, crate
517 ::soc::clocks::HpRootClkConfig::Pll64, crate
518 ::soc::clocks::HpRootClkConfig::Xtal, crate
519 ::soc::clocks::HpRootClkConfig::RcFast]
520 };
521 ("clock_tree.cpu_clk.divisor") => {
522 (0, 255)
523 };
524 ("clock_tree.ahb_clk.divisor") => {
525 (0, 255)
526 };
527 ("clock_tree.apb_clk.divisor") => {
528 (0, 255)
529 };
530 ("clock_tree.lp_fast_clk") => {
531 [crate ::soc::clocks::LpFastClkConfig::RcFastClk, crate
532 ::soc::clocks::LpFastClkConfig::PllLpClk, crate
533 ::soc::clocks::LpFastClkConfig::XtalD2Clk]
534 };
535 ("clock_tree.lp_slow_clk") => {
536 [crate ::soc::clocks::LpSlowClkConfig::Xtal32k, crate
537 ::soc::clocks::LpSlowClkConfig::RcSlow, crate
538 ::soc::clocks::LpSlowClkConfig::OscSlow]
539 };
540 ("clock_tree.timg_calibration_clock") => {
541 [crate ::soc::clocks::TimgCalibrationClockConfig::RcSlowClk, crate
542 ::soc::clocks::TimgCalibrationClockConfig::RcFastDivClk, crate
543 ::soc::clocks::TimgCalibrationClockConfig::Xtal32kClk]
544 };
545 ("clock_tree.uart.function_clock.sclk") => {
546 [crate ::soc::clocks::UartFunctionClockSclk::PllF48m, crate
547 ::soc::clocks::UartFunctionClockSclk::RcFast, crate
548 ::soc::clocks::UartFunctionClockSclk::Xtal]
549 };
550 ("clock_tree.uart.function_clock.div_num") => {
551 (0, 255)
552 };
553 ("clock_tree.uart.baud_rate_generator.fractional") => {
554 (0, 15)
555 };
556 ("clock_tree.uart.baud_rate_generator.integral") => {
557 (0, 4095)
558 };
559 ("clock_tree.rmt.sclk") => {
560 [crate ::soc::clocks::RmtSclkConfig::XtalClk, crate
561 ::soc::clocks::RmtSclkConfig::RcFastClk]
562 };
563 ("clock_tree.timg.function_clock") => {
564 [crate ::soc::clocks::TimgFunctionClockConfig::XtalClk, crate
565 ::soc::clocks::TimgFunctionClockConfig::RcFastClk, crate
566 ::soc::clocks::TimgFunctionClockConfig::PllF48m]
567 };
568 ("clock_tree.timg.wdt_clock") => {
569 [crate ::soc::clocks::TimgWdtClockConfig::XtalClk, crate
570 ::soc::clocks::TimgWdtClockConfig::RcFastClk, crate
571 ::soc::clocks::TimgWdtClockConfig::PllF48m]
572 };
573 ("clock_tree.mcpwm.function_clock") => {
574 [crate ::soc::clocks::McpwmFunctionClockConfig::PllF96m, crate
575 ::soc::clocks::McpwmFunctionClockConfig::RcFastClk, crate
576 ::soc::clocks::McpwmFunctionClockConfig::XtalClk]
577 };
578 ("clock_tree.parl_io.rx_clock") => {
579 [crate ::soc::clocks::ParlIoRxClockConfig::XtalClk, crate
580 ::soc::clocks::ParlIoRxClockConfig::RcFastClk, crate
581 ::soc::clocks::ParlIoRxClockConfig::PllF96m]
582 };
583 ("clock_tree.parl_io.tx_clock") => {
584 [crate ::soc::clocks::ParlIoTxClockConfig::XtalClk, crate
585 ::soc::clocks::ParlIoTxClockConfig::RcFastClk, crate
586 ::soc::clocks::ParlIoTxClockConfig::PllF96m]
587 };
588 ("clock_tree.i2c.function_clock.sclk") => {
589 [crate ::soc::clocks::I2cFunctionClockSclk::Xtal, crate
590 ::soc::clocks::I2cFunctionClockSclk::RcFast]
591 };
592 ("clock_tree.i2c.function_clock.div_num") => {
593 (0, 255)
594 };
595 ("clock_tree.spi.function_clock") => {
596 [crate ::soc::clocks::SpiFunctionClockConfig::Xtal, crate
597 ::soc::clocks::SpiFunctionClockConfig::PllF48m, crate
598 ::soc::clocks::SpiFunctionClockConfig::RcFast]
599 };
600}
601#[macro_export]
602#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
603macro_rules! for_each_dedicated_gpio {
604 ($($pattern:tt => $code:tt;)*) => {
605 macro_rules! _for_each_inner_dedicated_gpio { $(($pattern) => $code;)* ($other :
606 tt) => {} } _for_each_inner_dedicated_gpio!((0));
607 _for_each_inner_dedicated_gpio!((1)); _for_each_inner_dedicated_gpio!((2));
608 _for_each_inner_dedicated_gpio!((3)); _for_each_inner_dedicated_gpio!((4));
609 _for_each_inner_dedicated_gpio!((5)); _for_each_inner_dedicated_gpio!((6));
610 _for_each_inner_dedicated_gpio!((7)); _for_each_inner_dedicated_gpio!((0, 0,
611 CPU_GPIO_0)); _for_each_inner_dedicated_gpio!((0, 1, CPU_GPIO_1));
612 _for_each_inner_dedicated_gpio!((0, 2, CPU_GPIO_2));
613 _for_each_inner_dedicated_gpio!((0, 3, CPU_GPIO_3));
614 _for_each_inner_dedicated_gpio!((0, 4, CPU_GPIO_4));
615 _for_each_inner_dedicated_gpio!((0, 5, CPU_GPIO_5));
616 _for_each_inner_dedicated_gpio!((0, 6, CPU_GPIO_6));
617 _for_each_inner_dedicated_gpio!((0, 7, CPU_GPIO_7));
618 _for_each_inner_dedicated_gpio!((channels(0), (1), (2), (3), (4), (5), (6),
619 (7))); _for_each_inner_dedicated_gpio!((signals(0, 0, CPU_GPIO_0), (0, 1,
620 CPU_GPIO_1), (0, 2, CPU_GPIO_2), (0, 3, CPU_GPIO_3), (0, 4, CPU_GPIO_4), (0, 5,
621 CPU_GPIO_5), (0, 6, CPU_GPIO_6), (0, 7, CPU_GPIO_7)));
622 };
623}
624#[macro_export]
628#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
629macro_rules! define_lp_io_signals {
630 () => {};
631}
632#[macro_export]
654#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
655macro_rules! for_each_rmt_channel {
656 ($($pattern:tt => $code:tt;)*) => {
657 macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
658 => {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
659 _for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
660 _for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
661 _for_each_inner_rmt_channel!((2, 0)); _for_each_inner_rmt_channel!((3, 1));
662 _for_each_inner_rmt_channel!((all(0), (1), (2), (3)));
663 _for_each_inner_rmt_channel!((tx(0, 0), (1, 1)));
664 _for_each_inner_rmt_channel!((rx(2, 0), (3, 1)));
665 };
666}
667#[macro_export]
668#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
669macro_rules! for_each_sdm_channel {
670 ($($pattern:tt => $code:tt;)*) => {
671 macro_rules! _for_each_inner_sdm_channel { $(($pattern) => $code;)* ($other : tt)
672 => {} } _for_each_inner_sdm_channel!((0, SDM_CH0, SdmCh0, GPIO_SD0));
673 _for_each_inner_sdm_channel!((1, SDM_CH1, SdmCh1, GPIO_SD1));
674 _for_each_inner_sdm_channel!((2, SDM_CH2, SdmCh2, GPIO_SD2));
675 _for_each_inner_sdm_channel!((3, SDM_CH3, SdmCh3, GPIO_SD3));
676 _for_each_inner_sdm_channel!((channels(0, SDM_CH0, SdmCh0, GPIO_SD0), (1,
677 SDM_CH1, SdmCh1, GPIO_SD1), (2, SDM_CH2, SdmCh2, GPIO_SD2), (3, SDM_CH3, SdmCh3,
678 GPIO_SD3)));
679 };
680}
681#[macro_export]
682#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
683macro_rules! for_each_aes_key_length {
684 ($($pattern:tt => $code:tt;)*) => {
685 macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
686 tt) => {} } _for_each_inner_aes_key_length!((128));
687 _for_each_inner_aes_key_length!((256)); _for_each_inner_aes_key_length!((128, 0,
688 4)); _for_each_inner_aes_key_length!((256, 2, 6));
689 _for_each_inner_aes_key_length!((bits(128), (256)));
690 _for_each_inner_aes_key_length!((modes(128, 0, 4), (256, 2, 6)));
691 };
692}
693#[macro_export]
694#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
695macro_rules! for_each_ecc_working_mode {
696 ($($pattern:tt => $code:tt;)*) => {
697 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
698 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
699 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
700 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
701 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
702 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
703 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
704 _for_each_inner_ecc_working_mode!((7,
705 AffinePointVerificationAndJacobianPointMultiplication));
706 _for_each_inner_ecc_working_mode!((8, ModularAddition));
707 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
708 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
709 _for_each_inner_ecc_working_mode!((11, ModularDivision));
710 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
711 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
712 JacobianPointMultiplication), (5, AffinePointAddition), (6,
713 JacobianPointVerification), (7,
714 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
715 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
716 };
717}
718#[macro_export]
719#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
720macro_rules! for_each_ecc_curve {
721 ($($pattern:tt => $code:tt;)*) => {
722 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
723 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
724 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
725 P192, 192), (1, P256, 256)));
726 };
727}
728#[macro_export]
729#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
730macro_rules! for_each_rsa_exponentiation {
731 ($($pattern:tt => $code:tt;)*) => {
732 macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
733 ($other : tt) => {} } _for_each_inner_rsa_exponentiation!((32));
734 _for_each_inner_rsa_exponentiation!((64));
735 _for_each_inner_rsa_exponentiation!((96));
736 _for_each_inner_rsa_exponentiation!((128));
737 _for_each_inner_rsa_exponentiation!((160));
738 _for_each_inner_rsa_exponentiation!((192));
739 _for_each_inner_rsa_exponentiation!((224));
740 _for_each_inner_rsa_exponentiation!((256));
741 _for_each_inner_rsa_exponentiation!((288));
742 _for_each_inner_rsa_exponentiation!((320));
743 _for_each_inner_rsa_exponentiation!((352));
744 _for_each_inner_rsa_exponentiation!((384));
745 _for_each_inner_rsa_exponentiation!((416));
746 _for_each_inner_rsa_exponentiation!((448));
747 _for_each_inner_rsa_exponentiation!((480));
748 _for_each_inner_rsa_exponentiation!((512));
749 _for_each_inner_rsa_exponentiation!((544));
750 _for_each_inner_rsa_exponentiation!((576));
751 _for_each_inner_rsa_exponentiation!((608));
752 _for_each_inner_rsa_exponentiation!((640));
753 _for_each_inner_rsa_exponentiation!((672));
754 _for_each_inner_rsa_exponentiation!((704));
755 _for_each_inner_rsa_exponentiation!((736));
756 _for_each_inner_rsa_exponentiation!((768));
757 _for_each_inner_rsa_exponentiation!((800));
758 _for_each_inner_rsa_exponentiation!((832));
759 _for_each_inner_rsa_exponentiation!((864));
760 _for_each_inner_rsa_exponentiation!((896));
761 _for_each_inner_rsa_exponentiation!((928));
762 _for_each_inner_rsa_exponentiation!((960));
763 _for_each_inner_rsa_exponentiation!((992));
764 _for_each_inner_rsa_exponentiation!((1024));
765 _for_each_inner_rsa_exponentiation!((1056));
766 _for_each_inner_rsa_exponentiation!((1088));
767 _for_each_inner_rsa_exponentiation!((1120));
768 _for_each_inner_rsa_exponentiation!((1152));
769 _for_each_inner_rsa_exponentiation!((1184));
770 _for_each_inner_rsa_exponentiation!((1216));
771 _for_each_inner_rsa_exponentiation!((1248));
772 _for_each_inner_rsa_exponentiation!((1280));
773 _for_each_inner_rsa_exponentiation!((1312));
774 _for_each_inner_rsa_exponentiation!((1344));
775 _for_each_inner_rsa_exponentiation!((1376));
776 _for_each_inner_rsa_exponentiation!((1408));
777 _for_each_inner_rsa_exponentiation!((1440));
778 _for_each_inner_rsa_exponentiation!((1472));
779 _for_each_inner_rsa_exponentiation!((1504));
780 _for_each_inner_rsa_exponentiation!((1536));
781 _for_each_inner_rsa_exponentiation!((1568));
782 _for_each_inner_rsa_exponentiation!((1600));
783 _for_each_inner_rsa_exponentiation!((1632));
784 _for_each_inner_rsa_exponentiation!((1664));
785 _for_each_inner_rsa_exponentiation!((1696));
786 _for_each_inner_rsa_exponentiation!((1728));
787 _for_each_inner_rsa_exponentiation!((1760));
788 _for_each_inner_rsa_exponentiation!((1792));
789 _for_each_inner_rsa_exponentiation!((1824));
790 _for_each_inner_rsa_exponentiation!((1856));
791 _for_each_inner_rsa_exponentiation!((1888));
792 _for_each_inner_rsa_exponentiation!((1920));
793 _for_each_inner_rsa_exponentiation!((1952));
794 _for_each_inner_rsa_exponentiation!((1984));
795 _for_each_inner_rsa_exponentiation!((2016));
796 _for_each_inner_rsa_exponentiation!((2048));
797 _for_each_inner_rsa_exponentiation!((2080));
798 _for_each_inner_rsa_exponentiation!((2112));
799 _for_each_inner_rsa_exponentiation!((2144));
800 _for_each_inner_rsa_exponentiation!((2176));
801 _for_each_inner_rsa_exponentiation!((2208));
802 _for_each_inner_rsa_exponentiation!((2240));
803 _for_each_inner_rsa_exponentiation!((2272));
804 _for_each_inner_rsa_exponentiation!((2304));
805 _for_each_inner_rsa_exponentiation!((2336));
806 _for_each_inner_rsa_exponentiation!((2368));
807 _for_each_inner_rsa_exponentiation!((2400));
808 _for_each_inner_rsa_exponentiation!((2432));
809 _for_each_inner_rsa_exponentiation!((2464));
810 _for_each_inner_rsa_exponentiation!((2496));
811 _for_each_inner_rsa_exponentiation!((2528));
812 _for_each_inner_rsa_exponentiation!((2560));
813 _for_each_inner_rsa_exponentiation!((2592));
814 _for_each_inner_rsa_exponentiation!((2624));
815 _for_each_inner_rsa_exponentiation!((2656));
816 _for_each_inner_rsa_exponentiation!((2688));
817 _for_each_inner_rsa_exponentiation!((2720));
818 _for_each_inner_rsa_exponentiation!((2752));
819 _for_each_inner_rsa_exponentiation!((2784));
820 _for_each_inner_rsa_exponentiation!((2816));
821 _for_each_inner_rsa_exponentiation!((2848));
822 _for_each_inner_rsa_exponentiation!((2880));
823 _for_each_inner_rsa_exponentiation!((2912));
824 _for_each_inner_rsa_exponentiation!((2944));
825 _for_each_inner_rsa_exponentiation!((2976));
826 _for_each_inner_rsa_exponentiation!((3008));
827 _for_each_inner_rsa_exponentiation!((3040));
828 _for_each_inner_rsa_exponentiation!((3072));
829 _for_each_inner_rsa_exponentiation!((all(32), (64), (96), (128), (160), (192),
830 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
831 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
832 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
833 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536),
834 (1568), (1600), (1632), (1664), (1696), (1728), (1760), (1792), (1824), (1856),
835 (1888), (1920), (1952), (1984), (2016), (2048), (2080), (2112), (2144), (2176),
836 (2208), (2240), (2272), (2304), (2336), (2368), (2400), (2432), (2464), (2496),
837 (2528), (2560), (2592), (2624), (2656), (2688), (2720), (2752), (2784), (2816),
838 (2848), (2880), (2912), (2944), (2976), (3008), (3040), (3072)));
839 };
840}
841#[macro_export]
842#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
843macro_rules! for_each_rsa_multiplication {
844 ($($pattern:tt => $code:tt;)*) => {
845 macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
846 ($other : tt) => {} } _for_each_inner_rsa_multiplication!((32));
847 _for_each_inner_rsa_multiplication!((64));
848 _for_each_inner_rsa_multiplication!((96));
849 _for_each_inner_rsa_multiplication!((128));
850 _for_each_inner_rsa_multiplication!((160));
851 _for_each_inner_rsa_multiplication!((192));
852 _for_each_inner_rsa_multiplication!((224));
853 _for_each_inner_rsa_multiplication!((256));
854 _for_each_inner_rsa_multiplication!((288));
855 _for_each_inner_rsa_multiplication!((320));
856 _for_each_inner_rsa_multiplication!((352));
857 _for_each_inner_rsa_multiplication!((384));
858 _for_each_inner_rsa_multiplication!((416));
859 _for_each_inner_rsa_multiplication!((448));
860 _for_each_inner_rsa_multiplication!((480));
861 _for_each_inner_rsa_multiplication!((512));
862 _for_each_inner_rsa_multiplication!((544));
863 _for_each_inner_rsa_multiplication!((576));
864 _for_each_inner_rsa_multiplication!((608));
865 _for_each_inner_rsa_multiplication!((640));
866 _for_each_inner_rsa_multiplication!((672));
867 _for_each_inner_rsa_multiplication!((704));
868 _for_each_inner_rsa_multiplication!((736));
869 _for_each_inner_rsa_multiplication!((768));
870 _for_each_inner_rsa_multiplication!((800));
871 _for_each_inner_rsa_multiplication!((832));
872 _for_each_inner_rsa_multiplication!((864));
873 _for_each_inner_rsa_multiplication!((896));
874 _for_each_inner_rsa_multiplication!((928));
875 _for_each_inner_rsa_multiplication!((960));
876 _for_each_inner_rsa_multiplication!((992));
877 _for_each_inner_rsa_multiplication!((1024));
878 _for_each_inner_rsa_multiplication!((1056));
879 _for_each_inner_rsa_multiplication!((1088));
880 _for_each_inner_rsa_multiplication!((1120));
881 _for_each_inner_rsa_multiplication!((1152));
882 _for_each_inner_rsa_multiplication!((1184));
883 _for_each_inner_rsa_multiplication!((1216));
884 _for_each_inner_rsa_multiplication!((1248));
885 _for_each_inner_rsa_multiplication!((1280));
886 _for_each_inner_rsa_multiplication!((1312));
887 _for_each_inner_rsa_multiplication!((1344));
888 _for_each_inner_rsa_multiplication!((1376));
889 _for_each_inner_rsa_multiplication!((1408));
890 _for_each_inner_rsa_multiplication!((1440));
891 _for_each_inner_rsa_multiplication!((1472));
892 _for_each_inner_rsa_multiplication!((1504));
893 _for_each_inner_rsa_multiplication!((1536));
894 _for_each_inner_rsa_multiplication!((all(32), (64), (96), (128), (160), (192),
895 (224), (256), (288), (320), (352), (384), (416), (448), (480), (512), (544),
896 (576), (608), (640), (672), (704), (736), (768), (800), (832), (864), (896),
897 (928), (960), (992), (1024), (1056), (1088), (1120), (1152), (1184), (1216),
898 (1248), (1280), (1312), (1344), (1376), (1408), (1440), (1472), (1504), (1536)));
899 };
900}
901#[macro_export]
902#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
903macro_rules! for_each_sha_algorithm {
904 ($($pattern:tt => $code:tt;)*) => {
905 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
906 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
907 (insecure_against : "collision", "length extension"), 0));
908 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
909 (insecure_against : "length extension"), 1));
910 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
911 (insecure_against : "length extension"), 2));
912 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
913 (insecure_against : "collision", "length extension"), 0), (Sha224,
914 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
915 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
916 2)));
917 };
918}
919#[macro_export]
920#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
921macro_rules! for_each_wakeup_source {
922 ($($pattern:tt => $code:tt;)*) => {
923 macro_rules! _for_each_inner_wakeup_source { $(($pattern) => $code;)* ($other :
924 tt) => {} } _for_each_inner_wakeup_source!((Ext1, 1));
925 _for_each_inner_wakeup_source!((Gpio, 2));
926 _for_each_inner_wakeup_source!((WifiBeacon, 3));
927 _for_each_inner_wakeup_source!((Timer, 4)); _for_each_inner_wakeup_source!((Wifi,
928 5)); _for_each_inner_wakeup_source!((Uart0, 6));
929 _for_each_inner_wakeup_source!((Uart1, 7)); _for_each_inner_wakeup_source!((Sdio,
930 8)); _for_each_inner_wakeup_source!((Bt, 10));
931 _for_each_inner_wakeup_source!((LpCore, 11));
932 _for_each_inner_wakeup_source!((all(Ext1, 1), (Gpio, 2), (WifiBeacon, 3), (Timer,
933 4), (Wifi, 5), (Uart0, 6), (Uart1, 7), (Sdio, 8), (Bt, 10), (LpCore, 11)));
934 };
935}
936#[macro_export]
937#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
938macro_rules! for_each_dma_engine {
939 ($($pattern:tt => $code:tt;)*) => {
940 macro_rules! _for_each_inner_dma_engine { $(($pattern) => $code;)* ($other : tt)
941 => {} } _for_each_inner_dma_engine!(("AHB_GDMA"));
942 _for_each_inner_dma_engine!((all("AHB_GDMA")));
943 };
944}
945#[macro_export]
946#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
947macro_rules! for_each_dma_channel {
948 ($($pattern:tt => $code:tt;)*) => {
949 macro_rules! _for_each_inner_dma_channel { $(($pattern) => $code;)* ($other : tt)
950 => {} } _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0));
951 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1));
952 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2));
953 _for_each_inner_dma_channel!(("AHB_GDMA", any_channel = AhbGdmaChannel));
954 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH0, 0, interrupt_in = DMA_IN_CH0,
955 interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
956 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH1, 1,
957 interrupt_in = DMA_IN_CH1, interrupt_out = DMA_OUT_CH1, compatible = [SPI2,
958 UHCI0, I2S0, AES, SHA, APB_SARADC, PARL_IO]));
959 _for_each_inner_dma_channel!(("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
960 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
961 APB_SARADC, PARL_IO])); _for_each_inner_dma_channel!((names("AHB_GDMA", DMA_CH0),
962 ("AHB_GDMA", DMA_CH1), ("AHB_GDMA", DMA_CH2)));
963 _for_each_inner_dma_channel!((separate_any_type("AHB_GDMA", any_channel =
964 AhbGdmaChannel))); _for_each_inner_dma_channel!((shared));
965 _for_each_inner_dma_channel!((split("AHB_GDMA", DMA_CH0, 0, interrupt_in =
966 DMA_IN_CH0, interrupt_out = DMA_OUT_CH0, compatible = [SPI2, UHCI0, I2S0, AES,
967 SHA, APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH1, 1, interrupt_in = DMA_IN_CH1,
968 interrupt_out = DMA_OUT_CH1, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
969 APB_SARADC, PARL_IO]), ("AHB_GDMA", DMA_CH2, 2, interrupt_in = DMA_IN_CH2,
970 interrupt_out = DMA_OUT_CH2, compatible = [SPI2, UHCI0, I2S0, AES, SHA,
971 APB_SARADC, PARL_IO]))); _for_each_inner_dma_channel!((no_own_interrupt));
972 };
973}
974#[macro_export]
975#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
976macro_rules! for_each_dma_channel_peri_pair {
977 ($($pattern:tt => $code:tt;)*) => {
978 macro_rules! _for_each_inner_dma_channel_peri_pair { $(($pattern) => $code;)*
979 ($other : tt) => {} } _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
980 DMA_CH0, SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0,
981 UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, I2S0));
982 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, AES));
983 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, SHA));
984 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, APB_SARADC));
985 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH0, PARL_IO));
986 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SPI2));
987 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, UHCI0));
988 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, I2S0));
989 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, AES));
990 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, SHA));
991 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, APB_SARADC));
992 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH1, PARL_IO));
993 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SPI2));
994 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, UHCI0));
995 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, I2S0));
996 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, AES));
997 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, SHA));
998 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, APB_SARADC));
999 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", DMA_CH2, PARL_IO));
1000 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1001 SPI2)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1002 AhbGdmaChannel, UHCI0)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1003 any_channel = AhbGdmaChannel, I2S0));
1004 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1005 AES)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel =
1006 AhbGdmaChannel, SHA)); _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA",
1007 any_channel = AhbGdmaChannel, APB_SARADC));
1008 _for_each_inner_dma_channel_peri_pair!(("AHB_GDMA", any_channel = AhbGdmaChannel,
1009 PARL_IO)); _for_each_inner_dma_channel_peri_pair!((channels("AHB_GDMA", DMA_CH0,
1010 SPI2), ("AHB_GDMA", DMA_CH0, UHCI0), ("AHB_GDMA", DMA_CH0, I2S0), ("AHB_GDMA",
1011 DMA_CH0, AES), ("AHB_GDMA", DMA_CH0, SHA), ("AHB_GDMA", DMA_CH0, APB_SARADC),
1012 ("AHB_GDMA", DMA_CH0, PARL_IO), ("AHB_GDMA", DMA_CH1, SPI2), ("AHB_GDMA",
1013 DMA_CH1, UHCI0), ("AHB_GDMA", DMA_CH1, I2S0), ("AHB_GDMA", DMA_CH1, AES),
1014 ("AHB_GDMA", DMA_CH1, SHA), ("AHB_GDMA", DMA_CH1, APB_SARADC), ("AHB_GDMA",
1015 DMA_CH1, PARL_IO), ("AHB_GDMA", DMA_CH2, SPI2), ("AHB_GDMA", DMA_CH2, UHCI0),
1016 ("AHB_GDMA", DMA_CH2, I2S0), ("AHB_GDMA", DMA_CH2, AES), ("AHB_GDMA", DMA_CH2,
1017 SHA), ("AHB_GDMA", DMA_CH2, APB_SARADC), ("AHB_GDMA", DMA_CH2, PARL_IO)));
1018 _for_each_inner_dma_channel_peri_pair!((any_channels("AHB_GDMA", any_channel =
1019 AhbGdmaChannel, SPI2), ("AHB_GDMA", any_channel = AhbGdmaChannel, UHCI0),
1020 ("AHB_GDMA", any_channel = AhbGdmaChannel, I2S0), ("AHB_GDMA", any_channel =
1021 AhbGdmaChannel, AES), ("AHB_GDMA", any_channel = AhbGdmaChannel, SHA),
1022 ("AHB_GDMA", any_channel = AhbGdmaChannel, APB_SARADC), ("AHB_GDMA", any_channel
1023 = AhbGdmaChannel, PARL_IO)));
1024 };
1025}
1026#[macro_export]
1027#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1028macro_rules! for_each_mem2mem_channel {
1029 ($($pattern:tt => $code:tt;)*) => {
1030 macro_rules! _for_each_inner_mem2mem_channel { $(($pattern) => $code;)* ($other :
1031 tt) => {} } _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1032 AhbGdmaChannel, DMA_CH0, 4)); _for_each_inner_mem2mem_channel!(("AHB_GDMA",
1033 AhbGdma, AhbGdmaChannel, DMA_CH1, 5));
1034 _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2,
1035 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1036 4, 1, 5, 2, 10)); _for_each_inner_mem2mem_channel!(("AHB_GDMA", AhbGdma,
1037 AhbGdmaChannel)); _for_each_inner_mem2mem_channel!((channels("AHB_GDMA", AhbGdma,
1038 AhbGdmaChannel, DMA_CH0, 4), ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH1, 5),
1039 ("AHB_GDMA", AhbGdma, AhbGdmaChannel, DMA_CH2, 10)));
1040 _for_each_inner_mem2mem_channel!((erased("AHB_GDMA", AhbGdma, AhbGdmaChannel, 0,
1041 4, 1, 5, 2, 10))); _for_each_inner_mem2mem_channel!((engines("AHB_GDMA", AhbGdma,
1042 AhbGdmaChannel)));
1043 };
1044}
1045#[macro_export]
1046#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1047macro_rules! with_aes_dma_engine {
1048 ($($pattern:tt => $code:tt;)*) => {
1049 macro_rules! _with_inner_aes_dma_engine { $(($pattern) => $code;)* ($other : tt)
1050 => {} } _with_inner_aes_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1051 };
1052}
1053#[macro_export]
1054#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1055macro_rules! with_i2s_dma_engine {
1056 ($($pattern:tt => $code:tt;)*) => {
1057 macro_rules! _with_inner_i2s_dma_engine { $(($pattern) => $code;)* ($other : tt)
1058 => {} } _with_inner_i2s_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1059 };
1060}
1061#[macro_export]
1062#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1063macro_rules! with_parl_io_dma_engine {
1064 ($($pattern:tt => $code:tt;)*) => {
1065 macro_rules! _with_inner_parl_io_dma_engine { $(($pattern) => $code;)* ($other :
1066 tt) => {} } _with_inner_parl_io_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1067 };
1068}
1069#[macro_export]
1070#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1071macro_rules! with_sha_dma_engine {
1072 ($($pattern:tt => $code:tt;)*) => {
1073 macro_rules! _with_inner_sha_dma_engine { $(($pattern) => $code;)* ($other : tt)
1074 => {} } _with_inner_sha_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1075 };
1076}
1077#[macro_export]
1078#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1079macro_rules! with_spi_master_dma_engine {
1080 ($($pattern:tt => $code:tt;)*) => {
1081 macro_rules! _with_inner_spi_master_dma_engine { $(($pattern) => $code;)* ($other
1082 : tt) => {} } _with_inner_spi_master_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1083 };
1084}
1085#[macro_export]
1086#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1087macro_rules! with_spi_slave_dma_engine {
1088 ($($pattern:tt => $code:tt;)*) => {
1089 macro_rules! _with_inner_spi_slave_dma_engine { $(($pattern) => $code;)* ($other
1090 : tt) => {} } _with_inner_spi_slave_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1091 };
1092}
1093#[macro_export]
1094#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1095macro_rules! with_uhci_dma_engine {
1096 ($($pattern:tt => $code:tt;)*) => {
1097 macro_rules! _with_inner_uhci_dma_engine { $(($pattern) => $code;)* ($other : tt)
1098 => {} } _with_inner_uhci_dma_engine!(("AHB_GDMA", AhbGdmaChannel));
1099 };
1100}
1101#[macro_export]
1102#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1103macro_rules! for_each_interrupt {
1104 ($($pattern:tt => $code:tt;)*) => {
1105 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
1106 => {} } _for_each_inner_interrupt!(([reserved 0] 0));
1107 _for_each_inner_interrupt!(([direct_bindable 0] 1));
1108 _for_each_inner_interrupt!(([direct_bindable 1] 2));
1109 _for_each_inner_interrupt!(([reserved 1] 3));
1110 _for_each_inner_interrupt!(([reserved 2] 4));
1111 _for_each_inner_interrupt!(([direct_bindable 2] 5));
1112 _for_each_inner_interrupt!(([direct_bindable 3] 6));
1113 _for_each_inner_interrupt!(([reserved 3] 7));
1114 _for_each_inner_interrupt!(([direct_bindable 4] 8));
1115 _for_each_inner_interrupt!(([direct_bindable 5] 9));
1116 _for_each_inner_interrupt!(([direct_bindable 6] 10));
1117 _for_each_inner_interrupt!(([direct_bindable 7] 11));
1118 _for_each_inner_interrupt!(([direct_bindable 8] 12));
1119 _for_each_inner_interrupt!(([direct_bindable 9] 13));
1120 _for_each_inner_interrupt!(([direct_bindable 10] 14));
1121 _for_each_inner_interrupt!(([direct_bindable 11] 15));
1122 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
1123 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
1124 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
1125 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
1126 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
1127 7] 23)); _for_each_inner_interrupt!(([vector 8] 24));
1128 _for_each_inner_interrupt!(([vector 9] 25)); _for_each_inner_interrupt!(([vector
1129 10] 26)); _for_each_inner_interrupt!(([vector 11] 27));
1130 _for_each_inner_interrupt!(([vector 12] 28)); _for_each_inner_interrupt!(([vector
1131 13] 29)); _for_each_inner_interrupt!(([vector 14] 30));
1132 _for_each_inner_interrupt!(([disabled 0] 31));
1133 _for_each_inner_interrupt!((all([reserved 0] 0), ([direct_bindable 0] 1),
1134 ([direct_bindable 1] 2), ([reserved 1] 3), ([reserved 2] 4), ([direct_bindable 2]
1135 5), ([direct_bindable 3] 6), ([reserved 3] 7), ([direct_bindable 4] 8),
1136 ([direct_bindable 5] 9), ([direct_bindable 6] 10), ([direct_bindable 7] 11),
1137 ([direct_bindable 8] 12), ([direct_bindable 9] 13), ([direct_bindable 10] 14),
1138 ([direct_bindable 11] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18),
1139 ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7]
1140 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26), ([vector 11] 27),
1141 ([vector 12] 28), ([vector 13] 29), ([vector 14] 30), ([disabled 0] 31)));
1142 };
1143}
1144#[macro_export]
1145#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1146macro_rules! for_each_classified_interrupt {
1147 ($($pattern:tt => $code:tt;)*) => {
1148 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
1149 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
1150 1)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 2));
1151 _for_each_inner_classified_interrupt!(([direct_bindable 2] 5));
1152 _for_each_inner_classified_interrupt!(([direct_bindable 3] 6));
1153 _for_each_inner_classified_interrupt!(([direct_bindable 4] 8));
1154 _for_each_inner_classified_interrupt!(([direct_bindable 5] 9));
1155 _for_each_inner_classified_interrupt!(([direct_bindable 6] 10));
1156 _for_each_inner_classified_interrupt!(([direct_bindable 7] 11));
1157 _for_each_inner_classified_interrupt!(([direct_bindable 8] 12));
1158 _for_each_inner_classified_interrupt!(([direct_bindable 9] 13));
1159 _for_each_inner_classified_interrupt!(([direct_bindable 10] 14));
1160 _for_each_inner_classified_interrupt!(([direct_bindable 11] 15));
1161 _for_each_inner_classified_interrupt!(([vector 0] 16));
1162 _for_each_inner_classified_interrupt!(([vector 1] 17));
1163 _for_each_inner_classified_interrupt!(([vector 2] 18));
1164 _for_each_inner_classified_interrupt!(([vector 3] 19));
1165 _for_each_inner_classified_interrupt!(([vector 4] 20));
1166 _for_each_inner_classified_interrupt!(([vector 5] 21));
1167 _for_each_inner_classified_interrupt!(([vector 6] 22));
1168 _for_each_inner_classified_interrupt!(([vector 7] 23));
1169 _for_each_inner_classified_interrupt!(([vector 8] 24));
1170 _for_each_inner_classified_interrupt!(([vector 9] 25));
1171 _for_each_inner_classified_interrupt!(([vector 10] 26));
1172 _for_each_inner_classified_interrupt!(([vector 11] 27));
1173 _for_each_inner_classified_interrupt!(([vector 12] 28));
1174 _for_each_inner_classified_interrupt!(([vector 13] 29));
1175 _for_each_inner_classified_interrupt!(([vector 14] 30));
1176 _for_each_inner_classified_interrupt!(([reserved 0] 0));
1177 _for_each_inner_classified_interrupt!(([reserved 1] 3));
1178 _for_each_inner_classified_interrupt!(([reserved 2] 4));
1179 _for_each_inner_classified_interrupt!(([reserved 3] 7));
1180 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 1),
1181 ([direct_bindable 1] 2), ([direct_bindable 2] 5), ([direct_bindable 3] 6),
1182 ([direct_bindable 4] 8), ([direct_bindable 5] 9), ([direct_bindable 6] 10),
1183 ([direct_bindable 7] 11), ([direct_bindable 8] 12), ([direct_bindable 9] 13),
1184 ([direct_bindable 10] 14), ([direct_bindable 11] 15)));
1185 _for_each_inner_classified_interrupt!((vector([vector 0] 16), ([vector 1] 17),
1186 ([vector 2] 18), ([vector 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6]
1187 22), ([vector 7] 23), ([vector 8] 24), ([vector 9] 25), ([vector 10] 26),
1188 ([vector 11] 27), ([vector 12] 28), ([vector 13] 29), ([vector 14] 30)));
1189 _for_each_inner_classified_interrupt!((reserved([reserved 0] 0), ([reserved 1]
1190 3), ([reserved 2] 4), ([reserved 3] 7)));
1191 };
1192}
1193#[macro_export]
1194#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1195macro_rules! for_each_interrupt_priority {
1196 ($($pattern:tt => $code:tt;)*) => {
1197 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
1198 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
1199 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
1200 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
1201 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
1202 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
1203 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
1204 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
1205 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
1206 _for_each_inner_interrupt_priority!((8, 9, Priority9, Level9));
1207 _for_each_inner_interrupt_priority!((9, 10, Priority10, Level10));
1208 _for_each_inner_interrupt_priority!((10, 11, Priority11, Level11));
1209 _for_each_inner_interrupt_priority!((11, 12, Priority12, Level12));
1210 _for_each_inner_interrupt_priority!((12, 13, Priority13, Level13));
1211 _for_each_inner_interrupt_priority!((13, 14, Priority14, Level14));
1212 _for_each_inner_interrupt_priority!((14, 15, Priority15, Level15));
1213 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
1214 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
1215 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
1216 Priority8, Level8), (8, 9, Priority9, Level9), (9, 10, Priority10, Level10), (10,
1217 11, Priority11, Level11), (11, 12, Priority12, Level12), (12, 13, Priority13,
1218 Level13), (13, 14, Priority14, Level14), (14, 15, Priority15, Level15)));
1219 };
1220}
1221#[macro_export]
1222#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
1223macro_rules! for_each_sw_interrupt {
1224 ($($pattern:tt => $code:tt;)*) => {
1225 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
1226 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
1227 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
1228 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
1229 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
1230 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
1231 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
1232 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
1233 };
1234}
1235#[macro_export]
1236macro_rules! define_clock_tree_types {
1568 () => {
1569 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1570 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1571 pub enum SdmInstance {
1572 GpioSd = 0,
1573 }
1574 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1575 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1576 pub enum I2cInstance {
1577 I2c0 = 0,
1578 I2c1 = 1,
1579 }
1580 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1581 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1582 pub enum McpwmInstance {
1583 Mcpwm0 = 0,
1584 }
1585 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1586 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1587 pub enum ParlIoInstance {
1588 ParlIo = 0,
1589 }
1590 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1591 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1592 pub enum RmtInstance {
1593 Rmt = 0,
1594 }
1595 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1596 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1597 pub enum SpiInstance {
1598 Spi2 = 0,
1599 }
1600 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1601 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1602 pub enum TimgInstance {
1603 Timg0 = 0,
1604 Timg1 = 1,
1605 }
1606 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
1607 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1608 pub enum UartInstance {
1609 Uart0 = 0,
1610 Uart1 = 1,
1611 }
1612 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1614 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1615 pub enum XtalClkConfig {
1616 _32,
1618 }
1619 impl XtalClkConfig {
1620 pub fn value(&self) -> u32 {
1621 match self {
1622 XtalClkConfig::_32 => 32000000,
1623 }
1624 }
1625 }
1626 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1628 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1629 pub enum IomuxFunctionClockConfig {
1630 XtalClk,
1632 #[default]
1633 PllF48m,
1635 }
1636 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1638 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1639 pub enum HpRootClkConfig {
1640 Pll96,
1642 Pll64,
1644 Xtal,
1646 RcFast,
1648 }
1649 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1653 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1654 pub struct CpuClkConfig {
1655 divisor: u32,
1656 }
1657 impl CpuClkConfig {
1658 pub const fn new(divisor: u32) -> Self {
1665 ::core::assert!(
1666 divisor <= 255,
1667 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
1668 );
1669 Self { divisor }
1670 }
1671 pub(crate) fn divisor(self) -> u32 {
1672 self.divisor as u32
1673 }
1674 }
1675 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1679 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1680 pub struct AhbClkConfig {
1681 divisor: u32,
1682 }
1683 impl AhbClkConfig {
1684 pub const fn new(divisor: u32) -> Self {
1691 ::core::assert!(
1692 divisor <= 255,
1693 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
1694 );
1695 Self { divisor }
1696 }
1697 pub(crate) fn divisor(self) -> u32 {
1698 self.divisor as u32
1699 }
1700 }
1701 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1705 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1706 pub struct ApbClkConfig {
1707 divisor: u32,
1708 }
1709 impl ApbClkConfig {
1710 pub const fn new(divisor: u32) -> Self {
1717 ::core::assert!(
1718 divisor <= 255,
1719 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
1720 );
1721 Self { divisor }
1722 }
1723 pub(crate) fn divisor(self) -> u32 {
1724 self.divisor as u32
1725 }
1726 }
1727 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1729 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1730 pub enum LpFastClkConfig {
1731 RcFastClk,
1733 PllLpClk,
1735 XtalD2Clk,
1737 }
1738 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1740 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1741 pub enum LpSlowClkConfig {
1742 Xtal32k,
1744 RcSlow,
1746 OscSlow,
1748 }
1749 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1751 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1752 pub enum TimgCalibrationClockConfig {
1753 RcSlowClk,
1755 RcFastDivClk,
1757 Xtal32kClk,
1759 }
1760 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1761 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1762 pub enum I2cFunctionClockSclk {
1763 #[default]
1764 Xtal,
1766 RcFast,
1768 }
1769 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1773 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1774 pub struct I2cFunctionClockConfig {
1775 sclk: I2cFunctionClockSclk,
1776 div_num: u32,
1777 }
1778 impl I2cFunctionClockConfig {
1779 pub const fn new(sclk: I2cFunctionClockSclk, div_num: u32) -> Self {
1786 ::core::assert!(
1787 div_num <= 255,
1788 "`I2C0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1789 );
1790 Self { sclk, div_num }
1791 }
1792 pub(crate) fn sclk(self) -> I2cFunctionClockSclk {
1793 self.sclk
1794 }
1795 pub(crate) fn div_num(self) -> u32 {
1796 self.div_num as u32
1797 }
1798 }
1799 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1801 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1802 pub enum McpwmFunctionClockConfig {
1803 #[default]
1804 PllF96m,
1806 RcFastClk,
1808 XtalClk,
1810 }
1811 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1813 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1814 pub enum ParlIoRxClockConfig {
1815 XtalClk,
1817 RcFastClk,
1819 #[default]
1820 PllF96m,
1822 }
1823 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1825 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1826 pub enum ParlIoTxClockConfig {
1827 XtalClk,
1829 RcFastClk,
1831 #[default]
1832 PllF96m,
1834 }
1835 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1837 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1838 pub enum RmtSclkConfig {
1839 #[default]
1840 XtalClk,
1842 RcFastClk,
1844 }
1845 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1847 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1848 pub enum SpiFunctionClockConfig {
1849 #[default]
1850 Xtal,
1852 PllF48m,
1854 RcFast,
1856 }
1857 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1859 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1860 pub enum TimgFunctionClockConfig {
1861 #[default]
1862 XtalClk,
1864 RcFastClk,
1866 PllF48m,
1868 }
1869 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1871 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1872 pub enum TimgWdtClockConfig {
1873 #[default]
1874 XtalClk,
1876 RcFastClk,
1878 PllF48m,
1880 }
1881 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
1882 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1883 pub enum UartFunctionClockSclk {
1884 PllF48m,
1886 RcFast,
1888 #[default]
1889 Xtal,
1891 }
1892 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1896 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1897 pub struct UartFunctionClockConfig {
1898 sclk: UartFunctionClockSclk,
1899 div_num: u32,
1900 }
1901 impl UartFunctionClockConfig {
1902 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
1909 ::core::assert!(
1910 div_num <= 255,
1911 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
1912 );
1913 Self { sclk, div_num }
1914 }
1915 pub(crate) fn sclk(self) -> UartFunctionClockSclk {
1916 self.sclk
1917 }
1918 pub(crate) fn div_num(self) -> u32 {
1919 self.div_num as u32
1920 }
1921 }
1922 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1927 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
1928 pub struct UartBaudRateGeneratorConfig {
1929 fractional: u32,
1930 integral: u32,
1931 }
1932 impl UartBaudRateGeneratorConfig {
1933 pub const fn new(fractional: u32, integral: u32) -> Self {
1943 ::core::assert!(
1944 fractional <= 15,
1945 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1946 );
1947 ::core::assert!(
1948 integral <= 4095,
1949 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1950 );
1951 Self {
1952 fractional,
1953 integral,
1954 }
1955 }
1956 pub(crate) fn fractional(self) -> u32 {
1957 self.fractional as u32
1958 }
1959 pub(crate) fn integral(self) -> u32 {
1960 self.integral as u32
1961 }
1962 }
1963 pub struct ClockTree {
1965 xtal_clk: Option<XtalClkConfig>,
1966 iomux_function_clock: Option<IomuxFunctionClockConfig>,
1967 hp_root_clk: Option<HpRootClkConfig>,
1968 cpu_clk: Option<CpuClkConfig>,
1969 ahb_clk: Option<AhbClkConfig>,
1970 apb_clk: Option<ApbClkConfig>,
1971 lp_fast_clk: Option<LpFastClkConfig>,
1972 lp_slow_clk: Option<LpSlowClkConfig>,
1973 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1974 i2c_function_clock: [Option<I2cFunctionClockConfig>; 2],
1975 mcpwm_function_clock: [Option<McpwmFunctionClockConfig>; 1],
1976 parl_io_rx_clock: [Option<ParlIoRxClockConfig>; 1],
1977 parl_io_tx_clock: [Option<ParlIoTxClockConfig>; 1],
1978 rmt_sclk: [Option<RmtSclkConfig>; 1],
1979 spi_function_clock: [Option<SpiFunctionClockConfig>; 1],
1980 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1981 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1982 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
1983 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
1984 pll_f96m_clk_refcount: u32,
1985 pll_f48m_clk_refcount: u32,
1986 rc_fast_clk_refcount: u32,
1987 xtal32k_clk_refcount: u32,
1988 hp_root_clk_refcount: u32,
1989 apb_clk_refcount: u32,
1990 lp_fast_clk_refcount: u32,
1991 timg_calibration_clock_refcount: u32,
1992 sdm_function_clock_refcount: [u32; 1],
1993 i2c_function_clock_refcount: [u32; 2],
1994 mcpwm_function_clock_refcount: [u32; 1],
1995 parl_io_rx_clock_refcount: [u32; 1],
1996 parl_io_tx_clock_refcount: [u32; 1],
1997 rmt_sclk_refcount: [u32; 1],
1998 spi_function_clock_refcount: [u32; 1],
1999 timg_function_clock_refcount: [u32; 2],
2000 timg_wdt_clock_refcount: [u32; 2],
2001 uart_function_clock_refcount: [u32; 2],
2002 uart_baud_rate_generator_refcount: [u32; 2],
2003 }
2004 impl ClockTree {
2005 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
2007 CLOCK_TREE.with(f)
2008 }
2009 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
2011 self.xtal_clk
2012 }
2013 pub fn iomux_function_clock(&self) -> Option<IomuxFunctionClockConfig> {
2015 self.iomux_function_clock
2016 }
2017 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
2019 self.hp_root_clk
2020 }
2021 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
2023 self.cpu_clk
2024 }
2025 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
2027 self.ahb_clk
2028 }
2029 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
2031 self.apb_clk
2032 }
2033 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
2035 self.lp_fast_clk
2036 }
2037 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
2039 self.lp_slow_clk
2040 }
2041 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
2043 self.timg_calibration_clock
2044 }
2045 pub fn i2c0_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2047 self.i2c_function_clock[I2cInstance::I2c0 as usize]
2048 }
2049 pub fn i2c1_function_clock(&self) -> Option<I2cFunctionClockConfig> {
2051 self.i2c_function_clock[I2cInstance::I2c1 as usize]
2052 }
2053 pub fn mcpwm0_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
2055 self.mcpwm_function_clock[McpwmInstance::Mcpwm0 as usize]
2056 }
2057 pub fn parl_io_rx_clock(&self) -> Option<ParlIoRxClockConfig> {
2059 self.parl_io_rx_clock[ParlIoInstance::ParlIo as usize]
2060 }
2061 pub fn parl_io_tx_clock(&self) -> Option<ParlIoTxClockConfig> {
2063 self.parl_io_tx_clock[ParlIoInstance::ParlIo as usize]
2064 }
2065 pub fn rmt_sclk(&self) -> Option<RmtSclkConfig> {
2067 self.rmt_sclk[RmtInstance::Rmt as usize]
2068 }
2069 pub fn spi2_function_clock(&self) -> Option<SpiFunctionClockConfig> {
2071 self.spi_function_clock[SpiInstance::Spi2 as usize]
2072 }
2073 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2075 self.timg_function_clock[TimgInstance::Timg0 as usize]
2076 }
2077 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2079 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
2080 }
2081 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
2083 self.timg_function_clock[TimgInstance::Timg1 as usize]
2084 }
2085 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
2087 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
2088 }
2089 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
2091 self.uart_function_clock[UartInstance::Uart0 as usize]
2092 }
2093 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2095 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
2096 }
2097 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
2099 self.uart_function_clock[UartInstance::Uart1 as usize]
2100 }
2101 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
2103 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
2104 }
2105 }
2106 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
2107 ::esp_sync::NonReentrantMutex::new(ClockTree {
2108 xtal_clk: None,
2109 iomux_function_clock: None,
2110 hp_root_clk: None,
2111 cpu_clk: None,
2112 ahb_clk: None,
2113 apb_clk: None,
2114 lp_fast_clk: None,
2115 lp_slow_clk: None,
2116 timg_calibration_clock: None,
2117 i2c_function_clock: [None; 2],
2118 mcpwm_function_clock: [None; 1],
2119 parl_io_rx_clock: [None; 1],
2120 parl_io_tx_clock: [None; 1],
2121 rmt_sclk: [None; 1],
2122 spi_function_clock: [None; 1],
2123 timg_function_clock: [None; 2],
2124 timg_wdt_clock: [None; 2],
2125 uart_function_clock: [None; 2],
2126 uart_baud_rate_generator: [None; 2],
2127 pll_f96m_clk_refcount: 0,
2128 pll_f48m_clk_refcount: 0,
2129 rc_fast_clk_refcount: 0,
2130 xtal32k_clk_refcount: 0,
2131 hp_root_clk_refcount: 0,
2132 apb_clk_refcount: 0,
2133 lp_fast_clk_refcount: 0,
2134 timg_calibration_clock_refcount: 0,
2135 sdm_function_clock_refcount: [0; 1],
2136 i2c_function_clock_refcount: [0; 2],
2137 mcpwm_function_clock_refcount: [0; 1],
2138 parl_io_rx_clock_refcount: [0; 1],
2139 parl_io_tx_clock_refcount: [0; 1],
2140 rmt_sclk_refcount: [0; 1],
2141 spi_function_clock_refcount: [0; 1],
2142 timg_function_clock_refcount: [0; 2],
2143 timg_wdt_clock_refcount: [0; 2],
2144 uart_function_clock_refcount: [0; 2],
2145 uart_baud_rate_generator_refcount: [0; 2],
2146 });
2147 static XTAL_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2148 ::core::sync::atomic::AtomicU32::new(0);
2149 static IOMUX_FUNCTION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2150 ::core::sync::atomic::AtomicU32::new(0);
2151 static HP_ROOT_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2152 ::core::sync::atomic::AtomicU32::new(0);
2153 static CPU_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2154 ::core::sync::atomic::AtomicU32::new(0);
2155 static AHB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2156 ::core::sync::atomic::AtomicU32::new(0);
2157 static APB_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2158 ::core::sync::atomic::AtomicU32::new(0);
2159 static LP_FAST_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2160 ::core::sync::atomic::AtomicU32::new(0);
2161 static LP_SLOW_CLK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2162 ::core::sync::atomic::AtomicU32::new(0);
2163 static TIMG_CALIBRATION_CLOCK_FREQ_CACHE: ::core::sync::atomic::AtomicU32 =
2164 ::core::sync::atomic::AtomicU32::new(0);
2165 static I2C_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2166 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2167 static MCPWM_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2168 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2169 static PARL_IO_RX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2170 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2171 static PARL_IO_TX_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2172 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2173 static RMT_SCLK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2174 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2175 static SPI_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 1] =
2176 [const { ::core::sync::atomic::AtomicU32::new(0) }; 1];
2177 static TIMG_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2178 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2179 static TIMG_WDT_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2180 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2181 static UART_FUNCTION_CLOCK_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2182 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2183 static UART_BAUD_RATE_GENERATOR_FREQ_CACHE: [::core::sync::atomic::AtomicU32; 2] =
2184 [const { ::core::sync::atomic::AtomicU32::new(0) }; 2];
2185 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
2186 let old_config = clocks.xtal_clk.replace(config);
2187 refresh_xtal_clk_downstream(clocks);
2188 configure_xtal_clk_impl(clocks, old_config, config);
2189 }
2190 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
2191 clocks.xtal_clk
2192 }
2193 fn request_xtal_clk(_clocks: &mut ClockTree) {}
2194 fn release_xtal_clk(_clocks: &mut ClockTree) {}
2195 #[allow(unused_variables)]
2196 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
2197 config.value()
2198 }
2199 pub fn xtal_clk_frequency() -> u32 {
2200 XTAL_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2201 }
2202 pub fn request_pll_f96m_clk(clocks: &mut ClockTree) {
2203 trace!("Requesting PLL_F96M_CLK");
2204 if increment_reference_count(&mut clocks.pll_f96m_clk_refcount) {
2205 trace!("Enabling PLL_F96M_CLK");
2206 request_xtal_clk(clocks);
2207 enable_pll_f96m_clk_impl(clocks, true);
2208 }
2209 }
2210 pub fn release_pll_f96m_clk(clocks: &mut ClockTree) {
2211 trace!("Releasing PLL_F96M_CLK");
2212 if decrement_reference_count(&mut clocks.pll_f96m_clk_refcount) {
2213 trace!("Disabling PLL_F96M_CLK");
2214 enable_pll_f96m_clk_impl(clocks, false);
2215 release_xtal_clk(clocks);
2216 }
2217 }
2218 pub fn pll_f96m_clk_frequency() -> u32 {
2219 96000000
2220 }
2221 pub fn pll_f96m_clk_source_frequency() -> u32 {
2222 xtal_clk_frequency()
2223 }
2224 pub fn request_pll_f64m_clk(clocks: &mut ClockTree) {
2225 trace!("Requesting PLL_F64M_CLK");
2226 trace!("Enabling PLL_F64M_CLK");
2227 request_pll_f96m_clk(clocks);
2228 enable_pll_f64m_clk_impl(clocks, true);
2229 }
2230 pub fn release_pll_f64m_clk(clocks: &mut ClockTree) {
2231 trace!("Releasing PLL_F64M_CLK");
2232 trace!("Disabling PLL_F64M_CLK");
2233 enable_pll_f64m_clk_impl(clocks, false);
2234 release_pll_f96m_clk(clocks);
2235 }
2236 pub fn pll_f64m_clk_frequency() -> u32 {
2237 ((pll_f96m_clk_frequency() * 2) / 3)
2238 }
2239 pub fn pll_f64m_clk_source_frequency() -> u32 {
2240 pll_f96m_clk_frequency()
2241 }
2242 pub fn request_pll_f48m_clk(clocks: &mut ClockTree) {
2243 trace!("Requesting PLL_F48M_CLK");
2244 if increment_reference_count(&mut clocks.pll_f48m_clk_refcount) {
2245 trace!("Enabling PLL_F48M_CLK");
2246 request_pll_f96m_clk(clocks);
2247 enable_pll_f48m_clk_impl(clocks, true);
2248 }
2249 }
2250 pub fn release_pll_f48m_clk(clocks: &mut ClockTree) {
2251 trace!("Releasing PLL_F48M_CLK");
2252 if decrement_reference_count(&mut clocks.pll_f48m_clk_refcount) {
2253 trace!("Disabling PLL_F48M_CLK");
2254 enable_pll_f48m_clk_impl(clocks, false);
2255 release_pll_f96m_clk(clocks);
2256 }
2257 }
2258 pub fn pll_f48m_clk_frequency() -> u32 {
2259 (pll_f96m_clk_frequency() / 2)
2260 }
2261 pub fn pll_f48m_clk_source_frequency() -> u32 {
2262 pll_f96m_clk_frequency()
2263 }
2264 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
2265 trace!("Requesting RC_FAST_CLK");
2266 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
2267 trace!("Enabling RC_FAST_CLK");
2268 enable_rc_fast_clk_impl(clocks, true);
2269 }
2270 }
2271 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
2272 trace!("Releasing RC_FAST_CLK");
2273 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
2274 trace!("Disabling RC_FAST_CLK");
2275 enable_rc_fast_clk_impl(clocks, false);
2276 }
2277 }
2278 pub fn rc_fast_clk_frequency() -> u32 {
2279 8000000
2280 }
2281 pub fn configure_iomux_function_clock(
2282 clocks: &mut ClockTree,
2283 new_selector: IomuxFunctionClockConfig,
2284 ) {
2285 let old_selector = clocks.iomux_function_clock.replace(new_selector);
2286 refresh_iomux_function_clock_downstream(clocks);
2287 match new_selector {
2288 IomuxFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2289 IomuxFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
2290 }
2291 configure_iomux_function_clock_impl(clocks, old_selector, new_selector);
2292 if let Some(old_selector) = old_selector {
2293 match old_selector {
2294 IomuxFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2295 IomuxFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
2296 }
2297 }
2298 }
2299 pub fn iomux_function_clock_config(
2300 clocks: &mut ClockTree,
2301 ) -> Option<IomuxFunctionClockConfig> {
2302 clocks.iomux_function_clock
2303 }
2304 fn request_iomux_function_clock(_clocks: &mut ClockTree) {}
2305 fn release_iomux_function_clock(_clocks: &mut ClockTree) {}
2306 #[allow(unused_variables)]
2307 pub fn iomux_function_clock_config_frequency(
2308 clocks: &mut ClockTree,
2309 config: IomuxFunctionClockConfig,
2310 ) -> u32 {
2311 match config {
2312 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2313 IomuxFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
2314 }
2315 }
2316 pub fn iomux_function_clock_frequency() -> u32 {
2317 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2318 }
2319 pub fn iomux_function_clock_source_frequency(source: IomuxFunctionClockConfig) -> u32 {
2320 match source {
2321 IomuxFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2322 IomuxFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
2323 }
2324 }
2325 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
2326 trace!("Requesting XTAL32K_CLK");
2327 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
2328 trace!("Enabling XTAL32K_CLK");
2329 enable_xtal32k_clk_impl(clocks, true);
2330 }
2331 }
2332 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
2333 trace!("Releasing XTAL32K_CLK");
2334 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
2335 trace!("Disabling XTAL32K_CLK");
2336 enable_xtal32k_clk_impl(clocks, false);
2337 }
2338 }
2339 pub fn xtal32k_clk_frequency() -> u32 {
2340 32768
2341 }
2342 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
2343 trace!("Requesting OSC_SLOW_CLK");
2344 trace!("Enabling OSC_SLOW_CLK");
2345 enable_osc_slow_clk_impl(clocks, true);
2346 }
2347 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
2348 trace!("Releasing OSC_SLOW_CLK");
2349 trace!("Disabling OSC_SLOW_CLK");
2350 enable_osc_slow_clk_impl(clocks, false);
2351 }
2352 pub fn osc_slow_clk_frequency() -> u32 {
2353 32768
2354 }
2355 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
2356 trace!("Requesting RC_SLOW_CLK");
2357 trace!("Enabling RC_SLOW_CLK");
2358 enable_rc_slow_clk_impl(clocks, true);
2359 }
2360 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
2361 trace!("Releasing RC_SLOW_CLK");
2362 trace!("Disabling RC_SLOW_CLK");
2363 enable_rc_slow_clk_impl(clocks, false);
2364 }
2365 pub fn rc_slow_clk_frequency() -> u32 {
2366 130000
2367 }
2368 pub fn request_pll_lp_clk(clocks: &mut ClockTree) {
2369 trace!("Requesting PLL_LP_CLK");
2370 trace!("Enabling PLL_LP_CLK");
2371 request_xtal32k_clk(clocks);
2372 enable_pll_lp_clk_impl(clocks, true);
2373 }
2374 pub fn release_pll_lp_clk(clocks: &mut ClockTree) {
2375 trace!("Releasing PLL_LP_CLK");
2376 trace!("Disabling PLL_LP_CLK");
2377 enable_pll_lp_clk_impl(clocks, false);
2378 release_xtal32k_clk(clocks);
2379 }
2380 pub fn pll_lp_clk_frequency() -> u32 {
2381 8000000
2382 }
2383 pub fn pll_lp_clk_source_frequency() -> u32 {
2384 xtal32k_clk_frequency()
2385 }
2386 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
2387 let old_selector = clocks.hp_root_clk.replace(new_selector);
2388 refresh_hp_root_clk_downstream(clocks);
2389 if clocks.hp_root_clk_refcount > 0 {
2390 match new_selector {
2391 HpRootClkConfig::Pll96 => request_pll_f96m_clk(clocks),
2392 HpRootClkConfig::Pll64 => request_pll_f64m_clk(clocks),
2393 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2394 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2395 }
2396 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2397 if let Some(old_selector) = old_selector {
2398 match old_selector {
2399 HpRootClkConfig::Pll96 => release_pll_f96m_clk(clocks),
2400 HpRootClkConfig::Pll64 => release_pll_f64m_clk(clocks),
2401 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2402 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2403 }
2404 }
2405 } else {
2406 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
2407 }
2408 }
2409 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
2410 clocks.hp_root_clk
2411 }
2412 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
2413 trace!("Requesting HP_ROOT_CLK");
2414 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
2415 trace!("Enabling HP_ROOT_CLK");
2416 match unwrap!(clocks.hp_root_clk) {
2417 HpRootClkConfig::Pll96 => request_pll_f96m_clk(clocks),
2418 HpRootClkConfig::Pll64 => request_pll_f64m_clk(clocks),
2419 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
2420 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
2421 }
2422 enable_hp_root_clk_impl(clocks, true);
2423 }
2424 }
2425 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
2426 trace!("Releasing HP_ROOT_CLK");
2427 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
2428 trace!("Disabling HP_ROOT_CLK");
2429 enable_hp_root_clk_impl(clocks, false);
2430 match unwrap!(clocks.hp_root_clk) {
2431 HpRootClkConfig::Pll96 => release_pll_f96m_clk(clocks),
2432 HpRootClkConfig::Pll64 => release_pll_f64m_clk(clocks),
2433 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
2434 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
2435 }
2436 }
2437 }
2438 #[allow(unused_variables)]
2439 pub fn hp_root_clk_config_frequency(
2440 clocks: &mut ClockTree,
2441 config: HpRootClkConfig,
2442 ) -> u32 {
2443 match config {
2444 HpRootClkConfig::Pll96 => pll_f96m_clk_frequency(),
2445 HpRootClkConfig::Pll64 => pll_f64m_clk_frequency(),
2446 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2447 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2448 }
2449 }
2450 pub fn hp_root_clk_frequency() -> u32 {
2451 HP_ROOT_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2452 }
2453 pub fn hp_root_clk_source_frequency(source: HpRootClkConfig) -> u32 {
2454 match source {
2455 HpRootClkConfig::Pll96 => pll_f96m_clk_frequency(),
2456 HpRootClkConfig::Pll64 => pll_f64m_clk_frequency(),
2457 HpRootClkConfig::Xtal => xtal_clk_frequency(),
2458 HpRootClkConfig::RcFast => rc_fast_clk_frequency(),
2459 }
2460 }
2461 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
2462 let old_config = clocks.cpu_clk.replace(config);
2463 refresh_cpu_clk_downstream(clocks);
2464 configure_cpu_clk_impl(clocks, old_config, config);
2465 }
2466 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
2467 clocks.cpu_clk
2468 }
2469 fn request_cpu_clk(_clocks: &mut ClockTree) {}
2470 fn release_cpu_clk(_clocks: &mut ClockTree) {}
2471 #[allow(unused_variables)]
2472 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
2473 (hp_root_clk_frequency() / (config.divisor() + 1))
2474 }
2475 pub fn cpu_clk_frequency() -> u32 {
2476 CPU_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2477 }
2478 pub fn cpu_clk_source_frequency() -> u32 {
2479 hp_root_clk_frequency()
2480 }
2481 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
2482 let old_config = clocks.ahb_clk.replace(config);
2483 refresh_ahb_clk_downstream(clocks);
2484 configure_ahb_clk_impl(clocks, old_config, config);
2485 }
2486 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
2487 clocks.ahb_clk
2488 }
2489 fn request_ahb_clk(_clocks: &mut ClockTree) {}
2490 fn release_ahb_clk(_clocks: &mut ClockTree) {}
2491 #[allow(unused_variables)]
2492 pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
2493 (hp_root_clk_frequency() / (config.divisor() + 1))
2494 }
2495 pub fn ahb_clk_frequency() -> u32 {
2496 AHB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2497 }
2498 pub fn ahb_clk_source_frequency() -> u32 {
2499 hp_root_clk_frequency()
2500 }
2501 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
2502 let old_config = clocks.apb_clk.replace(config);
2503 refresh_apb_clk_downstream(clocks);
2504 configure_apb_clk_impl(clocks, old_config, config);
2505 }
2506 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
2507 clocks.apb_clk
2508 }
2509 pub fn request_apb_clk(clocks: &mut ClockTree) {
2510 trace!("Requesting APB_CLK");
2511 if increment_reference_count(&mut clocks.apb_clk_refcount) {
2512 trace!("Enabling APB_CLK");
2513 request_ahb_clk(clocks);
2514 enable_apb_clk_impl(clocks, true);
2515 }
2516 }
2517 pub fn release_apb_clk(clocks: &mut ClockTree) {
2518 trace!("Releasing APB_CLK");
2519 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
2520 trace!("Disabling APB_CLK");
2521 enable_apb_clk_impl(clocks, false);
2522 release_ahb_clk(clocks);
2523 }
2524 }
2525 #[allow(unused_variables)]
2526 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
2527 (ahb_clk_frequency() / (config.divisor() + 1))
2528 }
2529 pub fn apb_clk_frequency() -> u32 {
2530 APB_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2531 }
2532 pub fn apb_clk_source_frequency() -> u32 {
2533 ahb_clk_frequency()
2534 }
2535 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
2536 trace!("Requesting XTAL_D2_CLK");
2537 trace!("Enabling XTAL_D2_CLK");
2538 request_xtal_clk(clocks);
2539 enable_xtal_d2_clk_impl(clocks, true);
2540 }
2541 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
2542 trace!("Releasing XTAL_D2_CLK");
2543 trace!("Disabling XTAL_D2_CLK");
2544 enable_xtal_d2_clk_impl(clocks, false);
2545 release_xtal_clk(clocks);
2546 }
2547 pub fn xtal_d2_clk_frequency() -> u32 {
2548 (xtal_clk_frequency() / 2)
2549 }
2550 pub fn xtal_d2_clk_source_frequency() -> u32 {
2551 xtal_clk_frequency()
2552 }
2553 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
2554 let old_selector = clocks.lp_fast_clk.replace(new_selector);
2555 refresh_lp_fast_clk_downstream(clocks);
2556 if clocks.lp_fast_clk_refcount > 0 {
2557 match new_selector {
2558 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
2559 LpFastClkConfig::PllLpClk => request_pll_lp_clk(clocks),
2560 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
2561 }
2562 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2563 if let Some(old_selector) = old_selector {
2564 match old_selector {
2565 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
2566 LpFastClkConfig::PllLpClk => release_pll_lp_clk(clocks),
2567 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
2568 }
2569 }
2570 } else {
2571 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
2572 }
2573 }
2574 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
2575 clocks.lp_fast_clk
2576 }
2577 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
2578 trace!("Requesting LP_FAST_CLK");
2579 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
2580 trace!("Enabling LP_FAST_CLK");
2581 match unwrap!(clocks.lp_fast_clk) {
2582 LpFastClkConfig::RcFastClk => request_rc_fast_clk(clocks),
2583 LpFastClkConfig::PllLpClk => request_pll_lp_clk(clocks),
2584 LpFastClkConfig::XtalD2Clk => request_xtal_d2_clk(clocks),
2585 }
2586 enable_lp_fast_clk_impl(clocks, true);
2587 }
2588 }
2589 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
2590 trace!("Releasing LP_FAST_CLK");
2591 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
2592 trace!("Disabling LP_FAST_CLK");
2593 enable_lp_fast_clk_impl(clocks, false);
2594 match unwrap!(clocks.lp_fast_clk) {
2595 LpFastClkConfig::RcFastClk => release_rc_fast_clk(clocks),
2596 LpFastClkConfig::PllLpClk => release_pll_lp_clk(clocks),
2597 LpFastClkConfig::XtalD2Clk => release_xtal_d2_clk(clocks),
2598 }
2599 }
2600 }
2601 #[allow(unused_variables)]
2602 pub fn lp_fast_clk_config_frequency(
2603 clocks: &mut ClockTree,
2604 config: LpFastClkConfig,
2605 ) -> u32 {
2606 match config {
2607 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
2608 LpFastClkConfig::PllLpClk => pll_lp_clk_frequency(),
2609 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
2610 }
2611 }
2612 pub fn lp_fast_clk_frequency() -> u32 {
2613 LP_FAST_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2614 }
2615 pub fn lp_fast_clk_source_frequency(source: LpFastClkConfig) -> u32 {
2616 match source {
2617 LpFastClkConfig::RcFastClk => rc_fast_clk_frequency(),
2618 LpFastClkConfig::PllLpClk => pll_lp_clk_frequency(),
2619 LpFastClkConfig::XtalD2Clk => xtal_d2_clk_frequency(),
2620 }
2621 }
2622 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
2623 let old_selector = clocks.lp_slow_clk.replace(new_selector);
2624 refresh_lp_slow_clk_downstream(clocks);
2625 match new_selector {
2626 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2627 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2628 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2629 }
2630 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
2631 if let Some(old_selector) = old_selector {
2632 match old_selector {
2633 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2634 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2635 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2636 }
2637 }
2638 }
2639 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
2640 clocks.lp_slow_clk
2641 }
2642 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
2643 trace!("Requesting LP_SLOW_CLK");
2644 trace!("Enabling LP_SLOW_CLK");
2645 match unwrap!(clocks.lp_slow_clk) {
2646 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
2647 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
2648 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
2649 }
2650 enable_lp_slow_clk_impl(clocks, true);
2651 }
2652 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
2653 trace!("Releasing LP_SLOW_CLK");
2654 trace!("Disabling LP_SLOW_CLK");
2655 enable_lp_slow_clk_impl(clocks, false);
2656 match unwrap!(clocks.lp_slow_clk) {
2657 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
2658 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
2659 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
2660 }
2661 }
2662 #[allow(unused_variables)]
2663 pub fn lp_slow_clk_config_frequency(
2664 clocks: &mut ClockTree,
2665 config: LpSlowClkConfig,
2666 ) -> u32 {
2667 match config {
2668 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2669 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2670 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2671 }
2672 }
2673 pub fn lp_slow_clk_frequency() -> u32 {
2674 LP_SLOW_CLK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2675 }
2676 pub fn lp_slow_clk_source_frequency(source: LpSlowClkConfig) -> u32 {
2677 match source {
2678 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(),
2679 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(),
2680 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(),
2681 }
2682 }
2683 pub fn configure_timg_calibration_clock(
2684 clocks: &mut ClockTree,
2685 new_selector: TimgCalibrationClockConfig,
2686 ) {
2687 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
2688 refresh_timg_calibration_clock_downstream(clocks);
2689 if clocks.timg_calibration_clock_refcount > 0 {
2690 match new_selector {
2691 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
2692 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2693 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2694 }
2695 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2696 if let Some(old_selector) = old_selector {
2697 match old_selector {
2698 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
2699 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2700 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2701 }
2702 }
2703 } else {
2704 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
2705 }
2706 }
2707 pub fn timg_calibration_clock_config(
2708 clocks: &mut ClockTree,
2709 ) -> Option<TimgCalibrationClockConfig> {
2710 clocks.timg_calibration_clock
2711 }
2712 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
2713 trace!("Requesting TIMG_CALIBRATION_CLOCK");
2714 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2715 trace!("Enabling TIMG_CALIBRATION_CLOCK");
2716 crate::rtc_cntl::WakeLock::acquire();
2717 match unwrap!(clocks.timg_calibration_clock) {
2718 TimgCalibrationClockConfig::RcSlowClk => request_lp_slow_clk(clocks),
2719 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
2720 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
2721 }
2722 enable_timg_calibration_clock_impl(clocks, true);
2723 }
2724 }
2725 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
2726 trace!("Releasing TIMG_CALIBRATION_CLOCK");
2727 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
2728 trace!("Disabling TIMG_CALIBRATION_CLOCK");
2729 crate::rtc_cntl::WakeLock::release();
2730 enable_timg_calibration_clock_impl(clocks, false);
2731 match unwrap!(clocks.timg_calibration_clock) {
2732 TimgCalibrationClockConfig::RcSlowClk => release_lp_slow_clk(clocks),
2733 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
2734 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
2735 }
2736 }
2737 }
2738 #[allow(unused_variables)]
2739 pub fn timg_calibration_clock_config_frequency(
2740 clocks: &mut ClockTree,
2741 config: TimgCalibrationClockConfig,
2742 ) -> u32 {
2743 match config {
2744 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
2745 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2746 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2747 }
2748 }
2749 pub fn timg_calibration_clock_frequency() -> u32 {
2750 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.load(::core::sync::atomic::Ordering::Acquire)
2751 }
2752 pub fn timg_calibration_clock_source_frequency(source: TimgCalibrationClockConfig) -> u32 {
2753 match source {
2754 TimgCalibrationClockConfig::RcSlowClk => lp_slow_clk_frequency(),
2755 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(),
2756 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(),
2757 }
2758 }
2759 impl SdmInstance {
2760 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2761 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2762 if increment_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
2763 {
2764 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2765 request_iomux_function_clock(clocks);
2766 self.enable_function_clock_impl(clocks, true);
2767 }
2768 }
2769 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2770 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2771 if decrement_reference_count(&mut clocks.sdm_function_clock_refcount[self as usize])
2772 {
2773 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2774 self.enable_function_clock_impl(clocks, false);
2775 release_iomux_function_clock(clocks);
2776 }
2777 }
2778 pub fn function_clock_frequency(self) -> u32 {
2779 iomux_function_clock_frequency()
2780 }
2781 pub fn function_clock_source_frequency() -> u32 {
2782 iomux_function_clock_frequency()
2783 }
2784 }
2785 impl I2cInstance {
2786 pub fn configure_function_clock(
2787 self,
2788 clocks: &mut ClockTree,
2789 config: I2cFunctionClockConfig,
2790 ) {
2791 let old_config = clocks.i2c_function_clock[self as usize].replace(config);
2792 refresh_i2c_function_clock_downstream(clocks, self);
2793 if clocks.i2c_function_clock_refcount[self as usize] > 0 {
2794 match config.sclk {
2795 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2796 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2797 }
2798 self.configure_function_clock_impl(clocks, old_config, config);
2799 if let Some(old_config) = old_config {
2800 match old_config.sclk {
2801 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2802 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2803 }
2804 }
2805 } else {
2806 self.configure_function_clock_impl(clocks, old_config, config);
2807 }
2808 }
2809 pub fn function_clock_config(
2810 self,
2811 clocks: &mut ClockTree,
2812 ) -> Option<I2cFunctionClockConfig> {
2813 clocks.i2c_function_clock[self as usize]
2814 }
2815 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2816 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2817 if increment_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
2818 {
2819 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2820 crate::rtc_cntl::WakeLock::acquire();
2821 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
2822 I2cFunctionClockSclk::Xtal => request_xtal_clk(clocks),
2823 I2cFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
2824 }
2825 self.enable_function_clock_impl(clocks, true);
2826 }
2827 }
2828 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2829 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2830 if decrement_reference_count(&mut clocks.i2c_function_clock_refcount[self as usize])
2831 {
2832 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2833 crate::rtc_cntl::WakeLock::release();
2834 self.enable_function_clock_impl(clocks, false);
2835 match unwrap!(clocks.i2c_function_clock[self as usize]).sclk {
2836 I2cFunctionClockSclk::Xtal => release_xtal_clk(clocks),
2837 I2cFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
2838 }
2839 }
2840 }
2841 #[allow(unused_variables)]
2842 pub fn function_clock_config_frequency(
2843 clocks: &mut ClockTree,
2844 config: I2cFunctionClockConfig,
2845 ) -> u32 {
2846 (match config.sclk {
2847 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
2848 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2849 } / (config.div_num() + 1))
2850 }
2851 pub fn function_clock_frequency(self) -> u32 {
2852 I2C_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2853 .load(::core::sync::atomic::Ordering::Acquire)
2854 }
2855 pub fn function_clock_source_frequency(sclk: I2cFunctionClockSclk) -> u32 {
2856 match sclk {
2857 I2cFunctionClockSclk::Xtal => xtal_clk_frequency(),
2858 I2cFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
2859 }
2860 }
2861 }
2862 impl McpwmInstance {
2863 pub fn configure_function_clock(
2864 self,
2865 clocks: &mut ClockTree,
2866 new_selector: McpwmFunctionClockConfig,
2867 ) {
2868 let old_selector = clocks.mcpwm_function_clock[self as usize].replace(new_selector);
2869 refresh_mcpwm_function_clock_downstream(clocks, self);
2870 if clocks.mcpwm_function_clock_refcount[self as usize] > 0 {
2871 match new_selector {
2872 McpwmFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2873 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2874 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2875 }
2876 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2877 if let Some(old_selector) = old_selector {
2878 match old_selector {
2879 McpwmFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2880 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2881 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2882 }
2883 }
2884 } else {
2885 self.configure_function_clock_impl(clocks, old_selector, new_selector);
2886 }
2887 }
2888 pub fn function_clock_config(
2889 self,
2890 clocks: &mut ClockTree,
2891 ) -> Option<McpwmFunctionClockConfig> {
2892 clocks.mcpwm_function_clock[self as usize]
2893 }
2894 pub fn request_function_clock(self, clocks: &mut ClockTree) {
2895 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
2896 if increment_reference_count(
2897 &mut clocks.mcpwm_function_clock_refcount[self as usize],
2898 ) {
2899 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
2900 crate::rtc_cntl::WakeLock::acquire();
2901 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
2902 McpwmFunctionClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2903 McpwmFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2904 McpwmFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
2905 }
2906 self.enable_function_clock_impl(clocks, true);
2907 }
2908 }
2909 pub fn release_function_clock(self, clocks: &mut ClockTree) {
2910 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
2911 if decrement_reference_count(
2912 &mut clocks.mcpwm_function_clock_refcount[self as usize],
2913 ) {
2914 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
2915 crate::rtc_cntl::WakeLock::release();
2916 self.enable_function_clock_impl(clocks, false);
2917 match unwrap!(clocks.mcpwm_function_clock[self as usize]) {
2918 McpwmFunctionClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2919 McpwmFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2920 McpwmFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
2921 }
2922 }
2923 }
2924 #[allow(unused_variables)]
2925 pub fn function_clock_config_frequency(
2926 clocks: &mut ClockTree,
2927 config: McpwmFunctionClockConfig,
2928 ) -> u32 {
2929 match config {
2930 McpwmFunctionClockConfig::PllF96m => pll_f96m_clk_frequency(),
2931 McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
2932 McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2933 }
2934 }
2935 pub fn function_clock_frequency(self) -> u32 {
2936 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
2937 .load(::core::sync::atomic::Ordering::Acquire)
2938 }
2939 pub fn function_clock_source_frequency(source: McpwmFunctionClockConfig) -> u32 {
2940 match source {
2941 McpwmFunctionClockConfig::PllF96m => pll_f96m_clk_frequency(),
2942 McpwmFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
2943 McpwmFunctionClockConfig::XtalClk => xtal_clk_frequency(),
2944 }
2945 }
2946 }
2947 impl ParlIoInstance {
2948 pub fn configure_rx_clock(
2949 self,
2950 clocks: &mut ClockTree,
2951 new_selector: ParlIoRxClockConfig,
2952 ) {
2953 let old_selector = clocks.parl_io_rx_clock[self as usize].replace(new_selector);
2954 refresh_parl_io_rx_clock_downstream(clocks, self);
2955 if clocks.parl_io_rx_clock_refcount[self as usize] > 0 {
2956 match new_selector {
2957 ParlIoRxClockConfig::XtalClk => request_xtal_clk(clocks),
2958 ParlIoRxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2959 ParlIoRxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2960 }
2961 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
2962 if let Some(old_selector) = old_selector {
2963 match old_selector {
2964 ParlIoRxClockConfig::XtalClk => release_xtal_clk(clocks),
2965 ParlIoRxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2966 ParlIoRxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2967 }
2968 }
2969 } else {
2970 self.configure_rx_clock_impl(clocks, old_selector, new_selector);
2971 }
2972 }
2973 pub fn rx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoRxClockConfig> {
2974 clocks.parl_io_rx_clock[self as usize]
2975 }
2976 pub fn request_rx_clock(self, clocks: &mut ClockTree) {
2977 trace!("Requesting {:?}::RX_CLOCK", self);
2978 if increment_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
2979 trace!("Enabling {:?}::RX_CLOCK", self);
2980 crate::rtc_cntl::WakeLock::acquire();
2981 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
2982 ParlIoRxClockConfig::XtalClk => request_xtal_clk(clocks),
2983 ParlIoRxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
2984 ParlIoRxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
2985 }
2986 self.enable_rx_clock_impl(clocks, true);
2987 }
2988 }
2989 pub fn release_rx_clock(self, clocks: &mut ClockTree) {
2990 trace!("Releasing {:?}::RX_CLOCK", self);
2991 if decrement_reference_count(&mut clocks.parl_io_rx_clock_refcount[self as usize]) {
2992 trace!("Disabling {:?}::RX_CLOCK", self);
2993 crate::rtc_cntl::WakeLock::release();
2994 self.enable_rx_clock_impl(clocks, false);
2995 match unwrap!(clocks.parl_io_rx_clock[self as usize]) {
2996 ParlIoRxClockConfig::XtalClk => release_xtal_clk(clocks),
2997 ParlIoRxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
2998 ParlIoRxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
2999 }
3000 }
3001 }
3002 #[allow(unused_variables)]
3003 pub fn rx_clock_config_frequency(
3004 clocks: &mut ClockTree,
3005 config: ParlIoRxClockConfig,
3006 ) -> u32 {
3007 match config {
3008 ParlIoRxClockConfig::XtalClk => xtal_clk_frequency(),
3009 ParlIoRxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3010 ParlIoRxClockConfig::PllF96m => pll_f96m_clk_frequency(),
3011 }
3012 }
3013 pub fn rx_clock_frequency(self) -> u32 {
3014 PARL_IO_RX_CLOCK_FREQ_CACHE[self as usize]
3015 .load(::core::sync::atomic::Ordering::Acquire)
3016 }
3017 pub fn rx_clock_source_frequency(source: ParlIoRxClockConfig) -> u32 {
3018 match source {
3019 ParlIoRxClockConfig::XtalClk => xtal_clk_frequency(),
3020 ParlIoRxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3021 ParlIoRxClockConfig::PllF96m => pll_f96m_clk_frequency(),
3022 }
3023 }
3024 pub fn configure_tx_clock(
3025 self,
3026 clocks: &mut ClockTree,
3027 new_selector: ParlIoTxClockConfig,
3028 ) {
3029 let old_selector = clocks.parl_io_tx_clock[self as usize].replace(new_selector);
3030 refresh_parl_io_tx_clock_downstream(clocks, self);
3031 if clocks.parl_io_tx_clock_refcount[self as usize] > 0 {
3032 match new_selector {
3033 ParlIoTxClockConfig::XtalClk => request_xtal_clk(clocks),
3034 ParlIoTxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3035 ParlIoTxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
3036 }
3037 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
3038 if let Some(old_selector) = old_selector {
3039 match old_selector {
3040 ParlIoTxClockConfig::XtalClk => release_xtal_clk(clocks),
3041 ParlIoTxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3042 ParlIoTxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
3043 }
3044 }
3045 } else {
3046 self.configure_tx_clock_impl(clocks, old_selector, new_selector);
3047 }
3048 }
3049 pub fn tx_clock_config(self, clocks: &mut ClockTree) -> Option<ParlIoTxClockConfig> {
3050 clocks.parl_io_tx_clock[self as usize]
3051 }
3052 pub fn request_tx_clock(self, clocks: &mut ClockTree) {
3053 trace!("Requesting {:?}::TX_CLOCK", self);
3054 if increment_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
3055 trace!("Enabling {:?}::TX_CLOCK", self);
3056 crate::rtc_cntl::WakeLock::acquire();
3057 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
3058 ParlIoTxClockConfig::XtalClk => request_xtal_clk(clocks),
3059 ParlIoTxClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3060 ParlIoTxClockConfig::PllF96m => request_pll_f96m_clk(clocks),
3061 }
3062 self.enable_tx_clock_impl(clocks, true);
3063 }
3064 }
3065 pub fn release_tx_clock(self, clocks: &mut ClockTree) {
3066 trace!("Releasing {:?}::TX_CLOCK", self);
3067 if decrement_reference_count(&mut clocks.parl_io_tx_clock_refcount[self as usize]) {
3068 trace!("Disabling {:?}::TX_CLOCK", self);
3069 crate::rtc_cntl::WakeLock::release();
3070 self.enable_tx_clock_impl(clocks, false);
3071 match unwrap!(clocks.parl_io_tx_clock[self as usize]) {
3072 ParlIoTxClockConfig::XtalClk => release_xtal_clk(clocks),
3073 ParlIoTxClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3074 ParlIoTxClockConfig::PllF96m => release_pll_f96m_clk(clocks),
3075 }
3076 }
3077 }
3078 #[allow(unused_variables)]
3079 pub fn tx_clock_config_frequency(
3080 clocks: &mut ClockTree,
3081 config: ParlIoTxClockConfig,
3082 ) -> u32 {
3083 match config {
3084 ParlIoTxClockConfig::XtalClk => xtal_clk_frequency(),
3085 ParlIoTxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3086 ParlIoTxClockConfig::PllF96m => pll_f96m_clk_frequency(),
3087 }
3088 }
3089 pub fn tx_clock_frequency(self) -> u32 {
3090 PARL_IO_TX_CLOCK_FREQ_CACHE[self as usize]
3091 .load(::core::sync::atomic::Ordering::Acquire)
3092 }
3093 pub fn tx_clock_source_frequency(source: ParlIoTxClockConfig) -> u32 {
3094 match source {
3095 ParlIoTxClockConfig::XtalClk => xtal_clk_frequency(),
3096 ParlIoTxClockConfig::RcFastClk => rc_fast_clk_frequency(),
3097 ParlIoTxClockConfig::PllF96m => pll_f96m_clk_frequency(),
3098 }
3099 }
3100 }
3101 impl RmtInstance {
3102 pub fn configure_sclk(self, clocks: &mut ClockTree, new_selector: RmtSclkConfig) {
3103 let old_selector = clocks.rmt_sclk[self as usize].replace(new_selector);
3104 refresh_rmt_sclk_downstream(clocks, self);
3105 if clocks.rmt_sclk_refcount[self as usize] > 0 {
3106 match new_selector {
3107 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3108 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3109 }
3110 self.configure_sclk_impl(clocks, old_selector, new_selector);
3111 if let Some(old_selector) = old_selector {
3112 match old_selector {
3113 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3114 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3115 }
3116 }
3117 } else {
3118 self.configure_sclk_impl(clocks, old_selector, new_selector);
3119 }
3120 }
3121 pub fn sclk_config(self, clocks: &mut ClockTree) -> Option<RmtSclkConfig> {
3122 clocks.rmt_sclk[self as usize]
3123 }
3124 pub fn request_sclk(self, clocks: &mut ClockTree) {
3125 trace!("Requesting {:?}::SCLK", self);
3126 if increment_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3127 trace!("Enabling {:?}::SCLK", self);
3128 crate::rtc_cntl::WakeLock::acquire();
3129 match unwrap!(clocks.rmt_sclk[self as usize]) {
3130 RmtSclkConfig::XtalClk => request_xtal_clk(clocks),
3131 RmtSclkConfig::RcFastClk => request_rc_fast_clk(clocks),
3132 }
3133 self.enable_sclk_impl(clocks, true);
3134 }
3135 }
3136 pub fn release_sclk(self, clocks: &mut ClockTree) {
3137 trace!("Releasing {:?}::SCLK", self);
3138 if decrement_reference_count(&mut clocks.rmt_sclk_refcount[self as usize]) {
3139 trace!("Disabling {:?}::SCLK", self);
3140 crate::rtc_cntl::WakeLock::release();
3141 self.enable_sclk_impl(clocks, false);
3142 match unwrap!(clocks.rmt_sclk[self as usize]) {
3143 RmtSclkConfig::XtalClk => release_xtal_clk(clocks),
3144 RmtSclkConfig::RcFastClk => release_rc_fast_clk(clocks),
3145 }
3146 }
3147 }
3148 #[allow(unused_variables)]
3149 pub fn sclk_config_frequency(clocks: &mut ClockTree, config: RmtSclkConfig) -> u32 {
3150 match config {
3151 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3152 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3153 }
3154 }
3155 pub fn sclk_frequency(self) -> u32 {
3156 RMT_SCLK_FREQ_CACHE[self as usize].load(::core::sync::atomic::Ordering::Acquire)
3157 }
3158 pub fn sclk_source_frequency(source: RmtSclkConfig) -> u32 {
3159 match source {
3160 RmtSclkConfig::XtalClk => xtal_clk_frequency(),
3161 RmtSclkConfig::RcFastClk => rc_fast_clk_frequency(),
3162 }
3163 }
3164 }
3165 impl SpiInstance {
3166 pub fn configure_function_clock(
3167 self,
3168 clocks: &mut ClockTree,
3169 new_selector: SpiFunctionClockConfig,
3170 ) {
3171 let old_selector = clocks.spi_function_clock[self as usize].replace(new_selector);
3172 refresh_spi_function_clock_downstream(clocks, self);
3173 if clocks.spi_function_clock_refcount[self as usize] > 0 {
3174 match new_selector {
3175 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3176 SpiFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3177 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3178 }
3179 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3180 if let Some(old_selector) = old_selector {
3181 match old_selector {
3182 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3183 SpiFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3184 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3185 }
3186 }
3187 } else {
3188 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3189 }
3190 }
3191 pub fn function_clock_config(
3192 self,
3193 clocks: &mut ClockTree,
3194 ) -> Option<SpiFunctionClockConfig> {
3195 clocks.spi_function_clock[self as usize]
3196 }
3197 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3198 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3199 if increment_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3200 {
3201 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3202 crate::rtc_cntl::WakeLock::acquire();
3203 match unwrap!(clocks.spi_function_clock[self as usize]) {
3204 SpiFunctionClockConfig::Xtal => request_xtal_clk(clocks),
3205 SpiFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3206 SpiFunctionClockConfig::RcFast => request_rc_fast_clk(clocks),
3207 }
3208 self.enable_function_clock_impl(clocks, true);
3209 }
3210 }
3211 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3212 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3213 if decrement_reference_count(&mut clocks.spi_function_clock_refcount[self as usize])
3214 {
3215 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3216 crate::rtc_cntl::WakeLock::release();
3217 self.enable_function_clock_impl(clocks, false);
3218 match unwrap!(clocks.spi_function_clock[self as usize]) {
3219 SpiFunctionClockConfig::Xtal => release_xtal_clk(clocks),
3220 SpiFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3221 SpiFunctionClockConfig::RcFast => release_rc_fast_clk(clocks),
3222 }
3223 }
3224 }
3225 #[allow(unused_variables)]
3226 pub fn function_clock_config_frequency(
3227 clocks: &mut ClockTree,
3228 config: SpiFunctionClockConfig,
3229 ) -> u32 {
3230 match config {
3231 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3232 SpiFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
3233 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3234 }
3235 }
3236 pub fn function_clock_frequency(self) -> u32 {
3237 SPI_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3238 .load(::core::sync::atomic::Ordering::Acquire)
3239 }
3240 pub fn function_clock_source_frequency(source: SpiFunctionClockConfig) -> u32 {
3241 match source {
3242 SpiFunctionClockConfig::Xtal => xtal_clk_frequency(),
3243 SpiFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
3244 SpiFunctionClockConfig::RcFast => rc_fast_clk_frequency(),
3245 }
3246 }
3247 }
3248 impl TimgInstance {
3249 pub fn configure_function_clock(
3250 self,
3251 clocks: &mut ClockTree,
3252 new_selector: TimgFunctionClockConfig,
3253 ) {
3254 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
3255 refresh_timg_function_clock_downstream(clocks, self);
3256 if clocks.timg_function_clock_refcount[self as usize] > 0 {
3257 match new_selector {
3258 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3259 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3260 TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3261 }
3262 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3263 if let Some(old_selector) = old_selector {
3264 match old_selector {
3265 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3266 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3267 TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3268 }
3269 }
3270 } else {
3271 self.configure_function_clock_impl(clocks, old_selector, new_selector);
3272 }
3273 }
3274 pub fn function_clock_config(
3275 self,
3276 clocks: &mut ClockTree,
3277 ) -> Option<TimgFunctionClockConfig> {
3278 clocks.timg_function_clock[self as usize]
3279 }
3280 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3281 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3282 if increment_reference_count(
3283 &mut clocks.timg_function_clock_refcount[self as usize],
3284 ) {
3285 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3286 match unwrap!(clocks.timg_function_clock[self as usize]) {
3287 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
3288 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3289 TimgFunctionClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3290 }
3291 self.enable_function_clock_impl(clocks, true);
3292 }
3293 }
3294 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3295 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3296 if decrement_reference_count(
3297 &mut clocks.timg_function_clock_refcount[self as usize],
3298 ) {
3299 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3300 self.enable_function_clock_impl(clocks, false);
3301 match unwrap!(clocks.timg_function_clock[self as usize]) {
3302 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
3303 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3304 TimgFunctionClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3305 }
3306 }
3307 }
3308 #[allow(unused_variables)]
3309 pub fn function_clock_config_frequency(
3310 clocks: &mut ClockTree,
3311 config: TimgFunctionClockConfig,
3312 ) -> u32 {
3313 match config {
3314 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3315 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3316 TimgFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
3317 }
3318 }
3319 pub fn function_clock_frequency(self) -> u32 {
3320 TIMG_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3321 .load(::core::sync::atomic::Ordering::Acquire)
3322 }
3323 pub fn function_clock_source_frequency(source: TimgFunctionClockConfig) -> u32 {
3324 match source {
3325 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(),
3326 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(),
3327 TimgFunctionClockConfig::PllF48m => pll_f48m_clk_frequency(),
3328 }
3329 }
3330 pub fn configure_wdt_clock(
3331 self,
3332 clocks: &mut ClockTree,
3333 new_selector: TimgWdtClockConfig,
3334 ) {
3335 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
3336 refresh_timg_wdt_clock_downstream(clocks, self);
3337 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
3338 match new_selector {
3339 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3340 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3341 TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3342 }
3343 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3344 if let Some(old_selector) = old_selector {
3345 match old_selector {
3346 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3347 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3348 TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3349 }
3350 }
3351 } else {
3352 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
3353 }
3354 }
3355 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
3356 clocks.timg_wdt_clock[self as usize]
3357 }
3358 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
3359 trace!("Requesting {:?}::WDT_CLOCK", self);
3360 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3361 trace!("Enabling {:?}::WDT_CLOCK", self);
3362 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3363 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
3364 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
3365 TimgWdtClockConfig::PllF48m => request_pll_f48m_clk(clocks),
3366 }
3367 self.enable_wdt_clock_impl(clocks, true);
3368 }
3369 }
3370 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
3371 trace!("Releasing {:?}::WDT_CLOCK", self);
3372 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
3373 trace!("Disabling {:?}::WDT_CLOCK", self);
3374 self.enable_wdt_clock_impl(clocks, false);
3375 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
3376 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
3377 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
3378 TimgWdtClockConfig::PllF48m => release_pll_f48m_clk(clocks),
3379 }
3380 }
3381 }
3382 #[allow(unused_variables)]
3383 pub fn wdt_clock_config_frequency(
3384 clocks: &mut ClockTree,
3385 config: TimgWdtClockConfig,
3386 ) -> u32 {
3387 match config {
3388 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3389 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3390 TimgWdtClockConfig::PllF48m => pll_f48m_clk_frequency(),
3391 }
3392 }
3393 pub fn wdt_clock_frequency(self) -> u32 {
3394 TIMG_WDT_CLOCK_FREQ_CACHE[self as usize]
3395 .load(::core::sync::atomic::Ordering::Acquire)
3396 }
3397 pub fn wdt_clock_source_frequency(source: TimgWdtClockConfig) -> u32 {
3398 match source {
3399 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(),
3400 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(),
3401 TimgWdtClockConfig::PllF48m => pll_f48m_clk_frequency(),
3402 }
3403 }
3404 }
3405 impl UartInstance {
3406 pub fn configure_function_clock(
3407 self,
3408 clocks: &mut ClockTree,
3409 config: UartFunctionClockConfig,
3410 ) {
3411 let old_config = clocks.uart_function_clock[self as usize].replace(config);
3412 refresh_uart_function_clock_downstream(clocks, self);
3413 if clocks.uart_function_clock_refcount[self as usize] > 0 {
3414 match config.sclk {
3415 UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
3416 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3417 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3418 }
3419 self.configure_function_clock_impl(clocks, old_config, config);
3420 if let Some(old_config) = old_config {
3421 match old_config.sclk {
3422 UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
3423 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3424 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3425 }
3426 }
3427 } else {
3428 self.configure_function_clock_impl(clocks, old_config, config);
3429 }
3430 }
3431 pub fn function_clock_config(
3432 self,
3433 clocks: &mut ClockTree,
3434 ) -> Option<UartFunctionClockConfig> {
3435 clocks.uart_function_clock[self as usize]
3436 }
3437 pub fn request_function_clock(self, clocks: &mut ClockTree) {
3438 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
3439 if increment_reference_count(
3440 &mut clocks.uart_function_clock_refcount[self as usize],
3441 ) {
3442 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
3443 crate::rtc_cntl::WakeLock::acquire();
3444 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3445 UartFunctionClockSclk::PllF48m => request_pll_f48m_clk(clocks),
3446 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
3447 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
3448 }
3449 self.enable_function_clock_impl(clocks, true);
3450 }
3451 }
3452 pub fn release_function_clock(self, clocks: &mut ClockTree) {
3453 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
3454 if decrement_reference_count(
3455 &mut clocks.uart_function_clock_refcount[self as usize],
3456 ) {
3457 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
3458 crate::rtc_cntl::WakeLock::release();
3459 self.enable_function_clock_impl(clocks, false);
3460 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
3461 UartFunctionClockSclk::PllF48m => release_pll_f48m_clk(clocks),
3462 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
3463 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
3464 }
3465 }
3466 }
3467 #[allow(unused_variables)]
3468 pub fn function_clock_config_frequency(
3469 clocks: &mut ClockTree,
3470 config: UartFunctionClockConfig,
3471 ) -> u32 {
3472 (match config.sclk {
3473 UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(),
3474 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3475 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3476 } / (config.div_num() + 1))
3477 }
3478 pub fn function_clock_frequency(self) -> u32 {
3479 UART_FUNCTION_CLOCK_FREQ_CACHE[self as usize]
3480 .load(::core::sync::atomic::Ordering::Acquire)
3481 }
3482 pub fn function_clock_source_frequency(sclk: UartFunctionClockSclk) -> u32 {
3483 match sclk {
3484 UartFunctionClockSclk::PllF48m => pll_f48m_clk_frequency(),
3485 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(),
3486 UartFunctionClockSclk::Xtal => xtal_clk_frequency(),
3487 }
3488 }
3489 pub fn configure_baud_rate_generator(
3490 self,
3491 clocks: &mut ClockTree,
3492 config: UartBaudRateGeneratorConfig,
3493 ) {
3494 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
3495 refresh_uart_baud_rate_generator_downstream(clocks, self);
3496 self.configure_baud_rate_generator_impl(clocks, old_config, config);
3497 }
3498 pub fn baud_rate_generator_config(
3499 self,
3500 clocks: &mut ClockTree,
3501 ) -> Option<UartBaudRateGeneratorConfig> {
3502 clocks.uart_baud_rate_generator[self as usize]
3503 }
3504 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
3505 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
3506 if increment_reference_count(
3507 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3508 ) {
3509 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
3510 self.request_function_clock(clocks);
3511 self.enable_baud_rate_generator_impl(clocks, true);
3512 }
3513 }
3514 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
3515 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
3516 if decrement_reference_count(
3517 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
3518 ) {
3519 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
3520 self.enable_baud_rate_generator_impl(clocks, false);
3521 self.release_function_clock(clocks);
3522 }
3523 }
3524 #[allow(unused_variables)]
3525 pub fn baud_rate_generator_config_frequency(
3526 self,
3527 clocks: &mut ClockTree,
3528 config: UartBaudRateGeneratorConfig,
3529 ) -> u32 {
3530 ((self.function_clock_frequency() * 16)
3531 / ((config.integral() * 16) + config.fractional()))
3532 }
3533 pub fn baud_rate_generator_frequency(self) -> u32 {
3534 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[self as usize]
3535 .load(::core::sync::atomic::Ordering::Acquire)
3536 }
3537 }
3538 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3546 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3547 #[instability::unstable]
3548 pub struct ClockConfig {
3549 pub xtal_clk: Option<XtalClkConfig>,
3551 pub iomux_function_clock: Option<IomuxFunctionClockConfig>,
3553 pub hp_root_clk: Option<HpRootClkConfig>,
3555 pub cpu_clk: Option<CpuClkConfig>,
3557 pub ahb_clk: Option<AhbClkConfig>,
3559 pub apb_clk: Option<ApbClkConfig>,
3561 pub lp_fast_clk: Option<LpFastClkConfig>,
3563 pub lp_slow_clk: Option<LpSlowClkConfig>,
3565 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
3567 }
3568 impl ClockConfig {
3569 fn apply(&self, clocks: &mut ClockTree) {
3570 if let Some(config) = self.xtal_clk {
3571 configure_xtal_clk(clocks, config);
3572 }
3573 if let Some(config) = self.iomux_function_clock {
3574 configure_iomux_function_clock(clocks, config);
3575 }
3576 if let Some(config) = self.hp_root_clk {
3577 configure_hp_root_clk(clocks, config);
3578 }
3579 if let Some(config) = self.cpu_clk {
3580 configure_cpu_clk(clocks, config);
3581 }
3582 if let Some(config) = self.ahb_clk {
3583 configure_ahb_clk(clocks, config);
3584 }
3585 if let Some(config) = self.apb_clk {
3586 configure_apb_clk(clocks, config);
3587 }
3588 if let Some(config) = self.lp_fast_clk {
3589 configure_lp_fast_clk(clocks, config);
3590 }
3591 if let Some(config) = self.lp_slow_clk {
3592 configure_lp_slow_clk(clocks, config);
3593 }
3594 if let Some(config) = self.timg_calibration_clock {
3595 configure_timg_calibration_clock(clocks, config);
3596 }
3597 }
3598 }
3599 fn increment_reference_count(refcount: &mut u32) -> bool {
3600 let first = *refcount == 0;
3601 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
3602 first
3603 }
3604 fn decrement_reference_count(refcount: &mut u32) -> bool {
3605 *refcount = refcount.saturating_sub(1);
3606 let last = *refcount == 0;
3607 last
3608 }
3609 fn refresh_xtal_clk_downstream(clocks: &mut ClockTree) {
3610 if let Some(config) = clocks.xtal_clk {
3611 XTAL_CLK_FREQ_CACHE.store(
3612 xtal_clk_config_frequency(clocks, config),
3613 ::core::sync::atomic::Ordering::Release,
3614 );
3615 }
3616 refresh_iomux_function_clock_downstream(clocks);
3617 refresh_hp_root_clk_downstream(clocks);
3618 refresh_lp_fast_clk_downstream(clocks);
3619 for child_instance in [I2cInstance::I2c0, I2cInstance::I2c1] {
3620 refresh_i2c_function_clock_downstream(clocks, child_instance);
3621 }
3622 for child_instance in [McpwmInstance::Mcpwm0] {
3623 refresh_mcpwm_function_clock_downstream(clocks, child_instance);
3624 }
3625 for child_instance in [ParlIoInstance::ParlIo] {
3626 refresh_parl_io_rx_clock_downstream(clocks, child_instance);
3627 refresh_parl_io_tx_clock_downstream(clocks, child_instance);
3628 }
3629 for child_instance in [RmtInstance::Rmt] {
3630 refresh_rmt_sclk_downstream(clocks, child_instance);
3631 }
3632 for child_instance in [SpiInstance::Spi2] {
3633 refresh_spi_function_clock_downstream(clocks, child_instance);
3634 }
3635 for child_instance in [TimgInstance::Timg0, TimgInstance::Timg1] {
3636 refresh_timg_function_clock_downstream(clocks, child_instance);
3637 refresh_timg_wdt_clock_downstream(clocks, child_instance);
3638 }
3639 for child_instance in [UartInstance::Uart0, UartInstance::Uart1] {
3640 refresh_uart_function_clock_downstream(clocks, child_instance);
3641 }
3642 }
3643 fn refresh_iomux_function_clock_downstream(clocks: &mut ClockTree) {
3644 if let Some(config) = clocks.iomux_function_clock {
3645 IOMUX_FUNCTION_CLOCK_FREQ_CACHE.store(
3646 iomux_function_clock_config_frequency(clocks, config),
3647 ::core::sync::atomic::Ordering::Release,
3648 );
3649 }
3650 }
3651 fn refresh_hp_root_clk_downstream(clocks: &mut ClockTree) {
3652 if let Some(config) = clocks.hp_root_clk {
3653 HP_ROOT_CLK_FREQ_CACHE.store(
3654 hp_root_clk_config_frequency(clocks, config),
3655 ::core::sync::atomic::Ordering::Release,
3656 );
3657 }
3658 refresh_cpu_clk_downstream(clocks);
3659 refresh_ahb_clk_downstream(clocks);
3660 }
3661 fn refresh_cpu_clk_downstream(clocks: &mut ClockTree) {
3662 if let Some(config) = clocks.cpu_clk {
3663 CPU_CLK_FREQ_CACHE.store(
3664 cpu_clk_config_frequency(clocks, config),
3665 ::core::sync::atomic::Ordering::Release,
3666 );
3667 }
3668 }
3669 fn refresh_ahb_clk_downstream(clocks: &mut ClockTree) {
3670 if let Some(config) = clocks.ahb_clk {
3671 AHB_CLK_FREQ_CACHE.store(
3672 ahb_clk_config_frequency(clocks, config),
3673 ::core::sync::atomic::Ordering::Release,
3674 );
3675 }
3676 refresh_apb_clk_downstream(clocks);
3677 }
3678 fn refresh_apb_clk_downstream(clocks: &mut ClockTree) {
3679 if let Some(config) = clocks.apb_clk {
3680 APB_CLK_FREQ_CACHE.store(
3681 apb_clk_config_frequency(clocks, config),
3682 ::core::sync::atomic::Ordering::Release,
3683 );
3684 }
3685 }
3686 fn refresh_lp_fast_clk_downstream(clocks: &mut ClockTree) {
3687 if let Some(config) = clocks.lp_fast_clk {
3688 LP_FAST_CLK_FREQ_CACHE.store(
3689 lp_fast_clk_config_frequency(clocks, config),
3690 ::core::sync::atomic::Ordering::Release,
3691 );
3692 }
3693 }
3694 fn refresh_lp_slow_clk_downstream(clocks: &mut ClockTree) {
3695 if let Some(config) = clocks.lp_slow_clk {
3696 LP_SLOW_CLK_FREQ_CACHE.store(
3697 lp_slow_clk_config_frequency(clocks, config),
3698 ::core::sync::atomic::Ordering::Release,
3699 );
3700 }
3701 refresh_timg_calibration_clock_downstream(clocks);
3702 }
3703 fn refresh_timg_calibration_clock_downstream(clocks: &mut ClockTree) {
3704 if let Some(config) = clocks.timg_calibration_clock {
3705 TIMG_CALIBRATION_CLOCK_FREQ_CACHE.store(
3706 timg_calibration_clock_config_frequency(clocks, config),
3707 ::core::sync::atomic::Ordering::Release,
3708 );
3709 }
3710 }
3711 fn refresh_i2c_function_clock_downstream(clocks: &mut ClockTree, instance: I2cInstance) {
3712 if let Some(config) = clocks.i2c_function_clock[instance as usize] {
3713 I2C_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3714 I2cInstance::function_clock_config_frequency(clocks, config),
3715 ::core::sync::atomic::Ordering::Release,
3716 );
3717 }
3718 }
3719 fn refresh_mcpwm_function_clock_downstream(
3720 clocks: &mut ClockTree,
3721 instance: McpwmInstance,
3722 ) {
3723 if let Some(config) = clocks.mcpwm_function_clock[instance as usize] {
3724 MCPWM_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3725 McpwmInstance::function_clock_config_frequency(clocks, config),
3726 ::core::sync::atomic::Ordering::Release,
3727 );
3728 }
3729 }
3730 fn refresh_parl_io_rx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
3731 if let Some(config) = clocks.parl_io_rx_clock[instance as usize] {
3732 PARL_IO_RX_CLOCK_FREQ_CACHE[instance as usize].store(
3733 ParlIoInstance::rx_clock_config_frequency(clocks, config),
3734 ::core::sync::atomic::Ordering::Release,
3735 );
3736 }
3737 }
3738 fn refresh_parl_io_tx_clock_downstream(clocks: &mut ClockTree, instance: ParlIoInstance) {
3739 if let Some(config) = clocks.parl_io_tx_clock[instance as usize] {
3740 PARL_IO_TX_CLOCK_FREQ_CACHE[instance as usize].store(
3741 ParlIoInstance::tx_clock_config_frequency(clocks, config),
3742 ::core::sync::atomic::Ordering::Release,
3743 );
3744 }
3745 }
3746 fn refresh_rmt_sclk_downstream(clocks: &mut ClockTree, instance: RmtInstance) {
3747 if let Some(config) = clocks.rmt_sclk[instance as usize] {
3748 RMT_SCLK_FREQ_CACHE[instance as usize].store(
3749 RmtInstance::sclk_config_frequency(clocks, config),
3750 ::core::sync::atomic::Ordering::Release,
3751 );
3752 }
3753 }
3754 fn refresh_spi_function_clock_downstream(clocks: &mut ClockTree, instance: SpiInstance) {
3755 if let Some(config) = clocks.spi_function_clock[instance as usize] {
3756 SPI_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3757 SpiInstance::function_clock_config_frequency(clocks, config),
3758 ::core::sync::atomic::Ordering::Release,
3759 );
3760 }
3761 }
3762 fn refresh_timg_function_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3763 if let Some(config) = clocks.timg_function_clock[instance as usize] {
3764 TIMG_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3765 TimgInstance::function_clock_config_frequency(clocks, config),
3766 ::core::sync::atomic::Ordering::Release,
3767 );
3768 }
3769 }
3770 fn refresh_timg_wdt_clock_downstream(clocks: &mut ClockTree, instance: TimgInstance) {
3771 if let Some(config) = clocks.timg_wdt_clock[instance as usize] {
3772 TIMG_WDT_CLOCK_FREQ_CACHE[instance as usize].store(
3773 TimgInstance::wdt_clock_config_frequency(clocks, config),
3774 ::core::sync::atomic::Ordering::Release,
3775 );
3776 }
3777 }
3778 fn refresh_uart_function_clock_downstream(clocks: &mut ClockTree, instance: UartInstance) {
3779 if let Some(config) = clocks.uart_function_clock[instance as usize] {
3780 UART_FUNCTION_CLOCK_FREQ_CACHE[instance as usize].store(
3781 UartInstance::function_clock_config_frequency(clocks, config),
3782 ::core::sync::atomic::Ordering::Release,
3783 );
3784 }
3785 refresh_uart_baud_rate_generator_downstream(clocks, instance);
3786 }
3787 fn refresh_uart_baud_rate_generator_downstream(
3788 clocks: &mut ClockTree,
3789 instance: UartInstance,
3790 ) {
3791 if let Some(config) = clocks.uart_baud_rate_generator[instance as usize] {
3792 UART_BAUD_RATE_GENERATOR_FREQ_CACHE[instance as usize].store(
3793 instance.baud_rate_generator_config_frequency(clocks, config),
3794 ::core::sync::atomic::Ordering::Release,
3795 );
3796 }
3797 }
3798 };
3799}
3800#[macro_export]
3804#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3805macro_rules! implement_peripheral_clocks {
3806 () => {
3807 #[doc(hidden)]
3808 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3809 #[repr(u8)]
3810 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3811 pub enum Peripheral {
3812 Aes,
3814 AhbGdma,
3816 ApbSarAdc,
3818 Ds,
3820 Ecc,
3822 Ecdsa,
3824 Etm,
3826 GpioSd,
3828 Hmac,
3830 I2cExt0,
3832 I2cExt1,
3834 I2s0,
3836 Ledc,
3838 Mcpwm0,
3840 ParlIo,
3842 Pcnt,
3844 Rmt,
3846 Rsa,
3848 Sha,
3850 Spi2,
3852 Systimer,
3854 Timg0,
3856 Timg1,
3858 Trace0,
3860 Tsens,
3862 Twai0,
3864 Uart0,
3866 Uart1,
3868 Uhci0,
3870 UsbDevice,
3872 }
3873 impl Peripheral {
3874 const KEEP_ENABLED: &[Peripheral] =
3875 &[Self::Systimer, Self::Timg0, Self::Uart0, Self::UsbDevice];
3876 const COUNT: usize = Self::ALL.len();
3877 const ALL: &[Self] = &[
3878 Self::Aes,
3879 Self::AhbGdma,
3880 Self::ApbSarAdc,
3881 Self::Ds,
3882 Self::Ecc,
3883 Self::Ecdsa,
3884 Self::Etm,
3885 Self::GpioSd,
3886 Self::Hmac,
3887 Self::I2cExt0,
3888 Self::I2cExt1,
3889 Self::I2s0,
3890 Self::Ledc,
3891 Self::Mcpwm0,
3892 Self::ParlIo,
3893 Self::Pcnt,
3894 Self::Rmt,
3895 Self::Rsa,
3896 Self::Sha,
3897 Self::Spi2,
3898 Self::Systimer,
3899 Self::Timg0,
3900 Self::Timg1,
3901 Self::Trace0,
3902 Self::Tsens,
3903 Self::Twai0,
3904 Self::Uart0,
3905 Self::Uart1,
3906 Self::Uhci0,
3907 Self::UsbDevice,
3908 ];
3909 }
3910 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
3911 match peripheral {
3912 Peripheral::Aes => {
3913 crate::peripherals::SYSTEM::regs()
3914 .aes_conf()
3915 .modify(|_, w| w.aes_clk_en().bit(enable));
3916 }
3917 Peripheral::AhbGdma => {
3918 crate::peripherals::SYSTEM::regs()
3919 .gdma_conf()
3920 .modify(|_, w| w.gdma_clk_en().bit(enable));
3921 }
3922 Peripheral::ApbSarAdc => {
3923 crate::peripherals::SYSTEM::regs()
3924 .saradc_conf()
3925 .modify(|_, w| w.saradc_reg_clk_en().bit(enable));
3926 }
3927 Peripheral::Ds => {
3928 crate::peripherals::SYSTEM::regs()
3929 .ds_conf()
3930 .modify(|_, w| w.ds_clk_en().bit(enable));
3931 }
3932 Peripheral::Ecc => {
3933 crate::peripherals::SYSTEM::regs()
3934 .ecc_conf()
3935 .modify(|_, w| w.ecc_clk_en().bit(enable));
3936 }
3937 Peripheral::Ecdsa => {
3938 crate::peripherals::SYSTEM::regs()
3939 .ecdsa_conf()
3940 .modify(|_, w| w.ecdsa_clk_en().bit(enable));
3941 }
3942 Peripheral::Etm => {
3943 crate::peripherals::SYSTEM::regs()
3944 .etm_conf()
3945 .modify(|_, w| w.etm_clk_en().bit(enable));
3946 }
3947 Peripheral::GpioSd => {
3948 crate::peripherals::GPIO_SD::regs()
3949 .clock_gate()
3950 .modify(|_, w| w.clk_en().bit(enable));
3951 }
3952 Peripheral::Hmac => {
3953 crate::peripherals::SYSTEM::regs()
3954 .hmac_conf()
3955 .modify(|_, w| w.hmac_clk_en().bit(enable));
3956 }
3957 Peripheral::I2cExt0 => {
3958 crate::peripherals::SYSTEM::regs()
3959 .i2c0_conf()
3960 .modify(|_, w| w.i2c0_clk_en().bit(enable));
3961 }
3962 Peripheral::I2cExt1 => {
3963 crate::peripherals::SYSTEM::regs()
3964 .i2c1_conf()
3965 .modify(|_, w| w.i2c1_clk_en().bit(enable));
3966 }
3967 Peripheral::I2s0 => {
3968 crate::peripherals::SYSTEM::regs()
3969 .i2s_conf()
3970 .modify(|_, w| w.i2s_clk_en().bit(enable));
3971 }
3972 Peripheral::Ledc => {
3973 crate::peripherals::SYSTEM::regs()
3974 .ledc_conf()
3975 .modify(|_, w| w.ledc_clk_en().bit(enable));
3976 }
3977 Peripheral::Mcpwm0 => {
3978 crate::peripherals::SYSTEM::regs()
3979 .pwm_conf()
3980 .modify(|_, w| w.pwm_clk_en().bit(enable));
3981 }
3982 Peripheral::ParlIo => {
3983 crate::peripherals::SYSTEM::regs()
3984 .parl_io_conf()
3985 .modify(|_, w| w.parl_clk_en().bit(enable));
3986 }
3987 Peripheral::Pcnt => {
3988 crate::peripherals::SYSTEM::regs()
3989 .pcnt_conf()
3990 .modify(|_, w| w.pcnt_clk_en().bit(enable));
3991 }
3992 Peripheral::Rmt => {
3993 crate::peripherals::SYSTEM::regs()
3994 .rmt_conf()
3995 .modify(|_, w| w.rmt_clk_en().bit(enable));
3996 }
3997 Peripheral::Rsa => {
3998 crate::peripherals::SYSTEM::regs()
3999 .rsa_conf()
4000 .modify(|_, w| w.rsa_clk_en().bit(enable));
4001 }
4002 Peripheral::Sha => {
4003 crate::peripherals::SYSTEM::regs()
4004 .sha_conf()
4005 .modify(|_, w| w.sha_clk_en().bit(enable));
4006 }
4007 Peripheral::Spi2 => {
4008 crate::peripherals::SYSTEM::regs()
4009 .spi2_conf()
4010 .modify(|_, w| w.spi2_clk_en().bit(enable));
4011 }
4012 Peripheral::Systimer => {
4013 crate::peripherals::SYSTEM::regs()
4014 .systimer_conf()
4015 .modify(|_, w| w.systimer_clk_en().bit(enable));
4016 }
4017 Peripheral::Timg0 => {
4018 crate::peripherals::SYSTEM::regs()
4019 .timergroup(0)
4020 .conf()
4021 .modify(|_, w| w.clk_en().bit(enable));
4022 }
4023 Peripheral::Timg1 => {
4024 crate::peripherals::SYSTEM::regs()
4025 .timergroup(1)
4026 .conf()
4027 .modify(|_, w| w.clk_en().bit(enable));
4028 }
4029 Peripheral::Trace0 => {
4030 crate::peripherals::SYSTEM::regs()
4031 .trace_conf()
4032 .modify(|_, w| w.trace_clk_en().bit(enable));
4033 }
4034 Peripheral::Tsens => {
4035 crate::peripherals::SYSTEM::regs()
4036 .tsens_clk_conf()
4037 .modify(|_, w| w.tsens_clk_en().bit(enable));
4038 }
4039 Peripheral::Twai0 => {
4040 crate::peripherals::SYSTEM::regs()
4041 .twai0_conf()
4042 .modify(|_, w| w.twai0_clk_en().bit(enable));
4043 crate::peripherals::SYSTEM::regs()
4044 .twai0_func_clk_conf()
4045 .modify(|_, w| w.twai0_func_clk_en().bit(enable));
4046 }
4047 Peripheral::Uart0 => {
4048 crate::peripherals::SYSTEM::regs()
4049 .uart(0)
4050 .conf()
4051 .modify(|_, w| w.clk_en().bit(enable));
4052 }
4053 Peripheral::Uart1 => {
4054 crate::peripherals::SYSTEM::regs()
4055 .uart(1)
4056 .conf()
4057 .modify(|_, w| w.clk_en().bit(enable));
4058 }
4059 Peripheral::Uhci0 => {
4060 crate::peripherals::SYSTEM::regs()
4061 .uhci_conf()
4062 .modify(|_, w| w.uhci_clk_en().bit(enable));
4063 }
4064 Peripheral::UsbDevice => {
4065 crate::peripherals::SYSTEM::regs()
4066 .usb_device_conf()
4067 .modify(|_, w| w.usb_device_clk_en().bit(enable));
4068 }
4069 }
4070 }
4071 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
4072 match peripheral {
4073 Peripheral::Aes => {
4074 crate::peripherals::SYSTEM::regs()
4075 .aes_conf()
4076 .modify(|_, w| w.aes_rst_en().bit(reset));
4077 }
4078 Peripheral::AhbGdma => {
4079 crate::peripherals::SYSTEM::regs()
4080 .gdma_conf()
4081 .modify(|_, w| w.gdma_rst_en().bit(reset));
4082 }
4083 Peripheral::ApbSarAdc => {
4084 crate::peripherals::SYSTEM::regs()
4085 .saradc_conf()
4086 .modify(|_, w| w.saradc_reg_rst_en().bit(reset));
4087 }
4088 Peripheral::Ds => {
4089 crate::peripherals::SYSTEM::regs()
4090 .ds_conf()
4091 .modify(|_, w| w.ds_rst_en().bit(reset));
4092 }
4093 Peripheral::Ecc => {
4094 crate::peripherals::SYSTEM::regs()
4095 .ecc_conf()
4096 .modify(|_, w| w.ecc_rst_en().bit(reset));
4097 }
4098 Peripheral::Ecdsa => {
4099 crate::peripherals::SYSTEM::regs()
4100 .ecdsa_conf()
4101 .modify(|_, w| w.ecdsa_rst_en().bit(reset));
4102 }
4103 Peripheral::Etm => {
4104 crate::peripherals::SYSTEM::regs()
4105 .etm_conf()
4106 .modify(|_, w| w.etm_rst_en().bit(reset));
4107 }
4108 Peripheral::GpioSd => {
4109 let _ = reset;
4110 }
4111 Peripheral::Hmac => {
4112 crate::peripherals::SYSTEM::regs()
4113 .hmac_conf()
4114 .modify(|_, w| w.hmac_rst_en().bit(reset));
4115 }
4116 Peripheral::I2cExt0 => {
4117 crate::peripherals::SYSTEM::regs()
4118 .i2c0_conf()
4119 .modify(|_, w| w.i2c0_rst_en().bit(reset));
4120 }
4121 Peripheral::I2cExt1 => {
4122 crate::peripherals::SYSTEM::regs()
4123 .i2c1_conf()
4124 .modify(|_, w| w.i2c1_rst_en().bit(reset));
4125 }
4126 Peripheral::I2s0 => {
4127 crate::peripherals::SYSTEM::regs()
4128 .i2s_conf()
4129 .modify(|_, w| w.i2s_rst_en().bit(reset));
4130 }
4131 Peripheral::Ledc => {
4132 crate::peripherals::SYSTEM::regs()
4133 .ledc_conf()
4134 .modify(|_, w| w.ledc_rst_en().bit(reset));
4135 }
4136 Peripheral::Mcpwm0 => {
4137 crate::peripherals::SYSTEM::regs()
4138 .pwm_conf()
4139 .modify(|_, w| w.pwm_rst_en().bit(reset));
4140 }
4141 Peripheral::ParlIo => {
4142 crate::peripherals::SYSTEM::regs()
4143 .parl_io_conf()
4144 .modify(|_, w| w.parl_rst_en().bit(reset));
4145 }
4146 Peripheral::Pcnt => {
4147 crate::peripherals::SYSTEM::regs()
4148 .pcnt_conf()
4149 .modify(|_, w| w.pcnt_rst_en().bit(reset));
4150 }
4151 Peripheral::Rmt => {
4152 crate::peripherals::SYSTEM::regs()
4153 .rmt_conf()
4154 .modify(|_, w| w.rmt_rst_en().bit(reset));
4155 }
4156 Peripheral::Rsa => {
4157 crate::peripherals::SYSTEM::regs()
4158 .rsa_conf()
4159 .modify(|_, w| w.rsa_rst_en().bit(reset));
4160 }
4161 Peripheral::Sha => {
4162 crate::peripherals::SYSTEM::regs()
4163 .sha_conf()
4164 .modify(|_, w| w.sha_rst_en().bit(reset));
4165 }
4166 Peripheral::Spi2 => {
4167 crate::peripherals::SYSTEM::regs()
4168 .spi2_conf()
4169 .modify(|_, w| w.spi2_rst_en().bit(reset));
4170 }
4171 Peripheral::Systimer => {
4172 crate::peripherals::SYSTEM::regs()
4173 .systimer_conf()
4174 .modify(|_, w| w.systimer_rst_en().bit(reset));
4175 }
4176 Peripheral::Timg0 => {
4177 crate::peripherals::SYSTEM::regs()
4178 .timergroup(0)
4179 .conf()
4180 .modify(|_, w| w.rst_en().bit(reset));
4181 }
4182 Peripheral::Timg1 => {
4183 crate::peripherals::SYSTEM::regs()
4184 .timergroup(1)
4185 .conf()
4186 .modify(|_, w| w.rst_en().bit(reset));
4187 }
4188 Peripheral::Trace0 => {
4189 crate::peripherals::SYSTEM::regs()
4190 .trace_conf()
4191 .modify(|_, w| w.trace_rst_en().bit(reset));
4192 }
4193 Peripheral::Tsens => {
4194 crate::peripherals::SYSTEM::regs()
4195 .tsens_clk_conf()
4196 .modify(|_, w| w.tsens_rst_en().bit(reset));
4197 }
4198 Peripheral::Twai0 => {
4199 crate::peripherals::SYSTEM::regs()
4200 .twai0_conf()
4201 .modify(|_, w| w.twai0_rst_en().bit(reset));
4202 }
4203 Peripheral::Uart0 => {
4204 crate::peripherals::SYSTEM::regs()
4205 .uart(0)
4206 .conf()
4207 .modify(|_, w| w.rst_en().bit(reset));
4208 }
4209 Peripheral::Uart1 => {
4210 crate::peripherals::SYSTEM::regs()
4211 .uart(1)
4212 .conf()
4213 .modify(|_, w| w.rst_en().bit(reset));
4214 }
4215 Peripheral::Uhci0 => {
4216 crate::peripherals::SYSTEM::regs()
4217 .uhci_conf()
4218 .modify(|_, w| w.uhci_rst_en().bit(reset));
4219 }
4220 Peripheral::UsbDevice => {
4221 crate::peripherals::SYSTEM::regs()
4222 .usb_device_conf()
4223 .modify(|_, w| w.usb_device_rst_en().bit(reset));
4224 }
4225 }
4226 }
4227 };
4228}
4229#[macro_export]
4237#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4238macro_rules! memory_range {
4239 ("DRAM") => {
4240 0x40800000..0x40850000
4241 };
4242 (size as str, "DRAM") => {
4243 "327680"
4244 };
4245 ("DRAM2_UNINIT") => {
4246 0x4083EFD0..0x4084FEE0
4247 };
4248 (size as str, "DRAM2_UNINIT") => {
4249 "69392"
4250 };
4251 ("IROM") => {
4252 0x42000000..0x43000000
4253 };
4254 (size as str, "IROM") => {
4255 "16777216"
4256 };
4257 ("DROM") => {
4258 0x42000000..0x43000000
4259 };
4260 (size as str, "DROM") => {
4261 "16777216"
4262 };
4263}
4264#[macro_export]
4281#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4282macro_rules! for_each_i2c_master {
4283 ($($pattern:tt => $code:tt;)*) => {
4284 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
4285 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
4286 I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
4287 I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
4288 I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
4289 };
4290}
4291#[macro_export]
4318#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4319macro_rules! for_each_i2s {
4320 ($($pattern:tt => $code:tt;)*) => {
4321 macro_rules! _for_each_inner_i2s { $(($pattern) => $code;)* ($other : tt) => {} }
4322 _for_each_inner_i2s!((I2S0)); _for_each_inner_i2s!((I2S0, I2s0, I2S_MCLK,
4323 I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true, true, true,
4324 false)); _for_each_inner_i2s!((names(I2S0))); _for_each_inner_i2s!((all(I2S0,
4325 I2s0, I2S_MCLK, I2SO_BCK, I2SO_WS, I2SI_BCK, I2SI_WS, [I2SO_SD], [I2SI_SD], true,
4326 true, true, false)));
4327 };
4328}
4329#[macro_export]
4348#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4349macro_rules! for_each_uart {
4350 ($($pattern:tt => $code:tt;)*) => {
4351 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
4352 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS,
4353 wakeup_source = true)); _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD,
4354 U1CTS, U1RTS, wakeup_source = true)); _for_each_inner_uart!((all(0, UART0, Uart0,
4355 U0RXD, U0TXD, U0CTS, U0RTS, wakeup_source = true), (1, UART1, Uart1, U1RXD,
4356 U1TXD, U1CTS, U1RTS, wakeup_source = true)));
4357 };
4358}
4359#[macro_export]
4381#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4382macro_rules! for_each_spi_master {
4383 ($($pattern:tt => $code:tt;)*) => {
4384 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
4385 => {} } _for_each_inner_spi_master!((SPI2)); _for_each_inner_spi_master!((SPI2,
4386 Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID,
4387 FSPIQ, FSPIWP, FSPIHD], true)); _for_each_inner_spi_master!((names(SPI2)));
4388 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
4389 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
4390 };
4391}
4392#[macro_export]
4409#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4410macro_rules! for_each_spi_slave {
4411 ($($pattern:tt => $code:tt;)*) => {
4412 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
4413 => {} } _for_each_inner_spi_slave!((SPI2)); _for_each_inner_spi_slave!((SPI2,
4414 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
4415 _for_each_inner_spi_slave!((names(SPI2))); _for_each_inner_spi_slave!((all(SPI2,
4416 Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
4417 };
4418}
4419#[macro_export]
4420#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
4421macro_rules! for_each_peripheral {
4422 ($($pattern:tt => $code:tt;)*) => {
4423 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
4424 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
4425 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
4426 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
4427 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4428 "GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4429 "<section class=\"warning\">"] #[doc =
4430 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4431 #[doc = "<ul>"] #[doc =
4432 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4433 #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
4434 _for_each_inner_peripheral!((@ peri_type #[doc =
4435 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4436 "<section class=\"warning\">"] #[doc =
4437 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4438 #[doc = "<ul>"] #[doc =
4439 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4440 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
4441 _for_each_inner_peripheral!((@ peri_type #[doc =
4442 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4443 "<section class=\"warning\">"] #[doc =
4444 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4445 #[doc = "<ul>"] #[doc =
4446 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4447 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
4448 _for_each_inner_peripheral!((@ peri_type #[doc =
4449 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4450 "<section class=\"warning\">"] #[doc =
4451 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4452 #[doc = "<ul>"] #[doc =
4453 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4454 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
4455 _for_each_inner_peripheral!((@ peri_type #[doc =
4456 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4457 "<section class=\"warning\">"] #[doc =
4458 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4459 #[doc = "<ul>"] #[doc =
4460 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4461 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
4462 _for_each_inner_peripheral!((@ peri_type #[doc =
4463 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4464 "<section class=\"warning\">"] #[doc =
4465 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4466 #[doc = "<ul>"] #[doc =
4467 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4468 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
4469 _for_each_inner_peripheral!((@ peri_type #[doc =
4470 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4471 "<section class=\"warning\">"] #[doc =
4472 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4473 #[doc = "<ul>"] #[doc =
4474 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4475 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
4476 _for_each_inner_peripheral!((@ peri_type #[doc =
4477 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4478 "<section class=\"warning\">"] #[doc =
4479 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4480 #[doc = "<ul>"] #[doc =
4481 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4482 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
4483 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO10 peripheral singleton"]
4484 GPIO10 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4485 "GPIO11 peripheral singleton"] GPIO11 <= virtual()));
4486 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO12 peripheral singleton"]
4487 GPIO12 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4488 "GPIO13 peripheral singleton"] GPIO13 <= virtual()));
4489 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO14 peripheral singleton"]
4490 GPIO14 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
4491 "GPIO22 peripheral singleton"] GPIO22 <= virtual()));
4492 _for_each_inner_peripheral!((@ peri_type #[doc =
4493 "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4494 "<section class=\"warning\">"] #[doc =
4495 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4496 #[doc = "<ul>"] #[doc =
4497 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4498 = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()));
4499 _for_each_inner_peripheral!((@ peri_type #[doc =
4500 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4501 "<section class=\"warning\">"] #[doc =
4502 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4503 #[doc = "<ul>"] #[doc =
4504 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4505 = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()));
4506 _for_each_inner_peripheral!((@ peri_type #[doc =
4507 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4508 "<section class=\"warning\">"] #[doc =
4509 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4510 #[doc = "<ul>"] #[doc =
4511 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4512 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()));
4513 _for_each_inner_peripheral!((@ peri_type #[doc =
4514 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4515 "<section class=\"warning\">"] #[doc =
4516 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4517 #[doc = "<ul>"] #[doc =
4518 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4519 #[doc = "</section>"] GPIO26 <= virtual())); _for_each_inner_peripheral!((@
4520 peri_type #[doc = "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""]
4521 #[doc = "<section class=\"warning\">"] #[doc =
4522 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4523 #[doc = "<ul>"] #[doc =
4524 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4525 #[doc = "</section>"] GPIO27 <= virtual())); _for_each_inner_peripheral!((@
4526 peri_type #[doc = "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 :
4527 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4528 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4529 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4530 peri_type #[doc = "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 :
4531 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4532 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4533 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4534 peri_type #[doc = "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 :
4535 { bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4536 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4537 disable_dma_out_interrupt }) (unstable))); _for_each_inner_peripheral!((@
4538 peri_type #[doc = "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual()
4539 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4540 "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)));
4541 _for_each_inner_peripheral!((@ peri_type #[doc = "SDM_CH2 peripheral singleton"]
4542 SDM_CH2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4543 = "SDM_CH3 peripheral singleton"] SDM_CH3 <= virtual() (unstable)));
4544 _for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
4545 <= AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4546 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4547 "APB_SARADC peripheral singleton"] APB_SARADC <= APB_SARADC() (unstable)));
4548 _for_each_inner_peripheral!((@ peri_type #[doc =
4549 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
4550 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
4551 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4552 "DS peripheral singleton"] DS <= DS() (unstable)));
4553 _for_each_inner_peripheral!((@ peri_type #[doc = "ECC peripheral singleton"] ECC
4554 <= ECC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4555 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
4556 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
4557 GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4558 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
4559 _for_each_inner_peripheral!((@ peri_type #[doc = "HMAC peripheral singleton"]
4560 HMAC <= HMAC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4561 "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)));
4562 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_SYS peripheral singleton"]
4563 HP_SYS <= HP_SYS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4564 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
4565 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
4566 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4567 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4568 "I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
4569 enable_peri_interrupt, disable_peri_interrupt })));
4570 _for_each_inner_peripheral!((@ peri_type #[doc = "I2S0 peripheral singleton"]
4571 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
4572 disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4573 #[doc = "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
4574 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4575 _for_each_inner_peripheral!((@ peri_type #[doc =
4576 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
4577 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4578 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
4579 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
4580 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4581 "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)));
4582 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
4583 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4584 = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
4585 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
4586 LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4587 "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
4588 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_APM0 peripheral singleton"]
4589 LP_APM0 <= LP_APM0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4590 = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
4591 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
4592 LP_PERI <= LP_PERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4593 = "RTC_TIMER peripheral singleton"] RTC_TIMER <= LP_TIMER() (unstable)));
4594 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_WDT peripheral singleton"]
4595 LP_WDT <= LP_WDT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4596 "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
4597 _for_each_inner_peripheral!((@ peri_type #[doc =
4598 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
4599 _for_each_inner_peripheral!((@ peri_type #[doc =
4600 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
4601 _for_each_inner_peripheral!((@ peri_type #[doc =
4602 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
4603 _for_each_inner_peripheral!((@ peri_type #[doc =
4604 "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG() (unstable)));
4605 _for_each_inner_peripheral!((@ peri_type #[doc = "PARL_IO peripheral singleton"]
4606 PARL_IO <= PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
4607 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
4608 disable_tx_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
4609 #[doc = "PAU peripheral singleton"] PAU <= PAU() (unstable)));
4610 _for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
4611 PCNT <= PCNT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4612 "PCR peripheral singleton"] PCR <= PCR() (unstable)));
4613 _for_each_inner_peripheral!((@ peri_type #[doc = "PLIC_MX peripheral singleton"]
4614 PLIC_MX <= PLIC_MX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
4615 = "PMU peripheral singleton"] PMU <= PMU() (unstable)));
4616 _for_each_inner_peripheral!((@ peri_type #[doc = "RMT peripheral singleton"] RMT
4617 <= RMT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4618 "RNG peripheral singleton"] RNG <= virtual() (unstable)));
4619 _for_each_inner_peripheral!((@ peri_type #[doc = "RSA peripheral singleton"] RSA
4620 <= RSA(RSA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
4621 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4622 "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4623 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
4624 _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
4625 <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4626 "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)));
4627 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI1 peripheral singleton"]
4628 SPI1 <= SPI1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4629 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
4630 enable_peri_interrupt, disable_peri_interrupt })));
4631 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
4632 SYSTEM <= PCR() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4633 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)));
4634 _for_each_inner_peripheral!((@ peri_type #[doc = "TEE peripheral singleton"] TEE
4635 <= TEE() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4636 "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)));
4637 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG1 peripheral singleton"]
4638 TIMG1 <= TIMG1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4639 "TRACE0 peripheral singleton"] TRACE0 <= TRACE() (unstable)));
4640 _for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
4641 TWAI0 <= TWAI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4642 "UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
4643 enable_peri_interrupt, disable_peri_interrupt })));
4644 _for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
4645 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
4646 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
4647 "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)));
4648 _for_each_inner_peripheral!((@ peri_type #[doc =
4649 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
4650 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4651 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4652 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
4653 _for_each_inner_peripheral!((@ peri_type #[doc = "BT peripheral singleton"] BT <=
4654 virtual(LP_BLE_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
4655 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
4656 enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
4657 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
4658 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
4659 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)));
4660 _for_each_inner_peripheral!((@ peri_type #[doc =
4661 "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <= virtual() (unstable)));
4662 _for_each_inner_peripheral!((@ peri_type #[doc =
4663 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)));
4664 _for_each_inner_peripheral!((@ peri_type #[doc =
4665 "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <= virtual() (unstable)));
4666 _for_each_inner_peripheral!((@ peri_type #[doc =
4667 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable)));
4668 _for_each_inner_peripheral!((GPIO0)); _for_each_inner_peripheral!((GPIO1));
4669 _for_each_inner_peripheral!((GPIO2)); _for_each_inner_peripheral!((GPIO3));
4670 _for_each_inner_peripheral!((GPIO4)); _for_each_inner_peripheral!((GPIO5));
4671 _for_each_inner_peripheral!((GPIO6)); _for_each_inner_peripheral!((GPIO7));
4672 _for_each_inner_peripheral!((GPIO8)); _for_each_inner_peripheral!((GPIO9));
4673 _for_each_inner_peripheral!((GPIO10)); _for_each_inner_peripheral!((GPIO11));
4674 _for_each_inner_peripheral!((GPIO12));
4675 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO13));
4676 _for_each_inner_peripheral!((#[cfg(not(use_xtal32k))] GPIO14));
4677 _for_each_inner_peripheral!((GPIO22)); _for_each_inner_peripheral!((GPIO23));
4678 _for_each_inner_peripheral!((GPIO24)); _for_each_inner_peripheral!((GPIO25));
4679 _for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
4680 _for_each_inner_peripheral!((DMA_CH0(unstable)));
4681 _for_each_inner_peripheral!((DMA_CH1(unstable)));
4682 _for_each_inner_peripheral!((DMA_CH2(unstable)));
4683 _for_each_inner_peripheral!((SDM_CH0(unstable)));
4684 _for_each_inner_peripheral!((SDM_CH1(unstable)));
4685 _for_each_inner_peripheral!((SDM_CH2(unstable)));
4686 _for_each_inner_peripheral!((SDM_CH3(unstable)));
4687 _for_each_inner_peripheral!((AES(unstable)));
4688 _for_each_inner_peripheral!((APB_SARADC(unstable)));
4689 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
4690 _for_each_inner_peripheral!((DMA(unstable)));
4691 _for_each_inner_peripheral!((DS(unstable)));
4692 _for_each_inner_peripheral!((ECC(unstable)));
4693 _for_each_inner_peripheral!((GPIO(unstable)));
4694 _for_each_inner_peripheral!((GPIO_SD(unstable)));
4695 _for_each_inner_peripheral!((HMAC(unstable)));
4696 _for_each_inner_peripheral!((HP_APM(unstable)));
4697 _for_each_inner_peripheral!((HP_SYS(unstable)));
4698 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
4699 _for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
4700 _for_each_inner_peripheral!((I2S0(unstable)));
4701 _for_each_inner_peripheral!((IEEE802154(unstable)));
4702 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
4703 _for_each_inner_peripheral!((INTPRI(unstable)));
4704 _for_each_inner_peripheral!((IO_MUX(unstable)));
4705 _for_each_inner_peripheral!((LEDC(unstable)));
4706 _for_each_inner_peripheral!((LPWR(unstable)));
4707 _for_each_inner_peripheral!((LP_ANA(unstable)));
4708 _for_each_inner_peripheral!((LP_AON(unstable)));
4709 _for_each_inner_peripheral!((LP_APM(unstable)));
4710 _for_each_inner_peripheral!((LP_APM0(unstable)));
4711 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
4712 _for_each_inner_peripheral!((LP_PERI(unstable)));
4713 _for_each_inner_peripheral!((RTC_TIMER(unstable)));
4714 _for_each_inner_peripheral!((LP_WDT(unstable)));
4715 _for_each_inner_peripheral!((MCPWM0(unstable)));
4716 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
4717 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
4718 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
4719 _for_each_inner_peripheral!((OTP_DEBUG(unstable)));
4720 _for_each_inner_peripheral!((PARL_IO(unstable)));
4721 _for_each_inner_peripheral!((PAU(unstable)));
4722 _for_each_inner_peripheral!((PCNT(unstable)));
4723 _for_each_inner_peripheral!((PCR(unstable)));
4724 _for_each_inner_peripheral!((PLIC_MX(unstable)));
4725 _for_each_inner_peripheral!((PMU(unstable)));
4726 _for_each_inner_peripheral!((RMT(unstable)));
4727 _for_each_inner_peripheral!((RNG(unstable)));
4728 _for_each_inner_peripheral!((RSA(unstable)));
4729 _for_each_inner_peripheral!((SHA(unstable)));
4730 _for_each_inner_peripheral!((ETM(unstable)));
4731 _for_each_inner_peripheral!((SPI0(unstable)));
4732 _for_each_inner_peripheral!((SPI1(unstable)));
4733 _for_each_inner_peripheral!((SPI2));
4734 _for_each_inner_peripheral!((SYSTEM(unstable)));
4735 _for_each_inner_peripheral!((SYSTIMER(unstable)));
4736 _for_each_inner_peripheral!((TEE(unstable)));
4737 _for_each_inner_peripheral!((TIMG0(unstable)));
4738 _for_each_inner_peripheral!((TIMG1(unstable)));
4739 _for_each_inner_peripheral!((TRACE0(unstable)));
4740 _for_each_inner_peripheral!((TWAI0(unstable)));
4741 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
4742 _for_each_inner_peripheral!((UHCI0(unstable)));
4743 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
4744 _for_each_inner_peripheral!((ADC1(unstable)));
4745 _for_each_inner_peripheral!((BT(unstable)));
4746 _for_each_inner_peripheral!((FLASH(unstable)));
4747 _for_each_inner_peripheral!((GPIO_DEDICATED(unstable)));
4748 _for_each_inner_peripheral!((FROM_CPU_INTR0(unstable)));
4749 _for_each_inner_peripheral!((FROM_CPU_INTR1(unstable)));
4750 _for_each_inner_peripheral!((FROM_CPU_INTR2(unstable)));
4751 _for_each_inner_peripheral!((FROM_CPU_INTR3(unstable)));
4752 _for_each_inner_peripheral!((SPI2, Spi2, 0, AhbGdmaChannel));
4753 _for_each_inner_peripheral!((UHCI0, Uhci0, 2, AhbGdmaChannel));
4754 _for_each_inner_peripheral!((I2S0, I2s0, 3, AhbGdmaChannel));
4755 _for_each_inner_peripheral!((AES, Aes, 6, AhbGdmaChannel));
4756 _for_each_inner_peripheral!((SHA, Sha, 7, AhbGdmaChannel));
4757 _for_each_inner_peripheral!((APB_SARADC, ApbSaradc, 8, AhbGdmaChannel));
4758 _for_each_inner_peripheral!((PARL_IO, ParlIo, 9, AhbGdmaChannel));
4759 _for_each_inner_peripheral!((all(@ peri_type #[doc =
4760 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
4761 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
4762 "GPIO2 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>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4767 #[doc = "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
4768 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4769 "<section class=\"warning\">"] #[doc =
4770 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4771 #[doc = "<ul>"] #[doc =
4772 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4773 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
4774 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4775 "<section class=\"warning\">"] #[doc =
4776 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4777 #[doc = "<ul>"] #[doc =
4778 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4779 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
4780 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4781 "<section class=\"warning\">"] #[doc =
4782 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4783 #[doc = "<ul>"] #[doc =
4784 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
4785 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
4786 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4787 "<section class=\"warning\">"] #[doc =
4788 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4789 #[doc = "<ul>"] #[doc =
4790 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4791 "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
4792 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4793 "<section class=\"warning\">"] #[doc =
4794 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4795 #[doc = "<ul>"] #[doc =
4796 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
4797 "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
4798 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4799 "<section class=\"warning\">"] #[doc =
4800 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4801 #[doc = "<ul>"] #[doc =
4802 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4803 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
4804 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4805 "<section class=\"warning\">"] #[doc =
4806 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4807 #[doc = "<ul>"] #[doc =
4808 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4809 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
4810 "GPIO10 peripheral singleton"] GPIO10 <= virtual()), (@ peri_type #[doc =
4811 "GPIO11 peripheral singleton"] GPIO11 <= virtual()), (@ peri_type #[doc =
4812 "GPIO12 peripheral singleton"] GPIO12 <= virtual()), (@ peri_type #[doc =
4813 "GPIO13 peripheral singleton"] GPIO13 <= virtual()), (@ peri_type #[doc =
4814 "GPIO14 peripheral singleton"] GPIO14 <= virtual()), (@ peri_type #[doc =
4815 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
4816 "GPIO23 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4817 "<section class=\"warning\">"] #[doc =
4818 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4819 #[doc = "<ul>"] #[doc =
4820 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4821 = "</ul>"] #[doc = "</section>"] GPIO23 <= virtual()), (@ peri_type #[doc =
4822 "GPIO24 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4823 "<section class=\"warning\">"] #[doc =
4824 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4825 #[doc = "<ul>"] #[doc =
4826 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
4827 = "</ul>"] #[doc = "</section>"] GPIO24 <= virtual()), (@ peri_type #[doc =
4828 "GPIO25 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4829 "<section class=\"warning\">"] #[doc =
4830 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4831 #[doc = "<ul>"] #[doc =
4832 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
4833 = "</ul>"] #[doc = "</section>"] GPIO25 <= virtual()), (@ peri_type #[doc =
4834 "GPIO26 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4835 "<section class=\"warning\">"] #[doc =
4836 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4837 #[doc = "<ul>"] #[doc =
4838 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4839 #[doc = "</section>"] GPIO26 <= virtual()), (@ peri_type #[doc =
4840 "GPIO27 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
4841 "<section class=\"warning\">"] #[doc =
4842 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
4843 #[doc = "<ul>"] #[doc =
4844 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
4845 #[doc = "</section>"] GPIO27 <= virtual()), (@ peri_type #[doc =
4846 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual(DMA_IN_CH0 : {
4847 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4848 DMA_OUT_CH0 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4849 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4850 "DMA_CH1 peripheral singleton"] DMA_CH1 <= virtual(DMA_IN_CH1 : {
4851 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4852 DMA_OUT_CH1 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4853 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4854 "DMA_CH2 peripheral singleton"] DMA_CH2 <= virtual(DMA_IN_CH2 : {
4855 bind_dma_in_interrupt, enable_dma_in_interrupt, disable_dma_in_interrupt },
4856 DMA_OUT_CH2 : { bind_dma_out_interrupt, enable_dma_out_interrupt,
4857 disable_dma_out_interrupt }) (unstable)), (@ peri_type #[doc =
4858 "SDM_CH0 peripheral singleton"] SDM_CH0 <= virtual() (unstable)), (@ peri_type
4859 #[doc = "SDM_CH1 peripheral singleton"] SDM_CH1 <= virtual() (unstable)), (@
4860 peri_type #[doc = "SDM_CH2 peripheral singleton"] SDM_CH2 <= virtual()
4861 (unstable)), (@ peri_type #[doc = "SDM_CH3 peripheral singleton"] SDM_CH3 <=
4862 virtual() (unstable)), (@ peri_type #[doc = "AES peripheral singleton"] AES <=
4863 AES(AES : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
4864 (unstable)), (@ peri_type #[doc = "APB_SARADC peripheral singleton"] APB_SARADC
4865 <= APB_SARADC() (unstable)), (@ peri_type #[doc =
4866 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)),
4867 (@ peri_type #[doc = "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@
4868 peri_type #[doc = "DS peripheral singleton"] DS <= DS() (unstable)), (@ peri_type
4869 #[doc = "ECC peripheral singleton"] ECC <= ECC() (unstable)), (@ peri_type #[doc
4870 = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc
4871 = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@ peri_type #[doc =
4872 "GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)), (@ peri_type
4873 #[doc = "HMAC peripheral singleton"] HMAC <= HMAC() (unstable)), (@ peri_type
4874 #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)), (@
4875 peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)),
4876 (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <=
4877 I2C_ANA_MST() (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"] I2C0
4878 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
4879 disable_peri_interrupt })), (@ peri_type #[doc = "I2C1 peripheral singleton"]
4880 I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt, enable_peri_interrupt,
4881 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
4882 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
4883 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
4884 "IEEE802154 peripheral singleton"] IEEE802154 <= IEEE802154(ZB_MAC : {
4885 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)),
4886 (@ peri_type #[doc = "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <=
4887 INTERRUPT_CORE0() (unstable)), (@ peri_type #[doc =
4888 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)), (@ peri_type #[doc
4889 = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
4890 #[doc = "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type
4891 #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST() (unstable)), (@
4892 peri_type #[doc = "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)),
4893 (@ peri_type #[doc = "LP_AON peripheral singleton"] LP_AON <= LP_AON()
4894 (unstable)), (@ peri_type #[doc = "LP_APM peripheral singleton"] LP_APM <=
4895 LP_APM() (unstable)), (@ peri_type #[doc = "LP_APM0 peripheral singleton"]
4896 LP_APM0 <= LP_APM0() (unstable)), (@ peri_type #[doc =
4897 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)), (@
4898 peri_type #[doc = "LP_PERI peripheral singleton"] LP_PERI <= LP_PERI()
4899 (unstable)), (@ peri_type #[doc = "RTC_TIMER peripheral singleton"] RTC_TIMER <=
4900 LP_TIMER() (unstable)), (@ peri_type #[doc = "LP_WDT peripheral singleton"]
4901 LP_WDT <= LP_WDT() (unstable)), (@ peri_type #[doc =
4902 "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)), (@ peri_type #[doc
4903 = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)),
4904 (@ peri_type #[doc = "MODEM_LPCON peripheral singleton"] MODEM_LPCON <=
4905 MODEM_LPCON() (unstable)), (@ peri_type #[doc =
4906 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)),
4907 (@ peri_type #[doc = "OTP_DEBUG peripheral singleton"] OTP_DEBUG <= OTP_DEBUG()
4908 (unstable)), (@ peri_type #[doc = "PARL_IO peripheral singleton"] PARL_IO <=
4909 PARL_IO(PARL_IO_RX : { bind_rx_interrupt, enable_rx_interrupt,
4910 disable_rx_interrupt }, PARL_IO_TX : { bind_tx_interrupt, enable_tx_interrupt,
4911 disable_tx_interrupt }) (unstable)), (@ peri_type #[doc =
4912 "PAU peripheral singleton"] PAU <= PAU() (unstable)), (@ peri_type #[doc =
4913 "PCNT peripheral singleton"] PCNT <= PCNT() (unstable)), (@ peri_type #[doc =
4914 "PCR peripheral singleton"] PCR <= PCR() (unstable)), (@ peri_type #[doc =
4915 "PLIC_MX peripheral singleton"] PLIC_MX <= PLIC_MX() (unstable)), (@ peri_type
4916 #[doc = "PMU peripheral singleton"] PMU <= PMU() (unstable)), (@ peri_type #[doc
4917 = "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@ peri_type #[doc =
4918 "RNG peripheral singleton"] RNG <= virtual() (unstable)), (@ peri_type #[doc =
4919 "RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
4920 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4921 = "SHA peripheral singleton"] SHA <= SHA(SHA : { bind_peri_interrupt,
4922 enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
4923 = "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)), (@ peri_type #[doc =
4924 "SPI0 peripheral singleton"] SPI0 <= SPI0() (unstable)), (@ peri_type #[doc =
4925 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)), (@ peri_type #[doc =
4926 "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2 : { bind_peri_interrupt,
4927 enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
4928 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@ peri_type #[doc =
4929 "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER() (unstable)), (@ peri_type
4930 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)), (@ peri_type #[doc
4931 = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@ peri_type #[doc
4932 = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@ peri_type #[doc
4933 = "TRACE0 peripheral singleton"] TRACE0 <= TRACE() (unstable)), (@ peri_type
4934 #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@ peri_type
4935 #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
4936 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4937 peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
4938 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
4939 peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
4940 peri_type #[doc = "USB_DEVICE peripheral singleton"] USB_DEVICE <=
4941 USB_DEVICE(USB_DEVICE : { bind_peri_interrupt, enable_peri_interrupt,
4942 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
4943 "ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)), (@ peri_type #[doc =
4944 "BT peripheral singleton"] BT <= virtual(LP_BLE_TIMER : {
4945 bind_lp_timer_interrupt, enable_lp_timer_interrupt, disable_lp_timer_interrupt },
4946 BT_MAC : { bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt })
4947 (unstable)), (@ peri_type #[doc = "FLASH peripheral singleton"] FLASH <=
4948 virtual() (unstable)), (@ peri_type #[doc =
4949 "GPIO_DEDICATED peripheral singleton"] GPIO_DEDICATED <= virtual() (unstable)),
4950 (@ peri_type #[doc = "FROM_CPU_INTR0 peripheral singleton"] FROM_CPU_INTR0 <=
4951 virtual() (unstable)), (@ peri_type #[doc =
4952 "FROM_CPU_INTR1 peripheral singleton"] FROM_CPU_INTR1 <= virtual() (unstable)),
4953 (@ peri_type #[doc = "FROM_CPU_INTR2 peripheral singleton"] FROM_CPU_INTR2 <=
4954 virtual() (unstable)), (@ peri_type #[doc =
4955 "FROM_CPU_INTR3 peripheral singleton"] FROM_CPU_INTR3 <= virtual() (unstable))));
4956 _for_each_inner_peripheral!((singletons(GPIO0), (GPIO1), (GPIO2), (GPIO3),
4957 (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9), (GPIO10), (GPIO11),
4958 (GPIO12), (#[cfg(not(use_xtal32k))] GPIO13), (#[cfg(not(use_xtal32k))] GPIO14),
4959 (GPIO22), (GPIO23), (GPIO24), (GPIO25), (GPIO26), (GPIO27), (DMA_CH0(unstable)),
4960 (DMA_CH1(unstable)), (DMA_CH2(unstable)), (SDM_CH0(unstable)),
4961 (SDM_CH1(unstable)), (SDM_CH2(unstable)), (SDM_CH3(unstable)), (AES(unstable)),
4962 (APB_SARADC(unstable)), (ASSIST_DEBUG(unstable)), (DMA(unstable)),
4963 (DS(unstable)), (ECC(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)),
4964 (HMAC(unstable)), (HP_APM(unstable)), (HP_SYS(unstable)),
4965 (I2C_ANA_MST(unstable)), (I2C0), (I2C1), (I2S0(unstable)),
4966 (IEEE802154(unstable)), (INTERRUPT_CORE0(unstable)), (INTPRI(unstable)),
4967 (IO_MUX(unstable)), (LEDC(unstable)), (LPWR(unstable)), (LP_ANA(unstable)),
4968 (LP_AON(unstable)), (LP_APM(unstable)), (LP_APM0(unstable)),
4969 (LP_CLKRST(unstable)), (LP_PERI(unstable)), (RTC_TIMER(unstable)),
4970 (LP_WDT(unstable)), (MCPWM0(unstable)), (MEM_MONITOR(unstable)),
4971 (MODEM_LPCON(unstable)), (MODEM_SYSCON(unstable)), (OTP_DEBUG(unstable)),
4972 (PARL_IO(unstable)), (PAU(unstable)), (PCNT(unstable)), (PCR(unstable)),
4973 (PLIC_MX(unstable)), (PMU(unstable)), (RMT(unstable)), (RNG(unstable)),
4974 (RSA(unstable)), (SHA(unstable)), (ETM(unstable)), (SPI0(unstable)),
4975 (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
4976 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (TRACE0(unstable)),
4977 (TWAI0(unstable)), (UART0), (UART1), (UHCI0(unstable)), (USB_DEVICE(unstable)),
4978 (ADC1(unstable)), (BT(unstable)), (FLASH(unstable)), (GPIO_DEDICATED(unstable)),
4979 (FROM_CPU_INTR0(unstable)), (FROM_CPU_INTR1(unstable)),
4980 (FROM_CPU_INTR2(unstable)), (FROM_CPU_INTR3(unstable))));
4981 _for_each_inner_peripheral!((dma_eligible(SPI2, Spi2, 0, AhbGdmaChannel), (UHCI0,
4982 Uhci0, 2, AhbGdmaChannel), (I2S0, I2s0, 3, AhbGdmaChannel), (AES, Aes, 6,
4983 AhbGdmaChannel), (SHA, Sha, 7, AhbGdmaChannel), (APB_SARADC, ApbSaradc, 8,
4984 AhbGdmaChannel), (PARL_IO, ParlIo, 9, AhbGdmaChannel)));
4985 };
4986}
4987#[macro_export]
5014#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5015macro_rules! for_each_gpio {
5016 ($($pattern:tt => $code:tt;)*) => {
5017 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
5018 } _for_each_inner_gpio!((0, GPIO0(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
5019 [Output]))); _for_each_inner_gpio!((1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0)
5020 ([Input] [Output]))); _for_each_inner_gpio!((2, GPIO2(_0 => MTMS _2 => FSPIWP)
5021 (_2 => FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((3, GPIO3(_0 => MTDI
5022 _2 => FSPIHD) (_2 => FSPIHD) ([Input] [Output]))); _for_each_inner_gpio!((4,
5023 GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])));
5024 _for_each_inner_gpio!((5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input]
5025 [Output]))); _for_each_inner_gpio!((6, GPIO6() () ([Input] [Output])));
5026 _for_each_inner_gpio!((7, GPIO7() () ([Input] [Output])));
5027 _for_each_inner_gpio!((8, GPIO8() () ([Input] [Output])));
5028 _for_each_inner_gpio!((9, GPIO9() () ([Input] [Output])));
5029 _for_each_inner_gpio!((10, GPIO10() () ([Input] [Output])));
5030 _for_each_inner_gpio!((11, GPIO11() () ([Input] [Output])));
5031 _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
5032 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
5033 _for_each_inner_gpio!((14, GPIO14() () ([Input] [Output])));
5034 _for_each_inner_gpio!((22, GPIO22() () ([Input] [Output])));
5035 _for_each_inner_gpio!((23, GPIO23(_0 => U0RXD) (_2 => FSPICS1) ([Input]
5036 [Output]))); _for_each_inner_gpio!((24, GPIO24() (_0 => U0TXD _2 => FSPICS2)
5037 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25() (_2 => FSPICS3)
5038 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26() (_2 => FSPICS4)
5039 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27() (_2 => FSPICS5)
5040 ([Input] [Output]))); _for_each_inner_gpio!((all(0, GPIO0(_2 => FSPIQ) (_2 =>
5041 FSPIQ) ([Input] [Output])), (1, GPIO1(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
5042 [Output])), (2, GPIO2(_0 => MTMS _2 => FSPIWP) (_2 => FSPIWP) ([Input]
5043 [Output])), (3, GPIO3(_0 => MTDI _2 => FSPIHD) (_2 => FSPIHD) ([Input]
5044 [Output])), (4, GPIO4(_0 => MTCK _2 => FSPICLK) (_2 => FSPICLK) ([Input]
5045 [Output])), (5, GPIO5(_2 => FSPID) (_0 => MTDO _2 => FSPID) ([Input] [Output])),
5046 (6, GPIO6() () ([Input] [Output])), (7, GPIO7() () ([Input] [Output])), (8,
5047 GPIO8() () ([Input] [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10()
5048 () ([Input] [Output])), (11, GPIO11() () ([Input] [Output])), (12, GPIO12() ()
5049 ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14, GPIO14() ()
5050 ([Input] [Output])), (22, GPIO22() () ([Input] [Output])), (23, GPIO23(_0 =>
5051 U0RXD) (_2 => FSPICS1) ([Input] [Output])), (24, GPIO24() (_0 => U0TXD _2 =>
5052 FSPICS2) ([Input] [Output])), (25, GPIO25() (_2 => FSPICS3) ([Input] [Output])),
5053 (26, GPIO26() (_2 => FSPICS4) ([Input] [Output])), (27, GPIO27() (_2 => FSPICS5)
5054 ([Input] [Output]))));
5055 };
5056}
5057#[macro_export]
5084#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5085macro_rules! for_each_analog_function {
5086 ($($pattern:tt => $code:tt;)*) => {
5087 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
5088 tt) => {} } _for_each_inner_analog_function!((ADC1_CH0, GPIO1));
5089 _for_each_inner_analog_function!((ADC1_CH1, GPIO2));
5090 _for_each_inner_analog_function!((ADC1_CH2, GPIO3));
5091 _for_each_inner_analog_function!((ADC1_CH3, GPIO4));
5092 _for_each_inner_analog_function!((ADC1_CH4, GPIO5));
5093 _for_each_inner_analog_function!((ZCD0, GPIO10));
5094 _for_each_inner_analog_function!((ZCD1, GPIO11));
5095 _for_each_inner_analog_function!((XTAL_32K_P, GPIO13));
5096 _for_each_inner_analog_function!((XTAL_32K_N, GPIO14));
5097 _for_each_inner_analog_function!((USJ_DM, GPIO26));
5098 _for_each_inner_analog_function!((USJ_DP, GPIO27));
5099 _for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO1));
5100 _for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2));
5101 _for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3));
5102 _for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4));
5103 _for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5));
5104 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO10));
5105 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO11));
5106 _for_each_inner_analog_function!((all(ADC1_CH0, GPIO1), (ADC1_CH1, GPIO2),
5107 (ADC1_CH2, GPIO3), (ADC1_CH3, GPIO4), (ADC1_CH4, GPIO5), (ZCD0, GPIO10), (ZCD1,
5108 GPIO11), (XTAL_32K_P, GPIO13), (XTAL_32K_N, GPIO14), (USJ_DM, GPIO26), (USJ_DP,
5109 GPIO27))); _for_each_inner_analog_function!((ADCn_CHm((ADC1_CH0, ADCn_CHm, 1, 0),
5110 GPIO1), ((ADC1_CH1, ADCn_CHm, 1, 1), GPIO2), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO3),
5111 ((ADC1_CH3, ADCn_CHm, 1, 3), GPIO4), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO5)));
5112 _for_each_inner_analog_function!((ZCDn((ZCD0, ZCDn, 0), GPIO10), ((ZCD1, ZCDn,
5113 1), GPIO11)));
5114 };
5115}
5116#[macro_export]
5154#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5155macro_rules! for_each_lp_function {
5156 ($($pattern:tt => $code:tt;)*) => {
5157 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
5158 => {} } _for_each_inner_lp_function!((LP_GPIO0, GPIO7, _0));
5159 _for_each_inner_lp_function!((LP_GPIO1, GPIO8, _0));
5160 _for_each_inner_lp_function!((LP_GPIO2, GPIO9, _0));
5161 _for_each_inner_lp_function!((LP_GPIO3, GPIO10, _0));
5162 _for_each_inner_lp_function!((LP_GPIO4, GPIO11, _0));
5163 _for_each_inner_lp_function!((LP_GPIO5, GPIO12, _0));
5164 _for_each_inner_lp_function!((LP_GPIO6, GPIO13, _0));
5165 _for_each_inner_lp_function!((LP_GPIO7, GPIO14, _0));
5166 _for_each_inner_lp_function!(((LP_GPIO0, LP_GPIOn, 0), GPIO7, _0, () ()));
5167 _for_each_inner_lp_function!(((LP_GPIO1, LP_GPIOn, 1), GPIO8, _0, () ()));
5168 _for_each_inner_lp_function!(((LP_GPIO2, LP_GPIOn, 2), GPIO9, _0, () ()));
5169 _for_each_inner_lp_function!(((LP_GPIO3, LP_GPIOn, 3), GPIO10, _0, () ()));
5170 _for_each_inner_lp_function!(((LP_GPIO4, LP_GPIOn, 4), GPIO11, _0, () ()));
5171 _for_each_inner_lp_function!(((LP_GPIO5, LP_GPIOn, 5), GPIO12, _0, () ()));
5172 _for_each_inner_lp_function!(((LP_GPIO6, LP_GPIOn, 6), GPIO13, _0, () ()));
5173 _for_each_inner_lp_function!(((LP_GPIO7, LP_GPIOn, 7), GPIO14, _0, () ()));
5174 _for_each_inner_lp_function!((all(LP_GPIO0, GPIO7, _0), (LP_GPIO1, GPIO8, _0),
5175 (LP_GPIO2, GPIO9, _0), (LP_GPIO3, GPIO10, _0), (LP_GPIO4, GPIO11, _0), (LP_GPIO5,
5176 GPIO12, _0), (LP_GPIO6, GPIO13, _0), (LP_GPIO7, GPIO14, _0)));
5177 _for_each_inner_lp_function!((LP_GPIOn((LP_GPIO0, LP_GPIOn, 0), GPIO7, _0, ()
5178 ()), ((LP_GPIO1, LP_GPIOn, 1), GPIO8, _0, () ()), ((LP_GPIO2, LP_GPIOn, 2),
5179 GPIO9, _0, () ()), ((LP_GPIO3, LP_GPIOn, 3), GPIO10, _0, () ()), ((LP_GPIO4,
5180 LP_GPIOn, 4), GPIO11, _0, () ()), ((LP_GPIO5, LP_GPIOn, 5), GPIO12, _0, () ()),
5181 ((LP_GPIO6, LP_GPIOn, 6), GPIO13, _0, () ()), ((LP_GPIO7, LP_GPIOn, 7), GPIO14,
5182 _0, () ())));
5183 };
5184}
5185#[macro_export]
5216#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5217macro_rules! for_each_iomux_function {
5218 ($($pattern:tt => $code:tt;)*) => {
5219 macro_rules! _for_each_inner_iomux_function { $(($pattern) => $code;)* ($other :
5220 tt) => {} } _for_each_inner_iomux_function!((FSPIQ, GPIO0, _2));
5221 _for_each_inner_iomux_function!((FSPICS0, GPIO1, _2));
5222 _for_each_inner_iomux_function!((MTMS, GPIO2, _0));
5223 _for_each_inner_iomux_function!((FSPIWP, GPIO2, _2));
5224 _for_each_inner_iomux_function!((MTDI, GPIO3, _0));
5225 _for_each_inner_iomux_function!((FSPIHD, GPIO3, _2));
5226 _for_each_inner_iomux_function!((MTCK, GPIO4, _0));
5227 _for_each_inner_iomux_function!((FSPICLK, GPIO4, _2));
5228 _for_each_inner_iomux_function!((MTDO, GPIO5, _0));
5229 _for_each_inner_iomux_function!((FSPID, GPIO5, _2));
5230 _for_each_inner_iomux_function!((U0RXD, GPIO23, _0));
5231 _for_each_inner_iomux_function!((FSPICS1, GPIO23, _2));
5232 _for_each_inner_iomux_function!((U0TXD, GPIO24, _0));
5233 _for_each_inner_iomux_function!((FSPICS2, GPIO24, _2));
5234 _for_each_inner_iomux_function!((FSPICS3, GPIO25, _2));
5235 _for_each_inner_iomux_function!((FSPICS4, GPIO26, _2));
5236 _for_each_inner_iomux_function!((FSPICS5, GPIO27, _2));
5237 _for_each_inner_iomux_function!(((FSPICS0, FSPICSn, 0), GPIO1, _2));
5238 _for_each_inner_iomux_function!(((FSPICS1, FSPICSn, 1), GPIO23, _2));
5239 _for_each_inner_iomux_function!(((FSPICS2, FSPICSn, 2), GPIO24, _2));
5240 _for_each_inner_iomux_function!(((FSPICS3, FSPICSn, 3), GPIO25, _2));
5241 _for_each_inner_iomux_function!(((FSPICS4, FSPICSn, 4), GPIO26, _2));
5242 _for_each_inner_iomux_function!(((FSPICS5, FSPICSn, 5), GPIO27, _2));
5243 _for_each_inner_iomux_function!((all(FSPIQ, GPIO0, _2), (FSPICS0, GPIO1, _2),
5244 (MTMS, GPIO2, _0), (FSPIWP, GPIO2, _2), (MTDI, GPIO3, _0), (FSPIHD, GPIO3, _2),
5245 (MTCK, GPIO4, _0), (FSPICLK, GPIO4, _2), (MTDO, GPIO5, _0), (FSPID, GPIO5, _2),
5246 (U0RXD, GPIO23, _0), (FSPICS1, GPIO23, _2), (U0TXD, GPIO24, _0), (FSPICS2,
5247 GPIO24, _2), (FSPICS3, GPIO25, _2), (FSPICS4, GPIO26, _2), (FSPICS5, GPIO27,
5248 _2))); _for_each_inner_iomux_function!((FSPICSn((FSPICS0, FSPICSn, 0), GPIO1,
5249 _2), ((FSPICS1, FSPICSn, 1), GPIO23, _2), ((FSPICS2, FSPICSn, 2), GPIO24, _2),
5250 ((FSPICS3, FSPICSn, 3), GPIO25, _2), ((FSPICS4, FSPICSn, 4), GPIO26, _2),
5251 ((FSPICS5, FSPICSn, 5), GPIO27, _2)));
5252 };
5253}
5254#[macro_export]
5271#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5272macro_rules! gpio_for_signal {
5273 (FSPIQ $(, $_fallback:literal)?) => {
5274 "GPIO0"
5275 };
5276 (FSPICS0 $(, $_fallback:literal)?) => {
5277 "GPIO1"
5278 };
5279 (ADC1_CH0 $(, $_fallback:literal)?) => {
5280 "GPIO1"
5281 };
5282 (MTMS $(, $_fallback:literal)?) => {
5283 "GPIO2"
5284 };
5285 (FSPIWP $(, $_fallback:literal)?) => {
5286 "GPIO2"
5287 };
5288 (ADC1_CH1 $(, $_fallback:literal)?) => {
5289 "GPIO2"
5290 };
5291 (MTDI $(, $_fallback:literal)?) => {
5292 "GPIO3"
5293 };
5294 (FSPIHD $(, $_fallback:literal)?) => {
5295 "GPIO3"
5296 };
5297 (ADC1_CH2 $(, $_fallback:literal)?) => {
5298 "GPIO3"
5299 };
5300 (MTCK $(, $_fallback:literal)?) => {
5301 "GPIO4"
5302 };
5303 (FSPICLK $(, $_fallback:literal)?) => {
5304 "GPIO4"
5305 };
5306 (ADC1_CH3 $(, $_fallback:literal)?) => {
5307 "GPIO4"
5308 };
5309 (MTDO $(, $_fallback:literal)?) => {
5310 "GPIO5"
5311 };
5312 (FSPID $(, $_fallback:literal)?) => {
5313 "GPIO5"
5314 };
5315 (ADC1_CH4 $(, $_fallback:literal)?) => {
5316 "GPIO5"
5317 };
5318 (LP_GPIO0 $(, $_fallback:literal)?) => {
5319 "GPIO7"
5320 };
5321 (LP_GPIO1 $(, $_fallback:literal)?) => {
5322 "GPIO8"
5323 };
5324 (LP_GPIO2 $(, $_fallback:literal)?) => {
5325 "GPIO9"
5326 };
5327 (ZCD0 $(, $_fallback:literal)?) => {
5328 "GPIO10"
5329 };
5330 (LP_GPIO3 $(, $_fallback:literal)?) => {
5331 "GPIO10"
5332 };
5333 (ZCD1 $(, $_fallback:literal)?) => {
5334 "GPIO11"
5335 };
5336 (LP_GPIO4 $(, $_fallback:literal)?) => {
5337 "GPIO11"
5338 };
5339 (LP_GPIO5 $(, $_fallback:literal)?) => {
5340 "GPIO12"
5341 };
5342 (XTAL_32K_P $(, $_fallback:literal)?) => {
5343 "GPIO13"
5344 };
5345 (LP_GPIO6 $(, $_fallback:literal)?) => {
5346 "GPIO13"
5347 };
5348 (XTAL_32K_N $(, $_fallback:literal)?) => {
5349 "GPIO14"
5350 };
5351 (LP_GPIO7 $(, $_fallback:literal)?) => {
5352 "GPIO14"
5353 };
5354 (U0RXD $(, $_fallback:literal)?) => {
5355 "GPIO23"
5356 };
5357 (FSPICS1 $(, $_fallback:literal)?) => {
5358 "GPIO23"
5359 };
5360 (U0TXD $(, $_fallback:literal)?) => {
5361 "GPIO24"
5362 };
5363 (FSPICS2 $(, $_fallback:literal)?) => {
5364 "GPIO24"
5365 };
5366 (FSPICS3 $(, $_fallback:literal)?) => {
5367 "GPIO25"
5368 };
5369 (FSPICS4 $(, $_fallback:literal)?) => {
5370 "GPIO26"
5371 };
5372 (USJ_DM $(, $_fallback:literal)?) => {
5373 "GPIO26"
5374 };
5375 (FSPICS5 $(, $_fallback:literal)?) => {
5376 "GPIO27"
5377 };
5378 (USJ_DP $(, $_fallback:literal)?) => {
5379 "GPIO27"
5380 };
5381 ($_signal:ident, $fallback:literal) => {
5382 $fallback
5383 };
5384}
5385#[macro_export]
5389#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5390macro_rules! define_io_mux_signals {
5391 () => {
5392 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5393 #[derive(Debug, PartialEq, Copy, Clone)]
5394 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5395 #[doc(hidden)]
5396 pub enum InputSignal {
5397 EXT_ADC_START = 0,
5398 U0RXD = 6,
5399 U0CTS = 7,
5400 U0DSR = 8,
5401 U1RXD = 9,
5402 U1CTS = 10,
5403 U1DSR = 11,
5404 I2S_MCLK = 12,
5405 I2SO_BCK = 13,
5406 I2SO_WS = 14,
5407 I2SI_SD = 15,
5408 I2SI_BCK = 16,
5409 I2SI_WS = 17,
5410 USB_JTAG_TDO_BRIDGE = 19,
5411 CPU_GPIO_0 = 28,
5412 CPU_GPIO_1 = 29,
5413 CPU_GPIO_2 = 30,
5414 CPU_GPIO_3 = 31,
5415 CPU_GPIO_4 = 32,
5416 CPU_GPIO_5 = 33,
5417 CPU_GPIO_6 = 34,
5418 CPU_GPIO_7 = 35,
5419 I2CEXT0_SCL = 45,
5420 I2CEXT0_SDA = 46,
5421 PARL_RX_DATA0 = 47,
5422 PARL_RX_DATA1 = 48,
5423 PARL_RX_DATA2 = 49,
5424 PARL_RX_DATA3 = 50,
5425 PARL_RX_DATA4 = 51,
5426 PARL_RX_DATA5 = 52,
5427 PARL_RX_DATA6 = 53,
5428 PARL_RX_DATA7 = 54,
5429 I2CEXT1_SCL = 55,
5430 I2CEXT1_SDA = 56,
5431 FSPICLK = 63,
5432 FSPIQ = 64,
5433 FSPID = 65,
5434 FSPIHD = 66,
5435 FSPIWP = 67,
5436 FSPICS0 = 68,
5437 PARL_RX_CLK = 69,
5438 PARL_TX_CLK = 70,
5439 RMT_SIG_0 = 71,
5440 RMT_SIG_1 = 72,
5441 TWAI0_RX = 73,
5442 PWM0_SYNC0 = 87,
5443 PWM0_SYNC1 = 88,
5444 PWM0_SYNC2 = 89,
5445 PWM0_F0 = 90,
5446 PWM0_F1 = 91,
5447 PWM0_F2 = 92,
5448 PWM0_CAP0 = 93,
5449 PWM0_CAP1 = 94,
5450 PWM0_CAP2 = 95,
5451 SIG_FUNC_97 = 97,
5452 SIG_FUNC_98 = 98,
5453 SIG_FUNC_99 = 99,
5454 SIG_FUNC_100 = 100,
5455 PCNT0_SIG_CH0 = 101,
5456 PCNT0_SIG_CH1 = 102,
5457 PCNT0_CTRL_CH0 = 103,
5458 PCNT0_CTRL_CH1 = 104,
5459 PCNT1_SIG_CH0 = 105,
5460 PCNT1_SIG_CH1 = 106,
5461 PCNT1_CTRL_CH0 = 107,
5462 PCNT1_CTRL_CH1 = 108,
5463 PCNT2_SIG_CH0 = 109,
5464 PCNT2_SIG_CH1 = 110,
5465 PCNT2_CTRL_CH0 = 111,
5466 PCNT2_CTRL_CH1 = 112,
5467 PCNT3_SIG_CH0 = 113,
5468 PCNT3_SIG_CH1 = 114,
5469 PCNT3_CTRL_CH0 = 115,
5470 PCNT3_CTRL_CH1 = 116,
5471 SPIQ = 121,
5472 SPID = 122,
5473 SPIHD = 123,
5474 SPIWP = 124,
5475 MTDI,
5476 MTCK,
5477 MTMS,
5478 }
5479 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
5480 #[derive(Debug, PartialEq, Copy, Clone)]
5481 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5482 #[doc(hidden)]
5483 pub enum OutputSignal {
5484 LEDC_LS_SIG0 = 0,
5485 LEDC_LS_SIG1 = 1,
5486 LEDC_LS_SIG2 = 2,
5487 LEDC_LS_SIG3 = 3,
5488 LEDC_LS_SIG4 = 4,
5489 LEDC_LS_SIG5 = 5,
5490 U0TXD = 6,
5491 U0RTS = 7,
5492 U0DTR = 8,
5493 U1TXD = 9,
5494 U1RTS = 10,
5495 U1DTR = 11,
5496 I2S_MCLK = 12,
5497 I2SO_BCK = 13,
5498 I2SO_WS = 14,
5499 I2SO_SD = 15,
5500 I2SI_BCK = 16,
5501 I2SI_WS = 17,
5502 I2SO_SD1 = 18,
5503 USB_JTAG_TRST = 19,
5504 CPU_GPIO_0 = 28,
5505 CPU_GPIO_1 = 29,
5506 CPU_GPIO_2 = 30,
5507 CPU_GPIO_3 = 31,
5508 CPU_GPIO_4 = 32,
5509 CPU_GPIO_5 = 33,
5510 CPU_GPIO_6 = 34,
5511 CPU_GPIO_7 = 35,
5512 I2CEXT0_SCL = 45,
5513 I2CEXT0_SDA = 46,
5514 PARL_TX_DATA0 = 47,
5515 PARL_TX_DATA1 = 48,
5516 PARL_TX_DATA2 = 49,
5517 PARL_TX_DATA3 = 50,
5518 PARL_TX_DATA4 = 51,
5519 PARL_TX_DATA5 = 52,
5520 PARL_TX_DATA6 = 53,
5521 PARL_TX_DATA7 = 54,
5522 I2CEXT1_SCL = 55,
5523 I2CEXT1_SDA = 56,
5524 FSPICLK = 63,
5525 FSPIQ = 64,
5526 FSPID = 65,
5527 FSPIHD = 66,
5528 FSPIWP = 67,
5529 FSPICS0 = 68,
5530 PARL_RX_CLK = 69,
5531 PARL_TX_CLK = 70,
5532 RMT_SIG_0 = 71,
5533 RMT_SIG_1 = 72,
5534 TWAI0_TX = 73,
5535 TWAI0_BUS_OFF_ON = 74,
5536 TWAI0_CLKOUT = 75,
5537 TWAI0_STANDBY = 76,
5538 CTE_ANT7 = 78,
5539 CTE_ANT8 = 79,
5540 CTE_ANT9 = 80,
5541 GPIO_SD0 = 83,
5542 GPIO_SD1 = 84,
5543 GPIO_SD2 = 85,
5544 GPIO_SD3 = 86,
5545 PWM0_0A = 87,
5546 PWM0_0B = 88,
5547 PWM0_1A = 89,
5548 PWM0_1B = 90,
5549 PWM0_2A = 91,
5550 PWM0_2B = 92,
5551 SIG_IN_FUNC97 = 97,
5552 SIG_IN_FUNC98 = 98,
5553 SIG_IN_FUNC99 = 99,
5554 SIG_IN_FUNC100 = 100,
5555 FSPICS1 = 101,
5556 FSPICS2 = 102,
5557 FSPICS3 = 103,
5558 FSPICS4 = 104,
5559 FSPICS5 = 105,
5560 CTE_ANT10 = 106,
5561 CTE_ANT11 = 107,
5562 CTE_ANT12 = 108,
5563 CTE_ANT13 = 109,
5564 CTE_ANT14 = 110,
5565 CTE_ANT15 = 111,
5566 SPICLK = 114,
5567 SPICS0 = 115,
5568 SPICS1 = 116,
5569 SPIQ = 121,
5570 SPID = 122,
5571 SPIHD = 123,
5572 SPIWP = 124,
5573 CLK_OUT_OUT1 = 125,
5574 CLK_OUT_OUT2 = 126,
5575 CLK_OUT_OUT3 = 127,
5576 GPIO = 128,
5577 MTDO,
5578 }
5579 };
5580}
5581#[macro_export]
5588#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5589macro_rules! define_lp_functions {
5590 () => {
5591 #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
5596 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
5597 #[doc(hidden)]
5598 pub enum LpFunction {
5599 _0 = 0,
5601 }
5602 impl LpFunction {
5603 pub const LP_GPIO: Self = Self::_0;
5605 }
5606 };
5607}
5608#[macro_export]
5621#[expect(clippy::crate_in_macro_def)]
5622#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
5623macro_rules! define_io_mux_reg {
5624 () => {
5625 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
5626 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
5627 }
5628 };
5629}