annotate Small_CPU/Src/GNSS.c @ 947:96cf6c53c934 Evo_2_23

GNSS sleep mode: Backup voltage is now enabled during initialization. Power saving interval has been changed to 20 second active in a 60 minutes cycle.
author Ideenmodellierer
date Sun, 22 Dec 2024 21:14:41 +0100
parents 06aaccaf2e02
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"
947
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
31 #include "data_exchange.h"
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
32
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
33 union u_Short uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
34 union i_Short iShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
35 union u_Long uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
36 union i_Long iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
37
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
38 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
39 * Structure initialization.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
40 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
41 * @param huart Pointer to uart handle.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
42 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
43 void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
44 GNSS->huart = huart;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
45 GNSS->year = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
46 GNSS->month = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
47 GNSS->day = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
48 GNSS->hour = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
49 GNSS->min = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
50 GNSS->sec = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
51 GNSS->fixType = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
52 GNSS->lon = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
53 GNSS->lat = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
54 GNSS->height = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
55 GNSS->hMSL = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
56 GNSS->hAcc = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
57 GNSS->vAcc = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
58 GNSS->gSpeed = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
59 GNSS->headMot = 0;
947
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
60 GNSS->alive = 0;
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
61 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
62
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
63 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
64 * Parse data to unique chip ID standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
65 * Look at: 32.19.1.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
66 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
67 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
68 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS) {
942
06aaccaf2e02 Power down gnss module during dive:
Ideenmodellierer
parents: 940
diff changeset
69 for (int var = 0; var < 5; var++) {
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
70 GNSS->uniqueID[var] = GNSS_Handle.uartWorkingBuffer[10 + var];
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
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
74 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
75 * Parse data to navigation position velocity time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
76 * Look at: 32.17.15.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
77 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
78 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
79 void GNSS_ParsePVTData(GNSS_StateHandle *GNSS) {
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
80
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
81 static float searchCnt = 1.0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
82
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
83 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
84 GNSS->yearBytes[0]=GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
85 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
86 GNSS->yearBytes[1]=GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
87 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
88 GNSS->month = GNSS_Handle.uartWorkingBuffer[12];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
89 GNSS->day = GNSS_Handle.uartWorkingBuffer[13];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
90 GNSS->hour = GNSS_Handle.uartWorkingBuffer[14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
91 GNSS->min = GNSS_Handle.uartWorkingBuffer[15];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
92 GNSS->sec = GNSS_Handle.uartWorkingBuffer[16];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
93 GNSS->fixType = GNSS_Handle.uartWorkingBuffer[26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
94
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
95 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
96 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
97 GNSS->lonBytes[var]= GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
98 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
99 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
100 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
101 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
102 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
103 GNSS->latBytes[var]=GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
104 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
105 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
106 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
107 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
108 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 38];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
109 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
110 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
111
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
112 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
113 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
114 GNSS->hMSLBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
115 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
116 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
117
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
118 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
119 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 46];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
120 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
121 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
122
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
123 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
124 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 50];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
125 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
126 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
127
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
128 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
129 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
130 GNSS->gSpeedBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
131 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
132 GNSS->gSpeed = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
133
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
134 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
135 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 70];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
136 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
137 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
138
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
139 if((GNSS->fLat == 0.0) && (GNSS->fLon == 0.0))
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
140 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
141 GNSS->fLat = searchCnt++;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
142 }
940
4a406e873a95 GNSS improvments:
Ideenmodellierer
parents: 932
diff changeset
143
947
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
144 if(GNSS->alive & GNSS_ALIVE_STATE_ALIVE) /* alive */
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
145 {
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
146 GNSS->alive &= !GNSS_ALIVE_STATE_ALIVE;
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
147 }
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
148 else
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
149 {
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
150 GNSS->alive |= GNSS_ALIVE_STATE_ALIVE;
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
151 }
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
152 if((GNSS_Handle.uartWorkingBuffer[17] & 0x03) == 0x03) /* date/time valid */
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
153 {
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
154 GNSS->alive |= GNSS_ALIVE_STATE_TIME;
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
155 }
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
156 else
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
157 {
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
158 GNSS->alive &= !GNSS_ALIVE_STATE_TIME;
96cf6c53c934 GNSS sleep mode:
Ideenmodellierer
parents: 942
diff changeset
159 }
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
160 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
161
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
162 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
163 * Parse data to UTC time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
164 * Look at: 32.17.30.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
165 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
166 */
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
167 void GNSS_ParseNavSatData(GNSS_StateHandle *GNSS) {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
168
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
169 uint8_t loop = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
170 uint8_t searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
171 uint8_t statIndex = 0; /* only 4 state information will be forwarded */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
172 uint8_t signalQuality = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
173 GNSS->numSat = GNSS_Handle.uartWorkingBuffer[11];
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
174
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
175 memset(GNSS->statSat, 0, sizeof(GNSS->statSat));
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
176
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
177 if(GNSS->numSat > 0)
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
178 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
179 searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
180 while((searchIndex < GNSS->numSat) && (statIndex < 4)) /* get good signal quality */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
181 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
182 signalQuality = (GNSS_Handle.uartWorkingBuffer[22 + searchIndex * 12] & 0x7);
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
183 if(signalQuality > 4)
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
184 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
185 GNSS->statSat[statIndex++] = signalQuality;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
186 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
187 if(statIndex == 4) break;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
188 searchIndex++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
189 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
190 searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
191 while((searchIndex < GNSS->numSat) && (statIndex < 4)) /* get medium signal quality */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
192 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
193 signalQuality = (GNSS_Handle.uartWorkingBuffer[22 + searchIndex * 12] & 0x7);
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
194 if((signalQuality > 2) && (signalQuality <= 4))
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
195 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
196 GNSS->statSat[statIndex++] = signalQuality;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
197 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
198 if(statIndex == 4) break;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
199 searchIndex++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
200 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
201 searchIndex = 0;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
202 while((searchIndex < GNSS->numSat) && (statIndex < 4)) /* get poor signal quality */
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
203 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
204 signalQuality = (GNSS_Handle.uartWorkingBuffer[22 + searchIndex * 12] & 0x7);
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
205 if(signalQuality <= 2)
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
206 {
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
207 GNSS->statSat[statIndex++] = signalQuality;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
208 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
209 if(statIndex == 4) break;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
210 searchIndex++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
211 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
212 loop++;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
213 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
214 }
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
215
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
216 void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
217 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
218 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[19];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
219 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
220 GNSS->month = GNSS_Handle.uartWorkingBuffer[20];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
221 GNSS->day = GNSS_Handle.uartWorkingBuffer[21];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
222 GNSS->hour = GNSS_Handle.uartWorkingBuffer[22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
223 GNSS->min = GNSS_Handle.uartWorkingBuffer[23];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
224 GNSS->sec = GNSS_Handle.uartWorkingBuffer[24];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
225 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
226
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 919
diff changeset
227
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
228 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
229 * Parse data to geodetic position solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
230 * Look at: 32.17.14.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
231 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
232 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
233 void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS) {
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 + 10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
236 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
237 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
238 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
239
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
240 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
241 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
242 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
243 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
244 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
245
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
246 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
247 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
248 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
249 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
250
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
251 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
252 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
253 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
254 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
255
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
256 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
257 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
258 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
259 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
260
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
261 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
262 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
263 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
264 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
265 }