#35 trying new kind of parameter magic
This commit is contained in:
parent
9f39c11c75
commit
b767b4a251
|
@ -26,7 +26,6 @@ int getHip9011BandIndex(float frequency);
|
||||||
void prepareHip9011RpmLookup(float angleWindowWidth);
|
void prepareHip9011RpmLookup(float angleWindowWidth);
|
||||||
|
|
||||||
#define GAIN_INDEX(gain) (GAIN_LOOKUP_SIZE - 1 - findIndexMsg("fGain", gainLookupInReverseOrder, GAIN_LOOKUP_SIZE, (gain)))
|
#define GAIN_INDEX(gain) (GAIN_LOOKUP_SIZE - 1 - findIndexMsg("fGain", gainLookupInReverseOrder, GAIN_LOOKUP_SIZE, (gain)))
|
||||||
#define BAND(bore) (900 / (PIF * (bore) / 2))
|
|
||||||
|
|
||||||
extern float rpmLookup[INT_LOOKUP_SIZE];
|
extern float rpmLookup[INT_LOOKUP_SIZE];
|
||||||
int getIntegrationIndexByRpm(float rpm);
|
int getIntegrationIndexByRpm(float rpm);
|
||||||
|
|
|
@ -117,10 +117,6 @@ static SPIDriver *driver;
|
||||||
EXTERN_ENGINE
|
EXTERN_ENGINE
|
||||||
;
|
;
|
||||||
|
|
||||||
static float getBand(void) {
|
|
||||||
return engineConfiguration->knockBandCustom == 0 ?
|
|
||||||
BAND(engineConfiguration->cylinderBore) : engineConfiguration->knockBandCustom;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char hipPinNameBuffer[16];
|
static char hipPinNameBuffer[16];
|
||||||
|
|
||||||
|
@ -134,7 +130,7 @@ static void showHipInfo(void) {
|
||||||
scheduleMsg(logger, "enabled=%s state=%s bore=%.2fmm freq=%.2fkHz PaSDO=%d",
|
scheduleMsg(logger, "enabled=%s state=%s bore=%.2fmm freq=%.2fkHz PaSDO=%d",
|
||||||
boolToString(boardConfiguration->isHip9011Enabled),
|
boolToString(boardConfiguration->isHip9011Enabled),
|
||||||
getHip_state_e(instance.state),
|
getHip_state_e(instance.state),
|
||||||
engineConfiguration->cylinderBore, getBand(),
|
engineConfiguration->cylinderBore, getHIP9011Band(PASS_HIP_PARAMS),
|
||||||
engineConfiguration->hip9011PrescalerAndSDO);
|
engineConfiguration->hip9011PrescalerAndSDO);
|
||||||
|
|
||||||
char *outputName = getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, hipPinNameBuffer);
|
char *outputName = getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, hipPinNameBuffer);
|
||||||
|
@ -287,7 +283,7 @@ static void endOfSpiExchange(SPIDriver *spip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getBandIndex(void) {
|
static int getBandIndex(void) {
|
||||||
float freq = getBand();
|
float freq = getHIP9011Band(PASS_HIP_PARAMS);
|
||||||
return getHip9011BandIndex(freq);
|
return getHip9011BandIndex(freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,19 @@
|
||||||
|
|
||||||
#include "HIP9011_logic.h"
|
#include "HIP9011_logic.h"
|
||||||
|
|
||||||
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
HIP9011::HIP9011() {
|
HIP9011::HIP9011() {
|
||||||
needToInit = true;
|
needToInit = true;
|
||||||
state = NOT_READY;
|
state = NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BAND(bore) (900 / (PIF * (bore) / 2))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return frequency band we are interested in
|
||||||
|
*/
|
||||||
|
float getHIP9011Band(DEFINE_HIP_PARAMS) {
|
||||||
|
return GET_CONFIG_VALUE(knockBandCustom) == 0 ?
|
||||||
|
BAND(GET_CONFIG_VALUE(cylinderBore)) : GET_CONFIG_VALUE(knockBandCustom);
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
#ifndef HW_LAYER_HIP9011_LOGIC_H_
|
#ifndef HW_LAYER_HIP9011_LOGIC_H_
|
||||||
#define HW_LAYER_HIP9011_LOGIC_H_
|
#define HW_LAYER_HIP9011_LOGIC_H_
|
||||||
|
|
||||||
|
#include "efifeatures.h"
|
||||||
#include "rusefi_enums.h"
|
#include "rusefi_enums.h"
|
||||||
|
#include "hip9011_lookup.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this interface defines SPI communication channel with HIP9011 chip
|
* this interface defines SPI communication channel with HIP9011 chip
|
||||||
|
@ -36,4 +38,22 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
|
#define PASS_HIP_PARAMS
|
||||||
|
#define DEFINE_HIP_PARAMS
|
||||||
|
#define GET_CONFIG_VALUE(x) CONFIG(x)
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define PASS_HIP_PARAMS CONFIG(knockBandCustom), \
|
||||||
|
CONFIG(cylinderBore)
|
||||||
|
|
||||||
|
#define DEFINE_HIP_PARAMS float knockBandCustom,\
|
||||||
|
float cylinderBore
|
||||||
|
|
||||||
|
#define GET_CONFIG_VALUE(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
float getHIP9011Band(DEFINE_HIP_PARAMS);
|
||||||
|
|
||||||
#endif /* HW_LAYER_HIP9011_LOGIC_H_ */
|
#endif /* HW_LAYER_HIP9011_LOGIC_H_ */
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "unit_test_framework.h"
|
#include "unit_test_framework.h"
|
||||||
#include "hip9011_lookup.h"
|
#include "hip9011_lookup.h"
|
||||||
|
#include "HIP9011_logic.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
TEST(hip9011, lookup) {
|
TEST(hip9011, lookup) {
|
||||||
|
@ -28,3 +29,10 @@ TEST(hip9011, lookup) {
|
||||||
EXPECT_EQ(1, getIntegrationIndexByRpm(6600));
|
EXPECT_EQ(1, getIntegrationIndexByRpm(6600));
|
||||||
EXPECT_EQ(0, getIntegrationIndexByRpm(16600));
|
EXPECT_EQ(0, getIntegrationIndexByRpm(16600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(hip9011, band) {
|
||||||
|
|
||||||
|
EXPECT_FLOAT_EQ(3, getHIP9011Band(/* knockBandCustom*/3, /*cylinderBore*/76));
|
||||||
|
EXPECT_FLOAT_EQ(7.5389242, getHIP9011Band(/* knockBandCustom*/0, /*cylinderBore*/76));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue