ils

Dependencies:   mbed-dev

Fork of GA-Test_copy by Alejandro Ungria Hirte

Watchdog/Watchdog.cpp

Committer:
aungriah
Date:
2017-12-06
Revision:
0:a3b83d366423

File content as of revision 0:a3b83d366423:

#include "Watchdog.h"


Watchdog::Watchdog() {
}

// Load timeout value in watchdog timer and enable
void Watchdog::kick(float s) {
    
    uint32_t clk = SystemCoreClock / 3;    // found by trying. TODO: exakt values
    hiwdg.Instance = IWDG;
    hiwdg.Init.Prescaler = IWDG_PRESCALER_16;
    hiwdg.Init.Reload = s * (float)clk;
    if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
    {
      // Error Handler
    }    
}
    
// "kick" or "feed" the dog - reset the watchdog timer
// by writing this required bit pattern
void Watchdog::kick() {
    HAL_IWDG_Refresh(&hiwdg);
}