dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_wdg.c
Go to the documentation of this file.
1 
19 /*
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation; either version 3 of the License, or
23  * (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful, but
26  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28  * for more details.
29  *
30  * You should have received a copy of the GNU General Public License along
31  * with this program; if not, see <http://www.gnu.org/licenses/>
32  */
33 
34 #include <pios.h>
35 #include <pios_thread.h>
36 
37 unsigned int wdg_registered_flags;
38 unsigned int wdg_updated_flags;
41 
43 
44 static bool PIOS_WDG_Check();
45 
63 uint16_t PIOS_WDG_Init()
64 {
67 
69 
70  return 0;
71 }
72 
86 bool PIOS_WDG_RegisterFlag(uint16_t flag_requested)
87 {
88  wdg_registered_flags |= flag_requested;
89  return true;
90 }
91 
102 bool PIOS_WDG_UpdateFlag(uint16_t flag)
103 {
104  uint32_t now = PIOS_Thread_Systime();
105 
106  PIOS_WDG_Check();
107 
110  wdg_updated_flags = 0;
112  wdg_cleared_time = now;
113  }
114  return true;
115 }
116 
126 {
127  return (uint16_t) 0xffff;
128 }
129 
138 {
139  return (uint16_t) 0xffff;
140 }
141 
147 void PIOS_WDG_Clear(void)
148 {
149 }
150 
155 static bool PIOS_WDG_Check()
156 {
158  if(!wdg_expired)
159  fprintf(stderr, "Watchdog fired / %d %d %x %x\r\n",
164  wdg_expired = true;
165  }
166  return wdg_expired;
167 }
static bool PIOS_WDG_Check()
This function returns true if the watchdog would have expired.
Definition: pios_wdg.c:155
uint32_t PIOS_Thread_Systime(void)
Definition: pios_thread.c:212
unsigned int wdg_updated_flags
Definition: pios_wdg.c:38
Main PiOS header to include all the compiled in PiOS options.
bool PIOS_WDG_RegisterFlag(uint16_t flag_requested)
Register a module against the watchdog.
Definition: pios_wdg.c:86
bool PIOS_WDG_UpdateFlag(uint16_t flag)
Function called by modules to indicate they are still running.
Definition: pios_wdg.c:102
uint16_t PIOS_WDG_GetBootupFlags()
Returns the flags that were set at bootup.
Definition: pios_wdg.c:125
uint16_t PIOS_WDG_GetActiveFlags()
Returns the currently active flags.
Definition: pios_wdg.c:137
void PIOS_WDG_Clear(void)
Clear the watchdog timer.
Definition: pios_wdg.c:147
bool wdg_expired
Definition: pios_wdg.c:42
bool PIOS_Thread_Period_Elapsed(const uint32_t prev_systime, const uint32_t increment_ms)
Determine if a period has elapsed since a datum.
Definition: pios_thread.c:281
uint16_t PIOS_WDG_Init()
Initialize the watchdog timer for a specified timeout.
Definition: pios_wdg.c:63
uint32_t wdg_last_update_time
Definition: pios_wdg.c:40
uint32_t flag
Definition: msp_messages.h:99
uint32_t wdg_cleared_time
Definition: pios_wdg.c:39
unsigned int wdg_registered_flags
Definition: pios_wdg.c:37