Merge remote-tracking branch 'upstream/master' into obd2-lambda

This commit is contained in:
Matthew Kennedy 2020-07-29 12:16:02 -07:00
commit 4c1c95c241
55 changed files with 78 additions and 601 deletions

View File

@ -352,3 +352,8 @@ void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->fuelAlgorithm = LM_PLAIN_MAF; engineConfiguration->fuelAlgorithm = LM_PLAIN_MAF;
#endif /* BOARD_TLE8888_COUNT */ #endif /* BOARD_TLE8888_COUNT */
} }
void setMiataNA6_MAP_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
#if (BOARD_TLE8888_COUNT > 0)
#endif /* BOARD_TLE8888_COUNT */
}

View File

@ -20,4 +20,5 @@ void setMiataNA6_MAP_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE);
void miataNAcommon(DECLARE_CONFIG_PARAMETER_SIGNATURE); void miataNAcommon(DECLARE_CONFIG_PARAMETER_SIGNATURE);
void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE);
void setMiataNA6_MAP_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE);

View File

@ -323,7 +323,7 @@ expected<percent_t> EtbController::getClosedLoopAutotune(percent_t actualThrottl
return autotuneAmplitude * (isPositive ? -1 : 1); return autotuneAmplitude * (isPositive ? -1 : 1);
} }
expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t actualThrottlePosition) { expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t observation) {
if (m_shouldResetPid) { if (m_shouldResetPid) {
m_pid.reset(); m_pid.reset();
m_shouldResetPid = false; m_shouldResetPid = false;
@ -333,16 +333,16 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t act
if (m_myIndex == 0) { if (m_myIndex == 0) {
#if EFI_TUNER_STUDIO #if EFI_TUNER_STUDIO
// Error is positive if the throttle needs to open further // Error is positive if the throttle needs to open further
tsOutputChannels.etb1Error = target - actualThrottlePosition; tsOutputChannels.etb1Error = target - observation;
#endif /* EFI_TUNER_STUDIO */ #endif /* EFI_TUNER_STUDIO */
} }
// Only allow autotune with stopped engine // Only allow autotune with stopped engine
if (GET_RPM() == 0 && engine->etbAutoTune) { if (GET_RPM() == 0 && engine->etbAutoTune) {
return getClosedLoopAutotune(actualThrottlePosition); return getClosedLoopAutotune(observation);
} else { } else {
// Normal case - use PID to compute closed loop part // Normal case - use PID to compute closed loop part
return m_pid.getOutput(target, actualThrottlePosition, 1.0f / ETB_LOOP_FREQUENCY); return m_pid.getOutput(target, observation, 1.0f / ETB_LOOP_FREQUENCY);
} }
} }

View File

@ -55,7 +55,7 @@ public:
expected<percent_t> getSetpoint() const override; expected<percent_t> getSetpoint() const override;
expected<percent_t> getOpenLoop(percent_t target) const override; expected<percent_t> getOpenLoop(percent_t target) const override;
expected<percent_t> getClosedLoop(percent_t setpoint, percent_t target) override; expected<percent_t> getClosedLoop(percent_t setpoint, percent_t observation) override;
expected<percent_t> getClosedLoopAutotune(percent_t actualThrottlePosition); expected<percent_t> getClosedLoopAutotune(percent_t actualThrottlePosition);
void setOutput(expected<percent_t> outputValue) override; void setOutput(expected<percent_t> outputValue) override;

View File

@ -54,11 +54,11 @@ private:
/** /**
* Used for Fractional TPS enrichment. * Used for Fractional TPS enrichment.
*/ */
floatms_t accumulatedValue; floatms_t accumulatedValue = 0;
floatms_t maxExtraPerCycle; floatms_t maxExtraPerCycle = 0;
floatms_t maxExtraPerPeriod; floatms_t maxExtraPerPeriod = 0;
floatms_t maxInjectedPerPeriod; floatms_t maxInjectedPerPeriod = 0;
int cycleCnt; int cycleCnt = 0;
}; };
/** /**

View File

@ -12,7 +12,7 @@ struct AirmassResult {
struct AirmassModelBase { struct AirmassModelBase {
DECLARE_ENGINE_PTR; DECLARE_ENGINE_PTR;
AirmassModelBase(const ValueProvider3D& veTable); explicit AirmassModelBase(const ValueProvider3D& veTable);
virtual AirmassResult getAirmass(int rpm) = 0; virtual AirmassResult getAirmass(int rpm) = 0;
protected: protected:

View File

@ -4,7 +4,7 @@
class AlphaNAirmass : public SpeedDensityBase { class AlphaNAirmass : public SpeedDensityBase {
public: public:
AlphaNAirmass(const ValueProvider3D& veTable) : SpeedDensityBase(veTable) {} explicit AlphaNAirmass(const ValueProvider3D& veTable) : SpeedDensityBase(veTable) {}
AirmassResult getAirmass(int rpm) override; AirmassResult getAirmass(int rpm) override;
}; };

View File

@ -4,7 +4,7 @@
class MafAirmass final : public AirmassModelBase { class MafAirmass final : public AirmassModelBase {
public: public:
MafAirmass(const ValueProvider3D& veTable) : AirmassModelBase(veTable) {} explicit MafAirmass(const ValueProvider3D& veTable) : AirmassModelBase(veTable) {}
AirmassResult getAirmass(int rpm) override; AirmassResult getAirmass(int rpm) override;

View File

@ -4,6 +4,6 @@
class SpeedDensityAirmass : public SpeedDensityBase { class SpeedDensityAirmass : public SpeedDensityBase {
public: public:
SpeedDensityAirmass(const ValueProvider3D& veTable) : SpeedDensityBase(veTable) {} explicit SpeedDensityAirmass(const ValueProvider3D& veTable) : SpeedDensityBase(veTable) {}
AirmassResult getAirmass(int rpm) override; AirmassResult getAirmass(int rpm) override;
}; };

View File

@ -15,7 +15,7 @@ float idealGasLaw(float volume, float pressure, float temperature);
class SpeedDensityBase : public AirmassModelBase { class SpeedDensityBase : public AirmassModelBase {
protected: protected:
SpeedDensityBase(const ValueProvider3D& veTable) : AirmassModelBase(veTable) {} explicit SpeedDensityBase(const ValueProvider3D& veTable) : AirmassModelBase(veTable) {}
public: public:
static float getAirmassImpl(float ve, float manifoldPressure, float temperature DECLARE_ENGINE_PARAMETER_SUFFIX); static float getAirmassImpl(float ve, float manifoldPressure, float temperature DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -39,7 +39,6 @@ void setWholeIatCorrTimingTable(float value DECLARE_CONFIG_PARAMETER_SUFFIX);
void setWholeTimingTable_d(angle_t value DECLARE_CONFIG_PARAMETER_SUFFIX); void setWholeTimingTable_d(angle_t value DECLARE_CONFIG_PARAMETER_SUFFIX);
#define setWholeTimingTable(x) setWholeTimingTable_d(x PASS_CONFIG_PARAMETER_SUFFIX); #define setWholeTimingTable(x) setWholeTimingTable_d(x PASS_CONFIG_PARAMETER_SUFFIX);
void setConstantDwell(floatms_t dwellMs DECLARE_CONFIG_PARAMETER_SUFFIX); void setConstantDwell(floatms_t dwellMs DECLARE_CONFIG_PARAMETER_SUFFIX);
void printFloatArray(const char *prefix, float array[], int size);
// needed by bootloader // needed by bootloader
void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE);

View File

@ -37,7 +37,7 @@ public:
Accelerometer accelerometer; Accelerometer accelerometer;
float vBatt = 0; float vBatt = 0;
float currentAfr; float currentAfr = 0;
/** /**
* that's fuel in tank - just a gauge * that's fuel in tank - just a gauge
*/ */
@ -131,7 +131,7 @@ private:
struct multispark_state struct multispark_state
{ {
efitick_t delay; efitick_t delay = 0;
efitick_t dwell; efitick_t dwell = 0;
uint8_t count; uint8_t count = 0;
}; };

View File

@ -107,12 +107,12 @@ public:
* Desired timing advance * Desired timing advance
*/ */
angle_t sparkAngle = NAN; angle_t sparkAngle = NAN;
floatms_t sparkDwell; floatms_t sparkDwell = 0;
/** /**
* this timestamp allows us to measure actual dwell time * this timestamp allows us to measure actual dwell time
*/ */
uint32_t actualStartOfDwellNt; uint32_t actualStartOfDwellNt = 0;
event_trigger_position_s dwellPosition; event_trigger_position_s dwellPosition{};
/** /**
* Sequential number of currently processed spark event * Sequential number of currently processed spark event
* @see globalSparkIdCounter * @see globalSparkIdCounter

View File

@ -62,7 +62,7 @@ typedef enum {
MRE_MIATA_NB2_MAP = 11, MRE_MIATA_NB2_MAP = 11,
MRE_MIATA_NA6 = ET_MRE_MIATA_NA6, MRE_MIATA_NA6_VAF = ET_MRE_MIATA_NA6_VAF,
MRE_MIATA_NB2_ETB = 13, MRE_MIATA_NB2_ETB = 13,
@ -189,6 +189,9 @@ typedef enum {
DODGE_RAM = 64, DODGE_RAM = 64,
CITROEN_TU3JP = ET_CITROEN_TU3JP, CITROEN_TU3JP = ET_CITROEN_TU3JP,
MRE_MIATA_NA6_MAP = ET_MRE_MIATA_NA6_MAP,
/** /**
* this configuration has as few pins configured as possible * this configuration has as few pins configured as possible
*/ */

View File

