mirror of https://github.com/ARMmbed/mbed-os.git
VirtualWatchdog: provide hw timeout via ctor
parent
7b341847c4
commit
6313e530b3
|
|
@ -17,7 +17,6 @@
|
||||||
#ifdef DEVICE_WATCHDOG
|
#ifdef DEVICE_WATCHDOG
|
||||||
|
|
||||||
#include "drivers/VirtualWatchdog.h"
|
#include "drivers/VirtualWatchdog.h"
|
||||||
#include "drivers/Watchdog.h"
|
|
||||||
|
|
||||||
#define MS_TO_US(x) ((x) * 1000)
|
#define MS_TO_US(x) ((x) * 1000)
|
||||||
#define US_TO_MS(x) ((x) / 1000)
|
#define US_TO_MS(x) ((x) / 1000)
|
||||||
|
|
@ -34,7 +33,7 @@ VirtualWatchdog *VirtualWatchdog::_first = NULL;
|
||||||
bool VirtualWatchdog::_is_hw_watchdog_running = false;
|
bool VirtualWatchdog::_is_hw_watchdog_running = false;
|
||||||
us_timestamp_t VirtualWatchdog::_ticker_timeout = 0;
|
us_timestamp_t VirtualWatchdog::_ticker_timeout = 0;
|
||||||
|
|
||||||
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str): _name(str)
|
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str, uint32_t watchdog_hw_timeout) : _name(str)
|
||||||
{
|
{
|
||||||
_current_count = 0;
|
_current_count = 0;
|
||||||
_is_initialized = false;
|
_is_initialized = false;
|
||||||
|
|
@ -47,8 +46,8 @@ VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str): _name
|
||||||
MBED_MAKE_ERROR(MBED_MODULE_DRIVER_WATCHDOG, MBED_ERROR_INITIALIZATION_FAILED);
|
MBED_MAKE_ERROR(MBED_MODULE_DRIVER_WATCHDOG, MBED_ERROR_INITIALIZATION_FAILED);
|
||||||
}
|
}
|
||||||
// we use default hw timeout provided by config
|
// we use default hw timeout provided by config
|
||||||
watchdog.start(Watchdog::watchdog_timeout);
|
watchdog.start(watchdog_hw_timeout);
|
||||||
_ticker_timeout = MS_TO_US(Watchdog::watchdog_timeout / 2);
|
_ticker_timeout = MS_TO_US(watchdog_hw_timeout / 2);
|
||||||
if (_ticker_timeout == 0) {
|
if (_ticker_timeout == 0) {
|
||||||
_ticker_timeout = 1;
|
_ticker_timeout = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "platform/mbed_power_mgmt.h"
|
#include "platform/mbed_power_mgmt.h"
|
||||||
#include "platform/mbed_assert.h"
|
#include "platform/mbed_assert.h"
|
||||||
#include "platform/SingletonPtr.h"
|
#include "platform/SingletonPtr.h"
|
||||||
|
#include "drivers/Watchdog.h"
|
||||||
|
|
||||||
#if DEVICE_LPTICKER
|
#if DEVICE_LPTICKER
|
||||||
#include "drivers/LowPowerTicker.h"
|
#include "drivers/LowPowerTicker.h"
|
||||||
|
|
@ -65,11 +66,13 @@ public:
|
||||||
|
|
||||||
/** Constructor configured with timeout and name for this software watchdog instance.
|
/** Constructor configured with timeout and name for this software watchdog instance.
|
||||||
*
|
*
|
||||||
* We start hardware watchdog on the first run. This set-up uses default watchdog timeout set via config value
|
* @param timeout Timer timeout
|
||||||
* MBED_CONF_TARGET_WATCHDOG_TIMEOUT.
|
* @param str The name for this watchdog timer
|
||||||
|
* @param watchdog_hw_timeout The watchdog driver timeout - can be set only once (as soon as watchdog runs, cannot be reconfigured)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
VirtualWatchdog(uint32_t timeout = 1000, const char *const str = NULL);
|
VirtualWatchdog(uint32_t timeout = 1000, const char *const str = NULL, uint32_t watchdog_hw_timeout = Watchdog::watchdog_timeout);
|
||||||
|
|
||||||
~VirtualWatchdog();
|
~VirtualWatchdog();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue