Serial Fix

Fixes a typo with getc_nb, removes the RTC tick code (since we know it
works now and it is clogging up the screen), read characters in a loop
instead of just once.
This commit is contained in:
Byron Lathi
2023-11-28 23:23:31 -08:00
parent fd9ccdbce4
commit e73d8db74c
2 changed files with 10 additions and 10 deletions

View File

@@ -9,7 +9,7 @@
.export _serial_init .export _serial_init
.export _serial_handle_irq .export _serial_handle_irq
.export _serial_putc, _serial_puts, _serial_getc, _serial_get_nb .export _serial_putc, _serial_puts, _serial_getc, _serial_getc_nb
.zeropage .zeropage
@@ -39,8 +39,8 @@ UART_STATUS = UART + 1
; Get the character and store it. ; Get the character and store it.
.proc _serial_handle_irq .proc _serial_handle_irq
lda UART_RXB lda UART_RXB
sta last_char
ora #$80 ; set msb ora #$80 ; set msb
sta last_char
jsr _send_eoi jsr _send_eoi
rti rti
.endproc .endproc
@@ -58,7 +58,7 @@ L1: lda last_char
; Serial Port Get Character Non-Blocking ; Serial Port Get Character Non-Blocking
; return last character, even if it has already been read. ; return last character, even if it has already been read.
; If the character is new, we still clear the new flag. ; If the character is new, we still clear the new flag.
.proc _serial_get_nb .proc _serial_getc_nb
lda last_char lda last_char
bpl L1 bpl L1
and #$7f and #$7f

View File

@@ -8,7 +8,7 @@
void handle_rtc_interrupt() { void handle_rtc_interrupt() {
// cputs("In IRQ interrupt!\n"); // cputs("In IRQ interrupt!\n");
cputc('A'); // cputc('A');
send_eoi(); send_eoi();
asm volatile ("rti"); asm volatile ("rti");
} }
@@ -40,12 +40,12 @@ int main() {
serial_puts("Hello from serial!\n"); serial_puts("Hello from serial!\n");
while(1) {
c = serial_getc(); c = serial_getc();
serial_puts("Got a character!: "); serial_puts("Got a character!: ");
serial_putc(c); serial_putc(c);
serial_putc('\n');
while(1); }
return 0; return 0;
} }