]> git.gag.com Git - fw/altos/blob - src/drivers/ao_gps_mosaic.h
88ab03a2b7974a8a6b81a357a65b756b595ba86f
[fw/altos] / src / drivers / ao_gps_mosaic.h
1 /*
2  * Copyright © 2024 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AO_GPS_MOSAIC_H_
20 #define _AO_GPS_MOSAIC_H_
21
22 void
23 ao_gps_mosaic(void);
24
25 struct sbf_header {
26         uint16_t        crc;
27         struct {
28                 uint16_t        id;
29                 uint16_t        length;
30         } h;
31 };
32
33 #define SBF_BLOCK_NUMBER(id)    ((id) & 0x1fff)
34 #define SBF_BLOCK_REVISION(id)  ((id) >> 13)
35
36 #define SBF_MEAS_EPOCH          4027
37
38 struct sbf_meas_epoch {
39         uint32_t        tow;
40         uint16_t        wnc;
41         uint8_t         n1;
42         uint8_t         sb1length;
43         uint8_t         sb2length;
44         uint8_t         commonflags;
45         uint8_t         cumclkjumps;
46         uint8_t         reserved;
47 };
48
49 struct sbf_meas_epoch_channel_type1 {
50         uint8_t         rxchannel;
51         uint8_t         type;
52         uint8_t         svid;
53         uint8_t         misc;
54         uint32_t        codelsb;
55         int32_t         doppler;
56         uint16_t        carrierlsb;
57         int8_t          carriermsb;
58         uint8_t         cn0;
59         uint16_t        locktime;
60         uint8_t         obsinfo;
61         uint8_t         n2;
62 };
63
64 struct sbf_meas_epoch_channel_type2 {
65         uint8_t         type;
66         uint8_t         locktime;
67         uint8_t         cn0;
68         uint8_t         offsetmsb;
69         int8_t          carriermsb;
70         uint8_t         obsinfo;
71         uint16_t        codeoffsetlsb;
72         uint16_t        carrierlsb;
73         uint16_t        doppleroffsetlsb;
74 };
75
76 #define SBF_DOP                 4001
77
78 struct sbf_dop {
79         uint32_t        tow;
80         uint16_t        wnc;
81         uint8_t         nrsv;
82         uint8_t         reserved;
83         uint16_t        pdop;
84         uint16_t        tdop;
85         uint16_t        hdop;
86         uint16_t        vdop;
87         float           hpl;
88         float           vpl;
89 };
90
91 #define SBF_PVT_GEODETIC        4007
92
93 struct sbf_pvt_geodetic {
94         uint32_t        tow;
95         uint16_t        wnc;
96         uint8_t         mode;
97         uint8_t         error;
98         double          latitude;
99         double          longitude;
100         double          height;
101         float           undulation;
102         float           vn;
103         float           ve;
104         float           vu;
105         float           cog;
106         double          rxclkbias;
107         float           rxclkdrift;
108         uint8_t         timesystem;
109         uint8_t         datum;
110         uint8_t         nrsv;
111         uint8_t         wacorrinfo;
112         uint16_t        referenceid;
113         uint16_t        meancorrage;
114         uint32_t        signalinfo;
115         uint8_t         alertflag;
116         uint8_t         nrbases;
117         uint16_t        pppinfo;
118         uint16_t        latency;
119         uint16_t        haccuracy;
120         uint16_t        vaccuracy;
121         uint8_t         misc;
122 };
123
124 #define SBF_RECEIVER_TIME       5914
125
126 struct sbf_receiver_time {
127         uint32_t        tow;
128         uint16_t        wnc;
129         int8_t          utcyear;
130         int8_t          utcmonth;
131         int8_t          utcday;
132         int8_t          utchour;
133         int8_t          utcmin;
134         int8_t          utcsec;
135         int8_t          deltals;
136         uint8_t         synclevel;
137 };
138
139 #define MAX_SBF_DATA    1024
140
141 struct sbf {
142         struct sbf_header       header;
143         union {
144                 struct sbf_receiver_time        receiver_time;
145                 struct sbf_meas_epoch           meas_epoch;
146                 struct sbf_pvt_geodetic         geodetic;
147                 struct sbf_dop                  dop;
148                 uint8_t                         data[MAX_SBF_DATA];
149         };
150 };
151
152 #endif /* _AO_GPS_MOSAIC_H_ */