changeset 351:ba53ab77f059

Merge
author heinrichsweikamp
date Sun, 06 Oct 2019 14:12:41 +0200
parents 591c03a1e68d (diff) 607099140a41 (current diff)
children 1f24022345d1 5f46ec49f9bf
files RefPrj/Firmware/.cproject RefPrj/RTE/.cproject Small_CPU/Src/pressure.c ostc4pack/OSTC4_Firmware.bin ostc4pack/OSTC4_firmware_upload.bin
diffstat 9 files changed, 173 insertions(+), 171 deletions(-) [+]
line wrap: on
line diff
Binary file Current build/OSTC4update_190804.bin has changed
Binary file Current build/OSTC4update_191006.bin has changed
--- a/Discovery/Src/settings.c	Sun Oct 06 11:58:36 2019 +0000
+++ b/Discovery/Src/settings.c	Sun Oct 06 14:12:41 2019 +0200
@@ -55,15 +55,15 @@
 {
     .versionFirst   = 1,
     .versionSecond 	= 5,
-    .versionThird   = 0,
+    .versionThird   = 1,
     .versionBeta    = 0,
 
     /* 4 bytes with trailing 0 */
     .signature = "mh",
 
     .release_year = 19,
-    .release_month = 8,
-    .release_day = 5,
+    .release_month = 10,
+    .release_day = 6,
     .release_sub = 0,
 
     /* max 48 with trailing 0 */
--- a/RefPrj/Firmware/.cproject	Sun Oct 06 11:58:36 2019 +0000
+++ b/RefPrj/Firmware/.cproject	Sun Oct 06 14:12:41 2019 +0200
@@ -50,7 +50,7 @@
 								<option id="gnu.cpp.compiler.option.debugging.level.1733485526" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
 							</tool>
 							<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.1908756987" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
-								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.1377166494" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}\..\ostc4\Common\CPU1-F429.ld" valueType="string"/>
+								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.1377166494" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="C:\Users\mh\workspace\ostc4\Common\CPU1-F429.ld" valueType="string"/>
 								<option id="gnu.c.link.option.ldflags.1166539479" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false" value="-u _printf_float " valueType="string"/>
 								<option id="gnu.c.link.option.other.2080432652" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" useByScannerDiscovery="false"/>
 								<option id="gnu.c.link.option.paths.1365621909" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false"/>
@@ -115,7 +115,7 @@
 				</extensions>
 			</storageModule>
 			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
-				<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1554475450" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -R .upper* -R .font_firmware_data -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot;; arm-none-eabi-size &quot;${BuildArtifactFileName}&quot;">
+				<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1554475450" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -R .upper* -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot;; arm-none-eabi-size &quot;${BuildArtifactFileName}&quot;">
 					<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1554475450." name="/" resourcePath="">
 						<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.240202493" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
 							<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.1492720020" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" useByScannerDiscovery="false" value="STM32F429IITx" valueType="string"/>
@@ -151,7 +151,7 @@
 								<option id="gnu.cpp.compiler.option.debugging.level.1273410642" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
 							</tool>
 							<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.1139299269" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
-								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.920748377" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}\..\ostc4\Common\CPU1-F429.ld" valueType="string"/>
+								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.920748377" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="C:\Users\mh\workspace\ostc4\Common\CPU1-F429.ld" valueType="string"/>
 								<option id="gnu.c.link.option.strip.1057056433" name="Omit all symbol information (-s)" superClass="gnu.c.link.option.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
 								<option id="gnu.c.link.option.ldflags.1124840583" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false" value="-u _printf_float" valueType="string"/>
 								<option id="gnu.c.link.option.nostart.543218958" name="Do not use standard start files (-nostartfiles)" superClass="gnu.c.link.option.nostart" useByScannerDiscovery="false" value="false" valueType="boolean"/>
--- a/RefPrj/RTE/.cproject	Sun Oct 06 11:58:36 2019 +0000
+++ b/RefPrj/RTE/.cproject	Sun Oct 06 14:12:41 2019 +0200
@@ -117,7 +117,7 @@
 								<option id="gnu.cpp.compiler.option.debugging.level.1980132124" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
 							</tool>
 							<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.1224776758" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
-								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.477531566" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}\..\ostc4\Small_CPU\CPU2-RTE.ld" valueType="string"/>
+								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.477531566" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="C:\Users\mh\workspace\ostc4\Small_CPU\CPU2-RTE.ld" valueType="string"/>
 								<option id="gnu.c.link.option.nodeflibs.1006660034" name="Do not use default libraries (-nodefaultlibs)" superClass="gnu.c.link.option.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
 								<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1337752943" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
 									<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
--- a/Small_CPU/Src/baseCPU2.c	Sun Oct 06 11:58:36 2019 +0000
+++ b/Small_CPU/Src/baseCPU2.c	Sun Oct 06 14:12:41 2019 +0200
@@ -161,8 +161,8 @@
 // SHALL LOAD AT 0x08000000 + 0x00005000 = 0x08005000.
 // See CPU2-RTE.ld
 const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= {
-		.versionFirst = 1,
-		.versionSecond = 9,
+		.versionFirst = 2,
+		.versionSecond = 0,
 		.versionThird = 0,
 		.versionBeta = 0,
 
@@ -170,8 +170,8 @@
 		.signature = "mh",
 
 		.release_year = 19,
-		.release_month = 8,
-		.release_day = 5,
+		.release_month = 10,
+		.release_day = 6,
 		.release_sub = 0,
 
 		/* max 48 with trailing 0 */
--- a/Small_CPU/Src/pressure.c	Sun Oct 06 11:58:36 2019 +0000
+++ b/Small_CPU/Src/pressure.c	Sun Oct 06 14:12:41 2019 +0200
@@ -46,20 +46,11 @@
 #define CMD_ADC_4096 0x08 // ADC OSR=4096
 #define CMD_PROM_RD 0xA0 // Prom read command
 
-/* remove comment to use a predefined profile for pressure changes instead of real world data */
-/* #define SIMULATE_PRESSURE */
-
-#define PRESSURE_SURFACE_MAX_MBAR			(1070.0f)		/* It is very unlikely that pressure at surface is greater than this value => clip to it */
-#define PRESSURE_HISTORY_SIZE				(8u)
-#define PRESSURE_JUMP_VALID_MBAR	    	(500.0f)		/* values are measure several times a second => jumps > 5m very unlikely */
+#define PRESSURE_SURFACE_MAX_MBAR		(1030.0f)		/* It is unlikely that pressure at surface is greater than this value => clip to it */
+#define PRESSURE_HISTORY_SIZE			(8u)
+#define PRESSURE_JUMP_VALID_MBAR	    (500.0f)		/* values are measure several times a second => jumps > 5m very unlikely */
 
-#define PRESSURE_SURFACE_QUE					(30u)			/* history buffer [minutes] for past pressure measurements */
-#define PRESSURE_SURFACE_EVA_WINDOW				(15u)			/* Number of entries evaluated during instability test. Used to avoid detection while dive enters water */
-#define PRESSURE_SURFACE_STABLE_LIMIT			(10u)			/* Define pressure as stable if delta (mBar) is below this value */
-#define PRESSURE_SURFACE_DETECT_STABLE_CNT		(5u)			/* Event count to detect stable condition */
-#define PRESSURE_SURFACE_UNSTABLE_LIMIT			(50u)			/* Define pressure as not stable if delta (mBar) is larger than this value */
-#define PRESSURE_SURFACE_DETECT_UNSTABLE_CNT	(3u)			/* Event count to detect unstable condition */
-
+#define PRESSURE_SURFACE_QUE			(30u)			/* history buffer [minutes] for past pressure measurements */
 
 static uint16_t get_ci_by_coef_num(uint8_t coef_num);
 //void pressure_calculation_new(void);
@@ -95,10 +86,6 @@
 static float surface_pressure_mbar = 1000.0;
 static float surface_ring_mbar[PRESSURE_SURFACE_QUE] = { 0 };
 
-static uint8_t surface_pressure_writeIndex = 0;
-static float surface_pressure_stable_value = 0;
-static uint8_t surface_pressure_stable = 0;
-
 static float pressure_history_mbar[PRESSURE_HISTORY_SIZE];
 
 static uint8_t secondCounterSurfaceRing = 0;
@@ -132,7 +119,6 @@
 		for(int i=0; i<PRESSURE_SURFACE_QUE; i++)
 			surface_ring_mbar[i] = ambient_pressure_mbar;
 		surface_pressure_mbar = ambient_pressure_mbar;
-		surface_pressure_writeIndex = 0;			/* index of the oldest value in the ring buffer */
 	}
 }
 
@@ -144,81 +130,10 @@
 	}
 }
 
-uint8_t is_surface_pressure_stable(void)
-{
-	return surface_pressure_stable;
-}
 
-float set_last_surface_pressure_stable(void)
-{
-	surface_pressure_mbar = surface_pressure_stable_value;
-	return surface_pressure_stable_value;
-}
-
-/* iterate backward through the history memory and evaluate the changes pressure changes during the last 30 minutes */
-void evaluate_surface_pressure()
-{
-	uint8_t index;
-	float lastvalue;
-	uint8_t stablecnt = 0;
-	uint8_t unstablecnt = 0;
-	uint8_t EvaluationWindow = PRESSURE_SURFACE_QUE - PRESSURE_SURFACE_EVA_WINDOW;	/* do not use the latest 15 values to avoid unstable condition due to something like fin handling */
-	uint8_t EvaluatedValues = 0;
-
-	lastvalue = surface_ring_mbar[surface_pressure_writeIndex];
-	surface_pressure_stable_value = surface_ring_mbar[surface_pressure_writeIndex]; /* default: if no stable value is found return the oldest value */
-	index = surface_pressure_writeIndex;
-	surface_pressure_stable = 1;
-
-	if(index == 0)
-	{
-		index = PRESSURE_SURFACE_QUE - 1;
-	}
-	else
-	{
-		index = index - 1;
-	}
-	do
-	{
-		if((EvaluatedValues < EvaluationWindow) &&
-			(fabs(surface_pressure_stable_value - surface_ring_mbar[index]) > PRESSURE_SURFACE_UNSTABLE_LIMIT)) /* unusual change during last 30 minutes */
-		{
-			unstablecnt++;
-			if(unstablecnt > PRESSURE_SURFACE_DETECT_UNSTABLE_CNT)
-			{
-				surface_pressure_stable = 0;
-			}
-		}
-	/* search for a value which does not change for several iterations */
-		if (fabs(lastvalue - surface_ring_mbar[index]) < PRESSURE_SURFACE_STABLE_LIMIT)
-		{
-			stablecnt++;
-		}
-		else
-		{
-			stablecnt = 0;
-		}
-		if ((stablecnt >= PRESSURE_SURFACE_DETECT_STABLE_CNT) && (surface_pressure_stable == 0)&&(surface_pressure_stable_value == surface_ring_mbar[surface_pressure_writeIndex])) /* pressure is unstable => search for new stable value */
-		{
-			surface_pressure_stable_value = surface_ring_mbar[index];
-			unstablecnt = 0;
-		}
-
-		lastvalue = surface_ring_mbar[index];
-
-		if(index == 0)
-		{
-			index = PRESSURE_SURFACE_QUE - 1;
-		}
-		else
-		{
-			index = index - 1;
-		}
-		EvaluatedValues++;
-	} while (index != surface_pressure_writeIndex);
-}
 void update_surface_pressure(uint8_t call_rhythm_seconds)
 {
+	static uint8_t writeIndex = 0;		/* Reinitialization will reset all entries to the same value => no need to reinit write index */
 
 
 	if(is_init_pressure_done())
@@ -231,25 +146,24 @@
 		{
 			if(runningAvg < PRESSURE_SURFACE_MAX_MBAR)
 			{
-				surface_ring_mbar[surface_pressure_writeIndex] = runningAvg;
+				surface_ring_mbar[writeIndex] = runningAvg;
 			}
 			else
 			{
-				surface_ring_mbar[surface_pressure_writeIndex] =	PRESSURE_SURFACE_MAX_MBAR;
+				surface_ring_mbar[writeIndex] =	PRESSURE_SURFACE_MAX_MBAR;
 			}
-			surface_pressure_writeIndex++; /* the write index is now pointing to the oldest value in the buffer which will be overwritten next time */
+			writeIndex++; /* the write index is now pointing to the oldest value in the buffer which will be overwritten next time */
 
-			if(surface_pressure_writeIndex == PRESSURE_SURFACE_QUE)
+			if(writeIndex == PRESSURE_SURFACE_QUE)
 			{
-				surface_pressure_writeIndex = 0;
+				writeIndex = 0;
 			}
 
-			surface_pressure_mbar = surface_ring_mbar[surface_pressure_writeIndex]; /* 30 minutes old measurement */
+			surface_pressure_mbar = surface_ring_mbar[writeIndex]; /* 30 minutes old measurement */
 
 			secondCounterSurfaceRing = 0;
 			avgCount = 1;	/* use the current value as starting point but restart the weight decrement of the measurements */
 		}
-		evaluate_surface_pressure();
 	}
 }
 
