summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-01 07:06:54 +0800
committerChromeBot <chrome-bot@google.com>2013-04-30 22:53:14 -0700
commit23cb9982058092993f319b2b30fefd52639af288 (patch)
tree941c14bfd530cddf3034c9b354ef0cffd71e8f58
parente63aade5bd3553bd1a6fe7fa391edfb8b36c283e (diff)
downloadchrome-ec-23cb9982058092993f319b2b30fefd52639af288.tar.gz
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>
-rw-r--r--chip/stm32/adc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/chip/stm32/adc.c b/chip/stm32/adc.c
index 1aad5d5744..99b014ef29 100644
--- a/chip/stm32/adc.c
+++ b/chip/stm32/adc.c
@@ -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);