openMSX
RP5C01.hh
Go to the documentation of this file.
1// This class implements the RP5C01 chip (RTC)
2//
3// * For technical details on RP5C01 see
4// http://w3.qahwah.net/joost/openMSX/RP5C01.pdf
5
6#ifndef RP5C01_HH
7#define RP5C01_HH
8
9#include "Clock.hh"
10#include "EnumSetting.hh"
11#include "openmsx.hh"
12#include <string>
13
14namespace openmsx {
15
16class CommandController;
17class SRAM;
18
19class RP5C01
20{
21public:
23
24 RP5C01(CommandController& commandController, SRAM& regs,
25 EmuTime::param time, const std::string& name);
26
27 void reset(EmuTime::param time);
28 [[nodiscard]] nibble readPort(nibble port, EmuTime::param time);
29 [[nodiscard]] nibble peekPort(nibble port) const;
30 void writePort(nibble port, nibble value, EmuTime::param time);
31
32 template<typename Archive>
33 void serialize(Archive& ar, unsigned version);
34
35private:
36 void initializeTime();
37 void updateTimeRegs(EmuTime::param time);
38 void regs2Time();
39 void time2Regs();
40 void resetAlarm();
41
42private:
43 static constexpr unsigned FREQ = 16384;
44
45 SRAM& regs;
46 EnumSetting<RTCMode> modeSetting;
47
48 Clock<FREQ> reference;
49 unsigned fraction;
50 unsigned seconds, minutes, hours;
51 unsigned dayWeek, years, leapYear;
52 int days, months; // these two can be -1
53
54 nibble modeReg, testReg, resetReg;
55};
56
57} // namespace openmsx
58
59#endif
Represents a clock with a fixed frequency.
Definition Clock.hh:19
void serialize(Archive &ar, unsigned version)
Definition RP5C01.cc:271
nibble readPort(nibble port, EmuTime::param time)
Definition RP5C01.cc:68
void reset(EmuTime::param time)
Definition RP5C01.cc:60
nibble peekPort(nibble port) const
Definition RP5C01.cc:85
void writePort(nibble port, nibble value, EmuTime::param time)
Definition RP5C01.cc:102
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint8_t nibble
4 bit integer
Definition openmsx.hh:23