summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/rs232/exorterm.cpp
blob: 58957a878e3bf702447068476688cd5191f6fb10 (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
// license:BSD-3-Clause
// copyright-holders:68bit

#include "emu.h"
#include "exorterm.h"

exorterm155_terminal_device::exorterm155_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
	: device_t(mconfig, SERIAL_TERMINAL_EXORTERM155, tag, owner, clock)
	, device_rs232_port_interface(mconfig, *this)
	, m_exorterm155(*this, "exorterm155")
	, m_flow_control(*this, "FLOW_CONTROL")
{
}

void exorterm155_terminal_device::device_add_mconfig(machine_config &config)
{
	EXORTERM155(config, m_exorterm155);
	m_exorterm155->rs232_conn_txd_handler().set(FUNC(exorterm155_terminal_device::output_rxd));
	m_exorterm155->rs232_conn_rts_handler().set(FUNC(exorterm155_terminal_device::route_term_rts));
	m_exorterm155->rs232_conn_dtr_handler().set(FUNC(exorterm155_terminal_device::route_term_dtr));
}

INPUT_PORTS_START(exorterm155_terminal)

	PORT_START("FLOW_CONTROL")
	PORT_CONFNAME(0x1, 1, "Flow Control") PORT_CHANGED_MEMBER(DEVICE_SELF, exorterm155_terminal_device, flow_control, 0)
	PORT_CONFSETTING(0x00, "None")
	PORT_CONFSETTING(0x01, "Terminal DTR to remote CTS")

INPUT_PORTS_END

ioport_constructor exorterm155_terminal_device::device_input_ports() const
{
	return INPUT_PORTS_NAME(exorterm155_terminal);
}

WRITE_LINE_MEMBER(exorterm155_terminal_device::input_txd)
{
	m_exorterm155->rs232_conn_rxd_w(state);
}

WRITE_LINE_MEMBER(exorterm155_terminal_device::route_term_rts)
{
	// Loop the terminal RTS output to the terminal CTS input.
	m_exorterm155->rs232_conn_cts_w(state);
}

// This terminal uses DTR for hardware flow control.
WRITE_LINE_MEMBER(exorterm155_terminal_device::route_term_dtr)
{
	if (m_flow_control->read())
	{
		// Connect the terminal DTR output to CTS at the other end.
		output_cts(state);
	}

	// Cache the state, in case the ioport setting changes.
	m_dtr = state;
}

INPUT_CHANGED_MEMBER(exorterm155_terminal_device::flow_control)
{
	if (newval)
		output_cts(m_dtr);
	else
		output_cts(0);
}

void exorterm155_terminal_device::device_start()
{
	save_item(NAME(m_dtr));
}

void exorterm155_terminal_device::device_reset()
{
	// To the terminal
	m_exorterm155->rs232_conn_cts_w(0);

	// To the computer
	output_dcd(0);
	output_dsr(0);
	if (!m_flow_control->read())
		output_cts(0);
}

DEFINE_DEVICE_TYPE(SERIAL_TERMINAL_EXORTERM155, exorterm155_terminal_device, "exorterm155_terminal", "EXORterm 155 Terminal")