⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commondefine.h

📁 基于16位单片机的符合osek标准的操作系统
💻 H
📖 第 1 页 / 共 4 页
字号:
**********************analog.c******************************/
EXTERN struct Arraylp ArraylpCRP_V,ArraylpBAT_V,ArraylpIntake_T,
                      ArraylpAC_T,ArraylpCW_T,ArraylpVESS_V,
                      ArraylpOS_V,ArraylpKS_V,ArraylpCMP_V;
                   
EXTERN unsigned int G_u16CRP_V;//R	crp signal voltage analog value
EXTERN unsigned int G_u16BAT_V;//R	
EXTERN unsigned int G_u16Intake_P,G_u16Intake_P0,G_u16MAP0;//R  
EXTERN int int16dIntake_P; 
EXTERN unsigned int G_u16Intake_T;//R	intake tempreture analog value
EXTERN unsigned int G_u16AC_T;//R	air condition tempreture analog value
EXTERN unsigned int G_u16TPS;//R	
EXTERN unsigned int G_u16EGR_Pos;//R
EXTERN unsigned int G_u16CW_T;//R
EXTERN unsigned int G_u16VESS_V;//R
EXTERN unsigned int G_u16OS_V;//R
EXTERN unsigned int G_u16KS_V;//R
EXTERN unsigned int G_u16CMP_V;//R

EXTERN char Intake_T;//intake tempreture actually value
EXTERN char AC_T;//air condition tempreture actually value
EXTERN unsigned char ThrottleRatio;//throttle opening ratio
EXTERN unsigned int G_u16TPS_IdleBaseValue;//the throttle  value within idle range
EXTERN unsigned int G_u16TPS_FullLoadValue;//the throttle value within full load range
EXTERN unsigned char G_u8TPS_BaseIndex;
EXTERN unsigned int G_u16TPS_IdleBaseValueSum;
EXTERN unsigned int G_u16TPS0;//the last throttle value
EXTERN int G_n16dTPS;//the diffirential value of the throttle

EXTERN unsigned char EGR_Ratio;//egr opening ratio
EXTERN char CW_T;//coolant water tempreture actually value




extern void TPIC2603_CtrlData(void);
EXTERN unsigned int un16SPI2_SendDataTimer;
EXTERN BIT_Union		_TPIC2603Data;
#define TPIC2603Data				_TPIC2603Data.Byte//R
#define G_bCNST							_TPIC2603Data.Bits.BIT0//coolant water fan low
#define G_bMIL							_TPIC2603Data.Bits.BIT1//main relay
#define G_bFanL							_TPIC2603Data.Bits.BIT2//coolant water fan high
#define G_bFanH							_TPIC2603Data.Bits.BIT3//diagnose lamp
#define G_bPump							_TPIC2603Data.Bits.BIT4
#define G_bMainR							_TPIC2603Data.Bits.BIT5



EXTERN BIT_Union		_pre_TPIC2603Data;
#define pre_TPIC2603Data				_pre_TPIC2603Data.Byte//R
#define bPreCNST							_pre_TPIC2603Data.Bits.BIT0//coolant water fan low
#define bPreMIL							_pre_TPIC2603Data.Bits.BIT1//main relay
#define bPreFanL							_pre_TPIC2603Data.Bits.BIT2//coolant water fan high
#define bPreFanH							_pre_TPIC2603Data.Bits.BIT3//diagnose lamp
#define bPrePump							_pre_TPIC2603Data.Bits.BIT4
#define bPreMainR							_pre_TPIC2603Data.Bits.BIT5












/****************K Line Communication****************************/

extern void KLineSend(UINT8);
extern void KLineReceive(void);
extern void KLineTimer(void);
extern void KlineCommInit(UINT8 channel,UINT16 baudrate);
extern void KlineParaInit(void);
extern UINT8 CheckSum(void);  
extern void CreatRespMesKWP2000(void);                                       
extern void KlineCommunication(void);      
extern void ConfigCalibratedPara(void);                
extern void average(struct Arraylp* arraylp,unsigned int newvalue);
extern void McuWatchdog(void);//MCU喂狗



