Common_Interface.c 19.4 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10
#include "Common_Interface.h"
#include "CAN_Communication_Matrix.h"
#include "CAN_Lib.h"
#include "Data_VehicleSpeed.h"
#include "Data_EngineSpeed.h"
#include "System_Monitor.h"
#include "GaugesInterface.h"
#include "Gauges.h"
#include "dr7f701441.dvf.h"
#include "GPIO.h"
hu's avatar
hu committed
11
#include "Data_Voltmeter.h"
hu's avatar
hu committed
12 13 14 15 16

#include "Line_in.h"

#include "Maintenance.h"
#include "Menu.h"
hu's avatar
hu committed
17
#include "GUI.h"
hu's avatar
hu committed
18 19 20

#include "Emulated_EEPROM.h"
#include "Watchdog.h"
hu's avatar
hu committed
21
#include "UDS_Common.h"
hu's avatar
hu committed
22
#include "kwp2000_service.h"
hu's avatar
hu committed
23 24 25 26 27 28 29

/*修饰变量static*/

/*ig on off时间线*/
static uint32_t PowerIgnOnTimeLine;
static uint32_t PowerIgnOffTimeLine;

hu's avatar
hu committed
30 31 32 33 34
static COMMON_PowerStatus_t PowerSts; /*1 ON ;  0 OFF*/
static uint16_t Act_V_Speed;          /*实际值,十倍的*/
static uint16_t Act_E_Speed;          /*实际值*/
static uint16_t Disp_V_Speed;         /*显示值,十倍的*/
static uint16_t Disp_E_Speed;         /*显示值*/
hu's avatar
hu committed
35 36 37 38 39 40 41 42

/*数据有效 1 ;数据无效 0 /0xff */
static DataValid_t PowerSts_Valid;
static DataValid_t Act_V_Speed_Valid;
static DataValid_t Act_E_Speed_Valid;
static DataValid_t Disp_V_Speed_Valid;
static DataValid_t Disp_E_Speed_Valid;

hu's avatar
hu committed
43 44
static DataValid_t Set_18EF1718_Msg_Sta;

hu's avatar
hu committed
45 46 47 48 49 50 51 52 53 54 55
static void Common_Set_Act_V_Speed(uint16_t Val);
static void Common_Set_Act_E_Speed(uint16_t Val);
static void Common_Set_Disp_V_Speed(uint16_t Val);
static void Common_Set_Disp_E_Speed(uint16_t Val);

static void Common_Set_Act_V_Speed_Valid(DataValid_t Val);
static void Common_Set_Act_E_Speed_Valid(DataValid_t Val);
static void Common_Set_Disp_V_Speed_Valid(DataValid_t Val);
static void Common_Set_Disp_E_Speed_Valid(DataValid_t Val);

static uint16_t SysRollingCounter;
hu's avatar
hu committed
56

hu's avatar
hu committed
57
static uint8_t CanFirstEvent[ID_TOTAL_MAX];
hu's avatar
hu committed
58
static void Individual_ECU_Communication(void);
hu's avatar
hu committed
59

hu's avatar
hu committed
60
extern _EOL_K_LINE_SET K_Line_Set;
hu's avatar
hu committed
61

hu's avatar
hu committed
62
/**/
hu's avatar
hu committed
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
static uint32_t User_FDJYLQQ_Time;
static uint32_t User_RYLQQ_Time;
static uint32_t User_BSXY_Time;
static uint32_t User_CSQY_Time;
static uint32_t User_LHQY_Time;
static uint32_t User_KQGZJ_Time;
static uint32_t User_DLZXY_Time;
static uint32_t User_LT_Time;

static uint32_t CRUISE_1_Time;
static uint32_t CRUISE_STUDY_Time;
static uint32_t CRUISE_SLD1_Time;
static uint32_t CRUISE_SLD2_Time;

static uint32_t VolWarning_Time;

static uint32_t LOW_VOLTAGE_TIME1;
static uint32_t LOW_VOLTAGE_TIME2;
static uint32_t HIGH_VOLTAGE_TIME1;
static uint32_t HIGH_VOLTAGE_TIME2;

