Input and output operations are made by a program running on the processor.
Disadvantage: Inefficient - too much polling for general use. Interrupt driven I/O is more efficient.
#define IO_BASE 0xFFFC1000 // or whatever | char uart_polled_read()
{
while (UART_STATUS() &
UART_STATUS_RX_EMPTY) continue;
return UART_RECEIVE();
}
uart_polled_write(char d)
{
while (!(UART_STATUS() &
UART_STATUS_TX_EMPTY)) continue;
UART_SEND() = d;
}
|