Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
card10
firmware
Commits
ab363fde
Commit
ab363fde
authored
Aug 24, 2019
by
Jeff Gough
Committed by
Rahix
Aug 24, 2019
Browse files
feat(epicardium): Enable hardware-watchdog timer
parent
a5c5e87e
Changes
4
Hide whitespace changes
Inline
Side-by-side
epicardium/main.c
View file @
ab363fde
...
...
@@ -12,6 +12,8 @@
int
main
(
void
)
{
watchdog_init
();
LOG_INFO
(
"startup"
,
"Epicardium startup ..."
);
LOG_INFO
(
"startup"
,
"Version "
CARD10_VERSION
);
...
...
@@ -127,14 +129,6 @@ int main(void)
abort
();
}
/* Watchdog petting */
#if 0
/*
* Disabled for this release.
*/
watchdog_clearer_init();
#endif
LOG_DEBUG
(
"startup"
,
"Starting FreeRTOS ..."
);
vTaskStartScheduler
();
...
...
epicardium/modules/hardware.c
View file @
ab363fde
...
...
@@ -32,24 +32,7 @@ int hardware_early_init(void)
/*
* Watchdog timer
*/
#if 0
/*
* 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
watchdog_init
();
/*
* I2C bus for onboard peripherals (ie. PMIC, BMA400, BHI160, BME680,
...
...
@@ -207,6 +190,9 @@ int hardware_early_init(void)
*/
int
hardware_init
(
void
)
{
/* Watchdog clearer software timer */
watchdog_clearer_init
();
/* Light Sensor */
LOG_DEBUG
(
"init"
,
"Starting light sensor ..."
);
epic_light_sensor_run
();
...
...
epicardium/modules/modules.h
View file @
ab363fde
...
...
@@ -36,6 +36,7 @@ int personal_state_enabled();
void
vPmicTask
(
void
*
pvParameters
);
/* ---------- Watchdog ----------------------------------------------------- */
void
watchdog_init
();
void
watchdog_clearer_init
();
/* Critical battery voltage */
...
...
epicardium/modules/watchdog.c
View file @
ab363fde
...
...
@@ -14,8 +14,27 @@ static void watchdog_clearer_callback()
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
()
{
WDT_ResetTimer
(
MXC_WDT0
);
clearer_timer
=
xTimerCreateStatic
(
"watchdog_clearer_timer"
,
CLEAR_PERIOD
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment