Data_TPMS.c 19.2 KB
Newer Older
1
#include "Application.h"
2 3 4
#include "Data_TPMS\Data_TPMS.h"

_TPMS_Display TPMS;
5 6 7 8
uint32_t Front_LearnTime_Count0 = 0;
uint32_t Front_LearnTime_Count1 = 0;
uint32_t Rear_LearnTime_Count0 = 0;
uint32_t Rear_LearnTime_Count1 = 0;
9
uint8_t Can_341_Flg = 0;
10 11
void Data_TPMS_KL30_Init ( void )
{
李俭双's avatar
李俭双 committed
12
    uint8_t TPMS_L[2] = {0,0};
13 14
    //Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u);
    eeprom_ReadRecord(EEPROM_BLOCK_09,  TPMS_L , 2);
15 16
    MenuData.TPMS_Front_Learn = TPMS_L[0];
    MenuData.TPMS_Rear_Learn  = TPMS_L[1];
17
        //MenuData.TPMS_Front_FirstLearn_Flag = TPMS_L[2];
李俭双's avatar
李俭双 committed
18
    //MenuData.TPMS_Rear_FirstLearn_Flag  = TPMS_L[3];
19 20
    TPMS.Front_Press_Value = 0;
    TPMS.Rear_Press_Value  = 0;
李俭双's avatar
李俭双 committed
21

22 23 24
    TPMS.Front_TPMS_Valid  = 0;
    TPMS.Rear_TPMS_Valid   = 0;
    TPMS.TPMS_Warning      = 0;
25
    //TPMS.TPMS_Unit         = Get_Dis_Tpms_Unit();
26 27
    TPMS.TPMS_Front_Learn  = MenuData.TPMS_Front_Learn;
    TPMS.TPMS_Rear_Learn   = MenuData.TPMS_Rear_Learn;
李俭双's avatar
李俭双 committed
28 29
    TPMS.TPMS_Front_FirstLearn_Flag  = MenuData.TPMS_Front_FirstLearn_Flag;
    TPMS.TPMS_Rear_FirstLearn_Flag   = MenuData.TPMS_Rear_FirstLearn_Flag;
30 31

    TPMS.TPMS_LOST = 0;
32 33 34 35
    Front_LearnTime_Count0  = 0;
    Front_LearnTime_Count1 = 0;
    Rear_LearnTime_Count0  = 0;
    Rear_LearnTime_Count1  = 0;
36 37

    Can_341_Flg = 0;
38 39 40
}
void Data_TPMS_KL15_WAKE_UP_Init ( void )
{
李俭双's avatar
李俭双 committed
41
    uint8_t TPMS_L[2] = {0,0};
42 43
    //Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1);
    eeprom_ReadRecord(EEPROM_BLOCK_09, TPMS_L , 2);
44 45
    MenuData.TPMS_Front_Learn = TPMS_L[0];
    MenuData.TPMS_Rear_Learn  = TPMS_L[1];
李俭双's avatar
李俭双 committed
46 47
    //MenuData.TPMS_Front_FirstLearn_Flag = TPMS_L[2];
    //MenuData.TPMS_Rear_FirstLearn_Flag  = TPMS_L[3];
48 49
    TPMS.TPMS_Front_Learn     = MenuData.TPMS_Front_Learn;
    TPMS.TPMS_Rear_Learn      = MenuData.TPMS_Rear_Learn;
李俭双's avatar
李俭双 committed
50 51
    TPMS.TPMS_Front_FirstLearn_Flag  = MenuData.TPMS_Front_FirstLearn_Flag;
    TPMS.TPMS_Rear_FirstLearn_Flag   = MenuData.TPMS_Rear_FirstLearn_Flag;
52 53

    TPMS.TPMS_LOST = 0;
54 55 56 57 58 59 60
 
    Front_LearnTime_Count0  = 0;
    Front_LearnTime_Count1 = 0;
    Rear_LearnTime_Count0  = 0;
    Rear_LearnTime_Count1  = 0;
    
    Can_341_Flg = 0;
61 62 63 64 65
}

