Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for One-Shot Mode (OSM) #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions mcp2515.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ MCP2515::ERROR MCP2515::setNormalMode()

MCP2515::ERROR MCP2515::setMode(const CANCTRL_REQOP_MODE mode)
{
// Check for oneshot mode.
mode = osmFlag ? mode | CANCTRL_OSM : mode & ~(CANCTRL_OSM);

modifyRegister(MCP_CANCTRL, CANCTRL_REQOP, mode);

unsigned long endTime = millis() + 10;
Expand Down Expand Up @@ -764,3 +767,11 @@ uint8_t MCP2515::errorCountTX(void)
{
return readRegister(MCP_TEC);
}

void MCP2515::enableOSM(void) {
osmFlag = true;
}

void MCP2515::disableOSM(void) {
osmFlag = false;
}
5 changes: 5 additions & 0 deletions mcp2515.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ class MCP2515
} RXB[N_RXBUFFERS];

uint8_t SPICS;
bool osmFlag = false;

private:

Expand Down Expand Up @@ -490,6 +491,10 @@ class MCP2515
void clearERRIF();
uint8_t errorCountRX(void);
uint8_t errorCountTX(void);

// ONE SHOT MODE
void enableOSM(void);
void disableOSM(void);
};

#endif