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.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#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 {
|
2024-11-30 22:21:00 +00:00
|
|
|
public:
|
|
|
|
RP5C01(HalfCycles clock_rate);
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
/// @returns the result of a read from @c address.
|
|
|
|
uint8_t read(int address);
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
/// Performs a write of @c value to @c address.
|
|
|
|
void write(int address, uint8_t value);
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
/// Advances time.
|
|
|
|
void run_for(HalfCycles);
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
private:
|
|
|
|
std::array<uint8_t, 26> ram_;
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
HalfCycles sub_seconds_;
|
|
|
|
const HalfCycles clock_rate_;
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
// Contains the seconds, minutes and hours fields.
|
|
|
|
int seconds_ = 0;
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
// Calendar entries.
|
|
|
|
int day_of_the_week_ = 0;
|
|
|
|
int day_ = 0;
|
|
|
|
int month_ = 0;
|
|
|
|
int year_ = 0;
|
|
|
|
int leap_year_ = 0;
|
2023-01-14 19:17:28 +00:00
|
|
|
|
2024-11-30 22:21:00 +00:00
|
|
|
// Other flags.
|
|
|
|
bool timer_enabled_ = false;
|
|
|
|
bool alarm_enabled_ = false;
|
|
|
|
int mode_ = 0;
|
|
|
|
bool one_hz_on_ = false;
|
|
|
|
bool sixteen_hz_on_ = false;
|
|
|
|
bool twentyfour_hour_clock_ = true;
|
2023-01-14 19:17:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|