From 50fd22f735ecb1b113ca08eafd8edd838b0f8572 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 16 Apr 2012 22:15:33 +0000 Subject: Fix a couple of bugs in the STM32 IWDG driver git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4620 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/watchdog/watchdog_main.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'apps/examples') diff --git a/apps/examples/watchdog/watchdog_main.c b/apps/examples/watchdog/watchdog_main.c index 819f2636f..c1341e0fb 100644 --- a/apps/examples/watchdog/watchdog_main.c +++ b/apps/examples/watchdog/watchdog_main.c @@ -223,6 +223,9 @@ static void parse_args(FAR struct wdog_example_s *wdog, int argc, FAR char **arg int wdog_main(int argc, char *argv[]) { struct wdog_example_s wdog; +#ifdef CONFIG_DEBUG_WATCHDOG + struct watchdog_status_s status; +#endif long elapsed; int fd; int ret; @@ -278,6 +281,21 @@ int wdog_main(int argc, char *argv[]) usleep(wdog.pingdelay * 1000); + /* Show watchdog status. Only if debug is enabled because this + * could interfere with the timer. + */ + +#ifdef CONFIG_DEBUG_WATCHDOG + ret = ioctl(fd, WDIOC_GETSTATUS, (unsigned long)&status); + if (ret < 0) + { + message("wdog_main: ioctl(WDIOC_GETSTATUS) failed: %d\n", errno); + goto errout_with_dev; + } + message("wdog_main: flags=%08x timeout=%d timeleft=%d\n", + status.flags, status.timeout, status.timeleft); +#endif + /* Then ping */ ret = ioctl(fd, WDIOC_KEEPALIVE, 0); @@ -299,6 +317,21 @@ int wdog_main(int argc, char *argv[]) usleep(wdog.pingdelay * 1000); + /* Show watchdog status. Only if debug is enabled because this + * could interfere with the timer. + */ + +#ifdef CONFIG_DEBUG_WATCHDOG + ret = ioctl(fd, WDIOC_GETSTATUS, (unsigned long)&status); + if (ret < 0) + { + message("wdog_main: ioctl(WDIOC_GETSTATUS) failed: %d\n", errno); + goto errout_with_dev; + } + message("wdog_main: flags=%08x timeout=%d timeleft=%d\n", + status.flags, status.timeout, status.timeleft); +#endif + message(" NO ping elapsed=%ld\n", elapsed); msgflush(); } -- cgit v1.2.3