• 大小: 2KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-05
  • 语言: 其他
  • 标签: CCP  单片机  源码  

资源简介

该为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

评论

共有 条评论