ESP8266 Developer Zone The Official ESP8266 Forum 2018-02-08T21:12:22+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=8990 2018-02-08T21:12:22+08:00 2018-02-08T21:12:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8990&p=19363#p19363 <![CDATA[Re: SDK 2.1 ligth sleep mode]]>
Here is the function :

Code:

bool ICACHE_FLASH_ATTR
UART_CheckOutputFinished(uint8 uart_no, uint32 time_out_us)
{
    uint32 t_start = system_get_time();
    uint8 tx_fifo_len;
    uint32 tx_buff_len;
    while(1){
        tx_fifo_len =( (READ_PERI_REG(UART_STATUS(uart_no))>>UART_TXFIFO_CNT_S)&UART_TXFIFO_CNT);
        if(pTxBuffer){
            tx_buff_len = ((pTxBuffer->UartBuffSize)-(pTxBuffer->Space));
        }else{
            tx_buff_len = 0;
        }
      
        if( tx_fifo_len==0 && tx_buff_len==0){
            return TRUE;
        }
        if( system_get_time() - t_start > time_out_us){
            return FALSE;
        }
   WRITE_PERI_REG(0X60000914, 0X73);//WTD
    }   
}

Statistics: Posted by JulienInnovel — Thu Feb 08, 2018 9:12 pm


]]>
2018-01-17T16:16:06+08:00 2018-01-17T16:16:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8990&p=19097#p19097 <![CDATA[Re: SDK 2.1 ligth sleep mode]]> If it is a timer, the timer will stop the ESP to enter light sleep mode.

Statistics: Posted by Her Mary — Wed Jan 17, 2018 4:16 pm


]]>
2018-01-15T18:43:08+08:00 2018-01-15T18:43:08+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8990&p=19075#p19075 <![CDATA[SDK 2.1 ligth sleep mode]]>
I'm using the new SDK 2.1 since this morning.
Until the new sdk (using the SDK 2.0), I was able to use the light sleep mode by doing this :

void fpm_wakup_cb(void)
{
wifi_fpm_close(); // disable force sleep function
wifi_set_opmode(STATION_MODE); // set station mode
wifi_station_connect(); // connect to AP
os_timer_arm(&s_Timer, TIMER_TIME_MS, 1);
uart_rx_intr_enable(UART1);
os_printf("WakeUp !\n");
}

void ICACHE_FLASH_ATTR prepare_to_sleep(void)
{
int8_t err;

os_timer_disarm(&s_Timer);
LED_OFF;
os_printf("Go to sleep mode...\n\n");
uart_rx_intr_disable(UART1);
wifi_station_disconnect();
//wifi_set_opmode(NULL_MODE); // set WiFi mode to null mode.
wifi_set_opmode_current(NULL_MODE);
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); // light sleep
wifi_fpm_open(); // enable force sleep
wifi_fpm_set_wakeup_cb(fpm_wakup_cb); // Set wakeup callback
UART_CheckOutputFinished(UART1, 1000000);
wifi_fpm_do_sleep(30 * 1000 * 1000);
}

Each time I call function prepare_to_sleep, the ESP enter sleep mode and wake up after 30s.
But, since the new SDK 2.1, it doesn't work...
Sometimes the wakeup is done juste after the sleep, like if sleep timeout is 1us, and sometimes no wakeup from sleep...

Maybe I do something wrong...

Thanks for your help,
Best regards

Statistics: Posted by JulienInnovel — Mon Jan 15, 2018 6:43 pm


]]>