clean project

This commit is contained in:
2026-05-09 14:02:54 +03:00
parent c8f91af7da
commit 414d2cba60
77 changed files with 35443 additions and 35979 deletions
+4
View File
@@ -1,5 +1,6 @@
# macOS
.DS_Store
**/.DS_Store
# Temporary/editor files
*.swp
@@ -57,3 +58,6 @@ Release/**/*.obj
# Optional local launch configs
*.launch
# VS Code local settings
.vscode/
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file adc.h
* @brief This file contains all the function prototypes for
* the adc.c file
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ADC_H__
+3 -13
View File
@@ -1,14 +1,6 @@
/*
* board.h
*
* Created on: Apr 15, 2024
* Author: colorbass
*/
#pragma once
#ifndef SRC_BOARD_H_
#define SRC_BOARD_H_
void GBT_Lock(uint8_t state);
#include <stdint.h>
typedef enum{
RELAY_AUX0 = 0,
@@ -24,6 +16,7 @@ typedef enum{
} relay_t;
void RELAY_Write(relay_t num, uint8_t state);
uint8_t RELAY_Read(relay_t num);
void Init_Peripheral();
uint8_t GBT_LockGetState();
void GBT_Lock(uint8_t state);
@@ -60,6 +53,3 @@ typedef struct __attribute__((packed)) {
} InfoBlock_t;
extern InfoBlock_t *InfoBlock;
#endif /* SRC_BOARD_H_ */
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file can.h
* @brief This file contains all the function prototypes for
* the can.c file
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CAN_H__
+5 -3
View File
@@ -5,9 +5,11 @@
#define PSU_MIN_VOLTAGE 150 //1V/bit
#define PSU_MAX_CURRENT 133 //1A/bit
#define PSU_MIN_CURRENT 1 //1A/bit
#define PSU_MAX_POWER 30000 //1W/bit
#define PSU_MAX_POWER 40000 //1W/bit
#define PSU_NUM 1
#define GBT_CH_VER_MAJOR 1
#define GBT_CH_VER_MINOR 0
/* Everest / стенд: запрос «500 В» на шине — реально на PSU задаются U/I ниже; статус может оставаться 500 В (serial.c). */
#define FAKE_EVREQ_VOLTAGE_V 500u
#define FAKE_PSU_VOLTAGE_V 300u
#define FAKE_PSU_CURRENT_0P1A 10u
+1 -19
View File
@@ -1,12 +1,4 @@
/*
* charger_control.h
*
* Created on: Jul 29, 2024
* Author: colorbass
*/
#ifndef INC_CHARGER_CONTROL_H_
#define INC_CHARGER_CONTROL_H_
#pragma once
#include "main.h"
@@ -83,16 +75,6 @@ typedef struct{
extern ChargingConnector_t CONN;
//информация о зарядке
//база данных с хранением инфы
//главный блок хранит в себе инфу о конфиге возможно во флеше
//либо в charger_config.h
//OCPP - универсальный блок типа
void CONN_Init();
void CONN_Loop();
void CONN_PrintChargingTotal();
#endif /* INC_CHARGER_CONTROL_H_ */
+1 -12
View File
@@ -1,12 +1,4 @@
/*
* connector.h
*
* Created on: Jul 31, 2024
* Author: colorbass
*/
#ifndef INC_CONNECTOR_H_
#define INC_CONNECTOR_H_
#pragma once
#include "main.h"
#include "charger_control.h"
@@ -15,7 +7,4 @@
extern CONN_State_t connectorState;
void CONN_Init();
void CONN_Task();
void CONN_SetState(CONN_State_t state);
#endif /* INC_CONNECTOR_H_ */
+1 -4
View File
@@ -1,5 +1,4 @@
#ifndef __CP_H
#define __CP_H
#pragma once
#include "main.h"
#include <stdint.h>
@@ -27,5 +26,3 @@ CP_State_t CP_GetFilteredState(void);
void CP_FilterState(void);
void CP_Loop(void);
#endif
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file crc.h
* @brief This file contains all the function prototypes for
* the crc.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CRC_H__
+1 -11
View File
@@ -1,12 +1,4 @@
/*
* debug.h
*
* Created on: Apr 16, 2024
* Author: colorbass
*/
#ifndef SRC_DEBUG_H_
#define SRC_DEBUG_H_
#pragma once
#include <stdint.h>
#include <stdarg.h>
@@ -30,5 +22,3 @@ void debug_buffer_send(void);
// Кастомный printf с приоритетом лога
int log_printf(LogLevel_t level, const char *format, ...);
#endif /* SRC_DEBUG_H_ */
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file dma.h
* @brief This file contains all the function prototypes for
* the dma.c file
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DMA_H__
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GPIO_H__
+1 -4
View File
@@ -1,5 +1,4 @@
#ifndef ISR_OPT_H
#define ISR_OPT_H
#pragma once
/* GCC: быстрые функции, вызываемые из IRQ / из HAL из IRQ-контекста */
#if defined(__GNUC__)
@@ -7,5 +6,3 @@
#else
#define ISR_FAST
#endif
#endif /* ISR_OPT_H */
+3 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
@@ -55,6 +39,8 @@ extern "C" {
void Error_Handler(void);
/* USER CODE BEGIN EFP */
uint8_t ED_TraceWarning(uint8_t flag, uint8_t id);
void ED_Delay(uint32_t Delay);
/* USER CODE END EFP */
+1 -13
View File
@@ -1,25 +1,15 @@
/*
* psu_struct.h
*
* Created on: Jul 24, 2024
* Author: colorbass
*/
#ifndef INC_METER_H_
#define INC_METER_H_
#pragma once
#include "main.h"
#include "charger_config.h"
typedef struct {
uint32_t meterLastTick; // Время последнего пакета Alive
uint8_t online;
uint32_t lastTick; // Время последнего вызова для каждого коннектора
uint64_t EnergyPSU_Ws; // Энергия для каждого коннектора (расчет по силовым модулям)
uint32_t AbsoluteEnergy; // Абсолютная энергия каждого счетчика (ватт*час)
uint32_t EnergyOffset; // смещение энергии по счетчикам (если 0, значит не успели захватить Offset) (ватт*час)
uint32_t EnergyOffset1; // смещение энергии по счетчикам относительно PSU
uint8_t enable; //если 0, то счетчик обнуляется
}METER_t;
@@ -27,5 +17,3 @@ typedef struct {
extern METER_t METER;
void METER_CalculateEnergy();
#endif /* INC_METER_H_ */
+2 -15
View File
@@ -1,20 +1,11 @@
/*
* ccs_control.h
*
* Created on: 19 авг. 2024 г.
* Author: colorbass
*/
#ifndef INC_PSU_CONTROL_H_
#define INC_PSU_CONTROL_H_
#pragma once
#include "main.h"
#include "charger_config.h"
void PSU_Init();
void PSU_Enable(uint8_t addr, uint8_t enable);
void PSU_Loop();
void CONT_Loop();
void PSU_ReadWrite(void);
// --- Состояние силового модуля (DC30, один PSU) ---
@@ -191,7 +182,3 @@ extern PSU_1B_t PSU_1B;
extern PSU_1C_t PSU_1C;
#pragma pack(pop)
#endif /* INC_PSU_CONTROL_H_ */
+2 -12
View File
@@ -1,12 +1,4 @@
/*
* rgb_handler.h
*
* Created on: Jul 25, 2024
* Author: colorbass
*/
#ifndef INC_RGB_CONTROLLER_H_
#define INC_RGB_CONTROLLER_H_
#pragma once
#include "main.h"
@@ -48,6 +40,4 @@ typedef struct{
void LED_Task();
void LED_Write();
void LED_Init();
#endif /* INC_RGB_CONTROLLER_H_ */
void LED_SetColor(RGB_Cycle_t *color);
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file rtc.h
* @brief This file contains all the function prototypes for
* the rtc.c file
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RTC_H__
+1 -5
View File
@@ -1,5 +1,4 @@
#ifndef __SERIAL_H
#define __SERIAL_H
#pragma once
#include "main.h"
#include "charger_control.h"
@@ -125,6 +124,3 @@ extern CCS_MaxLoad_t CCS_MaxLoad;
extern CCS_EvInfo_t CCS_EvInfo;
extern CONN_State_t CCS_EvseState;
extern uint8_t REPLUG;
#endif
+1 -6
View File
@@ -1,13 +1,10 @@
#ifndef SERIALCONTROL_H
#define SERIALCONTROL_H
#pragma once
#include "main.h"
#include <string.h>
#include "charger_control.h"
#include "isr_opt.h"
#define USE_WEB_INTERFACE
// Команды от ПК к устройству
// Пакет статуса изоляции от отдельного блока по одностороннему UART
#define CMD_ISOLATION_STATUS 0x01
@@ -180,5 +177,3 @@ extern StatusPacket_t statusPacket;
extern InfoPacket_t infoPacket;
extern IsolationStatusPacket_t ISO;
extern volatile SC_Source_t g_sc_command_source;
#endif // SERIALCONTROL_H
+1 -5
View File
@@ -1,5 +1,4 @@
#ifndef SMA_FILTER_H
#define SMA_FILTER_H
#pragma once
#include <stdint.h>
@@ -18,6 +17,3 @@ typedef struct {
void SMAFilter_Init(SMAFilter_t* f);
int32_t SMAFilter_Update(SMAFilter_t* f, int32_t x);
#endif // SMA_FILTER_H
+1 -11
View File
@@ -1,12 +1,4 @@
/*
* soft_rtc.h
*
* Created on: Jul 22, 2024
* Author: colorbass
*/
#ifndef INC_SOFT_RTC_H_
#define INC_SOFT_RTC_H_
#pragma once
#include "main.h"
@@ -15,5 +7,3 @@ void set_Time(uint32_t unix_time);
void unix_to_bcd(uint32_t unix_time, uint8_t *time);
void writeTimeReg(uint8_t reg_number, uint8_t value);
uint8_t getTimeReg(uint8_t reg_number);
#endif /* INC_SOFT_RTC_H_ */
+1 -16
View File
@@ -1,20 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_conf.h
* @brief HAL configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
+1 -16
View File
@@ -1,20 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file tim.h
* @brief This file contains all the function prototypes for
* the tim.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TIM_H__
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file usart.h
* @brief This file contains all the function prototypes for
* the usart.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file adc.c
* @brief This file provides code for the configuration
* of the ADC instances.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "adc.h"
+6 -18
View File
@@ -1,13 +1,9 @@
#include "main.h"
#include "board.h"
#include "adc.h"
#include "tim.h"
#include "sma_filter.h"
//TODO:
//TEMP READ
// Connector temperature sensors
#include "adc.h"
#include "main.h"
#include "sma_filter.h"
#include "tim.h"
InfoBlock_t *InfoBlock = (InfoBlock_t *)(VERSION_OFFSET);
@@ -74,15 +70,8 @@ uint8_t IN_ReadInput(inputNum_t input_n){
}
}
uint8_t GetBoardTemp(){
//TODO
// HAL_ADC_Start(&hadc1); // start the adc
//
// HAL_ADC_PollForConversion(&hadc1, 100); // poll for conversion
//
// adc_val = HAL_ADC_GetValue(&hadc1); // get the adc value
//
// HAL_ADC_Stop(&hadc1); // stop adc
/* Заглушка: температура платы не измеряется (нет реализации АЦП для канала). */
uint8_t GetBoardTemp(void){
return 0;
}
@@ -138,7 +127,6 @@ int16_t CONN_ReadTemp(uint8_t ch){
return 20; //Термодатчик не подключен
}
// int adc_value = 2048; // Пример значения АЦП
float Vref = 3.3; // Напряжение опорное
float Vin = 5.0; // Входное напряжение
float R = 1000; // Сопротивление резистора в Омах
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file can.c
* @brief This file provides code for the configuration
* of the CAN instances.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "can.h"
+5 -22
View File
@@ -1,13 +1,11 @@
#include "charger_control.h"
#include "charger_config.h"
#include "psu_control.h"
#include "connector.h"
#include "debug.h"
#include "psu_control.h"
ChargingConnector_t CONN;
CONN_State_t connectorState;
extern uint8_t config_initialized;
void CONN_Init(){
@@ -28,24 +26,16 @@ void CONN_Loop(){
CONN.chargingError = CONN_ERR_CONTACTOR;
} else if(PSU0.psu_fault){
CONN.chargingError = CONN_ERR_PSU_FAULT;
// } else if(!CTRL.ac_ok) {
// CONN.chargingError = CONN_ERR_AC_FAULT;
// } else
}else if (CONN.EvConnected == 0){
CONN.chargingError = CONN_NO_ERROR;
}
if(ED_TraceWarning(CONN.chargingError, 0)) printf("CONN%d Error: %d\n", 0, CONN.chargingError);
if(ED_TraceWarning(CONN.chargingError, 0)) {
log_printf(LOG_WARN, "CONN0 Error: %d\n", (int)CONN.chargingError);
}
}
void CONN_Task(){
/* CCS state machine is handled in serial.c.
* Keep this task lightweight for scheduler compatibility.
*/
return;
}
void CONN_SetState(CONN_State_t state){
if (connectorState == state) {
CONN.connState = state;
@@ -71,10 +61,3 @@ void CONN_SetState(CONN_State_t state){
CONN.connState = state;
}
void CONN_PrintChargingTotal(){
printf("CONN%d Charging Finished:\n", 0);
// printf("Charging Time: %d\n", CONN.chargingTime);
printf("Charging Energy: %d\n", CONN.Energy);
// printf("Charging Power: %d\n", CONN.chargingPower);
}
+1
View File
@@ -1,4 +1,5 @@
#include "cp.h"
#include "adc.h"
#include "board.h"
#include "debug.h"
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file crc.c
* @brief This file provides code for the configuration
* of the CRC instances.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "crc.h"
+7 -14
View File
@@ -1,21 +1,14 @@
/*
* debug.c
*
* Created on: Apr 16, 2024
* Author: colorbass
*/
#include "main.h"
#include "board.h"
#include "connector.h"
#include "debug.h"
#include "serial_control.h"
#include "usart.h"
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdarg.h>
#include "debug.h"
#include "board.h"
#include "usart.h"
#include <time.h>
#include <connector.h>
#include "serial_control.h"
// Кольцевой буфер для отладочных сообщений
#define DEBUG_BUFFER_SIZE 1024
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file dma.c
* @brief This file provides code for the configuration
* of all the requested memory to memory DMA transfers.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file gpio.c
* @brief This file provides code for the configuration
* of all used GPIO pins.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
+11 -10
View File
@@ -1,4 +1,5 @@
/* USER CODE BEGIN Header */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
@@ -13,15 +14,17 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "can.h"
#include "board.h"
#include <stdio.h>
#include "debug.h"
#include "soft_rtc.h"
#include "connector.h"
#include "serial_control.h"
#include "charger_config.h"
#include "connector.h"
#include "debug.h"
#include "meter.h"
#include "psu_control.h"
#include "rgb_controller.h"
#include "serial.h"
#include "serial_control.h"
#include "soft_rtc.h"
#include <stdio.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -53,6 +56,7 @@ void SystemClock_Config(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
static void StopButtonControl(void);
/**
* @brief Vector base address configuration. It should no longer be at the start of
@@ -99,13 +103,12 @@ void ED_Delay(uint32_t Delay)
CCS_SerialLoop();
StopButtonControl();
CP_Loop();
CONN_Task();
LED_Task();
SC_Task();
}
}
void StopButtonControl(){
static void StopButtonControl(void){
static uint32_t tick;
static uint32_t hold_time;
static uint8_t stop_btn_fault = 1;
@@ -146,8 +149,6 @@ void StopButtonControl(){
}
}
uint8_t temp0, temp1;
static void CAN1_MinimalReInit(void)
{
HAL_CAN_Stop(&hcan1);
+1 -9
View File
@@ -1,13 +1,5 @@
/*
* meter.c
*
* Created on: 27 сент. 2024 г.
* Author: root
*/
#include "meter.h"
#include "charger_config.h"
#include "charger_control.h"
+8 -15
View File
@@ -1,14 +1,13 @@
#include "psu_control.h"
#include <psu_control.h>
#include "board.h"
#include "can.h"
#include "string.h"
#include "stdio.h"
#include "charger_config.h"
#include "charger_control.h"
#include "board.h"
#include "debug.h"
#include "isr_opt.h"
#include <stdio.h>
#include <string.h>
PSU_02_t PSU_02;
PSU_04_t PSU_04;
@@ -31,6 +30,8 @@ uint32_t can_lastpacket;
extern CAN_HandleTypeDef hcan2;
static void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data);
static void PSU_SwitchState(PSU_State_t state){
PSU0.state = state;
PSU0.statetick = HAL_GetTick();
@@ -227,7 +228,6 @@ void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data){
/* если отправка удалась, выход */
if(CAN_result == HAL_OK) {
return;
retry_counter = 0;
}
}
ED_Delay(1);
@@ -237,11 +237,6 @@ void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data){
}
uint32_t max(uint32_t a, uint32_t b){
if(a>b) return a;
else return b;
}
void PSU_ReadWrite(){
uint8_t zero_data[8] = {0,0,0,0,0,0,0,0};
@@ -264,8 +259,8 @@ void PSU_ReadWrite(){
CONN.RequestedPower = CONN.RequestedCurrent * CONN.RequestedVoltage / 10;
if(PSU0.ready){
if (CONN.RequestedVoltage == 500) { // fake
PSU_SetVoltageCurrent(0, 300, 10); // Normal mode
if (CONN.RequestedVoltage == FAKE_EVREQ_VOLTAGE_V) {
PSU_SetVoltageCurrent(0, (uint16_t)FAKE_PSU_VOLTAGE_V, (uint16_t)FAKE_PSU_CURRENT_0P1A);
}else{
PSU_SetVoltageCurrent(0, CONN.RequestedVoltage, CONN.RequestedCurrent); // Normal mode
}
@@ -288,7 +283,6 @@ void PSU_ReadWrite(){
void PSU_Task(void){
static uint32_t psu_on_tick = 0;
static uint32_t dc_on_tick = 0;
static uint32_t cont_ok_tick = 0;
// Обновляем ONLINE/READY по таймауту
@@ -368,7 +362,6 @@ void PSU_Task(void){
case PSU_WAIT_ACK_ON:
if(PSU0.PSU_enabled && PSU0.ready){
dc_on_tick = HAL_GetTick();
PSU_SwitchState(PSU_CONT_WAIT_ACK_ON);
}else if(PSU_StateTime() > 10000){
PSU0.psu_fault = 1;
+4 -29
View File
@@ -1,10 +1,10 @@
#include "rgb_controller.h"
#include "main.h"
#include "string.h"
#include "charger_control.h"
#include "board.h"
#include "board.h"
#include "charger_control.h"
#include "main.h"
#include "tim.h"
#include <string.h>
RGB_State_t LED_State;
RGB_Cycle_t LED_Cycle;
@@ -198,36 +198,11 @@ void LED_Init(){
RGB_SetColor(&color);
}
// void LED_PhaseSync(uint8_t led_n){
// if(LED_State[led_n].phasesync){
// LED_State[led_n].phasesync = 0;
// //default settings
// LED_State[led_n].state = LED_HIGH;
// LED_State[led_n].tick = 0;
// //ищем среди всех светодиодов такую же последовательность
// for (uint8_t led_n1 = 0; led_n1 < 5; led_n1++){
// if ((LED_Cycle[led_n].Tf == LED_Cycle[led_n1].Tf) &&
// (LED_Cycle[led_n].Tr == LED_Cycle[led_n1].Tr) &&
// (LED_Cycle[led_n].Th == LED_Cycle[led_n1].Th) &&
// (LED_Cycle[led_n].Tl == LED_Cycle[led_n1].Tl) &&
// (led_n != led_n1)){
// //если нашли, то копируем фазу оттуда
// LED_State[led_n].state = LED_State[led_n1].state;
// LED_State[led_n].tick = LED_State[led_n1].tick;
// return;
// }
// }
// }
// }
void LED_Task(){
static uint32_t led_tick;
if((HAL_GetTick() - led_tick) > 20){
led_tick = HAL_GetTick();
LED_State.tick++;
// LED_PhaseSync(led_n);
switch(LED_State.state){
case LED_RISING:
interpolateColors(&LED_Cycle.Color2, &LED_Cycle.Color1, LED_State.tick, LED_Cycle.Tr, &LED_State.color);
+6 -11
View File
@@ -1,14 +1,15 @@
#include "serial.h"
#include "cp.h"
#include "connector.h"
#include "board.h"
#include "charger_config.h"
#include "connector.h"
#include "cp.h"
#include "debug.h"
#include "isr_opt.h"
#include <stdint.h>
#include <string.h>
#include "charger_config.h"
#include "psu_control.h"
#include "serial_control.h"
#include <stdint.h>
#include <string.h>
extern UART_HandleTypeDef huart3;
extern uint8_t config_initialized;
@@ -28,15 +29,9 @@ CONN_Control_t last_cmd = CMD_NONE;
uint8_t ev_enable_output = 0;
#define CMD_INTERVAL 10
#define MAX_TX_BUFFER_SIZE 256
#define MAX_RX_BUFFER_SIZE 256
#define EVEREST_TIMEOUT_WARN_MS 5000u
#define EVEREST_TIMEOUT_STOP_MS 10000u
#define UART3_REINIT_TIMEOUT_MS 1500u
/* Everest requests 500 V -> PSU really gets 300 V / 1 A, state still reports 500 V. */
#define FAKE_EVREQ_VOLTAGE_V 500u
#define FAKE_PSU_VOLTAGE_V 300u
#define FAKE_PSU_CURRENT_0P1A 10u
static uint8_t rx_buffer[MAX_RX_BUFFER_SIZE];
static uint8_t tx_buffer[MAX_TX_BUFFER_SIZE];
+3 -2
View File
@@ -1,9 +1,10 @@
#include "serial_control.h"
#include "usart.h"
#include "board.h"
#include "serial.h"
#include "debug.h"
#include "isr_opt.h"
#include "serial.h"
#include "usart.h"
// Приватные функции
ISR_FAST static uint32_t calculate_crc32(const uint8_t* data, uint16_t length);
+6 -7
View File
@@ -1,14 +1,14 @@
#include "serial_control.h"
#include "usart.h"
#include "charger_control.h"
#include "board.h"
#include "psu_control.h"
#include "charger_control.h"
#include "debug.h"
#include "psu_control.h"
#include "usart.h"
#include <string.h>
#ifdef USE_WEB_INTERFACE
extern volatile SC_Source_t g_sc_command_source;
static void monitoring_data_callback(void);
IsolationStatusPacket_t ISO = {
.isolationResistance = 0xFFFF
@@ -122,7 +122,7 @@ void SC_CommandHandler(ReceivedCommand_t* cmd) {
// Колбэк для заполнения данных мониторинга
void monitoring_data_callback() {
static void monitoring_data_callback(void) {
// Информация о зарядной сессии
statusPacket.SOC = CONN.SOC;
@@ -202,4 +202,3 @@ void monitoring_data_callback() {
}
#endif
+2 -22
View File
@@ -1,11 +1,4 @@
/*
* rtc.c
*
* Created on: Jul 22, 2024
* Author: colorbass
*/
#include <soft_rtc.h>
#include "soft_rtc.h"
#include <stdint.h>
#include <time.h>
@@ -63,20 +56,7 @@ uint8_t getTimeReg(uint8_t reg_number){
}else{
return 0x00;
}
};
//int main() {
// uint32_t unix_time = 1672531199; // Example Unix timestamp
// uint8_t time[8];
//
// unix_to_bcd(unix_time, time);
//
// // Print the BCD values for verification
// for (int i = 0; i < 8; i++) {
// log_printf(LOG_INFO, "time[%d]: %02X\n", i, time[i]);
// }
//
// return 0;
//}
}
/**
* @brief Read the time counter available in RTC_CNT registers.
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_msp.c
* @brief This file provides code for the MSP Initialization
* and de-Initialization codes.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
+1 -16
View File
@@ -1,20 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file tim.c
* @brief This file provides code for the configuration
* of the TIM instances.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "tim.h"
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file usart.c
* @brief This file provides code for the configuration
* of the USART instances.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usart.h"
Binary file not shown.
Binary file not shown.
+3651 -3658
View File
File diff suppressed because it is too large Load Diff
+22696 -22752
View File
File diff suppressed because it is too large Load Diff
+2019 -2087
View File
File diff suppressed because it is too large Load Diff
+3650 -3658
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,5 +1,5 @@
../Core/Src/adc.c:29:6:ADC_ScanStart 2
../Core/Src/adc.c:37:15:HAL_ADC_ConvCpltCallback 2
../Core/Src/adc.c:59:6:MX_ADC1_Init 8
../Core/Src/adc.c:146:6:HAL_ADC_MspInit 3
../Core/Src/adc.c:200:6:HAL_ADC_MspDeInit 2
../Core/Src/adc.c:13:6:ADC_ScanStart 2
../Core/Src/adc.c:21:15:HAL_ADC_ConvCpltCallback 2
../Core/Src/adc.c:43:6:MX_ADC1_Init 8
../Core/Src/adc.c:130:6:HAL_ADC_MspInit 3
../Core/Src/adc.c:184:6:HAL_ADC_MspDeInit 2
+13 -13
View File
@@ -1,13 +1,13 @@
../Core/Src/board.c:18:6:RELAY_Write 9
../Core/Src/board.c:51:9:RELAY_Read 1
../Core/Src/board.c:56:9:IN_ReadInput 8
../Core/Src/board.c:77:9:GetBoardTemp 1
../Core/Src/board.c:89:6:Init_Peripheral 1
../Core/Src/board.c:106:7:pt1000_to_temperature 1
../Core/Src/board.c:117:7:calculate_NTC_resistance 2
../Core/Src/board.c:132:9:CONN_ReadTemp 4
../Core/Src/board.c:152:9:GBT_ReadTemp 1
../Core/Src/board.c:156:6:ADC_Select_Channel 2
../Core/Src/board.c:167:9:ADC_TryLock 4
../Core/Src/board.c:183:6:ADC_LockBlocking 2
../Core/Src/board.c:189:6:ADC_Unlock 2
../Core/Src/board.c:14:6:RELAY_Write 9
../Core/Src/board.c:47:9:RELAY_Read 1
../Core/Src/board.c:52:9:IN_ReadInput 8
../Core/Src/board.c:74:9:GetBoardTemp 1
../Core/Src/board.c:78:6:Init_Peripheral 1
../Core/Src/board.c:95:7:pt1000_to_temperature 1
../Core/Src/board.c:106:7:calculate_NTC_resistance 2
../Core/Src/board.c:121:9:CONN_ReadTemp 4
../Core/Src/board.c:140:9:GBT_ReadTemp 1
../Core/Src/board.c:144:6:ADC_Select_Channel 2
../Core/Src/board.c:155:9:ADC_TryLock 4
../Core/Src/board.c:171:6:ADC_LockBlocking 2
../Core/Src/board.c:177:6:ADC_Unlock 2
+4 -4
View File
@@ -1,4 +1,4 @@
../Core/Src/can.c:31:6:MX_CAN1_Init 2
../Core/Src/can.c:63:6:MX_CAN2_Init 2
../Core/Src/can.c:97:6:HAL_CAN_MspInit 5
../Core/Src/can.c:176:6:HAL_CAN_MspDeInit 5
../Core/Src/can.c:15:6:MX_CAN1_Init 2
../Core/Src/can.c:47:6:MX_CAN2_Init 2
../Core/Src/can.c:81:6:HAL_CAN_MspInit 5
../Core/Src/can.c:160:6:HAL_CAN_MspDeInit 5
+3 -5
View File
@@ -1,5 +1,3 @@
../Core/Src/charger_control.c:12:6:CONN_Init 1
../Core/Src/charger_control.c:20:6:CONN_Loop 6
../Core/Src/charger_control.c:42:6:CONN_Task 1
../Core/Src/charger_control.c:49:6:CONN_SetState 16
../Core/Src/charger_control.c:75:6:CONN_PrintChargingTotal 1
../Core/Src/charger_control.c:10:6:CONN_Init 1
../Core/Src/charger_control.c:18:6:CONN_Loop 6
../Core/Src/charger_control.c:39:6:CONN_SetState 16
+9 -9
View File
@@ -1,9 +1,9 @@
../Core/Src/cp.c:19:16:CP_ReadVoltageMv 1
../Core/Src/cp.c:36:6:CP_Init 1
../Core/Src/cp.c:53:6:CP_SetDuty 1
../Core/Src/cp.c:66:9:CP_GetDuty 1
../Core/Src/cp.c:70:9:CP_GetVoltage 1
../Core/Src/cp.c:75:12:CP_GetState 12
../Core/Src/cp.c:99:12:CP_GetFilteredState 1
../Core/Src/cp.c:103:6:CP_FilterState 5
../Core/Src/cp.c:131:6:CP_Loop 5
../Core/Src/cp.c:20:16:CP_ReadVoltageMv 1
../Core/Src/cp.c:37:6:CP_Init 1
../Core/Src/cp.c:54:6:CP_SetDuty 1
../Core/Src/cp.c:67:9:CP_GetDuty 1
../Core/Src/cp.c:71:9:CP_GetVoltage 1
../Core/Src/cp.c:76:12:CP_GetState 12
../Core/Src/cp.c:100:12:CP_GetFilteredState 1
../Core/Src/cp.c:104:6:CP_FilterState 5
../Core/Src/cp.c:132:6:CP_Loop 5
+3 -3
View File
@@ -1,3 +1,3 @@
../Core/Src/crc.c:30:6:MX_CRC_Init 2
../Core/Src/crc.c:51:6:HAL_CRC_MspInit 2
../Core/Src/crc.c:67:6:HAL_CRC_MspDeInit 2
../Core/Src/crc.c:14:6:MX_CRC_Init 2
../Core/Src/crc.c:35:6:HAL_CRC_MspInit 2
../Core/Src/crc.c:51:6:HAL_CRC_MspDeInit 2
+5 -5
View File
@@ -1,5 +1,5 @@
../Core/Src/debug.c:42:5:_write 1
../Core/Src/debug.c:50:6:debug_buffer_add 3
../Core/Src/debug.c:70:10:debug_buffer_available 1
../Core/Src/debug.c:79:6:debug_buffer_send 5
../Core/Src/debug.c:119:5:log_printf 3
../Core/Src/debug.c:35:5:_write 1
../Core/Src/debug.c:43:6:debug_buffer_add 3
../Core/Src/debug.c:63:10:debug_buffer_available 1
../Core/Src/debug.c:72:6:debug_buffer_send 5
../Core/Src/debug.c:112:5:log_printf 3
+1 -1
View File
@@ -1 +1 @@
../Core/Src/dma.c:39:6:MX_DMA_Init 1
../Core/Src/dma.c:23:6:MX_DMA_Init 1
+1 -1
View File
@@ -1 +1 @@
../Core/Src/gpio.c:44:6:MX_GPIO_Init 1
../Core/Src/gpio.c:28:6:MX_GPIO_Init 1
+8 -8
View File
@@ -1,9 +1,9 @@
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
../Core/Src/main.c:65:13:VectorBase_Config 1
../Core/Src/main.c:76:9:ED_TraceWarning 3
../Core/Src/main.c:88:6:ED_Delay 3
../Core/Src/main.c:108:6:StopButtonControl 8
../Core/Src/main.c:151:13:CAN1_MinimalReInit 3
../Core/Src/main.c:169:5:main 1
../Core/Src/main.c:250:6:SystemClock_Config 4
../Core/Src/main.c:310:6:Error_Handler 1
../Core/Src/main.c:69:13:VectorBase_Config 1
../Core/Src/main.c:80:9:ED_TraceWarning 3
../Core/Src/main.c:92:6:ED_Delay 3
../Core/Src/main.c:111:13:StopButtonControl 8
../Core/Src/main.c:152:13:CAN1_MinimalReInit 3
../Core/Src/main.c:170:5:main 1
../Core/Src/main.c:251:6:SystemClock_Config 4
../Core/Src/main.c:311:6:Error_Handler 1
+1 -1
View File
@@ -1 +1 @@
../Core/Src/meter.c:17:6:METER_CalculateEnergy 3
../Core/Src/meter.c:9:6:METER_CalculateEnergy 3
+11 -12
View File
@@ -1,12 +1,11 @@
../Core/Src/psu_control.c:34:13:PSU_SwitchState 1
../Core/Src/psu_control.c:39:17:PSU_StateTime 1
../Core/Src/psu_control.c:43:15:HAL_CAN_RxFifo1MsgPendingCallback 9
../Core/Src/psu_control.c:117:6:PSU_CAN_FilterInit 2
../Core/Src/psu_control.c:140:6:PSU_Init 1
../Core/Src/psu_control.c:158:6:PSU_Enable 3
../Core/Src/psu_control.c:170:6:PSU_SetHVMode 2
../Core/Src/psu_control.c:177:6:PSU_SetVoltageCurrent 5
../Core/Src/psu_control.c:204:6:PSU_SendCmd 4
../Core/Src/psu_control.c:240:10:max 2
../Core/Src/psu_control.c:245:6:PSU_ReadWrite 8
../Core/Src/psu_control.c:289:6:PSU_Task 41
../Core/Src/psu_control.c:35:13:PSU_SwitchState 1
../Core/Src/psu_control.c:40:17:PSU_StateTime 1
../Core/Src/psu_control.c:44:15:HAL_CAN_RxFifo1MsgPendingCallback 9
../Core/Src/psu_control.c:118:6:PSU_CAN_FilterInit 2
../Core/Src/psu_control.c:141:6:PSU_Init 1
../Core/Src/psu_control.c:159:6:PSU_Enable 3
../Core/Src/psu_control.c:171:6:PSU_SetHVMode 2
../Core/Src/psu_control.c:178:6:PSU_SetVoltageCurrent 5
../Core/Src/psu_control.c:205:6:PSU_SendCmd 4
../Core/Src/psu_control.c:240:6:PSU_ReadWrite 8
../Core/Src/psu_control.c:281:6:PSU_Task 41
+1 -1
View File
@@ -3,4 +3,4 @@
../Core/Src/rgb_controller.c:182:6:RGB_SetColor 1
../Core/Src/rgb_controller.c:188:6:LED_SetColor 1
../Core/Src/rgb_controller.c:193:6:LED_Init 1
../Core/Src/rgb_controller.c:225:6:LED_Task 10
../Core/Src/rgb_controller.c:201:6:LED_Task 10
+20 -20
View File
@@ -1,20 +1,20 @@
../Core/Src/serial.c:70:22:uart3_log_hal_error 3
../Core/Src/serial.c:90:22:uart3_arm_rx_or_log 3
../Core/Src/serial.c:106:15:CCS_RxEventCallback 4
../Core/Src/serial.c:129:15:HAL_UART_ErrorCallback 5
../Core/Src/serial.c:149:6:CCS_TxCpltCallback 4
../Core/Src/serial.c:165:6:CCS_SerialLoop 62
../Core/Src/serial.c:365:6:CCS_Init 1
../Core/Src/serial.c:380:26:crc16_ibm 3
../Core/Src/serial.c:395:17:CCS_BuildPacket 4
../Core/Src/serial.c:411:13:CCS_SendPacket 4
../Core/Src/serial.c:428:13:CCS_SendResetReason 1
../Core/Src/serial.c:432:6:CCS_SendEmergencyStop 1
../Core/Src/serial.c:436:6:CCS_SendStart 1
../Core/Src/serial.c:440:13:CCS_CalculateEnergy 2
../Core/Src/serial.c:455:13:send_state 3
../Core/Src/serial.c:485:26:expected_payload_len 2
../Core/Src/serial.c:501:22:apply_command 15
../Core/Src/serial.c:583:25:process_received_packet 8
../Core/Src/serial.c:636:13:CCS_UART3_Watchdog 4
../Core/Src/serial.c:649:13:CCS_LogUart3Error 1
../Core/Src/serial.c:65:22:uart3_log_hal_error 3
../Core/Src/serial.c:85:22:uart3_arm_rx_or_log 3
../Core/Src/serial.c:101:15:CCS_RxEventCallback 4
../Core/Src/serial.c:124:15:HAL_UART_ErrorCallback 5
../Core/Src/serial.c:144:6:CCS_TxCpltCallback 4
../Core/Src/serial.c:160:6:CCS_SerialLoop 62
../Core/Src/serial.c:360:6:CCS_Init 1
../Core/Src/serial.c:375:26:crc16_ibm 3
../Core/Src/serial.c:390:17:CCS_BuildPacket 4
../Core/Src/serial.c:406:13:CCS_SendPacket 4
../Core/Src/serial.c:423:13:CCS_SendResetReason 1
../Core/Src/serial.c:427:6:CCS_SendEmergencyStop 1
../Core/Src/serial.c:431:6:CCS_SendStart 1
../Core/Src/serial.c:435:13:CCS_CalculateEnergy 2
../Core/Src/serial.c:450:13:send_state 3
../Core/Src/serial.c:480:26:expected_payload_len 2
../Core/Src/serial.c:496:22:apply_command 15
../Core/Src/serial.c:578:25:process_received_packet 8
../Core/Src/serial.c:631:13:CCS_UART3_Watchdog 4
../Core/Src/serial.c:644:13:CCS_LogUart3Error 1
+15 -15
View File
@@ -1,15 +1,15 @@
../Core/Src/serial_control.c:71:6:ReadVersion 1
../Core/Src/serial_control.c:83:6:SC_Init 1
../Core/Src/serial_control.c:94:6:SC_Task 7
../Core/Src/serial_control.c:122:15:HAL_UARTEx_RxEventCallback 8
../Core/Src/serial_control.c:152:15:HAL_UART_TxCpltCallback 3
../Core/Src/serial_control.c:163:26:calculate_crc32 3
../Core/Src/serial_control.c:180:26:encode_packet 5
../Core/Src/serial_control.c:213:15:SC_SendPacket 4
../Core/Src/serial_control.c:230:25:parse_packet 3
../Core/Src/serial_control.c:263:25:process_received_packet 2
../Core/Src/serial_control.c:272:13:SC_UART2_Watchdog 5
../Core/Src/serial_control.c:293:13:SC_ArmUart2RxDma 4
../Core/Src/serial_control.c:301:13:SC_ArmUart5RxDma 3
../Core/Src/serial_control.c:310:6:SC_RecoverUartDma 3
../Core/Src/serial_control.c:325:13:SC_LogUartError 3
../Core/Src/serial_control.c:72:6:ReadVersion 1
../Core/Src/serial_control.c:84:6:SC_Init 1
../Core/Src/serial_control.c:95:6:SC_Task 7
../Core/Src/serial_control.c:123:15:HAL_UARTEx_RxEventCallback 8
../Core/Src/serial_control.c:153:15:HAL_UART_TxCpltCallback 3
../Core/Src/serial_control.c:164:26:calculate_crc32 3
../Core/Src/serial_control.c:181:26:encode_packet 5
../Core/Src/serial_control.c:214:15:SC_SendPacket 4
../Core/Src/serial_control.c:231:25:parse_packet 3
../Core/Src/serial_control.c:264:25:process_received_packet 2
../Core/Src/serial_control.c:273:13:SC_UART2_Watchdog 5
../Core/Src/serial_control.c:294:13:SC_ArmUart2RxDma 4
../Core/Src/serial_control.c:302:13:SC_ArmUart5RxDma 3
../Core/Src/serial_control.c:311:6:SC_RecoverUartDma 3
../Core/Src/serial_control.c:326:13:SC_LogUartError 3
+1 -1
View File
@@ -1,3 +1,3 @@
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
../Core/Src/serial_handler.c:26:6:SC_CommandHandler 19
../Core/Src/serial_handler.c:125:6:monitoring_data_callback 1
../Core/Src/serial_handler.c:125:13:monitoring_data_callback 1
+10 -10
View File
@@ -1,10 +1,10 @@
../Core/Src/soft_rtc.c:22:10:get_Current_Time 1
../Core/Src/soft_rtc.c:26:6:set_Time 1
../Core/Src/soft_rtc.c:30:9:to_bcd 1
../Core/Src/soft_rtc.c:34:6:unix_to_bcd 1
../Core/Src/soft_rtc.c:48:6:writeTimeReg 2
../Core/Src/soft_rtc.c:53:9:getTimeReg 5
../Core/Src/soft_rtc.c:87:17:RTC1_ReadTimeCounter 2
../Core/Src/soft_rtc.c:119:26:RTC1_WriteTimeCounter 3
../Core/Src/soft_rtc.c:151:26:RTC1_EnterInitMode 3
../Core/Src/soft_rtc.c:178:26:RTC1_ExitInitMode 3
../Core/Src/soft_rtc.c:15:10:get_Current_Time 1
../Core/Src/soft_rtc.c:19:6:set_Time 1
../Core/Src/soft_rtc.c:23:9:to_bcd 1
../Core/Src/soft_rtc.c:27:6:unix_to_bcd 1
../Core/Src/soft_rtc.c:41:6:writeTimeReg 2
../Core/Src/soft_rtc.c:46:9:getTimeReg 5
../Core/Src/soft_rtc.c:67:17:RTC1_ReadTimeCounter 2
../Core/Src/soft_rtc.c:99:26:RTC1_WriteTimeCounter 3
../Core/Src/soft_rtc.c:131:26:RTC1_EnterInitMode 3
../Core/Src/soft_rtc.c:158:26:RTC1_ExitInitMode 3
+1 -1
View File
@@ -1 +1 @@
../Core/Src/stm32f1xx_hal_msp.c:63:6:HAL_MspInit 1
../Core/Src/stm32f1xx_hal_msp.c:47:6:HAL_MspInit 1
+23 -23
View File
@@ -1,23 +1,23 @@
../Core/Src/stm32f1xx_it.c:84:6:NMI_Handler 1
../Core/Src/stm32f1xx_it.c:99:6:HardFault_Handler 1
../Core/Src/stm32f1xx_it.c:114:6:MemManage_Handler 1
../Core/Src/stm32f1xx_it.c:129:6:BusFault_Handler 1
../Core/Src/stm32f1xx_it.c:144:6:UsageFault_Handler 1
../Core/Src/stm32f1xx_it.c:159:6:SVC_Handler 1
../Core/Src/stm32f1xx_it.c:172:6:DebugMon_Handler 1
../Core/Src/stm32f1xx_it.c:185:6:PendSV_Handler 1
../Core/Src/stm32f1xx_it.c:198:6:SysTick_Handler 1
../Core/Src/stm32f1xx_it.c:219:6:DMA1_Channel1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:233:6:DMA1_Channel2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:247:6:DMA1_Channel3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:261:6:DMA1_Channel6_IRQHandler 1
../Core/Src/stm32f1xx_it.c:275:6:DMA1_Channel7_IRQHandler 1
../Core/Src/stm32f1xx_it.c:289:6:ADC1_2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:303:6:CAN1_RX0_IRQHandler 1
../Core/Src/stm32f1xx_it.c:317:6:TIM3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:331:6:USART1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:345:6:USART2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:359:6:USART3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:373:6:UART5_IRQHandler 1
../Core/Src/stm32f1xx_it.c:387:6:CAN2_TX_IRQHandler 1
../Core/Src/stm32f1xx_it.c:401:6:CAN2_RX1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:69:6:NMI_Handler 1
../Core/Src/stm32f1xx_it.c:84:6:HardFault_Handler 1
../Core/Src/stm32f1xx_it.c:99:6:MemManage_Handler 1
../Core/Src/stm32f1xx_it.c:114:6:BusFault_Handler 1
../Core/Src/stm32f1xx_it.c:129:6:UsageFault_Handler 1
../Core/Src/stm32f1xx_it.c:144:6:SVC_Handler 1
../Core/Src/stm32f1xx_it.c:157:6:DebugMon_Handler 1
../Core/Src/stm32f1xx_it.c:170:6:PendSV_Handler 1
../Core/Src/stm32f1xx_it.c:183:6:SysTick_Handler 1
../Core/Src/stm32f1xx_it.c:204:6:DMA1_Channel1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:218:6:DMA1_Channel2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:232:6:DMA1_Channel3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:246:6:DMA1_Channel6_IRQHandler 1
../Core/Src/stm32f1xx_it.c:260:6:DMA1_Channel7_IRQHandler 1
../Core/Src/stm32f1xx_it.c:274:6:ADC1_2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:288:6:CAN1_RX0_IRQHandler 1
../Core/Src/stm32f1xx_it.c:302:6:TIM3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:316:6:USART1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:330:6:USART2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:344:6:USART3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:358:6:UART5_IRQHandler 1
../Core/Src/stm32f1xx_it.c:372:6:CAN2_TX_IRQHandler 1
../Core/Src/stm32f1xx_it.c:386:6:CAN2_RX1_IRQHandler 1
+5 -5
View File
@@ -1,5 +1,5 @@
../Core/Src/tim.c:31:6:MX_TIM3_Init 8
../Core/Src/tim.c:95:6:MX_TIM4_Init 8
../Core/Src/tim.c:157:6:HAL_TIM_Base_MspInit 3
../Core/Src/tim.c:187:6:HAL_TIM_MspPostInit 3
../Core/Src/tim.c:235:6:HAL_TIM_Base_MspDeInit 3
../Core/Src/tim.c:15:6:MX_TIM3_Init 8
../Core/Src/tim.c:79:6:MX_TIM4_Init 8
../Core/Src/tim.c:141:6:HAL_TIM_Base_MspInit 3
../Core/Src/tim.c:171:6:HAL_TIM_MspPostInit 3
../Core/Src/tim.c:219:6:HAL_TIM_Base_MspDeInit 3
+6 -6
View File
@@ -1,6 +1,6 @@
../Core/Src/usart.c:37:6:MX_UART5_Init 2
../Core/Src/usart.c:66:6:MX_USART1_UART_Init 2
../Core/Src/usart.c:95:6:MX_USART2_UART_Init 2
../Core/Src/usart.c:124:6:MX_USART3_UART_Init 2
../Core/Src/usart.c:152:6:HAL_UART_MspInit 9
../Core/Src/usart.c:349:6:HAL_UART_MspDeInit 5
../Core/Src/usart.c:21:6:MX_UART5_Init 2
../Core/Src/usart.c:50:6:MX_USART1_UART_Init 2
../Core/Src/usart.c:79:6:MX_USART2_UART_Init 2
../Core/Src/usart.c:108:6:MX_USART3_UART_Init 2
../Core/Src/usart.c:136:6:HAL_UART_MspInit 9
../Core/Src/usart.c:333:6:HAL_UART_MspDeInit 5
+2 -2
View File
@@ -69,8 +69,8 @@ all: main-build
main-build: CCSModuleSW30Web.elf secondary-outputs
# Tool invocations
CCSModuleSW30Web.elf CCSModuleSW30Web.map: $(OBJS) $(USER_OBJS) /Users/colorbass/STM32CubeIDE/workspace_1.12.0/fork/CCSModuleSW30Web/STM32F107VCTX_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS)
arm-none-eabi-gcc -o "CCSModuleSW30Web.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m3 -T"/Users/colorbass/STM32CubeIDE/workspace_1.12.0/fork/CCSModuleSW30Web/STM32F107VCTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="CCSModuleSW30Web.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -u _printf_float -Wl,--start-group -lc -lm -Wl,--end-group
CCSModuleSW30Web.elf CCSModuleSW30Web.map: $(OBJS) $(USER_OBJS) /Users/colorbass/STM32CubeIDE/workspace_1.12.0/CCSModuleSW30Web/STM32F107VCTX_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS)
arm-none-eabi-gcc -o "CCSModuleSW30Web.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m3 -T"/Users/colorbass/STM32CubeIDE/workspace_1.12.0/CCSModuleSW30Web/STM32F107VCTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="CCSModuleSW30Web.map" -Wl,--gc-sections -Wl,--no-warn-rwx-segments -static --specs=nano.specs -mfloat-abi=soft -mthumb -u _printf_float -Wl,--start-group -lc -lm -Wl,--end-group
@echo 'Finished building target: $@'
@echo ' '
-9
View File
@@ -1,9 +0,0 @@
MIT License
Copyright (c) 2024 EDISON
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+139 -3
View File
@@ -1,5 +1,141 @@
# GbTModuleSW
# CCSModuleSW30Web
Программное обеспечение для блока управления зарядом Gb/T
Прошивка контроллера DC-зарядного модуля на STM32F107 (STM32CubeIDE).
Проект реализует управление зарядной сессией, обработку состояния EV по CP-линии, управление силовым блоком через CAN и обмен с верхним уровнем по UART.
Git-репозиторий: https://git.141922.ru/EDISON/GbTModuleSW30Web
## Архитектура прошивки
Логика разделена на несколько уровней:
- Оркестрация и планировщик задач: `Core/Src/main.c`
- Состояния зарядной сессии и протокол с Everest: `Core/Src/serial.c`
- Управление силовой частью и контакторами: `Core/Src/psu_control.c`
- Обработка CP (PWM/состояние EV): `Core/Src/cp.c`
- Единая модель состояния коннектора: `Core/Src/charger_control.c`, `Core/Inc/charger_control.h`
- Локальный протокол управления/мониторинга: `Core/Src/serial_control.c`, `Core/Src/serial_handler.c`
- Низкоуровневое управление платой: `Core/Src/board.c`, `Core/Src/gpio.c`, `Core/Src/can.c`, `Core/Src/usart.c`
## Основной цикл и выполнение задач
`main()` инициализирует периферию и подсистемы (`CCS_Init`, `SC_Init`, `PSU_Init`, `CONN_Init`), после чего переходит в бесконечный цикл.
В основном цикле выполняются:
- `PSU_ReadWrite()` — цикл опроса/команд силового блока и расчёт целевых значений.
- `PSU_Task()` — state machine силовой части, включение/выключение контакторов, контроль аварий.
- `METER_CalculateEnergy()` — расчёт энергии.
- `CONN_Loop()` — консолидация ошибок и общих флагов состояния сессии.
- `LED_Write()` — применение рассчитанного состояния индикации.
Ключевой механизм: `ED_Delay()` используется как кооперативный мини-планировщик и внутри задержки вызывает:
- `CCS_SerialLoop()` — обмен с Everest и переходы состояния коннектора;
- `StopButtonControl()` — обработка кнопки STOP/FORCE UNLOCK/RESET;
- `CP_Loop()` — чтение и фильтрация состояния CP;
- `CONN_Task()` — управление индикацией/сигнализацией;
- `LED_Task()` — анимация RGB;
- `SC_Task()` — локальный UART-протокол.
Таким образом, даже во время "задержек" критичные сервисные задачи продолжают выполняться.
## Модель управления зарядной сессией
Центр логики сессии находится в `CCS_SerialLoop()` (`serial.c`).
Она работает как state machine EVSE-стороны и переводит систему между состояниями:
- неизвестное/инициализация,
- отсутствие автомобиля,
- требование авторизации,
- подключено/заряд,
- режим переподключения,
- отключено по команде или по таймауту связи.
Переходы определяются комбинацией факторов:
- текущее состояние CP (автомобиль не подключен/подключен/готов),
- команды внешней системы (`start`, `stop`, `force unlock`),
- разрешение выдачи мощности (`EnableOutput`),
- наличие ошибок в силовой части и контакторах,
- состояние обмена с Everest.
Структура `CONN` выступает как единый контейнер рабочего состояния сессии, где сводятся:
- требуемые напряжение/ток,
- разрешение на выдачу мощности,
- команда оператора (start/stop/unlock),
- текущая стадия сессии,
- ошибки коннектора/силовой части.
## CP-линия и взаимодействие с EV
`cp.c` отвечает за:
- генерацию PWM на CP-линии (`CP_SetDuty`),
- измерение уровня CP и преобразование в дискретное состояние EV,
- цифровую фильтрацию переходов состояния (`CP_FilterState`) для подавления дребезга.
Команды верхнего уровня могут менять duty CP, что влияет на допустимый ток/режим со стороны EV.
Результат фильтрации CP непосредственно используется в state machine сессии (`serial.c`).
## Силовая часть и контакторы
`psu_control.c` реализует state machine источника питания и цепи контакторов:
- инициализация и проверка готовности PSU;
- отправка уставок напряжения/тока;
- включение/выключение силовой части;
- ожидание подтверждений и контроль таймаутов;
- контроль обратной связи контактора;
- аварийный останов при несогласованности состояния.
Управление силовыми выходами выполняется через реле платы (`RELAY_AC`, `RELAY_DC`), а факт замыкания контролируется входом обратной связи контактора.
При неисправностях флаги `contactor_fault`/`psu_fault` поднимаются и транслируются в общую модель `CONN`, что блокирует дальнейшую выдачу мощности.
## Интерфейсы обмена
### UART3: канал к Everest
`serial.c` реализует пакетный обмен с CRC:
- приём команд, их валидация и применение к текущей сессии;
- отправка телеметрии/состояния с фиксированной периодикой;
- обработка ошибок UART и восстановление DMA-приёма.
Встроен watchdog канала: при потере связи сначала выдаётся предупреждение, затем выполняется защитный переход в безопасное состояние с остановкой выдачи мощности.
### UART2/UART5: локальное управление и мониторинг
`serial_control.c` и `serial_handler.c` реализуют отдельный локальный протокол:
- разбор пакетов и CRC32-проверка;
- команды чтения состояния/информации;
- команды управления (разрешение заряда, ограничение мощности, reset и т.д.);
- публикация телеметрии.
### CAN2: управление силовым источником
`psu_control.c` использует CAN2 для обмена с PSU:
- передача управляющих команд и уставок;
- запрос/получение телеметрии;
- обработка приёмных кадров в callback и обновление внутренних переменных состояния.
## Защиты и отказобезопасность
В прошивке заложены независимые защитные механизмы:
- E-STOP (короткое/долгое/очень долгое удержание): stop, force unlock, reset.
- Потеря обмена с Everest: автоматическая остановка зарядки и перевод в безопасное состояние.
- Контроль контактора: проверка соответствия команды и физической обратной связи.
- Таймауты включения/выключения PSU: переход в fault при отсутствии ожидаемого подтверждения.
- Фильтрация CP-переходов: исключение ложных переключений от помех.
## Где смотреть ключевую логику в первую очередь
Для быстрого входа в проект:
- `Core/Src/main.c` — архитектурный "скелет" и расписание вызовов.
- `Core/Src/serial.c` — главная state machine зарядной сессии.
- `Core/Src/psu_control.c` — силовая логика, контакторы, fault-handling.
- `Core/Src/cp.c` — физика CP и распознавание состояния EV.
- `Core/Src/serial_control.c` + `Core/Src/serial_handler.c` — локальный протокол управления.