28 lines
673 B
C
28 lines
673 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
|
|
__enable_irqn(TIMER_IRQn); // Enable timer interrupt
|
|
__enable_irqs();
|
|
|
|
__enable_mcount();
|
|
|
|
// 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.
|
|
} |