Data_TPMS.c 18.9 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 13
    uint8_t TPMS_L[2] = {0,0};
    Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u);
14 15
    MenuData.TPMS_Front_Learn = TPMS_L[0];
    MenuData.TPMS_Rear_Learn  = TPMS_L[1];
16
        //MenuData.TPMS_Front_FirstLearn_Flag = TPMS_L[2];
李俭双's avatar
李俭双 committed
17
    //MenuData.TPMS_Rear_FirstLearn_Flag  = TPMS_L[3];
18 19
    TPMS.Front_Press_Value = 0;
    TPMS.Rear_Press_Value  = 0;
李俭双's avatar
李俭双 committed
20

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

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

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

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

void Can_341_Receive(void)
{
    Can_341_Flg = 1;
64 65 66 67 68 69
}

void Data_TPMS_Processing_Service ( void )
{
    uint16_t Front_TPMS = 0;
    uint16_t Rear_TPMS  = 0;
李俭双's avatar
李俭双 committed
70 71 72 73 74 75
    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();
76
        TPMS.TPMS_LOST = 1;
李俭双's avatar
李俭双 committed
77 78 79 80 81
    }
    else
    {
        TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
        TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
82
        TPMS.TPMS_LOST = 0;
李俭双's avatar
李俭双 committed
83
    }
84 85 86 87 88 89 90 91 92 93 94 95 96 97


    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;
        }

98
        
99 100 101 102 103 104 105 106
        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;
        }
107 108 109 110 111 112 113 114 115 116

        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;
        }
        
117 118 119 120 121 122
    }
    else
    {
        TPMS.TPMS_Front_ID_Value = 0;
        TPMS.TPMS_Rear_ID_Value = 0;
    }
李俭双's avatar
李俭双 committed
123 124 125 126
       
    
    if(TPMS.TPMS_Front_Learn == 0x0)
    {        
127

128 129 130 131 132 133 134 135 136 137
        //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;
138 139 140 141
          //LearnTime_Count = 0;
        }
        else
        {
142
             
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
            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
160 161
    }
    else if(TPMS.TPMS_Front_Learn == 0x1)
162
    { 
163 164 165 166 167 168 169 170 171 172
        //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;
        //}

173 174 175 176 177 178 179
        //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
180
        {
181
            Front_LearnTime_Count1++;
李俭双's avatar
李俭双 committed
182 183 184 185 186 187
            TPMS.TPMS_Front_Learn = Learning;
        }
        else
        {
            if ((MenuData.TPMS_Front_Learn != 0x2) && (MenuData.TPMS_Front_Learn != 0x3) ) 
            {
188 189 190 191 192 193 194 195
                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
196 197 198 199 200 201 202 203 204
            }
            else
            {
                TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
            }
        }
    }
    else if (TPMS.TPMS_Front_Learn == 0x2)
    {
205 206
        Front_LearnTime_Count0 = 0;
        Front_LearnTime_Count1 = 0;
207 208 209 210 211 212 213 214 215
        //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
216 217 218 219
        
    }
    else if (TPMS.TPMS_Front_Learn == 0x3)
    {
220 221
        Front_LearnTime_Count0 = 0;
        Front_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
222 223 224 225
        TPMS.TPMS_Front_Learn = LearningFailure;
    }
    else
    {
226 227
        Front_LearnTime_Count0 = 0;
        Front_LearnTime_Count1 = 0;
李俭双's avatar
李俭双 committed
228 229 230 231 232
        TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
    }

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

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

317 318
    if((TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn) || (TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn))
    {
李俭双's avatar
李俭双 committed
319 320 321 322 323 324 325 326 327
        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;
        }
         
328 329 330 331 332 333 334 335
        //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;
        //}
