comparison Discovery/Src/base.c @ 896:f29369fff71e Evo_2_23

Development Feature Runtime in Debugview: Added a compile switch which allows to show the deco, grafix and main loop runtimes in the T7 debug view.
author ideenmodellierer
date Thu, 26 Sep 2024 18:32:36 +0200
parents 8d3f3a635397
children
comparison
equal deleted inserted replaced
895:94535e672583 896:f29369fff71e
296 static uint8_t wasFirmwareUpdateCheckBattery = 0; 296 static uint8_t wasFirmwareUpdateCheckBattery = 0;
297 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */ 297 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */
298 static uint8_t DoHousekeeping = 0; /* trigger to cleanup the frame buffers */ 298 static uint8_t DoHousekeeping = 0; /* trigger to cleanup the frame buffers */
299 static SButtonLock ButtonLockState = LOCK_OFF; /* Used for button unlock sequence */ 299 static SButtonLock ButtonLockState = LOCK_OFF; /* Used for button unlock sequence */
300 300
301 #ifdef T7_DEBUG_RUNTIME
302 static uint32_t startTimeMainLoop = 0;
303 static uint32_t startTimeDecoLoop = 0;
304 static uint32_t startTimeGfxLoop = 0;
305 static uint32_t timeMainLoop = 0;
306 static uint32_t timeDecoLoop = 0;
307 static uint32_t timeGfxLoop = 0;
308 #endif
301 309
302 /* Private function prototypes -----------------------------------------------*/ 310 /* Private function prototypes -----------------------------------------------*/
303 static void SystemClock_Config(void); 311 static void SystemClock_Config(void);
304 static void Error_Handler(void); 312 static void Error_Handler(void);
305 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command); 313 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command);
485 * and resetToFirmwareUpdate() 493 * and resetToFirmwareUpdate()
486 * because tComm_control() does not exit before disconnection 494 * because tComm_control() does not exit before disconnection
487 */ 495 */
488 while( 1 ) 496 while( 1 )
489 { 497 {
498 #ifdef T7_DEBUG_RUNTIME
499 startTimeMainLoop = HAL_GetTick();
500 #endif
490 if( bootToBootloader ) 501 if( bootToBootloader )
491 resetToFirmwareUpdate(); 502 resetToFirmwareUpdate();
492 503
493 tCCR_control(); 504 tCCR_control();
494 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART 505 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART
529 { 540 {
530 simulation_UpdateLifeData(1); 541 simulation_UpdateLifeData(1);
531 } 542 }
532 check_warning(); 543 check_warning();
533 updateMiniLiveLogbook(1); 544 updateMiniLiveLogbook(1);
534 545 #ifdef T7_DEBUG_RUNTIME
546 startTimeGfxLoop = HAL_GetTick();
547 #endif
535 RefreshDisplay(); 548 RefreshDisplay();
549 #ifdef T7_DEBUG_RUNTIME
550 timeGfxLoop = time_elapsed_ms(startTimeGfxLoop, HAL_GetTick());
551 #endif
536 TimeoutControl(); /* exit menus if needed */ 552 TimeoutControl(); /* exit menus if needed */
537 553
538 #ifdef ENABLE_MOTION_CONTROL 554 #ifdef ENABLE_MOTION_CONTROL
539 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */ 555 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */
540 { 556 {
555 logbook_InitAndWrite(stateUsed); 571 logbook_InitAndWrite(stateUsed);
556 #endif 572 #endif
557 if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/ 573 if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/
558 logbook_InitAndWrite(stateUsed); 574 logbook_InitAndWrite(stateUsed);
559 } 575 }
576 #ifdef T7_DEBUG_RUNTIME
577 timeMainLoop = time_elapsed_ms(startTimeMainLoop, HAL_GetTick());
578 #endif
560 } 579 }
561 } 580 }
562 581
563 582
564 583
1720 decom_CreateGasChangeList(&stateDeco.diveSettings, &stateDeco.lifeData); 1739 decom_CreateGasChangeList(&stateDeco.diveSettings, &stateDeco.lifeData);
1721 1740
1722 switch(what) 1741 switch(what)
1723 { 1742 {
1724 case CALC_VPM: 1743 case CALC_VPM:
1744 #ifdef T7_DEBUG_RUNTIME
1745 startTimeDecoLoop = HAL_GetTick();
1746 #endif
1725 vpm_calc(&stateDeco.lifeData,&stateDeco.diveSettings,&stateDeco.vpm,&stateDeco.decolistVPM, DECOSTOPS); 1747 vpm_calc(&stateDeco.lifeData,&stateDeco.diveSettings,&stateDeco.vpm,&stateDeco.decolistVPM, DECOSTOPS);
1748 #ifdef T7_DEBUG_RUNTIME
1749 timeDecoLoop = time_elapsed_ms(startTimeDecoLoop, HAL_GetTick());
1750 #endif
1726 decoLock = DECO_CALC_FINSHED_vpm; 1751 decoLock = DECO_CALC_FINSHED_vpm;
1727 return; 1752 return;
1728 case CALC_VPM_FUTURE: 1753 case CALC_VPM_FUTURE:
1729 decom_tissues_exposure(stateDeco.diveSettings.future_TTS_minutes * 60,&stateDeco.lifeData); 1754 decom_tissues_exposure(stateDeco.diveSettings.future_TTS_minutes * 60,&stateDeco.lifeData);
1730 vpm_calc(&stateDeco.lifeData,&stateDeco.diveSettings,&stateDeco.vpm,&stateDeco.decolistFutureVPM, FUTURESTOPS); 1755 vpm_calc(&stateDeco.lifeData,&stateDeco.diveSettings,&stateDeco.vpm,&stateDeco.decolistFutureVPM, FUTURESTOPS);
1914 } 1939 }
1915 } 1940 }
1916 } 1941 }
1917 RequestModeChange = 0; 1942 RequestModeChange = 0;
1918 } 1943 }
1944
1945 #ifdef T7_DEBUG_RUNTIME
1946 uint32_t getMainLoopTime()
1947 {
1948 return timeMainLoop;
1949 }
1950 uint32_t getDecoLoopTime()
1951 {
1952 return timeDecoLoop;
1953 }
1954 uint32_t getGfxLoopTime()
1955 {
1956 return timeGfxLoop;
1957 }
1958 #endif
1919 // debugging by https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/ 1959 // debugging by https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/
1920 1960
1921 /* 1961 /*
1922 void printErrorMsg(const char * errMsg) 1962 void printErrorMsg(const char * errMsg)
1923 { 1963 {