mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(sleep/usb): support usb as wakeup source from light sleep
This commit is contained in:
@@ -137,6 +137,7 @@ typedef enum {
|
||||
ESP_SLEEP_WAKEUP_BT, //!< Wakeup caused by BT (light sleep only)
|
||||
ESP_SLEEP_WAKEUP_VAD, //!< Wakeup caused by VAD
|
||||
ESP_SLEEP_WAKEUP_VBAT_UNDER_VOLT, //!< Wakeup caused by VDD_BAT under voltage.
|
||||
ESP_SLEEP_WAKEUP_USB, //!< Wakeup caused by USB (light sleep only)
|
||||
} esp_sleep_source_t;
|
||||
|
||||
/**
|
||||
@@ -565,6 +566,22 @@ esp_err_t esp_sleep_enable_bt_wakeup(void);
|
||||
*/
|
||||
esp_err_t esp_sleep_disable_bt_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by USB
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if wakeup from USB is not supported
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_usb_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Disable wakeup by USB
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if wakeup from USB is not supported
|
||||
*/
|
||||
esp_err_t esp_sleep_disable_usb_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by WiFi MAC
|
||||
* @return
|
||||
|
||||
@@ -2456,6 +2456,26 @@ esp_err_t esp_sleep_disable_bt_wakeup(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_sleep_enable_usb_wakeup(void)
|
||||
{
|
||||
#if SOC_PM_SUPPORT_USB_WAKEUP
|
||||
s_config.wakeup_triggers |= RTC_USB_TRIG_EN;
|
||||
return ESP_OK;
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_sleep_disable_usb_wakeup(void)
|
||||
{
|
||||
#if SOC_PM_SUPPORT_USB_WAKEUP
|
||||
s_config.wakeup_triggers &= (~RTC_USB_TRIG_EN);
|
||||
return ESP_OK;
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void)
|
||||
{
|
||||
if (esp_rom_get_reset_reason(0) != RESET_REASON_CORE_DEEP_SLEEP && !s_light_sleep_wakeup) {
|
||||
@@ -2640,6 +2660,11 @@ uint32_t esp_sleep_get_wakeup_causes(void)
|
||||
if (wakeup_cause_raw & RTC_VBAT_UNDER_VOLT_TRIG_EN) {
|
||||
wakeup_cause |= BIT(ESP_SLEEP_WAKEUP_VBAT_UNDER_VOLT);
|
||||
}
|
||||
#endif
|
||||
#if SOC_PM_SUPPORT_USB_WAKEUP
|
||||
if (wakeup_cause_raw & RTC_USB_TRIG_EN) {
|
||||
wakeup_cause |= BIT(ESP_SLEEP_WAKEUP_USB);
|
||||
}
|
||||
#endif
|
||||
if (wakeup_cause == 0) {
|
||||
wakeup_cause |= BIT(ESP_SLEEP_WAKEUP_UNDEFINED);
|
||||
|
||||
Reference in New Issue
Block a user