@ -182,11 +182,9 @@ void canDashboardVAG(void) {
} }
void canDashboardW202(void) { void canDashboardW202(void) {
uint16_t tmp;
{ {
CanTxMessage msg(W202_STAT_1); CanTxMessage msg(W202_STAT_1);
tmp = GET_RPM(); uint16_t tmp = GET_RPM();
msg[0] = 0x08; // Unknown msg[0] = 0x08; // Unknown
msg[1] = (tmp >> 8); //RPM msg[1] = (tmp >> 8); //RPM
msg[2] = (tmp & 0xff); //RPM msg[2] = (tmp & 0xff); //RPM

View File

@ -191,8 +191,6 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
{ {
event->sparksRemaining--; event->sparksRemaining--;
efitick_t nowNt = getTimeNowNt();
efitick_t nextDwellStart = nowNt + engine->engineState.multispark.delay; efitick_t nextDwellStart = nowNt + engine->engineState.multispark.delay;
efitick_t nextFiring = nextDwellStart + engine->engineState.multispark.dwell; efitick_t nextFiring = nextDwellStart + engine->engineState.multispark.dwell;

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Tue Jul 28 13:12:08 UTC 2020 // this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Jul 29 18:54:42 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer // by class com.rusefi.output.FileFsioSettingsConsumer
FSIO_SETTING_FANONTEMPERATURE = 1000, FSIO_SETTING_FANONTEMPERATURE = 1000,

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Tue Jul 28 13:12:08 UTC 2020 // this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Jul 29 18:54:42 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer // by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE: case FSIO_SETTING_FANONTEMPERATURE:

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Tue Jul 28 13:12:08 UTC 2020 // this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Jul 29 18:54:42 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer // by class com.rusefi.output.FileFsioSettingsConsumer
static LENameOrdinalPair lefanOnTemperature(FSIO_SETTING_FANONTEMPERATURE, "cfg_fanOnTemperature"); static LENameOrdinalPair lefanOnTemperature(FSIO_SETTING_FANONTEMPERATURE, "cfg_fanOnTemperature");

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Tue Jul 28 13:12:08 UTC 2020 // this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Jul 29 18:54:42 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer // by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE: case FSIO_SETTING_FANONTEMPERATURE:

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD all #define SIGNATURE_BOARD all
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 714281655 #define SIGNATURE_HASH 4075980722
#define TS_SIGNATURE "rusEFI 2020.07.29.all.714281655" #define TS_SIGNATURE "rusEFI 2020.07.29.all.4075980722"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD frankenso_na6 #define SIGNATURE_BOARD frankenso_na6
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 4094983764 #define SIGNATURE_HASH 745925457
#define TS_SIGNATURE "rusEFI 2020.07.29.frankenso_na6.4094983764" #define TS_SIGNATURE "rusEFI 2020.07.29.frankenso_na6.745925457"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD kin #define SIGNATURE_BOARD kin
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 3886927405 #define SIGNATURE_HASH 1070357288
#define TS_SIGNATURE "rusEFI 2020.07.29.kin.3886927405" #define TS_SIGNATURE "rusEFI 2020.07.29.kin.1070357288"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD mre_f4 #define SIGNATURE_BOARD mre_f4
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 1668138041 #define SIGNATURE_HASH 3138146620
#define TS_SIGNATURE "rusEFI 2020.07.29.mre_f4.1668138041" #define TS_SIGNATURE "rusEFI 2020.07.29.mre_f4.3138146620"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD mre_f7 #define SIGNATURE_BOARD mre_f7
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 1668138041 #define SIGNATURE_HASH 3138146620
#define TS_SIGNATURE "rusEFI 2020.07.29.mre_f7.1668138041" #define TS_SIGNATURE "rusEFI 2020.07.29.mre_f7.3138146620"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD prometheus_405 #define SIGNATURE_BOARD prometheus_405
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 3750742579 #define SIGNATURE_HASH 133062454
#define TS_SIGNATURE "rusEFI 2020.07.29.prometheus_405.3750742579" #define TS_SIGNATURE "rusEFI 2020.07.29.prometheus_405.133062454"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD prometheus_469 #define SIGNATURE_BOARD prometheus_469
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 3750742579 #define SIGNATURE_HASH 133062454
#define TS_SIGNATURE "rusEFI 2020.07.29.prometheus_469.3750742579" #define TS_SIGNATURE "rusEFI 2020.07.29.prometheus_469.133062454"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD proteus_f4 #define SIGNATURE_BOARD proteus_f4
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 2801951608 #define SIGNATURE_HASH 2137257597
#define TS_SIGNATURE "rusEFI 2020.07.29.proteus_f4.2801951608" #define TS_SIGNATURE "rusEFI 2020.07.29.proteus_f4.2137257597"

View File

@ -4,5 +4,5 @@
#define SIGNATURE_BOARD proteus_f7 #define SIGNATURE_BOARD proteus_f7
#define SIGNATURE_DATE 2020.07.29 #define SIGNATURE_DATE 2020.07.29
#define SIGNATURE_HASH 2801951608 #define SIGNATURE_HASH 2137257597
#define TS_SIGNATURE "rusEFI 2020.07.29.proteus_f7.2801951608" #define TS_SIGNATURE "rusEFI 2020.07.29.proteus_f7.2137257597"

View File

@ -20,7 +20,7 @@ public:
private: private:
// Steinhart-Hart coefficients // Steinhart-Hart coefficients
float m_a; float m_a = 0;
float m_b; float m_b = 0;
float m_c; float m_c = 0;
}; };

View File

@ -24,7 +24,7 @@ public:
void showInfo(Logging* logger, const char* sensorName) const override; void showInfo(Logging* logger, const char* sensorName) const override;
private: private:
SensorResult get() const { SensorResult get() const override {
return Sensor::get(m_proxiedSensor); return Sensor::get(m_proxiedSensor);
} }

View File

@ -51,7 +51,7 @@ bool Sensor::Register() {
return false; return false;
} else { } else {
// put ourselves in the registry // put ourselves in the registry
s_sensorRegistry[getIndex()].sensor = this; entry.sensor = this;
return true; return true;
} }
} }

View File

@ -60,25 +60,6 @@ static Logging logger("settings control", LOGGING_BUFFER, sizeof(LOGGING_BUFFER)
EXTERN_ENGINE; EXTERN_ENGINE;
/*
static void printIntArray(int array[], int size) {
for (int j = 0; j < size; j++) {
print("%d ", array[j]);
}
print("\r\n");
}
*/
void printFloatArray(const char *prefix, float array[], int size) {
appendMsgPrefix(&logger);
appendPrintf(&logger, prefix);
for (int j = 0; j < size; j++) {
appendPrintf(&logger, "%.2f ", array[j]);
}
appendMsgPostfix(&logger);
scheduleLogging(&logger);
}
void printSpiState(Logging *logger, const engine_configuration_s *engineConfiguration) { void printSpiState(Logging *logger, const engine_configuration_s *engineConfiguration) {
scheduleMsg(logger, "spi 1=%s/2=%s/3=%s/4=%s", scheduleMsg(logger, "spi 1=%s/2=%s/3=%s/4=%s",
boolToString(engineConfiguration->is_enabled_spi_1), boolToString(engineConfiguration->is_enabled_spi_1),
@ -211,19 +192,6 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) {
// print("\r\n"); // print("\r\n");
} }
// printFloatArray("RPM bin: ", config->fuelRpmBins, FUEL_RPM_COUNT);
//
// printFloatArray("Y bin: ", config->fuelLoadBins, FUEL_LOAD_COUNT);
//
// printFloatArray("CLT: ", config->cltFuelCorr, CLT_CURVE_SIZE);
// printFloatArray("CLT bins: ", config->cltFuelCorrBins, CLT_CURVE_SIZE);
//
// printFloatArray("IAT: ", config->iatFuelCorr, IAT_CURVE_SIZE);
// printFloatArray("IAT bins: ", config->iatFuelCorrBins, IAT_CURVE_SIZE);
//
// printFloatArray("vBatt: ", engineConfiguration->injector.battLagCorr, VBAT_INJECTOR_CURVE_SIZE);
// printFloatArray("vBatt bins: ", engineConfiguration->injector.battLagCorrBins, VBAT_INJECTOR_CURVE_SIZE);
scheduleMsg(&logger, "rpmHardLimit: %d/operationMode=%d", engineConfiguration->rpmHardLimit, scheduleMsg(&logger, "rpmHardLimit: %d/operationMode=%d", engineConfiguration->rpmHardLimit,
engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE)); engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE));

View File

@ -77,7 +77,7 @@ private:
OutputPin* const m_disable; OutputPin* const m_disable;
float m_value = 0; float m_value = 0;
ControlType m_type; ControlType m_type = ControlType::PwmDirectionPins;
public: public:
/** /**
* @param enable SimplePwm driver for enable pin, for PWM speed control. * @param enable SimplePwm driver for enable pin, for PWM speed control.
@ -90,8 +90,8 @@ public:
float get() const override; float get() const override;
bool isOpenDirection() const override; bool isOpenDirection() const override;
void enable(); void enable() override;
void disable(); void disable() override;
void setType(ControlType type) { m_type = type; } void setType(ControlType type) { m_type = type; }
}; };

View File

@ -25,9 +25,6 @@ extern bool verboseMode;
uint32_t maxSchedulingPrecisionLoss = 0; uint32_t maxSchedulingPrecisionLoss = 0;
bool EventQueue::checkIfPending(scheduling_s *scheduling) {
assertNotInListMethodBody(scheduling_s, head, scheduling, nextScheduling_s);
}
/** /**
* @return true if inserted into the head of the list * @return true if inserted into the head of the list

View File

@ -64,7 +64,6 @@ public:
scheduling_s * getHead(); scheduling_s * getHead();
void assertListIsSorted() const; void assertListIsSorted() const;
private: private:
bool checkIfPending(scheduling_s *scheduling);
/** /**
* this list is sorted * this list is sorted
*/ */

View File

@ -14,7 +14,6 @@
#include "main_trigger_callback.h" #include "main_trigger_callback.h"
#include "engine_configuration.h" #include "engine_configuration.h"
#include "listener_array.h" #include "listener_array.h"
#include "data_buffer.h"
#include "pwm_generator_logic.h" #include "pwm_generator_logic.h"
#include "tooth_logger.h" #include "tooth_logger.h"

View File

@ -16,7 +16,6 @@
#include "global.h" #include "global.h"
#include "os_access.h" #include "os_access.h"
#include "eficonsole.h" #include "eficonsole.h"
#include "data_buffer.h"
#include "pin_repository.h" #include "pin_repository.h"
#include "allsensors.h" #include "allsensors.h"
#include "engine_configuration.h" #include "engine_configuration.h"

View File

@ -28,7 +28,7 @@ public:
/** /**
* Create a new CAN message, with the specified extended ID. * Create a new CAN message, with the specified extended ID.
*/ */
CanTxMessage(uint32_t eid, uint8_t dlc = 8); explicit CanTxMessage(uint32_t eid, uint8_t dlc = 8);
/** /**
* Destruction of an instance of CanTxMessage will transmit the message over the wire. * Destruction of an instance of CanTxMessage will transmit the message over the wire.
@ -71,7 +71,7 @@ class CanTxTyped final : public CanTxMessage
static_assert(sizeof(TData) == sizeof(CANTxFrame::data8)); static_assert(sizeof(TData) == sizeof(CANTxFrame::data8));
public: public:
CanTxTyped(uint32_t eid) : CanTxMessage(eid) { } explicit CanTxTyped(uint32_t eid) : CanTxMessage(eid) { }
/** /**
* Access members of the templated type. * Access members of the templated type.

View File

@ -149,15 +149,6 @@ static I2CConfig i2cfg = { HAL_I2C_F7_100_TIMINGR, 0, 0 }; // todo: does it work
static I2CConfig i2cfg = { OPMODE_I2C, 100000, STD_DUTY_CYCLE, }; static I2CConfig i2cfg = { OPMODE_I2C, 100000, STD_DUTY_CYCLE, };
#endif /* defined(STM32F4XX) */ #endif /* defined(STM32F4XX) */
void initI2Cmodule(void) {
print("Starting I2C module\r\n");
i2cInit();
i2cStart(&I2CD1, &i2cfg);
efiSetPadMode("I2C clock", EFI_I2C_SCL_BRAIN_PIN, PAL_MODE_ALTERNATE(EFI_I2C_AF) | PAL_STM32_OTYPE_OPENDRAIN);
efiSetPadMode("I2C data", EFI_I2C_SDA_BRAIN_PIN, PAL_MODE_ALTERNATE(EFI_I2C_AF) | PAL_STM32_OTYPE_OPENDRAIN);
}
//static char txbuf[1]; //static char txbuf[1];
static void sendI2Cbyte(int addr, int data) { static void sendI2Cbyte(int addr, int data) {
@ -474,7 +465,6 @@ void initHardware(Logging *l) {
initSingleTimerExecutorHardware(); initSingleTimerExecutorHardware();
#if EFI_HD44780_LCD #if EFI_HD44780_LCD
// initI2Cmodule();
lcd_HD44780_init(sharedLogger); lcd_HD44780_init(sharedLogger);
if (hasFirmwareError()) if (hasFirmwareError())
return; return;

View File

@ -268,8 +268,6 @@ static const USBEndpointConfig ep2config = {
* Handles the USB driver global events. * Handles the USB driver global events.
*/ */
static void usb_event(USBDriver *usbp, usbevent_t event) { static void usb_event(USBDriver *usbp, usbevent_t event) {
extern SerialUSBDriver SDU1;
switch (event) { switch (event) {
case USB_EVENT_ADDRESS: case USB_EVENT_ADDRESS:
return; return;

View File

@ -49,8 +49,8 @@ public:
void step(bool positive) override; void step(bool positive) override;
private: private:
DcMotor* m_motorPhaseA; DcMotor* m_motorPhaseA = nullptr;
DcMotor* m_motorPhaseB; DcMotor* m_motorPhaseB = nullptr;
uint8_t m_phase = 0; uint8_t m_phase = 0;
}; };

View File

@ -1640,12 +1640,13 @@ end_struct
#define PROTOCOL_COIL1_SHORT_NAME "c1" #define PROTOCOL_COIL1_SHORT_NAME "c1"
#define PROTOCOL_INJ1_SHORT_NAME "i1" #define PROTOCOL_INJ1_SHORT_NAME "i1"
#define ET_MRE_MIATA_NA6 12 #define ET_MRE_MIATA_NA6_VAF 12
#define ET_MRE_MIATA_NB2_MAP 11 #define ET_MRE_MIATA_NB2_MAP 11
#define ET_MRE_MIATA_NB2_MAF 15 #define ET_MRE_MIATA_NB2_MAF 15
#define ET_MRE_OLD_TEST_BOARD 30 #define ET_MRE_OLD_TEST_BOARD 30
#define ET_MRE_NEW_TEST_BOARD 31 #define ET_MRE_NEW_TEST_BOARD 31
#define ET_MRE_DEFAULTS 60 #define ET_MRE_DEFAULTS 60
#define ET_MRE_MIATA_NA6_MAP 66
#define ET_FRANKENSO_MIATA_NA6 41 #define ET_FRANKENSO_MIATA_NA6 41
#define ET_FRANKENSO_MIATA_NB2 47 #define ET_FRANKENSO_MIATA_NB2 47

View File

@ -1490,7 +1490,10 @@ cmd_dfu = "w\x00\xba\x00\x00"
cmd_set_engine_type_microRusEFI_Miata_NB2_MAP = "w\x00\x30@@ET_MRE_MIATA_NB2_MAP_16_hex@@" cmd_set_engine_type_microRusEFI_Miata_NB2_MAP = "w\x00\x30@@ET_MRE_MIATA_NB2_MAP_16_hex@@"
; MRE_MIATA_NA6 12 ; MRE_MIATA_NA6 12
cmd_set_engine_type_microRusEFI_Miata_NA6 = "w\x00\x30@@ET_MRE_MIATA_NA6_16_hex@@" cmd_set_engine_type_microRusEFI_Miata_NA6_VAF = "w\x00\x30@@ET_MRE_MIATA_NA6_VAF_16_hex@@"
cmd_set_engine_type_microRusEFI_Miata_NA6_MAP = "w\x00\x30@@ET_MRE_MIATA_NA6_MAP_16_hex@@"
; MRE_MIATA_NB2_MAF = 15 ; MRE_MIATA_NB2_MAF = 15
cmd_set_engine_type_microRusEFI_Miata_NB2_MAF = "w\x00\x30@@ET_MRE_MIATA_NB2_MAF_16_hex@@" cmd_set_engine_type_microRusEFI_Miata_NB2_MAF = "w\x00\x30@@ET_MRE_MIATA_NB2_MAF_16_hex@@"
@ -2944,6 +2947,8 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
commandButton = "Frankenso Miata NA6 Stage 1", cmd_set_engine_type_Frankenso_Miata_NA6_MAP@@if_show_Frankenso_presets commandButton = "Frankenso Miata NA6 Stage 1", cmd_set_engine_type_Frankenso_Miata_NA6_MAP@@if_show_Frankenso_presets
commandButton = "Frankenso Miata NB2 MAP", cmd_set_engine_type_Frankenso_Miata_NB2@@if_show_Frankenso_presets commandButton = "Frankenso Miata NB2 MAP", cmd_set_engine_type_Frankenso_Miata_NB2@@if_show_Frankenso_presets
commandButton = "microRusEFI Miata NA6 VAF", cmd_set_engine_type_microRusEFI_Miata_NA6_VAF@@if_show_microRusEFI_presets
commandButton = "microRusEFI Miata NA6 MAP", cmd_set_engine_type_microRusEFI_Miata_NA6_MAP@@if_show_microRusEFI_presets
commandButton = "microRusEfi Miata NB2 MAP", cmd_set_engine_type_microRusEFI_Miata_NB2_MAP@@if_show_microRusEFI_presets commandButton = "microRusEfi Miata NB2 MAP", cmd_set_engine_type_microRusEFI_Miata_NB2_MAP@@if_show_microRusEFI_presets
commandButton = "microRusEFI Miata NB2 MAF", cmd_set_engine_type_microRusEFI_Miata_NB2_MAF@@if_show_microRusEFI_presets commandButton = "microRusEFI Miata NB2 MAF", cmd_set_engine_type_microRusEFI_Miata_NB2_MAF@@if_show_microRusEFI_presets
commandButton = "microRusEFI Defaults", cmd_set_engine_type_microRusEFI_Defaults@@if_show_microRusEFI_presets commandButton = "microRusEFI Defaults", cmd_set_engine_type_microRusEFI_Defaults@@if_show_microRusEFI_presets

View File

@ -1,66 +0,0 @@
/*@
* @file data_buffer.c
*
* @date Dec 8, 2012
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "data_buffer.h"
int dbIsFull(data_buffer_s *db) {
return db->size == DB_MAX_SIZE;
}
void dbClear(data_buffer_s *db) {
db->size = 0;
}
void dbCopy(data_buffer_s *source, data_buffer_s *target) {
int s = source->size;
target->size = s;
for (int i = 0; i < s; i++)
target->elements[i] = source->elements[i];
}
void dbAdd(data_buffer_s *db, int value) {
if (db->size == DB_MAX_SIZE)
return;
int s = db->size;
db->elements[s] = value;
db->size = s + 1;
}
int modp(int param) {
return param > EF_PERIOD ? param - EF_PERIOD : param;
}
//void dbPrint(data_buffer_s *db, char *message, int withDiff) {
// int s = db->size;
// print("buffer [%s] size=%d\r\n", message, s);
// int range = db->elements[s - 1] - db->elements[0];
// print("range %d\r\n", range);
//
// for (int i = 0; i < s; i++) {
// print("%d: %d", i, db->elements[i]);
// if (withDiff && i > 0) {
// int diff = modp(db->elements[i]) - modp(db->elements[i - 1]);
// print(" t=%d", diff);
// }
// print("\r\n");
// }
//}
//void dbPrintTable(data_buffer_s *table[], char *caption[], int columns) {
// for (int c = 0; c < columns; c++)
// print("%7s", caption[c]);
// print("\r\n");
//
// for (int r = 0; r < DB_MAX_SIZE; r++) {
// for (int c = 0; c < columns; c++) {
// data_buffer_s *buf = table[c];
// print("%7d", buf->elements[r]);
// }
// print("\r\n");
// }
//}

View File

@ -1,24 +0,0 @@
/*
* data_buffer.h
*
* @date Dec 8, 2012
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#define DB_MAX_SIZE 1024
#define EF_PERIOD 100000000
typedef struct {
int elements[DB_MAX_SIZE];
int size;
} data_buffer_s;
int dbIsFull(data_buffer_s *db);
void dbClear(data_buffer_s *db);
void dbAdd(data_buffer_s *db, int value);
void dbCopy(data_buffer_s *source, data_buffer_s *target);
void dbPrint(data_buffer_s *db, char *message, int withDiff);
void dbPrintTable(data_buffer_s *table[], char *caption[], int columns);

View File

@ -112,7 +112,7 @@ void append(Logging *logging, const char *text) {
* @note This method if fast because it does not validate much, be sure what you are doing * @note This method if fast because it does not validate much, be sure what you are doing
*/ */
void appendFast(Logging *logging, const char *text) { void appendFast(Logging *logging, const char *text) {
register char *s; char *s;
s = logging->linePointer; s = logging->linePointer;
while ((*s++ = *text++) != 0) while ((*s++ = *text++) != 0)
; ;

View File

@ -64,7 +64,7 @@ float clampF(float min, float clamp, float max) {
} }
uint32_t efiStrlen(const char *param) { uint32_t efiStrlen(const char *param) {
register const char *s; const char *s;
for (s = param; *s; ++s) for (s = param; *s; ++s)
; ;
return (s - param); return (s - param);

View File

@ -1,60 +0,0 @@
/*
* avg_values.c
*
* @date Jul 23, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "avg_values.h"
#include <math.h>
void avgFill(AvgTable *table, int count, float value) {
for (int i = 0; i < AVG_TAB_SIZE; i++) {
for (int j = 0; j < AVG_TAB_SIZE; j++) {
table->counts[i][j] = count;
table->values[i][j] = value;
}
}
}
void avgReset(AvgTable *table) {
avgFill(table, 0, 0);
}
void avgAddValue(AvgTable *table, int rpm, float key, float value) {
if (rpm >= MAX_RPM || key >= MAX_KEY) {
return;
}
int i = (int)(AVG_TAB_SIZE * rpm / MAX_RPM);
int j = (int)(AVG_TAB_SIZE * key / MAX_KEY);
table->values[i][j] += value;
table->counts[i][j]++;
}
float avgGetValueByIndexes(AvgTable *table, int i, int j) {
int count = table->counts[i][j];
if (count == 0) {
return NAN;
}
return table->values[i][j] / count;
}
float avgGetValue(AvgTable *table, int rpm, float key) {
if (rpm >= MAX_RPM || key >= MAX_KEY) {
return NAN;
}
int i = (int)(AVG_TAB_SIZE * rpm / MAX_RPM);
int j = (int)(AVG_TAB_SIZE * key / MAX_KEY);
return avgGetValueByIndexes(table, i, j);
}
int avgGetValuesCount(AvgTable *table, int rpm, float key) {
if (rpm >= MAX_RPM || key >= MAX_KEY) {
return 0;
}
int i = (int)(AVG_TAB_SIZE * rpm / MAX_RPM);
int j = (int)(AVG_TAB_SIZE * key / MAX_KEY);
return table->counts[i][j];
}

View File

@ -1,27 +0,0 @@
/*
* avg_values.h
*
* @date Jul 23, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#define AVG_TAB_SIZE 48
#define MAX_RPM 8000
#define MAX_KEY 5
typedef struct {
float values[AVG_TAB_SIZE][AVG_TAB_SIZE];
int counts[AVG_TAB_SIZE][AVG_TAB_SIZE];
} AvgTable;
void avgReset(AvgTable *table);
void avgFill(AvgTable *table, int count, float value);
void avgAddValue(AvgTable *table, int rpm, float key, float value);
float avgGetValueByIndexes(AvgTable *table, int i, int j);
float avgGetValue(AvgTable *table, int rpm, float key);
int avgGetValuesCount(AvgTable *table, int rpm, float key);

View File

@ -1,63 +0,0 @@
/*
* @file signal_filtering.c
*
* @date Aug 5, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#ifndef SIGNAL_FILTERING_C_
#define SIGNAL_FILTERING_C_
#include "signal_filtering.h"
void sfInit(SignalFiltering *fs, float K, float initialValue) {
fs->pointer = 0;
fs->K = K;
fs->Vout = initialValue;
fs->Vacc = initialValue * K;
}
static void addCopyAndSort(SignalFiltering *fs, float value) {
fs->values[fs->pointer] = value;
fs->pointer = ++fs->pointer == FILTER_SIZE ? 0 : fs->pointer;
copyArray(fs->sorted, fs->values);
for (int i = 0; i < FILTER_SIZE; i++)
for (int j = i + 1; j < FILTER_SIZE; j++)
if (fs->sorted[i] < fs->sorted[j]) {
float temp = fs->sorted[i];
fs->sorted[i] = fs->sorted[j];
fs->sorted[j] = temp;
}
}
void sfAddValue(SignalFiltering *fs, float value) {
addCopyAndSort(fs, value);
float Vin = fs->sorted[FILTER_SIZE / 2];
fs->Vacc += Vin - fs->Vout;
fs->Vout = fs->Vacc / fs->K;
}
void sfAddValue2(SignalFiltering *fs, float value) {
addCopyAndSort(fs, value);
int fromIndex = FILTER_SIZE / 4;
int toIndex = FILTER_SIZE / 4 + FILTER_SIZE / 2;
/**
* this implementation takes the average of the middle hald of the sorted values
*/
float result = 0;
for (int i = fromIndex; i < toIndex; i++)
result += fs->sorted[i];
fs->Vout = result / (FILTER_SIZE / 2);
}
float sfGetValue(SignalFiltering *fs) {
return fs->Vout;
}
#endif /* SIGNAL_FILTERING_C_ */

View File

@ -1,22 +0,0 @@
/*
* @file signal_filtering.h
*
* @date Aug 5, 2013
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#pragma once
#define FILTER_SIZE 5
typedef struct {
float values[FILTER_SIZE];
float sorted[FILTER_SIZE];
int pointer;
float K, Vacc, Vout;
} SignalFiltering;
void sfInit(SignalFiltering *fs, float K, float initialValue);
void sfAddValue(SignalFiltering *fs, float value);
void sfAddValue2(SignalFiltering *fs, float value);
float sfGetValue(SignalFiltering *fs);

View File

@ -1,113 +0,0 @@
/**
* @file unaligned.c
* @brief unaligned data access helpers
*
* @date May, 2019
* @author Andrey Gusakov, (c) 2019
*
* This file is part of rusEfi - see http://rusefi.com
*
* rusEfi is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "unaligned.h"
#include "common.h"
/* generate mask */
static inline uint32_t bit_mask(unsigned int from, unsigned int to)
{
uint32_t mask = 0;
uint32_t shift;
if (to < from)
return 0;
shift = to - from + 1U;
if ((shift > 0U) && (shift <= 32U) && (from <= 31U)) {
if (shift < 32U) {
mask = (uint32_t)((1UL << shift) - 1UL);
mask = mask << from;
} else {
mask = 0xFFFFFFFFUL;
}
}
return mask;
}
/* get upto 32 bits from char array p, from bit position pos, lenght len */
uint32_t bits_get(uint8_t *p, unsigned int pos, int len)
{
int i;
unsigned int offset = 0;
uint32_t res = 0;
i = (int)pos / 8;
while (len > 0) {
uint32_t tmp;
uint32_t mask;
int nbits = 8 - ((int)pos % 8);
/* get */
tmp = (uint32_t)p[i];
/* shift */
tmp = tmp >> (8U - (uint32_t)nbits);
/* mask */
mask = bit_mask(0, MIN((uint32_t)len - 1U, (uint32_t)nbits - 1U));
tmp = tmp & mask;
res = res | ((tmp) << offset);
/* adjust for the next iteration */
offset += (unsigned int)nbits;
len -= nbits;
pos += (unsigned int)nbits;
i++;
}
return res;
}
/* set upto 32 bits in char array p, from bit position pos, lenght len */
void bits_set(uint8_t *p, unsigned int pos, int len, uint32_t val)
{
int i;
unsigned int offset = 0;
i = (int)pos / 8;
while (len > 0) {
uint32_t tmp;
uint32_t mask;
/* get number of bits to shift to get to the target range */
int shift = (int)pos % 8;
/* get next byte */
tmp = (val >> offset) & 0xffU;
/* shift temporary value to the start of the target range */
tmp = tmp << (uint8_t)shift;
/* calculate mask */
mask = bit_mask((uint32_t)shift, MIN(8U - 1U, (unsigned int)shift + (unsigned int)len - 1U));
/* clean all bits outside of the target range */
tmp &= mask;
/* pre-clean all target bits */
p[i] = p[i] & ~((uint8_t)mask);
/* finally set active bits */
p[i] |= (uint8_t)tmp;
/* adjust for the next iteration */
offset += ((uint32_t)8U - (uint32_t)shift);
len -= (8 - shift);
pos += ((unsigned int)8U - (unsigned int)shift);
i++;
}
}

View File

@ -1,105 +0,0 @@
/**
* @file unaligned.h
* @brief unaligned data access helpers header file
*
* @date May, 2019
* @author Andrey Gusakov, (c) 2019
*
* This file is part of rusEfi - see http://rusefi.com
*
* rusEfi is free software; you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UNALIGNED_H_INCLUDED
#define UNALIGNED_H_INCLUDED
#include <stdint.h>
/* bit operations */
uint32_t bits_get(uint8_t *p, unsigned int pos, int len);
void bits_set(uint8_t *p, unsigned int pos, int len, uint32_t val);
#define bit_set(p, pos) do {(p)[(pos) / 8] |= (1 << ((pos) % 8));} while(0)
#define bit_clr(p, pos) do {(p)[(pos) / 8] &= ~(1 << ((pos) % 8));} while(0)
#define bit_get(p, pos) (!!((p)[(pos) / 8] & (1 << ((pos) % 8))))
/* unaligned access */
static inline void put_be8(uint8_t *p, uint8_t v)
{
p[0] = v;
}
static inline void put_le8(uint8_t *p, uint8_t v)
{
p[0] = v;
}
static inline void put_be16(uint8_t *p, uint16_t v)
{
p[0] = (uint8_t)(v >> 8);
p[1] = (uint8_t)(v >> 0);
}
static inline void put_le16(uint8_t *p, uint16_t v)
{
p[0] = (uint8_t)(v >> 0);
p[1] = (uint8_t)(v >> 8);
}
static inline void put_be32(uint8_t *p, uint32_t v)
{
p[0] = (uint8_t)(v >> 24);
p[1] = (uint8_t)(v >> 16);
p[2] = (uint8_t)(v >> 8);
p[3] = (uint8_t)(v >> 0);
}
static inline void put_le32(uint8_t *p, uint32_t v)
{
p[0] = (uint8_t)(v >> 0);
p[1] = (uint8_t)(v >> 8);
p[2] = (uint8_t)(v >> 16);
p[3] = (uint8_t)(v >> 24);
}
static inline uint8_t get_be8(uint8_t *p)
{
return p[0];
}
static inline uint8_t get_le8(uint8_t *p)
{
return p[0];
}
static inline uint16_t get_be16(uint8_t *p)
{
return ((uint16_t)p[0] << 8) | p[1];
}
static inline uint16_t get_le16(uint8_t *p)
{
return ((uint16_t)p[1] << 8) | p[0];
}
static inline uint32_t get_be32(uint8_t *p)
{
return ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) |
((uint32_t)p[2] << 8) | p[3];
}
static inline uint32_t get_le32(uint8_t *p)
{
return ((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16) |
((uint32_t)p[1] << 8) | p[0];
}
#endif /* UNALIGNED_H_INCLUDED */

View File

@ -1,11 +1,9 @@
UTIL_DIR=$(PROJECT_DIR)/util UTIL_DIR=$(PROJECT_DIR)/util
UTILSRC = \ UTILSRC = \
$(UTIL_DIR)/containers/data_buffer.c \
$(UTIL_DIR)/math/crc.c \ $(UTIL_DIR)/math/crc.c \
$(UTIL_DIR)/os_util.c \ $(UTIL_DIR)/os_util.c \
$(UTIL_DIR)/histogram.c \ $(UTIL_DIR)/histogram.c
$(UTIL_DIR)/unaligned.c
UTILSRC_CPP = \ UTILSRC_CPP = \
$(UTIL_DIR)/containers/cyclic_buffer.cpp \ $(UTIL_DIR)/containers/cyclic_buffer.cpp \
@ -14,7 +12,6 @@ UTILSRC_CPP = \
$(UTIL_DIR)/containers/local_version_holder.cpp \ $(UTIL_DIR)/containers/local_version_holder.cpp \
$(UTIL_DIR)/containers/table_helper.cpp \ $(UTIL_DIR)/containers/table_helper.cpp \
$(UTIL_DIR)/math/pid.cpp \ $(UTIL_DIR)/math/pid.cpp \
$(UTIL_DIR)/math/avg_values.cpp \
$(UTIL_DIR)/math/interpolation.cpp \ $(UTIL_DIR)/math/interpolation.cpp \
$(PROJECT_DIR)/util/datalogging.cpp \ $(PROJECT_DIR)/util/datalogging.cpp \
$(PROJECT_DIR)/util/loggingcentral.cpp \ $(PROJECT_DIR)/util/loggingcentral.cpp \