VirtualWatchdog: use timeout in ctor to set hw timeout

No config, neither additional parameter - the first instance of the class initalizes the peripheral.
pull/10857/head
Martin Kojtal 2019-07-01 15:28:27 +01:00
parent fd445a57cb
commit dc4d4a32f4
2 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@ VirtualWatchdog *VirtualWatchdog::_first = NULL;
bool VirtualWatchdog::_is_hw_watchdog_running = false;
us_timestamp_t VirtualWatchdog::_ticker_timeout = 0;
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str, uint32_t watchdog_hw_timeout) : _name(str)
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str) : _name(str)
{
_current_count = 0;
_is_initialized = false;
@ -45,9 +45,8 @@ VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str, uint32
if (watchdog.is_running() == true) {
MBED_MAKE_ERROR(MBED_MODULE_DRIVER_WATCHDOG, MBED_ERROR_INITIALIZATION_FAILED);
}
// we use default hw timeout provided by config
watchdog.start(watchdog_hw_timeout);
_ticker_timeout = MS_TO_US(watchdog_hw_timeout / 2);
watchdog.start(timeout);
_ticker_timeout = MS_TO_US(timeout / 2);
if (_ticker_timeout == 0) {
_ticker_timeout = 1;
}

View File

@ -65,13 +65,14 @@ class VirtualWatchdog {
public:
/** Constructor configured with timeout and name for this software watchdog instance.
*
* Note, the first instance of VirtualWatchog configures the hardware watchdog peripheral (uses timeout value passed here).
*
* @param timeout Timer 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, uint32_t watchdog_hw_timeout = Watchdog::watchdog_timeout);
VirtualWatchdog(uint32_t timeout = 1000, const char *const str = NULL);
~VirtualWatchdog();
public: