我是用S3C2416做的cpu,系统用WINCE,扩展SJA1000的CAN模块,做驱动时遇到的困难,就是底层读写SJA1000寄存器出的错误,参考的是周立功的书。然后从串口打印观察,每次读出的寄存器值都不对,是最近一次写入的值,又懂得大神,请指导
void SJA1000_ReadRegister(UINT8 reg, UINT8 *value)
{
//g_lpBaseSJA1000[8] = reg;
//*value = (UINT8)g_lpBaseSJA1000[4];
WRITE_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[7], reg);
*value = READ_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[0]);
RETAILMSG(1,(TEXT("read from reg [0x%02x]=[0x%02x]\r\n"),reg,*value));
}
void SJA1000_WriteRegister(UINT8 reg, UINT8 value)
{
//g_lpBaseSJA1000[4] = reg;
//g_lpBaseSJA1000[8] = value;
WRITE_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[7], reg);
WRITE_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[0], value);
RETAILMSG(1,(TEXT("write value to reg [0x%02x]=[0x%02x]\r\n"),reg,value));
}
更多回帖