diff --git a/src/ArduinoMCP2515.cpp b/src/ArduinoMCP2515.cpp index 0a02164..7c5f61f 100644 --- a/src/ArduinoMCP2515.cpp +++ b/src/ArduinoMCP2515.cpp @@ -122,19 +122,19 @@ void ArduinoMCP2515::onExternalEventHandler() bool ArduinoMCP2515::transmitCANFrame(uint32_t const id, uint8_t const * data, uint8_t const len) { - uint8_t const status = _ctrl.status(); - - if (isBitClr(status, bp(STATUS::TX0REQ))) + if (isBitClr(_io.readRegister(Register::TXB0CTRL), bp(TXBnCTRL::TXREQ))) { _ctrl.transmit(TxB::TxB0, id, data, len); return true; } - else if (isBitClr(status, bp(STATUS::TX1REQ))) + + if (isBitClr(_io.readRegister(Register::TXB1CTRL), bp(TXBnCTRL::TXREQ))) { _ctrl.transmit(TxB::TxB1, id, data, len); return true; } - else if (isBitClr(status, bp(STATUS::TX2REQ))) + + if (isBitClr(_io.readRegister(Register::TXB2CTRL), bp(TXBnCTRL::TXREQ))) { _ctrl.transmit(TxB::TxB2, id, data, len); return true; diff --git a/src/MCP2515/MCP2515_Const.h b/src/MCP2515/MCP2515_Const.h index 71cf2f9..05c6cd5 100644 --- a/src/MCP2515/MCP2515_Const.h +++ b/src/MCP2515/MCP2515_Const.h @@ -212,6 +212,11 @@ enum class CANSTAT : uint8_t OPMOD0 = 5 }; +enum class TXBnCTRL : uint8_t +{ + TXREQ = 3, +}; + /************************************************************************************** * CONVERSION FUNCTIONS **************************************************************************************/