Skip to main content

WatchdogController Class

NuGet: GHIElectronics.TinyCLR.Devices.Watchdog
Assembly: GHIElectronics.TinyCLR.Devices.Watchdog
Namespace: GHIElectronics.TinyCLR.Devices.Watchdog

Independent watchdog timer. Enable(uint) with a timeout and call Reset periodically — if the timer ever expires without being reset, the chip reboots. Useful as a failsafe against firmware lockups.

public class WatchdogController : IDisposable

Properties​

Provider​

public IWatchdogControllerProvider Provider { get; }

The low-level provider backing this controller.

MaxTimeout​

public TimeSpan MaxTimeout { get; }

Largest legal value for the Enable(TimeSpan) timeout argument.

IsEnabled​

public bool IsEnabled { get; }

True once Enable(uint) has been called.

Methods​

GetDefault()​

public static WatchdogController GetDefault()

Returns the default watchdog for this device.

Returns WatchdogController

FromName(string name)​

public static WatchdogController FromName(string name)

Returns a watchdog identified by its native API name.

Returns WatchdogController

FromProvider(IWatchdogControllerProvider provider)​

public static WatchdogController FromProvider(IWatchdogControllerProvider provider)

Creates a controller from a custom IWatchdogControllerProvider.

Returns WatchdogController

Dispose()​

public void Dispose()

Releases the underlying provider.

Enable(TimeSpan timeout)​

public void Enable(TimeSpan timeout)

Starts the watchdog. From this point on, Reset must be called more often than timeout or the device will reboot. On many chips the watchdog cannot be disabled once enabled.

ParameterTypeDescription
timeoutTimeSpanTimeout in TimeSpan (must be > 0 and ≤ MaxTimeout).

Disable()​

public void Disable()

Disables the watchdog (only supported on hardware that allows it).

Reset()​

public void Reset()

Re-arms the watchdog. Must be called before the timeout elapses.