Add UART1 READ AND WRITE function

This commit is contained in:
Sanyog Nevase Nevase 2024-10-29 01:20:14 +05:30
parent a35071825e
commit 82b84be2c2
1 changed files with 15 additions and 1 deletions

14
main.c
View File

@ -38,6 +38,20 @@ void GPIO_PORT_B_init(void)
UART1_CTL_R |= 0x301; // ENABLE UART1, RX AND TX 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 int main(void) // MAIN FUNCTION
{ {
GPIO_PORT_F_init(); // GPIO PORT F INITIALISATION FUNCTION GPIO_PORT_F_init(); // GPIO PORT F INITIALISATION FUNCTION