altos: Pull igniter pins low as soon as possible at boot time
[fw/altos] / src / ao_gps_report.c
index e3e275238bd7f54c2c8b2fabe1e232345a536be4..e57f87443c2bb8debb6f3ca0d346910283767ee7 100644 (file)
 void
 ao_gps_report(void)
 {
-       static __xdata struct ao_log_record     gps_log;
-       static __xdata struct ao_gps_data       gps_data;
+       static __xdata struct ao_log_record             gps_log;
+       static __xdata struct ao_telemetry_location     gps_data;
        uint8_t date_reported = 0;
 
        for (;;) {
                ao_sleep(&ao_gps_data);
                ao_mutex_get(&ao_gps_mutex);
-               memcpy(&gps_data, &ao_gps_data, sizeof (struct ao_gps_data));
+               memcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
                ao_mutex_put(&ao_gps_mutex);
 
                if (!(gps_data.flags & AO_GPS_VALID))
                        continue;
 
-               gps_log.tick = ao_time();
+               gps_log.tick = ao_gps_tick;
                gps_log.type = AO_LOG_GPS_TIME;
                gps_log.u.gps_time.hour = gps_data.hour;
                gps_log.u.gps_time.minute = gps_data.minute;
@@ -51,12 +51,12 @@ ao_gps_report(void)
                gps_log.u.gps_altitude.unused = 0xffff;
                ao_log_data(&gps_log);
                if (!date_reported && (gps_data.flags & AO_GPS_DATE_VALID)) {
-                       date_reported = 1;
                        gps_log.type = AO_LOG_GPS_DATE;
                        gps_log.u.gps_date.year = gps_data.year;
                        gps_log.u.gps_date.month = gps_data.month;
                        gps_log.u.gps_date.day = gps_data.day;
-                       ao_log_data(&gps_log);
+                       gps_log.u.gps_date.extra = 0;
+                       date_reported = ao_log_data(&gps_log);
                }
        }
 }
@@ -64,20 +64,20 @@ ao_gps_report(void)
 void
 ao_gps_tracking_report(void)
 {
-       static __xdata struct ao_log_record     gps_log;
-       static __xdata struct ao_gps_tracking_data      gps_tracking_data;
+       static __xdata struct ao_log_record             gps_log;
+       static __xdata struct ao_telemetry_satellite    gps_tracking_data;
        uint8_t c, n;
 
        for (;;) {
                ao_sleep(&ao_gps_tracking_data);
                ao_mutex_get(&ao_gps_mutex);
-               memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
+               gps_log.tick = ao_gps_tick;
+               memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
                ao_mutex_put(&ao_gps_mutex);
 
                if (!(n = gps_tracking_data.channels))
                        continue;
 
-               gps_log.tick = ao_time();
                gps_log.type = AO_LOG_GPS_SAT;
                for (c = 0; c < n; c++)
                        if ((gps_log.u.gps_sat.svid = gps_tracking_data.sats[c].svid))