annotate Small_CPU/Src/uartProtocol_GNSS.c @ 933:43055e069bd1 Evo_2_23

UART Gnss: Added fletcher calculation: Communication is verified using the Fletcher check. In the example code the commands were har coded including the check bytes. To make definition of new commands easier the check bytes are now calculated at runtime. This may be referted to hardcoded values once the implementation is getting a mature state.
author Ideenmodellierer
date Sun, 08 Dec 2024 17:38:16 +0100
parents effadaa3a1f7
children 3029f0332f4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>&copy; 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
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
27 #include "configuration.h"
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
28 #include "externalInterface.h"
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
29
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
30
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
31 #if defined ENABLE_GNSS || defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
32
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
33 static uartGnssStatus_t gnssState = UART_GNSS_INIT;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
34 static gnssRequest_s activeRequest = {0,0};
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
35
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
36 static receiveStateGnss_t rxState = GNSSRX_READY;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
37 static uint8_t GnssConnected = 0; /* Binary indicator if a sensor is connected or not */
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
38
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
39 static uint8_t writeIndex = 0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
40
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
41 static uint8_t dataToRead = 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
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
66
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
67 uartGnssStatus_t uartGnss_GetState()
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
68 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
69 return gnssState;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
70 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
71 void uartGnss_SetState(uartGnssStatus_t newState)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
72 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
73 gnssState = newState;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
74 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
75
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
76 void UART_Gnss_SendCmd(uint8_t GnssCmd)
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
77 {
922
7c996354b8ac Moved UART6 into a separate unit:
Ideenmodellierer
parents: 919
diff changeset
78 const uint8_t* pData;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
79 uint8_t txLength = 0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
80
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
81 switch (GnssCmd)
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
82 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
83 case GNSSCMD_LOADCONF_0: pData = configUBX;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
84 txLength = sizeof(configUBX) / sizeof(uint8_t);
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
85 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
86 case GNSSCMD_LOADCONF_1: pData = setNMEA410;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
87 txLength = sizeof(setNMEA410) / sizeof(uint8_t);
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
88 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
89 case GNSSCMD_LOADCONF_2: pData = setGNSS;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
90 txLength = sizeof(setGNSS) / sizeof(uint8_t);
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
91 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
92 case GNSSCMD_GET_PVT_DATA: pData = getPVTData;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
93 txLength = sizeof(getPVTData) / sizeof(uint8_t);
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
94 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
95 case GNSSCMD_GET_NAV_DATA: pData = getNavigatorData;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
96 txLength = sizeof(getNavigatorData) / sizeof(uint8_t);
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
97 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
98 case GNSSCMD_GET_NAVSAT_DATA: pData = getNavSat;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
99 txLength = sizeof(getNavSat) / sizeof(uint8_t);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
100 break;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
101 default:
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
102 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
103 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
104 if(txLength != 0)
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
105 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
106 activeRequest.class = pData[2];
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
107 activeRequest.id = pData[3];
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
108 UART_SendCmdUbx(pData, txLength);
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
109 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
110 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
111
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
112 void uartGnss_Control(void)
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
113 {
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
114 static uint32_t warmupTick = 0;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
115 static uint8_t dataToggle = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
116 uint8_t activeSensor = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
117 sUartComCtrl* pUartCtrl = UART_GetGnssCtrl();
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
118 // uartGnssStatus_t localComState;
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
119
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
120 if(pUartCtrl == &Uart1Ctrl)
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
121 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
122 activeSensor = externalInterface_GetActiveUartSensor();
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
123 gnssState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
124 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
125
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
126 switch (gnssState)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
127 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
128 case UART_GNSS_INIT: gnssState = UART_GNSS_WARMUP;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
129 warmupTick = HAL_GetTick();
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
130 UART_clearRxBuffer(pUartCtrl);
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
131 break;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
132 case UART_GNSS_WARMUP: if(time_elapsed_ms(warmupTick,HAL_GetTick()) > 1000)
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
133 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
134 gnssState = UART_GNSS_LOADCONF_0;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
135 }
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
136 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
137 case UART_GNSS_LOADCONF_0: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_0);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
138 rxState = GNSSRX_DETECT_ACK_0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
139 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
140 case UART_GNSS_LOADCONF_1: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_1);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
141 rxState = GNSSRX_DETECT_ACK_0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
142 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
143 case UART_GNSS_LOADCONF_2: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2);
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
144 rxState = GNSSRX_DETECT_ACK_0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
145 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
146 case UART_GNSS_IDLE: if(dataToggle)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
147 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
148 UART_Gnss_SendCmd(GNSSCMD_GET_PVT_DATA);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
149 gnssState = UART_GNSS_GET_PVT;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
150 rxState = GNSSRX_DETECT_HEADER_0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
151 dataToggle = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
152 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
153 else
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
154 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
155 UART_Gnss_SendCmd(GNSSCMD_GET_NAVSAT_DATA);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
156 gnssState = UART_GNSS_GET_SAT;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
157 rxState = GNSSRX_DETECT_HEADER_0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
158 dataToggle = 1;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
159 }
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
160 break;
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
161 default:
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
162 break;
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
163 }
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
164 if(pUartCtrl == &Uart1Ctrl)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
165 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
166 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,gnssState);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
167 }
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
168
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
169 }
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
170
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
171 void uartGnss_ProcessData(uint8_t data)
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
172 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
173 static uint16_t rxLength = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
174 static uint8_t ck_A = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
175 static uint8_t ck_B = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
176 static uint8_t ck_A_Ref = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
177 static uint8_t ck_B_Ref = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
178
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
179 GNSS_Handle.uartWorkingBuffer[writeIndex++] = data;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
180 if((rxState >= GNSSRX_DETECT_HEADER_2) && (rxState < GNSSRX_READ_CK_A))
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
181 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
182 ck_A += data;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
183 ck_B += ck_A;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
184 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
185
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
186 switch(rxState)
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
187 {
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
188 case GNSSRX_DETECT_ACK_0:
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
189 case GNSSRX_DETECT_HEADER_0: if(data == 0xB5)
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
190 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
191 writeIndex = 0;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
192 memset(GNSS_Handle.uartWorkingBuffer,0xff, sizeof(GNSS_Handle.uartWorkingBuffer));
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
193 GNSS_Handle.uartWorkingBuffer[writeIndex++] = data;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
194 rxState++;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
195 ck_A = 0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
196 ck_B = 0;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
197 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
198 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
199 case GNSSRX_DETECT_ACK_1:
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
200 case GNSSRX_DETECT_HEADER_1: if(data == 0x62)
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
201 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
202 rxState++;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
203 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
204 else
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
205 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
206 rxState = GNSSRX_DETECT_HEADER_0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
207 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
208 break;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
209 case GNSSRX_DETECT_ACK_2: if(data == 0x05)
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
210 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
211 rxState++;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
212 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
213 else
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
214 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
215 rxState = GNSSRX_DETECT_HEADER_0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
216 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
217 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
218 case GNSSRX_DETECT_ACK_3: if((data == 0x01))
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
219 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
220 if((gnssState >= UART_GNSS_LOADCONF_0) && (gnssState <= UART_GNSS_LOADCONF_2))
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
221 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
222 if(gnssState == UART_GNSS_LOADCONF_2)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
223 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
224 gnssState = UART_GNSS_IDLE;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
225 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
226 else
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
227 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
228 gnssState++;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
229 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
230 }
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
231 GnssConnected = 1;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
232 rxState = GNSSRX_READY;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
233 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
234 else
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
235 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
236 rxState = GNSSRX_DETECT_HEADER_0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
237 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
238 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
239 case GNSSRX_DETECT_HEADER_2: if(data == activeRequest.class)
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
240 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
241 rxState++;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
242 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
243 else
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
244 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
245 rxState = GNSSRX_DETECT_HEADER_0;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
246 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
247 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
248 case GNSSRX_DETECT_HEADER_3: if(data == activeRequest.id)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
249 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
250 rxState = GNSSRX_DETECT_LENGTH_0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
251 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
252 else
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
253 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
254 rxState = GNSSRX_DETECT_HEADER_0;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
255 }
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
256 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
257 case GNSSRX_DETECT_LENGTH_0: rxLength = GNSS_Handle.uartWorkingBuffer[4];
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
258 rxState = GNSSRX_DETECT_LENGTH_1;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
259 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
260 case GNSSRX_DETECT_LENGTH_1: rxLength += (GNSS_Handle.uartWorkingBuffer[5] << 8);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
261 rxState = GNSSRX_READ_DATA;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
262 dataToRead = rxLength;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
263 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
264 case GNSSRX_READ_DATA: if(dataToRead > 0)
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
265 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
266 dataToRead--;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
267 }
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
268 if(dataToRead == 0)
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
269 {
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
270 rxState = GNSSRX_READ_CK_A;
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
271 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
272 break;
932
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
273 case GNSSRX_READ_CK_A: ck_A_Ref = data;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
274 rxState++;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
275 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
276 case GNSSRX_READ_CK_B: ck_B_Ref = data;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
277 if((ck_A_Ref == ck_A) && (ck_B_Ref == ck_B))
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
278 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
279 switch(gnssState)
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
280 {
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
281 case UART_GNSS_GET_PVT:GNSS_ParsePVTData(&GNSS_Handle);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
282 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
283 case UART_GNSS_GET_SAT: GNSS_ParseNavSatData(&GNSS_Handle);
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
284 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
285 default:
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
286 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
287 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
288 }
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
289 rxState = GNSSRX_DETECT_HEADER_0;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
290 gnssState = UART_GNSS_IDLE;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
291 break;
effadaa3a1f7 Cleanup Gnss UART implementation:
Ideenmodellierer
parents: 922
diff changeset
292
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
293 default: rxState = GNSSRX_READY;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
294 break;
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
295 }
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
296 }
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
297
919
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
298 uint8_t uartGnss_isSensorConnected()
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
299 {
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
300 return GnssConnected;
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
301 }
c0553dd70608 GNSS support for external UART interface:
Ideenmodellierer
parents: 899
diff changeset
302
899
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
303 #endif
2225c467f1e9 Added data path and visualization for position data:
Ideenmodellierer
parents:
diff changeset
304