mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(esp_hw_support): allows to forcefully disable submodes at mode initialization
This commit is contained in:
parent
00991f1bf5
commit
37fa09f1dc
@ -43,6 +43,7 @@ typedef enum {
|
||||
|
||||
/**
|
||||
* @brief Set sub-sleep power mode in sleep, mode enabled status is maintained by reference count.
|
||||
* The caller should ensure that the enabling and disabling behavior is symmetric.
|
||||
* This submode configuration will kept after deep sleep wakeup.
|
||||
*
|
||||
* @param mode sub-sleep mode type
|
||||
@ -54,6 +55,17 @@ typedef enum {
|
||||
*/
|
||||
esp_err_t esp_sleep_sub_mode_config(esp_sleep_sub_mode_t mode, bool activate);
|
||||
|
||||
/**
|
||||
* @brief Force disable sub-sleep power mode in sleep, usually used during initialization.
|
||||
*
|
||||
* @param mode sub-sleep mode type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
|
||||
*/
|
||||
esp_err_t esp_sleep_sub_mode_force_disable(esp_sleep_sub_mode_t mode);
|
||||
|
||||
/**
|
||||
* Dump the sub-sleep power mode enable status
|
||||
* @param stream The stream to dump to, if NULL then nothing will be dumped
|
||||
|
@ -2189,6 +2189,18 @@ esp_err_t esp_sleep_sub_mode_config(esp_sleep_sub_mode_t mode, bool activate)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_sleep_sub_mode_force_disable(esp_sleep_sub_mode_t mode)
|
||||
{
|
||||
if (mode >= ESP_SLEEP_MODE_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
portENTER_CRITICAL_SAFE(&s_config.lock);
|
||||
s_sleep_sub_mode_ref_cnt[mode] = 0;
|
||||
portEXIT_CRITICAL_SAFE(&s_config.lock);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int32_t* esp_sleep_sub_mode_dump_config(FILE *stream) {
|
||||
if (stream) {
|
||||
for (uint32_t mode = 0; mode < ESP_SLEEP_MODE_MAX; mode++) {
|
||||
@ -2414,15 +2426,27 @@ esp_deep_sleep_disable_rom_logging(void)
|
||||
|
||||
__attribute__((deprecated("Please use esp_sleep_sub_mode_config instead"))) void esp_sleep_periph_use_8m(bool use_or_not)
|
||||
{
|
||||
esp_sleep_sub_mode_config(ESP_SLEEP_DIG_USE_RC_FAST_MODE, use_or_not);
|
||||
if (use_or_not) {
|
||||
esp_sleep_sub_mode_config(ESP_SLEEP_DIG_USE_RC_FAST_MODE, use_or_not);
|
||||
} else {
|
||||
esp_sleep_sub_mode_force_disable(ESP_SLEEP_DIG_USE_RC_FAST_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((deprecated("Please use esp_sleep_sub_mode_config instead"))) void esp_sleep_enable_adc_tsens_monitor(bool enable)
|
||||
{
|
||||
esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TSEN_MONITOR_MODE, enable);
|
||||
if (enable) {
|
||||
esp_sleep_sub_mode_config(ESP_SLEEP_USE_ADC_TSEN_MONITOR_MODE, enable);
|
||||
} else {
|
||||
esp_sleep_sub_mode_force_disable(ESP_SLEEP_USE_ADC_TSEN_MONITOR_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((deprecated("Please use esp_sleep_sub_mode_config instead"))) void rtc_sleep_enable_ultra_low(bool enable)
|
||||
{
|
||||
esp_sleep_sub_mode_config(ESP_SLEEP_ULTRA_LOW_MODE, enable);
|
||||
if (enable) {
|
||||
esp_sleep_sub_mode_config(ESP_SLEEP_ULTRA_LOW_MODE, enable);
|
||||
} else {
|
||||
esp_sleep_sub_mode_force_disable(ESP_SLEEP_ULTRA_LOW_MODE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user