资源简介
这是一个关于PCI-CAN卡的驱动程序,针对VxWorks的
代码片段和文件信息
/*----------------------------------------------------------------------------
* PeliCAN.c -
*
* Author : redsea_li
* Version : 1.1
* Created : 2009-03-03 20:50:36
* Last Modified: 2009-03-18 22:03:54
* Copyright ECI
*----------------------------------------------------------------------------*/
#include “PeliCAN.h“
int int_lvl;
UINT32_T iobase_adr;
UINT8_T UrgBuf[13];
UINT8_T BTR0BTR1;
UINT8_T ACR0ACR1ACR2ACR3;
UINT8_T AMR0AMR1AMR2AMR3;
#define INT_NUM_IRQ 0X20 /* vector number for PIC IRQ0 */
#define INUM_TO_IVEC(intNum) ((VOIDFUNCPTR *) ((intNum) << 3))
#define INT_NUM_COM (INT_NUM_IRQ + int_lvl)
PFUNC p = NULL;
/*interrupt register function*/
void registerFunc(PFUNC func)
{
p = func;
}
/*time-lapse function*/
void delay(UINT32_T t)
{
UINT32_T td;
for(td = 0; td ;
return;
}
/*interrupt ID setup function*/
void can_set_urg(UINT8_T channel char *ACK)
{
int i;
UINT8_T BegWrtEndWrtBegRd;
char rdbck;
switch(channel) {
case 0:
BegWrt = 0x01;
EndWrt = 0x00;
BegRd = 0x02;
break;
case 1:
BegWrt = 0x04;
EndWrt = 0x00;
BegRd = 0x08;
break;
case 2:
BegWrt = 0x10;
EndWrt = 0x00;
BegRd = 0x20;
break;
case 3:
BegWrt = 0x40;
EndWrt = 0x00;
BegRd = 0x80;
break;
default:
break;
}
sysOutByte(iobase_adr + 0x13 BegWrt);
for(i = 0; i < 4; i++) {
sysOutByte(iobase_adr + 0x14 ACK[i]);
printf(“\nACK %d = %2x\n“i(UINT8_T)ACK[i]);
}
sysOutByte(iobase_adr + 0x13 EndWrt);
sysOutByte(iobase_adr + 0x13 BegRd);
for(i = 0; i < 4; i++) {
rdbck = sysInByte(iobase_adr + 0x14);
printf(“\n rdbck = %2x\n“(UINT8_T)rdbck);
}
sysOutByte(iobase_adr + 0x13 EndWrt);
return;
}
/*readback interrupt ID set before*/
can_rdurg(UINT8_T channel)
{
int i;
UINT8_T EndRdBegRd;
char rdbck;
switch(channel) {
case 0:
EndRd = 0x00;
BegRd = 0x02;
break;
case 1:
EndRd = 0x00;
BegRd = 0x08;
break;
case 2:
EndRd = 0x00;
BegRd = 0x20;
break;
case 3:
EndRd = 0x00;
BegRd = 0x80;
break;
default:
break;
}
sysOutByte(iobase_adr + 0x13 BegRd);
for(i = 0; i < 4; i++) {
rdbck = sysInByte(iobase_adr + 0x14);
printf(“\n rdbck = %2x\n“(UINT8_T)rdbck);
}
sysOutByte(iobase_adr + 0x13 EndRd);
return;
}
/*write registers of sja1000 not have to fill iobase_adr + 0x10 with 0x0f*/
void can_write(UINT8_T channel UINT8_T sja_reg char data)
{
UINT32_T sja_adr;
sja_adr = iobase_adr + 4 * channel;
sysOutByte(sja_adr sja_reg);
sysOutByte(sja_adr + 1data);
return;
}
/*read registers of sja1000 not have to fill iobase_adr + 0x10 with 0x0f*/
char can_read(UINT8_T channel UINT8_T sja_reg)
{
char data;
UINT32_T sja_adr;
sja_adr = iobase_adr + 4 * channel;
sysOutByte(sja_adr sja_reg);
data
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 25562 2009-03-24 09:23 PCI-CAN卡的VxWorks驱动\CAN卡的VxWorks驱动\CAN.c
文件 3047 2009-03-24 09:22 PCI-CAN卡的VxWorks驱动\CAN卡的VxWorks驱动\CAN.h
目录 0 2009-08-03 19:40 PCI-CAN卡的VxWorks驱动\CAN卡的VxWorks驱动
目录 0 2009-08-03 19:40 PCI-CAN卡的VxWorks驱动
----------- --------- ---------- ----- ----
28609 4
评论
共有 条评论