Rename myself
[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  * \version $Id$
36  * \author Bernie Innocenti <bernie@codewiz.org>
37  * \author Francesco Sacchi <batt@develer.com>
38  */
39
40 #ifndef DRV_SER_SIMPLE_AVR_H
41 #define DRV_SER_SIMPLE_AVR_H
42
43 #warning FIXME:This module is obsolete, yuo must refactor it.
44
45 #if 0
46 /* For checking which serial driver is linked */
47 #define SER_SIMPLE
48
49 #include <appconfig.h>
50 #include <cfg/compiler.h>
51
52
53 #if 0
54 #if CPU_AVR
55         typedef uint8_t serstatus_t;
56
57         /* Software errors */
58         #define SERRF_RXFIFOOVERRUN  BV(0)  /**< Rx FIFO buffer overrun */
59         #define SERRF_RXTIMEOUT      BV(5)  /**< Receive timeout */
60         #define SERRF_TXTIMEOUT      BV(6)  /**< Transmit timeout */
61
62         /* Hardware errors */
63         #define SERRF_RXSROVERRUN    BV(3)  /**< Rx shift register overrun */
64         #define SERRF_FRAMEERROR     BV(4)  /**< Stop bit missing */
65         #define SERRF_PARITYERROR    BV(7)  /**< Parity error */
66 #else
67         #error unknown architecture
68 #endif
69 /*\}*/
70
71 /**
72  * \name Serial hw numbers
73  *
74  * \{
75  */
76 enum
77 {
78 #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128
79         SER_UART0,
80         SER_UART1,
81         SER_SPI,
82 #elif CPU_AVR_ATMEGA103 || CPU_AVR_ATMEGA8
83         SER_UART0,
84         SER_SPI,
85 #else
86         #error unknown architecture
87 #endif
88         SER_CNT  /**< Number of serial ports */
89 };
90 /*\}*/
91 #endif
92
93 /** \name Parity settings for ser_setparity() */
94 /*\{*/
95 #define SER_PARITY_NONE  0
96 #define SER_PARITY_EVEN  2
97 #define SER_PARITY_ODD   3
98 /*\}*/
99
100
101 /** Serial handle structure */
102 struct Serial;
103
104 /* Function prototypes */
105 extern int _ser_putchar(int c);
106 extern int _ser_getchar(void);
107 extern int _ser_getchar_nowait(void);
108 /*
109 extern int ser_write(struct Serial *port, const void *buf, size_t len);
110 extern int ser_read(struct Serial *port, void *buf, size_t size);
111
112 extern int ser_printf(struct Serial *port, const char *format, ...) FORMAT(__printf__, 2, 3);
113
114 extern int ser_gets(struct Serial *port, char *buf, int size);
115 extern int ser_gets_echo(struct Serial *port, char *buf, int size, bool echo);
116 */
117 extern int _ser_print(const char *s);
118
119 extern void _ser_setbaudrate(unsigned long rate);
120 extern void _ser_setparity(int parity);
121 extern void _ser_settimeouts(void);
122 extern void _ser_setstatus(void);
123 /*
124 extern void ser_resync(struct Serial *port, time_t delay);
125 extern void ser_drain(struct Serial *port);
126 */
127 extern void _ser_purge(void);
128 extern struct Serial *_ser_open(void);
129 extern void _ser_close(void);
130
131 /**
132  * \name Functions implemented as macros
133  *
134  * \{
135  */
136 #define ser_putchar(c, port)        _ser_putchar(c)
137 #define ser_getchar(port)           _ser_getchar()
138 #define ser_getchar_nowait(port)    _ser_getchar_nowait()
139 #define ser_print(port, s)          _ser_print(s)
140 #define ser_setbaudrate(port, y)    _ser_setbaudrate(y)
141 #define ser_setparity(port, par)    _ser_setparity(par)
142 #define ser_settimeouts(port, y, z) _ser_settimeouts()
143 #define ser_purge(port)             _ser_purge()
144 #define ser_open(port)              _ser_open()
145 #define ser_getstatus(h)            0
146 #define ser_setstatus(h, x)         do {(void)(x);} while(0)
147 /* \} */
148
149 #endif /* DRV_SER_SIMPLE_AVR_H */
150
151 #endif