Line_In.c 16.8 KB
Newer Older
崔立宝's avatar
崔立宝 committed
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 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 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 648 649 650 651 652 653 654 655 656 657 658 659 660
/******************************************************************************
文 件 名:Line_In.c
功能描述:线路输入信号处理函数库文件
作    者:张暄
版    本:V1.1
日    期:2016.11.4
******************************************************************************/

#include "Line_In.h"

uint8_t LineInEnable;
volatile uint8_t    KeyLeftinStatus;
volatile uint8_t    KeyRightinStatus;
volatile uint8_t    KeyEnterinStatus;

#if CODEMODE==Normal
uint16_t Sample_Volt[] = {2500,3333,3750};   	   //对应K1,K2,K3,AD口所采集到的电压值,
#else
uint16_t Sample_Volt[] = {2250,3100,3500};   	   //对应K1,K2,K3,AD口所采集到的电压值, 4.48V版本
#endif
#ifdef    KEY_LEFT_SIGNAL
volatile uint8_t    KeyLeftStatus;
LineInDebounceStruct KeyLeftDeb;
#endif

#ifdef    KEY_RIGHT_SIGNAL
volatile uint8_t    KeyRightStatus;
LineInDebounceStruct KeyRightDeb;
#endif

#ifdef    KEY_ENTER_SIGNAL
volatile uint8_t    KeyEnterStatus;
LineInDebounceStruct KeyEnterDeb;
#endif


#ifdef LINE_IN_RIGHT_SIGNAL                     //右转向
volatile uint8_t     LineInRIGHTStatus;
LineInDebounceStruct LineInRIGHTDeb;
#endif

#ifdef LINE_IN_LEFT_SIGNAL                      //左转向
volatile uint8_t     LineInLEFTStatus;
LineInDebounceStruct LineInLEFTDeb;
#endif

#ifdef LINE_IN_SEATBELT_SIGNAL                  //安全带未系
volatile uint8_t     LineInSEATBELTStatus;
LineInDebounceStruct LineInSEATBELTDeb;
#endif

#ifdef LINE_IN_POSITION_SIGNAL                   //位置灯   
volatile uint8_t     LineInPOSITIONStatus;
LineInDebounceStruct LineInPOSITIONDeb;
#endif

#ifdef LINE_IN_BREAK_FLUID_SIGNAL                   //制动液位低   
volatile uint8_t     LineInBREAKFLUIDStatus;
LineInDebounceStruct LineInBREAKFLUIDDeb;
#endif

#ifdef LINE_IN_BREAK_SIGNAL                   //驻车制动   RF_HOOVES
volatile uint8_t     LineInBREAKStatus;
LineInDebounceStruct LineInBREAKDeb;
#endif

#ifdef LINE_IN_RF_HOOVES_SIGNAL                   //前桥蹄片磨损
volatile uint8_t     LineInRFHOOVESStatus;
LineInDebounceStruct LineInRFHOOVESDeb;
#endif

#ifdef LINE_IN_RR_HOOVES_SIGNAL                   //后桥蹄片磨损      
volatile uint8_t     LineInRRHOOVESStatus;
LineInDebounceStruct LineInRRHOOVESDeb;
#endif

#ifdef LINE_IN_CAB_LOCK_SIGNAL                   //驾驶室未锁止
volatile uint8_t     LineInCABLOCKStatus;
LineInDebounceStruct LineInCABLOCKDeb;
#endif

#ifdef LINE_IN_PTO_SIGNAL                   // PTO 
volatile uint8_t     LineInPTOStatus;
LineInDebounceStruct LineInPTODeb;
#endif

#ifdef LINE_IN_FILT_BLOCK_SIGNAL                   //  FILT_BLOCK  
volatile uint8_t     LineInFILTBLOCKStatus;
LineInDebounceStruct LineInFILTBLOCKDeb;
#endif

