Browse Source

合并修改,增加FFT

LAPTOP-KB7QFH2U\ChenJie-PC 2 years ago
parent
commit
0972942b57

+ 8 - 0
.vscode/settings.json

@@ -0,0 +1,8 @@
+{
+    "files.associations": {
+        "adc.h": "c",
+        "apptaskcan.h": "c",
+        "appglobalvar.h": "c",
+        "hal_adapter.h": "c"
+    }
+}

+ 161 - 157
code/app/AppGlobalVar.c

@@ -3,7 +3,7 @@
  * @Date         : 2022-01-23 13:45:09
  * @Version      : V3.0
  * @LastEditors: chenjie
- * @LastEditTime: 2022-10-28
+ * @LastEditTime: 2022-11-10
  * @Description  : file content
  * @FilePath: \S32K146_4G\code\app\AppGlobalVar.c
  */
@@ -15,7 +15,15 @@
  */
 
 #include "AppGlobalVar.h"
-//测试
+
+#define defaultSn "GYTEST00000000001"
+
+#define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
+#include "Eep_MemMap.h"
+AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
+#define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
+#include "Eep_MemMap.h"
+
 #ifdef APP_RELEASE
 const char WebSiteName[] = "\"iotp.fast-fun.cn\"";
 uint16 WebSitePort = 8712;
@@ -26,8 +34,7 @@ uint16 WebSitePort = 8812;
 
 //*全局变量*//
 const uint32 AppSwVersion = 0x00000105;
-
-const uint8 DataModuleType = 0x02;//01=NB,02-4G
+const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x001;
 const uint32 BlSwVersion = 0x00000001;
 const uint32 DrvSwVersion = 0x00000001;
@@ -53,7 +60,7 @@ QueueHandle_t CanRecvQueueHandle0;
 QueueHandle_t CanRecvQueueHandle1;
 QueueHandle_t CanRecvQueueHandle2;
 
-TaskHandle_t Uart_Hal_RecvTask_Handle,Uart_Hal_SendTask_Handle,MainTask_Handle,Uart0Task_Handle,CanTask_Handle,GpsTask_Handle,Uart_4G_Task_Handle;
+TaskHandle_t Uart_Hal_RecvTask_Handle, Uart_Hal_SendTask_Handle, MainTask_Handle, Uart0Task_Handle, CanTask_Handle, GpsTask_Handle, Uart_4G_Task_Handle;
 SemaphoreHandle_t sleep_mutex = NULL;
 
 bool TcpSysReboot = 1;
@@ -65,11 +72,8 @@ sint8 RegChkRet = 0;
 char WebSiteIp[20] = {0};
 uint8 TcpWorkState = 0;
 
-#define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
-#include "Eep_MemMap.h"
-AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
-#define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
-#include "Eep_MemMap.h"
+real_T returnFreq[3][5];
+real_T returnP[3][5];
 
 /*以下变量均为App_CAN相关变量*/
 #ifdef APP_CAN_ENABLE
@@ -131,186 +135,186 @@ UINT8 BcuRxFlag[28];
 /************************************************************
  *BCU->4G解码变量存放区
  ************************************************************/
-UINT8 BMS_ReqVIN = 0x00;						//是否请求VIN码,0:预留;1:请求VIN;2:不请求VIN;3:无效;,Re-1,Off-0,
-UINT8 BMS_ReqHVOff = 0x00;						//是否请求下高压,0:预留;1:请求下高压;2:不请求下高压;3:无效;,Re-1,Off-0,
-UINT8 BMS_ProtocolEditionH = 0x00;				//通讯协议版本高位(例 : 版本为3 .1, 则此处发3),	, Re - 1, Off - 0,
-UINT8 BMS_ProtocolEditionL = 0x00;				//通讯协议版本低位(例 : 版本为3 .1, 则此处发1),	, Re - 1, Off - 0,
-UINT8 BMS_CharDevNum = 0x00;					//可充电装置系统序号(BMS是整车中可充电装置系统中的第几个, 需要整车告知),1,Re-1,Off-0,
-UINT8 BMS_FtPosRly = 0x00;						//主正继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegRly = 0x00;						//主负继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly1 = 0x00;					//充正1继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly1 = 0x00;					//充负1继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly2 = 0x00;					//充正2继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly2 = 0x00;					//充负2继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHeatRly1 = 0x00;					//加热1/正继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHeatRly2 = 0x00;					//加热2/负继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_StPosRly = 0x00;						//主正继电器状态(如继电器状态由BMS检测),0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StNegRly = 0x00;						//主负继电器状态(如继电器状态由BMS检测),0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StPreCharRly = 0x00;					//预充继电器状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StPosCharRly1 = 0x00;					//直流充正继电器1状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StNegCharRly1 = 0x00;					//直流充负继电器1状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StPosCharRly2 = 0x00;					//直流充正继电器2状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StNegCharRly2 = 0x00;					//直流充负继电器2状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_FtAuxRelayWeld = 0x00;				//附件继电器粘连故障(保留),0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_BraOpenCirc = 0x00;					//支路断路故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtBackCharCurrOutLim = 0x00;			//回充电流超限报警,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtPosRlyOpen = 0x00;					//主正继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegRlyOpen = 0x00;					//主负继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly1Open = 0x00;				//直流充电正1继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly2Open = 0x00;				//直流充电正2继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly1Open = 0x00;				//直流充电负1继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly2Open = 0x00;				//直流充电负2继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtTMSContClose = 0x00;				//加热膜或TMS接触器无法断开报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtTMSContOpen = 0x00;					//加热膜或TMS接触器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtTMS = 0x00;							//热管理系统故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_ReqVIN = 0x00;						// 是否请求VIN码,0:预留;1:请求VIN;2:不请求VIN;3:无效;,Re-1,Off-0,
+UINT8 BMS_ReqHVOff = 0x00;						// 是否请求下高压,0:预留;1:请求下高压;2:不请求下高压;3:无效;,Re-1,Off-0,
+UINT8 BMS_ProtocolEditionH = 0x00;				// 通讯协议版本高位(例 : 版本为3 .1, 则此处发3),	, Re - 1, Off - 0,
+UINT8 BMS_ProtocolEditionL = 0x00;				// 通讯协议版本低位(例 : 版本为3 .1, 则此处发1),	, Re - 1, Off - 0,
+UINT8 BMS_CharDevNum = 0x00;					// 可充电装置系统序号(BMS是整车中可充电装置系统中的第几个, 需要整车告知),1,Re-1,Off-0,
+UINT8 BMS_FtPosRly = 0x00;						// 主正继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtNegRly = 0x00;						// 主负继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtPosCharRly1 = 0x00;					// 充正1继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtNegCharRly1 = 0x00;					// 充负1继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtPosCharRly2 = 0x00;					// 充正2继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtNegCharRly2 = 0x00;					// 充负2继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtHeatRly1 = 0x00;					// 加热1/正继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtHeatRly2 = 0x00;					// 加热2/负继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_StPosRly = 0x00;						// 主正继电器状态(如继电器状态由BMS检测),0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_StNegRly = 0x00;						// 主负继电器状态(如继电器状态由BMS检测),0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_StPreCharRly = 0x00;					// 预充继电器状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_StPosCharRly1 = 0x00;					// 直流充正继电器1状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_StNegCharRly1 = 0x00;					// 直流充负继电器1状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_StPosCharRly2 = 0x00;					// 直流充正继电器2状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_StNegCharRly2 = 0x00;					// 直流充负继电器2状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
+UINT8 BMS_FtAuxRelayWeld = 0x00;				// 附件继电器粘连故障(保留),0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_BraOpenCirc = 0x00;					// 支路断路故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtBackCharCurrOutLim = 0x00;			// 回充电流超限报警,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtPosRlyOpen = 0x00;					// 主正继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtNegRlyOpen = 0x00;					// 主负继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtPosCharRly1Open = 0x00;				// 直流充电正1继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtPosCharRly2Open = 0x00;				// 直流充电正2继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtNegCharRly1Open = 0x00;				// 直流充电负1继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtNegCharRly2Open = 0x00;				// 直流充电负2继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtTMSContClose = 0x00;				// 加热膜或TMS接触器无法断开报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtTMSContOpen = 0x00;					// 加热膜或TMS接触器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtTMS = 0x00;							// 热管理系统故障,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_Ft24VSpy = 0x00;						// BMS 24V供电异常报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPACKSelfProt = 0x00;				//电池包自保护报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCharSockTempOver = 0x00;			//充电插座过温报警,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtTempOutCtrl = 0x00;					//热失控报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_StPosHeatRly = 0x00;					//加热正继电器状态,0:保留;1:开启;2:闭合;3:无效,Re-1,Off-0,
-UINT8 BMS_StNegHeatRly = 0x00;					//加热负继电器状态,0:保留;1:开启;2:闭合;3:无效,Re-1,Off-0,
-UINT8 BMS_CharSysNum = 0x00;					//可充电储能子系统总数(保留),,Re-1,Off-0,
-UINT8 BMS_FtCode = 0x00;						//电池系统故障码,详见附表电池系统故障码列表,Re-1,Off-0,
+UINT8 BMS_FtPACKSelfProt = 0x00;				// 电池包自保护报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtCharSockTempOver = 0x00;			// 充电插座过温报警,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtTempOutCtrl = 0x00;					// 热失控报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_StPosHeatRly = 0x00;					// 加热正继电器状态,0:保留;1:开启;2:闭合;3:无效,Re-1,Off-0,
+UINT8 BMS_StNegHeatRly = 0x00;					// 加热负继电器状态,0:保留;1:开启;2:闭合;3:无效,Re-1,Off-0,
+UINT8 BMS_CharSysNum = 0x00;					// 可充电储能子系统总数(保留),,Re-1,Off-0,
+UINT8 BMS_FtCode = 0x00;						// 电池系统故障码,详见附表电池系统故障码列表,Re-1,Off-0,
 UINT8 BMS_ST1CheckSum = 0x00;					// B2V_ST1的CheckSum,Byte0=Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 XOR Byte7,Re-1,Off-0,
 UINT8 BMS_ST1Counter = 0x00;					// B2V_ST1的生命信号,0~14循环,15:信号无效,Re-1,Off-0,
 UINT8 BMS_Mode = 0x00;							// BMS当前状态,0:预留;1:高压上电;2:高压下电;3:无效;,Re-1,Off-0,
-UINT8 BMS_AuxRlySt = 0x00;						//附件继电器状态,0:开启;1:闭合;,Re-1,Off-0,
+UINT8 BMS_AuxRlySt = 0x00;						// 附件继电器状态,0:开启;1:闭合;,Re-1,Off-0,
 UINT8 BMS_BattBalaSt = 0x00;					// BMS当前均衡状态,0:未开启均衡;1:开启均衡;,Re-1,Off-0,
-UINT8 BMS_CharGunSt = 0x00;						//直流充电枪连接状态,0:未连接1 : 连接, Re - 1, Off - 0,
+UINT8 BMS_CharGunSt = 0x00;						// 直流充电枪连接状态,0:未连接1 : 连接, Re - 1, Off - 0,
 UINT8 BMS_CharMode = 0x00;						// BMS当前充电模式,0:预留1 : 直流充电 2 : 交流充电 3 : 其他充电, Re - 1, Off - 0,
-UINT8 BMS_CharSt = 0x00;						//充电状态,0:可以充电1 : 正在充电 2 : 充电结束 3 : 充电故障, Re - 1, Off - 0,
-UINT8 BMS_FtLvl = 0x00;							//当前最高故障等级,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellTempDiff = 0x00;				//电芯温差异常报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellTempHigh = 0x00;				//电芯温度过高报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_CharSt = 0x00;						// 充电状态,0:可以充电1 : 正在充电 2 : 充电结束 3 : 充电故障, Re - 1, Off - 0,
+UINT8 BMS_FtLvl = 0x00;							// 当前最高故障等级,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCellTempDiff = 0x00;				// 电芯温差异常报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCellTempHigh = 0x00;				// 电芯温度过高报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
 UINT8 BMS_FtPACKOverVolt = 0x00;				// PACK过压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
 UINT8 BMS_FtPACKUndeVolt = 0x00;				// PACK欠压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
 UINT8 BMS_FtSOCLow = 0x00;						// SOC过低报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellOverVolt = 0x00;				//单体电压过高报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellUndeVolt = 0x00;				//单体电压欠压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtIns = 0x00;							//绝缘报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellOverVoltDiff = 0x00;			//单体压差过大,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCharCurrOver = 0x00;				//充电电流过大报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtDisCharCurrOver = 0x00;				//放电电流过大报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellTempLow = 0x00;					//电芯温度过低报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtBranVoltDifOver = 0x00;				//支路压差过大报警(存在并联支路的系统),0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCellOverVolt = 0x00;				// 单体电压过高报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCellUndeVolt = 0x00;				// 单体电压欠压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtIns = 0x00;							// 绝缘报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCellOverVoltDiff = 0x00;			// 单体压差过大,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCharCurrOver = 0x00;				// 充电电流过大报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtDisCharCurrOver = 0x00;				// 放电电流过大报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtCellTempLow = 0x00;					// 电芯温度过低报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtBranVoltDifOver = 0x00;				// 支路压差过大报警(存在并联支路的系统),0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
 UINT8 BMS_FtBMSHardWare = 0x00;					// BMS硬件故障,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
 UINT8 BMS_FtSOCHigh = 0x00;						// SOC过高报警,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtSOCJump = 0x00;						// SOC跳变报警,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtInCom = 0x00;						// BMS内部通信故障,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtSysMism = 0x00;						// BMS/可充电储能系统不匹配报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHvIntLock = 0x00;					//高压互锁报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtSmoke = 0x00;						//火警探测器故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtFire = 0x00;						//电池包火灾报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtHvIntLock = 0x00;					// 高压互锁报警,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtSmoke = 0x00;						// 火警探测器故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtFire = 0x00;						// 电池包火灾报警,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtNum = 0x00;							// BMS当前发生的故障总数目(包括GB32960中规定的故障数目),,Re-1,Off-0,
-UINT8 BMS_PackSOC = 0x00;						//电池包SOC,,Re-0.4,Off-0,
-UINT8 BMS_PackSOH = 0x00;						//电池包SOH,,Re-0.4,Off-0,
-UINT8 BMS_MaxCellTemp = 0x00;					//单体最高温度,,Re-1,Off--50,℃
-UINT8 BMS_MinCellTemp = 0x00;					//单体最低温度,,Re-1,Off--50,℃
-UINT8 BMS_AverCellTemp = 0x00;					//单体平均温度,,Re-1,Off--50,℃
-UINT8 BMS_MaxCellTempCSC = 0x00;				//最高温度电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MaxCellTempNum = 0x00;				//最高温度电芯所在子系统(CSC)内温度探针编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellTempCSC = 0x00;				//最低温度电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellTempNum = 0x00;				//最低温度电芯所在子系统(CSC)内温度探针编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MaxCellVoltCSC = 0x00;				//最高电压电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MaxCellVoltNum = 0x00;				//最高电压电芯所在子系统(CSC)内单体编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellVoltCSC = 0x00;				//最低电压电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellVoltNum = 0x00;				//最低电压电芯所在子系统(CSC)内单体编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_PackSOC = 0x00;						// 电池包SOC,,Re-0.4,Off-0,
+UINT8 BMS_PackSOH = 0x00;						// 电池包SOH,,Re-0.4,Off-0,
+UINT8 BMS_MaxCellTemp = 0x00;					// 单体最高温度,,Re-1,Off--50,℃
+UINT8 BMS_MinCellTemp = 0x00;					// 单体最低温度,,Re-1,Off--50,℃
+UINT8 BMS_AverCellTemp = 0x00;					// 单体平均温度,,Re-1,Off--50,℃
+UINT8 BMS_MaxCellTempCSC = 0x00;				// 最高温度电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MaxCellTempNum = 0x00;				// 最高温度电芯所在子系统(CSC)内温度探针编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MinCellTempCSC = 0x00;				// 最低温度电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MinCellTempNum = 0x00;				// 最低温度电芯所在子系统(CSC)内温度探针编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MaxCellVoltCSC = 0x00;				// 最高电压电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MaxCellVoltNum = 0x00;				// 最高电压电芯所在子系统(CSC)内单体编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MinCellVoltCSC = 0x00;				// 最低电压电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
+UINT8 BMS_MinCellVoltNum = 0x00;				// 最低电压电芯所在子系统(CSC)内单体编号,范围(1~255),Re-1,Off-0,
 UINT8 BMS_InsDeteSt = 0x00;						// BMS绝缘检测状态,0:停止检测;1:激活检测;,Re-1,Off-0,
-UINT8 BMS_FtCharInsLow = 0x00;					//充电绝缘阻值低,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCurrSenr = 0x00;					//电流传感器故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHeatingFilm = 0x00;					//加热膜加热回路故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtMainLoopPreChar = 0x00;				//主回路预充或预检故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtAuxLoopPreChar = 0x00;				//辅件回路预充或预检故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtCharInsLow = 0x00;					// 充电绝缘阻值低,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtCurrSenr = 0x00;					// 电流传感器故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtHeatingFilm = 0x00;					// 加热膜加热回路故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtMainLoopPreChar = 0x00;				// 主回路预充或预检故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtAuxLoopPreChar = 0x00;				// 辅件回路预充或预检故障,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtACANLost = 0x00;					// ACAN/整车CAN通讯故障,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtDCDC = 0x00;						// BMS-DC-DC故障,0:正常; 1:故障,Re-1,Off-0,
 UINT8 BMS_FtSOCDif = 0x00;						// SOC差异过大,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCellOverDisChar = 0x00;				//电芯过放故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCharOver = 0x00;					//车载储能装置过充报警,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtContDisCharCurrOverLoad = 0x00;		//持续回充过流故障,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtContCharCurrOverLoad = 0x00;		//持续放电过流故障,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_Gun1DCNegTemp = 0x00;					//充电口1负温感值,,Re-1,Off--40,℃
-UINT8 BMS_Gun1DCPosTemp = 0x00;					//充电口1正温感值,,Re-1,Off--40,℃
-UINT8 BMS_Gun2DCNegTemp = 0x00;					//充电口2负温感值,,Re-1,Off--40,℃
-UINT8 BMS_Gun2DCPosTemp = 0x00;					//充电口2正温感值,,Re-1,Off--40,℃
-UINT8 BMS_CurrHeatSt = 0x00;					//当前加热状态,0:未加热;1:加热中;2:预留;3:无效;,Re-1,Off-0,
-UINT8 BMS_CurrCoolSt = 0x00;					//当前冷却状态,0:未冷却;1:冷却中;2:预留;3:无效;,Re-1,Off-0,
-UINT8 BMS_FtCharCnct = 0x00;					//插枪连接信号异常,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtOverDisCharCurrDuringChar = 0x00;	//充电时放电电流过大,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCharNTC = 0x00;						//充电插座NTC故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtELock = 0x00;						//电子锁故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_CellVoltFramNum = 0x00;				//单体电压帧序号,有效值1~255,Re-1,Off-0,
-UINT8 BMS_CellTempFramNum = 0x00;				//温度帧序号,有效值1~255,Re-1,Off-0,
-UINT8 BMS_CSC_Code = 0x00;						//子系统编号CSC,有效值1~255,Re-1,Off-0,
-UINT8 BMS_CellTemp[BMS_TEMP_MAX_NUM] = {0x00};	//当前CSC下的第N个探针的温度,255 "Invalid" 0xFF 无效有效值 0 ~254, 单位 ℃, 范围(-50 ~204)℃, , Re - 1, Off-- 50,℃
-UINT8 BMS_Checksum = 0x00;						//电池编码信息1的CheckSum,Byte0=Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 XOR Byte7,Re-1,Off-0,
-UINT8 BMS_PackComp = 0x00;						//电池厂家,1:"CATL" 2:"Li Shen" 3:"MGL" 4:"SAMSUN" 5:"LG",Re-1,Off-0,
-UINT8 BMS_BattCodeLeng = 0x00;					//电池编码长度,0:Do not transmit this Code,Re-1,Off-0,
-UINT8 BMS_SN[27] = {0x00};						//电池编码(SN)字符1(ASCII),,Re-1,Off-0,
-UINT8 BMS_BattType = 0x00;						//电池类型,1:铅酸电池; 2:镍氢电池; 3:磷酸铁锂电池; 4:锰酸锂电池; 5:钴酸锂电池; 6:三元材料电池; 7:聚合物锂离子电池; 8:钛酸锂电池; 9:超级电容; 10~13:保留; 14:燃料电池;15:保留,Re-1,Off-0,
-UINT8 BMS_CoolType = 0x00;						//电池冷却方式,0:其他冷却方式1 : 自然冷却 2 : 风扇冷却 3 : 水冷却, Re - 1, Off - 0,
-UINT8 BMS_CSC_Total = 0x00;						//电池系统中CSC总的数目,,Re-1,Off-0,
-UINT8 BMS_CellVoltLevel = 0x00;					//单体平台电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
-UINT8 BMS_CellMinVolt = 0x00;					//单体可用最低电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
-UINT8 BMS_CellMaxVolt = 0x00;					//单体可用最高电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
-UINT8 BMS_HVBranNum = 0x00;						//电池系统高压支路数,,Re-1,Off-0,
-UINT8 BMS_SingleHVBranchCellNum = 0x00;			//电池系统单支路电芯数,,Re-1,Off-0,
+UINT8 BMS_FtCellOverDisChar = 0x00;				// 电芯过放故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtCharOver = 0x00;					// 车载储能装置过充报警,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtContDisCharCurrOverLoad = 0x00;		// 持续回充过流故障,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_FtContCharCurrOverLoad = 0x00;		// 持续放电过流故障,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
+UINT8 BMS_Gun1DCNegTemp = 0x00;					// 充电口1负温感值,,Re-1,Off--40,℃
+UINT8 BMS_Gun1DCPosTemp = 0x00;					// 充电口1正温感值,,Re-1,Off--40,℃
+UINT8 BMS_Gun2DCNegTemp = 0x00;					// 充电口2负温感值,,Re-1,Off--40,℃
+UINT8 BMS_Gun2DCPosTemp = 0x00;					// 充电口2正温感值,,Re-1,Off--40,℃
+UINT8 BMS_CurrHeatSt = 0x00;					// 当前加热状态,0:未加热;1:加热中;2:预留;3:无效;,Re-1,Off-0,
+UINT8 BMS_CurrCoolSt = 0x00;					// 当前冷却状态,0:未冷却;1:冷却中;2:预留;3:无效;,Re-1,Off-0,
+UINT8 BMS_FtCharCnct = 0x00;					// 插枪连接信号异常,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtOverDisCharCurrDuringChar = 0x00;	// 充电时放电电流过大,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtCharNTC = 0x00;						// 充电插座NTC故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_FtELock = 0x00;						// 电子锁故障,0:正常; 1:故障,Re-1,Off-0,
+UINT8 BMS_CellVoltFramNum = 0x00;				// 单体电压帧序号,有效值1~255,Re-1,Off-0,
+UINT8 BMS_CellTempFramNum = 0x00;				// 温度帧序号,有效值1~255,Re-1,Off-0,
+UINT8 BMS_CSC_Code = 0x00;						// 子系统编号CSC,有效值1~255,Re-1,Off-0,
+UINT8 BMS_CellTemp[BMS_TEMP_MAX_NUM] = {0x00};	// 当前CSC下的第N个探针的温度,255 "Invalid" 0xFF 无效有效值 0 ~254, 单位 ℃, 范围(-50 ~204)℃, , Re - 1, Off-- 50,℃
+UINT8 BMS_Checksum = 0x00;						// 电池编码信息1的CheckSum,Byte0=Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 XOR Byte7,Re-1,Off-0,
+UINT8 BMS_PackComp = 0x00;						// 电池厂家,1:"CATL" 2:"Li Shen" 3:"MGL" 4:"SAMSUN" 5:"LG",Re-1,Off-0,
+UINT8 BMS_BattCodeLeng = 0x00;					// 电池编码长度,0:Do not transmit this Code,Re-1,Off-0,
+UINT8 BMS_SN[27] = {0x00};						// 电池编码(SN)字符1(ASCII),,Re-1,Off-0,
+UINT8 BMS_BattType = 0x00;						// 电池类型,1:铅酸电池; 2:镍氢电池; 3:磷酸铁锂电池; 4:锰酸锂电池; 5:钴酸锂电池; 6:三元材料电池; 7:聚合物锂离子电池; 8:钛酸锂电池; 9:超级电容; 10~13:保留; 14:燃料电池;15:保留,Re-1,Off-0,
+UINT8 BMS_CoolType = 0x00;						// 电池冷却方式,0:其他冷却方式1 : 自然冷却 2 : 风扇冷却 3 : 水冷却, Re - 1, Off - 0,
+UINT8 BMS_CSC_Total = 0x00;						// 电池系统中CSC总的数目,,Re-1,Off-0,
+UINT8 BMS_CellVoltLevel = 0x00;					// 单体平台电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
+UINT8 BMS_CellMinVolt = 0x00;					// 单体可用最低电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
+UINT8 BMS_CellMaxVolt = 0x00;					// 单体可用最高电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
+UINT8 BMS_HVBranNum = 0x00;						// 电池系统高压支路数,,Re-1,Off-0,
+UINT8 BMS_SingleHVBranchCellNum = 0x00;			// 电池系统单支路电芯数,,Re-1,Off-0,
 UINT8 BMS_ReqMode = 0x00;						// BMS请求设定模式,0:关机模式1 : 制冷模式 2 : 制热模式 3 : 自循环模式, Re - 1, Off - 0,
-UINT8 BMS_HVCmd = 0x00;							//高压请求,0:请求上高压1 : 请求下高压, Re - 1, Off - 0,
-UINT8 BMS_ChgSts = 0x00;						//充电状态,0:非充电1 : 充电, Re - 1, Off - 0,
+UINT8 BMS_HVCmd = 0x00;							// 高压请求,0:请求上高压1 : 请求下高压, Re - 1, Off - 0,
+UINT8 BMS_ChgSts = 0x00;						// 充电状态,0:非充电1 : 充电, Re - 1, Off - 0,
 UINT8 BMS_HVRelaySts = 0x00;					// BMS高压继电器状态,0:断开状态; 1:闭合状态; 2~3:无效,Re-1,Off-0,
-UINT8 BMS_SetTemp = 0x00;						//设定温度,,Re-1,Off--40,
+UINT8 BMS_SetTemp = 0x00;						// 设定温度,,Re-1,Off--40,
 UINT8 BMS_Life = 0x00;							// BMS生命帧,,Re-1,Off-0,
 UINT8 BMS_CRC = 0x00;							// CRC校验值,,Re-1,Off-0,
 UINT8 TMS_WorkStatus = 0x00;					// TMS工作状态,0:关机模式1 : 制冷模式 2 : 制热模式 3 : 自循环模式, Re - 1, Off - 0,
 UINT8 TMS_HVRelayST = 0x00;						// TMS高压继电器状态,0:断开状态; 1:闭合状态; 2~3:无效,Re-1,Off-0,
-UINT8 TMS_OutletTemp = 0x00;					//出水温度(机组到电池),255:无效,Re-1,Off--40,
-UINT8 TMS_InletTemp = 0x00;						//回水温度(电池到机组),255:无效,Re-1,Off--40,
+UINT8 TMS_OutletTemp = 0x00;					// 出水温度(机组到电池),255:无效,Re-1,Off--40,
+UINT8 TMS_InletTemp = 0x00;						// 回水温度(电池到机组),255:无效,Re-1,Off--40,
 UINT8 TMS_ErrCode = 0x00;						// TMS故障码,0:无故障; 出现 1 种以上循环发送,Re-1,Off-0,
 UINT8 TMS_FaultLevel = 0x00;					// TMS故障码等级,0:无效1 : 1级故障 2 : 2级故障 3 : 3级故障, Re - 1, Off - 0,
