Add systick function that checks for passed ticks with correct wrap around
This commit is contained in:
@@ -46,6 +46,26 @@ uint64_t systick_get_global_tick()
|
||||
return global_tick_ms;
|
||||
}
|
||||
|
||||
bool systick_ticks_have_passed(uint64_t start_timestamp, uint64_t ticks)
|
||||
{
|
||||
uint64_t end_timestamp = start_timestamp + ticks;
|
||||
uint64_t current_timestamp = systick_get_global_tick();
|
||||
|
||||
/* wrap around expected */
|
||||
if (end_timestamp < start_timestamp) {
|
||||
/* Wrap around occured */
|
||||
if (current_timestamp < start_timestamp) {
|
||||
if (current_timestamp >= end_timestamp)
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (current_timestamp >= end_timestamp)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Interrupt Handler for SysTick
|
||||
*
|
||||
|
Reference in New Issue
Block a user