13#ifndef EFI_HIP_9011_DEBUG
14#define EFI_HIP_9011_DEBUG EFI_HIP_9011
17#define HIP9011_ANALOG_OUTPUT_MAX 5.0f
18#define HIP9011_DIGITAL_OUTPUT_MAX 0x03ff
19#define HIP_INPUT_CHANNELS 2
21#define INT_LOOKUP_SIZE 32
22#define GAIN_LOOKUP_SIZE 64
23#define BAND_LOOKUP_SIZE 64
46#if EFI_PROD_CODE || EFI_SIMULATOR
47#define PASS_HIP_PARAMS
48#define DEFINE_HIP_PARAMS
49#define GET_CONFIG_VALUE(x) engineConfiguration->x
50#define FORWARD_HIP_PARAMS
51#define DEFINE_PARAM_SUFFIX(x)
54#define PASS_HIP_PARAMS \
55 engineConfiguration->cylinderBore, \
56 engineConfiguration->hip9011Gain, \
57 engineConfiguration->hip9011Prescaler, \
58 engineConfiguration->knockDetectionWindowStart, \
59 engineConfiguration->knockSamplingDuration
61#define FORWARD_HIP_PARAMS \
65 knockDetectionWindowStart, \
68#define DEFINE_HIP_PARAMS \
71 uint8_t hip9011Prescaler, \
72 float knockDetectionWindowStart, \
73 float knockSamplingDuration
76#define GET_CONFIG_VALUE(x) x
77#define DEFINE_PARAM_SUFFIX(x) , x
89 void handleSettings(
int rpm DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS));
93 float getBand(DEFINE_HIP_PARAMS);
131 #if EFI_HIP_9011_DEBUG
144#define SET_PRESCALER_CMD(v) (0x40 | (((v) & 0x0f) << 1) | 0)
146#define SET_CHANNEL_CMD(v) (0xE0 | ((v) & 0x01))
148#define SET_BAND_PASS_CMD(v) (0x00 | ((v) & 0x3f))
150#define SET_BAND_PASS_REP (0x01)
152#define SET_GAIN_CMD(v) (0x80 | ((v) & 0x3f))
154#define SET_GAIN_REP (0xe0)
156#define SET_INTEGRATOR_CMD(v) (0xC0 | ((v) & 0x1f))
158#define SET_INTEGRATOR_REP (0x71)
160#define SET_ADVANCED_MODE_CMD (0x71)
162#define SET_ADVANCED_MODE_REP ((~SET_ADVANCED_MODE_CMD) & 0xff)
165#define HIP_4MHZ_PRESCALER (0x0)
167#define HIP_5MHZ_PRESCALER (0x1)
169#define HIP_6MHZ_PRESCALER (0x2)
171#define HIP_8MHZ_PRESCALER (0x3)
173#define HIP_10MHZ_PRESCALER (0x4)
175#define HIP_12MHZ_PRESCALER (0x5)
177#define HIP_16MHZ_PRESCALER (0x6)
179#define HIP_20MHZ_PRESCALER (0x7)
181#define HIP_24MHZ_PRESCALER (0x8)
int cylinderToChannelIdx(int cylinder)
float getBand(DEFINE_HIP_PARAMS)
int getIntegrationTimeByIndex(int index)
efitick_t knockSampleTimestamp
void handleSettings(int rpm DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS))
int correctResponsesCount
int8_t expectedCylinderNumber
int getBandIndex(DEFINE_HIP_PARAMS)
int getGainIndex(DEFINE_HIP_PARAMS)
int readValueAndHandleChannel(DEFINE_HIP_PARAMS)
int handleChannel(DEFINE_HIP_PARAMS)
void setAngleWindowWidth(DEFINE_HIP_PARAMS)
float getRpmByAngleWindowAndTimeUs(int timeUs, float angleWindowWidth)
int sendCommand(uint8_t cmd)
Hip9011HardwareInterface * hw
int getIntegrationIndexByRpm(float rpm)
void prepareRpmLookup(void)
int sendCommandGetReply(uint8_t cmd, uint8_t *reply)
uint16_t rpmLookup[INT_LOOKUP_SIZE]
uint16_t rawValue[HIP_INPUT_CHANNELS]
int invalidResponsesCount
virtual int sendSyncCommand(unsigned char command, uint8_t *rx_ptr)=0
static Hip9011Hardware hardware
@ WAITING_FOR_ADC_TO_SKIP
Fundamental rusEFI enumerable types live here.