-UINT16 BMS_SoftwareVersion = 0x00;				//软件版本号:RyyyBzzz(R为软件版本、B为测试版本、正式版本不带B)  ,yyy:0~254,精度1,255:无效,不显示;zzz:0~254,精度1,255:无效,不显示;
-UINT16 BMS_HardwareVersion = 0x00;				//硬件版本号:VyyyBzzz(V为硬件版本、B为测试版本、正式版本不带B)  ,,Re-1,Off-0,
-UINT16 BMS_PackCurr = 0x00;						//电池包总电流,充电为负值,放电为正值,,Re-0.1,Off--1000,A
-UINT16 BMS_MaxCharCurr = 0x00;					//电池包最大回充电流,,Re-0.1,Off--1000,A
-UINT16 BMS_MaxDisCharCurr = 0x00;				//电池包最大放电电流,,Re-0.1,Off--1000,A
-UINT16 BMS_PosIns = 0x00;						//母线正对车体绝缘电阻,,Re-1,Off-0,KΩ
-UINT16 BMS_NegIns = 0x00;						//母线负对车体绝缘电阻,,Re-1,Off-0,KΩ
-UINT16 BMS_BattVolt = 0x00;						//电池包内侧电压,,Re-0.1,Off-0,V
-UINT16 BMS_LinkVolt = 0x00;						//电池包外侧电压,,Re-0.1,Off-0,V
-UINT16 BMS_MaxCellVolt = 0x00;					//单体最高电压值,,Re-0.001,Off-0,V
-UINT16 BMS_AverCellVolt = 0x00;					//电芯电压平均值,,Re-0.001,Off-0,V
-UINT16 BMS_MinCellVolt = 0x00;					//电芯最低电压值,,Re-0.001,Off-0,V
+UINT16 BMS_SoftwareVersion = 0x00;				// 软件版本号:RyyyBzzz(R为软件版本、B为测试版本、正式版本不带B)  ,yyy:0~254,精度1,255:无效,不显示;zzz:0~254,精度1,255:无效,不显示;
+UINT16 BMS_HardwareVersion = 0x00;				// 硬件版本号:VyyyBzzz(V为硬件版本、B为测试版本、正式版本不带B)  ,,Re-1,Off-0,
+UINT16 BMS_PackCurr = 0x00;						// 电池包总电流,充电为负值,放电为正值,,Re-0.1,Off--1000,A
+UINT16 BMS_MaxCharCurr = 0x00;					// 电池包最大回充电流,,Re-0.1,Off--1000,A
+UINT16 BMS_MaxDisCharCurr = 0x00;				// 电池包最大放电电流,,Re-0.1,Off--1000,A
+UINT16 BMS_PosIns = 0x00;						// 母线正对车体绝缘电阻,,Re-1,Off-0,KΩ
+UINT16 BMS_NegIns = 0x00;						// 母线负对车体绝缘电阻,,Re-1,Off-0,KΩ
+UINT16 BMS_BattVolt = 0x00;						// 电池包内侧电压,,Re-0.1,Off-0,V
+UINT16 BMS_LinkVolt = 0x00;						// 电池包外侧电压,,Re-0.1,Off-0,V
+UINT16 BMS_MaxCellVolt = 0x00;					// 单体最高电压值,,Re-0.001,Off-0,V
+UINT16 BMS_AverCellVolt = 0x00;					// 电芯电压平均值,,Re-0.001,Off-0,V
+UINT16 BMS_MinCellVolt = 0x00;					// 电芯最低电压值,,Re-0.001,Off-0,V
 UINT16 BMS_ContChrgCurr = 0x00;					// BMS允许的持续回充电流,,Re-0.1,Off-0,A
 UINT16 BMS_ContDisCharCurr = 0x00;				// BMS允许的持续放电电流,,Re-0.1,Off--1000,A
-UINT16 BMS_CharReqVolt = 0x00;					//充电所需电压(交流),,Re-0.1,Off-0,V
-UINT16 BMS_CharReqCurr = 0x00;					//充电所需电流(交流),,Re-0.1,Off--1000,A
-UINT16 BMS_SysInsRes = 0x00;					//系统绝缘电阻,,Re-1,Off-0,KΩ
-UINT16 BMS_MaxDisCharPwr = 0x00;				//最大允许放电功率,,Re-0.1,Off-0,kw
-UINT16 BMS_MaxCharPwr = 0x00;					//最大允许充电功率,,Re-0.1,Off-0,kw
+UINT16 BMS_CharReqVolt = 0x00;					// 充电所需电压(交流),,Re-0.1,Off-0,V
+UINT16 BMS_CharReqCurr = 0x00;					// 充电所需电流(交流),,Re-0.1,Off--1000,A
+UINT16 BMS_SysInsRes = 0x00;					// 系统绝缘电阻,,Re-1,Off-0,KΩ
+UINT16 BMS_MaxDisCharPwr = 0x00;				// 最大允许放电功率,,Re-0.1,Off-0,kw
+UINT16 BMS_MaxCharPwr = 0x00;					// 最大允许充电功率,,Re-0.1,Off-0,kw
 UINT16 BMS_ContDisCharPwr = 0x00;				// BMS允许的持续放电功率,,Re-0.1,Off-0,kw
 UINT16 BMS_ContCharPwr = 0x00;					// BMS允许的持续充电功率,,Re-0.1,Off-0,kw
-UINT16 BMS_InstEngyCons = 0x00;					//动力电池瞬时百公里能耗,,Re-0.1,Off-0,kwh
-UINT16 BMS_TotalEngyCons = 0x00;				//动力电池总/平均百公里能耗,,Re-0.1,Off-0,kwh
-UINT16 BMS_SOE = 0x00;							//剩余电量,,Re-0.01,Off-0,kwh
-UINT16 BMS_RmanCharTime = 0x00;					//剩余充电时间,,Re-1,Off-0,min
-UINT16 BMS_CharNum = 0x00;						//充电次数,,Re-1,Off-0,
-UINT16 BMS_CellVolt[BMS_CELL_MAX_NUM] = {0x00}; //电芯的电压,65535 "Invalid" 0xFFFF 无效有效值 0 ~65534, 范围(0 ~65.534) V, Re - 0.001, Off - 0, V
-UINT16 BMS_BattRateCap = 0x00;					//电池包额定容量,有效值 0~65534,65535 "Signal Invalid" 无效,Re-1,Off-0,Ah
-UINT16 BMS_BattRateVolt = 0x00;					//电池包额定电压,有效值 0~6553.4,65535 "Signal Invalid" 无效,Re-0.1,Off-0,V
-UINT16 BMS_BattRateEngy = 0x00;					//电池包额定能量,有效值 0~6553.4,65535 "Signal Invalid" 无效,Re-0.1,Off-0,kWh
+UINT16 BMS_InstEngyCons = 0x00;					// 动力电池瞬时百公里能耗,,Re-0.1,Off-0,kwh
+UINT16 BMS_TotalEngyCons = 0x00;				// 动力电池总/平均百公里能耗,,Re-0.1,Off-0,kwh
+UINT16 BMS_SOE = 0x00;							// 剩余电量,,Re-0.01,Off-0,kwh
+UINT16 BMS_RmanCharTime = 0x00;					// 剩余充电时间,,Re-1,Off-0,min
+UINT16 BMS_CharNum = 0x00;						// 充电次数,,Re-1,Off-0,
+UINT16 BMS_CellVolt[BMS_CELL_MAX_NUM] = {0x00}; // 电芯的电压,65535 "Invalid" 0xFFFF 无效有效值 0 ~65534, 范围(0 ~65.534) V, Re - 0.001, Off - 0, V
+UINT16 BMS_BattRateCap = 0x00;					// 电池包额定容量,有效值 0~65534,65535 "Signal Invalid" 无效,Re-1,Off-0,Ah
+UINT16 BMS_BattRateVolt = 0x00;					// 电池包额定电压,有效值 0~6553.4,65535 "Signal Invalid" 无效,Re-0.1,Off-0,V
+UINT16 BMS_BattRateEngy = 0x00;					// 电池包额定能量,有效值 0~6553.4,65535 "Signal Invalid" 无效,Re-0.1,Off-0,kWh
 UINT16 BMS_CellTotal = BMS_CELL_MAX_NUM;		// PACK中单体电芯的总数目,,Re-1,Off-0,//
 UINT16 BMS_TempTotal = BMS_TEMP_MAX_NUM;		// PACK中电芯温度点(探针)的总数目,,Re-1,Off-0,
-UINT16 BMS_SingleCharEngy = 0x00;				//单次充电kWh 数,,Re-0.1,Off-0,KWh
-UINT16 BMS_SingleCharCapy = 0x00;				//单次充电Ah 数,,Re-0.1,Off-0,Ah
+UINT16 BMS_SingleCharEngy = 0x00;				// 单次充电kWh 数,,Re-0.1,Off-0,KWh
+UINT16 BMS_SingleCharCapy = 0x00;				// 单次充电Ah 数,,Re-0.1,Off-0,Ah
 UINT16 BMS_HVVolt = 0x00;						// BMS当前电压,,Re-1,Off-0,
 UINT16 TMS_ReqPow = 0x00;						// TMS需求功率,65535:无效,Re-0.1,Off-0,Kw
-UINT32 BMS_TotalCharEngy = 0x00;				//累计充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalDisCharEngy = 0x00;				//累计放出kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalBackCharEngy = 0x00;			//累计动能回馈充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalStaCharEngy = 0x00;				//累计换电站充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalGunCharEngy = 0x00;				//累计插枪充电充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalGunCharCapy = 0x00;				//累计插枪充电充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalCharCapy = 0x00;				//累计充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalDisCharCapy = 0x00;				//累计放出Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalBackCharCapy = 0x00;			//累计动能回馈充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalStaCharCapy = 0x00;				//累计换电站充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BMS_TotalCharEngy = 0x00;				// 累计充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BMS_TotalDisCharEngy = 0x00;				// 累计放出kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BMS_TotalBackCharEngy = 0x00;			// 累计动能回馈充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BMS_TotalStaCharEngy = 0x00;				// 累计换电站充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BMS_TotalGunCharEngy = 0x00;				// 累计插枪充电充入kWh 数,,Re-0.1,Off-0,KWh
+UINT32 BMS_TotalGunCharCapy = 0x00;				// 累计插枪充电充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BMS_TotalCharCapy = 0x00;				// 累计充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BMS_TotalDisCharCapy = 0x00;				// 累计放出Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BMS_TotalBackCharCapy = 0x00;			// 累计动能回馈充入Ah 数,,Re-0.1,Off-0,Ah
+UINT32 BMS_TotalStaCharCapy = 0x00;				// 累计换电站充入Ah 数,,Re-0.1,Off-0,Ah
 #endif

+ 16 - 16
code/app/AppGlobalVar.h

@@ -1,9 +1,9 @@
-/*** 
+/***
  * @Author: chenjie
  * @Date: 2022-10-27
- * @LastEditTime: 2022-10-28
+ * @LastEditTime: 2022-11-10
  * @LastEditors: chenjie
- * @Description: 
+ * @Description:
  * @FilePath: \S32K146_4G\code\app\AppGlobalVar.h
  * @Copyright (c) 2022 by chenjie, All Rights Reserved.
  */
@@ -11,12 +11,10 @@
 #ifndef APPGLOBALVAR_H_
 #define APPGLOBALVAR_H_
 
-#define APP_CAN_ENABLE 
+#define APP_CAN_ENABLE
 
 #include "hal_adapter.h"
-// test Var
-#define defaultSn "GYTEST00000000001"
-// #define defaultSn "PZLCLL128N2236001"
+
 #define BATT_SN_LEN 17
 extern const uint32 AppSwVersion;
 extern const uint8 DataModuleType;
@@ -26,14 +24,13 @@ extern const uint32 DrvSwVersion;
 extern const uint8 BmsManuFacture;
 extern const uint8 BmsInfo;
 
-
 #define BMS_CELL_MAX_NUM 384
 #define BMS_TEMP_MAX_NUM 64
 
 typedef struct _AppDataType
 {
-    uint8 BattCellCount; 
-    uint8 BattTempCount; 
+    uint8 BattCellCount;
+    uint8 BattTempCount;
 } AppDataBody;
 
 extern bool TcpSysReboot;
@@ -54,6 +51,9 @@ typedef struct
 extern QueueHandle_t GpsDataQueueHandle;
 extern sint16 xyzData[3];
 /*Hal_Can*/
+extern real_T returnFreq[3][5];
+extern real_T returnP[3][5];
+
 extern uint8 CanIf_u8TxConfirmCnt;
 extern boolean CanIf_bTxFlag;
 extern uint8 CanIf_u8RxIndicationCnt;
@@ -62,7 +62,7 @@ extern QueueHandle_t CanRecvQueueHandle0;
 extern QueueHandle_t CanRecvQueueHandle1;
 extern QueueHandle_t CanRecvQueueHandle2;
 
-extern TaskHandle_t Uart_Hal_RecvTask_Handle,Uart_Hal_SendTask_Handle,MainTask_Handle,Uart0Task_Handle,CanTask_Handle,GpsTask_Handle,Uart_4G_Task_Handle;
+extern TaskHandle_t Uart_Hal_RecvTask_Handle, Uart_Hal_SendTask_Handle, MainTask_Handle, Uart0Task_Handle, CanTask_Handle, GpsTask_Handle, Uart_4G_Task_Handle;
 extern SemaphoreHandle_t sleep_mutex;
 
 extern uint8 CSQValue;
