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 "sensor.h"
|
||||
#include "gppwm.h"
|
||||
#include "tachometer.h"
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
#include "tunerstudio_outputs.h"
|
||||
|
@ -519,6 +520,8 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
#endif
|
||||
|
||||
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
tachSignalCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
}
|
||||
|
||||
void doScheduleStopEngine(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
*/
|
||||
|
||||
#include "tachometer.h"
|
||||
#include "trigger_central.h"
|
||||
#include "pwm_generator_logic.h"
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
@ -21,31 +20,23 @@ static float tachFreq;
|
|||
static float duty;
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
float getTachFreq(void) {
|
||||
float getTachFreq() {
|
||||
return tachFreq;
|
||||
}
|
||||
|
||||
float getTachDuty(void) {
|
||||
float getTachDuty() {
|
||||
return duty;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void tachSignalCallback(trigger_event_e ckpSignalType,
|
||||
uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
// only process at index configured to avoid too much cpu time for index 0?
|
||||
if (index != (uint32_t)CONFIG(tachPulseTriggerIndex)) {
|
||||
static bool tachHasInit = false;
|
||||
|
||||
void tachSignalCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
// Only do anything if tach enabled
|
||||
if (!tachHasInit) {
|
||||
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?
|
||||
int periods = CONFIG(tachPulsePerRev);
|
||||
|
||||
|
@ -74,10 +65,10 @@ static void tachSignalCallback(trigger_event_e ckpSignalType,
|
|||
|
||||
tachControl.setSimplePwmDutyCycle(duty);
|
||||
tachControl.setFrequency(tachFreq);
|
||||
|
||||
}
|
||||
|
||||
void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
tachHasInit = false;
|
||||
if (CONFIG(tachOutputPin) == GPIO_UNASSIGNED) {
|
||||
return;
|
||||
}
|
||||
|
@ -89,7 +80,5 @@ void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
&enginePins.tachOut,
|
||||
NAN, 0.1f);
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
addTriggerEventListener(tachSignalCallback, "tach", engine);
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
tachHasInit = true;
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
#include "engine.h"
|
||||
|
||||
void initTachometer(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
void tachSignalCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
|
Loading…
Reference in New Issue