annotate Small_CPU/Src/GNSS.c @ 926:875933272056 Evo_2_23 tip

Bugfix sensor de-/activation handling: In the previous version a CO2 sensor could cause a not used analog channel to be displayed. Rootcause was that all sensor type, not only o2 sensors, were used for o2 sensor deactivation evaluation. The deactivation state is the criteria if a value is displayed or not. In the new version only o2 sensor type are used for handling of sensor de-/activation state. In addition the cursor will now be set to the first valid sensor entry in case sensor slot 0 is empty.
author Ideenmodellierer
date Thu, 14 Nov 2024 20:13:18 +0100
parents c0553dd70608
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
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
29 #include "GNSS.h"
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
30
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
31 union u_Short uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
32 union i_Short iShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
33 union u_Long uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
34 union i_Long iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
35
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
36 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
37 * Structure initialization.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
38 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
39 * @param huart Pointer to uart handle.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
40 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
41 void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
42 GNSS->huart = huart;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
43 GNSS->year = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
44 GNSS->month = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
45 GNSS->day = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
46 GNSS->hour = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
47 GNSS->min = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
48 GNSS->sec = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
49 GNSS->fixType = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
50 GNSS->lon = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
51 GNSS->lat = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
52 GNSS->height = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
53 GNSS->hMSL = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
54 GNSS->hAcc = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
55 GNSS->vAcc = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
56 GNSS->gSpeed = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
57 GNSS->headMot = 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
58 }
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 * Searching for a header in data buffer and matching class and message ID to buffer data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
62 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
63 */
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 887
diff changeset
64 uint8_t GNSS_ParseBuffer(GNSS_StateHandle *GNSS) {
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 887
diff changeset
65
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 887
diff changeset
66 uint8_t DataReceived = 0;
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
67
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
68 for (int var = 0; var <= 100; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
69 if (GNSS->uartWorkingBuffer[var] == 0xB5
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
70 && GNSS->uartWorkingBuffer[var + 1] == 0x62) {
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 887
diff changeset
71 DataReceived = 1;
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
72 if (GNSS->uartWorkingBuffer[var + 2] == 0x27
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
73 && GNSS->uartWorkingBuffer[var + 3] == 0x03) { //Look at: 32.19.1.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
74 GNSS_ParseUniqID(GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
75 } else if (GNSS->uartWorkingBuffer[var + 2] == 0x01
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
76 && GNSS->uartWorkingBuffer[var + 3] == 0x21) { //Look at: 32.17.14.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
77 GNSS_ParseNavigatorData(GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
78 } else if (GNSS->uartWorkingBuffer[var + 2] == 0x01
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
79 && GNSS->uartWorkingBuffer[var + 3] == 0x07) { //ook at: 32.17.30.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
80 GNSS_ParsePVTData(GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
81 } else if (GNSS->uartWorkingBuffer[var + 2] == 0x01
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
82 && GNSS->uartWorkingBuffer[var + 3] == 0x02) { // Look at: 32.17.15.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
83 GNSS_ParsePOSLLHData(GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
84 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
85 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
86 }
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 887
diff changeset
87 return DataReceived;
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
88 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
89
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
90 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
91 * Make request for unique chip ID data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
92 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
93 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
94 void GNSS_GetUniqID(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
95 HAL_UART_Transmit_DMA(GNSS->huart, getDeviceID,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
96 sizeof(getDeviceID) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
97 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 17);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
98 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
99
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
100 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
101 * Make request for UTC time solution data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
102 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
103 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
104 void GNSS_GetNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
105 HAL_UART_Transmit_DMA(GNSS->huart, getNavigatorData,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
106 sizeof(getNavigatorData) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
107 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 28);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
108 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
109
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
110 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
111 * Make request for geodetic position solution data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
112 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
113 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
114 void GNSS_GetPOSLLHData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
115 HAL_UART_Transmit_DMA(GNSS->huart, getPOSLLHData,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
116 sizeof(getPOSLLHData) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
117 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 36);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
118 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
119
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
120 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
121 * Make request for navigation position velocity time solution data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
122 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
123 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
124 void GNSS_GetPVTData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
125 HAL_UART_Transmit_DMA(GNSS->huart, getPVTData,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
126 sizeof(getPVTData) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
127 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 100);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
128 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
129
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
130 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
131 * Parse data to unique chip ID standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
132 * Look at: 32.19.1.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
133 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
134 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
135 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
136 for (int var = 0; var < 5; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
137 GNSS->uniqueID[var] = GNSS_Handle.uartWorkingBuffer[10 + var];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
138 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
139 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
140
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
141 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
142 * Changing the GNSS mode.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
143 * Look at: 32.10.19 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
144 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
145 void GNSS_SetMode(GNSS_StateHandle *GNSS, short gnssMode) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
146 if (gnssMode == 0) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
147 HAL_UART_Transmit_DMA(GNSS->huart, setPortableMode,sizeof(setPortableMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
148 } else if (gnssMode == 1) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
149 HAL_UART_Transmit_DMA(GNSS->huart, setStationaryMode,sizeof(setStationaryMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
150 } else if (gnssMode == 2) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
151 HAL_UART_Transmit_DMA(GNSS->huart, setPedestrianMode,sizeof(setPedestrianMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
152 } else if (gnssMode == 3) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
153 HAL_UART_Transmit_DMA(GNSS->huart, setAutomotiveMode,sizeof(setAutomotiveMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
154 } else if (gnssMode == 4) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
155 HAL_UART_Transmit_DMA(GNSS->huart, setAutomotiveMode,sizeof(setAutomotiveMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
156 } else if (gnssMode == 5) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
157 HAL_UART_Transmit_DMA(GNSS->huart, setAirbone1GMode,sizeof(setAirbone1GMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
158 } else if (gnssMode == 6) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
159 HAL_UART_Transmit_DMA(GNSS->huart, setAirbone2GMode,sizeof(setAirbone2GMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
160 } else if (gnssMode == 7) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
161 HAL_UART_Transmit_DMA(GNSS->huart, setAirbone4GMode,sizeof(setAirbone4GMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
162 } else if (gnssMode == 8) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
163 HAL_UART_Transmit_DMA(GNSS->huart, setWirstMode,sizeof(setWirstMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
164 } else if (gnssMode == 9) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
165 HAL_UART_Transmit_DMA(GNSS->huart, setBikeMode,sizeof(setBikeMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
166 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
167 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
168 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
169 * Parse data to navigation position velocity time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
170 * Look at: 32.17.15.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
171 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
172 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
173 void GNSS_ParsePVTData(GNSS_StateHandle *GNSS) {
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
174
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
175 static float searchCnt = 1.0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
176
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
177 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
178 GNSS->yearBytes[0]=GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
179 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
180 GNSS->yearBytes[1]=GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
181 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
182 GNSS->month = GNSS_Handle.uartWorkingBuffer[12];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
183 GNSS->day = GNSS_Handle.uartWorkingBuffer[13];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
184 GNSS->hour = GNSS_Handle.uartWorkingBuffer[14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
185 GNSS->min = GNSS_Handle.uartWorkingBuffer[15];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
186 GNSS->sec = GNSS_Handle.uartWorkingBuffer[16];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
187 GNSS->fixType = GNSS_Handle.uartWorkingBuffer[26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
188
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
189 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
190 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
191 GNSS->lonBytes[var]= GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
192 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
193 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
194 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
195 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
196 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
197 GNSS->latBytes[var]=GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
198 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
199 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
200 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
201 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
202 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 38];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
203 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
204 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
205
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
206 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
207 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
208 GNSS->hMSLBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
209 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
210 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
211
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
212 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
213 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 46];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
214 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
215 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
216
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 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 50];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
219 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
220 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
221
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
222 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
223 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
224 GNSS->gSpeedBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
225 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
226 GNSS->gSpeed = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
227
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
228 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
229 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 70];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
230 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
231 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
232
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
233 if((GNSS->fLat == 0.0) && (GNSS->fLon == 0.0))
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
234 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
235 GNSS->fLat = searchCnt++;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
236 }
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
237 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
238
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
239 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
240 * Parse data to UTC time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
241 * Look at: 32.17.30.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
242 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
243 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
244 void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
245 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
246 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[19];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
247 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
248 GNSS->month = GNSS_Handle.uartWorkingBuffer[20];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
249 GNSS->day = GNSS_Handle.uartWorkingBuffer[21];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
250 GNSS->hour = GNSS_Handle.uartWorkingBuffer[22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
251 GNSS->min = GNSS_Handle.uartWorkingBuffer[23];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
252 GNSS->sec = GNSS_Handle.uartWorkingBuffer[24];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
253 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
254
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
255 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
256 * Parse data to geodetic position solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
257 * Look at: 32.17.14.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
258 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
259 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
260 void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS) {
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 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
263 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
264 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
265 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
266
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
267 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
268 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
269 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
270 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
271 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
272
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
273 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
274 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
275 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
276 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
277
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
278 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
279 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
280 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
281 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
282
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
283 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
284 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
285 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
286 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
287
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
288 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
289 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
290 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
291 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
292 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
293
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
294 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
295 * Sends the basic configuration: Activation of the UBX standard, change of NMEA version to 4.10 and turn on of the Galileo system.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
296 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
297 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
298 void GNSS_LoadConfig(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
299 HAL_UART_Transmit_DMA(GNSS->huart, configUBX,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
300 sizeof(configUBX) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
301 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
302 HAL_UART_Transmit_DMA(GNSS->huart, setNMEA410,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
303 sizeof(setNMEA410) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
304 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
305 HAL_UART_Transmit_DMA(GNSS->huart, setGNSS,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
306 sizeof(setGNSS) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
307 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
308 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
309
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
310
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
311
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
312 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
313 * Creates a checksum based on UBX standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
314 * @param class Class value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
315 * @param messageID MessageID value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
316 * @param dataLength Data length value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
317 * @param payload Just payload.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
318 * @return Returns checksum.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
319 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
320 uint8_t GNSS_Checksum(uint8_t class, uint8_t messageID, uint8_t dataLength,uint8_t *payload) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
321 //todo: Look at 32.4 UBX Checksum
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
322 return 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
323 }