Skip to content

Commit a937d30

Browse files
authored
Merge pull request #12511 from paul-szczepanek-arm/patch-1
allow reconfiguring a running watchdog
2 parents f4df4e7 + 59f0acb commit a937d30

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

UNITTESTS/drivers/Watchdog/test_watchdog.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class TestWatchdog : public testing::Test {
3838
TEST_F(TestWatchdog, test_watchdog_start_stop_get_timeout)
3939
{
4040
EXPECT_TRUE(Watchdog::get_instance().start(500));
41-
EXPECT_FALSE(Watchdog::get_instance().start(2000));
4241
EXPECT_TRUE(Watchdog::get_instance().stop());
4342
EXPECT_FALSE(Watchdog::get_instance().stop());
4443
EXPECT_EQ(500, Watchdog::get_instance().get_timeout());

drivers/Watchdog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class Watchdog : private NonCopyable<Watchdog> {
9898
* @param timeout Watchdog timeout in milliseconds.
9999
*
100100
* @return true if the Watchdog timer was started successfully;
101-
* false if Watchdog timer was not started or if the Watchdog
102-
* timer is already running.
101+
* false if Watchdog timer was not started or if setting
102+
* a new watchdog timeout was not possible.
103103
*/
104104
bool start(uint32_t timeout);
105105

drivers/source/Watchdog.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,14 @@ bool Watchdog::start(uint32_t timeout)
3434
MBED_ASSERT(timeout > 0);
3535

3636
core_util_critical_section_enter();
37-
if (_running) {
38-
core_util_critical_section_exit();
39-
return false;
40-
}
4137
watchdog_config_t config;
4238
config.timeout_ms = timeout;
4339
watchdog_status_t sts = hal_watchdog_init(&config);
4440
if (sts == WATCHDOG_STATUS_OK) {
4541
_running = true;
4642
}
4743
core_util_critical_section_exit();
48-
return _running;
44+
return (sts == WATCHDOG_STATUS_OK);
4945
}
5046

5147
bool Watchdog::start()

0 commit comments

Comments
 (0)