Modified:
/trunk/src/drivers/rf.c
/trunk/src/inc/rf.h
=======================================
--- /trunk/src/drivers/rf.c Tue Jan 18 15:52:22 2011
+++ /trunk/src/drivers/rf.c Wed Jan 19 20:04:13 2011
@@ -25,8 +25,9 @@
#endif
+struct lock objects_lock;
volatile board_coord objects[32];
-volatile uint32_t position_microtime;
+volatile uint32_t position_microtime[32];
#ifndef SIMULATE
@@ -287,8 +288,13 @@
rx->payload.coords[i] = t;
}
}
- memcpy((char *)&objects[(4*rx->seq_no) % 32],
rx->payload.coords, sizeof(rx->payload.coords));
- position_microtime = get_time_us();
+ acquire(&objects_lock);
+ int offset = (4*rx->seq_no) % 32;
+ memcpy((char *)&objects[offset], rx->payload.coords,
sizeof(rx->payload.coords));
+ uint32_t time_us = get_time_us();
+ for (uint8_t i=0;i<4;i++)
+ position_microtime[i+offset] = time_us;
+ release(&objects_lock);
break;
case START:
@@ -402,6 +408,8 @@
// characters to be interleaved between threads
init_lock(&rf_lock, "RF Lock");
+ init_lock(&objects_lock, "objects[] lock");
+
// STRING packets don't contain the null character
// for efficiency. rf_str_buf is one character larger
// than the payload to hold this additional character
=======================================
--- /trunk/src/inc/rf.h Mon Jan 17 22:48:31 2011
+++ /trunk/src/inc/rf.h Wed Jan 19 20:04:13 2011
@@ -12,8 +12,9 @@
* as well as retrieve information received over RF
*/
-extern volatile uint32_t position_microtime;
+extern struct lock objects_lock;
extern volatile board_coord objects[32];
+extern volatile uint32_t position_microtime[32];
#ifndef SIMULATE