50 lines
1.0 KiB
Rust
50 lines
1.0 KiB
Rust
//! This also includes functionality to enable the peripheral clocks
|
|
use va416xx::Sysconfig;
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
pub enum PeripheralSelect {
|
|
Spi0 = 0,
|
|
Spi1 = 1,
|
|
Spi2 = 2,
|
|
Spi3 = 3,
|
|
Uart0 = 4,
|
|
Uart1 = 5,
|
|
Uart2 = 6,
|
|
I2c0 = 7,
|
|
I2c1 = 8,
|
|
I2c2 = 9,
|
|
Can0 = 10,
|
|
Can1 = 11,
|
|
Rng = 12,
|
|
Adc = 13,
|
|
Dac = 14,
|
|
Dma = 15,
|
|
Ebi = 16,
|
|
Eth = 17,
|
|
Spw = 18,
|
|
Clkgen = 19,
|
|
IrqRouter = 20,
|
|
IoConfig = 21,
|
|
Utility = 22,
|
|
Watchdog = 23,
|
|
PortA = 24,
|
|
PortB = 25,
|
|
PortC = 26,
|
|
PortD = 27,
|
|
PortE = 28,
|
|
PortF = 29,
|
|
PortG = 30,
|
|
}
|
|
|
|
pub fn enable_peripheral_clock(syscfg: &mut Sysconfig, clock: PeripheralSelect) {
|
|
syscfg
|
|
.peripheral_clk_enable()
|
|
.modify(|r, w| unsafe { w.bits(r.bits() | (1 << clock as u8)) });
|
|
}
|
|
|
|
pub fn disable_peripheral_clock(syscfg: &mut Sysconfig, clock: PeripheralSelect) {
|
|
syscfg
|
|
.peripheral_clk_enable()
|
|
.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << clock as u8)) });
|
|
}
|