void Can_341_Receive(void)
{
    Can_341_Flg = 1;
66 67 68 69 70 71
}

void Data_TPMS_Processing_Service ( void )
{
    uint16_t Front_TPMS = 0;
    uint16_t Rear_TPMS  = 0;
李俭双's avatar
李俭双 committed
72 73 74 75 76 77
    uint8_t  TPMS_L[2] = {0,0};
    
    if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) != CAN_SIG_LOST) 
    {
        TPMS.TPMS_Front_Learn = Get_CAN_CH0_ID_341_Sig_Front_LearningStatus();
        TPMS.TPMS_Rear_Learn = Get_CAN_CH0_ID_341_Sig_Rear_LearningStatus();
78
        TPMS.TPMS_LOST = 1;
李俭双's avatar
李俭双 committed
79 80 81 82 83
    }
    else
    {
        TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
        TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
84
        TPMS.TPMS_LOST = 0;
李俭双's avatar
李俭双 committed
85
    }
86 87 88 89 90 91 92 93 94 95 96 97 98 99


    if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x373_Msg_Count) != CAN_SIG_LOST)
    {
        if((Get_CAN_CH0_ID_373_Sig_Rear_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Rear_id() != 0xFFFFFFFF))
        {
            TPMS.TPMS_Rear_ID_Value = 1;
            //TPMS.TPMS_Rear_Learn = LearningCompletion;
        }
        else
        {
            TPMS.TPMS_Rear_ID_Value = 0;
        }

100
        
101 102 103 104 105 106 107 108
        if((Get_CAN_CH0_ID_373_Sig_Front_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Front_id() != 0xFFFFFFFF))
        {
            TPMS.TPMS_Front_ID_Value = 1;
        }
        else
        {
            TPMS.TPMS_Front_ID_Value = 0;
        }
109 110 111 112 113 114 115 116 117 118

        if((Get_CAN_CH0_ID_373_Sig_Rear_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Rear_id() != 0xFFFFFFFF))
        {
            TPMS.TPMS_Rear_ID_Value = 1;
        }
        else
        {
            TPMS.TPMS_Rear_ID_Value = 0;
        }
        
119 120 121 122 123 124
    }
    else
    {
        TPMS.TPMS_Front_ID_Value = 0;
        TPMS.TPMS_Rear_ID_Value = 0;
    }
李俭双's avatar
李俭双 committed
125 126 127 128
       
    
    if(TPMS.TPMS_Front_Learn == 0x0)
    {        
129

130 131 132 133 134 135 136 137 138 139
        //if(TPMS.TPMS_Front_Timeclean == 0)
        //{
        //    LearnTime_Count = 0;
        //}
        //TPMS.TPMS_Front_Timeclean = 1; 
        Front_LearnTime_Count1 = 0;
        if(Front_LearnTime_Count0 <= 6000)
        {
            Front_LearnTime_Count0++;
            TPMS.TPMS_Front_Learn = Unstudied;
140 141 142 143
          //LearnTime_Count = 0;
        }
        else
        {
144
             
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
            if ((MenuData.TPMS_Front_Learn != 0x2) && (MenuData.TPMS_Front_Learn != 0x3) ) 
            {
                if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) != CAN_SIG_LOST) 
                {
                    TPMS.TPMS_Front_Learn = LearningFailure;
                }
                else
                {
                    TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
                }
                
            }
            else
            {
                TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
            }
        }
李俭双's avatar
李俭双 committed
162 163
    }
    else if(TPMS.TPMS_Front_Learn == 0x1)
