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.9 2006/03/22 09:49:09 bernie
18 *#* Add FreeRTOS support.
20 *#* Revision 1.8 2006/02/20 02:02:29 bernie
23 *#* Revision 1.7 2005/11/27 03:58:40 bernie
24 *#* Add POSIX timer emulator.
26 *#* Revision 1.6 2005/11/27 03:03:08 bernie
27 *#* Add Qt support hack.
29 *#* Revision 1.5 2005/11/04 16:20:02 bernie
30 *#* Fix reference to README.devlib in header.
32 *#* Revision 1.4 2005/04/12 01:37:17 bernie
33 *#* Prevent warning when watchdog is disabled.
35 *#* Revision 1.3 2005/04/11 19:10:28 bernie
36 *#* Include top-level headers from cfg/ subdir.
38 *#* Revision 1.2 2004/11/16 21:02:07 bernie
39 *#* Make driver optional; mark AVR specific parts as such.
41 *#* Revision 1.1 2004/10/26 08:34:47 bernie
42 *#* New DevLib module.
48 #include <appconfig.h>
49 #include <cfg/compiler.h> // INLINE
50 #include <cfg/arch_config.h>
52 /* Configury sanity check */
53 #if !defined(CONFIG_WATCHDOG) || (CONFIG_WATCHDOG != 0 && CONFIG_WATCHDOG != 1)
54 #error CONFIG_WATCHDOG must be defined to either 0 or 1
63 #include <qapplication.h>
65 #include <QtGui/QApplication>
68 #include <sys/select.h>
71 #include <cfg/macros.h> // BV()
72 #elif (ARCH & ARCH_FREERTOS)
73 #include <task.h> /* taskYIELD() */
77 #endif /* CONFIG_WATCHDOG */
80 * Reset the watchdog timer.
82 INLINE void wdt_reset(void)
86 // Let Qt handle events
88 qApp->processEvents();
90 static struct timeval tv = { 0, 0 };
91 select(0, NULL, NULL, NULL, &tv);
92 #elif (ARCH & ARCH_FREERTOS)
95 __asm__ __volatile__ ("wdr");
99 #endif /* CONFIG_WATCHDOG */
103 * Set watchdog timer timeout.
105 * \param timeout 0: 16.3ms, 7: 2.1s
107 INLINE void wdt_init(uint8_t timeout)
111 // Create a dummy QApplication object
115 new QApplication(argc, (char **)NULL);
119 (void)timeout; // NOP
120 #elif (ARCH & ARCH_FREERTOS)
123 WDTCR |= BV(WDCE) | BV(WDE);
130 #endif /* CONFIG_WATCHDOG */
133 INLINE void wdt_start(void)
140 #elif (ARCH & ARCH_FREERTOS)
147 #endif /* CONFIG_WATCHDOG */
150 INLINE void wdt_stop(void)
157 #elif (ARCH & ARCH_FREERTOS)
160 WDTCR |= BV(WDCE) | BV(WDE);
165 #endif /* CONFIG_WATCHDOG */
168 #endif /* DRV_WDT_H */