changeset 738:30717de00f3a

Added data init function for external interface: If external sensors have been removed while OSTC was sleeping then (in case of digital sensor) an old value was displayed. By initializing the data structures after wakeup this is now avoided.
author Ideenmodellierer
date Thu, 02 Feb 2023 17:19:24 +0100
parents 5071d554aaa5
children 4a6bffaa38b3
files Small_CPU/Inc/externalInterface.h Small_CPU/Src/baseCPU2.c Small_CPU/Src/externalInterface.c
diffstat 3 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Small_CPU/Inc/externalInterface.h	Mon Mar 06 16:03:00 2023 +0100
+++ b/Small_CPU/Inc/externalInterface.h	Thu Feb 02 17:19:24 2023 +0100
@@ -54,6 +54,7 @@
 
 void externalInterface_Init(void);
 void externalInterface_InitPower33(void);
+void externalInterface_InitDatastruct(void);
 uint8_t externalInterface_StartConversion(uint8_t channel);
 uint8_t externalInterface_ReadAndSwitch();
 float externalInterface_CalculateADCValue(uint8_t channel);
--- a/Small_CPU/Src/baseCPU2.c	Mon Mar 06 16:03:00 2023 +0100
+++ b/Small_CPU/Src/baseCPU2.c	Thu Feb 02 17:19:24 2023 +0100
@@ -521,7 +521,7 @@
 			{
 				externalInterface_SwitchPower33(true);
 			}
-
+			externalInterface_InitDatastruct();
 			// EXTILine0_Button_DeInit(); not now, later after testing
 			break;
 		}
--- a/Small_CPU/Src/externalInterface.c	Mon Mar 06 16:03:00 2023 +0100
+++ b/Small_CPU/Src/externalInterface.c	Thu Feb 02 17:19:24 2023 +0100
@@ -83,12 +83,23 @@
 	}
 	global.deviceDataSendToMaster.hw_Info.checkADC = 1;
 
-/* init data values */
+	externalInterface_InitDatastruct();
+}
+
+void externalInterface_InitDatastruct(void)
+{
+	uint8_t index = 0;
+	/* init data values */
 	externalV33_On = 0;
 	externalCO2Value = 0;
 	externalCO2SignalStrength = 0;
 	externalCO2Status = 0;
 	externalAutoDetect = DETECTION_OFF;
+
+	for(index = 0; index < MAX_ADC_CHANNEL; index++)
+	{
+		externalChannel_mV[index] = 0.0;
+	}
 }