changeset 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 0f5080f50ba7
children 0e7c16dd774d
files Current build/OSTC4update_200224.bin Current build/OSTC4update_200627.bin Discovery/Src/settings.c Small_CPU/Src/baseCPU2.c Small_CPU/Src/compass.c Small_CPU/Src/pressure.c Small_CPU/Src/scheduler.c
diffstat 7 files changed, 48 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
Binary file Current build/OSTC4update_200224.bin has changed
Binary file Current build/OSTC4update_200627.bin has changed
--- a/Discovery/Src/settings.c	Tue May 26 19:27:07 2020 +0000
+++ b/Discovery/Src/settings.c	Sat Jun 27 18:40:32 2020 +0200
@@ -38,7 +38,7 @@
 SSettings Settings;
 
 const uint8_t RTErequiredHigh = 2;
-const uint8_t RTErequiredLow = 3;
+const uint8_t RTErequiredLow = 4;
 
 const uint8_t FONTrequiredHigh = 1;
 const uint8_t FONTrequiredLow =	0;
@@ -64,8 +64,8 @@
     .signature = "mh",
 
     .release_year = 20,
-    .release_month = 4,
-    .release_day = 8,
+    .release_month = 6,
+    .release_day = 30,
     .release_sub = 0,
 
     /* max 48 with trailing 0 */
--- a/Small_CPU/Src/baseCPU2.c	Tue May 26 19:27:07 2020 +0000
+++ b/Small_CPU/Src/baseCPU2.c	Sat Jun 27 18:40:32 2020 +0200
@@ -164,7 +164,7 @@
 // See CPU2-RTE.ld
 const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= {
 		.versionFirst = 2,
-		.versionSecond = 3,
+		.versionSecond = 4,
 		.versionThird = 0,
 		.versionBeta = 0,
 
@@ -172,8 +172,8 @@
 		.signature = "mh",
 
 		.release_year = 20,
-		.release_month = 2,
-		.release_day = 26,
+		.release_month = 6,
+		.release_day = 30,
 		.release_sub = 0,
 
 		/* max 48 with trailing 0 */
@@ -314,7 +314,11 @@
 		if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) {
 			MX_I2C1_TestAndClear(); // do it a second time
 		}
+		HAL_Delay(100);
+		I2C_DeInit();
+		HAL_Delay(100);
 		MX_I2C1_Init();
+		HAL_Delay(100);
 	}
 
 
@@ -328,7 +332,11 @@
 		if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) {
 			MX_I2C1_TestAndClear(); // do it a second time
 		}
+		HAL_Delay(100);
+		I2C_DeInit();
+		HAL_Delay(100);
 		MX_I2C1_Init();
+		HAL_Delay(100);
 		global.sensorError[SENSOR_PRESSURE_ID] = init_pressure();
 		global.I2C_SystemStatus = global.sensorError[SENSOR_PRESSURE_ID];
 	}
--- a/Small_CPU/Src/compass.c	Tue May 26 19:27:07 2020 +0000
+++ b/Small_CPU/Src/compass.c	Sat Jun 27 18:40:32 2020 +0200
@@ -281,8 +281,11 @@
 	// test if both chips of the two-chip solution (gen 1) are present
 	if(hardwareCompass == compass_generation1)			// HMC5883L)
 	{
-		HAL_Delay(10);
+		HAL_Delay(100);
+		I2C_DeInit();
+		HAL_Delay(100);
 		MX_I2C1_Init();
+		HAL_Delay(100);
 		uint8_t data = 0x2A; // CTRL_REG1 of DEVICE_ACCELARATOR_MMA8452Q
 		resultOfOperationHMC_MMA = I2C_Master_Transmit( DEVICE_ACCELARATOR_MMA8452Q, &data, 1);
 		if(resultOfOperationHMC_MMA == HAL_OK)
--- 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;
--- a/Small_CPU/Src/scheduler.c	Tue May 26 19:27:07 2020 +0000
+++ b/Small_CPU/Src/scheduler.c	Sat Jun 27 18:40:32 2020 +0200
@@ -640,7 +640,12 @@
 			if(global.I2C_SystemStatus != HAL_OK)
 			{
 				MX_I2C1_TestAndClear();
+				HAL_Delay(100);
+				I2C_DeInit();
+				HAL_Delay(100);
 				MX_I2C1_Init();
+				HAL_Delay(100);
+
 				init_pressure();
 			}
 		}
@@ -876,7 +881,12 @@
 			if(global.I2C_SystemStatus != HAL_OK)
 			{
 				MX_I2C1_TestAndClear();
+				HAL_Delay(100);
+				I2C_DeInit();
+				HAL_Delay(100);
 				MX_I2C1_Init();
+				HAL_Delay(100);
+
 				if(global.I2C_SystemStatus == HAL_OK)
 				{
 					init_pressure();
@@ -1036,7 +1046,12 @@
 		if(global.I2C_SystemStatus != HAL_OK)
 		{
 			MX_I2C1_TestAndClear();
+			HAL_Delay(100);
+			I2C_DeInit();
+			HAL_Delay(100);
 			MX_I2C1_Init();
+			HAL_Delay(100);
+
 
 			if((global.I2C_SystemStatus == HAL_OK) && (!is_init_pressure_done()))
 			{