Mercurial > public > ostc4
comparison Small_CPU/Src/uart_Internal.c @ 939:f41974734268 Evo_2_23 tip
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 | effadaa3a1f7 |
children |
comparison
equal
deleted
inserted
replaced
938:df87dbfc9c21 | 939:f41974734268 |
---|---|
156 void UART6_HandleUART() | 156 void UART6_HandleUART() |
157 { | 157 { |
158 static uint8_t retryRequest = 0; | 158 static uint8_t retryRequest = 0; |
159 static uint32_t lastRequestTick = 0; | 159 static uint32_t lastRequestTick = 0; |
160 static uint32_t TriggerTick = 0; | 160 static uint32_t TriggerTick = 0; |
161 static uint8_t timeToTrigger = 0; | 161 static uint16_t timeToTrigger = 0; |
162 uint32_t tick = HAL_GetTick(); | 162 uint32_t tick = HAL_GetTick(); |
163 | 163 |
164 uartGnssStatus_t gnssState = uartGnss_GetState(); | 164 uartGnssStatus_t gnssState = uartGnss_GetState(); |
165 | 165 |
166 if(gnssState != UART_GNSS_INIT) | 166 if(gnssState != UART_GNSS_INIT) |
173 lastRequestTick = tick; | 173 lastRequestTick = tick; |
174 TriggerTick = tick - 10; /* just to make sure control is triggered */ | 174 TriggerTick = tick - 10; /* just to make sure control is triggered */ |
175 timeToTrigger = 1; | 175 timeToTrigger = 1; |
176 retryRequest = 0; | 176 retryRequest = 0; |
177 } | 177 } |
178 else if((gnssState == UART_GNSS_INACTIVE) && (!uartGnss_isPowerDownRequested())) /* send dummy bytes to wakeup receiver */ | |
179 { | |
180 txBufferUart6[0] = 0xFF; | |
181 txBufferUart6[1] = 0xFF; | |
182 HAL_UART_Transmit_DMA(Uart6Ctrl.pHandle, Uart6Ctrl.pTxBuffer,2); | |
183 timeToTrigger = 500; /* receiver needs 500ms for wakeup */ | |
184 lastRequestTick = tick; | |
185 gnssState = UART_GNSS_PWRUP; | |
186 uartGnss_SetState(gnssState); | |
187 } | |
178 else if(((retryRequest == 0) /* timeout or error */ | 188 else if(((retryRequest == 0) /* timeout or error */ |
179 && (((time_elapsed_ms(lastRequestTick,tick) > (TIMEOUT_SENSOR_ANSWER)) && (gnssState != UART_GNSS_IDLE)) /* retry if no answer after half request interval */ | 189 && (((time_elapsed_ms(lastRequestTick,tick) > (TIMEOUT_SENSOR_ANSWER)) && (gnssState != UART_GNSS_IDLE)) /* retry if no answer after half request interval */ |
180 || (gnssState == UART_GNSS_ERROR)))) | 190 || (gnssState == UART_GNSS_ERROR)))) |
181 { | 191 { |
182 /* The channel switch will cause the sensor to respond with an error message. */ | 192 /* The channel switch will cause the sensor to respond with an error message. */ |
192 lastRequestTick = tick; | 202 lastRequestTick = tick; |
193 TriggerTick = tick; | 203 TriggerTick = tick; |
194 retryRequest = 0; | 204 retryRequest = 0; |
195 timeToTrigger = 1; | 205 timeToTrigger = 1; |
196 | 206 |
197 if((gnssState == UART_GNSS_GET_SAT) || (gnssState == UART_GNSS_GET_PVT)) /* timeout */ | 207 if((gnssState == UART_GNSS_GET_SAT) || (gnssState == UART_GNSS_GET_PVT) || (gnssState == UART_GNSS_PWRUP)) /* timeout */ |
198 { | 208 { |
199 gnssState = UART_GNSS_IDLE; | 209 gnssState = UART_GNSS_IDLE; |
200 uartGnss_SetState(gnssState); | 210 uartGnss_SetState(gnssState); |
201 } | 211 } |
202 timeToTrigger = 1; | 212 timeToTrigger = 1; |