From b13e1820990c6d39089ccc26980dc48356200659 Mon Sep 17 00:00:00 2001 From: Max Neklyudov Date: Tue, 21 Jul 2015 07:15:39 -0600 Subject: [PATCH] Correct some problems with SAM3/4 watchdog driver. Includes some small improvements. From Max Neklyudov. --- arch/arm/src/sam34/sam_wdt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/sam34/sam_wdt.c b/arch/arm/src/sam34/sam_wdt.c index 599c36b292..0c030a9b33 100644 --- a/arch/arm/src/sam34/sam_wdt.c +++ b/arch/arm/src/sam34/sam_wdt.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sam34/sam_wdt.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * Bob Doiron * @@ -631,7 +631,7 @@ static int sam34_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, else if (mintime < priv->timeout) { uint32_t window = (((priv->timeout - mintime) * WDT_FCLK) / 1000) - 1; - DEBUGASSERT(window < priv->reload); + DEBUGASSERT(window <= priv->reload); priv->window = window; ret = OK; } @@ -664,6 +664,12 @@ static int sam34_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd, void sam_wdtinitialize(FAR const char *devpath) { FAR struct sam34_lowerhalf_s *priv = &g_wdgdev; + uint32_t mr_val; + + /* Enable watchdog with 5 sec timeout */ + + mr_val |= (WDT_MR_WDD((5) * WDT_FCLK) | WDT_MR_WDV((5) * WDT_FCLK) | WDT_MR_WDRSTEN); + sam34_putreg(mr_val, SAM_WDT_MR); wdvdbg("Entry: devpath=%s\n", devpath); @@ -690,6 +696,10 @@ void sam_wdtinitialize(FAR const char *devpath) sam34_settimeout((FAR struct watchdog_lowerhalf_s *)priv, CONFIG_WDT_TIMEOUT); + /* Disable minimum time feature for now. */ + + priv->window = priv->reload; + /* Register the watchdog driver as /dev/watchdog0 */ (void)watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv);