Only close SDC once conditions are met

- Watchdog is initialized
- Potential discharge is completed (5s)
- Flag is set by ABX
This commit is contained in:
Oskar Winkels 2023-05-24 13:29:38 +02:00
parent 1bc02e7f02
commit 460578e359
Signed by: o.winkels
GPG Key ID: E7484A06E99DAEF1

View File

@ -503,9 +503,6 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
if (rxHeader.StdId != CAN_ID_RX)
return;
HAL_GPIO_WritePin(ASB_Error_GPIO_Port, ASB_Error_Pin, rxData.signals.asb_error);
HAL_GPIO_WritePin(AS_close_SDC_GPIO_Port, AS_close_SDC_Pin, !rxData.signals.as_close_sdc);
#ifdef WATCHDOG_STM
if (rxData.signals.heartbeat != pHeartbeat) {
@ -516,17 +513,28 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) {
}
pHeartbeat = rxData.signals.heartbeat;
bool close_sdc = WD_initialized && rxData.signals.as_close_sdc;
#endif
#ifdef WATCHDOG_UCC
HAL_GPIO_WritePin(Watchdog_GPIO_Port, Watchdog_Pin, rxData.signals.heartbeat);
bool close_sdc = rxData.signals.as_close_sdc;
#endif
// Set whether to close the relay
// Inverted because the NAND was bodged out
HAL_GPIO_WritePin(AS_close_SDC_GPIO_Port, AS_close_SDC_Pin, !close_sdc);
// Reset old mission LED
setMissionLED(mission, GPIO_PIN_RESET);
mission = rxData.signals.as_mission;
setMissionLED(mission, GPIO_PIN_SET);
// Set ASB Error status
HAL_GPIO_WritePin(ASB_Error_GPIO_Port, ASB_Error_Pin, rxData.signals.asb_error);
}
/* USER CODE END 4 */