This driver uses two identical ring buffers (circular queues) which by default take up 130 bytes each. You may change the buffer data structure size by defining BUFFER_BITS in your compiler flags (the size if 2^BUFFER_BITS+1). See buffer.h for more information.
The following example (main.c) initializes the UART, prints a string, and then echoes any received characters back:
#include <avr/io.h> #include "uart.h" int main( void ) { char c; /* initialize */ uart_init( BAUD_SETTING ); /* enable interrupts */ asm("sei"); uart_puts( "Hello, world!\n" ); while( 1 ) { while( !uart_getchar( &c ) ); /* wait for a character */ uart_putchar( c ); /* echo it */ } return 0; }
This file and a Makefile to build it are included. The Makefile is based on the Makefile provided with the avr-libc project and it has only been tested on Linux.