Mercurial > public > ostc4
comparison Small_CPU/Src/uartProtocol_GNSS.c @ 1000:c386ae6635e4 GasConsumption
Improve GNSS operation:
during OSTC 4/5 code merge a problem with the wakeup of the gnss module showed up which has been fixed with the new verion. In addition a compile switch has been added which activated the synchronization of time between OSTC and gnss module. This my cause problems if the time is not accurate => deactivated at the moment.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 28 Apr 2025 19:51:36 +0200 |
| parents | d9290c76b840 |
| children | efb7d18cc564 |
comparison
equal
deleted
inserted
replaced
| 999:ac25c35a3c97 | 1000:c386ae6635e4 |
|---|---|
| 24 #include <uartProtocol_GNSS.h> | 24 #include <uartProtocol_GNSS.h> |
| 25 #include "uart.h" | 25 #include "uart.h" |
| 26 #include "GNSS.h" | 26 #include "GNSS.h" |
| 27 #include "configuration.h" | 27 #include "configuration.h" |
| 28 #include "externalInterface.h" | 28 #include "externalInterface.h" |
| 29 #include "rtc.h" | |
| 29 | 30 |
| 30 | 31 |
| 31 #if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN | 32 #if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN |
| 32 | 33 |
| 33 static uartGnssStatus_t gnssState = UART_GNSS_INIT; | 34 static uartGnssStatus_t gnssState = UART_GNSS_INIT; |
| 86 | 87 |
| 87 void UART_Gnss_SendCmd(uint8_t GnssCmd) | 88 void UART_Gnss_SendCmd(uint8_t GnssCmd) |
| 88 { | 89 { |
| 89 const uint8_t* pData; | 90 const uint8_t* pData; |
| 90 uint8_t txLength = 0; | 91 uint8_t txLength = 0; |
| 92 RTC_TimeTypeDef time; | |
| 93 RTC_DateTypeDef date; | |
| 94 | |
| 95 UBX_MGA_INI_TIME_UTC_t msg_DateTime; | |
| 91 | 96 |
| 92 switch (GnssCmd) | 97 switch (GnssCmd) |
| 93 { | 98 { |
| 94 case GNSSCMD_LOADCONF_0: pData = configUBX; | 99 case GNSSCMD_LOADCONF_0: pData = configUBX; |
| 95 txLength = sizeof(configUBX) / sizeof(uint8_t); | 100 txLength = sizeof(configUBX) / sizeof(uint8_t); |
| 119 txLength = sizeof(setPowerNormal) / sizeof(uint8_t); | 124 txLength = sizeof(setPowerNormal) / sizeof(uint8_t); |
| 120 break; | 125 break; |
| 121 case GNSSCMD_SET_CONFIG: pData = setConfig; | 126 case GNSSCMD_SET_CONFIG: pData = setConfig; |
| 122 txLength = sizeof(setConfig) / sizeof(uint8_t); | 127 txLength = sizeof(setConfig) / sizeof(uint8_t); |
| 123 break; | 128 break; |
| 129 case GNSSCMD_SETDATETIME: | |
| 130 RTC_GetDate(&date); | |
| 131 RTC_GetTime(&time); | |
| 132 | |
| 133 memset(&msg_DateTime, 0, sizeof(UBX_MGA_INI_TIME_UTC_t)); | |
| 134 msg_DateTime.header1 = 0xB5; | |
| 135 msg_DateTime.header2 = 0x62; | |
| 136 msg_DateTime.msgClass = 0x13; | |
| 137 msg_DateTime.msgID = 0x40; | |
| 138 msg_DateTime.length = sizeof(UBX_MGA_INI_TIME_UTC_t) - 6; | |
| 139 msg_DateTime.type = 0x00; | |
| 140 msg_DateTime.version = 0x00; | |
| 141 msg_DateTime.year = date.Year + 2000; | |
| 142 msg_DateTime.month = date.Month; | |
| 143 msg_DateTime.day = date.Date; | |
| 144 if((time.Hours - 2) < 0) | |
| 145 { | |
| 146 msg_DateTime.hour = time.Hours + 24 - 2; | |
| 147 } | |
| 148 else | |
| 149 { | |
| 150 msg_DateTime.hour = time.Hours - 2; | |
| 151 } | |
| 152 msg_DateTime.minute = time.Minutes; | |
| 153 msg_DateTime.second = time.Seconds; | |
| 154 msg_DateTime.accuracy_seconds = 60; | |
| 155 msg_DateTime.accuracy_nano = 0x0; | |
| 156 msg_DateTime.flags = 0x00; | |
| 157 msg_DateTime.leapsec = 0x80; | |
| 158 | |
| 159 pData = (uint8_t*)&msg_DateTime; | |
| 160 txLength = sizeof(msg_DateTime) / sizeof(uint8_t); | |
| 161 | |
| 162 break; | |
| 124 default: | 163 default: |
| 125 break; | 164 break; |
| 126 } | 165 } |
| 127 if(txLength != 0) | 166 if(txLength != 0) |
| 128 { | 167 { |
| 163 rxState = GNSSRX_DETECT_ACK_0; | 202 rxState = GNSSRX_DETECT_ACK_0; |
| 164 break; | 203 break; |
| 165 case UART_GNSS_LOADCONF_2: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2); | 204 case UART_GNSS_LOADCONF_2: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2); |
| 166 rxState = GNSSRX_DETECT_ACK_0; | 205 rxState = GNSSRX_DETECT_ACK_0; |
| 167 break; | 206 break; |
| 168 case UART_GNSS_SETMODE_MOBILE: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2); | 207 case UART_GNSS_SETMODE_MOBILE: UART_Gnss_SendCmd(GNSSCMD_SETMOBILE); |
| 169 rxState = GNSSRX_DETECT_ACK_0; | 208 rxState = GNSSRX_DETECT_ACK_0; |
| 209 break; | |
| 210 case UART_GNSS_SETDATE_TIME: UART_Gnss_SendCmd(GNSSCMD_SETDATETIME); | |
| 211 // rxState = GNSSRX_DETECT_ACK_0; /* aiding function will not acknoledge receiption (until config to do so) */ | |
| 212 gnssState = UART_GNSS_PWRUP; | |
| 170 break; | 213 break; |
| 171 case UART_GNSS_PWRDOWN: UART_Gnss_SendCmd(GNSSCMD_MODE_PWS); | 214 case UART_GNSS_PWRDOWN: UART_Gnss_SendCmd(GNSSCMD_MODE_PWS); |
| 172 rxState = GNSSRX_DETECT_ACK_0; | 215 rxState = GNSSRX_DETECT_ACK_0; |
| 173 break; | 216 break; |
| 174 | 217 |
| 287 case UART_GNSS_LOADCONF_0: | 330 case UART_GNSS_LOADCONF_0: |
| 288 case UART_GNSS_LOADCONF_1: gnssState++; | 331 case UART_GNSS_LOADCONF_1: gnssState++; |
| 289 break; | 332 break; |
| 290 case UART_GNSS_LOADCONF_2: gnssState = UART_GNSS_SETMODE_MOBILE; | 333 case UART_GNSS_LOADCONF_2: gnssState = UART_GNSS_SETMODE_MOBILE; |
| 291 break; | 334 break; |
| 292 case UART_GNSS_SETMODE_MOBILE: rxState = GNSSRX_DETECT_ACK_0; | 335 case UART_GNSS_SETMODE_MOBILE: |
| 336 #ifdef ENABLE_GNSS_TIME_INIT | |
| 337 gnssState = UART_GNSS_SETDATE_TIME; | |
| 338 #else | |
| 339 rxState = GNSSRX_DETECT_ACK_0; | |
| 293 UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); | 340 UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); |
| 294 gnssState = UART_GNSS_PWRUP; | 341 gnssState = UART_GNSS_PWRUP; |
| 295 break; | 342 #endif |
| 343 break; | |
| 344 case UART_GNSS_SETDATE_TIME: rxState = GNSSRX_DETECT_ACK_0; | |
| 345 UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL); | |
| 346 gnssState = UART_GNSS_PWRUP; | |
| 296 default: | 347 default: |
| 297 break; | 348 break; |
| 298 } | 349 } |
| 299 GnssConnected = 1; | 350 GnssConnected = 1; |
| 300 } | 351 } |
