2 Commits

3 changed files with 21 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ INCS := $(wildcard $(SRCDIR)*.inc)
AS := lwasm AS := lwasm
LD := lwlink LD := lwlink
FIX := mot2bin FIX := objcopy
ASFLAGS := -f obj ASFLAGS := -f obj
LDFLAGS := -f srec -m map.txt -s linkscript LDFLAGS := -f srec -m map.txt -s linkscript
@@ -36,7 +36,7 @@ all: $(TARGROM)
# Fix srec into flashable bin file # Fix srec into flashable bin file
$(TARGROM): $(TARGREC) $(TARGROM): $(TARGREC)
$(FIX) -out $@ $< $(FIX) -I srec -O binary $< $@
# Link objects # Link objects
$(TARGREC): $(OBJS) $(TARGREC): $(OBJS)

View File

@@ -41,7 +41,7 @@ SERINIT
lda #(UARTF_MCR_RTS) ; Enable Request-to-Send lda #(UARTF_MCR_RTS) ; Enable Request-to-Send
sta UART_MCR sta UART_MCR
lda #'H ; send 'H' lda #'H ; send 'H'
sta UART_BUFR sta UART_THR
WAIT WAIT
sync ; Wait for interrupts sync ; Wait for interrupts

View File

@@ -12,9 +12,25 @@
SECTION SERIAL SECTION SERIAL
EXPORT SETBAUD
EXPORT OUTCHAR EXPORT OUTCHAR
EXPORT OUTSTR 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. ; Writes a char to the UART in non FIFO mode, preserves A.
; @param b: char to write ; @param b: char to write
OUTCHAR OUTCHAR
@@ -23,7 +39,7 @@ NOTREADY@
lda UART_LSR ; if LSR.THRE == 1 then write lda UART_LSR ; if LSR.THRE == 1 then write
anda UARTF_LSR_THRE anda UARTF_LSR_THRE
bne NOTREADY@ ; Loop if UART not ready yet bne NOTREADY@ ; Loop if UART not ready yet
stb UART_BUFR ; Write char stb UART_THR ; Write char
puls a ; Restore A puls a ; Restore A
rts rts
@@ -39,7 +55,7 @@ NOTREADY@ ; Loop point for UART waiting
lda UART_LSR ; Wait for UART to be ready lda UART_LSR ; Wait for UART to be ready
anda UARTF_LSR_THRE anda UARTF_LSR_THRE
bne NOTREADY@ bne NOTREADY@
stb UART_BUFR ; Actually do our write stb UART_THR ; Actually do our write
bra OUTSTR ; Reset for the next char bra OUTSTR ; Reset for the next char
END@ ; Jump point for end of routine END@ ; Jump point for end of routine
rts rts