1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#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_GetIgnOnTime() < 3000)
{
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 == 2)
{
DataCoolantTemp_Dis.u8_Flg = 1;
DataCoolantTemp_Dis.u8_UpFlashtimer = 0;
DataCoolantTemp_Dis.u8_DownFlashtimer = 0;
}
else if(DataCoolantTemp_Dis.u8_Flg == 0)
{
DataCoolantTemp_Dis.u8_Flg = 2;
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;
}