Skip to content

Commit fab3ce5

Browse files
committed
Correct TX failure handling
1 parent f01f9e4 commit fab3ce5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/CAN.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,18 @@ int CANClass::endPacket()
254254

255255
writeRegister(REG_TXBnCTRL(n), 0x08);
256256

257-
while (readRegister(REG_TXBnCTRL(n)) & 0x09) {
257+
while (readRegister(REG_TXBnCTRL(n)) & 0x08) {
258+
if (readRegister(REG_TXBnCTRL(n)) & 0x10) {
259+
// abort
260+
modifyRegister(REG_CANCTRL, 0x10, 0x10);
261+
}
262+
258263
yield();
259264
}
260265

261266
modifyRegister(REG_CANINTF, FLAG_TXnIF(n), 0x00);
262267

263-
return (readRegister(REG_TXBnCTRL(n)) & 0x50) ? 0 : 1;
268+
return (readRegister(REG_TXBnCTRL(n)) & 0x70) ? 0 : 1;
264269
}
265270

266271
int CANClass::parsePacket()

0 commit comments

Comments
 (0)