annotate Small_CPU/Src/GNSS.c @ 890:651d21777b61 Evo_2_23

cleanup and disable function for GNSS uart and DMA
author heinrichsweikamp
date Fri, 06 Sep 2024 18:43:30 +0200
parents 17f02ac9da67
children 2225c467f1e9
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 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
64 void GNSS_ParseBuffer(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
65
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
66 for (int var = 0; var <= 100; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
67 if (GNSS->uartWorkingBuffer[var] == 0xB5
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
68 && GNSS->uartWorkingBuffer[var + 1] == 0x62) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
69 if (GNSS->uartWorkingBuffer[var + 2] == 0x27
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
70 && GNSS->uartWorkingBuffer[var + 3] == 0x03) { //Look at: 32.19.1.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
71 GNSS_ParseUniqID(GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
72 } else if (GNSS->uartWorkingBuffer[var + 2] == 0x01
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
73 && GNSS->uartWorkingBuffer[var + 3] == 0x21) { //Look at: 32.17.14.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
74 GNSS_ParseNavigatorData(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] == 0x07) { //ook at: 32.17.30.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
77 GNSS_ParsePVTData(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] == 0x02) { // Look at: 32.17.15.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
80 GNSS_ParsePOSLLHData(GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
81 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
82 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
83 }
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 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
87 * Make request for unique chip ID data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
88 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
89 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
90 void GNSS_GetUniqID(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
91 HAL_UART_Transmit_DMA(GNSS->huart, getDeviceID,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
92 sizeof(getDeviceID) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
93 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 17);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
94 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
95
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
96 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
97 * Make request for UTC time solution data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
98 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
99 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
100 void GNSS_GetNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
101 HAL_UART_Transmit_DMA(GNSS->huart, getNavigatorData,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
102 sizeof(getNavigatorData) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
103 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 28);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
104 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
105
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
106 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
107 * Make request for geodetic position solution data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
108 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
109 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
110 void GNSS_GetPOSLLHData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
111 HAL_UART_Transmit_DMA(GNSS->huart, getPOSLLHData,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
112 sizeof(getPOSLLHData) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
113 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 36);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
114 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
115
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
116 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
117 * Make request for navigation position velocity time solution data.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
118 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
119 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
120 void GNSS_GetPVTData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
121 HAL_UART_Transmit_DMA(GNSS->huart, getPVTData,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
122 sizeof(getPVTData) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
123 HAL_UART_Receive_IT(GNSS->huart, GNSS_Handle.uartWorkingBuffer, 100);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
124 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
125
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
126 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
127 * Parse data to unique chip ID standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
128 * Look at: 32.19.1.1 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
129 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
130 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
131 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
132 for (int var = 0; var < 5; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
133 GNSS->uniqueID[var] = GNSS_Handle.uartWorkingBuffer[10 + var];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
134 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
135 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
136
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
137 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
138 * Changing the GNSS mode.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
139 * Look at: 32.10.19 u-blox 8 Receiver description
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
140 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
141 void GNSS_SetMode(GNSS_StateHandle *GNSS, short gnssMode) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
142 if (gnssMode == 0) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
143 HAL_UART_Transmit_DMA(GNSS->huart, setPortableMode,sizeof(setPortableMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
144 } else if (gnssMode == 1) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
145 HAL_UART_Transmit_DMA(GNSS->huart, setStationaryMode,sizeof(setStationaryMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
146 } else if (gnssMode == 2) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
147 HAL_UART_Transmit_DMA(GNSS->huart, setPedestrianMode,sizeof(setPedestrianMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
148 } else if (gnssMode == 3) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
149 HAL_UART_Transmit_DMA(GNSS->huart, setAutomotiveMode,sizeof(setAutomotiveMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
150 } else if (gnssMode == 4) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
151 HAL_UART_Transmit_DMA(GNSS->huart, setAutomotiveMode,sizeof(setAutomotiveMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
152 } else if (gnssMode == 5) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
153 HAL_UART_Transmit_DMA(GNSS->huart, setAirbone1GMode,sizeof(setAirbone1GMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
154 } else if (gnssMode == 6) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
155 HAL_UART_Transmit_DMA(GNSS->huart, setAirbone2GMode,sizeof(setAirbone2GMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
156 } else if (gnssMode == 7) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
157 HAL_UART_Transmit_DMA(GNSS->huart, setAirbone4GMode,sizeof(setAirbone4GMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
158 } else if (gnssMode == 8) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
159 HAL_UART_Transmit_DMA(GNSS->huart, setWirstMode,sizeof(setWirstMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
160 } else if (gnssMode == 9) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
161 HAL_UART_Transmit_DMA(GNSS->huart, setBikeMode,sizeof(setBikeMode) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
162 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
163 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
164 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
165 * Parse data to navigation position velocity time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
166 * Look at: 32.17.15.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
167 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
168 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
169 void GNSS_ParsePVTData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
170 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
171 GNSS->yearBytes[0]=GNSS_Handle.uartWorkingBuffer[10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
172 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
173 GNSS->yearBytes[1]=GNSS_Handle.uartWorkingBuffer[11];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
174 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
175 GNSS->month = GNSS_Handle.uartWorkingBuffer[12];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
176 GNSS->day = GNSS_Handle.uartWorkingBuffer[13];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
177 GNSS->hour = GNSS_Handle.uartWorkingBuffer[14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
178 GNSS->min = GNSS_Handle.uartWorkingBuffer[15];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
179 GNSS->sec = GNSS_Handle.uartWorkingBuffer[16];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
180 GNSS->fixType = GNSS_Handle.uartWorkingBuffer[26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
181
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
182 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
183 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
184 GNSS->lonBytes[var]= GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
185 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
186 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
187 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
188 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
189 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
190 GNSS->latBytes[var]=GNSS_Handle.uartWorkingBuffer[var + 34];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
191 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
192 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
193 GNSS->fLat=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
194 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
195 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 38];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
196 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
197 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
198
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
199 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
200 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
201 GNSS->hMSLBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 42];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
202 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
203 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
204
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
205 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
206 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 46];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
207 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
208 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
209
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
210 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
211 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 50];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
212 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
213 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
214
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
215 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
216 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
217 GNSS->gSpeedBytes[var] = GNSS_Handle.uartWorkingBuffer[var + 66];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
218 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
219 GNSS->gSpeed = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
220
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
221 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
222 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 70];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
223 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
224 GNSS->headMot = iLong.iLong * 1e-5; // todo I'm not sure this good options.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
225 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
226
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
227 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
228 * Parse data to UTC time solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
229 * Look at: 32.17.30.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
230 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
231 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
232 void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
233 uShort.bytes[0] = GNSS_Handle.uartWorkingBuffer[18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
234 uShort.bytes[1] = GNSS_Handle.uartWorkingBuffer[19];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
235 GNSS->year = uShort.uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
236 GNSS->month = GNSS_Handle.uartWorkingBuffer[20];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
237 GNSS->day = GNSS_Handle.uartWorkingBuffer[21];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
238 GNSS->hour = GNSS_Handle.uartWorkingBuffer[22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
239 GNSS->min = GNSS_Handle.uartWorkingBuffer[23];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
240 GNSS->sec = GNSS_Handle.uartWorkingBuffer[24];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
241 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
242
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
243 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
244 * Parse data to geodetic position solution standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
245 * Look at: 32.17.14.1 u-blox 8 Receiver description.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
246 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
247 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
248 void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
249 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
250 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 10];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
251 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
252 GNSS->lon = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
253 GNSS->fLon=(float)iLong.iLong/10000000.0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
254
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
255 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
256 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 14];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
257 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
258 GNSS->lat = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
259 GNSS->fLat=(float)iLong.iLong/10000000.0;
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 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 18];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
263 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
264 GNSS->height = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
265
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
266 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
267 iLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 22];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
268 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
269 GNSS->hMSL = iLong.iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
270
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
271 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
272 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 26];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
273 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
274 GNSS->hAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
275
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
276 for (int var = 0; var < 4; ++var) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
277 uLong.bytes[var] = GNSS_Handle.uartWorkingBuffer[var + 30];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
278 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
279 GNSS->vAcc = uLong.uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
280 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
281
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
282 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
283 * 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
284 * @param GNSS Pointer to main GNSS structure.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
285 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
286 void GNSS_LoadConfig(GNSS_StateHandle *GNSS) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
287 HAL_UART_Transmit_DMA(GNSS->huart, configUBX,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
288 sizeof(configUBX) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
289 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
290 HAL_UART_Transmit_DMA(GNSS->huart, setNMEA410,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
291 sizeof(setNMEA410) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
292 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
293 HAL_UART_Transmit_DMA(GNSS->huart, setGNSS,
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
294 sizeof(setGNSS) / sizeof(uint8_t));
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
295 HAL_Delay(250);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
296 }
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
297
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
298
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
299
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
300 /*!
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
301 * Creates a checksum based on UBX standard.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
302 * @param class Class value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
303 * @param messageID MessageID value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
304 * @param dataLength Data length value from UBX doc.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
305 * @param payload Just payload.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
306 * @return Returns checksum.
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
307 */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
308 uint8_t GNSS_Checksum(uint8_t class, uint8_t messageID, uint8_t dataLength,uint8_t *payload) {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
309 //todo: Look at 32.4 UBX Checksum
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
310 return 0;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
311 }