Mercurial > public > ostc4
comparison Small_CPU/Src/uartProtocol_GNSS.c @ 899:2225c467f1e9 Evo_2_23
Added data path and visualization for position data:
The GNSS data exchange is now initialized and triggered on a cyclic basis (once a second). RTE verion has been increased because of interface change. For now only the position data is shown in a T7 surface views. The functionality may be switched on/off using the compile switch ENABLE_GNSS.
| author | Ideenmodellierer |
|---|---|
| date | Mon, 30 Sep 2024 21:56:05 +0200 |
| parents | |
| children | c0553dd70608 |
comparison
equal
deleted
inserted
replaced
| 898:fac13aa6ba93 | 899:2225c467f1e9 |
|---|---|
| 1 /** | |
| 2 ****************************************************************************** | |
| 3 * @file uartProtocol_GNSS.c | |
| 4 * @author heinrichs weikamp gmbh | |
| 5 * @version V0.0.1 | |
| 6 * @date 30-Sep-2024 | |
| 7 * @brief Interface functionality operation of GNSS devices | |
| 8 * | |
| 9 @verbatim | |
| 10 | |
| 11 | |
| 12 @endverbatim | |
| 13 ****************************************************************************** | |
| 14 * @attention | |
| 15 * | |
| 16 * <h2><center>© COPYRIGHT(c) 2024 heinrichs weikamp</center></h2> | |
| 17 * | |
| 18 ****************************************************************************** | |
| 19 */ | |
| 20 /* Includes ------------------------------------------------------------------*/ | |
| 21 | |
| 22 #include <string.h> | |
| 23 #include "scheduler.h" | |
| 24 #include <uartProtocol_GNSS.h> | |
| 25 #include "uart.h" | |
| 26 #include "GNSS.h" | |
| 27 | |
| 28 #ifdef ENABLE_GNSS | |
| 29 | |
| 30 static uartGnssStatus_t gnssOpState = UART_GNSS_INIT; | |
| 31 static receiveStateGnss_t rxState = GNSSRX_READY; | |
| 32 | |
| 33 void ConvertByteToHexString(uint8_t byte, char* str) | |
| 34 { | |
| 35 uint8_t worker = 0; | |
| 36 uint8_t digit = 0; | |
| 37 uint8_t digitCnt = 1; | |
| 38 | |
| 39 worker = byte; | |
| 40 while((worker!=0) && (digitCnt != 255)) | |
| 41 { | |
| 42 digit = worker % 16; | |
| 43 if( digit < 10) | |
| 44 { | |
| 45 digit += '0'; | |
| 46 } | |
| 47 else | |
| 48 { | |
| 49 digit += 'A' - 10; | |
| 50 } | |
| 51 str[digitCnt--]= digit; | |
| 52 worker = worker / 16; | |
| 53 } | |
| 54 } | |
| 55 | |
| 56 void uartGnss_Control(void) | |
| 57 { | |
| 58 static uint32_t delayStartTick = 0; | |
| 59 | |
| 60 uint32_t tick = HAL_GetTick(); | |
| 61 | |
| 62 switch (gnssOpState) | |
| 63 { | |
| 64 case UART_GNSS_INIT: delayStartTick = tick; | |
| 65 gnssOpState = UART_GNSS_LOAD; | |
| 66 break; | |
| 67 case UART_GNSS_LOAD: if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 1000) | |
| 68 { | |
| 69 GNSS_LoadConfig(&GNSS_Handle); | |
| 70 gnssOpState = UART_GNSS_GET_ID; | |
| 71 delayStartTick = tick; | |
| 72 } | |
| 73 break; | |
| 74 case UART_GNSS_GET_ID: if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 250) | |
| 75 { | |
| 76 GNSS_GetUniqID(&GNSS_Handle); | |
| 77 gnssOpState = UART_GNSS_IDLE; | |
| 78 rxState = GNSSRX_RECEIVING; | |
| 79 delayStartTick = tick; | |
| 80 } | |
| 81 break; | |
| 82 case UART_GNSS_IDLE: if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 1000) | |
| 83 { | |
| 84 GNSS_GetPVTData(&GNSS_Handle); | |
| 85 gnssOpState = UART_GNSS_OPERATING; | |
| 86 rxState = GNSSRX_RECEIVING; | |
| 87 delayStartTick = tick; | |
| 88 } | |
| 89 break; | |
| 90 case UART_GNSS_OPERATING: if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 1000) | |
| 91 { | |
| 92 gnssOpState = UART_GNSS_IDLE; /* simple error handling => start next request */ | |
| 93 rxState = GNSSRX_READY; | |
| 94 } | |
| 95 break; | |
| 96 default: | |
| 97 break; | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 void uartGnss_ProcessData(void) | |
| 102 { | |
| 103 if(rxState == GNSSRX_RECEIVING) | |
| 104 { | |
| 105 if(GNSS_ParseBuffer(&GNSS_Handle)) | |
| 106 { | |
| 107 gnssOpState = UART_GNSS_IDLE; | |
| 108 } | |
| 109 } | |
| 110 } | |
| 111 | |
| 112 #endif | |
| 113 |
