ATmega8GPSLoggerBasismodul
20131018
|
Interrupt UART library with receive/transmit circular buffers. More...
Go to the source code of this file.
Macros | |
#define | UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) |
#define | UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) |
Functions | |
SIGNAL (UART0_RECEIVE_INTERRUPT) | |
SIGNAL (UART0_TRANSMIT_INTERRUPT) | |
void | uart_init (unsigned int baudrate) |
Initialize UART and set baudrate. More... | |
unsigned int | uart_getc (void) |
Get received byte from ringbuffer. More... | |
void | uart_putc (unsigned char data) |
Put byte to ringbuffer for transmitting via UART. More... | |
void | uart_puts (const char *s) |
Put string to ringbuffer for transmitting via UART. More... | |
void | uart_puts_p (const char *progmem_s) |
Put string from program memory to ringbuffer for transmitting via UART. More... | |
Interrupt UART library with receive/transmit circular buffers.
Software: AVR-GCC 4.1, AVR Libc 1.4.6 or higher
Hardware: any AVR with built-in UART
License: GNU General Public License
DESCRIPTION:
An interrupt is generated when the UART has finished transmitting or receiving a byte. The interrupt handling routines use circular buffers for buffering received and transmitted data.
The UART_RX_BUFFER_SIZE and UART_TX_BUFFER_SIZE variables define the buffer size in bytes. Note that these variables must be a power of 2.
USAGE:
Refere to the header file uart.h for a description of the routines. See also example test_uart.c.
LICENSE: Copyright (C) 2006 Peter Fleury
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Definition in file uart.c.
#define UART_RX_BUFFER_MASK ( UART_RX_BUFFER_SIZE - 1) |
constants and macros
size of RX/TX buffers
Definition at line 52 of file uart.c.
Referenced by SIGNAL(), and uart_getc().
#define UART_TX_BUFFER_MASK ( UART_TX_BUFFER_SIZE - 1) |
Definition at line 53 of file uart.c.
Referenced by SIGNAL(), and uart_putc().
SIGNAL | ( | UART0_RECEIVE_INTERRUPT | ) |
UART Receive Complete interrupt called when the UART has received a character
read UART status register and UART data register
calculate buffer index
error: receive buffer overflow
store new index
store received data in buffer
Definition at line 248 of file uart.c.
References UART_BUFFER_OVERFLOW, and UART_RX_BUFFER_MASK.
SIGNAL | ( | UART0_TRANSMIT_INTERRUPT | ) |
UART Data Register Empty interrupt called when the UART is ready to transmit the next byte
calculate and store new buffer index
get one byte from buffer and write it to UART
tx buffer empty, disable UDRE interrupt
Definition at line 290 of file uart.c.
References UART_TX_BUFFER_MASK.