src/gba/timer.h (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef GBA_TIMER_H
7#define GBA_TIMER_H
8
9#include "util/common.h"
10
11CXX_GUARD_START
12
13#include "core/timing.h"
14
15DECL_BITFIELD(GBATimerFlags, uint32_t);
16DECL_BITS(GBATimerFlags, PrescaleBits, 0, 4);
17DECL_BIT(GBATimerFlags, CountUp, 4);
18DECL_BIT(GBATimerFlags, DoIrq, 5);
19DECL_BIT(GBATimerFlags, Enable, 6);
20
21struct GBA;
22struct GBATimer {
23 uint16_t reload;
24 uint16_t oldReload;
25 uint32_t lastEvent;
26 struct mTimingEvent event;
27 int32_t overflowInterval;
28 GBATimerFlags flags;
29};
30
31void GBATimerInit(struct GBA* gba);
32void GBATimerUpdateRegister(struct GBA* gba, int timer);
33void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t value);
34void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t value);
35
36CXX_GUARD_END
37
38#endif