@@ -511,74 +425,12 @@
 }
 
 
-#ifdef SIMULATE_PRESSURE
-void pressure_simulation()
-{
-	static uint32_t tickstart = 0;
-	static float pressure_sim_mbar = 0;
-	static uint32_t passedSecond = 0;
-	static uint32_t secondtick = 0;
-
-	uint32_t lasttick = 0;
-
-
-
-	if( tickstart == 0)
-	{
-		tickstart = HAL_GetTick(); /* init time stamp */
-		secondtick = tickstart;
-		pressure_sim_mbar = 1000;
-	}
-
-	lasttick = HAL_GetTick();
-	if(time_elapsed_ms(secondtick,lasttick) > 1000) /* one second passed since last tick */
-	{
-		secondtick = lasttick;
-		passedSecond++;
-
-#ifdef DIVE_AFTER_LANDING
-		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	 /* stay stable for 10 seconds */
-		else if(passedSecond < 300) pressure_sim_mbar -= 1.0; /* decrease pressure in 5 minutes target 770mbar => delta 330 */
-		else if(passedSecond < 900) pressure_sim_mbar += 0.0;	/*stay stable 10 minutes*/
-		else if(passedSecond < 1500) pressure_sim_mbar += 0.5;	/* return to 1 bar in 10 Minutes*/
-		else if(passedSecond < 1800) pressure_sim_mbar += 0.0;	/* 5 minutes break */
-		else if(passedSecond < 2000) pressure_sim_mbar += 10.0; /* start dive */
-		else if(passedSecond < 2300) pressure_sim_mbar += 0.0;  /* stay on depth */
-		else if(passedSecond < 2500) pressure_sim_mbar -= 10.0; /* return to surface */
-		else pressure_sim_mbar = 1000.0;					/* final state */
-#else	/* short dive */
-		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	   /* stay stable for 10 seconds */
-		else if(passedSecond < 180) pressure_sim_mbar += 10.0; /* Start dive */
-		else if(passedSecond < 300) pressure_sim_mbar += 0.0;	/*stay on depth*/
-		else if(passedSecond < 460) pressure_sim_mbar -= 10.0;	/* return to surface */
-		else if(passedSecond < 600) pressure_sim_mbar += 0.0;   /* stay */
-		else if(passedSecond < 610) pressure_sim_mbar = 1000.0; /* get ready for second dive */
-		else if(passedSecond < 780) pressure_sim_mbar += 10.0; /* Start dive */
-		else if(passedSecond < 900) pressure_sim_mbar += 0.0;	/*stay on depth*/
-		else if(passedSecond < 1060) pressure_sim_mbar -= 10.0;	/* return to surface */
-		else if(passedSecond < 1200) pressure_sim_mbar += 0.0;   /* stay */
-		else pressure_sim_mbar = 1000.0;					/* final state */
-#endif
-	}
-
-
-	ambient_pressure_mbar = pressure_sim_mbar;
-	ambient_temperature = 25.0;
-	return;
-}
-
-#endif
-
 void pressure_calculation(void)
 {
 	if(global.I2C_SystemStatus != HAL_OK)
 		return;
-
-#ifdef SIMULATE_PRESSURE
-	pressure_simulation();
-#else
+	
 	pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015();
-#endif
 }
 
 static uint8_t pressure_plausible(float pressurevalue)
