diff Small_CPU/Src/externalInterface.c @ 691:52d68cf9994c Betatest

Improvment external interface usage: The previous implementation of the external interface was straight forward for ADC and Co2 UART usage. The new implementation provides the possibility to configurate the behavior of the external interface. e.g. Switching of external3,3V and ADC separatly and selection of UART protocol.
author Ideenmodellierer
date Fri, 05 Aug 2022 15:26:28 +0200
parents 1b995079c045
children f1b40364b0af
line wrap: on
line diff
--- a/Small_CPU/Src/externalInterface.c	Fri Aug 05 15:22:26 2022 +0200
+++ b/Small_CPU/Src/externalInterface.c	Fri Aug 05 15:26:28 2022 +0200
@@ -56,6 +56,7 @@
 
 float externalChannel_mV[MAX_ADC_CHANNEL];
 static uint8_t  externalV33_On = 0;
+static uint8_t  externalADC_On = 0;
 static uint16_t externalCO2Value;
 static uint16_t externalCO2SignalStrength;
 static uint16_t  externalCO2Status = 0;
@@ -182,6 +183,18 @@
 	return retval;
 }
 
+uint8_t setExternalInterfaceChannel(uint8_t channel, float value)
+{
+	uint8_t retval = 0;
+
+	if(channel < MAX_ADC_CHANNEL)
+	{
+		externalChannel_mV[channel] = value;
+		retval = 1;
+	}
+	return retval;
+}
+
 void externalInterface_InitPower33(void)
 {
 	GPIO_InitTypeDef   GPIO_InitStructure;
@@ -199,6 +212,12 @@
 {
 	return externalV33_On;
 }
+
+uint8_t externalInterface_isEnabledADC()
+{
+	return externalADC_On;
+}
+
 void externalInterface_SwitchPower33(uint8_t state)
 {
 	if(state != externalV33_On)
@@ -219,6 +238,18 @@
 		}
 	}
 }
+void externalInterface_SwitchADC(uint8_t state)
+{
+	if((state) && (externalInterfacePresent))
+	{
+		externalInterface_StartConversion(activeChannel);
+		externalADC_On = 1;
+	}
+	else
+	{
+		externalADC_On = 0;
+	}
+}
 
 void externalInterface_SetCO2Value(uint16_t CO2_ppm)
 {