Adapt code to purged PCB version. Also wait 5s for discharge
This commit is contained in:
parent
d84d1b6eb0
commit
13435d0cea
|
@ -118,9 +118,6 @@ typedef union {
|
|||
|
||||
#define AMI_GPIO_Port GPIOB
|
||||
|
||||
//#define WATCHDOG_UCC
|
||||
#define WATCHDOG_STM
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
@ -141,11 +138,9 @@ const mission_t mission2next[] = {M_MANUAL , M_SKIDPAD , M_AUTOX , M_EBSTEST
|
|||
|
||||
mission_t mission = M_NONE;
|
||||
|
||||
#ifdef WATCHDOG_STM
|
||||
bool pHeartbeat = false;
|
||||
bool WD_OK = false;
|
||||
bool WD_initialized = false;
|
||||
#endif
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
|
@ -206,9 +201,6 @@ int main(void)
|
|||
// 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);
|
||||
|
||||
if (HAL_CAN_Start(&hcan) != HAL_OK)
|
||||
Error_Handler();
|
||||
|
||||
|
@ -253,14 +245,17 @@ int main(void)
|
|||
mission_t new_mission = mission; // By default, don't change mission
|
||||
|
||||
// Wait 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)
|
||||
// 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);
|
||||
while (HAL_GetTick() < 5000) {
|
||||
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();
|
||||
|
@ -270,9 +265,6 @@ int main(void)
|
|||
|
||||
bool TS_activate_MUXed = HAL_GPIO_ReadPin(TS_activate_MUXed_GPIO_Port, TS_activate_MUXed_Pin) == GPIO_PIN_RESET;
|
||||
bool ASMS = HAL_GPIO_ReadPin(ASMS_GPIO_Port, ASMS_Pin) == GPIO_PIN_RESET;
|
||||
#ifdef WATCHDOG_UCC
|
||||
bool WD_OK = HAL_GPIO_ReadPin(WD_OK_GPIO_Port, WD_OK_Pin) == GPIO_PIN_RESET;
|
||||
#endif
|
||||
bool SDC_is_ready = HAL_GPIO_ReadPin(SDC_is_ready_GPIO_Port, SDC_is_ready_Pin) == GPIO_PIN_SET;
|
||||
bool SDC_in_3V3 = HAL_GPIO_ReadPin(SDC_in_3V3_GPIO_Port, SDC_in_3V3_Pin) == GPIO_PIN_SET;
|
||||
bool LV_SENSE_1 = HAL_GPIO_ReadPin(LV_SENSE_1_GPIO_Port, LV_SENSE_1_Pin) == GPIO_PIN_SET;
|
||||
|
@ -498,30 +490,29 @@ 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 (WD_initialized && rxData.signals.heartbeat != pHeartbeat) {
|
||||
|
||||
// Pet watchdog
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
|
||||
// Set whether to close the relay
|
||||
HAL_GPIO_WritePin(AS_close_SDC_GPIO_Port, AS_close_SDC_Pin, rxData.signals.as_close_sdc);
|
||||
|
||||
WD_OK = true;
|
||||
|
||||
if (rxData.signals.heartbeat != pHeartbeat) {
|
||||
if (WD_initialized)
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
WD_OK = true;
|
||||
HAL_GPIO_WritePin(Watchdog_GPIO_Port, Watchdog_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
pHeartbeat = rxData.signals.heartbeat;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WATCHDOG_UCC
|
||||
HAL_GPIO_WritePin(Watchdog_GPIO_Port, Watchdog_Pin, rxData.signals.heartbeat);
|
||||
#endif
|
||||
|
||||
// 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 */
|
||||
|
|
Loading…
Reference in New Issue