rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions
trigger_emulator_algo.h File Reference

Detailed Description

Date
Mar 3, 2014
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file trigger_emulator_algo.h.

Data Structures

class  TriggerEmulatorHelper
 

Functions

void initTriggerEmulator ()
 
void startTriggerEmulatorPins ()
 
void stopTriggerEmulatorPins ()
 
void setTriggerEmulatorRPM (int value)
 
void onConfigurationChangeRpmEmulatorCallback (engine_configuration_s *previousConfiguration)
 
void enableTriggerStimulator (bool incGlobalConfiguration=true)
 
void enableExternalTriggerStimulator ()
 
void disableTriggerStimulator ()
 
int getPreviousIndex (const int currentIndex, const int size)
 
bool needEvent (const int currentIndex, const MultiChannelStateSequence &mcss, int channelIndex)
 

Function Documentation

◆ disableTriggerStimulator()

void disableTriggerStimulator ( )

Definition at line 222 of file trigger_emulator_algo.cpp.

222 {
224 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
226 }
229}
uint16_t channel
Definition adc_inputs.h:104
TriggerCentral triggerCentral
Definition engine.h:318
static EngineAccessor engine
Definition engine.h:413
void incrementGlobalConfigurationVersion(const char *msg)
PwmConfig triggerEmulatorSignals[NUM_EMULATOR_CHANNELS]
static bool hasInitTriggerEmulator

Referenced by configureRusefiLuaHooks(), enableOrDisable(), and handleCommandX14().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableExternalTriggerStimulator()

void enableExternalTriggerStimulator ( )

Definition at line 216 of file trigger_emulator_algo.cpp.

216 {
220}
static void startSimulatedTriggerSignal()

Referenced by enableOrDisable(), and handleCommandX14().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableTriggerStimulator()

void enableTriggerStimulator ( bool  incGlobalConfiguration = true)

Definition at line 205 of file trigger_emulator_algo.cpp.

205 {
209 if (incGlobalConfiguration) {
211 }
212}
RpmCalculator rpmCalculator
Definition engine.h:306
bool Register()
Definition sensor.cpp:131

Referenced by configureRusefiLuaHooks(), enableOrDisable(), and handleCommandX14().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPreviousIndex()

int getPreviousIndex ( const int  currentIndex,
const int  size 
)

Definition at line 19 of file trigger_emulator_algo.cpp.

19 {
20 return (currentIndex + size - 1) % size;
21}
composite packet size

Referenced by TriggerStimulatorHelper::feedSimulatedEvent(), and needEvent().

Here is the caller graph for this function:

◆ initTriggerEmulator()

void initTriggerEmulator ( )

Definition at line 239 of file trigger_emulator_algo.cpp.

239 {
241
243}
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
void setTriggerEmulatorRPM(int rpm)
void startTriggerEmulatorPins()

Referenced by initEngineEmulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ needEvent()

bool needEvent ( const int  currentIndex,
const MultiChannelStateSequence mcss,
int  channelIndex 
)

Definition at line 23 of file trigger_emulator_algo.cpp.

23 {
24 int prevIndex = getPreviousIndex(currentIndex, mcss.phaseCount);
25 pin_state_t previousValue = mcss.getChannelState(channelIndex, /*phaseIndex*/prevIndex);
26 pin_state_t currentValue = mcss.getChannelState(channelIndex, /*phaseIndex*/currentIndex);
27
28 return previousValue != currentValue;
29}
virtual pin_state_t getChannelState(int channelIndex, int phaseIndex) const =0
TriggerValue
int getPreviousIndex(const int currentIndex, const int size)

Referenced by TriggerStimulatorHelper::feedSimulatedEvent(), and TriggerEmulatorHelper::handleEmulatorCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onConfigurationChangeRpmEmulatorCallback()

void onConfigurationChangeRpmEmulatorCallback ( engine_configuration_s previousConfiguration)

Definition at line 231 of file trigger_emulator_algo.cpp.

231 {
233 previousConfiguration->triggerSimulatorRpm) {
234 return;
235 }
237}
static constexpr engine_configuration_s * engineConfiguration

Referenced by incrementGlobalConfigurationVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTriggerEmulatorRPM()

void setTriggerEmulatorRPM ( int  value)

All we need to do here is to change the periodMs togglePwmState() would see that the periodMs has changed and act accordingly

Definition at line 97 of file trigger_emulator_algo.cpp.

97 {
98 criticalAssertVoid(rpm >= 0 && rpm <= 30000, "emulator RPM out of range");
99
101 /**
102 * All we need to do here is to change the periodMs
103 * togglePwmState() would see that the periodMs has changed and act accordingly
104 */
105 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
106 float rPerSecond = NAN;
107 if (rpm != 0) {
108 // use 0.5 multiplier for cam
109 float rpmM = (channel == 0) ? getRpmMultiplier(getEngineRotationState()->getOperationMode()) : 0.5f;
110 rPerSecond = rpm * rpmM / 60.0; // per minute converted to per second
111 }
113 }
114
116
117 efiPrintf("Emulating position sensor(s). RPM=%d", rpm);
118}
void resetEngineSnifferIfInTestMode()
Definition engine.cpp:53
virtual operation_mode_e getOperationMode() const =0
void setFrequency(float frequency)
EngineRotationState * getEngineRotationState()
Definition engine.cpp:574
static float getRpmMultiplier(operation_mode_e mode)

Referenced by configureRusefiLuaHooks(), initTriggerEmulator(), onConfigurationChangeRpmEmulatorCallback(), setValue(), and startSimulatedTriggerSignal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startTriggerEmulatorPins()

void startTriggerEmulatorPins ( )

Definition at line 247 of file trigger_emulator_algo.cpp.

247 {
248 hasStimPins = false;
249 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
250 for (size_t i = 0; i < efi::size(emulatorOutputs[channel]); i++) {
252
253#if EFI_PROD_CODE
255
256 pin_output_mode_e outputMode;
257 if (channel == 0) {
260 } else if (channel == 1 && i == 0) {
263 } else {
264 // todo: add pin configs for cam simulator channels
265 continue;
266 }
267
268 // Only bother trying to set output pins if they're configured
269 if (isBrainPinValid(pin)) {
270 hasStimPins = true;
271 }
272
273 if (isConfigurationChanged(triggerSimulatorPins[i])) {
274 triggerEmulatorSignals[channel].outputPins[i]->initPin("Trigger emulator", pin,
275 outputMode);
276 }
277#endif // EFI_PROD_CODE
278 }
279 }
280}
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
OutputPin * outputPins[PWM_PHASE_MAX_WAVE_PER_PWM]
bool isBrainPinValid(brain_pin_e brainPin)
pin_output_mode_e
brain_pin_e pin
Definition stm32_adc.cpp:15
pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]
static bool hasStimPins
static OutputPin emulatorOutputs[NUM_EMULATOR_CHANNELS][PWM_PHASE_MAX_WAVE_PER_PWM]

Referenced by applyNewHardwareSettings(), and initTriggerEmulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopTriggerEmulatorPins()

void stopTriggerEmulatorPins ( )

Definition at line 282 of file trigger_emulator_algo.cpp.

282 {
283#if EFI_PROD_CODE
284 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
285 // todo: add pin configs for cam simulator channels
286 if (channel != 0)
287 continue;
288 for (size_t i = 0; i < efi::size(emulatorOutputs[channel]); i++) {
289 if (isConfigurationChanged(triggerSimulatorPins[i])) {
291 }
292 }
293 }
294#endif // EFI_PROD_CODE
295}
void deInit()
Definition efi_gpio.cpp:802

Referenced by stopHardware().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.