Overflow in currentTimeMillis and getTimeNowSeconds #3531
it now takes 1000 times longer to overflow
This commit is contained in:
parent
57ad75aa98
commit
825a57e33a
|
@ -166,15 +166,9 @@ private:
|
||||||
|
|
||||||
static EngineStateBlinkingTask engineStateBlinkingTask;
|
static EngineStateBlinkingTask engineStateBlinkingTask;
|
||||||
|
|
||||||
/**
|
|
||||||
* number of SysClock ticks in one ms
|
|
||||||
*/
|
|
||||||
#define TICKS_IN_MS (CH_CFG_ST_FREQUENCY / 1000)
|
|
||||||
|
|
||||||
// todo: this overflows pretty fast!
|
// todo: this overflows pretty fast!
|
||||||
efitimems_t currentTimeMillis(void) {
|
efitimems_t currentTimeMillis(void) {
|
||||||
// todo: migrate to getTimeNowUs? or not?
|
return US2MS(getTimeNowUs();
|
||||||
return chVTGetSystemTimeX() / TICKS_IN_MS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: this overflows pretty fast!
|
// todo: this overflows pretty fast!
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define NT_PER_SECOND (US2NT(US_PER_SECOND_LL))
|
#define NT_PER_SECOND (US2NT(US_PER_SECOND_LL))
|
||||||
|
|
||||||
#define MS2US(MS_TIME) ((MS_TIME) * 1000)
|
#define MS2US(MS_TIME) ((MS_TIME) * 1000)
|
||||||
|
#define US2MS(US_TIME) ((US_TIME) / 1000)
|
||||||
|
|
||||||
// microseconds to ticks
|
// microseconds to ticks
|
||||||
// since only about 20 seconds of ticks fit in 32 bits this macro is casting parameter into 64 bits 'efitime_t' type
|
// since only about 20 seconds of ticks fit in 32 bits this macro is casting parameter into 64 bits 'efitime_t' type
|
||||||
|
|
Loading…
Reference in New Issue