ibex_demo/src/system_init.c

27 lines
679 B
C
Raw Normal View History

#include "main.h"
2020-05-30 14:42:07 +00:00
__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);
2020-05-30 14:42:07 +00:00
SysTick = 0;
// Enable interrupts
2020-05-31 12:58:05 +00:00
__enable_irqs();
__enable_mcount();
2020-05-30 14:42:07 +00:00
// Setup systick timer
2020-06-01 10:05:19 +00:00
TIMER0->TCSR0 = 0x112; // Generate mode, down count, auto-reload
2020-05-30 14:42:07 +00:00
TIMER0->TLR0 = SYS_CLK_FREQ / SYS_TICK_RATE; // Set reload value
2020-06-01 10:05:19 +00:00
TIMER0->TCSR0 |= (1U << 0x05);
TIMER0->TCSR0 &= ~(1U << 0x05);
__enable_irqn(TIMER_IRQn); // Enable timer interrupt
2020-05-30 14:42:07 +00:00
2020-06-01 10:05:19 +00:00
TIMER0->TCSR0 |= (1U << 0x06) | (1U << 0x07); // Enable timer interrupt, enable counter.
2020-05-30 14:42:07 +00:00
}