Go to the documentation of this file.00001
00038 #ifndef _UART_H_
00039 #define _UART_H_ 1
00040
00041
00042
00043 #define UART_DDR DDRD ///< Data Directory Register of the desired USART
00044 #define RXPIN_bm (1<<2) ///< Bitmask of the RX-Pin
00045 #define TXPIN_bm (1<<3) ///< Bitmask of the TX-Pin
00046
00047 #define UART_DATA UDR ///< USART Data Register
00048
00049 #define RXC_vect USART_RXC_vect ///< RX-Complete Interrupt Vector
00050 #define DRE_vect USART_UDRE_vect ///< Data-Register-Empty Interrupt Vector
00051
00056 #define UART_RX_BUFFER_SIZE 64
00057
00062 #define UART_TX_BUFFER_SIZE 64
00063
00064
00079 #define UBRR_val 3
00080
00085 #define UART_CHRSIZE_9BIT 0
00086
00092 #define UART_PRINTF_COMPATIBILITY 1
00093
00100 #define UART_MPCM_ENABLE 0
00101
00106 void uart_init(void);
00107
00119 void uart_sendbyte(uint8_t data);
00120
00131 uint8_t uart_getbyte(uint8_t *data);
00132
00138 uint8_t uart_senddata(uint8_t data);
00139
00148 uint8_t uart_sendid(uint8_t data);
00149
00150 #if UART_MPCM_ENABLE == 1
00151
00159 uint8_t uart_senddata(uint8_t data);
00160
00169 uint8_t uart_sendid(uint8_t data);
00170 #endif
00171
00173 inline void uart_mpcm_en(void) {
00174 UCSRA |= (1<<MPCM);
00175 }
00176
00178 inline void uart_mpcm_dis(void) {
00179 UCSRA &= ~(1<<MPCM);
00180 }
00181
00183 inline void uart_udre_int_en(void) {
00184 UCSRB |= (1<<UDRIE);
00185 }
00186
00188 inline void uart_udre_int_dis(void) {
00189 UCSRB &= ~(1<<UDRIE);
00190 }
00191
00193 inline void uart_rxc_int_en(void) {
00194 UCSRB |= (1<<RXCIE);
00195 }
00196
00198 inline void uart_rxc_int_dis(void) {
00199 UCSRB &= ~(1<<RXCIE);
00200 }
00201
00202
00203 #if UART_PRINTF_COMPATIBILITY == 1
00204 #include <stdio.h>
00205
00220 int uart_putchar(char c, FILE *sream);
00221
00231 int uart_getchar(FILE *stream);
00232
00233 #endif
00234
00235 #endif //_UART_H_