Mercurial > public > ostc4
comparison Discovery/Src/base.c @ 367:e309f78f89a5 MotionDetection
Merge default
| author | Ideenmodellierer |
|---|---|
| date | Sat, 20 Jul 2019 21:42:45 +0200 |
| parents | 3014a698f46d 5ca177d2df5d |
| children | 50ea68c7a153 |
comparison
equal
deleted
inserted
replaced
| 366:3c7030d6d67a | 367:e309f78f89a5 |
|---|---|
| 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" |
| 250 | 248 |
| 251 //#define NO_TIMEOUT | 249 //#define NO_TIMEOUT |
| 252 //#define QUICK_SLEEP | 250 //#define QUICK_SLEEP |
| 253 | 251 |
| 254 /* Private define ------------------------------------------------------------*/ | 252 /* Private define ------------------------------------------------------------*/ |
| 255 //#define BUFFER_SIZE ((uint32_t)0x00177000) | |
| 256 //#define WRITE_READ_ADDR ((uint32_t)0x0000) | |
| 257 #define REFRESH_COUNT ((uint32_t)0x0569) /**< for SDRAM refresh counter (90Mhz SD clock) */ | 253 #define REFRESH_COUNT ((uint32_t)0x0569) /**< for SDRAM refresh counter (90Mhz SD clock) */ |
| 258 #define INVALID_BUTTON ((uint8_t) 0xFF) | 254 #define INVALID_BUTTON ((uint8_t) 0xFF) |
| 259 /* Private macro -------------------------------------------------------------*/ | 255 /* Private macro -------------------------------------------------------------*/ |
| 260 /* Private variables ---------------------------------------------------------*/ | 256 /* Private variables ---------------------------------------------------------*/ |
| 261 | 257 |
| 262 RTC_HandleTypeDef RtcHandle; /* used to change time and date, no RTC is running on this MCU */ | 258 static RTC_HandleTypeDef RtcHandle; /* used to change time and date, no RTC is running on this MCU */ |
| 263 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */ | 259 TIM_HandleTypeDef TimHandle; /* used in stm32f4xx_it.c too */ |
| 264 TIM_HandleTypeDef TimBacklightHandle; /* used in stm32f4xx_it.c too */ | 260 static TIM_HandleTypeDef TimBacklightHandle; |
| 265 #ifdef DEMOMODE | 261 #ifdef DEMOMODE |
| 266 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */ | 262 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */ |
| 267 #endif | 263 #endif |
| 268 | 264 |
| 269 uint8_t LastButtonPressed; | 265 static uint8_t LastButtonPressed; |
| 270 uint32_t LastButtonPressedTick; | 266 static uint32_t LastButtonPressedTick; |
| 271 uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ | 267 static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ |
| 272 | |
| 273 /* | |
| 274 uint32_t time_before; | |
| 275 uint32_t time_between; | |
| 276 uint32_t time_after; | |
| 277 */ | |
| 278 | 268 |
| 279 /* SDRAM handler declaration */ | 269 /* SDRAM handler declaration */ |
| 280 SDRAM_HandleTypeDef hsdram; | 270 static SDRAM_HandleTypeDef hsdram; |
| 281 FMC_SDRAM_TimingTypeDef SDRAM_Timing; | 271 static FMC_SDRAM_TimingTypeDef SDRAM_Timing; |
| 282 FMC_SDRAM_CommandTypeDef command; | 272 static FMC_SDRAM_CommandTypeDef command; |
| 283 | 273 |
| 284 /* This was used for Dual Boot */ | 274 /* This was used for Dual Boot */ |
| 285 //FLASH_OBProgramInitTypeDef OBInit; | 275 //FLASH_OBProgramInitTypeDef OBInit; |
| 286 //FLASH_AdvOBProgramInitTypeDef AdvOBInit; | 276 //FLASH_AdvOBProgramInitTypeDef AdvOBInit; |
| 287 | 277 |
| 288 /* Private variables with external access ------------------------------------*/ | 278 /* Private variables with external access ------------------------------------*/ |
| 289 | 279 |
| 290 uint32_t globalStateID = 0; | 280 static uint32_t globalStateID = 0; |
| 291 uint8_t globalModeID = SURFMODE; | 281 static uint32_t time_without_button_pressed_deciseconds = 0; /**< langbeschreibung (eigenes Feld) warum diese variable verwendet wird um den sleepmode zu aktivieren */ |
| 292 uint32_t time_without_button_pressed_deciseconds = 0; /**< langbeschreibung (eigenes Feld) warum diese variable verwendet wird um den sleepmode zu aktivieren */ | |
| 293 uint8_t bootToBootloader = 0; ///< set in tComm.c to install firmware updates, calls resetToFirmwareUpdate() | 282 uint8_t bootToBootloader = 0; ///< set in tComm.c to install firmware updates, calls resetToFirmwareUpdate() |
| 294 //uint8_t dataEx_VPM_call = 0; | 283 static uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit() |
| 295 uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit() | |
| 296 uint32_t base_tempLightLevel = 0; | 284 uint32_t base_tempLightLevel = 0; |
| 297 uint8_t updateButtonsToDefault = 0; | 285 static uint8_t wasFirmwareUpdateCheckBattery = 0; |
| 298 uint8_t wasFirmwareUpdateCheckBattery = 0; | |
| 299 | |
| 300 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */ | 286 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */ |
| 301 | 287 |
| 302 /* Private function prototypes -----------------------------------------------*/ | 288 /* Private function prototypes -----------------------------------------------*/ |
| 303 static void SystemClock_Config(void); | 289 static void SystemClock_Config(void); |
| 304 static void Error_Handler(void); | 290 static void Error_Handler(void); |
| 364 uint8_t measurementindex = 0; | 350 uint8_t measurementindex = 0; |
| 365 uint8_t lastsecond = 0xFF; | 351 uint8_t lastsecond = 0xFF; |
| 366 #endif | 352 #endif |
| 367 | 353 |
| 368 detectionState_t shakestate; | 354 detectionState_t shakestate; |
| 369 | |
| 370 set_globalState( StBoot0 ); | 355 set_globalState( StBoot0 ); |
| 371 LastButtonPressed = 0; | 356 LastButtonPressed = 0; |
| 372 | 357 |
| 373 HAL_Init(); | 358 HAL_Init(); |
| 374 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 ); | 359 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 ); |
| 391 wasFirmwareUpdateCheckBattery = 1; | 376 wasFirmwareUpdateCheckBattery = 1; |
| 392 set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values | 377 set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values |
| 393 } | 378 } |
| 394 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */ | 379 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */ |
| 395 //settingsGetPointer()->compassBearing = 0; | 380 //settingsGetPointer()->compassBearing = 0; |
| 396 set_new_settings_missing_in_ext_flash(); // inlcudes update of firmware version 161121 | 381 set_new_settings_missing_in_ext_flash(); // includes update of firmware version 161121 |
| 397 | 382 |
| 398 GFX_init( &pLayerInvisible ); | 383 GFX_init( &pLayerInvisible ); |
| 399 TIM_BACKLIGHT_init(); | 384 TIM_BACKLIGHT_init(); |
| 400 | |
| 401 /* | |
| 402 GFX_helper_font_memory_list(&FontT24); | |
| 403 GFX_helper_font_memory_list(&FontT42); | |
| 404 GFX_helper_font_memory_list(&FontT48); | |
| 405 GFX_helper_font_memory_list(&FontT54); | |
| 406 GFX_helper_font_memory_list(&FontT84); | |
| 407 GFX_helper_font_memory_list(&FontT105); | |
| 408 GFX_helper_font_memory_list(&FontT144); | |
| 409 */ | |
| 410 | |
| 411 | |
| 412 | 385 |
| 413 // new 170508: bluetooth on at start | 386 // new 170508: bluetooth on at start |
| 414 settingsGetPointer()->bluetoothActive = 1; | 387 settingsGetPointer()->bluetoothActive = 1; |
| 415 MX_Bluetooth_PowerOn(); | 388 MX_Bluetooth_PowerOn(); |
| 416 | 389 |
| 452 GFX_SetFramesTopBottom( pLayerInvisible, pLayerInvisible, 480 ); | 425 GFX_SetFramesTopBottom( pLayerInvisible, pLayerInvisible, 480 ); |
| 453 HAL_Delay( 20 ); | 426 HAL_Delay( 20 ); |
| 454 display_power_on__2_of_2__post_RGB(); | 427 display_power_on__2_of_2__post_RGB(); |
| 455 GFX_use_colorscheme( settingsGetPointer()->tX_colorscheme ); | 428 GFX_use_colorscheme( settingsGetPointer()->tX_colorscheme ); |
| 456 | 429 |
| 457 // ----------------------------- | |
| 458 tHome_init(); | 430 tHome_init(); |
| 459 tI_init(); | 431 tI_init(); |
| 460 tM_init(); | 432 tM_init(); |
| 461 tMenuEdit_init(); | 433 tMenuEdit_init(); |
| 462 tInfoLog_init(); | 434 tInfoLog_init(); |
| 498 */ | 470 */ |
| 499 while( 1 ) | 471 while( 1 ) |
| 500 { | 472 { |
| 501 if( bootToBootloader ) | 473 if( bootToBootloader ) |
| 502 resetToFirmwareUpdate(); | 474 resetToFirmwareUpdate(); |
| 503 | |
| 504 // this will allways reset after RTE reset -> no good! | |
| 505 // if(DataEX_was_power_on()) // new to allow for update after RTE update | |
| 506 // resetToFirmwareUpdate(); | |
| 507 | 475 |
| 508 tCCR_control(); | 476 tCCR_control(); |
| 509 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART | 477 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART |
| 510 { | 478 { |
| 511 createDiveSettings(); | 479 createDiveSettings(); |
| 951 ButtonAction = ACTION_END; | 919 ButtonAction = ACTION_END; |
| 952 } | 920 } |
| 953 } | 921 } |
| 954 | 922 |
| 955 | 923 |
| 956 void EvaluateButton() | 924 static void EvaluateButton() |
| 957 { | 925 { |
| 958 uint8_t action = 0; | 926 uint8_t action = 0; |
| 959 SStateList status; | 927 SStateList status; |
| 960 SSettings* pSettings; | 928 SSettings* pSettings; |
| 961 pSettings = settingsGetPointer(); | 929 pSettings = settingsGetPointer(); |
| 1031 } | 999 } |
| 1032 LastButtonPressed = INVALID_BUTTON; | 1000 LastButtonPressed = INVALID_BUTTON; |
| 1033 } | 1001 } |
| 1034 } | 1002 } |
| 1035 | 1003 |
| 1036 void gotoSleep(void) | 1004 static void gotoSleep(void) |
| 1037 { | 1005 { |
| 1038 /* not at the moment of testing */ | 1006 /* not at the moment of testing */ |
| 1039 // ext_flash_erase_firmware_if_not_empty(); | 1007 // ext_flash_erase_firmware_if_not_empty(); |
| 1040 GFX_logoAutoOff(); | 1008 GFX_logoAutoOff(); |
| 1041 set_globalState(StStop); | 1009 set_globalState(StStop); |
| 1042 } | 1010 } |
| 1043 | 1011 |
| 1044 | 1012 |
| 1045 // ----------------------------- | 1013 // ----------------------------- |
| 1046 | |
| 1047 uint8_t get_globalMode(void) | |
| 1048 { | |
| 1049 return globalModeID; | |
| 1050 } | |
| 1051 | |
| 1052 | |
| 1053 void set_globalMode(uint8_t newMode) | |
| 1054 { | |
| 1055 if((newMode != DIVEMODE) && (newMode != SURFMODE)) | |
| 1056 return; | |
| 1057 | |
| 1058 globalModeID = newMode; | |
| 1059 } | |
| 1060 | |
| 1061 | 1014 |
| 1062 uint32_t get_globalState(void) | 1015 uint32_t get_globalState(void) |
| 1063 { | 1016 { |
| 1064 return globalStateID; | 1017 return globalStateID; |
| 1065 } | 1018 } |
| 1673 } | 1626 } |
| 1674 } | 1627 } |
| 1675 #endif | 1628 #endif |
| 1676 | 1629 |
| 1677 | 1630 |
| 1678 void deco_loop(void) | 1631 static void deco_loop(void) |
| 1679 { | 1632 { |
| 1680 typedef enum | 1633 typedef enum |
| 1681 { | 1634 { |
| 1682 CALC_VPM, | 1635 CALC_VPM, |
| 1683 CALC_VPM_FUTURE, | 1636 CALC_VPM_FUTURE, |
| 1754 default: break; | 1707 default: break; |
| 1755 } | 1708 } |
| 1756 counter++; | 1709 counter++; |
| 1757 } | 1710 } |
| 1758 | 1711 |
| 1759 void resetToFirmwareUpdate(void) | 1712 static void resetToFirmwareUpdate(void) |
| 1760 { | 1713 { |
| 1761 __HAL_RCC_CLEAR_RESET_FLAGS(); | 1714 __HAL_RCC_CLEAR_RESET_FLAGS(); |
| 1762 HAL_NVIC_SystemReset(); | 1715 HAL_NVIC_SystemReset(); |
| 1763 } | 1716 } |
| 1764 | 1717 |
