Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushMakkar committed Jul 17, 2023
1 parent d034ba7 commit 3ac89d4
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 82 deletions.
22 changes: 0 additions & 22 deletions Drivers/IWDG_driver/Inc/IndependentWatchdog.h

This file was deleted.

19 changes: 19 additions & 0 deletions Drivers/IWDG_driver/Inc/independent_watchdog.h
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_ */

11 changes: 11 additions & 0 deletions Drivers/IWDG_driver/Inc/watchdog.h
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


60 changes: 0 additions & 60 deletions Drivers/IWDG_driver/Src/IndependentWatchdog.cpp

This file was deleted.

27 changes: 27 additions & 0 deletions Drivers/IWDG_driver/Src/independent_watchdog.cpp
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);
}

0 comments on commit 3ac89d4

Please sign in to comment.