LwWDG

group LWWDG

Lightweight watchdog for RTOS in embedded systems.

Functions

uint8_t lwwdg_init(void)

Initialize watchdog module.

Returns

1 on success, 0 otherwise

uint8_t lwwdg_add(lwwdg_wdg_t *wdg, uint32_t timeout)

Add new watchdog timer instance to internal linked list.

Parameters
  • wdg – Watchdog handle. Must not be local variable

  • timeout – Max allowed timeout in milliseconds

Returns

1 on success, 0 otherwise

uint8_t lwwdg_remove(lwwdg_wdg_t *wdg)

Remove watchdog from the list.

This function is typically used if a task is killed by the scheduler. A user must manually call the function and can later clean wdg memory

Parameters

wdg – Watchdog handle to remove from list

Returns

1 if removed, 0 otherwise

uint8_t lwwdg_reload(lwwdg_wdg_t *wdg)

Reload thread watchdog.

Note

Reload will not be successful, if there was a timeout before. This will ensure that main thread won’t reload hardware watchdog, resulting system to reset

Parameters

wdg – Watchdog handle to reload

Returns

1 on success, 0 otherwise

uint8_t lwwdg_process(void)

Process and check system timers.

Function will check all timers and will return OK, if all timers are within max timeout state

Returns

1 if hardware watchdog can be reset, 0 if at least one timer hasn’t been reloaded within maximum timeout

void lwwdg_set_name(lwwdg_wdg_t *wdg, const char *name)

Set the watchdog name for debug reasons.

Note

Available only when LWWDG_CFG_ENABLE_WDG_NAME is enabled

Parameters
  • wdg – Watchdog instance

  • name – Pointer to the constant string for the name. String is not copied, rather only pointer is set

void lwwdg_print_expired(void)

Print all expired watchdogs.

Note

LWWDG_CFG_ENABLE_WDG_NAME and LWWDG_CFG_WDG_NAME_ERR_DEBUG must be enabled and implemented

struct lwwdg_wdg_t
#include <lwwdg.h>

Watchdog structure.

Public Members

struct lwwdg_wdg *next

Next entry on a list

uint32_t timeout

Timeout in milliseconds

uint32_t last_reload_time

Last reload time in milliseconds

const char *name

Pointer to constant string indicating watchdog name