Off by one in GetTickCountDelta (FIXes #301)

FIXes #301 and prevent a `-1`aka`UINT_MAX` delta.
This commit is contained in:
Colin J. Brigato 2019-08-01 01:56:30 +02:00 committed by GitHub
parent 733a7d836d
commit b4e004abc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}