Logic analyzer ts report (#2080)
* Logic analyzer progress of integration with debug channels * Update logic_analyzer.cpp fixed duty report in % * Update logic_analyzer.cpp * Update logic_analyzer.cpp fix for setting one channel to unused, and use the same pin for another channel. this way we clear out hw pointer and we do not have the risk of reporting wrong values.
This commit is contained in:
parent
7c2f8707f2
commit
92247c58db
|
@ -866,6 +866,11 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
tle8888PostState(tsOutputChannels->getDebugChannels());
|
||||
#endif /* BOARD_TLE8888_COUNT */
|
||||
break;
|
||||
case DBG_LOGIC_ANALYZER:
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
reportLogicAnalyzerToTS();
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
|
|
@ -104,12 +104,20 @@ static void waIcuPeriodCallback(WaveReader *reader) {
|
|||
static void initWave(const char *name, int index) {
|
||||
brain_pin_e brainPin = CONFIG(logicAnalyzerPins)[index];
|
||||
|
||||
if (brainPin == GPIO_UNASSIGNED)
|
||||
return;
|
||||
|
||||
waveReaderCount++;
|
||||
efiAssertVoid(CUSTOM_ERR_6655, index < MAX_ICU_COUNT, "too many ICUs");
|
||||
WaveReader *reader = &readers[index];
|
||||
|
||||
if (brainPin == GPIO_UNASSIGNED) {
|
||||
/**
|
||||
* in case we are running, and we select none for a channel that was running,
|
||||
* this way we ensure that we do not get false report from that channel
|
||||
**/
|
||||
reader->hw = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
reader->name = name;
|
||||
|
||||
reader->hw = startDigitalCapture("wave input", brainPin);
|
||||
|
@ -241,4 +249,42 @@ void stopLogicAnalyzerPins() {
|
|||
}
|
||||
}
|
||||
|
||||
void getChannelFreqAndDuty(int index, float *duty, int *freq) {
|
||||
|
||||
float high,period;
|
||||
|
||||
if ((duty == nullptr) || (freq == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (readers[index].hw == nullptr) {
|
||||
*duty = 0.0;
|
||||
*freq = 0;
|
||||
} else {
|
||||
high = getSignalOnTime(index);
|
||||
period = getSignalPeriodMs(index);
|
||||
|
||||
if ((period != 0) && (readers[index].hw->started)) {
|
||||
|
||||
*duty = (high * 1000.0f) /(period * 10.0f);
|
||||
*freq = (int)(1 / (period / 1000.0f));
|
||||
} else {
|
||||
*duty = 0.0;
|
||||
*freq = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void reportLogicAnalyzerToTS() {
|
||||
#if EFI_TUNER_STUDIO
|
||||
int tmp;
|
||||
getChannelFreqAndDuty(0,&tsOutputChannels.debugFloatField1, &tsOutputChannels.debugIntField1);
|
||||
getChannelFreqAndDuty(1,&tsOutputChannels.debugFloatField2, &tsOutputChannels.debugIntField2);
|
||||
getChannelFreqAndDuty(2,&tsOutputChannels.debugFloatField3, &tsOutputChannels.debugIntField3);
|
||||
getChannelFreqAndDuty(3,&tsOutputChannels.debugFloatField4, &tmp);
|
||||
tsOutputChannels.debugIntField4 = (int16_t)tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
|
|
@ -55,6 +55,7 @@ void startLogicAnalyzerPins();
|
|||
void stopLogicAnalyzerPins();
|
||||
void printWave(Logging *logging);
|
||||
void showWaveInfo(void);
|
||||
void reportLogicAnalyzerToTS(void);
|
||||
|
||||
void waTriggerEventListener(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
|
Loading…
Reference in New Issue