diff Small_CPU/Src/baseCPU2.c @ 473:edfc1a464b42 Improve_Button_Sleep

Do not signal power on reset in case of a "warm" reset: The RTE signaled at every startup a coldstart to the firmware causing a reset of the button responsitivness to default. Even for example after a firmware update. The reset of the values is a wanted behavior in case a value was set which makes it impossible to operate the buttons. This is still possible by removing the battery => real cold start
author ideenmodellierer
date Tue, 12 May 2020 22:39:18 +0200
parents 5b4c78c36b04
children 9eeab3fead8f
line wrap: on
line diff
--- a/Small_CPU/Src/baseCPU2.c	Wed Apr 15 07:01:11 2020 +0000
+++ b/Small_CPU/Src/baseCPU2.c	Tue May 12 22:39:18 2020 +0200
@@ -343,29 +343,32 @@
 	init_battery_gas_gauge();
 	HAL_Delay(10);
 	battery_gas_gauge_get_data();
-	if(coldstart != 0xA5)
+
+	MX_SPI3_Init();
+
+	if(coldstart != 0xA5)	/* Not reading a 0xA5 means the memory cells has not been initialized before => cold start */
 	{
 		coldstart = 0xA5;
 		battery_gas_gauge_set(0);
+		global.dataSendToMaster.power_on_reset = 1;
+		global.deviceDataSendToMaster.power_on_reset = 1;
+
+		if (!scheduleSetButtonResponsiveness())
+		{
+			HAL_Delay(1);
+			if (!scheduleSetButtonResponsiveness()) // send again, if problem it's not my problem here.
+			{
+				HAL_Delay(1);
+				scheduleSetButtonResponsiveness(); // init
+				HAL_Delay(1);
+			}
+		}
 	}
 
 	global.lifeData.battery_voltage = get_voltage();
 	global.lifeData.battery_charge = get_charge();
 	copyBatteryData();
 
-	MX_SPI3_Init();
-	if (!scheduleSetButtonResponsiveness()) {
-		HAL_Delay(1);
-		scheduleSetButtonResponsiveness(); // init
-		HAL_Delay(1);
-		if (!scheduleSetButtonResponsiveness()) // send again, if problem it's not my problem here.
-		{
-			HAL_Delay(1);
-			scheduleSetButtonResponsiveness(); // init
-			HAL_Delay(1);
-		}
-	}
-
 	ADCx_Init();
 	GPIO_Power_MainCPU_Init();
 	global.mode = MODE_POWERUP;