16 #include <libopencm3/cm3/nvic.h>
17 #include <libopencm3/cm3/systick.h>
20 #error F_CPU is not defined
24 static uint64_t sys_tick_counter;
29 systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
30 systick_set_reload((F_CPU / (8 * 1000))-1);
33 systick_interrupt_enable();
34 systick_counter_enable();
39 sys_tick_counter += 1000;
44 return sys_tick_counter;
50 return sys_tick_counter;
void sys_tick_handler(void)