mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-07-27 19:55:59 +00:00
Merge branch 'master' of https://github.com/Seeed-Studio/CAN_BUS_Shield
This commit is contained in:
+35
-8
@@ -65,8 +65,7 @@ void MCP_CAN::mcp2515_readRegisterS(const INT8U address, INT8U values[], const I
|
||||
spi_readwrite(MCP_READ);
|
||||
spi_readwrite(address);
|
||||
// mcp2515 has auto-increment of address-pointer
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
for (i=0; i<n && i<CAN_MAX_CHAR_IN_MESSAGE; i++) {
|
||||
values[i] = spi_read();
|
||||
}
|
||||
MCP2515_UNSELECT();
|
||||
@@ -789,12 +788,40 @@ INT8U MCP_CAN::readMsg()
|
||||
*********************************************************************************************************/
|
||||
INT8U MCP_CAN::readMsgBuf(INT8U *len, INT8U buf[])
|
||||
{
|
||||
readMsg();
|
||||
*len = m_nDlc;
|
||||
for(int i = 0; i<m_nDlc; i++)
|
||||
{
|
||||
buf[i] = m_nDta[i];
|
||||
INT8U rc;
|
||||
|
||||
rc = readMsg();
|
||||
|
||||
if (rc == CAN_OK) {
|
||||
*len = m_nDlc;
|
||||
for(int i = 0; i<m_nDlc; i++) {
|
||||
buf[i] = m_nDta[i];
|
||||
}
|
||||
} else {
|
||||
*len = 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
** Function name: readMsgBufID
|
||||
** Descriptions: read message buf and can bus source ID
|
||||
*********************************************************************************************************/
|
||||
INT8U MCP_CAN::readMsgBufID(INT32U *ID, INT8U *len, INT8U buf[])
|
||||
{
|
||||
INT8U rc;
|
||||
rc = readMsg();
|
||||
|
||||
if (rc == CAN_OK) {
|
||||
*len = m_nDlc;
|
||||
*ID = m_nID;
|
||||
for(int i = 0; i<m_nDlc && i < MAX_CHAR_IN_MESSAGE; i++) {
|
||||
buf[i] = m_nDta[i];
|
||||
}
|
||||
} else {
|
||||
*len = 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*********************************************************************************************************
|
||||
@@ -843,4 +870,4 @@ INT32U MCP_CAN::getCanId(void)
|
||||
}
|
||||
/*********************************************************************************************************
|
||||
END FILE
|
||||
*********************************************************************************************************/
|
||||
*********************************************************************************************************/
|
||||
|
||||
@@ -101,6 +101,7 @@ public:
|
||||
INT8U init_Filt(INT8U num, INT8U ext, INT32U ulData); /* init filters */
|
||||
INT8U sendMsgBuf(INT32U id, INT8U ext, INT8U len, INT8U *buf); /* send buf */
|
||||
INT8U readMsgBuf(INT8U *len, INT8U *buf); /* read buf */
|
||||
INT8U readMsgBufID(INT32U *ID, INT8U *len, INT8U *buf); /* read buf with object ID */
|
||||
INT8U checkReceive(void); /* if something received */
|
||||
INT8U checkError(void); /* if something error */
|
||||
INT32U getCanId(void); /* get can id when receive */
|
||||
|
||||
Reference in New Issue
Block a user