#include "delay.h" void delayInitMs(uint32_t clk, uint32_t ticks) { /* Configure the SysTick to have interrupt in 1ms time base */ SysTick->LOAD = (uint32_t)((clk / ticks) - 1UL); /* set reload register */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable the Systick Timer */ } void delayMs(uint16_t delay) { uint16_t i = 0; while (delay) { if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) { delay--; } } }