164
    { 
165 166 167 168 169 170 171 172 173 174
        //if((Get_CAN_CH0_ID_373_Sig_Front_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Front_id() != 0xFFFFFFFF))
        //{
        //    TPMS.TPMS_Front_ID_Value = 1;
        //    //TPMS.TPMS_Front_Learn = LearningCompletion;
        //}
        //else
        //{
        //    TPMS.TPMS_Front_ID_Value = 0;
        //}

175 176 177 178 179 180 181
        //if(TPMS.TPMS_Front_Timeclean == 0)
        //{
        //    LearnTime_Count = 0;
        //}
        //TPMS.TPMS_Front_Timeclean = 1;   
        Front_LearnTime_Count0 = 0;     
        if(Front_LearnTime_Count1 <= 6000)
李俭双's avatar
李俭双 committed
182
        {
183
            Front_LearnTime_Count1++;
李俭双's avatar
李俭双 committed
184 185 186 187 188 189
            TPMS.TPMS_Front_Learn = Learning;
        }
        else
        {
            if ((MenuData.TPMS_Front_Learn != 0x2) && (MenuData.TPMS_Front_Learn != 0x3) ) 
            {
190 191 192 193 194 195 196 197
                if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) != CAN_SIG_LOST) 
                {
                    TPMS.TPMS_Front_Learn = LearningFailure;
                }
                else
                {
                    TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
                }
李俭双's avatar
李俭双 committed
198 199 200 201 202 203 204 205 206
            }
            else
            {
                TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
            }
        }
    }
    else if (TPMS.TPMS_Front_Learn == 0x2)
    {
207 208
        Front_LearnTime_Count0 = 0;
        Front_LearnTime_Count1 = 0;
209 210 211 212 213 214 215 216 217
        //if((Get_CAN_CH0_ID_373_Sig_Front_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Front_id() != 0xFFFFFFFF))
        //{
        //    TPMS.TPMS_Front_ID_Value = 1;
        //    //TPMS.TPMS_Front_Learn = LearningCompletion;
        //}
        //else
        //{
        //    TPMS.TPMS_Front_ID_Value = 0;
        //}
李俭双's avatar
李俭双 committed
218 219 220 221
        
    }
    else if (TPMS.TPMS_Front_Learn == 0x3)
    {
222 223
        Front_LearnTime_Count0 = 0;
        Front_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
224 225 226 227
        TPMS.TPMS_Front_Learn = LearningFailure;
    }
    else
    {
228 229
        Front_LearnTime_Count0 = 0;
        Front_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
230 231 232 233 234
        TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
    }

    if(TPMS.TPMS_Rear_Learn == 0x0)
    {        
235 236 237 238 239 240 241 242

        //if(TPMS.TPMS_Rear_Timeclean == 0)
        //{
        //    LearnTime_Count1 = 0;
        //}
        //TPMS.TPMS_Rear_Timeclean = 1; 
        Rear_LearnTime_Count1 = 0;
        if(Rear_LearnTime_Count0 <= 6000)
243
        {
244
            Rear_LearnTime_Count0++;// = 0;
李俭双's avatar
李俭双 committed
245
            TPMS.TPMS_Rear_Learn = Unstudied;
246 247 248
        }
        else
        {
249
            
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
            if ((MenuData.TPMS_Rear_Learn != 0x2) && (MenuData.TPMS_Rear_Learn != 0x3) ) 
            {
                if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) != CAN_SIG_LOST) 
                {
                    TPMS.TPMS_Rear_Learn = LearningFailure;
                }
                else
                {
                    TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
                }
            }
            else
            {
                TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
            }
        }
李俭双's avatar
李俭双 committed
266 267 268
    }
    else if(TPMS.TPMS_Rear_Learn == 0x1)
    {        
269 270 271 272 273 274 275
        //if(TPMS.TPMS_Rear_Timeclean == 0)
        //{
        //    LearnTime_Count1 = 0;
        //}
        //TPMS.TPMS_Rear_Timeclean = 1; 
        Rear_LearnTime_Count0 = 0;
        if(Rear_LearnTime_Count1 <= 6000)
李俭双's avatar
李俭双 committed
276
        {
277
            Rear_LearnTime_Count1++;
李俭双's avatar
李俭双 committed
278 279 280 281
            TPMS.TPMS_Rear_Learn = Learning;
        }
        else
        {
282
            
李俭双's avatar
李俭双 committed
283 284
            if ((MenuData.TPMS_Rear_Learn != 0x2) && (MenuData.TPMS_Rear_Learn != 0x3) )
            {
285 286 287 288 289 290 291 292
                if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) != CAN_SIG_LOST) 
                {
                    TPMS.TPMS_Rear_Learn = LearningFailure;
                }
                else
                {
                    TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
                }
李俭双's avatar
李俭双 committed
293 294 295
            }
            else
            {
296
                TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
李俭双's avatar
李俭双 committed
297 298 299 300 301
            }
        }
    }
    else if (TPMS.TPMS_Rear_Learn == 0x2)
    {
302 303
        Rear_LearnTime_Count0 = 0;
        Rear_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
304 305 306
    }
    else if (TPMS.TPMS_Rear_Learn == 0x3)
    {
307 308
        Rear_LearnTime_Count0 = 0;
        Rear_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
309 310 311 312
        TPMS.TPMS_Rear_Learn = LearningFailure;
    }
    else
    {
313 314
        Rear_LearnTime_Count0 = 0;
        Rear_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
315 316 317 318
        TPMS.TPMS_Rear_Learn = MenuData.TPMS_Front_Learn;
    }
    

319 320
    if((TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn) || (TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn))
    {
李俭双's avatar
李俭双 committed
321 322 323 324 325 326 327 328 329
        if(TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn)
        {
            TPMS.TPMS_Front_FirstLearn_Flag = 1;
        }
        if(TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn)
        {
            TPMS.TPMS_Rear_FirstLearn_Flag = 1;
        }
         
330 331 332 333 334 335 336 337
        //if((TPMS.TPMS_Front_Learn == 0x2) || (TPMS.TPMS_Front_Learn == 0x3))
        //{
        //    MenuData.TPMS_Front_Learn = TPMS.TPMS_Front_Learn;
        //}
        //if((TPMS.TPMS_Rear_Learn == 0x2) || (TPMS.TPMS_Rear_Learn == 0x3))
        //{
        //    MenuData.TPMS_Rear_Learn  = TPMS.TPMS_Rear_Learn;
        //}
338 339
        if(((TPMS.TPMS_Front_Learn == 0x2) || (TPMS.TPMS_Front_Learn == 0x3)) && (TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn))
        {
340
            MenuData.TPMS_Front_Learn = TPMS.TPMS_Front_Learn;
341 342
            TPMS_L[0] = MenuData.TPMS_Front_Learn;
            TPMS_L[1] = MenuData.TPMS_Rear_Learn;            
343 344
            //Data_User_EEPROM_Write(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u); 
            eeprom_WriteRecord(EEPROM_BLOCK_09, TPMS_L, 2); 
345

346 347 348
            
        }
        if( ((TPMS.TPMS_Rear_Learn == 0x2) || (TPMS.TPMS_Rear_Learn == 0x3)) && (TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn))
李俭双's avatar
李俭双 committed
349
        {
350
            MenuData.TPMS_Rear_Learn  = TPMS.TPMS_Rear_Learn;
李俭双's avatar
李俭双 committed
351 352
            TPMS_L[0] = MenuData.TPMS_Front_Learn;
            TPMS_L[1] = MenuData.TPMS_Rear_Learn;            
353 354
            //Data_User_EEPROM_Write(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u); 
            eeprom_WriteRecord(EEPROM_BLOCK_09, TPMS_L,  2); 
李俭双's avatar
李俭双 committed
355 356 357
            
        }
        
358
    }
李俭双's avatar
李俭双 committed
359

360
    //TPMS.TPMS_Unit      = Get_Dis_Tpms_Unit();
361 362
    Front_TPMS          = Get_CAN_CH0_ID_341_Sig_Front_Pressure();
    Rear_TPMS           = Get_CAN_CH0_ID_341_Sig_Rear_Pressure();
363

364
    if ( 1 )
365 366 367 368 369 370 371 372 373 374 375 376 377
    {
        if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) == CAN_SIG_LOST)
        {
            TPMS.Front_TPMS_Valid  = 0;  //信号掉线,显示--
            TPMS.Rear_TPMS_Valid   = 0;  //信号掉线,显示--
            TPMS.Front_Press_Value = 0;
            TPMS.Rear_Press_Value  = 0;
            TPMS.TPMS_Warning      = 0;  //白灯
        }
        else
        {            
            if((Front_TPMS == 0xFF) || (Rear_TPMS == 0xFF))
            {
李俭双's avatar
李俭双 committed
378
                
379 380 381
                if((Front_TPMS == 0xFF) && (Rear_TPMS != 0xFF))
                {
                    TPMS.Front_TPMS_Valid  = 0;
李俭双's avatar
李俭双 committed
382
                    TPMS.Rear_TPMS_Valid   = 1;
383
                    TPMS.Front_Press_Value = 990;
384
                    TPMS.Rear_Press_Value  = Rear_TPMS * 2750;
385
                    TPMS.Rear_Press_Value  /= 102 ;
386
                    if(TPMS.Rear_Press_Value > 9900)
387
                    {
388
                        TPMS.Rear_Press_Value = 9900;
389
                    }
390 391
                    //if(((TPMS.Rear_Press_Value + 50)< 1700) || ((TPMS.Rear_Press_Value + 50) > 2500))
                    if((Get_Rear_TPMS_Sig_Value() < 17) || (Get_Rear_TPMS_Sig_Value() > 25))
392 393 394 395 396 397 398 399
                    {
                        TPMS.TPMS_Warning = 1;
                    }
                    else
                    {
                        TPMS.TPMS_Warning = 0;
                    }
                }
400
                else if ((Front_TPMS != 0xFF) && (Rear_TPMS == 0xFF))
401
                {
李俭双's avatar
李俭双 committed
402
                    TPMS.Front_TPMS_Valid  = 1;
403
                    TPMS.Rear_TPMS_Valid   = 0;
404
                    TPMS.Rear_Press_Value  = 990;
405
                    TPMS.Front_Press_Value = Front_TPMS *2750 ;
406
                    TPMS.Front_Press_Value  /= 102 ;
407
                    if(TPMS.Front_Press_Value > 9900)
408
                    {
409
                        TPMS.Front_Press_Value = 9900;
410
                    }
411
                    //if(((TPMS.Front_Press_Value + 50) < 1700) || ((TPMS.Front_Press_Value + 50) > 2300))
412
                    if((Get_Front_TPMS_Sig_Value() < 17) || (Get_Front_TPMS_Sig_Value() > 23))
413 414 415 416 417 418 419 420 421 422
                    {
                        TPMS.TPMS_Warning = 1;
                    }
                    else
                    {
                        TPMS.TPMS_Warning = 0;
                    }
                }
                else
                {
423 424
                    TPMS.Front_Press_Value = 9900;
                    TPMS.Rear_Press_Value = 9900;
425
                    TPMS.TPMS_Warning = 0;
426 427 428 429 430 431
                    TPMS.Front_TPMS_Valid  = 0;
                    TPMS.Rear_TPMS_Valid   = 0;
                }
            }
            else
            {
李俭双's avatar
李俭双 committed
432 433
                TPMS.Front_TPMS_Valid  = 1;
                TPMS.Rear_TPMS_Valid   = 1;
434
                TPMS.Front_Press_Value = Front_TPMS * 2750 ;                
435
                TPMS.Front_Press_Value  /= 102 ;
436
                if(TPMS.Front_Press_Value > 9900)
437
                {
438
                    TPMS.Front_Press_Value = 9900;
439 440
                }

441
                TPMS.Rear_Press_Value  = Rear_TPMS * 2750;                
442
                TPMS.Rear_Press_Value  /= 102 ;
443
                if(TPMS.Rear_Press_Value > 9900)
444
                {
445
                    TPMS.Rear_Press_Value = 9900;
446
                }
447
                //if (((TPMS.Front_Press_Value + 50) < 1700) || ((TPMS.Front_Press_Value + 50) > 2300) || ((TPMS.Rear_Press_Value + 50) < 1700) || ((TPMS.Rear_Press_Value + 50) > 2500))
448
                if ((Get_Front_TPMS_Sig_Value() < 17) || (Get_Front_TPMS_Sig_Value() > 23) || (Get_Rear_TPMS_Sig_Value() < 17) || (Get_Rear_TPMS_Sig_Value() > 25))
449 450 451 452 453 454 455 456 457 458
                {
                    TPMS.TPMS_Warning = 1;
                }
                else
                {
                    TPMS.TPMS_Warning = 0;
                }
            }
            
        }
李俭双's avatar
李俭双 committed
459
        if(TPMS.TPMS_Front_Learn == Unstudied)
460
        {
李俭双's avatar
李俭双 committed
461
            TPMS.TPMS_Front_FirstLearn_Flag = Unstudied;            
462
        }
李俭双's avatar
李俭双 committed
463
        else if(TPMS.TPMS_Front_Learn == Learning)
464
        {
李俭双's avatar
李俭双 committed
465
            TPMS.TPMS_Front_FirstLearn_Flag = Learning;            
466
        }
李俭双's avatar
李俭双 committed
467
        else if(TPMS.TPMS_Front_Learn == LearningCompletion)
468
        {
李俭双's avatar
李俭双 committed
469 470
            TPMS.TPMS_Front_FirstLearn_Flag = LearningCompletion;
            
471
        }
李俭双's avatar
李俭双 committed
472
        else if(TPMS.TPMS_Front_Learn == LearningFailure)
473
        {
李俭双's avatar
李俭双 committed
474
            TPMS.TPMS_Front_FirstLearn_Flag = LearningFailure;
475
            TPMS.Front_Press_Value = 9900;
476 477 478 479 480 481
        }
        else
        {
            ;
        }

李俭双's avatar
李俭双 committed
482
        if(TPMS.TPMS_Rear_Learn == Unstudied)
483
        {
李俭双's avatar
李俭双 committed
484
            TPMS.TPMS_Rear_FirstLearn_Flag = Unstudied;
485
        }
李俭双's avatar
李俭双 committed
486
        else if(TPMS.TPMS_Rear_Learn == Learning)
487
        {
李俭双's avatar
李俭双 committed
488
            TPMS.TPMS_Rear_FirstLearn_Flag = Learning;
489
        }
李俭双's avatar
李俭双 committed
490
        else if(TPMS.TPMS_Rear_Learn == LearningCompletion)
491
        {
李俭双's avatar
李俭双 committed
492 493
            TPMS.TPMS_Rear_FirstLearn_Flag = LearningCompletion;
            
494
        }
李俭双's avatar
李俭双 committed
495
        else if(TPMS.TPMS_Rear_Learn == LearningFailure)
496
        {
李俭双's avatar
李俭双 committed
497
            TPMS.TPMS_Rear_FirstLearn_Flag = LearningFailure;
498
            TPMS.Rear_Press_Value = 9900;
499 500 501 502 503 504
        }
        else
        {
            ;
        }

李俭双's avatar
李俭双 committed
505 506 507 508
        //if ((MenuData.TPMS_Rear_Learn != LearningCompletion) && (MenuData.TPMS_Front_Learn != LearningCompletion))
        //{
        //    TPMS.TPMS_Warning = 0;
        //}
509

510 511 512 513 514 515 516 517 518 519
    }
    else
    {
        TPMS.Front_TPMS_Valid  = 0;
        TPMS.Rear_TPMS_Valid   = 0; 
        TPMS.Front_Press_Value = 0;
        TPMS.Rear_Press_Value  = 0;
        TPMS.TPMS_Warning      = 0; 
    }
}
520
uint32_t Data_Bar_To_Psi (uint32_t bar)
521
{
522 523 524
    uint32_t Bar = 0;
    Bar = bar * 145;
    Bar /= 10;
525
    //Bar += 5;
526 527 528 529
    // bar *= 145;
    // bar /= 10;
    // bar += 5;    
    return Bar;
530
}
531 532

/*指示灯报警信号  0:白色常亮   1:黄色常亮*/
533 534 535 536
uint8_t Get_Led_TPMS_Waring (void)
{
    return TPMS.TPMS_Warning;
}
537

李俭双's avatar
李俭双 committed
538
/*0:无效,常显--  1:有效,按实际胎压数值显示  */
539 540 541 542 543 544 545 546
uint8_t Get_Front_TPMS_Sig_Vaild (void)
{
    return TPMS.Front_TPMS_Valid;
}
uint8_t Get_Rear_TPMS_Sig_Vaild (void)
{
    return TPMS.Rear_TPMS_Valid;
}
547 548 549 550 551 552 553 554 555

uint8_t Get_Front_TPMS_ID_Vaild (void)
{
    return TPMS.TPMS_Front_ID_Value;
}
uint8_t Get_Rear_TPMS_ID_Vaild (void)
{
    return TPMS.TPMS_Rear_ID_Value;
}
556
//10倍
557 558 559
uint16_t Get_Front_TPMS_Sig_Value (void)
{
    uint16_t value = 0;
560 561 562 563 564 565 566 567 568
    //if (TPMS.TPMS_Unit == 1)
    //{
    //    value = (Data_Bar_To_Psi(TPMS.Front_Press_Value) + 500) / 1000;
    //    if(value > 99)
    //    {
    //        value = 99;
    //    }
    //}
    //else
569
    {        
570 571
        //value = TPMS.Front_Press_Value + 50;        
        value = (uint16_t)((TPMS.Front_Press_Value + 50) / 100);
572 573 574 575 576 577
    }
    return value;
}
uint16_t Get_Rear_TPMS_Sig_Value (void)
{
    uint16_t value = 0;
578 579 580 581 582 583 584 585 586 587
    //if (TPMS.TPMS_Unit == 1)
    //{
    //    value = (Data_Bar_To_Psi(TPMS.Rear_Press_Value) + 500) / 1000;
    //    if(value > 99)
    //    {
    //        value = 99;
    //    }
    //    
    //}
    //else
588
    {        
589 590
        //value = TPMS.Rear_Press_Value + 50;        
        value = (uint8_t)((TPMS.Rear_Press_Value + 50) / 100);        
591 592 593 594 595
    }
    return value;    
}
uint16_t Get_Rear_TPMS_TX (void)
{
596
    uint16_t value = 0;
597
    value = (uint16_t)(Data_Bar_To_Psi(TPMS.Rear_Press_Value) / 100);
598 599 600 601 602
    if(value > 990)
    {
        value = 990;
    }
    return value;
603 604 605
}
uint16_t Get_Front_TPMS_TX (void)
{
606
    uint16_t value = 0;
607
    value = (uint16_t)(Data_Bar_To_Psi(TPMS.Front_Press_Value) / 100);
608 609 610 611 612
    if(value > 990)
    {
        value = 990;
    }
    return value;
613
}
李俭双's avatar
李俭双 committed
614 615 616 617 618 619 620 621 622 623 624 625

/*前轮胎压学习结果 0-未学习“--”常显  1-学习中“--”闪烁  2-学习成功,正常显示数值  3-学习失败,闪烁显示最大值99*/
uint8_t Get_Front_FirstLearn_Flag (void)
{
    return TPMS.TPMS_Front_FirstLearn_Flag;
}
/*后轮胎压学习结果 0-未学习“--”常显  1-学习中“--”闪烁  2-学习成功,正常显示数值  3-学习失败,闪烁显示最大值99*/
uint8_t Get_Rear_FirstLearn_Flag (void)
{
    return TPMS.TPMS_Rear_FirstLearn_Flag;
}

626 627 628 629 630 631 632 633 634 635
uint8_t Get_TPMS_Front_Learn(void)
{
    return TPMS.TPMS_Front_Learn;
}

uint8_t Get_TPMS_Rear_Learn(void)
{
    return TPMS.TPMS_Rear_Learn;
}

636 637 638 639 640 641
/*获取0x341是否掉线  0-掉线  “--”闪烁   1-在线  获取学习结果进行显示*/
uint8_t Get_TPMS_CAN_LOST (void)
{
    return TPMS.TPMS_LOST ;
}