extern void PowerInit(void);//电源控制芯片初始化
extern void PowerWatchdog(void);//电源控制芯片喂狗
extern void V3_Ctrl(char OnOff);//12v电源输出控制
extern void ScanIgnKey(void);//巡检点火钥匙状态

extern void PowerOff(void);
EXTERN UINT16 un16ScanIgnKeyTimer; //钥匙状态巡检定时
EXTERN UINT8 bIgnKey,bIgnKey0;//点火钥匙状态瞬时值    
EXTERN UINT8 G_bIgnKey;  //点火钥匙状态
/****************** K Line Communication data*******************/
EXTERN 	UINT16 un16RecordValue;
EXTERN 	FLOAT32 floRecordValue;

EXTERN UINT16 G_n16WakeUpDelay;//Wake Up K line Communication
EXTERN UINT8 G_bWakeUpFlag;//flag of Wake-Up K line Communication
EXTERN UINT16 G_n16CommDelay;//请求与ECU回应之间的延时 >25ms&<50ms
EXTERN UINT8 ucReadBuffer;
EXTERN UINT8 G_uc8Receivedata[300];//SCI 1 Receive Buffer 接收缓冲区
EXTERN UINT8 G_un16ReceivedataNum;//the number of received data from K Line 接收到的数据数目
EXTERN UINT8 G_ServiceID;//the Service ID of Requst Message Received
EXTERN UINT8 G_StartLocation;//Start Location of Message in the Receive Buffer
EXTERN UINT8 G_SIDLocation;
EXTERN UINT16 G_uc8RequstMLength;//the length of requst message
EXTERN UINT8 G_ReadDataPID;//Local Identifier of Reading Data By Local Identifier service
EXTERN UINT8 G_WriteDataPID;//Local Identifier of Writing Data By Local Identifier service
EXTERN UINT8 G_uc8MemoryAddressH;//memoryAddress (High Byte) of Reading Memory By Address service
EXTERN UINT8 G_uc8MemoryAddressM;//memoryAddress (Middle Byte) of Reading Memory By Address service
EXTERN UINT8 G_uc8MemoryAddressL;//memoryAddress (Low Byte) of Reading Memory By Address service
EXTERN UINT8 G_uc8MemorySize;//memorySize of Reading Memory By Address service

EXTERN UINT8 G_uc8ResponseMessage[260];//SCI 1 Transmmit Buffer 发送缓冲区
EXTERN UINT16 G_un16ResponseMLength;//the length of response message
EXTERN UINT8 G_bSendEnble;//报文写入发送缓冲区,准备发送
EXTERN UINT8 G_bSendComplete;//发送完成标志
EXTERN UINT8 G_bReceiveComplete;//接收完成标志
EXTERN UINT8 G_bSendReady;
EXTERN UINT8 G_n8ByteInter; 

EXTERN UINT16 G_un8P1TimerMin;
EXTERN UINT16 G_un8P1TimerMax; 
EXTERN UINT16 G_un8P2TimerMin;
EXTERN UINT16 G_un8P2TimerMax; 
EXTERN UINT16 G_un16P3TimerMin;/**/ 
EXTERN UINT16 G_un16P3TimerMax; 
EXTERN UINT16 G_un16SendNum;
 //K Line Communication Service ID Flag KWP2000-3
EXTERN BIT_Union8 _CommunicationFlag ;					
#define CommunicationFlag _CommunicationFlag.Byte
//#define bServiceID9 _CommunicationFlag.Bits.BIT0	//Flag of Service $09
#define bGeneralReject _CommunicationFlag.Bits.BIT1	//Negative Response code=0x10
#define bNotSurpport _CommunicationFlag.Bits.BIT2	//Negative Response code=0x11
#define bSubFunNotSup _CommunicationFlag.Bits.BIT3	//Negative Response code=0x12
#define bBusyRepeat _CommunicationFlag.Bits.BIT4	//Negative Response code=0x21
#define bCondNotCorrect _CommunicationFlag.Bits.BIT5//Negative Response code=0x22
#define bResponsePending _CommunicationFlag.Bits.BIT6//Negative Response code=0x78 
                            

