Correct ticks being returned from port_get_raw_ticks()
Issue #2958 . Correct calculation of usec back to ticks in port_get_raw_ticks().
This commit is contained in:
parent
ef87cc3ed3
commit
d8bb2d7c6d
@ -118,11 +118,12 @@ uint32_t port_get_saved_word(void) {
|
||||
uint64_t port_get_raw_ticks(uint8_t* subticks) {
|
||||
struct timeval tv_now;
|
||||
gettimeofday(&tv_now, NULL);
|
||||
uint64_t all_subticks = (uint64_t)tv_now.tv_usec / 32768;
|
||||
// convert usec back to ticks
|
||||
uint64_t all_subticks = (uint64_t)tv_now.tv_usec / 1024;
|
||||
if (subticks != NULL) {
|
||||
*subticks = all_subticks % 32;
|
||||
}
|
||||
return (uint64_t)tv_now.tv_sec * 1024L + all_subticks / 32;
|
||||
return (uint64_t)tv_now.tv_sec * 1024L + all_subticks;
|
||||
}
|
||||
|
||||
// Enable 1/1024 second tick.
|
||||
|
Loading…
Reference in New Issue
Block a user