ATmega8GPSLoggerBasismodul  20131018
uart.h
Go to the documentation of this file.
1 #ifndef UART_H
2 #define UART_H
3 /************************************************************************
4 \file uart.h
5 \brief Interrupt UART library with receive/transmit circular buffers
6 \author Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
7 \version 1.8.2.1
8 \date 2007-07-01
9 
10 Software: AVR-GCC 4.1, AVR Libc 1.4<br>
11 Hardware: any AVR with built-in UART, tested on AT90S8515 & ATmega8 at 4 Mhz<br>
12 License: GNU General Public License<br>
13 Usage: see Doxygen manual<br>
14 <br>
15 LICENSE:<br>
16  Copyright (C) 2006 Peter Fleury<br>
17 <br>
18  This program is free software; you can redistribute it and/or modify
19  it under the terms of the GNU General Public License as published by
20  the Free Software Foundation; either version 2 of the License, or
21  any later version.<br>
22 <br>
23  This program is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU General Public License for more details.
27 
28 ************************************************************************/
29 
54 #if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
55 #error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
56 #endif
57 
58 
67 #define UART_BAUD_SELECT(baudRate,xtalCpu) ((xtalCpu)/((baudRate)*16l)-1)
68 
73 #define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) (((xtalCpu)/((baudRate)*8l)-1)|0x8000)
74 
75 
77 #ifndef UART_RX_BUFFER_SIZE
78 #define UART_RX_BUFFER_SIZE 64
79 #endif
80 
81 #ifndef UART_TX_BUFFER_SIZE
82 #define UART_TX_BUFFER_SIZE 64
83 #endif
84 
86 #if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
87 #error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
88 #endif
89 
93 #define UART_FRAME_ERROR 0x0800 /* Framing Error by UART */
94 #define UART_OVERRUN_ERROR 0x0400 /* Overrun condition by UART */
95 #define UART_BUFFER_OVERFLOW 0x0200 /* receive ringbuffer overflow */
96 #define UART_NO_DATA 0x0100 /* no receive data available */
97 
98 
107 extern void uart_init(unsigned int baudrate);
108 
109 
134 extern unsigned int uart_getc(void);
135 
136 
141 extern void uart_putc(unsigned char data);
142 
143 
153 extern void uart_puts(const char *s );
154 
155 
166 extern void uart_puts_p(const char *progmem_s );
167 
171 #define uart_puts_P(__s) uart_puts_p(PSTR(__s))
172 
173 
174 
176 extern void uart1_init(unsigned int baudrate);
178 extern unsigned int uart1_getc(void);
180 extern void uart1_putc(unsigned char data);
182 extern void uart1_puts(const char *s );
184 extern void uart1_puts_p(const char *s );
186 #define uart1_puts_P(__s) uart1_puts_p(PSTR(__s))
187 
191 #endif // UART_H
void uart1_puts_p(const char *s)
Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ...
void uart1_putc(unsigned char data)
Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) ...
void uart_puts(const char *s)
Put string to ringbuffer for transmitting via UART.
Definition: uart.c:440
unsigned int uart_getc(void)
Get received byte from ringbuffer.
Definition: uart.c:390
void uart1_init(unsigned int baudrate)
Initialize USART1 (only available on selected ATmegas)
void uart_puts_p(const char *progmem_s)
Put string from program memory to ringbuffer for transmitting via UART.
Definition: uart.c:452
void uart_init(unsigned int baudrate)
Initialize UART and set baudrate.
Definition: uart.c:313
unsigned int uart1_getc(void)
Get received byte of USART1 from ringbuffer. (only available on selected ATmega)
void uart_putc(unsigned char data)
Put byte to ringbuffer for transmitting via UART.
Definition: uart.c:416
void uart1_puts(const char *s)
Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) ...