From 7aac896cefaec31b390a3baa5712048b802ff16f Mon Sep 17 00:00:00 2001 From: Gale Faraday Date: Fri, 5 Sep 2025 08:07:47 -0500 Subject: [PATCH] feat(boot): new baud setup routine --- code/boot/src/reset.s | 2 +- code/boot/src/serial.s | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/code/boot/src/reset.s b/code/boot/src/reset.s index afc3c4b..b991d17 100644 --- a/code/boot/src/reset.s +++ b/code/boot/src/reset.s @@ -41,7 +41,7 @@ SERINIT lda #(UARTF_MCR_RTS) ; Enable Request-to-Send sta UART_MCR lda #'H ; send 'H' - sta UART_BUFR + sta UART_THR WAIT sync ; Wait for interrupts diff --git a/code/boot/src/serial.s b/code/boot/src/serial.s index f43d2d9..f906aab 100644 --- a/code/boot/src/serial.s +++ b/code/boot/src/serial.s @@ -12,9 +12,25 @@ SECTION SERIAL + EXPORT SETBAUD EXPORT OUTCHAR EXPORT OUTSTR +; Initializes the UART. +; @param d: new divisor +SETBAUD + pshs a ; Preserve A + lda UART_LCR ; Set only the DLAB bit + ora #UARTF_LCR_DLAB + sta UART_LCR + puls a + sta UART_DLM ; Store new divisor + stb UART_DLL + lda UART_LCR ; Reset DLAB + anda #$FE + sta UART_LCR + rts + ; Writes a char to the UART in non FIFO mode, preserves A. ; @param b: char to write OUTCHAR @@ -23,7 +39,7 @@ NOTREADY@ lda UART_LSR ; if LSR.THRE == 1 then write anda UARTF_LSR_THRE bne NOTREADY@ ; Loop if UART not ready yet - stb UART_BUFR ; Write char + stb UART_THR ; Write char puls a ; Restore A rts @@ -39,7 +55,7 @@ NOTREADY@ ; Loop point for UART waiting lda UART_LSR ; Wait for UART to be ready anda UARTF_LSR_THRE bne NOTREADY@ - stb UART_BUFR ; Actually do our write + stb UART_THR ; Actually do our write bra OUTSTR ; Reset for the next char END@ ; Jump point for end of routine rts