/* Serial header file License : GPL (c) Adam Majerczyk */ #ifndef ___SERIAL_H #define ___SERIAL_H #include "global.h" // for a fcpu of 11.0592, or 14,7456Mhz // all this modes works with 0 percent // of error-rating // for all other fcpu ( 8Mhz,16Mhz ...) // all modes excepting the 230,4 have // a little errorrating. #define UART_BAUD_RATE_2400 2400 #define UART_BAUD_RATE_4800 4800 #define UART_BAUD_RATE_9600 9600 #define UART_BAUD_RATE_14400 14400 #define UART_BAUD_RATE_19200 19200 #define UART_BAUD_RATE_28800 28800 #define UART_BAUD_RATE_38400 38400 #define UART_BAUD_RATE_57600 57600 #define UART_BAUD_RATE_76800 76800 #define UART_BAUD_RATE_115200 115200 #define UART_BAUD_RATE_230400 230400 //values for UBRR when fosc=14,7456Mhz, //and U2X = 0 // baud value // 2400 383 // 4800 191 // 9600 95 // 14400 63 // 19200 47 // 28800 31 // 38400 23 // 57600 15 // 76800 11 //115200 7 //230400 3 //this do it automatically #define UART_BAUD_SELECT_2400 (F_CPU/(UART_BAUD_RATE_2400*16L)-1) #define UART_BAUD_SELECT_4800 (F_CPU/(UART_BAUD_RATE_4800*16L)-1) #define UART_BAUD_SELECT_9600 (F_CPU/(UART_BAUD_RATE_9600*16L)-1) #define UART_BAUD_SELECT_14400 (F_CPU/(UART_BAUD_RATE_14400*16L)-1) #define UART_BAUD_SELECT_19200 (F_CPU/(UART_BAUD_RATE_19200*16L)-1) #define UART_BAUD_SELECT_28800 (F_CPU/(UART_BAUD_RATE_28800*16L)-1) #define UART_BAUD_SELECT_38400 (F_CPU/(UART_BAUD_RATE_38400*16L)-1) #define UART_BAUD_SELECT_57600 (F_CPU/(UART_BAUD_RATE_57600*16L)-1) #define UART_BAUD_SELECT_76800 (F_CPU/(UART_BAUD_RATE_76800*16L)-1) #define UART_BAUD_SELECT_115200 (F_CPU/(UART_BAUD_RATE_115200*16L)-1) #define UART_BAUD_SELECT_230400 (F_CPU/(UART_BAUD_RATE_230400*16L)-1) extern void ser_init(void); extern void ser_putc(unsigned char c); extern void ser_puts(unsigned char *s); extern int ser_gets(unsigned char *s, unsigned char len); extern unsigned char ser_getc(void); extern volatile unsigned char rcnt, rpos; extern volatile unsigned char busy; #endif