annotate Small_CPU/Src/GNSS.c @ 907:46a21ff3f5ab Evo_2_23

Adaptation custom view deco plan for VPM: The VPM deco plan now shows the start of deco zone as well as the state of the deco table state. In case the table defined when reaching the deco zone is updated then the header line will change to yellow to indicate this. In case a deco stop is missed the head line will change to red.
author ideenmodellierer
date Sun, 13 Oct 2024 18:13:35 +0200
parents 2225c467f1e9
children c0553dd70608
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) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
174 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
175 GNSS->yearBytes[0]=GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
176 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
177 GNSS->yearBytes[1]=GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
178 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
179 GNSS->month = GNSS_Handle.uartWorkingBuffer[12];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
180 GNSS->day = GNSS_Handle.uartWorkingBuffer[13];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
181 GNSS->hour = GNSS_Handle.uartWorkingBuffer[14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
182 GNSS->min = GNSS_Handle.uartWorkingBuffer[15];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
183 GNSS->sec = GNSS_Handle.uartWorkingBuffer[16];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
184 GNSS->fixType = GNSS_Handle.uartWorkingBuffer[26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
185
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
186 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
187 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
188 GNSS->lonBytes[var]= GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
189 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
190 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
191 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
192 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
193 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
194 GNSS->latBytes[var]=GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
195 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
196 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
197 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
198 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
199 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 38];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
200 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
201 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
202
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
203 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
204 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
205 GNSS->hMSLBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
206 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
207 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
208
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
209 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
210 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 46];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
211 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
212 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
213
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
214 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
215 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 50];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
216 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
217 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
218
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
219 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
220 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
221 GNSS->gSpeedBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
222 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
223 GNSS->gSpeed = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
224
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
225 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
226 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 70];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
227 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
228 GNSS->headMot = iLong.iLong * 1e-5; // todo I'm not sure this good options.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
229 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
230
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
231 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
232 * Parse data to UTC time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
233 * Look at: 32.17.30.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
234 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
235 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
236 void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
237 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
238 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[19];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
239 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
240 GNSS->month = GNSS_Handle.uartWorkingBuffer[20];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
241 GNSS->day = GNSS_Handle.uartWorkingBuffer[21];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
242 GNSS->hour = GNSS_Handle.uartWorkingBuffer[22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
243 GNSS->min = GNSS_Handle.uartWorkingBuffer[23];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
244 GNSS->sec = GNSS_Handle.uartWorkingBuffer[24];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
245 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
246
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
247 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
248 * Parse data to geodetic position solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
249 * Look at: 32.17.14.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
250 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
251 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
252 void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
253 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
254 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
255 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
256 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
257 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
258
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
259 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
260 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
261 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
262 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
263 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
264
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
265 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
266 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
267 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
268 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
269
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
270 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
271 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
272 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
273 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
274
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
275 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
276 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
277 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
278 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
279
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
280 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
281 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
282 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
283 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
284 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
285
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
286 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
287 * 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
288 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
289 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
290 void GNSS_LoadConfig(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
291 HAL_UART_Transmit_DMA(GNSS->huart, configUBX,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
292 sizeof(configUBX) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
293 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
294 HAL_UART_Transmit_DMA(GNSS->huart, setNMEA410,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
295 sizeof(setNMEA410) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
296 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
297 HAL_UART_Transmit_DMA(GNSS->huart, setGNSS,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
298 sizeof(setGNSS) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
299 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
300 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
301
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
302
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
303
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
304 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
305 * Creates a checksum based on UBX standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
306 * @param class Class value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
307 * @param messageID MessageID value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
308 * @param dataLength Data length value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
309 * @param payload Just payload.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
310 * @return Returns checksum.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
311 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
312 uint8_t GNSS_Checksum(uint8_t class, uint8_t messageID, uint8_t dataLength,uint8_t *payload) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
313 //todo: Look at 32.4 UBX Checksum
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
314 return 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
315 }