336 337
        if(((TPMS.TPMS_Front_Learn == 0x2) || (TPMS.TPMS_Front_Learn == 0x3)) && (TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn))
        {
338
            MenuData.TPMS_Front_Learn = TPMS.TPMS_Front_Learn;
339 340 341
            TPMS_L[0] = MenuData.TPMS_Front_Learn;
            TPMS_L[1] = MenuData.TPMS_Rear_Learn;            
            Data_User_EEPROM_Write(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u); 
342

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

356
    //TPMS.TPMS_Unit      = Get_Dis_Tpms_Unit();
357 358
    Front_TPMS          = Get_CAN_CH0_ID_341_Sig_Front_Pressure();
    Rear_TPMS           = Get_CAN_CH0_ID_341_Sig_Rear_Pressure();
359

360 361 362 363 364 365 366 367 368 369 370 371 372 373
    if ( Common_Get_IG_Sts() == COMMON_POWER_ON )
    {
        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
374
                
375 376 377
                if((Front_TPMS == 0xFF) && (Rear_TPMS != 0xFF))
                {
                    TPMS.Front_TPMS_Valid  = 0;
李俭双's avatar
李俭双 committed
378
                    TPMS.Rear_TPMS_Valid   = 1;
379
                    TPMS.Front_Press_Value = 990;
380
                    TPMS.Rear_Press_Value  = Rear_TPMS * 2750;
381
                    TPMS.Rear_Press_Value  /= 102 ;
382
                    if(TPMS.Rear_Press_Value > 9900)
383
                    {
384
                        TPMS.Rear_Press_Value = 9900;
385
                    }
386 387
                    //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))
388 389 390 391 392 393 394 395
                    {
                        TPMS.TPMS_Warning = 1;
                    }
                    else
                    {
                        TPMS.TPMS_Warning = 0;
                    }
                }
396
                else if ((Front_TPMS != 0xFF) && (Rear_TPMS == 0xFF))
397
                {
李俭双's avatar
李俭双 committed
398
                    TPMS.Front_TPMS_Valid  = 1;
399
                    TPMS.Rear_TPMS_Valid   = 0;
400
                    TPMS.Rear_Press_Value  = 990;
401
                    TPMS.Front_Press_Value = Front_TPMS *2750 ;
402
                    TPMS.Front_Press_Value  /= 102 ;
403
                    if(TPMS.Front_Press_Value > 9900)
404
                    {
405
                        TPMS.Front_Press_Value = 9900;
406
                    }
407 408
                    //if(((TPMS.Front_Press_Value + 50) < 1700) || ((TPMS.Front_Press_Value + 50) > 2300))
                    if((Get_Front_TPMS_Sig_Value() < 17) || (Get_Front_TPMS_Sig_Value() > 25))
409 410 411 412 413 414 415 416 417 418
                    {
                        TPMS.TPMS_Warning = 1;
                    }
                    else
                    {
                        TPMS.TPMS_Warning = 0;
                    }
                }
                else
                {
419 420
                    TPMS.Front_Press_Value = 9900;
                    TPMS.Rear_Press_Value = 9900;
421
                    TPMS.TPMS_Warning = 0;
422 423 424 425 426 427
                    TPMS.Front_TPMS_Valid  = 0;
                    TPMS.Rear_TPMS_Valid   = 0;
                }
            }
            else
            {
李俭双's avatar
李俭双 committed
428 429
                TPMS.Front_TPMS_Valid  = 1;
                TPMS.Rear_TPMS_Valid   = 1;
430
                TPMS.Front_Press_Value = Front_TPMS * 2750 ;                
431
                TPMS.Front_Press_Value  /= 102 ;
432
                if(TPMS.Front_Press_Value > 9900)
433
                {
434
                    TPMS.Front_Press_Value = 9900;
435 436
                }

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

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

李俭双's avatar
李俭双 committed
501 502 503 504
        //if ((MenuData.TPMS_Rear_Learn != LearningCompletion) && (MenuData.TPMS_Front_Learn != LearningCompletion))
        //{
        //    TPMS.TPMS_Warning = 0;
        //}
505

506 507 508 509 510 511 512 513 514 515
    }
    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; 
    }
}
516
uint32_t Data_Bar_To_Psi (uint32_t bar)
517
{
518 519 520
    uint32_t Bar = 0;
    Bar = bar * 145;
    Bar /= 10;
521
    //Bar += 5;
522 523 524 525
    // bar *= 145;
    // bar /= 10;
    // bar += 5;    
    return Bar;
526
}
527 528

/*指示灯报警信号  0:白色常亮   1:黄色常亮*/
529 530 531 532
uint8_t Get_Led_TPMS_Waring (void)
{
    return TPMS.TPMS_Warning;
}
533

李俭双's avatar
李俭双 committed
534
/*0:无效,常显--  1:有效,按实际胎压数值显示  */
535 536 537 538 539 540 541 542
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;
}
543 544 545 546 547 548 549 550 551

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

/*前轮胎压学习结果 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;
}

622 623 624 625 626 627 628 629 630 631
uint8_t Get_TPMS_Front_Learn(void)
{
    return TPMS.TPMS_Front_Learn;
}

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

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