Commit da3e8754 authored by 李俭双's avatar 李俭双

feat:增加水温表数据处理

parent c6757124
/*
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'HaoJin'
* Target: 'HaoJin232'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "BAT32A239.h"
#endif /* RTE_COMPONENTS_H */
......@@ -14,9 +14,10 @@
#include "CAN_APP\CAN_CH0_CAN_Communication_Matrix.h"
#include "Can_User/Can_User.h"
#include "Can_User/Can_App.h"
#include "Data_Coolant/Data_Coolant.h"
#include "Data_TPMS/Data_TPMS.h"
#include "Data_Voltage/Data_Voltage.h"
#include "FaultCode/FaultCode.h"
#endif
#include "Data_Coolant\Data_Coolant.h"
#include "Application.h"
DataCoolantTempStruct DataCoolantTemp ;
DataCoolantTempDisStruct DataCoolantTemp_Dis;
void Data_Coolant_Temp_KL30_Init ( void )
{
DataCoolantTemp.Value = 0;
DataCoolantTemp.Valid = 0;
DataCoolantTemp_Dis.u8_CurSeg = 0;
DataCoolantTemp_Dis.u8_DestSeg = 0;
DataCoolantTemp_Dis.u8_UpFlashtimer = CoolantFlashtimer;
DataCoolantTemp_Dis.u8_DownFlashtimer = CoolantFlashtimer;
DataCoolantTemp_Dis.u8_Warnflg = 0;
DataCoolantTemp_Dis.u8_Flg = 0;
}
void Data_Coolant_Temp_KL15_Init ( void )
{
DataCoolantTemp_Dis.u8_CurSeg = 0;
DataCoolantTemp_Dis.u8_DestSeg = 0;
DataCoolantTemp_Dis.u8_UpFlashtimer = 0;
DataCoolantTemp_Dis.u8_DownFlashtimer = 0;
DataCoolantTemp_Dis.u8_Warnflg = 0;
DataCoolantTemp_Dis.u8_Flg = 0;
}
void Data_Coolant_Temp_Processing_Service ( void )
{
uint16_t Coolant_Temperature;
uint8_t Coolant_Temperature_State;
uint32_t Temp;
uint8_t i;
Coolant_Temperature = Get_CAN_CH0_ID_101_Sig_ECU_Engine_Temperature();
Coolant_Temperature_State = Get_CAN_CH0_ID_101_Sig_ECU_Engine_Temperature_State();
if (SYS_OPR_STAT_IGN_ON )
{
if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x101_Msg_Count) == CAN_SIG_LOST)
{
DataCoolantTemp.Valid = 0;
DataCoolantTemp.Value = 0;
}
else
{
if(Coolant_Temperature_State == 1)
{
DataCoolantTemp.Valid = 0;
DataCoolantTemp.Value = 0;
}
else
{
DataCoolantTemp.Valid = 1;
if(Coolant_Temperature >= 2730)
{
Coolant_Temperature -= 2730;
}
else
{
Coolant_Temperature = 0;
}
if ((Coolant_Temperature % 10) >= 5)
{
Coolant_Temperature += 5;
}
if(Coolant_Temperature > 1990)
{
Coolant_Temperature = 1990 ;
}
DataCoolantTemp.Value = Coolant_Temperature / 10;
}
}
}
else
{
DataCoolantTemp.Valid = 0;
DataCoolantTemp.Value = 0;
}
//显示
Data_Coolant_Temp_Display();
}
void Data_Coolant_Temp_Display ( void )
{
if(SYS_OPR_STAT_IGN_ON)
{
if(Common_Get_SelfCheckTime_Finish() == 0)
{
DataCoolantTemp_Dis.u8_Uptimer = CoolantSelfCheckFlashtimer;
DataCoolantTemp_Dis.u8_Downtimer = CoolantSelfCheckFlashtimer;
if(DataCoolantTemp_Dis.u8_CurSeg == 0)
{
DataCoolantTemp_Dis.u8_DestSeg = 5;
}
if(DataCoolantTemp_Dis.u8_CurSeg == 5)
{
DataCoolantTemp_Dis.u8_DestSeg = 0;
}
DataCoolantTemp_Dis.u8_Warnflg = 0;
DataCoolantTemp_Dis.u8_Flg = 0;
DataCoolantTemp_Dis.Dis_Valid = 0;
}
else
{
DataCoolantTemp_Dis.u8_Uptimer = CoolantFlashtimer;
DataCoolantTemp_Dis.u8_Downtimer = CoolantFlashtimer;
Get_Coolant_Temp_Seg(DataCoolantTemp.Value);
if(DataCoolantTemp.Valid == 0)
{
DataCoolantTemp_Dis.Dis_Valid = 0;
DataCoolantTemp_Dis.u8_UpFlashtimer = DataCoolantTemp_Dis.u8_Uptimer;
DataCoolantTemp_Dis.u8_DownFlashtimer = DataCoolantTemp_Dis.u8_Downtimer;
DataCoolantTemp_Dis.u8_CurSeg = 0;
DataCoolantTemp_Dis.u8_DestSeg = 0 ;
DataCoolantTemp_Dis.u8_Flg = 0;
}
else
{
DataCoolantTemp_Dis.Dis_Valid = 1;
if(DataCoolantTemp_Dis.u8_Flg == 0)
{
DataCoolantTemp_Dis.u8_Flg = 1;
DataCoolantTemp_Dis.u8_CurSeg = DataCoolantTemp_Dis.u8_DestSeg;
DataCoolantTemp_Dis.u8_UpFlashtimer = DataCoolantTemp_Dis.u8_Uptimer;
DataCoolantTemp_Dis.u8_DownFlashtimer = DataCoolantTemp_Dis.u8_Downtimer;
}
}
}
if(DataCoolantTemp_Dis.u8_CurSeg > DataCoolantTemp_Dis.u8_DestSeg )
{
DataCoolantTemp_Dis.u8_UpFlashtimer = 0;
DataCoolantTemp_Dis.u8_DownFlashtimer++;
if(DataCoolantTemp_Dis.u8_DownFlashtimer >= DataCoolantTemp_Dis.u8_Downtimer)
{
DataCoolantTemp_Dis.u8_DownFlashtimer = 0;
DataCoolantTemp_Dis.u8_CurSeg --;
}
}
else if(DataCoolantTemp_Dis.u8_CurSeg < DataCoolantTemp_Dis.u8_DestSeg)
{
DataCoolantTemp_Dis.u8_DownFlashtimer = 0;
DataCoolantTemp_Dis.u8_UpFlashtimer++;
if(DataCoolantTemp_Dis.u8_UpFlashtimer >= DataCoolantTemp_Dis.u8_Uptimer)
{
DataCoolantTemp_Dis.u8_UpFlashtimer = 0;
DataCoolantTemp_Dis.u8_CurSeg ++;
}
}
//warning
if( DataCoolantTemp.Valid == 0 )
{
DataCoolantTemp_Dis.u8_Warnflg = 1;
}
else
{
if (DataCoolantTemp.Value >= 115)
{
DataCoolantTemp_Dis.u8_Warnflg = 2;
}
else if(DataCoolantTemp.Value >= 112)
{
DataCoolantTemp_Dis.u8_Warnflg = 0;
}
else
{
;
}
}
}
else
{
DataCoolantTemp_Dis.Dis_Valid = 0;
DataCoolantTemp_Dis.u8_UpFlashtimer = DataCoolantTemp_Dis.u8_Uptimer;
DataCoolantTemp_Dis.u8_DownFlashtimer = DataCoolantTemp_Dis.u8_Downtimer;
DataCoolantTemp_Dis.u8_Warnflg = 0;
DataCoolantTemp_Dis.u8_Flg = 0;
}
}
void Get_Coolant_Temp_Seg(uint16_t Temp_Value)
{
uint8_t TempSeg;
uint8_t CurTempSeg;
if(Temp_Value < 50)
{
if(DataCoolantTemp_Dis.u8_CurSeg > 1)
{
DataCoolantTemp_Dis.u8_DestSeg = 1;
}
else if (DataCoolantTemp_Dis.u8_CurSeg > 0)
{
if(Temp_Value <= 47)
{
DataCoolantTemp_Dis.u8_DestSeg = 0;
}
}
else
{
DataCoolantTemp_Dis.u8_DestSeg = 0;
}
}
else if((Temp_Value < 62)&&(Temp_Value >= 50))
{
if(DataCoolantTemp_Dis.u8_CurSeg > 2)
{
DataCoolantTemp_Dis.u8_DestSeg = 2;
}
else if(DataCoolantTemp_Dis.u8_CurSeg > 1 )
{
if(Temp_Value <= 59)
{
DataCoolantTemp_Dis.u8_DestSeg = 1;
}
}
else
{
DataCoolantTemp_Dis.u8_DestSeg = 1;
}
}
else if((Temp_Value < 80)&&(Temp_Value >= 62))
{
if(DataCoolantTemp_Dis.u8_CurSeg > 3)
{
DataCoolantTemp_Dis.u8_DestSeg = 3;
}
else if(DataCoolantTemp_Dis.u8_CurSeg > 2)
{
if(Temp_Value <= 77)
{
DataCoolantTemp_Dis.u8_DestSeg = 2;
}
}
else
{
DataCoolantTemp_Dis.u8_DestSeg = 2;
}
}
else if((Temp_Value < 98)&&(Temp_Value >= 80))
{
if(DataCoolantTemp_Dis.u8_CurSeg > 4)
{
DataCoolantTemp_Dis.u8_DestSeg = 4;
}
else if(DataCoolantTemp_Dis.u8_CurSeg > 3)
{
if(Temp_Value <= 95 )
{
DataCoolantTemp_Dis.u8_DestSeg = 3;
}
}
else
{
DataCoolantTemp_Dis.u8_DestSeg = 3;
}
}
else if((Temp_Value < 115)&&(Temp_Value >= 98))
{
if(DataCoolantTemp_Dis.u8_CurSeg > 4)
{
if(Temp_Value <= 112)
{
DataCoolantTemp_Dis.u8_DestSeg = 4;
}
}
else
{
DataCoolantTemp_Dis.u8_DestSeg = 4;
}
}
else
{
DataCoolantTemp_Dis.u8_DestSeg = 5;
}
}
//水温显示格数
uint8_t GET_DataCoolantTempSegDisp(void)
{
return DataCoolantTemp_Dis.u8_CurSeg;
}
//水温显示有效标志
uint8_t GET_DataCollantTempSegValid(void)
{
return DataCoolantTemp_Dis.Dis_Valid;
}
//水温数显。作为外发使用的时候+40
uint16_t GET_DataCoolantTempValueDisp(void)
{
return DataCoolantTemp.Value ;
}
uint8_t GET_DataCollantTempValueValid(void)
{
return DataCoolantTemp.Valid;
}
//水温灯及显示的报警信号 0:无报警,正常显示 1:掉线或者state无效,白色闪烁 2:高温,红色闪烁
uint8_t GET_DataCollantTempWarnflg(void)
{
return DataCoolantTemp_Dis.u8_Warnflg;
}
#ifndef _DATA_Coolant_H_
#define _DATA_Coolant_H_
#define CoolantFlashtimer 250
#define CoolantSelfCheckFlashtimer 15
/*** 控制结构 ***/
typedef struct
{
uint8_t Dis_Valid;
uint8_t u8_DestSeg;
uint8_t u8_CurSeg;
uint8_t u8_UpFlashtimer ;
uint8_t u8_DownFlashtimer ;
uint8_t u8_Uptimer ;
uint8_t u8_Downtimer ;
uint8_t u8_Flashflg;
uint8_t u8_Warnflg;
uint8_t u8_Flg;
}DataCoolantTempDisStruct;
extern DataCoolantTempDisStruct DataCoolantTemp_Dis;
typedef struct
{
uint16_t Value;
uint8_t Valid;
}DataCoolantTempStruct; //水温数据结构
void Data_Coolant_Temp_KL30_Init(void);
void Data_Coolant_Temp_KL15_Init(void);
void Data_Coolant_Temp_Processing_Service(void);
void Get_Coolant_Temp_Seg(uint16_t Temp_Value);
void Data_Coolant_Temp_Display ( void );
uint8_t GET_DataCollantTempSegValid(void);
uint8_t GET_DataCoolantTempSegDisp(void);
uint16_t GET_DataCoolantTempValueDisp(void);
uint8_t GET_DataCollantTempWarnflg(void);
extern DataCoolantTempStruct DataCoolantTemp ;
#endif
......@@ -54,6 +54,7 @@ static void Power_KL30_Init(void)
Checkself_Init();
Data_Vehicle_Speed_KL30_Init();
Data_Engine_Speed_KL30_Wakeup_Init();
Data_Coolant_Temp_KL30_Init();
LINE_IN_Init();
Key_KL30_Init_EXample();
Light_Sensor_Init_Example();//注意顺序1
......@@ -139,7 +140,7 @@ static void Power_IG_ON_Init(void)
Telltales_KL15_Init();
Telltales_UserInit();
Fuel_KL15_Init();
Data_Coolant_Temp_KL15_Init();
}
static void Power_Sleep_Init(void)
......
......@@ -55,6 +55,7 @@ void Sys_20ms_Tasks(void)
Key_Auto_Save();
Data_Vehicle_Speed_Processing_Service();
Data_Engine_Speed_Processing_Service();
Data_Coolant_Temp_Processing_Service();
}
void Sys_50ms_Tasks(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment