我在实验室中分配了一个项目来在 ARM 7 上实现 CAN 协议。
我找了一些教程和示例代码,但看起来都非常复杂,我想我应该在编码部分得到一些帮助。任何人都可以向我解释任何 ARM 板上的基本发射器和接收器编码吗?
发件人代码如下。我在不理解表达式的全部含义时使用了问号。
#include <lpc23xx.h>
#include "type.h
#include "can.h"
#include <LPC23xx.H>
CAN_MSG MsgBuf_RX1,MsgBuf_RX2; // TX and RX Buffers for CAN message
volatile DWORD CAN1RxDone, CAN2RxDone;
int main(void)
{
DWORD tempbuf1,tempbuf2;
int current;
FIO2DIR=0x000000FF;
CAN_Init(BITRATE100K28_8MHZ);
MsgBuf_RX2.Frame = 0x0;
MsgBuf_RX2.MsgID = 0x0;
MsgBuf_RX2.DataA = 0x0;
MsgBuf_RX2.DataB = 0x0;
CAN_SetACCF(ACCF_BYPASS);
while (1)
{
while (!(CAN2GSR & (1 << 0)) )
;
if (CAN2RxDone == TRUE)
{
tempbuf1 = MsgBuf_RX2.DataA; // Data A has 32 bits, of which only the
// first 16 bits are actual data
tempbuf2 = (tempbuf1 & 0x0000ffff); //??
current = tempbuf2;
if ((current/3) >= 25)
FIO2SET |= 0x00000001; ///??
}
CAN2RxDone = FALSE;
if (MsgBuf_RX2.Frame & (1 << 10)) //?
{
MsgBuf_RX2.Frame &= ~(1 << 10); //?
}
}
}