changeset 899:2225c467f1e9 Evo_2_23

Added data path and visualization for position data: The GNSS data exchange is now initialized and triggered on a cyclic basis (once a second). RTE verion has been increased because of interface change. For now only the position data is shown in a T7 surface views. The functionality may be switched on/off using the compile switch ENABLE_GNSS.
author Ideenmodellierer
date Mon, 30 Sep 2024 21:56:05 +0200
parents fac13aa6ba93
children 6a7701f66b16
files Common/Inc/configuration.h Common/Inc/data_central.h Common/Inc/data_exchange.h Discovery/Inc/tHome.h Discovery/Inc/text_multilanguage.h Discovery/Src/data_exchange_main.c Discovery/Src/settings.c Discovery/Src/t7.c Discovery/Src/tMenuEditCustom.c Discovery/Src/text_multilanguage.c Small_CPU/Inc/GNSS.h Small_CPU/Inc/uartProtocol_GNSS.h Small_CPU/Src/GNSS.c Small_CPU/Src/baseCPU2.c Small_CPU/Src/scheduler.c Small_CPU/Src/uartProtocol_GNSS.c
diffstat 16 files changed, 274 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/configuration.h	Thu Sep 26 18:40:41 2024 +0200
+++ b/Common/Inc/configuration.h	Mon Sep 30 21:56:05 2024 +0200
@@ -87,4 +87,7 @@
 /* Enable to have a faster transfer speed between bluetooth module and CPU */
 #define ENABLE_FAST_COMM
 
+/* Enable to have position sensor support active */
+#define ENABLE_GNSS
+
 #endif
--- a/Common/Inc/data_central.h	Thu Sep 26 18:40:41 2024 +0200
+++ b/Common/Inc/data_central.h	Mon Sep 30 21:56:05 2024 +0200
@@ -165,6 +165,13 @@
 }		SDeviceState;
 */
 
+typedef struct
+{
+	float Longitude;
+	float Latitude;
+} 	SPositionData;
+
+
 /* struct SLifeData
  * contains data all actual data (pressure, stuturation, etc. as received from second ship
  * and has actualGas to be send to Small CPU (second chip)
@@ -245,6 +252,9 @@
 
 /* for PSCR Mode */
 	 float ppo2Simulated_bar;
+/* GNSS data */
+	 SPositionData gnssPosition;
+
 } 	SLifeData;
 
 
--- a/Common/Inc/data_exchange.h	Thu Sep 26 18:40:41 2024 +0200
+++ b/Common/Inc/data_exchange.h	Mon Sep 30 21:56:05 2024 +0200
@@ -198,6 +198,8 @@
 		//debug
 		uint32_t pressure_uTick;
 		uint32_t compass_uTick;
+		float fLat;
+		float fLon;
 
 } 	SExchangeData;
 
--- a/Discovery/Inc/tHome.h	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Inc/tHome.h	Mon Sep 30 21:56:05 2024 +0200
@@ -80,6 +80,7 @@
 		CVIEW_Charger,
 		CVIEW_CcrSummary,
         CVIEW_Timer,
+		CVIEW_Position,
 		CVIEW_END			/* The ID is used in shift operation => 31 is the max number of supported views */
 };
 
--- a/Discovery/Inc/text_multilanguage.h	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Inc/text_multilanguage.h	Mon Sep 30 21:56:05 2024 +0200
@@ -381,6 +381,7 @@
         TXT2BYTE_Starting,
         TXT2BYTE_Finished,
 
+		TXT2BYTE_Position,
         TXT2BYTE_Page,
 
 		TXT2BYTE_END,
--- a/Discovery/Src/data_exchange_main.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Src/data_exchange_main.c	Mon Sep 30 21:56:05 2024 +0200
@@ -479,16 +479,16 @@
 	if(decoLock == DECO_CALC_running)
         return;
 
-		if(decoLock == DECO_CALC_init_as_is_start_of_dive)
-		{
+	if(decoLock == DECO_CALC_init_as_is_start_of_dive)
+	{
 	    vpm_init(&stateUsedWrite->vpm,  stateUsedWrite->diveSettings.vpm_conservatism, 0, 0);
 	    buehlmann_init();
 	    timer_init();
 	    resetEvents(stateUsedWrite);
 	    stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0;
-		}
+	}
 
-		if(decoLock == DECO_CALC_FINSHED_Buehlmann)
+	if(decoLock == DECO_CALC_FINSHED_Buehlmann)
     {
 
     }
@@ -530,6 +530,7 @@
     //Copy Inputdata from stateReal to stateDeco
     memcpy(&stateDeco.lifeData,&stateUsedWrite->lifeData,sizeof(SLifeData));
     memcpy(&stateDeco.diveSettings,&stateUsedWrite->diveSettings,sizeof(SDiveSettings));
+    memcpy(&stateDeco.decolistVPM,&stateUsedWrite->decolistVPM,sizeof(SDecoinfo));
 
     stateDeco.vpm.deco_zone_reached = stateUsedWrite->vpm.deco_zone_reached;
     // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm));
@@ -540,7 +541,7 @@
         stateDeco.vpm.adjusted_critical_radius_he[i] = stateUsedWrite->vpm.adjusted_critical_radius_he[i];
         stateDeco.vpm.adjusted_critical_radius_n2[i] = stateUsedWrite->vpm.adjusted_critical_radius_n2[i];
     }
-		decoLock = DECO_CALC_ready;
+	decoLock = DECO_CALC_ready;
 }
 
 
@@ -1006,6 +1007,9 @@
 	
 		pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr;
 		pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr;
+
+		pStateReal->lifeData.gnssPosition.Latitude = dataIn.data[0].fLat;
+		pStateReal->lifeData.gnssPosition.Longitude = dataIn.data[0].fLon;
 	}
 
 	if(pStateReal->data_old__lost_connection_to_slave == 0)
--- a/Discovery/Src/settings.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Src/settings.c	Mon Sep 30 21:56:05 2024 +0200
@@ -43,7 +43,7 @@
 SSettings Settings;
 
 const uint8_t RTErequiredHigh = 3;
-const uint8_t RTErequiredLow = 3;
+const uint8_t RTErequiredLow = 4;
 
 const uint8_t FONTrequiredHigh = 1;
 const uint8_t FONTrequiredLow =	0;
--- a/Discovery/Src/t7.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Src/t7.c	Mon Sep 30 21:56:05 2024 +0200
@@ -81,6 +81,7 @@
 
 static void t7_drawAcentGraph(uint8_t color);
 static uint8_t t7_drawSlowExitGraph(void);
+static void t7_showPosition(void);
 
 /* Imported function prototypes ---------------------------------------------*/
 extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium);
@@ -143,6 +144,9 @@
 	CVIEW_Charger,
     CVIEW_CcrSummary,
     CVIEW_Timer,
+#ifdef ENABLE_GNSS
+	CVIEW_Position,
+#endif
     CVIEW_END
 };
 
@@ -2684,9 +2688,7 @@
     case CVIEW_CcrSummary:
         snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_CcrSummary);
         GFX_write_string(&FontT42, &t7cH, text, 0);
-
         t7_CcrSummary(pSettings);
-
         break;
     case CVIEW_Timer:
         snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_Timer);
@@ -2699,6 +2701,11 @@
         showTimer(pSettings, nowS);
 
         break;
+
+    case CVIEW_Position:
+        snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_Position);
+        GFX_write_string(&FontT42, &t7cH, text, 0);
+        t7_showPosition();
     }
 
     last_customview = selection_customview;
@@ -3981,7 +3988,28 @@
 #endif
 }
 
-
+void t7_showPosition(void)
+{
+    char text[256+50];
+    uint8_t textpointer = 0;
+
+    t7cY0free.WindowLineSpacing = 28 + 48 + 14;
+    t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing;
+    t7cY0free.WindowNumberOfTextLines = 3;
+
+    textpointer += snprintf(&text[textpointer],50,"\001Longitude\n\r");
+    textpointer += snprintf(&text[textpointer],50,"\001Latitude\n\r");
+    GFX_write_string(&FontT24, &t7cY0free, text, 1);
+
+    t7cY0free.WindowY0 -= 52;
+    snprintf(text,60,
+        "\001%0.5f\n\r"
+        "\001%0.5f\n\r"
+        ,stateUsed->lifeData.gnssPosition.Longitude
+		,stateUsed->lifeData.gnssPosition.Latitude );
+
+    GFX_write_string(&FontT42, &t7cY0free, text, 1);
+}
 void t7_SummaryOfLeftCorner(void)
 {
     char text[256+60];
--- a/Discovery/Src/tMenuEditCustom.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Src/tMenuEditCustom.c	Mon Sep 30 21:56:05 2024 +0200
@@ -503,6 +503,9 @@
     case CVIEW_Timer:
         text = TXT2BYTE_Timer;
         break;
+    case CVIEW_Position:
+        text = TXT2BYTE_Position;
+        break;
     case CVIEW_noneOrDebug:
     	text = TXT2BYTE_DispNoneDbg;
     	break;
--- a/Discovery/Src/text_multilanguage.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Discovery/Src/text_multilanguage.c	Mon Sep 30 21:56:05 2024 +0200
@@ -1938,6 +1938,12 @@
 static uint8_t text_IT_Finished[] = "Finito";
 static uint8_t text_ES_Finished[] = "Terminado";
 
+static uint8_t text_EN_Position[] = "Position";
+static uint8_t text_DE_Position[] = "Position";
+static uint8_t text_FR_Position[] = "";
+static uint8_t text_IT_Position[] = "";
+static uint8_t text_ES_Position[] = "";
+
 static uint8_t text_EN_Page[] = "Page";
 static uint8_t text_DE_Page[] = "Blättern";
 static uint8_t text_FR_Page[] = "Défiler";
@@ -2240,5 +2246,7 @@
 	{(uint8_t)TXT2BYTE_Starting, 	{text_EN_Starting, text_DE_Starting, text_FR_Starting, text_IT_Starting, text_ES_Starting}},
 	{(uint8_t)TXT2BYTE_Finished, 	{text_EN_Finished, text_DE_Finished, text_FR_Finished, text_IT_Finished, text_ES_Finished}},
 
+	{(uint8_t)TXT2BYTE_Position, 	{text_EN_Position, text_DE_Position, text_FR_Position, text_IT_Position, text_ES_Position}},
+
 	{(uint8_t)TXT2BYTE_Page, 	{text_EN_Page, text_DE_Page, text_FR_Page, text_IT_Page, text_ES_Page}},
 };
--- a/Small_CPU/Inc/GNSS.h	Thu Sep 26 18:40:41 2024 +0200
+++ b/Small_CPU/Inc/GNSS.h	Mon Sep 30 21:56:05 2024 +0200
@@ -133,7 +133,7 @@
 static const uint8_t setPortableType[]={};
 void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart);
 void GNSS_LoadConfig(GNSS_StateHandle *GNSS);
-void GNSS_ParseBuffer(GNSS_StateHandle *GNSS);
+uint8_t GNSS_ParseBuffer(GNSS_StateHandle *GNSS);
 
 void GNSS_GetUniqID(GNSS_StateHandle *GNSS);
 void GNSS_ParseUniqID(GNSS_StateHandle *GNSS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Small_CPU/Inc/uartProtocol_GNSS.h	Mon Sep 30 21:56:05 2024 +0200
@@ -0,0 +1,55 @@
+/**
+  ******************************************************************************
+  * @file    uartProtocol_GNSS.h
+  * @author  heinrichs weikamp gmbh
+  * @version V0.0.1
+  * @date    30-Sep-2024
+  * @brief	 Interface functionality for operation of gnss devices
+  *
+  @verbatim
+  ==============================================================================
+                        ##### How to use #####
+  ==============================================================================
+  @endverbatim
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef UART_PROTOCOL_GNSS_H
+#define UART_PROTOCOL_GNSS_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "configuration.h"
+#include "stm32f4xx_hal.h"
+
+ typedef enum
+  {
+	UART_GNSS_INIT = 0,			/* Default Status for every sensor type */
+	UART_GNSS_LOAD,				/* Load modul configuration */
+	UART_GNSS_GET_ID,			/* get unique module ID */
+	UART_GNSS_IDLE,				/* sensor detected and no communication pending */
+	UART_GNSS_ERROR,
+  	UART_GNSS_OPERATING,		/* normal operation => cyclic request of PVT data */
+  } uartGnssStatus_t;
+
+  typedef enum
+  {
+  	GNSSRX_READY = 0,			/* Initial state */
+	GNSSRX_RECEIVING,			/* Pending data receiption */
+  } receiveStateGnss_t;
+
+
+void uartGnss_Control(void);
+void uartGnss_ProcessData(void);
+uint8_t uartSentinel_isSensorConnected();
+
+#endif /* UART_PROTOCOL_GNSS_H */
--- a/Small_CPU/Src/GNSS.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Small_CPU/Src/GNSS.c	Mon Sep 30 21:56:05 2024 +0200
@@ -61,11 +61,14 @@
  * Searching for a header in data buffer and matching class and message ID to buffer data.
  * @param GNSS Pointer to main GNSS structure.
  */
-void GNSS_ParseBuffer(GNSS_StateHandle *GNSS) {
+uint8_t GNSS_ParseBuffer(GNSS_StateHandle *GNSS) {
+
+	uint8_t DataReceived = 0;
 
 	for (int var = 0; var <= 100; ++var) {
 		if (GNSS->uartWorkingBuffer[var] == 0xB5
 				&& GNSS->uartWorkingBuffer[var + 1] == 0x62) {
+			DataReceived = 1;
 			if (GNSS->uartWorkingBuffer[var + 2] == 0x27
 					&& GNSS->uartWorkingBuffer[var + 3] == 0x03) { //Look at: 32.19.1.1 u-blox 8 Receiver description
 				GNSS_ParseUniqID(GNSS);
@@ -81,6 +84,7 @@
 			}
 		}
 	}
+	return DataReceived;
 }
 
 /*!
--- a/Small_CPU/Src/baseCPU2.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Small_CPU/Src/baseCPU2.c	Mon Sep 30 21:56:05 2024 +0200
@@ -168,7 +168,7 @@
 // See CPU2-RTE.ld
 const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= {
 		.versionFirst = 3,
-		.versionSecond = 3,
+		.versionSecond = 4,
 		.versionThird = 0,
 		.versionBeta = 1,
 
@@ -434,6 +434,8 @@
 			GNSS_IO_init();
 			MX_USART6_UART_Init();
 			GNSS_Init(&GNSS_Handle, &huart6);
+
+#if 0
 			HAL_Delay(1000);
 			GNSS_LoadConfig(&GNSS_Handle);
 			HAL_Delay(250);
@@ -442,7 +444,7 @@
 			HAL_Delay(250);
 			GNSS_GetPVTData(&GNSS_Handle);
 			GNSS_ParseBuffer(&GNSS_Handle);
-
+#endif
 /*
  * Demo code from SimpleMethod
  * called 1/second
--- a/Small_CPU/Src/scheduler.c	Thu Sep 26 18:40:41 2024 +0200
+++ b/Small_CPU/Src/scheduler.c	Mon Sep 30 21:56:05 2024 +0200
@@ -43,7 +43,10 @@
 #include "tm_stm32f4_otp.h"
 #include "externalInterface.h"
 #include "uart.h"
+#include "GNSS.h"
+#include "uartProtocol_GNSS.h"
 #include "math.h"
+#include "configuration.h"
 
 /* uncomment to enable restoting of last known date in case of a power loss (RTC looses timing data) */
 /* #define RESTORE_LAST_KNOWN_DATE */
@@ -101,6 +104,7 @@
 void copyPICdata(void);
 void copyExtADCdata();
 void copyExtCO2data();
+void copyGNSSdata(void);
 static void schedule_update_timer_helper(int8_t thisSeconds);
 static void evaluateAscentSpeed(void);
 uint32_t time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow);
@@ -874,6 +878,11 @@
 		{
 			adc_ambient_light_sensor_get_data();
 			copyAmbientLightData();
+#ifdef ENABLE_GNSS
+			uartGnss_ProcessData();
+			uartGnss_Control();
+#endif
+			copyGNSSdata();
 			Scheduler.counterAmbientLight100msec++;
 		}
 
@@ -1734,6 +1743,24 @@
 	global.dataSendToMaster.boolADCO2Data |= boolCO2Buffer;
 }
 
+void copyGNSSdata(void)
+{
+#ifdef ENABLE_GNSS
+	global.dataSendToMaster.data[0].fLat = GNSS_Handle.fLat;
+	global.dataSendToMaster.data[0].fLon = GNSS_Handle.fLon;
+#else
+	static float tmpLon = 0.0;
+	static float tmpLat= 100.0;
+	global.dataSendToMaster.data[0].fLat = tmpLat;
+	global.dataSendToMaster.data[0].fLon = tmpLon;
+	tmpLon += 0.15;
+	if(tmpLon > 360.0) tmpLon = 0.0;
+	tmpLat += 0.33;
+	if(tmpLat > 360.0) tmpLat = 0.0;
+#endif
+}
+
+
 typedef enum 
 {
   SPI3_OK      = 0x00,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Small_CPU/Src/uartProtocol_GNSS.c	Mon Sep 30 21:56:05 2024 +0200
@@ -0,0 +1,113 @@
+/**
+  ******************************************************************************
+  * @file    uartProtocol_GNSS.c
+  * @author  heinrichs weikamp gmbh
+  * @version V0.0.1
+  * @date    30-Sep-2024
+  * @brief   Interface functionality operation of GNSS devices
+  *
+  @verbatim
+
+
+  @endverbatim
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2024 heinrichs weikamp</center></h2>
+  *
+  ******************************************************************************
+  */
+/* Includes ------------------------------------------------------------------*/
+
+#include <string.h>
+#include "scheduler.h"
+#include <uartProtocol_GNSS.h>
+#include "uart.h"
+#include "GNSS.h"
+
+#ifdef ENABLE_GNSS
+
+static uartGnssStatus_t gnssOpState = UART_GNSS_INIT;
+static receiveStateGnss_t rxState = GNSSRX_READY;
+
+void ConvertByteToHexString(uint8_t byte, char* str)
+{
+	uint8_t worker = 0;
+	uint8_t digit = 0;
+	uint8_t digitCnt = 1;
+
+	worker = byte;
+	while((worker!=0) && (digitCnt != 255))
+	{
+		digit = worker % 16;
+		if( digit < 10)
+		{
+			digit += '0';
+		}
+		else
+		{
+			digit += 'A' - 10;
+		}
+		str[digitCnt--]= digit;
+		worker = worker / 16;
+	}
+}
+
+void uartGnss_Control(void)
+{
+	static uint32_t delayStartTick = 0;
+
+	uint32_t tick = HAL_GetTick();
+
+	switch (gnssOpState)
+	{
+		case UART_GNSS_INIT:	delayStartTick = tick;
+								gnssOpState = UART_GNSS_LOAD;
+				break;
+		case UART_GNSS_LOAD:	if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 1000)
+								{
+									GNSS_LoadConfig(&GNSS_Handle);
+									gnssOpState = UART_GNSS_GET_ID;
+									delayStartTick = tick;
+								}
+				break;
+		case UART_GNSS_GET_ID:	if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 250)
+								{
+									GNSS_GetUniqID(&GNSS_Handle);
+									gnssOpState = UART_GNSS_IDLE;
+									rxState = GNSSRX_RECEIVING;
+									delayStartTick = tick;
+								}
+				break;
+		case UART_GNSS_IDLE:	if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 1000)
+								{
+									GNSS_GetPVTData(&GNSS_Handle);
+									gnssOpState = UART_GNSS_OPERATING;
+									rxState = GNSSRX_RECEIVING;
+									delayStartTick = tick;
+								}
+				break;
+		case UART_GNSS_OPERATING: if(time_elapsed_ms(delayStartTick,HAL_GetTick()) > 1000)
+								{
+									gnssOpState = UART_GNSS_IDLE;	/* simple error handling => start next request */
+									rxState = GNSSRX_READY;
+								}
+				break;
+		default:
+				break;
+	}
+}
+
+void uartGnss_ProcessData(void)
+{
+	if(rxState == GNSSRX_RECEIVING)
+	{
+		if(GNSS_ParseBuffer(&GNSS_Handle))
+		{
+			gnssOpState = UART_GNSS_IDLE;
+		}
+	}
+}
+
+#endif
+