mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-09-15 02:52:53 +00:00
Modified can bus filter and pass all data
This commit is contained in:
+11
-18
@@ -89,7 +89,6 @@ void mcp2518fd::init_CS(byte _CS) {
|
||||
** Descriptions: init can and set speed
|
||||
*********************************************************************************************************/
|
||||
byte mcp2518fd::begin() {
|
||||
Serial.println("into mcp25184fd begin\n\r");
|
||||
SPI.begin();
|
||||
byte res = mcp2518fd_init();
|
||||
|
||||
@@ -101,7 +100,6 @@ byte mcp2518fd::begin() {
|
||||
void mcp2518fd::mcp2518fd_TransmitMessageQueue(void)
|
||||
{
|
||||
uint8_t attempts = MAX_TXQUEUE_ATTEMPTS;
|
||||
Serial.printf("into mcp2518fd_TransmitMessageQueue\n\r");
|
||||
|
||||
// Check if FIFO is not full
|
||||
do {
|
||||
@@ -136,7 +134,6 @@ void mcp2518fd::mcp2518fd_sendMsgBuf(const byte* buf,byte len) {
|
||||
** Descriptions: send message
|
||||
*********************************************************************************************************/
|
||||
void mcp2518fd::mcp2518fd_sendMsg(const byte* buf, byte len) {
|
||||
Serial.printf("into mcp2518fdsendMsg\n\r");
|
||||
uint8_t n;
|
||||
int i;
|
||||
|
||||
@@ -195,23 +192,19 @@ uint8_t mcp2518fd::mcp2518fd_init() {
|
||||
DRV_CANFDSPI_ConfigureObjectReset(&config);
|
||||
config.IsoCrcEnable = 1;
|
||||
config.StoreInTEF = 0;
|
||||
Serial.println("DRV_CANFDSPI_ConfigureObjectReset-------end\n\r");
|
||||
DRV_CANFDSPI_Configure(DRV_CANFDSPI_INDEX_0, &config);
|
||||
Serial.println("DRV_CANFDSPI_Configure-------end\n\r");
|
||||
|
||||
|
||||
// Setup TX FIFO
|
||||
DRV_CANFDSPI_TransmitChannelConfigureObjectReset(&txConfig);
|
||||
Serial.println("DRV_CANFDSPI_TransmitChannelConfigureObjectReset-------end\n\r");
|
||||
txConfig.FifoSize = 7;
|
||||
txConfig.PayLoadSize = CAN_PLSIZE_64;
|
||||
txConfig.TxPriority = 1;
|
||||
DRV_CANFDSPI_TransmitChannelConfigure(DRV_CANFDSPI_INDEX_0, APP_TX_FIFO, &txConfig);
|
||||
Serial.println("DRV_CANFDSPI_TransmitChannelConfigure-------end\n\r");
|
||||
|
||||
|
||||
// Setup RX FIFO
|
||||
DRV_CANFDSPI_ReceiveChannelConfigureObjectReset(&rxConfig);
|
||||
Serial.println("DRV_CANFDSPI_ReceiveChannelConfigureObjectReset-------end\n\r");
|
||||
rxConfig.FifoSize = 15;
|
||||
rxConfig.PayLoadSize = CAN_PLSIZE_64;
|
||||
DRV_CANFDSPI_ReceiveChannelConfigure(DRV_CANFDSPI_INDEX_0, APP_RX_FIFO, &rxConfig);
|
||||
@@ -219,16 +212,16 @@ uint8_t mcp2518fd::mcp2518fd_init() {
|
||||
|
||||
// Setup RX Filter
|
||||
fObj.word = 0;
|
||||
fObj.bF.SID = 0xda;
|
||||
fObj.bF.SID = 0;
|
||||
fObj.bF.EXIDE = 0;
|
||||
fObj.bF.EID = 0x00;
|
||||
|
||||
DRV_CANFDSPI_FilterObjectConfigure(DRV_CANFDSPI_INDEX_0, CAN_FILTER0, &fObj.bF);
|
||||
Serial.println("DRV_CANFDSPI_FilterObjectConfigure-------end\n\r");
|
||||
|
||||
// Setup RX Mask
|
||||
mObj.word = 0;
|
||||
mObj.bF.MSID = 0x0;
|
||||
mObj.bF.MIDE = 1; // Only allow standard IDs
|
||||
mObj.bF.MSID = 0;
|
||||
mObj.bF.MIDE = 0; // Only allow standard IDs
|
||||
mObj.bF.MEID = 0x0;
|
||||
DRV_CANFDSPI_FilterMaskConfigure(DRV_CANFDSPI_INDEX_0, CAN_FILTER0, &mObj.bF);
|
||||
|
||||
@@ -236,22 +229,22 @@ uint8_t mcp2518fd::mcp2518fd_init() {
|
||||
DRV_CANFDSPI_FilterToFifoLink(DRV_CANFDSPI_INDEX_0, CAN_FILTER0, APP_RX_FIFO, true);
|
||||
|
||||
// Setup Bit Time
|
||||
DRV_CANFDSPI_BitTimeConfigure(DRV_CANFDSPI_INDEX_0, CAN_500K_1M, CAN_SSP_MODE_AUTO, CAN_SYSCLK_40M);
|
||||
DRV_CANFDSPI_BitTimeConfigure(DRV_CANFDSPI_INDEX_0, CAN_125K_500K, CAN_SSP_MODE_AUTO, CAN_SYSCLK_20M);
|
||||
|
||||
// Setup Transmit and Receive Interrupts
|
||||
DRV_CANFDSPI_GpioModeConfigure(DRV_CANFDSPI_INDEX_0, GPIO_MODE_INT, GPIO_MODE_INT);
|
||||
#ifdef APP_USE_TX_INT
|
||||
//#ifdef APP_USE_TX_INT
|
||||
DRV_CANFDSPI_TransmitChannelEventEnable(DRV_CANFDSPI_INDEX_0, APP_TX_FIFO, CAN_TX_FIFO_NOT_FULL_EVENT);
|
||||
#endif
|
||||
//#endif
|
||||
DRV_CANFDSPI_ReceiveChannelEventEnable(DRV_CANFDSPI_INDEX_0, APP_RX_FIFO, CAN_RX_FIFO_NOT_EMPTY_EVENT);
|
||||
DRV_CANFDSPI_ModuleEventEnable(DRV_CANFDSPI_INDEX_0,(CAN_MODULE_EVENT)(CAN_TX_EVENT | CAN_RX_EVENT));
|
||||
|
||||
// Select Normal Mode
|
||||
DRV_CANFDSPI_OperationModeSelect(DRV_CANFDSPI_INDEX_0, CAN_CLASSIC_MODE);
|
||||
|
||||
CAN_OPERATION_MODE abc;
|
||||
abc = DRV_CANFDSPI_OperationModeGet(0);
|
||||
Serial.printf("DRV_CANFDSPI_OperationModeGet = %d\n\r",abc);
|
||||
// CAN_OPERATION_MODE abc;
|
||||
// abc = DRV_CANFDSPI_OperationModeGet(0);
|
||||
// Serial.printf("DRV_CANFDSPI_OperationModeGet = %d\n\r",abc);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user