Telltales_user.c 12.8 KB
Newer Older
时昊's avatar
时昊 committed
1 2


3 4 5 6
#include "Telltales_Lib.h"
#include "Telltales_user.h"
#include "Line_In\Line_In_user.h"
#include "Components.h"
时昊's avatar
时昊 committed
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
static Tellib_uint16_t LED_Turn_Left_Judgement(void);
static void            LED_Turn_Left_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Turn_Right_Judgement(void);
static void            LED_Turn_Right_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_High_Beam_Judgement(void);
static void            LED_High_Beam_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Efi_Fault_Judgement(void);//电喷故障灯
static void            LED_Efi_Fault_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_ABS_Judgement(void);
static void            LED_ABS_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Auto_Start_Stop_Judgement(void);
static void            LED_Auto_Start_Stop_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Oil_Pressure_Alert_Judgement(void);
static void            LED_Oil_Pressure_Alert_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_TCS_Judgement(void);
static void            LED_TCS_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_HEV_Judgement(void);
static void            LED_HEV_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Voltage_Judgement(void);
static void            LED_Voltage_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Fuel_Level_Low_Judgement(void);
static void            LED_Fuel_Level_Low_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Coolant_Temperature_Judgement(void);
static void            LED_Coolant_Temperature_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_WIFI_Judgement(void);
static void            LED_WIFI_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Bluetooth_Judgement(void);
static void            LED_Bluetooth_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_E_Judgement(void);
static void            LED_E_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_S_Judgement(void);
static void            LED_S_Execution(Tellib_uint16_t led_status);
uint8_t u8CanId401Flag = 0;
const LED_Attribute_st LED_Attribute [ LED_Max ] = {
    /*  指示灯索引                  是否自检          外部信号自检           工作电源状态       自检开始时间    自检持续时间       指示灯点亮条件                           指示灯执行函数               */
    
    {em_LED_Turn_Left,            SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Turn_Left_Judgement,            LED_Turn_Left_Execution                },
    {em_LED_Turn_Right,           SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Turn_Right_Judgement,           LED_Turn_Right_Execution               },
    {em_LED_High_Beam,            SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_High_Beam_Judgement,            LED_High_Beam_Execution                },
    {em_LED_Efi_Fault,            SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Efi_Fault_Judgement,            LED_Efi_Fault_Execution                },    
    {em_LED_ABS,                  SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_ABS_Judgement,                  LED_ABS_Execution                      },
    {em_LED_Auto_Start_Stop,      SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Auto_Start_Stop_Judgement,      LED_Auto_Start_Stop_Execution          },
    {em_LED_Oil_Pressure_Alert,   SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Oil_Pressure_Alert_Judgement,   LED_Oil_Pressure_Alert_Execution       },
    {em_LED_TCS,                  SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_TCS_Judgement,                  LED_TCS_Execution                      },
    {em_LED_HEV,                  SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_HEV_Judgement,                  LED_HEV_Execution                      },
    {em_LED_Voltage,              SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Voltage_Judgement,              LED_Voltage_Execution                  },
    {em_LED_Fuel_Level_Low,       SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Fuel_Level_Low_Judgement,       LED_Fuel_Level_Low_Execution           },
    {em_LED_Coolant_Temperature,  SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Coolant_Temperature_Judgement,  LED_Coolant_Temperature_Execution      },
    {em_LED_WIFI,                 SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_WIFI_Judgement,                 LED_WIFI_Execution                     },
    {em_LED_Bluetooth,            SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_Bluetooth_Judgement,            LED_Bluetooth_Execution                },
    {em_LED_E,                    SelfCheck,     NoExterNalCheck,        LED_IGN_ON,             0u,         3000ul,         LED_E_Judgement,                    LED_E_Execution                        },
};
Tellib_uint8_t Tel_Mem [ Tel_MEM_Block_Size * LED_Max + Tel_MEM_Block_Addition ];
 void Telltales_Init(void)
 {
    TelExtPara m_ExtPara;
    m_ExtPara.TotalLength           = LED_Max;
    m_ExtPara.LED_PowerOFF_TimerCbk = Common_GetIgnOffTime;
    m_ExtPara.LED_PowerON_TimerCbk  = Common_GetIgnOnTime;
    m_ExtPara.LED_PowerCbk          = Common_Get_IG_Sts;
    u8CanId401Flag = 0;
    Telltales_KL30_Wakeup_Init(Tel_Mem, LED_Attribute, &m_ExtPara);
 }
void Can_ID_401(uint8_t CopyData [])
{
    u8CanId401Flag = 1;
}
75 76 77 78 79



/*硬线-P10 高电平点亮*/
static Tellib_uint16_t LED_Turn_Left_Judgement(void)
80 81 82 83 84 85 86 87 88 89 90 91 92 93
{
    Tellib_uint16_t LED_STATE = 0u;
    if (Line_In_Get_Status(LINE_IN_Turn_Left))
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_Turn_Left_Execution(Tellib_uint16_t led_status)
{
94
   
95
}
96

97 98

/*硬线-P9 高电平点亮*/
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
static Tellib_uint16_t LED_Turn_Right_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
    if (Line_In_Get_Status(LINE_IN_Turn_Right))
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_Turn_Right_Execution(Tellib_uint16_t led_status)
{
114
   
115
}
116 117 118


/*硬线-P18 高电平点亮*/
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
static Tellib_uint16_t LED_High_Beam_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
    if (Line_In_Get_Status(LINE_IN_High_Beam))
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_High_Beam_Execution(Tellib_uint16_t led_status)
{
134
   
135
}
136 137

/*硬线-P15 低电平点亮*/
138 139 140
static Tellib_uint16_t LED_Efi_Fault_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
141
    if (Line_In_Get_Status(LINE_IN_Efi_Fault) == 0u)
142
    {
143
        LED_STATE = 1u;
144 145 146
    }
    else
    {
147
        LED_STATE = 0u;
148 149 150 151 152
    }
    return LED_STATE;
}
static void LED_Efi_Fault_Execution(Tellib_uint16_t led_status)
{
153
   
154
}
155 156


157 158 159 160
/*硬线-P7 悬空/高点亮 接地灭*/
static Tellib_uint16_t LED_ABS_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
161
    if (Line_In_Get_Status(LINE_IN_ABS) == 0)
162
    {
163
        LED_STATE = 0;
164 165 166
    }
    else
    {
167
        LED_STATE = 1;
168 169 170 171 172
    }
    return LED_STATE;
}
static void LED_ABS_Execution(Tellib_uint16_t led_status)
{
173

174
}
175

176 177 178 179
/*硬线-P12 低电平*/
static Tellib_uint16_t LED_Auto_Start_Stop_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
180
    if (Line_In_Get_Status(LINE_IN_Auto_Start_Stop) == 0)
181 182 183 184 185 186 187 188 189 190 191
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_Auto_Start_Stop_Execution(Tellib_uint16_t led_status)
{
192
   
193
}
194 195 196


/*硬线-P21 低电平点亮*/
197 198 199
static Tellib_uint16_t LED_Oil_Pressure_Alert_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
200
    if (Line_In_Get_Status(LINE_IN_Oil_Pressure_Alert) == 0)
201 202 203 204 205 206 207 208 209 210 211
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_Oil_Pressure_Alert_Execution(Tellib_uint16_t led_status)
{
212
  
213
}
214

215 216 217 218
/*
*@name:TCS指示灯
*@return: 0-都不亮 1-TCS亮 2-TCS/亮 3-TCS闪烁 
*/
219 220
static Tellib_uint16_t LED_TCS_Judgement(void)
{
221 222 223 224 225 226 227
    Tellib_uint16_t LED_STATE = 0u;
    if (CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CH0_37B_Msg_Count) == CAN_SIG_LOST)
    {
       LED_STATE = 0u;
    }
    else
    {
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
        if(Get_CAN_CH0_ID_37B_Sig_TCS_Work_Mode == 0x0)
        {
            if(Get_CAN_CH0_ID_37B_Sig_TCS_Warning_Lamp() == 0x1)
            {
                LED_STATE = 1u;/*TCS灯亮*/
            }
            else
            {
                LED_STATE = 0u;/*都不亮*/
            }
        }
        else
        {
            if(Get_CAN_CH0_ID_37B_Sig_TCS_Warning_Lamp() == 0x1)
            {
                LED_STATE = 2u;/*TCS/亮*/
            }
            else
            {
                ;
            } 
        } 
250 251
    }
    return LED_STATE;
252 253 254
}
static void LED_TCS_Execution(Tellib_uint16_t led_status)
{
255
   
256
}
257 258


