summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author arbee <rb6502@users.noreply.github.com>2020-03-22 21:01:59 -0400
committer arbee <rb6502@users.noreply.github.com>2020-03-22 21:01:59 -0400
commit8434fd6213811c4fa257106c3c680a2c729a11fc (patch)
tree8a268307eddefdc338e110dcb80a1d367ea09092
parent246b64ad0bf37be22c5266b390a299686b35579c (diff)
Added ICM7170 real-time clock device. [R. Belmont]
-rw-r--r--scripts/src/machine.lua12
-rw-r--r--scripts/target/mame/mess.lua1
-rw-r--r--src/devices/machine/icm7170.cpp149
-rw-r--r--src/devices/machine/icm7170.h85
-rw-r--r--src/mame/drivers/wxstar4000.cpp7
5 files changed, 253 insertions, 1 deletions
diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua
index f53859c6e8b..b5699bf01c9 100644
--- a/scripts/src/machine.lua
+++ b/scripts/src/machine.lua
@@ -1445,6 +1445,18 @@ end
---------------------------------------------------
--
+--@src/devices/machine/icm7170.h,MACHINES["ICM7170"] = true
+---------------------------------------------------
+
+if (MACHINES["ICM7170"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/machine/icm7170.cpp",
+ MAME_DIR .. "src/devices/machine/icm7170.h",
+ }
+end
+
+---------------------------------------------------
+--
--@src/devices/machine/idectrl.h,MACHINES["IDECTRL"] = true
--@src/devices/machine/vt83c461.h,MACHINES["IDECTRL"] = true
---------------------------------------------------
diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua
index 9eec1bfd5d0..8e7e1f00933 100644
--- a/scripts/target/mame/mess.lua
+++ b/scripts/target/mame/mess.lua
@@ -511,6 +511,7 @@ MACHINES["I8271"] = true
MACHINES["I8279"] = true
MACHINES["I8291A"] = true
MACHINES["I8355"] = true
+MACHINES["ICM7170"] = true
MACHINES["IDECTRL"] = true
MACHINES["IE15"] = true
MACHINES["IM6402"] = true
diff --git a/src/devices/machine/icm7170.cpp b/src/devices/machine/icm7170.cpp
new file mode 100644
index 00000000000..5b57d380c2f
--- /dev/null
+++ b/src/devices/machine/icm7170.cpp
@@ -0,0 +1,149 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/**********************************************************************
+
+ Intersil/Renesas ICM7170 Real Time Clock
+
+*********************************************************************/
+
+#include "emu.h"
+#include "icm7170.h"
+#include "coreutil.h"
+
+#define VERBOSE (1)
+#include "logmacro.h"
+
+DEFINE_DEVICE_TYPE(ICM7170, icm7170_device, "icm7170", "Intersil/Renesas ICM7170 Real Time Clock")
+
+// internal registers
+enum
+{
+ REG_CNT_100TH_SEC = 0,
+ REG_CNT_HOURS,
+ REG_CNT_MINUTES,
+ REG_CNT_SECONDS,
+ REG_CNT_MONTH,
+ REG_CNT_DAY,
+ REG_CNT_YEAR,
+ REG_CNT_DAY_OF_WEEK,
+ REG_RAM_100TH_SEC,
+ REG_RAM_HOURS,
+ REG_RAM_MINUTES,
+ REG_RAM_SECONDS,
+ REG_RAM_MONTH,
+ REG_RAM_DAY,
+ REG_RAM_YEAR,
+ REG_RAM_DAY_OF_WEEK,
+ REG_INT_STATUS_MASK,
+ REG_COMMAND
+};
+
+static constexpr int ICM7170_TIMER_ID = 0;
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// icm7170_device - constructor
+//-------------------------------------------------
+
+icm7170_device::icm7170_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, ICM7170, tag, owner, clock),
+ device_rtc_interface(mconfig, *this),
+ device_nvram_interface(mconfig, *this),
+ m_out_irq_cb(*this)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void icm7170_device::device_start()
+{
+ // resolve callbacks
+ m_out_irq_cb.resolve_safe();
+
+ m_timer = timer_alloc(ICM7170_TIMER_ID);
+ m_timer->adjust(attotime::never);
+
+ save_item(NAME(m_regs));
+}
+
+
+//-------------------------------------------------
+// device_timer - handles timer events
+//-------------------------------------------------
+
+void icm7170_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+}
+
+
+//-------------------------------------------------
+// rtc_clock_updated - called when the host time changes
+//-------------------------------------------------
+
+void icm7170_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
+{
+}
+
+
+//-------------------------------------------------
+// nvram_default - called to initialize NVRAM to
+// its default state
+//-------------------------------------------------
+
+void icm7170_device::nvram_default()
+{
+ memset(m_regs, 0, 0x20);
+}
+
+
+//-------------------------------------------------
+// nvram_read - called to read NVRAM from the
+// .nv file
+//-------------------------------------------------
+
+void icm7170_device::nvram_read(emu_file &file)
+{
+ file.read(m_regs, 0x20);
+}
+
+
+//-------------------------------------------------
+// nvram_write - called to write NVRAM to the
+// .nv file
+//-------------------------------------------------
+
+void icm7170_device::nvram_write(emu_file &file)
+{
+ file.write(m_regs, 0x20);
+}
+
+// non-inherited device functions
+READ8_MEMBER( icm7170_device::read )
+{
+ uint8_t data = m_regs[offset & 0x1f];
+
+ LOG("ICM7170 Register %d Read %02x\n", offset, data);
+
+ return data;
+}
+
+WRITE8_MEMBER( icm7170_device::write )
+{
+ switch (offset & 0x1f)
+ {
+ default:
+ m_regs[offset & 0x1f] = data;
+ LOG("ICM7170 Register %d Write %02x\n", offset & 0x1f, data);
+ break;
+ }
+}
+
+void icm7170_device::recalc_irqs()
+{
+}
+
diff --git a/src/devices/machine/icm7170.h b/src/devices/machine/icm7170.h
new file mode 100644
index 00000000000..c7c6f77d12b
--- /dev/null
+++ b/src/devices/machine/icm7170.h
@@ -0,0 +1,85 @@
+// license:BSD-3-Clause
+// copyright-holders:R. Belmont
+/**********************************************************************
+
+ Intersil/Renesas ICM7170 Real Time Clock
+
+**********************************************************************
+ PDIP package:
+ _____ _____
+ _WR 1 | \_/ | 24 _RD
+ ALE 2 | | 23 VDD
+ _CS 3 | | 22 D7
+ A4 4 | ICM7170 | 21 D6
+ A3 5 | | 20 D5
+ A2 6 | | 19 D4
+ A1 7 | | 18 D3
+ A0 8 | | 17 D2
+ OSC OUT 9 | | 16 D1
+ OSC IN 10 | | 15 D0
+ INT SOURCE 11 | | 14 VBACKUP
+ /INTERRUPT 12 |_____________| 13 VSS (GND)
+
+SOIC package:
+ _____ _____
+ A1 1 | \_/ | 24 A2
+ A0 2 | | 23 A3
+ OSC OUT 3 | | 22 A4
+ OSC IN 4 | ICM7170 | 21 _CS
+ INT SOURCE 5 | | 20 ALE
+ /INTERRUPT 6 | | 19 _WR
+ VSS 7 | | 18 _RD
+ VBACKUP 8 | | 17 VDD
+ D0 9 | | 16 D7
+ D1 10 | | 15 D6
+ D2 11 | | 14 D5
+ D3 12 |_____________| 13 D4
+
+**********************************************************************/
+
+#ifndef MAME_MACHINE_ICM7170_H
+#define MAME_MACHINE_ICM7170_H
+
+#pragma once
+
+#include "dirtc.h"
+
+class icm7170_device : public device_t,
+ public device_rtc_interface,
+ public device_nvram_interface
+{
+public:
+ // construction/destruction
+ icm7170_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ auto irq() { return m_out_irq_cb.bind(); }
+
+ DECLARE_READ8_MEMBER( read );
+ DECLARE_WRITE8_MEMBER( write );
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+ // device_rtc_interface overrides
+ virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override;
+
+ // device_nvram_interface overrides
+ virtual void nvram_default() override;
+ virtual void nvram_read(emu_file &file) override;
+ virtual void nvram_write(emu_file &file) override;
+
+private:
+ void recalc_irqs();
+
+ devcb_write_line m_out_irq_cb;
+
+ uint8_t m_regs[0x20];
+
+ emu_timer *m_timer;
+};
+
+DECLARE_DEVICE_TYPE(ICM7170, icm7170_device)
+
+#endif // MAME_MACHINE_ICM7170_H
diff --git a/src/mame/drivers/wxstar4000.cpp b/src/mame/drivers/wxstar4000.cpp
index 4b0b1592e18..b1901febd2d 100644
--- a/src/mame/drivers/wxstar4000.cpp
+++ b/src/mame/drivers/wxstar4000.cpp
@@ -59,6 +59,7 @@
#include "cpu/m68000/m68000.h"
#include "cpu/mcs51/mcs51.h"
#include "machine/gen_latch.h"
+#include "machine/icm7170.h"
#include "machine/nvram.h"
#include "machine/timer.h"
#include "video/bt47x.h"
@@ -78,7 +79,8 @@ public:
m_iocpu(*this, "iocpu"),
m_mainram(*this, "extram"),
m_extram(*this, "extram"),
- m_vram(*this, "vram")
+ m_vram(*this, "vram"),
+ m_rtc(*this, "rtc")
{ }
void wxstar4k(machine_config &config);
@@ -102,6 +104,7 @@ private:
optional_device<m68010_device> m_maincpu, m_gfxcpu;
optional_device<mcs51_cpu_device> m_gfxsubcpu, m_datacpu, m_iocpu;
optional_shared_ptr<uint16_t> m_mainram, m_extram, m_vram;
+ required_device<icm7170_device> m_rtc;
DECLARE_READ16_MEMBER(buserr_r)
{
@@ -255,6 +258,8 @@ void wxstar4k_state::wxstar4k(machine_config &config)
screen.set_palette("palette");
PALETTE(config, "palette").set_format(palette_device::xBGR_888, 256);
+
+ ICM7170(config, m_rtc, XTAL(32'768));
}
ROM_START( wxstar4k )