2019-05-07 06:32:45 +08:00
|
|
|
#![allow(unused)]
|
|
|
|
|
2019-05-05 20:56:23 +08:00
|
|
|
mod regs;
|
|
|
|
pub use regs::RegisterBlock;
|
|
|
|
|
|
|
|
pub struct Uart {
|
|
|
|
regs: &'static mut RegisterBlock,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Uart {
|
|
|
|
pub fn uart0() -> Self {
|
|
|
|
let uart_rst_ctrl = super::slcr::UartRstCtrl::new();
|
|
|
|
uart_rst_ctrl.reset_uart0();
|
|
|
|
// TODO: Route UART 0 RxD/TxD Signals to MIO Pins
|
|
|
|
|
|
|
|
let uart_clk_ctrl = super::slcr::UartClkCtrl::new();
|
|
|
|
uart_clk_ctrl.enable_uart0();
|
|
|
|
|
|
|
|
Uart {
|
|
|
|
regs: RegisterBlock::uart0(),
|
|
|
|
}.init()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn init(self) -> Self {
|
|
|
|
self.regs.configure();
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn write_byte(&self, v: u8) {
|
2019-05-07 06:32:45 +08:00
|
|
|
while self.regs.tx_fifo_full() {}
|
2019-05-05 20:56:23 +08:00
|
|
|
|
2019-05-07 06:32:45 +08:00
|
|
|
self.regs.write_byte(v);
|
2019-05-05 20:56:23 +08:00
|
|
|
}
|
|
|
|
}
|