last version before dma

This commit is contained in:
2026-05-07 12:26:13 +03:00
parent 910811df1d
commit ea8663e247
6 changed files with 22166 additions and 22163 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ extern "C" {
/* USER CODE BEGIN EC */ /* USER CODE BEGIN EC */
#define FW_VERSION_MAJOR 1 #define FW_VERSION_MAJOR 1
#define FW_VERSION_MINOR 0 #define FW_VERSION_MINOR 0
#define FW_VERSION_PATCH 16 #define FW_VERSION_PATCH 17
/* USER CODE END EC */ /* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
+30 -25
View File
@@ -29,7 +29,8 @@ uint8_t ev_enable_output = 0;
#define CMD_INTERVAL 10 #define CMD_INTERVAL 10
#define MAX_TX_BUFFER_SIZE 256 #define MAX_TX_BUFFER_SIZE 256
#define MAX_RX_BUFFER_SIZE 256 #define MAX_RX_BUFFER_SIZE 256
#define EVEREST_TIMEOUT_MS 5000u #define EVEREST_TIMEOUT_WARN_MS 5000u
#define EVEREST_TIMEOUT_STOP_MS 10000u
#define UART3_REINIT_TIMEOUT_MS 1500u #define UART3_REINIT_TIMEOUT_MS 1500u
/* Everest requests 500 V -> PSU really gets 300 V / 1 A, state still reports 500 V. */ /* Everest requests 500 V -> PSU really gets 300 V / 1 A, state still reports 500 V. */
#define FAKE_EVREQ_VOLTAGE_V 500u #define FAKE_EVREQ_VOLTAGE_V 500u
@@ -48,7 +49,8 @@ uint8_t isolation_enable = 0;
static uint32_t last_host_seen = 0; static uint32_t last_host_seen = 0;
static uint8_t fake_500_voltage_mode = 0; static uint8_t fake_500_voltage_mode = 0;
static uint8_t everest_timed_out = 0; static uint8_t everest_timed_out = 0;
static uint32_t last_everest_timeout_log_tick = 0; static uint8_t everest_timeout_warn_latched = 0;
static uint8_t everest_timeout_stop_latched = 0;
static uint32_t uart3_last_packet_tick = 0; static uint32_t uart3_last_packet_tick = 0;
static uint32_t uart3_last_reinit_tick = 0; static uint32_t uart3_last_reinit_tick = 0;
@@ -211,7 +213,27 @@ void CCS_SerialLoop(void) {
(void)replug_watchdog_tick; (void)replug_watchdog_tick;
(void)replug_watchdog1_tick; (void)replug_watchdog1_tick;
uint8_t host_timed_out = (last_host_seen > 0 && (HAL_GetTick() - last_host_seen) > EVEREST_TIMEOUT_MS); uint32_t now = HAL_GetTick();
uint8_t host_timeout_warn = (last_host_seen > 0 && (now - last_host_seen) > EVEREST_TIMEOUT_WARN_MS);
uint8_t host_timeout_stop = (last_host_seen > 0 && (now - last_host_seen) > EVEREST_TIMEOUT_STOP_MS);
uint8_t host_timed_out = host_timeout_stop;
if (host_timeout_warn && !everest_timeout_warn_latched) {
log_printf(LOG_ERR, "Everest timeout\n");
everest_timeout_warn_latched = 1;
}
if (host_timeout_stop && !everest_timeout_stop_latched) {
log_printf(LOG_ERR, "Everest timeout, stopping charging...\n");
everest_timeout_stop_latched = 1;
}
if (!host_timeout_warn) {
everest_timeout_warn_latched = 0;
everest_timeout_stop_latched = 0;
}
everest_timed_out = host_timeout_stop;
switch(CCS_ConnectorState){ switch(CCS_ConnectorState){
case CCS_UNKNOWN: case CCS_UNKNOWN:
RELAY_Write(RELAY_CP, 0); RELAY_Write(RELAY_CP, 0);
@@ -253,7 +275,7 @@ void CCS_SerialLoop(void) {
break; break;
case CCS_CONNECTED: case CCS_CONNECTED:
RELAY_Write(RELAY_CP, 1); RELAY_Write(RELAY_CP, 1);
if(CCS_EvseState < Preparing) { if((CCS_EvseState < Preparing) || (CCS_EvseState == AuthRequired)) {
CONN_SetState(Preparing); CONN_SetState(Preparing);
} else { } else {
CONN_SetState(CCS_EvseState); CONN_SetState(CCS_EvseState);
@@ -289,26 +311,8 @@ void CCS_SerialLoop(void) {
break; break;
} }
// If Everest timeout happened, keep safe-state and limit log frequency. // 10s timeout: enforce safe-state until host communication recovers.
// The safe-state must remain until we receive a valid packet from the host. if (host_timeout_stop) {
if (everest_timed_out) {
if (last_everest_timeout_log_tick == 0 ||
(HAL_GetTick() - last_everest_timeout_log_tick) >= EVEREST_TIMEOUT_MS) {
log_printf(LOG_ERR, "Everest timeout\n");
last_everest_timeout_log_tick = HAL_GetTick();
}
CONN.EnableOutput = 0;
CCS_EvseState = Unknown;
CP_SetDuty(100);
if (CCS_ConnectorState != CCS_DISABLED && CCS_ConnectorState != CCS_UNKNOWN) {
CCS_ConnectorState = CCS_DISABLED;
}
} else if (last_host_seen > 0 && (HAL_GetTick() - last_host_seen) > EVEREST_TIMEOUT_MS) {
log_printf(LOG_ERR, "Everest timeout\n");
everest_timed_out = 1;
last_host_seen = HAL_GetTick(); // reset after the first timeout
last_everest_timeout_log_tick = HAL_GetTick();
CONN.EnableOutput = 0; CONN.EnableOutput = 0;
CCS_EvseState = Unknown; CCS_EvseState = Unknown;
CP_SetDuty(100); CP_SetDuty(100);
@@ -465,7 +469,8 @@ ISR_FAST static void apply_command(uint8_t cmd, const uint8_t* payload, uint16_t
(void)payload_len; (void)payload_len;
last_host_seen = HAL_GetTick(); last_host_seen = HAL_GetTick();
everest_timed_out = 0; everest_timed_out = 0;
last_everest_timeout_log_tick = 0; everest_timeout_warn_latched = 0;
everest_timeout_stop_latched = 0;
switch (cmd) { switch (cmd) {
case CMD_E2M_PWM_DUTY: { case CMD_E2M_PWM_DUTY: {
const e2m_pwm_duty_t* p = (const e2m_pwm_duty_t*)payload; const e2m_pwm_duty_t* p = (const e2m_pwm_duty_t*)payload;
Binary file not shown.
+18949 -18953
View File
File diff suppressed because it is too large Load Diff
+3168 -3166
View File
File diff suppressed because it is too large Load Diff
+18 -18
View File
@@ -1,18 +1,18 @@
../Core/Src/serial.c:63:22:uart3_log_hal_error 3 ../Core/Src/serial.c:65:22:uart3_log_hal_error 3
../Core/Src/serial.c:83:22:uart3_arm_rx_or_log 3 ../Core/Src/serial.c:85:22:uart3_arm_rx_or_log 3
../Core/Src/serial.c:98:15:CCS_RxEventCallback 4 ../Core/Src/serial.c:100:15:CCS_RxEventCallback 4
../Core/Src/serial.c:121:15:HAL_UART_ErrorCallback 5 ../Core/Src/serial.c:123:15:HAL_UART_ErrorCallback 5
../Core/Src/serial.c:139:6:CCS_SerialLoop 60 ../Core/Src/serial.c:141:6:CCS_SerialLoop 62
../Core/Src/serial.c:338:6:CCS_Init 1 ../Core/Src/serial.c:342:6:CCS_Init 1
../Core/Src/serial.c:352:26:crc16_ibm 3 ../Core/Src/serial.c:356:26:crc16_ibm 3
../Core/Src/serial.c:367:17:CCS_BuildPacket 4 ../Core/Src/serial.c:371:17:CCS_BuildPacket 4
../Core/Src/serial.c:383:13:CCS_SendPacket 2 ../Core/Src/serial.c:387:13:CCS_SendPacket 2
../Core/Src/serial.c:391:13:CCS_SendResetReason 1 ../Core/Src/serial.c:395:13:CCS_SendResetReason 1
../Core/Src/serial.c:395:6:CCS_SendEmergencyStop 1 ../Core/Src/serial.c:399:6:CCS_SendEmergencyStop 1
../Core/Src/serial.c:399:6:CCS_SendStart 1 ../Core/Src/serial.c:403:6:CCS_SendStart 1
../Core/Src/serial.c:403:13:CCS_CalculateEnergy 2 ../Core/Src/serial.c:407:13:CCS_CalculateEnergy 2
../Core/Src/serial.c:418:13:send_state 3 ../Core/Src/serial.c:422:13:send_state 3
../Core/Src/serial.c:448:26:expected_payload_len 2 ../Core/Src/serial.c:452:26:expected_payload_len 2
../Core/Src/serial.c:464:22:apply_command 15 ../Core/Src/serial.c:468:22:apply_command 15
../Core/Src/serial.c:545:25:process_received_packet 8 ../Core/Src/serial.c:550:25:process_received_packet 8
../Core/Src/serial.c:598:13:CCS_UART3_Watchdog 3 ../Core/Src/serial.c:603:13:CCS_UART3_Watchdog 3