EXTERN BIT_Union8 _CommunicationFlag0 ;					
#define CommunicationFlag0 _CommunicationFlag0.Byte
#define bStartFlag _CommunicationFlag0.Bits.BIT0		//Flag of StartCommunication 
#define bStopFlag _CommunicationFlag0.Bits.BIT1	        //Flag of 
#define bAccessTimingFlag  _CommunicationFlag0.Bits.BIT2//Flag of  
#define bStartSessionFlag _CommunicationFlag0.Bits.BIT3	//Flag of 
#define bHandshakeFlag _CommunicationFlag0.Bits.BIT4	//Flag of HandShakeCommunication 
#define bSecurityAccessFlag _CommunicationFlag0.Bits.BIT5//Flag of  
#define bECUResetFlag _CommunicationFlag0.Bits.BIT6		//Flag of  
#define bReadEcuIdFlag _CommunicationFlag0.Bits.BIT7	//Flag of 


EXTERN BIT_Union8 _CommunicationFlag1;					
#define CommunicationFlag1 _CommunicationFlag1.Byte
#define bReadDataLIDFlag _CommunicationFlag1.Bits.BIT0	    //Flag of ReadDatabyLocalID 
#define bReadDataCIDFlag  _CommunicationFlag1.Bits.BIT1   	//Flag of  
#define bReadMemoryByAFlag  _CommunicationFlag1.Bits.BIT2  	//Flag of  
#define bDefineLocalIdFlag _CommunicationFlag1.Bits.BIT3	//Flag of  
#define bWriteDataByLIdFlag _CommunicationFlag1.Bits.BIT4	//Flag of 
#define bWriteDataByCIdFlag _CommunicationFlag1.Bits.BIT5   //Flag of  
#define bWriteMemoryByAFlag _CommunicationFlag1.Bits.BIT6	//Flag of 

 
EXTERN BIT_Union8 _CommunicationFlag2 ;					
#define CommunicationFlag2 _CommunicationFlag2.Byte
#define bReadDTCBySFlag _CommunicationFlag2.Bits.BIT0	        //Flag of ReadDTCCommunication  
#define bReadStatusofDTCFlag  _CommunicationFlag2.Bits.BIT1   	//Flag of  
#define bReadFreezeDataFlag _CommunicationFlag2.Bits.BIT2	    //Flag of 
#define bClearFlag  _CommunicationFlag2.Bits.BIT3   	        //Flag of ClearDTCCommunication 
#define bIOControlByLIdFlag _CommunicationFlag2.Bits.BIT4	    //Flag of 
#define bIOControlByCIdFlag  _CommunicationFlag2.Bits.BIT5  	//Flag of 
#define bStartRoutineByLIdFlag _CommunicationFlag2.Bits.BIT6	//Flag of   
#define bStartRoutineByAFlag _CommunicationFlag2.Bits.BIT7	    //Flag of  

EXTERN BIT_Union8 _CommunicationFlag3 ;					
#define CommunicationFlag3 _CommunicationFlag3.Byte
#define bStopRoutineByLIdFlag _CommunicationFlag3.Bits.BIT0		//Flag of 
#define bStopRoutineByAFlag _CommunicationFlag3.Bits.BIT1	    //Flag of 
#define bRoutineResultByLIdFlag  _CommunicationFlag3.Bits.BIT2  //Flag of  
#define bRoutineResultByAFlag _CommunicationFlag3.Bits.BIT3	    //Flag of 
#define bDownloadFlag _CommunicationFlag3.Bits.BIT4	            //Flag of 
#define bUploadFlag  _CommunicationFlag3.Bits.BIT5  	        //Flag of 
#define bTransferDataFlag _CommunicationFlag3.Bits.BIT6	        //Flag of 
#define bTransferExitFlag _CommunicationFlag3.Bits.BIT7	        //Flag of





