Add uart_rxb
Once you receive a uart interrupt you can call this function to get the received character.
This commit is contained in:
6
sw/irq.c
6
sw/irq.c
@@ -2,12 +2,14 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "interrupt.h"
|
#include "interrupt.h"
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
// This is defined in main.c
|
// This is defined in main.c
|
||||||
void puts(const char* s);
|
void puts(const char* s);
|
||||||
|
|
||||||
void handle_irq() {
|
void handle_irq() {
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
|
char c;
|
||||||
|
|
||||||
puts("Interrupt Detected!\n");
|
puts("Interrupt Detected!\n");
|
||||||
|
|
||||||
@@ -19,6 +21,10 @@ void handle_irq() {
|
|||||||
}
|
}
|
||||||
if (status & UART) {
|
if (status & UART) {
|
||||||
puts("UART Interrupt!\n");
|
puts("UART Interrupt!\n");
|
||||||
|
c = uart_rxb();
|
||||||
|
puts("Received: ");
|
||||||
|
puts(&c);
|
||||||
|
puts("\n");
|
||||||
irq_set_status(status & ~UART);
|
irq_set_status(status & ~UART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
void uart_txb(uint8_t val);
|
void uart_txb(uint8_t val);
|
||||||
void uart_txb_block(uint8_t val);
|
void uart_txb_block(uint8_t val);
|
||||||
|
|
||||||
|
uint8_t uart_rxb();
|
||||||
|
|
||||||
uint8_t uart_status();
|
uint8_t uart_status();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
.importzp sp, sreg
|
.importzp sp, sreg
|
||||||
|
|
||||||
.export _uart_txb
|
.export _uart_txb, _uart_txb_block
|
||||||
.export _uart_txb_block
|
.export _uart_rxb
|
||||||
.export _uart_status
|
.export _uart_status
|
||||||
|
|
||||||
.autoimport on
|
.autoimport on
|
||||||
@@ -23,6 +23,11 @@ _uart_txb_block:
|
|||||||
bne @1
|
bne @1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
_uart_rxb:
|
||||||
|
lda UART_RXB ; Read value
|
||||||
|
ldx #$00
|
||||||
|
rts
|
||||||
|
|
||||||
_uart_status:
|
_uart_status:
|
||||||
lda UART_STATUS
|
lda UART_STATUS
|
||||||
ldx #$00
|
ldx #$00
|
||||||
|
|||||||
Reference in New Issue
Block a user