From 5836e30fc1b3adc2510e6b24563d99227ad782c5 Mon Sep 17 00:00:00 2001 From: Stephan Walter Date: Thu, 8 Oct 2020 09:16:17 +0200 Subject: [PATCH] doc: End time comparison is wrong in my_wait_for_event sample code We need to loop while `end` is still in the future and thus larger than the current uptime, not smaller. Also fix indentation. Signed-off-by: Stephan Walter --- doc/reference/kernel/timing/clocks.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/reference/kernel/timing/clocks.rst b/doc/reference/kernel/timing/clocks.rst index 4518b521ab3..7d6397082e2 100644 --- a/doc/reference/kernel/timing/clocks.rst +++ b/doc/reference/kernel/timing/clocks.rst @@ -352,13 +352,13 @@ expire. So such a loop might look like: /* Compute the end time from the timeout */ uint64_t end = z_timeout_end_calc(timeout_in_ms); - while (end < k_uptime_ticks()) { - if (is_event_complete(obj)) { - return; - } + while (end > k_uptime_ticks()) { + if (is_event_complete(obj)) { + return; + } - /* Wait for notification of state change */ - k_sem_take(obj->sem, timeout_in_ms); + /* Wait for notification of state change */ + k_sem_take(obj->sem, timeout_in_ms); } }