1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00
CLK/Components/RP5C01/RP5C01.hpp

57 lines
1.0 KiB
C++
Raw Normal View History

2023-01-14 19:17:28 +00:00
//
// RP5C01.hpp
// Clock Signal
//
// Created by Thomas Harte on 14/01/2023.
// Copyright © 2023 Thomas Harte. All rights reserved.
//
#pragma once
2023-01-14 19:17:28 +00:00
#include "../../ClockReceiver/ClockReceiver.hpp"
#include <array>
#include <cstdint>
2023-05-10 21:02:18 +00:00
namespace Ricoh::RP5C01 {
2023-01-14 19:17:28 +00:00
class RP5C01 {
public:
RP5C01(HalfCycles clock_rate);
/// @returns the result of a read from @c address.
uint8_t read(int address);
/// Performs a write of @c value to @c address.
void write(int address, uint8_t value);
/// Advances time.
void run_for(HalfCycles);
private:
std::array<uint8_t, 26> ram_;
HalfCycles sub_seconds_;
const HalfCycles clock_rate_;
// Contains the seconds, minutes and hours fields.
int seconds_ = 0;
// Calendar entries.
int day_of_the_week_ = 0;
int day_ = 0;
int month_ = 0;
2023-01-17 01:11:42 +00:00
int year_ = 0;
2023-01-14 19:17:28 +00:00
int leap_year_ = 0;
// Other flags.
bool timer_enabled_ = false;
bool alarm_enabled_ = false;
int mode_ = 0;
bool one_hz_on_ = false;
bool sixteen_hz_on_ = false;
2023-01-17 03:25:20 +00:00
bool twentyfour_hour_clock_ = true;
2023-01-14 19:17:28 +00:00
};
}