summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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