mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
fix power change timer micros overflow
This commit is contained in:
parent
f83be05220
commit
6dd175f63b
|
@ -1 +1 @@
|
|||
#define GITHUB_SHA "devel-202306181725Z"
|
||||
#define GITHUB_SHA "devel-202306182233Z"
|
||||
|
|
|
@ -190,9 +190,10 @@ class MotorDriver {
|
|||
// was really long ago (approx > 52min) advance counter approx 35 min so that
|
||||
// we are at 18 minutes again. Times for 32 bit unsigned long.
|
||||
inline unsigned long microsSinceLastPowerChange() {
|
||||
unsigned long diff = micros() - lastPowerChange;
|
||||
if (diff > (1UL << (6 *sizeof(unsigned long))))
|
||||
lastPowerChange += 1UL << (4 * sizeof(unsigned long));
|
||||
unsigned long now = micros();
|
||||
unsigned long diff = now - lastPowerChange;
|
||||
if (diff > (1UL << (7 *sizeof(unsigned long)))) // 2^(4*7)us = 268.4 seconds
|
||||
lastPowerChange = now - 30000000UL; // 30 seconds ago
|
||||
return diff;
|
||||
};
|
||||
#ifdef ANALOG_READ_INTERRUPT
|
||||
|
|
Loading…
Reference in New Issue
Block a user