diff Small_CPU/Src/baseCPU2.c @ 988:d9290c76b840 GasConsumption

OSTC4/5 joined code: In the previous version code differences between OSTC4/5 were identified using the ENABLE_GPIO_V2 compiler switch. In the new version this is done using the display version as indicator which OSTC model is in used. Since this is detected by Firmware the information is forwarded from there to the RTE. This causes a little delay in the GPIO initialization but this applies only to the cold start of the RTE which should not happen very often.
author ideenmodellierer
date Sun, 06 Apr 2025 21:02:17 +0200 (3 weeks ago)
parents 81049905d829
children d63584d6428d
line wrap: on
line diff
--- a/Small_CPU/Src/baseCPU2.c	Sat Mar 29 14:56:08 2025 +0100
+++ b/Small_CPU/Src/baseCPU2.c	Sun Apr 06 21:02:17 2025 +0200
@@ -402,46 +402,19 @@
 
 			if (global.mode == MODE_BOOT) {
 				GPIO_Power_MainCPU_OFF();
-#ifdef ENABLE_GPIO_V2
-				GPIO_LED_GREEN_ON();
-#endif
 				HAL_Delay(100); // for GPIO_Power_MainCPU_ON();
 				GPIO_Power_MainCPU_ON();
-#ifdef ENABLE_GPIO_V2
-				GPIO_LED_GREEN_OFF();
-
-				GPIO_LED_RED_ON();
-				GPIO_VIBRATION_ON();
-#endif
 				HAL_Delay(100);
-#ifdef ENABLE_GPIO_V2
-				GPIO_LED_RED_OFF();
-				GPIO_VIBRATION_OFF();
-#endif
 			}
-#ifdef ENABLE_GPIO_V2
-			GPIO_LED_RED_OFF();
-			GPIO_LED_GREEN_OFF();
-			GPIO_VIBRATION_OFF();
-#endif
 			SPI_synchronize_with_Master();
 			MX_DMA_Init();
 			MX_SPI1_Init();
 			SPI_Start_single_TxRx_with_Master(); /* be prepared for the first data exchange */
 			Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD);
 
-#ifdef ENABLE_GPIO_V2
-			// GNSS tests
-			GNSS_IO_init();
-			GPIO_GPS_ON();
-			GPIO_GPS_BCKP_ON();
-			MX_USART6_UART_Init();
-			GNSS_Init(&GNSS_Handle, &huart6);
-#else
-#ifdef  ENABLE_GNSS_SUPPORT
+#ifdef  ENABLE_GNSS_EXTERN
 			GNSS_Init(&GNSS_Handle, &huart1);
 #endif
-#endif
 
 			global.mode = MODE_SURFACE;
 			break;
@@ -466,8 +439,11 @@
             global.no_fly_time_minutes = 0;
             global.lifeData.dive_time_seconds = 0;
             global.lifeData.dive_time_seconds_without_surface_time = 0;
-#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2
-            uartGnss_ReqPowerDown(1);
+#if defined ENABLE_GNSS_INTERN
+            if(GPIO_GetVersion() > 0)
+            {
+            	uartGnss_ReqPowerDown(1);
+            }
 #endif
             scheduleDiveMode();
             // done now in scheduler prior to change mode: global.seconds_since_last_dive = 1;
@@ -494,8 +470,11 @@
 
             backup.no_fly_time_minutes = 0;
             backup.seconds_since_last_dive = 0;
-#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2
-            uartGnss_ReqPowerDown(0);
+#if defined ENABLE_GNSS_INTERN
+            if(GPIO_GetVersion() > 0)
+            {
+            	uartGnss_ReqPowerDown(0);
+            }
 #endif
 			break;
 
@@ -504,17 +483,27 @@
 
 			MX_SPI3_Init();
 
-#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2
-			if(shutdownTick == 0)
+#if defined ENABLE_GNSS_INTERN || ENABLE_GNSS_EXTERN
+			if(GPIO_GetVersion() > 0)
 			{
-				shutdownTick = HAL_GetTick();
-				uartGnss_ReqPowerDown(1);
+				if(shutdownTick == 0)
+				{
+					shutdownTick = HAL_GetTick();
+					uartGnss_ReqPowerDown(1);
+				}
 			}
-#ifdef ENABLE_GNSS_SUPPORT
+#endif
+#ifdef ENABLE_GNSS_EXTERN
 			externalInterface_HandleUART();
 #else
-			UART6_HandleUART();
+#ifdef ENABLE_GNSS_INTERN
+			if(GPIO_GetVersion() > 0)
+			{
+				UART6_HandleUART();
+			}
 #endif
+#endif
+#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN
 			if((uartGnss_GetState() == UART_GNSS_INACTIVE) || (time_elapsed_ms(shutdownTick,HAL_GetTick()) > 3000))
 			{
 				global.mode = MODE_SLEEP;
@@ -934,14 +923,20 @@
 	HAL_GPIO_Init( GPIOH, &GPIO_InitStruct);
 
 	GPIO_Power_MainCPU_OFF();
-#ifdef ENABLE_GPIO_V2
-	GPIO_LED_GREEN_OFF();
-	GPIO_LED_RED_OFF();
-	GPIO_VIBRATION_OFF();
-	GPIO_GPS_BCKP_ON();			// mH : costs 100µA in sleep - beware
-/*	GPIO_GPS_OFF();				will be done in transition sleep => deep sleep */
 
-	MX_USART6_UART_DeInit();
+	if(GPIO_GetVersion() > 0)
+	{
+		GPIO_LED_GREEN_OFF();
+		GPIO_LED_RED_OFF();
+		GPIO_VIBRATION_OFF();
+	}
+#ifdef ENABLE_GNSS_INTERN
+	if(GPIO_GetVersion() > 0)
+	{
+		GPIO_GPS_BCKP_ON();			// mH : costs 100µA in sleep - beware
+		/*	GPIO_GPS_OFF();				will be done in transition sleep => deep sleep */
+		MX_USART6_UART_DeInit();
+	}
 #endif
 #ifndef ENABLE_SLEEP_DEBUG
 /*