Mercurial > public > ostc4
comparison Small_CPU/Src/baseCPU2.c @ 329:da5b91b1e20e I2C_Improvment
Improved startup robustness
The firmware implements a 30 minute delay for surface pressure values. This array might be corrupted if first pressure communication fails => only init array if initialization was successfull
author | ideenmodellierer |
---|---|
date | Wed, 17 Jul 2019 22:42:55 +0200 |
parents | d4d8d717e9a7 |
children | 143fe85f82a2 |
comparison
equal
deleted
inserted
replaced
328:4fe5400567e7 | 329:da5b91b1e20e |
---|---|
300 GPIO_new_DEBUG_Init(); // added 170322 hw | 300 GPIO_new_DEBUG_Init(); // added 170322 hw |
301 initGlobals(); | 301 initGlobals(); |
302 | 302 |
303 /* printf("CPU2-RTE running...\n"); */ | 303 /* printf("CPU2-RTE running...\n"); */ |
304 | 304 |
305 HAL_Delay(100); | |
306 | |
305 MX_I2C1_Init(); | 307 MX_I2C1_Init(); |
306 if (global.I2C_SystemStatus != HAL_OK) { | 308 if (global.I2C_SystemStatus != HAL_OK) |
309 { | |
307 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) { | 310 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) { |
308 MX_I2C1_TestAndClear(); // do it a second time | 311 MX_I2C1_TestAndClear(); // do it a second time |
309 } | 312 } |
310 MX_I2C1_Init(); | 313 MX_I2C1_Init(); |
311 } | 314 } |
312 | 315 |
316 | |
317 | |
313 //dangerous: TM_OTP_Write(0,0, 0x01); | 318 //dangerous: TM_OTP_Write(0,0, 0x01); |
314 #ifdef REGULAR_RUN | 319 #ifdef REGULAR_RUN |
315 global.sensorError[SENSOR_PRESSURE_ID] = init_pressure(); | 320 global.sensorError[SENSOR_PRESSURE_ID] = init_pressure(); |
316 global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID]; | 321 global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID]; |
317 if (global.I2C_SystemStatus != HAL_OK) { | 322 if (global.I2C_SystemStatus != HAL_OK) |
323 { | |
318 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) { | 324 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) { |
319 MX_I2C1_TestAndClear(); // do it a second time | 325 MX_I2C1_TestAndClear(); // do it a second time |
320 } | 326 } |
321 MX_I2C1_Init(); | 327 MX_I2C1_Init(); |
322 global.sensorError[SENSOR_PRESSURE_ID] = init_pressure(); | 328 global.sensorError[SENSOR_PRESSURE_ID] = init_pressure(); |
323 global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID]; | 329 global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID]; |
324 } | 330 } |
325 | 331 |
326 global.dataSendToMaster.sensorErrors = | 332 global.dataSendToMaster.sensorErrors = |
327 global.sensorError[SENSOR_PRESSURE_ID]; | 333 global.sensorError[SENSOR_PRESSURE_ID]; |
328 init_surface_ring(); | 334 |
335 if(is_init_pressure_done()) | |
336 { | |
337 init_surface_ring(); | |
338 } | |
329 init_battery_gas_gauge(); | 339 init_battery_gas_gauge(); |
330 HAL_Delay(10); | 340 HAL_Delay(10); |
331 battery_gas_gauge_get_data(); | 341 battery_gas_gauge_get_data(); |
332 // battery_gas_gauge_set(0); | 342 // battery_gas_gauge_set(0); |
333 | 343 |