changeset 942:06aaccaf2e02 Evo_2_23

Power down gnss module during dive: The gnss modul will now be send to powerdown at the start of the dive. After end of dive the module returns to normal operation. For development / test purpose a new simulated dive profile has been added.
author Ideenmodellierer
date Mon, 16 Dec 2024 19:09:00 +0100
parents 6d8ae8fbccf5
children e7f87ade3037
files Small_CPU/Src/GNSS.c Small_CPU/Src/baseCPU2.c Small_CPU/Src/pressure.c Small_CPU/Src/scheduler.c
diffstat 4 files changed, 41 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Small_CPU/Src/GNSS.c	Mon Dec 16 19:06:37 2024 +0100
+++ b/Small_CPU/Src/GNSS.c	Mon Dec 16 19:09:00 2024 +0100
@@ -64,7 +64,7 @@
  * @param GNSS Pointer to main GNSS structure.
  */
 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS) {
-	for (int var = 0; var < 5; ++var) {
+	for (int var = 0; var < 5; var++) {
 		GNSS->uniqueID[var] = GNSS_Handle.uartWorkingBuffer[10 + var];
 	}
 }
--- a/Small_CPU/Src/baseCPU2.c	Mon Dec 16 19:06:37 2024 +0100
+++ b/Small_CPU/Src/baseCPU2.c	Mon Dec 16 19:09:00 2024 +0100
@@ -275,9 +275,7 @@
 #endif
 
     uint8_t extInterfaceActive = 0;
-#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2
     uint32_t shutdownTick = 0;
-#endif
 
 	HAL_Init();
 	SystemClock_Config();
@@ -462,6 +460,9 @@
             global.no_fly_time_minutes = 0;
             global.lifeData.dive_time_seconds = 0;
             global.lifeData.dive_time_seconds_without_surface_time = 0;
+
+            uartGnss_ReqPowerDown(1);
+
             scheduleDiveMode();
             // done now in scheduler prior to change mode: global.seconds_since_last_dive = 1;
 
@@ -487,6 +488,8 @@
 
             backup.no_fly_time_minutes = 0;
             backup.seconds_since_last_dive = 0;
+
+            uartGnss_ReqPowerDown(0);
 			break;
 
 		case MODE_SHUTDOWN:
--- a/Small_CPU/Src/pressure.c	Mon Dec 16 19:06:37 2024 +0100
+++ b/Small_CPU/Src/pressure.c	Mon Dec 16 19:09:00 2024 +0100
@@ -49,7 +49,6 @@
 /* remove comment to use a predefined profile for pressure changes instead of real world data */
 /* #define SIMULATE_PRESSURE */
 
-
 #define PRESSURE_SURFACE_MAX_MBAR			(1060.0f)		/* It is unlikely that pressure at surface is greater than this value => clip to it */
 
 #define PRESSURE_MINIMUM					(0.0f)
@@ -564,7 +563,7 @@
 		}
 		secondtick = lasttick;
 
-#define DIVE_AT_SPEED 1
+#define DIVE_EASY 1
 #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 */
@@ -576,7 +575,14 @@
 		else if(passedSecond < 2500) pressure_sim_mbar -= 10.0; /* return to surface */
 		else pressure_sim_mbar = 1000.0;					/* final state */
 #endif
-#ifdef DIVE_AT_SPEED
+#ifdef DIVE_EASY
+		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	 /* stay stable for 10 seconds */
+		else if(passedSecond < 120) pressure_sim_mbar += 1.0; /* decrease pressure in 2 minutes */
+		else if(passedSecond < 240) pressure_sim_mbar += 0.0;	/*stay stable 2 minutes*/
+		else if(passedSecond < 360) pressure_sim_mbar -= 1.0;	/* return to 1 bar in 2 Minutes*/
+		else pressure_sim_mbar = 1000.0;					/* final state */
+#endif
+#if DIVE_AT_SPEED
 		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	   /* stay stable for 10 seconds */
 		else if(passedSecond < 20) delta_mbar = 200.0 / SECDIV; /* Start dive */
 		else if(passedSecond < 30) delta_mbar = 0.0;	/*stay on depth*/
