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-12 06:03:14 -08:00
|
|
|
#define INJECTOR_PIN_BY_INDEX(index) (io_pin_e) ((int) INJECTOR_1_OUTPUT + (index))
|
|
|
|
|
2014-11-07 21:07:22 -08:00
|
|
|
void findTriggerPosition(trigger_shape_s * s,
|
2014-11-12 13:05:43 -08:00
|
|
|
event_trigger_position_s *position, float angleOffset DECLARE_ENGINE_PARAMETER_S);
|
2014-08-29 07:52:33 -07:00
|
|
|
|
|
|
|
int isInjectionEnabled(engine_configuration_s *engineConfiguration);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2014-11-12 14:03:12 -08:00
|
|
|
float fixAngle(float angle DECLARE_ENGINE_PARAMETER_S);
|
2014-08-29 07:52:33 -07:00
|
|
|
|
2014-09-12 08:05:18 -07:00
|
|
|
/**
|
|
|
|
* @return time needed to rotate crankshaft by one degree, in milliseconds.
|
2014-11-24 11:03:17 -08:00
|
|
|
* @deprecated use at least Us, maybe even Nt
|
2014-09-12 08:05:18 -07:00
|
|
|
*/
|
2014-11-24 11:03:17 -08:00
|
|
|
#define getOneDegreeTimeMs(rpm) (1000.0f * 60 / 360 / (rpm))
|
2014-09-12 08:05:18 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
|
2014-11-24 09:03:09 -08:00
|
|
|
#define isCrankingR(rpm) ((rpm) > 0 && (rpm) < engineConfiguration->crankingSettings.crankingRpm)
|
2014-08-29 07:52:33 -07:00
|
|
|
|
2014-11-24 18:03:34 -08:00
|
|
|
float getEngineLoadT(DECLARE_ENGINE_PARAMETER_F);
|
|
|
|
|
2014-08-29 07:52:33 -07:00
|
|
|
|
2014-11-12 13:05:43 -08:00
|
|
|
float getSparkDwellMsT(int rpm DECLARE_ENGINE_PARAMETER_S);
|
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_ */
|