From 694257c5acdabc8c1cf3da6bff2653723bfd1d03 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Mon, 21 Mar 2022 21:53:08 +0100 Subject: [PATCH] Uart: add receive --- uart.c | 7 +++++++ uart.h | 1 + 2 files changed, 8 insertions(+) diff --git a/uart.c b/uart.c index 4df3466..47e5e07 100644 --- a/uart.c +++ b/uart.c @@ -36,6 +36,13 @@ void uart_init(void ) UART0_CR = 0x301; //Active Tx, Rx & FIFO } +char uart_recv(void) +{ + while (UART0_FR & (1 << 4)) { + } + return UART0_DR & 0xFF; +} + void putc(char c){ //FIFO Full? while(UART0_FR & (1<<5)){} diff --git a/uart.h b/uart.h index c6bbf1e..59888a0 100644 --- a/uart.h +++ b/uart.h @@ -12,5 +12,6 @@ #define UART0_ICR (*(volatile unsigned *)(UART0_BASE + 0x44)) void uart_init(void); +char uart_recv(void); void putc(char c); void puts(const char *s);