@@ -702,6 +554,156 @@
 }
 
 
+/*
+void pressure_calculation_new(void)
+{
+#define POW2_8	(256)
+#define POW2_17	(131072)
+#define POW2_6	(64)
+#define POW2_16	(65536)
+#define POW2_7	(128)
+#define POW2_23	(8388608)
+#define POW2_21	(2097152)
+#define POW2_15	(32768)
+#define POW2_13	(8192)
+#define POW2_37	(137438953472)
+#define POW2_4	(16)
+#define POW2_33	(8589934592)
+#define POW2_3	(8)
+	
+	int32_t	P; // compensated pressure value
+	int32_t T; // compensated temperature value
+	int32_t dT; // difference between actual and measured temperature
+	int64_t OFF; // offset at actual temperature
+	int64_t SENS;
+
+	int32_t T2;
+	int64_t OFF2;
+	int64_t SENS2;
+	
+	dT 		= ((int32_t)D2) - ((int32_t)C[5]) * POW2_8;
+	OFF 	= ((int64_t)C[2]) * POW2_16 + ((int64_t)dT) * ((int64_t)C[4]) / POW2_7;
+	SENS 	= ((int64_t)C[1]) * POW2_15 + ((int64_t)dT) * ((int64_t)C[3]) / POW2_8;
+
+	T	= 2000 + (dT * ((int32_t)C[6])) / POW2_23;
+
+
+if(T < 2000) // low temperature
+	{
+		T2 = 3 * dT * dT;
+		T2 /= POW2_33;
+		OFF2 = ((int64_t)T) - 2000;
+		OFF2 *= OFF2;
+		OFF2 *= 3;
+		OFF2 /= 2;
+		SENS2 = ((int64_t)T) - 2000;
+		SENS2 *= SENS2;
+		SENS2 *= 5;
+		SENS2 /= POW2_3;
+	}
+	else // high temperature
+	{
+		T2 = 7 * dT * dT;
+		T2 /= POW2_37;
+		OFF2 = ((int64_t)T) - 2000;
+		OFF2 *= OFF2;
+		OFF2 /= POW2_4;
+		SENS2 = 0;
+	}
+
+	T = T - T2;
+	OFF = OFF - OFF2;
+	SENS = SENS - SENS2;
+	
+	P = (int32_t)(((((int64_t)D1) * SENS) / POW2_21 - OFF) / POW2_13);
+	
+	ambient_temperature 	= ((float)T) / 100;
+	ambient_pressure_mbar	= ((float)P) / 10;
+}
+*/
+
+/*
+void pressure_calculation_old(void) {
+	//
+	double ambient_temperature_centigrad = 0;
+	double ambient_pressure_decimbar = 0;
+	
+	// static for debug
+	static int64_t dt = 0;
+	static int64_t temp = 0;
+	static int64_t ms_off = 0;
+	static int64_t sens = 0;
+	//
+	static int64_t ms_off2 = 0;
+	static int64_t sens2 = 0;
+	static int64_t t2 = 0;
+
+	if((D2 == 0) || (D1 == 0))
+		return;
+	//
+
+	// dT = D2 - C[5] * POW2_8;
+	// T	= 2000 + (dT * C[6]) / POW2_23;
+	dt = (int64_t)D2 - C5_x_2p8;
+	//temp ; // in 10 milliGrad Celcius
+	ambient_temperature_centigrad = 2000 + dt * C[6] / 8388608;
+	
+
+	if(ambient_temperature_centigrad < 2000) // low temperature
+		{
+			t2 = 3 * dt;
+			t2 *= dt;
+			t2 /= 8589934592;
+			ms_off2 = ambient_temperature_centigrad - 2000;
+			ms_off2 *= ms_off2;
+			sens2 = ms_off2;
+			ms_off2 *= 3;
+			ms_off2 /= 2;
+			sens2 *= 5;
+			sens2 /= 8;
+		}
+		else // high temperature
+		{
+			t2 = 7 * dt;
+			t2 *= dt;
+			t2 /= 137438953472;
+			ms_off2 = ambient_temperature_centigrad - 2000;
+			ms_off2 *= ms_off2;
+			ms_off2 /= 16;
+			sens2 = 0;
+		}
+	
+	
+	//
+
+	// pressure
+	// OFF 	= C[2] * POW2_16 + dT * C[4] / POW2_7;
+	// SENS = C[1] * POW2_15 + dT * C[3] / POW2_8;
+	ms_off =  C[4] * dt;
+	ms_off /= 128;
+	ms_off += C2_x_2p16;
+	//
+	sens =  C[3] * dt;
+	sens /= 256;
+	sens += C1_x_2p15;
+
+	// 2nd order correction
+	ambient_temperature_centigrad -= t2;
+	ms_off -= ms_off2;
+	sens -= sens2;
+
+	ambient_temperature = ambient_temperature_centigrad / 100;
+		// P = (D1 * SENS / POW2_21 - OFF) / POW2_13;
+	temp = D1 * sens;
+	temp /= 2097152;
+	temp -= ms_off;
+	temp /= 8192;
+	ambient_pressure_decimbar = temp; // to float/double
+	ambient_pressure_mbar = ambient_pressure_decimbar / 10;
+}
+*/
+
+
 /* taken from AN520 by meas-spec.com dated 9. Aug. 2011
  * short and int are both 16bit according to AVR/GCC google results
  */
Binary file ostc4pack/OSTC4_Firmware.bin has changed
Binary file ostc4pack/OSTC4_firmware_upload.bin has changed