12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /*----------------------------------------------------------------------------
- Copyright: Radig Ulrich mailto: mail@ulrichradig.de
- Author: Radig Ulrich
- Remarks:
- known Problems: none
- Version: 24.10.2007
- Description: RS232 Routinen
- Dieses Programm ist freie Software. Sie können es unter den Bedingungen der
- GNU General Public License, wie von der Free Software Foundation veröffentlicht,
- weitergeben und/oder modifizieren, entweder gemäß Version 2 der Lizenz oder
- (nach Ihrer Option) jeder späteren Version.
- Die Veröffentlichung dieses Programms erfolgt in der Hoffnung,
- daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE,
- sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT
- FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
- Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
- Programm erhalten haben.
- Falls nicht, schreiben Sie an die Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- ------------------------------------------------------------------------------*/
- #ifndef _UART_H
- #define _UART_H
- //----------------------------------------------------------------------------
- #include <stdlib.h>
- #include <stdarg.h>
- #include <ctype.h>
- #include <string.h>
- #include <avr/io.h>
- #include <avr/pgmspace.h>
-
- //----------------------------------------------------------------------------
-
- //Die Quarzfrequenz auf dem Board
- #ifndef F_CPU
- #define F_CPU 14745600UL
- #endif //SYSCLK
-
- //Anpassen der seriellen Schnittstellen Register wenn ein ATMega128 benutzt wird
- #if defined (__AVR_ATmega128__)
- #define USR UCSR0A
- #define UCR UCSR0B
- #define UDR UDR0
- #define UBRR UBRR0L
- #define USART_RX USART0_RX_vect
- #endif
-
- #if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__)
- #define USR UCSR0A
- #define UCR UCSR0B
- #define UBRR UBRR0L
- #define EICR EICRB
- #define TXEN TXEN0
- #define RXEN RXEN0
- #define RXCIE RXCIE0
- #define UDR UDR0
- #define UDRE UDRE0
- #define USART_RX USART0_RX_vect
- #endif
-
- #if defined (__AVR_ATmega32__)
- #define USR UCSRA
- #define UCR UCSRB
- #define UBRR UBRRL
- #define EICR EICRB
- #define USART_RX USART_RXC_vect
- #endif
-
- #if defined (__AVR_ATmega8__)
- #define USR UCSRA
- #define UCR UCSRB
- #define UBRR UBRRL
- #endif
-
- #if defined (__AVR_ATmega88__)
- #define USR UCSR0A
- #define UCR UCSR0B
- #define UBRR UBRR0L
- #define TXEN TXEN0
- #define UDR UDR0
- #define UDRE UDRE0
- #endif
- //----------------------------------------------------------------------------
-
- void usart_init(unsigned long baudrate);
- void usart_write_char(char c);
- void usart_write_str(char *str);
-
- void usart_write_P (const char *Buffer,...);
- #define usart_write(format, args...) usart_write_P(PSTR(format) , ## args)
-
- //----------------------------------------------------------------------------
- #endif //_UART_H
|