Skip to content

Commit e1c517f

Browse files
added One Shot Mode support
1 parent a2cece4 commit e1c517f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

mcp2515.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ MCP2515::MCP2515(const uint8_t _CS, const uint32_t _SPI_CLOCK, SPIClass * _SPI)
2626
SPI_CLOCK = _SPI_CLOCK;
2727
pinMode(SPICS, OUTPUT);
2828
digitalWrite(SPICS, HIGH);
29+
OSMflag = false;
2930
}
3031

3132
void MCP2515::startSPI() {
@@ -179,7 +180,7 @@ MCP2515::ERROR MCP2515::setNormalMode()
179180

180181
MCP2515::ERROR MCP2515::setMode(const CANCTRL_REQOP_MODE mode)
181182
{
182-
modifyRegister(MCP_CANCTRL, CANCTRL_REQOP, mode);
183+
modifyRegister(MCP_CANCTRL, CANCTRL_REQOP | CANCTRL_OSM, OSMflag ? mode | CANCTRL_OSM : mode & ~(CANCTRL_OSM));
183184

184185
unsigned long endTime = millis() + 10;
185186
bool modeMatch = false;
@@ -777,3 +778,13 @@ uint8_t MCP2515::errorCountTX(void)
777778
{
778779
return readRegister(MCP_TEC);
779780
}
781+
782+
// these merely set the OSM flag
783+
// setMode(...) or the other setXxxxMode() i.e: setNormalMode() must be called afterwards to set the correct mode with OSM
784+
void MCP2515::enableOSM(void) {
785+
OSMflag = true;
786+
}
787+
788+
void MCP2515::disableOSM(void) {
789+
OSMflag = false;
790+
}

0 commit comments

Comments
 (0)