mirror of https://github.com/ARMmbed/mbed-os.git
Watchdog: cleanup after singleton usage
parent
d9e12e4168
commit
91679d40d5
|
@ -23,19 +23,12 @@
|
||||||
|
|
||||||
namespace mbed {
|
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;
|
static const uint32_t elapsed_ms = MBED_CONF_TARGET_WATCHDOG_TIMEOUT / 2;
|
||||||
|
|
||||||
|
Watchdog::Watchdog() : _running(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool Watchdog::start()
|
bool Watchdog::start()
|
||||||
{
|
{
|
||||||
watchdog_status_t sts;
|
watchdog_status_t sts;
|
||||||
|
@ -54,7 +47,7 @@ bool Watchdog::start()
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
if (_running) {
|
if (_running) {
|
||||||
us_timestamp_t timeout = (MS_TO_US(((elapsed_ms <= 0) ? 1 : elapsed_ms)));
|
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;
|
return _running;
|
||||||
}
|
}
|
||||||
|
@ -110,4 +103,5 @@ uint32_t Watchdog::get_max_timeout() const
|
||||||
|
|
||||||
} // namespace mbed
|
} // namespace mbed
|
||||||
|
|
||||||
|
|
||||||
#endif // DEVICE_WATCHDOG
|
#endif // DEVICE_WATCHDOG
|
||||||
|
|
|
@ -108,17 +108,17 @@ private:
|
||||||
Watchdog();
|
Watchdog();
|
||||||
~Watchdog();
|
~Watchdog();
|
||||||
|
|
||||||
static void kick();
|
void kick();
|
||||||
static uint32_t _elapsed_ms;
|
|
||||||
static bool _running;
|
bool _running;
|
||||||
#if DEVICE_LPTICKER
|
#if DEVICE_LPTICKER
|
||||||
/** Create singleton instance of LowPowerTicker for watchdog periodic call back of kick.
|
/** Create singleton instance of LowPowerTicker for watchdog periodic call back of kick.
|
||||||
*/
|
*/
|
||||||
static SingletonPtr<LowPowerTicker> _ticker;
|
SingletonPtr<LowPowerTicker> _ticker;
|
||||||
#else
|
#else
|
||||||
/** Create singleton instance of Ticker for watchdog periodic call back of kick.
|
/** Create singleton instance of Ticker for watchdog periodic call back of kick.
|
||||||
*/
|
*/
|
||||||
static SingletonPtr<Ticker> _ticker;
|
SingletonPtr<Ticker> _ticker;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue