1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/***************************************************************************
SH7604 SCI Controller
Lies at 0xfffffe00-0xfffffe0f
TODO:
- diserial;
- CPU callbacks for RX and TX;
***************************************************************************/
#include "emu.h"
#include "sh7604_sci.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// device type definition
DEFINE_DEVICE_TYPE(SH7604_SCI, sh7604_sci_device, "sh7604sci", "SH7604 SCI Controller")
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
uint8_t sh7604_sci_device::serial_mode_r()
{
return m_smr;
}
void sh7604_sci_device::serial_mode_w(uint8_t data)
{
m_smr = data;
logerror("%s: serial mode set:\n",tag());
logerror("\tCommunication Mode: %s mode\n",data & 0x80 ? "clocked synchronous" : "asynchronous");
logerror("\tCharacter Length: %s mode\n",data & 0x40 ? "7-bit" : "8-bit");
logerror("\tParity Enable: %s\n",data & 0x20 ? "yes" : "no");
logerror("\tParity Mode: %s\n",data & 0x10 ? "Odd" : "Even");
logerror("\tStop bits: %s\n",data & 0x08 ? "2" : "1");
logerror("\tMultiprocessor mode: %s\n",data & 0x04 ? "yes" : "no");
logerror("\tClock select: clock/%d\n",4 << ((data & 0x03)*2));
}
uint8_t sh7604_sci_device::serial_control_r()
{
return m_scr;
}
void sh7604_sci_device::serial_control_w(uint8_t data)
{
m_scr = data;
if(data & 0x30)
throw emu_fatalerror("%s: enabled serial control %02x\n", tag(),data);
}
uint8_t sh7604_sci_device::serial_status_r()
{
return m_ssr;
}
void sh7604_sci_device::serial_ack_w(uint8_t data)
{
// TODO: verify this
m_ssr = (m_ssr & 0x06) | (m_ssr & data & 0xf9);
}
uint8_t sh7604_sci_device::bitrate_r()
{
return m_brr;
}
void sh7604_sci_device::bitrate_w(uint8_t data)
{
m_brr = data;
}
uint8_t sh7604_sci_device::transmit_data_r()
{
// ...
return 0;
}
void sh7604_sci_device::transmit_data_w(uint8_t data)
{
// ...
}
uint8_t sh7604_sci_device::receive_data_r()
{
// ...
return 0;
}
void sh7604_sci_device::sci_regs(address_map &map)
{
map(0x00, 0x00).rw(FUNC(sh7604_sci_device::serial_mode_r), FUNC(sh7604_sci_device::serial_mode_w));
map(0x01, 0x01).rw(FUNC(sh7604_sci_device::bitrate_r), FUNC(sh7604_sci_device::bitrate_w));
map(0x02, 0x02).rw(FUNC(sh7604_sci_device::serial_control_r), FUNC(sh7604_sci_device::serial_control_w));
map(0x03, 0x03).rw(FUNC(sh7604_sci_device::transmit_data_r), FUNC(sh7604_sci_device::transmit_data_w));
map(0x04, 0x04).rw(FUNC(sh7604_sci_device::serial_status_r), FUNC(sh7604_sci_device::serial_ack_w));
map(0x05, 0x05).r(FUNC(sh7604_sci_device::receive_data_r));
}
//-------------------------------------------------
// sh7604_sci_device - constructor
//-------------------------------------------------
sh7604_sci_device::sh7604_sci_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, SH7604_SCI, tag, owner, clock)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sh7604_sci_device::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void sh7604_sci_device::device_reset()
{
m_smr = 0;
m_scr = 0;
m_ssr = STATUS_TDRE|STATUS_TEND; //0x84;
m_brr = 0xff;
}
//**************************************************************************
// READ/WRITE HANDLERS
//**************************************************************************
uint8_t sh7604_sci_device::read(address_space &space, offs_t offset)
{
return space.read_byte(offset);
}
void sh7604_sci_device::write(address_space &space, offs_t offset, uint8_t data)
{
space.write_byte(offset,data);
}
|