comparison Small_CPU/Src/uartProtocol_Co2.c @ 932:effadaa3a1f7 Evo_2_23

Cleanup Gnss UART implementation: The first draft of the internal UART implementation was just a copy of the external UART handling. To avoid duplicated code and maintainance issue both UARTs (external/internal 6/1) share the same functions. To enable this a control structure has to be used as function input which defines the none shared resources like DMA control and rx/tx buffers
author Ideenmodellierer
date Sat, 07 Dec 2024 21:28:08 +0100
parents c0553dd70608
children 0b81ac558e89
comparison
equal deleted inserted replaced
931:5a9bc2e6112d 932:effadaa3a1f7
22 #include <string.h> 22 #include <string.h>
23 #include <uartProtocol_Co2.h> 23 #include <uartProtocol_Co2.h>
24 #include "uart.h" 24 #include "uart.h"
25 #include "externalInterface.h" 25 #include "externalInterface.h"
26 26
27
28 #ifdef ENABLE_CO2_SUPPORT 27 #ifdef ENABLE_CO2_SUPPORT
29 static uint8_t CO2Connected = 0; /* Binary indicator if a sensor is connected or not */ 28 static uint8_t CO2Connected = 0; /* Binary indicator if a sensor is connected or not */
30 static receiveStateCO2_t rxState = CO2RX_Ready; 29 static receiveStateCO2_t rxState = CO2RX_Ready;
31 30
32 31
82 81
83 if(localComState == UART_CO2_INIT) 82 if(localComState == UART_CO2_INIT)
84 { 83 {
85 CO2Connected = 0; 84 CO2Connected = 0;
86 externalInterface_SetCO2Scale(0.0); 85 externalInterface_SetCO2Scale(0.0);
87 UART_clearRxBuffer(); 86 UART_clearRxBuffer(&Uart1Ctrl);
88 UART_StartDMA_Receiption(); 87 UART_StartDMA_Receiption(&Uart1Ctrl);
89 localComState = UART_CO2_SETUP; 88 localComState = UART_CO2_SETUP;
90 } 89 }
91 if(localComState == UART_CO2_SETUP) 90 if(localComState == UART_CO2_SETUP)
92 { 91 {
93 if(externalInterface_GetCO2Scale() == 0.0) 92 if(externalInterface_GetCO2Scale() == 0.0)
121 } 120 }
122 } 121 }
123 else 122 else
124 { 123 {
125 localComState = UART_CO2_OPERATING; /* sensor in streaming mode if not connected to mux => operating */ 124 localComState = UART_CO2_OPERATING; /* sensor in streaming mode if not connected to mux => operating */
126 UART_StartDMA_Receiption(); 125 UART_StartDMA_Receiption(&Uart1Ctrl);
127 } 126 }
128 } 127 }
129 lastComState = localComState; 128 lastComState = localComState;
130 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); 129 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
131 } 130 }