Merge pull request #190 from sheinz/fix/deep_sleep_timer

Fix for system_deep_sleep ignoring argument
This commit is contained in:
sheinz 2016-08-19 10:28:09 +03:00 committed by GitHub
commit 519accd46c
2 changed files with 14 additions and 2 deletions

View file

@ -36,4 +36,8 @@ typedef struct ETSTimer_st {
void *timer_arg;
} ETSTimer;
void sdk_ets_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg);
void sdk_ets_timer_arm(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag);
void sdk_ets_timer_disarm(ETSTimer *ptimer);
#endif /* _ETSTIMER_H */

View file

@ -55,6 +55,9 @@ sdk_wifi_promiscuous_cb_t sdk_promiscuous_cb;
static uint8_t _system_upgrade_flag; // Ldata009
// Timer to execute a second phase of switching to a deep sleep
static ETSTimer deep_sleep_timer;
// Prototypes for static functions
static bool _check_boot_version(void);
static void _deep_sleep_phase2(void *timer_arg);
@ -407,8 +410,13 @@ void sdk_system_deep_sleep(uint32_t time_in_us) {
sdk_wifi_softap_stop();
}
sdk_os_timer_disarm(&sdk_sta_con_timer);
sdk_os_timer_setfn(&sdk_sta_con_timer, _deep_sleep_phase2, (void *)time_in_us);
sdk_os_timer_arm(&sdk_sta_con_timer, 100, 0);
// Originally deep sleep function reused sdk_sta_con_timer
// but we can't mix functions sdk_ets_timer_ with sdk_os_timer_ for the
// same timer. So now deep sleep function uses a separate timer.
sdk_ets_timer_disarm(&deep_sleep_timer);
sdk_ets_timer_setfn(&deep_sleep_timer, _deep_sleep_phase2, (void *)time_in_us);
sdk_ets_timer_arm(&deep_sleep_timer, 100, 0);
}
bool sdk_system_update_cpu_freq(uint8_t freq) {