From 82b84be2c2f9353cdd96421047b6fc4fd31edba4 Mon Sep 17 00:00:00 2001 From: Sanyog Date: Tue, 29 Oct 2024 01:20:14 +0530 Subject: [PATCH] Add UART1 READ AND WRITE function --- main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index dfa31af..a1c914e 100644 --- a/main.c +++ b/main.c @@ -38,6 +38,20 @@ void GPIO_PORT_B_init(void) UART1_CTL_R |= 0x301; // ENABLE UART1, RX AND TX } +void UART1_WRITE(char data) // UART1 WRITE DATA +{ + while (UART1_FR_R & 0x20); // WAIT UNTIL TX FIFO IS NOT FULL + UART1_DR_R = data; // WRITE DATA TO UART DATA REGISTER +} + +char UART1_READ(void) // UART1 READ DATA +{ + while (UART1_FR_R & 0x10); // WAIT UNTIL RX FIFO IS NOT EMPTY + return (char)UART1_DR_R; // RETURN RECEIVED DATA +} + + + int main(void) // MAIN FUNCTION { GPIO_PORT_F_init(); // GPIO PORT F INITIALISATION FUNCTION @@ -46,4 +60,4 @@ int main(void) // MAIN FUNCTION while (1) { -} \ No newline at end of file +}