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#include "core/timing.h"
11
12DECL_BITFIELD(GBATimerFlags, uint32_t);
13DECL_BITS(GBATimerFlags, PrescaleBits, 0, 4);
14DECL_BIT(GBATimerFlags, CountUp, 4);
15DECL_BIT(GBATimerFlags, DoIrq, 5);
16DECL_BIT(GBATimerFlags, Enable, 6);
17
18struct GBA;
19struct GBATimer {
20 uint16_t reload;
21 uint16_t oldReload;
22 uint32_t lastEvent;
23 struct mTimingEvent event;
24 int32_t overflowInterval;
25 GBATimerFlags flags;
26};
27
28void GBATimerInit(struct GBA* gba);
29void GBATimerUpdateRegister(struct GBA* gba, int timer);
30void GBATimerWriteTMCNT_LO(struct GBA* gba, int timer, uint16_t value);
31void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t value);
32
33#endif