Skip to content

Commit 436f16e

Browse files
AlbanJeantheau-silabsJarkko Paso
authored and
Arto Kinnunen
committed
Handle timer rollover in calculate_ufsi
Co-authored-by: Jarkko Paso <[email protected]>
1 parent 411cf5c commit 436f16e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,14 @@ static uint32_t fhss_ws_calculate_ufsi(fhss_structure_t *fhss_structure, uint32_
502502

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

0 commit comments

Comments
 (0)