mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-09-15 11:03:48 +00:00
Add "mode" parameter to constructor
This commit is contained in:
+13
-3
@@ -390,7 +390,7 @@ INT8U MCP_CAN::mcp2515_init(const INT8U canSpeed) /* mcp25
|
||||
MCP_RXB_RX_STDEXT);
|
||||
#endif
|
||||
/* enter normal mode */
|
||||
res = mcp2515_setCANCTRL_Mode(MODE_NORMAL);
|
||||
res = mcp2515_setCANCTRL_Mode(m_mode);
|
||||
if(res)
|
||||
{
|
||||
#if DEBUG_MODE
|
||||
@@ -553,6 +553,16 @@ INT8U MCP_CAN::mcp2515_getNextFreeTXBuf(INT8U *txbuf_n) /* get N
|
||||
*********************************************************************************************************/
|
||||
MCP_CAN::MCP_CAN(INT8U _CS)
|
||||
{
|
||||
MCP_CAN(_CS, MODE_NORMAL);
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
** Function name: set CS
|
||||
** Descriptions: init CS pin and set UNSELECTED
|
||||
*********************************************************************************************************/
|
||||
MCP_CAN::MCP_CAN(INT8U _CS, INT8U mode)
|
||||
{
|
||||
m_mode = mode;
|
||||
SPICS = _CS;
|
||||
pinMode(SPICS, OUTPUT);
|
||||
MCP2515_UNSELECT();
|
||||
@@ -603,7 +613,7 @@ INT8U MCP_CAN::init_Mask(INT8U num, INT8U ext, INT32U ulData)
|
||||
}
|
||||
else res = MCP2515_FAIL;
|
||||
|
||||
res = mcp2515_setCANCTRL_Mode(MODE_NORMAL);
|
||||
res = mcp2515_setCANCTRL_Mode(m_mode);
|
||||
if(res > 0){
|
||||
#if DEBUG_MODE
|
||||
Serial.print("Enter normal mode fall\r\n");
|
||||
@@ -673,7 +683,7 @@ INT8U MCP_CAN::init_Filt(INT8U num, INT8U ext, INT32U ulData)
|
||||
res = MCP2515_FAIL;
|
||||
}
|
||||
|
||||
res = mcp2515_setCANCTRL_Mode(MODE_NORMAL);
|
||||
res = mcp2515_setCANCTRL_Mode(m_mode);
|
||||
if(res > 0)
|
||||
{
|
||||
#if DEBUG_MODE
|
||||
|
||||
@@ -40,6 +40,7 @@ class MCP_CAN
|
||||
INT8U m_nRtr; /* rtr */
|
||||
INT8U m_nfilhit;
|
||||
INT8U SPICS;
|
||||
INT8U m_mode;
|
||||
|
||||
/*
|
||||
* mcp2515 driver function
|
||||
@@ -97,6 +98,7 @@ private:
|
||||
|
||||
public:
|
||||
MCP_CAN(INT8U _CS);
|
||||
MCP_CAN(INT8U _CS, INT8U mode);
|
||||
INT8U begin(INT8U speedset); /* init can */
|
||||
INT8U init_Mask(INT8U num, INT8U ext, INT32U ulData); /* init Masks */
|
||||
INT8U init_Filt(INT8U num, INT8U ext, INT32U ulData); /* init filters */
|
||||
|
||||
Reference in New Issue
Block a user