mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/temp_clk_gate_v5.01' into 'release/v5.0'
fix(temperature_snesor): Put clock gate enable/disable in to sar_periph_ctrl together (backport v5.0) See merge request espressif/esp-idf!26437
This commit is contained in:
commit
c33962259c
@ -95,10 +95,7 @@ esp_err_t temp_sensor_start(void)
|
|||||||
ESP_LOGE(TAG, "Is already running or not be configured");
|
ESP_LOGE(TAG, "Is already running or not be configured");
|
||||||
err = ESP_ERR_INVALID_STATE;
|
err = ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
regi2c_saradc_enable();
|
|
||||||
periph_module_enable(PERIPH_TEMPSENSOR_MODULE);
|
|
||||||
temperature_sensor_power_acquire();
|
temperature_sensor_power_acquire();
|
||||||
temperature_sensor_ll_clk_enable(true);
|
|
||||||
temperature_sensor_ll_clk_sel(TEMPERATURE_SENSOR_CLK_SRC_DEFAULT);
|
temperature_sensor_ll_clk_sel(TEMPERATURE_SENSOR_CLK_SRC_DEFAULT);
|
||||||
tsens_hw_state = TSENS_HW_STATE_STARTED;
|
tsens_hw_state = TSENS_HW_STATE_STARTED;
|
||||||
return err;
|
return err;
|
||||||
@ -106,7 +103,6 @@ esp_err_t temp_sensor_start(void)
|
|||||||
|
|
||||||
esp_err_t temp_sensor_stop(void)
|
esp_err_t temp_sensor_stop(void)
|
||||||
{
|
{
|
||||||
regi2c_saradc_disable();
|
|
||||||
temperature_sensor_power_release();
|
temperature_sensor_power_release();
|
||||||
tsens_hw_state = TSENS_HW_STATE_CONFIGURED;
|
tsens_hw_state = TSENS_HW_STATE_CONFIGURED;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
@ -90,8 +90,6 @@ esp_err_t temperature_sensor_install(const temperature_sensor_config_t *tsens_co
|
|||||||
ESP_GOTO_ON_FALSE(tsens != NULL, ESP_ERR_NO_MEM, err, TAG, "no mem for temp sensor");
|
ESP_GOTO_ON_FALSE(tsens != NULL, ESP_ERR_NO_MEM, err, TAG, "no mem for temp sensor");
|
||||||
tsens->clk_src = tsens_config->clk_src;
|
tsens->clk_src = tsens_config->clk_src;
|
||||||
|
|
||||||
periph_module_enable(PERIPH_TEMPSENSOR_MODULE);
|
|
||||||
periph_module_reset(PERIPH_TEMPSENSOR_MODULE);
|
|
||||||
ESP_GOTO_ON_ERROR(temperature_sensor_attribute_table_sort(), err, TAG, "Table sort failed");
|
ESP_GOTO_ON_ERROR(temperature_sensor_attribute_table_sort(), err, TAG, "Table sort failed");
|
||||||
ESP_GOTO_ON_ERROR(temperature_sensor_choose_best_range(tsens, tsens_config), err, TAG, "Cannot select the correct range");
|
ESP_GOTO_ON_ERROR(temperature_sensor_choose_best_range(tsens, tsens_config), err, TAG, "Cannot select the correct range");
|
||||||
|
|
||||||
@ -100,7 +98,6 @@ esp_err_t temperature_sensor_install(const temperature_sensor_config_t *tsens_co
|
|||||||
tsens->tsens_attribute->range_max,
|
tsens->tsens_attribute->range_max,
|
||||||
tsens->tsens_attribute->error_max);
|
tsens->tsens_attribute->error_max);
|
||||||
|
|
||||||
regi2c_saradc_enable();
|
|
||||||
temperature_sensor_ll_set_range(tsens->tsens_attribute->reg_val);
|
temperature_sensor_ll_set_range(tsens->tsens_attribute->reg_val);
|
||||||
|
|
||||||
tsens->fsm = TEMP_SENSOR_FSM_INIT;
|
tsens->fsm = TEMP_SENSOR_FSM_INIT;
|
||||||
@ -120,9 +117,7 @@ esp_err_t temperature_sensor_uninstall(temperature_sensor_handle_t tsens)
|
|||||||
free(s_tsens_attribute_copy);
|
free(s_tsens_attribute_copy);
|
||||||
}
|
}
|
||||||
s_tsens_attribute_copy = NULL;
|
s_tsens_attribute_copy = NULL;
|
||||||
regi2c_saradc_disable();
|
|
||||||
|
|
||||||
periph_module_disable(PERIPH_TEMPSENSOR_MODULE);
|
|
||||||
free(tsens);
|
free(tsens);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@ -152,7 +147,6 @@ esp_err_t temperature_sensor_enable(temperature_sensor_handle_t tsens)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
temperature_sensor_ll_clk_enable(true);
|
|
||||||
temperature_sensor_ll_clk_sel(tsens->clk_src);
|
temperature_sensor_ll_clk_sel(tsens->clk_src);
|
||||||
temperature_sensor_power_acquire();
|
temperature_sensor_power_acquire();
|
||||||
tsens->fsm = TEMP_SENSOR_FSM_ENABLE;
|
tsens->fsm = TEMP_SENSOR_FSM_ENABLE;
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#if SOC_TEMP_SENSOR_SUPPORTED
|
#if SOC_TEMP_SENSOR_SUPPORTED
|
||||||
#include "hal/temperature_sensor_ll.h"
|
#include "hal/temperature_sensor_ll.h"
|
||||||
#include "soc/temperature_sensor_periph.h"
|
#include "soc/temperature_sensor_periph.h"
|
||||||
|
#include "soc/periph_defs.h"
|
||||||
|
#include "esp_private/periph_ctrl.h"
|
||||||
|
|
||||||
extern __attribute__((unused)) portMUX_TYPE rtc_spinlock;
|
extern __attribute__((unused)) portMUX_TYPE rtc_spinlock;
|
||||||
|
|
||||||
@ -35,6 +37,10 @@ void temperature_sensor_power_acquire(void)
|
|||||||
portENTER_CRITICAL(&rtc_spinlock);
|
portENTER_CRITICAL(&rtc_spinlock);
|
||||||
s_temperature_sensor_power_cnt++;
|
s_temperature_sensor_power_cnt++;
|
||||||
if (s_temperature_sensor_power_cnt == 1) {
|
if (s_temperature_sensor_power_cnt == 1) {
|
||||||
|
periph_module_enable(PERIPH_TEMPSENSOR_MODULE);
|
||||||
|
periph_module_reset(PERIPH_TEMPSENSOR_MODULE);
|
||||||
|
regi2c_saradc_enable();
|
||||||
|
temperature_sensor_ll_clk_enable(true);
|
||||||
temperature_sensor_ll_enable(true);
|
temperature_sensor_ll_enable(true);
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL(&rtc_spinlock);
|
portEXIT_CRITICAL(&rtc_spinlock);
|
||||||
@ -50,7 +56,10 @@ void temperature_sensor_power_release(void)
|
|||||||
ESP_LOGE(TAG_TSENS, "%s called, but s_temperature_sensor_power_cnt == 0", __func__);
|
ESP_LOGE(TAG_TSENS, "%s called, but s_temperature_sensor_power_cnt == 0", __func__);
|
||||||
abort();
|
abort();
|
||||||
} else if (s_temperature_sensor_power_cnt == 0) {
|
} else if (s_temperature_sensor_power_cnt == 0) {
|
||||||
|
temperature_sensor_ll_clk_enable(false);
|
||||||
temperature_sensor_ll_enable(false);
|
temperature_sensor_ll_enable(false);
|
||||||
|
regi2c_saradc_disable();
|
||||||
|
periph_module_disable(PERIPH_TEMPSENSOR_MODULE);
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL(&rtc_spinlock);
|
portEXIT_CRITICAL(&rtc_spinlock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user