EasyManua.ls Logo

Espressif Systems ESP8266EX - Examples of Forced Sleep

Espressif Systems ESP8266EX
41 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
!
3. Sample Codes
3.4.2. Examples of Forced Sleep
The forced-sleep interface can be called, and the RF circuit can be closed mandatorily so
as to lower the power.
Example One: Modem-sleep Mode (RF Disabled)
󰲧󰲧󰲧󰲧#define󰲧FPM_SLEEP_MAX_TIME󰲧󰲧󰲧󰲧󰲧󰲧󰲧 0xFFFFFFF
void󰲧fpm_wakup_cb_func1(void)
{
󰲧󰲧󰲧󰲧Wi-Fi_fpm_close();󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧disable󰲧force󰲧sleep󰲧function
󰲧󰲧󰲧󰲧Wi-Fi_set_opmode(STATION_MODE);󰲧󰲧󰲧󰲧󰲧󰲧//󰲧set󰲧station󰲧mode
󰲧󰲧󰲧󰲧Wi-Fi_station_connect();󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧connect󰲧to󰲧AP
}
void󰲧user_func(…)
{
󰲧󰲧󰲧󰲧…
󰲧󰲧󰲧󰲧Wi-Fi_station_disconnect();
󰲧󰲧󰲧󰲧Wi-Fi_set_opmode(NULL_MODE);󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧set󰲧Wi-Fi󰲧mode󰲧to󰲧null󰲧mode.
󰲧󰲧󰲧󰲧Wi-Fi_fpm_set_sleep_type(MODEM_SLEEP_T);󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧modem󰲧sleep
󰲧󰲧󰲧󰲧Wi-Fi_fpm_open();󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧enable󰲧force󰲧sleep
#ifdef󰲧SLEEP_MAX
/*󰲧For󰲧modem󰲧sleep,󰲧FPM_SLEEP_MAX_TIME󰲧can󰲧only󰲧be󰲧wakened󰲧by󰲧calling󰲧Wi-Fi_fpm_do_wakeup.󰲧
*/
󰲧󰲧󰲧󰲧Wi-Fi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);
#else
//󰲧wakeup󰲧automatically󰲧when󰲧timeout.
󰲧󰲧󰲧󰲧Wi-Fi_fpm_set_wakeup_cb(fpm_wakup_cb_func1);󰲧󰲧󰲧//󰲧Set󰲧wakeup󰲧callback
󰲧󰲧󰲧󰲧󰲧Wi-Fi_fpm_do_sleep(50*1000);
#endif
󰲧󰲧󰲧󰲧…
}
#ifdef󰲧SLEEP_MAX
void󰲧func1(void)
{
󰲧󰲧󰲧󰲧Wi-Fi_fpm_do_wakeup();
󰲧󰲧󰲧󰲧Wi-Fi_fpm_close();󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧disable󰲧force󰲧sleep󰲧function
Notice:
When forced-sleep interface is called, the chip will not enter sleep mode instantly, it will enter sleep
mode when the system is executing the idle task.
Below are the sample codes for sleep modes.
Espressif
! /!28 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals