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.6 2005/11/27 03:03:08 bernie
18 *#* Add Qt support hack.
20 *#* Revision 1.5 2005/11/04 16:20:02 bernie
21 *#* Fix reference to README.devlib in header.
23 *#* Revision 1.4 2005/04/12 01:37:17 bernie
24 *#* Prevent warning when watchdog is disabled.
26 *#* Revision 1.3 2005/04/11 19:10:28 bernie
27 *#* Include top-level headers from cfg/ subdir.
29 *#* Revision 1.2 2004/11/16 21:02:07 bernie
30 *#* Make driver optional; mark AVR specific parts as such.
32 *#* Revision 1.1 2004/10/26 08:34:47 bernie
33 *#* New DevLib module.
39 #include <appconfig.h>
40 #include <cfg/compiler.h> // INLINE
42 /* Configury sanity check */
43 #if !defined(CONFIG_WATCHDOG) || (CONFIG_WATCHDOG != 0 && CONFIG_WATCHDOG != 1)
44 #error CONFIG_WATCHDOG must be defined to either 0 or 1
52 #include <qapplication.h>
55 #include <cfg/macros.h> // BV()
59 #endif /* CONFIG_WATCHDOG */
62 * Reset the watchdog timer.
64 INLINE void wdt_reset(void)
68 // Let Qt handle events
70 qApp->processEvents();
72 __asm__ __volatile__ ("wdr");
76 #endif /* CONFIG_WATCHDOG */
80 * Set watchdog timer timeout.
82 * \param timeout 0: 16.3ms, 7: 2.1s
84 INLINE void wdt_init(uint8_t timeout)
88 // create a dummy QApplication object
92 new QApplication(argc, (char **)NULL);
95 WDTCR |= BV(WDCE) | BV(WDE);
102 #endif /* CONFIG_WATCHDOG */
105 INLINE void wdt_start(void)
115 #endif /* CONFIG_WATCHDOG */
118 INLINE void wdt_stop(void)
124 WDTCR |= BV(WDCE) | BV(WDE);
129 #endif /* CONFIG_WATCHDOG */
132 #endif /* DRV_WDT_H */