annotate Small_CPU/Src/GNSS.c @ 942:06aaccaf2e02 Evo_2_23

Power down gnss module during dive: The gnss modul will now be send to powerdown at the start of the dive. After end of dive the module returns to normal operation. For development / test purpose a new simulated dive profile has been added.
author Ideenmodellierer
date Mon, 16 Dec 2024 19:09:00 +0100
parents 4a406e873a95
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
1 /*
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
2 * GNSS.c
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
3 *
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
4 * Created on: 03.10.2020
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
5 * Author: SimpleMethod
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
6 *
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
7 *Copyright 2020 SimpleMethod
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
8 *
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
9 *Permission is hereby granted, free of charge, to any person obtaining a copy of
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
10 *this software and associated documentation files (the "Software"), to deal in
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
11 *the Software without restriction, including without limitation the rights to
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
12 *use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
13 *of the Software, and to permit persons to whom the Software is furnished to do
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
14 *so, subject to the following conditions:
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
15 *
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
16 *The above copyright notice and this permission notice shall be included in all
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
17 *copies or substantial portions of the Software.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
18 *
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
19 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
20 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
21 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
22 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
23 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
24 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
25 *THE SOFTWARE.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
26 ******************************************************************************
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
27 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
28
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
29 #include <string.h>
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
30 #include "GNSS.h"
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
31
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
32 union u_Short uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
33 union i_Short iShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
34 union u_Long uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
35 union i_Long iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
36
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
37 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
38 * Structure initialization.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
39 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
40 * @param huart Pointer to uart handle.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
41 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
42 void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
43 GNSS->huart = huart;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
44 GNSS->year = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
45 GNSS->month = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
46 GNSS->day = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
47 GNSS->hour = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
48 GNSS->min = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
49 GNSS->sec = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
50 GNSS->fixType = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
51 GNSS->lon = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
52 GNSS->lat = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
53 GNSS->height = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
54 GNSS->hMSL = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
55 GNSS->hAcc = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
56 GNSS->vAcc = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
57 GNSS->gSpeed = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
58 GNSS->headMot = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
59 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
60
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
61 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
62 * Parse data to unique chip ID standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
63 * Look at: 32.19.1.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
64 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
65 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
66 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS) {
942
06aaccaf2e02 Power down gnss module during dive:
Ideenmodellierer
parents: 940
diff changeset
67 for (int var = 0; var < 5; var++) {
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
68 GNSS->uniqueID[var] = GNSS_Handle.uartWorkingBuffer[10 + var];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
69 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
70 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
71
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
72 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
73 * Parse data to navigation position velocity time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
74 * Look at: 32.17.15.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
75 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
76 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
77 void GNSS_ParsePVTData(GNSS_StateHandle *GNSS) {
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
78
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
79 static float searchCnt = 1.0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
80
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
81 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
82 GNSS->yearBytes[0]=GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
83 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
84 GNSS->yearBytes[1]=GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
85 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
86 GNSS->month = GNSS_Handle.uartWorkingBuffer[12];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
87 GNSS->day = GNSS_Handle.uartWorkingBuffer[13];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
88 GNSS->hour = GNSS_Handle.uartWorkingBuffer[14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
89 GNSS->min = GNSS_Handle.uartWorkingBuffer[15];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
90 GNSS->sec = GNSS_Handle.uartWorkingBuffer[16];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
91 GNSS->fixType = GNSS_Handle.uartWorkingBuffer[26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
92
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
93 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
94 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
95 GNSS->lonBytes[var]= GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
96 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
97 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
98 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
99 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
100 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
101 GNSS->latBytes[var]=GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
102 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
103 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
104 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
105 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
106 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 38];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
107 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
108 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
109
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
110 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
111 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
112 GNSS->hMSLBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
113 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
114 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
115
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
116 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
117 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 46];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
118 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
119 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
120
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
121 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
122 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 50];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
123 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
124 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
125
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
126 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
127 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
128 GNSS->gSpeedBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
129 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
130 GNSS->gSpeed = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
131
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
132 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
133 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 70];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
134 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
135 GNSS->headMot = iLong.iLong * 1e-5; // todo I'm not sure this good options.
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
136
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
137 if((GNSS->fLat == 0.0) && (GNSS->fLon == 0.0))
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
138 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
139 GNSS->fLat = searchCnt++;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
140 }
940
4a406e873a95 GNSS improvments:
Ideenmodellierer
parents: 932
diff changeset
141
4a406e873a95 GNSS improvments:
Ideenmodellierer
parents: 932
diff changeset
142 GNSS->alive = !GNSS->alive;
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
143 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
144
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
145 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
146 * Parse data to UTC time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
147 * Look at: 32.17.30.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
148 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
149 */
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
150 void GNSS_ParseNavSatData(GNSS_StateHandle *GNSS) {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
151
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
152 uint8_t loop = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
153 uint8_t searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
154 uint8_t statIndex = 0; /* only 4 state information will be forwarded */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
155 uint8_t signalQuality = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
156 GNSS->numSat = GNSS_Handle.uartWorkingBuffer[11];
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
157
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
158 memset(GNSS->statSat, 0, sizeof(GNSS->statSat));
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
159
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
160 if(GNSS->numSat > 0)
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
161 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
162 searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
163 while((searchIndex < GNSS->numSat) && (statIndex < 4)) /* get good signal quality */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
164 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
165 signalQuality = (GNSS_Handle.uartWorkingBuffer[22 + searchIndex * 12] & 0x7);
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
166 if(signalQuality > 4)
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
167 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
168 GNSS->statSat[statIndex++] = signalQuality;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
169 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
170 if(statIndex == 4) break;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
171 searchIndex++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
172 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
173 searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
174 while((searchIndex < GNSS->numSat) && (statIndex < 4)) /* get medium signal quality */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
175 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
176 signalQuality = (GNSS_Handle.uartWorkingBuffer[22 + searchIndex * 12] & 0x7);
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
177 if((signalQuality > 2) && (signalQuality <= 4))
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
178 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
179 GNSS->statSat[statIndex++] = signalQuality;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
180 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
181 if(statIndex == 4) break;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
182 searchIndex++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
183 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
184 searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
185 while((searchIndex < GNSS->numSat) && (statIndex < 4)) /* get poor signal quality */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
186 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
187 signalQuality = (GNSS_Handle.uartWorkingBuffer[22 + searchIndex * 12] & 0x7);
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
188 if(signalQuality <= 2)
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
189 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
190 GNSS->statSat[statIndex++] = signalQuality;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
191 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
192 if(statIndex == 4) break;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
193 searchIndex++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
194 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
195 loop++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
196 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
197 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
198
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
199 void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
200 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
201 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[19];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
202 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
203 GNSS->month = GNSS_Handle.uartWorkingBuffer[20];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
204 GNSS->day = GNSS_Handle.uartWorkingBuffer[21];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
205 GNSS->hour = GNSS_Handle.uartWorkingBuffer[22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
206 GNSS->min = GNSS_Handle.uartWorkingBuffer[23];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
207 GNSS->sec = GNSS_Handle.uartWorkingBuffer[24];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
208 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
209
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
210
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
211 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
212 * Parse data to geodetic position solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
213 * Look at: 32.17.14.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
214 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
215 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
216 void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
217 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
218 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
219 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
220 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
221 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
222
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
223 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
224 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
225 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
226 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
227 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
228
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
229 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
230 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
231 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
232 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
233
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
234 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
235 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
236 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
237 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
238
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
239 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
240 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
241 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
242 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
243
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
244 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
245 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
246 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
247 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
248 }