Flute_Hello_World/src/system_init.c

29 lines
632 B
C

#include "main.h"
__IO uint64_t SysTick;
void System_Init(void) {
soc_uart.instance = UART0;
xilinx_uartlite_init(&soc_uart);
soc_gpio.instance = GPIO0;
xilinx_gpio_init(&soc_gpio);
xilinx_gpio_pinmode(&soc_gpio, 0, 1);
// Setup interrupt system
uint64_t csr = 0x01ULL; // Enable vector'd exception handling.
__csrw("mtvec", csr);
SysTick = 0ULL;
*(uint64_t *)(CLINT_BASE + 0x4000) = SYS_TICK_STEP;
*(uint64_t *)(CLINT_BASE + 0xBFF8) = 0ULL;
csr = 1U << 7; // MTIE
__csrw("mie", csr); // Enable timer interrupt
csr = 1U << 3; // MIE
__csrw("mstatus", csr);
}