static uint32_t HIGH_VOLTAGE;
static uint32_t LOW_VOLTAGE;

static uint32_t TPMS_TEST_OFF_TIME;
hu's avatar
hu committed
88
static uint32_t Menu_FacDea_Time;
89
static uint32_t OIL_PRESSURE_Time;
hu's avatar
hu committed
90

hu's avatar
hu committed
91 92
uint32_t UdsCanIDSta;

hu's avatar
hu committed
93
#pragma ghs section bss=".myNonInitArea"
94
static uint32_t Menu_Off_Time;
hu's avatar
hu committed
95
#pragma ghs section bss=default
hu's avatar
hu committed
96

hu's avatar
hu committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
/*每次唤醒调用*/
void Common_DataInit(void)
{
    PowerSts = COMMON_POWER_UNKNOW;
    Act_V_Speed = 0xffffu;
    Act_E_Speed = 0xffffu;
    Disp_V_Speed = 0xffffu;
    Disp_E_Speed = 0xffffu;

    PowerSts_Valid = COMMON_Valid_UNKNOW;
    Act_V_Speed_Valid = COMMON_Valid_UNKNOW;
    Act_E_Speed_Valid = COMMON_Valid_UNKNOW;
    Disp_V_Speed_Valid = COMMON_Valid_UNKNOW;
    Disp_E_Speed_Valid = COMMON_Valid_UNKNOW;
    PowerIgnOnTimeLine = 0x0ul;
    PowerIgnOffTimeLine = 0x0ul;
hu's avatar
hu committed
113

hu's avatar
hu committed
114
    /**/
115 116 117 118 119 120 121 122
    User_FDJYLQQ_Time = 0x00u;
    User_RYLQQ_Time = 0x00u;
    User_BSXY_Time = 0x00u;
    User_CSQY_Time = 0x00u;
    User_LHQY_Time = 0x00u;
    User_KQGZJ_Time = 0x00u;
    User_DLZXY_Time = 0x00u;
    User_LT_Time = 0x00u;
hu's avatar
hu committed
123 124 125 126 127

    CRUISE_1_Time = 0x00u;
    CRUISE_STUDY_Time = 0x00u;
    CRUISE_SLD1_Time = 0x00u;
    CRUISE_SLD2_Time = 0x00u;
hu's avatar
hu committed
128 129

    VolWarning_Time = 0x00u;
130 131 132 133
    LOW_VOLTAGE_TIME1 = 0x00u;
    LOW_VOLTAGE_TIME2 = 0x00u;
    HIGH_VOLTAGE_TIME1 = 0x00u;
    HIGH_VOLTAGE_TIME2 = 0x00u;
hu's avatar
hu committed
134 135
    HIGH_VOLTAGE = 0x0u;
    LOW_VOLTAGE = 0x0u;
hu's avatar
hu committed
136

hu's avatar
hu committed
137 138
    TPMS_TEST_OFF_TIME = 0x00u;
    Menu_FacDea_Time = 0x00u;
139
    OIL_PRESSURE_Time = 0x00u;
hu's avatar
hu committed
140
    Set_18EF1718_Msg_Sta = COMMON_InValid;
hu's avatar
hu committed
141
    //Menu_Off_Time = 0x00u;
hu's avatar
hu committed
142
    UdsCanIDSta = 0x00u;
hu's avatar
hu committed
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
}

/*以下由各个处理模块按需调用*/
/*使用数据之前,需要先判断数据是否有效,如果无效,则不可以使用*/

COMMON_PowerStatus_t Common_Get_IG_Sts(void)
{
    return PowerSts;
}

uint16_t Common_Get_Act_V_Speed(void)
{
    return Act_V_Speed;
}
uint16_t Common_Get_Act_E_Speed(void)
{
    return Act_E_Speed;
}
uint16_t Common_Get_Disp_V_Speed(void)
{
    return Disp_V_Speed;
}
uint16_t Common_Get_Disp_E_Speed(void)
{
    return Disp_E_Speed;
}

/*获取超速报警状态*/
uint8_t Common_Get_OverSpeed_Status(void)
{
    uint8_t OverSpeedStatus = 0u;
    uint16_t DispVSpeed = 0u;
    DispVSpeed = Common_Get_Disp_V_Speed();

    if (DispVSpeed >= 1000u)
    {
        OverSpeedStatus = 1u;
    }
    else if (DispVSpeed <= 960u)
    {
        OverSpeedStatus = 0u;
    }

    return OverSpeedStatus;
}

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
uint8_t Common_Get_OverSpeedLine_Status(void)
{
    uint8_t OverSpeedStatus = 0u;
    uint16_t DispVSpeed = 0u;
    uint16_t DataOverSpeedValue = 0u;

    DataOverSpeedValue = K_Line_Set.K_Line_LID44;
    DataOverSpeedValue *= 10u;

    DispVSpeed = Common_Get_Disp_V_Speed();

    if (K_Line_Set.K_Line_LID44 != 0xFF)
    {
        if (DispVSpeed >= (DataOverSpeedValue + 20))
        {
            OverSpeedStatus = 1u;
        }
        else if (DispVSpeed <= DataOverSpeedValue)
        {
            OverSpeedStatus = 0u;
        }
    }
    else
    {
        OverSpeedStatus = 0u;
    }

    return OverSpeedStatus;
}

hu's avatar
hu committed
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
static void Common_Set_IG_Sts(COMMON_PowerStatus_t Val)
{
    PowerSts = Val;
}
static void Common_Set_Act_V_Speed(uint16_t Val)
{
    Act_V_Speed = Val;
}
static void Common_Set_Act_E_Speed(uint16_t Val)
{
    Act_E_Speed = Val;
}
static void Common_Set_Disp_V_Speed(uint16_t Val)
{
    Disp_V_Speed = Val;
}
static void Common_Set_Disp_E_Speed(uint16_t Val)
{
    Disp_E_Speed = Val;
}

DataValid_t Common_Get_IG_Sts_Valid(void)
{
    return PowerSts_Valid;
}
DataValid_t Common_Get_Act_V_Speed_Valid(void)
{
hu's avatar
hu committed
246
    return Act_V_Speed_Valid;
hu's avatar
hu committed
247 248 249
}
DataValid_t Common_Get_Act_E_Speed_Valid(void)
{
hu's avatar
hu committed
250
    return Act_E_Speed_Valid;
hu's avatar
hu committed
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
}
DataValid_t Common_Get_Disp_V_Speed_Valid(void)
{
    return Disp_V_Speed_Valid;
}
DataValid_t Common_Get_Disp_E_Speed_Valid(void)
{
    return Disp_E_Speed_Valid;
}

static void Common_Set_IG_Sts_Valid(DataValid_t Val)
{
    PowerSts_Valid = Val;
}
static void Common_Set_Act_V_Speed_Valid(DataValid_t Val)
{
    Act_V_Speed_Valid = Val;
}
static void Common_Set_Act_E_Speed_Valid(DataValid_t Val)
{
    Act_E_Speed_Valid = Val;
}
static void Common_Set_Disp_V_Speed_Valid(DataValid_t Val)
{
    Disp_V_Speed_Valid = Val;
}
static void Common_Set_Disp_E_Speed_Valid(DataValid_t Val)
{
    Disp_E_Speed_Valid = Val;
}

