Zephyr C++ Toolkit
Loading...
Searching...
No Matches
zct::WatchdogReal Class Reference

Real hardware implementation of the watchdog interface. More...

#include <WatchdogReal.hpp>

Inheritance diagram for zct::WatchdogReal:
Collaboration diagram for zct::WatchdogReal:

Public Member Functions

 WatchdogReal (const char *name, const struct device *device)
 Constructor.
 
 ~WatchdogReal ()
 Destructor.
 
int installTimeout (uint32_t timeoutMs, CallbackFn callback=nullptr, void *userData=nullptr, ResetFlag flags=ResetFlag::ResetSoc) override
 Install a watchdog timeout configuration.
 
int setup (Option options=Option::None) override
 Setup the watchdog with global configuration.
 
int feed (int channelId) override
 Feed (service) a watchdog channel to prevent timeout.
 
int disable () override
 Disable the watchdog instance.
 
const struct device * getRawDevice () const override
 Get the raw watchdog device pointer.
 
- Public Member Functions inherited from zct::IWatchdog
 IWatchdog (const char *name)
 Constructor.
 
virtual ~IWatchdog ()=default
 Virtual destructor.
 
const char * getName () const
 Get the name of this watchdog instance.
 

Static Private Member Functions

static uint8_t convertOptions (Option options)
 Convert IWatchdog::Option to Zephyr wdt options.
 
static uint8_t convertResetFlags (ResetFlag flags)
 Convert IWatchdog::ResetFlag to Zephyr wdt flags.
 
static void staticCallback (const struct device *dev, int channelId)
 Static callback function for Zephyr WDT API.
 

Private Attributes

const struct device * m_device
 Zephyr watchdog device.
 
bool m_isSetup
 Track if setup() has been called.
 
CallbackFn m_callback
 User callback function.
 
void * m_userData
 User data for callback.
 

Additional Inherited Members

- Public Types inherited from zct::IWatchdog
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.
 
- Protected Attributes inherited from zct::IWatchdog
const char * m_name
 Name of this watchdog instance.
 

Detailed Description

Real hardware implementation of the watchdog interface.

This class provides a C++ wrapper around Zephyr's watchdog driver API.

Constructor & Destructor Documentation

◆ WatchdogReal()

zct::WatchdogReal::WatchdogReal ( const char *  name,
const struct device *  device 
)

Constructor.

Parameters
nameName of the watchdog instance for logging purposes
devicePointer to the Zephyr watchdog device

◆ ~WatchdogReal()

zct::WatchdogReal::~WatchdogReal ( )

Destructor.

Member Function Documentation

◆ convertOptions()

uint8_t zct::WatchdogReal::convertOptions ( Option  options)
staticprivate

Convert IWatchdog::Option to Zephyr wdt options.

Parameters
optionsIWatchdog options
Returns
Zephyr wdt options

◆ convertResetFlags()

uint8_t zct::WatchdogReal::convertResetFlags ( ResetFlag  flags)
staticprivate

Convert IWatchdog::ResetFlag to Zephyr wdt flags.

Parameters
flagsIWatchdog reset flags
Returns
Zephyr wdt flags

◆ disable()

int zct::WatchdogReal::disable ( )
overridevirtual

Disable the watchdog instance.

Returns
0 on success, negative error code on failure

Implements zct::IWatchdog.

◆ feed()

int zct::WatchdogReal::feed ( int  channelId)
overridevirtual

Feed (service) a watchdog channel to prevent timeout.

Parameters
channelIdChannel ID to feed
Returns
0 on success, negative error code on failure

Implements zct::IWatchdog.

◆ getRawDevice()

const struct device * zct::WatchdogReal::getRawDevice ( ) const
overridevirtual

Get the raw watchdog device pointer.

Returns
Raw watchdog device pointer

Implements zct::IWatchdog.

◆ installTimeout()

int zct::WatchdogReal::installTimeout ( uint32_t  timeoutMs,
CallbackFn  callback = nullptr,
void *  userData = nullptr,
ResetFlag  flags = ResetFlag::ResetSoc 
)
overridevirtual

Install a watchdog timeout configuration.

Parameters
timeoutMsTimeout value in milliseconds
callbackCallback function to execute on timeout (optional)
userDataUser data to pass to callback (optional)
flagsReset behavior flags
optionsConfiguration options
Returns
Channel ID on success, negative error code on failure

Implements zct::IWatchdog.

◆ setup()

int zct::WatchdogReal::setup ( Option  options = Option::None)
overridevirtual

Setup the watchdog with global configuration.

Parameters
optionsGlobal watchdog options
Returns
0 on success, negative error code on failure

Implements zct::IWatchdog.

◆ staticCallback()

void zct::WatchdogReal::staticCallback ( const struct device *  dev,
int  channelId 
)
staticprivate

Static callback function for Zephyr WDT API.

Parameters
devWatchdog device
channelIdChannel that timed out

Member Data Documentation

◆ m_callback

CallbackFn zct::WatchdogReal::m_callback
private

User callback function.

◆ m_device

const struct device* zct::WatchdogReal::m_device
private

Zephyr watchdog device.

◆ m_isSetup

bool zct::WatchdogReal::m_isSetup
private

Track if setup() has been called.

◆ m_userData

void* zct::WatchdogReal::m_userData
private

User data for callback.


The documentation for this class was generated from the following files: