Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ To create connection with MCP2515 provide pin number where SPI CS is connected (

The available modes are listed as follows:
```C++
mcp2515.setNormalMode();
mcp2515.setLoopbackMode();
mcp2515.setListenOnlyMode();
mcp2515.setNormalMode(); // sends and receives data normally, sends acknowledgments to other nodes, when sending data, requires an acknowledgment from another node that the message was received or else, the 2515 will autonomously keep sending the same data
mcp2515.setNormalOneShotMode(); // sends and receives data normally, sends acknoledgements to other nodes that their message was received, when sending data, does not require an acknowledgement from another node that the message was received.
mcp2515.setLoopbackMode(); // data sent is immediately received and is not written to the bus, does not send acknowledgements
mcp2515.setListenOnlyMode(); // does not send data, only receives data, does not send acknowledgements
```
The available baudrates are listed as follows:
```C++
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=autowp-mcp2515
version=1.2.1
version=1.3.1
author=autowp <[email protected]>
maintainer=autowp <[email protected]>
sentence=Arduino MCP2515 CAN interface library
Expand Down
9 changes: 7 additions & 2 deletions mcp2515.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,14 @@ MCP2515::ERROR MCP2515::setNormalMode()
return setMode(CANCTRL_REQOP_NORMAL);
}

MCP2515::ERROR MCP2515::setNormalOneShotMode()
{
return setMode(CANCTRL_REQOP_OSM);
}

MCP2515::ERROR MCP2515::setMode(const CANCTRL_REQOP_MODE mode)
{
modifyRegister(MCP_CANCTRL, CANCTRL_REQOP, mode);
modifyRegister(MCP_CANCTRL, CANCTRL_REQOP | CANCTRL_OSM, mode);

unsigned long endTime = millis() + 10;
bool modeMatch = false;
Expand Down Expand Up @@ -776,4 +781,4 @@ uint8_t MCP2515::errorCountRX(void)
uint8_t MCP2515::errorCountTX(void)
{
return readRegister(MCP_TEC);
}
}
4 changes: 3 additions & 1 deletion mcp2515.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class MCP2515

enum /*class*/ CANCTRL_REQOP_MODE : uint8_t {
CANCTRL_REQOP_NORMAL = 0x00,
CANCTRL_REQOP_OSM = 0x08,
CANCTRL_REQOP_SLEEP = 0x20,
CANCTRL_REQOP_LOOPBACK = 0x40,
CANCTRL_REQOP_LISTENONLY = 0x60,
Expand Down Expand Up @@ -473,6 +474,7 @@ class MCP2515
ERROR setSleepMode();
ERROR setLoopbackMode();
ERROR setNormalMode();
ERROR setNormalOneShotMode();
ERROR setClkOut(const CAN_CLKOUT divisor);
ERROR setBitrate(const CAN_SPEED canSpeed);
ERROR setBitrate(const CAN_SPEED canSpeed, const CAN_CLOCK canClock);
Expand All @@ -498,4 +500,4 @@ class MCP2515
uint8_t errorCountTX(void);
};

#endif
#endif