Mercurial > public > ostc4
annotate Small_CPU/Src/uartProtocol_Co2.c @ 946:80ae8ea7f0a0 Evo_2_23
GNSS set to full power at startup:
In case of an reset the module would continue in sleep mode if it was in this state. To avoid this the module will now always set to full power at startup of the RTE.
author | Ideenmodellierer |
---|---|
date | Sun, 22 Dec 2024 20:52:08 +0100 |
parents | effadaa3a1f7 |
children |
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>© 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 #ifdef ENABLE_CO2_SUPPORT |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
28 static uint8_t CO2Connected = 0; /* Binary indicator if a sensor is connected or not */ |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
29 static receiveStateCO2_t rxState = CO2RX_Ready; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
30 |
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 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
|
34 float LED_ZeroOffset = 0.0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
35 float pCO2 = 0.0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
36 |
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 void uartCo2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
40 { |
809 | 41 *cmdLength = 0; |
42 | |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
43 switch (CO2Cmd) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
44 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
45 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
|
46 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
47 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
|
48 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
49 case CO2CMD_CALIBRATE: *cmdLength = snprintf((char*)cmdString, 10, "G\r\n"); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
50 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
51 case CO2CMD_GETDATA: *cmdLength = snprintf((char*)cmdString, 10, "Q\r\n"); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
52 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
53 case CO2CMD_GETSCALE: *cmdLength = snprintf((char*)cmdString, 10, ".\r\n"); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
54 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
55 default: *cmdLength = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
56 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
57 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
58 if(cmdLength != 0) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
59 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
60 UART_SendCmdString(cmdString); |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
65 void uartCo2_Control(void) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
66 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
67 static uint8_t cmdString[10]; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
68 static uint8_t cmdLength = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
69 static uint8_t lastComState = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
70 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
71 uint8_t activeSensor = externalInterface_GetActiveUartSensor(); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
72 uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
73 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
74 uint8_t *pmap = externalInterface_GetSensorMapPointer(0); |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
77 if(localComState == UART_CO2_ERROR) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
78 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
79 localComState = lastComState; |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
82 if(localComState == UART_CO2_INIT) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
83 { |
809 | 84 CO2Connected = 0; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
85 externalInterface_SetCO2Scale(0.0); |
932 | 86 UART_clearRxBuffer(&Uart1Ctrl); |
87 UART_StartDMA_Receiption(&Uart1Ctrl); | |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
88 localComState = UART_CO2_SETUP; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
89 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
90 if(localComState == UART_CO2_SETUP) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
91 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
92 if(externalInterface_GetCO2Scale() == 0.0) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
93 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
94 uartCo2_SendCmd(CO2CMD_GETSCALE, cmdString, &cmdLength); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
95 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
96 else |
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 localComState = UART_CO2_IDLE; |
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 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
101 else |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
102 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
103 if(localComState == UART_CO2_CALIBRATE) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
104 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
105 uartCo2_SendCmd(CO2CMD_CALIBRATE, cmdString, &cmdLength); |
809 | 106 localComState = UART_CO2_IDLE; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
107 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
108 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
|
109 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
110 //if(cmdLength == 0) /* poll data */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
111 if(localComState == UART_CO2_IDLE) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
112 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
113 uartCo2_SendCmd(CO2CMD_GETDATA, cmdString, &cmdLength); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
114 localComState = UART_CO2_OPERATING; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
115 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
116 else /* resend last command */ |
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 UART_SendCmdString(cmdString); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
119 cmdLength = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
120 } |
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 else |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
123 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
124 localComState = UART_CO2_OPERATING; /* sensor in streaming mode if not connected to mux => operating */ |
932 | 125 UART_StartDMA_Receiption(&Uart1Ctrl); |
798
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 lastComState = localComState; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
129 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
130 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
131 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
132 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
133 void uartCo2_ProcessData(uint8_t data) |
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 static uint8_t dataType = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
136 static uint32_t dataValue = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
137 uint8_t activeSensor = externalInterface_GetActiveUartSensor(); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
138 uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
139 |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
140 if(rxState == CO2RX_Ready) /* identify data content */ |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
141 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
142 switch(data) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
143 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
144 case 'G': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
145 case 'l': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
146 case 'D': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
147 case 'Z': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
148 case '.': dataType = data; |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
149 rxState = CO2RX_Data0; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
150 dataValue = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
151 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
152 case '?': localComState = UART_CO2_ERROR; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
153 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
154 default: /* unknown or corrupted => ignore */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
155 break; |
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 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
158 else if((data >= '0') && (data <= '9')) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
159 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
160 if((rxState >= CO2RX_Data0) && (rxState <= CO2RX_Data4)) |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
161 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
162 dataValue = dataValue * 10 + (data - '0'); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
163 rxState++; |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
164 if(rxState == CO2RX_Data5) |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
165 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
166 rxState = CO2RX_DataComplete; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
167 } |
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 else /* protocol error data has max 5 digits */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
170 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
171 if(rxState != CO2RX_DataComplete) /* commands will not answer with number values */ |
809 | 172 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
173 rxState = CO2RX_Ready; |
809 | 174 } |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
175 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
176 } |
916
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
177 else if((data == ' ') || (data == '\n')) /* Abort data detection */ |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
178 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
179 if(rxState == CO2RX_DataComplete) |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
180 { |
809 | 181 CO2Connected = 1; |
182 if(localComState == UART_CO2_SETUP) | |
183 { | |
184 if(dataType == '.') | |
185 { | |
186 localComState = UART_CO2_IDLE; | |
187 } | |
188 } | |
189 else | |
190 { | |
191 localComState = UART_CO2_IDLE; | |
192 } | |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
193 if(externalInterface_GetCO2State() == 0) |
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 externalInterface_SetCO2State(EXT_INTERFACE_33V_ON); |
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 switch(dataType) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
198 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
199 case 'D': externalInterface_SetCO2SignalStrength(dataValue); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
200 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
201 case 'l': LED_ZeroOffset = dataValue; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
202 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
203 case 'Z': externalInterface_SetCO2Value(dataValue); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
204 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
205 case '.': externalInterface_SetCO2Scale(dataValue); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
206 break; |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
207 default: rxState = CO2RX_Ready; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
208 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
209 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
210 } |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
211 if(rxState != CO2RX_Data0) /* reset state machine because message in wrong format */ |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
212 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
213 rxState = CO2RX_Ready; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
214 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
215 } |
916
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
216 else |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
217 { |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
218 if((rxState >= CO2RX_Data0) && (rxState <= CO2RX_Data4)) |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
219 { |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
220 rxState = CO2RX_Ready; /* numerical data expected => abort */ |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
221 } |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
222 } |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
223 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
224 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
225 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
226 uint8_t uartCo2_isSensorConnected() |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
227 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
228 return CO2Connected; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
229 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
230 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
231 #endif |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
232 |