changeset 87:e746bf846638 kittz

tmp
author Dmitry Romanov <kitt@bk.ru>
date Wed, 21 Nov 2018 13:57:58 +0300
parents cc41b5eaf1a7
children 3db7389d49cc
files Discovery/Src/data_exchange_main.c Discovery/Src/settings.c Small_CPU/Src/scheduler.c ostc4pack/OSTC4_Firmware.bin ostc4pack/OSTC4_RTE.bin ostc4pack/OSTC4_RTE_upload.bin ostc4pack/OSTC4_firmware_upload.bin
diffstat 7 files changed, 51 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c	Wed Nov 21 13:12:44 2018 +0300
+++ b/Discovery/Src/data_exchange_main.c	Wed Nov 21 13:57:58 2018 +0300
@@ -306,8 +306,8 @@
 	uint8_t SPI_DMA_answer = 0;
 	
 	HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET);
-	delayMicros(10);
-
+	delayMicros(50); //~exchange time(+20% reserve)
+	HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
 	/* one cycle with NotChipSelect true to clear slave spi buffer */
 
 	if(data_old__lost_connection_to_slave_counter_temp >= 3)
@@ -315,10 +315,10 @@
 		data_old__lost_connection_to_slave_counter_temp = 0;
 		data_old__lost_connection_to_slave_counter_retry++;
 	}
-	else
-	{
-		HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
-	}
+//	else
+//	{
+//		HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_RESET);
+//	}
 
 	DataEx_call_helper_requests();
 
@@ -327,7 +327,7 @@
 //HAL_GPIO_WritePin(OSCILLOSCOPE2_GPIO_PORT,OSCILLOSCOPE2_PIN,GPIO_PIN_RESET); /* only for testing with Oscilloscope */
 
 	SPI_DMA_answer = HAL_SPI_TransmitReceive_DMA(&cpu2DmaSpi, (uint8_t *)&dataOut, (uint8_t *)&dataIn, EXCHANGE_BUFFERSIZE+1);
-	HAL_Delay(3);
+//	HAL_Delay(3);
 	if(SPI_DMA_answer != HAL_OK)
     DataEX_Error_Handler(SPI_DMA_answer);
 //HAL_Delay(3);
--- a/Discovery/Src/settings.c	Wed Nov 21 13:12:44 2018 +0300
+++ b/Discovery/Src/settings.c	Wed Nov 21 13:57:58 2018 +0300
@@ -55,7 +55,7 @@
 {
     .versionFirst   = 1,
     .versionSecond 	= 4,
-    .versionThird   = 3,
+    .versionThird   = 5,
     .versionBeta    = 0,
 
     /* 4 bytes with trailing 0 */
--- a/Small_CPU/Src/scheduler.c	Wed Nov 21 13:12:44 2018 +0300
+++ b/Small_CPU/Src/scheduler.c	Wed Nov 21 13:57:58 2018 +0300
@@ -182,8 +182,44 @@
 void scheduleSpecial_Evaluate_DataSendToSlave(void)
 {
 
+	/* for device data updates */
+		deviceDataFlashValid = 0;
+		memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice));
 
-	global.dataSendToSlavePending = 0;
+		//TODO: (kittz) split by current mode.
+
+		// new hw 170523
+		if(global.I2C_SystemStatus != HAL_OK)
+		{
+		 MX_I2C1_TestAndClear();
+		 MX_I2C1_Init();
+		 if(!is_init_pressure_done())
+		 {
+			 init_pressure();
+		 }
+		}
+
+		pressure_update();
+		copyPressureData();
+		compass_read();
+		acceleration_read();
+		compass_calc();
+		battery_gas_gauge_get_data();
+		copyCompassData();
+
+		copyCnsAndOtuData();
+		copyTimeData();
+		copyBatteryData();
+		copyDeviceData();
+		copyVpmCrushingData();
+
+		deviceDataFlashValid = 1;
+		scheduleUpdateDeviceData();
+
+
+
+
+//	global.dataSendToSlavePending = 0;
 //	if(!global.dataSendToSlaveIsValid)		return; //TODO: WHAT THE FUCK?????!!!!!
 	
 	global.dataSendToMaster.confirmRequest.uw = 0;
@@ -267,39 +303,6 @@
 	/* for simulation / testing */
 	global.ceiling_from_main_CPU_mbar	= global.dataSendToSlave.data.ambient_pressure_mbar_ceiling;
 	
-	/* for device data updates */
-	deviceDataFlashValid = 0;
-	memcpy(&DeviceDataFlash, &global.dataSendToSlave.data.DeviceData, sizeof(SDevice));
-
-	//TODO: (kittz) split by current mode.
-
-	// new hw 170523
-	if(global.I2C_SystemStatus != HAL_OK)
-	{
-	 MX_I2C1_TestAndClear();
-	 MX_I2C1_Init();
-	 if(!is_init_pressure_done())
-	 {
-		 init_pressure();
-	 }
-	}
-
-	pressure_update();
-	copyPressureData();
-	compass_read();
-	acceleration_read();
-	compass_calc();
-	battery_gas_gauge_get_data();
-	copyCompassData();
-
-	copyCnsAndOtuData();
-	copyTimeData();
-	copyBatteryData();
-	copyDeviceData();
-	copyVpmCrushingData();
-
-	deviceDataFlashValid = 1;
-	scheduleUpdateDeviceData();
 
 }
 
@@ -1183,27 +1186,27 @@
 	if(temperature_centigrad_int32 < global.deviceData.temperatureMinimum.value_int32)
 	{
 		global.deviceData.temperatureMinimum.value_int32 = temperature_centigrad_int32;
-		//WTF?		scheduleSetDate(&global.deviceData.temperatureMinimum);
+		/*Last_change_time?*/		scheduleSetDate(&global.deviceData.temperatureMinimum);
 	}
 
 	if(temperature_centigrad_int32 > global.deviceData.temperatureMaximum.value_int32)
 	{
 		global.deviceData.temperatureMaximum.value_int32 = temperature_centigrad_int32;
-		//WTF?		scheduleSetDate(&global.deviceData.temperatureMaximum);
+		/*Last_change_time?*/		scheduleSetDate(&global.deviceData.temperatureMaximum);
 	}
 
 	pressure_mbar_int32 = (int32_t)get_pressure_mbar();
 	if(pressure_mbar_int32 > global.deviceData.depthMaximum.value_int32)
 	{
 		global.deviceData.depthMaximum.value_int32 = pressure_mbar_int32;
-		//WTF?		scheduleSetDate(&global.deviceData.depthMaximum);
+		/*Last_change_time?*/		scheduleSetDate(&global.deviceData.depthMaximum);
 	}
 	
 	voltage_mvolt_int32 = (int32_t)(get_voltage() * 1000);
 	if(voltage_mvolt_int32 < global.deviceData.voltageMinimum.value_int32)
 	{
 		global.deviceData.voltageMinimum.value_int32 = voltage_mvolt_int32;
-		//WTF?		scheduleSetDate(&global.deviceData.voltageMinimum);
+		/*Last_change_time?*/		scheduleSetDate(&global.deviceData.voltageMinimum);
 	}
 
 	/* third step, counter */
@@ -1230,14 +1233,14 @@
 void scheduleUpdateDeviceDataChargerFull(void)
 {
 	global.deviceData.batteryChargeCompleteCycles.value_int32++;
-//WTF?		scheduleSetDate(&global.deviceData.batteryChargeCompleteCycles);
+	/*Last_change_time?*/		scheduleSetDate(&global.deviceData.batteryChargeCompleteCycles);
 }
 
 
 void scheduleUpdateDeviceDataChargerCharging(void)
 {
 	global.deviceData.batteryChargeCycles.value_int32++;
-//WTF?		scheduleSetDate(&global.deviceData.batteryChargeCycles);
+	/*Last_change_time?*/		scheduleSetDate(&global.deviceData.batteryChargeCycles);
 }
 
 
Binary file ostc4pack/OSTC4_Firmware.bin has changed
Binary file ostc4pack/OSTC4_RTE.bin has changed
Binary file ostc4pack/OSTC4_RTE_upload.bin has changed
Binary file ostc4pack/OSTC4_firmware_upload.bin has changed