Add UART1 READ AND WRITE function
This commit is contained in:
parent
a35071825e
commit
82b84be2c2
14
main.c
14
main.c
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue