Mercurial > public > ostc4
diff Small_CPU/Src/pressure.c @ 488:9eeab3fead8f
Added "I2C_DeInit();" in hardware detection routines. It's the recommended way
to do and solves potential issues with older OSTC4 hardware generations.
Increased RTE and RTE required numbers
updated "Current build"
author | heinrichsweikamp |
---|---|
date | Sat, 27 Jun 2020 18:40:32 +0200 |
parents | 3fe9cc747c5c |
children | 666cafac87ab |
line wrap: on
line diff
--- a/Small_CPU/Src/pressure.c Tue May 26 19:27:07 2020 +0000 +++ b/Small_CPU/Src/pressure.c Sat Jun 27 18:40:32 2020 +0200 @@ -337,14 +337,10 @@ { PRESSURE_ADDRESS = DEVICE_PRESSURE_MS5803; // use old sensor HAL_Delay(100); + I2C_DeInit(); + HAL_Delay(100); MX_I2C1_Init(); - if (global.I2C_SystemStatus != HAL_OK) - { - if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) { - MX_I2C1_TestAndClear(); // do it a second time - } - MX_I2C1_Init(); - } + HAL_Delay(100); } else { @@ -460,22 +456,23 @@ switch (cmd & 0x0f) // wait necessary conversion time { - case CMD_ADC_256 : HAL_Delay(1); break; - case CMD_ADC_512 : HAL_Delay(3); break; - case CMD_ADC_1024: HAL_Delay(4); break; - case CMD_ADC_2048: HAL_Delay(6); break; - case CMD_ADC_4096: HAL_Delay(10); break; + case CMD_ADC_256 : HAL_Delay(2); break; + case CMD_ADC_512 : HAL_Delay(4); break; + case CMD_ADC_1024: HAL_Delay(5); break; + case CMD_ADC_2048: HAL_Delay(7); break; + case CMD_ADC_4096: HAL_Delay(11); break; default: break; } adcValue = get_adc(); - if(adcValue == 0xFFFFFFFF) +/* if(adcValue == 0xFFFFFFFF) { if(statusReturn) { *statusReturn = HAL_ERROR; } - } + }*/ + return adcValue; } @@ -488,13 +485,13 @@ - requestedValue = pressure_sensor_get_one_value(CMD_ADC_D2 + CMD_ADC_1024, &statusReturn2); + requestedValue = pressure_sensor_get_one_value(CMD_ADC_D2 + CMD_ADC_4096, &statusReturn2); if (statusReturn2 == HAL_OK) { D2 = requestedValue; } - requestedValue = pressure_sensor_get_one_value(CMD_ADC_D1 + CMD_ADC_1024, &statusReturn1); + requestedValue = pressure_sensor_get_one_value(CMD_ADC_D1 + CMD_ADC_4096, &statusReturn1); if (statusReturn1 == HAL_OK) { D1 = requestedValue; @@ -511,7 +508,7 @@ uint32_t requestedValue = 0; HAL_StatusTypeDef statusReturn = HAL_TIMEOUT; - requestedValue = pressure_sensor_get_one_value(CMD_ADC_D1 + CMD_ADC_1024, &statusReturn); + requestedValue = pressure_sensor_get_one_value(CMD_ADC_D1 + CMD_ADC_4096, &statusReturn); if (statusReturn == HAL_OK) { D1 = requestedValue; @@ -526,7 +523,7 @@ uint32_t requestedValue = 0; HAL_StatusTypeDef statusReturn = HAL_TIMEOUT; - requestedValue = pressure_sensor_get_one_value(CMD_ADC_D2 + CMD_ADC_1024, &statusReturn); + requestedValue = pressure_sensor_get_one_value(CMD_ADC_D2 + CMD_ADC_4096, &statusReturn); if (statusReturn == HAL_OK) { D2 = requestedValue;