Overflow in currentTimeMillis and getTimeNowSeconds #3531

it now takes 1000 times longer to overflow
This commit is contained in:
rusefillc 2021-11-11 16:39:23 -05:00
parent 57ad75aa98
commit 825a57e33a
2 changed files with 2 additions and 7 deletions

View File

@ -166,15 +166,9 @@ private:
static EngineStateBlinkingTask engineStateBlinkingTask;
/**
* number of SysClock ticks in one ms
*/
#define TICKS_IN_MS (CH_CFG_ST_FREQUENCY / 1000)
// todo: this overflows pretty fast!
efitimems_t currentTimeMillis(void) {
// todo: migrate to getTimeNowUs? or not?
return chVTGetSystemTimeX() / TICKS_IN_MS;
return US2MS(getTimeNowUs();
}
// todo: this overflows pretty fast!

View File

@ -18,6 +18,7 @@
#define NT_PER_SECOND (US2NT(US_PER_SECOND_LL))
#define MS2US(MS_TIME) ((MS_TIME) * 1000)
#define US2MS(US_TIME) ((US_TIME) / 1000)
// 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