259 260 261
/*
*信号来源:ISG_111
*/
262 263
static Tellib_uint16_t LED_HEV_Judgement(void)
{
264 265 266 267 268 269 270
    Tellib_uint16_t LED_STATE = 0u;
    if (CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CH0_111_Msg_Count) == CAN_SIG_LOST)
    {
       LED_STATE = 0u;
    }
    else
    {
271 272 273 274 275 276 277 278 279 280 281 282
        if((Get_CAN_CH0_ID_111_Sig_ISG_Ready() == 0x01UL)||((Get_CAN_CH0_ID_111_Sig_ISG_Power() == 1u)&&(Get_CAN_CH0_ID_111_Sig_ISG_Power_Enable() == 0u)))
        {
            LED_STATE = 1u;
        }
        else if((Get_CAN_CH0_ID_111_Sig_ISG_Ready() == 0UL)||(Get_CAN_CH0_ID_111_Sig_ISG_Power() == 0u)||(Get_CAN_CH0_ID_111_Sig_ISG_Power_Enable() == 0u))
        {
            LED_STATE = 0u;
        }
        else
        {
            LED_STATE = 0u;
        }
283 284
    }
    return LED_STATE;
285 286 287
}
static void LED_HEV_Execution(Tellib_uint16_t led_status)
{
288
   ;
289
}
290 291


292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
/*硬线-P19 电压值*/
static Tellib_uint16_t LED_Voltage_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
    if (Line_In_Get_Status(LINE_IN_Voltage))
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_Voltage_Execution(Tellib_uint16_t led_status)
{
308
  ;
309
}
310 311


312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
/*硬线P14-阻值*/
static Tellib_uint16_t LED_Fuel_Level_Low_Judgement(void)
{
    Tellib_uint16_t LED_STATE = 0u;
    if (Line_In_Get_Status(LINE_IN_Fuel_Level_Low))
    {
        LED_STATE = 1;
    }
    else
    {
        LED_STATE = 0;
    }
    return LED_STATE;
}
static void LED_Fuel_Level_Low_Execution(Tellib_uint16_t led_status)
{
328 329 330 331
   
}


332 333 334
/*信号来源:ECU_101 +硬线-P11 阻值 CAN>硬线*/
static Tellib_uint16_t LED_Coolant_Temperature_Judgement(void)
{
335 336 337
    Tellib_uint16_t LED_STATE = 0u;
    if (CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CH0_101_Msg_Count) == CAN_SIG_LOST)
    {
338 339 340 341 342 343 344 345 346
        LED_STATE = 0u;
        if(Line_In_Get_Status(LINE_IN_Coolant_Temperature))
        {
            LED_STATE = 1u;
        }
        else
        {
            LED_STATE = 0u;
        }
347 348 349 350 351 352 353 354 355
    }
    else
    {
        if(Get_CAN_CH0_ID_101_Sig_ECU_Engine_Temperature_State() == 0x01UL)
        {
          LED_STATE = 1u;
        }
        else
        {
356
            LED_STATE = 0u;
357 358 359
        }
    }
    return LED_STATE;
360 361 362
}
static void LED_Coolant_Temperature_Execution(Tellib_uint16_t led_status)
{
363
  
364
}
365 366


367
/*wifi*/
368 369
static Tellib_uint16_t LED_WIFI_Judgement(void)
{
370
    Tellib_uint16_t LED_STATE = 0u;/*设置为常灭*/
371 372 373 374
    return LED_STATE;
}
static void LED_WIFI_Execution(Tellib_uint16_t led_status)
{
375
    ;
376
}
377

378
/*bluetooth*/
379 380
static Tellib_uint16_t LED_Bluetooth_Judgement(void)
{
381 382
    Tellib_uint16_t LED_STATE = 0u;
    return LED_STATE;
383 384 385
}
static void LED_Bluetooth_Execution(Tellib_uint16_t led_status)
{
386
   ;
387
}
388

389 390 391 392 393 394

/*
* E S指示灯
*信号来源:0x111
* 0-都不亮  1-E亮 2-S亮
*/
395 396
static Tellib_uint16_t LED_E_Judgement(void)
{
397 398 399 400 401 402 403 404 405
    Tellib_uint16_t LED_STATE = 0u;
    if (CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CH0_111_Msg_Count) == CAN_SIG_LOST)
    {
       LED_STATE = 0u;
    }
    else
    {
        if(Get_CAN_CH0_ID_111_Sig_ISG_Power() == 0x01UL)
        {
406
            if(Get_CAN_CH0_ID_111_Sig_ISG_Power_Enable() == 1u)
407 408 409
            {
                LED_STATE = 1u;
            }
410 411 412 413
            else if(Get_CAN_CH0_ID_111_Sig_ISG_Power_Enable() == 2u)
            {
                LED_STATE = 2u;
            }
414 415 416 417 418 419 420 421 422 423 424
            else
            {
                LED_STATE = 0u;
            }
        }
        else
        {
            LED_STATE = 0u;
        }
    }
    return LED_STATE;
425 426 427
}
static void LED_E_Execution(Tellib_uint16_t led_status)
{
428
   ;
429
}
430