-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d034ba7
commit 3ac89d4
Showing
5 changed files
with
57 additions
and
82 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
#ifndef INDEPENDENT_WATCHDOG_H | ||
#define INDEPENDENT_WATCHDOG_H | ||
|
||
#include <stdint.h> | ||
#include "main.h" | ||
|
||
class IndependentWatchdog : public Watchdog { | ||
private: | ||
IWDG_HandleTypeDef* watchdog; | ||
|
||
public: | ||
IndependentWatchdog(IWDG_HandleTypeDef* watchdog); | ||
bool refreshWatchdog() override ; | ||
}; | ||
|
||
|
||
#endif /* SRC_DRIVERS_INDEPENDENTWATCHDOG_H_ */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef WATCHDOG_H_ | ||
#define WATCHDOG_H_ | ||
|
||
class Watchdog { | ||
public: | ||
virtual bool refreshWatchdog() = 0; | ||
}; | ||
|
||
#endif | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "independent_watchdog.h" | ||
#include "main.h" | ||
|
||
/** | ||
* @brief Borrow the configuration of an already existing watchdog and set it | ||
* to the prescaler and Reload values. | ||
* | ||
*/ | ||
IndependentWatchdog::IndependentWatchdog(IWDG_HandleTypeDef *watchdog) { | ||
this->watchdog = watchdog; | ||
IWDG_InitTypeDef initDef = watchdog->Init; | ||
this->iwdg_prescaler = initDef.Prescaler; | ||
this->iwdg_reload = initDef.Reload; | ||
} | ||
|
||
|
||
/** | ||
* @brief Refreshes the watchdog that is a member variable of the class | ||
* @returns true on success, false on failure | ||
*/ | ||
|
||
bool IndependentWatchdog::refreshWatchdog() { | ||
if (this->watchdog == nullptr) { | ||
return false; | ||
} | ||
return (HAL_IWDG_Refresh(watchdog) == HAL_OK); | ||
} |