/*2MS任务*/
hu's avatar
hu committed
283
static uint16_t wbyTest = 0;
hu's avatar
hu committed
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
void Common_Input_Para(void)
{
    /*    if (SYS_OPR_STAT_IGN_ON)
        {*/
    uint32_t V_Speed_Convert = 0ul;
    uint32_t u32IG_ON_Timer = 0u;
    uint16_t OilValue = 0u; /*机油压力数值*/
    uint32_t EBC2_Speed_Value = 0u;
    uint8_t LineStatus1 = 0u;
    uint8_t LineStatus2 = 0u;

    u32IG_ON_Timer = Common_GetIgnOnTime();

    if (SYS_OPR_STAT_IGN_ON)
    {
        Common_Set_IG_Sts(COMMON_POWER_ON);
        Common_Set_IG_Sts_Valid(COMMON_Valid);

        OilValue = Common_Get_Disp_E_Speed();

        //车速
        wbyTest = Speed_Get_Display_Value();
        Common_Set_Disp_V_Speed(wbyTest);
        Common_Set_Act_V_Speed(Speed_Get_ActualValue());
hu's avatar
hu committed
308

hu's avatar
hu committed
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
        if (Speed_Get_Valid())
        {
            Common_Set_Act_V_Speed_Valid(COMMON_Valid);
            Common_Set_Disp_V_Speed_Valid(COMMON_Valid);
        }
        else
        {
            Common_Set_Act_V_Speed_Valid(COMMON_InValid);
            Common_Set_Disp_V_Speed_Valid(COMMON_InValid);
        }

        Common_Set_Act_E_Speed(RevSpeedManage(Tacho_Get_ActualValue()));

        PowerIgnOffTimeLine = 0ul;
        if (PowerIgnOnTimeLine < 0x7ffffffful)
        {
            PowerIgnOnTimeLine += 2u;
        }
hu's avatar
hu committed
327

hu's avatar
hu committed
328 329 330 331 332
        /*电压计报警时间*/
        if (Gui_Get_Voltmeter_DisplayMode() <= 3u)
        {
            if (VolWarning_Time <= 5100)
            {
333
                VolWarning_Time++;
hu's avatar
hu committed
334 335 336 337 338 339 340
            }
        }
        else
        {
            VolWarning_Time = 0;
        }

341
        /**/
342
        if (RTE_Read_KL15_Voltage() <= (23500 - 800)) /*A2*/
343 344 345 346 347 348 349 350 351 352 353
        {
            if (LOW_VOLTAGE_TIME1 <= 3500)
                LOW_VOLTAGE_TIME1++;
            else
                LOW_VOLTAGE = 1;
        }
        else
        {
            LOW_VOLTAGE_TIME1 = 0;
        }

354
        if (RTE_Read_KL15_Voltage() >= (25000 - 800)) /*A2*/
355 356 357 358 359 360 361 362 363 364 365
        {
            if (LOW_VOLTAGE_TIME2 <= 5000)
                LOW_VOLTAGE_TIME2++;
            else
                LOW_VOLTAGE = 0;
        }
        else
        {
            LOW_VOLTAGE_TIME2 = 0;
        }
        //
366
        if (RTE_Read_KL15_Voltage() >= (30400 - 800)) /*A2*/
367 368 369 370 371 372 373 374 375 376 377
        {
            if (HIGH_VOLTAGE_TIME1 <= 3500)
                HIGH_VOLTAGE_TIME1++;
            else
                HIGH_VOLTAGE = 1;
        }
        else
        {
            HIGH_VOLTAGE_TIME1 = 0;
        }

378
        if (RTE_Read_KL15_Voltage() <= (29400 - 800)) /*A2*/
379 380 381 382 383 384 385 386 387 388 389
        {
            if (HIGH_VOLTAGE_TIME2 <= 5000)
                HIGH_VOLTAGE_TIME2++;
            else
                HIGH_VOLTAGE = 0;
        }
        else
        {
            HIGH_VOLTAGE_TIME2 = 0;
        }

hu's avatar
hu committed
390 391 392 393 394 395 396 397 398 399
        /*胎压匹配3分钟有效计时*/
        if ((TPMS_TEST_OFF_TIME <= 90000u) && (User_set_Num.User_TpmsStatus == 2u))
        {
            TPMS_TEST_OFF_TIME++;
        }
        else
        {
            TPMS_TEST_OFF_TIME = 0;
        }

hu's avatar
hu committed
400
        /**/
hu's avatar
hu committed
401 402 403 404 405
        if (
            ((bCurMenuIDX >= _FAC_DSP_LEVEL3_2MENU_1) && (bCurMenuIDX <= _FAC_DSP_LEVEL3_2MENU_6)) ||
            ((bCurMenuIDX >= _DEA_DSP_LEVEL3_2MENU_1) && (bCurMenuIDX <= _DEA_DSP_LEVEL3_2MENU_6)) ||
            (MenuFlag.Menu_StaFlag != 0x01u)
        )
hu's avatar
hu committed
406
        {
hu's avatar
hu committed
407
            if (Menu_FacDea_Time < 15000u)
hu's avatar
hu committed
408 409 410 411 412 413 414 415
            {
                Menu_FacDea_Time++;
            }
            else
            {
                ;/*Do Nothing!*/
            }
        }
416 417 418 419 420 421 422 423 424 425 426 427 428

        /**/
        if ((OilValue > 350u) && (Line_In_Get_Status(LINE_IN_ENG_OIL) == LINE_IN_LOGIC_VALID))
        {
            if (OIL_PRESSURE_Time < 5000u)
            {
                OIL_PRESSURE_Time++;
            }
        }
        else
        {
            OIL_PRESSURE_Time = 0u;
        }
hu's avatar
hu committed
429 430 431
        /**/
        if ((State_Flag.User_FDJYLQQ_FLAG == 1) || (State_Flag.User_FDJYLQQ_FLAG == 2))
        {
432
            if (User_FDJYLQQ_Time < 30001)
hu's avatar
hu committed
433 434 435 436
                User_FDJYLQQ_Time++;
        }
        else
        {
437
            User_FDJYLQQ_Time = 0;
hu's avatar
hu committed
438 439
        }

440
        if ((State_Flag.User_RYLQQ_FLAG == 1) || (State_Flag.User_RYLQQ_FLAG == 2))
hu's avatar
hu committed
441
        {
442
            if (User_RYLQQ_Time < 30001)
443
                User_RYLQQ_Time++;
hu's avatar
hu committed
444 445 446
        }
        else
        {
447
            User_RYLQQ_Time = 0;
hu's avatar
hu committed
448 449
        }

450
        if ((State_Flag.User_BSXY_FLAG == 1) || (State_Flag.User_BSXY_FLAG == 2))
hu's avatar
hu committed
451
        {
452
            if (User_BSXY_Time < 30001)
453
                User_BSXY_Time++;
hu's avatar
hu committed
454 455 456 457 458 459
        }
        else
        {
            User_BSXY_Time = 0;
        }

460
        if ((State_Flag.User_CSQY_FLAG == 1) || (State_Flag.User_CSQY_FLAG == 2))
hu's avatar
hu committed
461
        {
462
            if (User_CSQY_Time < 30001)
hu's avatar
hu committed
463 464 465 466 467 468 469
                User_CSQY_Time++;
        }
        else
        {
            User_CSQY_Time = 0;
        }

470
        if ((State_Flag.User_LHQY_FLAG == 1) || (State_Flag.User_LHQY_FLAG == 2))
hu's avatar
hu committed
471
        {
472
            if (User_LHQY_Time < 30001)
hu's avatar
hu committed
473 474 475 476 477 478 479
                User_LHQY_Time++;
        }
        else
        {
            User_LHQY_Time = 0;
        }

480
        if ((State_Flag.User_KQGZJ_FLAG == 1) || (State_Flag.User_KQGZJ_FLAG == 2))
hu's avatar
hu committed
481
        {
482
            if (User_KQGZJ_Time < 30001)
hu's avatar
hu committed
483 484 485 486 487 488 489
                User_KQGZJ_Time++;
        }
        else
        {
            User_KQGZJ_Time = 0;
        }

490
        if ((State_Flag.User_DLZXY_FLAG == 1) || (State_Flag.User_DLZXY_FLAG == 2))
hu's avatar
hu committed
491
        {
492
            if (User_DLZXY_Time < 30001)
493
                User_DLZXY_Time++;
hu's avatar
hu committed
494 495 496 497 498 499
        }
        else
        {
            User_DLZXY_Time = 0;
        }

500
        if ((State_Flag.User_LT_FLAG == 1) || (State_Flag.User_LT_FLAG == 2))
hu's avatar
hu committed
501
        {
502
            if (User_LT_Time < 30001)
503
                User_LT_Time++;
hu's avatar
hu committed
504 505 506 507 508 509 510
        }
        else
        {
            User_LT_Time = 0;
        }

        /**/
hu's avatar
hu committed
511 512
        if (Get_ID_18FF4100_Sig_Cruise_VariableSLD_Disp() == 1u)
        {
513
            if (CRUISE_1_Time < 1501u)
hu's avatar
hu committed
514
            {
515
                CRUISE_1_Time++;
hu's avatar
hu committed
516 517 518 519
            }
        }
        else
        {
520
            CRUISE_1_Time = 0;
hu's avatar
hu committed
521 522 523
        }
        if (Get_ID_18FF4100_Sig_Cruise_VariableSLD_Disp() == 2u)
        {
524
            if (CRUISE_STUDY_Time < 1501u)
hu's avatar
hu committed
525
            {
526
                CRUISE_STUDY_Time++;
hu's avatar
hu committed
527 528 529 530 531 532 533 534
            }
        }
        else
        {
            CRUISE_STUDY_Time = 0;
        }
        if (Get_ID_18FF4100_Sig_Cruise_VariableSLD_Disp() == 3u)
        {
535
            if (CRUISE_SLD1_Time < 1501u)
hu's avatar
hu committed
536 537 538 539 540 541
            {
                CRUISE_SLD1_Time++;
            }
        }
        else
        {
542
            CRUISE_SLD1_Time = 0;
hu's avatar
hu committed
543
        }
544 545

        Menu_Off_Time = 0u;
hu's avatar
hu committed
546 547 548
    }
    else
    {
549
        OIL_PRESSURE_Time = 0u;
hu's avatar
hu committed
550 551 552 553 554 555
        PowerIgnOnTimeLine = 0ul;
        if (PowerIgnOffTimeLine < 0x7ffffffful)
        {
            PowerIgnOffTimeLine += 2u;
        }

556 557 558 559
        if (Menu_Off_Time <= 300000u )
        {
            Menu_Off_Time ++;
        }
hu's avatar
hu committed
560 561 562 563 564 565 566 567
        Common_Set_IG_Sts(COMMON_POWER_OFF);
        Common_Set_IG_Sts_Valid(COMMON_Valid);

        /*车转真实值OFF为0*/
        Common_Set_Act_V_Speed(0u);
        Common_Set_Act_E_Speed(0u);
        Common_Set_Disp_V_Speed(0u);
        Common_Set_Disp_E_Speed(0u);
hu's avatar
hu committed
568 569

        /*----*/
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
        User_FDJYLQQ_Time = 0x00u;
        User_RYLQQ_Time = 0x00u;
        User_BSXY_Time = 0x00u;
        User_CSQY_Time = 0x00u;
        User_LHQY_Time = 0x00u;
        User_KQGZJ_Time = 0x00u;
        User_DLZXY_Time = 0x00u;
        User_LT_Time = 0x00u;

        CRUISE_1_Time = 0x00u;
        CRUISE_STUDY_Time = 0x00u;
        CRUISE_SLD1_Time = 0x00u;
        CRUISE_SLD2_Time = 0x00u;

        VolWarning_Time = 0x00u;
        LOW_VOLTAGE_TIME1 = 0x00u;
        LOW_VOLTAGE_TIME2 = 0x00u;
        HIGH_VOLTAGE_TIME1 = 0x00u;
        HIGH_VOLTAGE_TIME2 = 0x00u;
        HIGH_VOLTAGE = 0x0u;
        LOW_VOLTAGE = 0x0u;
hu's avatar
hu committed
591 592

        Menu_FacDea_Time = 0u;
hu's avatar
hu committed
593 594 595 596 597
    }
}

