Skip to content

Commit

Permalink
Handle timer rollover in calculate_ufsi
Browse files Browse the repository at this point in the history
Co-authored-by: Jarkko Paso <jarkko.paso@arm.com>
  • Loading branch information
2 people authored and Arto Kinnunen committed Jun 14, 2021
1 parent 411cf5c commit 436f16e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,14 @@ static uint32_t fhss_ws_calculate_ufsi(fhss_structure_t *fhss_structure, uint32_

uint32_t time_to_tx = 0;
uint32_t cur_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api);
if (cur_time < tx_time) {
// High time to TX value (1000ms) is because actual TX time already passed.
if (US_TO_MS(tx_time - cur_time) < 1000) {
time_to_tx = US_TO_MS(tx_time - cur_time);
}
uint64_t ms_since_seq_start;
if (fhss_structure->ws->unicast_timer_running == true) {
if (fhss_structure->ws->next_uc_timeout < cur_time) {
// Allow timer interrupt to delay max 10 seconds, otherwise assume next_uc_timeout overflowed
if ((fhss_structure->ws->next_uc_timeout < cur_time) && ((cur_time - fhss_structure->ws->next_uc_timeout) < 10000000)) {
// The unicast timer has already expired, so count all previous slots
// plus 1 completed slot
// plus the time from timer expiration to now
Expand Down

0 comments on commit 436f16e

Please sign in to comment.