Skip to content

Commit 37e4969

Browse files
committed
Fix persistently set abort transmission flag after first error
1 parent 1c1ade2 commit 37e4969

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/MCP2515.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,24 @@ int MCP2515Class::endPacket()
187187

188188
writeRegister(REG_TXBnCTRL(n), 0x08);
189189

190+
bool aborted = false;
191+
190192
while (readRegister(REG_TXBnCTRL(n)) & 0x08) {
191193
if (readRegister(REG_TXBnCTRL(n)) & 0x10) {
192194
// abort
195+
aborted = true;
196+
193197
modifyRegister(REG_CANCTRL, 0x10, 0x10);
194198
}
195199

196200
yield();
197201
}
198202

203+
if (aborted) {
204+
// clear abort command
205+
modifyRegister(REG_CANCTRL, 0x10, 0x00);
206+
}
207+
199208
modifyRegister(REG_CANINTF, FLAG_TXnIF(n), 0x00);
200209

201210
return (readRegister(REG_TXBnCTRL(n)) & 0x70) ? 0 : 1;

0 commit comments

Comments
 (0)