summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-10-10 00:17:48 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-10-10 00:17:48 +0200
commitd91d26ffc2a763469d403a8a297b2905785e80a8 (patch)
treefc55c2fb497851938145bb043f7d4af027ede56a
parent9a2a640c575ade2a4589e1954271abe3ed1e3f79 (diff)
Lock xbee while writing a message.
-rw-r--r--xbee.h8
1 files changed, 8 insertions, 0 deletions
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