Skip to content
Snippets Groups Projects
Commit 8301cd24 authored by Max Neklyudov's avatar Max Neklyudov Committed by Gregory Nutt
Browse files

Correct some problems with SAM3/4 watchdog driver. Includes some small...

Correct some problems with SAM3/4 watchdog driver.  Includes some small improvements.  From Max Neklyudov.
parent 6e8545dd
No related branches found
No related tags found
No related merge requests found
/****************************************************************************
* 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 <gnutt@nuttx.org>
* 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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment