Enhance board and PSU control structures; update connector state handling and stop button logic. Adjust LED color cycles for better visual feedback. Refactor serial communication to improve state management and error handling.

This commit is contained in:
2026-05-05 17:52:14 +03:00
parent 944952689e
commit 910811df1d
19 changed files with 28054 additions and 27761 deletions
+36 -5
View File
@@ -97,6 +97,7 @@ void ED_Delay(uint32_t Delay)
while ((HAL_GetTick() - tickstart) < wait){
CCS_SerialLoop();
StopButtonControl();
CP_Loop();
CONN_Task();
LED_Task();
@@ -105,12 +106,44 @@ void ED_Delay(uint32_t Delay)
}
void StopButtonControl(){
static uint32_t tick;
static uint32_t hold_time;
static uint8_t stop_btn_fault = 1;
uint32_t now = HAL_GetTick();
//Charging do nothing
if(!IN_ReadInput(IN_ESTOP)){
CONN.connControl = CMD_STOP;
/* Run no faster than once per 10 ms. */
if((now - tick) < 10){
return;
}
tick = now;
uint8_t pressed = !IN_ReadInput(IN_ESTOP);
if(!pressed){
stop_btn_fault = 0;
}
if(stop_btn_fault){
return;
}
if(pressed){
if(hold_time == 0){
CONN.connControl = CMD_STOP;
}
hold_time += 10;
if(hold_time == 5000){
CONN.connControl = CMD_FORCE_UNLOCK;
}
if(hold_time > 40000){
SC_SendPacket(NULL, 0, RESP_SUCCESS);
while(huart2.gState == HAL_UART_STATE_BUSY_TX);
HAL_Delay(10);
NVIC_SystemReset();
}
}
else{
hold_time = 0;
}
}
uint8_t temp0, temp1;
@@ -205,8 +238,6 @@ int main(void)
CONN_Loop();
LED_Write();
ED_Delay(10);
StopButtonControl();
ED_Delay(50);
}
/* USER CODE END 3 */