Merge remote-tracking branch 'origin/master'

# Conflicts:
#	firmware/controllers/engine_controller.cpp
This commit is contained in:
rusefi 2020-05-13 19:31:42 -04:00
commit a078922244
15 changed files with 119 additions and 74 deletions

View File

@ -31,4 +31,4 @@ endif
# Add them all together
DDEFS += $(MCU_DEFS) -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"microRusEfi\" $(DEFAULT_ENGINE_TYPE)
DDEFS += $(MCU_DEFS) -DEFI_USE_OSC=TRUE -DFIRMWARE_ID=\"microRusEfi\" $(DEFAULT_ENGINE_TYPE) $(LED_CRITICAL_ERROR_BRAIN_PIN)

View File

@ -70,7 +70,7 @@ static void setLedPins() {
engineConfiguration->communicationLedPin = GPIOE_2; // d23 = blue
#endif /* EFI_COMMUNICATION_PIN */
engineConfiguration->runningLedPin = GPIOE_4; // d22 = green
engineConfiguration->triggerErrorPin = GPIOE_1; // d27 = orange
engineConfiguration->warningLedPin = GPIOE_1; // d27 = orange or yellow
}
static void setupVbatt() {

View File

@ -168,6 +168,8 @@ static const ignition_table_t mapBased18vvtTimingTable = {
};
#endif
/*
#define MAF_TRANSFER_SIZE 8
static const float mafTransferVolts[MAF_TRANSFER_SIZE] = {1.365,
@ -180,6 +182,9 @@ static const float mafTransferVolts[MAF_TRANSFER_SIZE] = {1.365,
4.011,
};
according to internet this should be the Miata NB transfer function but in reality it seems off
this could be related to us not using proper signal conditioning hardware
static const float mafTransferKgH[MAF_TRANSFER_SIZE] = {
0,
3.9456,
@ -191,6 +196,39 @@ static const float mafTransferKgH[MAF_TRANSFER_SIZE] = {
594.2772
};
*/
#define MAF_TRANSFER_SIZE 10
// this transfer function somehow works with 1K pull-down
static const float mafTransferVolts[MAF_TRANSFER_SIZE] = {
0.50,
0.87,
1.07,
1.53,
1.85,
2.11,
2.46,
3.00,
3.51,
4.50
};
static const float mafTransferKgH[MAF_TRANSFER_SIZE] = {
0.00,
0.00,
1.00,
3.00,
8.00,
19.00,
45.00,
100.00,
175.00,
350.00
};
static void setMAFTransferFunction(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
memcpy(config->mafDecoding, mafTransferKgH, sizeof(mafTransferKgH));
memcpy(config->mafDecodingBins, mafTransferVolts, sizeof(mafTransferVolts));
@ -634,8 +672,7 @@ void setMiataNB2_MRE_MTB(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
setMiataNB2_MRE_common(PASS_CONFIG_PARAMETER_SIGNATURE);
// somehow MRE72 adapter 0.2 has TPS routed to pin 26?
engineConfiguration->tps1_1AdcChannel = EFI_ADC_13;
engineConfiguration->tps1_1AdcChannel = EFI_ADC_6; // PA6
// 1K pull-down to read current from this MAF

View File

@ -604,6 +604,9 @@ class CommunicationBlinkingTask : public PeriodicTimerController {
void PeriodicTask() override {
counter++;
bool lowVBatt = getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) < LOW_VBATT;
if (counter == 1) {
// first invocation of BlinkingTask
setAllLeds(1);
@ -612,7 +615,9 @@ class CommunicationBlinkingTask : public PeriodicTimerController {
setAllLeds(0);
} else if (counter % 2 == 0) {
enginePins.communicationLedPin.setValue(0);
enginePins.warningLedPin.setValue(0);
if (!lowVBatt) {
enginePins.warningLedPin.setValue(0);
}
} else {
if (hasFirmwareError()) {
// special behavior in case of critical error - not equal on/off time
@ -632,7 +637,7 @@ class CommunicationBlinkingTask : public PeriodicTimerController {
enginePins.communicationLedPin.setValue(1);
#if EFI_ENGINE_CONTROL
if (isTriggerErrorNow() || isIgnitionTimingError() || consoleByteArrived) {
if (lowVBatt || isTriggerErrorNow() || isIgnitionTimingError() || consoleByteArrived) {
consoleByteArrived = false;
enginePins.warningLedPin.setValue(1);
}

View File

@ -740,7 +740,7 @@ void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
void runHardcodedFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// see MAIN_RELAY_LOGIC
if (CONFIG(mainRelayPin) != GPIO_UNASSIGNED) {
enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) > 5) || engine->isInShutdownMode());
enginePins.mainRelay.setValue((getTimeNowSeconds() < 2) || (getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE) > LOW_VBATT) || engine->isInShutdownMode());
}
// see STARTER_RELAY_LOGIC
if (CONFIG(starterRelayDisablePin) != GPIO_UNASSIGNED) {

View File

@ -10,8 +10,13 @@
#pragma once
#include "global.h"
#define LOW_VBATT 7
#ifdef __cplusplus
#include "engine_configuration.h"
float getVRef(DECLARE_ENGINE_PARAMETER_SIGNATURE);
float getVBatt(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool hasVBatt(DECLARE_ENGINE_PARAMETER_SIGNATURE);
#endif /* __cplusplus */

View File

@ -718,7 +718,7 @@ void initTriggerDecoderLogger(Logging *sharedLogger) {
void initTriggerDecoder(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_GPIO_HARDWARE
enginePins.triggerDecoderErrorPin.initPin("trg_err", CONFIG(triggerErrorPin),
enginePins.triggerDecoderErrorPin.initPin("led: trigger debug", CONFIG(triggerErrorPin),
&CONFIG(triggerErrorPinMode));
#endif /* EFI_GPIO_HARDWARE */
}

View File

@ -18,4 +18,4 @@ HW_LAYER_DRIVERS = \
HW_LAYER_DRIVERS_CPP = \
$(DRIVERS_DIR)/can/can_hw.cpp \
$(DRIVERS_DIR)/can/can_msg_tx.cpp \
$(DRIVERS_DIR)/serial/serial_hw.cpp \
$(DRIVERS_DIR)/serial/serial_hw.cpp

View File

@ -40,6 +40,7 @@
#include "gpio/gpio_ext.h"
#include "pin_repository.h"
#include "os_util.h"
#include "voltage.h"
EXTERN_ENGINE_CONFIGURATION;
@ -82,7 +83,8 @@ typedef enum {
#define FWDRespCmd(d) CMD_WR(0x16, d)
#define FWDRespSyncCmd(d) CMD_WR(0x17, d)
#define CMD_SR CMD_WR(0x1a, 0x03)
#define CMD_SR_CODE 0x1a
#define CMD_SR CMD_WR(CMD_SR_CODE, 0x03)
// 0x238 = 568
#define CMD_OE_SET CMD_WR(0x1c, 0x02)
/* not used
@ -191,10 +193,6 @@ float vBattForTle8888 = 0;
// set debug_mode 31
static int tle8888SpiCounter = 0;
// that's a strange variable for troubleshooting
int tle8888initResponsesAccumulator = 0;
static int initResponse0 = 0;
static int initResponse1 = 0;
static uint16_t spiRxb = 0, spiTxb = 0;
@ -253,10 +251,7 @@ void tle8888PostState(TsDebugChannels *debugChannels) {
//debugChannels->debugIntField1 = tle8888SpiCounter;
//debugChannels->debugIntField2 = spiTxb;
//debugChannels->debugIntField3 = spiRxb;
debugChannels->debugIntField4 = tle8888initResponsesAccumulator;
debugChannels->debugIntField5 = tle8888reinitializationCounter;
debugChannels->debugFloatField1 = initResponse0;
debugChannels->debugFloatField2 = initResponse1;
debugChannels->debugFloatField3 = chips[0].OpStat[1];
debugChannels->debugFloatField4 = selfResetCounter * 1000000 + requestedResetCounter * 10000 + lowVoltageResetCounter;
@ -503,16 +498,12 @@ static void handleFWDStat1(struct tle8888_priv *chip, int registerNum, int data)
tle8888_spi_rw(chip, CMD_WdDiag, &wdDiagResponse);
}
int startupConfiguration(struct tle8888_priv *chip) {
static int startupConfiguration(struct tle8888_priv *chip) {
const struct tle8888_config *cfg = chip->cfg;
uint16_t response = 0;
/* Set LOCK bit to 0 */
// second 0x13D=317 => 0x35=53
tle8888_spi_rw(chip, CMD_UNLOCK, &response);
if (response == 53) {
tle8888initResponsesAccumulator += 8;
}
initResponse1 = response;
chip->o_direct_mask = 0;
chip->o_oe_mask = 0;
@ -637,7 +628,7 @@ static THD_FUNCTION(tle8888_driver_thread, p) {
/* should we care about msg == MSG_TIMEOUT? */
(void)msg;
if (vBattForTle8888 < 7) {
if (vBattForTle8888 < LOW_VBATT) {
// we assume TLE8888 is down and we should not bother with SPI communication
if (!needInitialSpi) {
needInitialSpi = true;
@ -826,7 +817,6 @@ int tle8888SpiStartupExchange(struct tle8888_priv *chip) {
const struct tle8888_config *cfg = chip->cfg;
tle8888reinitializationCounter++;
tle8888initResponsesAccumulator = 0;
/**
* We need around 50ms to get reliable TLE8888 start if MCU is powered externally but +12 goes gown and then goes up
@ -837,17 +827,12 @@ int tle8888SpiStartupExchange(struct tle8888_priv *chip) {
watchdogLogic(chip);
/* Software reset */
// first packet: 0x335=821 > 0xFD=253
uint16_t response = 0;
tle8888_spi_rw(chip, CMD_SR, &response);
if (response == 253) {
// I've seen this response on red board
tle8888initResponsesAccumulator += 4;
} else if (response == 2408) {
// and I've seen this response on red board
tle8888initResponsesAccumulator += 100;
tle8888_spi_rw(chip, CMD_SR, NULL);
tle8888_spi_rw(chip, CMD_UNLOCK, &response);
if (response != (CMD_WRITE | CMD_REG_ADDR(CMD_SR_CODE))) {
firmwareError(CUSTOM_ERR_6724, "TLE8888 SR Unexpected response %x", response);
}
initResponse0 = response;
/**
* Table 8. Reset Times. All reset times not more than 20uS
@ -902,6 +887,7 @@ static int tle8888_chip_init(void * data) {
}
}
if (ret) {
ret = -1;
goto err_gpios;

View File

@ -89,7 +89,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon May 11 23:43:09 EDT 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Tue May 12 14:29:57 EDT 2020
pageSize = 20000
page = 1
@ -3113,6 +3113,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Comparator hysteresis voltage (Max)", triggerCompHystMax
field = "VR-sensor saturation RPM", triggerCompSensorSatRpm
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
;
; allXXX sections allows a quick overview of used I/O in order to address conflicts mostly, not really to
; configure the features.
@ -3158,6 +3165,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Warning Led", warningLedPin
field = "tle6240_cs", tle6240_cs
field = "tle6240 SPI", tle6240spiDevice
panel = joystickPanel
dialog = allPins1_2
field = "Tachometer output Pin", tachOutputPin
@ -3828,12 +3836,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
panel = sdCard
panel = gpsReceiver
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
dialog = monitoringSettings, "rusEfi Console Settings"
field = "Sensor Sniffer", sensorChartMode

View File

@ -1843,6 +1843,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Comparator hysteresis voltage (Max)", triggerCompHystMax
field = "VR-sensor saturation RPM", triggerCompSensorSatRpm
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
;
; allXXX sections allows a quick overview of used I/O in order to address conflicts mostly, not really to
; configure the features.
@ -1888,6 +1895,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Warning Led", warningLedPin
field = "tle6240_cs", tle6240_cs
field = "tle6240 SPI", tle6240spiDevice
panel = joystickPanel
dialog = allPins1_2
field = "Tachometer output Pin", tachOutputPin
@ -2558,12 +2566,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
panel = sdCard @@if_ts_show_sd_card
panel = gpsReceiver @@if_ts_show_gps
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
dialog = monitoringSettings, "rusEfi Console Settings"
field = "Sensor Sniffer", sensorChartMode

View File

@ -89,7 +89,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon May 11 23:43:15 EDT 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Tue May 12 14:30:04 EDT 2020
pageSize = 20000
page = 1
@ -3113,6 +3113,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Comparator hysteresis voltage (Max)", triggerCompHystMax
field = "VR-sensor saturation RPM", triggerCompSensorSatRpm
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
;
; allXXX sections allows a quick overview of used I/O in order to address conflicts mostly, not really to
; configure the features.
@ -3158,6 +3165,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Warning Led", warningLedPin
field = "tle6240_cs", tle6240_cs
field = "tle6240 SPI", tle6240spiDevice
panel = joystickPanel
dialog = allPins1_2
field = "Tachometer output Pin", tachOutputPin
@ -3828,12 +3836,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
panel = sdCard
panel = gpsReceiver
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
dialog = monitoringSettings, "rusEfi Console Settings"
field = "Sensor Sniffer", sensorChartMode

View File

@ -89,7 +89,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon May 11 23:43:13 EDT 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Tue May 12 14:30:02 EDT 2020
pageSize = 20000
page = 1
@ -3104,6 +3104,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Comparator hysteresis voltage (Max)", triggerCompHystMax
field = "VR-sensor saturation RPM", triggerCompSensorSatRpm
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
;
; allXXX sections allows a quick overview of used I/O in order to address conflicts mostly, not really to
; configure the features.
@ -3149,6 +3156,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Warning Led", warningLedPin
field = "tle6240_cs", tle6240_cs
field = "tle6240 SPI", tle6240spiDevice
panel = joystickPanel
dialog = allPins1_2
field = "Tachometer output Pin", tachOutputPin
@ -3787,12 +3795,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
panel = canBus
panel = auxSerial
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
dialog = monitoringSettings, "rusEfi Console Settings"
field = "Sensor Sniffer", sensorChartMode

View File

@ -89,7 +89,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon May 11 23:43:18 EDT 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Tue May 12 14:30:05 EDT 2020
pageSize = 20000
page = 1
@ -3109,6 +3109,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Comparator hysteresis voltage (Max)", triggerCompHystMax
field = "VR-sensor saturation RPM", triggerCompSensorSatRpm
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
;
; allXXX sections allows a quick overview of used I/O in order to address conflicts mostly, not really to
; configure the features.
@ -3154,6 +3161,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Warning Led", warningLedPin
field = "tle6240_cs", tle6240_cs
field = "tle6240 SPI", tle6240spiDevice
panel = joystickPanel
dialog = allPins1_2
field = "Tachometer output Pin", tachOutputPin
@ -3824,12 +3832,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
panel = sdCard
panel = gpsReceiver
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
dialog = monitoringSettings, "rusEfi Console Settings"
field = "Sensor Sniffer", sensorChartMode

View File

@ -89,7 +89,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Mon May 11 23:43:20 EDT 2020
; this section was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.bat integration\rusefi_config.txt Tue May 12 14:30:06 EDT 2020
pageSize = 20000
page = 1
@ -3104,6 +3104,13 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Comparator hysteresis voltage (Max)", triggerCompHystMax
field = "VR-sensor saturation RPM", triggerCompSensorSatRpm
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
;
; allXXX sections allows a quick overview of used I/O in order to address conflicts mostly, not really to
; configure the features.
@ -3149,6 +3156,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Warning Led", warningLedPin
field = "tle6240_cs", tle6240_cs
field = "tle6240 SPI", tle6240spiDevice
panel = joystickPanel
dialog = allPins1_2
field = "Tachometer output Pin", tachOutputPin
@ -3795,12 +3803,6 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
panel = canBus
panel = auxSerial
dialog = joystickPanel, "Joystick"
field = "joustick center button", joystickCenterPin
field = "joustick button A", joystickAPin
field = "joustick button B", joystickBPin
field = "joustick button C", joystickCPin
field = "joustick button D", joystickDPin
dialog = monitoringSettings, "rusEfi Console Settings"
field = "Sensor Sniffer", sensorChartMode