-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrtc.hpp
53 lines (40 loc) · 857 Bytes
/
rtc.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2022 TotalJustice.
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "fwd.hpp"
namespace gba::rtc {
enum class State : u8
{
// waits until CS=0 and SCK=1
init1,
// waits until CS=1 and SCK=1 (CS rises)
init2,
// waits until 8 bits have been transfered
command,
// idk about these yet
read,
write,
};
enum class Command : u8
{
reset = 0,
control = 1,
date = 2,
time = 3,
alarm1 = 4,
alarm2 = 5,
irq = 6,
unused = 7,
};
struct Rtc
{
u64 bits; // bits shifted in / out
u8 bit_counter; // bit position
bool pending_bit; // pending bit that's been written
u8 control; // enable 12/24h, thats it
State state;
Command command;
auto init() -> void;
auto write(Gba& gba, u32 addr, u8 value) -> void;
};
} // namespace gba::rtc