From 86f688c0f74998035b7ecd4f64b13b3fd6df28f4 Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 19 May 2023 22:04:33 +0200 Subject: [PATCH] Bootup animation for LED debugging + Freeze WDG when debugging --- sdcl-firmware/Core/Src/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sdcl-firmware/Core/Src/main.c b/sdcl-firmware/Core/Src/main.c index 1e1d817..ecd257a 100644 --- a/sdcl-firmware/Core/Src/main.c +++ b/sdcl-firmware/Core/Src/main.c @@ -191,12 +191,11 @@ int main(void) /* USER CODE BEGIN SysInit */ - /* USER CODE END SysInit */ - MX_GPIO_Init(); MX_CAN_Init(); #if false + /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_CAN_Init(); @@ -204,6 +203,9 @@ int main(void) /* USER CODE BEGIN 2 */ #endif + // Freeze WDG when debugging + __HAL_DBGMCU_FREEZE_IWDG(); + // Ensure we start with SDC disabled HAL_GPIO_WritePin(Watchdog_GPIO_Port, Watchdog_Pin, GPIO_PIN_RESET); @@ -250,8 +252,16 @@ int main(void) bool pAMC = false; mission_t new_mission = mission; // By default, don't change mission - // Important to prevent bus error state while ABX is starting up - HAL_Delay(1000); + // Wait 1s to prevent bus error state while ABX is starting up + // During that time, show loading animation to show LEDs work + setMissionLED(M_MANUAL, GPIO_PIN_SET); + HAL_Delay(150); + setMissionLED(M_MANUAL, GPIO_PIN_RESET); + for (mission_t m = M_ACCEL; m != M_MANUAL; m = mission2next[m]) { + setMissionLED(m, GPIO_PIN_SET); + HAL_Delay(150); + setMissionLED(m, GPIO_PIN_RESET); + } MX_IWDG_Init(); WD_initialized = true;