From 7568e2aeac2b04680d3482c074754e62774d4133 Mon Sep 17 00:00:00 2001 From: Takashi Toyoshima Date: Thu, 11 Dec 2014 00:27:35 +0900 Subject: [PATCH] Add UART receive functions --- uart.S | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/uart.S b/uart.S index 3b00b04..98226ad 100644 --- a/uart.S +++ b/uart.S @@ -20,7 +20,7 @@ uart_init: str r1, [r0] // 1) IO port configuration to use UART ldr r0, =#IOCON_PIO1_6 - movs r1, #(PIO_BASE | FUNC_RXD) + movs r1, #(PIO_BASE | FUNC_RXD | MODE_UP) str r1, [r0] ldr r0, =#IOCON_PIO1_7 movs r1, #(PIO_BASE | FUNC_TXD) @@ -56,11 +56,6 @@ uart_init: movs r1, #(WORD_LEN_8 | STOP_BIT_1) str r1, [r0] - // Enable TX - ldr r0, =#U0TER - movs r1, #TXEN - str r1, [r0] - // Reset FIFO ldr r0, =#U0FCR movs r1, #(FIFO_ENABLE | RX_RESET | TX_RESET) @@ -69,6 +64,31 @@ uart_init: mov pc, lr .size uart_init, .-uart_init + // int uart_ready(); + .global uart_ready + .type uart_ready, %function +uart_ready: + ldr r0, =#U0LSR + ldr r0, [r0] + movs r1, #LSR_RDR + ands r0, r0, r1 + bne 1f + movs r0, #0 + mov pc, lr +1: + movs r0, #1 + mov pc, lr + .size uart_ready, .-uart_ready + + // int uart_getc(); + .global uart_getc + .type uart_getc, %function +uart_getc: + ldr r0, =#U0RBR + ldr r0, [r0] + mov pc, lr + .size uart_getc, .-uart_getc + // void uart_putc(char c); .global uart_putc .type uart_putc, %function