stm32: Fix ADC watchdog bug and extend sample time

This fixes a bug in ADC watchdog that sample sequence is not set before
enabling ADC watchdog. Also, current sample time isn't long enough for
some weakly driven net. This extends ADC sample time to 13.5 cycles.

BUG=chrome-os-partner:17928
TEST=Test with Toad cable and video dongle on Spring
BRANCH=spring

Change-Id: Iecdfd4aada4e974225a41144e213e92897f4797b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49680
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vic Yang
2013-05-01 07:06:54 +08:00
committed by ChromeBot
parent e63aade5bd
commit 23cb998205

View File

@@ -95,6 +95,8 @@ static int adc_enable_watchdog_no_lock(void)
return EC_ERROR_UNKNOWN;
/* Set channel */
STM32_ADC_SQR3 = watchdog_ain_id;
STM32_ADC_SQR1 = 0;
STM32_ADC_CR1 = (STM32_ADC_CR1 & ~0x1f) | watchdog_ain_id;
/* Clear interrupt bit */
@@ -271,11 +273,11 @@ static void adc_init(void)
STM32_ADC_CR2 &= ~(1 << 11);
/*
* Set sample time of all channels to 7.5 cycles.
* Conversion takes 8.75 us.
* Set sample time of all channels to 13.5 cycles.
* Conversion takes 15.75 us.
*/
STM32_ADC_SMPR1 = 0x00249249;
STM32_ADC_SMPR2 = 0x09249249;
STM32_ADC_SMPR1 = 0x00492492;
STM32_ADC_SMPR2 = 0x12492492;
}
DECLARE_HOOK(HOOK_INIT, adc_init, HOOK_PRIO_DEFAULT);