annotate Small_CPU/Src/uartProtocol_O2.c @ 921:eb4109d7d1e9 Evo_2_23

Improved mix mode ADC conversion: Activity of UART sensors may have an impact to ADC measurement. To avoid the ADC trigger was moved into a time window ~300ms after last UART command request => After UART sensor performed measurement but before next measurement is requested. In addition the general ADC measurement cycle has been changed to one second to avoid jitter in the value updates on the display.
author Ideenmodellierer
date Sun, 03 Nov 2024 18:19:51 +0100
parents 4832981f9af8
children effadaa3a1f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>&copy; 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
f8a112c5e71d Cleanup warnings
Ideenmodellierer
parents: 798
diff changeset
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
f8a112c5e71d Cleanup warnings
Ideenmodellierer
parents: 798
diff changeset
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
f8a112c5e71d Cleanup warnings
Ideenmodellierer
parents: 798
diff changeset
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;
921
eb4109d7d1e9 Improved mix mode ADC conversion:
Ideenmodellierer
parents: 916
diff changeset
109 UART_clearRxBuffer();
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);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
137 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
138 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
139 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
140
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
141 void uartO2_ProcessData(uint8_t data)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
142 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
143 static uint8_t cmdReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
144 static uint8_t errorReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
145 static char tmpRxBuf[30];
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
146 static uint8_t tmpRxIdx = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
147
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
148 uint32_t tmpO2 = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
149 uint32_t tmpData = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
150
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
151 uint32_t tick = HAL_GetTick();
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
152
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
153 uartO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
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 lastReceiveTick = tick;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
156 switch(rxState)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
157 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
158 case O2RX_CONFIRM: if(data == '#')
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
159 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
160 cmdReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
161 errorReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
162 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
163 if(errorReadIndex < sizeof(errorStr)-1)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
164 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
165 if(data == errorStr[errorReadIndex])
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 errorReadIndex++;
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 else
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 = 0;
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 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
174 else
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
175 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
176 respondErrorDetected = 1;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
177 errorReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
178 if(localComState != UART_O2_IDLE)
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 localComState = UART_O2_ERROR;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
181 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
182 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
183 if(data == cmdString[cmdReadIndex])
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
184 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
185 cmdReadIndex++;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
186 if(cmdReadIndex == cmdLength - 3)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
187 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
188 errorReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
189 if((activeSensor == MAX_MUX_CHANNEL))
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
190 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
191 if(respondErrorDetected)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
192 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
193 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
194 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
195 else
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 = 1;
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 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
200 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
201 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
202 digO2Connected = 1;
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 tmpRxIdx = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
205 memset((char*) tmpRxBuf, 0, sizeof(tmpRxBuf));
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
206 cmdReadIndex = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
207 switch (localComState)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
208 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
209 case UART_O2_CHECK: localComState = UART_O2_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
210 rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
211 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
212 case UART_O2_REQ_ID: rxState = O2RX_GETNR;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
213 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
214 case UART_O2_REQ_INFO: rxState = O2RX_GETTYPE;
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_RAW:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
217 case UART_O2_REQ_O2: rxState = O2RX_GETO2;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
218 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
219 default: localComState = UART_O2_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
220 rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
221 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
222 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
223 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
224 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
225 else
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 cmdReadIndex = 0;
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 break;
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 case O2RX_GETSTATUS:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
232 case O2RX_GETTEMP:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
233 case O2RX_GETTYPE:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
234 case O2RX_GETVERSION:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
235 case O2RX_GETCHANNEL:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
236 case O2RX_GETSUBSENSORS:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
237 case O2RX_GETO2:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
238 case O2RX_GETNR:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
239 case O2RX_GETDPHI:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
240 case O2RX_INTENSITY:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
241 case O2RX_AMBIENTLIGHT:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
242 case O2RX_PRESSURE:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
243 case O2RX_HUMIDITY:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
244 if(data != 0x0D)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
245 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
246 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
247 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
248 tmpRxBuf[tmpRxIdx++] = data;
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 else
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 if(tmpRxIdx != 0)
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 switch(rxState)
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 case O2RX_GETCHANNEL: StringToInt(tmpRxBuf,&tmpData);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
257 rxState = O2RX_GETVERSION;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
258 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
259 case O2RX_GETVERSION: StringToInt(tmpRxBuf,&tmpData);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
260 rxState = O2RX_GETSUBSENSORS;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
261 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
262 case O2RX_GETTYPE: StringToInt(tmpRxBuf,&tmpData);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
263 rxState = O2RX_GETCHANNEL;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
264 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
265
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
266 case O2RX_GETO2: StringToInt(tmpRxBuf,&tmpO2);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
267
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
268 setExternalInterfaceChannel(activeSensor + EXT_INTERFACE_MUX_OFFSET,(float)(tmpO2 / 10000.0));
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
269 rxState = O2RX_GETTEMP;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
270 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
271 case O2RX_GETTEMP: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.temperature);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
272 rxState = O2RX_GETSTATUS;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
273 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
274 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); /* raw data cycle */
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
275 rxState = O2RX_GETDPHI;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
276 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
277 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
278 rxState = O2RX_INTENSITY;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
279 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
280 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
281 rxState = O2RX_AMBIENTLIGHT;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
282 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
283 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
284 rxState = O2RX_PRESSURE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
285 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
286 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
287 rxState = O2RX_HUMIDITY;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
288 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
289 default:
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
290 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
291 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
292 memset((char*) tmpRxBuf, 0, tmpRxIdx);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
293 tmpRxIdx = 0;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
294 }
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 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
297 else
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
298 { /* 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
299 switch (rxState)
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 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
302 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
303 localComState = UART_O2_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
304 rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
305 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
306 case O2RX_GETSUBSENSORS: StringToInt(tmpRxBuf,&tmpData);
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_HUMIDITY: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.humidity); /* raw data cycle */
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
311 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
312 localComState = UART_O2_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
313 rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
314 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
315 case O2RX_GETNR: StringToUInt64((char*)tmpRxBuf,&tmpSensorDataDiveO2.sensorId);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
316 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
317 localComState = UART_O2_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
318 rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
319 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
320 default: localComState = UART_O2_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
321 rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
322 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
323 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
324 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
325 break;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
326 default: rxState = O2RX_IDLE;
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
327 break;
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 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
330 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
331 }
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 uint8_t uartO2_isSensorConnected()
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 return digO2Connected;
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
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
339 void uartO2_SetChannel(uint8_t channel)
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
340 {
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
341 if(channel <= MAX_MUX_CHANNEL)
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 activeSensor = 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 }
d4083ac09b5d Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff changeset
346