annotate Small_CPU/Src/uartProtocol_Co2.c @ 800:f8a112c5e71d

Cleanup warnings
author Ideenmodellierer
date Tue, 08 Aug 2023 17:29:03 +0200
parents e9eba334b942
children 9602a7338f28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
798
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
1 /**
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
2 ******************************************************************************
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
3 * @file uartProtocol_Co2.c
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
5 * @version V0.0.1
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
6 * @date 31-Jul-2023
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
7 * @brief Interface functionality to external, UART based CO2 sensors
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
8 *
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
9 @verbatim
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
10
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
11
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
12 @endverbatim
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
13 ******************************************************************************
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
14 * @attention
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
15 *
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
16 * <h2><center>&copy; COPYRIGHT(c) 2023 heinrichs weikamp</center></h2>
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
17 *
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
18 ******************************************************************************
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
19 */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
20 /* Includes ------------------------------------------------------------------*/
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
21
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
22 #include <string.h>
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
23 #include <uartProtocol_Co2.h>
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
24 #include "uart.h"
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
25 #include "externalInterface.h"
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
26
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
27
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
28 #ifdef ENABLE_CO2_SUPPORT
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
29 static uint8_t CO2Connected = 0; /* Binary indicator if a sensor is connected or not */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
30 static receiveState_t rxState = RX_Ready;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
31
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
32
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
33
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
34 float LED_Level = 0.0; /* Normalized LED value which may be used as indication for the health status of the sensor */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
35 float LED_ZeroOffset = 0.0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
36 float pCO2 = 0.0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
37
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
38
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
39
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
40 void uartCo2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
41 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
42 switch (CO2Cmd)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
43 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
44 case CO2CMD_MODE_POLL: *cmdLength = snprintf((char*)cmdString, 10, "K 2\r\n");
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
45 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
46 case CO2CMD_MODE_STREAM: *cmdLength = snprintf((char*)cmdString, 10, "K 1\r\n");
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
47 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
48 case CO2CMD_CALIBRATE: *cmdLength = snprintf((char*)cmdString, 10, "G\r\n");
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
49 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
50 case CO2CMD_GETDATA: *cmdLength = snprintf((char*)cmdString, 10, "Q\r\n");
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
51 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
52 case CO2CMD_GETSCALE: *cmdLength = snprintf((char*)cmdString, 10, ".\r\n");
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
53 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
54 default: *cmdLength = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
55 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
56 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
57 if(cmdLength != 0)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
58 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
59 UART_SendCmdString(cmdString);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
60 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
61 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
62
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
63
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
64 void uartCo2_Control(void)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
65 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
66 static uint8_t cmdString[10];
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
67 static uint8_t cmdLength = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
68 static uint8_t lastComState = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
69
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
70 uint8_t activeSensor = externalInterface_GetActiveUartSensor();
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
71 uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
72
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
73 uint8_t *pmap = externalInterface_GetSensorMapPointer(0);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
74
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
75
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
76 if(localComState == UART_CO2_ERROR)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
77 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
78 localComState = lastComState;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
79 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
80
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
81 if(localComState == UART_CO2_INIT)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
82 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
83 externalInterface_SetCO2Scale(0.0);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
84 UART_StartDMA_Receiption();
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
85 localComState = UART_CO2_SETUP;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
86 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
87 if(localComState == UART_CO2_SETUP)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
88 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
89 if(externalInterface_GetCO2Scale() == 0.0)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
90 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
91 uartCo2_SendCmd(CO2CMD_GETSCALE, cmdString, &cmdLength);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
92 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
93 else
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
94 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
95 localComState = UART_CO2_IDLE;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
96 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
97 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
98 else
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
99 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
100 if(localComState == UART_CO2_CALIBRATE)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
101 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
102 uartCo2_SendCmd(CO2CMD_CALIBRATE, cmdString, &cmdLength);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
103 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
104 else if(pmap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) /* sensor is working in polling mode if mux is connected to avoid interference with other sensors */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
105 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
106 //if(cmdLength == 0) /* poll data */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
107 if(localComState == UART_CO2_IDLE)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
108 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
109 uartCo2_SendCmd(CO2CMD_GETDATA, cmdString, &cmdLength);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
110 localComState = UART_CO2_OPERATING;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
111 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
112 else /* resend last command */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
113 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
114 UART_SendCmdString(cmdString);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
115 cmdLength = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
116 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
117 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
118 else
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
119 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
120 localComState = UART_CO2_OPERATING; /* sensor in streaming mode if not connected to mux => operating */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
121 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
122 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
123 lastComState = localComState;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
124 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
125 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
126
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
127
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
128 void uartCo2_ProcessData(uint8_t data)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
129 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
130 static uint8_t dataType = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
131 static uint32_t dataValue = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
132 uint8_t activeSensor = externalInterface_GetActiveUartSensor();
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
133 uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
134
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
135 if(rxState == RX_Ready) /* identify data content */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
136 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
137 switch(data)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
138 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
139 case 'G':
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
140 case 'l':
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
141 case 'D':
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
142 case 'Z':
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
143 case '.': dataType = data;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
144 rxState = RX_Data0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
145 dataValue = 0;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
146 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
147 case '?': localComState = UART_CO2_ERROR;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
148 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
149 default: /* unknown or corrupted => ignore */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
150 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
151 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
152 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
153 else if((data >= '0') && (data <= '9'))
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
154 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
155 if((rxState >= RX_Data0) && (rxState <= RX_Data4))
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
156 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
157 dataValue = dataValue * 10 + (data - '0');
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
158 rxState++;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
159 if(rxState == RX_Data5)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
160 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
161 rxState = RX_DataComplete;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
162 CO2Connected = 1;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
163 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
164 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
165 else /* protocol error data has max 5 digits */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
166 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
167 rxState = RX_Ready;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
168 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
169 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
170 if((data == ' ') || (data == '\n')) /* Abort data detection */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
171 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
172 if(rxState == RX_DataComplete)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
173 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
174 localComState = UART_CO2_IDLE;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
175 if(externalInterface_GetCO2State() == 0)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
176 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
177 externalInterface_SetCO2State(EXT_INTERFACE_33V_ON);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
178 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
179 switch(dataType)
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
180 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
181 case 'D': externalInterface_SetCO2SignalStrength(dataValue);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
182 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
183 case 'l': LED_ZeroOffset = dataValue;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
184 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
185 case 'Z': externalInterface_SetCO2Value(dataValue);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
186 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
187 case '.': externalInterface_SetCO2Scale(dataValue);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
188 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
189 default: rxState = RX_Ready;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
190 break;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
191 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
192 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
193 if(rxState != RX_Data0) /* reset state machine because message in wrong format */
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
194 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
195 rxState = RX_Ready;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
196 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
197 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
198 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
199 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
200
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
201 uint8_t uartCo2_isSensorConnected()
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
202 {
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
203 return CO2Connected;
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
204 }
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
205
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
206 #endif
e9eba334b942 Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff changeset
207