summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2012-06-20 22:44:10 +0200
committerDavid Lamparter <equinox@diac24.net>2012-06-20 22:44:10 +0200
commit4e2e5d88bce6a9e81ca2d3424a97b1de5d19281b (patch)
treedde026ebe8f51b04f410a5b8868110ad1e3c0661
parent6c0e642bd6e6d8697a8a95f167420ecf91bc08b6 (diff)
mcp2515: clear RTS after TX error
-rw-r--r--can.c13
1 files 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);