#ifdef LINE_IN_CHARGE_SIGNAL                   // CHARGE   
volatile uint8_t     LineInCHARGEStatus;
LineInDebounceStruct LineInCHARGEDeb;
#endif

#ifdef LINE_IN_GEAR_SIGNAL                   //    GEAR
volatile uint8_t     LineInGEARStatus;
LineInDebounceStruct LineInGEARDeb;
#endif
/******************************************************************************
函数名:Line_In_Enable
功  能:线路输入功能使能
参  数:Enable 0 -  禁止 1 - 使能
返回值:无
******************************************************************************/
void Line_In_Enable(uint8_t Enable)
{
  if (Enable)
    Enable = 1;

  if (LineInEnable != Enable)
  {
    Line_In_Status_Reset();
    LineInEnable = Enable;
  }
}

/******************************************************************************
函数名:Line_In_Debounce
功  能:线路输入消抖              
参  数:Input        - 输入信号
        DebCycleRise - 上升沿消抖周期数
        DebCycleFall - 下降沿消抖周期数
        pDebCtrl     - 消抖控制结构
返回值:当前线路输入值
******************************************************************************/
#pragma INLINE
uint8_t Line_In_Debounce (uint8_t Input, uint8_t DebCycleRise, uint16_t DebCycleFall, LineInDebounceStruct *pDebCtrl)
{
  if (Input == pDebCtrl -> Last)
  {
    pDebCtrl -> Timer++;
    
    if (Input)
    {
      if (pDebCtrl -> Timer >= DebCycleRise)
      {
        pDebCtrl -> Timer   = 0;
        pDebCtrl -> Current = Input;
      }
    }
    else
    {
      if (pDebCtrl -> Timer >= DebCycleFall)
      {
        pDebCtrl -> Timer   = 0;
        pDebCtrl -> Current = Input;
      }
    }
  }
  else
  {
    pDebCtrl -> Timer = 0;
    pDebCtrl -> Last  = Input;
  }

  return pDebCtrl -> Current;  
}
/******************************************************************************
函数名:Line_In_Status_Reset
功  能:复位各个线路输入状态为默认状态
参  数:无
返回值:无
******************************************************************************/
void Line_In_Status_Reset(void)
{
#ifdef KEY_LEFT_SIGNAL            //
  KEY_LEFT_SIGNAL = KEY_LEFT_DEFAULT;
  KeyLeftDeb.Timer = 0;
#endif

#ifdef KEY_RIGHT_SIGNAL            //
  KEY_RIGHT_SIGNAL = KEY_RIGHT_DEFAULT;
  KeyLeftDeb.Timer = 0;
#endif

#ifdef KEY_ENTER_SIGNAL            //
  KEY_ENTER_SIGNAL = KEY_ENTER_DEFAULT;
  KeyEnterDeb.Timer = 0;
#endif


#ifdef LINE_IN_RIGHT_SIGNAL                  //右转向
  LINE_IN_RIGHT_SIGNAL = LINE_IN_RIGHT_DEFAULT;
  LineInRIGHTDeb .Timer = 0;
#endif

#ifdef LINE_IN_LEFT_SIGNAL                   //左转向
  LINE_IN_LEFT_SIGNAL = LINE_IN_LEFT_DEFAULT;
  LineInLEFTDeb .Timer = 0;
#endif

#ifdef LINE_IN_SEATBELT_SIGNAL               //主安全带
  LINE_IN_SEATBELT_SIGNAL = LINE_IN_SEATBELT_DEFAULT;
  LineInSEATBELTDeb .Timer = 0;
#endif

#ifdef LINE_IN_POSITION_SIGNAL               //位置灯   
  LINE_IN_POSITION_SIGNAL = LINE_IN_POSITION_DEFAULT;
  LineInPOSITIONDeb .Timer = 0;
#endif

#ifdef LINE_IN_BREAK_FLUID_SIGNAL               //制动液位低
  LINE_IN_BREAK_FLUID_SIGNAL = LINE_IN_BREAK_FLUID_DEFAULT;
  LineInBREAKFLUIDDeb .Timer = 0;
#endif

#ifdef LINE_IN_BREAK_SIGNAL               //驻车制动
  LINE_IN_BREAK_SIGNAL = LINE_IN_BREAK_DEFAULT;
  LineInBREAKDeb .Timer = 0;
#endif

#ifdef LINE_IN_RF_HOOVES_SIGNAL               //前桥蹄片磨损
  LINE_IN_RF_HOOVES_SIGNAL = LINE_IN_RF_HOOVES_DEFAULT;
  LineInRFHOOVESDeb .Timer = 0;
#endif

#ifdef LINE_IN_RR_HOOVES_SIGNAL               //后桥蹄片磨损    
  LINE_IN_RR_HOOVES_SIGNAL = LINE_IN_RR_HOOVES_DEFAULT;
  LineInRRHOOVESDeb .Timer = 0;
#endif

#ifdef LINE_IN_CAB_LOCK_SIGNAL               //     
  LINE_IN_CAB_LOCK_SIGNAL = LINE_IN_CAB_LOCK_DEFAULT;
  LineInCABLOCKDeb .Timer = 0;
#endif

#ifdef LINE_IN_PTO_SIGNAL               //      PTO  
  LINE_IN_PTO_SIGNAL = LINE_IN_PTO_DEFAULT;
  LineInPTODeb .Timer = 0;
#endif

#ifdef LINE_IN_FILT_BLOCK_SIGNAL               //FILT_BLOCK  
  LINE_IN_FILT_BLOCK_SIGNAL = LINE_IN_FILT_BLOCK_DEFAULT;
  LineInFILTBLOCKDeb .Timer = 0;
#endif

#ifdef LINE_IN_CHARGE_SIGNAL               //  CHARGE
  LINE_IN_CHARGE_SIGNAL = LINE_IN_CHARGE_DEFAULT;
  LineInCHARGEDeb .Timer = 0;
#endif

#ifdef LINE_IN_GEAR_SIGNAL               //  GEAR
  LINE_IN_GEAR_SIGNAL = LINE_IN_GEAR_DEFAULT;
  LineInGEARDeb .Timer = 0;
#endif
/////////////////////////////////////////////////////////////////////////
}

/******************************************************************************
函数名:Line_In_Debounce_Service
功  能:线路输入消抖服务,用于接收各个线路输入信号并进行消抖处理
参  数:无
返回值:无
******************************************************************************
注  意:该服务函数必须每20ms被调用一次
******************************************************************************/
void Line_In_Debounce_Service(void)
{
  uint8_t LineStatus;
  uint16_t KeyVolt;

      KeyVolt = ANALOG_KEY_SENSOR_Vol; 
    if( (KeyVolt >= (Sample_Volt[0]-300)) && KeyVolt <= (Sample_Volt[0]+300)) //
	   KeyLeftinStatus=1;
		else
		 KeyLeftinStatus =0;
		
		 if( (KeyVolt >= (Sample_Volt[1]-300)) && KeyVolt <= (Sample_Volt[1]+150)) //
	   KeyRightinStatus=1;
		else
		 KeyRightinStatus =0;
		
		if( (KeyVolt >= (Sample_Volt[2]-150)) && KeyVolt <= (Sample_Volt[2]+300)) //
	   KeyEnterinStatus=1;
		else
		 KeyEnterinStatus =0;
		
      #ifdef  KEY_LEFT_SIGNAL          //
    #ifdef  KEY_LEFT_IN
      KEY_LEFT_SIGNAL = Line_In_Debounce(KEY_LEFT_IN, 
                                            KEY_DEB_RISE / LINE_IN_DEBOUNCE_CYCLE,
                                            KEY_DEB_FALL / LINE_IN_DEBOUNCE_CYCLE,
                                            &KeyLeftDeb);
    #else
      KEY_LEFT_SIGNAL = Line_In_Debounce(!KEY_LEFT_INn, 
                                            KEY_DEB_RISE / LINE_IN_DEBOUNCE_CYCLE,
                                            KEY_DEB_FALL / LINE_IN_DEBOUNCE_CYCLE,
                                            &KeyLeftDeb);
    #endif
  #endif 

     #ifdef  KEY_RIGHT_SIGNAL          //
    #ifdef  KEY_RIGHT_IN
      KEY_RIGHT_SIGNAL = Line_In_Debounce(KEY_RIGHT_IN, 
                                            KEY_DEB_RISE / LINE_IN_DEBOUNCE_CYCLE,
                                            KEY_DEB_FALL / LINE_IN_DEBOUNCE_CYCLE,
                                            &KeyRightDeb);
    #else
      KEY_RIGHT_SIGNAL = Line_In_Debounce(!KEY_RIGHT_INn, 
                                            KEY_DEB_RISE / LINE_IN_DEBOUNCE_CYCLE,
                                            KEY_DEB_FALL / LINE_IN_DEBOUNCE_CYCLE,
                                            &KeyRightDeb);
    #endif
  #endif

     #ifdef  KEY_ENTER_SIGNAL          //
    #ifdef  KEY_ENTER_IN
      KEY_ENTER_SIGNAL = Line_In_Debounce(KEY_ENTER_IN, 
                                            KEY_DEB_RISE / LINE_IN_DEBOUNCE_CYCLE,
                                            KEY_DEB_FALL / LINE_IN_DEBOUNCE_CYCLE,
                                            &KeyEnterDeb);
    #else
      KEY_ENTER_SIGNAL = Line_In_Debounce(!KEY_ENTER_INn, 
                                            KEY_DEB_RISE / LINE_IN_DEBOUNCE_CYCLE,
                                            KEY_DEB_FALL / LINE_IN_DEBOUNCE_CYCLE,
                                            &KeyEnterDeb);
    #endif
  #endif
  if (LineInEnable == 0)
    return;



  // LED_RIGHT_G
  #ifdef  LINE_IN_RIGHT_SIGNAL
  #ifdef  LINE_IN_RIGHT
    LineStatus = LINE_IN_RIGHT;
  #else
    LineStatus = !LINE_IN_RIGHTn;
  #endif

    if (LineStatus == LineInRIGHTDeb.Last)
    {
      LineInRIGHTDeb.Timer++;
     if(LineStatus)
     {
      if (LineInRIGHTDeb.Timer >= 4)    //////////////////////////80ms
      {
        LineInRIGHTDeb.Timer = 0;
        LINE_IN_RIGHT_SIGNAL = LineStatus;
      }
     }
     else
     {
       if (LineInRIGHTDeb.Timer >= 4)    //////////////////////////80ms
      {
        LineInRIGHTDeb.Timer = 0;
        LINE_IN_RIGHT_SIGNAL = LineStatus;
      }
     }

    }
    else
    {
      LineInRIGHTDeb.Timer = 0;
      LineInRIGHTDeb.Last  = LineStatus;
    }
  #endif

  // LED_LEFT_G
  #ifdef  LINE_IN_LEFT_SIGNAL
  #ifdef  LINE_IN_LEFT
    LineStatus = LINE_IN_LEFT;
  #else
    LineStatus = !LINE_IN_LEFTn;
  #endif

    if (LineStatus == LineInLEFTDeb.Last)
    {
      LineInLEFTDeb.Timer++;
      if(LineStatus)
      {
       if (LineInLEFTDeb.Timer >= 4)     //////////////////////////////80ms
       {
        LineInLEFTDeb.Timer = 0;
        LINE_IN_LEFT_SIGNAL = LineStatus;
       } 
      }
      else
      {
       if(LineInLEFTDeb.Timer >= 4)     //////////////////////////////80ms
       {
        LineInLEFTDeb.Timer = 0;
        LINE_IN_LEFT_SIGNAL = LineStatus;
       }  
      }
    }
    else
    {
      LineInLEFTDeb.Timer = 0;
      LineInLEFTDeb.Last  = LineStatus;
    }
  #endif

  // LED_SEATBELT_R      //安全带
  #ifdef  LINE_IN_SEATBELT_SIGNAL
  #ifdef  LINE_IN_SEATBELT
    LineStatus = LINE_IN_SEATBELT;
  #else
    LineStatus = !LINE_IN_SEATBELTn;
  #endif

    if (LineStatus == LineInSEATBELTDeb.Last)
    {
      LineInSEATBELTDeb.Timer++;
      if (LineInSEATBELTDeb.Timer >= LINE_TIME_CNT)
      {
        LineInSEATBELTDeb.Timer = 0;
        LINE_IN_SEATBELT_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInSEATBELTDeb.Timer = 0;
      LineInSEATBELTDeb.Last  = LineStatus;
    }
  #endif

  // LED_POSITION_G              
  #ifdef  LINE_IN_POSITION_SIGNAL
  #ifdef  LINE_IN_POSITION
    LineStatus = LINE_IN_POSITION;
  #else
    LineStatus = !LINE_IN_POSITIONn;
  #endif

    if (LineStatus == LineInPOSITIONDeb.Last)
    {
      LineInPOSITIONDeb.Timer++;
      if (LineInPOSITIONDeb.Timer >= LINE_TIME_CNT)
      {
        LineInPOSITIONDeb.Timer = 0;
        LINE_IN_POSITION_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInPOSITIONDeb.Timer = 0;
      LineInPOSITIONDeb.Last  = LineStatus;
    }
  #endif
  
    //制动液位低
  #ifdef  LINE_IN_BREAK_FLUID_SIGNAL
  #ifdef  LINE_IN_BREAK_FLUID
    LineStatus = LINE_IN_BREAK_FLUID;
  #else
    LineStatus = !LINE_IN_BREAK_FLUIDn;
  #endif

    if (LineStatus == LineInBREAKFLUIDDeb.Last)
    {
      LineInBREAKFLUIDDeb.Timer++;
      if (LineInBREAKFLUIDDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInBREAKFLUIDDeb.Timer = 0;
        LINE_IN_BREAK_FLUID_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInBREAKFLUIDDeb.Timer = 0;
      LineInBREAKFLUIDDeb.Last  = LineStatus;
    }
  #endif
  
      //驻车制动
  #ifdef  LINE_IN_BREAK_SIGNAL
  #ifdef  LINE_IN_BREAK
    LineStatus = LINE_IN_BREAK;
  #else
    LineStatus = !LINE_IN_BREAKn;
  #endif

    if (LineStatus == LineInBREAKDeb.Last)
    {
      LineInBREAKDeb.Timer++;
      if (LineInBREAKDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInBREAKDeb.Timer = 0;
        LINE_IN_BREAK_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInBREAKDeb.Timer = 0;
      LineInBREAKDeb.Last  = LineStatus;
    }
  #endif
  
        //前桥蹄片磨损
  #ifdef  LINE_IN_RF_HOOVES_SIGNAL
  #ifdef  LINE_IN_RF_HOOVES
    LineStatus = LINE_IN_RF_HOOVES;
  #else
    LineStatus = !LINE_IN_RF_HOOVESn;
  #endif

    if (LineStatus == LineInRFHOOVESDeb.Last)
    {
      LineInRFHOOVESDeb.Timer++;
      if (LineInRFHOOVESDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInRFHOOVESDeb.Timer = 0;
        LINE_IN_RF_HOOVES_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInRFHOOVESDeb.Timer = 0;
      LineInRFHOOVESDeb.Last  = LineStatus;
    }
  #endif
  
        //后桥蹄片磨损      
  #ifdef  LINE_IN_RR_HOOVES_SIGNAL
  #ifdef  LINE_IN_RR_HOOVES
    LineStatus = LINE_IN_RR_HOOVES;
  #else
    LineStatus = !LINE_IN_RR_HOOVESn;
  #endif

    if (LineStatus == LineInRRHOOVESDeb.Last)
    {
      LineInRRHOOVESDeb.Timer++;
      if (LineInRRHOOVESDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInRRHOOVESDeb.Timer = 0;
        LINE_IN_RR_HOOVES_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInRRHOOVESDeb.Timer = 0;
      LineInRRHOOVESDeb.Last  = LineStatus;
    }
  #endif
  
          //CAB_LOCK   PTO
  #ifdef  LINE_IN_CAB_LOCK_SIGNAL
  #ifdef  LINE_IN_CAB_LOCK
    LineStatus = LINE_IN_CAB_LOCK;
  #else
    LineStatus = !LINE_IN_CAB_LOCKn;
  #endif

    if (LineStatus == LineInCABLOCKDeb.Last)
    {
      LineInCABLOCKDeb.Timer++;
      if (LineInCABLOCKDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInCABLOCKDeb.Timer = 0;
        LINE_IN_CAB_LOCK_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInCABLOCKDeb.Timer = 0;
      LineInCABLOCKDeb.Last  = LineStatus;
    }
  #endif
  
            //  PTO   
  #ifdef  LINE_IN_PTO_SIGNAL
  #ifdef  LINE_IN_PTO
    LineStatus = LINE_IN_PTO;
  #else
    LineStatus = !LINE_IN_PTOn;
  #endif

    if (LineStatus == LineInPTODeb.Last)
    {
      LineInPTODeb.Timer++;
      if (LineInPTODeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInPTODeb.Timer = 0;
        LINE_IN_PTO_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInPTODeb.Timer = 0;
      LineInPTODeb.Last  = LineStatus;
    }
  #endif
  
              //FILT_BLOCK        
  #ifdef  LINE_IN_FILT_BLOCK_SIGNAL
  #ifdef  LINE_IN_FILT_BLOCK
    LineStatus = LINE_IN_FILT_BLOCK;
  #else
    LineStatus = !LINE_IN_FILT_BLOCKn;
  #endif

    if (LineStatus == LineInFILTBLOCKDeb.Last)
    {
      LineInFILTBLOCKDeb.Timer++;
      if (LineInFILTBLOCKDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInFILTBLOCKDeb.Timer = 0;
        LINE_IN_FILT_BLOCK_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInFILTBLOCKDeb.Timer = 0;
      LineInFILTBLOCKDeb.Last  = LineStatus;
    }
  #endif
  
                //CHARGE       
  #ifdef  LINE_IN_CHARGE_SIGNAL
  #ifdef  LINE_IN_CHARGE
    LineStatus = LINE_IN_CHARGE;
  #else
    LineStatus = !LINE_IN_CHARGEn;
  #endif

    if (LineStatus == LineInCHARGEDeb.Last)
    {
      LineInCHARGEDeb.Timer++;
      if (LineInCHARGEDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInCHARGEDeb.Timer = 0;
        LINE_IN_CHARGE_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInCHARGEDeb.Timer = 0;
      LineInCHARGEDeb.Last  = LineStatus;
    }
  #endif
  
                  //GEAR       
  #ifdef  LINE_IN_GEAR_SIGNAL
  #ifdef  LINE_IN_GEAR
    LineStatus = LINE_IN_GEAR;
  #else
    LineStatus = !LINE_IN_GEARn;
  #endif

    if (LineStatus == LineInGEARDeb.Last)
    {
      LineInGEARDeb.Timer++;
      if (LineInGEARDeb.Timer >= LINE_IN_DEBOUNCE_L_CNT)
      {
        LineInGEARDeb.Timer = 0;
        LINE_IN_GEAR_SIGNAL = LineStatus;
      }
    }
    else
    {
      LineInGEARDeb.Timer = 0;
      LineInGEARDeb.Last  = LineStatus;
    }
  #endif
}