mirror of
https://github.com/Seeed-Studio/Seeed_Arduino_CAN.git
synced 2026-07-27 19:55:59 +00:00
minor changes
This commit is contained in:
+7
-7
@@ -294,7 +294,7 @@ void MCP_CAN::initCANBuffers(void)
|
||||
** Function name: mcp2515_init
|
||||
** Descriptions: init the device
|
||||
*********************************************************************************************************/
|
||||
MCP_CAN::ERROR MCP_CAN::mcp2515_init(const CAN_SPEED canSpeed) /* mcp2515init */
|
||||
MCP_CAN::ERROR MCP_CAN::mcp2515_init(const CAN_SPEED canSpeed)
|
||||
{
|
||||
mcp2515_reset();
|
||||
|
||||
@@ -319,7 +319,7 @@ MCP_CAN::ERROR MCP_CAN::mcp2515_init(const CAN_SPEED canSpeed)
|
||||
MCP_RXB_RX_STDEXT | MCP_RXB_BUKT_MASK );
|
||||
modifyRegister(MCP_RXB1CTRL, MCP_RXB_RX_MASK,
|
||||
MCP_RXB_RX_STDEXT);
|
||||
/* enter normal mode */
|
||||
|
||||
res = setCANCTRL_Mode(m_mode);
|
||||
delay(10);
|
||||
|
||||
@@ -331,13 +331,13 @@ MCP_CAN::ERROR MCP_CAN::mcp2515_init(const CAN_SPEED canSpeed)
|
||||
** Function name: write_id
|
||||
** Descriptions: write can id
|
||||
*********************************************************************************************************/
|
||||
void MCP_CAN::write_id(const REGISTER mcp_addr, const bool ext, const uint32_t id)
|
||||
void MCP_CAN::write_id(const REGISTER reg, const bool ext, const uint32_t id)
|
||||
{
|
||||
uint8_t tbufdata[4];
|
||||
|
||||
prepareId(tbufdata, ext, id);
|
||||
|
||||
setRegisterS(mcp_addr, tbufdata, 4);
|
||||
setRegisterS(reg, tbufdata, 4);
|
||||
}
|
||||
|
||||
void MCP_CAN::prepareId(uint8_t *buffer, const bool ext, const uint32_t id)
|
||||
@@ -536,15 +536,15 @@ MCP_CAN::ERROR MCP_CAN::readMessage(const RXBn rxbn, uint32_t *id, uint8_t *dlc,
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
MCP_CAN::ERROR MCP_CAN::readMessage(uint32_t *id, uint8_t *len, uint8_t buf[], bool *rtr, bool *ext)
|
||||
MCP_CAN::ERROR MCP_CAN::readMessage(uint32_t *id, uint8_t *dlc, uint8_t buf[], bool *rtr, bool *ext)
|
||||
{
|
||||
ERROR rc;
|
||||
uint8_t stat = getStatus();
|
||||
|
||||
if ( stat & STAT_RX0IF ) {
|
||||
rc = readMessage(RXB0, id, len, buf, rtr, ext);
|
||||
rc = readMessage(RXB0, id, dlc, buf, rtr, ext);
|
||||
} else if ( stat & STAT_RX1IF ) {
|
||||
rc = readMessage(RXB1, id, len, buf, rtr, ext);
|
||||
rc = readMessage(RXB1, id, dlc, buf, rtr, ext);
|
||||
} else {
|
||||
rc = ERROR_NOMSG;
|
||||
}
|
||||
|
||||
@@ -231,33 +231,24 @@ class MCP_CAN
|
||||
|
||||
private:
|
||||
|
||||
void mcp2515_reset(void); /* reset mcp2515 */
|
||||
void mcp2515_reset(void);
|
||||
|
||||
uint8_t readRegister(const REGISTER reg); /* read mcp2515's register */
|
||||
uint8_t readRegister(const REGISTER reg);
|
||||
|
||||
void readRegisterS(const REGISTER reg,
|
||||
uint8_t values[],
|
||||
const uint8_t n);
|
||||
void setRegister(const REGISTER reg, /* set mcp2515's register */
|
||||
const uint8_t value);
|
||||
void readRegisterS(const REGISTER reg, uint8_t values[], const uint8_t n);
|
||||
void setRegister(const REGISTER reg, const uint8_t value);
|
||||
|
||||
void setRegisterS(const REGISTER reg, /* set mcp2515's registers */
|
||||
const uint8_t values[],
|
||||
const uint8_t n);
|
||||
void setRegisterS(const REGISTER reg, const uint8_t values[], const uint8_t n);
|
||||
|
||||
void initCANBuffers(void);
|
||||
|
||||
void modifyRegister(const REGISTER reg,
|
||||
const uint8_t mask,
|
||||
const uint8_t data);
|
||||
void modifyRegister(const REGISTER reg, const uint8_t mask, const uint8_t data);
|
||||
|
||||
ERROR setCANCTRL_Mode(const MODE newmode);
|
||||
ERROR configRate(const CAN_SPEED canSpeed);
|
||||
ERROR mcp2515_init(const CAN_SPEED canSpeed);
|
||||
|
||||
void write_id(const REGISTER mcp_addr,
|
||||
const bool ext,
|
||||
const uint32_t id);
|
||||
void write_id(const REGISTER reg, const bool ext, const uint32_t id);
|
||||
|
||||
void prepareId(uint8_t *buffer, const bool ext, const uint32_t id);
|
||||
|
||||
@@ -266,14 +257,14 @@ class MCP_CAN
|
||||
|
||||
public:
|
||||
MCP_CAN(const uint8_t _CS, const MODE mode);
|
||||
ERROR begin(const CAN_SPEED speedset); /* init can */
|
||||
ERROR initMask(const uint8_t num, const bool ext, const uint32_t ulData); /* init Masks */
|
||||
ERROR initFilt(const RXF num, const bool ext, const uint32_t ulData); /* init filters */
|
||||
ERROR sendMessage(const uint32_t id, const bool ext, const bool rtr, const uint8_t len, const uint8_t *buf); /* send buf */
|
||||
ERROR readMessage(const RXBn rxbn, uint32_t *id, uint8_t *dlc, uint8_t buf[], bool *rtr, bool *ext); /* read can msg */
|
||||
ERROR readMessage(uint32_t *ID, uint8_t *len, uint8_t buf[], bool *rtr, bool *ext); /* read buf with object ID */
|
||||
bool checkReceive(void); /* if something received */
|
||||
bool checkError(void); /* if something error */
|
||||
ERROR begin(const CAN_SPEED speedset);
|
||||
ERROR initMask(const uint8_t num, const bool ext, const uint32_t ulData);
|
||||
ERROR initFilt(const RXF num, const bool ext, const uint32_t ulData);
|
||||
ERROR sendMessage(const uint32_t id, const bool ext, const bool rtr, const uint8_t len, const uint8_t *buf);
|
||||
ERROR readMessage(const RXBn rxbn, uint32_t *id, uint8_t *dlc, uint8_t buf[], bool *rtr, bool *ext);
|
||||
ERROR readMessage(uint32_t *id, uint8_t *dlc, uint8_t buf[], bool *rtr, bool *ext);
|
||||
bool checkReceive(void);
|
||||
bool checkError(void);
|
||||
uint8_t getInterrupts(void);
|
||||
uint8_t getInterruptMask(void);
|
||||
void clearInterrupts(void);
|
||||
|
||||
Reference in New Issue
Block a user