mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
fix(esp8266): fix that WDEV time is larger than normal
This commit is contained in:
@ -49,6 +49,8 @@ typedef struct pm_soc_clk {
|
||||
|
||||
uint32_t frc2_enable;
|
||||
uint32_t frc2_cnt;
|
||||
|
||||
uint32_t wdev_cnt;
|
||||
} pm_soc_clk_t;
|
||||
|
||||
static uint16_t s_lock_cnt = 1;
|
||||
@ -79,6 +81,8 @@ static inline void save_soc_clk(pm_soc_clk_t *clk)
|
||||
clk->frc2_enable = REG_READ(FRC2_CTL) & FRC2_CNTL_ENABLE;
|
||||
if (clk->frc2_enable)
|
||||
clk->frc2_cnt = REG_READ(FRC2_COUNT);
|
||||
|
||||
clk->wdev_cnt = REG_READ(WDEV_COUNT_REG);
|
||||
}
|
||||
|
||||
static inline uint32_t min_sleep_us(pm_soc_clk_t *clk)
|
||||
@ -114,7 +118,15 @@ static inline void update_soc_clk(pm_soc_clk_t *clk, uint32_t us)
|
||||
REG_WRITE(FRC2_LOAD, frc2_cnt);
|
||||
}
|
||||
|
||||
WdevTimOffSet += us;
|
||||
uint32_t wdev_us;
|
||||
uint32_t wdev_cnt = REG_READ(WDEV_COUNT_REG);
|
||||
|
||||
if (clk->wdev_cnt < wdev_cnt)
|
||||
wdev_us = us - (wdev_cnt - clk->wdev_cnt);
|
||||
else
|
||||
wdev_us = us - (UINT32_MAX - clk->wdev_cnt + wdev_cnt);
|
||||
|
||||
WdevTimOffSet += wdev_us;
|
||||
}
|
||||
|
||||
static int cpu_is_wait_mode(void)
|
||||
|
Reference in New Issue
Block a user