summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/controlid.cpp
blob: ee09bd2f95644b7610238a49dec20c8e4533b7b7 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// license:BSD-3-Clause
// copyright-holder:FelipeSanches
//
// Control ID x628
//
// This is a fingerprint reader device
//
// TODO: Emulate the other CPU board (supposedly runs the Linux kernel on
//       a dedicated SoC targeting image-processing typically used on
//       fingerprint readers). The SoC is labelled ZKSoftware ZK6001
//       and someone online suggested it may be a rebranded device from
//       Ingenic, so likely a MIPS32 or MIPS64.
//
//       It has a 32Mb flash-rom and an ethernet controller
//       (model is Realtek RTL8201BL)
//
//       While the 8051 board has a tiny buzzer (and a battery-backed RAM)
//       the other PCB interfaces with an audio speaker.
//
//       There's also an RJ45 connector (ethernet port) as well as a
//       DB9 connector which seems to be used for a serial interface.
//
//       Finally, there are 2 LEDs, a 128x64 LCD with blueish backlight
//       and a keypad with the following layout:
//
//       1  2  3   ESC
//       4  5  6   MENU
//       7  8  9   UP-ARROW
//       .  0  OK  DOWN-ARROW

#include "emu.h"
#include "cpu/mcs51/mcs51.h"
#include "video/nt7534.h"
#include "emupal.h"
#include "screen.h"

class controlidx628_state : public driver_device
{
public:
	controlidx628_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_lcdc(*this, "nt7534")
	{ }

	void controlidx628(machine_config &config);

protected:
	virtual void machine_start() override;

private:
	DECLARE_WRITE8_MEMBER(p0_w);
	DECLARE_READ8_MEMBER(p1_r);
	DECLARE_WRITE8_MEMBER(p1_w);
	DECLARE_READ8_MEMBER(p2_r);
	DECLARE_READ8_MEMBER(p3_r);
	DECLARE_WRITE8_MEMBER(p3_w);
	void controlidx628_palette(palette_device &palette) const;

	void io_map(address_map &map);

	required_device<nt7534_device> m_lcdc;

	uint8_t m_p0_data;
	uint8_t m_p1_data;
	uint8_t m_p3_data;
};


void controlidx628_state::machine_start()
{
	m_p0_data = 0xff;
	m_p1_data = 0xff;
	m_p3_data = 0xff;

	save_item(NAME(m_p0_data));
	save_item(NAME(m_p1_data));
	save_item(NAME(m_p3_data));
}

/*************************
* Memory map information *
*************************/

void controlidx628_state::io_map(address_map &map)
{
	map(0x8000, 0xffff).ram();
}


WRITE8_MEMBER(controlidx628_state::p0_w)
{
	m_p0_data = data;
}

READ8_MEMBER(controlidx628_state::p1_r)
{
	// P1.1 is used for serial I/O; P1.4 and P1.5 are also used bidirectionally
	return 0xcd;
}

WRITE8_MEMBER(controlidx628_state::p1_w)
{
	if ((BIT(m_p1_data, 6) == 0) && (BIT(data, 6) == 1)) // on raising-edge of bit 6
	{
		m_lcdc->write(BIT(data, 7), m_p0_data);
	}
	// P1.0 is also used as a serial I/O clock
	m_p1_data = data;
}

READ8_MEMBER(controlidx628_state::p2_r)
{
	// Low nibble used for input
	return 0xf0;
}

READ8_MEMBER(controlidx628_state::p3_r)
{
	// P3.3 (INT1) and P3.4 (T0) used bidirectionally
	return 0xff;
}

WRITE8_MEMBER(controlidx628_state::p3_w)
{
	m_p3_data = data;
}

/*************************
*      Input ports       *
*************************/

//static INPUT_PORTS_START( controlidx628 )
//INPUT_PORTS_END

void controlidx628_state::controlidx628_palette(palette_device &palette) const
{
	// These colors were selected from a photo of the display
	// using the color-picker in Inkscape:
	palette.set_pen_color(0, rgb_t(0x06, 0x61, 0xee));
	palette.set_pen_color(1, rgb_t(0x00, 0x23, 0x84));
}

/*************************
*     Machine Driver     *
*************************/

void controlidx628_state::controlidx628(machine_config &config)
{
	// basic machine hardware
	at89s52_device &maincpu(AT89S52(config, "maincpu", XTAL(11'059'200)));
	maincpu.set_addrmap(AS_IO, &controlidx628_state::io_map);
	maincpu.port_out_cb<0>().set(FUNC(controlidx628_state::p0_w));
	maincpu.port_in_cb<1>().set(FUNC(controlidx628_state::p1_r));
	maincpu.port_out_cb<1>().set(FUNC(controlidx628_state::p1_w));
	maincpu.port_in_cb<2>().set(FUNC(controlidx628_state::p2_r));
	maincpu.port_in_cb<3>().set(FUNC(controlidx628_state::p3_r));
	maincpu.port_out_cb<3>().set(FUNC(controlidx628_state::p3_w));

	// video hardware
	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD));
	screen.set_refresh_hz(50);
	screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate
	screen.set_size(132, 65);
	screen.set_visarea(3, 130, 0, 63);
	screen.set_screen_update("nt7534", FUNC(nt7534_device::screen_update));
	screen.set_palette("palette");

	PALETTE(config, "palette", FUNC(controlidx628_state::controlidx628_palette), 2);

	NT7534(config, m_lcdc);
}


/*************************
*        Rom Load        *
*************************/

ROM_START( cidx628 )
	ROM_REGION( 0x2000, "maincpu", 0 )
	ROM_LOAD( "controlid_x628.u1",   0x0000, 0x2000, CRC(500d79b4) SHA1(5522115f2da622db389e067fcdd4bccb7aa8561a) )
ROM_END

COMP(200?, cidx628, 0, 0, controlidx628, 0, controlidx628_state, empty_init, "ControlID", "X628", MACHINE_NOT_WORKING|MACHINE_NO_SOUND)