ibex_demo/src/system_init.c

26 lines
727 B
C

#include "xilinx_timer.h"
#include "main.h"
__IO uint32_t SysTick;
void System_Init(void) {
soc_uart.instance = UART0;
xilinx_uartlite_init(&soc_uart);
soc_gpio.instance = GPIO0;
xilinx_gpio_init(&soc_gpio);
SysTick = 0;
// Enable interrupts
asm volatile("csrs mie, %0\n" : : "r"(0x80)); // Enable timer interrupt
asm volatile("csrs mstatus, %0\n" : : "r"(0x8)); // Enable global interrupt
// Setup systick timer
TIMER0->TCSR0 = 0x12; // Generate mode, down count, auto-reload
TIMER0->TCR0 = 0; // Clear counter
TIMER0->TLR0 = SYS_CLK_FREQ / SYS_TICK_RATE; // Set reload value
TIMER0->TCSR0 |= (1 << 0x06U) | (1 << 0x07U); // Enable timer interrupt, enable counter.
}