Skip to content
Snippets Groups Projects
Commit ab363fde authored by Jeff Gough's avatar Jeff Gough Committed by rahix
Browse files

feat(epicardium): Enable hardware-watchdog timer

parent a5c5e87e
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
int main(void) int main(void)
{ {
watchdog_init();
LOG_INFO("startup", "Epicardium startup ..."); LOG_INFO("startup", "Epicardium startup ...");
LOG_INFO("startup", "Version " CARD10_VERSION); LOG_INFO("startup", "Version " CARD10_VERSION);
...@@ -127,14 +129,6 @@ int main(void) ...@@ -127,14 +129,6 @@ int main(void)
abort(); abort();
} }
/* Watchdog petting */
#if 0
/*
* Disabled for this release.
*/
watchdog_clearer_init();
#endif
LOG_DEBUG("startup", "Starting FreeRTOS ..."); LOG_DEBUG("startup", "Starting FreeRTOS ...");
vTaskStartScheduler(); vTaskStartScheduler();
......
...@@ -32,24 +32,7 @@ int hardware_early_init(void) ...@@ -32,24 +32,7 @@ int hardware_early_init(void)
/* /*
* Watchdog timer * Watchdog timer
*/ */
#if 0 watchdog_init();
/*
* Disabled for this release.
*/
sys_cfg_wdt_t wdt_cfg = NULL;
WDT_Init(MXC_WDT0, wdt_cfg);
if (WDT_GetResetFlag(MXC_WDT0)) {
WDT_ClearResetFlag(MXC_WDT0);
LOG_INFO("watchdog", "Reset due to watchdog timeout");
}
WDT_Enable(MXC_WDT0, 1);
WDT_SetResetPeriod(
MXC_WDT0,
WDT_PERIOD_2_27); /* Clocked by PCLK at 50MHz, reset at 2^27 ticks = 2.7 seconds */
WDT_EnableReset(MXC_WDT0, 1);
#endif
/* /*
* I2C bus for onboard peripherals (ie. PMIC, BMA400, BHI160, BME680, * I2C bus for onboard peripherals (ie. PMIC, BMA400, BHI160, BME680,
...@@ -207,6 +190,9 @@ int hardware_early_init(void) ...@@ -207,6 +190,9 @@ int hardware_early_init(void)
*/ */
int hardware_init(void) int hardware_init(void)
{ {
/* Watchdog clearer software timer */
watchdog_clearer_init();
/* Light Sensor */ /* Light Sensor */
LOG_DEBUG("init", "Starting light sensor ..."); LOG_DEBUG("init", "Starting light sensor ...");
epic_light_sensor_run(); epic_light_sensor_run();
......
...@@ -36,6 +36,7 @@ int personal_state_enabled(); ...@@ -36,6 +36,7 @@ int personal_state_enabled();
void vPmicTask(void *pvParameters); void vPmicTask(void *pvParameters);
/* ---------- Watchdog ----------------------------------------------------- */ /* ---------- Watchdog ----------------------------------------------------- */
void watchdog_init();
void watchdog_clearer_init(); void watchdog_clearer_init();
/* Critical battery voltage */ /* Critical battery voltage */
......
...@@ -14,8 +14,27 @@ static void watchdog_clearer_callback() ...@@ -14,8 +14,27 @@ static void watchdog_clearer_callback()
WDT_ResetTimer(MXC_WDT0); WDT_ResetTimer(MXC_WDT0);
} }
void watchdog_init()
{
sys_cfg_wdt_t wdt_cfg = NULL;
WDT_Init(MXC_WDT0, wdt_cfg);
if (WDT_GetResetFlag(MXC_WDT0)) {
WDT_ClearResetFlag(MXC_WDT0);
LOG_INFO("watchdog", "Last reset was due to watchdog timeout");
}
WDT_Enable(MXC_WDT0, 1);
WDT_SetResetPeriod(
MXC_WDT0,
WDT_PERIOD_2_28); /* Clocked by PCLK at 50MHz, reset at 2^28 ticks = 5.4 seconds */
WDT_EnableReset(MXC_WDT0, 1);
}
void watchdog_clearer_init() void watchdog_clearer_init()
{ {
WDT_ResetTimer(MXC_WDT0);
clearer_timer = xTimerCreateStatic( clearer_timer = xTimerCreateStatic(
"watchdog_clearer_timer", "watchdog_clearer_timer",
CLEAR_PERIOD, CLEAR_PERIOD,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment