diff Small_CPU/Src/uartProtocol_GNSS.c @ 939:f41974734268 Evo_2_23

Resume UART com with gnss after sleep: Some changes were needed to get the communication up and running again after the gnns modul was set into power mode. The config needs to be safed at shutdown and the receiver needs to be wake up using dummy bytes before real communication may be resumed
author Ideenmodellierer
date Tue, 10 Dec 2024 21:03:04 +0100
parents 3029f0332f4f
children 80ae8ea7f0a0
line wrap: on
line diff
--- a/Small_CPU/Src/uartProtocol_GNSS.c	Tue Dec 10 21:00:55 2024 +0100
+++ b/Small_CPU/Src/uartProtocol_GNSS.c	Tue Dec 10 21:03:04 2024 +0100
@@ -66,10 +66,15 @@
 {
 	if(GnssConnected)
 	{
-		ReqPowerDown = 1;
+		ReqPowerDown = request;
 	}
 }
 
+uint8_t uartGnss_isPowerDownRequested()
+{
+	return ReqPowerDown;
+}
+
 uartGnssStatus_t uartGnss_GetState()
 {
 	return gnssState;
@@ -95,6 +100,9 @@
 		case GNSSCMD_LOADCONF_2:	pData = setGNSS;
 									txLength = sizeof(setGNSS) / sizeof(uint8_t);
 				break;
+		case GNSSCMD_SETMOBILE:		pData = setPortableMode;
+									txLength = sizeof(setPortableMode) / sizeof(uint8_t);
+				break;
 		case GNSSCMD_GET_PVT_DATA:	pData = getPVTData;
 									txLength = sizeof(getPVTData) / sizeof(uint8_t);
 			break;
@@ -157,12 +165,14 @@
 		case UART_GNSS_LOADCONF_2:	UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2);
 									rxState = GNSSRX_DETECT_ACK_0;
 				break;
+		case UART_GNSS_SETMODE_MOBILE: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2);
+									   rxState = GNSSRX_DETECT_ACK_0;
+				break;
 		case UART_GNSS_PWRDOWN:		UART_Gnss_SendCmd(GNSSCMD_MODE_PWS);
 									rxState = GNSSRX_DETECT_ACK_0;
 				break;
 
-		case UART_GNSS_PWRUP:
-		case UART_GNSS_INACTIVE:	UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL);
+		case UART_GNSS_PWRUP:		UART_Gnss_SendCmd(GNSSCMD_MODE_NORMAL);
 									rxState = GNSSRX_DETECT_ACK_0;
 									gnssState = UART_GNSS_PWRUP;
 				break;
@@ -264,30 +274,25 @@
 		case GNSSRX_DETECT_ACK_3:		if((data == 0x01))
 										{
 											rxState = GNSSRX_READY;
-											if(gnssState == UART_GNSS_PWRUP)
-											{
-												gnssState = UART_GNSS_IDLE;
-											}
-											else if(gnssState == UART_GNSS_PWRDOWN)
-											{
-												rxState = GNSSRX_DETECT_ACK_0;
-												UART_Gnss_SendCmd(GNSSCMD_SET_CONFIG);
-												gnssState = UART_GNSS_SETCONF;
-											}
-											else if(gnssState == UART_GNSS_SETCONF)
+											switch(gnssState)
 											{
-												gnssState = UART_GNSS_INACTIVE;
-											}
-											else if((gnssState >= UART_GNSS_LOADCONF_0) && (gnssState <= UART_GNSS_LOADCONF_2))
-											{
-												if(gnssState == UART_GNSS_LOADCONF_2)
-												{
-													gnssState = UART_GNSS_IDLE;
-												}
-												else
-												{
-													gnssState++;
-												}
+												case UART_GNSS_PWRUP: gnssState = UART_GNSS_IDLE;
+													break;
+												case UART_GNSS_PWRDOWN:	rxState = GNSSRX_DETECT_ACK_0;
+																		UART_Gnss_SendCmd(GNSSCMD_SET_CONFIG);
+																		gnssState = UART_GNSS_SETCONF;
+													break;
+												case UART_GNSS_SETCONF:	gnssState = UART_GNSS_INACTIVE;
+													break;
+												case UART_GNSS_LOADCONF_0:
+												case UART_GNSS_LOADCONF_1:	gnssState++;
+													break;
+												case UART_GNSS_LOADCONF_2:	gnssState = UART_GNSS_SETMODE_MOBILE;
+													break;
+												case UART_GNSS_SETMODE_MOBILE: gnssState = UART_GNSS_IDLE;
+													break;
+												default:
+													break;
 											}
 											GnssConnected = 1;
 										}