0.6.3 Changes since last version
[digitaldcpower] / uart.h
1 /* vim: set sw=8 ts=8 si et: */
2 /*************************************************************************
3  Title:   C include file for uart
4  Target:    atmega8
5  Copyright: GPL, Guido Socher
6 ***************************************************************************/
7 #ifndef UART_H
8 #define UART_H
9 #include <avr/pgmspace.h>
10
11 extern void uart_init(void);
12 extern void uart_poll_getchar_isr(void); // call this periodically from interrupt, has a buffer bigger than one char
13 extern unsigned char uart_getchar_isr_noblock(char *returnval); // get a char from buffer if available
14 extern void uart_sendchar(char c); // blocking, no buffer
15 extern void uart_sendstr(char *s); // blocking, no buffer
16 extern void uart_sendstr_p(const prog_char *progmem_s); // blocking, no buffer
17 /*
18 // you can either use the above _isr functions or one of the
19 // following two but you can not mix them.
20 extern char uart_getchar(void);
21 extern unsigned char uart_getchar_noblock(char *returnval);
22 extern void uart_flushRXbuf(void);
23 */
24
25 /*
26 ** macros for automatically storing string constant in program memory
27 */
28 #ifndef P
29 #define P(s) ({static const char c[] __attribute__ ((progmem)) = s;c;})
30 #endif
31 #define uart_sendstr_P(__s)         uart_sendstr_p(P(__s))
32
33 #endif /* UART_H */