refactor(cleanup): 📦 Clean up MiniUART code
This commit is contained in:
parent
d0e4334afe
commit
77d04d3d67
|
@ -184,9 +184,7 @@ impl crate::drivers::interface::DeviceDriver for MiniUart {
|
|||
|
||||
impl MiniUart {
|
||||
pub const COMPATIBLE: &'static str = "BCM MINI UART";
|
||||
}
|
||||
|
||||
impl MiniUart {
|
||||
/// Create an instance.
|
||||
///
|
||||
/// # Safety
|
||||
|
@ -226,9 +224,7 @@ impl MiniUartInner {
|
|||
registers: Registers::new(base_addr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MiniUartInner {
|
||||
/// Set baud rate and characteristics (115200 8N1) and map to GPIO
|
||||
pub fn prepare(&self) -> Result<(), &'static str> {
|
||||
use tock_registers::interfaces::Writeable;
|
||||
|
@ -256,6 +252,11 @@ impl MiniUartInner {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn flush_internal(&self) {
|
||||
use tock_registers::interfaces::Readable;
|
||||
crate::arch::loop_until(|| self.registers.AUX_MU_STAT.is_set(AUX_MU_STAT::TX_DONE));
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for MiniUartInner {
|
||||
|
@ -298,8 +299,7 @@ impl SerialOps for MiniUartInner {
|
|||
/// Wait until the TX FIFO is empty, aka all characters have been put on the
|
||||
/// line.
|
||||
fn flush(&self) {
|
||||
use tock_registers::interfaces::Readable;
|
||||
crate::arch::loop_until(|| self.registers.AUX_MU_STAT.is_set(AUX_MU_STAT::TX_DONE));
|
||||
self.flush_internal();
|
||||
}
|
||||
|
||||
/// Consume input until RX FIFO is empty, aka all pending characters have been
|
||||
|
|
Loading…
Reference in New Issue