diff Small_CPU/Src/uart.c @ 976:0b81ac558e89 Evo_2_23

Devbugfix UART buffer cleaning: In the previous version a buffer cleaning function was used which resets the ringbuffer read index. As result the processing of data was stopped until the DMA write comes to the index 0. When reaching it the complete buffer was proceeded including possibly invalid data. The usage of the cleanbuffer function was replaced by the flush buffer function (meaning the data is discarded but the data index is maintained). There was already a function for this. Because the function was 99% the same as the read function, it was integrated into the ReadData function. Calling the function with parameter flush = 1 will result in a buffer flush. The workaround of the previous revision was updated to only be applied in case a DiveO2 sensor is operated in stand alone mode.
author Ideenmodellierer
date Wed, 29 Jan 2025 17:21:20 +0100 (7 weeks ago)
parents 3029f0332f4f
children
line wrap: on
line diff
--- a/Small_CPU/Src/uart.c	Tue Jan 28 22:31:17 2025 +0100
+++ b/Small_CPU/Src/uart.c	Wed Jan 29 17:21:20 2025 +0100
@@ -317,6 +317,7 @@
 	Uart1Ctrl.rxReadIndex = 0;
 	Uart1Ctrl.rxWriteIndex = 0;
 	Uart1Ctrl.dmaRxActive = 0;
+	Uart1Ctrl.dmaTxActive = 0;
 	Uart1Ctrl.txBufferQueLen = 0;
 }
 
@@ -390,7 +391,7 @@
 
 	return ret;
 }
-void UART_ReadData(uint8_t sensorType)
+void UART_ReadData(uint8_t sensorType, uint8_t flush)	/* flush = 1 skips processing of data => data is discarded */
 {
 	uint8_t localRX;
 	uint8_t futureIndex;
@@ -422,7 +423,6 @@
 		moreData = 1;
 	}
 	
-	//if((!isEndIndication(pUartCtrl, localRX)) || (!isEndIndication(pUartCtrl,futureIndex)))	do
 	if((!UART_isEndIndication(pUartCtrl, localRX)) || (moreData))
 	do
 	{
@@ -492,36 +492,6 @@
 	}
 }
 
-void UART_FlushRxBuffer(void)
-{
-	uint8_t futureIndex = Uart1Ctrl.rxReadIndex + 1;
-
-	if(futureIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
-	{
-		futureIndex = 0;
-	}
-	while((rxBuffer[Uart1Ctrl.rxReadIndex] != BUFFER_NODATA_LOW) && (rxBuffer[futureIndex] != BUFFER_NODATA_HIGH))
-	{
-		if(Uart1Ctrl.rxReadIndex % 2)
-		{
-			rxBuffer[Uart1Ctrl.rxReadIndex++] = BUFFER_NODATA_HIGH;
-		}
-		else
-		{
-			rxBuffer[Uart1Ctrl.rxReadIndex++] = BUFFER_NODATA_LOW;
-		}
-		if(Uart1Ctrl.rxReadIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
-		{
-			Uart1Ctrl.rxReadIndex = 0;
-		}
-		futureIndex++;
-		if(futureIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
-		{
-			futureIndex = 0;
-		}
-	}
-}
-
 uint8_t UART_isComActive(uint8_t sensorId)
 {
 	uint8_t active = 1;