wdt.h
Go to the documentation of this file.00001
00043 #ifndef DRV_WDT_H
00044 #define DRV_WDT_H
00045
00046 #include "cfg/cfg_wdt.h"
00047
00048 #include <cfg/compiler.h>
00049
00050
00051 #if !defined(CONFIG_WATCHDOG) || (CONFIG_WATCHDOG != 0 && CONFIG_WATCHDOG != 1)
00052 #error CONFIG_WATCHDOG must be defined to either 0 or 1
00053 #endif
00054
00055 #if OS_HOSTED
00056 #include <cpu/detect.h>
00057 #include <cfg/os.h>
00058
00059 #if OS_QT
00060 #include <QtGui/QApplication>
00061 #elif OS_POSIX
00062 #include <sys/select.h>
00063 #else
00064 #error unknown CPU
00065 #endif
00066 #elif CONFIG_WATCHDOG
00067 #include CPU_HEADER(wdt)
00068 #endif
00069
00070
00071 #if OS_HOSTED || !CONFIG_WATCHDOG
00072
00076 INLINE void wdt_reset(void)
00077 {
00078 #if CONFIG_WATCHDOG
00079 #if OS_POSIX
00080 static struct timeval tv = { 0, 0 };
00081 select(0, NULL, NULL, NULL, &tv);
00082 #endif
00083 #endif
00084 }
00085
00093 INLINE void wdt_start(uint32_t timeout)
00094 {
00095 #if CONFIG_WATCHDOG
00096 #if OS_QT
00097
00098 if (!qApp)
00099 {
00100 int argc;
00101 new QApplication(argc, (char **)NULL);
00102 }
00103 (void)timeout;
00104 #elif OS_POSIX
00105 (void)timeout;
00106 #endif
00107 #endif
00108 (void)timeout;
00109 }
00110
00111 INLINE void wdt_stop(void)
00112 {
00113 #if CONFIG_WATCHDOG
00114 #if OS_QT
00115
00116 #elif OS_POSIX
00117
00118 #else
00119 #error unknown CPU
00120 #endif
00121 #endif
00122 }
00123 #endif
00124
00125 #endif