#include "systick.h" volatile uint32_t systick_millis; void systick_init(void) { SysTick->CTLR = 0x0000; SysTick->CMP = SysTick->CNT + SYSTICK_ONE_MILLISECOND; systick_millis = 0; SysTick->CTLR = SYSTICK_CTLR_STE | // Enable Counter SYSTICK_CTLR_STIE | // Enable Interrupts SYSTICK_CTLR_STCLK; // Set Clock Source to HCLK/1 NVIC_EnableIRQ(SysTick_IRQn); } void SysTick_Handler(void) __attribute__((interrupt)); void SysTick_Handler(void) { SysTick->CMP = SysTick->CNT + SYSTICK_ONE_MILLISECOND; SysTick->SR = 0; systick_millis++; }