gps: dump position in i2c message
[protos/imu.git] / gps_venus.h
1 #ifndef _GPS_VENUS_H
2 #define _GPS_VENUS_H
3
4 #include <stdint.h>
5
6 /* A GPS position structure. It also contains some information about the number
7  * of seen satellites, the message ID, the date, ...
8  * See App Notes AN0028 p68 */
9 struct gps_pos {
10         uint8_t msg_id; /* should be A8 */
11         uint8_t mode;   /* Quality of fix 0: none, 1: 2D, 2: 3D, 3: 3D+DGNSS */
12         uint8_t sv_num; /* number of SV in fix (0-12) */
13
14         uint16_t gps_week; /* GNSS week number */
15         uint32_t tow;      /* GNSS time of week */
16
17         int32_t latitude;  /* between -90e7 and 90e7, in 1/1e-7 degrees,
18                             * positive means north hemisphere */
19         int32_t longitude; /* between -180e7 and 180e7, in 1/1e-7 degrees,
20                             * positive means east */
21         uint32_t altitude; /* altitude from elipsoid, in 1/100 meters */
22         uint32_t sea_altitude; /* altitude from sea level, in 1/100 meters */
23
24         uint16_t gdop; /* Geometric dilution of precision */
25         uint16_t pdop; /* Position dilution of precision */
26         uint16_t hdop; /* Horizontal dilution of precision */
27         uint16_t vdop; /* Vertical dilution of precision */
28         uint16_t tdop; /* Timec dilution of precision */
29
30         int32_t ecef_x; /* Earth-Centered, Earth-Fixed X pos, 1/100 meters */
31         int32_t ecef_y; /* Earth-Centered, Earth-Fixed Y pos, 1/100 meters */
32         int32_t ecef_z; /* Earth-Centered, Earth-Fixed Z pos, 1/100 meters */
33
34         int32_t ecef_vx; /* Earth-Centered, Earth-Fixed X speed, 1/100 m/s */
35         int32_t ecef_vy; /* Earth-Centered, Earth-Fixed Y speed, 1/100 m/s */
36         int32_t ecef_vz; /* Earth-Centered, Earth-Fixed Z speed, 1/100 m/s */
37
38 } __attribute__ ((packed));
39
40 int gps_venus_init(void);
41 int gps_loop(void);
42
43 /* does not lock intr, must be done by user */
44 void gps_get_pos(struct gps_pos *pos);
45
46 static inline int8_t gps_pos_valid(struct gps_pos *pos)
47 {
48         /* XXX when a GPS position is valid ? */
49         return (pos->mode >= 2 && pos->sv_num >= 5);
50 }
51
52 #endif