資源簡介
該為CCP協議的源代碼,包括命令處理機和DAQ處理機,符合CCP2.1標準。集成到單片機后可以與上位機軟件CANape等進行標定。

代碼片段和文件信息
typedef?struct?ccpOdtEntry?{
unsigned?char????????*ptr;
}?ccpOdtEntry_t;
typedef?ccpOdtEntry_t?ccpODT_t[7];
typedef?struct?ccpDaqList?{
ccpODT_t????odt[3];
unsigned?short???????????prescaler;
unsigned?short???????????cycle;
unsigned?char????????????eventChannel;
unsigned?char????????????last;
unsigned?char????????????flags;
}?ccpDaqList_t;
typedef?struct?{
unsigned?char?????b[8];
}?ccpMsg_t;
typedef?struct?{
unsigned?char?????????len;
unsigned?char?????????rp;
ccpMsg_t?msg[(3?*?2)];
}?ccpQueue_t;
struct?ccp?{
unsigned?char?????Crm[8];
unsigned?char?????SessionStatus;
unsigned?char?????SendStatus;
unsigned?char????????*??????????????MTA[2];
ccpQueue_t?Queue;
ccpOdtEntry_t?*DaqListPtr;
ccpDaqList_t???DaqList[2];
unsigned?char?????UserSessionStatus;
unsigned?short????CheckSumSize;
};
extern??struct?ccp?ccp;
extern?void?ccpInit(void);
extern?void?ccpDaq(unsigned?char?????eventChannel);
extern?void?ccpCommand(unsigned?char?*???????????msg);
extern?unsigned?char?????ccpSendCallBack(void);
void?ccpSendCrm(void);
extern?unsigned?char?????ccpBackground(void);
extern?void?ccpSend(unsigned?char?*???????????msg);
extern?void?ccpUserBackground(void);
extern?unsigned?char????????*??????????????ccpGetPointer(unsigned?char?????addr_ext?unsigned?long??????addr);
unsigned?char?????ccpStationId[]?=?“ECU00001“;
struct?ccp?ccp;
void?ccpSendCrm(void)?{
;
if?(ccp.SendStatus&(0x20?|?0x10?|?0x40))?{
ccp.SendStatus?|=?0x01;
}
else?{
ccp.SendStatus?|=?0x10;
ccpSend(ccp.Crm);
}
;
}
void?ccpQueueInit(void)?{
ccp.Queue.len?=?0;
ccp.Queue.rp?=?0;
}
unsigned?char?????ccpQueueWrite(ccpMsg_t?*msg)?{
if?(ccp.Queue.len?>=?(3?*?2))?return?0;
ccp.Queue.msg[(ccp.Queue.rp?+?ccp.Queue.len)?%?(3?*?2)]?=?*msg;
ccp.Queue.len++;
return?1;
}
static?unsigned?char?????ccpWriteMTA(unsigned?char?????n?unsigned?char?????size?unsigned?char?*???????????d)?{
while?(size-->0)?{
*(ccp.MTA[n])?=?*d;
ccp.MTA[n]++;
d++;
}
return?1;
}
static?void?ccpReadMTA(unsigned?char?????n?unsigned?char?????size?unsigned?char?*???????????d)?{
while?(size-->0)?{
*d?=?*(ccp.MTA[n]);
d++;
ccp.MTA[n]++;
}
}
static?unsigned?char?????ccpClearDaqList(unsigned?char?????daq)?{
unsigned?char?*???????????p;
unsigned?char?*???????????pl;
if?(daq?>=?2)?return?0;
p?=?(unsigned?char?*)&ccp.DaqList[daq];
pl?=?p?+?sizeof(ccpDaqList_t);
while?(p ccp.SessionStatus?|=?0x02;
ccpQueueInit();
return?3;
}
static?unsigned?char?????ccpPrepareDaq(unsigned?char?????daq?unsigned?char?????last?unsigned?char?????eventChannel?unsigned?short????prescaler)?{
if?(daq?>=?2)?return?0;
ccp.DaqList[daq].eventChannel?=?eventChannel;
if?(prescaler?==?0)?prescaler?=?1;
ccp.DaqList[daq].prescaler?=?prescaler;
ccp.DaqList[daq].cycle?=?1;
ccp.DaqList[daq].last?=?last;
ccp.DaqList[daq].flags?=?0x04;
return?1;
}
static?unsigned?char?????ccpStartDaq(unsigned?char?????daq
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????10217??2017-11-19?08:38??CCP.c
- 上一篇:連連看游戲的設計思路文檔
- 下一篇:Qt類繼承關系圖
評論
共有 條評論