Merge branch 'master'
[fw/altos] / src / drivers / ao_gps_ublox.c
index 57cbf22a77b50245975955925096ba85ac9723f5..3d615e9c933f14b260f3cd0fb75faeec68073a3c 100644 (file)
@@ -29,6 +29,7 @@
 uint8_t ao_gps_new;
 uint8_t ao_gps_mutex;
 AO_TICK_TYPE ao_gps_tick;
+AO_TICK_TYPE ao_gps_utc_tick;
 struct ao_telemetry_location   ao_gps_data;
 struct ao_telemetry_satellite  ao_gps_tracking_data;
 
@@ -63,12 +64,13 @@ static uint16_t ao_ublox_len;
 
 #if AO_UBLOX_DEBUG
 
-static uint8_t ao_gps_dbg_enable;
 
 #define DBG_PROTO      1
 #define DBG_CHAR       2
 #define DBG_INIT       4
 
+static uint8_t ao_gps_dbg_enable = DBG_PROTO|DBG_CHAR|DBG_INIT;
+
 static void ao_gps_dbg(int level, char *format, ...) {
        va_list a;
 
@@ -397,6 +399,7 @@ ao_ublox_parse_nav_svinfo(void)
  * NAV-TIMEUTC message parsing
  */
 static struct nav_timeutc {
+       int32_t         nano;
        uint16_t        year;
        uint8_t         month;
        uint8_t         day;
@@ -411,7 +414,8 @@ static struct nav_timeutc {
 #define NAV_TIMEUTC_VALID_UTC  2
 
 static const struct ublox_packet_parse nav_timeutc_packet[] = {
-       { UBLOX_DISCARD, 12 },                                          /* 0 iTOW, tAcc, nano */
+       { UBLOX_DISCARD, 8 },                                           /* 0 iTOW, tAcc */
+       { UBLOX_U32, offsetof(struct nav_timeutc, nano) },              /* 8 nano */
        { UBLOX_U16, offsetof(struct nav_timeutc, year) },              /* 12 year */
        { UBLOX_U8, offsetof(struct nav_timeutc, month) },              /* 14 month */
        { UBLOX_U8, offsetof(struct nav_timeutc, day) },                /* 15 day */
@@ -721,7 +725,7 @@ ao_gps(void)
                        case UBLOX_NAV_TIMEUTC:
                                ao_mutex_get(&ao_gps_mutex);
                                ao_gps_tick = solution_tick;
-
+                               ao_gps_utc_tick = packet_start_tick + (AO_TICK_TYPE) AO_NS_TO_TICKS(nav_timeutc.nano);
                                ao_gps_data.flags = 0;
                                ao_gps_data.flags |= AO_GPS_RUNNING;
                                if (nav_sol.gps_fix & (1 << NAV_SOL_FLAGS_GPSFIXOK)) {
@@ -788,7 +792,7 @@ ao_gps(void)
 #if AO_UBLOX_DEBUG
 static void ao_gps_option(void)
 {
-       uint16_t r = ao_cmd_hex();
+       uint8_t r = (uint8_t) ao_cmd_hex();
        if (ao_cmd_status != ao_cmd_success) {
                ao_cmd_status = ao_cmd_success;
                ao_gps_show();