Skip to content

Commit dc4d4a3

Browse files
committed
VirtualWatchdog: use timeout in ctor to set hw timeout
No config, neither additional parameter - the first instance of the class initalizes the peripheral.
1 parent fd445a5 commit dc4d4a3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

drivers/VirtualWatchdog.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ VirtualWatchdog *VirtualWatchdog::_first = NULL;
3333
bool VirtualWatchdog::_is_hw_watchdog_running = false;
3434
us_timestamp_t VirtualWatchdog::_ticker_timeout = 0;
3535

36-
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str, uint32_t watchdog_hw_timeout) : _name(str)
36+
VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str) : _name(str)
3737
{
3838
_current_count = 0;
3939
_is_initialized = false;
@@ -45,9 +45,8 @@ VirtualWatchdog::VirtualWatchdog(uint32_t timeout, const char *const str, uint32
4545
if (watchdog.is_running() == true) {
4646
MBED_MAKE_ERROR(MBED_MODULE_DRIVER_WATCHDOG, MBED_ERROR_INITIALIZATION_FAILED);
4747
}
48-
// we use default hw timeout provided by config
49-
watchdog.start(watchdog_hw_timeout);
50-
_ticker_timeout = MS_TO_US(watchdog_hw_timeout / 2);
48+
watchdog.start(timeout);
49+
_ticker_timeout = MS_TO_US(timeout / 2);
5150
if (_ticker_timeout == 0) {
5251
_ticker_timeout = 1;
5352
}

drivers/VirtualWatchdog.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ class VirtualWatchdog {
6565
public:
6666

6767
/** Constructor configured with timeout and name for this software watchdog instance.
68+
*
69+
* Note, the first instance of VirtualWatchog configures the hardware watchdog peripheral (uses timeout value passed here).
6870
*
6971
* @param timeout Timer timeout
7072
* @param str The name for this watchdog timer
71-
* @param watchdog_hw_timeout The watchdog driver timeout - can be set only once (as soon as watchdog runs, cannot be reconfigured)
7273
*
7374
*/
74-
VirtualWatchdog(uint32_t timeout = 1000, const char *const str = NULL, uint32_t watchdog_hw_timeout = Watchdog::watchdog_timeout);
75+
VirtualWatchdog(uint32_t timeout = 1000, const char *const str = NULL);
7576

7677
~VirtualWatchdog();
7778
public:

0 commit comments

Comments
 (0)