diff --git a/mcp_can.cpp b/mcp_can.cpp index d1815b5..2c01c7a 100644 --- a/mcp_can.cpp +++ b/mcp_can.cpp @@ -233,7 +233,7 @@ INT8U MCP_CAN::mcp2515_configRate(const INT8U canSpeed, const INT8U canClock) { INT8U set, cfg1, cfg2, cfg3; set = 1; - switch (canClock) + switch (canClock & MCP_CLOCK_SELECT) { case (MCP_8MHZ): switch (canSpeed) @@ -486,6 +486,10 @@ INT8U MCP_CAN::mcp2515_configRate(const INT8U canSpeed, const INT8U canClock) break; } + if (canClock & MCP_CLKOUT_ENABLE) { + cfg3 &= (~SOF_ENABLE); + } + if (set) { mcp2515_setRegister(MCP_CNF1, cfg1); mcp2515_setRegister(MCP_CNF2, cfg2); diff --git a/mcp_can_dfs.h b/mcp_can_dfs.h index 310727d..919ef6f 100644 --- a/mcp_can_dfs.h +++ b/mcp_can_dfs.h @@ -441,6 +441,9 @@ #define MCP_20MHZ 0 #define MCP_16MHZ 1 #define MCP_8MHZ 2 +#define MCP_CLOCK_SELECT 3 +#define MCP_CLKOUT_ENABLE 4 + #define CAN_4K096BPS 0 #define CAN_5KBPS 1