|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
9: #include "device.h"
10: #include "rtc.h"
11:
12: struct RP5C15
13: {
14: // レジスタ 13, 14, 15 は Bank0/Bank1 どちらも同じものが見える。
15: // これらのレジスタは Bank1 だったら Bank0 を見せる。
16: //
17: // RTC の未使用ビットは、RTC への書き込み時に未使用ビットを
18: // mask[] で '0' にマスクしてから変数に書き込むこと。
19: union {
20: uint8 r[16 + 13];
21: struct {
22: uint8 sec1;
23: uint8 sec10;
24: uint8 min1;
25: uint8 min10;
26: uint8 hour1;
27: uint8 hour10;
28: uint8 wday;
29: uint8 day1;
30: uint8 day10;
31: uint8 mon1;
32: uint8 mon10;
33: uint8 year1;
34: uint8 year10;
35: uint8 mode;
36: uint8 test;
37: uint8 reset;
38:
39: uint8 clksel;
40: uint8 adjust;
41: uint8 alarm_min1;
42: uint8 alarm_min10;
43: uint8 alarm_hour1;
44: uint8 alarm_hour10;
45: uint8 alarm_wday;
46: uint8 alarm_day1;
47: uint8 alarm_day10;
48: uint8 padding1;
49: uint8 sel24;
50: uint8 leap;
51: uint8 padding2;
52: } __packed;
53: };
54:
55: // レジスタマスク (有効ビットを '1' としたもの)
56: static const uint8 mask[16 + 13];
57:
58: // バンク0
59: static const int SEC1 = 0x00; // $E8A001
60: static const int SEC10 = 0x01; // $E8A003
61: static const int MIN1 = 0x02; // $E8A005
62: static const int MIN10 = 0x03; // $E8A007
63: static const int HOUR1 = 0x04; // $E8A009
64: static const int HOUR10 = 0x05; // $E8A00B
65: static const int WDAY = 0x06; // $E8A00D
66: static const int DAY1 = 0x07; // $E8A00F
67: static const int DAY10 = 0x08; // $E8A011
68: static const int MON1 = 0x09; // $E8A013
69: static const int MON10 = 0x0a; // $E8A015
70: static const int YEAR1 = 0x0b; // $E8A017
71: static const int YEAR10 = 0x0c; // $E8A019
72: static const int MODE = 0x0d; // $E8A01B
73: static const int TEST = 0x0e; // $E8A01D
74: static const int RESET = 0x0f; // $E8A01F
75: // バンク1
76: static const int CLKSEL = 0x10; // $E8A001
77: static const int ADJUST = 0x11; // $E8A003
78: static const int ALARM_MIN1 = 0x12; // $E8A005
79: static const int ALARM_MIN10 = 0x13; // $E8A007
80: static const int ALARM_HOUR1 = 0x14; // $E8A009
81: static const int ALARM_HOUR10 = 0x15; // $E8A00B
82: static const int ALARM_WDAY = 0x16; // $E8A00D
83: static const int ALARM_DAY1 = 0x17; // $E8A00F
84: static const int ALARM_DAY10 = 0x18; // $E8A011
85: static const int notused1 = 0x19; // $E8A013
86: static const int SEL24 = 0x1a; // $E8A015
87: static const int LEAP = 0x1b; // $E8A017
88: static const int notused2 = 0x1c; // $E8A019
89: // バンク1 の 13, 14, 15 はバンク0 と共通
90: static const int MODE_BANK1 = 0x1d; // $E8A01B
91: static const int TEST_BANK1 = 0x1e; // $E8A01D
92: static const int RESET_BANK1 = 0x1f; // $E8A01F
93:
94: static const int MODE_TIMER_EN = 0x08;
95: static const int MODE_ALARM_EN = 0x04;
96: static const int MODE_BANK = 0x01;
97:
98: static const int RESET_1Hz = 0x08;
99: static const int RESET_16Hz = 0x04;
100: static const int RESET_TIMER = 0x02;
101: static const int RESET_ALARM = 0x01;
102: };
103:
104: class RP5C15Device : public RTCDevice
105: {
1.1.1.3 root 106: using inherited = RTCDevice;
1.1 root 107: public:
108: RP5C15Device();
1.1.1.3 root 109: ~RP5C15Device() override;
1.1 root 110:
1.1.1.3 root 111: bool InitRTC() override;
1.1.1.4 ! root 112:
! 113: void MonitorUpdate(TextScreen&) override;
1.1 root 114:
115: // 32Hz クロック入力
1.1.1.3 root 116: void ClockIn() override;
1.1 root 117:
1.1.1.3 root 118: protected:
119: // BusIO インタフェース
120: static const uint32 NPORT = 16;
121: uint64 Read(uint32 addr);
122: uint64 Write(uint32 addr, uint32 data);
123: uint64 Peek(uint32 addr);
1.1.1.2 root 124:
1.1.1.3 root 125: private:
1.1 root 126: // レジスタを更新
127: void UpdateReg(uint32);
128:
129: // レジスタ
130: RP5C15 reg {};
131:
132: // 現在のバンク
133: // MODE レジスタの BANK ビットが変更された時にこの値も更新すること。
134: int bank = 0;
135:
136: // CLKOUT 端子の状態 (true なら 'H')
137: bool clkout = false;
138: // ALARM 端子の状態 (true なら 'H')
139: bool alarmout = false;
140: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.