The Serial module provides functions to communicate using the UART interface. Examples of devices connected using the UART interface are GPS receivers and GSM modems. The UART can also be used for communicating between micro-controllers.
ZDev provides APIs to communicate using the UART. The Serial module, hooks on the receive interrupt and buffers received data using a FIFO. This reduces data loss when the program is busy doing something else.
The UART functions are declared in serial.h
. The following example
writes and echoes back characters received on the serial port.
Serial Echo.
#include <board.h>
#include <serial.h>
int main()
{
char ch;
board_init();
serial_init();
serial_puts("Echo World: ");
while(1) {
/* Read data from serial port. */
ch = serial_getc();
/* Send back the read data to the serial port. */
serial_putc(ch);
}
}