don't call tach from trigger, call from periodic fast (#1704)
* tacho * fix tests
This commit is contained in:
parent
466f412c7b
commit
184dee68e8
|
@ -26,6 +26,7 @@
|
||||||
#include "perf_trace.h"
|
#include "perf_trace.h"
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
#include "gppwm.h"
|
#include "gppwm.h"
|
||||||
|
#include "tachometer.h"
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
#include "tunerstudio_outputs.h"
|
#include "tunerstudio_outputs.h"
|
||||||
|
@ -519,6 +520,8 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
|
tachSignalCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doScheduleStopEngine(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void doScheduleStopEngine(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tachometer.h"
|
#include "tachometer.h"
|
||||||
#include "trigger_central.h"
|
|
||||||
#include "pwm_generator_logic.h"
|
#include "pwm_generator_logic.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
@ -21,31 +20,23 @@ static float tachFreq;
|
||||||
static float duty;
|
static float duty;
|
||||||
|
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
float getTachFreq(void) {
|
float getTachFreq() {
|
||||||
return tachFreq;
|
return tachFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getTachDuty(void) {
|
float getTachDuty() {
|
||||||
return duty;
|
return duty;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void tachSignalCallback(trigger_event_e ckpSignalType,
|
static bool tachHasInit = false;
|
||||||
uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|
||||||
// only process at index configured to avoid too much cpu time for index 0?
|
void tachSignalCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
if (index != (uint32_t)CONFIG(tachPulseTriggerIndex)) {
|
// Only do anything if tach enabled
|
||||||
|
if (!tachHasInit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_UNIT_TEST
|
|
||||||
printf("tachSignalCallback(%d %d)\n", ckpSignalType, index);
|
|
||||||
printf("Current RPM: %d\n",GET_RPM());
|
|
||||||
UNUSED(edgeTimestamp);
|
|
||||||
#else
|
|
||||||
UNUSED(ckpSignalType);
|
|
||||||
UNUSED(edgeTimestamp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// How many tach pulse periods do we have?
|
// How many tach pulse periods do we have?
|
||||||
int periods = CONFIG(tachPulsePerRev);
|
int periods = CONFIG(tachPulsePerRev);
|
||||||
|
|
||||||
|
@ -74,10 +65,10 @@ static void tachSignalCallback(trigger_event_e ckpSignalType,
|
||||||
|
|
||||||
tachControl.setSimplePwmDutyCycle(duty);
|
tachControl.setSimplePwmDutyCycle(duty);
|
||||||
tachControl.setFrequency(tachFreq);
|
tachControl.setFrequency(tachFreq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
tachHasInit = false;
|
||||||
if (CONFIG(tachOutputPin) == GPIO_UNASSIGNED) {
|
if (CONFIG(tachOutputPin) == GPIO_UNASSIGNED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +80,5 @@ void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
&enginePins.tachOut,
|
&enginePins.tachOut,
|
||||||
NAN, 0.1f);
|
NAN, 0.1f);
|
||||||
|
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
tachHasInit = true;
|
||||||
addTriggerEventListener(tachSignalCallback, "tach", engine);
|
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
void tachSignalCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
Loading…
Reference in New Issue