diff Small_CPU/Src/baseCPU2.c @ 437:6c824f902934

Merged in Ideenmodellierer/ostc4/Improve_BatteryGasGauge (pull request #40) Improve BatteryGasGauge
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Mon, 24 Feb 2020 07:58:37 +0000
parents aa286a4926c2
children 5b4c78c36b04
line wrap: on
line diff
--- a/Small_CPU/Src/baseCPU2.c	Tue Feb 18 12:41:45 2020 +0100
+++ b/Small_CPU/Src/baseCPU2.c	Mon Feb 24 07:58:37 2020 +0000
@@ -151,6 +151,8 @@
 #include "stm32f4xx_hal.h"
 #include <stdio.h>
 
+uint8_t coldstart __attribute__((section (".noinit")));
+
 uint8_t hasExternalClock(void) {
 	if ((TM_OTP_Read(0, 0) > 0) && (TM_OTP_Read(0, 0) < 0xFF))
 		return 1;
@@ -181,7 +183,9 @@
 		/* for safety reasons and coming functions */
 		.magic[0] = FIRMWARE_MAGIC_FIRST, .magic[1] = FIRMWARE_MAGIC_SECOND,
 		.magic[2] = FIRMWARE_MAGIC_CPU2_RTE, /* the magic byte for RTE */
-		.magic[3] = FIRMWARE_MAGIC_END };
+		.magic[3] = FIRMWARE_MAGIC_END
+};
+
 
 uint8_t firmwareVersionHigh(void) {
 	return cpu2_FirmwareData.versionFirst;
@@ -339,7 +343,11 @@
 	init_battery_gas_gauge();
 	HAL_Delay(10);
 	battery_gas_gauge_get_data();
-//	battery_gas_gauge_set(0);
+	if(coldstart != 0xA5)
+	{
+		coldstart = 0xA5;
+		battery_gas_gauge_set(0);
+	}
 
 	global.lifeData.battery_voltage = get_voltage();
 	global.lifeData.battery_charge = get_charge();