/************************************************************************
Title: Interrupt UART library with receive/transmit circular buffers
Author: Andy Gock
Software: AVR-GCC 4.1, AVR Libc 1.4
Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz
License: GNU General Public License
Usage: see README.md and Doxygen manual
Based on original library by Peter Fluery, Tim Sharpe, Nicholas Zambetti.
https://github.com/andygock/avr-uart
LICENSE:
Copyright (C) 2012 Andy Gock
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.
************************************************************************/
/************************************************************************
uart_available, uart_flush, uart1_available, and uart1_flush functions
were adapted from the Arduino HardwareSerial.h library by Tim Sharpe on
11 Jan 2009. The license info for HardwareSerial.h is as follows:
HardwareSerial.h - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
************************************************************************/
/**
* @defgroup avr-uart UART Library
* @code #include <uart.h> @endcode
*
* @brief Interrupt UART library using the built-in UART with transmit and receive circular buffers.
* @see README.md
*
* This library can be used to transmit and receive data through the built in UART.
*
* 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_RXn_BUFFER_SIZE and UART_TXn_BUFFER_SIZE constants define
* the size of the circular buffers in bytes. Note that these constants must be a power of 2.
*
* You need to define these buffer sizes as a symbol in your compiler settings or in uart.h
*
* See README.md for more detailed information. Especially that relating to symbols: USARTn_ENABLED and USARTn_LARGE_BUFFER
*
* @author Andy Gock <andy@gock.net>
* @note Based on Atmel Application Note AVR306 and original library by Peter Fleury and Tim Sharpe.
*/
/**@{*/
/*
* constants and macros
*/
/* Enable USART 1, 2, 3 as required */
/* Can be defined in compiler symbol setup with -D option (preferred) */
//#define USART1_ENABLED
//#define USART2_ENABLED
//#define USART3_ENABLED
/* Set size of receive and transmit buffers */
/* Check buffer sizes are not too large for 8-bit positioning */
/* Check buffer sizes are not too large for *_LARGE_BUFFER operation (16-bit positioning) */
/** @brief UART Baudrate Expression
* @param xtalCpu system clock in Mhz, e.g. 4000000L for 4Mhz
* @param baudRate baudrate in bps, e.g. 1200, 2400, 9600
*/
/** @brief UART Baudrate Expression for ATmega double speed mode
* @param xtalCpu system clock in Mhz, e.g. 4000000L for 4Mhz
* @param baudRate baudrate in bps, e.g. 1200, 2400, 9600
*/
/* test if the size of the circular buffers fits into SRAM */
/*
** high byte error return code of uart_getc()
*/
/* Macros, to allow use of legacy names */
/** @brief Macro to initialize USART0 (only available on selected ATmegas) @see uart0_init */
/** @brief Macro to get received byte of USART0 from ringbuffer. (only available on selected ATmega) @see uart0_getc */
/** @brief Macro to peek at next byte in USART0 ringbuffer */
/** @brief Macro to put byte to ringbuffer for transmitting via USART0 (only available on selected ATmega) @see uart0_putc */
/** @brief Macro to put string to ringbuffer for transmitting via USART0 (only available on selected ATmega) @see uart0_puts */
/** @brief Macro to put string from program memory to ringbuffer for transmitting via USART0 (only available on selected ATmega) @see uart0_puts_p */
/** @brief Macro to return number of bytes waiting in the receive buffer of USART0 @see uart0_available */
/** @brief Macro to flush bytes waiting in receive buffer of USART0 @see uart0_flush */
/*
** function prototypes
*/
/**
@brief Initialize UART and set baudrate
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
@return none
*/
/*extern*/void ;
/**
* @brief Get received byte from ringbuffer
*
* Returns in the lower byte the received character and in the
* higher byte the last receive error.
* UART_NO_DATA is returned when no data is available.
*
* @return lower byte: received byte from ringbuffer
* @return higher byte: last receive status
* - \b 0 successfully received data from UART
* - \b UART_NO_DATA
* <br>no receive data available
* - \b UART_BUFFER_OVERFLOW
* <br>Receive ringbuffer overflow.
* We are not reading the receive buffer fast enough,
* one or more received character have been dropped
* - \b UART_OVERRUN_ERROR
* <br>Overrun condition by UART.
* A character already present in the UART UDR register was
* not read by the interrupt handler before the next character arrived,
* one or more received characters have been dropped.
* - \b UART_FRAME_ERROR
* <br>Framing Error by UART
*/
/*extern*/uint16_t ;
/**
* @brief Peek at next byte in ringbuffer
*
* Returns the next byte (character) of incoming UART data without removing it from the
* internal ring buffer. That is, successive calls to uartN_peek() will return the same
* character, as will the next call to uartN_getc().
*
* UART_NO_DATA is returned when no data is available.
*
* @return lower byte: next byte in ringbuffer
* @return higher byte: last receive status
* - \b 0 successfully received data from UART
* - \b UART_NO_DATA
* <br>no receive data available
* - \b UART_BUFFER_OVERFLOW
* <br>Receive ringbuffer overflow.
* We are not reading the receive buffer fast enough,
* one or more received character have been dropped
* - \b UART_OVERRUN_ERROR
* <br>Overrun condition by UART.
* A character already present in the UART UDR register was
* not read by the interrupt handler before the next character arrived,
* one or more received characters have been dropped.
* - \b UART_FRAME_ERROR
* <br>Framing Error by UART
*/
/*extern*/uint16_t ;
/**
* @brief Put byte to ringbuffer for transmitting via UART
* @param data byte to be transmitted
* @return none
*/
/*extern*/void ;
/**
* @brief Put string to ringbuffer for transmitting via UART
*
* The string is buffered by the uart library in a circular buffer
* and one character at a time is transmitted to the UART using interrupts.
* Blocks if it can not write the whole string into the circular buffer.
*
* @param s string to be transmitted
* @return none
*/
/*extern*/void ;
/**
* @brief Put string from program memory to ringbuffer for transmitting via UART.
*
* The string is buffered by the uart library in a circular buffer
* and one character at a time is transmitted to the UART using interrupts.
* Blocks if it can not write the whole string into the circular buffer.
*
* @param s program memory string to be transmitted
* @return none
* @see uart0_puts_P
*/
/*extern*/void ;
/**
* @brief Macro to automatically put a string constant into program memory
* \param __s string in program memory
*/
/** @brief Macro to automatically put a string constant into program memory */
/**
* @brief Return number of bytes waiting in the receive buffer
* @return bytes waiting in the receive buffer
*/
/*extern*/uint16_t ;
/**
* @brief Flush bytes waiting in receive buffer
*/
/*extern*/void ;
/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */
/*extern*/void ;
/** @brief Get received byte of USART1 from ringbuffer. (only available on selected ATmega) @see uart_getc */
/*extern*/uint16_t ;
/** @brief Peek at next byte in USART1 ringbuffer */
/*extern*/uint16_t ;
/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */
/*extern*/void ;
/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */
/*extern*/void ;
/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */
/*extern*/void ;
/** @brief Macro to automatically put a string constant into program memory of USART1 @see uart1_puts_p */
/** @brief Return number of bytes waiting in the receive buffer of USART1 */
/*extern*/uint16_t ;
/** @brief Flush bytes waiting in receive buffer of USART1 */
/*extern*/void ;
/** @brief Initialize USART2 (only available on selected ATmegas) @see uart_init */
/*extern*/void ;
/** @brief Get received byte of USART2 from ringbuffer. (only available on selected ATmega) @see uart_getc */
/*extern*/uint16_t ;
/** @brief Peek at next byte in USART2 ringbuffer */
/*extern*/uint16_t ;
/** @brief Put byte to ringbuffer for transmitting via USART2 (only available on selected ATmega) @see uart_putc */
/*extern*/void ;
/** @brief Put string to ringbuffer for transmitting via USART2 (only available on selected ATmega) @see uart_puts */
/*extern*/void ;
/** @brief Put string from program memory to ringbuffer for transmitting via USART2 (only available on selected ATmega) @see uart_puts_p */
/*extern*/void ;
/** @brief Macro to automatically put a string constant into program memory of USART2 @see uart2_puts_p */
/** @brief Return number of bytes waiting in the receive buffer of USART2 */
/*extern*/uint16_t ;
/** @brief Flush bytes waiting in receive buffer of USART2 */
/*extern*/void ;
/** @brief Initialize USART3 (only available on selected ATmegas) @see uart_init */
/*extern*/void ;
/** @brief Get received byte of USART3 from ringbuffer. (only available on selected ATmega) @see uart_getc */
/*extern*/uint16_t ;
/** @brief Peek at next byte in USART3 ringbuffer */
/*extern*/uint16_t ;
/** @brief Put byte to ringbuffer for transmitting via USART3 (only available on selected ATmega) @see uart_putc */
/*extern*/void ;
/** @brief Put string to ringbuffer for transmitting via USART3 (only available on selected ATmega) @see uart_puts */
/*extern*/void ;
/** @brief Put string from program memory to ringbuffer for transmitting via USART3 (only available on selected ATmega) @see uart_puts_p */
/*extern*/void ;
/** @brief Macro to automatically put a string constant into program memory of USART3 @see uart3_puts_p */
/** @brief Return number of bytes waiting in the receive buffer of USART3 */
/*extern*/uint16_t ;
/** @brief Flush bytes waiting in receive buffer of USART3 */
/*extern*/void ;
/**@}*/
// UART_H