mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-18 01:30:56 +00:00
Add RAM.
This commit is contained in:
parent
a15d4610f7
commit
0537e59486
@ -35,6 +35,9 @@ class RTC {
|
|||||||
|
|
||||||
switch(selected_) {
|
switch(selected_) {
|
||||||
default:
|
default:
|
||||||
|
if(ram_selected()) {
|
||||||
|
return ram_[ram_address()];
|
||||||
|
}
|
||||||
return 0xff;
|
return 0xff;
|
||||||
|
|
||||||
case 0x00: return bcd(time_date->tm_sec); // Seconds [0-59]
|
case 0x00: return bcd(time_date->tm_sec); // Seconds [0-59]
|
||||||
@ -63,7 +66,8 @@ class RTC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int selected_;
|
std::size_t selected_;
|
||||||
|
std::array<uint8_t, 50> ram_{};
|
||||||
|
|
||||||
uint8_t statusA_ = 0x00;
|
uint8_t statusA_ = 0x00;
|
||||||
uint8_t statusB_ = 0x02;
|
uint8_t statusB_ = 0x02;
|
||||||
@ -71,6 +75,9 @@ class RTC {
|
|||||||
bool is_decimal() const { return statusB_ & 0x04; }
|
bool is_decimal() const { return statusB_ & 0x04; }
|
||||||
bool is_24hour() const { return statusB_ & 0x02; }
|
bool is_24hour() const { return statusB_ & 0x02; }
|
||||||
|
|
||||||
|
bool ram_selected() const { return selected_ >= 0xe && selected_ < 0xe + ram_.size(); }
|
||||||
|
std::size_t ram_address() const { return selected_ - 0xe; }
|
||||||
|
|
||||||
template <typename IntT>
|
template <typename IntT>
|
||||||
uint8_t bcd(IntT input) {
|
uint8_t bcd(IntT input) {
|
||||||
// If calendar is in binary format, don't convert.
|
// If calendar is in binary format, don't convert.
|
||||||
@ -87,7 +94,11 @@ class RTC {
|
|||||||
|
|
||||||
void write_register(uint8_t value) {
|
void write_register(uint8_t value) {
|
||||||
switch(selected_) {
|
switch(selected_) {
|
||||||
default: break;
|
default:
|
||||||
|
if(ram_selected()) {
|
||||||
|
ram_[ram_address()] = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 0x0a: statusA_ = value; break;
|
case 0x0a: statusA_ = value; break;
|
||||||
case 0x0b: statusB_ = value; break;
|
case 0x0b: statusB_ = value; break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user