From d91d26ffc2a763469d403a8a297b2905785e80a8 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Mon, 10 Oct 2011 00:17:48 +0200 Subject: Lock xbee while writing a message. --- xbee.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xbee.h b/xbee.h index 53f9288..f868972 100644 --- a/xbee.h +++ b/xbee.h @@ -1,7 +1,13 @@ #ifndef XBEE_H #define XBEE_H +#include "mutex.h" + +Mutex xbm; + void xbee_send(uint16_t type, int len, const uint8_t* buf) { + xbm.lock(); + // Start and length. usart_send(0x7e); usart_send(((len + 16) >> 8) & 0xff); @@ -40,6 +46,8 @@ void xbee_send(uint16_t type, int len, const uint8_t* buf) { } usart_send(chsum); + + xbm.unlock(); } #endif -- cgit v1.2.3