Commit 803b3871 authored by 崔立宝's avatar 崔立宝

TCanInit时间超标问题修改+取消0x18FFOA17外发(EF01报文矩阵里没有)

parent 98586541
OPEN source 0 0 49 100
OPEN source 0 0 56 100
Source < attributes TOOLTIP on,TOOLTIP_FORMAT signed,TOOLTIP_MODE details,FREEZE off,MARKS off
OPEN assembly 60 0 40 31
Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xF780DB
Assembly < attributes ADR on,CODE off,ABSADR on,SYMB off,FORMAT Auto,FREEZE off,TOPPC 0xFFFF
OPEN procedure 0 39 60 17
Procedure < attributes VALUES on,TYPES off
OPEN register 60 31 40 25
......@@ -10,7 +10,7 @@ OPEN memory 60 56 40 22
Memory < attributes FORMAT hex,COMPLEMENT None,WORD 1,ASC on,ADR on,MODE automatic,UPDATERATE 10,SHOW_ADDRESSSPACE 0,ADDRESS 0x80
OPEN data 0 56 60 22
Data:1 < attributes SCOPE global,COMPLEMENT None,FORMAT Symb,MODE automatic,SORT NotSort,UPDATERATE 10,NAMEWIDTH 16
OPEN data 50 1 70 98
OPEN data 30 0 70 98
Data:2 < attributes SCOPE local,COMPLEMENT None,FORMAT Symb,MODE periodical,SORT NotSort,UPDATERATE 1,NAMEWIDTH 16
OPEN command 60 78 40 22
Command < attributes CACHESIZE 1000
......
/******************************************************************************
?? ?? ??;UDS_ISO14229_Services.c
????????;ISO 14229 ?Z??????????????????????????????
?? ??;????
?? ??;V1.0
?? ??;2016.11.1
文 件 名;UDS_ISO14229_Services.c
功能描述;ISO 14229 规范规定的诊断服务服务器端服务实现函数库文件
作 者;张暄
版 本;V1.0
日 期;2016.11.1
******************************************************************************/
//#include "Include.h"
//#include "Const.h"
......@@ -163,89 +163,109 @@ INT8U EraseMemoryFF[128];
INT8U APPFLAG;
DiagSendDataRes PosRes;
DiagSendDataNeg NegRes;
uint8_t S3_ServerEN; // ?????5s???????????
uint16_t S3_ServerCnt; //????????????????
uint8_t S3_Server_refresh; //????????S3?????
uint16_t S19DataCntOfReceive; //S19?????????????
uint8_t S3_ServerEN; //扩展会话5s定时器使能开关
uint16_t S3_ServerCnt; //扩展会话定时器计数器
uint8_t S3_Server_refresh; //刷新扩展会话S3时间标志
uint16_t S19DataCntOfReceive; //S19数据的接收总长度
SRecord_t srcd;
//uint16_t CheckSum;
uint8_t BlockSCT; //BlockSequenceCounter (1,2,...255,0)
uint8_t REC_DLlen; //?????????????????(???????)
uint8_t DTCControlType; //DTC?????????? 0
uint8_t BlocKCnt; //S19 ?????block???
uint8_t RequestTransfer; //???????????
//uint32_t SectorAddress; //???????
uint32_t EraseAddress; //???????
uint8_t ControlType; // ???????????
uint8_t CommunicationType; // ???????????
uint8_t Wait10s; //27???????????????10??
uint8_t wait10cnt = 0;
uint8_t Wait10sFlag; //???10????
uint8_t DiagLockFlag; //27??????????
//uint8_t AttemptCnt; //27?????????
//uint8_t RequestSeedCnt; //????????????
uint8_t SeedkeyValidFlag; //??1 ????????
uint32_t ValidSeedKey1; //??????????
//uint32_t ValidSeedKey4; //??????????
uint32_t ValidSeedKey2; //??????????
uint8_t BlockSCT; //BlockSequenceCounter (1,2,...255,0)
uint8_t REC_DLlen; //已经接收到的数据个数(多少字节)
uint8_t DTCControlType; //DTC记录控制开关 0
uint8_t BlocKCnt; //S19 传输的block数目
uint8_t RequestTransfer; //请求下载的标志
//uint32_t SectorAddress; //扇区地址
uint32_t EraseAddress; //擦除地址
uint8_t ControlType; //通信控制的类型
uint8_t CommunicationType; //通信控制的类型
uint8_t Wait10s; //27服务尝试失败需要等待10秒
uint8_t wait10cnt = 0;
uint8_t Wait10sFlag; //等待10秒标志
uint8_t DiagLockFlag; //27服务解锁标志
//uint8_t AttemptCnt; //27服务尝试次数
//uint8_t RequestSeedCnt; //请求种子的次数
uint8_t SeedkeyValidFlag; //置1 表示秘钥生效
uint32_t ValidSeedKey1; //表示有效的秘钥
//uint32_t ValidSeedKey4; //表示有效的秘钥
uint32_t ValidSeedKey2; //表示有效的秘钥
uint16_t SeedHigh;
uint16_t SeedLow;
uint8_t Services27_01_Requested;
uint8_t noDataLenth;
uint8_t Time10sLock;
uint16_t EngineSpeed; //?????????
uint8_t MotorPosition; //?????
uint8_t DisplayColor; //???????????
uint8_t ControlMotor; //????????????????
uint16_t ESpeedVal; //???
uint16_t VspeedVal; //????
uint8_t TempSeg; //???
uint8_t BuzzerStatus; //????????
uint8_t SessionType = 1; //??????
uint8_t IO_Group_1;
uint8_t IO_Group_2;
uint8_t IO_Group_3;
uint8_t IO_Group_4;
uint8_t IO_MASK_1;
uint8_t IO_MASK_2;
uint8_t IO_MASK_3;
uint8_t IO_MASK_4;
uint8_t Services27_01_Requested;
uint8_t noDataLenth;
uint8_t Time10sLock;
uint16_t EngineSpeed; //发动机转速
uint8_t MotorPosition; //电机位置
uint8_t DisplayColor; //需要显示的颜色
uint8_t ControlMotor; //需要控制的是哪个电机
uint16_t ESpeedVal; //转速
uint16_t VspeedVal; //车速
uint8_t TempSeg; //水温
uint8_t BuzzerStatus; //蜂鸣器状态
uint8_t SessionType = 1; //会话类型
uint8_t IO_Group_1;
uint8_t IO_Group_2;
uint8_t IO_Group_3;
uint8_t IO_Group_4;
uint8_t IO_MASK_1;
uint8_t IO_MASK_2;
uint8_t IO_MASK_3;
uint8_t IO_MASK_4;
uint8_t Error;
uint32_t DFLASHeep_adr;
INT16U MYeturnCode;
uint8_t seed[4];//????27?????????????????????
uint32_t RANDOM;//????????????? ???????????
INT16U MYeturnCode;
uint8_t seed[4]; //用于27服务存放种子可以为局部变量
uint32_t RANDOM; //用于随机数计算 必须为全局变量
const uint8_t XorArray[4] = {0x31, 0x23, 0x56, 0x71};
uint8_t UDS_ISO14229_Transfer[250];
uint8_t ContrlorResumeofSOC; //soc????
uint8_t ContrlorResumeofSOC; //soc控制
uint8_t SocSeg; //Soc
uint8_t ContrlorResumeofEspeed; //??????
uint16_t ESpeedValNUM; //???
uint8_t ContrlorResumeofVspeed; //???????
uint16_t VspeedValNUM; //????
//----hyq--20190827 ???????
uint8_t ContrlorResumeofGAS1 ; //???1
uint8_t ContrlorResumeofLamp; //???????????
uint8_t LampWarningStatus; //?????
uint8_t ContrlorResumeofBuzzer; //??????????
uint8_t ContrlorResumeofGauge; //?????????
uint8_t ContrlorResumeofLCD; //LCD????
uint8_t ContrlorResumeofIO; //IO????
uint8_t ContrlorResumeofIOLast; //IO????
uint8_t ContrlorResumeofBuzzer; //??????????
uint8_t ContrlorResumeofGauge; //?????????
uint8_t ContrlorResumeofLCD; //LCD????
uint8_t ContrlorResumeofIO; //IO????
uint8_t ContrlorResumeofIOLast; //IO????
uint8_t ContrlorResumeofTEMP; //???????
uint8_t ContrlorResumeofEspeed; //转速控制
uint16_t ESpeedValNUM; //转速
uint8_t ContrlorResumeofVspeed; //车速控制
uint16_t VspeedValNUM; //车速
//----hyq--20190827 定义变量
uint8_t ContrlorResumeofGAS1 ; //气压1
uint8_t ContrlorResumeofLamp; //所有报警灯测试
uint8_t LampWarningStatus; //灯光状态
uint8_t ContrlorResumeofBuzzer; //蜂鸣器控制
uint8_t ContrlorResumeofGauge; //所有表头控制
uint8_t ContrlorResumeofLCD; //LCD控制
uint8_t ContrlorResumeofIO; //IO控制
uint8_t ContrlorResumeofIOLast; //IO控制
//uint8_t ContrlorResumeofBuzzer; //??????????
//uint8_t ContrlorResumeofGauge; //???§Ò??????
//uint8_t ContrlorResumeofLCD; //LCD????
//uint8_t ContrlorResumeofIO; //IO????
//uint8_t ContrlorResumeofIOLast; //IO????
uint8_t ContrlorResumeofTEMP; //??¡À?????
uint8_t CAN_NORMAL_TT;
uint8_t CAN_NORMAL_2SFF;
uint8_t CAN_DTC_OFF;
......@@ -256,14 +276,15 @@ uint8_t CANNetRxOFF = 0;
uint8_t CoCanTxOff = 0;
Diag27Data diag27;
uint8_t UPDOWNFLAG;
uint8_t CJINF[18]; //????????(18ASSIC?????)(??????EEPROM????????)
uint8_t CJINF[18]; //存储厂家信息(18位ASSIC字符串)(保存在EEPROM但不备份)
_DTC DiagDtc[cnDTCslen];
RecDTC_WaitBusoff_STRUCT RecDTC_Wait_NoBusoff[cnDTCslen];
INT8U HIGH_VOLTAGE;
INT8U LOW_VOLTAGE;
INT8U BUS_OFF_FLAG;
INT8U VoltageACKFF;
//DTC?????
INT8U HIGH_VOLTAGE;
INT8U LOW_VOLTAGE;
INT8U BUS_OFF_FLAG;
INT8U VoltageACKFF;
//DTC定时器
extern INT8U GUIIconSeatbeltRStatus;
extern INT8U GUIIconDRLGStatus;
extern INT8U GUIIconSVSYStatus;
......@@ -389,9 +410,10 @@ INT8U D_P_FLASH_Program ( INT8U mTYPE, INT32U address, INT16U *ptr, INT8U numb
ptr++;
}
cli(); //????
CallFnCmdInRam();//asm JSR Send_Command; //equal to FSTAT_CCIF=1; while(FSTAT_CCIF==0)asm JSR Send_Command;
sei(); //????
cli(); //我加的
CallFnCmdInRam(); //asm JSR Send_Command; //equal to FSTAT_CCIF=1; while(FSTAT_CCIF==0)asm JSR Send_Command;
sei(); //我加的
if ( ( FSTAT & ( FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK ) ) != 0 )
return ACCESS_ERROR;
......@@ -401,7 +423,7 @@ INT8U D_P_FLASH_Program ( INT8U mTYPE, INT32U address, INT16U *ptr, INT8U numb
//==============================================================================
//DFLASH_Erase_Verify_Section
//
//???:address ??????, number_of_words ?????????????
//入口:address 为全局地址, number_of_words 为要校验的字单元个数
//==============================================================================
INT8U DFLASH_Erase_Verify_Section ( INT32U address, INT16U number_of_words )
{
......@@ -481,13 +503,14 @@ uint8_t PP_FLASH_N_Program ( uint32_t address, uint8_t *ptr, uint8_t number_of
uint32_t DFLASH_Read_Word ( INT32U address )
{
INT16U Data16;
//?????????
//获取逻辑地址
uint32_t LogicAddress = address - DFLASH_FirstAddress;
//DFLASH??PAGE?????????
//DFLASH的PAGE寄存器设置
EPAGE = (uint8_t)(LogicAddress / 0x400);
//??PAGE???????
//在PAGE中的相对地址
LogicAddress %= 0x400;
//?????????????????
//将全局地址转化为逻辑地址
Data16 = ( *(volatile unsigned short * )(0x800 + LogicAddress));
return Data16;
}
......@@ -720,7 +743,7 @@ INT8U DFLASH_Erase_Sector ( INT32U address )
//==============================================================================
//DFLASH_N_Program
//
//???:address ??????
//入口:address 为全局地址
//
// 1<=number_of_words<=128
//==============================================================================
......@@ -730,7 +753,8 @@ INT8U DFLASH_N_Program ( INT32U address, INT16U *ptr, INT8U number_of_words )
for ( ;; )
{
//???????
//复位看门狗
__RESET_WATCHDOG();
if ( number_of_words >= 4 )
......@@ -756,13 +780,13 @@ INT8U DFLASH_N_Program ( INT32U address, INT16U *ptr, INT8U number_of_words )
}
//====================================================
//??FLASH??N??????????RAM (mLEN????????)
//从FLASH中读N个字节数据到RAM (mLEN必须为偶数)
//====================================================
void ReadNbyteFrDFalsh ( INT16U *mP, INT16U mLEN )
{
INT8U i;
INT16U k;
__RESET_WATCHDOG(); //????????????
__RESET_WATCHDOG(); //复位看门狗定时器
k = mLEN / 2;
for ( i = 0; i < k; i++ )
......@@ -772,16 +796,17 @@ void ReadNbyteFrDFalsh ( INT16U *mP, INT16U mLEN )
}
}
//====================================================
//N??????????FLASH (mLEN????????)
//写N个字节数据到FLASH (mLEN必须为偶数)
//====================================================
void WriteNbyteToDFalsh ( INT16U *mP, INT16U mLEN )
{
__RESET_WATCHDOG(); //????????????
__RESET_WATCHDOG(); //复位看门狗定时器
MYeturnCode = DFLASH_N_Program ( DFLASHeep_adr, mP, mLEN / 2 );
DFLASHeep_adr = DFLASHeep_adr + mLEN;
}
//?????APP?????????
//读取改写APP部分程序标志位
void WRITE_BZ_inDFLAH2Sector ( INT16U bz )
{
INT8U mRUL = 0;
......@@ -792,7 +817,7 @@ void WRITE_BZ_inDFLAH2Sector ( INT16U bz )
}
//========================================================
//??FLASH???????27?????????RAM
//从FLASH中读诊断协议27内容参数到RAM
//========================================================
void Read_27_DATA_FROM_FLASH ( void )
{
......@@ -820,19 +845,21 @@ void Read_27_DATA_FROM_FLASH ( void )
}
}
//========================================================
// ?????2E???? ??????FALSH
//写 诊断协议2E内容 参数到FALSH
//========================================================
void Write_27_DATA_TO_FLASH ( void )
{
INT16U m16;
//????27????flash?????
MYeturnCode = DFLASH_Erase_Sector ( DFLASH_LockAddress ); //??????3??????(256???)
//?????????????
//擦除27服务flash存储扇区
MYeturnCode = DFLASH_Erase_Sector ( DFLASH_LockAddress ); //擦除第3个扇区(256字节)
//清除失败退出函数
if ( MYeturnCode != OK )
return;
DFLASHeep_adr = DFLASH_LockAddress + 2;
//????????falsh??
//将数据写入到falsh中
WriteNbyteToDFalsh ( ( INT16U * ) &diag27, sizeof ( diag27 ) );
m16 = 0x7AA7;
MYeturnCode = DFLASH_N_Program ( DFLASH_LockAddress, &m16, 1 );
......@@ -863,49 +890,49 @@ service primitives are specified:
******************************************************************************/
/******************************************************************************
?????????????????????;
每一个服务由三个函数实现;
1. ??????; <service_name>_Indication
<service_name> ??????? UDS_Service_<SI>
?? ??;???????????????????????????????????????????????
????????
1. 函数名; <service_name>_Indication
<service_name> 统一命名为 UDS_Service_<SI>
功 能;应用层通过该函数向诊断服务实现函数请求服务并将相关数据传送给诊断服
务实现函数
The indication primitive is used by the application layer, to
indicate an internal event which is significant to the ECU
diagnostic application and pass data about the requested diagnostic
service to the server function of the ECU diagnostic application.
?? ??;A_TA_type ;????????,????????????
A_Length ;?????????????
A_Data ;?????????
?????;??
2. ??????; <service_name>_Response
<service_name> ??????? UDS_Service_<SI>
?? ??;??????????????????????,?????????????????????????
??????
参 数;A_TA_type ;源地址类型,物理寻址或功能寻址
A_Length ;传输的数据的长度
A_Data ;传输的数据
返回值;无
2. 函数名; <service_name>_Response
<service_name> 统一命名为 UDS_Service_<SI>
功 能;该函数由诊断服务实现函数发起,用于向应用层发送诊断服务函数生成的反
馈数据
The response primitive is used by the server function in the ECU
diagnostic application, to initiate the service and pass response
data provided by the requested diagnostic service to the
application layer.
?? ??;RspType ;???????? POSITIVE_RSP ??????
NEGATIVE_RSP ??????
A_TA_type ;?????????,????????????? DIAG_ID_Tx
A_Length ;?????????????
A_Data ;?????????
?????;??
3. ??????; <service_name>_Rsp_Confirm
<service_name> ??????? UDS_Service_<SI>
?? ??;?????????????????,??????????????????????????????
??????????????
参 数;RspType ;反馈类型 POSITIVE_RSP 正反馈
NEGATIVE_RSP 负反馈
A_TA_type ;目标地址类型,发送数据请使用 DIAG_ID_Tx
A_Length ;传输的数据的长度
A_Data ;传输的数据
返回值;无
3. 函数名; <service_name>_Rsp_Confirm
<service_name> 统一命名为 UDS_Service_<SI>
功 能;反馈确认函数由应用层发起,用于向诊断服务实现方告知前一次向应用层发送
反馈数据的传输结果
The response-confirm primitive is used by the application layer
to indicate an internal event, which is significant to the server
application, and pass communication results of an associated
previous service response to the server function in the ECU
application.
?? ??;A_TA_type ;?????????
A_Result ;?????? A_OK ???????
A_ERR ???????
?????;??
参 数;A_TA_type ;目标地址类型
A_Result ;传输结果 A_OK 正确传输
A_ERR 传输失败
返回值;无
******************************************************************************/
void Randomcnt ( void )
{
......@@ -955,7 +982,7 @@ void S3_ServerCNT ( void )
S3_ServerCnt++;
if ( S3_ServerCnt > S3_SERVER ) //S3???
if ( S3_ServerCnt > S3_SERVER ) //S3超时
{
S3_ServerCnt = 0;
S3_ServerEN = 0;
......@@ -964,12 +991,13 @@ void S3_ServerCNT ( void )
DiagLockFlag = 0;
ContrlorResumeofIO = 0;
ContrlorResumeofSOC = 0; //soc????
ContrlorResumeofSOC = 0; //soc控制
SocSeg = 0; //Soc
ContrlorResumeofEspeed = 0; //??????
ESpeedValNUM = 0; //???
ContrlorResumeofVspeed = 0; //???????
VspeedValNUM = 0; //????
ContrlorResumeofEspeed = 0; //转速控制
ESpeedValNUM = 0; //转速
ContrlorResumeofVspeed = 0; //车速控制
VspeedValNUM = 0; //车速
ContrlorResumeofLamp = 0;
// ISD_Stop_Loop();
......@@ -1008,20 +1036,22 @@ void UDS_Service_10_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
Service10DiagDataLength = A_Length;
S3_ServerCnt = 0;
//???????????????13??????
//数据长度异常,返回13负反馈
if ( Service10DiagDataLength != 1 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0???????22??????
//???????
//供电电压异常,车速大于0,返回会22负反馈
//获取数据
for ( i = 0; i < Service10DiagDataLength; i++ )
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
//?????????????
//判断子服务是否支持
switch(UDS_ISO14229_Transfer[0]){
case 0x81 :
case 0x01 :
......@@ -1031,10 +1061,11 @@ void UDS_Service_10_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
S3_ServerCnt = 50;
SeedkeyValidFlag = 0;
DiagLockFlag = NormalKeyLock;
//????????
//切换到默认会话
SessionType = DefaultSession;
}
//10 01????????? 10 81???????????
//10 01需要正反馈 10 81不需要正反馈
if ( UDS_ISO14229_Transfer[0] == 0x01 )
{
UDS_Service_Response ( 0x10, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer );;
......@@ -1042,7 +1073,8 @@ void UDS_Service_10_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
break;
case 0x02 :
//????????????7E??????
//会话不支持,返回7E负反馈
if( DefaultSession ==SessionType ){
if(FunorPhy == DIAG_ID_Rx_FUN )
return ;
......@@ -1057,50 +1089,54 @@ void UDS_Service_10_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
for(i = 0; i < 30000; ++i){
nop();
}
WRITE_BZ_inDFLAH2Sector ( 0x3AA3 ); //????????
WRITE_BZ_inDFLAH2Sector ( 0x3AA3 ); //进入编程模式
}else {
WRITE_BZ_inDFLAH2Sector ( 0x8AA8 ); //????????
WRITE_BZ_inDFLAH2Sector ( 0x8AA8 ); //进入编程模式
}
COPCTL = 0x01; //enable watchdog
ARMCOP = 0x00;
//?????????????
//相同会话不进行操作
break;
case 0x83 :
case 0x03 :
//?????????????
//相同会话不进行操作
if( ExtendedDiagnosticSession !=SessionType )
{
//???????????????
//重置扩展会话的定时器
S3_Server_refresh = 1;
S3_ServerEN = 1;
S3_ServerCnt = 0;
SeedkeyValidFlag = 0;
// DiagLockFlag = NormalKeyLock;
//?????????
//切换到扩展会话
SessionType = ExtendedDiagnosticSession;
}
DiagLockFlag = NormalKeyLock; //???????
DiagLockFlag = NormalKeyLock; //重新进入
//10 03????????? 10 83???????????
//10 03需要正反馈 10 83不需要正反馈
if ( UDS_ISO14229_Transfer[0] == 0x03 )
{
UDS_Service_Response ( 0x10, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer );
}
break;
default ://??????????????12??????
if(FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = subFunctionNotSupported; //????sub Function ?????
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
break;
default ://子功能不支持,返回12负反馈
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = subFunctionNotSupported; //返回sub Function 不支持
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
break;
}
}
/*void CalculateKey ( uint32_t Seed ) //????seed?????key? ???????Level1 ?? Level4 ???
/*void CalculateKey ( uint32_t Seed ) //根据seed计算得出key值 分别计算出Level1 和 Level4 的值
{
uint8_t i;
uint8_t xorArray[4] = {0x74, 0xF7, 0x15, 0x17 };
......@@ -1198,9 +1234,7 @@ void CalculateKey(uint32_t Seed,const uint32_t mask)
SeedkeyValidFlag = 1;
}
//???????
//安全访问
void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
//uint16_t i;
......@@ -1214,41 +1248,47 @@ void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
uint32_t Diag_Id = 0;
Diag_Id = A_TA_type;;
//??????????
//不支持功能寻址
if ( Diag_Id == DIAG_ID_Rx_FUN )
return;
//?????????????????0??????22??????
//供电电压异常,车速大于0,返回22负反馈
//?????????,????7F??????
if ( SessionType == DefaultSession )
//不支持默认会话,返回7F负反馈
if ( SessionType == DefaultSession )
{
NegRes.code = serviceNotSupportedInActiveSession; //?????????
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
S3_ServerCnt = 0;
//??????????
//获取数据长度
Service27DiagDataLength = A_Length;
//???????
//获取数据
(void) memcpy(UDS_ISO14229_Transfer,A_Data,Service27DiagDataLength);
//27???????????1
(void) memcpy(UDS_ISO14229_Transfer, A_Data, Service27DiagDataLength);
//27??????§3?????1
if(Service27DiagDataLength < 1)
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//??????27 01??27 02?????????????12??????
//不支持除27 01和27 02以外的子服务,返回12负反馈
if ( ( UDS_ISO14229_Transfer[0] != 0x01 ) && ( UDS_ISO14229_Transfer[0] != 0x02 ) && ( UDS_ISO14229_Transfer[0] != 0x05 ) && ( UDS_ISO14229_Transfer[0] != 0x06 ))
{
NegRes.code = subFunctionNotSupported;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//??????27 01??27 02?????????????12??????
if ( (( UDS_ISO14229_Transfer[0] == 0x01 ) || ( UDS_ISO14229_Transfer[0] == 0x02 )) && (SessionType != ExtendedDiagnosticSession))
//不支持除27 01和27 02以外的子服务,返回12负反馈
if ((( UDS_ISO14229_Transfer[0] == 0x01 ) || ( UDS_ISO14229_Transfer[0] == 0x02 )) && (SessionType != ExtendedDiagnosticSession))
{
NegRes.code = subfunctionNotSupportinActiveSession;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
......@@ -1262,29 +1302,32 @@ void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
return;
}
//???????????
//判断子服务类型
switch ( UDS_ISO14229_Transfer[0] )
{
case 0x01:
//???????????????13??????
//数据长度异常,返回13负反馈
if ( Service27DiagDataLength != 1 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//????10s??????
if(Wait10sFlag==1)
{ //????????????3??????????4?????????????????????????? ??????10?? ?????????????
NegRes.code=requiredTimeDelayNotExpired;//???10???????
UDS_Service_Response(0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
//判断等待10s是否完成
if (Wait10sFlag == 1)
{ //超过最大尝试次数3次,或者连续4次发送请求种子而没有发送正确的秘钥 需要等待10秒 才可以进行一次尝试
NegRes.code = requiredTimeDelayNotExpired;//延时10秒时间未达到
UDS_Service_Response(0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
return;
}
//????????1
//请求标志位置1
Services27_01_Requested = 1;
//????????????????????????
if ( DiagLockFlag == Level1UnLock|| DiagLockFlag == Level2UnLock )
//如果安全服务已解锁则不发送种子
if ( DiagLockFlag == Level1UnLock|| DiagLockFlag == Level2UnLock )
{
UDS_ISO14229_Transfer[0] = 0x01;
UDS_ISO14229_Transfer[1] = 0; //S1
......@@ -1294,20 +1337,24 @@ void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}
else
{
//???????+1
//??27????????flash
//?????????????????????36??????
if ( diag27.RequestSeedCnt >= 2 ) //???????????????10??
{
//???????????
//请求次数+1
//将27服务状态写入flash
//错误密钥达到最大次数,返回36负反馈
if ( diag27.RequestSeedCnt >= 2 ) //错误超过二次,需要等待10秒
{
//将请求标志位清空
Services27_01_Requested = 0;
Wait10sFlag = 1; //10????????
wait10cnt = 0; //10??????????
NegRes.code = requiredTimeDelayNotExpired; //??????
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
Wait10sFlag = 1; //10秒计时器打开
wait10cnt = 0; //10秒计时器重置
NegRes.code = requiredTimeDelayNotExpired; //最大次数
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//???????????????????????????
//如果当前种子无效,则生成一个种子
if ( SeedkeyValidFlag == 0 )
{
tempbuffer = ( uint16_t ) ( RANDOM );
......@@ -1316,86 +1363,92 @@ void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
SeedkeyValidFlag = 1;
}
UDS_ISO14229_Transfer[0] = 0x01;
UDS_ISO14229_Transfer[1] = 0x31 + ~SeedHigh; //S1
UDS_ISO14229_Transfer[2] = 0x23 + ~SeedLow; //S2
UDS_ISO14229_Transfer[3] = 0x56 + SeedHigh; //S3
UDS_ISO14229_Transfer[4] = 0x71 + SeedHigh; //S4
(void) memcpy(DigKeyValue.Msg, UDS_ISO14229_Transfer+1,4);
//??????????????????????????
CalculateKey ( DigKeyValue.Value,MASK1_Safe );
UDS_ISO14229_Transfer[0] = 0x01;
UDS_ISO14229_Transfer[1] = 0x31 + ~SeedHigh; //S1
UDS_ISO14229_Transfer[2] = 0x23 + ~SeedLow; //S2
UDS_ISO14229_Transfer[3] = 0x56 + SeedHigh; //S3
UDS_ISO14229_Transfer[4] = 0x71 + SeedHigh; //S4
(void)memcpy(DigKeyValue.Msg, UDS_ISO14229_Transfer + 1, 4);
//根据种子计算密钥,为解锁做准备
CalculateKey ( DigKeyValue.Value,MASK1_Safe );
}
UDS_Service_Response ( 0x27, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer );
break;
case 0x02:
//???????????????13??????
if ( Service27DiagDataLength != 5 )
//数据长度不对,返回13负反馈
if ( Service27DiagDataLength != 5 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????24??????
if ( Services27_01_Requested != 1 )
//请求序列错误,返回24负反馈
if ( Services27_01_Requested != 1 )
{
NegRes.code = requestSequenceError; //??????
NegRes.code = requestSequenceError; //序列不对
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
(void)memcpy(DigKeyValue.Msg, UDS_ISO14229_Transfer + 1, 4);
//???????????
//将请求标志位清空
Services27_01_Requested = 0;
if(DiagLockFlag == Level1UnLock){
if(DigKeyValue.Value == 0x00000000){
//???level 1???????
//清空level 1尝试次数
diag27.attemptcnt = 0;
//???level 1???????????
//清空level 1请求种子次数
diag27.RequestSeedCnt = 0;
UDS_Service_Response ( 0x27, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer );
}else{
//?????
//种子失效
SeedkeyValidFlag = 0;
//????????
//重新上锁
DiagLockFlag = 0;
//level 1???????+1
//level 1尝试次数+1
diag27.attemptcnt = diag27.RequestSeedCnt;
diag27.RequestSeedCnt++;
//??27????????flash
//将27服务状态写入flash
Write_27_DATA_TO_FLASH();
//????????????څ???????10s??????????????1??????36??????
if ( diag27.attemptcnt >= 1 )
//尝试次数超过设定值,开启10s定时器尝试次数减1,返回36负反馈
if ( diag27.attemptcnt >= 1 )
{
Wait10sFlag = 1; //10????????
Wait10sFlag = 1; //10秒计时器打开
wait10cnt = 0;
NegRes.code = exceedNumberOfAttempts; //??????
NegRes.code = exceedNumberOfAttempts; //最大次数
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//???????????35??????
NegRes.code = invalidKey;
//无效密钥,返回35负反馈
NegRes.code = invalidKey;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
}
}else{
//???????????????????????????????????????
//如果种子有效并且获取的密钥和计算的一致则解锁安全模式
// if ( ( DigKeyValue.Value == ValidSeedKey1 ) && ( SeedkeyValidFlag == 1 ) )
if ( ( DigKeyValue.Value == ValidSeedKey1 ) && ( SeedkeyValidFlag == 1 ))
{
//?????????? 0
//安全服务解锁 0
DiagLockFlag = Level1UnLock;
//???level 1???????
//清空level 1尝试次数
diag27.attemptcnt = 0;
//???level 1???????????
//清空level 1请求种子次数
diag27.RequestSeedCnt = 0;
//SeedkeyValidFlag = 1;
UDS_ISO14229_Transfer[0] = 0x02;
UDS_Service_Response ( 0x27, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer );
//??27????????flash
//将27服务状态写入flash
Write_27_DATA_TO_FLASH();
}
else
......@@ -1406,31 +1459,34 @@ void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
return;
#endif
//?????
//种子失效
SeedkeyValidFlag = 0;
//level 1???????+1
//level 1尝试次数+1
diag27.attemptcnt = diag27.RequestSeedCnt;
diag27.RequestSeedCnt++;
//??27????????flash
//将27服务状态写入flash
Write_27_DATA_TO_FLASH();
//????????????څ???????10s??????????????1??????36??????
if ( diag27.attemptcnt >= 1 )
//尝试次数超过设定值,开启10s定时器尝试次数减1,返回36负反馈
if ( diag27.attemptcnt >= 1 )
{
Wait10sFlag = 1; //10????????
Wait10sFlag = 1; //10秒计时器打开
wait10cnt = 0;
NegRes.code = exceedNumberOfAttempts; //??????
NegRes.code = exceedNumberOfAttempts; //最大次数
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//???????????35??????
NegRes.code = invalidKey;
//无效密钥,返回35负反馈
NegRes.code = invalidKey;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
}
break;
//?????????,????12??????
//子功能不支持,返回12负反馈
default:
NegRes.code = subFunctionNotSupported;
UDS_Service_Response ( 0x27, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
......@@ -1441,15 +1497,15 @@ void UDS_Service_27_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
extern uint8_t BLPWMDutyCycle;
extern uint8_t GUIIconDRLGStatus;
/*************************************************************************************
???????????;
1?????????????????????????????
2??????????????????????????????
3???????????????????????????????
4??????????????????????????
***************************************************************************************/
诊断服务执行步骤;
1、获取数据长度,判断数据长度是否有误
2、获取目标地址类型,判断功能寻址和物理寻址
3、根据长度获取数据。判断数据是否符合要求
4、根据数据判断子服务是否符合要求
*************************************************************************************/
extern INT32U BD83790A;
//DID???????
//DID读取服务
void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
......@@ -1467,24 +1523,25 @@ void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
S3_ServerCnt = 0;
Service22DiagDataLength = A_Length;
//???????????????13??????
if ( Service22DiagDataLength != 2 )
//数据长度异常,发挥13负反馈
if ( Service22DiagDataLength != 2 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x22, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0??????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x22, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
NegRes.code = 0;
//???????
//获取数据
for ( i = 0; i < Service22DiagDataLength; i++ )
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
......@@ -1577,7 +1634,7 @@ void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_ISO14229_Transfer[11] = 28;
UDS_Service_Response ( 0x22, POSITIVE_RSP, DIAG_ID_Tx, 12, UDS_ISO14229_Transfer );
break;
//????????????????????
//?????д??????豸?????
case 0xF184:
//memcpy(UDS_ISO14229_Transfer+2,NVMConfigF184.Data,sizeof(NVMConfigF184.Data));
memcpy(UDS_ISO14229_Transfer+2,DiagBootData.D_F184,sizeof(DiagBootData.D_F184));
......@@ -1602,7 +1659,7 @@ void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_ISO14229_Transfer[ 4] = Value;
UDS_Service_Response ( 0x22, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer );
break;
//???????
//С?????
case 0x3202:
Value = DATA_TRIPA / 10;
UDS_ISO14229_Transfer[ 2] = Value >> 16;
......@@ -1610,7 +1667,7 @@ void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_ISO14229_Transfer[ 4] = Value;
UDS_Service_Response ( 0x22, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer );
break;
//????????
//????λ??
case 0x3203:
if(TelltaleLCDFlag.Sig.LCD23 == 0)
{
......@@ -1648,7 +1705,7 @@ void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_ISO14229_Transfer[ 2] = Value;
UDS_Service_Response ( 0x22, POSITIVE_RSP, DIAG_ID_Tx, 3, UDS_ISO14229_Transfer );
break;
//?????????
//?????λ??
case 0x3207:
if(BD83790A & BD8379_D9)
{
......@@ -1662,18 +1719,15 @@ void UDS_Service_22_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
default:
if(Diag_Id == DIAG_ID_Rx_FUN )
return ;
NegRes.code = requestOutOfRange; //????31??????
NegRes.code = requestOutOfRange; //返回31负反馈
UDS_Service_Response ( 0x22, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
break;
}
}
//??????
//通讯控制
void UDS_Service_28_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
......@@ -1682,8 +1736,9 @@ void UDS_Service_28_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
FunorPhy = A_TA_type;
S3_ServerCnt = 0;
//???????????????7F??????
if ( SessionType != ExtendedDiagnosticSession )
//只支持扩展会话,返回7F负反馈
if ( SessionType != ExtendedDiagnosticSession )
{
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
......@@ -1693,132 +1748,138 @@ void UDS_Service_28_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}
Service28DiagDataLength = A_Length;
//???????????????13??????
if ( Service28DiagDataLength != 2 )
//数据长度异常,返回13负反馈
if ( Service28DiagDataLength != 2 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0???????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回会22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
//???????
for ( i = 0; i < Service28DiagDataLength; i++ ) //???????? ???????
//获取数据
for ( i = 0; i < Service28DiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
//????0x03????
switch(UDS_ISO14229_Transfer[0])
switch (UDS_ISO14229_Transfer[0])
{
//??????
case 0x80:
case enableRxAndTx:
// CommunicationType=UDS_ISO14229_Transfer[0];
// ControlType=enableRxAndTx;
//??????????????22??????
/* if ( EngineSpeed >= 400 )
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
} */
//??????????
#if 0
if( 1 == UDS_ISO14229_Transfer[1])
{
Com_RxStart();
Com_TxStart();
}
//???????????????
else if (2 == UDS_ISO14229_Transfer[1])
{
CANNetRxOFF = 0;
CANNetTxOFF = 0;
}
//??????????????????????????
else
#endif
if( 3 == UDS_ISO14229_Transfer[1] )
{
Com_RxStart();
Com_TxStart();
CANNetRxOFF = 0;
CANNetTxOFF = 0;
}
//?????????????31??????
else
{
if(FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = requestOutOfRange ;
UDS_Service_Response(0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ));
break;
}
if(bit_is_clear(UDS_ISO14229_Transfer[0],7))
UDS_Service_Response(0x28, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
break;
//??????
case 0x83:
case disableRxAndTx:
//CommunicationType=UDS_ISO14229_Transfer[0];
//ControlType=disableRxAndEnableTx;
//??????????
#if 0
if( 1 == UDS_ISO14229_Transfer[1])
{
Com_TxStop();
Com_RxStop();
}
//???????????????
else if (2 == UDS_ISO14229_Transfer[1])
{
CANNetRxOFF = 1;
CANNetTxOFF = 1;
}
//??????????????????????????
else
#endif
if( 3 == UDS_ISO14229_Transfer[1] )
{
Com_TxStop();
Com_RxStop();
CANNetRxOFF = 1;
CANNetTxOFF = 1;
}
//?????????????31??????
else
{
if(FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = requestOutOfRange ;
UDS_Service_Response(0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ));
break;
}
if(bit_is_clear(UDS_ISO14229_Transfer[0],7))
UDS_Service_Response(0x28, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
//使能收发
case 0x80:
case enableRxAndTx:
// CommunicationType = UDS_ISO14229_Transfer[0];
// ControlType = enableRxAndTx;
//发动机运行,返回22负反馈
/* if ( EngineSpeed >= 400 )
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
} */
//所有应用报文
#if 0
if (1 == UDS_ISO14229_Transfer[1])
{
Com_RxStart();
Com_TxStart();
}
//所有网络管理报文
break;
//??????????????12??????
default:
if(FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code=subFunctionNotSupported;
UDS_Service_Response(0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
break;
else if (2 == UDS_ISO14229_Transfer[1])
{
CANNetRxOFF = 0;
CANNetTxOFF = 0;
}
//所有应用报文和所有网络管理报文
else
#endif
if (3 == UDS_ISO14229_Transfer[1])
{
Com_RxStart();
Com_TxStart();
CANNetRxOFF = 0;
CANNetTxOFF = 0;
}
//请求超出范围,返回31负反馈
else
{
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = requestOutOfRange ;
UDS_Service_Response(0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ));
break;
}
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
UDS_Service_Response(0x28, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
break;
//禁止收发
case 0x83:
case disableRxAndTx:
//CommunicationType = UDS_ISO14229_Transfer[0];
//ControlType = disableRxAndEnableTx;
//所有应用报文
#if 0
if ( 1 == UDS_ISO14229_Transfer[1])
{
Com_TxStop();
Com_RxStop();
}
//所有网络管理报文
else if (2 == UDS_ISO14229_Transfer[1])
{
CANNetRxOFF = 1;
CANNetTxOFF = 1;
}
//所有应用报文和所有网络管理报文
else
#endif
if (3 == UDS_ISO14229_Transfer[1])
{
Com_TxStop();
Com_RxStop();
CANNetRxOFF = 1;
CANNetTxOFF = 1;
}
//请求超出范围,返回31负反馈
else
{
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = requestOutOfRange ;
UDS_Service_Response(0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ));
break;
}
if (bit_is_clear(UDS_ISO14229_Transfer[0], 7))
UDS_Service_Response(0x28, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer);
break;
//子功能不支持,返回12负反馈
default:
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = subFunctionNotSupported;
UDS_Service_Response(0x28, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
break;
}
}
//DTC???????
//DTC记录控制
void UDS_Service_85_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
......@@ -1827,8 +1888,9 @@ void UDS_Service_85_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
FunorPhy = A_TA_type;
S3_ServerCnt = 0;
//???????????????7F??????
if ( SessionType == DefaultSession )
//只支持扩展会话,返回7F负反馈
if ( SessionType == DefaultSession )
{
if (FunorPhy == DIAG_ID_Rx_FUN )
return;
......@@ -1836,33 +1898,35 @@ void UDS_Service_85_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_Service_Response ( 0x85, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//??????????
//获取数据长度
Service85DiagDataLength = A_Length;
//???????????????13??????
if ( Service85DiagDataLength != 1 )
//数据长度异常,返回13负反馈
if ( Service85DiagDataLength != 1 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x85, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0???????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回会22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x85, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
//???????
for ( i = 0; i < Service85DiagDataLength; i++ ) //???????? ???????
//获取数据
for ( i = 0; i < Service85DiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
//???????
//子服务判断
switch ( UDS_ISO14229_Transfer[0] )
{ //01 01 ????DTC????
{ //01 01 开启DTC设置
case 0x81:
case DTCSettingOn:
DTCControlType = DTCSettingOn;
......@@ -1872,7 +1936,7 @@ void UDS_Service_85_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_Service_Response ( 0x85, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer );
break;
//02 02 ???DTC????
//02 02 关闭DTC设置
case 0x82:
case DTCSettingOff:
DTCControlType = DTCSettingOff;
......@@ -1883,8 +1947,9 @@ void UDS_Service_85_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
break;
default ://??????????????12??????
if(FunorPhy == DIAG_ID_Rx_FUN )
default ://子功能不支持,返回12负反馈
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = subFunctionNotSupported;
UDS_Service_Response ( 0x85, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
......@@ -1892,7 +1957,7 @@ void UDS_Service_85_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}
}
//???????
//例程控制
void UDS_Service_31_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint8_t Service31DiagDataLength;
......@@ -1904,10 +1969,10 @@ void UDS_Service_31_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
//uint32_t SectorAddress;
FunOrPhy = A_TA_type;
S3_ServerCnt = 0;
//??????????
//只支持物理寻址
if ( DIAG_ID_Rx_FUN == FunOrPhy )
return;
//?????????????????0??????22??????
//供电电压异常,车速大于0,返回22负反馈
//if ( EngineSpeed >= 400 )
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
......@@ -1926,20 +1991,21 @@ void UDS_Service_31_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
//?????????????????33??????
if ( DiagLockFlag == NormalKeyLock )
{
NegRes.code = securityAccessDenied; //?????????
NegRes.code = securityAccessDenied; //安全模式未解锁
UDS_Service_Response ( 0x31, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//??????????
//获取数据长度
Service31DiagDataLength = A_Length;
//???????????????13??????
if ( Service31DiagDataLength != 3 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x31, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//???????
//获取数据
for ( i = 0; i < Service31DiagDataLength; i++ )
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
......@@ -1972,7 +2038,7 @@ void UDS_Service_31_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
//???????????
//请求下载服务
void UDS_Service_34_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
......@@ -1986,17 +2052,20 @@ void UDS_Service_34_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if ( FunOrPhy == DIAG_ID_Rx_FUN )
return;
if ( SessionType != ProgrammingSession ) //?????????
{
NegRes.code = serviceNotSupportedInActiveSession; //?????????
UDS_Service_Response ( 0x34, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
if ( SessionType != ProgrammingSession ) //只支持编程会话模式
{
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持
UDS_Service_Response ( 0x34, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
if ( DiagLockFlag == BootKeyLock )
{
NegRes.code = securityAccessDenied; //?????????
UDS_Service_Response ( 0x34, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
NegRes.code = securityAccessDenied; //安全模式未解锁
UDS_Service_Response ( 0x34, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -2004,25 +2073,26 @@ void UDS_Service_34_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if ( Service34DiagDataLength != 10 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x34, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0???????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回会22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
for ( i = 0; i < Service34DiagDataLength; i++ ) //???????? ???????
for ( i = 0; i < Service34DiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
if ( ( UDS_ISO14229_Transfer[0] != 0 ) || ( UDS_ISO14229_Transfer[1] != 0x44 ) )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x34, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -2033,7 +2103,7 @@ void UDS_Service_34_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_Service_Response ( 0x34, POSITIVE_RSP, DIAG_ID_Tx, 3, UDS_ISO14229_Transfer );
}
//???????????
//数据下载服务
void UDS_Service_36_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
uint16_t i;
......@@ -2048,21 +2118,22 @@ void UDS_Service_36_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if ( FunOrPhy == DIAG_ID_Rx_FUN )
return;
if ( SessionType != ProgrammingSession ) //?????????
if ( SessionType != ProgrammingSession ) //只支持编程会话模式
{
NegRes.code = serviceNotSupportedInActiveSession; //????????? 7F
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持 7F
UDS_Service_Response ( 0x36, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
if ( DiagLockFlag == BootKeyLock )
{
NegRes.code = securityAccessDenied; //????????? 33
NegRes.code = securityAccessDenied; //安全模式未解锁 33
UDS_Service_Response ( 0x36, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0???????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回会22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
......@@ -2070,7 +2141,7 @@ void UDS_Service_36_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}*/
Service36DiagDataLength = A_Length;
for ( i = 0; i < Service36DiagDataLength; i++ ) //?????
for ( i = 0; i < Service36DiagDataLength; i++ ) //取数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
......@@ -2079,7 +2150,7 @@ void UDS_Service_36_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if ( UDS_ISO14229_Transfer[0] != BlocKCnt )
{
NegRes.code = wrongBlockSequenceCounter; //?????????? 73
NegRes.code = wrongBlockSequenceCounter; //请求序列错误 73
UDS_Service_Response ( 0x36, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -2092,7 +2163,7 @@ void UDS_Service_36_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_Service_Response ( 0x36, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer );
}
//???????????
//请求下载服务
void UDS_Service_37_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
//uint16_t i;
......@@ -2106,14 +2177,15 @@ void UDS_Service_37_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
S3_ServerCnt = 0;
if ( SessionType != ProgrammingSession ) //?????????
if ( SessionType != ProgrammingSession ) //只支持编程会话模式
{
NegRes.code = serviceNotSupportedInActiveSession; //????????? 7F
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持 7F
UDS_Service_Response ( 0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//?????????????????0???????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回会22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x10, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
......@@ -2121,26 +2193,26 @@ void UDS_Service_37_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}*/
//if(RequestTransfer!=Download)
//{
// NegRes.code=requestSequenceError;//?????????
// UDS_Service_Response(0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
// return;
// NegRes.code=requestSequenceError; //会话模式不支持
// UDS_Service_Response(0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
// return;
//}
//Service37DiagDataLength = A_Length;
//if (Service37DiagDataLength != 1)
//{
// NegRes.code=incorrectMessageLength;//??????????
// UDS_Service_Response(0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
// return;
// NegRes.code = incorrectMessageLength; //数据长度不对
// UDS_Service_Response(0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
// return;
//}
//for(i=0; i<Service37DiagDataLength; i++) //???????? ???????
//for (i=0; i<Service37DiagDataLength; i++) //长度不固定 要收数据
//{
// UDS_ISO14229_Transfer[i] = *(A_Data + i);
//}
//if (UDS_ISO14229_Transfer[0] != 00)
//{
// NegRes.code=subFunctionNotSupported;//??????????
// UDS_Service_Response(0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
// return;
// NegRes.code = subFunctionNotSupported; //数据长度不对
// UDS_Service_Response(0x37, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t *)(&NegRes.code));
// return;
//}
//UDS_ISO14229_Transfer[0] = 0x00;
UDS_Service_Response ( 0x37, POSITIVE_RSP, DIAG_ID_Tx, 0, UDS_ISO14229_Transfer );
......@@ -2154,24 +2226,27 @@ void UDS_Service_3E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
FunorPhy = A_TA_type;
Service3EDiagDataLength = A_Length;
S3_ServerCnt = 0;
//???????????????13??????
if ( Service3EDiagDataLength != 1 )
//数据长度不对,返回13负反馈
if ( Service3EDiagDataLength != 1 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x3E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//???????????
for ( i = 0; i < Service3EDiagDataLength; i++ ) //???????? ???????
//获取子服务信息
for ( i = 0; i < Service3EDiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
//???????00??80???????12???????????
//子服务不是00和80的,返回12负反馈不支持
if ( ( UDS_ISO14229_Transfer[0] != 0 ) && ( UDS_ISO14229_Transfer[0] != 0x80 ) )
//if ( UDS_ISO14229_Transfer[0] != 0 )
{
//??????????
if(FunorPhy == DIAG_ID_Rx_FUN )
//吉利要求不响应
if (FunorPhy == DIAG_ID_Rx_FUN )
return ;
NegRes.code = subFunctionNotSupported;
UDS_Service_Response ( 0x3E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
......@@ -2179,7 +2254,7 @@ void UDS_Service_3E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}
S3_Server_refresh = 1;
//3E 00??????????3E 80?????????
//3E 00有正反馈,3E 80没有正反馈
if ( UDS_ISO14229_Transfer[0] == 0x00 )
{
UDS_Service_Response ( 0x3E, POSITIVE_RSP, DIAG_ID_Tx, 1, UDS_ISO14229_Transfer );
......@@ -2195,39 +2270,44 @@ void UDS_Service_11_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
FunorPhy = A_TA_type;
S3_ServerCnt = 0;
Service11DiagDataLength = A_Length;
//?????????????????0??????22??????
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
//供电电压异常,车速大于0,返回22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x11, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
//???????????????7F??????
//不支持默认会话,返回7F负反馈
/*
if ( ( SessionType == DefaultSession ) )
{
NegRes.code = serviceNotSupportedInActiveSession; //?????????
UDS_Service_Response ( 0x11, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持
UDS_Service_Response ( 0x11, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
*/
//???????????????13??????
if ( Service11DiagDataLength != 1 )
//数据长度异常,返回13负反馈
if ( Service11DiagDataLength != 1 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x11, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//????????
for ( i = 0; i < Service11DiagDataLength; i++ ) //???????? ???????
//获取子功能
for ( i = 0; i < Service11DiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
//1.6????????11 02??11 82????
// if ( ( UDS_ISO14229_Transfer[0] == 0x01 ) || ( UDS_ISO14229_Transfer[0] == 0x03 ) || ( UDS_ISO14229_Transfer[0] == 0x81 ) || ( UDS_ISO14229_Transfer[0] == 0x83 ))
if(( UDS_ISO14229_Transfer[0] == 0x01 )|| ( UDS_ISO14229_Transfer[0] == 0x81 )) //?????01?????
{
//????????????
//1.6版本不用支持11 02和11 82服务
//if ( ( UDS_ISO14229_Transfer[0] == 0x01 ) || ( UDS_ISO14229_Transfer[0] == 0x03 ) || ( UDS_ISO14229_Transfer[0] == 0x81 ) || ( UDS_ISO14229_Transfer[0] == 0x83 ))
if (( UDS_ISO14229_Transfer[0] == 0x01 ) || ( UDS_ISO14229_Transfer[0] == 0x81 )) //仅支持01子功能
{
//将会话类型重置
SessionType = 1;
if( UDS_ISO14229_Transfer[0] == 0x01 ){
......@@ -2246,17 +2326,17 @@ void UDS_Service_11_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
//return;
}
else//??????????????12??????
else //子功能不支持,返回12负反馈
{
if ( FunorPhy == DIAG_ID_Rx_FUN )
return;
NegRes.code = subFunctionNotSupported; //?????????
NegRes.code = subFunctionNotSupported; //子功能不支持
UDS_Service_Response ( 0x11, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
}
//????????
//故障码存储列表
const uint32_t DTC_CODE_TABLE[] =
{
......@@ -2269,7 +2349,7 @@ const uint32_t DTC_CODE_TABLE[] =
U010087,
};
//=================================================
//??????????3??????DTC??
//根据序号输出3个字节的DTC码
//=================================================
void GJXHOUTDTCCODE ( INT8U xh )
{
......@@ -2283,7 +2363,7 @@ void GJXHOUTDTCCODE ( INT8U xh )
}
//============================================
//???ACC??????DTC STATUS
//每次开ACC后初始化DTC STATUS
//============================================
void INIT_DTC_STATUS_IGN_ON ( void )
{
......@@ -2303,7 +2383,7 @@ void INIT_DTC_STATUS_IGN_ON ( void )
DiagLockFlag = 0;
ContrlorResumeofIO = 0; //IO????
ContrlorResumeofIO = 0; //IO控制
IO_Group_1 = 0;
......@@ -2322,11 +2402,11 @@ void INIT_DTC_STATUS_IGN_ON ( void )
CANNetTxOFF = 0;
//for ( i = 0; i < cnDTCslen; i++ )
// DTC_STATUS[i] = DTC_STATUS[i] | 0x50; //??4,6 BIT??1
// DTC_STATUS[i] = DTC_STATUS[i] | 0x50; //第4,6 BIT置1
}
//===========================================================
//???DTC?????
//????:DTCstatusCHGFF=1???DTC??????(??????EEPROM??)
//修改DTC状态记录
//出口:DTCstatusCHGFF=1表示DTC记录有改变(需要存储到EEPROM中)
//===========================================================
void ChangeDTCs_ST_PRG ( INT8U pos, INT8U status )
......@@ -2385,14 +2465,14 @@ void ChangeDTCs_ST_PRG ( INT8U pos, INT8U status )
}
//========================================
//???DTC???????????EEPROM?? 100ms
//如果DTC记录有改变则存入EEPROM中 100ms
//========================================
void SaveDTCsToEEPROM ( void )
{
uint8_t i;
if ( isNeedSaveDTC ) //DTC?????????,YES
if ( isNeedSaveDTC ) //DTC????и???,YES
{
isNeedSaveDTC = 0;
......@@ -2405,7 +2485,7 @@ void SaveDTCsToEEPROM ( void )
//=========================================
//+++++++++100MS+++++++++++
//
//CAN????NORMAL??2S???
//CAN进入NORMAL状态2S计时
//=========================================
void CAN_NORMAL_TIME_PRG ( void )
{
......@@ -2413,11 +2493,11 @@ void CAN_NORMAL_TIME_PRG ( void )
{
CAN_NORMAL_TT++;
if ( CAN_NORMAL_TT == 50 ) // 2S?,YES //??ACC 6S
if ( CAN_NORMAL_TT == 50 ) // 2S?,YES //ACC 6S
{
CAN_NORMAL_TT = 0;
CAN_NORMAL_2SFF = 1; // =1???CAN????NORMAL????2S
CAN_NORMAL_2SFF = 1; // =1表示CAN进入NORMAL超过2S
}
}
}
......@@ -2575,7 +2655,7 @@ void CanLoseDetected ( void )
{
if( CAN_DTC_OFF == 0 )
{
//???????
//????ж?
if(getKL15Status())
{
......@@ -2820,35 +2900,34 @@ void UDS_Service_19_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
Service19DiagDataLength = A_Length;
__RESET_WATCHDOG();
S3_ServerCnt = 0;
//??????????????7F??????
//不支持编程会话,返回7F负反馈
if ( SessionType == ProgrammingSession )
{
NegRes.code = serviceNotSupportedInActiveSession;
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//????????????13??????
//长度异常,返回13负反馈
if ( Service19DiagDataLength < 1 )
{
NegRes.code = incorrectMessageLength;
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//???????
//获取数据
for ( i = 0; i < Service19DiagDataLength; i++ )
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
//????????
//执行子服务
switch ( UDS_ISO14229_Transfer[0] )
{
//???????????DTC????
//通过状态掩码报告DTC的数
case 0x01:
//???????????????13??????
//数据长度异常,返回13负反馈
if ( Service19DiagDataLength != 2 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -2868,24 +2947,24 @@ void UDS_Service_19_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_ISO14229_Transfer[4] = ( INT8U ) ( DTCnum & 0x00FF );
UDS_Service_Response ( 0x19, POSITIVE_RSP, DIAG_ID_Tx, 5, UDS_ISO14229_Transfer );
break;
//???????????DTC
//通过状态掩码报告DTC
case 0x02:
//???????????????13??????
//数据长度异常,返回13负反馈
if ( Service19DiagDataLength != 2 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
DTCSnapshotRecordNumber = UDS_ISO14229_Transfer[1];
DTCcnt = 2;
//????DTC?????????????????DTC??
//返回DTC码(高位、中位、低位)和和DTC状态
for ( i = 0; i < cnDTCslen; i++ )
{
if ( DiagDtc[ i ].Status.Flag & UDS_ISO14229_Transfer[1] )
{
GJXHOUTDTCCODE ( i ); //??????????3??????DTC??
GJXHOUTDTCCODE ( i ); //根据序号输出3个字节的DTC码
UDS_ISO14229_Transfer[DTCcnt] = CJINF[0];
DTCcnt++;
UDS_ISO14229_Transfer[DTCcnt] = CJINF[1];
......@@ -2900,12 +2979,77 @@ void UDS_Service_19_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_Service_Response ( 0x19, POSITIVE_RSP, DIAG_ID_Tx, DTCcnt, UDS_ISO14229_Transfer );
break;
//????????DTC */
//通过DTC报告Snapshot的记录
/* case 0x04:
//数据长度异常,返回13负反馈
if ( Service19DiagDataLength != 5 )
{
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
DTCMaskRecord = ( ( uint32_t ) UDS_ISO14229_Transfer[1] << 16 ) | ( ( uint32_t ) UDS_ISO14229_Transfer[2] << 8 ) | ( ( uint32_t ) UDS_ISO14229_Transfer[3] );
DTCSnapshotRecordNumber = UDS_ISO14229_Transfer[4];
if (( DTCSnapshotRecordNumber == 1 ) || ( DTCSnapshotRecordNumber == 0xff ) )
{
}
else
{
NegRes.code = requestOutOfRange; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
for ( i = 0; i < cnDTCslen; i++)
{
if ( DTCMaskRecord == DTC_CODE_TABLE[i] )
goto label_temp;
}
NegRes.code = requestOutOfRange; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
label_temp:
//已经找到了这请求的故障码了 开始回数
//UDS_ISO14229_Transfer[0] = 0x04;
//UDS_ISO14229_Transfer[1] = 0x04;
//UDS_ISO14229_Transfer[2] = 0x04;
//UDS_ISO14229_Transfer[3] = 0x04;
m_SnapshotData = *DTC_CODE_add_TABLE[i];//别问我为啥 c环境试出来的
UDS_ISO14229_Transfer[5] = UDS_ISO14229_Transfer[4]; //当前的故障码状态
UDS_ISO14229_Transfer[4] = DTC_STATUS[i]; //当前的故障码状态
UDS_ISO14229_Transfer[6] = 0x04;
//ICUPowerVoltage 1 byte
//ICUVspeed 2 byte
//OccurrenceCounter 1 byte
//TheOdometerOfLastMalfunction 3byte
UDS_ISO14229_Transfer[7] = 0xDF;
UDS_ISO14229_Transfer[8] = 0X00;
UDS_ISO14229_Transfer[9] = m_SnapshotData.Sig.ECUPowerVoltage;
UDS_ISO14229_Transfer[10] = 0xDF;
UDS_ISO14229_Transfer[11] = 0X01;
UDS_ISO14229_Transfer[12] = ( uint8_t ) ( m_SnapshotData.Sig.ICUVspeed >> 8 );
UDS_ISO14229_Transfer[13] = ( uint8_t ) ( m_SnapshotData.Sig.ICUVspeed );
UDS_ISO14229_Transfer[14] = 0xDF;
UDS_ISO14229_Transfer[15] = 0X02;
UDS_ISO14229_Transfer[16] = m_SnapshotData.Sig.OccurrenceCounter;;
UDS_ISO14229_Transfer[17] = 0xDF;
UDS_ISO14229_Transfer[18] = 0X04;
UDS_ISO14229_Transfer[19] = ( uint8_t ) ( m_SnapshotData.Sig.TheOdometerOfLastMalfunction >> 16 );
UDS_ISO14229_Transfer[20] = ( uint8_t ) ( m_SnapshotData.Sig.TheOdometerOfLastMalfunction >> 8 );
UDS_ISO14229_Transfer[21] = ( uint8_t ) ( m_SnapshotData.Sig.TheOdometerOfLastMalfunction );
if ( UDS_ISO14229_Transfer[0] == 0x04 )
UDS_Service_Response ( 0x19, POSITIVE_RSP, DIAG_ID_Tx, 22 , UDS_ISO14229_Transfer );
break;
//报告支持的DTC */
case 0x0A: //Only available if more than 1 DTC exist
//???????????????13??????
//数据长度异常,返回13负反馈
if ( Service19DiagDataLength != 1 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -2916,17 +3060,17 @@ void UDS_Service_19_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}
else
{
NegRes.code = requestOutOfRange; //??????????
NegRes.code = requestOutOfRange; //数据长度不对
UDS_Service_Response ( 0x19, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
*/
DTCcnt0A = 2;
//????DTC?????????????????DTC??
//返回DTC码(高位、中位、低位)和和DTC状态
for ( i = 0; i < cnDTCslen; i++ )
{
__RESET_WATCHDOG();
GJXHOUTDTCCODE ( i ); //??????????3??????DTC??
GJXHOUTDTCCODE ( i ); //根据序号输出3个字节的DTC码
UDS_ISO14229_Transfer[DTCcnt0A] = CJINF[0];
DTCcnt0A++;
UDS_ISO14229_Transfer[DTCcnt0A] = CJINF[1];
......@@ -2939,7 +3083,7 @@ void UDS_Service_19_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
UDS_ISO14229_Transfer[1] = 0x09;
UDS_Service_Response ( 0x19, POSITIVE_RSP, DIAG_ID_Tx, DTCcnt0A, UDS_ISO14229_Transfer );
break;
//??????????????12??????
//子功能不支持,返回12负反馈
default:
if(FunorPhy == DIAG_ID_Rx_FUN )
return ;
......@@ -2958,7 +3102,7 @@ void UDS_Service_19_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
void UDS_Service_2E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t *A_Data )
{
//???????? ???EEPROM
//每个写入之后 要写入到EEPROM
uint16_t i;
uint16_t DID;
uint8_t Service2EDiagDataLength;
......@@ -2969,43 +3113,41 @@ void UDS_Service_2E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if ( DiagIDNum == DIAG_ID_Rx_FUN )
return;
if ( SessionType == DefaultSession ) //?????????
if ( SessionType == DefaultSession ) //不支持默认会话
{
NegRes.code = serviceNotSupportedInActiveSession; //????????? 7F
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持 7F
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
for ( i = 0; i < Service2EDiagDataLength; i++ ) //???????? ???????
for ( i = 0; i < Service2EDiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
if ( Service2EDiagDataLength <= 2 )
{
NegRes.code = incorrectMessageLength; //?????????? 13
NegRes.code = incorrectMessageLength; //数据长度不对 13
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
DID = ( ( ( uint16_t ) ( UDS_ISO14229_Transfer[0] << 8 ) ) | ( ( uint16_t ) ( UDS_ISO14229_Transfer[1] ) ) );
switch ( DID ) //????????2?????????????????[2]???
switch ( DID ) //已经使用了2个数据长度,写入内容从[2]开始
{
case 0xF1A8:
if(DiagLockFlag!=Level1UnLock)
{
NegRes.code=securityAccessDenied;//???? 33
NegRes.code=securityAccessDenied;//未解锁 33
UDS_Service_Response(0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
return;
}
if ( Service2EDiagDataLength != 20 + 2 )
{
NegRes.code = incorrectMessageLength; //?????????? 13
NegRes.code = incorrectMessageLength; //数据长度不对 13
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -3021,10 +3163,10 @@ void UDS_Service_2E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
}
else
{
NegRes.code = requestOutOfRange; //???????? 0x31 ?????????
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
NegRes.code = requestOutOfRange; //数据不正确 0x31 数据超出范围
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
break;
......@@ -3032,14 +3174,14 @@ void UDS_Service_2E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if(DiagLockFlag!=Level1UnLock)
{
NegRes.code=securityAccessDenied;//????
NegRes.code=securityAccessDenied;//未解锁
UDS_Service_Response(0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
return;
}
if ( Service2EDiagDataLength != 17 + 2 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -3062,14 +3204,14 @@ void UDS_Service_2E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
if(DiagLockFlag!=Level1UnLock)
{
NegRes.code=securityAccessDenied;//???? 33
NegRes.code=securityAccessDenied;//未解锁 33
UDS_Service_Response(0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
return;
}
if ( Service2EDiagDataLength != 16 + 2 )
{
NegRes.code = incorrectMessageLength; //?????????? 13
NegRes.code = incorrectMessageLength; //数据长度不对 13
UDS_Service_Response ( 0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
......@@ -3080,7 +3222,7 @@ void UDS_Service_2E_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
case 0xF1FA:
if(DiagLockFlag!=Level1UnLock)
{
NegRes.code=securityAccessDenied;//?????? 33
NegRes.code=securityAccessDenied;//δ???? 33
UDS_Service_Response(0x2E, NEGATIVE_RSP, DIAG_ID_Tx, 1, (uint8_t*)(&NegRes.code));
return;
}
......@@ -3130,35 +3272,35 @@ void UDS_Service_14_Indication ( uint32_t A_TA_type, uint16_t A_Length, uint8_t
uint32_t ClearDTCGroup;
Service14DiagDataLength = A_Length;
S3_ServerCnt = 0;
//?????????????????0??????22??????
//供电电压异常,车速大于0,返回22负反馈
/*if (( HIGH_VOLTAGE )||( LOW_VOLTAGE )||(DATA_VEHICLE_SPEED_DISPLAYING>0))
{
NegRes.code = conditionsNotCorrect;
UDS_Service_Response ( 0x14, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
//???????????????13??????
//数据长度异常,返回13负反馈
if ( Service14DiagDataLength != 3 )
{
NegRes.code = incorrectMessageLength; //??????????
NegRes.code = incorrectMessageLength; //数据长度不对
UDS_Service_Response ( 0x14, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}
//??????????????7E??????
//不支持编程会话,返回7E负反馈
/*if ( SessionType == ProgrammingSession )
{
NegRes.code = serviceNotSupportedInActiveSession; //?????????
NegRes.code = serviceNotSupportedInActiveSession; //会话模式不支持
UDS_Service_Response ( 0x14, NEGATIVE_RSP, DIAG_ID_Tx, 1, ( uint8_t * ) ( &NegRes.code ) );
return;
}*/
//???????
for ( i = 0; i < Service14DiagDataLength; i++ ) //???????? ???????
//获取数据
for ( i = 0; i < Service14DiagDataLength; i++ ) //长度不固定 要收数据
{
UDS_ISO14229_Transfer[i] = * ( A_Data + i );
}
ClearDTCGroup = ( ( ( uint32_t ) UDS_ISO14229_Transfer[0] << 16 ) | ( ( uint32_t ) UDS_ISO14229_Transfer[1] << 8 ) | ( ( uint32_t ) UDS_ISO14229_Transfer[2] ) );
//??????????14 FF FF FF???????????
//如果接收的是14 FF FF FF,清除诊断信息
if ( ClearDTCGroup == 0xffffff )
{
//ClearAllDTC();
......@@ -3192,19 +3334,19 @@ void HandleOf2FServices ( void ) //lgh
{
ContrlorResumeofIOLast = Resume;
ContrlorResumeofIO = 0;
ContrlorResumeofSOC = 0; //soc????
SocSeg = 0; //Soc
ContrlorResumeofEspeed = 0; //??????
ESpeedValNUM = 0; //???
ContrlorResumeofVspeed = 0; //???????
VspeedValNUM = 0; //????
ContrlorResumeofLamp = 0;
//ISD_Stop_Loop();
IO_Group_1 = 0;
IO_Group_2 = 0;
IO_Group_3 = 0;
IO_Group_4 = 0;
ContrlorResumeofIO = 0;
ContrlorResumeofSOC = 0; //soc控制
SocSeg = 0; //Soc
ContrlorResumeofEspeed = 0; //转速控制
ESpeedValNUM = 0; //转速
ContrlorResumeofVspeed = 0; //车速控制
VspeedValNUM = 0; //车速
ContrlorResumeofLamp = 0;
//ISD_Stop_Loop();
IO_Group_1 = 0;
IO_Group_2 = 0;
IO_Group_3 = 0;
IO_Group_4 = 0;
return;
}
......
/******************************************************************************
?? ?? ????CLOCK.c
?????????????????????????
?? ???????
?? ????V1.0
?? ???2016.11.2
文 件 名:CLOCK.c
功能描述:时钟系统初始化库文件
作 者:张暄
版 本:V1.0
日 期:2016.11.2
******************************************************************************/
#include "CRG.h"
......@@ -23,24 +23,24 @@ extern void Data_Mileage_Rolling_Counter_Update_ISR(void);
extern void Data_Fuel_Consumption_Count_ISR(void);
/******************************************************************************
????????WDT_Init
?? ?????????????
?? ??????
?????????
函数名:WDT_Init
功 能:看门狗初始化
参 数:无
返回值:无
******************************************************************************/
void WDT_Init(void)
{
//????????
//配置看门狗
wdt_reset();
COPCTL = WDT_PERIOD; //???????????????
// PLLCTL_PCE = 1; //???????Pseudo Stop???????????
COPCTL = WDT_PERIOD; //配置看门狗定时周期
// PLLCTL_PCE = 1; //看门狗在Pseudo Stop模式下持续运行
}
/******************************************************************************
????????Clock_Init
?? ?????????????
?? ??????
?????????
函数名:Clock_Init
功 能:时钟系统初始化
参 数:无
返回值:无
******************************************************************************/
void Clock_Init(void)
{
......@@ -53,10 +53,10 @@ void Clock_Init(void)
uint8_t Result; ;
//???OSCCLK????????
//使用OSCCLK作为系统时钟
CLKSEL = 0x00;
//???????????????
//计算时钟配置寄存器值
Result = 0;
REFDIVVal = 0;
while ((REFDIVVal < 64) && (Result == 0))
......@@ -88,7 +88,7 @@ void Clock_Init(void)
if (POSTDIVVal == 0)
{
/*========================================================
??POSTDIV?0?,fPLL????fVCO
当POSTDIV为0时,fPLL等于fVCO
fPLL fVCO
fPLL = fVCO fBUS = ------ = ------
2 2
......@@ -101,7 +101,7 @@ void Clock_Init(void)
else
{
/*========================================================
??POSTDIV???0?
当POSTDIV不为0时
fVCO fPLL fVCO
fPLL = ------------- fBUS = ------ = -------------
2 x POSTDIV 2 4 x POSTDIV
......@@ -123,9 +123,9 @@ void Clock_Init(void)
REFDIVVal++;
}
while (Result == 0); //????????????BUSCLK,?????????
while (Result == 0); //无法生成所需的BUSCLK,在这里停机
//??????????????
//设置时钟配置寄存器
PLLCTL_SCME = 0;
PLLCTL_CME = 1;
......@@ -147,7 +147,7 @@ void Clock_Init(void)
POSTDIV = POSTDIVVal;
while (!CRGFLG_LOCK); //??? fVCO ??????
while (!CRGFLG_LOCK); //等待 fVCO 输出稳定
while (!FSTAT_CCIF); /* wait for FTM reset to complete */
......@@ -157,33 +157,33 @@ void Clock_Init(void)
//FPROT = 0x9C; // Protect 0x7F_C000 to 0x7F_FFFF (pages FD and FF)
DFPROT = 0xFF; /* Disable any protection set on DFlash */
CLKSEL_PLLSEL = 1; //???PLLCLK????????
CLKSEL_PLLSEL = 1; //选择PLLCLK作为系统时钟
#if CRG_USE_PSEUDO_STOP_MODE
CLKSEL_PSTP = 1; //Oscillator??Stop???????????(Pseudo Stop)
CLKSEL_PSTP = 1; //Oscillator在Stop模式下持续运行(Pseudo Stop)
#else
CLKSEL_PSTP = 0; //Oscillator??Stop??????????(Full Stop)
CLKSEL_PSTP = 0; //Oscillator在Stop模式下停止运行(Full Stop)
#endif
CRG_STOP_MODE = 0; //??????????,?????????
CRG_STOP_MODE = 0; //系统正常运行,不在停机模式
}
/******************************************************************************
????????Enter_Stop_Mode
?? ????????????
?? ??????
?????????
函数名:Enter_Stop_Mode
功 能:进入停机模式
参 数:无
返回值:无
******************************************************************************/
void Enter_Stop_Mode(void)
{
CRG_STOP_MODE = 1; //?????????
CRG_STOP_MODE = 1; //进入停机模式
asm ANDCC #0x7F;
asm STOP;
}
/******************************************************************************
????????RTI_Init
?? ????????RTI
?? ??????
?????????
函数名:RTI_Init
功 能:初始化RTI
参 数:无
返回值:无
******************************************************************************/
void RTI_Init(void)
{
......@@ -199,25 +199,25 @@ void RTI_Init(void)
RealTimeClock.LeapYear = Determine_Leap_Year(RealTimeClock.Year);
PLLCTL_PRE = 1; //1 RTI continues running during Pseudo Stop Mode.
//Real Time ??????????
//Real Time 时钟频率设置
RTICTL = 0xDF; //Real Time = 8M / 800000 = 10HZ (100MS)
CRGINT_RTIE = 1; //??Real Time ??
CRGINT_RTIE = 1; //开Real Time 中断
}
/******************************************************************************
????????RTI_Timing_Service
?? ???RTI?????????
?? ??????
?????????
函数名:RTI_Timing_Service
功 能:RTI实时计时服务
参 数:无
返回值:无
*******************************************************************************
? ?????????????100ms?????????
注 意:该服务函数必须每100ms被调用一次
******************************************************************************/
void RTI_Timing_Service(void)
{
uint16_t Counter;
uint16_t SecInc;
if (RealTimeClock.Year != RealTimeClock.BackupYear) //??????????
if (RealTimeClock.Year != RealTimeClock.BackupYear) //曾经修改过年
{
RealTimeClock.LeapYear = Determine_Leap_Year(RealTimeClock.Year);
RealTimeClock.BackupYear = RealTimeClock.Year;
......@@ -309,10 +309,10 @@ void RTI_Timing_Service(void)
}
/******************************************************************************
????????Determine_Leap_Year
?? ?????????
?? ????Year????
???????1 - ?????? 0 -????????
函数名:Determine_Leap_Year
功 能:闰年检测
参 数:Year:年
返回值:1 - 是闰年 0 -不是闰年
******************************************************************************/
uint8_t Determine_Leap_Year(uint16_t Year)
{
......@@ -333,12 +333,12 @@ extern uint8_t DiagnosticReceived;
#pragma CODE_SEG __NEAR_SEG NON_BANKED
/******************************************************************************
????????RTI_ISR
?? ???RTI???????
RTI?100ms???????,??????????????????1
RTI???????????????????????
?? ??????
????????? 2017??5??27??16:47:20
函数名:RTI_ISR
功 能:RTI中断服务函数
RTI每100ms发生中断后,其滚动计数器会自动加1
RTI中断还可以将处理器从睡眠中唤醒
参 数:无
返回值:无 2017年5月27日16:47:20
******************************************************************************/
void interrupt RTI_ISR(void)
......@@ -363,6 +363,6 @@ void interrupt RTI_ISR(void)
DiagnosticReceived--;
Data_Mileage_Rolling_Counter_Update_ISR();
CRGFLG_RTIF = 1; //???1??0???
CRGFLG_RTIF = 1; //通过写1清0中断标
}
#pragma CODE_SEG DEFAULT
......@@ -2347,14 +2347,14 @@ static const CANMsgAttrStruct CANMsgAttrTable[] =
{ BCM_PEPS_MSG1, CANMsg08FF00DD.Msg, 8, 8, CAN_MSG_Rx, CAN_MSG_CYCLE, 2000, 0, &CANMsg08FF00DDStatus, CANMsg08FF00DDInit, CANMsg08FF00DDTimeout, CANMsg08FF00DDMask,},
//网络管理报文必须放在这个位置,与诊断的28服务关联
{ NWM_ICM, CANMsg18FEF717.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 1000, 0, &CANMsg18FEF717Status, CANMsg18FEF717Init, CANMsg18FEF717Timeout, CANMsg18FEF717Mask,},
{ NWM_ICM, CANMsg18FEF717.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 1000, 1, &CANMsg18FEF717Status, CANMsg18FEF717Init, CANMsg18FEF717Timeout, CANMsg18FEF717Mask,},
{ TCO1, CANMsg18FE6CEE.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 50, 3, &CANMsg18FE6CEEStatus, CANMsg18FE6CEEInit, CANMsg18FE6CEETimeout, CANMsg18FE6CEEMask,},
{ VDHR, CANMsg18FEC117.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 1000, 11, &CANMsg18FEC117Status, CANMsg18FEC117Init, CANMsg18FEC117Timeout, CANMsg18FEC117Mask,},
{ AIR1, CANMsg18FEAE17.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 1000, 13, &CANMsg18FEAE17Status, CANMsg18FEAE17Init, CANMsg18FEAE17Timeout, CANMsg18FEAE17Mask,},
{ ETCS, CANMsg18FEC317.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 100, 7, &CANMsg18FEC317Status, CANMsg18FEC317Init, CANMsg18FEC317Timeout, CANMsg18FEC317Mask,},
{ ICM_1, CANMsg18FE8E17.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 1000, 17, &CANMsg18FE8E17Status, CANMsg18FE8E17Init, CANMsg18FE8E17Timeout, CANMsg18FE8E17Mask,},
{ ICM_2, CANMsg18FEF117.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 100, 3, &CANMsg18FEF117Status, CANMsg18FEF117Init, CANMsg18FEF117Timeout, CANMsg18FEF117Mask,},
{ ICM_3, CANMsg18FF0A17.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 100, 11, &CANMsg18FF0A17Status, CANMsg18FF0A17Init, CANMsg18FF0A17Timeout, CANMsg18FF0A17Mask,},
//{ ICM_3, CANMsg18FF0A17.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 100, 11, &CANMsg18FF0A17Status, CANMsg18FF0A17Init, CANMsg18FF0A17Timeout, CANMsg18FF0A17Mask,},
{ ICM_4, CANMsg18FEFC17.Msg, 8, 8, CAN_MSG_Tx, CAN_MSG_CYCLE, 1000, 9, &CANMsg18FEFC17Status, CANMsg18FEFC17Init, CANMsg18FEFC17Timeout, CANMsg18FEFC17Mask,},
{ NWM_TBOX, CANMsg18EFCD27.Msg, 8, 8, CAN_MSG_Rx, CAN_MSG_CYCLE, 10000, 0, &CANMsg18EFCD27Status, CANMsg18EFCD27Init, CANMsg18EFCD27Timeout, CANMsg18EFCD27Mask,},
......@@ -2397,7 +2397,7 @@ static const CANMsgAttrStruct CANMsgAttrTable[] =
{ EMS_51C, CANMsg18FEC600.Msg, 8, 8, CAN_MSG_Rx, CAN_MSG_CYCLE, 5000, 0, &CANMsg18FEC600Status, CANMsg18FEC600Init, CANMsg18FEC600Timeout, CANMsg18FEC600Mask,},
/*==========================================================================================================================================================================*/
};
#define CAN_TX_MSG_NUM 9
#define CAN_TX_MSG_NUM 8
#define CAN_RX_MSG_NUM 42
#endif
/******************************************************************************
?? ?? ????Communication_Over_CAN.h
??????????????CAN?????????????????????
?? ???????
?? ????V1.3
?? ???2017.5.31
文 件 名:Communication_Over_CAN.h
功能描述:基于CAN总线的信号收发函数库头文件
作 者:张暄
版 本:V1.3
日 期:2017.5.31
******************************************************************************/
#ifndef _COMMUNICATION_OVER_CAN_
......@@ -15,35 +15,35 @@
#include "CAN_Communication_Matrix.h"
/******************************************************************************
CAN??????????
CAN通信参数配置
******************************************************************************/
#define CoCAN_RX_MSG_FIFO_MAX_DEPTH 16 //????FIFO???
#define CoCAN_MSG_NUM_CHECK 0 //???????????(Debug??)
#define CoCAN_RX_MSG_FIFO_MAX_DEPTH 16 //接收FIFO深度
#define CoCAN_MSG_NUM_CHECK 0 //报文数量检查(Debug用)
#define CoCAN_TOTAL_MSG_NUM (sizeof(CANMsgAttrTable) / sizeof(CANMsgAttrStruct))
/******************************************************************************
CAN???????????
CAN通信收发使能状态
******************************************************************************/
#define CoCAN_DISABLE 0
#define COCAN_PSEUDO_DISABLE 1
#define CoCAN_ENABLE 2
/******************************************************************************
CAN?????????????
CAN报文发送请求状态
******************************************************************************/
#define CoCAN_TX_IDLE 0
#define CoCAN_TX_REQ 1
#define CoCAN_TX_ON 2
/******************************************************************************
CAN?????????????
CAN报文发送请求状态
******************************************************************************/
#define CoCAN_MODE_NORMAL 0
#define CoCAN_MODE_INIT 1
/******************************************************************************
CAN???????FIFO??
CAN报文发送FIFO结构
******************************************************************************/
typedef struct
{
......@@ -54,7 +54,7 @@ typedef struct
} CoCANTxMsgFIFOStruct;
/******************************************************************************
CAN???????FIFO??
CAN报文接收FIFO结构
******************************************************************************/
typedef struct
{
......@@ -66,61 +66,61 @@ typedef struct
typedef struct
{
CoCANMsgStruct Msg[CoCAN_RX_MSG_FIFO_MAX_DEPTH];
uint8_t Iptr; //????????
uint8_t Optr; //????????
uint8_t Iptr; //进队列位置
uint8_t Optr; //出队列位置
uint8_t Depth;
} CoCANRxMsgFIFOStruct;
/******************************************************************************
CAN?????????????
CAN报文快速查找表结构
******************************************************************************/
/*** ????????????? ***/
/*** 发送报文查找表结构 ***/
typedef struct
{
uint32_t Identifier; //????ID
uint16_t Offset; //?????????????
uint16_t Cycle; //???????????
uint8_t Rsvd; //????
uint8_t Index; //??????????????????????????,0xFF??????????????
uint8_t TxReq; //????????
uint8_t DLC; //???????
volatile uint8_t *pMsg; //????????
const uint8_t *pInit; //?????????
volatile uint8_t *pStatus; //???????
uint32_t Identifier; //报文ID
uint16_t Offset; //报文发送时间偏移
uint16_t Cycle; //报文发送周期
uint8_t Rsvd; //保留
uint8_t Index; //发送报文对应在周期性报文表中的序号,0xFF表示非周期性报文
uint8_t TxReq; //发送请求
uint8_t DLC; //报文长度
volatile uint8_t *pMsg; //报文寄存器
const uint8_t *pInit; //报文初始化值
volatile uint8_t *pStatus; //状态寄存器
} CoCANTxMsgIDLookupStruct;
/*** ????????????? ***/
/*** 接收报文查找表结构 ***/
typedef struct
{
uint32_t Identifier; //????ID
uint16_t Cycle; //??????????,?????????
uint8_t Rsvd; //????
uint8_t Index; //??????????????????????????,0xFF??????????????
uint8_t DLCMax; //????????
uint8_t DLCMin; //??????????
volatile uint8_t *pMsg; //????????
const uint8_t *pInit; //?????????
const uint8_t *pTimeOut; //????????
const uint8_t *pMask; //????????(????????????????????????)
volatile uint8_t *pStatus; //???????
uint32_t Identifier; //报文ID
uint16_t Cycle; //报文超时周期,用于掉线判断
uint8_t Rsvd; //保留
uint8_t Index; //接收报文对应在周期性报文表中的序号,0xFF表示非周期性报文
uint8_t DLCMax; //报文最大长度
uint8_t DLCMin; //报文最小长度
volatile uint8_t *pMsg; //报文寄存器
const uint8_t *pInit; //报文初始化值
const uint8_t *pTimeOut; //报文掉线值
const uint8_t *pMask; //报文屏蔽位(决定某一位在掉线时是否更新为掉线值)
volatile uint8_t *pStatus; //状态寄存器
} CoCANRxMsgIDLookupStruct;
/******************************************************************************
CAN??????????????
CAN周期性报文管理结构
******************************************************************************/
typedef struct
{
uint8_t TxNum; //????????????????
uint8_t TxIndex[CAN_TX_MSG_NUM]; //?????????????????????????
uint16_t TxTimer[CAN_TX_MSG_NUM]; //???????????
uint8_t TxNum; //周期性发送报文数量
uint8_t TxIndex[CAN_TX_MSG_NUM]; //报文对应在发送报文查找表中的序号
uint16_t TxTimer[CAN_TX_MSG_NUM]; //发送报文定时器
uint8_t RxNum; //????????????????
uint8_t RxIndex[CAN_RX_MSG_NUM]; //???????????????????????
uint16_t RxTimer[CAN_RX_MSG_NUM]; //???????????,?????????
uint8_t RxNum; //周期性发送报文数量
uint8_t RxIndex[CAN_RX_MSG_NUM]; //报文对应在发送报文查找表中的序号
uint16_t RxTimer[CAN_RX_MSG_NUM]; //接收报文定时器,用于掉线判断
} CoCANCycleMsgStruct;
/******************************************************************************
CAN???????
CAN通信控制结构
******************************************************************************/
typedef struct
{
......@@ -132,9 +132,9 @@ typedef struct
}CoCANCtrlStruct;
extern CoCANCtrlStruct CoCANCtrl;
/******************************************************************************
????????
函数声明
******************************************************************************/
void CoCAN_L_Data_Indication(uint32_t Identifier, uint8_t DLC, uint8_t *Data); //?????????????????
void CoCAN_L_Data_Indication(uint32_t Identifier, uint8_t DLC, uint8_t *Data); //必须由下一层函数引用
#define CoCAN_L_Data_Request(Identifier, DLC, Data) MSCAN0_L_Data_Request(Identifier, DLC, Data, 2)
......@@ -147,7 +147,7 @@ void CoCAN_Tx_Enable(uint8_t En);
uint8_t CoCAN_Search_Tx_Msg(uint32_t Identifier);
uint8_t CoCAN_Search_Rx_Msg(uint32_t Identifier);
void CoCAN_Signal_Update_Service(void); //?????1ms?????????
void CoCAN_Signal_Update_Service(void); //必须每1ms被调用一次
void CoCAN_Transmit_Message(uint32_t Identifier);
void CoCAN_Modify_Tx_Msg_Cycle(uint32_t Identifier, uint16_t Cycle);
......
......@@ -69,7 +69,7 @@ void Power_Management_Init(void)
g_Power_St = IGN_Default; //20200301
for (i=0; i<16; i++)
{
NVMConfig3300.Data[i]=NVMDefault3300.Data[i];
NVMConfig3300.Data[i] = NVMDefault3300.Data[i];
}
}
......
/******************************************************************************
�� �� ����main.h
�����������������ļ�
����ϵͳ��ʼ����������Լ���Դ����
�� �ߣ�����
�� ����V1.0
�� �ڣ�2016.11.1
文 件 名:main.h
功能描述:主程序文件
负责系统初始化、任务调试及电源管理
作 者:张暄
版 本:V1.0
日 期:2016.11.1
******************************************************************************/
//20210422 �޸����Ѵ���ʱ��
//20210621 �޸���Ӳ���汾��
//20220115 ���TFT����Ƶ��(61194оƬ����9967оƬ)
//20231114 TYW-2023-0695�����������Ȼ�������ơ�����Һ����Ϊ��Ȼ����
//20231122 �޸IJ�����Ϊ500k
//20231204 ȡ��RVM������
//20231205 �޸ı������������⣺35470��35462��35101
//20231206 �޸�ȼ����ָ��ָʾ��������
//20210422 修改完友达屏时序
//20210621 修改软硬件版本号
//20220115 变更TFT背光频率(61194芯片换成9967芯片)
//20231114 TYW-2023-0695变更:增加天然气报警灯、天蓝液表改为天然气表
//20231122 修改波特率为500k
//20231204 取消RVM报警灯
//20231205 修改变更测出禅道问题:35470、35462、35101
//20231206 修改燃气表指针指示误差大问题
//V00.10
//20240122 �޸IJ����㣬����ȼ���ⷢ
//20240123 ȥ����ѹ�������ã��޸���������汾��
//20240130 �޸���֡�����ⷢʱ�䣨������200ms���ڣ�
//20240201 �޸��谴OK����γ��ڴ�Ʋ�����������(��ʷ���⣩
//20240227 ͬ������޸ģ���׷�ӱ����ȡ��ʱ�Ӻ������¶���ʾ
//20240228 ȥ��ʱ�����ò˵�
//20240305 ȥ�� 20240201 �޸��谴OK����γ��ڴ�Ʋ�����������(��ʷ���⣩���ָ�ԭ��
//20240307 �޸�ȼ�Ͳ������⣨���������3300�����
//20240122 修改采样点,增加燃油外发
//20240123 去掉油压关联配置,修改诊断软件版本号
//20240130 修改首帧报文外发时间(控制在200ms以内)
//20240201 修改需按OK键多次厂内大计才能清零问题(历史问题)
//20240227 同步诊断修改,按追加变更单取消时钟和室外温度显示
//20240228 去掉时间设置菜单
//20240305 去掉 20240201 修改需按OK键多次厂内大计才能清零问题(历史问题),恢复原样
//20240307 修改燃油不走问题(诊断屏蔽了3300配置项)
//20240313 取消0x18FFOA17外发(EF01报文矩阵里没有),修改30电15电同时上首帧网络管理报文外发超时问题
#include "main.h"
#include "fuelconfig.h"
......@@ -51,10 +52,10 @@ uint8_t AverageFuel_HH;
uint16_t TankLevel_temp;
uint8_t RESET_ODO_count;
/******************************************************************************
��������main
�� �ܣ�������
�� ������
����ֵ����
函数名:main
功 能:主函数
参 数:无
返回值:无
******************************************************************************/
void main(void)
{
......@@ -63,17 +64,17 @@ void main(void)
if ((NVM_CONFIG_FUELBOX == 1) || (NVM_CONFIG_FUELBOX == 2))
{
FuelInitPara.FuelShortCircuitR = 5;
FuelInitPara.FuelOpenCircuitR = 2900; //1900������2000
FuelInitPara.FuelOpenCircuitR = 2900; //1900必须小于2000
FuelInitPara.DisplayZoneBoundary[0] = 1101;
FuelInitPara.DisplayZoneBoundary[1] = 1101;
FuelInitPara.DisplayZoneBoundary[2] = 921; //��ֲ
FuelInitPara.DisplayZoneBoundary[2] = 921; //
FuelInitPara.DisplayZoneBoundary[3] = 621;
FuelInitPara.DisplayZoneBoundary[4] = 471; //��ֲ
FuelInitPara.DisplayZoneBoundary[4] = 471; //
FuelInitPara.DisplayZoneBoundary[5] = 321;
FuelInitPara.DisplayZoneBoundary[6] = 258; //��ֲ
FuelInitPara.DisplayZoneBoundary[6] = 258; //
FuelInitPara.DisplayZoneBoundary[7] = 172;
FuelInitPara.DisplayZoneBoundary[8] = 96; //��ֲ
FuelInitPara.DisplayZoneBoundary[8] = 96; //
FuelInitPara.DisplayZoneBoundary[9] = 30;
FuelInitPara.DisplayZoneBoundary[10] = 10;
......@@ -92,17 +93,17 @@ void main(void)
else if (NVM_CONFIG_FUELBOX == 3)
{
FuelInitPara.FuelShortCircuitR = 5;
FuelInitPara.FuelOpenCircuitR = 2900; //1900������2000
FuelInitPara.FuelOpenCircuitR = 2900; //1900必须小于2000
FuelInitPara.DisplayZoneBoundary[0] = 1102;
FuelInitPara.DisplayZoneBoundary[1] = 1102;
FuelInitPara.DisplayZoneBoundary[2] = 922; //��ֲ
FuelInitPara.DisplayZoneBoundary[2] = 922; //
FuelInitPara.DisplayZoneBoundary[3] = 620;
FuelInitPara.DisplayZoneBoundary[4] = 470; //��ֲ
FuelInitPara.DisplayZoneBoundary[4] = 470; //
FuelInitPara.DisplayZoneBoundary[5] = 320;
FuelInitPara.DisplayZoneBoundary[6] = 247; //��ֲ
FuelInitPara.DisplayZoneBoundary[6] = 247; //
FuelInitPara.DisplayZoneBoundary[7] = 169;
FuelInitPara.DisplayZoneBoundary[8] = 97; //��ֲ
FuelInitPara.DisplayZoneBoundary[8] = 97; //
FuelInitPara.DisplayZoneBoundary[9] = 31;
FuelInitPara.DisplayZoneBoundary[10] = 10;
......@@ -119,21 +120,21 @@ void main(void)
FuelInitPara.FuelCapacityBoundary[10] = 1041;
}
AFC_Init.CalcAFCMaxNum = 100; //50�������100����һ����
AFC_Init.AFCMin = 30; //�ͺ���Сֵʮ��
AFC_Init.AFCMax = 300; //�ͺ����ֵ
AFC_Init.AFCPreinstall = 150; //��ʼֵ 8 20200310
AFC_Init.CurODO = NVMODO.Sig.Value * 100; //�ܹ�����100��
AFC_Init.MaxDRMileage = 999900; //����������ֵ
AFC_Init.CalcAFCMaxNum = 100; //50公里或者100公里一更新
AFC_Init.AFCMin = 30; //油耗最小值十倍
AFC_Init.AFCMax = 300; //油耗最大值
AFC_Init.AFCPreinstall = 150; //始值 8 20200310
AFC_Init.CurODO = NVMODO.Sig.Value * 100; //总公里数100倍
AFC_Init.MaxDRMileage = 999900; //续航里程最大
InitFuelParamter((FuelStruct*)&FuelInitPara);
InitAFC((AFC_INIT *)&AFC_Init);
SetFuelSensorRecoverGroupCnt(24); //���
SetFuelSensorOpenCircuitGroupCnt(24); //��·
SetFuelSensorShortCircuitGroupCnt(24); //��·
SetFuelSensorRecoverGroupCnt(24); //检测
SetFuelSensorOpenCircuitGroupCnt(24); //
SetFuelSensorShortCircuitGroupCnt(24); //
Read_CZSYBKPILSFR_FLASH(); //����ָ��Ƕ�
Read_CZSYBKPILSFR_FLASH(); //调表指针角度
Task_Scheduler_Init();
Stepper_Motor_Reset();
......@@ -144,7 +145,7 @@ void main(void)
Power_Management_Service();
Task_Scheduling_Service();
DoCAN_Communication_Service();
UDS_Server_Application_Service(); //���
UDS_Server_Application_Service(); //诊断
EEPROM_RW_Service();
TFT_LCD_General_Table_Write_Service();
UDS_KL15_init();
......@@ -167,14 +168,14 @@ void main(void)
Stepper_Motor_Speed_Control_Service();
APIBGNMEnable = 0;
TSzhen_mode(); //�������ģʽ
TSzhen_mode(); //表针调试模式
TASK_1ms_ALL CoCAN_Signal_Update_Service();
TASK_2ms_GROUP_0 {
Randomcnt();
Analog_Signal_Conversion_Service(); //AD�źŲɼ�
Analog_Signal_Conversion_Service(); //AD信号采集
SaveDTCsToEEPROM();
//DoCAN_Get_Multi_frame_Recv(); //�㲥֡���շ���--hyq
//DoCAN_Get_Multi_frame_Recv(); //广播帧接收服务--hyq
}
TASK_2ms_GROUP_1 {
TFT_LCD_Display_Update_Service(); //tft
......@@ -183,57 +184,57 @@ void main(void)
}
TASK_10ms_GROUP_0 NVM_Data_Update_Service(); //eep
TASK_10ms_GROUP_1 EEPROM_Access_Service(); //写eep
// TASK_10ms_GROUP_2 Telltales_Left_Right_Management_Service(); //ת��
TASK_10ms_GROUP_4 Sound_Play_Service(); //��������
// TASK_10ms_GROUP_2 Telltales_Left_Right_Management_Service(); //转
TASK_10ms_GROUP_4 Sound_Play_Service(); //声音播放
TASK_10ms_GROUP_5 {
Data_Engine_Speed_Processing_Service(); //ת��
Data_Engine_Speed_Processing_Service(); //转
enableDTCTimer(10);
MsgLostTimer(10);
}
TASK_10ms_GROUP_6 Fuel_Process(); //ȼ��
//TASK_10ms_GROUP_7 Radar_R3_Receiving_Service(); //�״�
TASK_10ms_GROUP_9 Startup_Animation_Play_Service(); //��������
TASK_10ms_GROUP_6 Fuel_Process(); //燃
//TASK_10ms_GROUP_7 Radar_R3_Receiving_Service(); //雷达
TASK_10ms_GROUP_9 Startup_Animation_Play_Service(); //开机动画
TASK_20ms_GROUP_0 Sys_Status_Update_Service(); //��Դ״̬
TASK_20ms_GROUP_0 Sys_Status_Update_Service(); //源状态
TASK_20ms_GROUP_1 {
MSCAN0_Bus_Off_Monitoring_Service(); //MSCAN0 Bus-off״̬��ط���
BL_Management_Service(); //�������
MSCAN0_Bus_Off_Monitoring_Service(); //MSCAN0 Bus-off状态监控服务
BL_Management_Service(); //背光控制
}
TASK_20ms_GROUP_2 {
Line_In_Debounce_Service(); //Ӳ��
//Menu_Processing_Service(); //�˵���������
Key_Status_Detect_Service(); //����������
Line_In_Debounce_Service(); //硬线
//Menu_Processing_Service(); //菜单按键处理
Key_Status_Detect_Service(); //按键服务器
}
TASK_20ms_GROUP_3 IO_Management_Service(); //�������
TASK_20ms_GROUP_4 Gauges_Management_Service(); //��תˮ����ʾ
TASK_20ms_GROUP_3 IO_Management_Service(); //界面管理
TASK_20ms_GROUP_4 Gauges_Management_Service(); //车转水油显
TASK_20ms_GROUP_5 {
Data_Vehicle_Speed_Processing_Service(); //����
Data_Vehicle_Speed_Processing_Service(); //车速
}
TASK_20ms_GROUP_6 {
Data_Coolant_ADblue_Processing_Service(); //����Һ LCD
Data_Coolant_ADblue_Processing_Service(); //天蓝液 LCD
}
TASK_20ms_GROUP_7 {
Data_Coolant_Temp_Processing_Service(); //ˮ��
Data_Coolant_Temp_Processing_Service(); //水
}
TASK_20ms_GROUP_8 {
Data_Coolant_Oil_Processing_Service(); //����
Data_Coolant_Oil_Processing_Service(); //机油
}
TASK_20ms_GROUP_9 {
}
TASK_50ms_GROUP_0 Flash_Sync_Signal_Generation_Service(); //��˸
TASK_50ms_GROUP_1 Telltales_Management(); //ָʾ��
TASK_50ms_GROUP_2 Sound_Scheduling_Service(); //����
TASK_50ms_GROUP_0 Flash_Sync_Signal_Generation_Service(); //
TASK_50ms_GROUP_1 Telltales_Management(); //指示
TASK_50ms_GROUP_2 Sound_Scheduling_Service(); //声音
TASK_50ms_GROUP_3 {
Data_AirO_Level_Processing_Service(); //��ѹ1
Data_AirO_Level_Processing_Service(); //压1
}
TASK_50ms_GROUP_4 {
Data_AirT_Level_Processing_Service(); //��ѹ2
Data_AirT_Level_Processing_Service(); //压2
}
TASK_100ms_GROUP_0 CAN_NORMAL_TIME_PRG();
TASK_100ms_GROUP_1 Popups_Management_Service(); //�����߼� ��ʾ
TASK_100ms_GROUP_1 Popups_Management_Service(); //报警逻辑 显
TASK_100ms_GROUP_2 {
Drive_Info_Display_Update_Service(); //��ʾ
Drive_Info_Display_Update_Service(); //
}
TASK_100ms_GROUP_3 {
/*if (NVM_ODO_VALUE < 29980)
......@@ -273,40 +274,40 @@ void main(void)
}
TASK_100ms_GROUP_4 {
RTI_Timing_Service(); //ʱ�䶨ʱ��
Data_IGN_Off_Timing_Service(); //IGN_IGOFF��ʱ
Drive_Info_Import_Export_Service(); //������� �����ⷢ
RTI_Timing_Service(); //时间定时器
Data_IGN_Off_Timing_Service(); //IGN_IGOFF
Drive_Info_Import_Export_Service(); //车速输出 报文外
}
TASK_100ms_GROUP_5 {
Data_Drive_Info_Group1_Processing_Service(); //ODO/TRIP
Data_Drive_Info_Group2_Processing_Service(); //˲ʱ�ͺ�
Data_Drive_Info_Group2_Processing_Service(); //瞬时油耗
}
TASK_100ms_GROUP_6 {
Popup_Scheduling_Service(); //��������
Popup_Scheduling_Service(); //报警调度
}
TASK_100ms_GROUP_7 SaveDTCsToEEPROM();
//TASK_100ms_GROUP_8 Warning_Processing_Service(); //�����߼� ״̬
//TASK_100ms_GROUP_8 Warning_Processing_Service(); //报警逻辑 状态
TASK_100ms_GROUP_9 {
Factory_ClearOdoM(); //����������G
Factory_ClearOdoM(); //生产清理大G
}
}
}
/******************************************************************************
��������Fuel_Process
�� �ܣ�
�� ������
����ֵ����
函数名:Fuel_Process
功 能:
参 数:无
返回值:无
******************************************************************************/
uint8_t Fuel_Seg, FuelStatus;
uint16_t AVYOUHAO;
uint16_t DataDTE;
uint16_t FuelConsumeSum;
uint16_t DataAvgFuelConsByLF; //ƽ���ͺ�
uint16_t DataAvgFuelConsByLF; //平均油耗
void Fuel_Process(void) //��ƽ���ͺĵ�ͬʱ����Ҳ������
void Fuel_Process(void) //清平均油耗的同时续航也会清零
{
uint32_t result;
uint16_t DataAvgFuel; //ƽ���ͺ�
uint16_t DataAvgFuel; //平均油耗
wdt_reset();
......@@ -322,10 +323,10 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
FuelConsumeSum = 0;
AFCPara.CurODO = NVMODO.Sig.Value * 100; //��G
AFCPara.CurODO = NVMODO.Sig.Value * 100; //G
AFCPara.RPM = DataESpeedActual; //ת��
AFCPara.Speed = (uint8_t)(DataVSpeedActual / 10); //����
AFCPara.RPM = DataESpeedActual; //转
AFCPara.Speed = (uint8_t)(DataVSpeedActual / 10); //车速
SetAFCPara((AFC_PARA *)&AFCPara);
......@@ -340,12 +341,12 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
SaveSampleVal(AnalogFuelSensorRes);
FuelFSM();
FuelResistanceV = GetFuelResistance(); //ȼ�͵����ȡ
FuelResistanceV = GetFuelResistance(); //燃油电阻获取
FuelStatus = GetFuelSensorState(); //ȼ��״̬��ȡ
FuelStatus = GetFuelSensorState(); //燃油状态获
/*if (FuelStatus == FuelSensorNormal)
DataDTE=GetDRMileage(); //unit:km,accuracy:1�������
DataDTE=GetDRMileage(); //unit:km,accuracy:1续航里程
else
DataDTE = 0;*/
......@@ -357,15 +358,15 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
}
else
{
DataDTE = GetDRMileage(); //unit:km,accuracy:1������� //�����������Ϊ0 2021.1.19
DataDTE = GetDRMileage(); //unit:km,accuracy:1续航里程 //更改续航里程为0 2021.1.19
}
}
else
DataDTE = 0;
DataAvgFuelConsByLF = GetCurAFC(); //ƽ���ͺ�
DataAvgFuelConsByLF = GetCurAFC(); //平均油耗
DataAvgFuel = DataAvgFuelConsByLF / 10;
AverageFuel_LL = (DataAvgFuel << 1) & 0xFF; //ϵ��0.5
AverageFuel_LL = (DataAvgFuel << 1) & 0xFF; //系0.5
AverageFuel_LH = (DataAvgFuel >> 7) & 0xFF;
AverageFuel_HL = (DataAvgFuel >> 15) & 0xFF;
AverageFuel_HH = (DataAvgFuel >> 23) & 0xFF;
......@@ -375,10 +376,10 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
Fuel_Seg = GetFuelStep();
}
if (FuelStatus == FuelSensorOpenCircuit) //2021.2.8 ȡ����·
if (FuelStatus == FuelSensorOpenCircuit) //2021.2.8 取消短
Fuel_Seg = 0;
/*if ((Fuel_Seg >= 20) && (Fuel_Seg < 40)) //ϵ��1
/*if ((Fuel_Seg >= 20) && (Fuel_Seg < 40)) //系1
TankLevel_temp = 1;
else if ((Fuel_Seg >= 40) && (Fuel_Seg < 60))
TankLevel_temp = 2;
......@@ -392,7 +393,7 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
TankLevel_temp = 0;
*/
DataFuelVolRemaining = GetFuelCapacityVal(); //ʣ������
DataFuelVolRemaining = GetFuelCapacityVal(); //剩余油量
TankLevel_temp = DataFuelVolRemaining;
if ((NVM_CONFIG_FUELBOX == 1) || (NVM_CONFIG_FUELBOX == 2))
......@@ -420,10 +421,10 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
//FuelConsumeSum = FuelConsumeSumData / 10;
//FuelConsumeSumData = 0;
AFCPara.CurODO = NVMODO.Sig.Value * 100; //��G
AFCPara.CurODO = NVMODO.Sig.Value * 100; //G
AFCPara.RPM = DataESpeedActual; //ת��
AFCPara.Speed = (uint8_t)(DataVSpeedActual / 10); //����
AFCPara.RPM = DataESpeedActual; //转
AFCPara.Speed = (uint8_t)(DataVSpeedActual / 10); //车速
SetAFCPara((AFC_PARA *)&AFCPara);
......@@ -438,12 +439,12 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
SaveSampleVal(AnalogFuelSensorRes);
FuelFSM();
FuelResistanceV = GetFuelResistance(); //ȼ�͵����ȡ
FuelResistanceV = GetFuelResistance(); //燃油电阻获取
FuelStatus = GetFuelSensorState(); //ȼ��״̬��ȡ
FuelStatus = GetFuelSensorState(); //燃油状态获
/*if (FuelStatus == FuelSensorNormal)
DataDTE = GetDRMileage(); //unit:km,accuracy:1�������
DataDTE = GetDRMileage(); //unit:km,accuracy:1续航里程
else
DataDTE = 0;*/
......@@ -455,15 +456,15 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
}
else
{
DataDTE = GetDRMileage(); //unit:km,accuracy:1������� //�����������Ϊ0 2021.1.19
DataDTE = GetDRMileage(); //unit:km,accuracy:1续航里程 //更改续航里程为0 2021.1.19
}
}
else
DataDTE = 0;
DataAvgFuelConsByLF = GetCurAFC(); //ƽ���ͺ�
DataAvgFuelConsByLF = GetCurAFC(); //平均油耗
DataAvgFuel = DataAvgFuelConsByLF / 10;
AverageFuel_LL = (DataAvgFuel << 1) & 0xFF; //ϵ��0.5
AverageFuel_LL = (DataAvgFuel << 1) & 0xFF; //系0.5
AverageFuel_LH = (DataAvgFuel >> 7) & 0xFF;
AverageFuel_HL = (DataAvgFuel >> 15) & 0xFF;
AverageFuel_HH = (DataAvgFuel >> 23) & 0xFF;
......@@ -476,7 +477,7 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
if (FuelStatus == FuelSensorOpenCircuit) //2021.2.8
Fuel_Seg = 0;
/*if ((Fuel_Seg >= 20) && (Fuel_Seg < 40)) //ϵ��1
/*if ((Fuel_Seg >= 20) && (Fuel_Seg < 40)) //系1
TankLevel_temp = 1;
else if ((Fuel_Seg >= 40) && (Fuel_Seg < 60))
TankLevel_temp = 2;
......@@ -490,7 +491,7 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
TankLevel_temp = 0;
*/
DataFuelVolRemaining = GetFuelCapacityVal(); //ʣ������
DataFuelVolRemaining = GetFuelCapacityVal(); //剩余油量
TankLevel_temp = DataFuelVolRemaining;
if ((NVM_CONFIG_FUELBOX == 1) || (NVM_CONFIG_FUELBOX == 2))
{
......@@ -516,10 +517,10 @@ void Fuel_Process(void) //锟斤拷平锟斤拷锟酵耗碉拷同时锟斤拷锟斤拷
}
}
/******************************************************************************
��������Task_Scheduler_Init
�� �ܣ������������ʼ��
�� ������
����ֵ����
函数名:Task_Scheduler_Init
功 能:任务调度器初始化
参 数:无
返回值:无
******************************************************************************/
void Task_Scheduler_Init(void)
{
......@@ -535,64 +536,64 @@ void Task_Scheduler_Init(void)
*(p + i) = 0xFF;
}
/******************************************************************************
��������Task_Scheduling_Service
�� �ܣ�������ȷ�����
�� ������
����ֵ����
函数名:Task_Scheduling_Service
功 能:任务调度服务函数
参 数:无
返回值:无
*******************************************************************************
ע �⣺�÷��������뱻ʵʱ����
意:该服务函数必须被实时调用
******************************************************************************/
void Task_Scheduling_Service(void)
{
ScheduleUpdate.TaskFlagAll = 0; //��������±�־
ScheduleUpdate.TaskFlagAll = 0; //清任务更新标志
if (API_1ms_Timer_Update())
{
ScheduleUpdate.TaskFlagAll = TaskScheduleTable[ScheduleCtrlCnt];
if (ScheduleUpdate.Task.Flag2ms) //���µ�ǰ2ms��������
if (ScheduleUpdate.Task.Flag2ms) //更新当前2ms任务组编号
{
if (TaskGroup.ID2ms)
TaskGroup.ID2ms = 0;
else
TaskGroup.ID2ms = 1;
}
if (ScheduleUpdate.Task.Flag10ms) //���µ�ǰ10ms��������
if (ScheduleUpdate.Task.Flag10ms) //更新当前10ms任务组编号
{
if (TaskGroup.ID10ms >= 9)
TaskGroup.ID10ms = 0;
else
TaskGroup.ID10ms++;
}
if (ScheduleUpdate.Task.Flag20ms) //���µ�ǰ20ms��������
if (ScheduleUpdate.Task.Flag20ms) //更新当前20ms任务组编号
{
if (TaskGroup.ID20ms >= 9)
TaskGroup.ID20ms = 0;
else
TaskGroup.ID20ms++;
}
if (ScheduleUpdate.Task.Flag50ms) //���µ�ǰ50ms��������
if (ScheduleUpdate.Task.Flag50ms) //更新当前50ms任务组编号
{
if (TaskGroup.ID50ms >= 9)
TaskGroup.ID50ms = 0;
else
TaskGroup.ID50ms++;
}
if (ScheduleUpdate.Task.Flag100ms) //���µ�ǰ100ms��������
if (ScheduleUpdate.Task.Flag100ms) //更新当前100ms任务组编号
{
if (TaskGroup.ID100ms >= 9)
TaskGroup.ID100ms = 0;
else
TaskGroup.ID100ms++;
}
if (ScheduleCtrlCnt >= 9) //���µ��ȼ�����
if (ScheduleCtrlCnt >= 9) //更新调度计数器
ScheduleCtrlCnt = 0;
else
ScheduleCtrlCnt++;
}
}
/********************�����������***************************/
/********************生产清理大计***************************/
//extern uint8_t ClrOdoEn;
void Factory_ClearOdoM(void)
......@@ -623,7 +624,7 @@ void Factory_ClearOdoM(void)
//Checksum = YGV642_Calc_Pattern_Memory_CheckSum(ROMDATA_STARTADDR, ROMDATA_ENDADDR);
//if (Checksum != ROMDATA_CHECKSUM) //YVC_LYR_NUM_CPU
// TFT_LCD_Display_Sprite(YVC_LYR_NUM_CPU-1, SN_R_bmp, 0, 0, 64); //���
// TFT_LCD_Display_Sprite(YVC_LYR_NUM_CPU-1, SN_R_bmp, 0, 0, 64); //光标
}
//NVM_Data_Update(NVM_USER_SETTINGS);
......
......@@ -11,7 +11,7 @@ Layout=C_layout.hwl
LoadDialogOptions=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
CPU=HC12
AEFWarningDialog=FALSE
MainFrame=2,3,-32000,-32000,-1,-1,2158,69,3544,905
MainFrame=2,3,-1,-1,-1,-1,2158,69,3544,905
TOOLBAR=57600 57601 32795 0 57635 57634 57637 0 57671 57669 0 32777 32776 32782 32780 32781 32778 0 32806
Configuration=TBDML.hwc
Statusbar=1
......@@ -69,7 +69,7 @@ ISRDISABLEDSTEP=1
[TBDML]
COMSETTINGS=SETCOMM DRIVER NOPROTOCOL NOPERIODICAL
NV_PARAMETER_FILE=
NV_PARAMETER_FILE=C:\Program Files (x86)\Freescale\CWS12v5.1\prog\FPP\mcu01C9.fpp
NV_SAVE_WSP=0
NV_AUTO_ID=1
......@@ -77,12 +77,12 @@ NV_AUTO_ID=1
[Recent HI-WAVE FindProcedure Search]
Search0=Power_On_System_Init
Search1=Power_Management_Init
Search2=API_ISR
Search3=Sys_Status_Update_Service
Search4=MSCAN0_TX_ISR
Search5=MSCAN0_L_Data_Request
Search0=MSCAN0_L_Data_Request
Search1=Power_On_System_Init
Search2=Power_Management_Init
Search3=API_ISR
Search4=Sys_Status_Update_Service
Search5=MSCAN0_TX_ISR
Search6=Power_Wake_Up_Init
Search7=IGN_OFF_State_Keep
Search8=Power_Sleep_Init
......@@ -110,11 +110,11 @@ Search15=GUI_ADAS_Display
[Recent Applications File List]
File0=H:\EF01\������\bin\WuZhengProject7.0.abs
File1=H:\EF01\��\�½��ļ���\W3_EF01_BootApp_BV1.2_SV00.10_HV1.07_FV0.08.s19
File0=H:\EF01\\原程序\bin\WuZhengProject7.0.abs
File1=H:\EF01\\新建文件夹\W3_EF01_BootApp_BV1.2_SV00.10_HV1.07_FV0.08.s19
File2=I:\GIT\DEV\WZ-EF01\s19\W3_EF01_20231206_BV1.01(500k)_SVa00.09_HV1.07_FV0.08-12V_ALL.s19
File3=H:\EF01��\03-����Դ��\wuzheng_a901-master����\bin\WuZhengProject7.0.abs
LoadFlags0=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
File3=H:\EF01\源\03-程序源码\wuzheng_a901-master\原程序\bin\WuZhengProject7.0.abs
LoadFlags0=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags1=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags2=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
LoadFlags3=AUTOERASEANDFLASH RUNANDSTOPAFTERLOAD="main"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,3 +12,8 @@ Data:2 < ADDXPR ONLY_ADD_IF_NEW "DataESpeedActual"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "DataESPeedDamping.Speed"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "NVMConfig3300"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "FuelResistanceV"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "CANNetTxOFF"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "CoCANCycleMsg"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "CoCANCtrl.Timer"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "CoCANTxMsgTable"
Data:2 < ADDXPR ONLY_ADD_IF_NEW "CANMsg18FEF717Status"
1、WZ_EF01_BootApp_BV1.2_SV00.10_HV1.07_FV0.08_20240311.s19,完整版,适用于新生产的无程序仪表
2、WZ_EF01_UpdateApp_BV1.2_SV00.10_HV1.07_FV0.08_20240311.s19,APP版,适用于烧过完整版程序仪表,需配合诊断工具使用
1、WZ_EF01_BootApp_BV1.30_SV00.10_HV1.07_FV0.08_20240313.s19,完整版,适用于新生产的无程序仪表
2、WZ_EF01_UpdateApp_BV1.30_SV00.10_HV1.07_FV0.08_20240313.s19,APP版,适用于烧过完整版程序仪表,需配合诊断工具使用
#new Option
#Thu Mar 07 10:34:08 CST 2024
#Wed Mar 13 19:17:49 CST 2024
IsSort=true
MergeFlashIsCompression=false
ChangeAppFilePath=
......@@ -7,7 +7,7 @@ MergeCanXLSPath=
RH850_D1M1AGPIOJSONpath=
DBFFilePath=
MergeCrcTtpe=1
MergeBootFilePath=I\:\\GIT\\DEV\\WZ-EF01\\utility\\Boot_Release\\EF01_Boot_V1.2_20240227.s19
MergeBootFilePath=I\:\\GIT\\DEV\\WZ-EF01\\utility\\Boot_Release\\WuZheng_EF01_3820010-EF01_Boot_BV1.30_20240308.s19
IsMergeChangeAddress=false
MergeFlashOutPutFilePath=
GPIOOutPutPath=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment