forked from achamaikin/CCSModuleSW30Web
Update firmware version to 1.0.10, add hv_tick parameter to PSU control, enhance serial control with response handling, and improve stop button control logic.
This commit is contained in:
+36
-5
@@ -96,6 +96,7 @@ void ED_Delay(uint32_t Delay)
|
||||
|
||||
while ((HAL_GetTick() - tickstart) < wait){
|
||||
CCS_SerialLoop();
|
||||
StopButtonControl();
|
||||
// CP_Loop();
|
||||
CONN_Task();
|
||||
LED_Task();
|
||||
@@ -104,12 +105,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;
|
||||
@@ -202,8 +235,6 @@ int main(void)
|
||||
CONN_Loop();
|
||||
LED_Write();
|
||||
ED_Delay(10);
|
||||
StopButtonControl();
|
||||
ED_Delay(50);
|
||||
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
|
||||
Reference in New Issue
Block a user