#include "uart.h"
uartInit(); // initialize UART (serial port) uartSetBaudRate(9600); // set UART speed to 9600 baud rprintfInit(uartSendByte); // configure rprintf to use UART for output rprintf("Hello World\r\n"); // send "hello world" message via serial port
global.h
for the UART library to calculate correct baud rates. Furthermore, certain CPU frequencies will not produce exact baud rates due to integer frequency division round-off. See your AVR processor's datasheet for full details.
Defines | |
#define | UART_DEFAULT_BAUD_RATE 9600 |
#define | UART_TX_BUFFER_SIZE 0x0040 |
#define | UART_RX_BUFFER_SIZE 0x0040 |
#define | UART_INTERRUPT_HANDLER SIGNAL |
Functions | |
void | uartInit (void) |
void | uartInitBuffers (void) |
void | uartSetRxHandler (void(*rx_func)(unsigned char c)) |
void | uartSetBaudRate (u32 baudrate) |
cBuffer * | uartGetRxBuffer (void) |
cBuffer * | uartGetTxBuffer (void) |
void | uartSendByte (u08 data) |
int | uartGetByte (void) |
u08 | uartReceiveByte (u08 *data) |
u08 | uartReceiveBufferIsEmpty (void) |
void | uartFlushReceiveBuffer (void) |
u08 | uartAddToTxBuffer (u08 data) |
void | uartSendTxBuffer (void) |
u08 | uartSendBuffer (char *buffer, u16 nBytes) |
|
Default uart baud rate. This is the default speed after a uartInit() command, and can be changed by using uartSetBaudRate(). |
|
Type of interrupt handler to use for uart interrupts. Value may be SIGNAL or INTERRUPT.
|
|
Number of bytes for uart receive buffer. Do not change this value in uart.h, but rather override it with the desired value defined in your project's global.h |
|
Number of bytes for uart transmit buffer. Do not change this value in uart.h, but rather override it with the desired value defined in your project's global.h |
|
Add byte to end of uart Tx buffer. Returns TRUE if successful, FALSE if failed (no room left in buffer). |
|
Flushes (deletes) all data from receive buffer. |
|
Gets a single byte from the uart receive buffer. Returns the byte, or -1 if no byte is available (getchar-style). |
|
Returns pointer to the receive buffer structure. |
|
Returns pointer to the transmit buffer structure. |
|
Initializes uart.
|
|
Initializes transmit and receive buffers. Automatically called from uartInit() |
|
Returns TRUE/FALSE if receive buffer is empty/not-empty. |
|
Gets a single byte from the uart receive buffer. Function returns TRUE if data was available, FALSE if not. Actual data is returned in variable pointed to by "data". Example usage: char myReceivedByte; uartReceiveByte( &myReceivedByte ); |
|
Sends a block of data via the uart using interrupt control.
|
|
Sends a single byte over the uart.
|
|
Begins transmission of the transmit buffer under interrupt control. |
|
Sets the uart baud rate. Argument should be in bits-per-second, like |
|
Redirects received data to a user function. |