mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 04:15:26 +03:00
Debug timers added (use -DDEBUG_TIMERS=YES to enable and CLI command "print dt" to see them)
This commit is contained in:
parent
a8aa6148e5
commit
2990e9b9a3
11 changed files with 517 additions and 276 deletions
|
@ -165,3 +165,64 @@ void CoTaskSwitchHook(uint8_t taskID)
|
|||
}
|
||||
|
||||
#endif // #if defined(DEBUG_TASKS)
|
||||
|
||||
#if defined(DEBUG_TIMERS)
|
||||
|
||||
void DebugTimer::start()
|
||||
{
|
||||
_start_hiprec = getTmr2MHz();
|
||||
_start_loprec = get_tmr10ms();
|
||||
}
|
||||
|
||||
void DebugTimer::stop()
|
||||
{
|
||||
// getTmr2MHz is 16 bit timer, resolution 0.5us, max measurable value 32.7675 milli seconds
|
||||
// tmr10ms_t tmr10ms = get_tmr10ms(); 32 bit timer, resolution 10ms, max measurable value: 42949672.95 s = 1.3 years
|
||||
// if time difference is bigger than 30ms, then use low resolution timer
|
||||
// otherwise use high resolution
|
||||
if ((_start_hiprec == 0) && (_start_loprec == 0)) return;
|
||||
|
||||
last = get_tmr10ms() - _start_loprec; //use low precision timer
|
||||
if (last < 3) {
|
||||
//use high precision
|
||||
last = (uint16_t)(getTmr2MHz() - _start_hiprec) / 2;
|
||||
}
|
||||
else {
|
||||
last *= 10000ul; //adjust unit to 1us
|
||||
}
|
||||
evalStats();
|
||||
}
|
||||
|
||||
DebugTimer debugTimers[DEBUG_TIMERS_COUNT];
|
||||
|
||||
const char * debugTimerNames[DEBUG_TIMERS_COUNT] = {
|
||||
"Pulses int." // debugTimerIntPulses,
|
||||
,"Pulses dur." // debugTimerIntPulsesDuration,
|
||||
,"10ms dur. " // debugTimerPer10ms,
|
||||
,"Rotary enc." // debugTimerRotEnc,
|
||||
,"Haptic " // debugTimerHaptic,
|
||||
,"Mixer calc " // debugTimerMixer,
|
||||
,"Tel. wakeup" // debugTimerTelemetryWakeup,
|
||||
,"perMain dur" // debugTimerPerMain,
|
||||
," perMain s1" // debugTimerPerMain1,
|
||||
," guiMain " // debugTimerGuiMain,
|
||||
," LUA bg " // debugTimerLuaBg,
|
||||
," LCD wait " // debugTimerLcdRefreshWait,
|
||||
," LUA fg " // debugTimerLuaFg,
|
||||
," LCD refr." // debugTimerLcdRefresh,
|
||||
," Menus " // debugTimerMenus,
|
||||
," Menu hnd" // debugTimerMenuHandlers,
|
||||
,"Menu Vers. " // debugTimerVersion,
|
||||
,"Menu simple" // debugTimerSimpleMenu,
|
||||
,"Menu drawte" // debugTimerDrawText,
|
||||
,"Menu drawt1" // debugTimerDrawText1,
|
||||
,"Mix ADC " // debugTimerGetAdc,
|
||||
,"Mix getsw " // debugTimerGetSwitches,
|
||||
,"Mix eval " // debugTimerEvalMixes,
|
||||
,"Mix 10ms " // debugTimerMixes10ms,
|
||||
,"ADC read " // debugTimerAdcRead,
|
||||
,"ADC loop " // debugTimerAdcLoop,
|
||||
,"ADC wait " // debugTimerAdcWait,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue