Mercurial > public > ostc4
changeset 936:3029f0332f4f Evo_2_23
GNSS introduced power saving mode:
In the previous implementation the modul always did a cold start. In the new one the power saving functions of the module are activated. The module will be switched to intervall mode while entering sleep. If the computer remains in sleep for a long time then the GNSS modul will be switchen of completly.
author | Ideenmodellierer |
---|---|
date | Sun, 08 Dec 2024 22:03:07 +0100 |
parents | f2494a708f52 |
children | d461d9e89e3c |
files | Small_CPU/Inc/GNSS.h Small_CPU/Inc/uart.h Small_CPU/Inc/uartProtocol_GNSS.h Small_CPU/Src/baseCPU2.c Small_CPU/Src/scheduler.c Small_CPU/Src/uart.c Small_CPU/Src/uartProtocol_GNSS.c |
diffstat | 7 files changed, 143 insertions(+), 172 deletions(-) [+] |
line wrap: on
line diff
--- a/Small_CPU/Inc/GNSS.h Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Inc/GNSS.h Sun Dec 08 22:03:07 2024 +0100 @@ -115,12 +115,15 @@ static const uint8_t getNavSat[]={0xB5,0x62,0x01,0x35,0x00,0x00}; -static const uint8_t setPowerLow[]={0xB5,0x62,0x06,0x86,0x08,0x00,0x02,0xff,0x00,0x1E,0x00,0x00,0x00}; +static const uint8_t setPowerLow[]={0xB5,0x62,0x06,0x86,0x08,0x00,0x00,0x02,0x78,0x00,0x14,0x00,0x00,0x00}; + +static const uint8_t setPowerNormal[]={0xB5,0x62,0x06,0x86,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; static const uint8_t setPortableMode[]={0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x00,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x5E,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; static const uint8_t setPedestrianMode[]={0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x03,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x5E,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +static const uint8_t setConfig[]={0xB5,0x62,0x06,0x09,0x0D,0x00, 0x00,0x00,0x00,0x00, 0x18,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x01}; static const uint8_t setPortableType[]={}; void GNSS_Init(GNSS_StateHandle *GNSS, UART_HandleTypeDef *huart);
--- a/Small_CPU/Inc/uart.h Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Inc/uart.h Sun Dec 08 22:03:07 2024 +0100 @@ -28,7 +28,7 @@ #define BUFFER_NODATA_LOW (0x15) /* The read function needs a signiture which indicates that no data for processing is available.*/ #define BUFFER_NODATA_HIGH (0xA5) -#define TX_BUF_SIZE (40u) /* max length for commands */ +#define TX_BUF_SIZE (80u) /* max length for commands */ #define CHUNK_SIZE (80u) /* the DMA will handle chunk size transfers */ #define CHUNKS_PER_BUFFER (3u)
--- a/Small_CPU/Inc/uartProtocol_GNSS.h Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Inc/uartProtocol_GNSS.h Sun Dec 08 22:03:07 2024 +0100 @@ -37,9 +37,13 @@ UART_GNSS_IDLE, /* sensor detected and no communication pending */ UART_GNSS_ERROR, /* Error message received from sensor */ UART_GNSS_WARMUP = 10, + UART_GNSS_INACTIVE, /* no requests to the receiver */ UART_GNSS_LOADCONF_0, UART_GNSS_LOADCONF_1, UART_GNSS_LOADCONF_2, + UART_GNSS_PWRDOWN, + UART_GNSS_PWRUP, + UART_GNSS_SETCONF, /* save configuration */ UART_GNSS_GET_PVT, UART_GNSS_GET_SAT } uartGnssStatus_t; @@ -68,6 +72,9 @@ GNSSCMD_LOADCONF_0 = 0, GNSSCMD_LOADCONF_1, GNSSCMD_LOADCONF_2, + GNSSCMD_MODE_PWS, + GNSSCMD_MODE_NORMAL, + GNSSCMD_SET_CONFIG, GNSSCMD_GET_NAV_DATA, GNSSCMD_GET_PVT_DATA, GNSSCMD_GET_POSLLH_DATA, @@ -80,6 +87,7 @@ uint8_t id; } gnssRequest_s; +void uartGnss_ReqPowerDown(uint8_t request); uartGnssStatus_t uartGnss_GetState(void); void uartGnss_SetState(uartGnssStatus_t newState); void uartGnss_Control(void);
--- a/Small_CPU/Src/baseCPU2.c Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Src/baseCPU2.c Sun Dec 08 22:03:07 2024 +0100 @@ -135,6 +135,7 @@ #include "spi.h" #include "rtc.h" #include "adc.h" +#include "gpio.h" #include "compass.h" #include "pressure.h" #include "batteryGasGauge.h" @@ -144,6 +145,7 @@ #include "externalInterface.h" #include "uart.h" #include "uart_Internal.h" +#include "uartProtocol_GNSS.h" #include "GNSS.h" @@ -215,12 +217,6 @@ #define BUTTON_OSTC_HAL_RCC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() #define BUTTON_OSTC_IRQn EXTI0_IRQn -#define VIBRATION_CONTROL_PIN GPIO_PIN_3 /* PortA */ -#define LED_CONTROL_PIN_RED GPIO_PIN_2 /* PortA */ -#define LED_CONTROL_PIN_GREEN GPIO_PIN_1 /* PortA */ -#define MAINCPU_CONTROL_PIN GPIO_PIN_0 /* PortC */ -#define GPS_POWER_CONTROL_PIN GPIO_PIN_15 /* PortB */ -#define GPS_BCKP_CONTROL_PIN GPIO_PIN_14 /* PortB */ /* Private macro -------------------------------------------------------------*/ @@ -232,22 +228,6 @@ static void EXTI_Wakeup_Button_Init(void); static void EXTI_Wakeup_Button_DeInit(void); -static void GPIO_LEDs_VIBRATION_Init(void); -static void GPIO_Power_MainCPU_Init(void); -static void GPIO_Power_MainCPU_ON(void); -static void GPIO_Power_MainCPU_OFF(void); -#ifdef ENABLE_GPIO_V2 -static void GPIO_LED_RED_OFF(void); -static void GPIO_LED_RED_ON(void); -static void GPIO_LED_GREEN_OFF(void); -static void GPIO_LED_GREEN_ON(void); -static void GPIO_VIBRATION_OFF(void); -static void GPIO_VIBRATION_ON(void); -static void GPIO_GPS_OFF(void); -static void GPIO_GPS_ON(void); -static void GPIO_GPS_BCKP_OFF(void); -static void GPIO_GPS_BCKP_ON(void); -#endif #ifdef DEBUG_I2C_LINES void GPIO_test_I2C_lines(void); #endif @@ -294,6 +274,9 @@ #endif uint8_t extInterfaceActive = 0; +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + uint32_t shutdownTick = 0; +#endif HAL_Init(); SystemClock_Config(); @@ -454,33 +437,6 @@ #endif #endif -/* - * Demo code from SimpleMethod - * called 1/second - while (1) { - - if ((HAL_GetTick() - Timer) > 1000) { - GNSS_GetUniqID(&GNSS_Handle); - GNSS_ParseBuffer(&GNSS_Handle); - HAL_Delay(250); - GNSS_GetPVTData(&GNSS_Handle); - GNSS_ParseBuffer(&GNSS_Handle); - printf("Day: %d-%d-%d \r\n", GNSS_Handle.day, GNSS_Handle.month,GNSS_Handle.year); - printf("Time: %d:%d:%d \r\n", GNSS_Handle.hour, GNSS_Handle.min,GNSS_Handle.sec); - printf("Status of fix: %d \r\n", GNSS_Handle.fixType); - printf("Latitude: %f \r\n", GNSS_Handle.fLat); - printf("Longitude: %f \r\n",(float) GNSS_Handle.lon / 10000000.0); - printf("Height above ellipsoid: %d \r\n", GNSS_Handle.height); - printf("Height above mean sea level: %d \r\n", GNSS_Handle.hMSL); - printf("Ground Speed (2-D): %d \r\n", GNSS_Handle.gSpeed); - printf("Unique ID: %04X %04X %04X %04X %04X \n\r", - GNSS_Handle.uniqueID[0], GNSS_Handle.uniqueID[1], - GNSS_Handle.uniqueID[2], GNSS_Handle.uniqueID[3], - GNSS_Handle.uniqueID[4], GNSS_Handle.uniqueID[5]); - Timer = HAL_GetTick(); - } -*/ - global.mode = MODE_SURFACE; break; @@ -533,8 +489,29 @@ case MODE_SHUTDOWN: HAL_Delay(200); + + MX_SPI3_Init(); + +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + if(shutdownTick == 0) + { + shutdownTick = HAL_GetTick(); + uartGnss_ReqPowerDown(1); + } +#ifdef ENABLE_GNSS_SUPPORT + externalInterface_HandleUART(); +#else + UART6_HandleUART(); +#endif + if((uartGnss_GetState() == UART_GNSS_INACTIVE) || (time_elapsed_ms(shutdownTick,HAL_GetTick()) > 5000)) + { + global.mode = MODE_SLEEP; + } +#else global.mode = MODE_SLEEP; - MX_SPI3_Init(); +#endif + + break; case MODE_SLEEP: @@ -809,47 +786,6 @@ } */ -static void GPIO_LEDs_VIBRATION_Init(void) { - GPIO_InitTypeDef GPIO_InitStructure; - - __GPIOA_CLK_ENABLE(); - GPIO_InitStructure.Pin = LED_CONTROL_PIN_RED; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLUP; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - HAL_GPIO_Init( GPIOA, &GPIO_InitStructure); - HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET); - - GPIO_InitStructure.Pin = LED_CONTROL_PIN_GREEN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLUP; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - HAL_GPIO_Init( GPIOA, &GPIO_InitStructure); - HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET); - - GPIO_InitStructure.Pin = VIBRATION_CONTROL_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLDOWN; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - HAL_GPIO_Init( GPIOA, &GPIO_InitStructure); - HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET); - - __GPIOB_CLK_ENABLE(); - GPIO_InitStructure.Pin = GPS_POWER_CONTROL_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLUP; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - HAL_GPIO_Init( GPIOB, &GPIO_InitStructure); - HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET); - - GPIO_InitStructure.Pin = GPS_BCKP_CONTROL_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLDOWN; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - HAL_GPIO_Init( GPIOB, &GPIO_InitStructure); - HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET); -} - void GPIO_new_DEBUG_Init(void) { #ifdef DEBUG_PIN_ACTIVE GPIO_InitTypeDef GPIO_InitStructure; @@ -875,67 +811,6 @@ #endif } -static void GPIO_Power_MainCPU_Init(void) { - GPIO_InitTypeDef GPIO_InitStructure; - __GPIOC_CLK_ENABLE(); - GPIO_InitStructure.Pin = MAINCPU_CONTROL_PIN; - GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStructure.Pull = GPIO_PULLUP; - GPIO_InitStructure.Speed = GPIO_SPEED_LOW; - HAL_GPIO_Init( GPIOC, &GPIO_InitStructure); - HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET); -} - -static void GPIO_Power_MainCPU_ON(void) { - HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET); -} - -static void GPIO_Power_MainCPU_OFF(void) { - HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET); -} - -#ifdef ENABLE_GPIO_V2 -static void GPIO_LED_GREEN_ON(void) { - HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET); -} - -static void GPIO_LED_GREEN_OFF(void) { - HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_SET); -} - -static void GPIO_LED_RED_ON(void) { - HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_RESET); -} - -static void GPIO_LED_RED_OFF(void) { - HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_RED, GPIO_PIN_SET); -} - -static void GPIO_VIBRATION_ON(void) { - HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_SET); -} - -static void GPIO_VIBRATION_OFF(void) { - HAL_GPIO_WritePin( GPIOA, VIBRATION_CONTROL_PIN, GPIO_PIN_RESET); -} - -static void GPIO_GPS_ON(void) { - HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_RESET); -} - -static void GPIO_GPS_OFF(void) { - HAL_GPIO_WritePin( GPIOB, GPS_POWER_CONTROL_PIN, GPIO_PIN_SET); -} - -static void GPIO_GPS_BCKP_ON(void) { - HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_SET); -} - -static void GPIO_GPS_BCKP_OFF(void) { - HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET); -} -#endif - /** * @brief Configures EXTI Line0 (connected to PA0 + PA1 pin) in interrupt mode * @param None @@ -1023,9 +898,10 @@ GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9); /* debug */ #endif +/* GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN | GPS_BCKP_CONTROL_PIN); HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); - +*/ GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( MAINCPU_CONTROL_PIN | CHARGE_OUT_PIN | EXT33V_CONTROL_PIN); /* power off & charger in & charge out & OSC32 & ext33Volt */ HAL_GPIO_Init( GPIOC, &GPIO_InitStruct); @@ -1045,7 +921,7 @@ GPIO_LED_RED_OFF(); GPIO_VIBRATION_OFF(); GPIO_GPS_BCKP_ON(); // mH : costs 100µA in sleep - beware - GPIO_GPS_OFF(); +/* GPIO_GPS_OFF(); will be done in transition slleep => deep sleep */ MX_USART6_UART_DeInit(); #endif
--- a/Small_CPU/Src/scheduler.c Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Src/scheduler.c Sun Dec 08 22:03:07 2024 +0100 @@ -37,6 +37,7 @@ #include "rtc.h" #include "dma.h" #include "adc.h" +#include "gpio.h" #include "calc_crush.h" #include "stm32f4xx_hal_rtc_ex.h" #include "decom.h" @@ -1100,7 +1101,10 @@ global.dataSendToMaster.mode = 0; global.deviceDataSendToMaster.mode = 0; secondsCount = 0; - +#ifdef ENABLE_GPIO_V2 + uint16_t deepSleepCntDwn = 21600; /* 12 hours in 2 second steps */ + GPIO_InitTypeDef GPIO_InitStruct; +#endif /* prevent button wake up problem while in sleep_prepare * sleep prepare does I2C_DeInit() */ @@ -1179,6 +1183,22 @@ global.mode = MODE_BOOT; } scheduleUpdateLifeData(2000); +#ifdef ENABLE_GPIO_V2 + if(deepSleepCntDwn) + { + deepSleepCntDwn--; + if(deepSleepCntDwn == 0) + { + 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); + HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); + GPIO_GPS_OFF(); + uartGnss_SetState(UART_GNSS_INIT); + } + } +#endif } while(global.mode == MODE_SLEEP); /* new section for system after Standby */
--- a/Small_CPU/Src/uart.c Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Src/uart.c Sun Dec 08 22:03:07 2024 +0100 @@ -38,7 +38,7 @@ DMA_HandleTypeDef hdma_usart1_rx, hdma_usart1_tx; uint8_t rxBuffer[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */ -uint8_t txBuffer[CHUNK_SIZE]; /* tx uses less bytes */ +uint8_t txBuffer[TX_BUF_SIZE]; /* tx uses less bytes */ uint8_t txBufferQue[TX_BUF_SIZE]; /* In MUX mode command may be send shortly after each other => allow q 1 entry que */
--- a/Small_CPU/Src/uartProtocol_GNSS.c Sun Dec 08 21:59:22 2024 +0100 +++ b/Small_CPU/Src/uartProtocol_GNSS.c Sun Dec 08 22:03:07 2024 +0100 @@ -35,10 +35,9 @@ static receiveStateGnss_t rxState = GNSSRX_READY; static uint8_t GnssConnected = 0; /* Binary indicator if a sensor is connected or not */ - static uint8_t writeIndex = 0; - static uint8_t dataToRead = 0; +static uint8_t ReqPowerDown = 0; void ConvertByteToHexString(uint8_t byte, char* str) { @@ -63,6 +62,13 @@ } } +void uartGnss_ReqPowerDown(uint8_t request) +{ + if(GnssConnected) + { + ReqPowerDown = 1; + } +} uartGnssStatus_t uartGnss_GetState() { @@ -98,6 +104,15 @@ case GNSSCMD_GET_NAVSAT_DATA: pData = getNavSat; txLength = sizeof(getNavSat) / sizeof(uint8_t); break; + case GNSSCMD_MODE_PWS: pData = setPowerLow; + txLength = sizeof(setPowerLow) / sizeof(uint8_t); + break; + case GNSSCMD_MODE_NORMAL: pData = setPowerNormal; + txLength = sizeof(setPowerNormal) / sizeof(uint8_t); + break; + case GNSSCMD_SET_CONFIG: pData = setConfig; + txLength = sizeof(setConfig) / sizeof(uint8_t); + break; default: break; } @@ -115,7 +130,6 @@ static uint8_t dataToggle = 0; uint8_t activeSensor = 0; sUartComCtrl* pUartCtrl = UART_GetGnssCtrl(); -// uartGnssStatus_t localComState; if(pUartCtrl == &Uart1Ctrl) { @@ -143,19 +157,41 @@ case UART_GNSS_LOADCONF_2: UART_Gnss_SendCmd(GNSSCMD_LOADCONF_2); rxState = GNSSRX_DETECT_ACK_0; break; - case UART_GNSS_IDLE: if(dataToggle) + 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); + rxState = GNSSRX_DETECT_ACK_0; + gnssState = UART_GNSS_PWRUP; + break; + case UART_GNSS_SETCONF: UART_Gnss_SendCmd(GNSSCMD_SET_CONFIG); + rxState = GNSSRX_DETECT_ACK_0; + break; + + case UART_GNSS_IDLE: if(ReqPowerDown) { - UART_Gnss_SendCmd(GNSSCMD_GET_PVT_DATA); - gnssState = UART_GNSS_GET_PVT; - rxState = GNSSRX_DETECT_HEADER_0; - dataToggle = 0; + UART_Gnss_SendCmd(GNSSCMD_MODE_PWS); + gnssState = UART_GNSS_PWRDOWN; + rxState = GNSSRX_DETECT_ACK_0; } else { - UART_Gnss_SendCmd(GNSSCMD_GET_NAVSAT_DATA); - gnssState = UART_GNSS_GET_SAT; - rxState = GNSSRX_DETECT_HEADER_0; - dataToggle = 1; + if(dataToggle) + { + UART_Gnss_SendCmd(GNSSCMD_GET_PVT_DATA); + gnssState = UART_GNSS_GET_PVT; + rxState = GNSSRX_DETECT_HEADER_0; + dataToggle = 0; + } + else + { + UART_Gnss_SendCmd(GNSSCMD_GET_NAVSAT_DATA); + gnssState = UART_GNSS_GET_SAT; + rxState = GNSSRX_DETECT_HEADER_0; + dataToggle = 1; + } } break; default: @@ -168,6 +204,7 @@ } + void uartGnss_ProcessData(uint8_t data) { static uint16_t rxLength = 0; @@ -175,6 +212,15 @@ static uint8_t ck_B = 0; static uint8_t ck_A_Ref = 0; static uint8_t ck_B_Ref = 0; + uint8_t activeSensor = 0; + + sUartComCtrl* pUartCtrl = UART_GetGnssCtrl(); + + if(pUartCtrl == &Uart1Ctrl) + { + activeSensor = externalInterface_GetActiveUartSensor(); + gnssState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET); + } GNSS_Handle.uartWorkingBuffer[writeIndex++] = data; if((rxState >= GNSSRX_DETECT_HEADER_2) && (rxState < GNSSRX_READ_CK_A)) @@ -217,7 +263,22 @@ break; case GNSSRX_DETECT_ACK_3: if((data == 0x01)) { - if((gnssState >= UART_GNSS_LOADCONF_0) && (gnssState <= UART_GNSS_LOADCONF_2)) + 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) + { + gnssState = UART_GNSS_INACTIVE; + } + else if((gnssState >= UART_GNSS_LOADCONF_0) && (gnssState <= UART_GNSS_LOADCONF_2)) { if(gnssState == UART_GNSS_LOADCONF_2) { @@ -229,7 +290,6 @@ } } GnssConnected = 1; - rxState = GNSSRX_READY; } else { @@ -293,6 +353,10 @@ default: rxState = GNSSRX_READY; break; } + if(pUartCtrl == &Uart1Ctrl) + { + externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,gnssState); + } } uint8_t uartGnss_isSensorConnected()