refactor(serial): use official uart_16550::SerialPort::init

This commit is contained in:
RarDog
2026-09-02 15:58:45 +03:00
parent 645bab6b72
commit 31aa2fa058
+2 -18
View File
@@ -19,24 +19,8 @@ static SERIAL: Mutex<Option<SerialPort>> = Mutex::new(None);
/// Инициализировать serial и зарегистрировать logger.
pub fn init() {
unsafe {
let mut ier: Port<u8> = Port::new(SERIAL_IO_PORT + 1);
let mut lcr: Port<u8> = Port::new(SERIAL_IO_PORT + 3);
let mut dll: Port<u8> = Port::new(SERIAL_IO_PORT);
let mut dlm: Port<u8> = Port::new(SERIAL_IO_PORT + 1);
let mut fcr: Port<u8> = Port::new(SERIAL_IO_PORT + 2);
let mut mcr: Port<u8> = Port::new(SERIAL_IO_PORT + 4);
ier.write(0x00); // Disable interrupts
lcr.write(0x80); // Enable DLAB (baud rate divisor)
dll.write(0x01); // 115200 baud (divisor 1 low byte)
dlm.write(0x00); // (divisor 1 high byte)
lcr.write(0x03); // 8 bits, no parity, 1 stop bit (DLAB disabled)
fcr.write(0x07); // Enable FIFO, clear RX/TX, 1-byte threshold
mcr.write(0x0B); // RTS/DTR + OUT2 (enable line driver)
}
let port = unsafe { SerialPort::new(SERIAL_IO_PORT) };
let mut port = unsafe { SerialPort::new(SERIAL_IO_PORT) };
port.init();
*SERIAL.lock() = Some(port);
flush_rx();