From 4d9670d6245cc381313a3ff41dd80f6596a266c8 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Tue, 4 Mar 2014 21:54:02 +0100 Subject: [PATCH] lock irq when retrieving time --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 326ce64..1b9bc97 100644 --- 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) -- 2.39.5