Skip to content

Commit 3e380c8

Browse files
authored
Merge pull request #2501 from particle-iot/fix/sc-107615/millis-rollover
[rtl872x] Fix millis() rollover
2 parents 053ad27 + 0dcab6c commit 3e380c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hal/src/rtl872x/timer_hal.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace {
6666
constexpr int TIMER_INDEX = 4; // Use TIM4
6767
constexpr int TIMER_PRESCALAR = 39; // Input clock = 40MHz_XTAL / (39 + 1) = 1MHz
6868
constexpr int TIMER_COUNTER_US_THRESHOLD = 1; // 1us = 1tick
69-
constexpr int US_PER_OVERFLOW = 65536; // 65536us
69+
constexpr uint64_t US_PER_OVERFLOW = 65536; // 65536us
7070
constexpr int TIMER_IRQ_PRIORITY = 0; // Default priority in the close-source timer driver per FAE
7171
constexpr IRQn_Type TIMER_IRQ[] = {
7272
TIMER0_IRQ,
@@ -183,7 +183,7 @@ class RtlTimer {
183183
uint64_t getTime() {
184184
#ifndef HAL_TIMER_USE_SYSTIMER_ONLY
185185
auto state = getOverflowCounterWithTick();
186-
return usSystemTimeMicrosBase_ + state.overflowCounter * US_PER_OVERFLOW + ticksToTime(state.curTimerTicks);
186+
return usSystemTimeMicrosBase_ + state.overflowCounter * (uint64_t)US_PER_OVERFLOW + ticksToTime(state.curTimerTicks);
187187
#else
188188
return sysTimerUs();
189189
#endif // HAL_TIMER_USE_SYSTIMER_ONLY

0 commit comments

Comments
 (0)