Watchdog: cleanup after singleton usage

pull/10857/head
Martin Kojtal 2019-06-27 15:46:06 +01:00
parent d9e12e4168
commit 91679d40d5
2 changed files with 11 additions and 17 deletions

View File

@ -23,19 +23,12 @@
namespace mbed {
#if DEVICE_LPTICKER
/** Create singleton instance of LowPowerTicker for watchdog periodic call back of kick.
*/
SingletonPtr<LowPowerTicker> Watchdog::_ticker;
#else
/** Create singleton instance of Ticker for watchdog periodic call back of kick.
*/
SingletonPtr<Ticker> Watchdog::_ticker;
#endif
bool Watchdog::_running = false;
static const uint32_t elapsed_ms = MBED_CONF_TARGET_WATCHDOG_TIMEOUT / 2;
Watchdog::Watchdog() : _running(false)
{
}
bool Watchdog::start()
{
watchdog_status_t sts;
@ -54,7 +47,7 @@ bool Watchdog::start()
core_util_critical_section_exit();
if (_running) {
us_timestamp_t timeout = (MS_TO_US(((elapsed_ms <= 0) ? 1 : elapsed_ms)));
_ticker->attach_us(callback(&Watchdog::kick), timeout);
_ticker->attach_us(callback(&Watchdog::get_instance(), &Watchdog::kick), timeout);
}
return _running;
}
@ -110,4 +103,5 @@ uint32_t Watchdog::get_max_timeout() const
} // namespace mbed
#endif // DEVICE_WATCHDOG

View File

@ -108,17 +108,17 @@ private:
Watchdog();
~Watchdog();
static void kick();
static uint32_t _elapsed_ms;
static bool _running;
void kick();
bool _running;
#if DEVICE_LPTICKER
/** Create singleton instance of LowPowerTicker for watchdog periodic call back of kick.
*/
static SingletonPtr<LowPowerTicker> _ticker;
SingletonPtr<LowPowerTicker> _ticker;
#else
/** Create singleton instance of Ticker for watchdog periodic call back of kick.
*/
static SingletonPtr<Ticker> _ticker;
SingletonPtr<Ticker> _ticker;
#endif
};