forked from achamaikin/CCSModuleSW30Web
Add fire alarm handling for DC30 CCS main controller.
Latch fire alarm until reboot, block recovery commands, and send periodic Everest ESTOP while active. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+32
-3
@@ -9,6 +9,7 @@
|
||||
#include "charger_config.h"
|
||||
#include "psu_control.h"
|
||||
#include "serial_control.h"
|
||||
#include "fire_alarm.h"
|
||||
|
||||
extern UART_HandleTypeDef huart3;
|
||||
extern uint8_t config_initialized;
|
||||
@@ -175,6 +176,7 @@ void CCS_SerialLoop(void) {
|
||||
static uint32_t stop_tick = 0;
|
||||
|
||||
CCS_UART3_Watchdog();
|
||||
FireAlarm_Maintain();
|
||||
|
||||
if (CONN.connControl != CMD_NONE) {
|
||||
last_cmd = CONN.connControl;
|
||||
@@ -216,7 +218,8 @@ void CCS_SerialLoop(void) {
|
||||
|
||||
if (((CONN.connControl == CMD_STOP) ||
|
||||
(CONN.connControl == CMD_FORCE_UNLOCK) ||
|
||||
(CONN.chargingError != CONN_NO_ERROR)) &&
|
||||
(CONN.chargingError != CONN_NO_ERROR) ||
|
||||
FireAlarm_IsLatched()) &&
|
||||
((int32_t)(HAL_GetTick() - last_stop_sent) > 1000)) {
|
||||
last_stop_sent = HAL_GetTick();
|
||||
log_printf(LOG_WARN, "Stopping charging...\n");
|
||||
@@ -259,6 +262,10 @@ void CCS_SerialLoop(void) {
|
||||
everest_timed_out = host_timeout_stop;
|
||||
switch(CCS_ConnectorState){
|
||||
case CCS_UNKNOWN:
|
||||
if (FireAlarm_IsLatched()) {
|
||||
CCS_ConnectorState = CCS_DISABLED;
|
||||
break;
|
||||
}
|
||||
RELAY_Write(RELAY_CP, 0);
|
||||
CONN_SetState(Unknown);
|
||||
if (config_initialized && !host_timed_out) {
|
||||
@@ -268,11 +275,15 @@ void CCS_SerialLoop(void) {
|
||||
case CCS_DISABLED:
|
||||
RELAY_Write(RELAY_CP, 0);
|
||||
CONN_SetState(Disabled);
|
||||
if ((CONN.chargingError == CONN_NO_ERROR) && !host_timed_out){
|
||||
if (!FireAlarm_IsLatched() && (CONN.chargingError == CONN_NO_ERROR) && !host_timed_out){
|
||||
CCS_ConnectorState = CCS_UNPLUGGED;
|
||||
}
|
||||
break;
|
||||
case CCS_UNPLUGGED:
|
||||
if (FireAlarm_IsLatched()) {
|
||||
CCS_ConnectorState = CCS_DISABLED;
|
||||
break;
|
||||
}
|
||||
RELAY_Write(RELAY_CP, 1);
|
||||
CONN_SetState(Unplugged);
|
||||
if ((cp_state_buffer == EV_STATE_B_CONN_PREP) || (cp_state_buffer == EV_STATE_C_CONN_ACTIVE)){
|
||||
@@ -285,6 +296,10 @@ void CCS_SerialLoop(void) {
|
||||
|
||||
break;
|
||||
case CCS_AUTH_REQUIRED:
|
||||
if (FireAlarm_IsLatched()) {
|
||||
CCS_ConnectorState = CCS_DISABLED;
|
||||
break;
|
||||
}
|
||||
RELAY_Write(RELAY_CP, 1);
|
||||
CONN_SetState(AuthRequired);
|
||||
if(CONN.connControl == CMD_START){
|
||||
@@ -297,6 +312,10 @@ void CCS_SerialLoop(void) {
|
||||
}
|
||||
break;
|
||||
case CCS_CONNECTED:
|
||||
if (FireAlarm_IsLatched()) {
|
||||
CCS_ConnectorState = CCS_DISABLED;
|
||||
break;
|
||||
}
|
||||
RELAY_Write(RELAY_CP, 1);
|
||||
if((CCS_EvseState < Preparing) || (CCS_EvseState == AuthRequired)) {
|
||||
CONN_SetState(Preparing);
|
||||
@@ -313,6 +332,10 @@ void CCS_SerialLoop(void) {
|
||||
}
|
||||
break;
|
||||
case CCS_REPLUGGING:
|
||||
if (FireAlarm_IsLatched()) {
|
||||
CCS_ConnectorState = CCS_DISABLED;
|
||||
break;
|
||||
}
|
||||
RELAY_Write(RELAY_CP, 0);
|
||||
CONN_SetState(Replugging);
|
||||
if((int32_t)(HAL_GetTick() - replug_tick) > 1000){
|
||||
@@ -335,7 +358,13 @@ void CCS_SerialLoop(void) {
|
||||
}
|
||||
|
||||
// 10s timeout: enforce safe-state until host communication recovers.
|
||||
if (host_timeout_stop) {
|
||||
if (FireAlarm_IsLatched()) {
|
||||
CONN.EnableOutput = 0;
|
||||
CP_SetDuty(100);
|
||||
if (CCS_ConnectorState != CCS_DISABLED && CCS_ConnectorState != CCS_UNKNOWN) {
|
||||
CCS_ConnectorState = CCS_DISABLED;
|
||||
}
|
||||
} else if (host_timeout_stop) {
|
||||
CONN.EnableOutput = 0;
|
||||
CCS_EvseState = Unknown;
|
||||
CP_SetDuty(100);
|
||||
|
||||
Reference in New Issue
Block a user