rusefi-1/firmware/controllers/core/EfiWave.h

69 lines
1.7 KiB
C
Raw Normal View History

2014-08-29 07:52:33 -07:00
/**
* @file EfiWave.h
*
* @date May 18, 2014
2015-01-12 15:04:10 -08:00
* @author Andrey Belomutskiy, (c) 2012-2015
2014-08-29 07:52:33 -07:00
*/
#ifndef EFI_WAVE_H_
#define EFI_WAVE_H_
#include "engine_configuration.h"
#define PWM_PHASE_MAX_COUNT 250
#define PWM_PHASE_MAX_WAVE_PER_PWM 3
2015-01-20 20:07:37 -08:00
/**
* int8_t is probably less efficient then int32_t but we need
* to reduce memory footprint
*
* todo: migrate to bit-array to same memory? but this would
* this would some CPU cycles. see std::vector<bool>
*/
typedef int8_t pin_state_t;
2014-08-29 07:52:33 -07:00
/**
* @brief PWM configuration for the specific output pin
*/
class single_wave_s {
public:
single_wave_s();
2015-01-20 20:07:37 -08:00
single_wave_s(pin_state_t *pinStates);
void init(pin_state_t *pinStates);
pin_state_t *pinStates;
2014-08-29 07:52:33 -07:00
};
2015-01-13 05:04:00 -08:00
class TriggerShape;
2014-08-29 07:52:33 -07:00
class multi_wave_s {
public:
multi_wave_s();
multi_wave_s(float *st, single_wave_s *waves);
void init(float *st, single_wave_s *waves);
void reset(void);
float getSwitchTime(int phaseIndex) const;
void setSwitchTime(int phaseIndex, float value);
void checkSwitchTimes(int size);
int getChannelState(int channelIndex, int phaseIndex) const;
int findAngleMatch(float angle, int size) const;
int waveIndertionAngle(float angle, int size) const;
/**
* Number of signal wires
*/
int waveCount;
single_wave_s *waves;
//private:
/**
* values in the (0..1] range which refer to points within the period at at which pin state should be changed
* So, in the simplest case we turn pin off at 0.3 and turn it on at 1 - that would give us a 70% duty cycle PWM
*/
float *switchTimes;
};
void checkSwitchTimes2(int size, float *switchTimes);
2015-01-13 05:04:00 -08:00
void configureHondaAccordCD(TriggerShape *s, bool with3rdSignal);
void configureHondaAccordCDDip(TriggerShape *s);
2014-08-29 07:52:33 -07:00
#endif /* EFI_WAVE_H_ */