void Set_Can18FF5510_FirstRecv_Event(void)
{
hu's avatar
hu committed
598
    CanFirstEvent[ID_CanMsg18FF5510_Msg_Count] = 1;
hu's avatar
hu committed
599 600 601 602
}

void Set_Can18FF2300_FirstRecv_Event(void)
{
hu's avatar
hu committed
603
    CanFirstEvent[ID_CanMsg18FF2300_Msg_Count] = 1;
hu's avatar
hu committed
604 605
}

hu's avatar
hu committed
606 607 608
uint8_t Get_CanFirstRecv_Event(uint8_t ID)
{
    return CanFirstEvent[ID];
hu's avatar
hu committed
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
}

void Common_RollingCounterAdd(void)
{
    SysRollingCounter++;
}

void Common_RollingCounterClear(void)
{
    SysRollingCounter = 0u;
}

uint16_t Common_ReadRollingCounter(void)
{
    return SysRollingCounter;
}

void Common_BlockDelay(uint16_t m_MS)
{
    uint16_t RocBackup;
    uint16_t Counter;
    uint16_t DIMCounter;

    DIMCounter = m_MS * 20u;
    Common_RollingCounterClear();
    RocBackup = Common_ReadRollingCounter();
    do
    {
        Counter = Common_ReadRollingCounter();

        if (Counter >= RocBackup)
        {
            Counter -= RocBackup;
        }
        else
        {
            Counter = 65535u - RocBackup + Counter + 1u;
        }

hu's avatar
hu committed
648 649
    }
    while (Counter < DIMCounter);
hu's avatar
hu committed
650 651 652 653 654 655 656 657 658 659 660 661
}

