diff options
author | Keith Packard <keithp@keithp.com> | 2017-08-24 16:45:54 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-08-27 17:38:58 -0700 |
commit | cf20e213f39fb24f15e0ac94307c2d138fcadecb (patch) | |
tree | 49914763b691edb7164c762a49798294ad9c4350 /src/kernel/ao_flight.c | |
parent | 43e2275250d9c91560a770942f3c06a8f74ed501 (diff) |
altos: Perform time comparisons using 16-bit arithmetic to handle wrap
Subtracting two 16-bit unsigned values to perform time comparisons
yields mystic results unless we carefully cast that to int16_t.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/kernel/ao_flight.c')
-rw-r--r-- | src/kernel/ao_flight.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index 50f2b68f..b0d911ed 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -269,7 +269,7 @@ ao_flight(void) * number of seconds. */ if (ao_config.apogee_lockout) { - if ((ao_sample_tick - ao_boost_tick) < + if ((int16_t) (ao_sample_tick - ao_boost_tick) < AO_SEC_TO_TICKS(ao_config.apogee_lockout)) break; } |