Line_In.h 8.78 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
/******************************************************************************
文 件 名:Line_In.c
功能描述:线路输入信号处理函数头文件
作    者:张暄
版    本:V1.1
日    期:2016.11.4
******************************************************************************/
/******************************************************************************

                           线路输入IO管脚名称定义

-------------------------------------------------------------------------------
注意:在GPIO.h中定义线路输入对应的IO管脚时,必须使用下表中列出的名称
-------------------------------------------------------------------------------
    线路输入IO管脚名称     | 有效电平  |      功能
-------------------------------------------------------------------------------
LINE_IN_KEY0               |  高电平   | 按键0输入
LINE_IN_KEY0n              |  低电平   |
LINE_IN_KEY1               |  高电平   | 按键1输入
LINE_IN_KEY1n              |  低电平   |
LINE_IN_KEY2               |  高电平   | 按键2输入
LINE_IN_KEY2n              |  低电平   |
-------------------------------------------------------------------------------
******************************************************************************/

/******************************************************************************

                                信号名称列表

------------------------------------------------------------------------------
说明:1.信号名称的命名规则为 <线路输入IO管脚名称>_SIGNAL .移植程序时应严格按上
        表中的管脚名称命名对应线路输入的IO端口, 则该线路输入所对应的信号自动变
        为可用
      2.不同车型有不同的线路输入信号,因此并非下面列表中所有信号都是可用的.应将
        可用的信号名称标注于下表中,便于查找
      3.当Line_In_Debounce_Service服务被以20ms周期调用后, 以下列表中各可用信号
        会状态跟随外部线路输入变化而变化,这些信号的作用域是整个工程,可在工程中
        的任意文件中自由调用
      4.这些信号表示线路输入的逻辑状态,即 无效(0值) 和 有效(非0值) ,并非线路的
        电平高低
------------------------------------------------------------------------------
  当前可用  |      信号名称                  |       功能
------------------------------------------------------------------------------
            | LINE_IN_EPB_SIGNAL             | 电子驻车状态
            | LINE_IN_ESPOFF_SIGNAL          | ESP关闭状态
      *     | LINE_IN_KEY0_SIGNAL            | 按键0状态(Timer按键)
      *     | LINE_IN_KEY1_SIGNAL            | 按键1状态(Reset按键)
      *     | LINE_IN_KEY2_SIGNAL            | 按键2状态(Trip 按键)
-------------------------------------------------------------------------------
******************************************************************************/
#ifndef _LINE_IN_H_
#define _LINE_IN_H_

#include "GPIO.h"
#include "Analog_Signal_Conversion.h"
/******************************************************************************
按键消抖时间定义
******************************************************************************/
#define   LINE_IN_DEBOUNCE_TIME             500
#define   LINE_TIME                         200
#define   LINE_IN_DEBOUNCE_L_TIME           200     //2021.01.29由80改为200
/******************************************************************************
结构体定义
******************************************************************************/
typedef struct
{
  uint8_t   Current;
  uint8_t   Last;
  uint16_t  Timer;
}LineInDebounceStruct;

/******************************************************************************
信号预处理
******************************************************************************/
#define   LINE_IN_DEBOUNCE_L_CNT           (LINE_IN_DEBOUNCE_L_TIME / 20)
#define   LINE_IN_DEBOUNCE_CNT             (LINE_IN_DEBOUNCE_TIME / 20)
#define   LINE_TIME_CNT                    (LINE_TIME / 20)

/******************************************************************************
按键消抖周期
******************************************************************************/
#define   LINE_IN_DEBOUNCE_CYCLE            20    //消抖服务函数调用周期,单位ms

 /***Key***/
 
extern volatile uint8_t    KeyLeftinStatus; 
#define    KEY_LEFT_IN               KeyLeftinStatus
#if  ((defined  KEY_LEFT_IN) || (defined KEY_LEFT_INn))
                                                                    
extern volatile uint8_t    KeyLeftStatus;

#define    KEY_LEFT_SIGNAL            KeyLeftStatus
#define    KEY_LEFT_DEFAULT           0
#define    KEY_DEB_RISE 80   //上升沿消抖时间(ms)
#define    KEY_DEB_FALL 80    //下降沿消抖时间(ms)
#endif

extern volatile uint8_t    KeyRightinStatus; 
#define    KEY_RIGHT_IN               KeyRightinStatus
#if  ((defined  KEY_RIGHT_IN) || (defined KEY_RIGHT_INn))
                                                                    
extern volatile uint8_t    KeyRightStatus;

#define    KEY_RIGHT_SIGNAL            KeyRightStatus
#define    KEY_RIGHT_DEFAULT           0
#endif

extern volatile uint8_t    KeyEnterinStatus; 
#define    KEY_ENTER_IN               KeyEnterinStatus
#if  ((defined  KEY_ENTER_IN) || (defined KEY_ENTER_INn))
                                                                    
extern volatile uint8_t    KeyEnterStatus;

#define    KEY_ENTER_SIGNAL            KeyEnterStatus
#define    KEY_ENTER_DEFAULT           0
#endif



/***LED_SEATBELT_R ***/    //主安全带
#if  ((defined  LINE_IN_SEATBELT) || (defined LINE_IN_SEATBELTn))  		   

extern volatile uint8_t    LineInSEATBELTStatus;

#define    LINE_IN_SEATBELT_SIGNAL            LineInSEATBELTStatus
#define    LINE_IN_SEATBELT_DEFAULT           0
#endif


/***LED_POSITION_G ***/
#if  ((defined  LINE_IN_POSITION) || (defined LINE_IN_POSITIONn))  		   

extern volatile uint8_t    LineInPOSITIONStatus;

#define    LINE_IN_POSITION_SIGNAL            LineInPOSITIONStatus
#define    LINE_IN_POSITION_DEFAULT           0
#endif

////////////////////////////////////////////////////////////////////////
/***LED_MIL_Y ***/
#if  ((defined  LINE_IN_MIL) || (defined LINE_IN_MILn))  	   

extern volatile uint8_t    LineInMILStatus;

#define    LINE_IN_MIL_SIGNAL            LineInMILStatus
#define    LINE_IN_MIL_DEFAULT           0
#endif

 /***PTO ***/
#if  ((defined  LINE_IN_PTO) || (defined LINE_IN_PTOn))      

  extern volatile uint8_t    LineInPTOStatus;
 
  #define    LINE_IN_PTO_SIGNAL            LineInPTOStatus
  #define    LINE_IN_PTO_DEFAULT           0  
#endif

/*** LINE_IN_BREAK_FLUID_SIGNAL ***/        
#if  ((defined LINE_IN_BREAK_FLUID) || (defined LINE_IN_BREAK_FLUIDn))  

  extern volatile uint8_t   LineInBREAKFLUIDStatus;
  
  #define    LINE_IN_BREAK_FLUID_SIGNAL            LineInBREAKFLUIDStatus
  #define    LINE_IN_BREAK_FLUID_DEFAULT           0
#endif

/*** LINE_IN_BREAK_SIGNAL ***/         
#if  ((defined LINE_IN_BREAK) || (defined LINE_IN_BREAKn))  

  extern volatile uint8_t   LineInBREAKStatus;
  
  #define    LINE_IN_BREAK_SIGNAL            LineInBREAKStatus
  #define    LINE_IN_BREAK_DEFAULT           0
#endif

/*** LINE_IN_RF_HOOVES_SIGNAL ***/         
#if  ((defined LINE_IN_RF_HOOVES) || (defined LINE_IN_RF_HOOVESn))  

  extern volatile uint8_t   LineInRFHOOVESStatus;
  
  #define    LINE_IN_RF_HOOVES_SIGNAL            LineInRFHOOVESStatus
  #define    LINE_IN_RF_HOOVES_DEFAULT           0
#endif

/*** LINE_IN_RR_HOOVES_SIGNAL ***/         
#if  ((defined LINE_IN_RR_HOOVES) || (defined LINE_IN_RR_HOOVESn))  

  extern volatile uint8_t   LineInRRHOOVESStatus;
  
  #define    LINE_IN_RR_HOOVES_SIGNAL            LineInRRHOOVESStatus
  #define    LINE_IN_RR_HOOVES_DEFAULT           0
#endif

/*** LINE_IN_CAB_LOCK_SIGNAL ***/         
#if  ((defined LINE_IN_CAB_LOCK) || (defined LINE_IN_CAB_LOCKn))  

  extern volatile uint8_t   LineInCABLOCKStatus;
  
  #define    LINE_IN_CAB_LOCK_SIGNAL            LineInCABLOCKStatus
  #define    LINE_IN_CAB_LOCK_DEFAULT           0
#endif

/*** LINE_IN_FILT_BLOCK_SIGNAL ***/         
#if  ((defined LINE_IN_FILT_BLOCK) || (defined LINE_IN_FILT_BLOCKn))  

  extern volatile uint8_t   LineInFILTBLOCKStatus;
  
  #define    LINE_IN_FILT_BLOCK_SIGNAL            LineInFILTBLOCKStatus
  #define    LINE_IN_FILT_BLOCK_DEFAULT           0
#endif

/*** LINE_IN_CHARGE_SIGNAL ***/         
#if  ((defined LINE_IN_CHARGE) || (defined LINE_IN_CHARGEn))  

  extern volatile uint8_t   LineInCHARGEStatus;
  
  #define    LINE_IN_CHARGE_SIGNAL            LineInCHARGEStatus
  #define    LINE_IN_CHARGE_DEFAULT           0
#endif

/*** LINE_IN_GEAR_SIGNAL ***/        
#if  ((defined LINE_IN_GEAR) || (defined LINE_IN_GEARn))  

  extern volatile uint8_t   LineInGEARStatus;
  
  #define    LINE_IN_GEAR_SIGNAL            LineInGEARStatus
  #define    LINE_IN_GEAR_DEFAULT           0
#endif
/******************************************************************************
函数声明
******************************************************************************/
void    Line_In_Enable(uint8_t Enable);
void    Line_In_Status_Reset(void);
void    Line_In_Debounce_Service(void);          //必须每20ms调用一次

#endif