uint32_t Common_GetIgnOnTime(void)
{
    return PowerIgnOnTimeLine;
}

uint32_t Common_GetIgnOffTime(void)
{
    return PowerIgnOffTimeLine;
}

hu's avatar
hu committed
662 663 664
#pragma diag_suppress = Pm064
int32_t SEGGER_RTT_printf(uint16_t BufferIndex, const char *sFormat, ...);
int32_t SEGGER_RTT_printf(uint16_t BufferIndex, const char *sFormat, ...)
hu's avatar
hu committed
665 666 667
{
    return 0;
}
hu's avatar
hu committed
668

669
uint8_t Common_Get_Cruise_TimeSta(void)
hu's avatar
hu committed
670
{
hu's avatar
hu committed
671
    uint8_t Time_Sta = 0u;
hu's avatar
hu committed
672

673 674 675 676 677 678 679 680 681 682
    if ((CRUISE_1_Time > 0u) && (CRUISE_1_Time < 1500u))
    {
        Time_Sta = 1u;
    }
    else
    {
        Time_Sta = 0u;
    }

    return Time_Sta;
hu's avatar
hu committed
683 684
}

685 686
uint8_t Common_Get_Cruise_SLD_TimeSta(void)
{
hu's avatar
hu committed
687
    uint8_t Time_Sta = 0u;
hu's avatar
hu committed
688

689 690 691 692 693 694 695 696
    if ((CRUISE_SLD1_Time > 0u) && (CRUISE_SLD1_Time < 1500u))
    {
        Time_Sta = 1u;
    }
    else
    {
        Time_Sta = 0u;
    }
hu's avatar
hu committed
697

698 699
    return Time_Sta;
}
hu's avatar
hu committed
700

