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
|
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/**********************************************************************
macrtc.h - Apple 343-0042 real time clock and battery RAM
by R. Belmont
**********************************************************************/
#ifndef MAME_MACHINE_MACRTC_H
#define MAME_MACHINE_MACRTC_H
#pragma once
#include "dirtc.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> rtc3430042_device
class rtc3430042_device : public device_t,
public device_rtc_interface,
public device_nvram_interface
{
public:
// construction/destruction
rtc3430042_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
DECLARE_WRITE_LINE_MEMBER( ce_w );
DECLARE_WRITE_LINE_MEMBER( clk_w );
DECLARE_READ_LINE_MEMBER( data_r );
DECLARE_WRITE_LINE_MEMBER( data_w );
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() 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;
virtual bool rtc_feature_leap_year() const override { return true; }
// device_nvram_interface overrides
virtual void nvram_default() override;
virtual bool nvram_read(util::read_stream &file) override;
virtual bool nvram_write(util::write_stream &file) override;
TIMER_CALLBACK_MEMBER(seconds_tick);
private:
/* state of rTCEnb and rTCClk lines */
uint8_t m_rtc_rTCEnb = 0;
uint8_t m_rtc_rTCClk = 0;
/* serial transmit/receive register : bits are shifted in/out of this byte */
uint8_t m_rtc_data_byte = 0;
/* serial transmitted/received bit count */
uint8_t m_rtc_bit_count = 0;
/* direction of the current transfer (0 : VIA->RTC, 1 : RTC->VIA) */
uint8_t m_rtc_data_dir = 0;
/* when rtc_data_dir == 1, state of rTCData as set by RTC (-> data bit seen by VIA) */
uint8_t m_rtc_data_out = 0;
/* set to 1 when command in progress */
uint8_t m_rtc_cmd = 0;
/* write protect flag */
uint8_t m_rtc_write_protect = 0;
/* internal seconds register */
uint8_t m_rtc_seconds[/*8*/4]{};
/* 20-byte long PRAM, or 256-byte long XPRAM */
uint8_t m_pram[256]{};
/* current extended address and RTC state */
uint8_t m_rtc_xpaddr = 0;
uint8_t m_rtc_state = 0;
uint8_t m_data_latch = 0;
// timers
emu_timer *m_clock_timer = nullptr;
void rtc_shift_data(int data);
void rtc_execute_cmd(int data);
};
// device type definition
DECLARE_DEVICE_TYPE(RTC3430042, rtc3430042_device)
#endif // MAME_MACHINE_MACRTC_H
|