Mercurial > public > ostc4
annotate Small_CPU/Src/uartProtocol_GNSS.c @ 1022:ca713e199f22 GasConsumption
Add model ID 0x44 for the OSTC5 to the 0x60 (HARDWARE2) endpoint. The OSTC4 stays at model ID 0x43.
(mikeller)
| author | heinrichsweikamp |
|---|---|
| date | Sun, 29 Jun 2025 13:45:56 +0200 |
| parents | efb7d18cc564 |
| children |
| rev | line source |
|---|---|
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
1 /** |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
2 ****************************************************************************** |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
3 * @file uartProtocol_GNSS.c |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
4 * @author heinrichs weikamp gmbh |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
5 * @version V0.0.1 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
6 * @date 30-Sep-2024 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
7 * @brief Interface functionality operation of GNSS devices |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
8 * |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
9 @verbatim |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
10 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
11 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
12 @endverbatim |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
13 ****************************************************************************** |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
14 * @attention |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
15 * |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
16 * <h2><center>© COPYRIGHT(c) 2024 heinrichs weikamp</center></h2> |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
17 * |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
18 ****************************************************************************** |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
19 */ |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
20 /* Includes ------------------------------------------------------------------*/ |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
21 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
22 #include <string.h> |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
23 #include "scheduler.h" |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
24 #include <uartProtocol_GNSS.h> |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
25 #include "uart.h" |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
26 #include "GNSS.h" |
| 919 | 27 #include "configuration.h" |
| 28 #include "externalInterface.h" | |
| 1000 | 29 #include "rtc.h" |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
30 |
| 932 | 31 |
| 988 | 32 #if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN |
| 932 | 33 |
| 34 static uartGnssStatus_t gnssState = UART_GNSS_INIT; | |
| 35 static gnssRequest_s activeRequest = {0,0}; | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
36 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
37 static receiveStateGnss_t rxState = GNSSRX_READY; |
| 919 | 38 static uint8_t GnssConnected = 0; /* Binary indicator if a sensor is connected or not */ |
| 39 static uint8_t writeIndex = 0; | |
| 40 static uint8_t dataToRead = 0; | |
| 936 | 41 static uint8_t ReqPowerDown = 0; |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
42 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
43 void ConvertByteToHexString(uint8_t byte, char* str) |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
44 { |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
45 uint8_t worker = 0; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
46 uint8_t digit = 0; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
47 uint8_t digitCnt = 1; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
48 |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
49 worker = byte; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
50 while((worker!=0) && (digitCnt != 255)) |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
51 { |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
52 digit = worker % 16; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
53 if( digit < 10) |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
54 { |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
55 digit += '0'; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
56 } |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
57 else |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
58 { |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
59 digit += 'A' - 10; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
60 } |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
61 str[digitCnt--]= digit; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
62 worker = worker / 16; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
63 } |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
64 } |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
65 |
| 936 | 66 void uartGnss_ReqPowerDown(uint8_t request) |
| 67 { | |
| 68 if(GnssConnected) | |
| 69 { | |
| 939 | 70 ReqPowerDown = request; |
| 936 | 71 } |
| 72 } | |
| 919 | 73 |
| 939 | 74 uint8_t uartGnss_isPowerDownRequested() |
| 75 { | |
| 76 return ReqPowerDown; | |
| 77 } | |
| 78 | |
| 932 | 79 uartGnssStatus_t uartGnss_GetState() |
| 80 { | |
| 81 return gnssState; | |
| 82 } | |
| 83 void uartGnss_SetState(uartGnssStatus_t newState) | |
| 84 { | |
| 85 gnssState = newState; | |
| 86 } | |
| 87 | |
| 88 void UART_Gnss_SendCmd(uint8_t GnssCmd) | |
| 919 | 89 { |
| 922 | 90 const uint8_t* pData; |
| 919 | 91 uint8_t txLength = 0; |
| 1000 | 92 RTC_TimeTypeDef time; |
| 93 RTC_DateTypeDef date; | |
| 94 | |
| 95 UBX_MGA_INI_TIME_UTC_t msg_DateTime; | |
|
1004
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
96 UBX_MGA_INI_POS_LLH_t msg_Position; |
| 919 | 97 |
| 98 switch (GnssCmd) | |
| 99 { | |
| 100 case GNSSCMD_LOADCONF_0: pData = configUBX; | |
| 101 txLength = sizeof(configUBX) / sizeof(uint8_t); | |
| 102 break; | |
| 103 case GNSSCMD_LOADCONF_1: pData = setNMEA410; | |
| 104 txLength = sizeof(setNMEA410) / sizeof(uint8_t); | |
| 105 break; | |
| 106 case GNSSCMD_LOADCONF_2: pData = setGNSS; | |
| 107 txLength = sizeof(setGNSS) / sizeof(uint8_t); | |
| 108 break; | |
| 939 | 109 case GNSSCMD_SETMOBILE: pData = setPortableMode; |
| 110 txLength = sizeof(setPortableMode) / sizeof(uint8_t); | |
| 111 break; | |
| 919 | 112 case GNSSCMD_GET_PVT_DATA: pData = getPVTData; |
| 113 txLength = sizeof(getPVTData) / sizeof(uint8_t); | |
| 114 break; | |
| 115 case GNSSCMD_GET_NAV_DATA: pData = getNavigatorData; | |
| 116 txLength = sizeof(getNavigatorData) / sizeof(uint8_t); | |
| 117 break; | |
| 932 | 118 case GNSSCMD_GET_NAVSAT_DATA: pData = getNavSat; |
| 119 txLength = sizeof(getNavSat) / sizeof(uint8_t); | |
| 120 break; | |
| 936 | 121 case GNSSCMD_MODE_PWS: pData = setPowerLow; |
| 122 txLength = sizeof(setPowerLow) / sizeof(uint8_t); | |
| 123 break; | |
| 124 case GNSSCMD_MODE_NORMAL: pData = setPowerNormal; | |
| 125 txLength = sizeof(setPowerNormal) / sizeof(uint8_t); | |
| 126 break; | |
| 127 case GNSSCMD_SET_CONFIG: pData = setConfig; | |
| 128 txLength = sizeof(setConfig) / sizeof(uint8_t); | |
| 129 break; | |
| 1000 | 130 case GNSSCMD_SETDATETIME: |
| 131 RTC_GetDate(&date); | |
| 132 RTC_GetTime(&time); | |
| 133 | |
| 134 memset(&msg_DateTime, 0, sizeof(UBX_MGA_INI_TIME_UTC_t)); | |
| 135 msg_DateTime.header1 = 0xB5; | |
| 136 msg_DateTime.header2 = 0x62; | |
| 137 msg_DateTime.msgClass = 0x13; | |
| 138 msg_DateTime.msgID = 0x40; | |
| 139 msg_DateTime.length = sizeof(UBX_MGA_INI_TIME_UTC_t) - 6; | |
| 140 msg_DateTime.type = 0x00; | |
| 141 msg_DateTime.version = 0x00; | |
| 142 msg_DateTime.year = date.Year + 2000; | |
| 143 msg_DateTime.month = date.Month; | |
| 144 msg_DateTime.day = date.Date; | |
| 145 if((time.Hours - 2) < 0) | |
| 146 { | |
| 147 msg_DateTime.hour = time.Hours + 24 - 2; | |
| 148 } | |
| 149 else | |
| 150 { | |
| 151 msg_DateTime.hour = time.Hours - 2; | |
| 152 } | |
| 153 msg_DateTime.minute = time.Minutes; | |
| 154 msg_DateTime.second = time.Seconds; | |
| 155 msg_DateTime.accuracy_seconds = 60; | |
| 156 msg_DateTime.accuracy_nano = 0x0; | |
| 157 msg_DateTime.flags = 0x00; | |
| 158 msg_DateTime.leapsec = 0x80; | |
| 159 | |
| 160 pData = (uint8_t*)&msg_DateTime; | |
| 161 txLength = sizeof(msg_DateTime) / sizeof(uint8_t); | |
| 162 break; | |
|
1004
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
163 case GNSSCMD_SET_POSITION: msg_Position.header1 = 0xB5; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
164 msg_Position.header2 = 0x62; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
165 msg_Position.class_id = 0x13; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
166 msg_Position.msg_id = 0x40; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
167 msg_Position.length = sizeof(UBX_MGA_INI_POS_LLH_t) - 6; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
168 msg_Position.latitude = (int32_t) (8.98647 * 1e7); |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
169 msg_Position.longitude = (int32_t) (47.77147 * 1e7); |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
170 msg_Position.altitude = (int32_t) 40000; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
171 msg_Position.accuracy = 100000; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
172 pData = (uint8_t*)&msg_Position; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
173 txLength = sizeof(msg_Position) / sizeof(uint8_t); |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
174 break; |
| 919 | 175 default: |
| 176 break; | |
| 177 } | |
| 178 if(txLength != 0) | |
| 179 { | |
| 932 | 180 activeRequest.class = pData[2]; |
| 181 activeRequest.id = pData[3]; | |
| 919 | 182 UART_SendCmdUbx(pData, txLength); |
| 183 } | |
| 184 } | |
| 185 | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
186 void uartGnss_Control(void) |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
187 { |
| 919 | 188 static uint32_t warmupTick = 0; |
| 932 | 189 static uint8_t dataToggle = 0; |
| 190 uint8_t activeSensor = 0; | |
| 191 sUartComCtrl* pUartCtrl = UART_GetGnssCtrl(); | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
192 |
| 932 | 193 if(pUartCtrl == &Uart1Ctrl) |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
194 { |
| 932 | 195 activeSensor = externalInterface_GetActiveUartSensor(); |
| 196 gnssState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); | |
| 197 } | |
| 198 | |
| 199 switch (gnssState) | |
| 200 { | |
| 201 case UART_GNSS_INIT: gnssState = UART_GNSS_WARMUP; | |
| 919 | 202 warmupTick = HAL_GetTick(); |
| 932 | 203 UART_clearRxBuffer(pUartCtrl); |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
204 break; |
| 919 | 205 case UART_GNSS_WARMUP: if(time_elapsed_ms(warmupTick,HAL_GetTick()) > 1000) |
| 206 { | |
| 932 | 207 gnssState = UART_GNSS_LOADCONF_0; |
| 919 | 208 } |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
209 break; |
| 932 | 210 case UART_GNSS_LOADCONF_0: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_0); |
| 211 rxState = GNSSRX_DETECT_ACK_0; | |
| 212 break; | |
| 213 case UART_GNSS_LOADCONF_1: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_1); | |
| 214 rxState = GNSSRX_DETECT_ACK_0; | |
| 215 break; | |
| 216 case UART_GNSS_LOADCONF_2: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2); | |
| 919 | 217 rxState = GNSSRX_DETECT_ACK_0; |
| 218 break; | |
| 1000 | 219 case UART_GNSS_SETMODE_MOBILE: UART_Gnss_SendCmd(GNSSCMD_SETMOBILE); |
| 939 | 220 rxState = GNSSRX_DETECT_ACK_0; |
| 221 break; | |
| 1000 | 222 case UART_GNSS_SETDATE_TIME: UART_Gnss_SendCmd(GNSSCMD_SETDATETIME); |
| 223 // rxState = GNSSRX_DETECT_ACK_0; /* aiding function will not acknoledge receiption (until config to do so) */ | |
|
1004
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
224 gnssState = UART_GNSS_SET_POSITION; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
225 break; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
226 case UART_GNSS_SET_POSITION: UART_Gnss_SendCmd(GNSSCMD_SET_POSITION); |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
227 // rxState = GNSSRX_DETECT_ACK_0; /* aiding function will not acknoledge receiption (until config to do so) */ |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
228 gnssState = UART_GNSS_IDLE; |
| 1000 | 229 break; |
| 936 | 230 case UART_GNSS_PWRDOWN: UART_Gnss_SendCmd(GNSSCMD_MODE_PWS); |
| 231 rxState = GNSSRX_DETECT_ACK_0; | |
| 232 break; | |
| 233 | |
| 939 | 234 case UART_GNSS_PWRUP: UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); |
| 936 | 235 rxState = GNSSRX_DETECT_ACK_0; |
| 236 gnssState = UART_GNSS_PWRUP; | |
| 237 break; | |
| 238 case UART_GNSS_SETCONF: UART_Gnss_SendCmd(GNSSCMD_SET_CONFIG); | |
| 239 rxState = GNSSRX_DETECT_ACK_0; | |
| 240 break; | |
| 241 | |
| 242 case UART_GNSS_IDLE: if(ReqPowerDown) | |
| 932 | 243 { |
| 936 | 244 UART_Gnss_SendCmd(GNSSCMD_MODE_PWS); |
| 245 gnssState = UART_GNSS_PWRDOWN; | |
| 246 rxState = GNSSRX_DETECT_ACK_0; | |
| 932 | 247 } |
| 248 else | |
| 249 { | |
| 936 | 250 if(dataToggle) |
| 251 { | |
| 252 UART_Gnss_SendCmd(GNSSCMD_GET_PVT_DATA); | |
| 253 gnssState = UART_GNSS_GET_PVT; | |
| 254 rxState = GNSSRX_DETECT_HEADER_0; | |
| 255 dataToggle = 0; | |
| 256 } | |
| 257 else | |
| 258 { | |
| 259 UART_Gnss_SendCmd(GNSSCMD_GET_NAVSAT_DATA); | |
| 260 gnssState = UART_GNSS_GET_SAT; | |
| 261 rxState = GNSSRX_DETECT_HEADER_0; | |
| 262 dataToggle = 1; | |
| 263 } | |
| 932 | 264 } |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
265 break; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
266 default: |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
267 break; |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
268 } |
| 932 | 269 if(pUartCtrl == &Uart1Ctrl) |
| 270 { | |
| 271 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,gnssState); | |
| 272 } | |
| 919 | 273 |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
274 } |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
275 |
| 936 | 276 |
| 919 | 277 void uartGnss_ProcessData(uint8_t data) |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
278 { |
| 932 | 279 static uint16_t rxLength = 0; |
| 280 static uint8_t ck_A = 0; | |
| 281 static uint8_t ck_B = 0; | |
| 282 static uint8_t ck_A_Ref = 0; | |
| 283 static uint8_t ck_B_Ref = 0; | |
| 936 | 284 uint8_t activeSensor = 0; |
| 285 | |
| 286 sUartComCtrl* pUartCtrl = UART_GetGnssCtrl(); | |
| 287 | |
| 288 if(pUartCtrl == &Uart1Ctrl) | |
| 289 { | |
| 290 activeSensor = externalInterface_GetActiveUartSensor(); | |
| 291 gnssState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); | |
| 292 } | |
| 932 | 293 |
| 919 | 294 GNSS_Handle.uartWorkingBuffer[writeIndex++] = data; |
| 932 | 295 if((rxState >= GNSSRX_DETECT_HEADER_2) && (rxState < GNSSRX_READ_CK_A)) |
| 296 { | |
| 297 ck_A += data; | |
| 298 ck_B += ck_A; | |
| 299 } | |
| 300 | |
| 919 | 301 switch(rxState) |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
302 { |
| 919 | 303 case GNSSRX_DETECT_ACK_0: |
| 304 case GNSSRX_DETECT_HEADER_0: if(data == 0xB5) | |
| 305 { | |
| 306 writeIndex = 0; | |
| 932 | 307 memset(GNSS_Handle.uartWorkingBuffer,0xff, sizeof(GNSS_Handle.uartWorkingBuffer)); |
| 919 | 308 GNSS_Handle.uartWorkingBuffer[writeIndex++] = data; |
| 309 rxState++; | |
| 932 | 310 ck_A = 0; |
| 311 ck_B = 0; | |
| 919 | 312 } |
| 313 break; | |
| 314 case GNSSRX_DETECT_ACK_1: | |
| 315 case GNSSRX_DETECT_HEADER_1: if(data == 0x62) | |
| 316 { | |
| 317 rxState++; | |
| 318 } | |
| 319 else | |
| 320 { | |
| 321 rxState = GNSSRX_DETECT_HEADER_0; | |
| 322 } | |
| 323 break; | |
| 324 case GNSSRX_DETECT_ACK_2: if(data == 0x05) | |
| 325 { | |
| 326 rxState++; | |
| 327 } | |
| 328 else | |
| 329 { | |
| 330 rxState = GNSSRX_DETECT_HEADER_0; | |
| 331 } | |
| 332 break; | |
| 932 | 333 case GNSSRX_DETECT_ACK_3: if((data == 0x01)) |
| 919 | 334 { |
| 936 | 335 rxState = GNSSRX_READY; |
| 939 | 336 switch(gnssState) |
| 936 | 337 { |
| 939 | 338 case UART_GNSS_PWRUP: gnssState = UART_GNSS_IDLE; |
| 339 break; | |
| 340 case UART_GNSS_PWRDOWN: rxState = GNSSRX_DETECT_ACK_0; | |
| 341 UART_Gnss_SendCmd(GNSSCMD_SET_CONFIG); | |
| 342 gnssState = UART_GNSS_SETCONF; | |
| 343 break; | |
| 344 case UART_GNSS_SETCONF: gnssState = UART_GNSS_INACTIVE; | |
| 345 break; | |
| 346 case UART_GNSS_LOADCONF_0: | |
| 347 case UART_GNSS_LOADCONF_1: gnssState++; | |
| 348 break; | |
|
1004
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
349 case UART_GNSS_LOADCONF_2: |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
350 #ifdef ENABLE_GNSS_TIME_INIT |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
351 gnssState = UART_GNSS_SETMODE_MOBILE; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
352 #else |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
353 gnssState = UART_GNSS_SET_POSITION; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
354 #endif |
| 939 | 355 break; |
| 1000 | 356 case UART_GNSS_SETMODE_MOBILE: |
| 357 #ifdef ENABLE_GNSS_TIME_INIT | |
| 358 gnssState = UART_GNSS_SETDATE_TIME; | |
| 359 #else | |
| 360 rxState = GNSSRX_DETECT_ACK_0; | |
| 955 | 361 UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); |
| 362 gnssState = UART_GNSS_PWRUP; | |
| 1000 | 363 #endif |
| 939 | 364 break; |
|
1004
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
365 case UART_GNSS_SET_POSITION: rxState = GNSSRX_DETECT_ACK_0; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
366 UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
367 gnssState = UART_GNSS_PWRUP; |
|
efb7d18cc564
DevelopmentOption: added the possibility to provide a fixed position info to the gnss module. Code is deactivated at the moment.
Ideenmodellierer
parents:
1000
diff
changeset
|
368 break; |
| 1000 | 369 case UART_GNSS_SETDATE_TIME: rxState = GNSSRX_DETECT_ACK_0; |
| 370 UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); | |
| 371 gnssState = UART_GNSS_PWRUP; | |
| 939 | 372 default: |
| 373 break; | |
| 932 | 374 } |
| 919 | 375 GnssConnected = 1; |
| 376 } | |
| 377 else | |
| 378 { | |
| 379 rxState = GNSSRX_DETECT_HEADER_0; | |
| 380 } | |
| 381 break; | |
| 932 | 382 case GNSSRX_DETECT_HEADER_2: if(data == activeRequest.class) |
| 919 | 383 { |
| 384 rxState++; | |
| 385 } | |
| 386 else | |
| 387 { | |
| 388 rxState = GNSSRX_DETECT_HEADER_0; | |
| 389 } | |
| 390 break; | |
| 932 | 391 case GNSSRX_DETECT_HEADER_3: if(data == activeRequest.id) |
| 392 { | |
| 393 rxState = GNSSRX_DETECT_LENGTH_0; | |
| 394 } | |
| 395 else | |
| 919 | 396 { |
| 932 | 397 rxState = GNSSRX_DETECT_HEADER_0; |
| 919 | 398 } |
| 932 | 399 break; |
| 400 case GNSSRX_DETECT_LENGTH_0: rxLength = GNSS_Handle.uartWorkingBuffer[4]; | |
| 401 rxState = GNSSRX_DETECT_LENGTH_1; | |
| 402 break; | |
| 403 case GNSSRX_DETECT_LENGTH_1: rxLength += (GNSS_Handle.uartWorkingBuffer[5] << 8); | |
| 404 rxState = GNSSRX_READ_DATA; | |
| 405 dataToRead = rxLength; | |
| 406 break; | |
| 407 case GNSSRX_READ_DATA: if(dataToRead > 0) | |
| 919 | 408 { |
| 409 dataToRead--; | |
| 410 } | |
| 932 | 411 if(dataToRead == 0) |
| 919 | 412 { |
| 932 | 413 rxState = GNSSRX_READ_CK_A; |
| 919 | 414 } |
| 415 break; | |
| 932 | 416 case GNSSRX_READ_CK_A: ck_A_Ref = data; |
| 417 rxState++; | |
| 418 break; | |
| 419 case GNSSRX_READ_CK_B: ck_B_Ref = data; | |
| 420 if((ck_A_Ref == ck_A) && (ck_B_Ref == ck_B)) | |
| 421 { | |
| 422 switch(gnssState) | |
| 423 { | |
| 424 case UART_GNSS_GET_PVT:GNSS_ParsePVTData(&GNSS_Handle); | |
| 425 break; | |
| 426 case UART_GNSS_GET_SAT: GNSS_ParseNavSatData(&GNSS_Handle); | |
| 427 break; | |
| 428 default: | |
| 429 break; | |
| 430 } | |
| 431 } | |
| 432 rxState = GNSSRX_DETECT_HEADER_0; | |
| 433 gnssState = UART_GNSS_IDLE; | |
| 434 break; | |
| 435 | |
| 919 | 436 default: rxState = GNSSRX_READY; |
| 437 break; | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
438 } |
| 936 | 439 if(pUartCtrl == &Uart1Ctrl) |
| 440 { | |
| 441 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,gnssState); | |
| 442 } | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
443 } |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
444 |
| 919 | 445 uint8_t uartGnss_isSensorConnected() |
| 446 { | |
| 447 return GnssConnected; | |
| 448 } | |
| 449 | |
|
899
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
450 #endif |
|
2225c467f1e9
Added data path and visualization for position data:
Ideenmodellierer
parents:
diff
changeset
|
451 |
