From ce09f2c208366d7864a9141187410bbdd69b590c Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Sat, 19 Dec 2020 15:45:42 +0100 Subject: [PATCH] kbd_task: Get timestamp after mutex to avoid getting incorrect timestamp on mutex blocking --- openrtx/src/threads.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index 7796090e..6f9f4501 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -170,11 +170,11 @@ static void kbd_task(void *arg) // Reset flags and get current time long_press = false; send_event = false; - now = OSTimeGet(&os_err); // Lock display mutex and read keyboard status OSMutexPend(&display_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err); keys = kbd_getKeys(); OSMutexPost(&display_mutex, OS_OPT_POST_NONE, &os_err); + now = OSTimeGet(&os_err); // The key status has changed if(keys != prev_keys) {