Files
@ 7e9d097bfe72
Branch filter:
Location: protofuse-firmware/src/watchdog.c - annotation
7e9d097bfe72
746 B
text/plain
Added interrupts to code
ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d ad3725832a9d | //
// Watchdog: configure and initialize the watchdog peripheral
//
#include "stm32f3xx_hal.h"
#include "config.h"
#include "watchdog.h"
#ifdef WATCHDOG_ENABLE
static IWDG_HandleTypeDef hiwdg;
uint8_t watchdog_enabled = 0;
#endif
// Initialize the watchdog timer
void watchdog_init(void)
{
#ifdef WATCHDOG_ENABLE
// ~2 seconds?
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
hiwdg.Init.Window = 4095;
hiwdg.Init.Reload = 4095;
HAL_IWDG_Init(&hiwdg);
watchdog_feed();
HAL_IWDG_Start(&hiwdg);
watchdog_enabled = 1;
#endif
}
// Feed the watchdog timer
void watchdog_feed(void)
{
#ifdef WATCHDOG_ENABLE
if(watchdog_enabled)
HAL_IWDG_Refresh(&hiwdg);
#endif
}
|