diff --git a/components/esp8266/include/esp_sleep.h b/components/esp8266/include/esp_sleep.h index d5c1a33e..b9d54a56 100644 --- a/components/esp8266/include/esp_sleep.h +++ b/components/esp8266/include/esp_sleep.h @@ -15,6 +15,7 @@ #pragma once #include +#include #include "esp_err.h" #include "driver/gpio.h" @@ -261,6 +262,22 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void); */ esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source); +/** + * @brief Print power consumption information + * + * @note This function is used to print power consumption data. The current + * when the RF and CPU are both turned on is 70 mA. The current when + * only the CPU is turned on is 18 mA. 900uA when both CPU and RF are off. + * There may be some errors compared to the actual power consumption. + * The power consumption is based on the actual measurement, and the printing + * in the function is for reference only. + * + * @param clear_old_data - Recalculate power consumption info or not. + * + * @return null + */ +void esp_power_consumption_info(bool clear_old_data); + #ifdef __cplusplus } #endif diff --git a/components/esp8266/include/internal/esp_wifi_internal.h b/components/esp8266/include/internal/esp_wifi_internal.h index 91f2ca88..887a2486 100644 --- a/components/esp8266/include/internal/esp_wifi_internal.h +++ b/components/esp8266/include/internal/esp_wifi_internal.h @@ -191,6 +191,42 @@ void esp_wifi_set_pm_recv_multi_data(bool enable); */ bool esp_wifi_get_pm_recv_multi_data(void); +/** + * @brief Set max beacon early time. + * + * @param max_bcn_early_ms max beacon early time(2~15ms), default 4ms. + */ +void esp_wifi_set_pm_max_bcn_early(uint8_t max_bcn_early_ms); + +/** + * @brief get max beacon early time. + */ +uint8_t esp_wifi_get_pm_max_bcn_early(void); + +/** + * @brief Set max beacon timeout time. + * + * @param max_bcn_early_ms max beacon timeout time(12~32ms), default 24ms. + */ +void esp_wifi_set_pm_max_bcn_timeout(uint8_t max_bcn_timeout_ms); + +/** + * @brief get max beacon timeout time. + */ +uint8_t esp_wifi_get_pm_max_bcn_timeout(void); + +/** + * @brief Set max wait tx rx time. + * + * @param max_bcn_early_ms max wait tx rx time(10~2000ms), default 20ms. + */ +void esp_wifi_set_pm_wait_tx_rx_time(uint32_t wait_tx_rx_time_ms); + +/** + * @brief get max wait tx rx time. + */ +uint32_t esp_wifi_get_pm_wait_tx_rx_time(); + #ifdef __cplusplus } #endif diff --git a/components/esp8266/source/esp_sleep.c b/components/esp8266/source/esp_sleep.c index bc3e7b37..220322b6 100644 --- a/components/esp8266/source/esp_sleep.c +++ b/components/esp8266/source/esp_sleep.c @@ -146,7 +146,7 @@ static inline uint32_t sleep_rtc_ticks(pm_soc_clk_t *clk) static inline void update_soc_clk(pm_soc_clk_t *clk) { - extern uint32_t WdevTimOffSet; + extern uint64_t WdevTimOffSet; uint32_t slept_us; diff --git a/components/esp8266/source/startup.c b/components/esp8266/source/startup.c index 4118fffb..14bdae5f 100644 --- a/components/esp8266/source/startup.c +++ b/components/esp8266/source/startup.c @@ -74,16 +74,10 @@ static void user_init_entry(void *param) extern void app_main(void); - extern void phy_close_rf(void); - - extern void esp_sleep_unlock(); - /* initialize C++ construture function */ for (func = &__init_array_start; func < &__init_array_end; func++) func[0](); - phy_get_bb_evm(); - /*enable tsf0 interrupt for pwm*/ REG_WRITE(PERIPHS_DPORT_BASEADDR, (REG_READ(PERIPHS_DPORT_BASEADDR) & ~0x1F) | 0x1); REG_WRITE(INT_ENA_WDEV, REG_READ(INT_ENA_WDEV) | WDEV_TSF0_REACH_INT); @@ -92,9 +86,6 @@ static void user_init_entry(void *param) assert(rtc_init() == 0); assert(mac_init() == 0); assert(base_gpio_init() == 0); - esp_phy_load_cal_and_init(0); - phy_close_rf(); - esp_sleep_unlock(); esp_wifi_set_rx_pbuf_mem_type(WIFI_RX_PBUF_DRAM);