Mercurial > public > ostc4
annotate Small_CPU/Src/uartProtocol_O2.c @ 803:96ffad0a4e57
Cleanup initialisation / deinitialization:
The UART1 is now deactivated during sleep and will be reactivated with the default baudrate 19200. This avoid unpredicted behavior in case of sleep => awake transitions (always start from scratch)
author | Ideenmodellierer |
---|---|
date | Thu, 10 Aug 2023 21:30:24 +0200 |
parents | f8a112c5e71d |
children | 4832981f9af8 |
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); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
110 |
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 UART_StartDMA_Receiption(); |
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 else |
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 if(localComState == UART_O2_ERROR) |
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 localComState = lastComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
122 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
123 lastComState = localComState; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
124 if(localComState == UART_O2_IDLE) /* cyclic request of o2 value */ |
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 if((activeSensor != MAX_MUX_CHANNEL) && (tmpSensorDataDiveO2.sensorId == 0)) |
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 localComState = UART_O2_REQ_ID; |
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 else |
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 localComState = UART_O2_REQ_RAW; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
135 rxState = O2RX_CONFIRM; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
136 uartO2_SetupCmd(localComState,cmdString,&cmdLength); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
137 UART_SendCmdString(cmdString); |
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 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
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 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
142 void uartO2_ProcessData(uint8_t data) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
143 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
144 static uint8_t cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
145 static uint8_t errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
146 static char tmpRxBuf[30]; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
147 static uint8_t tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
148 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
149 uint32_t tmpO2 = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
150 uint32_t tmpData = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
151 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
152 uint32_t tick = HAL_GetTick(); |
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 uartO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
155 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
156 lastReceiveTick = tick; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
157 switch(rxState) |
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 case O2RX_CONFIRM: if(data == '#') |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
160 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
161 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
162 errorReadIndex = 0; |
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(errorReadIndex < sizeof(errorStr)-1) |
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 if(data == errorStr[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 errorReadIndex++; |
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 else |
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 errorReadIndex = 0; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
175 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
176 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
177 respondErrorDetected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
178 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
179 if(localComState != UART_O2_IDLE) |
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 localComState = UART_O2_ERROR; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
184 if(data == cmdString[cmdReadIndex]) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
185 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
186 cmdReadIndex++; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
187 if(cmdReadIndex == cmdLength - 3) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
188 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
189 errorReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
190 if((activeSensor == MAX_MUX_CHANNEL)) |
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 if(respondErrorDetected) |
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 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
|
195 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
196 else |
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 digO2Connected = 1; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
201 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
|
202 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
203 digO2Connected = 1; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
204 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
205 tmpRxIdx = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
206 memset((char*) tmpRxBuf, 0, sizeof(tmpRxBuf)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
207 cmdReadIndex = 0; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
208 switch (localComState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
209 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
210 case UART_O2_CHECK: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
211 rxState = O2RX_IDLE; |
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_ID: rxState = O2RX_GETNR; |
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_INFO: rxState = O2RX_GETTYPE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
216 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
217 case UART_O2_REQ_RAW: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
218 case UART_O2_REQ_O2: rxState = O2RX_GETO2; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
219 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
220 default: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
221 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
222 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
223 } |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
226 else |
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 cmdReadIndex = 0; |
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 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
231 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
232 case O2RX_GETSTATUS: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
233 case O2RX_GETTEMP: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
234 case O2RX_GETTYPE: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
235 case O2RX_GETVERSION: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
236 case O2RX_GETCHANNEL: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
237 case O2RX_GETSUBSENSORS: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
238 case O2RX_GETO2: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
239 case O2RX_GETNR: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
240 case O2RX_GETDPHI: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
241 case O2RX_INTENSITY: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
242 case O2RX_AMBIENTLIGHT: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
243 case O2RX_PRESSURE: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
244 case O2RX_HUMIDITY: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
245 if(data != 0x0D) |
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 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
|
248 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
249 tmpRxBuf[tmpRxIdx++] = data; |
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 else |
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 if(tmpRxIdx != 0) |
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 switch(rxState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
256 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
257 case O2RX_GETCHANNEL: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
258 rxState = O2RX_GETVERSION; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
259 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
260 case O2RX_GETVERSION: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
261 rxState = O2RX_GETSUBSENSORS; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
262 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
263 case O2RX_GETTYPE: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
264 rxState = O2RX_GETCHANNEL; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
265 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
266 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
267 case O2RX_GETO2: StringToInt(tmpRxBuf,&tmpO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
268 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
269 setExternalInterfaceChannel(activeSensor + EXT_INTERFACE_MUX_OFFSET,(float)(tmpO2 / 10000.0)); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
270 rxState = O2RX_GETTEMP; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
271 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
272 case O2RX_GETTEMP: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.temperature); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
273 rxState = O2RX_GETSTATUS; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
274 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
275 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
276 rxState = O2RX_GETDPHI; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
277 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
278 case O2RX_GETDPHI: /* ignored to save memory and most likly irrelevant for diver */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
279 rxState = O2RX_INTENSITY; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
280 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
281 case O2RX_INTENSITY: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.intensity); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
282 rxState = O2RX_AMBIENTLIGHT; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
283 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
284 case O2RX_AMBIENTLIGHT: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.ambient); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
285 rxState = O2RX_PRESSURE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
286 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
287 case O2RX_PRESSURE: StringToInt(tmpRxBuf,(uint32_t*)&tmpSensorDataDiveO2.pressure); /* raw data cycle */ |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
288 rxState = O2RX_HUMIDITY; |
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 default: |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
291 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
292 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
293 memset((char*) tmpRxBuf, 0, tmpRxIdx); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
294 tmpRxIdx = 0; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
298 else |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
299 { /* 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
|
300 switch (rxState) |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
301 { |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
302 case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&tmpSensorDataDiveO2.status); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
303 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
304 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
305 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
306 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
307 case O2RX_GETSUBSENSORS: StringToInt(tmpRxBuf,&tmpData); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
308 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
309 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
310 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
311 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
|
312 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
313 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
314 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
315 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
316 case O2RX_GETNR: StringToUInt64((char*)tmpRxBuf,&tmpSensorDataDiveO2.sensorId); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
317 externalInterface_SetSensorData(activeSensor + EXT_INTERFACE_MUX_OFFSET,(uint8_t*)&tmpSensorDataDiveO2); |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
318 localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
319 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
320 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
321 default: localComState = UART_O2_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
322 rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
323 break; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
324 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
325 } |
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 default: rxState = O2RX_IDLE; |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
328 break; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
331 externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState); |
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 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
335 uint8_t uartO2_isSensorConnected() |
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 return digO2Connected; |
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 |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
340 void uartO2_SetChannel(uint8_t 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 if(channel <= MAX_MUX_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 activeSensor = channel; |
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 } |
d4083ac09b5d
Moved DiveO2 sensor specific funtionality into separated file:
Ideenmodellierer
parents:
diff
changeset
|
347 |