summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/hd61602.h
blob: 8a76b0b2bd83578e2024faf0a5e078152dde1c9a (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
// license:BSD-3-Clause
// copyright-holders:m1macrophage

/*
Hitachi HD61602 LCD Driver.
51 segment outputs, 4 common outputs, configurable duty cycle.

Pinout (80-pin QFP)

pin     desc
------------------------------
1     = VDD
2     = READY
3     = _CS
4     = _WE
5     = _RE
6     = SB
7-10  = D7-D4
11    = VSS
12-15 = D3-D0
16    = VREF1
17    = VREF2
18,19 = VC2
20-22 = V1-V3
23-26 = COM0-COM3
27-77 = SEG50-SEG0
78    = SYNC
79,80 = OSC2,OSC1
*/

#ifndef MAME_VIDEO_HD61602_H
#define MAME_VIDEO_HD61602_H

#pragma once

class hd61602_device : public device_t
{
public:
	static constexpr const int NCOM = 4;   // COM (common) outputs, aka rows.
	static constexpr const int NSEG = 51;  // SEG (segment) outputs, aka columns.

	hd61602_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0) ATTR_COLD;

	auto write_segs() { return m_write_segs.bind(); }

	void data_w(u8 data);

	// Byte counter resets when /CS and /RE are both driven low.
	void reset_counter_strobe();

protected:
	virtual void device_start() override ATTR_COLD;

private:
	void set_ram_bit(u8 com, u8 seg, u8 bit);
	void set_drive_mode(u8 drive_mode);
	TIMER_CALLBACK_MEMBER(refresh_timer_tick);

	enum display_mode
	{
		DM_STATIC = 0,
		DM_HALF,     // 1/2 duty cycle.
		DM_THIRD,    // 1/3 duty cycle.
		DM_QUARTER,  // 1/4 duty cycle.
	};

	emu_timer *m_refresh_timer;
	devcb_write64 m_write_segs;

	u8 m_count;
	u16 m_data;
	std::array<u64, NCOM> m_ram;
	bool m_blank;
	u8 m_display_mode;
	u8 m_drive_mode;
	u8 m_com_count;
	u8 m_active_com;
};

DECLARE_DEVICE_TYPE(HD61602, hd61602_device)

#endif // MAME_VIDEO_HD61602_H