ibex_demo/src/system_init.c

27 lines
679 B
C

#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
__enable_irqs();
__enable_mcount();
// Setup systick timer
TIMER0->TCSR0 = 0x112; // Generate mode, down count, auto-reload
TIMER0->TLR0 = SYS_CLK_FREQ / SYS_TICK_RATE; // Set reload value
TIMER0->TCSR0 |= (1U << 0x05);
TIMER0->TCSR0 &= ~(1U << 0x05);
__enable_irqn(TIMER_IRQn); // Enable timer interrupt
TIMER0->TCSR0 |= (1U << 0x06) | (1U << 0x07); // Enable timer interrupt, enable counter.
}