From b4e004abc23251dbc2a68794451f11f7a38471f6 Mon Sep 17 00:00:00 2001 From: "Colin J. Brigato" Date: Thu, 1 Aug 2019 01:56:30 +0200 Subject: [PATCH] Off by one in GetTickCountDelta (FIXes #301) FIXes #301 and prevent a `-1`aka`UINT_MAX` delta. --- armsrc/ticks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/armsrc/ticks.c b/armsrc/ticks.c index 7ece25b93..22c5d5be1 100644 --- a/armsrc/ticks.c +++ b/armsrc/ticks.c @@ -64,7 +64,7 @@ uint32_t RAMFUNC GetTickCount(void) { uint32_t RAMFUNC GetTickCountDelta(uint32_t start_ticks) { uint32_t stop_ticks = AT91C_BASE_RTTC->RTTC_RTVR; - if (stop_ticks > start_ticks) + if (stop_ticks >= start_ticks) return stop_ticks - start_ticks; return (UINT32_MAX - start_ticks) + stop_ticks; }