mirror of https://github.com/ARMmbed/mbed-os.git
VirtualWatchdog: make sure we are the only owner of watchdog
If virtual one is not the only owner we error - init error code in driver.pull/10857/head
parent
a3599414e1
commit
701d8f7cef
|
@ -22,6 +22,7 @@
|
|||
namespace mbed {
|
||||
|
||||
VirtualWatchdog *VirtualWatchdog::_first = NULL;
|
||||
bool _is_hw_watchdog_running = false;
|
||||
|
||||
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str): _name(str)
|
||||
{
|
||||
|
@ -31,7 +32,13 @@ VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str): _name
|
|||
_max_timeout = timeout;
|
||||
// start watchdog
|
||||
Watchdog &watchdog = Watchdog::get_instance();
|
||||
watchdog.start(&VirtualWatchdog::process, Watchdog::elapsed_ms);
|
||||
if (!_is_hw_watchdog_running) {
|
||||
if (watchdog.is_running() == true) {
|
||||
MBED_MAKE_ERROR(MBED_MODULE_DRIVER_WATCHDOG, INITIALIZATION_FAILED);
|
||||
}
|
||||
watchdog.start(&VirtualWatchdog::process, Watchdog::elapsed_ms);
|
||||
_is_hw_watchdog_running = true;
|
||||
}
|
||||
}
|
||||
|
||||
VirtualWatchdog::~VirtualWatchdog()
|
||||
|
|
|
@ -112,6 +112,7 @@ private:
|
|||
const char *_name; //To store the details of user
|
||||
uint32_t _current_count; //this parameter is used to reset everytime threads/user calls kick
|
||||
bool _is_initialized; //To control start and stop functionality
|
||||
static bool _is_hw_watchdog_running; // track we are the first owner of watchdog
|
||||
static VirtualWatchdog *_first; //List to store the user/threads who called start
|
||||
VirtualWatchdog *_next;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue