kopia lustrzana https://github.com/espressif/esp-idf
fix(adc2): fix cct and xpd configurations to improve precision of ADCs
rodzic
9ea38560ec
commit
28e832c37e
|
@ -0,0 +1,16 @@
|
||||||
|
#menu "Driver configurations"
|
||||||
|
|
||||||
|
menu "ADC configuration"
|
||||||
|
|
||||||
|
config ADC_FORCE_XPD_FSM
|
||||||
|
bool "Use the FSM to control ADC power"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
ADC power can be controlled by the FSM instead of software. This allows the ADC to
|
||||||
|
be shut off when it is not working leading to lower power consumption. However
|
||||||
|
using the FSM control ADC power will increase the noise of ADC.
|
||||||
|
|
||||||
|
endmenu # ADC Configuration
|
||||||
|
|
||||||
|
#endmenu # Driver configurations
|
||||||
|
|
|
@ -1046,11 +1046,18 @@ void adc_power_always_on()
|
||||||
void adc_power_on()
|
void adc_power_on()
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL(&rtc_spinlock);
|
portENTER_CRITICAL(&rtc_spinlock);
|
||||||
|
//The power FSM controlled mode saves more power, while the ADC noise may get increased.
|
||||||
|
#ifndef CONFIG_ADC_FORCE_XPD_FSM
|
||||||
|
//Set the power always on to increase precision.
|
||||||
|
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
|
||||||
|
#else
|
||||||
|
//Use the FSM to turn off the power while not used to save power.
|
||||||
if (SENS.sar_meas_wait2.force_xpd_sar & SENS_FORCE_XPD_SAR_SW_M) {
|
if (SENS.sar_meas_wait2.force_xpd_sar & SENS_FORCE_XPD_SAR_SW_M) {
|
||||||
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
|
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
|
||||||
} else {
|
} else {
|
||||||
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_FSM;
|
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_FSM;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
portEXIT_CRITICAL(&rtc_spinlock);
|
portEXIT_CRITICAL(&rtc_spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1466,6 +1473,8 @@ static inline void adc2_config_width(adc_bits_width_t width_bit)
|
||||||
portENTER_CRITICAL(&rtc_spinlock);
|
portENTER_CRITICAL(&rtc_spinlock);
|
||||||
//sar_start_force shared with ADC1
|
//sar_start_force shared with ADC1
|
||||||
SENS.sar_start_force.sar2_bit_width = width_bit;
|
SENS.sar_start_force.sar2_bit_width = width_bit;
|
||||||
|
//cct set to the same value with PHY
|
||||||
|
SENS.sar_start_force.sar2_pwdet_cct = 4;
|
||||||
portEXIT_CRITICAL(&rtc_spinlock);
|
portEXIT_CRITICAL(&rtc_spinlock);
|
||||||
|
|
||||||
//Invert the adc value,the Output value is invert
|
//Invert the adc value,the Output value is invert
|
||||||
|
|
Ładowanie…
Reference in New Issue