Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Member Functions | List of all members
SerialWombatWatchdog Class Reference

A class to wrap around a Serial Wombat Watchdog Pin. More...

`#include <SerialWombatWatchdog.h>`

Inheritance diagram for SerialWombatWatchdog:
[legend]
Collaboration diagram for SerialWombatWatchdog:
[legend]

## Public Member Functions
| SerialWombatWatchdog (SerialWombatChip &serialWombat)
| Constructor for SerialWombatWatchdog.
void | begin (uint8_t pin, SerialWombatPinState_t normalState, SerialWombatPinState_t resetState, uint16_t timeout_mS, bool resetWombatAfterTimeout)
| Initialize a SerialWombatWatchdog.
void | updateResetCountdown (uint16_t time_mS)
| Reset the countdown timer to a specified number of mS.
Public Member Functions inherited from SerialWombatPin
| SerialWombatPin (SerialWombatChip &serialWombatChip)
| Instantiates a Serial Wombat Pin.
| SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
| Instantiates a Serial Wombat Pin.
uint16_t | readPublicData ()
| Read the 16 Bit public data associated with this pin.
void | pinMode (uint8_t mode, bool pullDown=false, bool openDrain=false)
| Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
void | digitalWrite (uint8_t val)
| Set output pin High or Low.
int | digitalRead ()
| Reads the state of the Pin.
uint16_t | writePublicData (uint16_t value)
| Write a 16 bit value to this pin.
uint8_t | pin ()
| Returns the current SW pin number. Used primarily for virtual calls by derived classes.
uint8_t | swPinModeNumber ()
| Returns the Mode number. Used primarily by derived classes to populate packet data.
int16_t | initPacketNoResponse (uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0, uint16_t param1, uint8_t param2=0x55)
int16_t | disable ()
| Disables the pin mode (if applicable)
int16_t | enablePullup (bool enabled)
| Enables the weak pull up on a pin. Implemented on SW18AB and SW8B only.
int16_t | enablePulldown (bool enabled)
| Enables the weak pull down on a pin. Implemented on SW18AB and SW8B only.
int16_t | enableOpenDrain (bool enabled)
| Enables open drain mode on a pin. Implemented on SW18AB and SW8B only.
int16_t | forceDMA (bool enabled)
| Forces use of DMA instead of hardware timing resources on SW18AB.

## Additional Inherited Members
Protected Attributes inherited from SerialWombatPin
uint8_t | _pin = 255
SerialWombatChip & | _sw
uint8_t | _pinMode = 0

## Detailed Description

A class to wrap around a Serial Wombat Watchdog Pin.

The Serial Wombat Watchdog Pin Mode is designed to improve system reliability in case of communications loss with the host device. This may be because the communications lines are no longer functional (e.g. I2C bus locked up) or the host ceases to communicate (Such as when an Arduino malfunctions due to issues allocating string memory).

Once enabled, the Serial Wombat Watchdog will change its output and optionally other Serial Wombat outputs to predefined states and optionally reset the Serial Wombat itself if a new Watchdog feeding message isn't received within a period of time specified in the initialization.

The output can be used to reset the host, for instance when connected to an Arduino reset pin, or used to shut off an output. For instance, a motor controlled by a SerialWombatWatchdog pin could be configured to turn off if the host doesn't periodically feed the watchdog.

A video tutorial is available:

https://youtu.be/fIObjmHmprY

Definition at line 29 of file SerialWombatWatchdog.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatWatchdog()

SerialWombatWatchdog::SerialWombatWatchdog | ( | SerialWombatChip & | serialWombat | ) |

Constructor for SerialWombatWatchdog.

Parameters

  serialWombat | SerialWombat chip on which the SerialWombatWatchdog will run

Definition at line 3 of file SerialWombatWatchdog.cpp.

## Member Function Documentation

## ◆ begin()

void SerialWombatWatchdog::begin | ( | uint8_t | pin,
|  | SerialWombatPinState_t | normalState,
|  | SerialWombatPinState_t | resetState,
|  | uint16_t | timeout_mS,
|  | bool | resetWombatAfterTimeout )

Initialize a SerialWombatWatchdog.

Parameters

  pin | Pin on which the SerialWombat Watchdog will run. Valid values for SW4A: 0-3 SW4B: 1-3.
  normalState | The pin state while the countdown has not expired. Valid values are SW_LOW, SW_HIGH or SW_INPUT
  resetState | The pin state after the countdown has expired. Valid values are SW_LOW, SW_HIGH or SW_INPUT
  timeout_mS | The number of milliseconds before the countdown will expire if not reset. Maximum value of 65535.
  resetWombatAfterTimeout | TRUE: The Serial Wombat will set outputs to resetState, wait 10mS, then reset the Serial Wombat itself. FALSE: Pins stay in resetState, Wombat continues operating

Definition at line 7 of file SerialWombatWatchdog.cpp.

## ◆ updateResetCountdown()

void SerialWombatWatchdog::updateResetCountdown | ( | uint16_t | time_mS | ) |

Reset the countdown timer to a specified number of mS.

Parameters

  time_mS | number of mS until countdown timer expires.

Definition at line 24 of file SerialWombatWatchdog.cpp.