Skip to content

Commit

Permalink
Re-enable IT CC1 after deepsleep
Browse files Browse the repository at this point in the history
  • Loading branch information
bcostm committed Jul 4, 2018
1 parent f785c23 commit fcdd529
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions targets/TARGET_STM/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void hal_deepsleep(void)
// Disable IRQs
core_util_critical_section_enter();

// Save the timer counter value in order to reprogram it after deepsleep
uint32_t EnterTimeUS = us_ticker_read();

// Request to enter STOP mode with regulator in low power mode
Expand Down Expand Up @@ -198,9 +199,12 @@ void hal_deepsleep(void)
* deep sleep */
wait_loop(500);

// Reprogram the timer counter value saved before the deepsleep
TIM_HandleTypeDef TimMasterHandle;
TimMasterHandle.Instance = TIM_MST;
__HAL_TIM_SET_COUNTER(&TimMasterHandle, EnterTimeUS);
__HAL_TIM_CLEAR_FLAG(&TimMasterHandle, TIM_FLAG_CC1);
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC1);

#if DEVICE_RTC
/* Wait for RTC RSF bit synchro if RTC is configured */
Expand Down

0 comments on commit fcdd529

Please sign in to comment.