SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
AXP2101Watchdog Class Reference

I2C watchdog timer control for the AXP2101 PMIC. More...

#include <AXP2101Watchdog.hpp>

Inheritance diagram for AXP2101Watchdog:
[legend]

Public Member Functions

 AXP2101Watchdog (AXP2101Core &core)
 
 ~AXP2101Watchdog ()=default
 
bool enableWatchdog (bool enable) override
 Enable or disable the watchdog timer.
 
bool isWatchdogEnabled () const override
 Check whether the watchdog timer is enabled.
 
bool setWatchdogTimeout (uint16_t timeout_s) override
 Set the watchdog timeout duration.
 
uint16_t getWatchdogTimeout () const override
 Get the current watchdog timeout setting.
 
bool resetWatchdog () override
 Reset (pet) the watchdog timer.
 
- Public Member Functions inherited from PmicWatchdogBase
virtual ~PmicWatchdogBase ()=default
 Virtual destructor.
 

Detailed Description

I2C watchdog timer control for the AXP2101 PMIC.

The watchdog monitors I2C bus activity. If no communication occurs within the configured timeout, the PMIC resets suspect registers to their default values. Regular calls to resetWatchdog() are required to prevent timeout expiry.

Supported timeout values: 1, 2, 4, 8, 16, 32, 64, 128 seconds. Watchdog behaviour (IRQ only / IRQ+reset) is configured via AXP2101Core::setWatchdogConfig(), default is IRQ Only.

Definition at line 47 of file AXP2101Watchdog.hpp.

Constructor & Destructor Documentation

◆ AXP2101Watchdog()

AXP2101Watchdog::AXP2101Watchdog ( AXP2101Core core)
explicit

Definition at line 38 of file AXP2101Watchdog.cpp.

◆ ~AXP2101Watchdog()

AXP2101Watchdog::~AXP2101Watchdog ( )
default

Member Function Documentation

◆ enableWatchdog()

bool AXP2101Watchdog::enableWatchdog ( bool  enable)
overridevirtual

Enable or disable the watchdog timer.

Parameters
enabletrue to enable (default 64s timeout), false to disable.
Returns
true on success.

Implements PmicWatchdogBase.

Definition at line 42 of file AXP2101Watchdog.cpp.

References AXP2101Core::enableModule(), and AXP2101Core::WATCHDOG.

◆ getWatchdogTimeout()

uint16_t AXP2101Watchdog::getWatchdogTimeout ( ) const
overridevirtual

Get the current watchdog timeout setting.

Returns
Timeout in seconds (1, 2, 4, 8, 16, 32, 64, or 128).

Implements PmicWatchdogBase.

Definition at line 69 of file AXP2101Watchdog.cpp.

References SensorCommWrapper::readReg(), and axp2101_regs::ctrl::WDT_CTRL.

◆ isWatchdogEnabled()

bool AXP2101Watchdog::isWatchdogEnabled ( ) const
overridevirtual

Check whether the watchdog timer is enabled.

Returns
true if watchdog is active.

Implements PmicWatchdogBase.

Definition at line 47 of file AXP2101Watchdog.cpp.

References AXP2101Core::isModuleEnabled(), and AXP2101Core::WATCHDOG.

◆ resetWatchdog()

bool AXP2101Watchdog::resetWatchdog ( )
overridevirtual

Reset (pet) the watchdog timer.

Must be called at least once before the timeout expires to prevent register reset. Recommended interval is half the configured timeout period.

Returns
true on success.

Implements PmicWatchdogBase.

Definition at line 79 of file AXP2101Watchdog.cpp.

References SensorCommWrapper::setRegBit(), and axp2101_regs::ctrl::WDT_CTRL.

◆ setWatchdogTimeout()

bool AXP2101Watchdog::setWatchdogTimeout ( uint16_t  timeout_s)
overridevirtual

Set the watchdog timeout duration.

Valid values: 1, 2, 4, 8, 16, 32, 64, 128 seconds. Other values will be rejected (return false).

Parameters
timeout_sTimeout in seconds.
Returns
true on success.

Implements PmicWatchdogBase.

Definition at line 52 of file AXP2101Watchdog.cpp.

References SensorCommWrapper::updateBits(), and axp2101_regs::ctrl::WDT_CTRL.


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