29#define REG32(ADDR) (*(uint32_t volatile(*))(ADDR))
34#define REG16(ADDR) (*(uint16_t volatile(*))(ADDR))
39#define REG8(ADDR) (*(uint8_t volatile(*))(ADDR))
44#define MEM16(ADDR) ((uint16_t(*))(ADDR))
49#define GBA_PTR_TO_IRQ_HANDLER REG32(0x3007ffc)
71#define GBA_IE REG16(0x4000200)
76#define GBA_IE_TIMERS (0x0F << 3)
81#define GBA_IE_UART (1 << 7)
103#define GBA_IF REG16(0x4000202)
108#define GBA_IF_CLEAR_ALL (0x3FFF)
113#define GBA_IF_TIMERS (0x0F << 3)
118#define GBA_IF_UART (1 << 7)
125#define GBA_IME REG16(0x4000208)
131#define GBA_TM0_CNT_L REG16(0x4000100)
132#define GBA_TM0_CNT_H REG16(0x4000102)
133#define GBA_TM1_CNT_L REG16(0x4000104)
134#define GBA_TM1_CNT_H REG16(0x4000106)
135#define GBA_TM2_CNT_L REG16(0x4000108)
136#define GBA_TM2_CNT_H REG16(0x400010A)
137#define GBA_TM3_CNT_L REG16(0x400010C)
138#define GBA_TM3_CNT_H REG16(0x400010E)
144#define GBA_TIMER_MAX_TICKS (0xFFFF)
150#define GBA_TIMER_FRQ_16K (16400lu)
151#define GBA_TIMER_FRQ_65K (65500lu)
152#define GBA_TIMER_FRQ_262K (262200lu)
153#define GBA_TIMER_FRQ_16M (16780000lu)
170static_assert(
sizeof(
gba_timer) == 4,
"2 x Timer register should be 4 bytes");
181#define GBA_TIMER_0 ((gba_timer_t *)0x4000100)
182#define GBA_TIMER_1 ((gba_timer_t *)0x4000104)
183#define GBA_TIMER_2 ((gba_timer_t *)0x4000108)
184#define GBA_TIMER_3 ((gba_timer_t *)0x400010C)
190#define GBA_SIO_SCNT REG16(0x4000128)
195#define GBA_SIO_DATA8 REG8(0x400012A)
200#define GBA_SIO_RCNT REG16(0x4000134)
230#define GBA_UART ((volatile gba_uart_t *) 0x4000128)
236#define GBA_SCREEN_WIDTH (240)
237#define GBA_SCREEN_HEIGHT (160)
243#define GBA_DISPCNT REG16(0x4000000)
249#define GBA_DISPCNT_BGMODE_0 0x0000
250#define GBA_DISPCNT_BGMODE_1 0x0001
251#define GBA_DISPCNT_BGMODE_2 0x0002
252#define GBA_DISPCNT_BGMODE_3 0x0003
253#define GBA_DISPCNT_BGMODE_4 0x0004
254#define GBA_DISPCNT_BGMODE_5 0x0005
256#define GBA_DISPCNT_SDBG_0 0x0100
257#define GBA_DISPCNT_SDBG_1 0x0200
258#define GBA_DISPCNT_SDBG_2 0x0400
259#define GBA_DISPCNT_SDBG_3 0x0800
261#define GBA_DISPCNT_SDOBJ 0x1000
267#define GBA_DISPSTAT REG16(0x4000004)
273#define GBA_BG0CNT REG16(0x4000008)
274#define GBA_BG1CNT REG16(0x400000a)
275#define GBA_BG2CNT REG16(0x400000c)
276#define GBA_BG3CNT REG16(0x400000e)
282#define GBA_VRAM_PALETTE MEM16(0x5000000)
287#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 gba_uart gba_uart_t
The type for the GBA uart.
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.
Struct whose members map onto the uart register.
uint16_t fifo_enable
Enable FIFO.
uint16_t must_be_1_for_uart
Config bits, unrelated to UART configuration.
uint16_t unused_15
Unused.
uint16_t cts
0: Always Send, 1: Wait for SC=LOW
uint16_t send_data_full
Send FIFO full.
uint16_t receive_data_empty
Receive FIFO empty.
uint16_t error
Error occurred.
uint16_t baud
Baud rate, 0:9600, 38400, 57600, 3:115200.
uint16_t parity
0: even, 1: odd
uint16_t irq_enable
Enable IRQ on send_data_full, receive_data_empty and error.
uint16_t data_bits
0: 7 bits, 1: 8 bits
uint16_t parity_enable
Enable parity.
uint16_t receive_enable
Enable receiving data.
uint16_t send_enable
Enable sending data.