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.10 2006/05/18 00:38:42 bernie
18 *#* Work around missing ARCH_FREERTOS symbol.
20 *#* Revision 1.9 2006/03/22 09:49:09 bernie
21 *#* Add FreeRTOS support.
23 *#* Revision 1.8 2006/02/20 02:02:29 bernie
26 *#* Revision 1.7 2005/11/27 03:58:40 bernie
27 *#* Add POSIX timer emulator.
29 *#* Revision 1.6 2005/11/27 03:03:08 bernie
30 *#* Add Qt support hack.
32 *#* Revision 1.5 2005/11/04 16:20:02 bernie
33 *#* Fix reference to README.devlib in header.
35 *#* Revision 1.4 2005/04/12 01:37:17 bernie
36 *#* Prevent warning when watchdog is disabled.
38 *#* Revision 1.3 2005/04/11 19:10:28 bernie
39 *#* Include top-level headers from cfg/ subdir.
41 *#* Revision 1.2 2004/11/16 21:02:07 bernie
42 *#* Make driver optional; mark AVR specific parts as such.
44 *#* Revision 1.1 2004/10/26 08:34:47 bernie
45 *#* New DevLib module.
51 #include <appconfig.h>
52 #include <cfg/compiler.h> // INLINE
53 #include <cfg/arch_config.h>
55 /* Configury sanity check */
56 #if !defined(CONFIG_WATCHDOG) || (CONFIG_WATCHDOG != 0 && CONFIG_WATCHDOG != 1)
57 #error CONFIG_WATCHDOG must be defined to either 0 or 1
66 #include <qapplication.h>
68 #include <QtGui/QApplication>
71 #include <sys/select.h>
74 #include <cfg/macros.h> // BV()
75 #elif defined(ARCH_FREERTOS) && (ARCH & ARCH_FREERTOS)
76 #include <task.h> /* taskYIELD() */
80 #endif /* CONFIG_WATCHDOG */
83 * Reset the watchdog timer.
85 INLINE void wdt_reset(void)
89 // Let Qt handle events
91 qApp->processEvents();
93 static struct timeval tv = { 0, 0 };
94 select(0, NULL, NULL, NULL, &tv);
95 #elif defined(ARCH_FREERTOS) && (ARCH & ARCH_FREERTOS)
98 __asm__ __volatile__ ("wdr");
102 #endif /* CONFIG_WATCHDOG */
106 * Set watchdog timer timeout.
108 * \param timeout 0: 16.3ms, 7: 2.1s
110 INLINE void wdt_init(uint8_t timeout)
114 // Create a dummy QApplication object
118 new QApplication(argc, (char **)NULL);
122 (void)timeout; // NOP
123 #elif defined(ARCH_FREERTOS) && (ARCH & ARCH_FREERTOS)
126 WDTCR |= BV(WDCE) | BV(WDE);
133 #endif /* CONFIG_WATCHDOG */
136 INLINE void wdt_start(void)
143 #elif defined(ARCH_FREERTOS) && (ARCH & ARCH_FREERTOS)
150 #endif /* CONFIG_WATCHDOG */
153 INLINE void wdt_stop(void)
160 #elif defined(ARCH_FREERTOS) && (ARCH & ARCH_FREERTOS)
163 WDTCR |= BV(WDCE) | BV(WDE);
168 #endif /* CONFIG_WATCHDOG */
171 #endif /* DRV_WDT_H */