aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-24 21:56:07 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-24 21:56:07 +0100
commit50130396427009ed0c75f9976e7f9939e8195f2e (patch)
treedcf7d765d56eab54cc55322ae71e6b754f04d7aa /src
parent06925990d5ec2b10c64b83ab93087b942d8127b1 (diff)
downloadglutte-o-matic-50130396427009ed0c75f9976e7f9939e8195f2e.tar.gz
glutte-o-matic-50130396427009ed0c75f9976e7f9939e8195f2e.tar.bz2
glutte-o-matic-50130396427009ed0c75f9976e7f9939e8195f2e.zip
Enable Watchdog to 2 seconds
Diffstat (limited to 'src')
-rw-r--r--src/fsm/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/fsm/main.c b/src/fsm/main.c
index bf1c541..aba3465 100644
--- a/src/fsm/main.c
+++ b/src/fsm/main.c
@@ -74,6 +74,12 @@ int main(void) {
usart_init();
usart_debug_puts("******* glutt-o-matique version " GIT_VERSION " *******\r\n");
+ if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET)
+ {
+ usart_debug_puts("WARNING: A IWDG Reset occured!\r\n");
+ }
+ RCC_ClearFlag();
+
TaskHandle_t task_handle;
xTaskCreate(
launcher_task,
@@ -267,6 +273,9 @@ static void gps_monit_task(void *pvParameters)
}
vTaskDelay(100 / portTICK_RATE_MS);
+
+ // Reload watchdog
+ IWDG_ReloadCounter();
}
}
@@ -346,5 +355,15 @@ void init() {
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+
+ /* Setup Watchdog
+ * The IWDG runs at 32kHz. With a prescaler of 32 -> 1kHz.
+ * Counting to 2000 / 1000 = 2 seconds
+ */
+ IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
+ IWDG_SetPrescaler(IWDG_Prescaler_32);
+ IWDG_SetReload(2000);
+ IWDG_Enable();
}