move watchdog at start to detext early blocking code

This commit is contained in:
King Kévin 2017-01-21 20:52:26 +01:00
parent 2a1db39276
commit a3a2d61b1d
1 changed files with 15 additions and 15 deletions

30
main.c
View File

@ -265,6 +265,10 @@ void main(void)
DBGMCU_CR |= DBGMCU_CR_STANDBY; // allow debug also in standby mode (keep digital part and clock powered)
DBGMCU_CR |= DBGMCU_CR_STOP; // allow debug also in stop mode (keep clock powered)
DBGMCU_CR |= DBGMCU_CR_SLEEP; // allow debug also in sleep mode (keep clock powered)
#else
//setup watchdog to reset in case we get stuck (i.e. when an error occurred)
iwdg_set_period_ms(WATCHDOG_PERIOD); // set independent watchdog period
iwdg_start(); // start independent watchdog
#endif
// setup board
@ -279,6 +283,17 @@ void main(void)
// minimal setup ready
printf("welcome to the spark abacus electricity monitoring system\n"); // print welcome message
#if !(DEBUG)
printf("watchdog set to %.2fs\n",WATCHDOG_PERIOD/1000.0);
if (FLASH_OBR&FLASH_OBR_OPTERR) {
printf("option bytes not set in flash: software wachtdog used (not started at reset)\n");
} else if (FLASH_OBR&FLASH_OBR_WDG_SW) {
printf("software wachtdog used (not started at reset)\n");
} else {
printf("hardware wachtdog used (started at reset)\n");
}
#endif
// setup LEDs
printf("setup status LEDs: ");
rcc_periph_clock_enable(RCC_GPIO(LED_HEARTBEAT_PORT)); // enable clock for LED
@ -348,21 +363,6 @@ void main(void)
radio_esp8266_setup();
printf("OK\n");
#if !(DEBUG)
//setup watchdog to reset in case we get stuck (i.e. when an error occurred)
printf("setup watchdog (%.2fs): ",WATCHDOG_PERIOD/1000.0);
iwdg_set_period_ms(WATCHDOG_PERIOD); // set independent watchdog period
iwdg_start(); // start independent watchdog
printf("OK\n");
if (FLASH_OBR&FLASH_OBR_OPTERR) {
printf("option bytes not set in flash: software wachtdog used (not started at reset)\n");
} else if (FLASH_OBR&FLASH_OBR_WDG_SW) {
printf("software wachtdog used (not started at reset)\n");
} else {
printf("hardware wachtdog used (started at reset)\n");
}
#endif
// main loop
printf("command input: ready\n");
bool action = false; // if an action has been performed don't go to sleep