1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

examples/twr_aloha: fix shell blocking function

This commit is contained in:
Francisco Molina 2022-03-03 17:13:49 +01:00
parent 26969e299b
commit 32e78fa921
3 changed files with 16 additions and 1 deletions

View File

@ -289,3 +289,9 @@ void uwb_core_rng_init(void)
uwb_sleep_config(_udev);
uwb_enter_sleep(_udev);
}
uint32_t uwb_core_rng_req_remaining(void)
{
/* doesn't matter if its not atomic */
return _rng_request_event.periodic.count;
}

View File

@ -100,6 +100,11 @@ void uwb_core_rng_listen_disable(void);
void uwb_core_rng_start(uint16_t addr, twr_protocol_t proto, uint32_t interval,
uint32_t count);
/**
* @brief Returns remaining rng requests
*/
uint32_t uwb_core_rng_req_remaining(void);
#ifdef __cplusplus
}
#endif

View File

@ -181,7 +181,11 @@ int _twr_handler(int argc, char **argv)
puts("[twr]: start ranging");
uwb_core_rng_start(short_addr, proto, interval_ms, count);
if (IS_ACTIVE(CONFIG_TWR_SHELL_BLOCKING)) {
ztimer_sleep(ZTIMER_MSEC, interval_ms * (count + 1));
while (uwb_core_rng_req_remaining()) {
ztimer_sleep(ZTIMER_MSEC, interval_ms);
}
/* some time to finish up */
ztimer_sleep(ZTIMER_MSEC, 100 + interval_ms);
}
return 0;
}