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
108
109
110
111
112
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Ricoh RP5C01(A) Real Time Clock With Internal RAM emulation
**********************************************************************
_____ _____
_CS 1 |* \_/ | 18 Vcc
CS 2 | | 17 OSCOUT
ADJ 3 | | 16 OSCIN
A0 4 | RP5C01 | 15 _ALARM
A1 5 | RP5C01A | 14 D3
A2 6 | RF5C01A | 13 D2
A3 7 | TC8521 | 12 D1
_RD 8 | | 11 D0
GND 9 |_____________| 10 _WR
**********************************************************************/
#pragma once
#ifndef __RP5C01__
#define __RP5C01__
#include "emu.h"
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_RP5C01_OUT_ALARM_CB(_devcb) \
devcb = &rp5c01_device::set_out_alarm_callback(*device, DEVCB_##_devcb);
// include this macro if the chip is not battery backed
#define MCFG_RP5C01_REMOVE_BATTERY() \
rp5c01_device::remove_battery(*device);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> rp5c01_device
class rp5c01_device : public device_t,
public device_rtc_interface,
public device_nvram_interface
{
public:
// construction/destruction
rp5c01_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
template<class _Object> static devcb_base &set_out_alarm_callback(device_t &device, _Object object) { return downcast<rp5c01_device &>(device).m_out_alarm_cb.set_callback(object); }
static void remove_battery(device_t &device) { downcast<rp5c01_device &>(device).m_battery_backed = false; }
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
DECLARE_READ_LINE_MEMBER( alarm_r ) { return m_alarm; }
DECLARE_WRITE_LINE_MEMBER( adj_w ) { if (state) adjust_seconds(); }
protected:
// device-level overrides
virtual void device_start();
virtual void device_reset();
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// device_rtc_interface overrides
virtual bool rtc_feature_leap_year() { return true; }
virtual void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second);
// device_nvram_interface overrides
virtual void nvram_default();
virtual void nvram_read(emu_file &file);
virtual void nvram_write(emu_file &file);
private:
inline void set_alarm_line();
inline int read_counter(int counter);
inline void write_counter(int counter, int value);
inline void check_alarm();
static const device_timer_id TIMER_CLOCK = 0;
static const device_timer_id TIMER_16HZ = 1;
devcb_write_line m_out_alarm_cb;
bool m_battery_backed;
UINT8 m_reg[2][13]; // clock registers
UINT8 m_ram[13]; // RAM
UINT8 m_mode; // mode register
UINT8 m_reset; // reset register
int m_alarm; // alarm output
int m_alarm_on; // alarm condition
int m_1hz; // 1 Hz condition
int m_16hz; // 16 Hz condition
// timers
emu_timer *m_clock_timer;
emu_timer *m_16hz_timer;
};
// device type definition
extern const device_type RP5C01;
#endif
|