//设置数据接收相关寄存器
// 设置RXM[1:0]=11,关闭接收缓冲器0屏蔽/滤波功能,接收所有报文;禁止滚存功能
mcp2515_write_register( RXB0CTRL, (1<<RXM1)|(1<<RXM0) );
// 设置RXM[1:0]=11,关闭接收缓冲器1屏蔽/滤波功能,接收所有报文;
mcp2515_write_register( RXB1CTRL, (1<<RXM1)|(1<<RXM0) );
temp[0]=0;
temp[1]=0;
temp[2]=0;
temp[3]=0;
//设置6个验收滤波寄存器为0,
mcp2515_write_register_p( RXF0SIDH, temp, 4 );
mcp2515_write_register_p( RXF1SIDH, temp, 4 );
mcp2515_write_register_p( RXF2SIDH, temp, 4 );
mcp2515_write_register_p( RXF3SIDH, temp, 4 );
mcp2515_write_register_p( RXF4SIDH, temp, 4 );
mcp2515_write_register_p( RXF5SIDH, temp, 4 );
//设置2个验收滤波寄存器为0,
mcp2515_write_register_p( RXM0SIDH, temp, 4 );
mcp2515_write_register_p( RXM1SIDH, temp, 4 );
//配置引脚
//设置接收相关引脚控制寄存器,配置它们禁用第二功能
mcp2515_write_register( BFPCTRL, 0 );
//调试使用,设置BFPCTRL使RX0BF,RX1BF设置为数字输出。
//mcp2515_bit_modify( BFPCTRL, (1<<B1BFE)|(1<<B0BFE)|(1<<B1BFM)|(1<<B0BFM), (1<<B1BFE)|(1<<B0BFE) );
//设置发送相关引脚控制寄存器,配置它们禁用第二功能
mcp2515_write_register( TXRTSCTRL, 0 );
//MCP2515进入正常模式
mcp2515_bit_modify( CANCTRL, 0xE0, 0);//
} |