Skip to content

Commit

Permalink
sandeepmistry#31 Replace MPC2515 by MPC2518 to have CAN FD
Browse files Browse the repository at this point in the history
  • Loading branch information
fterretf committed May 23, 2023
1 parent 79c6ca4 commit baec410
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/MCP2515.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#define RXBXCTRL_FILTER01_ON_NO_ROLLOVER 0x00 //Enable filters on MBX0 and 1 and disable rollover. See datasheet RXB0CTRL, RXB1CTRL


MCP2515Class::MCP2515Class(eCanBusId busId) :
MCP2515Class::MCP2515Class(CanCmn::eCanBusId busId) :
CANControllerClass(),
_spiSettings(4E6, MSBFIRST, SPI_MODE0),
_csPin(MCP2515_DEFAULT_CS_PIN),
Expand Down Expand Up @@ -618,16 +618,16 @@ void MCP2515Class::handleInterrupt()
void MCP2515Class::csSelect()
{
switch (_busId) {
case MCP2515Class::eCanBusId::eCan0:
case CanCmn::eCanBusId::eCan0:
digitalWrite(_csPin, LOW);
break;
case MCP2515Class::eCanBusId::eCan1:
case CanCmn::eCanBusId::eCan1:
_Mux.can1Cs();
break;
case MCP2515Class::eCanBusId::eCan2:
case CanCmn::eCanBusId::eCan2:
_Mux.can2Cs();
break;
case MCP2515Class::eCanBusId::eCan3:
case CanCmn::eCanBusId::eCan3:
_Mux.can3Cs();
break;
default:
Expand All @@ -637,16 +637,16 @@ void MCP2515Class::csSelect()
void MCP2515Class::csUnselect()
{
switch (_busId) {
case MCP2515Class::eCanBusId::eCan0:
case CanCmn::eCanBusId::eCan0:
digitalWrite(_csPin, HIGH);
break;
case MCP2515Class::eCanBusId::eCan1:
case CanCmn::eCanBusId::eCan1:
_Mux.can1UnCs();
break;
case MCP2515Class::eCanBusId::eCan2:
case CanCmn::eCanBusId::eCan2:
_Mux.can2UnCs();
break;
case MCP2515Class::eCanBusId::eCan3:
case CanCmn::eCanBusId::eCan3:
_Mux.can3UnCs();
break;
default:
Expand Down
14 changes: 5 additions & 9 deletions src/MCP2515.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

#include <SPI.h>
#include <functional>
// #include "canCmn.h"

#include "CANController.h"
#include "canCmn.h"


#define MCP2515_DEFAULT_CLOCK_FREQUENCY 16e6
Expand All @@ -26,16 +28,10 @@
class MCP2515Class : public CANControllerClass {

public:
enum eCanBusId : int8_t {
eCan0 = 0, //CAN on CAN bus shield daughter board
eCan1, //CAN1-C4
eCan2, //CAN2-vehicle1
eCan3, //CAN3-vehicle2
eCanNb,
};


public:
MCP2515Class(eCanBusId busId);
MCP2515Class(CanCmn::eCanBusId busId);
virtual ~MCP2515Class();

virtual int begin(long baudRate);
Expand Down Expand Up @@ -106,7 +102,7 @@ class MCP2515Class : public CANControllerClass {
int _csPin;
int _intPin;
long _clockFrequency;
eCanBusId _busId;
CanCmn::eCanBusId _busId;
// See PinDescription in variant.cpp : D6 is on PA20, D7 on PA21, mask is 1<<20 | 1 << 21;
//.platformio\packages\framework-arduino-samd\variants\mkrwifi1010\variant.cpp
const uint32_t MUX_IOPIN_MASK = 0x00300000;
Expand Down

0 comments on commit baec410

Please sign in to comment.