From 8c89bcff4dce7f8921ffda1603d6f77bf8465356 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Tue, 27 May 2014 10:45:32 -0700 Subject: zinger: activate the watchdog. Ensure we are never stuck somewhere without doing the safety checks by enabling the watchdog and reloading it in the safaty checks function. I have kept the default timing constants, so on STM32F0xx the watchdog period should be between 1.2s (LSI at 30kHz) and 2.0s (LSI at 50kHz). Signed-off-by: Vincent Palatin BRANCH=none BUG=none TEST=add a 2s loop in the serial port interrupt handler and see the power supply rebooting. Change-Id: I000f2a36a31e1166adf63a36c2b7f52999adc928 Reviewed-on: https://chromium-review.googlesource.com/201575 Reviewed-by: Alec Berg Commit-Queue: Vincent Palatin Tested-by: Vincent Palatin --- board/zinger/hardware.c | 2 ++ board/zinger/usb_pd_policy.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/board/zinger/hardware.c b/board/zinger/hardware.c index 0bafa48839..52d2f4e057 100644 --- a/board/zinger/hardware.c +++ b/board/zinger/hardware.c @@ -13,6 +13,7 @@ #include "task.h" #include "timer.h" #include "util.h" +#include "watchdog.h" static void clock_init(void) { @@ -164,6 +165,7 @@ void hardware_init(void) pins_init(); uart_init(); timers_init(); + watchdog_init(); adc_init(); irq_init(); } diff --git a/board/zinger/usb_pd_policy.c b/board/zinger/usb_pd_policy.c index c8dfcb0ea2..1b52d0876c 100644 --- a/board/zinger/usb_pd_policy.c +++ b/board/zinger/usb_pd_policy.c @@ -186,6 +186,9 @@ int pd_board_checks(void) int vbus_volt, vbus_amp; int watchdog_enabled = STM32_ADC_CFGR1 & (1 << 23); + /* Reload the watchdog */ + STM32_IWDG_KR = STM32_IWDG_KR_RELOAD; + if (watchdog_enabled) /* if the watchdog is enabled, stop it to do other readings */ adc_disable_watchdog(); -- cgit v1.2.1