701
uint8_t Common_Get_VolWarning_Sta(void)
hu's avatar
hu committed
702 703 704 705 706 707 708 709 710 711 712 713
{
    uint8_t DataHiCollantVolWarning = 0u;

    if (VolWarning_Time >= 5000u)
    {
        DataHiCollantVolWarning = 1u;
    }
    else
    {
        DataHiCollantVolWarning = 0u;
    }

714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
    return DataHiCollantVolWarning;
}

uint8_t Common_Get_HIGH_VOLTAGE(void)
{
    return HIGH_VOLTAGE;
}

uint8_t Common_Get_LOW_VOLTAGE(void)
{
    return LOW_VOLTAGE;
}

uint8_t Common_Get_FDJYLQQ_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_FDJYLQQ_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_RYLQQ_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_RYLQQ_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_BSXY_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_BSXY_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_CSQY_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_CSQY_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_LHQY_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_LHQY_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_KQGZJ_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_KQGZJ_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_DLZXY_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_DLZXY_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
}

uint8_t Common_Get_LT_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (User_LT_Time < 30000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return ValueSta;
hu's avatar
hu committed
853 854
}

hu's avatar
hu committed
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870
uint8_t Common_Get_TPMS_TEST_OFF_Time_Sta(void)
{
    uint8_t ValueSta = 0u;

    if (TPMS_TEST_OFF_TIME >= 90000u)
    {
        ValueSta = 1u;
    }
    else
    {
        ValueSta = 0u;
    }

    return 0u;
}

