flash savings (#3858)

* save table space

* turn some stuff off on some boards

* comment
This commit is contained in:
Matthew Kennedy 2022-01-31 05:57:37 -08:00 committed by GitHub
parent 00a087619f
commit 493dcb4d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 29 deletions

View File

@ -28,6 +28,7 @@ EFI_CONSOLE_TTL_PINS = -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOB_10 -DEFI_CONSOLE_RX_BRAI
DDEFS += -DEFI_CAN_SERIAL=TRUE
DDEFS += -DEFI_CJ125=FALSE -DEFI_MAX_31855=FALSE -DBOARD_L9779_COUNT=0 -DEFI_HD44780_LCD=FALSE -DEFI_LCD=FALSE
# Add them all together
DDEFS += -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"microRusEFI\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN) $(EFI_CONSOLE_TTL_PINS) -DEFI_SOFTWARE_KNOCK=TRUE -DSTM32_ADC_USE_ADC3=TRUE

View File

@ -24,6 +24,9 @@ DDEFS += -DEFI_LOGIC_ANALYZER=FALSE
DDEFS += -DEFI_CAN_SERIAL=TRUE
# Turn off stuff proteus doesn't have/need
DDEFS += -DEFI_CJ125=FALSE -DEFI_MAX_31855=FALSE -DBOARD_L9779_COUNT=0 -DBOARD_TLE8888_COUNT=0 -DEFI_HD44780_LCD=FALSE -DEFI_LCD=FALSE
# This stuff doesn't work on H7 yet
ifneq ($(PROJECT_CPU),ARCH_STM32H7)
DDEFS += -DSTM32_ADC_USE_ADC3=TRUE

View File

@ -78,7 +78,7 @@ void setFordEscortGt() {
engineConfiguration->specs.displacement = 1.839;
setAlgorithm(LM_SPEED_DENSITY);
static const float veRpmBins[] =
static const uint16_t veRpmBins[] =
{
800,
1200,
@ -211,7 +211,7 @@ void setFordEscortGt() {
engineConfiguration->vbattDividerCoeff = ((float) (10 + 33)) / 10 * 2;
// VICS solenoid
static const float ignitionRpmBins[] =
static const uint16_t ignitionRpmBins[] =
{
800,
1200,

View File

@ -22,23 +22,24 @@
static const float hardCodedmafDecodingBins[42] = {0.1, 0.2, 0.3, 0.4, 0.5, 0.5999985, 0.70000076, 0.79999924, 0.9000015, 1.0, 1.0999985, 1.199997, 1.300003, 1.4000015, 1.5, 1.5999985, 1.699997, 1.800003, 1.9000015, 2.0, 2.100006, 2.2000122, 2.2999878, 2.399994, 2.5, 2.600006, 2.7000122, 2.7999878, 2.899994, 3.0, 3.100006, 3.2000122, 3.2999878, 3.399994, 3.5, 3.600006, 3.7000122, 3.7999878, 3.899994, 4.0, 4.0999756, 4.2};
static const float hardCodedmafDecoding[256] = {570.0, 437.0, 351.5, 293.55078, 237.0, 186.0, 145.0, 116.0, 96.0, 78.84961, 65.549805, 56.049805, 48.0, 40.0, 33.25, 29.449951, 25.649902, 22.800049, 20.899902, 19.0, 17.100098, 16.149902, 13.775024, 12.824951, 11.400024, 10.449951, 9.5, 8.550049, 8.454956, 8.359985, 8.300049, 8.199951, 7.5999756, 7.125, 7.125, 7.125, 6.6500244, 6.6500244, 6.6500244, 6.6500244, 6.6500244, 6.6500244, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
static const float hardCodedmafDecoding[42] = {570.0, 437.0, 351.5, 293.55078, 237.0, 186.0, 145.0, 116.0, 96.0, 78.84961, 65.549805, 56.049805, 48.0, 40.0, 33.25, 29.449951, 25.649902, 22.800049, 20.899902, 19.0, 17.100098, 16.149902, 13.775024, 12.824951, 11.400024, 10.449951, 9.5, 8.550049, 8.454956, 8.359985, 8.300049, 8.199951, 7.5999756, 7.125, 7.125, 7.125, 6.6500244, 6.6500244, 6.6500244, 6.6500244, 6.6500244, 6.6500244};
/* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/
static void setMafDecodingBins() {
for (size_t i = 0; i < 42; i++) {
config->mafDecodingBins[i] = hardCodedmafDecodingBins[i];
}
for (size_t i = 42; i < MAF_DECODING_COUNT; i++) {
config->mafDecodingBins[i] = 4.2 + 0.01 * i;
config->mafDecoding[i] = hardCodedmafDecoding[i];
}
copyArray(config->mafDecoding, hardCodedmafDecoding);
for (size_t i = 42; i < MAF_DECODING_COUNT; i++) {
config->mafDecodingBins[i] = 4.2 + 0.01 * i;
config->mafDecoding[i] = 0;
}
}
static const float hardCodedveLoadBins[16] = {20.0, 30.0, 34.0, 38.0, 43.0, 48.0, 54.0, 60.0, 67.0, 74.0, 82.0, 90.0, 99.0, 108.0, 118.0, 128.0};
static const uint8_t hardCodedveLoadBins[16] = {20, 30, 34, 38, 43, 48, 54, 60, 67, 74, 82, 90, 99, 108, 118, 128};
static const float hardCodedveRpmBins[16] = {650.0, 950.0, 1250.0, 1600.0, 1950.0, 2350.0, 2750.0, 3200.0, 3700.0, 4200.0, 4700.0, 5200.0, 5800.0, 6400.0, 7100.0, 7800.0};
static const uint16_t hardCodedveRpmBins[16] = {650, 950, 1250, 1600, 1950, 2350, 2750, 3200, 3700, 4200, 4700, 5200, 5800, 6400, 7100, 7800};
static const uint8_t hardCodedveTable[16][16] = {
/* Generated by TS2C on Sun Aug 02 10:02:25 EDT 2020*/
@ -67,9 +68,9 @@ static void setMapVeTable() {
copyTable(config->veTable, hardCodedveTable);
}
static const float hardCodedVafveLoadBins[16] = {10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0, 160.0, 180.0, 210.0, 240.0};
static const uint8_t hardCodedVafveLoadBins[16] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 210, 240};
static const float hardCodedVafveRpmBins[16] = {650.0, 950.0, 1250.0, 1600.0, 1950.0, 2350.0, 2750.0, 3200.0, 3700.0, 4200.0, 4700.0, 5200.0, 5800.0, 6400.0, 7100.0, 7800.0};
static const uint16_t hardCodedVafveRpmBins[16] = {650, 950, 1250, 1600, 1950, 2350, 2750, 3200, 3700, 4200, 4700, 5200, 5800, 6400, 7100, 7800};
static const uint8_t hardCodedVafveTable[16][16] = {
/* Generated by TS2C on Tue Aug 11 21:13:28 EDT 2020*/
@ -98,9 +99,9 @@ static void setVafVeTable() {
copyTable(config->veTable, hardCodedVafveTable);
}
static const float hardCodedVafignitionLoadBins[16] = {10.0, 16.0, 21.0, 26.0, 32.0, 39.0, 47.0, 56.0, 66.0, 77.0, 89.0, 101.0, 113.0, 125.0, 137.0, 149.0};
static const uint8_t hardCodedVafignitionLoadBins[16] = {10, 16, 21, 26, 32, 39, 47, 56, 66, 77, 89, 101, 113, 125, 137, 149};
static const float hardCodedVafignitionRpmBins[16] = {500.0, 900.0, 1200.0, 1500.0, 1800.0, 2300.0, 2900.0, 3400.0, 3900.0, 4300.0, 4800.0, 5300.0, 5900.0, 6500.0, 7200.0, 8000.0};
static const uint16_t hardCodedVafignitionRpmBins[16] = {500, 900, 1200, 1500, 1800, 2300, 2900, 3400, 3900, 4300, 4800, 5300, 5900, 6500, 7200, 8000};
static const uint8_t hardCodedVafignitionTable[16][16] = {
/* Generated by TS2C on Tue Aug 11 21:13:28 EDT 2020*/

View File

@ -24,16 +24,16 @@
//extern const float mazda_miata_nb2_RpmBins[FUEL_RPM_COUNT];
//extern const float mazda_miata_nb2_LoadBins[FUEL_LOAD_COUNT];
const float mazda_miata_nb2_RpmBins[FUEL_RPM_COUNT] = {700.0, 820.0, 950.0, 1100.0,
1300.0, 1550.0, 1800.0, 2150.0,
2500.0, 3000.0, 3500.0, 4150.0,
4900.0, 5800.0, 6800.0, 8000.0}
const uint16_t mazda_miata_nb2_RpmBins[FUEL_RPM_COUNT] = {700, 820, 950, 1100,
1300, 1550, 1800, 2150,
2500, 3000, 3500, 4150,
4900, 5800, 6800, 8000}
;
const float mazda_miata_nb2_LoadBins[FUEL_LOAD_COUNT] = {20.0, 25.0, 30.0, 35.0,
40.0, 46.0, 54.0, 63.0,
73.0, 85.0, 99.0, 116.0,
135.0, 158.0, 185.0, 220.0}
const uint8_t mazda_miata_nb2_LoadBins[FUEL_LOAD_COUNT] = {20, 25, 30, 35,
40, 46, 54, 63,
73, 85, 99, 116,
135, 158, 185, 220}
;
static uint8_t const SCRIPT_TABLE_dyno[SCRIPT_TABLE_8][SCRIPT_TABLE_8] = {
@ -70,16 +70,16 @@ static const uint8_t mapBased18vvtVeTable_NA_fuel_rail[16][16] = {
};
#endif
static const float mazda_miata_nb2_targetLambdaRpmBins[FUEL_RPM_COUNT] = {650.0, 800.0, 1050.0, 1300.0,
1550.0, 1800.0, 2050.0, 2300.0,
2550.0, 2800.0, 3050.0, 3300.0,
3550.0, 3800.0, 4050.0, 6400.0}
static const uint16_t mazda_miata_nb2_targetLambdaRpmBins[FUEL_RPM_COUNT] = {650, 800, 1050, 1300,
1550, 1800, 2050, 2300,
2550, 2800, 3050, 3300,
3550, 3800, 4050, 6400}
;
static const float mazda_miata_nb2_targetLambdaLoadBins[FUEL_LOAD_COUNT] = {10.0, 20.0, 30.0, 40.0,
50.0, 60.0, 70.0, 80.0,
90.0, 100.0, 110.0, 120.0,
130.0, 140.0, 150.0, 160.0};
static const uint8_t mazda_miata_nb2_targetLambdaLoadBins[FUEL_LOAD_COUNT] = {10, 20, 30, 40,
50, 60, 70, 80,
90, 100, 110, 120,
130, 140, 150, 160};
void setMazdaMiata2003EngineConfigurationNaFuelRail() {
setMazdaMiata2003EngineConfiguration();

View File

@ -166,6 +166,17 @@ constexpr void copyTable(TDest (&dest)[N][M], const TSource (&source)[N][M], flo
}
}
// specialization that can use memcpy when src and dest types match
template <typename TDest, size_t N, size_t M>
constexpr void copyTable(scaled_channel<TDest, 1, 1> (&dest)[N][M], const TDest (&source)[N][M]) {
memcpy(dest, source, N * M * sizeof(TDest));
}
template <typename TDest, size_t N, size_t M>
constexpr void copyTable(TDest (&dest)[N][M], const TDest (&source)[N][M]) {
memcpy(dest, source, N * M * sizeof(TDest));
}
template<typename kType>
void setRpmBin(kType array[], int size, float idleRpm, float topRpm) {
array[0] = idleRpm - 150;

View File

@ -147,6 +147,17 @@ constexpr void copyArray(DElement (&dest)[N], const SElement (&src)[N]) {
}
}
// specialization that can use memcpy when src and dest types match
template <typename DElement, size_t N>
constexpr void copyArray(scaled_channel<DElement, 1, 1> (&dest)[N], const DElement (&src)[N]) {
memcpy(dest, src, sizeof(DElement) * N);
}
template <typename DElement, size_t N>
constexpr void copyArray(DElement (&dest)[N], const DElement (&src)[N]) {
memcpy(dest, src, sizeof(DElement) * N);
}
/**
* Copies an array from src to the beginning of dst. If dst is larger
* than src, then only the elements copied from src will be touched.