software:firmware
MakAir Firmware
RpiWatchdog Class Reference

Watchdog for the Raspberry PI. More...

#include <rpi_watchdog.h>

Public Member Functions

 RpiWatchdog ()
 Default constructor. More...
 
void update ()
 This should be called by the main state machine every 1s. More...
 
void resetCountDown ()
 When the UI software on the Raspberry PI sends a heartbeat, reset countdown. More...
 
void disable ()
 Disable countdown mode (used for debug) More...
 

Private Types

enum  RpiWatchdogStep {
  COUNT_DOWN , SWITCH_OFF_RASPBERRY , SWITCH_ON_RASPBERRY , WAIT_FOR_FIRST_HEARTBEAT ,
  DISABLED
}
 

Private Attributes

int32_t m_countDown
 
RpiWatchdogStep m_rpiWatchdogStep
 

Detailed Description

Watchdog for the Raspberry PI.

Definition at line 15 of file rpi_watchdog.h.

Member Enumeration Documentation

◆ RpiWatchdogStep

Enumerator
COUNT_DOWN 
SWITCH_OFF_RASPBERRY 
SWITCH_ON_RASPBERRY 
WAIT_FOR_FIRST_HEARTBEAT 
DISABLED 

Definition at line 31 of file rpi_watchdog.h.

Constructor & Destructor Documentation

◆ RpiWatchdog()

RpiWatchdog::RpiWatchdog ( )

Default constructor.

Definition at line 20 of file rpi_watchdog.cpp.

20  {
23 }
int32_t m_countDown
Definition: rpi_watchdog.h:30
RpiWatchdogStep m_rpiWatchdogStep
Definition: rpi_watchdog.h:38
#define COUNTDOWN_IN_S
Number of seconds with no heartbeat after which the RPi should be restarted.
Definition: rpi_watchdog.h:12

Member Function Documentation

◆ disable()

void RpiWatchdog::disable ( )

Disable countdown mode (used for debug)

Definition at line 58 of file rpi_watchdog.cpp.

◆ resetCountDown()

void RpiWatchdog::resetCountDown ( )

When the UI software on the Raspberry PI sends a heartbeat, reset countdown.

Definition at line 50 of file rpi_watchdog.cpp.

50  {
53  }
54 
56 }

◆ update()

void RpiWatchdog::update ( )

This should be called by the main state machine every 1s.

Definition at line 25 of file rpi_watchdog.cpp.

25  {
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 }
#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

Member Data Documentation

◆ m_countDown

int32_t RpiWatchdog::m_countDown
private

Definition at line 30 of file rpi_watchdog.h.

◆ m_rpiWatchdogStep

RpiWatchdogStep RpiWatchdog::m_rpiWatchdogStep
private

Definition at line 38 of file rpi_watchdog.h.


The documentation for this class was generated from the following files: