diff options
-rw-r--r-- | chip/npcx/clock.c | 7 | ||||
-rw-r--r-- | chip/npcx/hwtimer.c | 5 | ||||
-rw-r--r-- | chip/npcx/hwtimer_chip.h | 5 |
3 files changed, 12 insertions, 5 deletions
diff --git a/chip/npcx/clock.c b/chip/npcx/clock.c index 718d7733b7..196248c592 100644 --- a/chip/npcx/clock.c +++ b/chip/npcx/clock.c @@ -312,6 +312,13 @@ void __idle(void) /* Do we have enough time before next event to deep sleep. */ if (DEEP_SLEEP_ALLOWED && + /* + * Our HW timer doesn't tick in deep sleep - we do manual + * adjustment based on sleep duration after wake. Avoid + * the tricky overflow case by waiting out the period just + * before overflow. + */ + next_evt != EVT_MAX_EXPIRED_US && /* Ensure event hasn't already expired */ next_evt > t0.le.lo && /* Ensure we have sufficient time before expiration */ diff --git a/chip/npcx/hwtimer.c b/chip/npcx/hwtimer.c index 48204724eb..366f1624f4 100644 --- a/chip/npcx/hwtimer.c +++ b/chip/npcx/hwtimer.c @@ -18,11 +18,6 @@ #include "timer.h" #include "util.h" -/* Use ITIM32 as main hardware timer */ -#define TICK_ITIM32_MAX_CNT 0xFFFFFFFF -/* Maximum deadline of event */ -#define EVT_MAX_EXPIRED_US 0xFFFFFFFF - /* Depth of event timer */ #define TICK_EVT_DEPTH 16 /* Depth of event timer Unit: bits */ #define TICK_EVT_INTERVAL (1 << TICK_EVT_DEPTH) /* Unit: us */ diff --git a/chip/npcx/hwtimer_chip.h b/chip/npcx/hwtimer_chip.h index 52b17c7dee..08cf8e278f 100644 --- a/chip/npcx/hwtimer_chip.h +++ b/chip/npcx/hwtimer_chip.h @@ -12,6 +12,11 @@ #define ITIM_EVENT_NO ITIM16_1 #define ITIM_WDG_NO ITIM16_5 +/* Use ITIM32 as main hardware timer */ +#define TICK_ITIM32_MAX_CNT 0xFFFFFFFF +/* Maximum deadline of event */ +#define EVT_MAX_EXPIRED_US TICK_ITIM32_MAX_CNT + /* Clock source for ITIM16 */ enum ITIM_SOURCE_CLOCK_T { ITIM_SOURCE_CLOCK_APB2 = 0, |