annotate Discovery/Src/tCCR.c @ 341:591c03a1e68d

change max. allowed surface pressure to 1030hPa (As in the small OSTC) Change Firmware to 1.5.1 Change RTE to 2.0 Create install file for testing and release
author heinrichsweikamp
date Sun, 06 Oct 2019 14:07:51 +0200
parents 31e471d60797
children f1257a32f2d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/tCCR.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief HUD data via optical port
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 18-Dec-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include <string.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #include "tCCR.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "ostc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "data_central.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "data_exchange.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "check_warning.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 typedef struct
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 uint8_t hud_firmwareVersion;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 bit8_Type status_byte;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 uint16_t sensor_voltage_100uV[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 uint8_t sensor_ppo2_cbar[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 uint8_t temp1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 uint16_t battery_voltage_mV;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 uint16_t checksum;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 } SIrLink;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
49 #define HUD_BABBLING_IDIOT (30u) /* 30 Bytes received without break */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
50 #define HUD_RX_FRAME_LENGTH (15u) /* Length of a HUD data frame */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
51 #define HUD_RX_FRAME_BREAK_MS (100u) /* Time used to detect a gap between two byte receptions => frame start */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
52 #define HUD_RX_START_DELAY_MS (500u) /* Delay for start of RX function to avoid start of reception while a transmission is ongoing. */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
53 /* Based on an assumed cycle time by the sensor of 1 second. Started at time of last RX */
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
55 /* Private variables ---------------------------------------------------------*/
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
56 static SIrLink receiveHUD[2];
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
57 static uint8_t boolHUDdata = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
58 static uint8_t data_old__lost_connection_to_HUD = 1;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
60 static uint8_t receiveHUDraw[16];
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
61
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
62 static uint8_t StartListeningToUART_HUD = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
63 static uint16_t HUDTimeoutCount = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
64
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
65 static __IO ITStatus UartReadyHUD = RESET;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
66 static uint32_t LastReceivedTick_HUD = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 /* Private variables with external access via get_xxx() function -------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 /* Private function prototypes -----------------------------------------------*/
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
71 static void tCCR_fallbackToFixedSetpoint(void);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 #ifndef USART_IR_HUD
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 void tCCR_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 void tCCR_control(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 void tCCR_test(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 void tCCR_restart(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 float get_ppO2Sensor_bar(uint8_t sensor_id)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 float get_sensorVoltage_mV(uint8_t sensor_id)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 float get_HUD_battery_voltage_V(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 void tCCR_tick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 #else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 float get_ppO2Sensor_bar(uint8_t sensor_id)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 if((sensor_id > 2) || data_old__lost_connection_to_HUD)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 return (float)(receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id]) / 100.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 float get_sensorVoltage_mV(uint8_t sensor_id)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 if((sensor_id > 2) || data_old__lost_connection_to_HUD)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 return (float)(receiveHUD[boolHUDdata].sensor_voltage_100uV[sensor_id]) / 10.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 float get_HUD_battery_voltage_V(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 if(data_old__lost_connection_to_HUD)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 return (float)(receiveHUD[boolHUDdata].battery_voltage_mV) / 1000.0f;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 void test_HUD_sensor_values_outOfBounds(int8_t * outOfBouds1, int8_t * outOfBouds2, int8_t * outOfBouds3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 uint8_t sensorNotActiveBinary;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 uint8_t sensorActive[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 // test1: user deactivation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 sensorNotActiveBinary = stateUsed->diveSettings.ppo2sensors_deactivated;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 for(int i=0;i<3;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 sensorActive[i] = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 if(sensorNotActiveBinary)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 if(sensorNotActiveBinary & 1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 sensorActive[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 if(sensorNotActiveBinary & 2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 sensorActive[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 if(sensorNotActiveBinary & 4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 sensorActive[2] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 // test2: mV of remaining sensors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 for(int i=0;i<3;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 if(sensorActive[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 if( (receiveHUD[boolHUDdata].sensor_voltage_100uV[i] < 80) ||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 (receiveHUD[boolHUDdata].sensor_voltage_100uV[i] > 2500))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 sensorActive[i] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 switch(i)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 case 0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 sensorNotActiveBinary |= 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 sensorNotActiveBinary |= 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 sensorNotActiveBinary |= 4;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 *outOfBouds1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 *outOfBouds2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 *outOfBouds3 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 /* with two, one or no sensor, there is nothing to compare anymore
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 if(sensorNotActiveBinary)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 // set outOfBounds for both tests
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 if(!sensorActive[0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 *outOfBouds1 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 if(!sensorActive[1])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 *outOfBouds2 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 if(!sensorActive[2])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 *outOfBouds3 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 uint8_t sensor_id_ordered[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 uint8_t difference[2];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 if((receiveHUD[boolHUDdata].sensor_ppo2_cbar[1]) > (receiveHUD[boolHUDdata].sensor_ppo2_cbar[0]))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 sensor_id_ordered[0] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 sensor_id_ordered[1] = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 sensor_id_ordered[0] = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 sensor_id_ordered[1] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 if(receiveHUD[boolHUDdata].sensor_ppo2_cbar[2] > receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[1]])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 sensor_id_ordered[2] = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 sensor_id_ordered[2] = sensor_id_ordered[1];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 if(receiveHUD[boolHUDdata].sensor_ppo2_cbar[2] > receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[0]])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 sensor_id_ordered[1] = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 sensor_id_ordered[1] = sensor_id_ordered[0];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 sensor_id_ordered[0] = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 difference[0] = receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[1]]- receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[0]];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 difference[1] = receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[2]]- receiveHUD[boolHUDdata].sensor_ppo2_cbar[sensor_id_ordered[1]];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 if((difference[0] > difference[1]) && (difference[0] > 15))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 switch(sensor_id_ordered[0])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 case 0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 *outOfBouds1 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 *outOfBouds2 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 *outOfBouds3 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 if((difference[0] < difference[1]) && (difference[1] > 15))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 switch(sensor_id_ordered[2])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 case 0:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 *outOfBouds1 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 case 1:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 *outOfBouds2 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 case 2:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 *outOfBouds3 = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 break;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 uint8_t get_ppO2SensorWeightedResult_cbar(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 int8_t sensorOutOfBound[3];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 uint16_t result = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 uint8_t count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 test_HUD_sensor_values_outOfBounds(&sensorOutOfBound[0], &sensorOutOfBound[1], &sensorOutOfBound[2]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 for(int i=0;i<3;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 if(!sensorOutOfBound[i])
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 result += receiveHUD[boolHUDdata].sensor_ppo2_cbar[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 count++;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 if(count == 0) // all sensors out of bounds!
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 return 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 return (uint8_t)(result / count);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 void tCCR_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 StartListeningToUART_HUD = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 /* after 3 seconds without update from HUD
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 * data is considered old
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 void tCCR_tick(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 {
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
301 if(HUDTimeoutCount < 3 * 10)
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
302 HUDTimeoutCount++;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 data_old__lost_connection_to_HUD = 1;
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
306 if(HUDTimeoutCount < 20 * 10)
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
307 HUDTimeoutCount++;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 tCCR_fallbackToFixedSetpoint();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
313 void tCCR_SetRXIndication(void)
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
314 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
315 static uint8_t floatingRXCount = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
316
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
317 if((UartIR_HUD_Handle.RxXferSize == HUD_RX_FRAME_LENGTH) || (UartIR_HUD_Handle.RxXferSize == HUD_RX_FRAME_LENGTH - 1)) /* we expected a complete frame */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
318 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
319 UartReadyHUD = SET;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
320 LastReceivedTick_HUD = HAL_GetTick();
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
321 floatingRXCount = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
322 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
323 else /* follow up of error handling */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
324 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
325 if(time_elapsed_ms(LastReceivedTick_HUD, HAL_GetTick()) > HUD_RX_FRAME_BREAK_MS) /* Reception took a while => frame start detected */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
326 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
327 HAL_UART_Receive_IT(&UartIR_HUD_Handle, &receiveHUDraw[1], 14); /* We have already the first byte => get the missing 14 */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
328 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
329 else
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
330 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
331 if(floatingRXCount++ < HUD_BABBLING_IDIOT)
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
332 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
333 HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, 1); /* Start polling of incoming bytes */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
334 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
335 else /* Significant amount of data comming in without break => disable input */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
336 { /* by not reactivation HUD RX, no recovery fromthis state */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
337 stateUsedWrite->diveSettings.ppo2sensors_deactivated = 0x07; /* Display deactivation */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
338 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
339 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
340 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
341
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
342 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 void tCCR_restart(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 {
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
346 HAL_UART_AbortReceive_IT(&UartIR_HUD_Handle); /* Called by the error handler. RX will be restarted by control function */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
347 StartListeningToUART_HUD = 1;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 void tCCR_control(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 {
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
353
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
354 if((UartReadyHUD == RESET) && StartListeningToUART_HUD && (time_elapsed_ms(LastReceivedTick_HUD, HAL_GetTick()) > HUD_RX_START_DELAY_MS))
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
355 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
356 StartListeningToUART_HUD = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
357 HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, HUD_RX_FRAME_LENGTH);
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
358 }
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 if(UartReadyHUD == SET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 UartReadyHUD = RESET;
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
363 StartListeningToUART_HUD = 1;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 memcpy(&receiveHUD[!boolHUDdata], receiveHUDraw, 11);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 receiveHUD[!boolHUDdata].battery_voltage_mV = receiveHUDraw[11] + (256 * receiveHUDraw[12]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 receiveHUD[!boolHUDdata].checksum = receiveHUDraw[13] + (256 * receiveHUDraw[14]);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 uint16_t checksum = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 for(int i=0;i<13;i++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 checksum += receiveHUDraw[i];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 if(checksum == receiveHUD[!boolHUDdata].checksum)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 boolHUDdata = !boolHUDdata;
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
378 HUDTimeoutCount = 0;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 data_old__lost_connection_to_HUD = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 }
322
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
381 else
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
382 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
383 if(data_old__lost_connection_to_HUD) /* we lost connection, maybe due to RX shift => start single byte read to resynchronize */
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
384 {
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
385 HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, 1);
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
386 StartListeningToUART_HUD = 0;
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
387 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
388 }
31e471d60797 Added start of frame detection for HUD data
ideenmodellierer
parents: 272
diff changeset
389 memset(receiveHUDraw,0,sizeof(receiveHUDraw));
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
396 static void tCCR_fallbackToFixedSetpoint(void)
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 if((stateUsed->mode == MODE_DIVE) && (stateUsed->diveSettings.diveMode == DIVEMODE_CCR) && (stateUsed->diveSettings.CCR_Mode == CCRMODE_Sensors) && (stateUsed->diveSettings.fallbackOption))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 uint8_t setpointCbar, actualGasID;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
402 setpointCbar = stateUsed->diveSettings.setpoint[1].setpoint_cbar;
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
403 stateUsedWrite->diveSettings.CCR_Mode = CCRMODE_FixedSetpoint;
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
272
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
405 actualGasID = stateUsed->lifeData.actualGas.GasIdInSettings;
74a8296a2318 cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents: 38
diff changeset
406 setActualGas_DM(&stateUsedWrite->lifeData,actualGasID,setpointCbar);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 set_warning_fallback();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 }