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 "esp32c61"
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-C61"
34 };
35}
36#[macro_export]
38#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
39macro_rules! property {
40 ("chip") => {
41 "esp32c61"
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-c61_technical_reference_manual_en.pdf"
54 };
55 ("bt.controller") => {
56 "npl"
57 };
58 ("dma.kind") => {
59 "gdma"
60 };
61 ("dma.supports_mem2mem") => {
62 true
63 };
64 ("dma.can_access_psram") => {
65 false
66 };
67 ("dma.ext_mem_configurable_block_size") => {
68 false
69 };
70 ("dma.separate_in_out_interrupts") => {
71 true
72 };
73 ("dma.max_priority") => {
74 5
75 };
76 ("dma.max_priority", str) => {
77 stringify!(5)
78 };
79 ("dma.gdma_version") => {
80 2
81 };
82 ("dma.gdma_version", str) => {
83 stringify!(2)
84 };
85 ("ecc.zero_extend_writes") => {
86 true
87 };
88 ("ecc.separate_jacobian_point_memory") => {
89 true
90 };
91 ("ecc.has_memory_clock_gate") => {
92 true
93 };
94 ("ecc.supports_enhanced_security") => {
95 true
96 };
97 ("ecc.mem_block_size") => {
98 32
99 };
100 ("gpio.has_bank_1") => {
101 false
102 };
103 ("gpio.gpio_function") => {
104 1
105 };
106 ("gpio.gpio_function", str) => {
107 stringify!(1)
108 };
109 ("gpio.constant_0_input") => {
110 96
111 };
112 ("gpio.constant_0_input", str) => {
113 stringify!(96)
114 };
115 ("gpio.constant_1_input") => {
116 64
117 };
118 ("gpio.constant_1_input", str) => {
119 stringify!(64)
120 };
121 ("gpio.remap_iomux_pin_registers") => {
122 false
123 };
124 ("gpio.func_in_sel_offset") => {
125 0
126 };
127 ("gpio.func_in_sel_offset", str) => {
128 stringify!(0)
129 };
130 ("gpio.input_signal_max") => {
131 100
132 };
133 ("gpio.input_signal_max", str) => {
134 stringify!(100)
135 };
136 ("gpio.output_signal_max") => {
137 256
138 };
139 ("gpio.output_signal_max", str) => {
140 stringify!(256)
141 };
142 ("i2c_master.has_fsm_timeouts") => {
143 true
144 };
145 ("i2c_master.has_hw_bus_clear") => {
146 true
147 };
148 ("i2c_master.has_bus_timeout_enable") => {
149 true
150 };
151 ("i2c_master.separate_filter_config_registers") => {
152 false
153 };
154 ("i2c_master.can_estimate_nack_reason") => {
155 true
156 };
157 ("i2c_master.has_conf_update") => {
158 true
159 };
160 ("i2c_master.has_reliable_fsm_reset") => {
161 true
162 };
163 ("i2c_master.has_arbitration_en") => {
164 true
165 };
166 ("i2c_master.has_tx_fifo_watermark") => {
167 true
168 };
169 ("i2c_master.bus_timeout_is_exponential") => {
170 true
171 };
172 ("i2c_master.max_bus_timeout") => {
173 31
174 };
175 ("i2c_master.max_bus_timeout", str) => {
176 stringify!(31)
177 };
178 ("i2c_master.ll_intr_mask") => {
179 262143
180 };
181 ("i2c_master.ll_intr_mask", str) => {
182 stringify!(262143)
183 };
184 ("i2c_master.fifo_size") => {
185 32
186 };
187 ("i2c_master.fifo_size", str) => {
188 stringify!(32)
189 };
190 ("interrupts.status_registers") => {
191 3
192 };
193 ("interrupts.status_registers", str) => {
194 stringify!(3)
195 };
196 ("interrupts.disabled_interrupt") => {
197 0
198 };
199 ("psram.octal_spi") => {
200 false
201 };
202 ("psram.extmem_origin") => {
203 1107296256
204 };
205 ("psram.extmem_origin", str) => {
206 stringify!(1107296256)
207 };
208 ("rng.apb_cycle_wait_num") => {
209 16
210 };
211 ("rng.apb_cycle_wait_num", str) => {
212 stringify!(16)
213 };
214 ("rng.trng_supported") => {
215 false
216 };
217 ("sha.dma") => {
218 true
219 };
220 ("soc.cpu_has_branch_predictor") => {
221 false
222 };
223 ("soc.cpu_has_csr_pc") => {
224 false
225 };
226 ("soc.multi_core_enabled") => {
227 false
228 };
229 ("soc.rc_fast_clk_default") => {
230 17500000
231 };
232 ("soc.rc_fast_clk_default", str) => {
233 stringify!(17500000)
234 };
235 ("clock_tree.cpu_clk.divisor") => {
236 (0, 255)
237 };
238 ("clock_tree.ahb_clk.divisor") => {
239 (0, 255)
240 };
241 ("clock_tree.apb_clk.divisor") => {
242 (0, 255)
243 };
244 ("clock_tree.uart.function_clock.div_num") => {
245 (0, 255)
246 };
247 ("clock_tree.uart.baud_rate_generator.fractional") => {
248 (0, 15)
249 };
250 ("clock_tree.uart.baud_rate_generator.integral") => {
251 (0, 4095)
252 };
253 ("spi_master.supports_dma") => {
254 true
255 };
256 ("spi_master.has_octal") => {
257 false
258 };
259 ("spi_master.has_app_interrupts") => {
260 true
261 };
262 ("spi_master.has_dma_segmented_transfer") => {
263 true
264 };
265 ("spi_master.has_clk_pre_div") => {
266 true
267 };
268 ("spi_slave.supports_dma") => {
269 false
270 };
271 ("timergroup.timg_has_timer1") => {
272 false
273 };
274 ("timergroup.timg_has_divcnt_rst") => {
275 true
276 };
277 ("uart.ram_size") => {
278 128
279 };
280 ("uart.ram_size", str) => {
281 stringify!(128)
282 };
283 ("uart.peripheral_controls_mem_clk") => {
284 true
285 };
286 ("uart.has_sclk_divider") => {
287 false
288 };
289 ("wifi.has_wifi6") => {
290 true
291 };
292 ("wifi.mac_version") => {
293 3
294 };
295 ("wifi.mac_version", str) => {
296 stringify!(3)
297 };
298 ("wifi.has_5g") => {
299 false
300 };
301 ("wifi.csi_supported") => {
302 true
303 };
304}
305#[macro_export]
306#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
307macro_rules! for_each_ecc_working_mode {
308 ($($pattern:tt => $code:tt;)*) => {
309 macro_rules! _for_each_inner_ecc_working_mode { $(($pattern) => $code;)* ($other
310 : tt) => {} } _for_each_inner_ecc_working_mode!((0, AffinePointMultiplication));
311 _for_each_inner_ecc_working_mode!((2, AffinePointVerification));
312 _for_each_inner_ecc_working_mode!((3, AffinePointVerificationAndMultiplication));
313 _for_each_inner_ecc_working_mode!((4, JacobianPointMultiplication));
314 _for_each_inner_ecc_working_mode!((5, AffinePointAddition));
315 _for_each_inner_ecc_working_mode!((6, JacobianPointVerification));
316 _for_each_inner_ecc_working_mode!((7,
317 AffinePointVerificationAndJacobianPointMultiplication));
318 _for_each_inner_ecc_working_mode!((8, ModularAddition));
319 _for_each_inner_ecc_working_mode!((9, ModularSubtraction));
320 _for_each_inner_ecc_working_mode!((10, ModularMultiplication));
321 _for_each_inner_ecc_working_mode!((11, ModularDivision));
322 _for_each_inner_ecc_working_mode!((all(0, AffinePointMultiplication), (2,
323 AffinePointVerification), (3, AffinePointVerificationAndMultiplication), (4,
324 JacobianPointMultiplication), (5, AffinePointAddition), (6,
325 JacobianPointVerification), (7,
326 AffinePointVerificationAndJacobianPointMultiplication), (8, ModularAddition), (9,
327 ModularSubtraction), (10, ModularMultiplication), (11, ModularDivision)));
328 };
329}
330#[macro_export]
331#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
332macro_rules! for_each_ecc_curve {
333 ($($pattern:tt => $code:tt;)*) => {
334 macro_rules! _for_each_inner_ecc_curve { $(($pattern) => $code;)* ($other : tt)
335 => {} } _for_each_inner_ecc_curve!((0, P192, 192));
336 _for_each_inner_ecc_curve!((1, P256, 256)); _for_each_inner_ecc_curve!((all(0,
337 P192, 192), (1, P256, 256)));
338 };
339}
340#[macro_export]
341#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
342macro_rules! for_each_interrupt {
343 ($($pattern:tt => $code:tt;)*) => {
344 macro_rules! _for_each_inner_interrupt { $(($pattern) => $code;)* ($other : tt)
345 => {} } _for_each_inner_interrupt!(([disabled 0] 0));
346 _for_each_inner_interrupt!(([reserved 0] 1));
347 _for_each_inner_interrupt!(([reserved 1] 2));
348 _for_each_inner_interrupt!(([reserved 2] 3));
349 _for_each_inner_interrupt!(([reserved 3] 4));
350 _for_each_inner_interrupt!(([reserved 4] 5));
351 _for_each_inner_interrupt!(([reserved 5] 6));
352 _for_each_inner_interrupt!(([reserved 6] 7));
353 _for_each_inner_interrupt!(([reserved 7] 8));
354 _for_each_inner_interrupt!(([reserved 8] 9));
355 _for_each_inner_interrupt!(([reserved 9] 10));
356 _for_each_inner_interrupt!(([reserved 10] 11));
357 _for_each_inner_interrupt!(([reserved 11] 12));
358 _for_each_inner_interrupt!(([reserved 12] 13));
359 _for_each_inner_interrupt!(([reserved 13] 14));
360 _for_each_inner_interrupt!(([reserved 14] 15));
361 _for_each_inner_interrupt!(([vector 0] 16)); _for_each_inner_interrupt!(([vector
362 1] 17)); _for_each_inner_interrupt!(([vector 2] 18));
363 _for_each_inner_interrupt!(([vector 3] 19)); _for_each_inner_interrupt!(([vector
364 4] 20)); _for_each_inner_interrupt!(([vector 5] 21));
365 _for_each_inner_interrupt!(([vector 6] 22)); _for_each_inner_interrupt!(([vector
366 7] 23)); _for_each_inner_interrupt!(([direct_bindable 0] 24));
367 _for_each_inner_interrupt!(([direct_bindable 1] 25));
368 _for_each_inner_interrupt!(([direct_bindable 2] 26));
369 _for_each_inner_interrupt!(([direct_bindable 3] 27));
370 _for_each_inner_interrupt!(([direct_bindable 4] 28));
371 _for_each_inner_interrupt!(([direct_bindable 5] 29));
372 _for_each_inner_interrupt!(([direct_bindable 6] 30));
373 _for_each_inner_interrupt!(([direct_bindable 7] 31));
374 _for_each_inner_interrupt!((all([disabled 0] 0), ([reserved 0] 1), ([reserved 1]
375 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
376 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
377 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
378 ([reserved 14] 15), ([vector 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector
379 3] 19), ([vector 4] 20), ([vector 5] 21), ([vector 6] 22), ([vector 7] 23),
380 ([direct_bindable 0] 24), ([direct_bindable 1] 25), ([direct_bindable 2] 26),
381 ([direct_bindable 3] 27), ([direct_bindable 4] 28), ([direct_bindable 5] 29),
382 ([direct_bindable 6] 30), ([direct_bindable 7] 31)));
383 };
384}
385#[macro_export]
386#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
387macro_rules! for_each_classified_interrupt {
388 ($($pattern:tt => $code:tt;)*) => {
389 macro_rules! _for_each_inner_classified_interrupt { $(($pattern) => $code;)*
390 ($other : tt) => {} } _for_each_inner_classified_interrupt!(([direct_bindable 0]
391 24)); _for_each_inner_classified_interrupt!(([direct_bindable 1] 25));
392 _for_each_inner_classified_interrupt!(([direct_bindable 2] 26));
393 _for_each_inner_classified_interrupt!(([direct_bindable 3] 27));
394 _for_each_inner_classified_interrupt!(([direct_bindable 4] 28));
395 _for_each_inner_classified_interrupt!(([direct_bindable 5] 29));
396 _for_each_inner_classified_interrupt!(([direct_bindable 6] 30));
397 _for_each_inner_classified_interrupt!(([direct_bindable 7] 31));
398 _for_each_inner_classified_interrupt!(([vector 0] 16));
399 _for_each_inner_classified_interrupt!(([vector 1] 17));
400 _for_each_inner_classified_interrupt!(([vector 2] 18));
401 _for_each_inner_classified_interrupt!(([vector 3] 19));
402 _for_each_inner_classified_interrupt!(([vector 4] 20));
403 _for_each_inner_classified_interrupt!(([vector 5] 21));
404 _for_each_inner_classified_interrupt!(([vector 6] 22));
405 _for_each_inner_classified_interrupt!(([vector 7] 23));
406 _for_each_inner_classified_interrupt!(([reserved 0] 1));
407 _for_each_inner_classified_interrupt!(([reserved 1] 2));
408 _for_each_inner_classified_interrupt!(([reserved 2] 3));
409 _for_each_inner_classified_interrupt!(([reserved 3] 4));
410 _for_each_inner_classified_interrupt!(([reserved 4] 5));
411 _for_each_inner_classified_interrupt!(([reserved 5] 6));
412 _for_each_inner_classified_interrupt!(([reserved 6] 7));
413 _for_each_inner_classified_interrupt!(([reserved 7] 8));
414 _for_each_inner_classified_interrupt!(([reserved 8] 9));
415 _for_each_inner_classified_interrupt!(([reserved 9] 10));
416 _for_each_inner_classified_interrupt!(([reserved 10] 11));
417 _for_each_inner_classified_interrupt!(([reserved 11] 12));
418 _for_each_inner_classified_interrupt!(([reserved 12] 13));
419 _for_each_inner_classified_interrupt!(([reserved 13] 14));
420 _for_each_inner_classified_interrupt!(([reserved 14] 15));
421 _for_each_inner_classified_interrupt!((direct_bindable([direct_bindable 0] 24),
422 ([direct_bindable 1] 25), ([direct_bindable 2] 26), ([direct_bindable 3] 27),
423 ([direct_bindable 4] 28), ([direct_bindable 5] 29), ([direct_bindable 6] 30),
424 ([direct_bindable 7] 31))); _for_each_inner_classified_interrupt!((vector([vector
425 0] 16), ([vector 1] 17), ([vector 2] 18), ([vector 3] 19), ([vector 4] 20),
426 ([vector 5] 21), ([vector 6] 22), ([vector 7] 23)));
427 _for_each_inner_classified_interrupt!((reserved([reserved 0] 1), ([reserved 1]
428 2), ([reserved 2] 3), ([reserved 3] 4), ([reserved 4] 5), ([reserved 5] 6),
429 ([reserved 6] 7), ([reserved 7] 8), ([reserved 8] 9), ([reserved 9] 10),
430 ([reserved 10] 11), ([reserved 11] 12), ([reserved 12] 13), ([reserved 13] 14),
431 ([reserved 14] 15)));
432 };
433}
434#[macro_export]
435#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
436macro_rules! for_each_interrupt_priority {
437 ($($pattern:tt => $code:tt;)*) => {
438 macro_rules! _for_each_inner_interrupt_priority { $(($pattern) => $code;)*
439 ($other : tt) => {} } _for_each_inner_interrupt_priority!((0, 1, Priority1,
440 Level1)); _for_each_inner_interrupt_priority!((1, 2, Priority2, Level2));
441 _for_each_inner_interrupt_priority!((2, 3, Priority3, Level3));
442 _for_each_inner_interrupt_priority!((3, 4, Priority4, Level4));
443 _for_each_inner_interrupt_priority!((4, 5, Priority5, Level5));
444 _for_each_inner_interrupt_priority!((5, 6, Priority6, Level6));
445 _for_each_inner_interrupt_priority!((6, 7, Priority7, Level7));
446 _for_each_inner_interrupt_priority!((7, 8, Priority8, Level8));
447 _for_each_inner_interrupt_priority!((all(0, 1, Priority1, Level1), (1, 2,
448 Priority2, Level2), (2, 3, Priority3, Level3), (3, 4, Priority4, Level4), (4, 5,
449 Priority5, Level5), (5, 6, Priority6, Level6), (6, 7, Priority7, Level7), (7, 8,
450 Priority8, Level8)));
451 };
452}
453#[macro_export]
454#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
455macro_rules! for_each_sw_interrupt {
456 ($($pattern:tt => $code:tt;)*) => {
457 macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
458 tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
459 software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
460 software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
461 software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
462 software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
463 software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
464 FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
465 };
466}
467#[macro_export]
468macro_rules! sw_interrupt_delay {
469 () => {
470 unsafe {
471 ::core::arch::asm!("nop");
472 ::core::arch::asm!("nop");
473 ::core::arch::asm!("nop");
474 ::core::arch::asm!("nop");
475 ::core::arch::asm!("nop");
476 ::core::arch::asm!("nop");
477 ::core::arch::asm!("nop");
478 ::core::arch::asm!("nop");
479 ::core::arch::asm!("nop");
480 ::core::arch::asm!("nop");
481 ::core::arch::asm!("nop");
482 ::core::arch::asm!("nop");
483 ::core::arch::asm!("nop");
484 ::core::arch::asm!("nop");
485 ::core::arch::asm!("nop");
486 ::core::arch::asm!("nop");
487 ::core::arch::asm!("nop");
488 ::core::arch::asm!("nop");
489 ::core::arch::asm!("nop");
490 ::core::arch::asm!("nop");
491 ::core::arch::asm!("nop");
492 ::core::arch::asm!("nop");
493 ::core::arch::asm!("nop");
494 ::core::arch::asm!("nop");
495 }
496 };
497}
498#[macro_export]
499#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
500macro_rules! for_each_sha_algorithm {
501 ($($pattern:tt => $code:tt;)*) => {
502 macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
503 tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
504 (insecure_against : "collision", "length extension"), 0));
505 _for_each_inner_sha_algorithm!((Sha224, "SHA-224"(sizes : 64, 28, 8)
506 (insecure_against : "length extension"), 1));
507 _for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
508 (insecure_against : "length extension"), 2));
509 _for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
510 (insecure_against : "collision", "length extension"), 0), (Sha224,
511 "SHA-224"(sizes : 64, 28, 8) (insecure_against : "length extension"), 1),
512 (Sha256, "SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"),
513 2)));
514 };
515}
516#[macro_export]
517macro_rules! define_clock_tree_types {
769 () => {
770 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
771 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
772 pub enum TimgInstance {
773 Timg0 = 0,
774 Timg1 = 1,
775 }
776 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
777 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
778 pub enum UartInstance {
779 Uart0 = 0,
780 Uart1 = 1,
781 }
782 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
784 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
785 pub enum XtalClkConfig {
786 _40,
788 }
789 impl XtalClkConfig {
790 pub fn value(&self) -> u32 {
791 match self {
792 XtalClkConfig::_40 => 40000000,
793 }
794 }
795 }
796 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
798 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
799 pub enum HpRootClkConfig {
800 Xtal,
802 RcFast,
804 PllF160m,
806 }
807 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
811 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
812 pub struct CpuClkConfig {
813 divisor: u32,
814 }
815 impl CpuClkConfig {
816 pub const fn new(divisor: u32) -> Self {
823 ::core::assert!(
824 divisor <= 255,
825 "`CPU_CLK` divisor must be between 0 and 255 (inclusive)."
826 );
827 Self { divisor }
828 }
829 fn divisor(self) -> u32 {
830 self.divisor as u32
831 }
832 }
833 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
837 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
838 pub struct AhbClkConfig {
839 divisor: u32,
840 }
841 impl AhbClkConfig {
842 pub const fn new(divisor: u32) -> Self {
849 ::core::assert!(
850 divisor <= 255,
851 "`AHB_CLK` divisor must be between 0 and 255 (inclusive)."
852 );
853 Self { divisor }
854 }
855 fn divisor(self) -> u32 {
856 self.divisor as u32
857 }
858 }
859 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
863 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
864 pub struct ApbClkConfig {
865 divisor: u32,
866 }
867 impl ApbClkConfig {
868 pub const fn new(divisor: u32) -> Self {
875 ::core::assert!(
876 divisor <= 255,
877 "`APB_CLK` divisor must be between 0 and 255 (inclusive)."
878 );
879 Self { divisor }
880 }
881 fn divisor(self) -> u32 {
882 self.divisor as u32
883 }
884 }
885 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
887 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
888 pub enum LpFastClkConfig {
889 RcFast,
891 XtalD2,
893 Xtal,
895 }
896 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
898 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
899 pub enum LpSlowClkConfig {
900 RcSlow,
902 Xtal32k,
904 OscSlow,
906 }
907 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
909 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
910 pub enum TimgCalibrationClockConfig {
911 OscSlowClk,
913 RcSlowClk,
915 RcFastDivClk,
917 Xtal32kClk,
919 }
920 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
922 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
923 pub enum TimgFunctionClockConfig {
924 #[default]
925 XtalClk,
927 RcFastClk,
929 PllF80m,
931 }
932 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
934 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
935 pub enum TimgWdtClockConfig {
936 #[default]
937 XtalClk,
939 RcFastClk,
941 PllF80m,
943 }
944 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
945 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
946 pub enum UartFunctionClockSclk {
947 #[default]
948 Xtal,
950 PllF80m,
952 RcFast,
954 }
955 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
959 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
960 pub struct UartFunctionClockConfig {
961 sclk: UartFunctionClockSclk,
962 div_num: u32,
963 }
964 impl UartFunctionClockConfig {
965 pub const fn new(sclk: UartFunctionClockSclk, div_num: u32) -> Self {
972 ::core::assert!(
973 div_num <= 255,
974 "`UART0_FUNCTION_CLOCK` div_num must be between 0 and 255 (inclusive)."
975 );
976 Self { sclk, div_num }
977 }
978 fn sclk(self) -> UartFunctionClockSclk {
979 self.sclk
980 }
981 fn div_num(self) -> u32 {
982 self.div_num as u32
983 }
984 }
985 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
990 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
991 pub struct UartBaudRateGeneratorConfig {
992 fractional: u32,
993 integral: u32,
994 }
995 impl UartBaudRateGeneratorConfig {
996 pub const fn new(fractional: u32, integral: u32) -> Self {
1006 ::core::assert!(
1007 fractional <= 15,
1008 "`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
1009 );
1010 ::core::assert!(
1011 integral <= 4095,
1012 "`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 4095 (inclusive)."
1013 );
1014 Self {
1015 fractional,
1016 integral,
1017 }
1018 }
1019 fn fractional(self) -> u32 {
1020 self.fractional as u32
1021 }
1022 fn integral(self) -> u32 {
1023 self.integral as u32
1024 }
1025 }
1026 pub struct ClockTree {
1028 xtal_clk: Option<XtalClkConfig>,
1029 hp_root_clk: Option<HpRootClkConfig>,
1030 cpu_clk: Option<CpuClkConfig>,
1031 ahb_clk: Option<AhbClkConfig>,
1032 apb_clk: Option<ApbClkConfig>,
1033 lp_fast_clk: Option<LpFastClkConfig>,
1034 lp_slow_clk: Option<LpSlowClkConfig>,
1035 timg_calibration_clock: Option<TimgCalibrationClockConfig>,
1036 timg_function_clock: [Option<TimgFunctionClockConfig>; 2],
1037 timg_wdt_clock: [Option<TimgWdtClockConfig>; 2],
1038 uart_function_clock: [Option<UartFunctionClockConfig>; 2],
1039 uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 2],
1040 rc_fast_clk_refcount: u32,
1041 pll_clk_refcount: u32,
1042 xtal32k_clk_refcount: u32,
1043 osc_slow_clk_refcount: u32,
1044 rc_slow_clk_refcount: u32,
1045 pll_f20m_refcount: u32,
1046 pll_f40m_refcount: u32,
1047 pll_f48m_refcount: u32,
1048 pll_f60m_refcount: u32,
1049 pll_f80m_refcount: u32,
1050 pll_f120m_refcount: u32,
1051 hp_root_clk_refcount: u32,
1052 cpu_clk_refcount: u32,
1053 apb_clk_refcount: u32,
1054 lp_fast_clk_refcount: u32,
1055 lp_slow_clk_refcount: u32,
1056 timg_calibration_clock_refcount: u32,
1057 timg_function_clock_refcount: [u32; 2],
1058 timg_wdt_clock_refcount: [u32; 2],
1059 uart_function_clock_refcount: [u32; 2],
1060 uart_baud_rate_generator_refcount: [u32; 2],
1061 }
1062 impl ClockTree {
1063 pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
1065 CLOCK_TREE.with(f)
1066 }
1067 pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
1069 self.xtal_clk
1070 }
1071 pub fn hp_root_clk(&self) -> Option<HpRootClkConfig> {
1073 self.hp_root_clk
1074 }
1075 pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
1077 self.cpu_clk
1078 }
1079 pub fn ahb_clk(&self) -> Option<AhbClkConfig> {
1081 self.ahb_clk
1082 }
1083 pub fn apb_clk(&self) -> Option<ApbClkConfig> {
1085 self.apb_clk
1086 }
1087 pub fn lp_fast_clk(&self) -> Option<LpFastClkConfig> {
1089 self.lp_fast_clk
1090 }
1091 pub fn lp_slow_clk(&self) -> Option<LpSlowClkConfig> {
1093 self.lp_slow_clk
1094 }
1095 pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
1097 self.timg_calibration_clock
1098 }
1099 pub fn timg0_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1101 self.timg_function_clock[TimgInstance::Timg0 as usize]
1102 }
1103 pub fn timg0_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1105 self.timg_wdt_clock[TimgInstance::Timg0 as usize]
1106 }
1107 pub fn timg1_function_clock(&self) -> Option<TimgFunctionClockConfig> {
1109 self.timg_function_clock[TimgInstance::Timg1 as usize]
1110 }
1111 pub fn timg1_wdt_clock(&self) -> Option<TimgWdtClockConfig> {
1113 self.timg_wdt_clock[TimgInstance::Timg1 as usize]
1114 }
1115 pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
1117 self.uart_function_clock[UartInstance::Uart0 as usize]
1118 }
1119 pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1121 self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
1122 }
1123 pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
1125 self.uart_function_clock[UartInstance::Uart1 as usize]
1126 }
1127 pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
1129 self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
1130 }
1131 }
1132 static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
1133 ::esp_sync::NonReentrantMutex::new(ClockTree {
1134 xtal_clk: None,
1135 hp_root_clk: None,
1136 cpu_clk: None,
1137 ahb_clk: None,
1138 apb_clk: None,
1139 lp_fast_clk: None,
1140 lp_slow_clk: None,
1141 timg_calibration_clock: None,
1142 timg_function_clock: [None; 2],
1143 timg_wdt_clock: [None; 2],
1144 uart_function_clock: [None; 2],
1145 uart_baud_rate_generator: [None; 2],
1146 rc_fast_clk_refcount: 0,
1147 pll_clk_refcount: 0,
1148 xtal32k_clk_refcount: 0,
1149 osc_slow_clk_refcount: 0,
1150 rc_slow_clk_refcount: 0,
1151 pll_f20m_refcount: 0,
1152 pll_f40m_refcount: 0,
1153 pll_f48m_refcount: 0,
1154 pll_f60m_refcount: 0,
1155 pll_f80m_refcount: 0,
1156 pll_f120m_refcount: 0,
1157 hp_root_clk_refcount: 0,
1158 cpu_clk_refcount: 0,
1159 apb_clk_refcount: 0,
1160 lp_fast_clk_refcount: 0,
1161 lp_slow_clk_refcount: 0,
1162 timg_calibration_clock_refcount: 0,
1163 timg_function_clock_refcount: [0; 2],
1164 timg_wdt_clock_refcount: [0; 2],
1165 uart_function_clock_refcount: [0; 2],
1166 uart_baud_rate_generator_refcount: [0; 2],
1167 });
1168 pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
1169 let old_config = clocks.xtal_clk.replace(config);
1170 configure_xtal_clk_impl(clocks, old_config, config);
1171 }
1172 pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
1173 clocks.xtal_clk
1174 }
1175 fn request_xtal_clk(_clocks: &mut ClockTree) {}
1176 fn release_xtal_clk(_clocks: &mut ClockTree) {}
1177 #[allow(unused_variables)]
1178 pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
1179 config.value()
1180 }
1181 pub fn xtal_clk_frequency(clocks: &mut ClockTree) -> u32 {
1182 if let Some(config) = clocks.xtal_clk {
1183 xtal_clk_config_frequency(clocks, config)
1184 } else {
1185 0
1186 }
1187 }
1188 pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
1189 trace!("Requesting RC_FAST_CLK");
1190 if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
1191 trace!("Enabling RC_FAST_CLK");
1192 enable_rc_fast_clk_impl(clocks, true);
1193 }
1194 }
1195 pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
1196 trace!("Releasing RC_FAST_CLK");
1197 if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
1198 trace!("Disabling RC_FAST_CLK");
1199 enable_rc_fast_clk_impl(clocks, false);
1200 }
1201 }
1202 pub fn rc_fast_clk_frequency(clocks: &mut ClockTree) -> u32 {
1203 17500000
1204 }
1205 pub fn request_pll_clk(clocks: &mut ClockTree) {
1206 trace!("Requesting PLL_CLK");
1207 if increment_reference_count(&mut clocks.pll_clk_refcount) {
1208 trace!("Enabling PLL_CLK");
1209 request_xtal_clk(clocks);
1210 enable_pll_clk_impl(clocks, true);
1211 }
1212 }
1213 pub fn release_pll_clk(clocks: &mut ClockTree) {
1214 trace!("Releasing PLL_CLK");
1215 if decrement_reference_count(&mut clocks.pll_clk_refcount) {
1216 trace!("Disabling PLL_CLK");
1217 enable_pll_clk_impl(clocks, false);
1218 release_xtal_clk(clocks);
1219 }
1220 }
1221 pub fn pll_clk_frequency(clocks: &mut ClockTree) -> u32 {
1222 480000000
1223 }
1224 pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
1225 trace!("Requesting XTAL32K_CLK");
1226 if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
1227 trace!("Enabling XTAL32K_CLK");
1228 enable_xtal32k_clk_impl(clocks, true);
1229 }
1230 }
1231 pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
1232 trace!("Releasing XTAL32K_CLK");
1233 if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
1234 trace!("Disabling XTAL32K_CLK");
1235 enable_xtal32k_clk_impl(clocks, false);
1236 }
1237 }
1238 pub fn xtal32k_clk_frequency(clocks: &mut ClockTree) -> u32 {
1239 32768
1240 }
1241 pub fn request_osc_slow_clk(clocks: &mut ClockTree) {
1242 trace!("Requesting OSC_SLOW_CLK");
1243 if increment_reference_count(&mut clocks.osc_slow_clk_refcount) {
1244 trace!("Enabling OSC_SLOW_CLK");
1245 enable_osc_slow_clk_impl(clocks, true);
1246 }
1247 }
1248 pub fn release_osc_slow_clk(clocks: &mut ClockTree) {
1249 trace!("Releasing OSC_SLOW_CLK");
1250 if decrement_reference_count(&mut clocks.osc_slow_clk_refcount) {
1251 trace!("Disabling OSC_SLOW_CLK");
1252 enable_osc_slow_clk_impl(clocks, false);
1253 }
1254 }
1255 pub fn osc_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
1256 32768
1257 }
1258 pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
1259 trace!("Requesting RC_SLOW_CLK");
1260 if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
1261 trace!("Enabling RC_SLOW_CLK");
1262 enable_rc_slow_clk_impl(clocks, true);
1263 }
1264 }
1265 pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
1266 trace!("Releasing RC_SLOW_CLK");
1267 if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
1268 trace!("Disabling RC_SLOW_CLK");
1269 enable_rc_slow_clk_impl(clocks, false);
1270 }
1271 }
1272 pub fn rc_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
1273 136000
1274 }
1275 pub fn request_pll_f20m(clocks: &mut ClockTree) {
1276 trace!("Requesting PLL_F20M");
1277 if increment_reference_count(&mut clocks.pll_f20m_refcount) {
1278 trace!("Enabling PLL_F20M");
1279 request_pll_clk(clocks);
1280 enable_pll_f20m_impl(clocks, true);
1281 }
1282 }
1283 pub fn release_pll_f20m(clocks: &mut ClockTree) {
1284 trace!("Releasing PLL_F20M");
1285 if decrement_reference_count(&mut clocks.pll_f20m_refcount) {
1286 trace!("Disabling PLL_F20M");
1287 enable_pll_f20m_impl(clocks, false);
1288 release_pll_clk(clocks);
1289 }
1290 }
1291 pub fn pll_f20m_frequency(clocks: &mut ClockTree) -> u32 {
1292 (pll_clk_frequency(clocks) / 24)
1293 }
1294 pub fn request_pll_f40m(clocks: &mut ClockTree) {
1295 trace!("Requesting PLL_F40M");
1296 if increment_reference_count(&mut clocks.pll_f40m_refcount) {
1297 trace!("Enabling PLL_F40M");
1298 request_pll_clk(clocks);
1299 enable_pll_f40m_impl(clocks, true);
1300 }
1301 }
1302 pub fn release_pll_f40m(clocks: &mut ClockTree) {
1303 trace!("Releasing PLL_F40M");
1304 if decrement_reference_count(&mut clocks.pll_f40m_refcount) {
1305 trace!("Disabling PLL_F40M");
1306 enable_pll_f40m_impl(clocks, false);
1307 release_pll_clk(clocks);
1308 }
1309 }
1310 pub fn pll_f40m_frequency(clocks: &mut ClockTree) -> u32 {
1311 (pll_clk_frequency(clocks) / 12)
1312 }
1313 pub fn request_pll_f48m(clocks: &mut ClockTree) {
1314 trace!("Requesting PLL_F48M");
1315 if increment_reference_count(&mut clocks.pll_f48m_refcount) {
1316 trace!("Enabling PLL_F48M");
1317 request_pll_clk(clocks);
1318 enable_pll_f48m_impl(clocks, true);
1319 }
1320 }
1321 pub fn release_pll_f48m(clocks: &mut ClockTree) {
1322 trace!("Releasing PLL_F48M");
1323 if decrement_reference_count(&mut clocks.pll_f48m_refcount) {
1324 trace!("Disabling PLL_F48M");
1325 enable_pll_f48m_impl(clocks, false);
1326 release_pll_clk(clocks);
1327 }
1328 }
1329 pub fn pll_f48m_frequency(clocks: &mut ClockTree) -> u32 {
1330 (pll_clk_frequency(clocks) / 10)
1331 }
1332 pub fn request_pll_f60m(clocks: &mut ClockTree) {
1333 trace!("Requesting PLL_F60M");
1334 if increment_reference_count(&mut clocks.pll_f60m_refcount) {
1335 trace!("Enabling PLL_F60M");
1336 request_pll_clk(clocks);
1337 enable_pll_f60m_impl(clocks, true);
1338 }
1339 }
1340 pub fn release_pll_f60m(clocks: &mut ClockTree) {
1341 trace!("Releasing PLL_F60M");
1342 if decrement_reference_count(&mut clocks.pll_f60m_refcount) {
1343 trace!("Disabling PLL_F60M");
1344 enable_pll_f60m_impl(clocks, false);
1345 release_pll_clk(clocks);
1346 }
1347 }
1348 pub fn pll_f60m_frequency(clocks: &mut ClockTree) -> u32 {
1349 (pll_clk_frequency(clocks) / 8)
1350 }
1351 pub fn request_pll_f80m(clocks: &mut ClockTree) {
1352 trace!("Requesting PLL_F80M");
1353 if increment_reference_count(&mut clocks.pll_f80m_refcount) {
1354 trace!("Enabling PLL_F80M");
1355 request_pll_clk(clocks);
1356 enable_pll_f80m_impl(clocks, true);
1357 }
1358 }
1359 pub fn release_pll_f80m(clocks: &mut ClockTree) {
1360 trace!("Releasing PLL_F80M");
1361 if decrement_reference_count(&mut clocks.pll_f80m_refcount) {
1362 trace!("Disabling PLL_F80M");
1363 enable_pll_f80m_impl(clocks, false);
1364 release_pll_clk(clocks);
1365 }
1366 }
1367 pub fn pll_f80m_frequency(clocks: &mut ClockTree) -> u32 {
1368 (pll_clk_frequency(clocks) / 6)
1369 }
1370 pub fn request_pll_f120m(clocks: &mut ClockTree) {
1371 trace!("Requesting PLL_F120M");
1372 if increment_reference_count(&mut clocks.pll_f120m_refcount) {
1373 trace!("Enabling PLL_F120M");
1374 request_pll_clk(clocks);
1375 enable_pll_f120m_impl(clocks, true);
1376 }
1377 }
1378 pub fn release_pll_f120m(clocks: &mut ClockTree) {
1379 trace!("Releasing PLL_F120M");
1380 if decrement_reference_count(&mut clocks.pll_f120m_refcount) {
1381 trace!("Disabling PLL_F120M");
1382 enable_pll_f120m_impl(clocks, false);
1383 release_pll_clk(clocks);
1384 }
1385 }
1386 pub fn pll_f120m_frequency(clocks: &mut ClockTree) -> u32 {
1387 (pll_clk_frequency(clocks) / 4)
1388 }
1389 pub fn request_pll_f160m(clocks: &mut ClockTree) {
1390 trace!("Requesting PLL_F160M");
1391 trace!("Enabling PLL_F160M");
1392 request_pll_clk(clocks);
1393 enable_pll_f160m_impl(clocks, true);
1394 }
1395 pub fn release_pll_f160m(clocks: &mut ClockTree) {
1396 trace!("Releasing PLL_F160M");
1397 trace!("Disabling PLL_F160M");
1398 enable_pll_f160m_impl(clocks, false);
1399 release_pll_clk(clocks);
1400 }
1401 pub fn pll_f160m_frequency(clocks: &mut ClockTree) -> u32 {
1402 (pll_clk_frequency(clocks) / 3)
1403 }
1404 pub fn configure_hp_root_clk(clocks: &mut ClockTree, new_selector: HpRootClkConfig) {
1405 let old_selector = clocks.hp_root_clk.replace(new_selector);
1406 if clocks.hp_root_clk_refcount > 0 {
1407 match new_selector {
1408 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
1409 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
1410 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
1411 }
1412 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
1413 if let Some(old_selector) = old_selector {
1414 match old_selector {
1415 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
1416 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
1417 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
1418 }
1419 }
1420 } else {
1421 configure_hp_root_clk_impl(clocks, old_selector, new_selector);
1422 }
1423 }
1424 pub fn hp_root_clk_config(clocks: &mut ClockTree) -> Option<HpRootClkConfig> {
1425 clocks.hp_root_clk
1426 }
1427 pub fn request_hp_root_clk(clocks: &mut ClockTree) {
1428 trace!("Requesting HP_ROOT_CLK");
1429 if increment_reference_count(&mut clocks.hp_root_clk_refcount) {
1430 trace!("Enabling HP_ROOT_CLK");
1431 match unwrap!(clocks.hp_root_clk) {
1432 HpRootClkConfig::Xtal => request_xtal_clk(clocks),
1433 HpRootClkConfig::RcFast => request_rc_fast_clk(clocks),
1434 HpRootClkConfig::PllF160m => request_pll_f160m(clocks),
1435 }
1436 enable_hp_root_clk_impl(clocks, true);
1437 }
1438 }
1439 pub fn release_hp_root_clk(clocks: &mut ClockTree) {
1440 trace!("Releasing HP_ROOT_CLK");
1441 if decrement_reference_count(&mut clocks.hp_root_clk_refcount) {
1442 trace!("Disabling HP_ROOT_CLK");
1443 enable_hp_root_clk_impl(clocks, false);
1444 match unwrap!(clocks.hp_root_clk) {
1445 HpRootClkConfig::Xtal => release_xtal_clk(clocks),
1446 HpRootClkConfig::RcFast => release_rc_fast_clk(clocks),
1447 HpRootClkConfig::PllF160m => release_pll_f160m(clocks),
1448 }
1449 }
1450 }
1451 #[allow(unused_variables)]
1452 pub fn hp_root_clk_config_frequency(
1453 clocks: &mut ClockTree,
1454 config: HpRootClkConfig,
1455 ) -> u32 {
1456 match config {
1457 HpRootClkConfig::Xtal => xtal_clk_frequency(clocks),
1458 HpRootClkConfig::RcFast => rc_fast_clk_frequency(clocks),
1459 HpRootClkConfig::PllF160m => pll_f160m_frequency(clocks),
1460 }
1461 }
1462 pub fn hp_root_clk_frequency(clocks: &mut ClockTree) -> u32 {
1463 if let Some(config) = clocks.hp_root_clk {
1464 hp_root_clk_config_frequency(clocks, config)
1465 } else {
1466 0
1467 }
1468 }
1469 pub fn configure_cpu_clk(clocks: &mut ClockTree, config: CpuClkConfig) {
1470 let old_config = clocks.cpu_clk.replace(config);
1471 configure_cpu_clk_impl(clocks, old_config, config);
1472 }
1473 pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
1474 clocks.cpu_clk
1475 }
1476 pub fn request_cpu_clk(clocks: &mut ClockTree) {
1477 trace!("Requesting CPU_CLK");
1478 if increment_reference_count(&mut clocks.cpu_clk_refcount) {
1479 trace!("Enabling CPU_CLK");
1480 request_hp_root_clk(clocks);
1481 enable_cpu_clk_impl(clocks, true);
1482 }
1483 }
1484 pub fn release_cpu_clk(clocks: &mut ClockTree) {
1485 trace!("Releasing CPU_CLK");
1486 if decrement_reference_count(&mut clocks.cpu_clk_refcount) {
1487 trace!("Disabling CPU_CLK");
1488 enable_cpu_clk_impl(clocks, false);
1489 release_hp_root_clk(clocks);
1490 }
1491 }
1492 #[allow(unused_variables)]
1493 pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
1494 (hp_root_clk_frequency(clocks) / (config.divisor() + 1))
1495 }
1496 pub fn cpu_clk_frequency(clocks: &mut ClockTree) -> u32 {
1497 if let Some(config) = clocks.cpu_clk {
1498 cpu_clk_config_frequency(clocks, config)
1499 } else {
1500 0
1501 }
1502 }
1503 pub fn configure_ahb_clk(clocks: &mut ClockTree, config: AhbClkConfig) {
1504 let old_config = clocks.ahb_clk.replace(config);
1505 configure_ahb_clk_impl(clocks, old_config, config);
1506 }
1507 pub fn ahb_clk_config(clocks: &mut ClockTree) -> Option<AhbClkConfig> {
1508 clocks.ahb_clk
1509 }
1510 pub fn request_ahb_clk(clocks: &mut ClockTree) {
1511 trace!("Requesting AHB_CLK");
1512 trace!("Enabling AHB_CLK");
1513 request_hp_root_clk(clocks);
1514 enable_ahb_clk_impl(clocks, true);
1515 }
1516 pub fn release_ahb_clk(clocks: &mut ClockTree) {
1517 trace!("Releasing AHB_CLK");
1518 trace!("Disabling AHB_CLK");
1519 enable_ahb_clk_impl(clocks, false);
1520 release_hp_root_clk(clocks);
1521 }
1522 #[allow(unused_variables)]
1523 pub fn ahb_clk_config_frequency(clocks: &mut ClockTree, config: AhbClkConfig) -> u32 {
1524 (hp_root_clk_frequency(clocks) / (config.divisor() + 1))
1525 }
1526 pub fn ahb_clk_frequency(clocks: &mut ClockTree) -> u32 {
1527 if let Some(config) = clocks.ahb_clk {
1528 ahb_clk_config_frequency(clocks, config)
1529 } else {
1530 0
1531 }
1532 }
1533 pub fn configure_apb_clk(clocks: &mut ClockTree, config: ApbClkConfig) {
1534 let old_config = clocks.apb_clk.replace(config);
1535 configure_apb_clk_impl(clocks, old_config, config);
1536 }
1537 pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
1538 clocks.apb_clk
1539 }
1540 pub fn request_apb_clk(clocks: &mut ClockTree) {
1541 trace!("Requesting APB_CLK");
1542 if increment_reference_count(&mut clocks.apb_clk_refcount) {
1543 trace!("Enabling APB_CLK");
1544 request_ahb_clk(clocks);
1545 enable_apb_clk_impl(clocks, true);
1546 }
1547 }
1548 pub fn release_apb_clk(clocks: &mut ClockTree) {
1549 trace!("Releasing APB_CLK");
1550 if decrement_reference_count(&mut clocks.apb_clk_refcount) {
1551 trace!("Disabling APB_CLK");
1552 enable_apb_clk_impl(clocks, false);
1553 release_ahb_clk(clocks);
1554 }
1555 }
1556 #[allow(unused_variables)]
1557 pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
1558 (ahb_clk_frequency(clocks) / (config.divisor() + 1))
1559 }
1560 pub fn apb_clk_frequency(clocks: &mut ClockTree) -> u32 {
1561 if let Some(config) = clocks.apb_clk {
1562 apb_clk_config_frequency(clocks, config)
1563 } else {
1564 0
1565 }
1566 }
1567 pub fn request_xtal_d2_clk(clocks: &mut ClockTree) {
1568 trace!("Requesting XTAL_D2_CLK");
1569 trace!("Enabling XTAL_D2_CLK");
1570 request_xtal_clk(clocks);
1571 enable_xtal_d2_clk_impl(clocks, true);
1572 }
1573 pub fn release_xtal_d2_clk(clocks: &mut ClockTree) {
1574 trace!("Releasing XTAL_D2_CLK");
1575 trace!("Disabling XTAL_D2_CLK");
1576 enable_xtal_d2_clk_impl(clocks, false);
1577 release_xtal_clk(clocks);
1578 }
1579 pub fn xtal_d2_clk_frequency(clocks: &mut ClockTree) -> u32 {
1580 (xtal_clk_frequency(clocks) / 2)
1581 }
1582 pub fn configure_lp_fast_clk(clocks: &mut ClockTree, new_selector: LpFastClkConfig) {
1583 let old_selector = clocks.lp_fast_clk.replace(new_selector);
1584 if clocks.lp_fast_clk_refcount > 0 {
1585 match new_selector {
1586 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
1587 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
1588 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
1589 }
1590 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
1591 if let Some(old_selector) = old_selector {
1592 match old_selector {
1593 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
1594 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
1595 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
1596 }
1597 }
1598 } else {
1599 configure_lp_fast_clk_impl(clocks, old_selector, new_selector);
1600 }
1601 }
1602 pub fn lp_fast_clk_config(clocks: &mut ClockTree) -> Option<LpFastClkConfig> {
1603 clocks.lp_fast_clk
1604 }
1605 pub fn request_lp_fast_clk(clocks: &mut ClockTree) {
1606 trace!("Requesting LP_FAST_CLK");
1607 if increment_reference_count(&mut clocks.lp_fast_clk_refcount) {
1608 trace!("Enabling LP_FAST_CLK");
1609 match unwrap!(clocks.lp_fast_clk) {
1610 LpFastClkConfig::RcFast => request_rc_fast_clk(clocks),
1611 LpFastClkConfig::XtalD2 => request_xtal_d2_clk(clocks),
1612 LpFastClkConfig::Xtal => request_xtal_clk(clocks),
1613 }
1614 enable_lp_fast_clk_impl(clocks, true);
1615 }
1616 }
1617 pub fn release_lp_fast_clk(clocks: &mut ClockTree) {
1618 trace!("Releasing LP_FAST_CLK");
1619 if decrement_reference_count(&mut clocks.lp_fast_clk_refcount) {
1620 trace!("Disabling LP_FAST_CLK");
1621 enable_lp_fast_clk_impl(clocks, false);
1622 match unwrap!(clocks.lp_fast_clk) {
1623 LpFastClkConfig::RcFast => release_rc_fast_clk(clocks),
1624 LpFastClkConfig::XtalD2 => release_xtal_d2_clk(clocks),
1625 LpFastClkConfig::Xtal => release_xtal_clk(clocks),
1626 }
1627 }
1628 }
1629 #[allow(unused_variables)]
1630 pub fn lp_fast_clk_config_frequency(
1631 clocks: &mut ClockTree,
1632 config: LpFastClkConfig,
1633 ) -> u32 {
1634 match config {
1635 LpFastClkConfig::RcFast => rc_fast_clk_frequency(clocks),
1636 LpFastClkConfig::XtalD2 => xtal_d2_clk_frequency(clocks),
1637 LpFastClkConfig::Xtal => xtal_clk_frequency(clocks),
1638 }
1639 }
1640 pub fn lp_fast_clk_frequency(clocks: &mut ClockTree) -> u32 {
1641 if let Some(config) = clocks.lp_fast_clk {
1642 lp_fast_clk_config_frequency(clocks, config)
1643 } else {
1644 0
1645 }
1646 }
1647 pub fn configure_lp_slow_clk(clocks: &mut ClockTree, new_selector: LpSlowClkConfig) {
1648 let old_selector = clocks.lp_slow_clk.replace(new_selector);
1649 if clocks.lp_slow_clk_refcount > 0 {
1650 match new_selector {
1651 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
1652 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
1653 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
1654 }
1655 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
1656 if let Some(old_selector) = old_selector {
1657 match old_selector {
1658 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
1659 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
1660 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
1661 }
1662 }
1663 } else {
1664 configure_lp_slow_clk_impl(clocks, old_selector, new_selector);
1665 }
1666 }
1667 pub fn lp_slow_clk_config(clocks: &mut ClockTree) -> Option<LpSlowClkConfig> {
1668 clocks.lp_slow_clk
1669 }
1670 pub fn request_lp_slow_clk(clocks: &mut ClockTree) {
1671 trace!("Requesting LP_SLOW_CLK");
1672 if increment_reference_count(&mut clocks.lp_slow_clk_refcount) {
1673 trace!("Enabling LP_SLOW_CLK");
1674 match unwrap!(clocks.lp_slow_clk) {
1675 LpSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
1676 LpSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
1677 LpSlowClkConfig::OscSlow => request_osc_slow_clk(clocks),
1678 }
1679 enable_lp_slow_clk_impl(clocks, true);
1680 }
1681 }
1682 pub fn release_lp_slow_clk(clocks: &mut ClockTree) {
1683 trace!("Releasing LP_SLOW_CLK");
1684 if decrement_reference_count(&mut clocks.lp_slow_clk_refcount) {
1685 trace!("Disabling LP_SLOW_CLK");
1686 enable_lp_slow_clk_impl(clocks, false);
1687 match unwrap!(clocks.lp_slow_clk) {
1688 LpSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
1689 LpSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
1690 LpSlowClkConfig::OscSlow => release_osc_slow_clk(clocks),
1691 }
1692 }
1693 }
1694 #[allow(unused_variables)]
1695 pub fn lp_slow_clk_config_frequency(
1696 clocks: &mut ClockTree,
1697 config: LpSlowClkConfig,
1698 ) -> u32 {
1699 match config {
1700 LpSlowClkConfig::RcSlow => rc_slow_clk_frequency(clocks),
1701 LpSlowClkConfig::Xtal32k => xtal32k_clk_frequency(clocks),
1702 LpSlowClkConfig::OscSlow => osc_slow_clk_frequency(clocks),
1703 }
1704 }
1705 pub fn lp_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
1706 if let Some(config) = clocks.lp_slow_clk {
1707 lp_slow_clk_config_frequency(clocks, config)
1708 } else {
1709 0
1710 }
1711 }
1712 pub fn configure_timg_calibration_clock(
1713 clocks: &mut ClockTree,
1714 new_selector: TimgCalibrationClockConfig,
1715 ) {
1716 let old_selector = clocks.timg_calibration_clock.replace(new_selector);
1717 if clocks.timg_calibration_clock_refcount > 0 {
1718 match new_selector {
1719 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
1720 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
1721 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
1722 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
1723 }
1724 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
1725 if let Some(old_selector) = old_selector {
1726 match old_selector {
1727 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
1728 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
1729 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
1730 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
1731 }
1732 }
1733 } else {
1734 configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
1735 }
1736 }
1737 pub fn timg_calibration_clock_config(
1738 clocks: &mut ClockTree,
1739 ) -> Option<TimgCalibrationClockConfig> {
1740 clocks.timg_calibration_clock
1741 }
1742 pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
1743 trace!("Requesting TIMG_CALIBRATION_CLOCK");
1744 if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
1745 trace!("Enabling TIMG_CALIBRATION_CLOCK");
1746 match unwrap!(clocks.timg_calibration_clock) {
1747 TimgCalibrationClockConfig::OscSlowClk => request_osc_slow_clk(clocks),
1748 TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
1749 TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_clk(clocks),
1750 TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
1751 }
1752 enable_timg_calibration_clock_impl(clocks, true);
1753 }
1754 }
1755 pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
1756 trace!("Releasing TIMG_CALIBRATION_CLOCK");
1757 if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
1758 trace!("Disabling TIMG_CALIBRATION_CLOCK");
1759 enable_timg_calibration_clock_impl(clocks, false);
1760 match unwrap!(clocks.timg_calibration_clock) {
1761 TimgCalibrationClockConfig::OscSlowClk => release_osc_slow_clk(clocks),
1762 TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
1763 TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_clk(clocks),
1764 TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
1765 }
1766 }
1767 }
1768 #[allow(unused_variables)]
1769 pub fn timg_calibration_clock_config_frequency(
1770 clocks: &mut ClockTree,
1771 config: TimgCalibrationClockConfig,
1772 ) -> u32 {
1773 match config {
1774 TimgCalibrationClockConfig::OscSlowClk => osc_slow_clk_frequency(clocks),
1775 TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(clocks),
1776 TimgCalibrationClockConfig::RcFastDivClk => rc_fast_clk_frequency(clocks),
1777 TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(clocks),
1778 }
1779 }
1780 pub fn timg_calibration_clock_frequency(clocks: &mut ClockTree) -> u32 {
1781 if let Some(config) = clocks.timg_calibration_clock {
1782 timg_calibration_clock_config_frequency(clocks, config)
1783 } else {
1784 0
1785 }
1786 }
1787 impl TimgInstance {
1788 pub fn configure_function_clock(
1789 self,
1790 clocks: &mut ClockTree,
1791 new_selector: TimgFunctionClockConfig,
1792 ) {
1793 let old_selector = clocks.timg_function_clock[self as usize].replace(new_selector);
1794 if clocks.timg_function_clock_refcount[self as usize] > 0 {
1795 match new_selector {
1796 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
1797 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
1798 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
1799 }
1800 self.configure_function_clock_impl(clocks, old_selector, new_selector);
1801 if let Some(old_selector) = old_selector {
1802 match old_selector {
1803 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
1804 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
1805 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
1806 }
1807 }
1808 } else {
1809 self.configure_function_clock_impl(clocks, old_selector, new_selector);
1810 }
1811 }
1812 pub fn function_clock_config(
1813 self,
1814 clocks: &mut ClockTree,
1815 ) -> Option<TimgFunctionClockConfig> {
1816 clocks.timg_function_clock[self as usize]
1817 }
1818 pub fn request_function_clock(self, clocks: &mut ClockTree) {
1819 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
1820 if increment_reference_count(
1821 &mut clocks.timg_function_clock_refcount[self as usize],
1822 ) {
1823 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
1824 match unwrap!(clocks.timg_function_clock[self as usize]) {
1825 TimgFunctionClockConfig::XtalClk => request_xtal_clk(clocks),
1826 TimgFunctionClockConfig::RcFastClk => request_rc_fast_clk(clocks),
1827 TimgFunctionClockConfig::PllF80m => request_pll_f80m(clocks),
1828 }
1829 self.enable_function_clock_impl(clocks, true);
1830 }
1831 }
1832 pub fn release_function_clock(self, clocks: &mut ClockTree) {
1833 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
1834 if decrement_reference_count(
1835 &mut clocks.timg_function_clock_refcount[self as usize],
1836 ) {
1837 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
1838 self.enable_function_clock_impl(clocks, false);
1839 match unwrap!(clocks.timg_function_clock[self as usize]) {
1840 TimgFunctionClockConfig::XtalClk => release_xtal_clk(clocks),
1841 TimgFunctionClockConfig::RcFastClk => release_rc_fast_clk(clocks),
1842 TimgFunctionClockConfig::PllF80m => release_pll_f80m(clocks),
1843 }
1844 }
1845 }
1846 #[allow(unused_variables)]
1847 pub fn function_clock_config_frequency(
1848 self,
1849 clocks: &mut ClockTree,
1850 config: TimgFunctionClockConfig,
1851 ) -> u32 {
1852 match config {
1853 TimgFunctionClockConfig::XtalClk => xtal_clk_frequency(clocks),
1854 TimgFunctionClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
1855 TimgFunctionClockConfig::PllF80m => pll_f80m_frequency(clocks),
1856 }
1857 }
1858 pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
1859 if let Some(config) = clocks.timg_function_clock[self as usize] {
1860 self.function_clock_config_frequency(clocks, config)
1861 } else {
1862 0
1863 }
1864 }
1865 pub fn configure_wdt_clock(
1866 self,
1867 clocks: &mut ClockTree,
1868 new_selector: TimgWdtClockConfig,
1869 ) {
1870 let old_selector = clocks.timg_wdt_clock[self as usize].replace(new_selector);
1871 if clocks.timg_wdt_clock_refcount[self as usize] > 0 {
1872 match new_selector {
1873 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
1874 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
1875 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
1876 }
1877 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
1878 if let Some(old_selector) = old_selector {
1879 match old_selector {
1880 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
1881 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
1882 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
1883 }
1884 }
1885 } else {
1886 self.configure_wdt_clock_impl(clocks, old_selector, new_selector);
1887 }
1888 }
1889 pub fn wdt_clock_config(self, clocks: &mut ClockTree) -> Option<TimgWdtClockConfig> {
1890 clocks.timg_wdt_clock[self as usize]
1891 }
1892 pub fn request_wdt_clock(self, clocks: &mut ClockTree) {
1893 trace!("Requesting {:?}::WDT_CLOCK", self);
1894 if increment_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
1895 trace!("Enabling {:?}::WDT_CLOCK", self);
1896 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
1897 TimgWdtClockConfig::XtalClk => request_xtal_clk(clocks),
1898 TimgWdtClockConfig::RcFastClk => request_rc_fast_clk(clocks),
1899 TimgWdtClockConfig::PllF80m => request_pll_f80m(clocks),
1900 }
1901 self.enable_wdt_clock_impl(clocks, true);
1902 }
1903 }
1904 pub fn release_wdt_clock(self, clocks: &mut ClockTree) {
1905 trace!("Releasing {:?}::WDT_CLOCK", self);
1906 if decrement_reference_count(&mut clocks.timg_wdt_clock_refcount[self as usize]) {
1907 trace!("Disabling {:?}::WDT_CLOCK", self);
1908 self.enable_wdt_clock_impl(clocks, false);
1909 match unwrap!(clocks.timg_wdt_clock[self as usize]) {
1910 TimgWdtClockConfig::XtalClk => release_xtal_clk(clocks),
1911 TimgWdtClockConfig::RcFastClk => release_rc_fast_clk(clocks),
1912 TimgWdtClockConfig::PllF80m => release_pll_f80m(clocks),
1913 }
1914 }
1915 }
1916 #[allow(unused_variables)]
1917 pub fn wdt_clock_config_frequency(
1918 self,
1919 clocks: &mut ClockTree,
1920 config: TimgWdtClockConfig,
1921 ) -> u32 {
1922 match config {
1923 TimgWdtClockConfig::XtalClk => xtal_clk_frequency(clocks),
1924 TimgWdtClockConfig::RcFastClk => rc_fast_clk_frequency(clocks),
1925 TimgWdtClockConfig::PllF80m => pll_f80m_frequency(clocks),
1926 }
1927 }
1928 pub fn wdt_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
1929 if let Some(config) = clocks.timg_wdt_clock[self as usize] {
1930 self.wdt_clock_config_frequency(clocks, config)
1931 } else {
1932 0
1933 }
1934 }
1935 }
1936 impl UartInstance {
1937 pub fn configure_function_clock(
1938 self,
1939 clocks: &mut ClockTree,
1940 config: UartFunctionClockConfig,
1941 ) {
1942 let old_config = clocks.uart_function_clock[self as usize].replace(config);
1943 if clocks.uart_function_clock_refcount[self as usize] > 0 {
1944 match config.sclk {
1945 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
1946 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
1947 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
1948 }
1949 self.configure_function_clock_impl(clocks, old_config, config);
1950 if let Some(old_config) = old_config {
1951 match old_config.sclk {
1952 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
1953 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
1954 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
1955 }
1956 }
1957 } else {
1958 self.configure_function_clock_impl(clocks, old_config, config);
1959 }
1960 }
1961 pub fn function_clock_config(
1962 self,
1963 clocks: &mut ClockTree,
1964 ) -> Option<UartFunctionClockConfig> {
1965 clocks.uart_function_clock[self as usize]
1966 }
1967 pub fn request_function_clock(self, clocks: &mut ClockTree) {
1968 trace!("Requesting {:?}::FUNCTION_CLOCK", self);
1969 if increment_reference_count(
1970 &mut clocks.uart_function_clock_refcount[self as usize],
1971 ) {
1972 trace!("Enabling {:?}::FUNCTION_CLOCK", self);
1973 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
1974 UartFunctionClockSclk::Xtal => request_xtal_clk(clocks),
1975 UartFunctionClockSclk::PllF80m => request_pll_f80m(clocks),
1976 UartFunctionClockSclk::RcFast => request_rc_fast_clk(clocks),
1977 }
1978 self.enable_function_clock_impl(clocks, true);
1979 }
1980 }
1981 pub fn release_function_clock(self, clocks: &mut ClockTree) {
1982 trace!("Releasing {:?}::FUNCTION_CLOCK", self);
1983 if decrement_reference_count(
1984 &mut clocks.uart_function_clock_refcount[self as usize],
1985 ) {
1986 trace!("Disabling {:?}::FUNCTION_CLOCK", self);
1987 self.enable_function_clock_impl(clocks, false);
1988 match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
1989 UartFunctionClockSclk::Xtal => release_xtal_clk(clocks),
1990 UartFunctionClockSclk::PllF80m => release_pll_f80m(clocks),
1991 UartFunctionClockSclk::RcFast => release_rc_fast_clk(clocks),
1992 }
1993 }
1994 }
1995 #[allow(unused_variables)]
1996 pub fn function_clock_config_frequency(
1997 self,
1998 clocks: &mut ClockTree,
1999 config: UartFunctionClockConfig,
2000 ) -> u32 {
2001 (match config.sclk {
2002 UartFunctionClockSclk::Xtal => xtal_clk_frequency(clocks),
2003 UartFunctionClockSclk::PllF80m => pll_f80m_frequency(clocks),
2004 UartFunctionClockSclk::RcFast => rc_fast_clk_frequency(clocks),
2005 } / (config.div_num() + 1))
2006 }
2007 pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
2008 if let Some(config) = clocks.uart_function_clock[self as usize] {
2009 self.function_clock_config_frequency(clocks, config)
2010 } else {
2011 0
2012 }
2013 }
2014 pub fn configure_baud_rate_generator(
2015 self,
2016 clocks: &mut ClockTree,
2017 config: UartBaudRateGeneratorConfig,
2018 ) {
2019 let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
2020 self.configure_baud_rate_generator_impl(clocks, old_config, config);
2021 }
2022 pub fn baud_rate_generator_config(
2023 self,
2024 clocks: &mut ClockTree,
2025 ) -> Option<UartBaudRateGeneratorConfig> {
2026 clocks.uart_baud_rate_generator[self as usize]
2027 }
2028 pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
2029 trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
2030 if increment_reference_count(
2031 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
2032 ) {
2033 trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
2034 self.request_function_clock(clocks);
2035 self.enable_baud_rate_generator_impl(clocks, true);
2036 }
2037 }
2038 pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
2039 trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
2040 if decrement_reference_count(
2041 &mut clocks.uart_baud_rate_generator_refcount[self as usize],
2042 ) {
2043 trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
2044 self.enable_baud_rate_generator_impl(clocks, false);
2045 self.release_function_clock(clocks);
2046 }
2047 }
2048 #[allow(unused_variables)]
2049 pub fn baud_rate_generator_config_frequency(
2050 self,
2051 clocks: &mut ClockTree,
2052 config: UartBaudRateGeneratorConfig,
2053 ) -> u32 {
2054 ((self.function_clock_frequency(clocks) * 16)
2055 / ((config.integral() * 16) + config.fractional()))
2056 }
2057 pub fn baud_rate_generator_frequency(self, clocks: &mut ClockTree) -> u32 {
2058 if let Some(config) = clocks.uart_baud_rate_generator[self as usize] {
2059 self.baud_rate_generator_config_frequency(clocks, config)
2060 } else {
2061 0
2062 }
2063 }
2064 }
2065 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2073 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2074 #[instability::unstable]
2075 pub struct ClockConfig {
2076 pub xtal_clk: Option<XtalClkConfig>,
2078 pub hp_root_clk: Option<HpRootClkConfig>,
2080 pub cpu_clk: Option<CpuClkConfig>,
2082 pub ahb_clk: Option<AhbClkConfig>,
2084 pub apb_clk: Option<ApbClkConfig>,
2086 pub lp_fast_clk: Option<LpFastClkConfig>,
2088 pub lp_slow_clk: Option<LpSlowClkConfig>,
2090 pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
2092 }
2093 impl ClockConfig {
2094 fn apply(&self) {
2095 ClockTree::with(|clocks| {
2096 if let Some(config) = self.xtal_clk {
2097 configure_xtal_clk(clocks, config);
2098 }
2099 if let Some(config) = self.hp_root_clk {
2100 configure_hp_root_clk(clocks, config);
2101 }
2102 if let Some(config) = self.cpu_clk {
2103 configure_cpu_clk(clocks, config);
2104 }
2105 if let Some(config) = self.ahb_clk {
2106 configure_ahb_clk(clocks, config);
2107 }
2108 if let Some(config) = self.apb_clk {
2109 configure_apb_clk(clocks, config);
2110 }
2111 if let Some(config) = self.lp_fast_clk {
2112 configure_lp_fast_clk(clocks, config);
2113 }
2114 if let Some(config) = self.lp_slow_clk {
2115 configure_lp_slow_clk(clocks, config);
2116 }
2117 if let Some(config) = self.timg_calibration_clock {
2118 configure_timg_calibration_clock(clocks, config);
2119 }
2120 });
2121 }
2122 }
2123 fn increment_reference_count(refcount: &mut u32) -> bool {
2124 let first = *refcount == 0;
2125 *refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
2126 first
2127 }
2128 fn decrement_reference_count(refcount: &mut u32) -> bool {
2129 *refcount = refcount.saturating_sub(1);
2130 let last = *refcount == 0;
2131 last
2132 }
2133 };
2134}
2135#[macro_export]
2139#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2140macro_rules! implement_peripheral_clocks {
2141 () => {
2142 #[doc(hidden)]
2143 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2144 #[repr(u8)]
2145 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
2146 pub enum Peripheral {
2147 Dma,
2149 Ecc,
2151 I2cExt0,
2153 Sha,
2155 Spi2,
2157 Systimer,
2159 Timg0,
2161 Timg1,
2163 Uart0,
2165 Uart1,
2167 }
2168 impl Peripheral {
2169 const KEEP_ENABLED: &[Peripheral] = &[Self::Systimer, Self::Timg0, Self::Uart0];
2170 const COUNT: usize = Self::ALL.len();
2171 const ALL: &[Self] = &[
2172 Self::Dma,
2173 Self::Ecc,
2174 Self::I2cExt0,
2175 Self::Sha,
2176 Self::Spi2,
2177 Self::Systimer,
2178 Self::Timg0,
2179 Self::Timg1,
2180 Self::Uart0,
2181 Self::Uart1,
2182 ];
2183 }
2184 unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
2185 match peripheral {
2186 Peripheral::Dma => {
2187 crate::peripherals::SYSTEM::regs()
2188 .gdma_conf()
2189 .modify(|_, w| w.gdma_clk_en().bit(enable));
2190 }
2191 Peripheral::Ecc => {
2192 crate::peripherals::SYSTEM::regs()
2193 .ecc_conf()
2194 .modify(|_, w| w.ecc_clk_en().bit(enable));
2195 }
2196 Peripheral::I2cExt0 => {
2197 crate::peripherals::SYSTEM::regs()
2198 .i2c0_conf()
2199 .modify(|_, w| w.i2c0_clk_en().bit(enable));
2200 }
2201 Peripheral::Sha => {
2202 crate::peripherals::SYSTEM::regs()
2203 .sha_conf()
2204 .modify(|_, w| w.sha_clk_en().bit(enable));
2205 }
2206 Peripheral::Spi2 => {
2207 crate::peripherals::SYSTEM::regs()
2208 .spi2_conf()
2209 .modify(|_, w| w.spi2_clk_en().bit(enable));
2210 }
2211 Peripheral::Systimer => {
2212 crate::peripherals::SYSTEM::regs()
2213 .systimer_conf()
2214 .modify(|_, w| w.systimer_clk_en().bit(enable));
2215 }
2216 Peripheral::Timg0 => {
2217 crate::peripherals::SYSTEM::regs()
2218 .timergroup(0)
2219 .conf()
2220 .modify(|_, w| w.clk_en().bit(enable));
2221 }
2222 Peripheral::Timg1 => {
2223 crate::peripherals::SYSTEM::regs()
2224 .timergroup(1)
2225 .conf()
2226 .modify(|_, w| w.clk_en().bit(enable));
2227 }
2228 Peripheral::Uart0 => {
2229 crate::peripherals::SYSTEM::regs()
2230 .uart(0)
2231 .conf()
2232 .modify(|_, w| w.clk_en().bit(enable));
2233 }
2234 Peripheral::Uart1 => {
2235 crate::peripherals::SYSTEM::regs()
2236 .uart(1)
2237 .conf()
2238 .modify(|_, w| w.clk_en().bit(enable));
2239 }
2240 }
2241 }
2242 unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
2243 match peripheral {
2244 Peripheral::Dma => {
2245 crate::peripherals::SYSTEM::regs()
2246 .gdma_conf()
2247 .modify(|_, w| w.gdma_rst_en().bit(reset));
2248 }
2249 Peripheral::Ecc => {
2250 crate::peripherals::SYSTEM::regs()
2251 .ecc_conf()
2252 .modify(|_, w| w.ecc_rst_en().bit(reset));
2253 }
2254 Peripheral::I2cExt0 => {
2255 crate::peripherals::SYSTEM::regs()
2256 .i2c0_conf()
2257 .modify(|_, w| w.i2c0_rst_en().bit(reset));
2258 }
2259 Peripheral::Sha => {
2260 crate::peripherals::SYSTEM::regs()
2261 .sha_conf()
2262 .modify(|_, w| w.sha_rst_en().bit(reset));
2263 }
2264 Peripheral::Spi2 => {
2265 crate::peripherals::SYSTEM::regs()
2266 .spi2_conf()
2267 .modify(|_, w| w.spi2_rst_en().bit(reset));
2268 }
2269 Peripheral::Systimer => {
2270 crate::peripherals::SYSTEM::regs()
2271 .systimer_conf()
2272 .modify(|_, w| w.systimer_rst_en().bit(reset));
2273 }
2274 Peripheral::Timg0 => {
2275 crate::peripherals::SYSTEM::regs()
2276 .timergroup(0)
2277 .conf()
2278 .modify(|_, w| w.rst_en().bit(reset));
2279 }
2280 Peripheral::Timg1 => {
2281 crate::peripherals::SYSTEM::regs()
2282 .timergroup(1)
2283 .conf()
2284 .modify(|_, w| w.rst_en().bit(reset));
2285 }
2286 Peripheral::Uart0 => {
2287 crate::peripherals::SYSTEM::regs()
2288 .uart(0)
2289 .conf()
2290 .modify(|_, w| w.rst_en().bit(reset));
2291 }
2292 Peripheral::Uart1 => {
2293 crate::peripherals::SYSTEM::regs()
2294 .uart(1)
2295 .conf()
2296 .modify(|_, w| w.rst_en().bit(reset));
2297 }
2298 }
2299 }
2300 };
2301}
2302#[macro_export]
2310#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2311macro_rules! memory_range {
2312 ("DRAM") => {
2313 0x40800000..0x40850000
2314 };
2315 (size as str, "DRAM") => {
2316 "327680"
2317 };
2318 ("DRAM2_UNINIT") => {
2319 0x4083EA70..0x4084EA70
2320 };
2321 (size as str, "DRAM2_UNINIT") => {
2322 "65536"
2323 };
2324}
2325#[macro_export]
2342#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2343macro_rules! for_each_i2c_master {
2344 ($($pattern:tt => $code:tt;)*) => {
2345 macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
2346 => {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
2347 I2CEXT0_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
2348 I2CEXT0_SDA)));
2349 };
2350}
2351#[macro_export]
2370#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2371macro_rules! for_each_uart {
2372 ($($pattern:tt => $code:tt;)*) => {
2373 macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
2374 } _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
2375 _for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
2376 _for_each_inner_uart!((all(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (1,
2377 UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS)));
2378 };
2379}
2380#[macro_export]
2402#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2403macro_rules! for_each_spi_master {
2404 ($($pattern:tt => $code:tt;)*) => {
2405 macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
2406 => {} } _for_each_inner_spi_master!((SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1,
2407 FSPICS2, FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true));
2408 _for_each_inner_spi_master!((all(SPI2, Spi2, FSPICLK[FSPICS0, FSPICS1, FSPICS2,
2409 FSPICS3, FSPICS4, FSPICS5] [FSPID, FSPIQ, FSPIWP, FSPIHD], true)));
2410 };
2411}
2412#[macro_export]
2429#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2430macro_rules! for_each_spi_slave {
2431 ($($pattern:tt => $code:tt;)*) => {
2432 macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
2433 => {} } _for_each_inner_spi_slave!((SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0));
2434 _for_each_inner_spi_slave!((all(SPI2, Spi2, FSPICLK, FSPID, FSPIQ, FSPICS0)));
2435 };
2436}
2437#[macro_export]
2438#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
2439macro_rules! for_each_peripheral {
2440 ($($pattern:tt => $code:tt;)*) => {
2441 macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
2442 => {} } _for_each_inner_peripheral!((@ peri_type #[doc =
2443 "GPIO0 peripheral singleton"] GPIO0 <= virtual()));
2444 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO1 peripheral singleton"]
2445 GPIO1 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
2446 "GPIO2 peripheral singleton"] GPIO2 <= virtual()));
2447 _for_each_inner_peripheral!((@ peri_type #[doc =
2448 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2449 "<section class=\"warning\">"] #[doc =
2450 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2451 #[doc = "<ul>"] #[doc =
2452 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2453 =
2454 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2455 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
2456 _for_each_inner_peripheral!((@ peri_type #[doc =
2457 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2458 "<section class=\"warning\">"] #[doc =
2459 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2460 #[doc = "<ul>"] #[doc =
2461 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2462 =
2463 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2464 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()));
2465 _for_each_inner_peripheral!((@ peri_type #[doc =
2466 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2467 "<section class=\"warning\">"] #[doc =
2468 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2469 #[doc = "<ul>"] #[doc =
2470 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2471 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
2472 _for_each_inner_peripheral!((@ peri_type #[doc =
2473 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2474 "<section class=\"warning\">"] #[doc =
2475 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2476 #[doc = "<ul>"] #[doc =
2477 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2478 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
2479 _for_each_inner_peripheral!((@ peri_type #[doc =
2480 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2481 "<section class=\"warning\">"] #[doc =
2482 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2483 #[doc = "<ul>"] #[doc =
2484 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2485 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
2486 _for_each_inner_peripheral!((@ peri_type #[doc =
2487 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2488 "<section class=\"warning\">"] #[doc =
2489 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2490 #[doc = "<ul>"] #[doc =
2491 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2492 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
2493 _for_each_inner_peripheral!((@ peri_type #[doc =
2494 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2495 "<section class=\"warning\">"] #[doc =
2496 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2497 #[doc = "<ul>"] #[doc =
2498 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2499 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
2500 _for_each_inner_peripheral!((@ peri_type #[doc =
2501 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2502 "<section class=\"warning\">"] #[doc =
2503 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2504 #[doc = "<ul>"] #[doc =
2505 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
2506 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
2507 _for_each_inner_peripheral!((@ peri_type #[doc =
2508 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2509 "<section class=\"warning\">"] #[doc =
2510 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2511 #[doc = "<ul>"] #[doc =
2512 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
2513 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
2514 _for_each_inner_peripheral!((@ peri_type #[doc =
2515 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2516 "<section class=\"warning\">"] #[doc =
2517 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2518 #[doc = "<ul>"] #[doc =
2519 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
2520 #[doc = "</section>"] GPIO12 <= virtual())); _for_each_inner_peripheral!((@
2521 peri_type #[doc = "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""]
2522 #[doc = "<section class=\"warning\">"] #[doc =
2523 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2524 #[doc = "<ul>"] #[doc =
2525 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
2526 #[doc = "</section>"] GPIO13 <= virtual())); _for_each_inner_peripheral!((@
2527 peri_type #[doc = "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""]
2528 #[doc = "<section class=\"warning\">"] #[doc =
2529 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2530 #[doc = "<ul>"] #[doc =
2531 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2532 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
2533 _for_each_inner_peripheral!((@ peri_type #[doc =
2534 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2535 "<section class=\"warning\">"] #[doc =
2536 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2537 #[doc = "<ul>"] #[doc =
2538 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2539 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
2540 _for_each_inner_peripheral!((@ peri_type #[doc =
2541 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2542 "<section class=\"warning\">"] #[doc =
2543 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2544 #[doc = "<ul>"] #[doc =
2545 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2546 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
2547 _for_each_inner_peripheral!((@ peri_type #[doc =
2548 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2549 "<section class=\"warning\">"] #[doc =
2550 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2551 #[doc = "<ul>"] #[doc =
2552 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2553 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
2554 _for_each_inner_peripheral!((@ peri_type #[doc =
2555 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2556 "<section class=\"warning\">"] #[doc =
2557 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2558 #[doc = "<ul>"] #[doc =
2559 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2560 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()));
2561 _for_each_inner_peripheral!((@ peri_type #[doc =
2562 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2563 "<section class=\"warning\">"] #[doc =
2564 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2565 #[doc = "<ul>"] #[doc =
2566 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2567 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()));
2568 _for_each_inner_peripheral!((@ peri_type #[doc =
2569 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2570 "<section class=\"warning\">"] #[doc =
2571 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2572 #[doc = "<ul>"] #[doc =
2573 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2574 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
2575 _for_each_inner_peripheral!((@ peri_type #[doc =
2576 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2577 "<section class=\"warning\">"] #[doc =
2578 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2579 #[doc = "<ul>"] #[doc =
2580 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2581 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()));
2582 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO22 peripheral singleton"]
2583 GPIO22 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
2584 "GPIO23 peripheral singleton"] GPIO23 <= virtual()));
2585 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO24 peripheral singleton"]
2586 GPIO24 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
2587 "GPIO25 peripheral singleton"] GPIO25 <= virtual()));
2588 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
2589 GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
2590 "GPIO27 peripheral singleton"] GPIO27 <= virtual()));
2591 _for_each_inner_peripheral!((@ peri_type #[doc = "GPIO28 peripheral singleton"]
2592 GPIO28 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
2593 "GPIO29 peripheral singleton"] GPIO29 <= virtual()));
2594 _for_each_inner_peripheral!((@ peri_type #[doc =
2595 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)));
2596 _for_each_inner_peripheral!((@ peri_type #[doc = "CLINT peripheral singleton"]
2597 CLINT <= CLINT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2598 "CACHE peripheral singleton"] CACHE <= CACHE() (unstable)));
2599 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA peripheral singleton"] DMA
2600 <= DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2601 "ECC peripheral singleton"] ECC <= ECC() (unstable)));
2602 _for_each_inner_peripheral!((@ peri_type #[doc = "ECDSA peripheral singleton"]
2603 ECDSA <= ECDSA() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2604 "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
2605 _for_each_inner_peripheral!((@ peri_type #[doc = "ETM peripheral singleton"] ETM
2606 <= SOC_ETM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2607 "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)));
2608 _for_each_inner_peripheral!((@ peri_type #[doc = "HP_APM peripheral singleton"]
2609 HP_APM <= HP_APM() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2610 "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS() (unstable)));
2611 _for_each_inner_peripheral!((@ peri_type #[doc =
2612 "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST <= I2C_ANA_MST() (unstable)));
2613 _for_each_inner_peripheral!((@ peri_type #[doc = "I2C0 peripheral singleton"]
2614 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
2615 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
2616 "I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
2617 enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
2618 _for_each_inner_peripheral!((@ peri_type #[doc =
2619 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
2620 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2621 "INTPRI peripheral singleton"] INTPRI <= INTPRI() (unstable)));
2622 _for_each_inner_peripheral!((@ peri_type #[doc = "IO_MUX peripheral singleton"]
2623 IO_MUX <= IO_MUX() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2624 "LP_ANA peripheral singleton"] LP_ANA <= LP_ANA() (unstable)));
2625 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_AON peripheral singleton"]
2626 LP_AON <= LP_AON() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2627 "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)));
2628 _for_each_inner_peripheral!((@ peri_type #[doc =
2629 "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)));
2630 _for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
2631 LPWR <= LP_CLKRST() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
2632 = "LP_IO_MUX peripheral singleton"] LP_IO_MUX <= LP_IO_MUX() (unstable)));
2633 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_PERI peripheral singleton"]
2634 LP_PERI <= LPPERI() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
2635 = "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)));
2636 _for_each_inner_peripheral!((@ peri_type #[doc = "LP_TIMER peripheral singleton"]
2637 LP_TIMER <= LP_TIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
2638 #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)));
2639 _for_each_inner_peripheral!((@ peri_type #[doc =
2640 "MEM_MONITOR peripheral singleton"] MEM_MONITOR <= MEM_MONITOR() (unstable)));
2641 _for_each_inner_peripheral!((@ peri_type #[doc =
2642 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)));
2643 _for_each_inner_peripheral!((@ peri_type #[doc =
2644 "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <= MODEM_SYSCON() (unstable)));
2645 _for_each_inner_peripheral!((@ peri_type #[doc = "PAU peripheral singleton"] PAU
2646 <= PAU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2647 "PCR peripheral singleton"] PCR <= PCR() (unstable)));
2648 _for_each_inner_peripheral!((@ peri_type #[doc = "PMU peripheral singleton"] PMU
2649 <= PMU() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2650 "RNG peripheral singleton"] RNG <= RNG() (unstable)));
2651 _for_each_inner_peripheral!((@ peri_type #[doc = "SHA peripheral singleton"] SHA
2652 <= SHA(SHA : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
2653 }) (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2654 "SLC peripheral singleton"] SLC <= SLC() (unstable)));
2655 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
2656 SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2657 "SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
2658 _for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
2659 SPI2 <= SPI2(SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
2660 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
2661 "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)));
2662 _for_each_inner_peripheral!((@ peri_type #[doc = "SYSTIMER peripheral singleton"]
2663 SYSTIMER <= SYSTIMER() (unstable))); _for_each_inner_peripheral!((@ peri_type
2664 #[doc = "TEE peripheral singleton"] TEE <= TEE() (unstable)));
2665 _for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
2666 TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2667 "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
2668 _for_each_inner_peripheral!((@ peri_type #[doc = "UART0 peripheral singleton"]
2669 UART0 <= UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
2670 disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
2671 "UART1 peripheral singleton"] UART1 <= UART1(UART1 : { bind_peri_interrupt,
2672 enable_peri_interrupt, disable_peri_interrupt })));
2673 _for_each_inner_peripheral!((@ peri_type #[doc =
2674 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
2675 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
2676 (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2677 "DMA_CH0 peripheral singleton"] DMA_CH0 <= virtual() (unstable)));
2678 _for_each_inner_peripheral!((@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
2679 DMA_CH1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc
2680 = "BT peripheral singleton"] BT <= virtual(LP_TIMER : { bind_lp_timer_interrupt,
2681 enable_lp_timer_interrupt, disable_lp_timer_interrupt }, BT_MAC : {
2682 bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt }) (unstable)));
2683 _for_each_inner_peripheral!((@ peri_type #[doc = "FLASH peripheral singleton"]
2684 FLASH <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
2685 "LP_CORE peripheral singleton"] LP_CORE <= virtual() (unstable)));
2686 _for_each_inner_peripheral!((@ peri_type #[doc =
2687 "SW_INTERRUPT peripheral singleton"] SW_INTERRUPT <= virtual() (unstable)));
2688 _for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
2689 WIFI <= virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt,
2690 disable_bb_interrupt }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
2691 disable_mac_interrupt }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt,
2692 disable_pwr_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
2693 "MEM2MEM0 peripheral singleton"] MEM2MEM0 <= virtual() (unstable)));
2694 _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM1 peripheral singleton"]
2695 MEM2MEM1 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
2696 #[doc = "MEM2MEM2 peripheral singleton"] MEM2MEM2 <= virtual() (unstable)));
2697 _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM3 peripheral singleton"]
2698 MEM2MEM3 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
2699 #[doc = "MEM2MEM4 peripheral singleton"] MEM2MEM4 <= virtual() (unstable)));
2700 _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM5 peripheral singleton"]
2701 MEM2MEM5 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
2702 #[doc = "MEM2MEM6 peripheral singleton"] MEM2MEM6 <= virtual() (unstable)));
2703 _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM7 peripheral singleton"]
2704 MEM2MEM7 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
2705 #[doc = "MEM2MEM8 peripheral singleton"] MEM2MEM8 <= virtual() (unstable)));
2706 _for_each_inner_peripheral!((@ peri_type #[doc = "MEM2MEM9 peripheral singleton"]
2707 MEM2MEM9 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
2708 #[doc = "MEM2MEM10 peripheral singleton"] MEM2MEM10 <= virtual() (unstable)));
2709 _for_each_inner_peripheral!((@ peri_type #[doc =
2710 "MEM2MEM11 peripheral singleton"] MEM2MEM11 <= virtual() (unstable)));
2711 _for_each_inner_peripheral!((@ peri_type #[doc = "PSRAM peripheral singleton"]
2712 PSRAM <= virtual() (unstable))); _for_each_inner_peripheral!((GPIO0));
2713 _for_each_inner_peripheral!((GPIO1)); _for_each_inner_peripheral!((GPIO2));
2714 _for_each_inner_peripheral!((GPIO3)); _for_each_inner_peripheral!((GPIO4));
2715 _for_each_inner_peripheral!((GPIO5)); _for_each_inner_peripheral!((GPIO6));
2716 _for_each_inner_peripheral!((GPIO7)); _for_each_inner_peripheral!((GPIO8));
2717 _for_each_inner_peripheral!((GPIO9)); _for_each_inner_peripheral!((GPIO10));
2718 _for_each_inner_peripheral!((GPIO11)); _for_each_inner_peripheral!((GPIO12));
2719 _for_each_inner_peripheral!((GPIO13)); _for_each_inner_peripheral!((GPIO14));
2720 _for_each_inner_peripheral!((GPIO15)); _for_each_inner_peripheral!((GPIO16));
2721 _for_each_inner_peripheral!((GPIO17)); _for_each_inner_peripheral!((GPIO18));
2722 _for_each_inner_peripheral!((GPIO19)); _for_each_inner_peripheral!((GPIO20));
2723 _for_each_inner_peripheral!((GPIO21)); _for_each_inner_peripheral!((GPIO22));
2724 _for_each_inner_peripheral!((GPIO23)); _for_each_inner_peripheral!((GPIO24));
2725 _for_each_inner_peripheral!((GPIO25)); _for_each_inner_peripheral!((GPIO26));
2726 _for_each_inner_peripheral!((GPIO27)); _for_each_inner_peripheral!((GPIO28));
2727 _for_each_inner_peripheral!((GPIO29));
2728 _for_each_inner_peripheral!((ASSIST_DEBUG(unstable)));
2729 _for_each_inner_peripheral!((CLINT(unstable)));
2730 _for_each_inner_peripheral!((CACHE(unstable)));
2731 _for_each_inner_peripheral!((DMA(unstable)));
2732 _for_each_inner_peripheral!((ECC(unstable)));
2733 _for_each_inner_peripheral!((ECDSA(unstable)));
2734 _for_each_inner_peripheral!((EFUSE(unstable)));
2735 _for_each_inner_peripheral!((ETM(unstable)));
2736 _for_each_inner_peripheral!((GPIO(unstable)));
2737 _for_each_inner_peripheral!((HP_APM(unstable)));
2738 _for_each_inner_peripheral!((HP_SYS(unstable)));
2739 _for_each_inner_peripheral!((I2C_ANA_MST(unstable)));
2740 _for_each_inner_peripheral!((I2C0));
2741 _for_each_inner_peripheral!((I2S0(unstable)));
2742 _for_each_inner_peripheral!((INTERRUPT_CORE0(unstable)));
2743 _for_each_inner_peripheral!((INTPRI(unstable)));
2744 _for_each_inner_peripheral!((IO_MUX(unstable)));
2745 _for_each_inner_peripheral!((LP_ANA(unstable)));
2746 _for_each_inner_peripheral!((LP_AON(unstable)));
2747 _for_each_inner_peripheral!((LP_APM(unstable)));
2748 _for_each_inner_peripheral!((LP_CLKRST(unstable)));
2749 _for_each_inner_peripheral!((LPWR(unstable)));
2750 _for_each_inner_peripheral!((LP_IO_MUX(unstable)));
2751 _for_each_inner_peripheral!((LP_PERI(unstable)));
2752 _for_each_inner_peripheral!((LP_TEE(unstable)));
2753 _for_each_inner_peripheral!((LP_TIMER(unstable)));
2754 _for_each_inner_peripheral!((LP_WDT(unstable)));
2755 _for_each_inner_peripheral!((MEM_MONITOR(unstable)));
2756 _for_each_inner_peripheral!((MODEM_LPCON(unstable)));
2757 _for_each_inner_peripheral!((MODEM_SYSCON(unstable)));
2758 _for_each_inner_peripheral!((PAU(unstable)));
2759 _for_each_inner_peripheral!((PCR(unstable)));
2760 _for_each_inner_peripheral!((PMU(unstable)));
2761 _for_each_inner_peripheral!((RNG(unstable)));
2762 _for_each_inner_peripheral!((SHA(unstable)));
2763 _for_each_inner_peripheral!((SLC(unstable)));
2764 _for_each_inner_peripheral!((SPI0(unstable)));
2765 _for_each_inner_peripheral!((SPI1(unstable)));
2766 _for_each_inner_peripheral!((SPI2));
2767 _for_each_inner_peripheral!((SYSTEM(unstable)));
2768 _for_each_inner_peripheral!((SYSTIMER(unstable)));
2769 _for_each_inner_peripheral!((TEE(unstable)));
2770 _for_each_inner_peripheral!((TIMG0(unstable)));
2771 _for_each_inner_peripheral!((TIMG1(unstable)));
2772 _for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
2773 _for_each_inner_peripheral!((USB_DEVICE(unstable)));
2774 _for_each_inner_peripheral!((DMA_CH0(unstable)));
2775 _for_each_inner_peripheral!((DMA_CH1(unstable)));
2776 _for_each_inner_peripheral!((BT(unstable)));
2777 _for_each_inner_peripheral!((FLASH(unstable)));
2778 _for_each_inner_peripheral!((LP_CORE(unstable)));
2779 _for_each_inner_peripheral!((SW_INTERRUPT(unstable)));
2780 _for_each_inner_peripheral!((WIFI));
2781 _for_each_inner_peripheral!((MEM2MEM0(unstable)));
2782 _for_each_inner_peripheral!((MEM2MEM1(unstable)));
2783 _for_each_inner_peripheral!((MEM2MEM2(unstable)));
2784 _for_each_inner_peripheral!((MEM2MEM3(unstable)));
2785 _for_each_inner_peripheral!((MEM2MEM4(unstable)));
2786 _for_each_inner_peripheral!((MEM2MEM5(unstable)));
2787 _for_each_inner_peripheral!((MEM2MEM6(unstable)));
2788 _for_each_inner_peripheral!((MEM2MEM7(unstable)));
2789 _for_each_inner_peripheral!((MEM2MEM8(unstable)));
2790 _for_each_inner_peripheral!((MEM2MEM9(unstable)));
2791 _for_each_inner_peripheral!((MEM2MEM10(unstable)));
2792 _for_each_inner_peripheral!((MEM2MEM11(unstable)));
2793 _for_each_inner_peripheral!((PSRAM(unstable)));
2794 _for_each_inner_peripheral!((MEM2MEM0, Mem2mem0, 0));
2795 _for_each_inner_peripheral!((SPI2, Spi2, 1));
2796 _for_each_inner_peripheral!((MEM2MEM1, Mem2mem1, 2));
2797 _for_each_inner_peripheral!((I2S0, I2s0, 3));
2798 _for_each_inner_peripheral!((MEM2MEM2, Mem2mem2, 4));
2799 _for_each_inner_peripheral!((MEM2MEM3, Mem2mem3, 5));
2800 _for_each_inner_peripheral!((MEM2MEM4, Mem2mem4, 6));
2801 _for_each_inner_peripheral!((SHA, Sha, 7));
2802 _for_each_inner_peripheral!((MEM2MEM5, Mem2mem5, 9));
2803 _for_each_inner_peripheral!((MEM2MEM6, Mem2mem6, 10));
2804 _for_each_inner_peripheral!((MEM2MEM7, Mem2mem7, 11));
2805 _for_each_inner_peripheral!((MEM2MEM8, Mem2mem8, 12));
2806 _for_each_inner_peripheral!((MEM2MEM9, Mem2mem9, 13));
2807 _for_each_inner_peripheral!((MEM2MEM10, Mem2mem10, 14));
2808 _for_each_inner_peripheral!((MEM2MEM11, Mem2mem11, 15));
2809 _for_each_inner_peripheral!((all(@ peri_type #[doc =
2810 "GPIO0 peripheral singleton"] GPIO0 <= virtual()), (@ peri_type #[doc =
2811 "GPIO1 peripheral singleton"] GPIO1 <= virtual()), (@ peri_type #[doc =
2812 "GPIO2 peripheral singleton"] GPIO2 <= virtual()), (@ peri_type #[doc =
2813 "GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2814 "<section class=\"warning\">"] #[doc =
2815 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2816 #[doc = "<ul>"] #[doc =
2817 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2818 =
2819 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2820 #[doc = "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
2821 "GPIO4 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2822 "<section class=\"warning\">"] #[doc =
2823 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2824 #[doc = "<ul>"] #[doc =
2825 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2826 =
2827 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2828 #[doc = "</ul>"] #[doc = "</section>"] GPIO4 <= virtual()), (@ peri_type #[doc =
2829 "GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2830 "<section class=\"warning\">"] #[doc =
2831 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2832 #[doc = "<ul>"] #[doc =
2833 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2834 #[doc = "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
2835 "GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2836 "<section class=\"warning\">"] #[doc =
2837 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2838 #[doc = "<ul>"] #[doc =
2839 "<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
2840 #[doc = "</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
2841 "GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2842 "<section class=\"warning\">"] #[doc =
2843 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2844 #[doc = "<ul>"] #[doc =
2845 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2846 = "</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
2847 "GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2848 "<section class=\"warning\">"] #[doc =
2849 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2850 #[doc = "<ul>"] #[doc =
2851 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2852 = "</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
2853 "GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2854 "<section class=\"warning\">"] #[doc =
2855 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2856 #[doc = "<ul>"] #[doc =
2857 "<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
2858 = "</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
2859 "GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2860 "<section class=\"warning\">"] #[doc =
2861 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2862 #[doc = "<ul>"] #[doc =
2863 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
2864 = "</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
2865 "GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2866 "<section class=\"warning\">"] #[doc =
2867 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2868 #[doc = "<ul>"] #[doc =
2869 "<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
2870 = "</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
2871 "GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2872 "<section class=\"warning\">"] #[doc =
2873 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2874 #[doc = "<ul>"] #[doc =
2875 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
2876 #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
2877 "GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2878 "<section class=\"warning\">"] #[doc =
2879 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2880 #[doc = "<ul>"] #[doc =
2881 "<li>These pins may be used to debug the chip using USB.</li>"] #[doc = "</ul>"]
2882 #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
2883 "GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2884 "<section class=\"warning\">"] #[doc =
2885 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2886 #[doc = "<ul>"] #[doc =
2887 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2888 "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
2889 "GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2890 "<section class=\"warning\">"] #[doc =
2891 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2892 #[doc = "<ul>"] #[doc =
2893 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2894 "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
2895 "GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2896 "<section class=\"warning\">"] #[doc =
2897 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2898 #[doc = "<ul>"] #[doc =
2899 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2900 "</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
2901 "GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2902 "<section class=\"warning\">"] #[doc =
2903 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2904 #[doc = "<ul>"] #[doc =
2905 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2906 "</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
2907 "GPIO18 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2908 "<section class=\"warning\">"] #[doc =
2909 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2910 #[doc = "<ul>"] #[doc =
2911 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2912 "</ul>"] #[doc = "</section>"] GPIO18 <= virtual()), (@ peri_type #[doc =
2913 "GPIO19 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2914 "<section class=\"warning\">"] #[doc =
2915 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2916 #[doc = "<ul>"] #[doc =
2917 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2918 "</ul>"] #[doc = "</section>"] GPIO19 <= virtual()), (@ peri_type #[doc =
2919 "GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2920 "<section class=\"warning\">"] #[doc =
2921 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2922 #[doc = "<ul>"] #[doc =
2923 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2924 "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
2925 "GPIO21 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
2926 "<section class=\"warning\">"] #[doc =
2927 "This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
2928 #[doc = "<ul>"] #[doc =
2929 "<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
2930 "</ul>"] #[doc = "</section>"] GPIO21 <= virtual()), (@ peri_type #[doc =
2931 "GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
2932 "GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
2933 "GPIO24 peripheral singleton"] GPIO24 <= virtual()), (@ peri_type #[doc =
2934 "GPIO25 peripheral singleton"] GPIO25 <= virtual()), (@ peri_type #[doc =
2935 "GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
2936 "GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
2937 "GPIO28 peripheral singleton"] GPIO28 <= virtual()), (@ peri_type #[doc =
2938 "GPIO29 peripheral singleton"] GPIO29 <= virtual()), (@ peri_type #[doc =
2939 "ASSIST_DEBUG peripheral singleton"] ASSIST_DEBUG <= ASSIST_DEBUG() (unstable)),
2940 (@ peri_type #[doc = "CLINT peripheral singleton"] CLINT <= CLINT() (unstable)),
2941 (@ peri_type #[doc = "CACHE peripheral singleton"] CACHE <= CACHE() (unstable)),
2942 (@ peri_type #[doc = "DMA peripheral singleton"] DMA <= DMA() (unstable)), (@
2943 peri_type #[doc = "ECC peripheral singleton"] ECC <= ECC() (unstable)), (@
2944 peri_type #[doc = "ECDSA peripheral singleton"] ECDSA <= ECDSA() (unstable)), (@
2945 peri_type #[doc = "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@
2946 peri_type #[doc = "ETM peripheral singleton"] ETM <= SOC_ETM() (unstable)), (@
2947 peri_type #[doc = "GPIO peripheral singleton"] GPIO <= GPIO() (unstable)), (@
2948 peri_type #[doc = "HP_APM peripheral singleton"] HP_APM <= HP_APM() (unstable)),
2949 (@ peri_type #[doc = "HP_SYS peripheral singleton"] HP_SYS <= HP_SYS()
2950 (unstable)), (@ peri_type #[doc = "I2C_ANA_MST peripheral singleton"] I2C_ANA_MST
2951 <= I2C_ANA_MST() (unstable)), (@ peri_type #[doc = "I2C0 peripheral singleton"]
2952 I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt, enable_peri_interrupt,
2953 disable_peri_interrupt })), (@ peri_type #[doc = "I2S0 peripheral singleton"]
2954 I2S0 <= I2S0(I2S0 : { bind_peri_interrupt, enable_peri_interrupt,
2955 disable_peri_interrupt }) (unstable)), (@ peri_type #[doc =
2956 "INTERRUPT_CORE0 peripheral singleton"] INTERRUPT_CORE0 <= INTERRUPT_CORE0()
2957 (unstable)), (@ peri_type #[doc = "INTPRI peripheral singleton"] INTPRI <=
2958 INTPRI() (unstable)), (@ peri_type #[doc = "IO_MUX peripheral singleton"] IO_MUX
2959 <= IO_MUX() (unstable)), (@ peri_type #[doc = "LP_ANA peripheral singleton"]
2960 LP_ANA <= LP_ANA() (unstable)), (@ peri_type #[doc =
2961 "LP_AON peripheral singleton"] LP_AON <= LP_AON() (unstable)), (@ peri_type #[doc
2962 = "LP_APM peripheral singleton"] LP_APM <= LP_APM() (unstable)), (@ peri_type
2963 #[doc = "LP_CLKRST peripheral singleton"] LP_CLKRST <= LP_CLKRST() (unstable)),
2964 (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= LP_CLKRST()
2965 (unstable)), (@ peri_type #[doc = "LP_IO_MUX peripheral singleton"] LP_IO_MUX <=
2966 LP_IO_MUX() (unstable)), (@ peri_type #[doc = "LP_PERI peripheral singleton"]
2967 LP_PERI <= LPPERI() (unstable)), (@ peri_type #[doc =
2968 "LP_TEE peripheral singleton"] LP_TEE <= LP_TEE() (unstable)), (@ peri_type #[doc
2969 = "LP_TIMER peripheral singleton"] LP_TIMER <= LP_TIMER() (unstable)), (@
2970 peri_type #[doc = "LP_WDT peripheral singleton"] LP_WDT <= LP_WDT() (unstable)),
2971 (@ peri_type #[doc = "MEM_MONITOR peripheral singleton"] MEM_MONITOR <=
2972 MEM_MONITOR() (unstable)), (@ peri_type #[doc =
2973 "MODEM_LPCON peripheral singleton"] MODEM_LPCON <= MODEM_LPCON() (unstable)), (@
2974 peri_type #[doc = "MODEM_SYSCON peripheral singleton"] MODEM_SYSCON <=
2975 MODEM_SYSCON() (unstable)), (@ peri_type #[doc = "PAU peripheral singleton"] PAU
2976 <= PAU() (unstable)), (@ peri_type #[doc = "PCR peripheral singleton"] PCR <=
2977 PCR() (unstable)), (@ peri_type #[doc = "PMU peripheral singleton"] PMU <= PMU()
2978 (unstable)), (@ peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG()
2979 (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA <= SHA(SHA : {
2980 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
2981 (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <= SLC()
2982 (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0 <= SPI0()
2983 (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <= SPI1()
2984 (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <= SPI2(SPI2
2985 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
2986 peri_type #[doc = "SYSTEM peripheral singleton"] SYSTEM <= PCR() (unstable)), (@
2987 peri_type #[doc = "SYSTIMER peripheral singleton"] SYSTIMER <= SYSTIMER()
2988 (unstable)), (@ peri_type #[doc = "TEE peripheral singleton"] TEE <= TEE()
2989 (unstable)), (@ peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0()
2990 (unstable)), (@ peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1()
2991 (unstable)), (@ peri_type #[doc = "UART0 peripheral singleton"] UART0 <=
2992 UART0(UART0 : { bind_peri_interrupt, enable_peri_interrupt,
2993 disable_peri_interrupt })), (@ peri_type #[doc = "UART1 peripheral singleton"]
2994 UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
2995 disable_peri_interrupt })), (@ peri_type #[doc =
2996 "USB_DEVICE peripheral singleton"] USB_DEVICE <= USB_DEVICE(USB_DEVICE : {
2997 bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
2998 (unstable)), (@ peri_type #[doc = "DMA_CH0 peripheral singleton"] DMA_CH0 <=
2999 virtual() (unstable)), (@ peri_type #[doc = "DMA_CH1 peripheral singleton"]
3000 DMA_CH1 <= virtual() (unstable)), (@ peri_type #[doc = "BT peripheral singleton"]
3001 BT <= virtual(LP_TIMER : { bind_lp_timer_interrupt, enable_lp_timer_interrupt,
3002 disable_lp_timer_interrupt }, BT_MAC : { bind_mac_interrupt,
3003 enable_mac_interrupt, disable_mac_interrupt }) (unstable)), (@ peri_type #[doc =
3004 "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@ peri_type #[doc
3005 = "LP_CORE peripheral singleton"] LP_CORE <= virtual() (unstable)), (@ peri_type
3006 #[doc = "SW_INTERRUPT peripheral singleton"] SW_INTERRUPT <= virtual()
3007 (unstable)), (@ peri_type #[doc = "WIFI peripheral singleton"] WIFI <=
3008 virtual(WIFI_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt
3009 }, WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt
3010 }, WIFI_PWR : { bind_pwr_interrupt, enable_pwr_interrupt, disable_pwr_interrupt
3011 })), (@ peri_type #[doc = "MEM2MEM0 peripheral singleton"] MEM2MEM0 <= virtual()
3012 (unstable)), (@ peri_type #[doc = "MEM2MEM1 peripheral singleton"] MEM2MEM1 <=
3013 virtual() (unstable)), (@ peri_type #[doc = "MEM2MEM2 peripheral singleton"]
3014 MEM2MEM2 <= virtual() (unstable)), (@ peri_type #[doc =
3015 "MEM2MEM3 peripheral singleton"] MEM2MEM3 <= virtual() (unstable)), (@ peri_type
3016 #[doc = "MEM2MEM4 peripheral singleton"] MEM2MEM4 <= virtual() (unstable)), (@
3017 peri_type #[doc = "MEM2MEM5 peripheral singleton"] MEM2MEM5 <= virtual()
3018 (unstable)), (@ peri_type #[doc = "MEM2MEM6 peripheral singleton"] MEM2MEM6 <=
3019 virtual() (unstable)), (@ peri_type #[doc = "MEM2MEM7 peripheral singleton"]
3020 MEM2MEM7 <= virtual() (unstable)), (@ peri_type #[doc =
3021 "MEM2MEM8 peripheral singleton"] MEM2MEM8 <= virtual() (unstable)), (@ peri_type
3022 #[doc = "MEM2MEM9 peripheral singleton"] MEM2MEM9 <= virtual() (unstable)), (@
3023 peri_type #[doc = "MEM2MEM10 peripheral singleton"] MEM2MEM10 <= virtual()
3024 (unstable)), (@ peri_type #[doc = "MEM2MEM11 peripheral singleton"] MEM2MEM11 <=
3025 virtual() (unstable)), (@ peri_type #[doc = "PSRAM peripheral singleton"] PSRAM
3026 <= virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0),
3027 (GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9),
3028 (GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO15), (GPIO16), (GPIO17),
3029 (GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22), (GPIO23), (GPIO24), (GPIO25),
3030 (GPIO26), (GPIO27), (GPIO28), (GPIO29), (ASSIST_DEBUG(unstable)),
3031 (CLINT(unstable)), (CACHE(unstable)), (DMA(unstable)), (ECC(unstable)),
3032 (ECDSA(unstable)), (EFUSE(unstable)), (ETM(unstable)), (GPIO(unstable)),
3033 (HP_APM(unstable)), (HP_SYS(unstable)), (I2C_ANA_MST(unstable)), (I2C0),
3034 (I2S0(unstable)), (INTERRUPT_CORE0(unstable)), (INTPRI(unstable)),
3035 (IO_MUX(unstable)), (LP_ANA(unstable)), (LP_AON(unstable)), (LP_APM(unstable)),
3036 (LP_CLKRST(unstable)), (LPWR(unstable)), (LP_IO_MUX(unstable)),
3037 (LP_PERI(unstable)), (LP_TEE(unstable)), (LP_TIMER(unstable)),
3038 (LP_WDT(unstable)), (MEM_MONITOR(unstable)), (MODEM_LPCON(unstable)),
3039 (MODEM_SYSCON(unstable)), (PAU(unstable)), (PCR(unstable)), (PMU(unstable)),
3040 (RNG(unstable)), (SHA(unstable)), (SLC(unstable)), (SPI0(unstable)),
3041 (SPI1(unstable)), (SPI2), (SYSTEM(unstable)), (SYSTIMER(unstable)),
3042 (TEE(unstable)), (TIMG0(unstable)), (TIMG1(unstable)), (UART0), (UART1),
3043 (USB_DEVICE(unstable)), (DMA_CH0(unstable)), (DMA_CH1(unstable)), (BT(unstable)),
3044 (FLASH(unstable)), (LP_CORE(unstable)), (SW_INTERRUPT(unstable)), (WIFI),
3045 (MEM2MEM0(unstable)), (MEM2MEM1(unstable)), (MEM2MEM2(unstable)),
3046 (MEM2MEM3(unstable)), (MEM2MEM4(unstable)), (MEM2MEM5(unstable)),
3047 (MEM2MEM6(unstable)), (MEM2MEM7(unstable)), (MEM2MEM8(unstable)),
3048 (MEM2MEM9(unstable)), (MEM2MEM10(unstable)), (MEM2MEM11(unstable)),
3049 (PSRAM(unstable)))); _for_each_inner_peripheral!((dma_eligible(MEM2MEM0,
3050 Mem2mem0, 0), (SPI2, Spi2, 1), (MEM2MEM1, Mem2mem1, 2), (I2S0, I2s0, 3),
3051 (MEM2MEM2, Mem2mem2, 4), (MEM2MEM3, Mem2mem3, 5), (MEM2MEM4, Mem2mem4, 6), (SHA,
3052 Sha, 7), (MEM2MEM5, Mem2mem5, 9), (MEM2MEM6, Mem2mem6, 10), (MEM2MEM7, Mem2mem7,
3053 11), (MEM2MEM8, Mem2mem8, 12), (MEM2MEM9, Mem2mem9, 13), (MEM2MEM10, Mem2mem10,
3054 14), (MEM2MEM11, Mem2mem11, 15)));
3055 };
3056}
3057#[macro_export]
3084#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3085macro_rules! for_each_gpio {
3086 ($($pattern:tt => $code:tt;)*) => {
3087 macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
3088 } _for_each_inner_gpio!((0, GPIO0() () ([Input] [Output])));
3089 _for_each_inner_gpio!((1, GPIO1() () ([Input] [Output])));
3090 _for_each_inner_gpio!((2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input] [Output])));
3091 _for_each_inner_gpio!((3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
3092 [Output]))); _for_each_inner_gpio!((4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 =>
3093 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((5, GPIO5(_0 => MTCK) ()
3094 ([Input] [Output]))); _for_each_inner_gpio!((6, GPIO6(_0 => MTDO _2 => FSPICLK)
3095 (_2 => FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((7, GPIO7(_2 =>
3096 FSPID) (_2 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((8, GPIO8(_2 =>
3097 FSPICS0) (_2 => FSPICS0) ([Input] [Output]))); _for_each_inner_gpio!((9, GPIO9()
3098 () ([Input] [Output]))); _for_each_inner_gpio!((10, GPIO10(_0 => U0RXD) ()
3099 ([Input] [Output]))); _for_each_inner_gpio!((11, GPIO11() (_0 => U0TXD) ([Input]
3100 [Output]))); _for_each_inner_gpio!((12, GPIO12() () ([Input] [Output])));
3101 _for_each_inner_gpio!((13, GPIO13() () ([Input] [Output])));
3102 _for_each_inner_gpio!((14, GPIO14() (_0 => FSPICS1) ([Input] [Output])));
3103 _for_each_inner_gpio!((15, GPIO15(_0 => FSPICS0) (_0 => FSPICS0) ([Input]
3104 [Output]))); _for_each_inner_gpio!((16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ)
3105 ([Input] [Output]))); _for_each_inner_gpio!((17, GPIO17(_0 => FSPIWP) (_0 =>
3106 FSPIWP) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18() () ([Input]
3107 [Output]))); _for_each_inner_gpio!((19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
3108 ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20(_0 => FSPICLK) (_0 =>
3109 FSPICLK) ([Input] [Output]))); _for_each_inner_gpio!((21, GPIO21(_0 => FSPID) (_0
3110 => FSPID) ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22(_0 =>
3111 SDIO_DATA2) () ([Input] [Output]))); _for_each_inner_gpio!((23, GPIO23(_0 =>
3112 SDIO_DATA3) () ([Input] [Output]))); _for_each_inner_gpio!((24, GPIO24() ()
3113 ([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_0 => SDIO_CMD) ()
3114 ([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_0 => SDIO_CLK) ()
3115 ([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27(_0 => SDIO_DATA0) ()
3116 ([Input] [Output]))); _for_each_inner_gpio!((28, GPIO28(_0 => SDIO_DATA1) ()
3117 ([Input] [Output]))); _for_each_inner_gpio!((29, GPIO29() () ([Input]
3118 [Output]))); _for_each_inner_gpio!((all(0, GPIO0() () ([Input] [Output])), (1,
3119 GPIO1() () ([Input] [Output])), (2, GPIO2(_2 => FSPIQ) (_2 => FSPIQ) ([Input]
3120 [Output])), (3, GPIO3(_0 => MTMS _2 => FSPIHD) (_2 => FSPIHD) ([Input]
3121 [Output])), (4, GPIO4(_0 => MTDI _2 => FSPIWP) (_2 => FSPIWP) ([Input]
3122 [Output])), (5, GPIO5(_0 => MTCK) () ([Input] [Output])), (6, GPIO6(_0 => MTDO _2
3123 => FSPICLK) (_2 => FSPICLK) ([Input] [Output])), (7, GPIO7(_2 => FSPID) (_2 =>
3124 FSPID) ([Input] [Output])), (8, GPIO8(_2 => FSPICS0) (_2 => FSPICS0) ([Input]
3125 [Output])), (9, GPIO9() () ([Input] [Output])), (10, GPIO10(_0 => U0RXD) ()
3126 ([Input] [Output])), (11, GPIO11() (_0 => U0TXD) ([Input] [Output])), (12,
3127 GPIO12() () ([Input] [Output])), (13, GPIO13() () ([Input] [Output])), (14,
3128 GPIO14() (_0 => FSPICS1) ([Input] [Output])), (15, GPIO15(_0 => FSPICS0) (_0 =>
3129 FSPICS0) ([Input] [Output])), (16, GPIO16(_0 => FSPIQ) (_0 => FSPIQ) ([Input]
3130 [Output])), (17, GPIO17(_0 => FSPIWP) (_0 => FSPIWP) ([Input] [Output])), (18,
3131 GPIO18() () ([Input] [Output])), (19, GPIO19(_0 => FSPIHD) (_0 => FSPIHD)
3132 ([Input] [Output])), (20, GPIO20(_0 => FSPICLK) (_0 => FSPICLK) ([Input]
3133 [Output])), (21, GPIO21(_0 => FSPID) (_0 => FSPID) ([Input] [Output])), (22,
3134 GPIO22(_0 => SDIO_DATA2) () ([Input] [Output])), (23, GPIO23(_0 => SDIO_DATA3) ()
3135 ([Input] [Output])), (24, GPIO24() () ([Input] [Output])), (25, GPIO25(_0 =>
3136 SDIO_CMD) () ([Input] [Output])), (26, GPIO26(_0 => SDIO_CLK) () ([Input]
3137 [Output])), (27, GPIO27(_0 => SDIO_DATA0) () ([Input] [Output])), (28, GPIO28(_0
3138 => SDIO_DATA1) () ([Input] [Output])), (29, GPIO29() () ([Input] [Output]))));
3139 };
3140}
3141#[macro_export]
3168#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3169macro_rules! for_each_analog_function {
3170 ($($pattern:tt => $code:tt;)*) => {
3171 macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
3172 tt) => {} } _for_each_inner_analog_function!((XTAL_32K_P, GPIO0));
3173 _for_each_inner_analog_function!((XTAL_32K_N, GPIO1));
3174 _for_each_inner_analog_function!((ZCD0, GPIO8));
3175 _for_each_inner_analog_function!((ZCD1, GPIO9));
3176 _for_each_inner_analog_function!((USB_DM, GPIO12));
3177 _for_each_inner_analog_function!((USB_DP, GPIO13));
3178 _for_each_inner_analog_function!(((ZCD0, ZCDn, 0), GPIO8));
3179 _for_each_inner_analog_function!(((ZCD1, ZCDn, 1), GPIO9));
3180 _for_each_inner_analog_function!((all(XTAL_32K_P, GPIO0), (XTAL_32K_N, GPIO1),
3181 (ZCD0, GPIO8), (ZCD1, GPIO9), (USB_DM, GPIO12), (USB_DP, GPIO13)));
3182 _for_each_inner_analog_function!((all_expanded((ZCD0, ZCDn, 0), GPIO8), ((ZCD1,
3183 ZCDn, 1), GPIO9)));
3184 };
3185}
3186#[macro_export]
3213#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3214macro_rules! for_each_lp_function {
3215 ($($pattern:tt => $code:tt;)*) => {
3216 macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
3217 => {} } _for_each_inner_lp_function!((all));
3218 _for_each_inner_lp_function!((all_expanded));
3219 };
3220}
3221#[macro_export]
3225#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3226macro_rules! define_io_mux_signals {
3227 () => {
3228 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
3229 #[derive(Debug, PartialEq, Copy, Clone)]
3230 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3231 #[doc(hidden)]
3232 pub enum InputSignal {
3233 U0RXD = 6,
3234 U0CTS = 7,
3235 U0DSR = 8,
3236 U1RXD = 9,
3237 U1CTS = 10,
3238 U1DSR = 11,
3239 I2S_MCLK = 12,
3240 I2SO_BCK = 13,
3241 I2SO_WS = 14,
3242 I2SI_SD = 15,
3243 I2SI_BCK = 16,
3244 I2SI_WS = 17,
3245 CPU_GPIO_0 = 27,
3246 CPU_GPIO_1 = 28,
3247 CPU_GPIO_2 = 29,
3248 CPU_GPIO_3 = 30,
3249 CPU_GPIO_4 = 31,
3250 CPU_GPIO_5 = 32,
3251 CPU_GPIO_6 = 33,
3252 CPU_GPIO_7 = 34,
3253 USB_JTAG_TDO_BRIDGE = 35,
3254 I2CEXT0_SCL = 46,
3255 I2CEXT0_SDA = 47,
3256 FSPICLK = 64,
3257 FSPIQ = 65,
3258 FSPID = 66,
3259 FSPIHD = 67,
3260 FSPIWP = 68,
3261 FSPICS0 = 69,
3262 U2RXD = 72,
3263 U2CTS = 73,
3264 U2DSR = 74,
3265 SIG_IN_FUNC97 = 97,
3266 SIG_IN_FUNC98 = 98,
3267 SIG_IN_FUNC99 = 99,
3268 SIG_IN_FUNC100 = 100,
3269 SDIO_CLK,
3270 SDIO_CMD,
3271 SDIO_DATA0,
3272 SDIO_DATA1,
3273 SDIO_DATA2,
3274 SDIO_DATA3,
3275 MTDI,
3276 MTDO,
3277 MTCK,
3278 MTMS,
3279 }
3280 #[allow(non_camel_case_types, clippy::upper_case_acronyms)]
3281 #[derive(Debug, PartialEq, Copy, Clone)]
3282 #[cfg_attr(feature = "defmt", derive(defmt::Format))]
3283 #[doc(hidden)]
3284 pub enum OutputSignal {
3285 LEDC_LS_SIG0 = 0,
3286 LEDC_LS_SIG1 = 1,
3287 LEDC_LS_SIG2 = 2,
3288 LEDC_LS_SIG3 = 3,
3289 LEDC_LS_SIG4 = 4,
3290 LEDC_LS_SIG5 = 5,
3291 U0TXD = 6,
3292 U0RTS = 7,
3293 U0DTR = 8,
3294 U1TXD = 9,
3295 U1RTS = 10,
3296 U1DTR = 11,
3297 I2S_MCLK = 12,
3298 I2SO_BCK = 13,
3299 I2SO_WS = 14,
3300 I2SO_SD = 15,
3301 I2SI_BCK = 16,
3302 I2SI_WS = 17,
3303 I2SO_SD1 = 18,
3304 CPU_GPIO_0 = 27,
3305 CPU_GPIO_1 = 28,
3306 CPU_GPIO_2 = 29,
3307 CPU_GPIO_3 = 30,
3308 CPU_GPIO_4 = 31,
3309 CPU_GPIO_5 = 32,
3310 CPU_GPIO_6 = 33,
3311 CPU_GPIO_7 = 34,
3312 I2CEXT0_SCL = 46,
3313 I2CEXT0_SDA = 47,
3314 FSPICLK = 64,
3315 FSPIQ = 65,
3316 FSPID = 66,
3317 FSPIHD = 67,
3318 FSPIWP = 68,
3319 FSPICS0 = 69,
3320 U2TXD = 72,
3321 U2RTS = 73,
3322 U2DTR = 74,
3323 FSPICS1 = 102,
3324 FSPICS2 = 103,
3325 FSPICS3 = 104,
3326 FSPICS4 = 105,
3327 FSPICS5 = 106,
3328 SDIO_TOHOST_INT = 124,
3329 GPIO = 256,
3330 }
3331 };
3332}
3333#[macro_export]
3346#[expect(clippy::crate_in_macro_def)]
3347#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
3348macro_rules! define_io_mux_reg {
3349 () => {
3350 pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO {
3351 crate::peripherals::IO_MUX::regs().gpio(gpio_num as usize)
3352 }
3353 };
3354}