#include "ltc1867.h"
#include "debug.h"
#include "stm32f4xx_rcc.h"

uint32_t system_tick_cnt;

void system_tick_init(void)
{
    RCC_ClocksTypeDef rcc_clocks;

    system_tick_cnt = 0;
    RCC_GetClocksFreq(&rcc_clocks);
    SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
    SysTick_Config(rcc_clocks.HCLK_Frequency / 1000);
}

void system_init(void)
{
    ltc1867_init();
    debug_init();
    system_tick_init();
}

int main(void)
{
    system_init();
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    SCB->VTOR = 0x08020000;
    __enable_irq();
    while (1) {

    }
    return 0;
}

void SysTick_Handler(void)
{
    system_tick_cnt++;
}
