Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / src / kernel / ao_flight.c
index 4a7055c415e80d9eef3d86eacae715ce4f8b416b..cee8b2b8b38d008c16460b5c293b8c4b326c005d 100644 (file)
@@ -50,8 +50,8 @@
 /* Main flight thread. */
 
 enum ao_flight_state   ao_flight_state;        /* current flight state */
-uint16_t               ao_boost_tick;          /* time of most recent boost detect */
-uint16_t               ao_launch_tick;         /* time of first boost detect */
+AO_TICK_TYPE           ao_boost_tick;          /* time of most recent boost detect */
+AO_TICK_TYPE           ao_launch_tick;         /* time of first boost detect */
 uint16_t               ao_motor_number;        /* number of motors burned so far */
 
 #if HAS_SENSOR_ERRORS
@@ -63,7 +63,7 @@ uint8_t                       ao_sensor_errors;
  * track min/max data over a long interval to detect
  * resting
  */
-static uint16_t                ao_interval_end;
+static AO_TICK_TYPE    ao_interval_end;
 #ifdef HAS_BARO
 static ao_v_t          ao_interval_min_height;
 static ao_v_t          ao_interval_max_height;
@@ -272,7 +272,7 @@ ao_flight(void)
                         * (15 seconds) has past.
                         */
                        if ((ao_accel < AO_MSS_TO_ACCEL(-2.5)) ||
-                           (int16_t) (ao_sample_tick - ao_boost_tick) > BOOST_TICKS_MAX)
+                           (AO_TICK_SIGNED) (ao_sample_tick - ao_boost_tick) > (AO_TICK_SIGNED) BOOST_TICKS_MAX)
                        {
 #if HAS_ACCEL
 #if HAS_BARO
@@ -319,8 +319,8 @@ ao_flight(void)
                         * number of seconds.
                         */
                        if (ao_config.apogee_lockout) {
-                               if ((int16_t) (ao_sample_tick - ao_launch_tick) <
-                                   AO_SEC_TO_TICKS(ao_config.apogee_lockout))
+                               if ((AO_TICK_SIGNED) (ao_sample_tick - ao_launch_tick) <
+                                   (AO_TICK_SIGNED) AO_SEC_TO_TICKS(ao_config.apogee_lockout))
                                        break;
                        }
 
@@ -363,7 +363,7 @@ ao_flight(void)
 
 #define MAX_QUIET_ACCEL        2
 
-                       if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
+                       if ((AO_TICK_SIGNED) (ao_sample_tick - ao_interval_end) >= 0) {
                                if (ao_interval_max_accel_along - ao_interval_min_accel_along <= ao_data_accel_to_sample(MAX_QUIET_ACCEL) &&
                                    ao_interval_max_accel_across - ao_interval_min_accel_across <= ao_data_accel_to_sample(MAX_QUIET_ACCEL) &&
                                    ao_interval_max_accel_through - ao_interval_min_accel_through <= ao_data_accel_to_sample(MAX_QUIET_ACCEL))
@@ -443,7 +443,7 @@ ao_flight(void)
                        if (ao_avg_height > ao_interval_max_height)
                                ao_interval_max_height = ao_avg_height;
 
-                       if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
+                       if ((AO_TICK_SIGNED) (ao_sample_tick - ao_interval_end) >= 0) {
                                if (ao_interval_max_height - ao_interval_min_height <= AO_M_TO_HEIGHT(4))
                                {
                                        ao_flight_state = ao_flight_landed;