comparison Discovery/Src/base.c @ 300:5ca177d2df5d cleanup-4

cleanup: remove commented/unused code, make static without any functional change. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Fri, 17 May 2019 21:19:04 +0200
parents 74a8296a2318
children 84f5c18b74ea e309f78f89a5
comparison
equal deleted inserted replaced
299:b70c26be71a0 300:5ca177d2df5d
204 #include "ostc.h" 204 #include "ostc.h"
205 #include "base.h" 205 #include "base.h"
206 #include "display.h" 206 #include "display.h"
207 #include "gfx_engine.h" 207 #include "gfx_engine.h"
208 #include "show_logbook.h" 208 #include "show_logbook.h"
209 //#include "test_vpm.h"
210 #include "text_multilanguage.h" 209 #include "text_multilanguage.h"
211 #include "tHome.h" 210 #include "tHome.h"
212 #include "tInfo.h" 211 #include "tInfo.h"
213 #include "tInfoLog.h" 212 #include "tInfoLog.h"
214 #include "tMenu.h" 213 #include "tMenu.h"
215 #include "tMenuEdit.h" 214 #include "tMenuEdit.h"
216 #include "tMenuEditGasOC.h" 215 #include "tMenuEditGasOC.h"
217 #include "tStructure.h" 216 #include "tStructure.h"
218 //#include "gfx_specialeffects.h"
219 #include "externLogbookFlash.h" 217 #include "externLogbookFlash.h"
220 #include "tComm.h" 218 #include "tComm.h"
221 #include "tCCR.h" 219 #include "tCCR.h"
222 #include "data_exchange.h" 220 #include "data_exchange.h"
223 #include "data_exchange_main.h" 221 #include "data_exchange_main.h"
248 246
249 //#define NO_TIMEOUT 247 //#define NO_TIMEOUT
250 //#define QUICK_SLEEP 248 //#define QUICK_SLEEP
251 249
252 /* Private define ------------------------------------------------------------*/ 250 /* Private define ------------------------------------------------------------*/
253 //#define BUFFER_SIZE ((uint32_t)0x00177000)
254 //#define WRITE_READ_ADDR ((uint32_t)0x0000)
255 #define REFRESH_COUNT ((uint32_t)0x0569) /**< for SDRAM refresh counter (90Mhz SD clock) */ 251 #define REFRESH_COUNT ((uint32_t)0x0569) /**< for SDRAM refresh counter (90Mhz SD clock) */
256 #define INVALID_BUTTON ((uint8_t) 0xFF) 252 #define INVALID_BUTTON ((uint8_t) 0xFF)
257 /* Private macro -------------------------------------------------------------*/ 253 /* Private macro -------------------------------------------------------------*/
258 /* Private variables ---------------------------------------------------------*/ 254 /* Private variables ---------------------------------------------------------*/
259 255
260 RTC_HandleTypeDef RtcHandle; /* used to change time and date, no RTC is running on this MCU */ 256 static RTC_HandleTypeDef RtcHandle; /* used to change time and date, no RTC is running on this MCU */
261 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */ 257 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */
262 TIM_HandleTypeDef TimBacklightHandle; /* used in stm32f4xx_it.c too */ 258 static TIM_HandleTypeDef TimBacklightHandle;
263 #ifdef DEMOMODE 259 #ifdef DEMOMODE
264 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */ 260 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */
265 #endif 261 #endif
266 262
267 uint8_t LastButtonPressed; 263 static uint8_t LastButtonPressed;
268 uint32_t LastButtonPressedTick; 264 static uint32_t LastButtonPressedTick;
269 uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ 265 static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */
270
271 /*
272 uint32_t time_before;
273 uint32_t time_between;
274 uint32_t time_after;
275 */
276 266
277 /* SDRAM handler declaration */ 267 /* SDRAM handler declaration */
278 SDRAM_HandleTypeDef hsdram; 268 static SDRAM_HandleTypeDef hsdram;
279 FMC_SDRAM_TimingTypeDef SDRAM_Timing; 269 static FMC_SDRAM_TimingTypeDef SDRAM_Timing;
280 FMC_SDRAM_CommandTypeDef command; 270 static FMC_SDRAM_CommandTypeDef command;
281 271
282 /* This was used for Dual Boot */ 272 /* This was used for Dual Boot */
283 //FLASH_OBProgramInitTypeDef OBInit; 273 //FLASH_OBProgramInitTypeDef OBInit;
284 //FLASH_AdvOBProgramInitTypeDef AdvOBInit; 274 //FLASH_AdvOBProgramInitTypeDef AdvOBInit;
285 275
286 /* Private variables with external access ------------------------------------*/ 276 /* Private variables with external access ------------------------------------*/
287 277
288 uint32_t globalStateID = 0; 278 static uint32_t globalStateID = 0;
289 uint8_t globalModeID = SURFMODE; 279 static uint32_t time_without_button_pressed_deciseconds = 0; /**< langbeschreibung (eigenes Feld) warum diese variable verwendet wird um den sleepmode zu aktivieren */
290 uint32_t time_without_button_pressed_deciseconds = 0; /**< langbeschreibung (eigenes Feld) warum diese variable verwendet wird um den sleepmode zu aktivieren */
291 uint8_t bootToBootloader = 0; ///< set in tComm.c to install firmware updates, calls resetToFirmwareUpdate() 280 uint8_t bootToBootloader = 0; ///< set in tComm.c to install firmware updates, calls resetToFirmwareUpdate()
292 //uint8_t dataEx_VPM_call = 0; 281 static uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit()
293 uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit()
294 uint32_t base_tempLightLevel = 0; 282 uint32_t base_tempLightLevel = 0;
295 uint8_t updateButtonsToDefault = 0; 283 static uint8_t wasFirmwareUpdateCheckBattery = 0;
296 uint8_t wasFirmwareUpdateCheckBattery = 0;
297
298 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */ 284 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */
299 285
300 /* Private function prototypes -----------------------------------------------*/ 286 /* Private function prototypes -----------------------------------------------*/
301 static void SystemClock_Config(void); 287 static void SystemClock_Config(void);
302 static void Error_Handler(void); 288 static void Error_Handler(void);
353 RTC_TimeTypeDef Stime; 339 RTC_TimeTypeDef Stime;
354 uint8_t measurementindex = 0; 340 uint8_t measurementindex = 0;
355 uint8_t lastsecond = 0xFF; 341 uint8_t lastsecond = 0xFF;
356 #endif 342 #endif
357 343
358
359 set_globalState( StBoot0 ); 344 set_globalState( StBoot0 );
360 LastButtonPressed = 0; 345 LastButtonPressed = 0;
361 346
362 HAL_Init(); 347 HAL_Init();
363 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 ); 348 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 );
380 wasFirmwareUpdateCheckBattery = 1; 365 wasFirmwareUpdateCheckBattery = 1;
381 set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values 366 set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values
382 } 367 }
383 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */ 368 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */
384 //settingsGetPointer()->compassBearing = 0; 369 //settingsGetPointer()->compassBearing = 0;
385 set_new_settings_missing_in_ext_flash(); // inlcudes update of firmware version 161121 370 set_new_settings_missing_in_ext_flash(); // includes update of firmware version 161121
386 371
387 GFX_init( &pLayerInvisible ); 372 GFX_init( &pLayerInvisible );
388 TIM_BACKLIGHT_init(); 373 TIM_BACKLIGHT_init();
389
390 /*
391 GFX_helper_font_memory_list(&FontT24);
392 GFX_helper_font_memory_list(&FontT42);
393 GFX_helper_font_memory_list(&FontT48);
394 GFX_helper_font_memory_list(&FontT54);
395 GFX_helper_font_memory_list(&FontT84);
396 GFX_helper_font_memory_list(&FontT105);
397 GFX_helper_font_memory_list(&FontT144);
398 */
399
400
401 374
402 // new 170508: bluetooth on at start 375 // new 170508: bluetooth on at start
403 settingsGetPointer()->bluetoothActive = 1; 376 settingsGetPointer()->bluetoothActive = 1;
404 MX_Bluetooth_PowerOn(); 377 MX_Bluetooth_PowerOn();
405 378
441 GFX_SetFramesTopBottom( pLayerInvisible, pLayerInvisible, 480 ); 414 GFX_SetFramesTopBottom( pLayerInvisible, pLayerInvisible, 480 );
442 HAL_Delay( 20 ); 415 HAL_Delay( 20 );
443 display_power_on__2_of_2__post_RGB(); 416 display_power_on__2_of_2__post_RGB();
444 GFX_use_colorscheme( settingsGetPointer()->tX_colorscheme ); 417 GFX_use_colorscheme( settingsGetPointer()->tX_colorscheme );
445 418
446 // -----------------------------
447 tHome_init(); 419 tHome_init();
448 tI_init(); 420 tI_init();
449 tM_init(); 421 tM_init();
450 tMenuEdit_init(); 422 tMenuEdit_init();
451 tInfoLog_init(); 423 tInfoLog_init();
487 */ 459 */
488 while( 1 ) 460 while( 1 )
489 { 461 {
490 if( bootToBootloader ) 462 if( bootToBootloader )
491 resetToFirmwareUpdate(); 463 resetToFirmwareUpdate();
492
493 // this will allways reset after RTE reset -> no good!
494 // if(DataEX_was_power_on()) // new to allow for update after RTE update
495 // resetToFirmwareUpdate();
496 464
497 tCCR_control(); 465 tCCR_control();
498 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART 466 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART
499 { 467 {
500 createDiveSettings(); 468 createDiveSettings();
930 ButtonAction = ACTION_END; 898 ButtonAction = ACTION_END;
931 } 899 }
932 } 900 }
933 901
934 902
935 void EvaluateButton() 903 static void EvaluateButton()
936 { 904 {
937 uint8_t action = 0; 905 uint8_t action = 0;
938 SStateList status; 906 SStateList status;
939 SSettings* pSettings; 907 SSettings* pSettings;
940 pSettings = settingsGetPointer(); 908 pSettings = settingsGetPointer();
1010 } 978 }
1011 LastButtonPressed = INVALID_BUTTON; 979 LastButtonPressed = INVALID_BUTTON;
1012 } 980 }
1013 } 981 }
1014 982
1015 void gotoSleep(void) 983 static void gotoSleep(void)
1016 { 984 {
1017 /* not at the moment of testing */ 985 /* not at the moment of testing */
1018 // ext_flash_erase_firmware_if_not_empty(); 986 // ext_flash_erase_firmware_if_not_empty();
1019 GFX_logoAutoOff(); 987 GFX_logoAutoOff();
1020 set_globalState(StStop); 988 set_globalState(StStop);
1021 } 989 }
1022 990
1023 991
1024 // ----------------------------- 992 // -----------------------------
1025
1026 uint8_t get_globalMode(void)
1027 {
1028 return globalModeID;
1029 }
1030
1031
1032 void set_globalMode(uint8_t newMode)
1033 {
1034 if((newMode != DIVEMODE) && (newMode != SURFMODE))
1035 return;
1036
1037 globalModeID = newMode;
1038 }
1039
1040 993
1041 uint32_t get_globalState(void) 994 uint32_t get_globalState(void)
1042 { 995 {
1043 return globalStateID; 996 return globalStateID;
1044 } 997 }
1652 } 1605 }
1653 } 1606 }
1654 #endif 1607 #endif
1655 1608
1656 1609
1657 void deco_loop(void) 1610 static void deco_loop(void)
1658 { 1611 {
1659 typedef enum 1612 typedef enum
1660 { 1613 {
1661 CALC_VPM, 1614 CALC_VPM,
1662 CALC_VPM_FUTURE, 1615 CALC_VPM_FUTURE,
1733 default: break; 1686 default: break;
1734 } 1687 }
1735 counter++; 1688 counter++;
1736 } 1689 }
1737 1690
1738 void resetToFirmwareUpdate(void) 1691 static void resetToFirmwareUpdate(void)
1739 { 1692 {
1740 __HAL_RCC_CLEAR_RESET_FLAGS(); 1693 __HAL_RCC_CLEAR_RESET_FLAGS();
1741 HAL_NVIC_SystemReset(); 1694 HAL_NVIC_SystemReset();
1742 } 1695 }
1743 1696