From 688f925657e9eabfb9d104482dc59e1b480d4bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B7=E5=BA=8A=E5=B0=B1=E7=8A=AF=E5=9B=B0?= <11730503+psx123456@user.noreply.gitee.com> Date: Sat, 4 Jan 2025 17:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=B2=E5=8F=A3=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=96=B9=E5=BC=8F=E4=B8=BA=E7=8A=B6=E6=80=81=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 5 +- APP/businessLogic/Inc/SOE.h | 1 - APP/businessLogic/Inc/bl_usart.h | 44 + APP/businessLogic/Inc/cfg_protocol.h | 12 - APP/businessLogic/Inc/hy_protocol.h | 14 - APP/businessLogic/Inc/inFlash.h | 1 + APP/businessLogic/Inc/parameter.h | 3 +- APP/businessLogic/Inc/task.h | 4 +- APP/businessLogic/Src/SOE.c | 22 +- APP/businessLogic/Src/bl_usart.c | 679 +++++++ APP/businessLogic/Src/cfg_protocol.c | 422 ---- APP/businessLogic/Src/hy_protocol.c | 1925 ------------------- APP/businessLogic/Src/inFlash.c | 2 +- APP/businessLogic/Src/task.c | 246 +-- EWARM/chargeController.ewp | 2659 +++++++++++++------------- EWARM/chargeController.ewt | 8 +- tools/configParameter.h | 5 + 17 files changed, 2214 insertions(+), 3838 deletions(-) create mode 100644 APP/businessLogic/Inc/bl_usart.h delete mode 100644 APP/businessLogic/Inc/cfg_protocol.h delete mode 100644 APP/businessLogic/Inc/hy_protocol.h create mode 100644 APP/businessLogic/Src/bl_usart.c delete mode 100644 APP/businessLogic/Src/cfg_protocol.c delete mode 100644 APP/businessLogic/Src/hy_protocol.c diff --git a/.vscode/settings.json b/.vscode/settings.json index 6123606..e632179 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -35,6 +35,9 @@ "rtc.h": "c", "soe.h": "c", "hd_rtc.h": "c", - "flash.h": "c" + "flash.h": "c", + "configparameter.h": "c", + "usart.h": "c", + "w25qxx.h": "c" } } \ No newline at end of file diff --git a/APP/businessLogic/Inc/SOE.h b/APP/businessLogic/Inc/SOE.h index b60b8e3..094f337 100644 --- a/APP/businessLogic/Inc/SOE.h +++ b/APP/businessLogic/Inc/SOE.h @@ -15,5 +15,4 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode); - #endif diff --git a/APP/businessLogic/Inc/bl_usart.h b/APP/businessLogic/Inc/bl_usart.h new file mode 100644 index 0000000..e07cabb --- /dev/null +++ b/APP/businessLogic/Inc/bl_usart.h @@ -0,0 +1,44 @@ + +#ifndef BL_USART_H_ +#define BL_USART_H_ + + +#include "comm_types.h" +#include "chargControlTypes.h" +#include "uart_dev.h" + + + +/* SL协议读取寄存器最大地址 */ +#define maxReadRegAddrMacro 0x0120 +/* SL协议读取寄存器最小地址 */ +#define minReadRegAddrMacro 0x0100 +/* SL协议读取寄存器最大长度 */ +#define maxReadRegAddrNumMacro 10 + + +/* SL协议写入寄存器最大地址 */ +#define maxWriteRegAddrMacro 0x0120 +/* SL协议写入寄存器最小地址 */ +#define minWriteRegAddrMacro 0x0100 +/* SL协议写入寄存器最大长度 */ +#define maxWriteRegAddrNumMacro 10 + + +/* SL协议寄存器长度 */ +#define RegAddrNumMacro 32 + + + + + + + + +uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len); + +void gw485DataAnalysis(device_handle device); + + + +#endif diff --git a/APP/businessLogic/Inc/cfg_protocol.h b/APP/businessLogic/Inc/cfg_protocol.h deleted file mode 100644 index 9b2b562..0000000 --- a/APP/businessLogic/Inc/cfg_protocol.h +++ /dev/null @@ -1,12 +0,0 @@ - -#ifndef BL_CFG_PROTOCOL_H_ -#define BL_CFG_PROTOCOL_H_ - -#include "comm_types.h" - -void inConfigBuff(uint8_t c); -void zeroConfigBuff(void); -uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len); -void read_and_process_config_data(void); - -#endif diff --git a/APP/businessLogic/Inc/hy_protocol.h b/APP/businessLogic/Inc/hy_protocol.h deleted file mode 100644 index 033e08a..0000000 --- a/APP/businessLogic/Inc/hy_protocol.h +++ /dev/null @@ -1,14 +0,0 @@ - -#ifndef BL_HY_PROTOCOL_H_ -#define BL_HY_PROTOCOL_H_ - -#include "uart_dev.h" - -BOOL getHYconfigModeState(void); -void setHYconfigModeState(BOOL state); - -void HY_read_and_process_uart_data(device_handle device); - - - -#endif diff --git a/APP/businessLogic/Inc/inFlash.h b/APP/businessLogic/Inc/inFlash.h index 69d62e2..b27e8ee 100644 --- a/APP/businessLogic/Inc/inFlash.h +++ b/APP/businessLogic/Inc/inFlash.h @@ -5,6 +5,7 @@ #include "flash.h" #include "stm32g431xx.h" #include "chargControlTypes.h" +#include "bl_usart.h" #pragma pack(push, 1) diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h index b89530a..5419ed0 100644 --- a/APP/businessLogic/Inc/parameter.h +++ b/APP/businessLogic/Inc/parameter.h @@ -4,8 +4,7 @@ #include "main.h" #include "comm_types.h" #include "chargControlTypes.h" - -#define softVer "SV01_24101501" +#include "configParameter.h" // #pragma pack(push,1) diff --git a/APP/businessLogic/Inc/task.h b/APP/businessLogic/Inc/task.h index 73038a2..5bb6ca0 100644 --- a/APP/businessLogic/Inc/task.h +++ b/APP/businessLogic/Inc/task.h @@ -10,8 +10,8 @@ void task_Init(void); void beginStartControlTask(void); void beginSoftStartTask(void); -void beginHYconfigMode(void); -void uartTaskInit(void); +// void beginHYconfigMode(void); +// void uartTaskInit(void); void startShortCircuitProtection(void); void stopShortCircuitProtection(void); diff --git a/APP/businessLogic/Src/SOE.c b/APP/businessLogic/Src/SOE.c index 8088a79..0103d11 100644 --- a/APP/businessLogic/Src/SOE.c +++ b/APP/businessLogic/Src/SOE.c @@ -3,7 +3,7 @@ #include "stdio.h" #include "parameter.h" #include "FM_RTC.h" - +#include "flash.h" #define eventsOrderRecordStartAddr 4096 @@ -46,7 +46,7 @@ void eventsOrderRecordStartInit(void) soeInfo.outData = NULL; soeInfo.insertData = &soeInfo.data[soeInfo.insertPos]; - read_Flash((uint8_t *)(&soeParameters), sizeof(soeParameters)); + // read_Flash((uint8_t *)(&soeParameters), sizeof(soeParameters)); } /** @@ -72,35 +72,35 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode) } soeInfo.count--; - soeInfo.insertData->data.mode = mode; + soeInfo.insertData->mode = mode; getRTC_Time(&soeInfo.insertData->time); if (mode == firstStageProtection) { - soeInfo.insertData->data.temp = getDischargCurrent(); + soeInfo.insertData->temp = getDischargCurrent(); } else if (mode == secondStageProtection) { - soeInfo.insertData->data.temp = getDischargCurrent(); + soeInfo.insertData->temp = getDischargCurrent(); } else if (mode == thirdStageProtection) { - soeInfo.insertData->data.temp = getDischargCurrent(); + soeInfo.insertData->temp = getDischargCurrent(); } else if (mode == lowInputLoad) { - soeInfo.insertData->data.temp = getOutputVoltage(); + soeInfo.insertData->temp = getOutputVoltage(); } else if (mode == overTemperature) { - soeInfo.insertData->data.temp = getHighSideMosTemperature(); + soeInfo.insertData->temp = getHighSideMosTemperature(); } else if (mode == stopTemperature) { - soeInfo.insertData->data.temp = getHighSideMosTemperature(); + soeInfo.insertData->temp = getHighSideMosTemperature(); } else if (mode == overchargCurr) { - soeInfo.insertData->data.temp = getChargCurrent(); + soeInfo.insertData->temp = getChargCurrent(); } @@ -109,7 +109,7 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode) soeInfo.insertPos = 0; } - if (count <= 0) { + if (soeInfo.count <= 0) { soeInfo.insertData = NULL; } else { soeInfo.insertData = &soeInfo.data[soeInfo.insertPos]; diff --git a/APP/businessLogic/Src/bl_usart.c b/APP/businessLogic/Src/bl_usart.c new file mode 100644 index 0000000..2f4f750 --- /dev/null +++ b/APP/businessLogic/Src/bl_usart.c @@ -0,0 +1,679 @@ + +#include "bl_usart.h" +#include "parameter.h" +#include "chargControlTypes.h" +#include "configParameter.h" +#include "string.h" +#include "pDebug.h" + +typedef enum { + wait = 0, /* 串口状态机初始状态 */ + startFlagSL, /* 接收到SL帧头 */ + addressSL, /* 接收到设备地址 */ + functionCodeSL, /* 接收到SL功能码 */ + readRegStartAddressSL, /* 接收到SL读取寄存器起始地址 */ + readRegStartNumberSL, /* 接收到SL读取寄存器个数 */ + crcCheckBitSL, /* 接收到SL校验位 */ + endFlagSL, /* 接收到SL帧尾 */ + writeRegStartAddressSL, /* 接收到SL写入寄存器起始地址 */ + writeRegStartNumberSL, /* 接收到SL写入寄存器个数 */ + regLengthSL, /* 接收到SL寄存器长度 */ + regStatusSL, /* 接收到SL寄存器状态 */ + + +} uartStateMachine; + +/* 功能码 */ +typedef enum +{ + SL_Function_Code_Read_Register = 0x30, /* 读寄存器数据 */ + SL_Function_Code_Write_Register = 0x10, /* 写寄存器数据 */ + SL_Function_Code_Broadcast_Scan = 0xA0, /* 广播扫描 */ + SL_Function_Code_Registration_request = 0xA1, /* 注册请求 */ + SL_Function_Code_Distribution_Profile = 0xD0, /* 配置文件下发 */ + SL_Function_Code_Read_Profile = 0xD1, /* 配置文件读取 */ +}SL_MsgFunctionCode; + +#define gw485RxBufferSize 256 + +/* 计时参数,一秒后没解析出数据,丢掉当前数据 */ +static uint32_t gw485RxTime = 0; +/* 储存gw485数据 */ +static uint8_t gw485RxBuffer[gw485RxBufferSize]; +static uint16_t gw485RxBufferIndex = 0; +/* 状态机状态机变量 */ +static uartStateMachine state = wait; +static uint16_t frameLength = 0; + +static void stateMachine(device_handle device); + +/* 状态机函数 */ +static BOOL analysisWait(void); +static BOOL analysisStartFlagSL(void); +static BOOL analysisAddressSL(void); +static BOOL analysisFunctionCodeSL(void); +static BOOL analysisReadRegStartAddressSL(void); +static BOOL analysisReadRegStartNumberSL(void); +static BOOL analysisCrcCheckBitSL(void); +static void analysisEndFlagSL(device_handle device); +static BOOL analysisWriteRegStartAddressSL(void); +static BOOL analysisWriteRegStartNumberSL(void); +static BOOL analysisRegLengthSL(void); +static BOOL analysisRegStatusSL(void); + + +/* 解析出来指令对应函数 */ +static void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t MsgLen); +static void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t MsgLen); +static void SL_MsgProcFunc_Broadcast_Scan(device_handle device, void *pMsg, uint32_t MsgLen); +static void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint32_t MsgLen); +static void SL_MsgProcFunc_Distribution_Profile(device_handle device, void *pMsg, uint32_t MsgLen); +static void SL_MsgProcFunc_Read_Profile(device_handle device, void *pMsg, uint32_t MsgLen); + + + + +/** + * @brief modbus的crc校验 + * @param *arr_buff 需要校验的数据 + * len 数据长度 + * @retval crc 校验的结果 + */ +uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len) +{ + uint16_t crc = 0xFFFF; + uint16_t i, j; + for (j = 0; j < len; ++j) { + crc = crc ^ (*arr_buff++); + for (i = 0; i < 8; ++i) { + if ((crc&0x0001) > 0) { + crc = crc >> 1; + crc = crc ^ 0xa001; + } + else { + crc = crc >> 1; + } + } + } + return crc; +} + +/** + * @brief 状态机函数 + * @param + * @retval + */ +void stateMachine(device_handle device) +{ + if (state == wait) { + if (analysisWait() == TRUE) { + gw485RxTime = 0; + } + } + + else if (state == startFlagSL) { + analysisStartFlagSL(); + } + + else if (state == addressSL) { + analysisAddressSL(); + } + + else if (state == functionCodeSL) { + analysisFunctionCodeSL(); + } + + else if (state == readRegStartAddressSL) { + analysisReadRegStartAddressSL(); + } + + else if (state == readRegStartNumberSL) { + analysisReadRegStartNumberSL(); + } + + else if (state == crcCheckBitSL) { + analysisCrcCheckBitSL(); + } + + else if (state == endFlagSL) { + analysisEndFlagSL(device); + } + + else if (state == writeRegStartAddressSL) { + analysisWriteRegStartAddressSL(); + } + + else if (state == writeRegStartNumberSL) { + analysisWriteRegStartNumberSL(); + } + + else if (state == regLengthSL) { + analysisRegLengthSL(); + } + + else if (state == regStatusSL) { + analysisRegStatusSL(); + } +} + +void gw485DataAnalysis(device_handle device) +{ + /* 1S未解析出来一帧数据,将数据清零 */ + gw485RxTime++; + if (gw485RxTime == 10) { + gw485RxTime = 0; + gw485RxBufferIndex = 0; + state = wait; + } + + while (uart_dev_char_present(device) == 1) { + gw485RxBuffer[gw485RxBufferIndex++] = uart_dev_in_char(device); + stateMachine(device); + } + + stateMachine(device); +} + +/** + * @brief 状态 wait + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisWait(void) +{ + static uint16_t maxLen = 2; + + /* 解析SL协议的包头 */ + if (gw485RxBufferIndex >= 2) { + if (gw485RxBuffer[0] == 'S' && gw485RxBuffer[1] == 'L') { + state = startFlagSL; + return TRUE; + } + } + + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 StartFlagSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisStartFlagSL(void) +{ + static uint16_t maxLen = 9; + + /* 解析SL协议设备地址 */ + if (gw485RxBufferIndex >= 9) { + if (gw485RxBuffer[2] == g_cfgParameter.address[0] + && gw485RxBuffer[3] == g_cfgParameter.address[1] + && gw485RxBuffer[4] == g_cfgParameter.address[2] + && gw485RxBuffer[5] == g_cfgParameter.address[3] + && gw485RxBuffer[6] == g_cfgParameter.address[4] + && gw485RxBuffer[7] == g_cfgParameter.address[5] + && gw485RxBuffer[8] == g_cfgParameter.address[6]) { + state = addressSL; + return TRUE; + } + + if (gw485RxBuffer[2] == 0xFF + && gw485RxBuffer[3] == 0xFF + && gw485RxBuffer[4] == 0xFF + && gw485RxBuffer[5] == 0xFF + && gw485RxBuffer[6] == 0xFF + && gw485RxBuffer[7] == 0xFF + && gw485RxBuffer[8] == 0xFF) { + state = addressSL; + return TRUE; + } + } + + + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 addressSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisAddressSL(void) +{ + static uint16_t maxLen = 10; + + /* 解析SL功能码 */ + if (gw485RxBufferIndex >= 10) { + /* 判断地址是否为广播ID */ + uint8_t temp = 0; + if (gw485RxBuffer[2] == 0xFF + && gw485RxBuffer[3] == 0xFF + && gw485RxBuffer[4] == 0xFF + && gw485RxBuffer[5] == 0xFF + && gw485RxBuffer[6] == 0xFF + && gw485RxBuffer[7] == 0xFF + && gw485RxBuffer[8] == 0xFF) { + temp = 1; + } else { + temp = 0; + } + + /* 判断功能码类型 */ + if (temp == 0) { + if (gw485RxBuffer[9] == SL_Function_Code_Read_Register + || gw485RxBuffer[9] == SL_Function_Code_Write_Register + || gw485RxBuffer[9] == SL_Function_Code_Registration_request + || gw485RxBuffer[9] == SL_Function_Code_Distribution_Profile + || gw485RxBuffer[9] == SL_Function_Code_Read_Profile ) { + + state = functionCodeSL; + return TRUE; + } + } + else { + if (gw485RxBuffer[9] == SL_Function_Code_Broadcast_Scan) { + state = functionCodeSL; + frameLength = 13; + return TRUE; + } + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 functionCodeSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisFunctionCodeSL(void) +{ + static uint16_t maxLen = 12; + + /* 解析读取寄存器起始位置 */ + if ((gw485RxBufferIndex >= 12) && (gw485RxBuffer[9] == SL_Function_Code_Read_Register)) { + uint32_t tempAddrStart = 0; + tempAddrStart = (gw485RxBuffer[10] << 8) | gw485RxBuffer[11]; + + if (tempAddrStart >= minReadRegAddrMacro && tempAddrStart <= maxReadRegAddrMacro) { + state = readRegStartAddressSL; + return TRUE; + } + } + + /* 解析写入寄存器起始位置 */ + if ((gw485RxBufferIndex >= 12) && (gw485RxBuffer[9] == SL_Function_Code_Write_Register)) { + uint32_t tempAddrStart = 0; + tempAddrStart = (gw485RxBuffer[10] << 8) | gw485RxBuffer[11]; + + if (tempAddrStart >= minWriteRegAddrMacro && tempAddrStart <= maxWriteRegAddrMacro) { + state = writeRegStartAddressSL; + return TRUE; + } + } + + /* 解析扫描广播帧crc校验 */ + if ((gw485RxBufferIndex >= 12) && (gw485RxBuffer[9] == SL_Function_Code_Broadcast_Scan)) { + uint32_t tempCrc = 0; + tempCrc = (gw485RxBuffer[frameLength - 3] << 8) | gw485RxBuffer[frameLength - 2]; + if (tempCrc == checkModebusCrc(gw485RxBuffer, frameLength - 3)) { + state = crcCheckBitSL; + return TRUE; + } + log_info("tempCrc:%d", tempCrc); + log_info("checkModebusCrc:%d", checkModebusCrc(gw485RxBuffer, frameLength - 3)); + } + + + /* 解析注册回复帧寄存器长度 */ + if ((gw485RxBufferIndex >= 12) && (gw485RxBuffer[9] == SL_Function_Code_Registration_request)) { + uint32_t tempRegLen = 0; + tempRegLen = (gw485RxBuffer[10] << 8) | gw485RxBuffer[11]; + + if (tempRegLen < RegAddrNumMacro && tempRegLen > 0) { + state = regLengthSL; + frameLength = 17; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 readRegStartAddressSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisReadRegStartAddressSL(void) +{ + static uint16_t maxLen = 12; + + /* 解析读取寄存器长度 */ + if (gw485RxBufferIndex >= 14) { + uint32_t tempAddrNumber = 0; + tempAddrNumber = (gw485RxBuffer[12] << 8) | gw485RxBuffer[13]; + + if (tempAddrNumber >= 1 && tempAddrNumber <= maxReadRegAddrNumMacro) { + state = readRegStartNumberSL; + frameLength = 17; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 readRegStartNumberSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisReadRegStartNumberSL(void) +{ + static uint16_t maxLen = 16; + + /* crc校验 */ + if (gw485RxBufferIndex >= 16) { + uint32_t tempCrc = 0; + tempCrc = (gw485RxBuffer[14] << 8) | gw485RxBuffer[15]; + + if (tempCrc == checkModebusCrc(gw485RxBuffer, 14)) { + state = crcCheckBitSL; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 crcCheckBitSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisCrcCheckBitSL(void) +{ + /* 结束标志校验校验 */ + if (gw485RxBufferIndex == frameLength) { + if (gw485RxBuffer[frameLength - 1] == 0x16) { + state = endFlagSL; + return TRUE; + } + } + + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 endFlagSL + * @param device 串口设备 + * @retval TRUE:解析成功 FALSE:解析失败 + */ +void analysisEndFlagSL(device_handle device) +{ + /* 数据为读取寄存器 */ + if (gw485RxBuffer[9] == SL_Function_Code_Read_Register) { + SL_MsgProcFunc_Read_Register(device, gw485RxBuffer, frameLength); + } + + /* 数据为写入寄存器 */ + else if (gw485RxBuffer[9] == SL_Function_Code_Write_Register) { + SL_MsgProcFunc_Write_Register(device, gw485RxBuffer, frameLength); + } + + /* 数据为扫描广播帧 */ + else if (gw485RxBuffer[9] == SL_Function_Code_Broadcast_Scan) { + SL_MsgProcFunc_Broadcast_Scan(device, gw485RxBuffer, frameLength); + } + + /* 数据为注册回复帧 */ + else if (gw485RxBuffer[9] == SL_Function_Code_Registration_request) { + SL_MsgProcFunc_Registration_request(device, gw485RxBuffer, frameLength); + } + + /* 数据为下发配置文件 */ + else if (gw485RxBuffer[9] == SL_Function_Code_Distribution_Profile) { + SL_MsgProcFunc_Distribution_Profile(device, gw485RxBuffer, frameLength); + } + + /* 数据为读取配置文件 */ + else if (gw485RxBuffer[9] == SL_Function_Code_Read_Profile) { + SL_MsgProcFunc_Read_Profile(device, gw485RxBuffer, frameLength); + } + + state = wait; + gw485RxBufferIndex = 0; + // memcpy(gw485RxBuffer, gw485RxBuffer + gw485RxBufferIndex, ); +} + +/** + * @brief 状态 writeRegStartAddressSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisWriteRegStartAddressSL(void) +{ + static uint16_t maxLen = 14; + + /* 解析写入寄存器长度 */ + if (gw485RxBufferIndex >= 14) { + uint32_t tempAddrNumber = 0; + tempAddrNumber = (gw485RxBuffer[12] << 8) | gw485RxBuffer[13]; + + if (tempAddrNumber >= 1 && tempAddrNumber <= maxWriteRegAddrNumMacro) { + state = writeRegStartNumberSL; + frameLength = 17 + tempAddrNumber * 2; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 writeRegStartNumberSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisWriteRegStartNumberSL(void) +{ + static uint16_t maxLen = 16; + /* crc校验 */ + if (gw485RxBufferIndex >= 16) { + uint32_t tempCrc = 0; + tempCrc = (gw485RxBuffer[frameLength - 3] << 8) | gw485RxBuffer[frameLength - 2]; + + if (tempCrc == checkModebusCrc(gw485RxBuffer, frameLength - 3)) { + state = crcCheckBitSL; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 regLengthSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisRegLengthSL(void) +{ + static uint16_t maxLen = 12; + /* crc校验 */ + if (gw485RxBufferIndex >= 12) { + uint32_t tempRegStatus = 0; + tempRegStatus = (gw485RxBuffer[12] << 8) | gw485RxBuffer[13]; + + if (tempRegStatus == UNREGISTER + || tempRegStatus == REGISTER_FAIL + || tempRegStatus == REGISTER_SUCCESS) { + state = regStatusSL; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + +/** + * @brief 状态 regStatusSL + * @param + * @retval TRUE:解析成功 FALSE:解析失败 + */ +BOOL analysisRegStatusSL(void) +{ + static uint16_t maxLen = 16; + /* crc校验 */ + if (gw485RxBufferIndex >= 16) { + uint32_t tempCrc = 0; + tempCrc = (gw485RxBuffer[frameLength - 3] << 8) | gw485RxBuffer[frameLength - 2]; + + if (tempCrc == checkModebusCrc(gw485RxBuffer, frameLength - 3)) { + state = crcCheckBitSL; + return TRUE; + } + } + + if (gw485RxBufferIndex < maxLen) { + return FALSE; + } + state = wait; + gw485RxBufferIndex--; + memcpy(gw485RxBuffer, gw485RxBuffer + 1, gw485RxBufferIndex); + return FALSE; +} + + +/** + * @brief 赛联协议读取寄存器 + * @param device 串口设备 + * pMsg 数据内容 + * MsgLen 数据长度 + * @retval + */ +void SL_MsgProcFunc_Read_Register(device_handle device, void *pMsg, uint32_t MsgLen) +{ + debug_printf("SL_MsgProcFunc_Read_Register\n"); +} + +/** + * @brief 赛联协议写入寄存器 + * @param device 串口设备 + * pMsg 数据内容 + * MsgLen 数据长度 + * @retval + */ +void SL_MsgProcFunc_Write_Register(device_handle device, void *pMsg, uint32_t MsgLen) +{ + debug_printf("SL_MsgProcFunc_Write_Register\n"); +} + +/** + * @brief 赛联协议扫描广播帧 + * @param device 串口设备 + * pMsg 数据内容 + * MsgLen 数据长度 + * @retval + */ +void SL_MsgProcFunc_Broadcast_Scan(device_handle device, void *pMsg, uint32_t MsgLen) +{ + debug_printf("SL_MsgProcFunc_Broadcast_Scan\n"); +} + +/** + * @brief 赛联协议写入寄存器 + * @param device 串口设备 + * pMsg 数据内容 + * MsgLen 数据长度 + * @retval + */ +void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint32_t MsgLen) +{ + debug_printf("SL_MsgProcFunc_Registration_request\n"); +} + +/** + * @brief 赛联协议写入配置文件 + * @param device 串口设备 + * pMsg 数据内容 + * MsgLen 数据长度 + * @retval + */ +void SL_MsgProcFunc_Distribution_Profile(device_handle device, void *pMsg, uint32_t MsgLen) +{ + debug_printf("SL_MsgProcFunc_Distribution_Profile\n"); +} + +/** + * @brief 赛联协议读取配置文件 + * @param device 串口设备 + * pMsg 数据内容 + * MsgLen 数据长度 + * @retval + */ +void SL_MsgProcFunc_Read_Profile(device_handle device, void *pMsg, uint32_t MsgLen) +{ + debug_printf("SL_MsgProcFunc_Read_Profile\n"); +} \ No newline at end of file diff --git a/APP/businessLogic/Src/cfg_protocol.c b/APP/businessLogic/Src/cfg_protocol.c deleted file mode 100644 index 0b5b05a..0000000 --- a/APP/businessLogic/Src/cfg_protocol.c +++ /dev/null @@ -1,422 +0,0 @@ - -#include "cfg_protocol.h" -#include "uart_dev.h" -#include "inFlash.h" -#include "parameter.h" -#include "string.h" -#include "chargControlTypes.h" -#include "pDebug.h" - -#define cfgBuffLen 200 -static uint8_t configBuff[cfgBuffLen]; -static uint8_t cfigLen = 0; - -/* 配置文件中的部分数据放大倍数 */ -#define enlargeScale 100 - -/** - * @brief 向配置文件buff中存入一个数据 - * @param c 数据 - * @retval - * - */ -void inConfigBuff(uint8_t c) -{ - if (cfigLen < cfgBuffLen) { - configBuff[cfigLen] = c; - cfigLen++; - } -} - -/** - * @brief 向配置文件buff中丢掉一个数据 - * @param - * @retval - * - */ -void outConfigBuff(void) -{ - if (cfigLen > 0) { - cfigLen--; - memcpy(configBuff, configBuff + 1, cfigLen); - // memcpy(configBuff, configBuff + 1, sizeof(configBuff) - 1); - } -} - -/** - * @brief modbus的crc校验 - * @param *arr_buff 需要校验的数据 - * len 数据长度 - * @retval crc 校验的结果 - */ -uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len) -{ - uint16_t crc = 0xFFFF; - uint16_t i, j; - for (j = 0; j < len; ++j) { - crc = crc ^ (*arr_buff++); - for (i = 0; i < 8; ++i) { - if ((crc&0x0001) > 0) { - crc = crc >> 1; - crc = crc ^ 0xa001; - } - else { - crc = crc >> 1; - } - } - } - return crc; -} - -/** - * @brief 清空配置文件buff - * @param - * @retval - * - */ -void zeroConfigBuff(void) -{ - cfigLen = 0; -} - -/** - * @brief 判断接收到的配置文件数据是否正确,正确的话存入flash中 - * @param None - * @retval None - * - */ -void read_and_process_config_data(void) -{ - static config_info save_configInfo = {0}; - recv_config_info *pack = (recv_config_info *)configBuff; - while (cfigLen >= RECV_CONFIG_INFO) { - /* 判断起始标志是否正确 */ - // debug_printf(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]); - if (pack->start_Flag[0] != g_cfgParameter.startFlagSL[0] - || pack->start_Flag[1] != g_cfgParameter.startFlagSL[1]) { - debug(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]); - goto err; - } - -// /* 判断接入节点类型是否正确 */ -// save_configInfo.Access_Node_Type = (uint16_t)pack->Access_Node_Type[0] << 8 -// | (uint16_t)pack->Access_Node_Type[1]; -// if (save_configInfo.Access_Node_Type != POWERBOX) { -// // debug(" Access_Node_Type : 0x%x \n", save_configInfo.Access_Node_Type); -// goto err; -// } - -// /* 判断通信方式是否正确 */ -// save_configInfo.Communication_Methods = (uint16_t)pack->Communication_Methods[0] << 8 -// | (uint16_t)pack->Communication_Methods[1]; -// // if (temp_u16 != RS485 || temp_u16 != RJ45) { -// if (save_configInfo.Communication_Methods != RS485) { -// debug(" Communication_Methods : 0x%x \n", save_configInfo.Communication_Methods); -// goto err; -// } - - /* 判断波特率是否正确 */ - save_configInfo.gw485_Baud = (uint32_t)pack->gw485_Baud[0] << 24 - | (uint32_t)pack->gw485_Baud[1] << 16 - | (uint32_t)pack->gw485_Baud[2] << 8 - | (uint32_t)pack->gw485_Baud[3]; -// debug(" gw485_Baud : 0x%x, %d \n", save_configInfo.gw485_Baud, save_configInfo.gw485_Baud); - if (save_configInfo.gw485_Baud != 9600 - && save_configInfo.gw485_Baud != 115200) { - debug(" gw485_Baud : %d\n", save_configInfo.gw485_Baud); - goto err; - } - - save_configInfo.bat485_Baud = (uint32_t)pack->bat485_Baud[0] << 24 - | (uint32_t)pack->bat485_Baud[1] << 16 - | (uint32_t)pack->bat485_Baud[2] << 8 - | (uint32_t)pack->bat485_Baud[3]; - if (save_configInfo.bat485_Baud != 9600 - && save_configInfo.bat485_Baud!= 115200 - && save_configInfo.bat485_Baud!= 0) { - debug(" bat485_Baud : 0x%x, %d \n", save_configInfo.bat485_Baud, save_configInfo.bat485_Baud); - goto err; - } - - /* 判断汇源协议类型是否正确 */ - if (pack->protocolType != 0x01 && pack->protocolType != 0x02) { - debug(" protocolType : 0x%x \n", pack->protocolType); - goto err; - } - - /* 判断通信协议类型是否正确 */ - if (pack->CommunicationProtocolType != 0x00 - && pack->CommunicationProtocolType != 0x01) { - debug(" CommunicationProtocolType : 0x%x \n", pack->CommunicationProtocolType); - goto err; - } - - - /* 判断电源盒类型是否正确 */ - if (pack->onlyPower != 0x00 && pack->onlyPower != 0x01) { - debug(" onlyPower : 0x%x \n", pack->onlyPower); - goto err; - } - - /* 判断恒压充电阈值是否正确 */ - save_configInfo.constantVoltageV = - (float)(pack->ConstantVoltageV[0] << 8 | pack->ConstantVoltageV[1]) / enlargeScale; - if (!((save_configInfo.constantVoltageV < 14.4f && save_configInfo.constantVoltageV > 13.5f) - || save_configInfo.constantVoltageV == 0)) { - debug(" constantVoltageV : %f \n", save_configInfo.constantVoltageV); - goto err; - } - - /* 判断浮充充电阈值是否正确 */ - save_configInfo.floatI = (float)(pack->FloatI[0] << 8 | pack->FloatI[1]) / enlargeScale; - if (save_configInfo.floatI > 0.2f || save_configInfo.floatI < 0) { - debug(" floatI : %f \n", save_configInfo.floatI); - goto err; - } - - /* 判断太阳能板开路启动电压是否正确 */ - save_configInfo.startSolarOpenCircuitV = - (float)(pack->startSolarOpenCircuitV[0] << 8 | pack->startSolarOpenCircuitV[1]) / enlargeScale; - if (!((save_configInfo.startSolarOpenCircuitV < 24 && save_configInfo.startSolarOpenCircuitV > 14) - || save_configInfo.startSolarOpenCircuitV == 0)) { - debug(" startSolarOpenCircuitV : %f \n", save_configInfo.startSolarOpenCircuitV); - goto err; - } - - /* 判断太阳能板关闭电压是否正确 */ - save_configInfo.stopSolarOpenCircuitV = - (float)(pack->stopSolarOpenCircuitV[0] << 8 | pack->stopSolarOpenCircuitV[1]) / enlargeScale; - if (!((save_configInfo.stopSolarOpenCircuitV < 17 && save_configInfo.stopSolarOpenCircuitV > 13) - || save_configInfo.stopSolarOpenCircuitV == 0)) { - debug(" stopSolarOpenCircuitV : %f \n", save_configInfo.stopSolarOpenCircuitV); - goto err; - } - - /* 判断恒压充电时的输出电压是否正确 */ - save_configInfo.constantVoltageChargeV = - (float)(pack->constantVoltageChargeV[0] << 8 | pack->constantVoltageChargeV[1]) / enlargeScale; - if (!((save_configInfo.constantVoltageChargeV < 14.6f && save_configInfo.constantVoltageChargeV > 14) - || save_configInfo.constantVoltageChargeV == 0)) { - debug(" constantVoltageChargeV : %f \n", save_configInfo.constantVoltageChargeV); - goto err; - } - - /* 判断浮充充电时的输出电压是否正确 */ - save_configInfo.FloatChargeV = - (float)(pack->FloatChargeV[0] << 8 | pack->FloatChargeV[1]) / enlargeScale; - if (!((save_configInfo.FloatChargeV < 14.4f && save_configInfo.FloatChargeV > 13.8f) - || save_configInfo.FloatChargeV == 0)) { - debug(" FloatChargeV : %f \n", save_configInfo.FloatChargeV); - goto err; - } - - /* 判断mos管停止工作温度是否正确 */ - save_configInfo.HighSideMosTemperature_stop = - (float)(pack->HighSideMosTemperature_stop[0] << 8 | pack->HighSideMosTemperature_stop[1]) / enlargeScale; - if (save_configInfo.HighSideMosTemperature_stop < 50 && save_configInfo.HighSideMosTemperature_stop != 0) { - debug(" HighSideMosTemperature_stop : %f \n", save_configInfo.HighSideMosTemperature_stop); - goto err; - } - - /* 判断mos管降低工作功率工作温度是否正确 */ - save_configInfo.HighSideMosTemperature_end = - (float)(pack->HighSideMosTemperature_end[0] << 8 | pack->HighSideMosTemperature_end[1]) / enlargeScale; - if (save_configInfo.HighSideMosTemperature_end < 40 && save_configInfo.HighSideMosTemperature_end != 0) { - debug(" HighSideMosTemperature_end : %f \n", save_configInfo.HighSideMosTemperature_end); - goto err; - } - - /* 判断mos管完全恢复工作温度是否正确 */ - save_configInfo.HighSideMosTemperature_start = - (float)(pack->HighSideMosTemperature_start[0] << 8 | pack->HighSideMosTemperature_start[1]) / enlargeScale; - if (save_configInfo.HighSideMosTemperature_start > 70 && save_configInfo.HighSideMosTemperature_start != 0) { - debug(" HighSideMosTemperature_start : %d \n", save_configInfo.HighSideMosTemperature_start); - goto err; - } - - // /* 判断启动任务中太阳能板开路电压检测间隔时间是否正确 */ - // save_configInfo.checkSolarOpenCircuitVTime = - // pack->checkSolarOpenCircuitVTime[0] << 8 | pack->checkSolarOpenCircuitVTime[1]; - // if (save_configInfo.checkSolarOpenCircuitVTime > 1800 || save_configInfo.checkSolarOpenCircuitVTime < 5) { - // debug(" checkSolarOpenCircuitVTime : %d \n", save_configInfo.checkSolarOpenCircuitVTime); - // goto err; - // } - - // /* 判断传感器运行再次注册的间隔是否正确 */ - // save_configInfo.sensorEnableBroadcastTime = - // pack->sensorEnableBroadcastTime[0] << 8 | pack->sensorEnableBroadcastTime[1]; - // if (save_configInfo.sensorEnableBroadcastTime > 60 || save_configInfo.sensorEnableBroadcastTime < 10) { - // debug(" sensorEnableBroadcastTime : %d \n", save_configInfo.sensorEnableBroadcastTime); - // goto err; - // } - - /* 判断出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出的间隔是否正确 */ - save_configInfo.outputAgainFlagTime = - pack->outputAgainFlagTime[0] << 8 | pack->outputAgainFlagTime[1]; - if (!((save_configInfo.outputAgainFlagTime < 30 && save_configInfo.outputAgainFlagTime > 5) - || save_configInfo.outputAgainFlagTime == 0)) { - debug(" outputAgainFlagTime : %d \n", save_configInfo.outputAgainFlagTime); - goto err; - } - - /* 判断出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出的间隔是否正确 */ - save_configInfo.excessiveLoadFlagTime = - pack->excessiveLoadFlagTime[0] << 8 | pack->excessiveLoadFlagTime[1]; - if (!((save_configInfo.excessiveLoadFlagTime < 90 && save_configInfo.excessiveLoadFlagTime > 20) - || save_configInfo.excessiveLoadFlagTime == 0)) { - debug(" excessiveLoadFlagTime : %d \n", save_configInfo.excessiveLoadFlagTime); - goto err; - } - - /* 判断出现过载过载保护后,在该间隔段时间后,再次尝试输出的间隔是否正确 */ - save_configInfo.eLAgainTime = pack->eLAgainTime[0] << 8 | pack->eLAgainTime[1]; - if (save_configInfo.eLAgainTime > 3000 || save_configInfo.eLAgainTime < 1000) { - debug(" eLAgainTime : %d \n", save_configInfo.eLAgainTime); - goto err; - } - - /* crc校验 */ - save_configInfo.crc = pack->crc[0] << 8 | pack->crc[1]; - if (save_configInfo.crc != checkModebusCrc(configBuff, RECV_CONFIG_INFO - 3)) { - debug(" crc : %x%x \n", pack->crc[0], pack->crc[1]); - debug(" checkModebusCrc : %x \n", checkModebusCrc(configBuff, RECV_CONFIG_INFO)); - goto err; - } - - - /* 结束标志 */ - if (pack->end_Flag != 0x16) { - debug(" end_Flag : %x \n", pack->end_Flag); - goto err; - } - -// debug("address : 0x %x %x %x %x %x %x %x\n", pack->address[0] -// , pack->address[1], pack->address[2], pack->address[3] -// , pack->address[4], pack->address[5], pack->address[6]); - config_info temp_configInfo; - read_config_info(&temp_configInfo); - - if (pack->address[0] != 0xFF - || pack->address[1] != 0xFF - || pack->address[2] != 0xFF - || pack->address[3] != 0xFF - || pack->address[4] != 0xFF - || pack->address[5] != 0xFF - || pack->address[6] != 0xFF) { - save_configInfo.address[0] = pack->address[0]; - save_configInfo.address[1] = pack->address[1]; - save_configInfo.address[2] = pack->address[2]; - save_configInfo.address[3] = pack->address[3]; - save_configInfo.address[4] = pack->address[4]; - save_configInfo.address[5] = pack->address[5]; - save_configInfo.address[6] = pack->address[6]; -// debug("address : 0x %x %x %x %x %x %x %x\n", save_configInfo.address[0] -// , save_configInfo.address[1], save_configInfo.address[2], save_configInfo.address[3] -// , save_configInfo.address[4], save_configInfo.address[5], save_configInfo.address[6]); - } else { - save_configInfo.address[0] = temp_configInfo.address[0]; - save_configInfo.address[1] = temp_configInfo.address[1]; - save_configInfo.address[2] = temp_configInfo.address[2]; - save_configInfo.address[3] = temp_configInfo.address[3]; - save_configInfo.address[4] = temp_configInfo.address[4]; - save_configInfo.address[5] = temp_configInfo.address[5]; - save_configInfo.address[6] = temp_configInfo.address[6]; - } - - if (pack->hardwareID[0] != 0xFF - || pack->hardwareID[1] != 0xFF - || pack->hardwareID[2] != 0xFF - || pack->hardwareID[3] != 0xFF - || pack->hardwareID[4] != 0xFF - || pack->hardwareID[5] != 0xFF) { - save_configInfo.hardwareID[0] = pack->hardwareID[0]; - save_configInfo.hardwareID[1] = pack->hardwareID[1]; - save_configInfo.hardwareID[2] = pack->hardwareID[2]; - save_configInfo.hardwareID[3] = pack->hardwareID[3]; - save_configInfo.hardwareID[4] = pack->hardwareID[4]; - save_configInfo.hardwareID[5] = pack->hardwareID[5]; - } else { - save_configInfo.hardwareID[0] = temp_configInfo.hardwareID[0]; - save_configInfo.hardwareID[1] = temp_configInfo.hardwareID[1]; - save_configInfo.hardwareID[2] = temp_configInfo.hardwareID[2]; - save_configInfo.hardwareID[3] = temp_configInfo.hardwareID[3]; - save_configInfo.hardwareID[4] = temp_configInfo.hardwareID[4]; - save_configInfo.hardwareID[5] = temp_configInfo.hardwareID[5]; - } - - if (pack->communicationID[0] != 0xFF - || pack->communicationID[1] != 0xFF - || pack->communicationID[2] != 0xFF - || pack->communicationID[3] != 0xFF) { - save_configInfo.communicationID[0] = pack->communicationID[0]; - save_configInfo.communicationID[1] = pack->communicationID[1]; - save_configInfo.communicationID[2] = pack->communicationID[2]; - save_configInfo.communicationID[3] = pack->communicationID[3]; - } else { - save_configInfo.communicationID[0] = temp_configInfo.communicationID[0]; - save_configInfo.communicationID[1] = temp_configInfo.communicationID[1]; - save_configInfo.communicationID[2] = temp_configInfo.communicationID[2]; - save_configInfo.communicationID[3] = temp_configInfo.communicationID[3]; - } - - save_configInfo.protocolType = pack->protocolType; - - save_configInfo.CommunicationProtocolType = pack->CommunicationProtocolType; - - save_configInfo.onlyPower = pack->onlyPower; - - - save_configInfo.crc = checkModebusCrc((uint8_t *)&save_configInfo, CONFIG_INFO_SIZE - 2); - // save_backups_config_info(&save_configInfo); - // save_config_info(&save_configInfo); - saveConfigInfo(&save_configInfo); - - // memset(config_buff, 0, sizeof(config_buff)); - zeroConfigBuff(); - - // /* 返回更改配置文件成功 */ - // SL_Mppt_SOther_pack SUpdateProfile_pack = {0}; - - // SUpdateProfile_pack.start_Flag[0] = g_otherParameter.startFlagSL[0]; - // SUpdateProfile_pack.start_Flag[1] = g_otherParameter.startFlagSL[1]; - - // SUpdateProfile_pack.address[0] = save_configInfo.address[0]; - // SUpdateProfile_pack.address[1] = save_configInfo.address[1]; - // SUpdateProfile_pack.address[2] = save_configInfo.address[2]; - // SUpdateProfile_pack.address[3] = save_configInfo.address[3]; - // SUpdateProfile_pack.address[4] = save_configInfo.address[4]; - // SUpdateProfile_pack.address[5] = save_configInfo.address[5]; - // SUpdateProfile_pack.address[6] = save_configInfo.address[6]; - - // SUpdateProfile_pack.function_Code = SL_Function_Code_Update_Profile; - - // SUpdateProfile_pack.state = 0x01; - - // uint16_t crc = CheckFuncSL((uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE - 3); - // SUpdateProfile_pack.check_Bit_H = crc >> 8; - // SUpdateProfile_pack.check_Bit_L = crc; - - // SUpdateProfile_pack.end_Flag = g_otherParameter.endFlagSL; - - // while (1) { - // if (!Check_485_bus_busy(g_gw485_uart4_handle)) { - // uart_dev_write(g_gw485_uart4_handle, (uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE); - // USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); - // break; - // } - // Delay_Ms(randomDelay()); - // } - uart_dev_write(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n")); - - HAL_Delay(1000); - - /* 复位 */ - NVIC_SystemReset(); - - err: - // config_buff_pos--; - // memcpy(config_buff, config_buff + 1, sizeof(config_buff) - 1); - outConfigBuff(); - } -} - diff --git a/APP/businessLogic/Src/hy_protocol.c b/APP/businessLogic/Src/hy_protocol.c deleted file mode 100644 index 37f7067..0000000 --- a/APP/businessLogic/Src/hy_protocol.c +++ /dev/null @@ -1,1925 +0,0 @@ - -#include - -#include "hy_protocol.h" -#include "pDebug.h" -#include "comm_types.h" -#include "parameter.h" -#include "cfg_protocol.h" -#include "inFlash.h" -#include "bl_chargControl.h" -#include "bl_comm.h" -#include "chargControlTypes.h" -#include "FM_RTC.h" -#include "interruptSend.h" - - -// #include "RingQueue.h" - -// 声明 beginHYconfigMode 函数 -extern void beginHYconfigMode(void); - -static BOOL HYconfigModeState = FALSE; - -/* 功能码 */ -typedef enum -{ - HY_batteryStatus = 0x60, /* 电池状态数据报 */ - HY_electricityStatistics = 0x61, /* 电量统计数据报 */ - HY_sensorNumberConfiguration = 0x62, /* 传感器号码配置 */ - HY_sensorNumberInquiry = 0x63, /* 传感器号码查询 */ - HY_chargingThresholdVoltageConfiguration = 0x64, /* 充电阈值电压配置 */ - HY_chargingRangeVoltageQuery = 0x65, /* 充电域值电压查询 */ - HY_resetInstruction = 0x66, /* 复位指令 */ - - HY_chargingControlConfiguration = 0x6C, /* 充电控制配置 */ - HY_chargingControlQuery = 0x6D, /* 充电控制查询 */ - HY_configurationTime = 0x6E, /* 配置时间 */ - HY_queryTime = 0x6F, /* 查询时间 */ - - HY_configureProtocolType = 0x70, /* 配置协议类型 */ - HY_responseConfigureProtocolType = 0x71, /* 响应配置协议类型 */ - - HY_queryControlBoxConfiguration = 0x74, /* 查询电池控制盒当前配置 */ - HY_querySoftwareVersion = 0x75, /* 查询电池控制盒软件版本 */ - HY_enterConfigurationMode = 0x76, /* 进入配置模式 */ - - HY_configureHardwareID = 0x7B, /* 配置控制盒硬件ID号 */ - HY_hardwareID_communicationIDQuery = 0x7C, /* 控制盒硬件ID号及通信ID号(原传感器号)查询 */ - HY_modifyCommunicationID = 0x7D, /* 修改通信ID号(原传感器号) */ - HY_checkMotherboardTemperature = 0x7E, /* 查询主板温度值 */ - -}HY_MsgFunctionCode; - - -/* 解析数据包的长度 */ -typedef enum -{ - HY_analyzeStartFlag = 1, /* 长度为1时解析起始标志 */ - HY_analyzeHardwareID = 7, /* 长度为7时解析硬件ID */ - HY_analyzeCommunicationID = 11, /* 长度为10时解析通信ID */ - HY_analyzeControlWord = 12, /* 长度为12时解析控制字 */ - HY_analyzeDataLen = 14, /* 长度为14时解析数据长度 */ - -}HY_AnalyzeDataLen; - -/* 执行状态 */ -typedef enum -{ - /* 返回状态 */ - HY_success = 0xFF, /* 成功 */ - HY_fail = 0x00, /* 失败 */ - - /* 返回状态 */ - HY_success1 = 0x01, /* 成功 */ - - /* 充电开关状态 */ - HY_switchON = 0x01, /* 打开 */ - HY_switchOFF = 0x00, /* 关闭 */ - - /* 控制开关状态 */ - HY_cSwitchON = 0x00, /* 打开 */ - HY_cSwitchOFF = 0x01, /* 关闭 */ - -}HY_state; - - -/* 指定对齐方式为1字节 */ -#pragma pack(push,1) - -/* 通用参数 */ -typedef struct _HY_Recv_pack{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ -}HY_Recv_pack; - -/* 功能码处理函数 */ -typedef void (*HYMsgProcFunc)(device_handle device, void*, uint32_t MsgLen); -typedef struct _HY_FunctionMsgProcTable{ - u_int32_t msgId; - HYMsgProcFunc pMsgProc; -}HY_FuncionMsgProcTable; - - -/* 电池状态数据报查询 */ -typedef struct _HY_batteryStatusQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_batteryStatusQuery; -#define HY_batteryStatusQuery_PACK_SIZE (sizeof(HY_batteryStatusQuery)) - -/* 电池状态数据报响应 */ -typedef struct _HY_batteryStatusResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - float_t batteryVoltage; /* 电池电压 */ - float_t dischargCurrent; /* 输出电流(流向负载) */ - float_t chargCurrent1; /* 充电电流(流向电池+负载) */ - float_t SOC; /* 剩余电量 */ - float_t openCircuitVoltage1; /* 充电开路电压 */ - uint8_t chargSwitchStatus1; /* 充电开关状态 */ - float_t chargCurrent2; /* 充电电流(流向电池+负载) */ - float_t openCircuitVoltage2; /* 充电开路电压 */ - uint8_t chargSwitchStatus2; /* 充电开关状态 */ - float_t Mos_Temperature; /* 工作温度 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_batteryStatusResponse; -#define HY_batteryStatusResponse_PACK_SIZE (sizeof(HY_batteryStatusResponse)) -#define HY_batteryStatusResponse_dataLen 38 - -/* 电量统计数据报查询 */ -typedef struct _HY_electricityStatisticsQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_electricityStatisticsQuery; -#define HY_electricityStatisticsQuery_PACK_SIZE (sizeof(HY_electricityStatisticsQuery)) - -/* 电量统计数据报响应 */ -typedef struct _HY_electricityStatisticsResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t statisticalDuration; /* 统计时长 */ - float_t totalElectricityConsumption; /* 总电量消耗 */ - float_t totalChargCapacity; /* 总充电电量 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_electricityStatisticsResponse; -#define HY_electricityStatisticsResponse_PACK_SIZE (sizeof(HY_electricityStatisticsResponse)) -#define HY_electricityStatisticsResponse_dataLen 16 - -/* 传感器号码配置 */ -typedef struct _HY_sensorNumberConfig{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t newHardwareID[6]; /* 新硬件ID;高字节在前,低字节在后(保持不变) */ - uint8_t newCommunicationID[4]; /* 新通信ID;高字节在前,低字节在后 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_sensorNumberConfig; -#define HY_sensorNumberConfiguration_PACK_SIZE (sizeof(HY_sensorNumberConfig)) - -/* 传感器号码配置响应 */ -typedef struct _HY_sensorNumberConfigurationResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_sensorNumberConfigurationResponse; -#define HY_sensorNumberConfigurationResponse_PACK_SIZE (sizeof(HY_sensorNumberConfigurationResponse)) -#define HY_sensorNumberConfigurationResponse_dataLen 5 - -/* 传感器号码查询 */ -typedef struct _HY_sensorNumberInquiryQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t broadcastTerminal[6]; /* 广播终端ID:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF */ - uint8_t broadcastCommunication[4]; /* 广播通信ID:0xFF 0xFF 0xFF 0xFF */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_sensorNumberInquiryQuery; -#define HY_sensorNumberInquiryQuery_PACK_SIZE (sizeof(HY_sensorNumberInquiryQuery)) - -/* 传感器号码查询响应 */ -typedef struct _HY_sensorNumberInquiryResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t hardwareIDR[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationIDR[4]; /* 通信ID;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_sensorNumberInquiryResponse; -#define HY_sensorNumberInquiryResponse_PACK_SIZE (sizeof(HY_sensorNumberInquiryResponse)) -#define HY_sensorNumberInquiryResponse_dataLen 14 - -/* 充电阈值电压配置 */ -typedef struct _HY_chargingThresholdVoltageConfig{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - float_t chargOpenVoltage; /* 充电开电池电压 */ - float_t chargCloseVoltage; /* 充电关电池电压 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_chargingThresholdVoltageConfig; -#define HY_chargingThresholdVoltageConfig_PACK_SIZE (sizeof(HY_chargingThresholdVoltageConfig)) - -/* 充电阈值电压配置响应 */ -typedef struct _HY_chargingThresholdVoltageConfigResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_chargingThresholdVoltageConfigResponse; -#define HY_chargingThresholdVoltageConfigResponse_PACK_SIZE (sizeof(HY_chargingThresholdVoltageConfigResponse)) - - -/* 充电域值电压查询 */ -typedef struct _HY_chargRangeVoltageQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_chargRangeVoltageQuery; -#define HY_chargRangeVoltageQuery_PACK_SIZE (sizeof(HY_chargRangeVoltageQuery)) - -/* 充电域值电压查询响应 */ -typedef struct _HY_chargRangeVoltageQueryResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - float_t chargOpenVoltage; /* 充电开电池电压 */ - float_t chargCloseVoltage; /* 充电关电池电压 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_chargRangeVoltageQueryResponse; -#define HY_chargRangeVoltageQueryResponse_PACK_SIZE (sizeof(HY_chargRangeVoltageQueryResponse)) - -/* 复位指令 */ -typedef struct _HY_resetInstructionQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_resetInstructionQuery; -#define HY_resetInstructionQuery_PACK_SIZE (sizeof(HY_resetInstructionQuery)) - -/* 复位指令响应 */ -typedef struct _HY_resetInstructionResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_resetInstructionResponse; -#define HY_resetInstructionResponse_PACK_SIZE (sizeof(HY_resetInstructionResponse)) -#define HY_resetInstructionResponse_dataLen 5 - -/* 充电控制配置 */ -typedef struct _HY_chargingControlConfig{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t chargInterface; /* 充电接口 */ - uint8_t chargInterfaceControl; /* 充电接口控制 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_chargingControlConfig; -#define HY_chargingControlConfig_PACK_SIZE (sizeof(HY_chargingControlConfig)) - -/* 充电控制配置响应 */ -typedef struct _HY_chargingControlConfigResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_chargingControlConfigResponse; -#define HY_chargingControlConfigResponse_PACK_SIZE (sizeof(HY_chargingControlConfigResponse)) -#define HY_chargingControlConfigResponse_dataLen 5 - -/* 充电控制查询 */ -typedef struct _HY_QueryChargingControl{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_QueryChargingControl; -#define HY_QueryChargingControl_PACK_SIZE (sizeof(HY_QueryChargingControl)) - -/* 充电控制查询响应 */ -typedef struct _HY_QueryChargingControlResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t chargInterface1; /* 充电接口1状态 */ - uint8_t chargInterface2; /* 充电接口2状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_QueryChargingControlResponse; -#define HY_QueryChargingControlResponse_PACK_SIZE (sizeof(HY_QueryChargingControlResponse)) -#define HY_QueryChargingControlResponse_dataLen 6 - -/* 配置协议类型 */ -typedef struct _HY_configProtocolType{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_configProtocolType; -#define HY_configProtocolType_PACK_SIZE (sizeof(HY_configProtocolType)) - -/* 配置协议类型响应 */ -typedef struct _HY_configProtocolTypeResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_configProtocolTypeResponse; -#define HY_configProtocolTypeResponse_PACK_SIZE (sizeof(HY_configProtocolTypeResponse)) -#define HY_configProtocolTypeResponse_dataLen 5 - -/* 查询电池控制盒当前配置 */ -typedef struct _HY_queryControlBoxConfigurationQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_queryControlBoxConfigurationQuery; -#define HY_queryControlBoxConfigurationQuery_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationQuery)) - -/* 查询电池控制盒当前配置响应 */ -typedef struct _HY_queryControlBoxConfigurationResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/ - uint8_t voltageLevel; /* 电压等级 */ - uint8_t mainBoardTemperatureSensorType; /* 主板温度传感器类型 */ - uint8_t batteryTemperatureSensorType; /* 电池温度传感器类型 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_queryControlBoxConfigurationResponse; -#define HY_queryControlBoxConfigurationResponse_PACK_SIZE (sizeof(HY_queryControlBoxConfigurationResponse)) -#define HY_queryControlBoxConfigurationResponse_dataLen 8 - -/* 查询电池控制盒软件版本 */ -typedef struct _HY_SoftwareVersionQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_SoftwareVersionQuery; -#define HY_SoftwareVersionQuery_PACK_SIZE (sizeof(HY_SoftwareVersionQuery)) - -/* 查询电池控制盒软件版本响应 */ -typedef struct _HY_SoftwareVersionQueryResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t versionInformation[13]; /* 版本信息 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_SoftwareVersionQueryResponse; -#define HY_SoftwareVersionQueryResponse_PACK_SIZE (sizeof(HY_SoftwareVersionQueryResponse)) -#define HY_SoftwareVersionQueryResponse_dataLen 17 - -/* 进入配置模式 */ -typedef struct _HY_enterConfigMode{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_enterConfigMode; -#define HY_enterConfigMode_PACK_SIZE (sizeof(HY_enterConfigMode)) - -/* 进入配置模式响应 */ -typedef struct _HY_enterConfigModeResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_enterConfigModeResponse; -#define HY_enterConfigModeResponse_PACK_SIZE (sizeof(HY_enterConfigModeResponse)) -#define HY_enterConfigModeResponse_dataLen 5 - -/* 配置控制盒硬件ID号 */ -typedef struct _HY_configHardwareID{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t newHardwareID[6]; /* 新硬件ID;高字节在前,低字节在后 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_configHardwareID; -#define HY_configHardwareID_PACK_SIZE (sizeof(HY_configHardwareID)) - -/* 配置控制盒硬件ID号 响应*/ -typedef struct _HY_configHardwareIDResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_configHardwareIDResponse; -#define HY_configHardwareIDResponse_PACK_SIZE (sizeof(HY_configHardwareIDResponse)) -#define HY_configHardwareIDResponse_dataLen 5 - -/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */ -typedef struct _HY_QueryhardwareID_communicationID{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_QueryhardwareID_communicationID; -#define HY_QueryhardwareID_communicationID_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationID)) - -/* 控制盒硬件ID号及通信ID号(原传感器号)查询响应 */ -typedef struct _HY_QueryhardwareID_communicationIDResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t hardwareIDR[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationIDR[4]; /* 通信ID;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_QueryhardwareID_communicationIDResponse; -#define HY_QueryhardwareID_communicationIDResponse_PACK_SIZE (sizeof(HY_QueryhardwareID_communicationIDResponse)) -#define HY_QueryhardwareID_dataLen 14 - -/* 修改通信ID号(原传感器号) */ -typedef struct _HY_modifyCommunicationIDChange{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t newHardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t newCommunicationID[4]; /* 新通信ID;高字节在前,低字节在后 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_modifyCommunicationIDChange; -#define HY_modifyCommunicationIDChange_PACK_SIZE (sizeof(HY_modifyCommunicationIDChange)) - -/* 修改通信ID号(原传感器号)响应 */ -typedef struct _HY_modifyCommunicationIDChangeResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_modifyCommunicationIDChangeResponse; -#define HY_modifyCommunicationIDChangeResponse_PACK_SIZE (sizeof(HY_modifyCommunicationIDChangeResponse)) -#define HY_modifyCommunicationIDChangeResponse_dataLen 5 - -/* 查询主板温度值 */ -typedef struct _HY_checkMotherboardTemperatureQuery{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_checkMotherboardTemperatureQuery; -#define HY_checkMotherboardTemperatureQuery_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureQuery)) - -/* 查询主板温度值响应 */ -typedef struct _HY_checkMotherboardTemperatureResponse{ - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - float_t MotherboardTemperature; /* 主板温度 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_checkMotherboardTemperatureResponse; -#define HY_checkMotherboardTemperatureResponse_PACK_SIZE (sizeof(HY_checkMotherboardTemperatureResponse)) -#define HY_checkMotherboardTemperatureResponse_dataLen 8 - -/* 配置时间 */ -typedef struct _HY_configTime { - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - timeInfo time; /* 年月日时分秒 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_configTime; -#define HY_configTime_PACK_SIZE (sizeof(HY_configTime)) - -/* 配置时间响应 */ -typedef struct _HY_configTimeResponse { - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint8_t state; /* 状态 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_configTimeResponse; -#define HY_configTimeResponse_PACK_SIZE (sizeof(HY_configTimeResponse)) -#define HY_configTimeResponse_dataLen 5 - -/* 查询时间 */ -typedef struct _HY_timeQuery { - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_timeQuery; -#define HY_timeQuery_PACK_SIZE (sizeof(HY_timeQuery)) - -/* 查询时间响应 */ -typedef struct _HY_queryTimeResponse { - uint8_t start_Flag; /* 起始标志 */ - uint8_t hardwareID[6]; /* 硬件ID;高字节在前,低字节在后 */ - uint8_t communicationID[4]; /* 通信ID;高字节在前,低字节在后 */ - uint8_t controlWord; /* 控制字 */ - uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ - timeInfo time; /* 年月日时分秒 */ - uint32_t frameNumber; /* 帧序号 */ - uint8_t check_Bit; /* 校验码 */ - uint8_t end_Flag; /* 结束标志 */ -}HY_queryTimeResponse; -#define HY_queryTimeResponse_PACK_SIZE (sizeof(HY_queryTimeResponse)) -#define HY_queryTimeResponse_dataLen 10 - - -/* 恢复默认的对齐设置 */ -#pragma pack(pop) - - -/** - * @brief 校验算法 - * @param 采用累加和取反的校验方式,将终端号码、传感器号码、控制字、数据长度 - * 和数据区的所有字节进行算术累加,抛弃高位,只保留最后单字节,将单字节取反; - * @retval - */ -static uint8_t HY_CheckFunc(uint8_t *arr_buff, uint8_t len) -{ - uint8_t temp = 0x00; - uint32_t sum = 0x00; - - for(uint8_t i = 0; i < len; i++) { - sum += *arr_buff++; - } - - temp = (~sum) & 0xff; - - return temp; -} - - -/* 电池状态数据报 */ -static void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t MsgLen); -/* 电量统计数据报 */ -static void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint32_t MsgLen); -/* 传感器号码配置 */ -static void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg, uint32_t MsgLen); -/* 传感器号码查询 */ -static void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32_t MsgLen); -/* 充电阈值电压配置 */ -static void HY_MsgProcFunc_chargingThresholdVoltageConfiguration(device_handle device, void *pMsg, uint32_t MsgLen); -/* 充电域值电压查询 */ -static void HY_MsgProcFunc_chargingRangeVoltageQuery(device_handle device, void *pMsg, uint32_t MsgLen); -/* 复位指令 */ -static void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t MsgLen); - -/* 充电控制配置 */ -static void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMsg, uint32_t MsgLen); -/* 充电控制查询 */ -static void HY_MsgProcFunc_chargingControlQuery(device_handle device, void *pMsg, uint32_t MsgLen); -/* 配置时间 */ -static void HY_MsgProcFunc_configTime(device_handle device, void *pMsg, uint32_t MsgLen); -/* 查询时间 */ -static void HY_MsgProcFunc_queryTime(device_handle device, void *pMsg, uint32_t MsgLen); - - -/* 配置协议类型 */ -static void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint32_t MsgLen); -///* 响应配置协议类型 */ -//static void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t MsgLen); - -/* 查询电池控制盒当前配置 */ -static void HY_MsgProcFunc_queryControlBoxConfiguration(device_handle device, void *pMsg, uint32_t MsgLen); -/* 查询电池控制盒软件版本 */ -static void HY_MsgProcFunc_querySoftwareVersion(device_handle device, void *pMsg, uint32_t MsgLen); -/* 进入配置模式 */ -static void HY_MsgProcFunc_enterConfigurationMode(device_handle device, void *pMsg, uint32_t MsgLen); - -/* 配置控制盒硬件ID号 */ -static void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32_t MsgLen); -/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */ -static void HY_MsgProcFunc_hardwareID_communicationIDQuery(device_handle device, void *pMsg, uint32_t MsgLen); -/* 修改通信ID号(原传感器号) */ -static void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint32_t MsgLen); -/* 查询主板温度值 */ -static void HY_MsgProcFunc_checkMotherboardTemperature(device_handle device, void *pMsg, uint32_t MsgLen); - -/* 功能码处理表 */ -HY_FuncionMsgProcTable g_hyMsgTbl[] = -{ - {HY_batteryStatus, HY_MsgProcFunc_batteryStatus}, - {HY_electricityStatistics, HY_MsgProcFunc_electricityStatistics}, - {HY_sensorNumberConfiguration, HY_MsgProcFunc_sensorNumberConfiguration}, - {HY_sensorNumberInquiry, HY_MsgProcFunc_sensorNumberInquiry}, - {HY_chargingThresholdVoltageConfiguration, HY_MsgProcFunc_chargingThresholdVoltageConfiguration}, - {HY_chargingRangeVoltageQuery, HY_MsgProcFunc_chargingRangeVoltageQuery}, - {HY_resetInstruction, HY_MsgProcFunc_resetInstruction}, - {HY_chargingControlConfiguration, HY_MsgProcFunc_chargingControlConfiguration}, - {HY_chargingControlQuery, HY_MsgProcFunc_chargingControlQuery}, - {HY_configureProtocolType, HY_MsgProcFunc_configureProtocolType}, -// {HY_responseConfigureProtocolType, HY_MsgProcFunc_batteryStatus}, - {HY_queryControlBoxConfiguration, HY_MsgProcFunc_queryControlBoxConfiguration}, - {HY_querySoftwareVersion, HY_MsgProcFunc_querySoftwareVersion}, - {HY_enterConfigurationMode, HY_MsgProcFunc_enterConfigurationMode}, - {HY_configureHardwareID, HY_MsgProcFunc_configureHardwareID}, - {HY_hardwareID_communicationIDQuery, HY_MsgProcFunc_hardwareID_communicationIDQuery}, - {HY_modifyCommunicationID, HY_MsgProcFunc_modifyCommunicationID}, - {HY_checkMotherboardTemperature, HY_MsgProcFunc_checkMotherboardTemperature}, - {HY_configurationTime, HY_MsgProcFunc_configTime}, - {HY_queryTime, HY_MsgProcFunc_queryTime}, -}; - - - -/** - * @brief 读取HY协议配置状态 - * @param None - * @retval TRUE 能修改配置 - * FALSE 不能修改配置 - */ -BOOL getHYconfigModeState(void) -{ - return HYconfigModeState; -} - -/** - * @brief 匹配广播ID - * @param address 地址 - * @retval 1 匹配成功 - * 0 匹配失败 - */ -void setHYconfigModeState(BOOL state) -{ - if (state == TRUE || state == FALSE) { - HYconfigModeState = state; - } -} - - -/** - * @brief 匹配广播ID - * @param address 地址 - * @retval 1 匹配成功 - * 0 匹配失败 - */ -static int Match_BroadcastCommunicationID(u_int8_t communicationID[4]) -{ - if (communicationID[0] == 0xFF && \ - communicationID[1] == 0xFF && \ - communicationID[2] == 0xFF && \ - communicationID[3] == 0xFF) { - // log_info("Match_BroadcastCommunicationID success\r\n"); - return 1; - } - return 0; -} - -/** - * @brief 匹配设备通信ID - * @param address 地址 - * @retval 1 匹配成功 - * 0 匹配失败 - */ -static int HY_matchCommunicationID(u_int8_t communicationID[4]) -{ - if ((communicationID[0] == g_cfgParameter.communicationID[0]) && \ - (communicationID[1] == g_cfgParameter.communicationID[1]) && \ - (communicationID[2] == g_cfgParameter.communicationID[2]) && \ - (communicationID[3] == g_cfgParameter.communicationID[3])) { - // log_info("Match_CommunicationIDHY success \r\n"); - return 1; - } - return 0; -} -/** - * @brief 匹配设备硬件ID - * @param address 地址 - * @retval 1 匹配成功 - * 0 匹配失败 - */ -static int HY_matchHardwareID(u_int8_t hardwareID[6]) -{ - if ((hardwareID[0] == g_cfgParameter.hardwareID[0]) && \ - (hardwareID[1] == g_cfgParameter.hardwareID[1]) && \ - (hardwareID[2] == g_cfgParameter.hardwareID[2]) && \ - (hardwareID[3] == g_cfgParameter.hardwareID[3]) && \ - (hardwareID[4] == g_cfgParameter.hardwareID[4]) && \ - (hardwareID[5] == g_cfgParameter.hardwareID[5])) { - // log_info("Match_hardwareIDHY success \r\n"); - return 1; - } - return 0; -} - -/** - * @brief 匹配广播硬件ID - * @param address 地址 - * @retval 1 匹配成功 - * 0 匹配失败 - */ -static int Match_BroadcastHardwareID(u_int8_t hardwareID[6]) -{ - if (hardwareID[0] == 0xFF && \ - hardwareID[1] == 0xFF && \ - hardwareID[2] == 0xFF && \ - hardwareID[3] == 0xFF && \ - hardwareID[4] == 0xFF && \ - hardwareID[5] == 0xFF) { - // log_info("Match_BroadcastHardwareID success\r\n"); - return 1; - } - return 0; -} - -/** - * @brief 读取串口数据 - * @param uart_handle 串口句柄 - * @param buff 缓冲区 - * @param buff_size 缓冲区长度 - * @retval - */ -static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, uint32_t buff_size) -{ - uint32_t offset = 0; - uint32_t len = 0; - uint8_t flag_run = 0; - - /* 接收到的硬件ID种类 - * 0x01 广播ID - * 0x02 硬件ID - **/ - uint8_t hardwordIDType = 0; - uint8_t c = 0; - - HY_Recv_pack *pack = (HY_Recv_pack *)buff; - - buff_size--; //预留一个'\0'位置 - for (; offset < buff_size;){ - if (uart_dev_char_present(uart_handle) == 0) { - break; - } - - c = uart_dev_in_char(uart_handle); - - buff[offset++] = c; - inConfigBuff(c); - - /* 匹配起始标志位 */ - if (offset == HY_analyzeStartFlag || (flag_run > 0)) { - if (pack->start_Flag != g_cfgParameter.startFlagHY) { - // log_info(" Match_start_Flag error %x ", pack->start_Flag); -// printf("1 : %x \n", pack->start_Flag); - memcpy(buff, buff+1, offset-1); - offset--; - continue; - } -// log_info(" Match_start_Flag success "); -// printf("%x\n", pack->start_Flag); - } - - /* 匹配硬件ID */ - if (offset == HY_analyzeHardwareID || (flag_run > 1)) { - if (HY_matchHardwareID(pack->hardwareID)) { - hardwordIDType = 0x02; - } - - else if (Match_BroadcastHardwareID(pack->hardwareID)) { - hardwordIDType = 0x01; - } - - else { - // log_info("Match_hardwordID error"); - hardwordIDType = 0x00; - if (flag_run < 1) { - flag_run = 1; - } - memcpy(buff, buff+1, offset-1); - offset--; - continue; - } - } - - /* 匹配通信ID */ - if (offset == HY_analyzeCommunicationID || (flag_run > 2)) { - if (!(HY_matchCommunicationID(pack->communicationID) || Match_BroadcastCommunicationID(pack->communicationID))) { - if (flag_run < 2) { - flag_run = 2; - } - // log_info("Match_CommunicationID error"); - memcpy(buff, buff+1, offset-1); - offset--; - continue; - } - } - - /* 匹配 */ - if (offset == HY_analyzeControlWord || (flag_run > 3)) { - if (pack->controlWord == HY_batteryStatus && hardwordIDType == 0x02) { - len = HY_batteryStatusQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_electricityStatistics && hardwordIDType == 0x02) { - len = HY_electricityStatisticsQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_sensorNumberConfiguration && hardwordIDType == 0x02) { - len = HY_sensorNumberConfiguration_PACK_SIZE; - } - - else if (pack->controlWord == HY_sensorNumberInquiry && hardwordIDType == 0x01) { - len = HY_sensorNumberInquiryQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_chargingThresholdVoltageConfiguration && hardwordIDType == 0x02) { - len = HY_chargingThresholdVoltageConfig_PACK_SIZE; - } - - else if (pack->controlWord == HY_chargingRangeVoltageQuery && hardwordIDType == 0x02) { - len = HY_chargRangeVoltageQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_resetInstruction && hardwordIDType == 0x02) { - len = HY_resetInstructionQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_chargingControlConfiguration && hardwordIDType == 0x02) { - len = HY_chargingControlConfig_PACK_SIZE; - } - - else if (pack->controlWord == HY_chargingControlQuery && hardwordIDType == 0x02) { - len = HY_QueryChargingControl_PACK_SIZE; - } - - else if (pack->controlWord == HY_configureProtocolType && hardwordIDType == 0x02) { - len = HY_configProtocolType_PACK_SIZE; - } - - else if (pack->controlWord == HY_queryControlBoxConfiguration && hardwordIDType == 0x02) { - len = HY_queryControlBoxConfigurationQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_querySoftwareVersion && hardwordIDType == 0x02) { - len = HY_SoftwareVersionQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_enterConfigurationMode && hardwordIDType == 0x02) { - len = HY_enterConfigMode_PACK_SIZE; - } - - else if (pack->controlWord == HY_configureHardwareID && hardwordIDType == 0x02) { - len = HY_configHardwareID_PACK_SIZE; - } - else if (pack->controlWord == HY_hardwareID_communicationIDQuery && hardwordIDType == 0x01) { - len = HY_QueryhardwareID_communicationID_PACK_SIZE; - } - else if (pack->controlWord == HY_modifyCommunicationID && hardwordIDType == 0x02) { - len = HY_modifyCommunicationIDChange_PACK_SIZE; - } - - else if (pack->controlWord == HY_checkMotherboardTemperature && hardwordIDType == 0x02) { - len = HY_checkMotherboardTemperatureQuery_PACK_SIZE; - } - - else if (pack->controlWord == HY_configurationTime && hardwordIDType == 0x02) { - len = HY_configTime_PACK_SIZE; - } - - else if (pack->controlWord == HY_queryTime && hardwordIDType == 0x02) { - len = HY_timeQuery_PACK_SIZE; - } - - else { - if (flag_run < 3) { - flag_run = 3; - } - // log_info("Match_controlWord error"); - memcpy(buff, buff+1, offset-1); - offset--; - continue; - } - } - - /* 匹配数据长度 */ - if (offset == HY_analyzeDataLen || (flag_run > 4)) { - if (len != ((pack->dataLen[0] << 8 | pack->dataLen[1]) + 16)) { - if (flag_run < 4) { - flag_run = 4; - } - // log_info("Match_dataLen error: %x", len); - // log_info("Match_dataLen error: %x", (pack->dataLen[0] << 8 | pack->dataLen[1]) + 16); - // log_info("Match_dataLen error: %x", pack->dataLen[0]); - // log_info("Match_dataLen error: %x", pack->dataLen[1]); - memcpy(buff, buff+1, offset-1); - offset--; - continue; - } - } - - if (offset == len) { - if (buff[len - 2] != HY_CheckFunc(buff, len - 2) - || buff[len - 1] != g_cfgParameter.endFlagHY) { - if (flag_run < 5) { - flag_run = 5; - } - // log_info("check: %x, %x", (HY_CheckFunc(buff, len - 2) & 0xff), buff[len - 2]); - memcpy(buff, buff+1, offset-1); - offset--; - continue; - } - zeroConfigBuff(); - return len; - } - } - return 0; -} - -/** - * @brief 处理一条消息 - * @param - * @retval - */ -static void HY_FRT_MsgHandler(device_handle device, uint8_t *pMsg, uint32_t MsgLen) -{ - HY_Recv_pack *pack = (HY_Recv_pack *)pMsg; - - for (u_int16_t i = 0; i < sizeof(g_hyMsgTbl) / sizeof(HY_FuncionMsgProcTable); i++){ - if (pack->controlWord == g_hyMsgTbl[i].msgId){ - g_hyMsgTbl[i].pMsgProc(device, pMsg, MsgLen); - } - } -} - - -/** - * @brief 读取并解析串口数据 - * @param - * @retval - */ -void HY_read_and_process_uart_data(device_handle device) -{ -// if (uart_dev_char_present(device)) { -// Delay_Ms(20); -// memset(rs485_buff, 0, sizeof(rs485_buff)); -// int ret = HY_uart_read_climate_pack(device, rs485_buff, sizeof(rs485_buff)); -// if(ret > 0){ -// HY_FRT_MsgHandler(device, rs485_buff, ret); -// } -// } - memset(rs485_buff, 0, sizeof(rs485_buff)); - int ret = HY_uart_read_climate_pack(device, rs485_buff, sizeof(rs485_buff)); - if(ret > 0){ - HY_FRT_MsgHandler(device, rs485_buff, ret); - } -} - -/* 电池状态数据报 */ -void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_batteryStatusResponse pack; - pack.start_Flag = g_cfgParameter.startFlagHY; - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = HY_batteryStatus; - pack.dataLen[0] = HY_batteryStatusResponse_dataLen >> 8; - pack.dataLen[1] = HY_batteryStatusResponse_dataLen; - - pack.batteryVoltage = getBatteryVoltage(); - -// pack.batteryVoltage = 6.66; - pack.dischargCurrent = getDischargCurrent(); - pack.chargCurrent1 = getChargCurrent(); - pack.SOC = getSOC(); - pack.openCircuitVoltage1 = getSolarOpenCircuitVoltage(); - - // if (getDutyRatio() > 0 && getChargCurrent() > 0.05) { - if (getDutyRatio() > 0) { - pack.chargSwitchStatus1 = HY_switchON; - } else { - pack.chargSwitchStatus1 = HY_switchOFF; - } - - pack.chargCurrent2 = pack.chargCurrent1; - pack.openCircuitVoltage2 = pack.openCircuitVoltage1; - - pack.chargSwitchStatus2 = pack.chargSwitchStatus1; - - pack.Mos_Temperature = getHighSideMosTemperature(); - - HY_batteryStatusQuery *Tpack = (HY_batteryStatusQuery *)pMsg; - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_batteryStatusResponse_PACK_SIZE - 2); - - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_batteryStatusResponse_PACK_SIZE); - // uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE); -} - -/* 电量统计数据报 */ -void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_electricityStatisticsResponse pack; - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = HY_electricityStatistics; - - pack.dataLen[0] = HY_electricityStatisticsResponse_dataLen >> 8; - pack.dataLen[1] = HY_electricityStatisticsResponse_dataLen; - - timeInfo time1, time2 = {0}; - getRTC_Time(&time1); - time2 = getLastTime(); - pack.statisticalDuration = differTime(&time1, &time2); - setLastTime(time1); - - // pack.statisticalDuration = 0; - pack.totalChargCapacity = getTotalChargCapacity(); - pack.totalElectricityConsumption = getTotalElectricityConsumption(); - - /* 查询后清空 */ - totalChargCapacityInt(0); - totalElectricityConsumptionInt(0); - - // float temp = 0; - // // temp = getTotalChargCapacity(); - // savetotalChargCapacity(&temp); - // // temp = getTotalElectricityConsumption(); - // savetotalElectricityConsumption(&temp); - - - HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg; - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_electricityStatisticsResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - - uart_interruptSend(device, (uint8_t *)&pack, HY_electricityStatisticsResponse_PACK_SIZE); - // uart_dev_write(device, &pack, HY_electricityStatisticsResponse_PACK_SIZE); - -} - -/* 传感器号码配置 */ -void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_sensorNumberConfigurationResponse pack; - - HY_sensorNumberConfig *Tpack = (HY_sensorNumberConfig *)pMsg; - if (HY_matchHardwareID(Tpack->newHardwareID)) { - g_cfgParameter.communicationID[0] = Tpack->newCommunicationID[0]; - g_cfgParameter.communicationID[1] = Tpack->newCommunicationID[1]; - g_cfgParameter.communicationID[2] = Tpack->newCommunicationID[2]; - g_cfgParameter.communicationID[3] = Tpack->newCommunicationID[3]; - - config_info temp_configInfo; - read_config_info(&temp_configInfo); - temp_configInfo.communicationID[0] = Tpack->newCommunicationID[0]; - temp_configInfo.communicationID[1] = Tpack->newCommunicationID[1]; - temp_configInfo.communicationID[2] = Tpack->newCommunicationID[2]; - temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3]; - - temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - saveConfigInfo(&temp_configInfo); - - pack.state = HY_success; - } - else { - pack.state = HY_fail; - } - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_sensorNumberConfigurationResponse_dataLen >> 8; - pack.dataLen[1] = HY_sensorNumberConfigurationResponse_dataLen; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfigurationResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_sensorNumberConfigurationResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_sensorNumberConfigurationResponse_PACK_SIZE); -} - -/* 传感器号码查询 */ -void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_sensorNumberInquiryQuery *Tpack = (HY_sensorNumberInquiryQuery *)pMsg; - - HY_sensorNumberInquiryResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_sensorNumberInquiryResponse_dataLen >> 8; - pack.dataLen[1] = HY_sensorNumberInquiryResponse_dataLen; - - pack.hardwareIDR[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareIDR[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareIDR[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareIDR[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareIDR[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareIDR[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationIDR[0] = g_cfgParameter.communicationID[0]; - pack.communicationIDR[1] = g_cfgParameter.communicationID[1]; - pack.communicationIDR[2] = g_cfgParameter.communicationID[2]; - pack.communicationIDR[3] = g_cfgParameter.communicationID[3]; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberInquiryResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_sensorNumberInquiryResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_sensorNumberInquiryResponse_PACK_SIZE); -} - -/* 充电阈值电压配置 */ -void HY_MsgProcFunc_chargingThresholdVoltageConfiguration(device_handle device, void *pMsg, uint32_t MsgLen) -{ - -} - -/* 充电域值电压查询 */ -void HY_MsgProcFunc_chargingRangeVoltageQuery(device_handle device, void *pMsg, uint32_t MsgLen) -{ - -} - -/* 复位指令 */ -void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_resetInstructionQuery *Tpack = (HY_resetInstructionQuery *)pMsg; - - HY_resetInstructionResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_resetInstructionResponse_dataLen >> 8; - pack.dataLen[1] = HY_resetInstructionResponse_dataLen; - - pack.state = HY_success; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_resetInstructionResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_resetInstructionResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_resetInstructionResponse_PACK_SIZE); - - /* 复位 */ - NVIC_SystemReset(); -} - - -/* 充电控制配置 */ -void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_chargingControlConfig *Tpack = (HY_chargingControlConfig *)pMsg; - - if (Tpack->chargInterfaceControl == HY_cSwitchON) { - if (getDutyRatio() == 0) { - beginChargWork(); - } - } - - if (Tpack->chargInterfaceControl == HY_cSwitchOFF) { - if (getDutyRatio() != 0) { - stopChargWork(); - } - } - - HY_chargingControlConfigResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_chargingControlConfigResponse_dataLen >> 8; - pack.dataLen[1] = HY_chargingControlConfigResponse_dataLen; - - pack.state = HY_success; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_chargingControlConfigResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_chargingControlConfigResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_chargingControlConfigResponse_PACK_SIZE); -} - -/* 充电控制查询 */ -static void HY_MsgProcFunc_chargingControlQuery(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_QueryChargingControl *Tpack = (HY_QueryChargingControl *)pMsg; - - HY_QueryChargingControlResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_QueryChargingControlResponse_dataLen >> 8; - pack.dataLen[1] = HY_QueryChargingControlResponse_dataLen; - - // if (getDutyRatio() > 0 && g_cfgParameter.Charg_Current > 0.05) { - if (getDutyRatio() > 0) { - pack.chargInterface1 = HY_switchON; - } else { - pack.chargInterface1 = HY_switchOFF; - } - - pack.chargInterface2 = pack.chargInterface1; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryChargingControlResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_QueryChargingControlResponse_PACK_SIZE); - uart_dev_write(device, (uint8_t *)&pack, HY_QueryChargingControlResponse_PACK_SIZE); -} - - -/* 配置协议类型 */ -void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_configProtocolType *Tpack = (HY_configProtocolType *)pMsg; - - g_cfgParameter.protocolType = Tpack->protocolType; - - config_info temp_configInfo; - read_config_info(&temp_configInfo); - temp_configInfo.protocolType = Tpack->protocolType; - - temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - saveConfigInfo(&temp_configInfo); - - if (g_cfgParameter.protocolType == 0x01) { - g_cfgParameter.gw485_Baud = 9600; - } else if (g_cfgParameter.protocolType == 0x02) { - g_cfgParameter.gw485_Baud = 115200; - } - - HY_chargingControlConfigResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = HY_responseConfigureProtocolType; - - pack.dataLen[0] = HY_configProtocolTypeResponse_dataLen >> 8; - pack.dataLen[1] = HY_configProtocolTypeResponse_dataLen; - - pack.state = HY_success; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configProtocolTypeResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - - uart_interruptSend(device, (uint8_t *)&pack, HY_configProtocolTypeResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_configProtocolTypeResponse_PACK_SIZE); - - Init_GW485_uart(g_cfgParameter.gw485_Baud); -} - - -/* 查询电池控制盒当前配置 */ -void HY_MsgProcFunc_queryControlBoxConfiguration(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_queryControlBoxConfigurationQuery *Tpack = (HY_queryControlBoxConfigurationQuery *)pMsg; - - HY_queryControlBoxConfigurationResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_queryControlBoxConfigurationResponse_dataLen >> 8; - pack.dataLen[1] = HY_queryControlBoxConfigurationResponse_dataLen; - -// pack.state = HY_success; - pack.protocolType = g_cfgParameter.protocolType; - pack.voltageLevel = 0x00; //12V - pack.mainBoardTemperatureSensorType = 0xFF; - pack.batteryTemperatureSensorType = 0xFF; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryControlBoxConfigurationResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE); -} - -/* 查询电池控制盒软件版本 */ -void HY_MsgProcFunc_querySoftwareVersion(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_SoftwareVersionQuery *Tpack = (HY_SoftwareVersionQuery *)pMsg; - - HY_SoftwareVersionQueryResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_SoftwareVersionQueryResponse_dataLen >> 8; - pack.dataLen[1] = HY_SoftwareVersionQueryResponse_dataLen; - - // strlcpy(pack.versionInformation, getVersionInformation(), 13); - memcpy(pack.versionInformation, getVersionInformation(), 13); - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_SoftwareVersionQueryResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_SoftwareVersionQueryResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_SoftwareVersionQueryResponse_PACK_SIZE); -} - -/* 进入配置模式 */ -void HY_MsgProcFunc_enterConfigurationMode(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_enterConfigMode *Tpack = (HY_enterConfigMode *)pMsg; - - HY_enterConfigModeResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_enterConfigModeResponse_dataLen >> 8; - pack.dataLen[1] = HY_enterConfigModeResponse_dataLen; - - pack.state = HY_success; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_enterConfigModeResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_enterConfigModeResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_enterConfigModeResponse_PACK_SIZE); - - beginHYconfigMode(); -} - -/* 配置控制盒硬件ID号 */ -void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_configHardwareIDResponse pack; - - HY_configHardwareID *Tpack = (HY_configHardwareID *)pMsg; - if (getHYconfigModeState() == TRUE) { - g_cfgParameter.hardwareID[0] = Tpack->hardwareID[0]; - g_cfgParameter.hardwareID[1] = Tpack->hardwareID[1]; - g_cfgParameter.hardwareID[2] = Tpack->hardwareID[2]; - g_cfgParameter.hardwareID[3] = Tpack->hardwareID[3]; - g_cfgParameter.hardwareID[4] = Tpack->hardwareID[4]; - g_cfgParameter.hardwareID[5] = Tpack->hardwareID[5]; - - config_info temp_configInfo; - read_config_info(&temp_configInfo); - temp_configInfo.hardwareID[0] = Tpack->hardwareID[0]; - temp_configInfo.hardwareID[1] = Tpack->hardwareID[1]; - temp_configInfo.hardwareID[2] = Tpack->hardwareID[2]; - temp_configInfo.hardwareID[3] = Tpack->hardwareID[3]; - temp_configInfo.hardwareID[4] = Tpack->hardwareID[4]; - temp_configInfo.hardwareID[5] = Tpack->hardwareID[5]; - - temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - saveConfigInfo(&temp_configInfo); - - pack.state = HY_success; - } - else { - pack.state = HY_fail; - } - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_configHardwareIDResponse_dataLen >> 8; - pack.dataLen[1] = HY_configHardwareIDResponse_dataLen; - - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configHardwareIDResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_configHardwareIDResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_configHardwareIDResponse_PACK_SIZE); -} - -/* 控制盒硬件ID号及通信ID号(原传感器号)查询 */ -void HY_MsgProcFunc_hardwareID_communicationIDQuery(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_QueryhardwareID_communicationID *Tpack = (HY_QueryhardwareID_communicationID *)pMsg; - - HY_QueryhardwareID_communicationIDResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_QueryhardwareID_dataLen >> 8; - pack.dataLen[1] = HY_QueryhardwareID_dataLen; - - pack.hardwareIDR[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareIDR[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareIDR[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareIDR[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareIDR[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareIDR[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationIDR[0] = g_cfgParameter.communicationID[0]; - pack.communicationIDR[1] = g_cfgParameter.communicationID[1]; - pack.communicationIDR[2] = g_cfgParameter.communicationID[2]; - pack.communicationIDR[3] = g_cfgParameter.communicationID[3]; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryhardwareID_communicationIDResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE); -} - -/* 修改通信ID号(原传感器号) */ -void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_modifyCommunicationIDChangeResponse pack; - - HY_modifyCommunicationIDChange *Tpack = (HY_modifyCommunicationIDChange *)pMsg; - if (HY_matchHardwareID(Tpack->newHardwareID)) { - g_cfgParameter.communicationID[0] = Tpack->newCommunicationID[0]; - g_cfgParameter.communicationID[1] = Tpack->newCommunicationID[1]; - g_cfgParameter.communicationID[2] = Tpack->newCommunicationID[2]; - g_cfgParameter.communicationID[3] = Tpack->newCommunicationID[3]; - - config_info temp_configInfo; - read_config_info(&temp_configInfo); - temp_configInfo.communicationID[0] = Tpack->newCommunicationID[0]; - temp_configInfo.communicationID[1] = Tpack->newCommunicationID[1]; - temp_configInfo.communicationID[2] = Tpack->newCommunicationID[2]; - temp_configInfo.communicationID[3] = Tpack->newCommunicationID[3]; - - temp_configInfo.crc = checkModebusCrc((uint8_t *)&temp_configInfo, CONFIG_INFO_SIZE - 2); - saveConfigInfo(&temp_configInfo); - - pack.state = HY_success1; - } - else { - pack.state = HY_fail; - } - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_modifyCommunicationIDChangeResponse_dataLen >> 8; - pack.dataLen[1] = HY_modifyCommunicationIDChangeResponse_dataLen; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_modifyCommunicationIDChangeResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE); -} - -/* 查询主板温度值 */ -void HY_MsgProcFunc_checkMotherboardTemperature(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_checkMotherboardTemperatureQuery *Tpack = (HY_checkMotherboardTemperatureQuery *)pMsg; - - HY_checkMotherboardTemperatureResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_checkMotherboardTemperatureResponse_dataLen >> 8; - pack.dataLen[1] = HY_checkMotherboardTemperatureResponse_dataLen; - - pack.MotherboardTemperature = getHighSideMosTemperature(); - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_checkMotherboardTemperatureResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE); -} - -/* 配置时间 */ -void HY_MsgProcFunc_configTime(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_configTime *Tpack = (HY_configTime *)pMsg; - - // static timeInfo time; - // time = Tpack->time; - // setRTC_Time(&time); - setRTC_Time((timeInfo *)&Tpack->time); - - HY_configTimeResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_configTimeResponse_dataLen >> 8; - pack.dataLen[1] = HY_configTimeResponse_dataLen; - - pack.state = HY_success; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configTimeResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_configTimeResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_configTimeResponse_PACK_SIZE); -} - - - - -/* 查询时间 */ -static void HY_MsgProcFunc_queryTime(device_handle device, void *pMsg, uint32_t MsgLen) -{ - HY_timeQuery *Tpack = (HY_timeQuery *)pMsg; - - HY_queryTimeResponse pack; - - pack.start_Flag = g_cfgParameter.startFlagHY; - - pack.hardwareID[0] = g_cfgParameter.hardwareID[0]; - pack.hardwareID[1] = g_cfgParameter.hardwareID[1]; - pack.hardwareID[2] = g_cfgParameter.hardwareID[2]; - pack.hardwareID[3] = g_cfgParameter.hardwareID[3]; - pack.hardwareID[4] = g_cfgParameter.hardwareID[4]; - pack.hardwareID[5] = g_cfgParameter.hardwareID[5]; - - pack.communicationID[0] = g_cfgParameter.communicationID[0]; - pack.communicationID[1] = g_cfgParameter.communicationID[1]; - pack.communicationID[2] = g_cfgParameter.communicationID[2]; - pack.communicationID[3] = g_cfgParameter.communicationID[3]; - - pack.controlWord = Tpack->controlWord; - - pack.dataLen[0] = HY_queryTimeResponse_dataLen >> 8; - pack.dataLen[1] = HY_queryTimeResponse_dataLen; - - static timeInfo time; - getRTC_Time(&time); - - pack.time = time; - - pack.frameNumber = Tpack->frameNumber; - - pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryTimeResponse_PACK_SIZE - 2); - pack.end_Flag = g_cfgParameter.endFlagHY; - - uart_interruptSend(device, (uint8_t *)&pack, HY_queryTimeResponse_PACK_SIZE); - // uart_dev_write(device, (uint8_t *)&pack, HY_queryTimeResponse_PACK_SIZE); -} \ No newline at end of file diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index a4164aa..afc72c0 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -2,7 +2,7 @@ #include "inFlash.h" #include "parameter.h" #include "pDebug.h" -#include "cfg_protocol.h" +//#include "cfg_protocol.h" #include "configParameter.h" static void save_config_info(config_info *save_config_info); diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index 2236615..e356ac0 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -5,16 +5,20 @@ #include "FM_GPIO.h" #include "chargControlTypes.h" #include "bl_chargControl.h" -#include "hy_protocol.h" -#include "cfg_protocol.h" +//#include "hy_protocol.h" +//#include "cfg_protocol.h" #include "uart_dev.h" #include "abnormalManage.h" #include "interruptSend.h" #include "configParameter.h" #include "capture.h" +#include "bl_usart.h" #include + + + /* 控制运行指示灯和喂狗 */ #define runled_reloadVal 2000 /* 任务执行间隔 */ // static uint16_t runled_reloadVal = 1000; /* 任务执行间隔 */ @@ -58,31 +62,31 @@ static void Task_impedanceCalculation(void); STR_TimeSliceOffset m_collectOpenCircuitVoltage; void Task_collectOpenCircuitVoltage(void); -/* 限时开启HY协议配置模式 */ -#define beginHYconfigMode_reloadVal 1000 /* 任务执行间隔 */ -#define beginHYconfigMode_offset 0 /* 任务执行偏移量 */ -static STR_TimeSliceOffset m_beginHYconfigMode; -static void Task_beginHYconfigMode(void); +// /* 限时开启HY协议配置模式 */ +// #define beginHYconfigMode_reloadVal 1000 /* 任务执行间隔 */ +// #define beginHYconfigMode_offset 0 /* 任务执行偏移量 */ +// static STR_TimeSliceOffset m_beginHYconfigMode; +// static void Task_beginHYconfigMode(void); -/* 串口数据接收判断 */ -#define usartJudge_reloadVal 100 /* 任务执行间隔 */ -#define usartJudge_offset 0 /* 任务执行偏移量 */ -static STR_TimeSliceOffset m_usartJudge; -static void Task_usartJudge(void); +// /* 串口数据接收判断 */ +// #define usartJudge_reloadVal 100 /* 任务执行间隔 */ +// #define usartJudge_offset 0 /* 任务执行偏移量 */ +// static STR_TimeSliceOffset m_usartJudge; +// static void Task_usartJudge(void); -/* 串口数据解析和处理 */ -#define usartHandle_reloadVal 20 /* 任务执行间隔 */ -#define usartHandle_offset 0 /* 任务执行偏移量 */ -static STR_TimeSliceOffset m_usartHandle; -static void Task_usartHandle(void); -typedef void (*uartJudgeHandle)(device_handle device); -static uartJudgeHandle uart_judge_handle; +// /* 串口数据解析和处理 */ +// #define usartHandle_reloadVal 20 /* 任务执行间隔 */ +// #define usartHandle_offset 0 /* 任务执行偏移量 */ +// static STR_TimeSliceOffset m_usartHandle; +// static void Task_usartHandle(void); +// typedef void (*uartJudgeHandle)(device_handle device); +// static uartJudgeHandle uart_judge_handle; -/* 配置文件数据解析和处理 */ -#define usartCfg_reloadVal 200 /* 任务执行间隔 */ -#define usartCfg_offset 0 /* 任务执行偏移量 */ -static STR_TimeSliceOffset m_usartCfg; -static void Task_usartCfg(void); +// /* 配置文件数据解析和处理 */ +// #define usartCfg_reloadVal 200 /* 任务执行间隔 */ +// #define usartCfg_offset 0 /* 任务执行偏移量 */ +// static STR_TimeSliceOffset m_usartCfg; +// static void Task_usartCfg(void); /* 短路保护 */ #define shortCircuitProtection_reloadVal 1000 /* 任务执行间隔 */ @@ -120,6 +124,13 @@ void Task_busFree(void); STR_TimeSliceOffset m_softShortCircuit; void Task_softShortCircuit(void); + +/* 串口任务 */ +#define uart_reloadVal 100 /* 任务执行间隔 */ +#define uart_offset 0 /* 任务执行偏移量 */ +STR_TimeSliceOffset m_uart; +void Task_uart(void); + /** * @brief 启动时初始化各任务 * @param None @@ -136,9 +147,7 @@ void task_Init(void) TimeSliceOffset_Register(&m_collectOpenCircuitVoltage, Task_collectOpenCircuitVoltage , collectOpenCircuitVoltage_reloadVal, collectOpenCircuitVoltage_offset); - uartTaskInit(); - TimeSliceOffset_Register(&m_usartJudge, Task_usartJudge, usartJudge_reloadVal, usartJudge_offset); - TimeSliceOffset_Register(&m_usartCfg, Task_usartCfg, usartCfg_reloadVal, usartCfg_offset); + TimeSliceOffset_Register(&m_uart, Task_uart, uart_reloadVal, uart_offset); TimeSliceOffset_Register(&m_busFree, Task_busFree, busFree_reloadVal, busFree_offset); } @@ -179,17 +188,17 @@ void Task_wdi(void) { feedDog(); - debug_printf("chargCurrent:%f \n", getChargCurrent()); - debug_printf("outputVoltage:%f \n", getOutputVoltage()); - debug_printf("BatteryVoltage:%f \n", getBatteryVoltage()); - debug_printf("dischargCurrent:%f \n", getDischargCurrent()); - debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage()); - debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature()); - debug_printf("InputVoltage:%f \n", getInputVoltage()); - debug_printf("DischargMosState:%d \n", getDischargMosState()); - debug_printf("MPPT_Mode:%d \n", getMPPT_Mode()); - debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance); - debug_printf("DutyRatio:%f \n", getDutyRatio()); + // debug_printf("chargCurrent:%f \n", getChargCurrent()); + // debug_printf("outputVoltage:%f \n", getOutputVoltage()); + // debug_printf("BatteryVoltage:%f \n", getBatteryVoltage()); + // debug_printf("dischargCurrent:%f \n", getDischargCurrent()); + // debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage()); + // debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature()); + // debug_printf("InputVoltage:%f \n", getInputVoltage()); + // debug_printf("DischargMosState:%d \n", getDischargMosState()); + // debug_printf("MPPT_Mode:%d \n", getMPPT_Mode()); + // debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance); + // debug_printf("DutyRatio:%f \n", getDutyRatio()); // char buf[100]; // sprintf(buf, "chargCurrent:%f \n", getChargCurrent()); @@ -502,86 +511,86 @@ void Task_collectOpenCircuitVoltage(void) } } -/** - * @brief 开启HY配置模式后,配置完成后120S后自动退出 - * @param - * @retval - */ -void Task_beginHYconfigMode(void) -{ - static uint8_t num = 0; - num++; - if (num >= 120) { - TimeSliceOffset_Unregister(&m_beginHYconfigMode); - m_beginHYconfigMode.runFlag = 0; - num = 0; - setHYconfigModeState(FALSE); - } -} +// /** +// * @brief 开启HY配置模式后,配置完成后120S后自动退出 +// * @param +// * @retval +// */ +// void Task_beginHYconfigMode(void) +// { +// static uint8_t num = 0; +// num++; +// if (num >= 120) { +// TimeSliceOffset_Unregister(&m_beginHYconfigMode); +// m_beginHYconfigMode.runFlag = 0; +// num = 0; +// setHYconfigModeState(FALSE); +// } +// } -/** - * @brief 开启HY配置模式后启动退出任务 - * @param - * @retval - */ -void beginHYconfigMode(void) -{ - setHYconfigModeState(TRUE); - TimeSliceOffset_Register(&m_beginHYconfigMode, Task_beginHYconfigMode - , beginHYconfigMode_reloadVal, beginHYconfigMode_offset); -} +// /** +// * @brief 开启HY配置模式后启动退出任务 +// * @param +// * @retval +// */ +// void beginHYconfigMode(void) +// { +// setHYconfigModeState(TRUE); +// TimeSliceOffset_Register(&m_beginHYconfigMode, Task_beginHYconfigMode +// , beginHYconfigMode_reloadVal, beginHYconfigMode_offset); +// } -/** - * @brief 初始化串口任务,确定使用的协议 - * @param - * @retval - */ -void uartTaskInit(void) -{ - // if (g_cfgParameter.CommunicationProtocolType == 0x00) { - // uart_judge_handle = read_and_process_uart_data; - // } else if (g_cfgParameter.CommunicationProtocolType == 0x01) { - // uart_judge_handle = HY_read_and_process_uart_data; - // } +// /** +// * @brief 初始化串口任务,确定使用的协议 +// * @param +// * @retval +// */ +// void uartTaskInit(void) +// { +// // if (g_cfgParameter.CommunicationProtocolType == 0x00) { +// // uart_judge_handle = read_and_process_uart_data; +// // } else if (g_cfgParameter.CommunicationProtocolType == 0x01) { +// // uart_judge_handle = HY_read_and_process_uart_data; +// // } - uart_judge_handle = HY_read_and_process_uart_data; -} +// uart_judge_handle = HY_read_and_process_uart_data; +// } -/** - * @brief 检测有无通信数据传来 - * @param - * @retval - */ -void Task_usartJudge(void) -{ - /* 检测到对上通信串口有数据启动读取并解析任务 */ - if (uart_dev_char_present(g_gw485_uart2_handle)) { - TimeSliceOffset_Register(&m_usartHandle, Task_usartHandle - , usartHandle_reloadVal, usartHandle_offset); - } -} +// /** +// * @brief 检测有无通信数据传来 +// * @param +// * @retval +// */ +// void Task_usartJudge(void) +// { +// /* 检测到对上通信串口有数据启动读取并解析任务 */ +// if (uart_dev_char_present(g_gw485_uart2_handle)) { +// TimeSliceOffset_Register(&m_usartHandle, Task_usartHandle +// , usartHandle_reloadVal, usartHandle_offset); +// } +// } -/** - * @brief 读取并解析对上通讯的数据 - * @param - * @retval - */ -void Task_usartHandle(void) -{ - TimeSliceOffset_Unregister(&m_usartHandle); - m_usartHandle.runFlag = 0; - uart_judge_handle(g_gw485_uart2_handle); -} +// /** +// * @brief 读取并解析对上通讯的数据 +// * @param +// * @retval +// */ +// void Task_usartHandle(void) +// { +// TimeSliceOffset_Unregister(&m_usartHandle); +// m_usartHandle.runFlag = 0; +// uart_judge_handle(g_gw485_uart2_handle); +// } -/** - * @brief 读取并解析配置文件的数据 - * @param - * @retval - */ -void Task_usartCfg(void) -{ - read_and_process_config_data(); -} +// /** +// * @brief 读取并解析配置文件的数据 +// * @param +// * @retval +// */ +// void Task_usartCfg(void) +// { +// read_and_process_config_data(); +// } /** * @brief 短路保护任务,短路后启动该任务 @@ -774,4 +783,15 @@ void startSoftShortCircuitProtection(void) { TimeSliceOffset_Register(&m_softShortCircuit, Task_softShortCircuit , softShortCircuit_reloadVal, softShortCircuit_offset); -} \ No newline at end of file +} + + +/** + * @brief 启动软件解析任务 + * @param + * @retval + */ +void Task_uart(void) +{ + gw485DataAnalysis(g_gw485_uart2_handle); +} diff --git a/EWARM/chargeController.ewp b/EWARM/chargeController.ewp index d0eda29..2269689 100644 --- a/EWARM/chargeController.ewp +++ b/EWARM/chargeController.ewp @@ -1,1348 +1,1347 @@ - 4 - - chargeController - - ARM - - 1 - - General - 3 - - 36 - 1 + 4 + + chargeController + + ARM + 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 38 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 12 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - 160 - inputOutputBased - - - - ILINK - 0 - - 27 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BUILDACTION - 2 - - - - Coder - 0 - - - - - APP + + General + 3 + + 36 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 38 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 12 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + 1 + inputOutputBased + + + + ILINK + 0 + + 27 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BUILDACTION + 2 + + + + Coder + 0 + + + - application - - $PROJ_DIR$\..\APP\application\Src\chargControl.c - - - $PROJ_DIR$\..\APP\application\Src\start.c - + APP + + application + + $PROJ_DIR$\..\APP\application\Src\chargControl.c + + + $PROJ_DIR$\..\APP\application\Src\start.c + + + + businessLogic + + $PROJ_DIR$\..\APP\businessLogic\Src\abnormalManage.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\bl_chargControl.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\bl_comm.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\bl_usart.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\Init.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\interruptSend.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\parameter.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\SOE.c + + + $PROJ_DIR$\..\APP\businessLogic\Src\task.c + + + + functionalModule + + $PROJ_DIR$\..\APP\functionalModule\Src\capture.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\checkTime.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\flash.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\FM_GPIO.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\FM_RTC.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\FM_TIM.c + + + $PROJ_DIR$\..\APP\functionalModule\Src\uart_dev.c + + + + hardwareDriver + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_ADC.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_COMM.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_GPIO.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_RTC.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_TIM.c + + + $PROJ_DIR$\..\APP\hardwareDriver\Src\w25qxx.c + + - businessLogic - - $PROJ_DIR$\..\APP\businessLogic\Src\abnormalManage.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\bl_chargControl.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\bl_comm.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\cfg_protocol.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\hy_protocol.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\Init.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\interruptSend.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\parameter.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\task.c - + Application + + EWARM + + $PROJ_DIR$\startup_stm32g431xx.s + + + + User + + Core + + $PROJ_DIR$\..\Core\Src\adc.c + + + $PROJ_DIR$\..\Core\Src\dma.c + + + $PROJ_DIR$\..\Core\Src\gpio.c + + + $PROJ_DIR$\..\Core\Src\main.c + + + $PROJ_DIR$\..\Core\Src\rtc.c + + + $PROJ_DIR$\..\Core\Src\spi.c + + + $PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c + + + $PROJ_DIR$\..\Core\Src\stm32g4xx_it.c + + + $PROJ_DIR$\..\Core\Src\tim.c + + + $PROJ_DIR$\..\Core\Src\usart.c + + + - functionalModule - - $PROJ_DIR$\..\APP\functionalModule\Src\capture.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\checkTime.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\flash.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\FM_GPIO.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\FM_RTC.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\FM_TIM.c - - - $PROJ_DIR$\..\APP\functionalModule\Src\uart_dev.c - + Drivers + + CMSIS + + $PROJ_DIR$\..\Core\Src\system_stm32g4xx.c + + + + STM32G4xx_HAL_Driver + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rtc.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rtc_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c + + + $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c + + - hardwareDriver - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_ADC.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_COMM.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_GPIO.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_RTC.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\HD_TIM.c - - - $PROJ_DIR$\..\APP\hardwareDriver\Src\w25qxx.c - - - - - Application - - EWARM - - $PROJ_DIR$\startup_stm32g431xx.s - + Middlewares + + Library + + DSP Library/DSP Library + + $PROJ_DIR$\..\Middlewares\ST\ARM\DSP\Lib\iar_cortexM4lf_math.a + + + - User - - Core + tools - $PROJ_DIR$\..\Core\Src\main.c + $PROJ_DIR$\..\tools\RingQueue\ring_queue.c - $PROJ_DIR$\..\Core\Src\gpio.c + $PROJ_DIR$\..\tools\TimeSliceOffset\timeSliceOffset.c - - $PROJ_DIR$\..\Core\Src\adc.c - - - $PROJ_DIR$\..\Core\Src\dma.c - - - $PROJ_DIR$\..\Core\Src\rtc.c - - - $PROJ_DIR$\..\Core\Src\spi.c - - - $PROJ_DIR$\..\Core\Src\tim.c - - - $PROJ_DIR$\..\Core\Src\usart.c - - - $PROJ_DIR$\..\Core\Src\stm32g4xx_it.c - - - $PROJ_DIR$\..\Core\Src\stm32g4xx_hal_msp.c - - - - - Drivers - - CMSIS - - $PROJ_DIR$\..\Core\Src\system_stm32g4xx.c - - - - STM32G4xx_HAL_Driver - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_adc_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_ll_adc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rcc_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_flash_ramfunc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_gpio.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_exti.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_dma_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_pwr_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_cortex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rtc.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_rtc_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_spi_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_tim_ex.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart.c - - - $PROJ_DIR$\..\Drivers\STM32G4xx_HAL_Driver\Src\stm32g4xx_hal_uart_ex.c - - - - - tools - - $PROJ_DIR$\..\tools\RingQueue\ring_queue.c - - - $PROJ_DIR$\..\tools\TimeSliceOffset\timeSliceOffset.c - - - - Middlewares - - Library - - DSP Library/DSP Library - - $PROJ_DIR$/../Middlewares/ST/ARM/DSP/Lib/iar_cortexM4lf_math.a - - - - - diff --git a/EWARM/chargeController.ewt b/EWARM/chargeController.ewt index b92301b..8eb6877 100644 --- a/EWARM/chargeController.ewt +++ b/EWARM/chargeController.ewt @@ -1449,10 +1449,7 @@ $PROJ_DIR$\..\APP\businessLogic\Src\bl_comm.c - $PROJ_DIR$\..\APP\businessLogic\Src\cfg_protocol.c - - - $PROJ_DIR$\..\APP\businessLogic\Src\hy_protocol.c + $PROJ_DIR$\..\APP\businessLogic\Src\bl_usart.c $PROJ_DIR$\..\APP\businessLogic\Src\inFlash.c @@ -1466,6 +1463,9 @@ $PROJ_DIR$\..\APP\businessLogic\Src\parameter.c + + $PROJ_DIR$\..\APP\businessLogic\Src\SOE.c + $PROJ_DIR$\..\APP\businessLogic\Src\task.c diff --git a/tools/configParameter.h b/tools/configParameter.h index 47c1f18..e2fbc2a 100644 --- a/tools/configParameter.h +++ b/tools/configParameter.h @@ -4,6 +4,7 @@ #include "comm_types.h" +#define softVer "SV01_24101501" // /* 第一段保护的延时时间(单位100uS) */ // const uint32_t firstStageProtectionDelay = 2; // 200uS @@ -64,4 +65,8 @@ /* 最大充电电压(V) */ #define maxOpenSolarOpenCircuitVMacro 25.0f + + + + #endif