#include "delay.h"
volatile uint32_t msTicks;   /* counts 1ms timeTicks */

void SysTick_init(void) {
	SystemCoreClockUpdate();                      /* Get Core Clock Frequency  */
	if (SysTick_Config(SystemCoreClock / 1000)) { /* SysTick 1 msec interrupts */
		while (1);                                  /* Capture error             */
	}
}
/*-----------------------------------------------------
  SysTick_Handler
 *---------------------------------------------------*/
void SysTick_Handler(void) {
  msTicks++;
}
/*-----------------------------------------------------
  delays number of tick Systicks (happens every 1 ms)
 *---------------------------------------------------*/
void msDelay (uint32_t dlyTicks) {
  uint32_t curTicks;

  curTicks = msTicks;
  while ((msTicks - curTicks) < dlyTicks);
}