/* avr_uart.h provide functions to set up uart Copyright Henrik Björkman www.eit.se/hb 2007 This file 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 (at your option) 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. If you do modify it please make a note about it in the history section below. History 2005-02-16 Modified for atmega8 and renamed. Henrik Björkman 2007-03-15 Modified for atmega88. Henrik Björkman */ /* ------------------------------------------------------------------------- * BUGS * ------------------------------------------------------------------------- */ /* // port_or is not defined in iomacro.h (which gets included in io.h) while // __port_or has a definition. This seems to be a bug in iomacro.h #define port_or __port_or // ditto #define port_and __port_and */ /* ------------------------------------------------------------------------- * includes * ------------------------------------------------------------------------- */ #include #include #include #include "avr_cfg.h" #include "avr_uart.h" /* compatibilty macros for old style */ /* for new design instead of "sbi(DDRC,PC5);" use "DDRC|= _BV(PC5);" */ #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif #ifndef outp #define outp(value,sfr) (_SFR_BYTE(sfr) = value) #endif #ifndef inp #define inp(sfr) (_SFR_BYTE(sfr)) #endif /* ------------------------------------------------------------------------- * local variables and defines * ------------------------------------------------------------------------- */ #ifdef __AVR_ATmega8__ #define UART_OUTBUF_EMPTY() (!( UCSRA & (1<>8); UBRRL = (unsigned char)ubrr_value; /* Enable receiver and transmitter */ UCSRB = (1<>8); UBRR0L = (unsigned char)ubrr_value; /* Enable receiver and transmitter */ UCSR0B = (1<