From 4e2e5d88bce6a9e81ca2d3424a97b1de5d19281b Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 20 Jun 2012 22:44:10 +0200 Subject: mcp2515: clear RTS after TX error --- can.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/can.c b/can.c index 16b66a0..5cc879a 100644 --- a/can.c +++ b/can.c @@ -191,13 +191,22 @@ static void can_int(void) if (canintf & 0x80 || canintf & 0x04) { uint8_t txb0ctrl; spi_ss(0); - spi_wrrd(0x03); - spi_wrrd(0x30); + spi_wrrd(MCP2515_READ); + spi_wrrd(A_TXB0CTRL); txb0ctrl = spi_wrrd(0xff); spi_ss(1); uart_puts("can: TXB0CTRL "); uart_puthex(txb0ctrl); uart_puts("\n"); + + /* clear RTS */ + if (txb0ctrl & 0x08) { + spi_ss(0); + spi_wrrd(MCP2515_WRITE); + spi_wrrd(A_TXB0CTRL); + spi_wrrd(0x00); + spi_ss(1); + } } if (canintf & 0x01) can_rxh(0); -- cgit v1.2.1