Mercurial > public > ostc4
annotate Small_CPU/Src/uartProtocol_O2.c @ 918:f72613a152dd Evo_2_23
Switch external interface tx communication to DMA:
In the previous version the transmitting of data was done in polling mode. With the introduction of new sensors the length of commands send to the sensor may increase and have a impact to the runtim behavior of the SW. To avoid this the DMA transfers for TX has been activated.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Nov 2024 15:40:55 +0100 |
parents | 4832981f9af8 |
children | eb4109d7d1e9 |
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; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
109 uartO2_SetupCmd(localComState,cmdString,&cmdLength); |
916
4832981f9af8
External sensor UART: Switch to DMA TX transfers:
Ideenmodellierer
parents:
800
diff
changeset
|
110 UART_SendCmdString(cmdString); |
795
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
111 rxState = O2RX_CONFIRM; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
112 respondErrorDetected = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
113 digO2Connected = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
114 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
115 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
116 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
117 if(localComState == UART_O2_ERROR) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
118 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
119 localComState = lastComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
120 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
121 lastComState = localComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
122 if(localComState == UART_O2_IDLE) /* cyclic request of o2 value */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
123 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
124 if((activeSensor != MAX_MUX_CHANNEL) && (tmpSensorDataDiveO2.sensorId == 0)) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
125 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
126 localComState = UART_O2_REQ_ID; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
127 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
128 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
129 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
130 localComState = UART_O2_REQ_RAW; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
131 } |
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 rxState = O2RX_CONFIRM; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
134 uartO2_SetupCmd(localComState,cmdString,&cmdLength); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
135 UART_SendCmdString(cmdString); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
136 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
137 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
138 } |
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 void uartO2_ProcessData(uint8_t data) |
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 static uint8_t cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
143 static uint8_t errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
144 static char tmpRxBuf[30]; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
145 static uint8_t tmpRxIdx = 0; |
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 uint32_t tmpO2 = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
148 uint32_t tmpData = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
149 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
150 uint32_t tick = HAL_GetTick(); |
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 uartO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
153 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
154 lastReceiveTick = tick; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
155 switch(rxState) |
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 case O2RX_CONFIRM: if(data == '#') |
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 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
160 errorReadIndex = 0; |
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 if(errorReadIndex < sizeof(errorStr)-1) |
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 if(data == errorStr[errorReadIndex]) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
165 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
166 errorReadIndex++; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
167 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
168 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
169 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
170 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
171 } |
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 respondErrorDetected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
176 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
177 if(localComState != UART_O2_IDLE) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
178 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
179 localComState = UART_O2_ERROR; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
180 } |
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 if(data == cmdString[cmdReadIndex]) |
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 cmdReadIndex++; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
185 if(cmdReadIndex == cmdLength - 3) |
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 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
188 if((activeSensor == MAX_MUX_CHANNEL)) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
189 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
190 if(respondErrorDetected) |
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 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
|
193 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
194 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
195 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
196 digO2Connected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
197 } |
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 /* 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
|
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 tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
204 memset((char*) tmpRxBuf, 0, sizeof(tmpRxBuf)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
205 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
206 switch (localComState) |
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 case UART_O2_CHECK: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
209 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
210 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
211 case UART_O2_REQ_ID: rxState = O2RX_GETNR; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
212 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
213 case UART_O2_REQ_INFO: rxState = O2RX_GETTYPE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
214 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
215 case UART_O2_REQ_RAW: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
216 case UART_O2_REQ_O2: rxState = O2RX_GETO2; |
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 default: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
219 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
220 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
221 } |
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 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
225 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
226 cmdReadIndex = 0; |
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 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
229 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
230 case O2RX_GETSTATUS: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
231 case O2RX_GETTEMP: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
232 case O2RX_GETTYPE: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
233 case O2RX_GETVERSION: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
234 case O2RX_GETCHANNEL: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
235 case O2RX_GETSUBSENSORS: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
236 case O2RX_GETO2: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
237 case O2RX_GETNR: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
238 case O2RX_GETDPHI: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
239 case O2RX_INTENSITY: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
240 case O2RX_AMBIENTLIGHT: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
241 case O2RX_PRESSURE: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
242 case O2RX_HUMIDITY: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
243 if(data != 0x0D) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
244 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
245 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
|
246 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
247 tmpRxBuf[tmpRxIdx++] = data; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
248 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
249 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
250 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
251 if(tmpRxIdx != 0) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
252 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
253 switch(rxState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
254 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
255 case O2RX_GETCHANNEL: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
256 rxState = O2RX_GETVERSION; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
257 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
258 case O2RX_GETVERSION: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
259 rxState = O2RX_GETSUBSENSORS; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
260 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
261 case O2RX_GETTYPE: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
262 rxState = O2RX_GETCHANNEL; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
263 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
264 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
265 case O2RX_GETO2: StringToInt(tmpRxBuf,&tmpO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
266 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
267 setExternalInterfaceChannel(activeSensor + EXT_INTERFACE_MUX_OFFSET,(float)(tmpO2 / 10000.0)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
268 rxState = O2RX_GETTEMP; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
269 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
270 case O2RX_GETTEMP: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.temperature); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
271 rxState = O2RX_GETSTATUS; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
272 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
273 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
274 rxState = O2RX_GETDPHI; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
275 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
276 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
|
277 rxState = O2RX_INTENSITY; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
278 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
279 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
|
280 rxState = O2RX_AMBIENTLIGHT; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
281 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
282 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
|
283 rxState = O2RX_PRESSURE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
284 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
285 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
|
286 rxState = O2RX_HUMIDITY; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
287 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
288 default: |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
291 memset((char*) tmpRxBuf, 0, tmpRxIdx); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
292 tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
293 } |
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 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
297 { /* 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
|
298 switch (rxState) |
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 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
301 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
302 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
303 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
304 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
305 case O2RX_GETSUBSENSORS: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
306 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
307 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
308 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
309 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
|
310 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
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_GETNR: StringToUInt64((char*)tmpRxBuf,&tmpSensorDataDiveO2.sensorId); |
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 default: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
320 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
321 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
322 } |
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 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
325 default: 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 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
330 } |
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 uint8_t uartO2_isSensorConnected() |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
334 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
335 return digO2Connected; |
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 void uartO2_SetChannel(uint8_t channel) |
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 if(channel <= MAX_MUX_CHANNEL) |
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 activeSensor = channel; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
343 } |
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 |