Uart: add receive

This commit is contained in:
Mathieu Maret 2022-03-21 21:53:08 +01:00 committed by Mathieu Maret
parent 1fcf63409c
commit 694257c5ac
2 changed files with 8 additions and 0 deletions

7
uart.c
View File

@ -36,6 +36,13 @@ void uart_init(void )
UART0_CR = 0x301; //Active Tx, Rx & FIFO UART0_CR = 0x301; //Active Tx, Rx & FIFO
} }
char uart_recv(void)
{
while (UART0_FR & (1 << 4)) {
}
return UART0_DR & 0xFF;
}
void putc(char c){ void putc(char c){
//FIFO Full? //FIFO Full?
while(UART0_FR & (1<<5)){} while(UART0_FR & (1<<5)){}

1
uart.h
View File

@ -12,5 +12,6 @@
#define UART0_ICR (*(volatile unsigned *)(UART0_BASE + 0x44)) #define UART0_ICR (*(volatile unsigned *)(UART0_BASE + 0x44))
void uart_init(void); void uart_init(void);
char uart_recv(void);
void putc(char c); void putc(char c);
void puts(const char *s); void puts(const char *s);