Mercurial > public > ostc4
changeset 988:d9290c76b840 GasConsumption tip
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 (4 hours ago) |
parents | 41136649b90d |
children | |
files | Discovery/Src/data_exchange_main.c Discovery/Src/logbook.c Discovery/Src/show_logbook.c Discovery/Src/t7.c Discovery/Src/tMenuCustom.c Discovery/Src/tMenuEditCustom.c Discovery/Src/tMenuEditSystem.c Small_CPU/Inc/externalInterface.h Small_CPU/Inc/gpio.h Small_CPU/Inc/uart.h Small_CPU/Src/baseCPU2.c Small_CPU/Src/externalInterface.c Small_CPU/Src/gpio.c Small_CPU/Src/scheduler.c Small_CPU/Src/stm32f4xx_it_v3.c Small_CPU/Src/uart.c Small_CPU/Src/uartProtocol_GNSS.c |
diffstat | 17 files changed, 175 insertions(+), 128 deletions(-) [+] |
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/data_exchange_main.c Sun Apr 06 21:02:17 2025 +0200 @@ -412,7 +412,7 @@ break; case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1; break; -#if defined ENABLE_GPIO_V2 || defined ENABLE_GNSS_SUPPORT +#if defined ENABLE_GNSS_INTERNAL || defined ENABLE_GNSS_EXTERN case SENSOR_GNSS: SensorActive[SENSOR_GNSS] = 1; break; #endif @@ -442,12 +442,10 @@ } #endif -#ifdef ENABLE_GPIO_V2 - if(getBuzzerActivationState()) + if((isNewDisplay()) && getBuzzerActivationState()) { externalInterface_Cmd |= EXT_INTERFACE_BUZZER_ON; } -#endif dataOut.data.externalInterface_Cmd = externalInterface_Cmd; externalInterface_Cmd = 0; @@ -468,7 +466,11 @@ dataOut.revisionHardware = 0xFF; dataOut.revisionCRCx0x7A = 0xFF; } - + if(isNewDisplay()) + { + dataOut.displayVersion = 1; + } + if(DataEX_check_header_and_footer_ok() && !told_reset_logik_alles_ok) { MX_tell_reset_logik_alles_ok();
--- a/Discovery/Src/logbook.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/logbook.c Sun Apr 06 21:02:17 2025 +0200 @@ -1361,7 +1361,7 @@ ext_flash_CloseSector(); /* this is just a repair function which invalidates a not used sector in case a log maintenance was called before dive */ bDiveMode = 3; -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN pStateReal->events.gnssPositionUpdate = 1; if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_BACKUP_POS)
--- a/Discovery/Src/show_logbook.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/show_logbook.c Sun Apr 06 21:02:17 2025 +0200 @@ -466,7 +466,7 @@ Gfx_write_label_var(hgfx, 30, 250,10, &FontT42,CLUT_GasSensor1,text); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN if((posCoord.fLat != 0.0) || (posCoord.fLon != 0.0)) { snprintf(text, 20, "%2.4f - %2.4f", posCoord.fLat, posCoord.fLon );
--- a/Discovery/Src/t7.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/t7.c Sun Apr 06 21:02:17 2025 +0200 @@ -139,7 +139,7 @@ CVIEW_Charger, CVIEW_CcrSummary, CVIEW_Timer, -#if defined ENABLE_GPIO_V2 || defined ENABLE_GNSS_SUPPORT +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN CVIEW_Position, #endif CVIEW_END
--- a/Discovery/Src/tMenuCustom.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/tMenuCustom.c Sun Apr 06 21:02:17 2025 +0200 @@ -119,10 +119,9 @@ textPointer += 2; #endif -#ifdef ENABLE_GPIO_V2 - if((line == 0) || (line == 5)) + + if((isNewDisplay()) && ((line == 0) || (line == 5))) { - /* MotionCtrl */ text[textPointer++] = TXT_2BYTE; text[textPointer++] = TXT2BYTE_BUZZER; text[textPointer++] = ' '; @@ -136,7 +135,6 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; -#endif return StMCustom; }
--- a/Discovery/Src/tMenuEditCustom.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/tMenuEditCustom.c Sun Apr 06 21:02:17 2025 +0200 @@ -40,6 +40,7 @@ #include "motion.h" #include "tMenu.h" #include "tMenuSystem.h" +#include "ostc.h" #include <math.h> @@ -379,10 +380,11 @@ case 5: openEdit_ViewPort(); break; #endif -#ifdef ENABLE_GPIO_V2 - case 5: openEdit_WarningBuz(); + case 5: if(isNewDisplay()) + { + openEdit_WarningBuz(); + } break; -#endif } } @@ -480,6 +482,7 @@ if(pSettings->warningBuzzer == 0) { pSettings->warningBuzzer = 1; + requestBuzzerActivation(1); } else {
--- a/Discovery/Src/tMenuEditSystem.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Discovery/Src/tMenuEditSystem.c Sun Apr 06 21:02:17 2025 +0200 @@ -247,7 +247,7 @@ char formatStr[20]; SSettings *pSettings; const SFirmwareData *pFirmwareInfo; -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN uint8_t localHours = 0; uint8_t localMinutes = 0; #endif @@ -285,7 +285,7 @@ write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN write_label_var( 20, 340, ME_Y_LINE5, &FontT42, "GNSS"); snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_TIMEZONE); write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); @@ -307,7 +307,7 @@ } tMenuEdit_newButtonText(StMSYS1_FORMAT, formatStr); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_STATE_TIME) { convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); @@ -373,7 +373,7 @@ write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN write_label_var( 20, 340, ME_Y_LINE5, &FontT42, "GNSS"); snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_TIMEZONE); write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); @@ -395,7 +395,7 @@ write_field_button(StMSYS1_FORMAT, 320, 790, ME_Y_LINE4, &FontT48, formatStr); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN snprintf(text, 32, "--:--"); write_field_button(StMSYS1_GNSSDT, 320, 790, ME_Y_LINE5, &FontT48, text); write_field_sdigit(StMSYS1_ZONE, 320, 780, ME_Y_LINE6, &FontT48, "UTC: ###:###", pSettings->timeZone.hours, pSettings->timeZone.minutes,0,0); @@ -405,7 +405,7 @@ setEvent(StMSYS1_Time, (uint32_t)OnAction_Time); setEvent(StMSYS1_12HR, (uint32_t)OnAction_12HR); setEvent(StMSYS1_FORMAT, (uint32_t)OnAction_Format); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN setEvent(StMSYS1_GNSSDT, (uint32_t)OnAction_SetGnss); setEvent(StMSYS1_ZONE, (uint32_t)OnAction_UTC); #endif
--- a/Small_CPU/Inc/externalInterface.h Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Inc/externalInterface.h Sun Apr 06 21:02:17 2025 +0200 @@ -72,7 +72,7 @@ DETECTION_CO2_2, DETECTION_CO2_3, #endif -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN DETECTION_GNSS_0, /* check UART channel for connected gnss sensor */ DETECTION_GNSS_1, DETECTION_GNSS_2,
--- a/Small_CPU/Inc/gpio.h Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Inc/gpio.h Sun Apr 06 21:02:17 2025 +0200 @@ -38,7 +38,7 @@ void GPIO_Power_MainCPU_ON(void); void GPIO_Power_MainCPU_OFF(void); -#ifdef ENABLE_GPIO_V2 + void GPIO_LED_RED_OFF(void); void GPIO_LED_RED_ON(void); void GPIO_LED_GREEN_OFF(void); @@ -50,11 +50,12 @@ void GPIO_GPS_BCKP_OFF(void); void GPIO_GPS_BCKP_ON(void); +uint8_t GPIO_GetVersion(void); +void GPIO_Activate_V2(void); void GPIO_HandleBuzzer(); #endif #ifdef __cplusplus } -#endif #endif /* GPIO_H */
--- a/Small_CPU/Inc/uart.h Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Inc/uart.h Sun Apr 06 21:02:17 2025 +0200 @@ -68,7 +68,7 @@ void DigitalCO2_SendCmd(uint8_t CO2Cmd, uint8_t *cmdString, uint8_t *cmdLength); #endif -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN void UART_HandleGnssData(void); #endif #ifdef ENABLE_SENTINEL_MODE
--- 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 /*
--- a/Small_CPU/Src/externalInterface.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Src/externalInterface.c Sun Apr 06 21:02:17 2025 +0200 @@ -401,7 +401,7 @@ #ifdef ENABLE_CO2_SUPPORT || ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3)) #endif -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN || ((externalAutoDetect >= DETECTION_GNSS_0) && (externalAutoDetect <= DETECTION_GNSS_3)) #endif @@ -672,7 +672,7 @@ { static uint8_t sensorIndex = 0; static uint8_t uartMuxChannel = 0; -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN static uint8_t detectionDelayCnt = 0; #endif uint8_t index = 0; @@ -829,7 +829,7 @@ case DETECTION_CO2_3: if(uartCo2_isSensorConnected()) { foundSensorMap[EXT_INTERFACE_MUX_OFFSET + activeUartChannel] = SENSOR_CO2; -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN externalAutoDetect = DETECTION_GNSS_0; /* only one CO2 sensor supported */ #else externalAutoDetect = DETECTION_DONE; /* only one CO2 sensor supported */ @@ -852,8 +852,8 @@ { -#if defined ENABLE_SENTINEL_MODE || defined ENABLE_GNSS_SUPPORT -#ifdef ENABLE_GNSS_SUPPORT +#if defined ENABLE_SENTINEL_MODE || defined ENABLE_GNSS_EXTERN +#ifdef ENABLE_GNSS_EXTERN externalAutoDetect = DETECTION_GNSS_0; externalInterface_SwitchUART(EXT_INTERFACE_UART_GNSS); #else @@ -867,7 +867,7 @@ } #endif -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN if(externalAutoDetect == DETECTION_GNSS_0) { tmpSensorMap[uartMuxChannel + EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE; @@ -1251,7 +1251,7 @@ case SENSOR_CO2: uartCo2_Control(); break; #endif -#ifdef ENABLE_GNSS_SUPPORT +#ifdef ENABLE_GNSS_EXTERN case SENSOR_GNSS: uartGnss_Control(); break; #endif
--- a/Small_CPU/Src/gpio.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Src/gpio.c Sun Apr 06 21:02:17 2025 +0200 @@ -25,10 +25,12 @@ #include "gpio.h" #include "data_exchange.h" #include "scheduler.h" +#include "uart_internal.h" +#include "GNSS.h" /* Exported variables --------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ - +static uint8_t GPIO_Version = 0; /* Private types -------------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ @@ -91,7 +93,6 @@ HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET); } -#ifdef ENABLE_GPIO_V2 void GPIO_HandleBuzzer() { static uint32_t buzzerOnTick = 0; @@ -124,7 +125,7 @@ buzzerWasOn = 0; } } -#endif + void GPIO_Power_MainCPU_ON(void) { HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_RESET); } @@ -133,7 +134,6 @@ HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET); } -#ifdef ENABLE_GPIO_V2 void GPIO_LED_GREEN_ON(void) { HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET); } @@ -173,8 +173,25 @@ void GPIO_GPS_BCKP_OFF(void) { HAL_GPIO_WritePin( GPIOB, GPS_BCKP_CONTROL_PIN, GPIO_PIN_RESET); } + +uint8_t GPIO_GetVersion() +{ + return GPIO_Version; +} + +void GPIO_Activate_V2(void) +{ + GPIO_Version = 1; + GPIO_LEDs_VIBRATION_Init(); + +#ifdef ENABLE_GNSS_INTERN + GNSS_IO_init(); + GPIO_GPS_ON(); + GPIO_GPS_BCKP_ON(); + MX_USART6_UART_Init(); + GNSS_Init(&GNSS_Handle, &huart6); #endif - +} /* Private functions ---------------------------------------------------------*/
--- a/Small_CPU/Src/scheduler.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Src/scheduler.c Sun Apr 06 21:02:17 2025 +0200 @@ -342,9 +342,16 @@ { externalInterface_ExecuteCmd(global.dataSendToSlave.data.externalInterface_Cmd); } -#ifdef ENABLE_GPIO_V2 - GPIO_HandleBuzzer(); -#endif + + if(GPIO_GetVersion() < global.dataSendToSlave.displayVersion) + { + GPIO_Activate_V2(); + } + + if(GPIO_GetVersion() > 0) + { + GPIO_HandleBuzzer(); + } #if 0 @@ -533,8 +540,11 @@ ticksdiff = time_elapsed_ms(Scheduler.tickstart,lasttick); externalInterface_HandleUART(); -#ifdef ENABLE_GPIO_V2 - UART6_HandleUART(); +#ifdef ENABLE_GNSS_INTERN + if(GPIO_GetVersion() > 0) + { + UART6_HandleUART(); + } #endif if(ticksdiff >= Scheduler.counterSPIdata100msec * 100 + 10) { @@ -838,8 +848,11 @@ } externalInterface_HandleUART(); -#ifdef ENABLE_GPIO_V2 - UART6_HandleUART(); +#ifdef ENABLE_GNSS_INTERN + if(GPIO_GetVersion() > 0) + { + UART6_HandleUART(); + } #endif /* Evaluate received data at 10 ms, 110 ms, 210 ms,... duration ~<1ms */ @@ -893,7 +906,7 @@ adc_ambient_light_sensor_get_data(); copyAmbientLightData(); -#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN copyGNSSdata(); #endif Scheduler.counterAmbientLight100msec++; @@ -1110,7 +1123,7 @@ global.dataSendToMaster.mode = 0; global.deviceDataSendToMaster.mode = 0; secondsCount = 0; -#ifdef ENABLE_GPIO_V2 +#ifdef ENABLE_GNSS_INTERN uint16_t deepSleepCntDwn = 21600; /* 12 hours in 2 second steps */ uint8_t deepSleep = 0; GPIO_InitTypeDef GPIO_InitStruct; @@ -1191,31 +1204,34 @@ global.mode = MODE_BOOT; } scheduleUpdateLifeData(2000); -#ifdef ENABLE_GPIO_V2 - if(deepSleepCntDwn) +#ifdef ENABLE_GNSS_INTER + if(GPIO_GetVersion() > 0) { - deepSleepCntDwn--; - if(deepSleepCntDwn == 0) + if(deepSleepCntDwn) { - deepSleep = 1; - GPIO_GPS_OFF(); - 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); - HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); - uartGnss_SetState(UART_GNSS_INIT); + deepSleepCntDwn--; + if(deepSleepCntDwn == 0) + { + deepSleep = 1; + GPIO_GPS_OFF(); + 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); + HAL_GPIO_Init( GPIOB, &GPIO_InitStruct); + uartGnss_SetState(UART_GNSS_INIT); + } } - } - else - { - if((deepSleep = 1) && (global.lifeData.battery_voltage < 3.5)) /* switch off backup voltage if battery gets low */ + else { - deepSleep = 2; - 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(); + if((deepSleep = 1) && (global.lifeData.battery_voltage < 3.5)) /* switch off backup voltage if battery gets low */ + { + deepSleep = 2; + 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(); + } } } #endif @@ -1227,10 +1243,13 @@ setButtonsNow = 0; reinitGlobals(); ReInit_battery_charger_status_pins(); -#ifdef ENABLE_GPIO_V2 - if(deepSleep != 0) +#ifdef ENABLE_GNSS_INTERN + if(GPIO_GetVersion() > 0) { - GPIO_GNSS_Init(); + if(deepSleep != 0) + { + GPIO_GNSS_Init(); + } } #endif }
--- a/Small_CPU/Src/stm32f4xx_it_v3.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Src/stm32f4xx_it_v3.c Sun Apr 06 21:02:17 2025 +0200 @@ -61,9 +61,11 @@ extern UART_HandleTypeDef huart1; extern DMA_HandleTypeDef hdma_usart1_rx; extern DMA_HandleTypeDef hdma_usart1_tx; +#ifdef ENABLE_GNSS_INTERN extern UART_HandleTypeDef huart6; extern DMA_HandleTypeDef hdma_usart6_rx; extern DMA_HandleTypeDef hdma_usart6_tx; +#endif /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ @@ -249,7 +251,7 @@ HAL_DMA_IRQHandler(&hdma_usart1_tx); } -#ifdef ENABLE_GPIO_V2 +#ifdef ENABLE_GNSS_INTERN void DMA2_Stream2_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_usart6_rx); @@ -327,7 +329,7 @@ HAL_UART_IRQHandler(&huart1); } -#ifdef ENABLE_GPIO_V2 +#ifdef ENABLE_GNSS_INTERN void USART6_IRQHandler(void) { HAL_UART_IRQHandler(&huart6);
--- a/Small_CPU/Src/uart.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Src/uart.c Sun Apr 06 21:02:17 2025 +0200 @@ -28,7 +28,7 @@ #include "data_exchange.h" #include <string.h> /* memset */ -#ifdef ENABLE_GPIO_V2 +#ifdef ENABLE_GNSS_INTERN extern UART_HandleTypeDef huart6; extern sUartComCtrl Uart6Ctrl; #endif @@ -104,9 +104,11 @@ Uart1Ctrl.pTxBuffer = txBuffer; Uart1Ctrl.txBufferQueLen = 0; -#ifndef ENABLE_GPIO_V2 +#ifndef ENABLE_GNSS_INTERN +#ifdef ENABLE_GNSS_EXTERN UART_SetGnssCtrl(&Uart1Ctrl); #endif +#endif } @@ -337,10 +339,13 @@ { UART_HandleRxComplete(&Uart1Ctrl); } -#ifdef ENABLE_GPIO_V2 - if(huart == &huart6) +#ifdef ENABLE_GNSS_INTERN + if(GPIO_GetVersion() > 0) { - UART_HandleRxComplete(&Uart6Ctrl); + if(huart == &huart6) + { + UART_HandleRxComplete(&Uart6Ctrl); + } } #endif } @@ -363,10 +368,13 @@ { UART_HandleTxComplete(&Uart1Ctrl); } -#ifdef ENABLE_GPIO_V2 - if(huart == &huart6) +#ifdef ENABLE_GNSS_INTERN + if(GPIO_GetVersion() > 0) { - UART_HandleTxComplete(&Uart6Ctrl); + if(huart == &huart6) + { + UART_HandleTxComplete(&Uart6Ctrl); + } } #endif } @@ -401,11 +409,13 @@ if(sensorType == SENSOR_GNSS) { -#ifdef ENABLE_GPIO_V2 +#ifdef ENABLE_GNSS_INTERN pUartCtrl = &Uart6Ctrl; #else +#ifdef ENABLE_GNSS_EXTERN pUartCtrl = &Uart1Ctrl; #endif +#endif } else { @@ -438,7 +448,7 @@ case SENSOR_CO2: uartCo2_ProcessData(pUartCtrl->pRxBuffer[localRX]); break; #endif - #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + #if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN case SENSOR_GNSS: uartGnss_ProcessData(pUartCtrl->pRxBuffer[localRX]); break; #endif
--- a/Small_CPU/Src/uartProtocol_GNSS.c Sat Mar 29 14:56:08 2025 +0100 +++ b/Small_CPU/Src/uartProtocol_GNSS.c Sun Apr 06 21:02:17 2025 +0200 @@ -28,7 +28,7 @@ #include "externalInterface.h" -#if defined ENABLE_GNSS || defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 +#if defined ENABLE_GNSS_INTERN || defined ENABLE_GNSS_EXTERN static uartGnssStatus_t gnssState = UART_GNSS_INIT; static gnssRequest_s activeRequest = {0,0};