annotate Small_CPU/Inc/GNSS.h @ 939:f41974734268 Evo_2_23

Resume UART com with gnss after sleep: Some changes were needed to get the communication up and running again after the gnns modul was set into power mode. The config needs to be safed at shutdown and the receiver needs to be wake up using dummy bytes before real communication may be resumed
author Ideenmodellierer
date Tue, 10 Dec 2024 21:03:04 +0100
parents 3029f0332f4f
children 4a406e873a95
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.h
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 #ifndef INC_GNSS_H_
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
30 #define INC_GNSS_H_
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
31
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
32 #include "stm32f4xx_hal.h"
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
33
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
34 union u_Short
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
35 {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
36 uint8_t bytes[2];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
37 unsigned short uShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
38 };
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
39
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
40 union i_Short
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
41 {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
42 uint8_t bytes[2];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
43 signed short iShort;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
44 };
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
45
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
46 union u_Long
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
47 {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
48 uint8_t bytes[4];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
49 unsigned long uLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
50 };
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
51
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
52 union i_Long
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
53 {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
54 uint8_t bytes[4];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
55 signed long iLong;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
56 };
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
57
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
58 typedef struct
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
59 {
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
60 UART_HandleTypeDef *huart;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
61
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
62 uint8_t uniqueID[4];
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 899
diff changeset
63 uint8_t uartWorkingBuffer[255];
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
64
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
65 unsigned short year;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
66 uint8_t yearBytes[2];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
67 uint8_t month;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
68 uint8_t day;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
69 uint8_t hour;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
70 uint8_t min;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
71 uint8_t sec;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
72 uint8_t fixType;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
73
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
74 signed long lon;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
75 uint8_t lonBytes[4];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
76 signed long lat;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
77 uint8_t latBytes[4];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
78 float fLon;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
79 float fLat;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
80
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
81 signed long height;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
82 signed long hMSL;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
83 uint8_t hMSLBytes[4];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
84 unsigned long hAcc;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
85 unsigned long vAcc;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
86
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
87 signed long gSpeed;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
88 uint8_t gSpeedBytes[4];
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
89 signed long headMot;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
90
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 899
diff changeset
91 uint8_t numSat;
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 899
diff changeset
92 uint8_t statSat[4];
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 899
diff changeset
93
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
94 }GNSS_StateHandle;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
95
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
96 GNSS_StateHandle GNSS_Handle;
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
97
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
98
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
99 enum GNSSMode{Portable=0, Stationary=1, Pedestrian=2, Automotiv=3, Airbone1G=5, Airbone2G=6,Airbone4G=7,Wirst=8,Bike=9};
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
100
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
101 static const uint8_t configUBX[]={0xB5,0x62,0x06,0x00,0x14,0x00,0x01,0x00,0x00,0x00,0xD0,0x08,0x00,0x00,0x80,0x25,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
102
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
103 static const uint8_t setNMEA410[]={0xB5,0x62,0x06,0x17,0x14,0x00,0x00,0x41,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
104
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
105 //Activation of navigation system: Galileo, Glonass, GPS, SBAS, IMES
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
106 static const uint8_t setGNSS[]={0xB5,0x62,0x06,0x3E,0x24,0x00,0x00,0x00,0x20,0x04,0x00,0x08,0x10,0x00,0x01,0x00,0x01,0x01,0x01,0x01,0x03,0x00,0x01,0x00,0x01,0x01,0x02,0x04,0x08,0x00,0x01,0x00,0x01,0x01,0x06,0x08,0x0E,0x00,0x01,0x00,0x01,0x01};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
107
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
108 static const uint8_t getDeviceID[]={0xB5,0x62,0x27,0x03,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
109
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
110 static const uint8_t getNavigatorData[]={0xB5,0x62,0x01,0x21,0x00,0x00};
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 899
diff changeset
111
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
112 static const uint8_t getPOSLLHData[]={0xB5,0x62,0x01,0x02,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
113
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
114 static const uint8_t getPVTData[]={0xB5,0x62,0x01,0x07,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
115
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
116 static const uint8_t getNavSat[]={0xB5,0x62,0x01,0x35,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
117
936
3029f0332f4f GNSS introduced power saving mode:
Ideenmodellierer
parents: 933
diff changeset
118 static const uint8_t setPowerLow[]={0xB5,0x62,0x06,0x86,0x08,0x00,0x00,0x02,0x78,0x00,0x14,0x00,0x00,0x00};
3029f0332f4f GNSS introduced power saving mode:
Ideenmodellierer
parents: 933
diff changeset
119
939
f41974734268 Resume UART com with gnss after sleep:
Ideenmodellierer
parents: 936
diff changeset
120 static const uint8_t setPowerNormal[]={0xB5,0x62,0x06,0x86,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
121
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
122 static const uint8_t setPortableMode[]={0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x00,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x5E,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
123
933
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
124 static const uint8_t setPedestrianMode[]={0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x03,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x5E,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
43055e069bd1 UART Gnss: Added fletcher calculation:
Ideenmodellierer
parents: 931
diff changeset
125
936
3029f0332f4f GNSS introduced power saving mode:
Ideenmodellierer
parents: 933
diff changeset
126 static const uint8_t setConfig[]={0xB5,0x62,0x06,0x09,0x0D,0x00, 0x00,0x00,0x00,0x00, 0x18,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x01};
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
127
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
128 static const uint8_t setPortableType[]={};
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
129 void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
130 void GNSS_LoadConfig(GNSS_StateHandle *GNSS);
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents: 887
diff changeset
131 uint8_t GNSS_ParseBuffer(GNSS_StateHandle *GNSS);
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
132
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
133 void GNSS_GetUniqID(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
134 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
135
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
136 void GNSS_GetNavigatorData(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
137 void GNSS_ParseNavigatorData(GNSS_StateHandle *GNSS);
931
5a9bc2e6112d Added Sat Status Overview:
Ideenmodellierer
parents: 899
diff changeset
138 void GNSS_ParseNavSatData(GNSS_StateHandle *GNSS);
887
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
139
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
140 void GNSS_GetPOSLLHData(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
141 void GNSS_ParsePOSLLHData(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
142
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
143 void GNSS_GetPVTData(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
144 void GNSS_ParsePVTData(GNSS_StateHandle *GNSS);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
145
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
146 void GNSS_SetMode(GNSS_StateHandle *GNSS, short gnssMode);
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
147 #endif /* INC_GNSS_H_ */
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
148
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
149
17f02ac9da67 adding GNSS code
heinrichsweikamp
parents:
diff changeset
150