1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // This class implements the RP5C01 chip (RTC)
- //
- // * For techncal details on RP5C01 see
- // http://w3.qahwah.net/joost/openMSX/RP5C01.pdf
- #ifndef RP5C01_HH
- #define RP5C01_HH
- #include "Clock.hh"
- #include "EnumSetting.hh"
- #include "openmsx.hh"
- #include <string>
- namespace openmsx {
- class CommandController;
- class SRAM;
- class RP5C01
- {
- public:
- enum RTCMode { EMUTIME, REALTIME };
- RP5C01(CommandController& commandController, SRAM& regs,
- EmuTime::param time, const std::string& name);
- void reset(EmuTime::param time);
- nibble readPort(nibble port, EmuTime::param time);
- nibble peekPort(nibble port) const;
- void writePort(nibble port, nibble value, EmuTime::param time);
- template<typename Archive>
- void serialize(Archive& ar, unsigned version);
- private:
- void initializeTime();
- void updateTimeRegs(EmuTime::param time);
- void regs2Time();
- void time2Regs();
- void resetAlarm();
- static constexpr unsigned FREQ = 16384;
- SRAM& regs;
- EnumSetting<RTCMode> modeSetting;
- Clock<FREQ> reference;
- unsigned fraction;
- unsigned seconds, minutes, hours;
- unsigned dayWeek, years, leapYear;
- int days, months; // these two can be -1
- nibble modeReg, testReg, resetReg;
- };
- } // namespace openmsx
- #endif
|