Merge branch 'bugfix/adc2_cct' into 'master'

fix(adc2): fix cct and xpd configurations to improve precision of ADCs

See merge request idf/esp-idf!2020
This commit is contained in:
Ivan Grokhotkov 2018-03-27 16:23:43 +08:00
commit 2935e958fc
2 changed files with 25 additions and 0 deletions

16
components/driver/Kconfig Normal file
View file

@ -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

View file

@ -1046,11 +1046,18 @@ void adc_power_always_on()
void adc_power_on()
{
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) {
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
} else {
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_FSM;
}
#endif
portEXIT_CRITICAL(&rtc_spinlock);
}
@ -1466,6 +1473,8 @@ static inline void adc2_config_width(adc_bits_width_t width_bit)
portENTER_CRITICAL(&rtc_spinlock);
//sar_start_force shared with ADC1
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);
//Invert the adc value,the Output value is invert