mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-07-10 04:48:21 +08:00
feat(wifi): refactor wifi power management
This commit is contained in:
components/esp8266
@ -15,6 +15,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "driver/gpio.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);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -191,6 +191,42 @@ void esp_wifi_set_pm_recv_multi_data(bool enable);
|
|||||||
*/
|
*/
|
||||||
bool esp_wifi_get_pm_recv_multi_data(void);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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)
|
static inline void update_soc_clk(pm_soc_clk_t *clk)
|
||||||
{
|
{
|
||||||
extern uint32_t WdevTimOffSet;
|
extern uint64_t WdevTimOffSet;
|
||||||
|
|
||||||
uint32_t slept_us;
|
uint32_t slept_us;
|
||||||
|
|
||||||
|
@ -74,16 +74,10 @@ static void user_init_entry(void *param)
|
|||||||
|
|
||||||
extern void app_main(void);
|
extern void app_main(void);
|
||||||
|
|
||||||
extern void phy_close_rf(void);
|
|
||||||
|
|
||||||
extern void esp_sleep_unlock();
|
|
||||||
|
|
||||||
/* initialize C++ construture function */
|
/* initialize C++ construture function */
|
||||||
for (func = &__init_array_start; func < &__init_array_end; func++)
|
for (func = &__init_array_start; func < &__init_array_end; func++)
|
||||||
func[0]();
|
func[0]();
|
||||||
|
|
||||||
phy_get_bb_evm();
|
|
||||||
|
|
||||||
/*enable tsf0 interrupt for pwm*/
|
/*enable tsf0 interrupt for pwm*/
|
||||||
REG_WRITE(PERIPHS_DPORT_BASEADDR, (REG_READ(PERIPHS_DPORT_BASEADDR) & ~0x1F) | 0x1);
|
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);
|
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(rtc_init() == 0);
|
||||||
assert(mac_init() == 0);
|
assert(mac_init() == 0);
|
||||||
assert(base_gpio_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);
|
esp_wifi_set_rx_pbuf_mem_type(WIFI_RX_PBUF_DRAM);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user