va416xx_hal/irq_router.rs
1//! IRQ Router peripheral support.
2use vorago_shared_hal::{enable_peripheral_clock, reset_peripheral_for_cycles, PeripheralSelect};
3
4use crate::pac;
5
6/// This enables and initiates the peripheral.
7///
8/// Please note that this method also writes 0 to the registers which do not have 0 as the default
9/// reset value. The programmers guide v1.2 and the actual values inspected using a SVD viewer
10/// are inconsistent here, and the registers being non-zero can actually lead to weird bugs
11/// when working with interrupts. Registers DMASELx and ADCSEL/DMASELx will reset to 0x7f and 0x1f
12/// respectively instead of 0x00.
13pub fn enable_and_init_irq_router() {
14 let irq_router = unsafe { pac::IrqRouter::steal() };
15 enable_peripheral_clock(PeripheralSelect::IrqRouter);
16 reset_peripheral_for_cycles(PeripheralSelect::IrqRouter, 2);
17 unsafe {
18 irq_router.dmasel0().write_with_zero(|w| w);
19 irq_router.dmasel1().write_with_zero(|w| w);
20 irq_router.dmasel2().write_with_zero(|w| w);
21 irq_router.dmasel3().write_with_zero(|w| w);
22 irq_router.adcsel().write_with_zero(|w| w);
23 irq_router.dacsel0().write_with_zero(|w| w);
24 irq_router.dacsel1().write_with_zero(|w| w);
25 }
26}