From 27d60bb83eae453955ae55235ea31d7aa2d39a3f Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Tue, 14 Oct 2014 16:50:52 -0700 Subject: [PATCH] zinger: fix double ADC interrupt bug The ADC interrupt does not clear the NVIC pending register. This can cause the interrupt to fire more than once for a given interrupt. BUG=none BRANCH=samus TEST=Send hard reset from samus to zinger using "pd 1 hard" on PD MCU console. This causes zinger to cut its output voltage and go into voltage discharging mode. When voltage discharge is complete, we get an ADC interrupt and switch back to current monitoring. Before this CL, sometimes (1 out of 20) times the ADC interrupt will fire twice, causing an OCP to be detected. With this CL, we never see the double fire. Change-Id: I91397a04773d04e263bc80a698c8799342b80a2e Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/223381 Reviewed-by: Vincent Palatin --- board/zinger/usb_pd_policy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c index 78b5430194..103450e24a 100644 --- a/board/zinger/usb_pd_policy.c +++ b/board/zinger/usb_pd_policy.c @@ -369,6 +369,9 @@ void pd_adc_interrupt(void) fault = FAULT_FAST_OCP; /* pd_board_checks() will record the timeout later */ } + + /* clear ADC irq so we don't get a second interrupt */ + task_clear_pending_irq(STM32_IRQ_ADC_COMP); } DECLARE_IRQ(STM32_IRQ_ADC_COMP, pd_adc_interrupt, 1);