extern unsigned int LookUpStartInjRPM_Table(unsigned int CWT_AD_VALUE);
extern float LookUpInjWidth_Table(unsigned int Revolution,unsigned int IntakePressure/*floMAP ATD value*/);
extern float LookUpStartInjWidth_Table(unsigned int workcycle,unsigned int coolantWater/*floMAP ATD value*/);
extern float LookUpInjdv_Table(unsigned int Revolution,unsigned int IntakePressure/*floMAP ATD value*/);
extern unsigned char LookUp_UN8SpareTable1(unsigned int ColumnValue,unsigned int RowValue);
extern unsigned int LookUp_UN16SpareTable1(unsigned int ColumnValue,unsigned int RowValue);
extern unsigned int LookUp_UN16SpareDim1Table1(unsigned int InputValue);
extern unsigned char LookUp_UN8SpareDim1Table1(unsigned int InputValue);
extern void TableData_Init(void);


EXTERN BIT_Union _CalibrateTable ;		//Sensors		
#define CalibrateTable _CalibrateTable.Byte	
#define bCalInjWidth_Table		 _CalibrateTable.Bits.BIT0 
#define bCalStartInjWidth_Table		 _CalibrateTable.Bits.BIT1  
#define bCalInjAdv_Table			_CalibrateTable.Bits.BIT2
//#define bCalInjAdv_Table			 _CalibrateTable.Bits.BIT3
#define bCalMAT_Value_Table			 _CalibrateTable.Bits.BIT4 
#define bCalUN8SpareTable1			 _CalibrateTable.Bits.BIT5
#define bCalUN16SpareTable1			 _CalibrateTable.Bits.BIT6  


#pragma DATA_SEG MAP_RAM            
EXTERN unsigned char MAPData[2000];
#pragma DATA_SEG DEFAULT



#define InjWidth_Table_Row				15
#define InjWidth_Table_RowMin			200
#define InjWidth_Table_RowMax			900
#define InjWidth_Table_RowStep			50
#define InjWidth_Table_Column			15
#define InjWidth_Table_ColMin			100
#define InjWidth_Table_ColMax			2900
#define InjWidth_Table_ColStep			200

#define StartInjWidth_Table_Row				15
#define StartInjWidth_Table_RowMin			200
#define StartInjWidth_Table_RowMax			900
#define StartInjWidth_Table_RowStep			50
#define StartInjWidth_Table_Column			15
#define StartInjWidth_Table_ColMin			1
#define StartInjWidth_Table_ColMax			15
#define StartInjWidth_Table_ColStep			1

#define InjAdv_Table_Row 			15
#define InjAdv_Table_RowMin 		200
#define InjAdv_Table_RowMax 		900
#define InjAdv_Table_RowStep		50
#define InjAdv_Table_Column			15
#define InjAdv_Table_ColMin			100
#define InjAdv_Table_ColMax			2900
#define InjAdv_Table_ColStep		200



#define UN8SpareTable1_Row 			15
#define UN8SpareTable1_RowMin 		200
#define UN8SpareTable1_RowMax 		900
#define UN8SpareTable1_RowStep		50
#define UN8SpareTable1_Column		15
#define UN8SpareTable1_ColMin		100
#define UN8SpareTable1_ColMax		2900
#define UN8SpareTable1_ColStep		200


#define UN16SpareTable1_Row 		15
#define UN16SpareTable1_RowMin 		200
#define UN16SpareTable1_RowMax 		900
#define UN16SpareTable1_RowStep		50
#define UN16SpareTable1_Column		15
#define UN16SpareTable1_ColMin		100
#define UN16SpareTable1_ColMax		2900
#define UN16SpareTable1_ColStep		200 



#define UN16SpareDim1Table1_Length	17
#define UN16SpareDim1Table1Min 		0
#define UN16SpareDim1Table1Max 		1024
#define UN16SpareDim1Table1Step		64


#define UN8SpareDim1Table1_Length	17
#define UN8SpareDim1Table1Min 		0
#define UN8SpareDim1Table1Max 		1024

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -