software:firmware
MakAir Firmware
rpi_watchdog.cpp
Go to the documentation of this file.
1 
8 #pragma once
9 
10 // INCLUDES ===================================================================
11 
12 #include "../includes/rpi_watchdog.h"
13 
14 // INITIALISATION =============================================================
15 
17 
18 // FUNCTIONS ==================================================================
19 
23 }
24 
27  m_countDown--;
28  if (m_countDown <= 0) {
30  }
32  // Turn off the Raspberry Pi power
35  } else if (m_rpiWatchdogStep == SWITCH_ON_RASPBERRY) {
36  // Turn on the Raspberry Pi power
37  digitalWrite(PIN_ENABLE_PWR_RASP, PWR_RASP_ACTIVE);
41  // Do nothing here
42  // Next time resetCountDown() is called because a heartbeat was received, let's resume
43  } else if (m_rpiWatchdogStep == DISABLED) {
44  // Do nothing when watchdog is disabled
45  } else {
46  // Do nothing
47  }
48 }
49 
53  }
54 
56 }
57 
Watchdog for the Raspberry PI.
Definition: rpi_watchdog.h:15
int32_t m_countDown
Definition: rpi_watchdog.h:30
RpiWatchdogStep m_rpiWatchdogStep
Definition: rpi_watchdog.h:38
@ SWITCH_ON_RASPBERRY
Definition: rpi_watchdog.h:34
@ WAIT_FOR_FIRST_HEARTBEAT
Definition: rpi_watchdog.h:35
@ SWITCH_OFF_RASPBERRY
Definition: rpi_watchdog.h:33
RpiWatchdog()
Default constructor.
void update()
This should be called by the main state machine every 1s.
void disable()
Disable countdown mode (used for debug)
void resetCountDown()
When the UI software on the Raspberry PI sends a heartbeat, reset countdown.
#define PIN_ENABLE_PWR_RASP
Definition: parameters.h:281
#define PWR_RASP_INACTIVE
Definition: parameters.h:283
#define PWR_RASP_ACTIVE
Definition: parameters.h:282
RpiWatchdog rpiWatchdog
#define COUNTDOWN_IN_S
Number of seconds with no heartbeat after which the RPi should be restarted.
Definition: rpi_watchdog.h:12