uart  1.4
Serial stream for Xmega/Wrapper for UART-driver Xmega
 All Files Functions Variables Macros
uart.h
Go to the documentation of this file.
1 
37 #ifndef UART_H
38 #define UART_H
39 #endif
40 
41 #ifndef COMPILER_AVR_H
42 #include "avr_compiler.h"
43 #endif
44 
45 #ifndef USART_DRIVER_H
46 #include "usart_driver.h"
47 #endif
48 
52 #define UART_NO_DATA 0x0100
53 
54 uint16_t calc_bsel(uint32_t f_cpu, uint32_t baud, int8_t scale, uint8_t clk2x);
55 uint16_t uart_getc(USART_data_t *uart);
56 void uart_putc(USART_data_t *uart, uint8_t data);
57 void uart_puts(USART_data_t *uart, char *s);
58 void set_usart_txrx_direction(USART_t *usart);
59 void init_uart(USART_data_t *uart, USART_t *usart, uint32_t f_cpu, uint32_t baud, uint8_t clk2x);
60 void init_uart_levels(USART_data_t *uart, USART_t *usart,
61  uint32_t f_cpu, uint32_t baud, uint8_t clk2x,
62  USART_RXCINTLVL_t rxcIntLevel, USART_DREINTLVL_t dreIntLevel);
63 
64 #if ENABLE_UART_C0
65 
69 USART_data_t uartC0;
70 
75 ISR(USARTC0_RXC_vect)
76 {
77  USART_RXComplete(&uartC0.usart);
78 }
79 
84 ISR(USARTC0_DRE_vect)
85 {
86  USART_DataRegEmpty(&uartC0.usart);
87 }
88 #endif
89 
90 
91 #if ENABLE_UART_C1
92 
97 USART_data_t uartC1;
98 
103 ISR(USARTC1_RXC_vect)
104 {
105  USART_RXComplete(&uartC1);
106 }
107 
112 ISR(USARTC1_DRE_vect)
113 {
114  USART_DataRegEmpty(&uartC1);
115 }
116 #endif
117 
118 
119 #if ENABLE_UART_D0
120 
124 USART_data_t uartD0;
125 
130 ISR(USARTD0_RXC_vect)
131 {
132  USART_RXComplete(&uartD0);
133 }
134 
139 ISR(USARTD0_DRE_vect)
140 {
141  USART_DataRegEmpty(&uartD0);
142 }
143 #endif
144 
145 
146 #if ENABLE_UART_D1
147 
151 USART_data_t uartD1;
152 
157 ISR(USARTD1_RXC_vect)
158 {
159  USART_RXComplete(&uartD1);
160 }
161 
166 ISR(USARTD1_DRE_vect)
167 {
168  USART_DataRegEmpty(&uartD1);
169 }
170 #endif
171 
172 
173 #if ENABLE_UART_E0
174 
178 USART_data_t uartE0;
179 
184 ISR(USARTE0_RXC_vect)
185 {
186  USART_RXComplete(&uartE0);
187 }
188 
193 ISR(USARTE0_DRE_vect)
194 {
195  USART_DataRegEmpty(&uartE0);
196 }
197 #endif
198 
199 
200 #if ENABLE_UART_E1
201 
205 USART_data_t uartE1;
206 
211 ISR(USARTE1_RXC_vect)
212 {
213  USART_RXComplete(&uartE1);
214 }
215 
220 ISR(USARTE1_DRE_vect)
221 {
222  USART_DataRegEmpty(&uartE1);
223 }
224 #endif
225 
226 
227 #if ENABLE_UART_F0
228 
232 USART_data_t uartF0;
233 
238 ISR(USARTF0_RXC_vect)
239 {
240  USART_RXComplete(&uartF0);
241 }
242 
247 ISR(USARTF0_DRE_vect)
248 {
249  USART_DataRegEmpty(&uartF0);
250 }
251 #endif
252 
253 
254 #if ENABLE_UART_F1
255 
259 USART_data_t uartF1;
260 
265 ISR(USARTF1_RXC_vect)
266 {
267  USART_RXComplete(&uartF1);
268 }
269 
274 ISR(USARTF1_DRE_vect)
275 {
276  USART_DataRegEmpty(&uartF1);
277 }
278 #endif
279 
USART_data_t uartF0
Global declaration uart with databuffers for UARTF0. This variable is only defined if the macro ENABL...
Definition: uart.h:232
USART_data_t uartE1
Global declaration uart with databuffers for UARTE1. This variable is only defined if the macro ENABL...
Definition: uart.h:205
USART_data_t uartF1
Global declaration uart with databuffers for UARTF1. This variable is only defined if the macro ENABL...
Definition: uart.h:259
ISR(USARTC0_RXC_vect)
Interrupt Service Routine for receiving with UARTC0. This ISR is only defined if the macro ENABLE_UAR...
Definition: uart.h:75
uint16_t uart_getc(USART_data_t *uart)
Get a byte from the circular receive buffer.
Definition: uart.c:51
void init_uart(USART_data_t *uart, USART_t *usart, uint32_t f_cpu, uint32_t baud, uint8_t clk2x)
Initializes the UART.
Definition: uart.c:233
void init_uart_levels(USART_data_t *uart, USART_t *usart, uint32_t f_cpu, uint32_t baud, uint8_t clk2x, USART_RXCINTLVL_t rxcIntLevel, USART_DREINTLVL_t dreIntLevel)
Initializes the UART.
Definition: uart.c:269
USART_data_t uartC1
Global declaration uart with databuffers for UARTC1. This variable is only defined if the macro ENABL...
Definition: uart.h:97
USART_data_t uartD0
Global declaration uart with databuffers for UARTD0. This variable is only defined if the macro ENABL...
Definition: uart.h:124
USART_data_t uartE0
Global declaration uart with databuffers for UARTE0. This variable is only defined if the macro ENABL...
Definition: uart.h:178
void uart_putc(USART_data_t *uart, uint8_t data)
Write a byte to the circular transmit buffer.
Definition: uart.c:71
uint16_t calc_bsel(uint32_t f_cpu, uint32_t baud, int8_t scale, uint8_t clk2x)
Calculates the baud rate value BSEL.
Definition: uart.c:182
USART_data_t uartD1
Global declaration uart with databuffers for UARTD1. This variable is only defined if the macro ENABL...
Definition: uart.h:151
USART_data_t uartC0
Global declaration uart with databuffers for UARTC0. This variable is only defined if the macro ENABL...
Definition: uart.h:69
void set_usart_txrx_direction(USART_t *usart)
Set direction for the transmit and receive pin.
Definition: uart.c:100
void uart_puts(USART_data_t *uart, char *s)
Write a string to the circulair transmit buffer.
Definition: uart.c:85