oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
watchdog.h
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
30#ifndef OVE_WATCHDOG_H
31#define OVE_WATCHDOG_H
32
33#include "ove/types.h"
34#include "ove_config.h"
35#include "ove/storage.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#ifdef CONFIG_OVE_WATCHDOG
42
58 ove_watchdog_storage_t *storage,
59 uint32_t timeout_ms);
60
71
84#ifdef OVE_HEAP_WATCHDOG
85int ove_watchdog_create(ove_watchdog_t *wdt, uint32_t timeout_ms);
86
97#elif !defined(__ZIG_CIMPORT__) /* !OVE_HEAP_WATCHDOG — zero-heap mode */
98
99#define ove_watchdog_create(pwdt, timeout_ms) \
100 ({ static ove_watchdog_storage_t _ove_stor_; \
101 ove_watchdog_init((pwdt), &_ove_stor_, (timeout_ms)); })
102#define ove_watchdog_destroy(wdt) ove_watchdog_deinit(wdt)
103
104#endif /* OVE_HEAP_WATCHDOG */
105
117
129
143
144#else /* !CONFIG_OVE_WATCHDOG */
145
146static inline int ove_watchdog_create(ove_watchdog_t *w, uint32_t t) { (void)w; (void)t; return OVE_ERR_NOT_SUPPORTED; }
147static inline void ove_watchdog_destroy(ove_watchdog_t w) { (void)w; }
148static inline int ove_watchdog_start(ove_watchdog_t w) { (void)w; return OVE_ERR_NOT_SUPPORTED; }
149static inline int ove_watchdog_stop(ove_watchdog_t w) { (void)w; return OVE_ERR_NOT_SUPPORTED; }
150static inline int ove_watchdog_feed(ove_watchdog_t w) { (void)w; return OVE_ERR_NOT_SUPPORTED; }
151
152#endif /* CONFIG_OVE_WATCHDOG */
153
154#ifdef __cplusplus
155}
156#endif
157
/* end of ove_watchdog group */
159
160#endif /* OVE_WATCHDOG_H */
#define OVE_ERR_NOT_SUPPORTED
The requested feature is not supported by the active backend.
Definition types.h:38
struct ove_watchdog * ove_watchdog_t
Opaque handle for a software watchdog object.
Definition types.h:109
void ove_watchdog_destroy(ove_watchdog_t wdt)
Destroy a heap-allocated watchdog timer.
int ove_watchdog_start(ove_watchdog_t wdt)
Start (arm) the watchdog timer.
int ove_watchdog_create(ove_watchdog_t *wdt, uint32_t timeout_ms)
Allocate and initialise a heap-backed watchdog timer.
int ove_watchdog_feed(ove_watchdog_t wdt)
Feed (pet) the watchdog to prevent a system reset.
int ove_watchdog_init(ove_watchdog_t *wdt, ove_watchdog_storage_t *storage, uint32_t timeout_ms)
Initialise a watchdog timer using caller-provided static storage.
int ove_watchdog_stop(ove_watchdog_t wdt)
Stop (disarm) the watchdog timer.
void ove_watchdog_deinit(ove_watchdog_t wdt)
Deinitialise a statically-allocated watchdog timer.