Skip to content

Commit 2c88cc0

Browse files
ABESTMnashif
authored andcommitted
drivers: timer: Fix timing in suspend-to-ram
Fix timing in suspend-to-ram when using STM32WBA. Switch to use RTC timer should be done only when idle is set and LPTIM clocks should be switched off Signed-off-by: Adam Berlinger <[email protected]>
1 parent 36fb027 commit 2c88cc0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/timer/stm32_lptim_timer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
204204

205205
next = pm_policy_next_state(CURRENT_CPU, ticks);
206206

207-
if ((next != NULL) && (next->state == PM_STATE_SUSPEND_TO_RAM)) {
207+
if ((next != NULL) && idle && (next->state == PM_STATE_SUSPEND_TO_RAM)) {
208208
uint64_t timeout_us =
209209
((uint64_t)ticks * USEC_PER_SEC) / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
210210

@@ -230,6 +230,9 @@ void sys_clock_set_timeout(int32_t ticks, bool idle)
230230
counter_get_value(stdby_timer, &stdby_timer_pre_stdby);
231231
lptim_cnt_pre_stdby = z_clock_lptim_getcounter();
232232

233+
/* Stop clocks for LPTIM, since RTC is used instead */
234+
clock_control_off(clk_ctrl, (clock_control_subsys_t) &lptim_clk[0]);
235+
233236
return;
234237
}
235238
#endif /* CONFIG_STM32_LPTIM_STDBY_TIMER */

0 commit comments

Comments
 (0)