comparison 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
comparison
equal deleted inserted replaced
690:fca2bd25e6e2 691:52d68cf9994c
54 static uint8_t timeoutCnt = 0; 54 static uint8_t timeoutCnt = 0;
55 static uint8_t externalInterfacePresent = 0; 55 static uint8_t externalInterfacePresent = 0;
56 56
57 float externalChannel_mV[MAX_ADC_CHANNEL]; 57 float externalChannel_mV[MAX_ADC_CHANNEL];
58 static uint8_t externalV33_On = 0; 58 static uint8_t externalV33_On = 0;
59 static uint8_t externalADC_On = 0;
59 static uint16_t externalCO2Value; 60 static uint16_t externalCO2Value;
60 static uint16_t externalCO2SignalStrength; 61 static uint16_t externalCO2SignalStrength;
61 static uint16_t externalCO2Status = 0; 62 static uint16_t externalCO2Status = 0;
62 63
63 64
180 retval = externalChannel_mV[channel]; 181 retval = externalChannel_mV[channel];
181 } 182 }
182 return retval; 183 return retval;
183 } 184 }
184 185
186 uint8_t setExternalInterfaceChannel(uint8_t channel, float value)
187 {
188 uint8_t retval = 0;
189
190 if(channel < MAX_ADC_CHANNEL)
191 {
192 externalChannel_mV[channel] = value;
193 retval = 1;
194 }
195 return retval;
196 }
197
185 void externalInterface_InitPower33(void) 198 void externalInterface_InitPower33(void)
186 { 199 {
187 GPIO_InitTypeDef GPIO_InitStructure; 200 GPIO_InitTypeDef GPIO_InitStructure;
188 201
189 GPIO_InitStructure.Pin = GPIO_PIN_7; 202 GPIO_InitStructure.Pin = GPIO_PIN_7;
197 210
198 uint8_t externalInterface_isEnabledPower33() 211 uint8_t externalInterface_isEnabledPower33()
199 { 212 {
200 return externalV33_On; 213 return externalV33_On;
201 } 214 }
215
216 uint8_t externalInterface_isEnabledADC()
217 {
218 return externalADC_On;
219 }
220
202 void externalInterface_SwitchPower33(uint8_t state) 221 void externalInterface_SwitchPower33(uint8_t state)
203 { 222 {
204 if(state != externalV33_On) 223 if(state != externalV33_On)
205 { 224 {
206 if(state) 225 if(state)
217 externalInterface_SetCO2SignalStrength(0); 236 externalInterface_SetCO2SignalStrength(0);
218 MX_USART1_UART_DeInit(); 237 MX_USART1_UART_DeInit();
219 } 238 }
220 } 239 }
221 } 240 }
241 void externalInterface_SwitchADC(uint8_t state)
242 {
243 if((state) && (externalInterfacePresent))
244 {
245 externalInterface_StartConversion(activeChannel);
246 externalADC_On = 1;
247 }
248 else
249 {
250 externalADC_On = 0;
251 }
252 }
222 253
223 void externalInterface_SetCO2Value(uint16_t CO2_ppm) 254 void externalInterface_SetCO2Value(uint16_t CO2_ppm)
224 { 255 {
225 externalCO2Value = CO2_ppm; 256 externalCO2Value = CO2_ppm;
226 } 257 }