comparison Small_CPU/Src/baseCPU2.c @ 938:df87dbfc9c21 Evo_2_23

Update GPIO: Splitted the init function and moved GPS deactivation into the sleep loop (deep sleep)
author Ideenmodellierer
date Tue, 10 Dec 2024 21:00:55 +0100
parents 3029f0332f4f
children 4a406e873a95
comparison
equal deleted inserted replaced
937:d461d9e89e3c 938:df87dbfc9c21
145 #include "externalInterface.h" 145 #include "externalInterface.h"
146 #include "uart.h" 146 #include "uart.h"
147 #include "uart_Internal.h" 147 #include "uart_Internal.h"
148 #include "uartProtocol_GNSS.h" 148 #include "uartProtocol_GNSS.h"
149 #include "GNSS.h" 149 #include "GNSS.h"
150 #include "configuration.h"
150 151
151 152
152 // From Common/Inc: 153 // From Common/Inc:
153 #include "calc_crush.h" 154 #include "calc_crush.h"
154 #include "decom.h" 155 #include "decom.h"
285 HAL_SYSTICK_CLKSourceConfig( SYSTICK_CLKSOURCE_HCLK); 286 HAL_SYSTICK_CLKSourceConfig( SYSTICK_CLKSOURCE_HCLK);
286 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 287 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
287 288
288 MX_RTC_init(); 289 MX_RTC_init();
289 GPIO_LEDs_VIBRATION_Init(); 290 GPIO_LEDs_VIBRATION_Init();
291 GPIO_GNSS_Init();
290 GPIO_new_DEBUG_Init(); // added 170322 hw 292 GPIO_new_DEBUG_Init(); // added 170322 hw
291 initGlobals(); 293 initGlobals();
292 294
293 /* printf("CPU2-RTE running...\n"); */ 295 /* printf("CPU2-RTE running...\n"); */
294 296
504 UART6_HandleUART(); 506 UART6_HandleUART();
505 #endif 507 #endif
506 if((uartGnss_GetState() == UART_GNSS_INACTIVE) || (time_elapsed_ms(shutdownTick,HAL_GetTick()) > 5000)) 508 if((uartGnss_GetState() == UART_GNSS_INACTIVE) || (time_elapsed_ms(shutdownTick,HAL_GetTick()) > 5000))
507 { 509 {
508 global.mode = MODE_SLEEP; 510 global.mode = MODE_SLEEP;
511 uartGnss_ReqPowerDown(0); /* release power down request */
509 } 512 }
510 #else 513 #else
511 global.mode = MODE_SLEEP; 514 global.mode = MODE_SLEEP;
512 #endif 515 #endif
513 516
892 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 895 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
893 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; 896 GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
894 GPIO_InitStruct.Pull = GPIO_NOPULL; 897 GPIO_InitStruct.Pull = GPIO_NOPULL;
895 GPIO_InitStruct.Pin = GPIO_PIN_All; 898 GPIO_InitStruct.Pin = GPIO_PIN_All;
896 HAL_GPIO_Init( GPIOH, &GPIO_InitStruct); 899 HAL_GPIO_Init( GPIOH, &GPIO_InitStruct);
897 #ifdef DEBUGMODE 900 #ifdef ENABLE_SLEEP_DEBUG
898 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9); /* debug */ 901 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9); /* debug */
899 #endif 902 #endif
900 903
901 /* 904 /*
902 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN | GPS_BCKP_CONTROL_PIN); 905 GPIO_InitStruct.Pin = GPIO_PIN_All ^ (GPS_POWER_CONTROL_PIN | GPS_BCKP_CONTROL_PIN);
905 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( MAINCPU_CONTROL_PIN | CHARGE_OUT_PIN | EXT33V_CONTROL_PIN); /* power off & charger in & charge out & OSC32 & ext33Volt */ 908 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( MAINCPU_CONTROL_PIN | CHARGE_OUT_PIN | EXT33V_CONTROL_PIN); /* power off & charger in & charge out & OSC32 & ext33Volt */
906 909
907 HAL_GPIO_Init( GPIOC, &GPIO_InitStruct); 910 HAL_GPIO_Init( GPIOC, &GPIO_InitStruct);
908 911
909 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | VIBRATION_CONTROL_PIN | LED_CONTROL_PIN_RED | LED_CONTROL_PIN_GREEN); 912 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | VIBRATION_CONTROL_PIN | LED_CONTROL_PIN_RED | LED_CONTROL_PIN_GREEN);
910 #ifdef DEBUGMODE 913 #ifdef ENABLE_SLEEP_DEBUG
911 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | GPIO_PIN_13 | GPIO_PIN_14); /* wake up button & debug */ 914 GPIO_InitStruct.Pin = GPIO_PIN_All ^ ( GPIO_PIN_0 | GPIO_PIN_13 | GPIO_PIN_14); /* wake up button & debug */
912 #endif 915 #endif
913 HAL_GPIO_Init( GPIOA, &GPIO_InitStruct); 916 HAL_GPIO_Init( GPIOA, &GPIO_InitStruct);
914 917
915 GPIO_InitStruct.Pin = GPIO_PIN_All; 918 GPIO_InitStruct.Pin = GPIO_PIN_All;
919 #ifdef ENABLE_GPIO_V2 922 #ifdef ENABLE_GPIO_V2
920 GPIO_LED_GREEN_OFF(); 923 GPIO_LED_GREEN_OFF();
921 GPIO_LED_RED_OFF(); 924 GPIO_LED_RED_OFF();
922 GPIO_VIBRATION_OFF(); 925 GPIO_VIBRATION_OFF();
923 GPIO_GPS_BCKP_ON(); // mH : costs 100µA in sleep - beware 926 GPIO_GPS_BCKP_ON(); // mH : costs 100µA in sleep - beware
924 /* GPIO_GPS_OFF(); will be done in transition slleep => deep sleep */ 927 /* GPIO_GPS_OFF(); will be done in transition sleep => deep sleep */
925 928
926 MX_USART6_UART_DeInit(); 929 MX_USART6_UART_DeInit();
927 #endif 930 #endif
928 #ifndef DEBUGMODE 931 #ifndef ENABLE_SLEEP_DEBUG
932 /*
929 __HAL_RCC_GPIOB_CLK_DISABLE(); 933 __HAL_RCC_GPIOB_CLK_DISABLE();
934 */
930 #endif 935 #endif
931 __HAL_RCC_GPIOH_CLK_DISABLE(); 936 __HAL_RCC_GPIOH_CLK_DISABLE();
932 937
933 HAL_Delay(1000); 938 HAL_Delay(1000);
934 } 939 }