altos: Stop storing pyro fired status in config block
authorKeith Packard <keithp@keithp.com>
Mon, 9 Oct 2017 01:50:59 +0000 (18:50 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 9 Oct 2017 01:53:52 +0000 (18:53 -0700)
We already have the fired status saved in the ao_pyro_fired variable,
so just use that to detect whether a channel has already been fired.

Fixes possible cases where the pyro config data gets written back to
eeprom with the fired bit set, which then inhibits the channel during
flight.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_pyro.c
src/kernel/ao_pyro.h

index 0aed50d5434f65b8b0c7c03190bf47cc5b89160c..e5c30eec42da6e1504880684f773da59760bd482 100644 (file)
@@ -76,7 +76,7 @@ uint16_t      ao_pyro_fired;
 
 #if PYRO_DBG
 int pyro_dbg;
-#define DBG(...)       do { if (pyro_dbg) printf("\t%d: ", (int) (pyro - ao_config.pyro)); printf(__VA_ARGS__); } while (0)
+#define DBG(...)       do { if (pyro_dbg) { printf("\t%d: ", (int) (pyro - ao_config.pyro)); printf(__VA_ARGS__); } } while (0)
 #else
 #define DBG(...)
 #endif
@@ -239,11 +239,8 @@ ao_pyro_pins_fire(uint16_t fire)
        }
        ao_delay(ao_config.pyro_time);
        for (p = 0; p < AO_PYRO_NUM; p++) {
-               if (fire & (1 << p)) {
+               if (fire & (1 << p))
                        ao_pyro_pin_set(p, 0);
-                       ao_config.pyro[p].fired = 1;
-                       ao_pyro_fired |= (1 << p);
-               }
        }
        ao_delay(AO_MS_TO_TICKS(50));
 }
@@ -261,7 +258,7 @@ ao_pyro_check(void)
 
                /* Ignore igniters which have already fired
                 */
-               if (pyro->fired)
+               if (ao_pyro_fired & (1 << p))
                        continue;
 
                /* Ignore disabled igniters
@@ -296,7 +293,7 @@ ao_pyro_check(void)
                         * by setting the fired bit
                         */
                        if (!ao_pyro_ready(pyro)) {
-                               pyro->fired = 1;
+                               ao_pyro_fired |= (1 << p);
                                continue;
                        }
 
@@ -307,8 +304,10 @@ ao_pyro_check(void)
                fire |= (1 << p);
        }
 
-       if (fire)
+       if (fire) {
+               ao_pyro_fired |= fire;
                ao_pyro_pins_fire(fire);
+       }
 
        return any_waiting;
 }
index a730ef1947c21ee683cf39f2f276cdfa9a16db3d..3ab5af3bf8972d2f2e1ae2f79e482cc96b272e8e 100644 (file)
@@ -63,7 +63,7 @@ struct ao_pyro {
        uint8_t                 state_less, state_greater_or_equal;
        int16_t                 motor;
        uint16_t                delay_done;
-       uint8_t                 fired;
+       uint8_t                 _unused;        /* was 'fired' */
 };
 
 #define AO_PYRO_8_BIT_VALUE    (ao_pyro_state_less|ao_pyro_state_greater_or_equal)