2014-08-29 07:52:33 -07:00
|
|
|
/**
|
|
|
|
* @file engine_math.h
|
|
|
|
*
|
|
|
|
* @date Jul 13, 2013
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2014
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ENGINE_MATH_H_
|
|
|
|
#define ENGINE_MATH_H_
|
|
|
|
|
|
|
|
#include "engine_configuration.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2014-11-07 21:07:22 -08:00
|
|
|
|
2014-08-29 07:52:33 -07:00
|
|
|
#include "ec2.h"
|
|
|
|
#include "trigger_structure.h"
|
|
|
|
#include "table_helper.h"
|
|
|
|
#include "engine.h"
|
|
|
|
|
2014-11-07 21:07:22 -08:00
|
|
|
void findTriggerPosition(trigger_shape_s * s,
|
|
|
|
event_trigger_position_s *position, float angleOffset DECLATE_ENGINE_PARAMETER);
|
2014-08-29 07:52:33 -07:00
|
|
|
|
|
|
|
int isInjectionEnabled(engine_configuration_s *engineConfiguration);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-11-06 07:06:08 -08:00
|
|
|
float fixAngle(engine_configuration_s const *engineConfiguration, float angle);
|
2014-08-29 07:52:33 -07:00
|
|
|
|
2014-09-12 08:05:18 -07:00
|
|
|
/**
|
|
|
|
* So that's how 'inline' syntax for both GCC and IAR
|
|
|
|
* It is interesting to mention that GCC compiler chooses not to inline this function.
|
|
|
|
*
|
|
|
|
* @return time needed to rotate crankshaft by one degree, in milliseconds.
|
|
|
|
* @deprecated use at least Us, maybe event Nt
|
|
|
|
*/
|
|
|
|
inline float getOneDegreeTimeMs(int rpm) {
|
|
|
|
return 1000.0f * 60 / 360 / rpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return time needed to rotate crankshaft by one degree, in microseconds.
|
|
|
|
*/
|
|
|
|
#define getOneDegreeTimeUs(rpm) (1000000.0f * 60 / 360 / (rpm))
|
|
|
|
|
2014-11-06 17:04:40 -08:00
|
|
|
#define getOneDegreeTimeNt(rpm) (US2NT(1000000.0f) * 60 / 360 / (rpm))
|
|
|
|
|
2014-08-29 07:52:33 -07:00
|
|
|
float getCrankshaftRevolutionTimeMs(int rpm);
|
|
|
|
|
|
|
|
int isCrankingRT(engine_configuration_s *engineConfiguration, int rpm);
|
|
|
|
#define isCrankingR(rpm) isCrankingRT(engineConfiguration, rpm)
|
|
|
|
|
|
|
|
float getEngineLoadT(Engine *engine);
|
2014-11-07 19:04:45 -08:00
|
|
|
#define getEngineLoad() getEngineLoadT(engine)
|
2014-08-29 07:52:33 -07:00
|
|
|
|
2014-11-07 21:07:22 -08:00
|
|
|
float getSparkDwellMsT(int rpm DECLATE_ENGINE_PARAMETER);
|
2014-08-29 07:52:33 -07:00
|
|
|
|
|
|
|
int getCylinderId(firing_order_e firingOrder, int index);
|
|
|
|
|
|
|
|
void setFuelRpmBin(engine_configuration_s *engineConfiguration, float l, float r);
|
|
|
|
void setFuelLoadBin(engine_configuration_s *engineConfiguration, float l, float r);
|
|
|
|
void setTimingRpmBin(engine_configuration_s *engineConfiguration, float l, float r);
|
|
|
|
void setTimingLoadBin(engine_configuration_s *engineConfiguration, float l, float r);
|
|
|
|
|
|
|
|
void setSingleCoilDwell(engine_configuration_s *engineConfiguration);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* ENGINE_MATH_H_ */
|