Mercurial > public > ostc4
comparison Small_CPU/Src/scheduler.c @ 87:e746bf846638 kittz
tmp
author | Dmitry Romanov <kitt@bk.ru> |
---|---|
date | Wed, 21 Nov 2018 13:57:58 +0300 |
parents | cc41b5eaf1a7 |
children | 3db7389d49cc |
comparison
equal
deleted
inserted
replaced
86:cc41b5eaf1a7 | 87:e746bf846638 |
---|---|
180 | 180 |
181 | 181 |
182 void scheduleSpecial_Evaluate_DataSendToSlave(void) | 182 void scheduleSpecial_Evaluate_DataSendToSlave(void) |
183 { | 183 { |
184 | 184 |
185 | 185 /* for device data updates */ |
186 global.dataSendToSlavePending = 0; | 186 deviceDataFlashValid = 0; |
187 memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); | |
188 | |
189 //TODO: (kittz) split by current mode. | |
190 | |
191 // new hw 170523 | |
192 if(global.I2C_SystemStatus != HAL_OK) | |
193 { | |
194 MX_I2C1_TestAndClear(); | |
195 MX_I2C1_Init(); | |
196 if(!is_init_pressure_done()) | |
197 { | |
198 init_pressure(); | |
199 } | |
200 } | |
201 | |
202 pressure_update(); | |
203 copyPressureData(); | |
204 compass_read(); | |
205 acceleration_read(); | |
206 compass_calc(); | |
207 battery_gas_gauge_get_data(); | |
208 copyCompassData(); | |
209 | |
210 copyCnsAndOtuData(); | |
211 copyTimeData(); | |
212 copyBatteryData(); | |
213 copyDeviceData(); | |
214 copyVpmCrushingData(); | |
215 | |
216 deviceDataFlashValid = 1; | |
217 scheduleUpdateDeviceData(); | |
218 | |
219 | |
220 | |
221 | |
222 // global.dataSendToSlavePending = 0; | |
187 // if(!global.dataSendToSlaveIsValid) return; //TODO: WHAT THE FUCK?????!!!!! | 223 // if(!global.dataSendToSlaveIsValid) return; //TODO: WHAT THE FUCK?????!!!!! |
188 | 224 |
189 global.dataSendToMaster.confirmRequest.uw = 0; | 225 global.dataSendToMaster.confirmRequest.uw = 0; |
190 | 226 |
191 if(TM_OTP_Read(0,0) == 0xFF) | 227 if(TM_OTP_Read(0,0) == 0xFF) |
265 } | 301 } |
266 | 302 |
267 /* for simulation / testing */ | 303 /* for simulation / testing */ |
268 global.ceiling_from_main_CPU_mbar = global.dataSendToSlave.data.ambient_pressure_mbar_ceiling; | 304 global.ceiling_from_main_CPU_mbar = global.dataSendToSlave.data.ambient_pressure_mbar_ceiling; |
269 | 305 |
270 /* for device data updates */ | |
271 deviceDataFlashValid = 0; | |
272 memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice)); | |
273 | |
274 //TODO: (kittz) split by current mode. | |
275 | |
276 // new hw 170523 | |
277 if(global.I2C_SystemStatus != HAL_OK) | |
278 { | |
279 MX_I2C1_TestAndClear(); | |
280 MX_I2C1_Init(); | |
281 if(!is_init_pressure_done()) | |
282 { | |
283 init_pressure(); | |
284 } | |
285 } | |
286 | |
287 pressure_update(); | |
288 copyPressureData(); | |
289 compass_read(); | |
290 acceleration_read(); | |
291 compass_calc(); | |
292 battery_gas_gauge_get_data(); | |
293 copyCompassData(); | |
294 | |
295 copyCnsAndOtuData(); | |
296 copyTimeData(); | |
297 copyBatteryData(); | |
298 copyDeviceData(); | |
299 copyVpmCrushingData(); | |
300 | |
301 deviceDataFlashValid = 1; | |
302 scheduleUpdateDeviceData(); | |
303 | 306 |
304 } | 307 } |
305 | 308 |
306 | 309 |
307 /** | 310 /** |
1181 | 1184 |
1182 temperature_centigrad_int32 = (int32_t)(get_temperature() * 100); | 1185 temperature_centigrad_int32 = (int32_t)(get_temperature() * 100); |
1183 if(temperature_centigrad_int32 < global.deviceData.temperatureMinimum.value_int32) | 1186 if(temperature_centigrad_int32 < global.deviceData.temperatureMinimum.value_int32) |
1184 { | 1187 { |
1185 global.deviceData.temperatureMinimum.value_int32 = temperature_centigrad_int32; | 1188 global.deviceData.temperatureMinimum.value_int32 = temperature_centigrad_int32; |
1186 //WTF? scheduleSetDate(&global.deviceData.temperatureMinimum); | 1189 /*Last_change_time?*/ scheduleSetDate(&global.deviceData.temperatureMinimum); |
1187 } | 1190 } |
1188 | 1191 |
1189 if(temperature_centigrad_int32 > global.deviceData.temperatureMaximum.value_int32) | 1192 if(temperature_centigrad_int32 > global.deviceData.temperatureMaximum.value_int32) |
1190 { | 1193 { |
1191 global.deviceData.temperatureMaximum.value_int32 = temperature_centigrad_int32; | 1194 global.deviceData.temperatureMaximum.value_int32 = temperature_centigrad_int32; |
1192 //WTF? scheduleSetDate(&global.deviceData.temperatureMaximum); | 1195 /*Last_change_time?*/ scheduleSetDate(&global.deviceData.temperatureMaximum); |
1193 } | 1196 } |
1194 | 1197 |
1195 pressure_mbar_int32 = (int32_t)get_pressure_mbar(); | 1198 pressure_mbar_int32 = (int32_t)get_pressure_mbar(); |
1196 if(pressure_mbar_int32 > global.deviceData.depthMaximum.value_int32) | 1199 if(pressure_mbar_int32 > global.deviceData.depthMaximum.value_int32) |
1197 { | 1200 { |
1198 global.deviceData.depthMaximum.value_int32 = pressure_mbar_int32; | 1201 global.deviceData.depthMaximum.value_int32 = pressure_mbar_int32; |
1199 //WTF? scheduleSetDate(&global.deviceData.depthMaximum); | 1202 /*Last_change_time?*/ scheduleSetDate(&global.deviceData.depthMaximum); |
1200 } | 1203 } |
1201 | 1204 |
1202 voltage_mvolt_int32 = (int32_t)(get_voltage() * 1000); | 1205 voltage_mvolt_int32 = (int32_t)(get_voltage() * 1000); |
1203 if(voltage_mvolt_int32 < global.deviceData.voltageMinimum.value_int32) | 1206 if(voltage_mvolt_int32 < global.deviceData.voltageMinimum.value_int32) |
1204 { | 1207 { |
1205 global.deviceData.voltageMinimum.value_int32 = voltage_mvolt_int32; | 1208 global.deviceData.voltageMinimum.value_int32 = voltage_mvolt_int32; |
1206 //WTF? scheduleSetDate(&global.deviceData.voltageMinimum); | 1209 /*Last_change_time?*/ scheduleSetDate(&global.deviceData.voltageMinimum); |
1207 } | 1210 } |
1208 | 1211 |
1209 /* third step, counter */ | 1212 /* third step, counter */ |
1210 switch (global.mode) | 1213 switch (global.mode) |
1211 { | 1214 { |
1228 | 1231 |
1229 | 1232 |
1230 void scheduleUpdateDeviceDataChargerFull(void) | 1233 void scheduleUpdateDeviceDataChargerFull(void) |
1231 { | 1234 { |
1232 global.deviceData.batteryChargeCompleteCycles.value_int32++; | 1235 global.deviceData.batteryChargeCompleteCycles.value_int32++; |
1233 //WTF? scheduleSetDate(&global.deviceData.batteryChargeCompleteCycles); | 1236 /*Last_change_time?*/ scheduleSetDate(&global.deviceData.batteryChargeCompleteCycles); |
1234 } | 1237 } |
1235 | 1238 |
1236 | 1239 |
1237 void scheduleUpdateDeviceDataChargerCharging(void) | 1240 void scheduleUpdateDeviceDataChargerCharging(void) |
1238 { | 1241 { |
1239 global.deviceData.batteryChargeCycles.value_int32++; | 1242 global.deviceData.batteryChargeCycles.value_int32++; |
1240 //WTF? scheduleSetDate(&global.deviceData.batteryChargeCycles); | 1243 /*Last_change_time?*/ scheduleSetDate(&global.deviceData.batteryChargeCycles); |
1241 } | 1244 } |
1242 | 1245 |
1243 | 1246 |
1244 /** | 1247 /** |
1245 ****************************************************************************** | 1248 ****************************************************************************** |