Skip to content

Commit

Permalink
Allow clkout to be selected in CNF3 register.
Browse files Browse the repository at this point in the history
  • Loading branch information
consp committed Dec 15, 2021
1 parent f44efa6 commit 1b7b722
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mcp_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions mcp_can_dfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b7b722

Please sign in to comment.