summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHesham ALMatary <heshamelmatary@gmail.com>2014-09-19 14:20:35 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-09-29 14:37:25 -0500
commitfbe59f7c6756edc2952b13167893b85fe6e7aecb (patch)
treea9e833d9b1147c596a2adac4bd29cf9d1b1dd6d8
parent5464752f79983a84d81ba9022da1ee588a2f839c (diff)
downloadrtems-fbe59f7c6756edc2952b13167893b85fe6e7aecb.tar.bz2
or1ksim: Console: implement uart_read_polled
Implement uart_read_polled which is needed for any application that reads input from users. It works fine with pppd, capture, and all termios tests.
-rw-r--r--c/src/lib/libbsp/or1k/or1ksim/console/uart.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/c/src/lib/libbsp/or1k/or1ksim/console/uart.c b/c/src/lib/libbsp/or1k/or1ksim/console/uart.c
index f1cfa0985f..7ceca816a5 100644
--- a/c/src/lib/libbsp/or1k/or1ksim/console/uart.c
+++ b/c/src/lib/libbsp/or1k/or1ksim/console/uart.c
@@ -86,9 +86,18 @@ static int uart_last_close(int major, int minor, void *arg)
return 0;
}
-static int uart_read_polled(int minor)
+static char uart_read_polled(int minor)
{
- return -1;
+ unsigned char lsr;
+ char c;
+
+ /* Get a character when avaiable */
+ do {
+ lsr = OR1KSIM_REG(OR1KSIM_BSP_UART_REG_LINE_STATUS);
+ } while ((lsr & OR1KSIM_BSP_UART_REG_LINE_STATUS_DR)
+ != OR1KSIM_BSP_UART_REG_LINE_STATUS_DR);
+
+ return OR1KSIM_REG(OR1KSIM_BSP_UART_REG_RX);
}
static void uart_write_polled(int minor, char c)