Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow reconfiguring a running watchdog #12511

Merged
merged 3 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drivers/Watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class Watchdog : private NonCopyable<Watchdog> {
* @param timeout Watchdog timeout in milliseconds.
*
* @return true if the Watchdog timer was started successfully;
* false if Watchdog timer was not started or if the Watchdog
* timer is already running.
* false if Watchdog timer was not started or if setting
* a new watchdog timeout was not possible.
*/
bool start(uint32_t timeout);

Expand Down
6 changes: 1 addition & 5 deletions drivers/source/Watchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ bool Watchdog::start(uint32_t timeout)
MBED_ASSERT(timeout > 0);

core_util_critical_section_enter();
if (_running) {
core_util_critical_section_exit();
return false;
}
watchdog_config_t config;
config.timeout_ms = timeout;
watchdog_status_t sts = hal_watchdog_init(&config);
if (sts == WATCHDOG_STATUS_OK) {
_running = true;
}
core_util_critical_section_exit();
return _running;
return (sts == WATCHDOG_STATUS_OK);
}

bool Watchdog::start()
Expand Down