summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Needell <jerryneedell@gmail.com>2018-04-20 15:23:03 -0400
committerJerry Needell <jerryneedell@gmail.com>2018-04-20 15:23:03 -0400
commitbef05ffbf183225563d087de8b48e80dbeb7dd17 (patch)
tree813177954b2769d2c705e1ff41231232d0679be8
parentfe738598dacd97149db738216fe4e574b8a926a7 (diff)
cleanup in tick.c
-rw-r--r--ports/atmel-samd/tick.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/ports/atmel-samd/tick.c b/ports/atmel-samd/tick.c
index 72dddbe86..27b5f05b4 100644
--- a/ports/atmel-samd/tick.c
+++ b/ports/atmel-samd/tick.c
@@ -60,15 +60,13 @@ void tick_delay(uint32_t us) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
uint32_t us_until_next_tick = SysTick->VAL / ticks_per_us;
uint32_t start_tick;
- while (us > us_until_next_tick) {
+ while (us >= us_until_next_tick) {
start_tick=SysTick->VAL; // wait for SysTick->VAL to RESET
while (SysTick->VAL < start_tick) {}
us -= us_until_next_tick;
us_until_next_tick = 1000;
}
- if(us){
- while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {}
- }
+ while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {}
}
// us counts down!