hu's avatar
hu committed
871 872 873 874 875 876 877 878 879
void Common_Set_Menu_FacDea_Time_Sta(uint32_t Value)
{
    Menu_FacDea_Time = Value;
}
uint32_t Common_Get_Menu_FacDea_Time_Sta(void)
{
    return Menu_FacDea_Time;
}

880 881 882 883 884
uint32_t Coom_Get_Menu_Off_Time(void)
{
    return Menu_Off_Time;
}

hu's avatar
hu committed
885 886 887 888 889 890 891 892 893 894
void Common_Set_18EF1718_Msg_Sta(void)
{
    Set_18EF1718_Msg_Sta = COMMON_Valid;
}

DataValid_t Common_Get_18EF1718_Msg_Sta(void)
{
    return Set_18EF1718_Msg_Sta;
}

hu's avatar
hu committed
895 896 897 898 899 900
/*EOL诊断配置数据转换为仪表配置数据*/
void ReadDTCEOLValue_Meter_K_LINE(void)
{
    /*获取所有存储数据*/
    ReadDFlashData(EEPROM_BLOCK_EOL_K_LINE, (uint32_t *)&K_Line_Set.Flag, (sizeof(K_Line_Set) / 4u), K_LINE_EOL_InitVal);
}
hu's avatar
hu committed
901 902 903 904 905 906 907 908 909 910 911 912

void Common_Set_K_Line_Value(void)
{
    uint8_t K_Line_Set_Flag = 0u;
    EEPROM_RW_Result_en_t enResult = EEPROM_RW_FAIL;

    K_Line_Set_Flag = Common_Get_DTCstatusCHGFFK_Flag();

    if (K_Line_Set_Flag == 1u)
    {
        Common_Set_DTCstatusCHGFFK_Flag(0);
        /*存储*/
hu's avatar
hu committed
913 914 915
        //if (EEPROM_Get_Block_Status (EEPROM_BLOCK_EOL_K_LINE) != EEPROM_STAT_ERROR)
        //{
        while (EEPROM_Get_Status() == EEPROM_STAT_BUSY)
hu's avatar
hu committed
916
        {
hu's avatar
hu committed
917
            WDT_Clear();
hu's avatar
hu committed
918
        }
hu's avatar
hu committed
919 920
        enResult = EEPROM_Write_Data(EEPROM_BLOCK_EOL_K_LINE, &K_Line_Set, (sizeof(K_Line_Set) / 4u));
        //}
hu's avatar
hu committed
921
    }
hu's avatar
hu committed
922 923 924 925 926 927
}

void Common_Set_UdsCanIDSta(uint32_t Val)
{
    UdsCanIDSta = Val;
}
hu's avatar
hu committed
928

hu's avatar
hu committed
929 930 931
uint32_t Common_Get_UdsCanIDSta(void)
{
    return UdsCanIDSta;
932 933 934 935 936
}

uint32_t Common_Get_OIL_PRESSURE_Time(void)
{
    return OIL_PRESSURE_Time;
hu's avatar
hu committed
937
}