Now you can download a copy of these docs so you can use them offline! Download now
Watchdog.cpp
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #include "Watchdog.h"
8 
9 constexpr double Watchdog::kDefaultWatchdogExpiration;
10 
15  : m_fpgaWatchDog(NULL)
16 {
17  tRioStatusCode localStatus = NiFpga_Status_Success;
18  m_fpgaWatchDog = tWatchdog::create(&localStatus);
19  wpi_setError(localStatus);
20  SetExpiration(kDefaultWatchdogExpiration);
21  SetEnabled(true);
22 }
23 
28 {
29  SetEnabled(false);
30  delete m_fpgaWatchDog;
31  m_fpgaWatchDog = NULL;
32 }
33 
47 {
48  bool previous = GetEnabled();
49  tRioStatusCode localStatus = NiFpga_Status_Success;
50  m_fpgaWatchDog->strobeFeed(&localStatus);
51  wpi_setError(localStatus);
52  return previous;
53 }
54 
62 {
63  tRioStatusCode localStatus = NiFpga_Status_Success;
64  m_fpgaWatchDog->strobeKill(&localStatus);
65  wpi_setError(localStatus);
66 }
67 
74 {
75  tRioStatusCode localStatus = NiFpga_Status_Success;
76  uint32_t timer = m_fpgaWatchDog->readTimer(&localStatus);
77  wpi_setError(localStatus);
78  return timer / (kSystemClockTicksPerMicrosecond * 1e6);
79 }
80 
87 {
88  tRioStatusCode localStatus = NiFpga_Status_Success;
89  uint32_t expiration = m_fpgaWatchDog->readExpiration(&localStatus);
90  wpi_setError(localStatus);
91  return expiration / (kSystemClockTicksPerMicrosecond * 1e6);
92 }
93 
99 void Watchdog::SetExpiration(double expiration)
100 {
101  tRioStatusCode localStatus = NiFpga_Status_Success;
102  m_fpgaWatchDog->writeExpiration((uint32_t)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), &localStatus);
103  wpi_setError(localStatus);
104 }
105 
112 {
113  tRioStatusCode localStatus = NiFpga_Status_Success;
114  bool enabled = !m_fpgaWatchDog->readImmortal(&localStatus);
115  wpi_setError(localStatus);
116  return enabled;
117 }
118 
131 void Watchdog::SetEnabled(bool enabled)
132 {
133  tRioStatusCode localStatus = NiFpga_Status_Success;
134  m_fpgaWatchDog->writeImmortal(!enabled, &localStatus);
135  wpi_setError(localStatus);
136 }
137 
151 {
152  tRioStatusCode localStatus = NiFpga_Status_Success;
153  bool alive = m_fpgaWatchDog->readStatus_Alive(&localStatus);
154  wpi_setError(localStatus);
155  return alive;
156 }
157 
164 {
165  tRioStatusCode localStatus = NiFpga_Status_Success;
166  bool alive = m_fpgaWatchDog->readStatus_SystemActive(&localStatus);
167  wpi_setError(localStatus);
168  return alive;
169 }
170 
double GetTimer()
Definition: Watchdog.cpp:73
bool IsSystemActive()
Definition: Watchdog.cpp:163
void SetExpiration(double expiration)
Definition: Watchdog.cpp:99
Watchdog()
Definition: Watchdog.cpp:14
void Kill()
Definition: Watchdog.cpp:61
void SetEnabled(bool enabled)
Definition: Watchdog.cpp:131
bool Feed()
Definition: Watchdog.cpp:46
virtual ~Watchdog()
Definition: Watchdog.cpp:27
bool GetEnabled()
Definition: Watchdog.cpp:111
double GetExpiration()
Definition: Watchdog.cpp:86
bool IsAlive()
Definition: Watchdog.cpp:150

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6