openMSX
Main Page
Namespaces
Classes
Files
File List
File Members
serial
I8251.hh
Go to the documentation of this file.
1
// This class implements the Intel 8251 chip (UART)
2
3
#ifndef I8251_HH
4
#define I8251_HH
5
6
#include "
ClockPin.hh
"
7
#include "
SerialDataInterface.hh
"
8
#include "
Schedulable.hh
"
9
#include "
openmsx.hh
"
10
11
namespace
openmsx {
12
13
class
I8251Interface
:
public
SerialDataInterface
14
{
15
public
:
16
virtual
~I8251Interface
() {}
17
virtual
void
setRxRDY
(
bool
status,
EmuTime::param
time) = 0;
18
virtual
void
setDTR
(
bool
status,
EmuTime::param
time) = 0;
19
virtual
void
setRTS
(
bool
status,
EmuTime::param
time) = 0;
20
virtual
bool
getDSR
(
EmuTime::param
time) = 0;
21
virtual
bool
getCTS
(
EmuTime::param
time) = 0;
// TODO use this
22
virtual
void
signal
(
EmuTime::param
time) = 0;
23
};
24
25
class
I8251
:
public
SerialDataInterface
,
public
Schedulable
26
{
27
public
:
28
I8251
(
Scheduler
& scheduler,
I8251Interface
& interf,
EmuTime::param
time);
29
30
void
reset
(
EmuTime::param
time);
31
byte
readIO
(
word
port,
EmuTime::param
time);
32
byte
peekIO
(
word
port,
EmuTime::param
time)
const
;
33
void
writeIO
(
word
port,
byte
value,
EmuTime::param
time);
34
ClockPin
&
getClockPin
();
35
bool
isRecvReady
();
36
bool
isRecvEnabled
();
37
38
// SerialDataInterface
39
virtual
void
setDataBits
(
DataBits
bits);
40
virtual
void
setStopBits
(
StopBits
bits);
41
virtual
void
setParityBit
(
bool
enable,
ParityBit
parity);
42
virtual
void
recvByte
(
byte
value,
EmuTime::param
time);
43
44
// Schedulable
45
virtual
void
executeUntil
(
EmuTime::param
time,
int
userData);
46
47
template
<
typename
Archive>
48
void
serialize
(Archive& ar,
unsigned
version);
49
50
// public for serialize
51
enum
CmdFaze
{
52
FAZE_MODE
,
FAZE_SYNC1
,
FAZE_SYNC2
,
FAZE_CMD
53
};
54
55
private
:
56
void
setMode(
byte
mode);
57
void
writeCommand(
byte
value,
EmuTime::param
time);
58
byte
readStatus(
EmuTime::param
time);
59
byte
readTrans(
EmuTime::param
time);
60
void
writeTrans(
byte
value,
EmuTime::param
time);
61
void
send(
byte
value,
EmuTime::param
time);
62
63
I8251Interface
& interf;
64
ClockPin
clock;
65
unsigned
charLength;
66
67
CmdFaze
cmdFaze;
68
SerialDataInterface::DataBits
recvDataBits;
69
SerialDataInterface::StopBits
recvStopBits;
70
SerialDataInterface::ParityBit
recvParityBit;
71
bool
recvParityEnabled;
72
byte
recvBuf;
73
bool
recvReady;
74
75
byte
sendByte;
76
byte
sendBuffer;
77
78
byte
status;
79
byte
command;
80
byte
mode;
81
byte
sync1, sync2;
82
};
83
84
}
// namespace openmsx
85
86
#endif
Generated on Sun May 19 2013 12:18:12 for openMSX by
1.8.1.2