]> git.droids-corp.org - protos/xbee-avr.git/commitdiff
lock irq when retrieving time
authorOlivier Matz <zer0@droids-corp.org>
Tue, 4 Mar 2014 20:54:02 +0000 (21:54 +0100)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 9 Mar 2014 21:13:08 +0000 (22:13 +0100)
main.c

diff --git a/main.c b/main.c
index 326ce64930ee66be51ad0e79e915e940ef4a43f9..1b9bc971fca111c87614b7699955904608d813ed 100644 (file)
--- a/main.c
+++ b/main.c
@@ -91,7 +91,12 @@ void bootloader(void)
 /* return time in milliseconds on unsigned 16 bits */
 static uint16_t get_time_ms(void)
 {
-       return (uint16_t)global_ms;
+       uint16_t ms;
+       uint8_t flags;
+       IRQ_LOCK(flags);
+       ms = global_ms;
+       IRQ_UNLOCK(flags);
+       return ms;
 }
 
 static void main_timer_interrupt(void)