HAL support for 8s watchdog

This commit is contained in:
Scott Lahteine
2020-11-04 15:08:31 -06:00
parent 2a78fe0f81
commit 4fe1adc383
14 changed files with 82 additions and 73 deletions

View File

@ -19,31 +19,27 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef __IMXRT1062__
/**
* HAL Watchdog for Teensy 4.0 (IMXRT1062DVL6A) / 4.1 (IMXRT1062DVJ6A)
*/
#ifdef __IMXRT1062__
#include "../../inc/MarlinConfig.h"
#if ENABLED(USE_WATCHDOG)
#include "watchdog.h"
// 4 seconds timeout
#define WDTO 4 //seconds
#define WDT_TIMEOUT TERN(WATCHDOG_DURATION_8S, 8, 4) // 4 or 8 second timeout
uint8_t timeoutval = (WDTO - 0.5f) / 0.5f;
constexpr uint8_t timeoutval = (WDT_TIMEOUT - 0.5f) / 0.5f;
void watchdog_init() {
CCM_CCGR3 |= CCM_CCGR3_WDOG1(3); // enable WDOG1 clocks
WDOG1_WMCR = 0; // disable power down PDE
WDOG1_WCR |= WDOG_WCR_SRS | WDOG_WCR_WT(timeoutval);
WDOG1_WCR |= WDOG_WCR_WDE | WDOG_WCR_WDT | WDOG_WCR_SRE;
}
void HAL_watchdog_refresh() {