summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/com52c50.cpp
blob: 7f4ad470c0178188885de373be605162ea4f0742 (plain) (blame)
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:AJR
/***************************************************************************

    Standard Microsystems Corp. COM52C50 Twinax Interface Circuit (TIC)

    Skeleton device.

***************************************************************************/

#include "emu.h"
#include "com52c50.h"


// device type definition
DEFINE_DEVICE_TYPE(COM52C50, com52c50_device, "com52c50", "SMC COM52C50 TIC")

com52c50_device::com52c50_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
	: device_t(mconfig, COM52C50, tag, owner, clock)
	, m_int1_callback(*this)
	, m_int2_callback(*this)
	, m_rx_dma_callback(*this)
	, m_tx_dma_callback(*this)
	, m_int_mask(0)
	, m_int_status(0)
	, m_zero_fill(0)
	, m_present_address(0)
	, m_rx_status(0)
	, m_tx_status(0)
	, m_control(0)
	, m_mode(0)
{
}

void com52c50_device::map(address_map &map)
{
	map(0, 0).w(FUNC(com52c50_device::mode_w));
	map(1, 1).rw(FUNC(com52c50_device::int_status_r), FUNC(com52c50_device::int_mask_w));
	map(2, 2).rw(FUNC(com52c50_device::rx_status_r), FUNC(com52c50_device::address_select_w));
	map(3, 3).rw(FUNC(com52c50_device::rx_buffer_r), FUNC(com52c50_device::control_w));
	map(4, 4).w(FUNC(com52c50_device::zero_fill_w));
	map(5, 5).rw(FUNC(com52c50_device::present_address_r), FUNC(com52c50_device::present_address_w));
	map(6, 6).mirror(1).r(FUNC(com52c50_device::tx_status_r));
	map(6, 6).w(FUNC(com52c50_device::tx_buffer_w));
	map(7, 7).w(FUNC(com52c50_device::tx_buffer_eom_w));
}

void com52c50_device::device_start()
{
	save_item(NAME(m_int_mask));
	save_item(NAME(m_int_status));
	save_item(NAME(m_zero_fill));
	save_item(NAME(m_present_address));
	save_item(NAME(m_rx_status));
	save_item(NAME(m_tx_status));
	save_item(NAME(m_control));
	save_item(NAME(m_mode));
}

void com52c50_device::device_reset()
{
	m_int_mask = 0;
	m_int_status = 0;
	m_zero_fill = 0;
	m_rx_status = 0;
	m_tx_status = 0;
	m_control = 0x01;
	m_mode = 0;

	m_int1_callback(CLEAR_LINE);
	m_int2_callback(CLEAR_LINE);
}

u8 com52c50_device::rx_buffer_r()
{
	if (!machine().side_effects_disabled())
		logerror("%s: Reading data from RX buffer\n", machine().describe_context());
	return 0;
}

void com52c50_device::tx_buffer_w(u8 data)
{
	logerror("%s: Writing %02X to TX buffer\n", machine().describe_context(), data);
}

void com52c50_device::tx_buffer_eom_w(u8 data)
{
	logerror("%s: Writing %02X to TX buffer EOM\n", machine().describe_context(), data);
}

void com52c50_device::zero_fill_w(u8 data)
{
	logerror("%s: Writing %02X to zero fill register\n", machine().describe_context(), data);
	m_zero_fill = data;
}

void com52c50_device::int_mask_w(u8 data)
{
	logerror("%s: Writing %02X to interrupt mask register\n", machine().describe_context(), data);
	m_int_mask = data;
}

void com52c50_device::address_select_w(u8 data)
{
	logerror("%s: Writing %02X to address select register\n", machine().describe_context(), data);
}

u8 com52c50_device::present_address_r()
{
	return m_present_address;
}

void com52c50_device::present_address_w(u8 data)
{
	logerror("%s: Writing %02X to present address register\n", machine().describe_context(), data);
	m_present_address = data & 0x07;
}

u8 com52c50_device::int_status_r()
{
	return m_int_status;
}

u8 com52c50_device::rx_status_r()
{
	return m_rx_status | (m_present_address << 1);
}

u8 com52c50_device::tx_status_r()
{
	return m_tx_status;
}

void com52c50_device::control_w(u8 data)
{
	if (!BIT(data, 0))
	{
		logerror("%s: Software reset\n", machine().describe_context());

		m_int_mask = 0;
		m_int_status = 0;
		m_zero_fill = 0;
		m_rx_status = 0;
		m_tx_status = 0;
		m_mode = 0;
	}

	logerror("%s: Writing %02X to control register\n", machine().describe_context(), data);
	m_control = data;
}

void com52c50_device::mode_w(u8 data)
{
	logerror("%s: Writing %02X to mode register\n", machine().describe_context(), data);
	m_mode = data;
}