Mercurial > public > ostc4
annotate Small_CPU/Src/uartProtocol_O2.c @ 958:902cb199eee6 Evo_2_23
Changed menu name O2 Sensors to External Sensors:
Meanwhile not only O2 sensors may be connected using the external interface (e.g. CO2 sensors) => renamed menu to avoid confusions.
author | Ideenmodellierer |
---|---|
date | Mon, 06 Jan 2025 21:34:33 +0100 |
parents | 3420e3ba698d |
children |
rev | line source |
---|---|
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
1 /** |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
2 ****************************************************************************** |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
3 * @file uartProtocol_O2.c |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
4 * @author heinrichs weikamp gmbh |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
5 * @version V0.0.1 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
6 * @date 16-Jun-2023 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
7 * @brief Interface functionality to external, UART based O2 sensors |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
8 * |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
9 @verbatim |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
10 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
11 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
12 @endverbatim |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
13 ****************************************************************************** |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
14 * @attention |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
15 * |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
16 * <h2><center>© COPYRIGHT(c) 2023 heinrichs weikamp</center></h2> |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
17 * |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
18 ****************************************************************************** |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
19 */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
20 /* Includes ------------------------------------------------------------------*/ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
21 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
22 #include <string.h> |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
23 #include "uart.h" |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
24 #include "uartProtocol_O2.h" |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
25 #include "externalInterface.h" |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
26 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
27 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
28 const uint8_t errorStr[] = "#ERRO"; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
29 static uint32_t lastReceiveTick = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
30 static uartO2RxState_t rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
31 static uint8_t digO2Connected = 0; /* Binary indicator if a sensor is connected or not */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
32 static SSensorDataDiveO2 tmpSensorDataDiveO2; /* intermediate storage for additional sensor data */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
33 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
34 static uint8_t activeSensor = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
35 static uint8_t respondErrorDetected = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
36 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
37 void uartO2_InitData() |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
38 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
39 digO2Connected = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
40 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
41 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
42 void uartO2_SetupCmd(uint8_t O2State, uint8_t *cmdString, uint8_t *cmdLength) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
43 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
44 switch (O2State) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
45 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
46 case UART_O2_CHECK: *cmdLength = snprintf((char*)cmdString, 10, "#LOGO"); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
47 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
48 case UART_O2_REQ_INFO: *cmdLength = snprintf((char*)cmdString, 10, "#VERS"); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
49 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
50 case UART_O2_REQ_ID: *cmdLength = snprintf((char*)cmdString, 10, "#IDNR"); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
51 break; |
800 | 52 case UART_O2_REQ_O2: *cmdLength = snprintf((char*)cmdString, 10, "#DOXY"); |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
53 break; |
800 | 54 case UART_O2_REQ_RAW: *cmdLength = snprintf((char*)cmdString, 10, "#DRAW"); |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
55 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
56 default: *cmdLength = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
57 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
58 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
59 if(*cmdLength != 0) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
60 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
61 cmdString[*cmdLength] = 0x0D; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
62 *cmdLength = *cmdLength + 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
63 cmdString[*cmdLength] = 0x0A; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
64 *cmdLength = *cmdLength + 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
65 cmdString[*cmdLength] = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
66 *cmdLength = *cmdLength + 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
67 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
68 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
69 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
70 static uint8_t cmdLength = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
71 static uint8_t cmdString[10]; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
72 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
73 void uartO2_Control(void) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
74 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
75 static uint8_t lastComState = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
76 static uint8_t lastActiveSensor = 0xFF; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
77 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
78 uint8_t activeSensor = externalInterface_GetActiveUartSensor(); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
79 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
80 uartO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
81 externalInterface_GetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET, (uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
82 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
83 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
84 if(lastActiveSensor != activeSensor) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
85 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
86 lastActiveSensor = activeSensor; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
87 if(localComState != UART_O2_ERROR) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
88 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
89 lastComState = localComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
90 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
91 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
92 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
93 lastComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
94 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
95 if(localComState == UART_O2_CHECK) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
96 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
97 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
98 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
99 UART_FlushRxBuffer(); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
100 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
101 |
800 | 102 if(localComState == UART_O2_INIT) |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
103 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
104 memset((char*) &tmpSensorDataDiveO2, 0, sizeof(tmpSensorDataDiveO2)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
105 externalInterface_SetSensorData(0xFF,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
106 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
107 localComState = UART_O2_CHECK; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
108 lastComState = UART_O2_CHECK; |
932 | 109 UART_clearRxBuffer(&Uart1Ctrl); |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
110 uartO2_SetupCmd(localComState,cmdString,&cmdLength); |
916
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
800
diff
changeset
|
111 UART_SendCmdString(cmdString); |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
112 rxState = O2RX_CONFIRM; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
113 respondErrorDetected = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
114 digO2Connected = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
115 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
116 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
117 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
118 if(localComState == UART_O2_ERROR) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
119 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
120 localComState = lastComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
121 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
122 lastComState = localComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
123 if(localComState == UART_O2_IDLE) /* cyclic request of o2 value */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
124 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
125 if((activeSensor != MAX_MUX_CHANNEL) && (tmpSensorDataDiveO2.sensorId == 0)) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
126 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
127 localComState = UART_O2_REQ_ID; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
128 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
129 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
130 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
131 localComState = UART_O2_REQ_RAW; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
132 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
133 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
134 rxState = O2RX_CONFIRM; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
135 uartO2_SetupCmd(localComState,cmdString,&cmdLength); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
136 UART_SendCmdString(cmdString); |
957
3420e3ba698d
External sensor commands: Add sensor ID to command:
Ideenmodellierer
parents:
932
diff
changeset
|
137 if(localComState == UART_O2_CHECK) |
3420e3ba698d
External sensor commands: Add sensor ID to command:
Ideenmodellierer
parents:
932
diff
changeset
|
138 { |
3420e3ba698d
External sensor commands: Add sensor ID to command:
Ideenmodellierer
parents:
932
diff
changeset
|
139 localComState = UART_O2_IDLE; /* confirmation seems to be send after blinking => the response could be longer as the channel switch time => ignore */ |
3420e3ba698d
External sensor commands: Add sensor ID to command:
Ideenmodellierer
parents:
932
diff
changeset
|
140 } |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
141 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
142 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
143 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
144 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
145 void uartO2_ProcessData(uint8_t data) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
146 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
147 static uint8_t cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
148 static uint8_t errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
149 static char tmpRxBuf[30]; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
150 static uint8_t tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
151 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
152 uint32_t tmpO2 = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
153 uint32_t tmpData = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
154 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
155 uint32_t tick = HAL_GetTick(); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
156 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
157 uartO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
158 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
159 lastReceiveTick = tick; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
160 switch(rxState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
161 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
162 case O2RX_CONFIRM: if(data == '#') |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
163 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
164 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
165 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
166 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
167 if(errorReadIndex < sizeof(errorStr)-1) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
168 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
169 if(data == errorStr[errorReadIndex]) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
170 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
171 errorReadIndex++; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
172 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
173 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
174 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
175 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
176 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
177 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
178 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
179 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
180 respondErrorDetected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
181 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
182 if(localComState != UART_O2_IDLE) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
183 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
184 localComState = UART_O2_ERROR; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
185 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
186 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
187 if(data == cmdString[cmdReadIndex]) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
188 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
189 cmdReadIndex++; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
190 if(cmdReadIndex == cmdLength - 3) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
191 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
192 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
193 if((activeSensor == MAX_MUX_CHANNEL)) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
194 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
195 if(respondErrorDetected) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
196 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
197 digO2Connected = 0; /* the multiplexer mirrors the incoming message and does not generate an error information => no mux connected */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
198 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
199 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
200 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
201 digO2Connected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
202 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
203 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
204 else /* handle sensors which should respond with an error message after channel switch */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
205 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
206 digO2Connected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
207 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
208 tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
209 memset((char*) tmpRxBuf, 0, sizeof(tmpRxBuf)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
210 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
211 switch (localComState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
212 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
213 case UART_O2_CHECK: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
214 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
215 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
216 case UART_O2_REQ_ID: rxState = O2RX_GETNR; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
217 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
218 case UART_O2_REQ_INFO: rxState = O2RX_GETTYPE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
219 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
220 case UART_O2_REQ_RAW: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
221 case UART_O2_REQ_O2: rxState = O2RX_GETO2; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
222 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
223 default: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
224 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
225 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
226 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
227 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
228 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
229 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
230 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
231 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
232 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
233 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
234 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
235 case O2RX_GETSTATUS: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
236 case O2RX_GETTEMP: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
237 case O2RX_GETTYPE: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
238 case O2RX_GETVERSION: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
239 case O2RX_GETCHANNEL: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
240 case O2RX_GETSUBSENSORS: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
241 case O2RX_GETO2: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
242 case O2RX_GETNR: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
243 case O2RX_GETDPHI: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
244 case O2RX_INTENSITY: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
245 case O2RX_AMBIENTLIGHT: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
246 case O2RX_PRESSURE: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
247 case O2RX_HUMIDITY: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
248 if(data != 0x0D) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
249 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
250 if(data != ' ') /* the following data entities are placed within the data stream => no need to store data at the end */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
251 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
252 tmpRxBuf[tmpRxIdx++] = data; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
253 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
254 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
255 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
256 if(tmpRxIdx != 0) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
257 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
258 switch(rxState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
259 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
260 case O2RX_GETCHANNEL: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
261 rxState = O2RX_GETVERSION; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
262 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
263 case O2RX_GETVERSION: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
264 rxState = O2RX_GETSUBSENSORS; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
265 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
266 case O2RX_GETTYPE: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
267 rxState = O2RX_GETCHANNEL; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
268 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
269 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
270 case O2RX_GETO2: StringToInt(tmpRxBuf,&tmpO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
271 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
272 setExternalInterfaceChannel(activeSensor + EXT_INTERFACE_MUX_OFFSET,(float)(tmpO2 / 10000.0)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
273 rxState = O2RX_GETTEMP; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
274 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
275 case O2RX_GETTEMP: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.temperature); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
276 rxState = O2RX_GETSTATUS; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
277 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
278 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
279 rxState = O2RX_GETDPHI; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
280 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
281 case O2RX_GETDPHI: /* ignored to save memory and most likly irrelevant for diver */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
282 rxState = O2RX_INTENSITY; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
283 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
284 case O2RX_INTENSITY: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.intensity); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
285 rxState = O2RX_AMBIENTLIGHT; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
286 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
287 case O2RX_AMBIENTLIGHT: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.ambient); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
288 rxState = O2RX_PRESSURE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
289 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
290 case O2RX_PRESSURE: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.pressure); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
291 rxState = O2RX_HUMIDITY; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
292 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
293 default: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
294 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
295 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
296 memset((char*) tmpRxBuf, 0, tmpRxIdx); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
297 tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
298 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
299 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
300 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
301 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
302 { /* the following data items are the last of a sensor respond => store temporal data */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
303 switch (rxState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
304 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
305 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
306 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
307 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
308 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
309 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
310 case O2RX_GETSUBSENSORS: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
311 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
312 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
313 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
314 case O2RX_HUMIDITY: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.humidity); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
315 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
316 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
317 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
318 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
319 case O2RX_GETNR: StringToUInt64((char*)tmpRxBuf,&tmpSensorDataDiveO2.sensorId); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
320 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
321 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
322 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
323 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
324 default: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
325 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
326 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
327 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
328 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
329 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
330 default: rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
331 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
332 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
333 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
334 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
335 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
336 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
337 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
338 uint8_t uartO2_isSensorConnected() |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
339 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
340 return digO2Connected; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
341 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
342 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
343 void uartO2_SetChannel(uint8_t channel) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
344 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
345 if(channel <= MAX_MUX_CHANNEL) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
346 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
347 activeSensor = channel; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
348 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
349 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
350 |