@@ -76,16 +76,16 @@ extern char IccidNum[20];
 extern uint8 TcpWorkState;
 typedef struct _AppEppType
 {
-	uint32 battDischrgAccCap; 
-	uint32 battDischrgAccEnrg;
-	uint16 battCycleTimes;
-}AppEppBody;
+    uint32 battDischrgAccCap;
+    uint32 battDischrgAccEnrg;
+    uint16 battCycleTimes;
+} AppEppBody;
 typedef struct _AppConfigType
 {
     bool appSaveFlg;
     bool eolFlg;
     uint8 deviceSn[17];
-	AppEppBody AppDataInfo;
+    AppEppBody AppDataInfo;
     uint8 re[20];
 } AppConfigBody;
 extern AppConfigBody AppConfigInfo;

+ 189 - 173
code/app/AppTaskCan.c

@@ -1,17 +1,17 @@
 /*
  * @Author: chenjie
  * @Date: 2022-10-27
- * @LastEditTime: 2022-10-28
+ * @LastEditTime: 2022-11-10
  * @LastEditors: chenjie
- * @Description: 
+ * @Description:
  * @FilePath: \S32K146_4G\code\app\AppTaskCan.c
  * Copyright (c) 2022 by chenjie, All Rights Reserved.
  */
 
 #include "AppTaskCan.h"
+#include "AppFuncLib.h"
 #ifdef APP_CAN_ENABLE
-uint32 timerCANIdle = 0x00;
-uint32 timerCounterNow = 0;
+uint32 timerCounterGetdata = 0;
 static uint8 BattSendFlg = 0;
 static void UDSAnsFunc(uint8 *rawData);
 static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen);
@@ -23,11 +23,12 @@ static void vCanRxCallback(TimerHandle_t pxTimer)
 	if (ulTimerID == 0)
 	{
 		Can_MainFunction_Read();
-		timerCANIdle++;
+		timerCounterGetdata++;
 	}
 }
 void CanTask(void *pvParameters)
 {
+	uint32 timerCANIdle = 0x00;
 	uint32 timerCounterNow = 0;
 	(void)pvParameters;
 	CanIf_bRxFlag = false;
@@ -38,6 +39,10 @@ void CanTask(void *pvParameters)
 	xTimerStart(monitorTimer1ms, 0);
 	BaseType_t ret = pdFALSE;
 	GsensorInit();
+	uint8 fftIdx = 0;
+	real_T S0[SIZE_FFT];
+	real_T S1[SIZE_FFT];
+	real_T S2[SIZE_FFT];
 	while (1)
 	{
 		do
@@ -59,27 +64,39 @@ void CanTask(void *pvParameters)
 					BcuDecodeFunction(CanRxMsg.id, CanRxMsg.data); // can协议解析
 				}
 			}
-			if(/*CanRxMsg.id == 0x100 ||*/ timerCANIdle>20000)
+			else
+			{
+				timerCANIdle++;
+			}
+			if (timerCANIdle > 20000)
 			{
 				timerCANIdle = 0;
 				xSemaphoreGive(sleep_mutex);
 			}
 		} while (ret == pdPASS);
-
-//		if (BattSendFlg)
-//		{
-//			BattSendFunc();
-//		}
-		if((TimerCounter - timerCounterNow)>=100)
+		if ((TimerCounter - timerCounterNow) >= 100)
 		{
 			BcuRxDiagnose();
 			timerCounterNow = TimerCounter;
-			SL_SC7A20_Read_XYZ_Data(xyzData);
-//			ADC_ReadValue();
 		}
+//		if (timerCounterGetdata % 10 == 0)
+//		{
+//			SL_SC7A20_Read_XYZ_Data(xyzData);
+//			S0[fftIdx] = (real_T)xyzData[0];
+//			S1[fftIdx] = (real_T)xyzData[1];
+//			S2[fftIdx] = (real_T)xyzData[2];
+//			fftIdx++;
+//		}
+//		if (fftIdx >= SIZE_FFT)
+//		{
+//			fftIdx = 0;
+////			fft(S0, sizeof(S0) / sizeof(real_T), 100, returnFreq[0], returnP[0]); // 50 max
+////			fft(S1, sizeof(S1) / sizeof(real_T), 100, returnFreq[1], returnP[1]);
+////			fft(S2, sizeof(S2) / sizeof(real_T), 100, returnFreq[2], returnP[2]);
+//		}
 	}
 }
-//注意解码超限问题
+// 注意解码超限问题
 void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 {
 	switch (ID)
@@ -281,9 +298,9 @@ void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 			if (((BMS_CellTempFramNum - 1) * 6 + i) < sizeof(BMS_CellTemp))
 			{
 				BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] = (UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF);
-				if(BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] <= (0xFF - 10)   &&   BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] >= 10)
+				if (BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] <= (0xFF - 10) && BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] >= 10)
 				{
-					BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] = BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] - 10;  //the tcp offset is -40, while the can message offset is -50
+					BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] = BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] - 10; // the tcp offset is -40, while the can message offset is -50
 				}
 			}
 		}
@@ -449,18 +466,18 @@ static void UDSAnsFunc(uint8 *rawData)
 	static uint8 deviceSnRecvFlg = 0;
 	switch (UdsService)
 	{
-	case 0x10: //模式切换
+	case 0x10: // 模式切换
 	{
 		if (UdsSubService == 0x01)
 		{
-			UdsStates = 0x01; //关闭UDS诊断
+			UdsStates = 0x01; // 关闭UDS诊断
 			UdsAns(true, UdsService, UdsSubService, 0x00, NULL, 0);
 		}
 		else if (UdsSubService == 0x02)
 		{
 			if (UdsStates == 0x01 || UdsStates == 0x02)
 			{
-				UdsStates = 0x02; //打开UDS诊断
+				UdsStates = 0x02; // 打开UDS诊断
 				UdsAns(true, UdsService, UdsSubService, 0x00, NULL, 0);
 			}
 			else
@@ -470,50 +487,50 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x11://控制
+	case 0x11: // 控制
 	{
-		if(UdsStates==0x02)
+		if (UdsStates == 0x02)
 		{
-			switch(UdsSubService)
+			switch (UdsSubService)
 			{
-				case 0x01://重启
-				{
-					AnsData[0] = AppSwVersion>>24;
-					AnsData[1] = AppSwVersion>>16;
-					AnsData[2] = AppSwVersion>>8;
-					AnsData[3] = AppSwVersion>>0;
-					UdsAns(true,UdsService,UdsSubService,0x00,AnsData,4);
-					AppConfigInfo.appSaveFlg = true;
-					vTaskDelay(pdMS_TO_TICKS(1000));
-					SystemSoftwareReset();
-					break;
-				}
-				default:
-				{
-					UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
-					break;
-				}
+			case 0x01: // 重启
+			{
+				AnsData[0] = AppSwVersion >> 24;
+				AnsData[1] = AppSwVersion >> 16;
+				AnsData[2] = AppSwVersion >> 8;
+				AnsData[3] = AppSwVersion >> 0;
+				UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 4);
+				AppConfigInfo.appSaveFlg = true;
+				vTaskDelay(pdMS_TO_TICKS(1000));
+				SystemSoftwareReset();
+				break;
+			}
+			default:
+			{
+				UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
+				break;
+			}
 			}
 		}
 		else
 		{
-			UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
+			UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
 		}
 		break;
 	}
-	case 0x22: //查询
+	case 0x22: // 查询
 	{
 		if (UdsStates == 0x02)
 		{
 			switch (UdsSubService)
 			{
-			case 0x01: //版本号查询
+			case 0x01: // 版本号查询
 			{
-				AnsData[0] = AppSwVersion>>24;
-				AnsData[1] = AppSwVersion>>16;
-				AnsData[2] = AppSwVersion>>8;
-				AnsData[3] = AppSwVersion>>0;
-				UdsAns(true,UdsService,UdsSubService,0x00,AnsData,4);
+				AnsData[0] = AppSwVersion >> 24;
+				AnsData[1] = AppSwVersion >> 16;
+				AnsData[2] = AppSwVersion >> 8;
+				AnsData[3] = AppSwVersion >> 0;
+				UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 4);
 				break;
 			}
 			case 0x02: // SN号码查询
@@ -543,19 +560,19 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
-			case 0x05: //驻网状态查询
+			case 0x05: // 驻网状态查询
 			{
 				AnsData[0] = RegChkRet;
 				UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
 				break;
 			}
-			case 0x06: //联网状态查询
+			case 0x06: // 联网状态查询
 			{
 				AnsData[0] = SocketId;
 				UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
 				break;
 			}
-			case 0x07: //定位信息查询
+			case 0x07: // 定位信息查询
 			{
 				GPSInfo GpsRecvData;
 				if (xQueuePeek(GpsDataQueueHandle, &GpsRecvData, 0) == pdPASS)
@@ -585,18 +602,18 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
-			case 0x08: //温度检测查询
+			case 0x08: // 温度检测查询
 			{
 				UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
 				break;
 			}
-			case 0x09: //电池信息查询
+			case 0x09: // 电池信息查询
 			{
 				UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
 				BattSendFlg = 1;
 				break;
 			}
-			case 0x0A: //三轴数据查询
+			case 0x0A: // 三轴数据查询
 			{
 				AnsData[0] = xyzData[0] >> 8;
 				AnsData[1] = xyzData[0] >> 0;
@@ -618,7 +635,7 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x27: //控制
+	case 0x27: // 控制
 	{
 		if (UdsStates == 0x02)
 		{
@@ -629,7 +646,7 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x2E: //写入
+	case 0x2E: // 写入
 	{
 		if (UdsStates == 0x02)
 		{
@@ -652,7 +669,7 @@ static void UDSAnsFunc(uint8 *rawData)
 				{
 					deviceSnRecvFlg = 0;
 					AppConfigInfo.appSaveFlg = true;
-					AppConfigInfo.eolFlg=true;
+					AppConfigInfo.eolFlg = true;
 				}
 				break;
 			}
@@ -660,15 +677,14 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		else
 		{
-			UdsAns(false,UdsService,UdsSubService,0x00,NULL,0);
+			UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
 		}
 		break;
 	}
-	case 0x31://控制
+	case 0x31: // 控制
 	{
-		if(UdsStates==0x02)
+		if (UdsStates == 0x02)
 		{
-
 		}
 		else
 		{
@@ -712,116 +728,116 @@ static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx
 }
 static void BattSendFunc(void)
 {
-//	Can_Msg_Type CanTxMsg;
-//	uint32 CanAnsId = 0;
-//	uint8 SendData[8] = {0};
-//	static uint8 SendStep = 0;
-//	static uint8 SendCounter = 0;
-//	switch (SendStep)
-//	{
-//	case 0x00:
-//	{
-//		SendStep++;
-//		break;
-//	}
-//	case 0x01:
-//	{
-//		CanAnsId = 0x1C01EAED;
-//		SendData[0] =  battHeatState;
-//		SendData[1] =  battFanState;
-//		SendData[2] =  battRelayState;
-//		SendData[3] =  battConverState;
-//		SendStep++;
-//		break;
-//	}
-//	case 0x02:
-//	{
-//		uint16 ErrorTemp ;
-//		ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2);
-//		CanAnsId = 0x1C09EAED;
-//		SendData[0] =  battWorkState;
-//		SendData[1] =  ErrorTemp>>8;
-//		SendData[2] =  ErrorTemp;
-//		SendData[3] =  0;
-//		SendData[4] =  0;
-//		SendData[5] =  0;
-//		SendData[6] =  0;
-//		SendData[7] =  0;
-//		SendStep++;
-//		break;
-//	}
-//	case 0x03:
-//	{
-//		CanAnsId = 0x1C0AEAED;
-//		uint16 SocTemp = battSOC*10;
-//		SendData[0] =  battI>>8;
-//		SendData[1] =  battI;
-//		SendData[2] =  battPackVol>>8;
-//		SendData[3] =  battPackVol;
-//		SendData[4] =  SocTemp>>8;
-//		SendData[5] =  SocTemp;
-//		SendData[6] =  battSOH;
-//		SendData[7] =  battMOSSwitchState;
-//		SendStep++;
-//		break;
-//	}
-//	case 0x04:
-//	{
-//		CanAnsId = 0x1C10EAED + (SendCounter<<16);
-//		if((SendCounter*8 + 7)>BMS_TEMPNUM)
-//		{
-//			SendCounter = 0;
-//			SendStep++;
-//			break;
-//		}
-//		else
-//		{
-//			SendData[0] =  battCellTemp[SendCounter*8 + 0];
-//			SendData[1] =  battCellTemp[SendCounter*8 + 1];
-//			SendData[2] =  battCellTemp[SendCounter*8 + 2];
-//			SendData[3] =  battCellTemp[SendCounter*8 + 3];
-//			SendData[4] =  battCellTemp[SendCounter*8 + 4];
-//			SendData[5] =  battCellTemp[SendCounter*8 + 5];
-//			SendData[6] =  battCellTemp[SendCounter*8 + 6];
-//			SendData[7] =  battCellTemp[SendCounter*8 + 7];
-//		}
-//		break;
-//	}
-//	case 0x05:
-//	{
-//		CanAnsId = 0x1CA0EAED + (SendCounter<<16);
-//		if((SendCounter*4 + 3)>BMS_CELLNUM)
-//		{
-//			SendCounter = 0;
-//			SendStep++;
-//			break;
-//		}
-//		else
-//		{
-//			SendData[0] =  battCellU[SendCounter*4 + 0]>>8;
-//			SendData[1] =  battCellU[SendCounter*4 + 0];
-//			SendData[2] =  battCellU[SendCounter*4 + 1]>>8;
-//			SendData[3] =  battCellU[SendCounter*4 + 1];
-//			SendData[4] =  battCellU[SendCounter*4 + 2]>>8;
-//			SendData[5] =  battCellU[SendCounter*4 + 2];
-//			SendData[6] =  battCellU[SendCounter*4 + 3]>>8;
-//			SendData[7] =  battCellU[SendCounter*4 + 3];
-//		}
-//		break;
-//	}
-//	default:
-//	{
-//		SendStep = 0;
-//		BattSendFlg = 0;
-//		return;
-//		break;
-//	}
-//	}
-//	CanTxMsg.id = CanAnsId;
-//	CanTxMsg.idFrame = CAN_EXTENDED_ID_TYPE;
-//	CanTxMsg.sdu = SendData;
-//	CanTxMsg.length = 8;
-//	CanIf_SendMessage(CAN1, CanTxMsg);
+	//	Can_Msg_Type CanTxMsg;
+	//	uint32 CanAnsId = 0;
+	//	uint8 SendData[8] = {0};
+	//	static uint8 SendStep = 0;
+	//	static uint8 SendCounter = 0;
+	//	switch (SendStep)
+	//	{
+	//	case 0x00:
+	//	{
+	//		SendStep++;
+	//		break;
+	//	}
+	//	case 0x01:
+	//	{
+	//		CanAnsId = 0x1C01EAED;
+	//		SendData[0] =  battHeatState;
+	//		SendData[1] =  battFanState;
+	//		SendData[2] =  battRelayState;
+	//		SendData[3] =  battConverState;
+	//		SendStep++;
+	//		break;
+	//	}
+	//	case 0x02:
+	//	{
+	//		uint16 ErrorTemp ;
+	//		ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2);
+	//		CanAnsId = 0x1C09EAED;
+	//		SendData[0] =  battWorkState;
+	//		SendData[1] =  ErrorTemp>>8;
+	//		SendData[2] =  ErrorTemp;
+	//		SendData[3] =  0;
+	//		SendData[4] =  0;
+	//		SendData[5] =  0;
+	//		SendData[6] =  0;
+	//		SendData[7] =  0;
+	//		SendStep++;
+	//		break;
+	//	}
+	//	case 0x03:
+	//	{
+	//		CanAnsId = 0x1C0AEAED;
+	//		uint16 SocTemp = battSOC*10;
+	//		SendData[0] =  battI>>8;
+	//		SendData[1] =  battI;
+	//		SendData[2] =  battPackVol>>8;
+	//		SendData[3] =  battPackVol;
+	//		SendData[4] =  SocTemp>>8;
+	//		SendData[5] =  SocTemp;
+	//		SendData[6] =  battSOH;
+	//		SendData[7] =  battMOSSwitchState;
+	//		SendStep++;
+	//		break;
+	//	}
+	//	case 0x04:
+	//	{
+	//		CanAnsId = 0x1C10EAED + (SendCounter<<16);
+	//		if((SendCounter*8 + 7)>BMS_TEMPNUM)
+	//		{
+	//			SendCounter = 0;
+	//			SendStep++;
+	//			break;
+	//		}
+	//		else
+	//		{
+	//			SendData[0] =  battCellTemp[SendCounter*8 + 0];
+	//			SendData[1] =  battCellTemp[SendCounter*8 + 1];
+	//			SendData[2] =  battCellTemp[SendCounter*8 + 2];
+	//			SendData[3] =  battCellTemp[SendCounter*8 + 3];
+	//			SendData[4] =  battCellTemp[SendCounter*8 + 4];
+	//			SendData[5] =  battCellTemp[SendCounter*8 + 5];
+	//			SendData[6] =  battCellTemp[SendCounter*8 + 6];
+	//			SendData[7] =  battCellTemp[SendCounter*8 + 7];
+	//		}
+	//		break;
+	//	}
+	//	case 0x05:
+	//	{
+	//		CanAnsId = 0x1CA0EAED + (SendCounter<<16);
+	//		if((SendCounter*4 + 3)>BMS_CELLNUM)
+	//		{
+	//			SendCounter = 0;
+	//			SendStep++;
+	//			break;
+	//		}
+	//		else
+	//		{
+	//			SendData[0] =  battCellU[SendCounter*4 + 0]>>8;
+	//			SendData[1] =  battCellU[SendCounter*4 + 0];
+	//			SendData[2] =  battCellU[SendCounter*4 + 1]>>8;
+	//			SendData[3] =  battCellU[SendCounter*4 + 1];
+	//			SendData[4] =  battCellU[SendCounter*4 + 2]>>8;
+	//			SendData[5] =  battCellU[SendCounter*4 + 2];
+	//			SendData[6] =  battCellU[SendCounter*4 + 3]>>8;
+	//			SendData[7] =  battCellU[SendCounter*4 + 3];
+	//		}
+	//		break;
+	//	}
+	//	default:
+	//	{
+	//		SendStep = 0;
+	//		BattSendFlg = 0;
+	//		return;
+	//		break;
+	//	}
+	//	}
+	//	CanTxMsg.id = CanAnsId;
+	//	CanTxMsg.idFrame = CAN_EXTENDED_ID_TYPE;
+	//	CanTxMsg.sdu = SendData;
+	//	CanTxMsg.length = 8;
+	//	CanIf_SendMessage(CAN1, CanTxMsg);
 }
 
 void BcuRxDiagnose(void) // 100ms调用一次
@@ -1153,8 +1169,8 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 		break;
 	case 0x18E6D0F3:
 		BMS_CSC_Total = 0xFF;
-//		BMS_CellTotal = BMS_CELL_MAX_NUM;
-//		BMS_TempTotal = BMS_TEMP_MAX_NUM;
+		//		BMS_CellTotal = BMS_CELL_MAX_NUM;
+		//		BMS_TempTotal = BMS_TEMP_MAX_NUM;
 		BMS_CellVoltLevel = 0xFF;
 		BMS_CellMinVolt = 0xFF;
 		BMS_CellMaxVolt = 0xFF;

+ 3 - 2
code/app/AppTaskCan.h

@@ -1,9 +1,9 @@
-/*** 
+/***
  * @Author: chenjie
  * @Date: 2022-06-06
  * @LastEditTime: 2022-10-27
  * @LastEditors: chenjie
- * @Description: 
+ * @Description:
  * @FilePath: \S32K146_4G\code\app\AppTaskCan.h
  * @Copyright (c) 2022 by chenjie, All Rights Reserved.
  */
@@ -16,6 +16,7 @@
 #include "UDSTask.h"
 #include "Hal_Wdg.h"
 #include "AppTaskGps.h"
+
 void BcuDecodeFunction(uint32 ID, uint8 *rawData);
 void BcuRxDiagnose(void);
 void BcuRxMsgSetInvalidValue(uint32 ID);

+ 17 - 85
code/app/AppTaskMain.c

@@ -1,129 +1,61 @@
 /*
  * AppTaskMain.c
  *
- *  Created on: 2022Äê2ÔÂ22ÈÕ
+ *  Created on: 2022年2月22日
  *      Author: QiXiang_CHENJIE
  */
 
 #include "AppTaskMain.h"
 #include "hal_fls.h"
 static void vTimerCallback(TimerHandle_t pxTimer);
-extern uint32 timerCANIdle;
 void MainTask(void *pvParameters)
 {
 	(void)pvParameters;
 	TimerHandle_t monitorTimer;
-	monitorTimer = xTimerCreate("monitor",10,pdTRUE,(void *)0,vTimerCallback);
-	xTimerStart(monitorTimer,0);
+	monitorTimer = xTimerCreate("monitor", 10, pdTRUE, (void *)0, vTimerCallback);
+	xTimerStart(monitorTimer, 0);
 	TimerHandle_t monitorTimer1ms;
-	monitorTimer1ms = xTimerCreate("monitor1ms",1,pdTRUE,(void *)0,vTimer1msCallback);
-	xTimerStart(monitorTimer1ms,0);
+	monitorTimer1ms = xTimerCreate("monitor1ms", 1, pdTRUE, (void *)0, vTimer1msCallback);
+	xTimerStart(monitorTimer1ms, 0);
 
 	sleep_mutex = xSemaphoreCreateBinary();
 
 	uint32 *eppromAddStart = 0x14000000;
-	if(*(uint8 *)(eppromAddStart)==0xff)
+	if (*(uint8 *)(eppromAddStart) == 0xff)
 	{
-		HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
+		HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
 	}
-	HAL_EEP_Read(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
-	while(1)
+	HAL_EEP_Read(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
+	while (1)
 	{
 		vTaskDelay(pdMS_TO_TICKS(10));
-		if(HAL_Is100msTickTimeout())
+		if (HAL_Is100msTickTimeout())
 		{
-			if(IsFeedWdg == TRUE)
+			if (IsFeedWdg == TRUE)
 			{
 				WATCHDOG_HAL_Feed();
 			}
 		}
-		if(AppConfigInfo.appSaveFlg)
+		if (AppConfigInfo.appSaveFlg)
 		{
 			AppConfigInfo.appSaveFlg = false;
-			HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
+			HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
 		}
-		if(Fota_update_flag || Fota_error_flag)
+		if (Fota_update_flag || Fota_error_flag)
 		{
-			//ÖØÆôÇ°±£´æÊý¾Ý
+			// ����存数�
 			AppConfigInfo.appSaveFlg = false;
-			HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
+			HAL_EEP_Write(0, (uint8 *)&AppConfigInfo, sizeof(AppConfigInfo));
 			SystemSoftwareReset();
 		}
-
 		MCUEnterSleep();
-
-//		if(pdTRUE == xSemaphoreTake(sleep_mutex,1))
-//		{
-//			extern boolean Uart_4G_Task_Sleep_FLag;
-//			WdgDeInit();
-//			do
-//			{
-//				waitForSleepFlag = true;
-//				vTaskDelay(pdMS_TO_TICKS(10));
-//			}while(Uart_4G_Task_Sleep_FLag == false);
-//
-//			vTaskDelete(Uart_Hal_RecvTask_Handle);
-//			vTaskDelete(Uart_Hal_SendTask_Handle);
-//			vTaskDelete(CanTask_Handle);
-//			vTaskDelete(GpsTask_Handle);
-//			vTaskDelete(Uart_4G_Task_Handle);
-//
-//			SystemPeripheralDeinit();
-//			MCUSleep();
-
-//			vTaskDelete(MainTask_Handle);
-//for(;;)
-//{
-//	vTaskDelay(pdMS_TO_TICKS(1000));
-//}
-//
-//			coreInit();
-//			SystemModulesInit();
-//			waitForSleepFlag = false;
-//			Uart_4G_Task_Sleep_FLag = false;
-
-			/* Initialize all pins*/
-//			#if (PORT_PRECOMPILE_SUPPORT == STD_ON)
-//				Port_Init(NULL_PTR);
-//			#elif (PORT_PRECOMPILE_SUPPORT == STD_OFF)
-//				Port_Init(&Port_Config_VS_0);
-//			#endif
-//			vTaskDelay(pdMS_TO_TICKS(100));
-
-//			vTaskDelay(pdMS_TO_TICKS(100));
-		//					currentMode = Mcu_GetPowerModeState();
-//			Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_OFF);
-
-//			vTaskDelay(pdMS_TO_TICKS(500));
-//			Icu_DeInit();
-			//4G module power on
-//			vTaskDelay(pdMS_TO_TICKS(1000));
-
-//			timerCANIdle = 0;
-//			Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
-//			vTaskDelay(pdMS_TO_TICKS(1000));
-//			Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
-//			vTaskDelay(pdMS_TO_TICKS(500));
-//			Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
-
-			//GPS module power on
-//			Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_ON);
-//			vTaskDelay(pdMS_TO_TICKS(1000));
-
-//			vTaskResume(Uart_Hal_RecvTask_Handle);
-//			vTaskResume(Uart_Hal_SendTask_Handle);
-//			vTaskResume(CanTask_Handle);
-//			vTaskResume(GpsTask_Handle);
-//			vTaskResume(Uart_4G_Task_Handle);
-
-//		}
 	}
 }
 static void vTimerCallback(TimerHandle_t pxTimer)
 {
 	uint32 ulTimerID;
 	ulTimerID = (uint32)pvTimerGetTimerID(pxTimer);
-	if(ulTimerID==0)
+	if (ulTimerID == 0)
 	{
 		TimerCounter = TimerCounter + 10;
 	}

+ 1 - 1
code/app/AppTaskUart0.c

@@ -1,7 +1,7 @@
 /*
  * AppTaskUart0.c
  *
- *  Created on: 2022Äê2ÔÂ22ÈÕ
+ *  Created on: 2022年2月22日
  *      Author: QiXiang_CHENJIE
  */
 #include "AppTaskUart0.h"

File diff suppressed because it is too large
+ 322 - 268
code/app/AppTaskUart1.c


+ 28 - 9
code/app/AppTaskUart1.h

@@ -9,8 +9,8 @@
  */
 /*
  * AppTaskUart2.h
- *4GµÄ´®¿Úº¯Êý
- *  Created on: 2022Äê2ÔÂ10ÈÕ
+ *4G的串�函数
+ *  Created on: 2022年2月10日
  *      Author: QiXiang_CHENJIE
  */
 
@@ -24,14 +24,15 @@
 #define BATT_SN_LEN 17
 #define TCP_START_SYM1 0x23
 #define TCP_START_SYM2 0x23
-#define TCP_CMD_SYM 0x02   //ʵʱÐÅÏ¢Éϱ¨ÊÇ0x02
-#define TCP_HEART_SYM 0x07 //ÐÄÌø°ü±êÖ¾
+#define TCP_CMD_SYM 0x02   // 实时信�上报是0x02
+#define TCP_HEART_SYM 0x07 // 心跳包标志
 #define TCP_ANS_SYM 0xFE
 #define TCP_ENCPT_ENABLE 0x00
 #define TCP_ENCPT_DISABLE 0x01
 #define BattMsg (0x80)
 #define GpsMsg (0x82)
 #define VerMsg (0x86)
+#define DebugMsg (0x8C)
 #define TruckBattMsg (0x91)
 #define TruckVehiMsg (0x90)
 #define TruckAcclMsg (0x92)
@@ -149,7 +150,7 @@ typedef struct AccInfoType
 	uint8 accOverChrgTimes;
 	uint8 accOverDischrgTimes;
 	uint8 accCycleTimes[2];
-}AccInfo;
+} AccInfo;
 typedef struct AccInfoToTcpType
 {
 	uint8 startSymbol[2];
@@ -160,7 +161,24 @@ typedef struct AccInfoToTcpType
 	uint8 dataLength[2];
 	AccInfo AccMsg;
 	uint8 CRC;
-}AccInfoToTcp;
+} AccInfoToTcp;
+typedef struct _DebugInfoType
+{
+	UINT8 sendTimeUTC[6];
+	UINT8 msgMark;
+	UINT8 DebugLen[2];
+} DebugInfoType;
+typedef struct DebugMsgtoTcp_Type
+{
+	UINT8 startSymbol[2];
+	UINT8 cmdSymbol;
+	UINT8 ansSymbol;
+	UINT8 SN[BATT_SN_LEN];
+	UINT8 encryptMethod;
+	UINT8 dataLength[2];
+	DebugInfoType DebugInfo;
+	UINT8 _CRC;
+} DebugMsgtoTcpType;
 typedef struct UTC8Time_Type
 {
 	uint8 year;
@@ -191,13 +209,14 @@ typedef sint8 (*pFunc)(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pRea
 sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen);
 typedef struct
 {
-	ATCmd cmd; /*Ö¸ÁîÐòºÅ*/
-	char *str; /*Ö¸ÁîÄÚÈÝ*/
-	pFunc cb;  /*¶ÔÓ¦µÄÖ´ÐÐ*/
+	ATCmd cmd; /*指令��*/
+	char *str; /*指令内容*/
+	pFunc cb;  /*对应的执行*/
 } ATCmdFunc;
 typedef enum
 {
 	PROCESS_TCP_IDLE = 0,
+	PROCESS_TCP_INIT,
 	PROCESS_TCP_ATSYS,
 	PROCESS_TCP_REGCHK,
 	PROCESS_TCP_CONNECT,

+ 600 - 6
code/app/lib/AppFuncLib.c

@@ -1,9 +1,9 @@
 /*
  * @Author: chenjie
  * @Date: 2022-06-06
- * @LastEditTime: 2022-10-27
+ * @LastEditTime: 2022-11-10
  * @LastEditors: chenjie
- * @Description: 
+ * @Description:
  * @FilePath: \S32K146_4G\code\app\lib\AppFuncLib.c
  * Copyright (c) 2022 by chenjie, All Rights Reserved.
  */
@@ -107,7 +107,7 @@ unsigned char HexToChar(unsigned char bHex)
 {
     if ((bHex >= 0) && (bHex <= 9))
         bHex += 0x30;
-    else if ((bHex >= 10) && (bHex <= 15)) //大写字母
+    else if ((bHex >= 10) && (bHex <= 15)) // 大写字母
         bHex += 0x37;
     else
         bHex = 0xff;
@@ -117,9 +117,9 @@ unsigned char CharToHex(unsigned char bChar)
 {
     if ((bChar >= 0x30) && (bChar <= 0x39))
         bChar -= 0x30;
-    else if ((bChar >= 0x41) && (bChar <= 0x46)) //大写字母
+    else if ((bChar >= 0x41) && (bChar <= 0x46)) // 大写字母
         bChar -= 0x37;
-    else if ((bChar >= 0x61) && (bChar <= 0x66)) //小写字母
+    else if ((bChar >= 0x61) && (bChar <= 0x66)) // 小写字母
         bChar -= 0x57;
     else
         bChar = 0xff;
@@ -130,7 +130,7 @@ uint8 AtStrCompare(const char *a, const char *b)
     uint8 out = 1;
     while (1)
     {
-        if (*a == '\0' || *b == '\0') //判断其中是否有字符串结束
+        if (*a == '\0' || *b == '\0') // 判断其中是否有字符串结束
         {
             if (strlen(a) == strlen(b))
             {
@@ -425,3 +425,597 @@ uint16 crc_chk(uint8 *data, uint8 length)
     }
     return reg_crc;
 }
+/***************************************************************************************************/
+
+#define PI 3.14159265358979
+
+//-------------------uint16数组取最大-------------------------------------
+uint16_T ArrMax(uint16_T *Data, uint16_T n)
+{
+    uint16_T i;
+    uint16_T DataMax;
+    DataMax = Data[0];
+    for (i = 0; i < n; i++)
+    {
+        if (DataMax < Data[i])
+        {
+            DataMax = Data[i];
+        }
+    }
+    return DataMax;
+}
+
+//-----------------uint16数组取最小-------------------------------------
+uint16_T ArrMin(uint16_T *Data, uint16_T n)
+{
+    uint16_T i;
+    uint16_T DataMin;
+    DataMin = Data[0];
+    for (i = 0; i < n; i++)
+    {
+        if (DataMin > Data[i])
+        {
+            DataMin = Data[i];
+        }
+    }
+    return DataMin;
+}
+//
+
+/////////////////////////// int16数组求均值////////////////////////////////////
+int16_T ArrMean(int16_T *Data, uint16_T n)
+{
+    uint16_T i;
+    int32_T Sum = 0;
+    int16_T DataMean;
+
+    for (i = 0; i < n; i++)
+    {
+        Sum = Sum + Data[i];
+    }
+    DataMean = (int16_T)Sum / n;
+    return DataMean;
+}
+
+//-----------------real_T 限幅函数
+real_T Saturation_r(real_T in, real_T LowLim, real_T UpLim)
+{
+    real_T out;
+
+    out = in > LowLim ? in : LowLim;
+    out = out > UpLim ? UpLim : out;
+    return out;
+}
+
+//-----------------uint16 限幅函数
+
+uint16_T Saturation_u(uint16_T in, uint16_T LowLim, uint16_T UpLim)
+{
+    uint16_T out;
+
+    out = in > LowLim ? in : LowLim;
+    out = out > UpLim ? UpLim : out;
+    return out;
+}
+
+// ---------------------滤波控制变动速率--------------------------------------
+uint16_T DataFilt(uint16_T in, uint16_T *out, uint16_T Lim)
+{
+    int16_T delt;
+    delt = (int16_T)(in - *out);
+    if (delt > Lim)
+    {
+        *out = *out + (delt > Lim ? Lim : delt);
+    }
+    if (delt < -Lim)
+    {
+        *out = *out + (delt < -Lim ? -Lim : delt);
+    }
+    if (delt <= Lim && delt >= -Lim)
+    {
+        *out = in;
+    }
+    return *out;
+}
+
+// ---------------------滤波控制变动速率--------------------------------------
+uint8_T DataFilt8(uint8_T in, uint8_T *out, uint8_T Lim)
+{
+    int8_T delt;
+    delt = (int8_T)(in - *out);
+    if (delt > Lim)
+    {
+        *out = *out + (delt > Lim ? Lim : delt);
+    }
+    if (delt < -Lim)
+    {
+        *out = *out + (delt < -Lim ? -Lim : delt);
+    }
+    if (delt <= Lim && delt >= -Lim)
+    {
+        *out = in;
+    }
+    return *out;
+}
+
+//-------------------uint16 to uint16的一维查表--------------------------------------
+uint16_T look1_u16tu16(uint16_T u0, const uint16_T *bp0, const uint16_T *table, uint16_T MaxLen)
+{
+
+    uint32_T bpIdx = 0;
+    uint32_T iLeft = 0;
+    uint32_T iRght = 0;
+    uint16_T y = 0;
+    uint32_T yL_0d0 = 0;
+    uint32_T yR_0d0 = 0;
+    uint32_T maxIndex = MaxLen - 1;
+    if (u0 <= bp0[0U])
+    {
+        iLeft = 0U;
+        iRght = 0U;
+    }
+    else if (u0 < bp0[maxIndex])
+    {
+        //????????u0??λ??
+        bpIdx = maxIndex >> 1U;
+        iLeft = 0U;
+        iRght = maxIndex;
+        while ((iRght - iLeft) > 1)
+        {
+            if (u0 < bp0[bpIdx])
+            {
+                iRght = bpIdx;
+            }
+            else
+            {
+                iLeft = bpIdx;
+            }
+            bpIdx = (iRght + iLeft) >> 1U;
+        }
+    }
+    else
+    {
+        iLeft = maxIndex;
+        iRght = maxIndex;
+    }
+    //???λ??????????
+    if (iLeft != iRght)
+    {
+        //??????
+        yR_0d0 = table[iLeft + 1U];
+        yL_0d0 = table[iLeft];
+        if (yR_0d0 >= yL_0d0)
+        {
+            y = (uint16_T)(((uint32_T)(u0 - bp0[iLeft]) * (yR_0d0 - yL_0d0)) / (bp0[iLeft + 1] - bp0[iLeft]) + yL_0d0);
+        }
+        else
+        {
+            y = (uint16_T)((yL_0d0 - ((uint32_T)(u0 - bp0[iLeft]) * (yL_0d0 - yR_0d0)) / (bp0[iLeft + 1] - bp0[iLeft])));
+        }
+    }
+    else
+    {
+        y = (uint16_T)table[iLeft];
+    }
+    return y;
+}
+
+//-------------------int16 to uint16的一维查表--------------------------------------
+uint16_T look1_i16tu16(int16_T u0, const int16_T *bp0, const uint16_T *table, uint16_T MaxLen)
+{
+    uint32_T bpIdx = 0;
+    uint32_T iLeft = 0;
+    uint32_T iRght = 0;
+    uint16_T y = 0;
+    uint32_T yL_0d0 = 0;
+    uint32_T yR_0d0 = 0;
+    uint32_T maxIndex = MaxLen - 1;
+    if (u0 <= bp0[0U])
+    {
+        iLeft = 0U;
+        iRght = 0U;
+    }
+    else if (u0 < bp0[maxIndex])
+    {
+        //????????u0??λ??
+        bpIdx = maxIndex >> 1U;
+        iLeft = 0U;
+        iRght = maxIndex;
+        while ((iRght - iLeft) > 1)
+        {
+            if (u0 < bp0[bpIdx])
+            {
+                iRght = bpIdx;
+            }
+            else
+            {
+                iLeft = bpIdx;
+            }
+            bpIdx = (iRght + iLeft) >> 1U;
+        }
+    }
+    else
+    {
+        iLeft = maxIndex;
+        iRght = maxIndex;
+    }
+    //???λ??????????
+    if (iLeft != iRght)
+    {
+        //??????
+        yR_0d0 = table[iLeft + 1U];
+        yL_0d0 = table[iLeft];
+        if (yR_0d0 >= yL_0d0)
+        {
+            y = (uint16_T)(((uint32_T)(u0 - bp0[iLeft]) * (yR_0d0 - yL_0d0)) / (bp0[iLeft + 1] - bp0[iLeft]) + yL_0d0);
+        }
+        else
+        {
+            y = (uint16_T)((yL_0d0 - ((uint32_T)(u0 - bp0[iLeft]) * (yL_0d0 - yR_0d0)) / (bp0[iLeft + 1] - bp0[iLeft])));
+        }
+    }
+    else
+    {
+        y = (uint16_T)table[iLeft];
+    }
+    return y;
+}
+
+//  uint16 二维查表
+uint16_T look2_u16u16tu16(uint16_T x, uint16_T y, const uint16_T xTable[], const uint16_T yTable[], const uint16_T zTable[], uint16_T xLen, uint16_T yLen)
+{
+    uint16_T xMaxIndex;
+    uint16_T yMaxIndex;
+    uint16_T xIndexLeft;
+    uint16_T xIndexRight;
+    uint16_T yIndexLeft;
+    uint16_T yIndexRight;
+    uint16_T xValueLeft;
+    uint16_T xValueRight;
+    uint16_T yValueLeft;
+    uint16_T yValueRight;
+    uint16_T bpIdx;
+    uint32_T zIndex1;
+    uint32_T zIndex2;
+    uint32_T zValueMid_xLeft;
+    uint32_T zValueMid_xRight;
+    uint16_T z;
+    xMaxIndex = xLen - 1;
+    yMaxIndex = yLen - 1;
+
+    if (x <= xTable[0U])
+    {
+        xIndexLeft = 0U;
+        xIndexRight = 0U;
+    }
+    else if (x >= xTable[xMaxIndex])
+    {
+        xIndexLeft = xMaxIndex;
+        xIndexRight = xMaxIndex;
+    }
+    else
+    {
+        bpIdx = xMaxIndex >> 1U;
+        xIndexLeft = 0;
+        xIndexRight = xMaxIndex;
+        while (xIndexRight - xIndexLeft > 1U)
+        {
+            if (x < xTable[bpIdx])
+            {
+                xIndexRight = bpIdx;
+            }
+            else
+            {
+                xIndexLeft = bpIdx;
+            }
+
+            bpIdx = (xIndexRight + xIndexLeft) >> 1U;
+        }
+    }
+    xValueLeft = xTable[xIndexLeft];
+    xValueRight = xTable[xIndexRight];
+
+    if (y <= yTable[0U])
+    {
+        yIndexLeft = 0U;
+        yIndexRight = 0U;
+    }
+    else if (y >= yTable[yMaxIndex])
+    {
+        yIndexLeft = yMaxIndex;
+        yIndexRight = yMaxIndex;
+    }
+    else
+    {
+        bpIdx = yMaxIndex >> 1U;
+        yIndexLeft = 0;
+        yIndexRight = yMaxIndex;
+        while (yIndexRight - yIndexLeft > 1U)
+        {
+            if (y < yTable[bpIdx])
+            {
+                yIndexRight = bpIdx;
+            }
+            else
+            {
+                yIndexLeft = bpIdx;
+            }
+
+            bpIdx = (yIndexRight + yIndexLeft) >> 1U;
+        }
+    }
+    yValueLeft = yTable[yIndexLeft];
+    yValueRight = yTable[yIndexRight];
+
+    zIndex1 = yIndexLeft * xLen + xIndexLeft;
+    zIndex2 = yIndexRight * xLen + xIndexLeft;
+    if (yIndexLeft != yIndexRight)
+    {
+        if (zTable[zIndex2] > zTable[zIndex1])
+        {
+            zValueMid_xLeft = (uint16_T)(((uint32_T)(y - yValueLeft) * (zTable[zIndex2] - zTable[zIndex1])) / (yValueRight - yValueLeft) + zTable[zIndex1]);
+        }
+        else
+        {
+            zValueMid_xLeft = (uint16_T)(zTable[zIndex1] - ((uint32_T)(y - yValueLeft) * (zTable[zIndex1] - zTable[zIndex2])) / (yValueRight - yValueLeft));
+        }
+
+        if (zTable[zIndex2 + 1] > zTable[zIndex1 + 1])
+        {
+            zValueMid_xRight = (uint16_T)(((uint32_T)(y - yValueLeft) * (zTable[zIndex2 + 1] - zTable[zIndex1 + 1])) / (yValueRight - yValueLeft) + zTable[zIndex1 + 1]);
+        }
+        else
+        {
+            zValueMid_xRight = (uint16_T)(zTable[zIndex1 + 1] - ((uint32_T)(y - yValueLeft) * (zTable[zIndex1 + 1] - zTable[zIndex2 + 1])) / (yValueRight - yValueLeft));
+        }
+    }
+    else
+    {
+        zValueMid_xLeft = (uint16_T)zTable[zIndex1];
+        zValueMid_xRight = (uint16_T)zTable[zIndex1 + 1];
+    }
+    if (xIndexLeft != xIndexRight)
+    {
+        if (zValueMid_xLeft < zValueMid_xRight)
+        {
+            z = (uint16_T)(((uint32_T)(x - xValueLeft) * (zValueMid_xRight - zValueMid_xLeft)) / ((uint16_T)(xValueRight - xValueLeft)) + zValueMid_xLeft);
+        }
+        else
+        {
+            z = (uint16_T)(zValueMid_xLeft - ((uint32_T)(x - xValueLeft) * (zValueMid_xLeft - zValueMid_xRight)) / ((uint16_T)(xValueRight - xValueLeft)));
+        }
+    }
+    else
+    {
+        z = (uint16_T)(zValueMid_xLeft);
+    }
+    return z;
+}
+
+//-----------------------------------------------诊断大于阈值
+boolean_T DiagThrSystem1(boolean_T Enable, boolean_T precondition, uint16_T Input, uint16_T fltThr, uint16_T recThr, uint8_T fltNumThr, uint8_T recNumThr, uint8_T *fltNum, uint8_T *recNum, boolean_T *fitFlg)
+{
+
+    if (Enable && precondition && Input > fltThr)
+    {
+        *fltNum = (*fltNum + 1) > 200 ? 200 : (*fltNum + 1);
+    }
+    else
+    {
+        *fltNum = 0;
+    }
+
+    if (Enable && precondition && Input < recThr)
+    {
+        *recNum = (*recNum + 1) > 200 ? 200 : (*recNum + 1);
+    }
+    else
+    {
+        *recNum = 0;
+    }
+
+    if ((*fltNum > fltNumThr || (*fitFlg && *recNum < recNumThr)) && precondition)
+    {
+        *fitFlg = true;
+    }
+    else
+    {
+        *fitFlg = false;
+    }
+    return *fitFlg;
+}
+
+//================================诊断小于阈值===================================
+boolean_T DiagThrSystem2(boolean_T Enable, boolean_T precondition, uint16_T Input, uint16_T fltThr, uint16_T recThr, uint8_T fltNumThr, uint8_T recNumThr, uint8_T *fltNum, uint8_T *recNum, boolean_T *fitFlg)
+{
+    if (Enable && precondition && Input < fltThr)
+    {
+        *fltNum = (*fltNum + 1) > 200 ? 200 : (*fltNum + 1);
+    }
+    else
+    {
+        *fltNum = 0;
+    }
+
+    if (Enable && precondition && Input > recThr)
+    {
+        *recNum = (*recNum + 1) > 200 ? 200 : (*recNum + 1);
+    }
+    else
+    {
+        *recNum = 0;
+    }
+
+    if ((*fltNum > fltNumThr || (*fitFlg && *recNum < recNumThr)) && precondition)
+    {
+        *fitFlg = true;
+    }
+    else
+    {
+        *fitFlg = false;
+    }
+
+    return *fitFlg;
+}
+
+//---------------------------判断条件成立次数
+boolean_T JudgeTimeSystem(boolean_T Enable, boolean_T Input, uint16_T *N, uint16_T Thr)
+{
+    boolean_T Flg = false;
+    if (Input && Enable)
+    {
+        *N = (*N + 1) > 20000 ? 20000 : (*N + 1);
+    }
+    else
+    {
+        *N = 0;
+    }
+    if (*N > Thr && Enable)
+    {
+        Flg = true;
+    }
+    else
+    {
+        Flg = false;
+    }
+    return Flg;
+}
+void fft(real_T *S, uint16_T N, real_T freq, real_T *returnFreq, real_T *returnP) // N为偶数
+{
+
+    creal_T X[SIZE_FFT];
+    creal_T W[SIZE_FFT];
+    real_T Y1[SIZE_FFT];
+    real_T Y2[SIZE_FFT / 2 + 1];
+    real_T F[SIZE_FFT / 2 + 1];
+
+    uint16_T i = 0;
+    uint16_T j = 0;
+    uint16_T k = 0;
+    uint16_T l = 0;
+    creal_T up;
+    creal_T down;
+    creal_T product;
+
+    // 变换
+    for (uint16_t i = 0; i < N; i++)
+    {
+        X[i].re = S[i];
+        X[i].im = 0;
+    }
+    RaderReverse(X, N);
+
+    for (i = 0; i < N; i++)
+    {
+        W[i].re = cos(2 * PI / N * i);
+        W[i].im = -sin(2 * PI / N * i);
+    }
+    for (i = 0; i < log(N) / log(2); i++)
+    {
+        l = 1 << i;
+        for (j = 0; j < N; j += 2 * l)
+        {
+            for (k = 0; k < l; k++)
+            {
+                cmul(X[j + k + l], W[N * k / 2 / l], &product);
+                cadd(X[j + k], product, &up);
+                csub(X[j + k], product, &down);
+                X[j + k] = up;
+                X[j + k + l] = down;
+            }
+        }
+    }
+
+    // 计算幅值
+    for (i = 0; i < N; i++)
+    {
+        Y1[i] = sqrt((X[i].im) * (X[i].im) + (X[i].re) * (X[i].re)) / N;
+    }
+
+    Y2[0] = Y1[0];
+    Y2[N / 2] = Y1[N / 2];
+    for (i = 1; i < N / 2; i++)
+    {
+        Y2[i] = 2 * Y1[i];
+    }
+    // 计算频率
+    for (i = 0; i < N / 2 + 1; i++)
+    {
+        F[i] = freq * i / N;
+    }
+
+    // 从大到小 排序
+    real_T temp;
+    uint16_T temp_idx;
+    uint16_T idx[5];
+    for (i = 0; i < N / 2 + 1; i++)
+    {
+        idx[i] = i;
+    }
+
+    for (j = 0; j < N / 2 + 1; j++) // 比较n-1轮
+    {
+        for (k = 0; k < N / 2 - j; k++) // 每轮比较n-1-i次,
+        {
+
+            if (Y2[k] < Y2[k + 1]) // 从大到小
+            {
+                temp = Y2[k];
+                Y2[k] = Y2[k + 1];
+                Y2[k + 1] = temp;
+
+                temp_idx = idx[k];
+                idx[k] = idx[k + 1];
+                idx[k + 1] = temp_idx;
+            }
+        }
+    }
+    // 输出前5个
+    for (i = 0; i < 5; i++)
+    {
+        returnFreq[i] = F[idx[i]];
+        returnP[i] = Y2[i];
+    }
+}
+
+//
+void RaderReverse(creal_T *X, uint16_T N)
+{
+    uint16_T i;
+    uint16_T j;
+    uint16_T k;
+    creal_T temp;
+    j = N / 2;
+    for (i = 1; i < N - 1; i++)
+    {
+        if (i < j)
+        {
+            temp = X[j];
+            X[j] = X[i];
+            X[i] = temp;
+        }
+        k = N / 2;
+        while (k <= j)
+        {
+            j = j - k;
+            k = k / 2;
+        }
+        j = j + k;
+    }
+}
+
+void cmul(creal_T a, creal_T b, creal_T *c)
+{
+    c->re = a.re * b.re - a.im * b.im;
+    c->im = a.re * b.im + a.im * b.re;
+}
+void cadd(creal_T a, creal_T b, creal_T *c)
+{
+    c->re = a.re + b.re;
+    c->im = a.im + b.im;
+}
+void csub(creal_T a, creal_T b, creal_T *c)
+{
+    c->re = a.re - b.re;
+    c->im = a.im - b.im;
+}

+ 32 - 5
code/app/lib/AppFuncLib.h

@@ -1,9 +1,9 @@
-/*** 
+/***
  * @Author: chenjie
  * @Date: 2022-06-06
- * @LastEditTime: 2022-10-27
+ * @LastEditTime: 2022-11-10
  * @LastEditors: chenjie
- * @Description: 
+ * @Description:
  * @FilePath: \S32K146_4G\code\app\lib\AppFuncLib.h
  * @Copyright (c) 2022 by chenjie, All Rights Reserved.
  */
@@ -13,6 +13,7 @@
 #include "hal_adapter.h"
 #include <stdarg.h>
 #include "stdio.h"
+#include <math.h>
 #ifndef va_copy
 #define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list))
 #endif
@@ -40,6 +41,32 @@ int __ftoa(double val, char buf[32], int eps);
 
 // 替代sprintf
 int _sprintf(char *dst, const char *format, ...);
-//串口校验
+// 串口校验
 uint16 crc_chk(uint8 *data, uint8 length);
-#endif /* APPFUNCLIB_H_ */
+
+/*********************************************************************************************/
+#define SIZE_FFT 128
+extern uint16_T ArrMax(uint16_T *Data, uint16_T m);
+extern uint16_T ArrMin(uint16_T *Data, uint16_T m);
+extern int16_T ArrMean(int16_T *Data, uint16_T n);
+extern real_T Saturation_r(real_T in, real_T LowLim, real_T UpLim);
+extern uint16_T Saturation_u(uint16_T in, uint16_T LowLim, uint16_T UpLim);
+
+extern uint16_T DataFilt(uint16_T in, uint16_T *out, uint16_T Lim);
+extern uint8_T DataFilt8(uint8_T in, uint8_T *out, uint8_T Lim);
+
+extern uint16_T look1_i16tu16(int16_T u0, const int16_T *bp0, const uint16_T *table, uint16_T MaxLen);
+extern uint16_T look1_u16tu16(uint16_T u0, const uint16_T *bp0, const uint16_T *table, uint16_T MaxLen);
+extern uint16_T look2_u16u16tu16(uint16_T x, uint16_T y, const uint16_T xTable[], const uint16_T yTable[], const uint16_T zTable[], uint16_T xLen, uint16_T yLen);
+
+extern boolean_T DiagThrSystem1(boolean_T Enable, boolean_T precondition, uint16_T Input, uint16_T fltThr, uint16_T recThr, uint8_T fltNumThr, uint8_T recNumThr, uint8_T *fltNum, uint8_T *recNum, boolean_T *fitFlg);
+extern boolean_T DiagThrSystem2(boolean_T Enable, boolean_T precondition, uint16_T Input, uint16_T fltThr, uint16_T recThr, uint8_T fltNumThr, uint8_T recNumThr, uint8_T *fltNum, uint8_T *recNum, boolean_T *fitFlg);
+extern boolean_T JudgeTimeSystem(boolean_T Enable, boolean_T Input, uint16_T *N, uint16_T Thr);
+
+extern void RaderReverse(creal_T *X, uint16_T N);
+extern void fft(real_T *S, uint16_T N, real_T freq, real_T *returnFreq, real_T *returnP);
+extern void cmul(creal_T a, creal_T b, creal_T *c);
+extern void cadd(creal_T a, creal_T b, creal_T *c);
+extern void csub(creal_T a, creal_T b, creal_T *c);
+/***********************************************************************************************/
+#endif /* APPFUNCLIB_H_ */

+ 160 - 0
code/app/lib/rtwtypes.h

@@ -0,0 +1,160 @@
+/*
+ * File: rtwtypes.h
+ *
+ * Code generated for Simulink model 'SFM'.
+ *
+ * Model version                  : 1.71
+ * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
+ * C/C++ source code generated on : Thu Sep  9 17:17:31 2021
+ */
+
+#ifndef RTWTYPES_H
+#define RTWTYPES_H
+
+/* Logical type definitions */
+#if (!defined(__cplusplus))
+#ifndef false
+#define false (0U)
+#endif
+
+#ifndef true
+#define true (1U)
+#endif
+#endif
+
+/*=======================================================================*
+ * Target hardware information
+ *   Device type: Intel->x86-64 (Windows64)
+ *   Number of bits:     char:   8    short:   16    int:  32
+ *                       long:  32
+ *                       native word size:  64
+ *   Byte ordering: LittleEndian
+ *   Signed integer division rounds to: Zero
+ *   Shift right on a signed integer as arithmetic shift: on
+ *=======================================================================*/
+
+/*=======================================================================*
+ * Fixed width word size data types:                                     *
+ *   int8_T, int16_T, int32_T     - signed 8, 16, or 32 bit integers     *
+ *   uint8_T, uint16_T, uint32_T  - unsigned 8, 16, or 32 bit integers   *
+ *   real32_T, real64_T           - 32 and 64 bit floating point numbers *
+ *=======================================================================*/
+typedef signed char int8_T;
+typedef unsigned char uint8_T;
+typedef short int16_T;
+typedef unsigned short uint16_T;
+typedef int int32_T;
+typedef unsigned int uint32_T;
+typedef float real32_T;
+typedef double real64_T;
+
+/*===========================================================================*
+ * Generic type definitions: boolean_T, char_T, byte_T, int_T, uint_T,       *
+ *                           real_T, time_T, ulong_T.                        *
+ *===========================================================================*/
+typedef double real_T;
+typedef double time_T;
+typedef unsigned char boolean_T;
+typedef int int_T;
+typedef unsigned int uint_T;
+typedef unsigned long ulong_T;
+typedef char char_T;
+typedef unsigned char uchar_T;
+typedef char_T byte_T;
+
+/*===========================================================================*
+ * Complex number type definitions                                           *
+ *===========================================================================*/
+#define CREAL_T
+
+typedef struct
+{
+  real32_T re;
+  real32_T im;
+} creal32_T;
+
+typedef struct
+{
+  real64_T re;
+  real64_T im;
+} creal64_T;
+
+typedef struct
+{
+  real_T re;
+  real_T im;
+} creal_T;
+
+#define CINT8_T
+
+typedef struct
+{
+  int8_T re;
+  int8_T im;
+} cint8_T;
+
+#define CUINT8_T
+
+typedef struct
+{
+  uint8_T re;
+  uint8_T im;
+} cuint8_T;
+
+#define CINT16_T
+
+typedef struct
+{
+  int16_T re;
+  int16_T im;
+} cint16_T;
+
+#define CUINT16_T
+
+typedef struct
+{
+  uint16_T re;
+  uint16_T im;
+} cuint16_T;
+
+#define CINT32_T
+
+typedef struct
+{
+  int32_T re;
+  int32_T im;
+} cint32_T;
+
+#define CUINT32_T
+
+typedef struct
+{
+  uint32_T re;
+  uint32_T im;
+} cuint32_T;
+
+/*=======================================================================*
+ * Min and Max:                                                          *
+ *   int8_T, int16_T, int32_T     - signed 8, 16, or 32 bit integers     *
+ *   uint8_T, uint16_T, uint32_T  - unsigned 8, 16, or 32 bit integers   *
+ *=======================================================================*/
+#define MAX_int8_T ((int8_T)(127))
+#define MIN_int8_T ((int8_T)(-128))
+#define MAX_uint8_T ((uint8_T)(255U))
+#define MAX_int16_T ((int16_T)(32767))
+#define MIN_int16_T ((int16_T)(-32768))
+#define MAX_uint16_T ((uint16_T)(65535U))
+#define MAX_int32_T ((int32_T)(2147483647))
+#define MIN_int32_T ((int32_T)(-2147483647 - 1))
+#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))
+
+/* Block D-Work pointer type */
+typedef void *pointer_T;
+
+#endif /* RTWTYPES_H */
+
+/*
+ * File trailer for generated code.
+ *
+ * [EOF]
+ */

+ 5 - 3
code/debug/cm_backtrace/cmb_cfg.h

@@ -30,15 +30,17 @@
 #define _CMB_CFG_H_
 #include "SEGGER_RTT.h"
 /* print line, must config by user */
-#define cmb_println(...)       SEGGER_RTT_printf(__VA_ARGS__);SEGGER_RTT_printf("\r\n");        /* e.g., printf(__VA_ARGS__);printf("\r\n")  or  SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_WriteString(0, "\r\n")  */
+#define cmb_println(...)            \
+    SEGGER_RTT_printf(__VA_ARGS__); \
+    SEGGER_RTT_printf("\r\n"); /* e.g., printf(__VA_ARGS__);printf("\r\n")  or  SEGGER_RTT_printf(0, __VA_ARGS__);SEGGER_RTT_WriteString(0, "\r\n")  */
 /* enable bare metal(no OS) platform */
 /* #define CMB_USING_BARE_METAL_PLATFORM */
 /* enable OS platform */
 #define CMB_USING_OS_PLATFORM
 /* OS platform type, must config when CMB_USING_OS_PLATFORM is enable */
-#define CMB_OS_PLATFORM_TYPE   CMB_OS_PLATFORM_FREERTOS        /*CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS or CMB_OS_PLATFORM_RTX5 */
+#define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_FREERTOS /*CMB_OS_PLATFORM_RTT or CMB_OS_PLATFORM_UCOSII or CMB_OS_PLATFORM_UCOSIII or CMB_OS_PLATFORM_FREERTOS or CMB_OS_PLATFORM_RTX5 */
 /* cpu platform type, must config by user */
-#define CMB_CPU_PLATFORM_TYPE  CMB_CPU_ARM_CORTEX_M4     /* CMB_CPU_ARM_CORTEX_M0 or CMB_CPU_ARM_CORTEX_M3 or CMB_CPU_ARM_CORTEX_M4 or CMB_CPU_ARM_CORTEX_M7 */
+#define CMB_CPU_PLATFORM_TYPE CMB_CPU_ARM_CORTEX_M4 /* CMB_CPU_ARM_CORTEX_M0 or CMB_CPU_ARM_CORTEX_M3 or CMB_CPU_ARM_CORTEX_M4 or CMB_CPU_ARM_CORTEX_M7 */
 /* enable dump stack information */
 #define CMB_USING_DUMP_STACK_INFO
 /* language of print information */

+ 1 - 1
code/hal/Hal_Fls.c

@@ -1,7 +1,7 @@
 /*
  * Hal_Fls.c
  *
- *  Created on: 2022Äê4ÔÂ6ÈÕ
+ *  Created on: 
  *      Author: Zhengchao
  */
 #include "Hal_Fls.h"

+ 1 - 1
code/hal/Hal_Fls.h

@@ -1,7 +1,7 @@
 /*
  * Hal_Fls.h
  *
- *  Created on: 2022Äê4ÔÂ6ÈÕ
+ *  Created on: 
  *      Author: Zhengchao
  */
 

+ 6 - 4
code/hal/hal_adapter.c

@@ -1,7 +1,7 @@
 /*
  * hal_adapter.c
- *Öмä²ãº¯Êýµ÷Óÿâ
- *  Created on: 2022Äê1ÔÂ18ÈÕ
+ *中间层函数调用库
+ *  Created on: 2022年1月18日
  *      Author: QiXiang_CHENJIE
  */
 #include "hal_adapter.h"
@@ -357,7 +357,7 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 		    	 UartSendState[UartIdx] = UartStartSend;
 		     }
 		 }
-		 /*¿ªÊ¼·¢ËͺóµÄÅж¨*/
+		 /*开始���的判定*/
 		 if(UartSendState[UartIdx] == UartStartSend)
 		 {
 			 Uart_TransmitStatus[UartIdx] = Uart_GetStatus(UartIdx, &T_bytesRemaining[UartIdx], UART_SEND);
@@ -1082,7 +1082,9 @@ void MCUEnterSleep(void)
 //		vTaskDelete(MainTask_Handle);
 
 		SystemDeinit();
-
+#ifdef SEGGER_RTT_PRINTF
+	SEGGER_RTT_printf("[%d]\n",__LINE__);
+#endif
 		MCUSleep();
 //		WdgInit();
 //		DoResetECUWithWdg();

+ 43 - 43
code/hal/hal_adapter.h

@@ -9,8 +9,8 @@
  */
 /*
  * hal_adapter.h
- *Öмä²ãº¯Êýµ÷Óÿâ
- *  Created on: 2022Äê1ÔÂ18ÈÕ
+ *中间层函数调用库
+ *  Created on: 2022年1月18日
  *      Author: QiXiang_CHENJIE
  */
 
@@ -44,7 +44,8 @@
 #include "SEGGER_RTT_Conf.h"
 #include "SEGGER_RTT.h"
 #include "hal_Wdg.h"
-/*ÊÊÓ¦ÐÔ¶¨Òå*/
+#include "rtwtypes.h"
+/*适应性定义*/
 typedef unsigned char UINT8;
 typedef unsigned short UINT16;
 typedef unsigned long UINT32;
@@ -61,9 +62,9 @@ typedef signed long INT32;
 #ifndef max
 #define max(A, B) ((A) < (B) ? (B) : (A))
 #endif
-#define getbit(x, y) ((x) >> (y)&1) //»ñÈ¡xµÄµÚyλµÄÊýÖµ
-#define setbit(x, y) x |= (1 << y)  // xµÄµÚyλÖÃ1
-#define clrbit(x, y) x &= ~(1 << y) // xµÄµÚyλÖÃ0
+#define getbit(x, y) ((x) >> (y)&1) // 获�x的第y�的数值
+#define setbit(x, y) x |= (1 << y)  // x的第y�置1
+#define clrbit(x, y) x &= ~(1 << y) // x的第y�置0
 #define UART_LPUART0 0
 #define UART_LPUART1 1
 #define UART_LPUART2 2
@@ -79,47 +80,48 @@ typedef signed long INT32;
 #define DMA_SIZE 128
 void Uart_Hal_RecvTask(void *pvParameters);
 void Uart_Hal_SendTask(void *pvParameters);
-typedef struct {
+typedef struct
+{
     uint8_t *source;
     uint32_t br;
     uint32_t bw;
     uint32_t btoRead;
     uint32_t length;
-}ringbuffer_t;
+} ringbuffer_t;
 
- typedef struct
- {
-     uint16 DataLen;
-     uint8 *dataPtr;
-     uint32 dataAddr;
- } UartMsg_t;
- typedef struct
- {
-	 uint8 Channel;
-	 Lpuart_Uart_Ip_EventType event;
-     uint16  value;
- } UartHalMsg_t;
- typedef enum
- {
-	 UartStartRecv = 0,
-	 UartAbortRecv,
-	 UartRecvOnGoing,
-	 UartRecvComplete,
+typedef struct
+{
+    uint16 DataLen;
+    uint8 *dataPtr;
+    uint32 dataAddr;
+} UartMsg_t;
+typedef struct
+{
+    uint8 Channel;
+    Lpuart_Uart_Ip_EventType event;
+    uint16 value;
+} UartHalMsg_t;
+typedef enum
+{
+    UartStartRecv = 0,
+    UartAbortRecv,
+    UartRecvOnGoing,
+    UartRecvComplete,
 
-	 UartStartSend,
-	 UartAbortSend,
-	 UartSendOnGoing,
-	 UartSendComplete,
-	 UartNoDataSend,
- };
- typedef enum
- {
-	 SystemTPChannel = 0,
-	 SlowChargeTPChannel,
-	 QuickChargeTPChannel,
-	 CC1TPChannel,
-	 ChannelCounter = 4,
- }ADC_TP_Channel_Type;
+    UartStartSend,
+    UartAbortSend,
+    UartSendOnGoing,
+    UartSendComplete,
+    UartNoDataSend,
+};
+typedef enum
+{
+    SystemTPChannel = 0,
+    SlowChargeTPChannel,
+    QuickChargeTPChannel,
+    CC1TPChannel,
+    ChannelCounter = 4,
+} ADC_TP_Channel_Type;
 
 typedef uint32 TP_Value_Type;
 /*CAN*/
@@ -236,7 +238,7 @@ Std_ReturnType HAL_EEP_Read(uint32 eepReadStartAddr, uint8 *pDataBuffer, uint32
 Std_ReturnType HAL_EEP_Write(uint32 eepWriteStartAddr, uint8 *pDataNeedtoWrite, uint32 dataSize);
 Std_ReturnType HAL_EEP_Compare(uint32 eepCompareStartAddr, uint8 *pDataNeedtoCompare, uint32 dataSize);
 Std_ReturnType ADC_ReadValue(void);
-sint8 AtcmdDelayRecvFunc(uint8 recvChannel,char *ResultStrPtr,uint16 delayTime);
+sint8 AtcmdDelayRecvFunc(uint8 recvChannel, char *ResultStrPtr, uint16 delayTime);
 Std_ReturnType UART_Query_Data(uint8 transChannel, uint8 recvChannel, uint8 *txBuffer, uint16 sendLength, uint8 *rxBuffer, uint16 *rxlen, uint32 T_timeout);
 Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32 sendLength, uint32 T_timeout);
 Std_ReturnType UART_Receive_Data(uint8 recvChannel, uint8 *rxBuffer, uint8 *rxlen, uint32 T_timeout);
@@ -249,7 +251,6 @@ void clear_ringBuffer(ringbuffer_t *ringBuf);
 uint32_t write_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
 uint32_t read_ringBuffer(uint8_t *buffer, uint32_t size, ringbuffer_t *ringBuf);
 
-
 void coreInit(void);
 void SystemModulesInit(void);
 void Icu_DeInit(void);
@@ -258,5 +259,4 @@ void MCUSleep(void);
 void MCUEnterSleep(void);
 void displayResetReasonWithLED(void);
 
-
 #endif /* HAL_ADAPTER_H_ */

+ 15 - 7
code/main.c

@@ -64,21 +64,29 @@
 #include "Hal_Fls.h"
 #include "SEGGER_SYSVIEW.h"
 #include "cm_backtrace.h"
-#define APPNAME                        "S32K146_4G"
-#define HARDWARE_VERSION               "V1.0.0"
-#define SOFTWARE_VERSION               "V0.0.1"
+#define APPNAME "S32K146_4G"
+#define HARDWARE_VERSION "V1.0.0"
+#define SOFTWARE_VERSION "V0.0.1"
 int main(void)
 {
- 	volatile int exit_code = 0;
+	volatile int exit_code = 0;
 
 	coreInit();
 	SystemModulesInit();
 	displayResetReasonWithLED();
-
+#ifdef SEGGER_SYSTEMVIEW
+	SEGGER_SYSVIEW_Conf();
+	SEGGER_SYSVIEW_Start();
+#endif
+#ifdef SEGGER_RTT_PRINTF
+	SEGGER_RTT_Init();
+	cm_backtrace_init(APPNAME, HARDWARE_VERSION, SOFTWARE_VERSION);
+	SEGGER_RTT_printf("boot\n");
+#endif
 	UartInit();
 	xTaskCreate(MainTask, (const char *const)"MainTask", 512, (void *)0, main_TASK_PRIORITY + 6, MainTask_Handle);
-//	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, Uart0Task_Handle);
-	xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, &CanTask_Handle);
+	//	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 512, (void *)0, main_TASK_PRIORITY + 2, Uart0Task_Handle);
+	xTaskCreate(CanTask, (const char *const)"CanTask", 1024, (void *)0, main_TASK_PRIORITY + 2, &CanTask_Handle);
 	xTaskCreate(GpsTask, (const char *const)"GpsTask", 512, (void *)0, main_TASK_PRIORITY + 1, &GpsTask_Handle);
 	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, &Uart_4G_Task_Handle);
 	vTaskStartScheduler();

Some files were not shown because too many files changed in this diff