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
|
// license:GPL-2.0+
// copyright-holders:Russell Bull
/*********************************************************************
bml3rtc.cpp
Hitachi RTC card for the MB-6890
I cannot find any reference to the original Hitachi board that
had this feature, but I was given a schematic back in the 1980's
and I designed a board that included the circuitry.
The standard ROM supported this battery-backed RTC and detects
it's presence on start up.
*********************************************************************/
#include "emu.h"
#include "bml3rtc.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(BML3BUS_RTC, bml3bus_rtc_device, "bml3rtc", "Hitachi Real Time Clock Card")
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void bml3bus_rtc_device::device_add_mconfig(machine_config &config)
{
MSM5832(config, m_rtc, 32.768_kHz_XTAL);
}
uint8_t bml3bus_rtc_device::bml3_rtc_r(offs_t offset)
{
uint8_t data = 0x00;
if (offset == 2) // read @ 0xff3a
{
if (BIT(m_addr_latch, 7)) //bit 7 is the !write buffer enable
{
data = m_rtc->data_r();
}
else
{
data = m_data_latch; //the Hitachi ROM code detects RTC presence by reading back what it wrote to the data latch
}
}
return data | 0xf0; // return low nibble only
}
void bml3bus_rtc_device::bml3_rtc_w(offs_t offset, uint8_t data)
{
switch (offset)
{
case 0: // addr latch @ 0xff38
m_rtc->cs_w(1); //always selected
m_rtc->write_w(BIT(data, 6));
m_rtc->read_w(BIT(data, 7));
m_rtc->address_w(data & 0x0f);
m_addr_latch = data;
break;
case 1: // data latch @ 0xff39
m_rtc->hold_w(BIT(data, 6));
if (BIT(m_addr_latch, 6))
{
m_rtc->data_w(data & 0x0f);
}
m_data_latch = data;
break;
}
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
bml3bus_rtc_device::bml3bus_rtc_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
: device_t(mconfig, BML3BUS_RTC, tag, owner, clock)
, device_bml3bus_card_interface(mconfig, *this)
, m_rtc(*this, "rtc")
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void bml3bus_rtc_device::device_start()
{
// install into memory
address_space &space_prg = space();
space_prg.install_readwrite_handler(0xff38, 0xff3a, read8sm_delegate(*this, FUNC(bml3bus_rtc_device::bml3_rtc_r)), write8sm_delegate(*this, FUNC(bml3bus_rtc_device::bml3_rtc_w)));
m_addr_latch = 0;
m_data_latch = 0;
save_item(NAME(m_addr_latch));
save_item(NAME(m_data_latch));
}
|