From 57a6f844e2490a963ce1ef3a2beb9e47258967af Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 21 Feb 2022 09:43:54 -0800 Subject: [PATCH] altos: Document how delay_done is used in ao_pyro.c delay_done is the time at which the delay finishes, but non-zero values also indicate that some delay is pending. Add a comment about why the value is set to 1 when it is zero, and switch the tests of this value to comparisons against zero. Signed-off-by: Keith Packard --- src/kernel/ao_pyro.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index ee94eca3..d4091205 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -303,7 +303,18 @@ ao_pyro_check(void) if (delay < 0) delay = 0; delay_done = ao_time() + (AO_TICK_TYPE) delay; - if (!delay_done) + + /* + * delay_done is the time at which the + * delay ends, but it is also used as + * an indication that a delay is + * active -- non-zero values indicate + * an active delay. This code ensures + * the value is non-zero, which might + * introduce an additional tick + * of delay. + */ + if (delay_done == 0) delay_done = 1; pyro_delay_done[p] = delay_done; } @@ -312,7 +323,7 @@ ao_pyro_check(void) /* Check to see if we're just waiting for * the delay to expire */ - if (pyro_delay_done[p]) { + if (pyro_delay_done[p] != 0) { /* Check to make sure the required conditions * remain valid. If not, inhibit the channel -- 2.30.2