summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2019-12-06 02:24:49 +0100
committer hap <happppp@users.noreply.github.com>2019-12-06 02:25:10 +0100
commitcc116dc97298912d19731a465ffc2bbd8864b81f (patch)
tree12422fdfb01a46df6b0fd3cf96033f37081a8bd8 /src/devices
parent41e5fd22e03cd78dd0b3efa7dd24141d14665208 (diff)
added LC7582 LCD Driver (nw)
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/video/lc7582.cpp100
-rw-r--r--src/devices/video/lc7582.h71
2 files changed, 171 insertions, 0 deletions
diff --git a/src/devices/video/lc7582.cpp b/src/devices/video/lc7582.cpp
new file mode 100644
index 00000000000..d062486e827
--- /dev/null
+++ b/src/devices/video/lc7582.cpp
@@ -0,0 +1,100 @@
+// license:BSD-3-Clause
+// copyright-holders:hap
+/*
+
+Sanyo LC7582 LCD Driver
+
+53 outputs (static), or 106 outputs (1/2 duty)
+
+TODO:
+- OSC pin (input is R/C)
+- AD/DSP function
+
+*/
+
+#include "emu.h"
+#include "video/lc7582.h"
+
+
+DEFINE_DEVICE_TYPE(LC7582, lc7582_device, "lc7582", "Sanyo LC7582 LCD Driver")
+
+//-------------------------------------------------
+// constructor
+//-------------------------------------------------
+
+lc7582_device::lc7582_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) :
+ device_t(mconfig, type, tag, owner, clock),
+ m_latch{0, 0},
+ m_write_segs(*this)
+{ }
+
+lc7582_device::lc7582_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
+ lc7582_device(mconfig, LC7582, tag, owner, clock)
+{ }
+
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void lc7582_device::device_start()
+{
+ // resolve callbacks
+ m_write_segs.resolve_safe();
+
+ // register for savestates
+ save_item(NAME(m_data));
+ save_item(NAME(m_ce));
+ save_item(NAME(m_clk));
+ save_item(NAME(m_blank));
+ save_item(NAME(m_duty));
+ save_item(NAME(m_addsp));
+ save_item(NAME(m_shift));
+ save_item(NAME(m_latch));
+}
+
+
+//-------------------------------------------------
+// handlers
+//-------------------------------------------------
+
+void lc7582_device::refresh_output()
+{
+ m_write_segs(0, m_blank ? 0 : m_latch[0]);
+ m_write_segs(1, (m_blank || !m_duty) ? 0 : m_latch[1]);
+}
+
+WRITE_LINE_MEMBER(lc7582_device::clk_w)
+{
+ state = (state) ? 1 : 0;
+
+ // clock shift register
+ if (state && !m_clk)
+ m_shift = m_shift >> 1 | u64(m_data) << 55;
+
+ m_clk = state;
+}
+
+WRITE_LINE_MEMBER(lc7582_device::ce_w)
+{
+ state = (state) ? 1 : 0;
+
+ // latch at falling edge
+ if (!state && m_ce)
+ {
+ // d53: DP (drive mode select, aka duty)
+ // d54: DQ (AD/DSP function)
+ // d55: commons
+ if (!BIT(m_shift, 55))
+ {
+ m_duty = BIT(m_shift, 53);
+ m_addsp = BIT(m_shift, 54);
+ }
+
+ m_latch[BIT(m_shift, 55)] = m_shift & u64(0x1f'ffff'ffff'ffff);
+ refresh_output();
+ }
+
+ m_ce = state;
+}
diff --git a/src/devices/video/lc7582.h b/src/devices/video/lc7582.h
new file mode 100644
index 00000000000..7aea77814ac
--- /dev/null
+++ b/src/devices/video/lc7582.h
@@ -0,0 +1,71 @@
+// license:BSD-3-Clause
+// copyright-holders:hap
+/*
+
+ Sanyo LC7582 LCD Driver
+
+*/
+
+#ifndef MAME_VIDEO_LC7582_H
+#define MAME_VIDEO_LC7582_H
+
+#pragma once
+
+/*
+
+quick pinout reference (64-pin QFP)
+
+1-54: S1-S53 segment outputs, pin 24 N/C, pins 45-54 also used with AD/DSP
+55: OSC
+56: Vdd
+57: _INH
+58: Vlcd
+59: Vss
+60: CE \
+61: CLK | serial input
+62: DATA /
+63,64: COM1/COM2 outputs
+
+*/
+
+
+class lc7582_device : public device_t
+{
+public:
+ lc7582_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+ // configuration helpers
+ auto write_segs() { return m_write_segs.bind(); } // S pins, COM1/COM2 in offset
+
+ DECLARE_WRITE_LINE_MEMBER(data_w) { m_data = (state) ? 1 : 0; }
+ DECLARE_WRITE_LINE_MEMBER(clk_w);
+ DECLARE_WRITE_LINE_MEMBER(ce_w);
+ DECLARE_WRITE_LINE_MEMBER(inh_w) { m_blank = bool(state); refresh_output(); }
+
+protected:
+ lc7582_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
+
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_post_load() override { refresh_output(); }
+
+ void refresh_output();
+
+ int m_data = 0;
+ int m_ce = 0;
+ int m_clk = 0;
+ bool m_blank = false;
+
+ int m_duty = 0;
+ int m_addsp = 0;
+ u64 m_shift = 0;
+ u64 m_latch[2];
+
+ // callbacks
+ devcb_write64 m_write_segs;
+};
+
+
+DECLARE_DEVICE_TYPE(LC7582, lc7582_device)
+
+#endif // MAME_VIDEO_LC7582_H