gps: dump position in i2c message
[protos/imu.git] / gps_venus.h
index 641bcbb..ca2bd8f 100644 (file)
@@ -4,33 +4,36 @@
 #include <stdint.h>
 
 /* A GPS position structure. It also contains some information about the number
- * of seen satellites, the message ID, the date, .. */
+ * of seen satellites, the message ID, the date, ...
+ * See App Notes AN0028 p68 */
 struct gps_pos {
-       uint8_t msg_id; /* */
-       uint8_t mode;
-       uint8_t sv_num;
-       uint16_t gps_week;
-       uint32_t tow;
-
-       int32_t latitude;
-       int32_t longitude;
-       uint32_t altitude;
-
-       uint32_t sea_altitude;
-
-       uint16_t gdop;
-       uint16_t pdop;
-       uint16_t hdop;
-       uint16_t vdop;
-       uint16_t tdop;
-
-       int32_t ecef_x;
-       int32_t ecef_y;
-       int32_t ecef_z;
-
-       int32_t ecef_vx;
-       int32_t ecef_vy;
-       int32_t ecef_vz;
+       uint8_t msg_id; /* should be A8 */
+       uint8_t mode;   /* Quality of fix 0: none, 1: 2D, 2: 3D, 3: 3D+DGNSS */
+       uint8_t sv_num; /* number of SV in fix (0-12) */
+
+       uint16_t gps_week; /* GNSS week number */
+       uint32_t tow;      /* GNSS time of week */
+
+       int32_t latitude;  /* between -90e7 and 90e7, in 1/1e-7 degrees,
+                           * positive means north hemisphere */
+       int32_t longitude; /* between -180e7 and 180e7, in 1/1e-7 degrees,
+                           * positive means east */
+       uint32_t altitude; /* altitude from elipsoid, in 1/100 meters */
+       uint32_t sea_altitude; /* altitude from sea level, in 1/100 meters */
+
+       uint16_t gdop; /* Geometric dilution of precision */
+       uint16_t pdop; /* Position dilution of precision */
+       uint16_t hdop; /* Horizontal dilution of precision */
+       uint16_t vdop; /* Vertical dilution of precision */
+       uint16_t tdop; /* Timec dilution of precision */
+
+       int32_t ecef_x; /* Earth-Centered, Earth-Fixed X pos, 1/100 meters */
+       int32_t ecef_y; /* Earth-Centered, Earth-Fixed Y pos, 1/100 meters */
+       int32_t ecef_z; /* Earth-Centered, Earth-Fixed Z pos, 1/100 meters */
+
+       int32_t ecef_vx; /* Earth-Centered, Earth-Fixed X speed, 1/100 m/s */
+       int32_t ecef_vy; /* Earth-Centered, Earth-Fixed Y speed, 1/100 m/s */
+       int32_t ecef_vz; /* Earth-Centered, Earth-Fixed Z speed, 1/100 m/s */
 
 } __attribute__ ((packed));
 
@@ -40,4 +43,10 @@ int gps_loop(void);
 /* does not lock intr, must be done by user */
 void gps_get_pos(struct gps_pos *pos);
 
+static inline int8_t gps_pos_valid(struct gps_pos *pos)
+{
+       /* XXX when a GPS position is valid ? */
+       return (pos->mode >= 2 && pos->sv_num >= 5);
+}
+
 #endif