Simplify get_ts_elapsed

master
Riccardo 2019-06-11 02:07:02 -07:00
parent cd20d123c4
commit f4419b08b9
1 changed files with 2 additions and 1 deletions

View File

@ -145,8 +145,9 @@ int safety_set_mode(uint16_t mode, int16_t param) {
}
// compute the time elapsed (in microseconds) from 2 counter samples
// case where ts < ts_last is ok: overflow is properly re-casted into uint32_t
uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) {
return ts > ts_last ? ts - ts_last : (0xFFFFFFFF - ts_last) + 1 + ts;
return ts - ts_last;
}
// convert a trimmed integer to signed 32 bit int