-
Notifications
You must be signed in to change notification settings - Fork 8
/
startup.c
54 lines (40 loc) · 971 Bytes
/
startup.c
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
54
#include "ports.h"
#include "uart.h"
#include "mmu.h"
#include "system.h"
#include "display.h"
#include "interrupts.h"
#include "ccu.h"
#include "usb.h"
uint32_t tick_counter;
void game_tick(uint32_t tick_counter);
void game_start();
void startup() {
init_bss();
// Reboot in n seconds using watchdog
reboot(2); // 0x8 == 10 second reset timer
// Enble all GPIO
gpio_init();
// Configure the UART for debugging
uart_init();
uart_print("Booting!\r\n");
// Set up MMU and paging configuration
mmu_init();
// Illuminate the power LED
set_pin_mode(PORTL, 10, 1); // PORT L10 output
set_pin_data(PORTL, 10, 1); // PORT L10 high
// Configure display
display_init((volatile uint32_t*)(0x60000000-VIDEO_RAM_BYTES));
// USB
usb_init();
uart_print("Ready!\r\n");
game_start();
install_ivt();
// Go back to sleep
while(1) asm("wfi");
}
void game_tick_next() {
buffer_swap();
game_tick(tick_counter);
tick_counter++;
}