5 // the systick interrupt is supposed to increment this at 1 kHz rate
6 volatile uint32_t systick_millis_count = 0;
12 uint32_t count, current, istatus;
16 count = systick_millis_count;
17 istatus = SCB_ICSR; // bit 26 indicates if systick exception pending
19 if ((istatus & SCB_ICSR_PENDSTSET) && current > ((F_CPU / 1000) - 50)) count++;
20 current = ((F_CPU / 1000) - 1) - current;
21 return count * 1000 + current / (F_CPU / 1000000);
24 void delay(uint32_t ms)
26 uint32_t start = micros();
29 if ((micros() - start) >= 1000) {