File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 27
27
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
28
*******************************************************************************
29
29
*/
30
- #include "sleep_api.h"
31
- #include "rtc_api_hal.h"
32
-
33
30
#if DEVICE_SLEEP
34
31
35
32
#include "cmsis.h"
33
+ #include "us_ticker_api.h"
34
+ #include "sleep_api.h"
35
+ #include "rtc_api_hal.h"
36
+ #include "hal_tick.h"
36
37
38
+ extern void HAL_SuspendTick (void );
39
+ extern void HAL_ResumeTick (void );
37
40
38
41
void hal_sleep (void )
39
42
{
40
- // Stop HAL systick
43
+ // Stop HAL tick to avoid to exit sleep in 1ms
41
44
HAL_SuspendTick ();
42
45
// Request to enter SLEEP mode
43
46
HAL_PWR_EnterSLEEPMode (PWR_MAINREGULATOR_ON , PWR_SLEEPENTRY_WFI );
44
- // Restart HAL systick
47
+
48
+ // Restart HAL tick
45
49
HAL_ResumeTick ();
46
50
}
47
51
48
52
void hal_deepsleep (void )
49
53
{
50
- // Stop HAL systick
54
+ // Stop HAL tick
51
55
HAL_SuspendTick ();
56
+ uint32_t EnterTimeUS = us_ticker_read ();
52
57
53
58
// Request to enter STOP mode with regulator in low power mode
54
59
#if TARGET_STM32L4
@@ -74,12 +79,16 @@ void hal_deepsleep(void)
74
79
HAL_PWR_EnterSTOPMode (PWR_LOWPOWERREGULATOR_ON , PWR_STOPENTRY_WFI );
75
80
#endif /* TARGET_STM32L4 */
76
81
77
- // Restart HAL systick
82
+ // Restart HAL tick
78
83
HAL_ResumeTick ();
79
84
80
85
// After wake-up from STOP reconfigure the PLL
81
86
SetSysClock ();
82
87
88
+ TIM_HandleTypeDef TimMasterHandle ;
89
+ TimMasterHandle .Instance = TIM_MST ;
90
+ __HAL_TIM_SET_COUNTER (& TimMasterHandle , EnterTimeUS );
91
+
83
92
#if DEVICE_LOWPOWERTIMER
84
93
rtc_synchronize ();
85
94
#endif
You can’t perform that action at this time.
0 commit comments