Mercurial > public > ostc4
annotate Small_CPU/Src/uartProtocol_Co2.c @ 929:63c340abd70e Evo_2_23
Add a line to the compass heading dive menu that shows the currently set heading to enable the
diver to confirm it / add it to notes.
Also add a log entry every time a new compass heading is set or the heading is cleared.
And add a way to add compass headings to the log without changing the currently set heading -
this was added after discussion with cave divers who are interested in recording headings
when mapping out caves.
From mikeller
author | heinrichsweikamp |
---|---|
date | Mon, 02 Dec 2024 11:16:10 +0100 |
parents | c0553dd70608 |
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 |
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 */ |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
30 static receiveStateCO2_t rxState = CO2RX_Ready; |
798
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 { |
809 | 42 *cmdLength = 0; |
43 | |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
44 switch (CO2Cmd) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
45 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
46 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
|
47 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
48 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
|
49 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
50 case CO2CMD_CALIBRATE: *cmdLength = snprintf((char*)cmdString, 10, "G\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_GETDATA: *cmdLength = snprintf((char*)cmdString, 10, "Q\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 case CO2CMD_GETSCALE: *cmdLength = snprintf((char*)cmdString, 10, ".\r\n"); |
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 default: *cmdLength = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
57 break; |
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 if(cmdLength != 0) |
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 UART_SendCmdString(cmdString); |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
66 void uartCo2_Control(void) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
67 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
68 static uint8_t cmdString[10]; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
69 static uint8_t cmdLength = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
70 static uint8_t lastComState = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
71 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
72 uint8_t activeSensor = externalInterface_GetActiveUartSensor(); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
73 uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
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 uint8_t *pmap = externalInterface_GetSensorMapPointer(0); |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
78 if(localComState == UART_CO2_ERROR) |
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 localComState = lastComState; |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
83 if(localComState == UART_CO2_INIT) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
84 { |
809 | 85 CO2Connected = 0; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
86 externalInterface_SetCO2Scale(0.0); |
919 | 87 UART_clearRxBuffer(); |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
88 UART_StartDMA_Receiption(); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
89 localComState = UART_CO2_SETUP; |
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 if(localComState == UART_CO2_SETUP) |
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 if(externalInterface_GetCO2Scale() == 0.0) |
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 uartCo2_SendCmd(CO2CMD_GETSCALE, cmdString, &cmdLength); |
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 else |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
98 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
99 localComState = UART_CO2_IDLE; |
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 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
102 else |
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 if(localComState == UART_CO2_CALIBRATE) |
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 uartCo2_SendCmd(CO2CMD_CALIBRATE, cmdString, &cmdLength); |
809 | 107 localComState = UART_CO2_IDLE; |
798
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 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
|
110 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
111 //if(cmdLength == 0) /* poll data */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
112 if(localComState == UART_CO2_IDLE) |
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 uartCo2_SendCmd(CO2CMD_GETDATA, cmdString, &cmdLength); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
115 localComState = UART_CO2_OPERATING; |
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 else /* resend last command */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
118 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
119 UART_SendCmdString(cmdString); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
120 cmdLength = 0; |
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 else |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
124 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
125 localComState = UART_CO2_OPERATING; /* sensor in streaming mode if not connected to mux => operating */ |
809 | 126 UART_StartDMA_Receiption(); |
798
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 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
129 lastComState = localComState; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
130 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
134 void uartCo2_ProcessData(uint8_t data) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
135 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
136 static uint8_t dataType = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
137 static uint32_t dataValue = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
138 uint8_t activeSensor = externalInterface_GetActiveUartSensor(); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
139 uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
140 |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
141 if(rxState == CO2RX_Ready) /* identify data content */ |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
142 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
143 switch(data) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
144 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
145 case 'G': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
146 case 'l': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
147 case 'D': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
148 case 'Z': |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
149 case '.': dataType = data; |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
150 rxState = CO2RX_Data0; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
151 dataValue = 0; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
152 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
153 case '?': localComState = UART_CO2_ERROR; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
154 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
155 default: /* unknown or corrupted => ignore */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
156 break; |
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 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
159 else if((data >= '0') && (data <= '9')) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
160 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
161 if((rxState >= CO2RX_Data0) && (rxState <= CO2RX_Data4)) |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
162 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
163 dataValue = dataValue * 10 + (data - '0'); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
164 rxState++; |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
165 if(rxState == CO2RX_Data5) |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
166 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
167 rxState = CO2RX_DataComplete; |
798
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 else /* protocol error data has max 5 digits */ |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
171 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
172 if(rxState != CO2RX_DataComplete) /* commands will not answer with number values */ |
809 | 173 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
174 rxState = CO2RX_Ready; |
809 | 175 } |
798
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 } |
916
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
178 else if((data == ' ') || (data == '\n')) /* Abort data detection */ |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
179 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
180 if(rxState == CO2RX_DataComplete) |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
181 { |
809 | 182 CO2Connected = 1; |
183 if(localComState == UART_CO2_SETUP) | |
184 { | |
185 if(dataType == '.') | |
186 { | |
187 localComState = UART_CO2_IDLE; | |
188 } | |
189 } | |
190 else | |
191 { | |
192 localComState = UART_CO2_IDLE; | |
193 } | |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
194 if(externalInterface_GetCO2State() == 0) |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
195 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
196 externalInterface_SetCO2State(EXT_INTERFACE_33V_ON); |
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 switch(dataType) |
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 case 'D': externalInterface_SetCO2SignalStrength(dataValue); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
201 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
202 case 'l': LED_ZeroOffset = dataValue; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
203 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
204 case 'Z': externalInterface_SetCO2Value(dataValue); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
205 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
206 case '.': externalInterface_SetCO2Scale(dataValue); |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
207 break; |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
208 default: rxState = CO2RX_Ready; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
209 break; |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
210 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
211 } |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
212 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
|
213 { |
842
c3dd461ca3f9
Migrated Sentinel protocol to new UART structure:
Ideenmodellierer
parents:
809
diff
changeset
|
214 rxState = CO2RX_Ready; |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
215 } |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
216 } |
916
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
217 else |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
218 { |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
219 if((rxState >= CO2RX_Data0) && (rxState <= CO2RX_Data4)) |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
220 { |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
221 rxState = CO2RX_Ready; /* numerical data expected => abort */ |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
222 } |
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
842
diff
changeset
|
223 } |
798
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
224 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
227 uint8_t uartCo2_isSensorConnected() |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
228 { |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
229 return CO2Connected; |
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 |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
232 #endif |
e9eba334b942
Migrated CO2 protocol implementation to new format:
Ideenmodellierer
parents:
diff
changeset
|
233 |