1 Commits
main ... serial

Author SHA1 Message Date
7aac896cef feat(boot): new baud setup routine 2025-09-05 08:07:47 -05:00
2 changed files with 19 additions and 3 deletions

View File

@@ -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

View File

@@ -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