changeset 725:621265ec3d23

Update CO2 sensor implementation: Some updates were needed to get the CO2 sensor code up and running again (menu handling and UART DMA transfer).
author Ideenmodellierer
date Sat, 07 Jan 2023 18:11:52 +0100
parents f285424f04d9
children 8f3a8c85a6c4
files Discovery/Src/tMenuEditXtra.c Small_CPU/Src/scheduler.c Small_CPU/Src/uart.c
diffstat 3 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/tMenuEditXtra.c	Thu Jan 05 18:30:06 2023 +0100
+++ b/Discovery/Src/tMenuEditXtra.c	Sat Jan 07 18:11:52 2023 +0100
@@ -319,6 +319,9 @@
 static void openEdit_CO2Sensor()
 {
     char text[32];
+
+    resetMenuEdit(CLUT_MenuPageXtra);
+
     snprintf(text,32,"\001%c",TXT_CO2Sensor);
     write_topline(text);
 
--- a/Small_CPU/Src/scheduler.c	Thu Jan 05 18:30:06 2023 +0100
+++ b/Small_CPU/Src/scheduler.c	Sat Jan 07 18:11:52 2023 +0100
@@ -516,7 +516,7 @@
 		ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick);
 
 #ifdef ENABLE_CO2_SUPPORT
-		if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_SENTINEL)
+		if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_CO2)
 		{
 			HandleUARTCO2Data();
 		}
@@ -838,7 +838,7 @@
 		}
 
 #ifdef ENABLE_CO2_SUPPORT
-		if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_SENTINEL)
+		if(global.dataSendToSlave.data.externalInterface_Cmd & EXT_INTERFACE_UART_CO2)
 		{
 			HandleUARTCO2Data();
 		}
--- a/Small_CPU/Src/uart.c	Thu Jan 05 18:30:06 2023 +0100
+++ b/Small_CPU/Src/uart.c	Sat Jan 07 18:11:52 2023 +0100
@@ -148,7 +148,8 @@
 	static receiveState_t rxState = RX_Ready;
 	static uint32_t lastReceiveTick = 0;
 
-	while(localRX != rxWriteIndex)
+
+	while((rxBuffer[localRX]!=0))
 	{
 		lastReceiveTick = HAL_GetTick();
 		if(rxState == RX_Ready)		/* identify data content */
@@ -167,12 +168,20 @@
 					break;
 			}
 		}
-		else if((rxState >= RX_Data0) && (rxState <= RX_Data4))
+		else if((rxBuffer[localRX] >= '0') && (rxBuffer[localRX] <= '9'))
 		{
-			if((rxBuffer[localRX] >= '0') && (rxBuffer[localRX] <= '9'))
+			if((rxState >= RX_Data0) && (rxState <= RX_Data4))
 			{
 				dataValue = dataValue * 10 + (rxBuffer[localRX] - '0');
 				rxState++;
+				if(rxState == RX_Data5)
+				{
+					rxState = RX_DataComplete;
+				}
+			}
+			else	/* protocol error data has max 5 digits */
+			{
+				rxState = RX_Ready;
 			}
 		}
 		if((rxBuffer[localRX] == ' ') || (rxBuffer[localRX] == '\n'))	/* Abort data detection */