comparison Small_CPU/Src/uart.c @ 1079:9e1fdb383d86 Icon_Integration

Changed reaction for uart DMA buffer overruns: In the previous version a DMA was not restarted in case the read pointer is in the chunk which should be filled next. In normal operation this should never happen, in special cases, like debugging, it may occure. In case of an overrun the data may be already outdated and can be discarded. Because of this the new handling of a buffer overflow is to set the read pointer to the start of the chunk => the read function will start with the latest received data. Not yet processed data will be discarded.
author Ideenmodellierer
date Sun, 08 Mar 2026 21:04:36 +0100
parents bd8ab302ef4a
children
comparison
equal deleted inserted replaced
1078:082825daccb5 1079:9e1fdb383d86
300 300
301 void UART_StartDMA_Receiption(sUartComCtrl* pUartCtrl) 301 void UART_StartDMA_Receiption(sUartComCtrl* pUartCtrl)
302 { 302 {
303 if(pUartCtrl->dmaRxActive == 0) 303 if(pUartCtrl->dmaRxActive == 0)
304 { 304 {
305 if(((pUartCtrl->rxWriteIndex / CHUNK_SIZE) != (pUartCtrl->rxReadIndex / CHUNK_SIZE)) || ((UART_isEndIndication(pUartCtrl, pUartCtrl->rxWriteIndex)) && (UART_isEndIndication(pUartCtrl, pUartCtrl->rxWriteIndex + 1)))) /* start next transfer if we did not catch up with read index */ 305 if((pUartCtrl->rxWriteIndex / CHUNK_SIZE) == (pUartCtrl->rxReadIndex / CHUNK_SIZE)) /* write pointer catched up with read pointer (should never happen) => Reset read pointer to start of block */
306 { 306 {
307 if(HAL_OK == HAL_UART_Receive_DMA (pUartCtrl->pHandle, &pUartCtrl->pRxBuffer[pUartCtrl->rxWriteIndex], CHUNK_SIZE)) 307 pUartCtrl->rxReadIndex = pUartCtrl->rxWriteIndex;
308 { 308 }
309 pUartCtrl->dmaRxActive = 1; 309 if(HAL_OK == HAL_UART_Receive_DMA (pUartCtrl->pHandle, &pUartCtrl->pRxBuffer[pUartCtrl->rxWriteIndex], CHUNK_SIZE))
310 } 310 {
311 pUartCtrl->dmaRxActive = 1;
311 } 312 }
312 } 313 }
313 } 314 }
314 315
315 void UART_ChangeBaudrate(uint32_t newBaudrate) 316 void UART_ChangeBaudrate(uint32_t newBaudrate)