@@ -594,8 +600,8 @@
 		{
 			pressure_sim_mbar = surface_pressure_mbar;
 		}
-
-#else	/* short dive */
+#endif
+#ifdef SHORTDIVE	/* 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*/
--- a/Small_CPU/Src/scheduler.c	Mon Dec 16 19:06:37 2024 +0100
+++ b/Small_CPU/Src/scheduler.c	Mon Dec 16 19:09:00 2024 +0100
@@ -169,6 +169,11 @@
 	global.dataSendToMaster.footer.checkCode[0] = 0xE1;
 	global.dataSendToMaster.sensorErrors = 0;
 
+	global.dataSendToMaster.data[0].gnssInfo.coord.fLat = 0.0;
+	global.dataSendToMaster.data[0].gnssInfo.coord.fLon = 0.0;
+	global.dataSendToMaster.data[0].gnssInfo.fixType = 0;
+	global.dataSendToMaster.data[0].gnssInfo.numSat = 0;
+
 	global.sync_error_count = 0;
 	global.check_sync_not_running = 0;
 
@@ -525,6 +530,9 @@
 		ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick);
 
 		externalInterface_HandleUART();
+#ifdef ENABLE_GPIO_V2
+		UART6_HandleUART();
+#endif
 		if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10)
 		{
 			if(SPI_Evaluate_RX_Data()!=0) /* did we receive something ? */
@@ -1119,8 +1127,6 @@
 		RTC_StopMode_2seconds();
 #endif
 		
-
-		
 		if(global.mode == MODE_SLEEP)
 			secondsCount += 2;
 
@@ -1191,10 +1197,20 @@
 				GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
 				GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
 				GPIO_InitStruct.Pull = GPIO_NOPULL;
-				GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN | GPS_BCKP_CONTROL_PIN);
+				GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN);
+				HAL_GPIO_Init( GPIOB, &GPIO_InitStruct);
+
+				uartGnss_SetState(UART_GNSS_INIT);
+			}
+		}
+		else
+		{
+			if(global.lifeData.battery_voltage < 3.5)	/* switch off backup voltage if battery gets low */
+			{
+				GPIO_GPS_BCKP_OFF();
+				GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_BCKP_CONTROL_PIN);
 				HAL_GPIO_Init( GPIOB, &GPIO_InitStruct);
 				__HAL_RCC_GPIOB_CLK_DISABLE();
-				uartGnss_SetState(UART_GNSS_INIT);
 			}
 		}
 #endif
@@ -1206,11 +1222,12 @@
 	setButtonsNow = 0;
 	reinitGlobals();
 	ReInit_battery_charger_status_pins();
-
+#ifdef ENABLE_GPIO_V2
 	if(deepSleepCntDwn == 0)
 	{
 		GPIO_GNSS_Init();
 	}
+#endif
 }
 
 
@@ -1772,8 +1789,8 @@
 
 void copyGNSSdata(void)
 {
-	global.dataSendToMaster.data[0].gnssInfo.fLat = GNSS_Handle.fLat;
-	global.dataSendToMaster.data[0].gnssInfo.fLon = GNSS_Handle.fLon;
+	global.dataSendToMaster.data[0].gnssInfo.coord.fLat = GNSS_Handle.fLat;
+	global.dataSendToMaster.data[0].gnssInfo.coord.fLon = GNSS_Handle.fLon;
 	global.dataSendToMaster.data[0].gnssInfo.fixType = GNSS_Handle.fixType;
 	global.dataSendToMaster.data[0].gnssInfo.numSat = GNSS_Handle.numSat;
 	global.dataSendToMaster.data[0].gnssInfo.alive = GNSS_Handle.alive;