4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
10 * \author Bernardo Innocenti <bernie@develer.com>
12 * \brief Watchdog interface
17 *#* Revision 1.8 2006/02/20 02:02:29 bernie
20 *#* Revision 1.7 2005/11/27 03:58:40 bernie
21 *#* Add POSIX timer emulator.
23 *#* Revision 1.6 2005/11/27 03:03:08 bernie
24 *#* Add Qt support hack.
26 *#* Revision 1.5 2005/11/04 16:20:02 bernie
27 *#* Fix reference to README.devlib in header.
29 *#* Revision 1.4 2005/04/12 01:37:17 bernie
30 *#* Prevent warning when watchdog is disabled.
32 *#* Revision 1.3 2005/04/11 19:10:28 bernie
33 *#* Include top-level headers from cfg/ subdir.
35 *#* Revision 1.2 2004/11/16 21:02:07 bernie
36 *#* Make driver optional; mark AVR specific parts as such.
38 *#* Revision 1.1 2004/10/26 08:34:47 bernie
39 *#* New DevLib module.
45 #include <appconfig.h>
46 #include <cfg/compiler.h> // INLINE
48 /* Configury sanity check */
49 #if !defined(CONFIG_WATCHDOG) || (CONFIG_WATCHDOG != 0 && CONFIG_WATCHDOG != 1)
50 #error CONFIG_WATCHDOG must be defined to either 0 or 1
59 #include <qapplication.h>
61 #include <QtGui/QApplication>
64 #include <sys/select.h>
67 #include <cfg/macros.h> // BV()
71 #endif /* CONFIG_WATCHDOG */
74 * Reset the watchdog timer.
76 INLINE void wdt_reset(void)
80 // Let Qt handle events
82 qApp->processEvents();
84 static struct timeval tv = { 0, 0 };
85 select(0, NULL, NULL, NULL, &tv);
87 __asm__ __volatile__ ("wdr");
91 #endif /* CONFIG_WATCHDOG */
95 * Set watchdog timer timeout.
97 * \param timeout 0: 16.3ms, 7: 2.1s
99 INLINE void wdt_init(uint8_t timeout)
103 // Create a dummy QApplication object
107 new QApplication(argc, (char **)NULL);
111 (void)timeout; // NOP
113 WDTCR |= BV(WDCE) | BV(WDE);
120 #endif /* CONFIG_WATCHDOG */
123 INLINE void wdt_start(void)
135 #endif /* CONFIG_WATCHDOG */
138 INLINE void wdt_stop(void)
146 WDTCR |= BV(WDCE) | BV(WDE);
151 #endif /* CONFIG_WATCHDOG */
154 #endif /* DRV_WDT_H */