1 /*****************************************************************************
2 ** $Source: /cygdrive/d/Private/_SVNROOT/bluemsx/blueMSX/Src/IoDevice/I8251.h,v $
3 **
4 ** $Revision: 1.7 $
5 **
6 ** $Date: 2008-03-31 19:42:19 $
7 **
8 ** More info: http://www.bluemsx.com
9 **
10 ** Copyright (C) 2003-2006 Daniel Vik, Tomas Karlsson
11 **
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License as published by
14 ** the Free Software Foundation; either version 2 of the License, or
15 ** (at your option) any later version.
16 **
17 ** This program is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ** GNU General Public License for more details.
21 **
22 ** You should have received a copy of the GNU General Public License
23 ** along with this program; if not, write to the Free Software
24 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 **
26 ******************************************************************************
27 */
28 #ifndef I8251_H
29 #define I8251_H
30 
31 #include "MsxTypes.h"
32 
33 typedef int  (*I8251Transmit) (void*, UInt8);
34 typedef int  (*I8251Signal) (void*);
35 typedef void (*I8251Set) (void*, int);
36 typedef int  (*I8251Get) (void*);
37 
38 typedef enum {
39     I8251_STOP_INV = 0,
40     I8251_STOP_1 = 2,
41     I8251_STOP_15 = 3,
42     I8251_STOP_2 = 4
43 } I8251StopBits;
44 
45 typedef enum {
46     I8251_PARITY_NONE,
47     I8251_PARITY_EVEN,
48     I8251_PARITY_ODD
49 } I8251Parity;
50 
51 typedef struct I8251 I8251;
52 
53 UInt8 i8251Peek(I8251* usart, UInt16 port);
54 UInt8 i8251Read(I8251* usart, UInt16 port);
55 void i8251Write(I8251* usart, UInt16 port, UInt8 value);
56 
57 void i8251RxData(I8251* usart, UInt8 value);
58 
59 void i8251LoadState(I8251* usart);
60 void i8251SaveState(I8251* usart);
61 
62 void i8251Reset(I8251* usart);
63 void i8251Destroy(I8251* usart);
64 
65 I8251* i8251Create(I8251Transmit transmit,    I8251Signal   signal,
66                    I8251Set      setDataBits, I8251Set      setStopBits,
67                    I8251Set      setParity,   I8251Set      setRxReady,
68                    I8251Set      setDtr,      I8251Set      setRts,
69                    I8251Get      getDtr,      I8251Get      getRts,
70                    void* ref);
71 
72 #endif
73