Zephyr C++ Toolkit
|
Interface for a hardware watchdog peripheral (not the software watchdog, this does not need to be mocked). More...
#include <IWatchdog.hpp>
Public Types | |
enum class | Option : uint8_t { None = 0 , PauseInSleep = 1 , PauseHaltedByDebug = 2 } |
Watchdog configuration options. More... | |
enum class | ResetFlag : uint8_t { None = 0 , ResetCpuCore = 1 , ResetSoc = 2 } |
Watchdog reset behavior flags. More... | |
using | CallbackFn = std::function< void(int channelId, void *userData)> |
Watchdog callback function type. | |
Public Member Functions | |
IWatchdog (const char *name) | |
Constructor. | |
virtual | ~IWatchdog ()=default |
Virtual destructor. | |
virtual int | installTimeout (uint32_t timeoutMs, CallbackFn callback=nullptr, void *userData=nullptr, ResetFlag flags=ResetFlag::ResetSoc)=0 |
Install a watchdog timeout configuration. | |
virtual int | setup (Option options=Option::None)=0 |
Setup the watchdog with global configuration. | |
virtual int | feed (int channelId)=0 |
Feed (service) a watchdog channel to prevent timeout. | |
virtual int | disable ()=0 |
Disable the watchdog instance. | |
const char * | getName () const |
Get the name of this watchdog instance. | |
virtual const struct device * | getRawDevice () const =0 |
Get the raw watchdog device pointer. Only valid on real implementations, mock implementations will return nullptr. | |
Protected Attributes | |
const char * | m_name |
Name of this watchdog instance. | |
Interface for a hardware watchdog peripheral (not the software watchdog, this does not need to be mocked).
This class provides a C++ abstraction layer over Zephyr's watchdog API. It follows the same patterns as other ZephyrCppToolkit peripheral interfaces.
using zct::IWatchdog::CallbackFn = std::function<void(int channelId, void* userData)> |
Watchdog callback function type.
channelId | The channel ID that timed out |
userData | User data passed during configuration |
|
strong |
|
strong |
zct::IWatchdog::IWatchdog | ( | const char * | name | ) |
Constructor.
name | Name of the watchdog instance for logging purposes |
|
virtualdefault |
Virtual destructor.
|
pure virtual |
Disable the watchdog instance.
Implemented in zct::WatchdogMock, and zct::WatchdogReal.
|
pure virtual |
Feed (service) a watchdog channel to prevent timeout.
channelId | Channel ID to feed |
Implemented in zct::WatchdogMock, and zct::WatchdogReal.
|
inline |
Get the name of this watchdog instance.
|
pure virtual |
Get the raw watchdog device pointer. Only valid on real implementations, mock implementations will return nullptr.
Implemented in zct::WatchdogMock, and zct::WatchdogReal.
|
pure virtual |
Install a watchdog timeout configuration.
timeoutMs | Timeout value in milliseconds |
callback | Callback function to execute on timeout (optional) |
userData | User data to pass to callback (optional) |
flags | Reset behavior flags |
Implemented in zct::WatchdogMock, and zct::WatchdogReal.
|
pure virtual |
Setup the watchdog with global configuration.
options | Global watchdog options |
Implemented in zct::WatchdogMock, and zct::WatchdogReal.
|
protected |
Name of this watchdog instance.