Skip to content

Commit bef05ff

Browse files
committed
cleanup in tick.c
1 parent fe73859 commit bef05ff

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ports/atmel-samd/tick.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@ void tick_delay(uint32_t us) {
6060
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
6161
uint32_t us_until_next_tick = SysTick->VAL / ticks_per_us;
6262
uint32_t start_tick;
63-
while (us > us_until_next_tick) {
63+
while (us >= us_until_next_tick) {
6464
start_tick=SysTick->VAL; // wait for SysTick->VAL to RESET
6565
while (SysTick->VAL < start_tick) {}
6666
us -= us_until_next_tick;
6767
us_until_next_tick = 1000;
6868
}
69-
if(us){
70-
while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {}
71-
}
69+
while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {}
7270
}
7371

7472
// us counts down!

0 commit comments

Comments
 (0)