summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2013-03-10 04:34:53 +0100
committerDavid Lamparter <equinox@diac24.net>2013-03-10 04:34:53 +0100
commit53b0281e610b1c7802e2c953053402671d4de86e (patch)
tree75398fb3b44017192ed4d00e1004ae327bd4d73e
parent75aa2df2c319a43186c6853dce551d63b3425bdf (diff)
can: disable IRQs while sending
-rw-r--r--can.c12
1 files changed, 12 insertions, 0 deletions
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