ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_watchdog.h File Reference
#include "ruuvi_driver_enabled_modules.h"
#include "ruuvi_driver_error.h"
#include <stdbool.h>

Go to the source code of this file.

Typedefs

typedef void(* wdt_evt_handler_t) (void)
 Enable implementation selected by application. More...
 

Functions

rd_status_t ri_watchdog_init (const uint32_t interval_ms, const wdt_evt_handler_t handler)
 
rd_status_t ri_watchdog_feed (void)
 

Detailed Description

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2020-01-28

Interface for Watchdog basic usage. Typical use:

err_code = ri_watchdog_init(WATCHDOG_INTERVAL_MS, on_wdt);
while(1)
{
err_code = do_stuff();
if(RD_SUCCESS == err_code)
{
}
}
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_CHECK(error, mask)
Shorthand macro for calling the rd_error_check with current file & line.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_SELFTEST
Self-test fail.
rd_status_t ri_watchdog_init(const uint32_t interval_ms, const wdt_evt_handler_t handler)
rd_status_t ri_watchdog_feed(void)

Definition in file ruuvi_interface_watchdog.h.

Typedef Documentation

◆ wdt_evt_handler_t

typedef void(* wdt_evt_handler_t) (void)

Enable implementation selected by application.

Watchdog event handler function.

Set up at initialization, gets called on watchdog triggered.

Definition at line 44 of file ruuvi_interface_watchdog.h.

Function Documentation

◆ ri_watchdog_feed()

rd_status_t ri_watchdog_feed ( void  )

"Feed" the watchdog, resets the watchdog timer. This must be called after watchdog initialization or the program will reset.

◆ ri_watchdog_init()

rd_status_t ri_watchdog_init ( const uint32_t  interval_ms,
const wdt_evt_handler_t  handler 
)

Initializes watchdog module. After initialization watchdog must be fed at given interval or the program will reset. There is not way to uninitialize the watchdog. Consider bootloader watchdog interval on setup.

Parameters
interval_msWatchdog will reset program unless fed faster than this.
handlerHandler for watchdog event.
Return values
RD_SUCCESSon success, error code on failure.