Remove \version svn tag.
[bertos.git] / bertos / cpu / avr / drv / ser_simple_avr.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
30  * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
31  * -->
32  *
33  * \brief Simple serial I/O driver
34  *
35  * \author Bernie Innocenti <bernie@codewiz.org>
36  * \author Francesco Sacchi <batt@develer.com>
37  */
38
39 #ifndef DRV_SER_SIMPLE_AVR_H
40 #define DRV_SER_SIMPLE_AVR_H
41
42 #warning FIXME:This module is obsolete, yuo must refactor it.
43
44 #if 0
45 /* For checking which serial driver is linked */
46 #define SER_SIMPLE
47
48 #include <appconfig.h>
49 #include <cfg/compiler.h>
50
51
52 #if 0
53 #if CPU_AVR
54         typedef uint8_t serstatus_t;
55
56         /* Software errors */
57         #define SERRF_RXFIFOOVERRUN  BV(0)  /**< Rx FIFO buffer overrun */
58         #define SERRF_RXTIMEOUT      BV(5)  /**< Receive timeout */
59         #define SERRF_TXTIMEOUT      BV(6)  /**< Transmit timeout */
60
61         /* Hardware errors */
62         #define SERRF_RXSROVERRUN    BV(3)  /**< Rx shift register overrun */
63         #define SERRF_FRAMEERROR     BV(4)  /**< Stop bit missing */
64         #define SERRF_PARITYERROR    BV(7)  /**< Parity error */
65 #else
66         #error unknown architecture
67 #endif
68 /*\}*/
69
70 /**
71  * \name Serial hw numbers
72  *
73  * \{
74  */
75 enum
76 {
77 #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128
78         SER_UART0,
79         SER_UART1,
80         SER_SPI,
81 #elif CPU_AVR_ATMEGA103 || CPU_AVR_ATMEGA8
82         SER_UART0,
83         SER_SPI,
84 #else
85         #error unknown architecture
86 #endif
87         SER_CNT  /**< Number of serial ports */
88 };
89 /*\}*/
90 #endif
91
92 /** \name Parity settings for ser_setparity() */
93 /*\{*/
94 #define SER_PARITY_NONE  0
95 #define SER_PARITY_EVEN  2
96 #define SER_PARITY_ODD   3
97 /*\}*/
98
99
100 /** Serial handle structure */
101 struct Serial;
102
103 /* Function prototypes */
104 extern int _ser_putchar(int c);
105 extern int _ser_getchar(void);
106 extern int _ser_getchar_nowait(void);
107 /*
108 extern int ser_write(struct Serial *port, const void *buf, size_t len);
109 extern int ser_read(struct Serial *port, void *buf, size_t size);
110
111 extern int ser_printf(struct Serial *port, const char *format, ...) FORMAT(__printf__, 2, 3);
112
113 extern int ser_gets(struct Serial *port, char *buf, int size);
114 extern int ser_gets_echo(struct Serial *port, char *buf, int size, bool echo);
115 */
116 extern int _ser_print(const char *s);
117
118 extern void _ser_setbaudrate(unsigned long rate);
119 extern void _ser_setparity(int parity);
120 extern void _ser_settimeouts(void);
121 extern void _ser_setstatus(void);
122 /*
123 extern void ser_resync(struct Serial *port, time_t delay);
124 extern void ser_drain(struct Serial *port);
125 */
126 extern void _ser_purge(void);
127 extern struct Serial *_ser_open(void);
128 extern void _ser_close(void);
129
130 /**
131  * \name Functions implemented as macros
132  *
133  * \{
134  */
135 #define ser_putchar(c, port)        _ser_putchar(c)
136 #define ser_getchar(port)           _ser_getchar()
137 #define ser_getchar_nowait(port)    _ser_getchar_nowait()
138 #define ser_print(port, s)          _ser_print(s)
139 #define ser_setbaudrate(port, y)    _ser_setbaudrate(y)
140 #define ser_setparity(port, par)    _ser_setparity(par)
141 #define ser_settimeouts(port, y, z) _ser_settimeouts()
142 #define ser_purge(port)             _ser_purge()
143 #define ser_open(port)              _ser_open()
144 #define ser_getstatus(h)            0
145 #define ser_setstatus(h, x)         do {(void)(x);} while(0)
146 /* \} */
147
148 #endif /* DRV_SER_SIMPLE_AVR_H */
149
150 #endif