29#define REG32(ADDR) (*(uint32_t volatile(*))(ADDR))
34#define REG16(ADDR) (*(uint16_t volatile(*))(ADDR))
39#define MEM16(ADDR) ((uint16_t(*))(ADDR))
44#define GBA_PTR_TO_IRQ_HANDLER REG32(0x3007ffc)
66#define GBA_IE REG16(0x4000200)
71#define GBA_IE_TIMERS (0x0F << 3)
93#define GBA_IF REG16(0x4000202)
98#define GBA_IF_CLEAR_ALL (0x3FFF)
103#define GBA_IF_TIMERS (0x0F << 3)
110#define GBA_IME REG16(0x4000208)
116#define GBA_TM0_CNT_L REG16(0x4000100)
117#define GBA_TM0_CNT_H REG16(0x4000102)
118#define GBA_TM1_CNT_L REG16(0x4000104)
119#define GBA_TM1_CNT_H REG16(0x4000106)
120#define GBA_TM2_CNT_L REG16(0x4000108)
121#define GBA_TM2_CNT_H REG16(0x400010A)
122#define GBA_TM3_CNT_L REG16(0x400010C)
123#define GBA_TM3_CNT_H REG16(0x400010E)
129#define GBA_TIMER_MAX_TICKS (0xFFFF)
135#define GBA_TIMER_FRQ_16K (16400lu)
136#define GBA_TIMER_FRQ_65K (65500lu)
137#define GBA_TIMER_FRQ_262K (262200lu)
138#define GBA_TIMER_FRQ_16M (16780000lu)
155static_assert(
sizeof(
gba_timer) == 4,
"2 x Timer register should be 4 bytes");
166#define GBA_TIMER_0 ((gba_timer_t *)0x4000100)
167#define GBA_TIMER_1 ((gba_timer_t *)0x4000104)
168#define GBA_TIMER_2 ((gba_timer_t *)0x4000108)
169#define GBA_TIMER_3 ((gba_timer_t *)0x400010C)
176#define GBA_SCREEN_WIDTH (240)
177#define GBA_SCREEN_HEIGHT (160)
183#define GBA_DISPCNT REG16(0x4000000)
189#define GBA_DISPCNT_BGMODE_0 0x0000
190#define GBA_DISPCNT_BGMODE_1 0x0001
191#define GBA_DISPCNT_BGMODE_2 0x0002
192#define GBA_DISPCNT_BGMODE_3 0x0003
193#define GBA_DISPCNT_BGMODE_4 0x0004
194#define GBA_DISPCNT_BGMODE_5 0x0005
196#define GBA_DISPCNT_SDBG_0 0x0100
197#define GBA_DISPCNT_SDBG_1 0x0200
198#define GBA_DISPCNT_SDBG_2 0x0400
199#define GBA_DISPCNT_SDBG_3 0x0800
201#define GBA_DISPCNT_SDOBJ 0x1000
207#define GBA_DISPSTAT REG16(0x4000004)
213#define GBA_BG0CNT REG16(0x4000008)
214#define GBA_BG1CNT REG16(0x400000a)
215#define GBA_BG2CNT REG16(0x400000c)
216#define GBA_BG3CNT REG16(0x400000e)
222#define GBA_VRAM_PALETTE MEM16(0x5000000)
227#define GBA_VRAM MEM16(0x6000000)
POSIX.1-2008 compliant version of the assert macro.
volatile gba_timer gba_timer_t
The type for the GBA timers.
Struct whose members map onto the timer register.
uint16_t prescaler
The prescaler sets the divider for this timer.
uint16_t count_up_on_neighbour_overflow
If set, counts up this timer when the previous overflowed.
uint16_t unused_8_15
unused
uint16_t unused_3_5
unused
uint16_t irq_enable
enables interrupt request for this timer on overflow
uint16_t run
starts the timer
uint16_t current_value
The counter / current value of this timer.