From 53b0281e610b1c7802e2c953053402671d4de86e Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 10 Mar 2013 04:34:53 +0100 Subject: can: disable IRQs while sending --- can.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/can.c b/can.c index 255cf14..88289c3 100644 --- a/can.c +++ b/can.c @@ -117,6 +117,14 @@ static uint8_t can_CANSTAT(void) return canstat; } +#ifndef R0KET +#define can_irq_cli() EIMSK &= ~(1 << INT0) +#define can_irq_sei() EIMSK |= (1 << INT0) +#else +#define can_irq_cli() cli() +#define can_irq_sei() sei() +#endif + /* daddr: * 31-24 ID 10:3 * 23-16 ID 2:0, x, EXIDE, x, EID17:16 @@ -125,6 +133,8 @@ static uint8_t can_CANSTAT(void) */ static void can_send(uint32_t daddr, uint8_t len, const uint8_t *data) { + can_irq_cli(); + spi_ss(0); spi_wrrd(MCP2515_WRTXB | MCP2515_WRTXB_TXB0); spi_wrrd((daddr >> 24) & 0xff); @@ -136,6 +146,8 @@ static void can_send(uint32_t daddr, uint8_t len, const uint8_t *data) spi_wrrd(*data++); spi_ss(1); spi_perform(MCP2515_RTS | 0x01); + + can_irq_sei(); } #ifndef R0KET -- cgit v1.2.1