forked from M-Labs/zynq-rs
1
0
Fork 0
zynq-rs/src/slcr.rs

46 lines
1.2 KiB
Rust
Raw Normal View History

2019-05-05 20:56:23 +08:00
use volatile_register::{RO, WO, RW};
2019-05-07 05:56:53 +08:00
use crate::{register, register_bit, register_bits, regs::Register};
2019-05-05 20:56:23 +08:00
2019-05-07 05:56:53 +08:00
register!(uart_clk_ctrl, UartClkCtrl, u32);
register_bit!(uart_clk_ctrl, clkact0, 0);
register_bit!(uart_clk_ctrl, clkact1, 1);
register_bits!(uart_clk_ctrl, divisor, u8, 8, 13);
2019-05-05 20:56:23 +08:00
impl UartClkCtrl {
const ADDR: *mut Self = 0xF8000154 as *mut _;
pub fn new() -> &'static mut Self {
unsafe { &mut *Self::ADDR }
}
pub fn enable_uart0(&self) {
2019-05-07 05:56:53 +08:00
self.modify(|_, w| {
w.clkact0(true)
.divisor(0x14)
})
2019-05-05 20:56:23 +08:00
}
}
2019-05-07 05:56:53 +08:00
register!(uart_rst_ctrl, UartRstCtrl, u32);
register_bit!(uart_rst_ctrl, uart0_ref_rst, 3);
register_bit!(uart_rst_ctrl, uart1_ref_rst, 2);
register_bit!(uart_rst_ctrl, uart0_cpu1x_rst, 1);
register_bit!(uart_rst_ctrl, uart1_cpu1x_rst, 0);
2019-05-05 20:56:23 +08:00
impl UartRstCtrl {
const ADDR: *mut Self = 0xF8000228 as *mut _;
pub fn new() -> &'static mut Self {
unsafe { &mut *Self::ADDR }
}
pub fn reset_uart0(&self) {
2019-05-07 05:56:53 +08:00
self.modify(|_, w| w.uart0_ref_rst(true));
self.modify(|_, w| w.uart0_ref_rst(false));
2019-05-05 20:56:23 +08:00
}
pub fn reset_uart1(&self) {
2019-05-07 05:56:53 +08:00
self.modify(|_, w| w.uart1_ref_rst(true));
self.modify(|_, w| w.uart1_ref_rst(false));
2019-05-05 20:56:23 +08:00
}
}