Fix bug where WDG wouldn't initialize if ASMS is turned on after SDCL bootup

This commit is contained in:
Oskar Winkels 2023-07-31 01:27:56 +02:00
parent 3fedb7117b
commit 18d02abf9d
Signed by: o.winkels
GPG Key ID: E7484A06E99DAEF1
1 changed files with 10 additions and 8 deletions

View File

@ -254,10 +254,11 @@ int main(void)
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
bool pAMC = false; bool pAMC = false;
bool pASMS = false;
mission_t new_mission = mission; // By default, don't change mission mission_t new_mission = mission; // By default, don't change mission
// Wait 1s to prevent bus error state while ABX is starting up // Wait at least 1s to prevent bus error state while ABX is starting up
// Wait 5s for the discharge of the DC link (so AMS can't restart) // Wait at least 5s for the discharge of the DC link (so AMS can't restart)
// During that time, show loading animation to show LEDs work // During that time, show loading animation to show LEDs work
while (HAL_GetTick() < 5000) { while (HAL_GetTick() < 5000) {
setMissionLED(M_MANUAL, GPIO_PIN_SET); setMissionLED(M_MANUAL, GPIO_PIN_SET);
@ -272,12 +273,6 @@ int main(void)
setup_done = true; setup_done = true;
// TEMP: Only enable WD if in autonomous mode because EMI currently messes it up during R2D
if (HAL_GPIO_ReadPin(ASMS_GPIO_Port, ASMS_Pin) == GPIO_PIN_RESET) {
MX_IWDG_Init();
WD_initialized = true;
}
while (true) { while (true) {
// Compare with RESET for signals obtained via inverting buffer // Compare with RESET for signals obtained via inverting buffer
@ -307,6 +302,12 @@ int main(void)
} }
// TEMP: Only enable WD if in autonomous mode because EMI currently messes it up during R2D
if (ASMS > pASMS) {
MX_IWDG_Init();
WD_initialized = true;
}
txData = (tx_data_t) { txData = (tx_data_t) {
.signals = { .signals = {
.asms_state = ASMS, .asms_state = ASMS,
@ -328,6 +329,7 @@ int main(void)
// Store previous button value to detect signal edges // Store previous button value to detect signal edges
pAMC = AMC; pAMC = AMC;
pASMS = ASMS;
HAL_Delay(TX_UPDATE_PERIOD); HAL_Delay(TX_UPDATE_PERIOD);