RAII wrapper around an oveRTOS hardware watchdog timer.
More...
#include <watchdog.hpp>
|
| | Watchdog (uint32_t timeout_ms) |
| | Constructs the watchdog and tries to initialise it with the given timeout.
|
| |
|
| ~Watchdog () noexcept |
| | Destroys the watchdog, stopping it and releasing the kernel resource.
|
| |
|
| Watchdog (const Watchdog &)=delete |
| |
|
Watchdog & | operator= (const Watchdog &)=delete |
| |
| | Watchdog (Watchdog &&other) noexcept |
| | Move constructor — transfers ownership of the kernel handle.
|
| |
| Watchdog & | operator= (Watchdog &&other) noexcept |
| | Move-assignment operator — transfers ownership of the kernel handle.
|
| |
| Result< void > | start () noexcept |
| | Arms the watchdog and starts the countdown.
|
| |
| Result< void > | stop () noexcept |
| | Disarms the watchdog, stopping the countdown.
|
| |
| Result< void > | feed () noexcept |
| | Resets the watchdog countdown, preventing a system reset.
|
| |
| bool | valid () const |
| | Returns true if the underlying kernel handle is non-null.
|
| |
| ove_watchdog_t | handle () const |
| | Returns the raw oveRTOS watchdog handle.
|
| |
RAII wrapper around an oveRTOS hardware watchdog timer.
The watchdog resets the system if feed() is not called within the configured timeout. Use start() to arm the watchdog after construction. The destructor stops and releases the underlying kernel resource.
- Note
- Not copyable. Move-only when heap allocation is enabled.
◆ Watchdog() [1/2]
| ove::Watchdog::Watchdog |
( |
uint32_t |
timeout_ms | ) |
|
|
inlineexplicit |
Constructs the watchdog and tries to initialise it with the given timeout.
Unlike the other RAII wrappers in this header set, the watchdog ctor does not abort if the underlying create/init call fails: boards without an enabled IWDG/WWDG (or a Zephyr watchdog0 alias) are a common, legitimate runtime configuration, so the binding leaves handle_ as nullptr and lets start()/stop()/ feed() return OVE_ERR_NOT_SUPPORTED. Apps that care can check valid() after construction or just inspect each method's return value (the existing [[nodiscard]] discipline already prompts callers to do so).
- Parameters
-
| [in] | timeout_ms | Watchdog timeout in milliseconds. |
◆ Watchdog() [2/2]
| ove::Watchdog::Watchdog |
( |
Watchdog && |
other | ) |
|
|
inlinenoexcept |
Move constructor — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
◆ operator=()
Move-assignment operator — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
- Returns
- Reference to this object.
◆ start()
| Result< void > ove::Watchdog::start |
( |
| ) |
|
|
inlinenoexcept |
Arms the watchdog and starts the countdown.
- Returns
- Empty
Result<void> on success; unexpected Error::NotSupported if no watchdog peripheral is available, or other Error variants on failure.
◆ stop()
| Result< void > ove::Watchdog::stop |
( |
| ) |
|
|
inlinenoexcept |
Disarms the watchdog, stopping the countdown.
- Returns
- Empty
Result<void> on success; unexpected Error on failure.
◆ feed()
| Result< void > ove::Watchdog::feed |
( |
| ) |
|
|
inlinenoexcept |
Resets the watchdog countdown, preventing a system reset.
Must be called within the configured timeout period.
- Returns
- Empty
Result<void> on success; unexpected Error on failure.
◆ valid()
| bool ove::Watchdog::valid |
( |
| ) |
const |
|
inline |
Returns true if the underlying kernel handle is non-null.
- Returns
true when the watchdog was successfully initialised.
◆ handle()
| ove_watchdog_t ove::Watchdog::handle |
( |
| ) |
const |
|
inline |
Returns the raw oveRTOS watchdog handle.
- Returns
- The opaque
ove_watchdog_t handle.
The documentation for this class was generated from the following file: