Data_CoolantTemperature.c 4.91 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5
#include "Data_CoolantTemperature.h"
#include "CAN_Communication_Matrix.h"
#include "GaugesInterface.h"
#include "GPIO.h"
//-------------------------------------------
hu's avatar
hu committed
6
//水温数据处理
hu's avatar
hu committed
7 8 9
//-------------------------------------------
//断码显示
//-------------------------------------------
hu's avatar
hu committed
10
//344 - 3.1.1.  水温计显示
hu's avatar
hu committed
11 12 13
//-------------------------------------------
static struct
{
hu's avatar
hu committed
14 15 16 17
    uint8_t Value ;
    uint8_t Valid ;
    uint8_t CurSeg ;
} CoolantVariable ;
hu's avatar
hu committed
18

hu's avatar
hu committed
19
static uint8_t CalCoolant_CurSeg(uint8_t Valid, uint8_t Temp);
hu's avatar
hu committed
20 21 22 23 24 25 26 27 28 29
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_KL30_Init
 * Description    : 水温KL30初始化
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
void Coolant_KL30_Init(void)
{
hu's avatar
hu committed
30 31 32
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
33 34 35 36

}
void Coolant_KL15_ON_Init(void)
{
hu's avatar
hu committed
37 38 39
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
40 41 42
}
void Coolant_KL15_OFF_Init(void)
{
hu's avatar
hu committed
43 44 45
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
46 47 48
}
void Coolant_Wakeup_Init(void)
{
hu's avatar
hu committed
49 50 51
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
52 53 54
}
void Coolant_Sleep_Init(void)
{
hu's avatar
hu committed
55 56 57
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
58 59 60 61 62 63 64 65 66 67 68
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Processing_Service
 * Description    : 水温
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
void Coolant_Processing_Service(void)
{
hu's avatar
hu committed
69 70
    static uint8_t Timer2s = 0 ;
    uint8_t TargetSeg = 0 ;
hu's avatar
hu committed
71 72
    uint8_t Msg_CoolTemp = 0u ;
    uint8_t CanStatus = 0u;
hu's avatar
hu committed
73

hu's avatar
hu committed
74
    CanStatus = CAN_MSG_Status(ID_CanMsg18FEEE00_Msg_Count);
hu's avatar
hu committed
75

hu's avatar
hu committed
76
    if (CanStatus == CAN_SIG_LOST)
hu's avatar
hu committed
77 78
    {
        CoolantVariable.Valid = 0 ;
hu's avatar
hu committed
79
        CoolantVariable.Value = 0u;
hu's avatar
hu committed
80 81 82 83 84
        Timer2s = 0 ;
    }
    else
    {
        Msg_CoolTemp = Get_ID_18FEEE00_Sig_Engine_Coolant_Temperature();
hu's avatar
hu committed
85

hu's avatar
hu committed
86
        if (Msg_CoolTemp > 0xFAu)
hu's avatar
hu committed
87
        {
hu's avatar
hu committed
88 89
            CoolantVariable.Valid = 0u ;
            TargetSeg = 0u;
hu's avatar
hu committed
90 91 92 93
        }
        else
        {
            Timer2s = 0 ;
hu's avatar
hu committed
94
            CoolantVariable.Valid = 1u;
hu's avatar
hu committed
95

hu's avatar
hu committed
96 97 98 99 100 101 102 103
            if (Msg_CoolTemp >= 40)
            {
                CoolantVariable.Value = Msg_CoolTemp - 40u;
            }
            else
            {
                CoolantVariable.Value  = 0u;
            }
hu's avatar
hu committed
104 105 106
        }
    }

hu's avatar
hu committed
107
    CoolantVariable.CurSeg = CalCoolant_CurSeg(CoolantVariable.Valid, CoolantVariable.Value);
hu's avatar
hu committed
108 109 110 111 112 113 114 115 116
}
/*-------------------------------------------------------------------------
 * Function Name  : CalCoolant_CurSeg
 * Description    : 计算当前段
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
117
static uint8_t CalCoolant_CurSeg(uint8_t Valid, uint8_t Temp)
hu's avatar
hu committed
118
{
hu's avatar
hu committed
119
    uint8_t u8Result = 0u;
hu's avatar
hu committed
120

hu's avatar
hu committed
121 122 123 124 125 126 127 128 129 130
    if (Valid)
    {
        SetGaugesPara(TempGauges, Temp);
        u8Result = GetGaugesCurrentPos(TempGauges) ;
    }
    else
    {
        //范围外/CAN中断
        u8Result = 0 ;
    }
hu's avatar
hu committed
131

hu's avatar
hu committed
132
    return u8Result ;
hu's avatar
hu committed
133 134 135 136 137 138 139 140 141 142 143 144
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_ActualValue
 * Description    : 水温值.结果带偏移 - 40
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_ActualValue(void)
{
    uint8_t u8Result = 0u;
hu's avatar
hu committed
145
    u8Result = CoolantVariable.Value ;
hu's avatar
hu committed
146 147 148 149
    return u8Result;
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_Valid
hu's avatar
hu committed
150
 * Description    :
hu's avatar
hu committed
151 152 153 154 155 156 157 158
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_Valid(void)
{
    uint8_t u8Result = 0u;
hu's avatar
hu committed
159
    u8Result = CoolantVariable.Valid ;
hu's avatar
hu committed
160 161 162 163 164 165 166 167 168 169 170 171 172
    return u8Result;
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_CurSeg
 * Description    : 水温当前段
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_CurSeg(void)
{
    uint8_t u8Result = 0u;
hu's avatar
hu committed
173
    u8Result = CoolantVariable.CurSeg ;
hu's avatar
hu committed
174
    return u8Result;
hu's avatar
hu committed
175
}