auto-sync
This commit is contained in:
parent
9d5b28a7d9
commit
4643b63a41
|
@ -64,6 +64,7 @@
|
||||||
#include "rusefi.h"
|
#include "rusefi.h"
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "flash_main.h"
|
#include "flash_main.h"
|
||||||
|
#include "max31855.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern Engine engine;
|
extern Engine engine;
|
||||||
|
@ -374,6 +375,8 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels) {
|
||||||
tsOutputChannels->manifold_air_pressure = getMap();
|
tsOutputChannels->manifold_air_pressure = getMap();
|
||||||
tsOutputChannels->checkEngine = hasErrorCodes();
|
tsOutputChannels->checkEngine = hasErrorCodes();
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
tsOutputChannels->egtValues.values[0] = getEgtValue(boardConfiguration, 0);
|
||||||
|
|
||||||
tsOutputChannels->needBurn = getNeedToWriteConfiguration();
|
tsOutputChannels->needBurn = getNeedToWriteConfiguration();
|
||||||
tsOutputChannels->hasSdCard = isSdCardAlive();
|
tsOutputChannels->hasSdCard = isSdCardAlive();
|
||||||
tsOutputChannels->isFuelPumpOn = getOutputPinValue(FUEL_PUMP_RELAY);
|
tsOutputChannels->isFuelPumpOn = getOutputPinValue(FUEL_PUMP_RELAY);
|
||||||
|
|
|
@ -14,7 +14,13 @@
|
||||||
/**
|
/**
|
||||||
* this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version
|
* this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version
|
||||||
*/
|
*/
|
||||||
#define TS_FILE_VERSION 20140917
|
#define TS_FILE_VERSION 20140920
|
||||||
|
|
||||||
|
#define EGT_CHANNEL_COUNT 8
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t values[EGT_CHANNEL_COUNT];
|
||||||
|
} egt_values_s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* please be aware that 'float' (F32) type requires TunerStudio version 2.6 and later
|
* please be aware that 'float' (F32) type requires TunerStudio version 2.6 and later
|
||||||
|
@ -61,7 +67,8 @@ typedef struct {
|
||||||
unsigned int isMapError : 1; // bit 2
|
unsigned int isMapError : 1; // bit 2
|
||||||
unsigned int isIatError : 1; // bit 3
|
unsigned int isIatError : 1; // bit 3
|
||||||
int tsConfigVersion;
|
int tsConfigVersion;
|
||||||
int unused[7];
|
egt_values_s egtValues;
|
||||||
|
int unused[3];
|
||||||
} TunerStudioOutputChannels;
|
} TunerStudioOutputChannels;
|
||||||
|
|
||||||
#endif /* TUNERSTUDIO_CONFIGURATION_H_ */
|
#endif /* TUNERSTUDIO_CONFIGURATION_H_ */
|
||||||
|
|
|
@ -439,6 +439,11 @@ static void setWholeFuelMapCmd(float value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
|
||||||
|
static void setEgtSpi(int spi) {
|
||||||
|
boardConfiguration->max31855spiDevice = (spi_device_e) spi;
|
||||||
|
}
|
||||||
|
|
||||||
static void setPotSpi(int spi) {
|
static void setPotSpi(int spi) {
|
||||||
boardConfiguration->digitalPotentiometerSpiDevice = (spi_device_e) spi;
|
boardConfiguration->digitalPotentiometerSpiDevice = (spi_device_e) spi;
|
||||||
}
|
}
|
||||||
|
@ -798,7 +803,10 @@ void initSettings(engine_configuration_s *engineConfiguration) {
|
||||||
addConsoleActionSS("set_ignition_pin", setIgnitionPin);
|
addConsoleActionSS("set_ignition_pin", setIgnitionPin);
|
||||||
addConsoleActionSS("set_trigger_input_pin", setTriggerInputPin);
|
addConsoleActionSS("set_trigger_input_pin", setTriggerInputPin);
|
||||||
addConsoleActionSS("set_trigger_simulator_pin", setTriggerSimulatorPin);
|
addConsoleActionSS("set_trigger_simulator_pin", setTriggerSimulatorPin);
|
||||||
|
|
||||||
addConsoleActionSSP("set_egt_cs_pin", (VoidCharPtrCharPtrVoidPtr)setEgtCSPin, boardConfiguration);
|
addConsoleActionSSP("set_egt_cs_pin", (VoidCharPtrCharPtrVoidPtr)setEgtCSPin, boardConfiguration);
|
||||||
|
addConsoleActionI("set_egt_spi", setEgtSpi);
|
||||||
|
|
||||||
addConsoleActionSS("set_trigger_simulator_mode", setTriggerSimulatorMode);
|
addConsoleActionSS("set_trigger_simulator_mode", setTriggerSimulatorMode);
|
||||||
addConsoleActionS("set_fuel_pump_pin", setFuelPumpPin);
|
addConsoleActionS("set_fuel_pump_pin", setFuelPumpPin);
|
||||||
addConsoleActionS("set_idle_pin", setIdlePin);
|
addConsoleActionS("set_idle_pin", setIdlePin);
|
||||||
|
|
|
@ -270,20 +270,23 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SPIDriver * getSpiDevice(spi_device_e spiDevice) {
|
SPIDriver * getSpiDevice(spi_device_e spiDevice) {
|
||||||
|
if (spiDevice == SPI_NONE) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#if STM32_SPI_USE_SPI1 || defined(__DOXYGEN__)
|
#if STM32_SPI_USE_SPI1 || defined(__DOXYGEN__)
|
||||||
if (spiDevice == SPI_DEVICE_1) {
|
if (spiDevice == SPI_DEVICE_1) {
|
||||||
return &SPID1;
|
return &SPID1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if STM32_SPI_USE_SPI2 || defined(__DOXYGEN__)
|
#if STM32_SPI_USE_SPI2 || defined(__DOXYGEN__)
|
||||||
if (spiDevic e== SPI_DEVICE_2) {
|
if (spiDevic e== SPI_DEVICE_2) {
|
||||||
return &SPID2;
|
return &SPID2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if STM32_SPI_USE_SPI3 || defined(__DOXYGEN__)
|
#if STM32_SPI_USE_SPI3 || defined(__DOXYGEN__)
|
||||||
if (spiDevice == SPI_DEVICE_3) {
|
if (spiDevice == SPI_DEVICE_3) {
|
||||||
return &SPID3;
|
return &SPID3;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
firmwareError("Unexpected SPI device: %d", spiDevice);
|
firmwareError("Unexpected SPI device: %d", spiDevice);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#if EFI_MAX_31855
|
#if EFI_MAX_31855
|
||||||
|
|
||||||
|
#define EGT_ERROR_VALUE -1000
|
||||||
|
|
||||||
static Logging logger;
|
static Logging logger;
|
||||||
|
|
||||||
static SPIConfig spiConfig[MAX31855_CS_COUNT];
|
static SPIConfig spiConfig[MAX31855_CS_COUNT];
|
||||||
|
@ -28,6 +30,8 @@ static SPIConfig spiConfig[MAX31855_CS_COUNT];
|
||||||
static void showEgtInfo(board_configuration_s *boardConfiguration) {
|
static void showEgtInfo(board_configuration_s *boardConfiguration) {
|
||||||
printSpiState(&logger, boardConfiguration);
|
printSpiState(&logger, boardConfiguration);
|
||||||
|
|
||||||
|
scheduleMsg(&logger, "EGT spi: %d", boardConfiguration->max31855spiDevice);
|
||||||
|
|
||||||
for (int i = 0; i < MAX31855_CS_COUNT; i++) {
|
for (int i = 0; i < MAX31855_CS_COUNT; i++) {
|
||||||
if (boardConfiguration->max31855_cs[i] != GPIO_NONE) {
|
if (boardConfiguration->max31855_cs[i] != GPIO_NONE) {
|
||||||
scheduleMsg(&logger, "%d ETG @ %s", i, hwPortname(boardConfiguration->max31855_cs[i]));
|
scheduleMsg(&logger, "%d ETG @ %s", i, hwPortname(boardConfiguration->max31855_cs[i]));
|
||||||
|
@ -37,8 +41,6 @@ static void showEgtInfo(board_configuration_s *boardConfiguration) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t rx_buff;
|
|
||||||
|
|
||||||
// bits D17 and D3 are always expected to be zero
|
// bits D17 and D3 are always expected to be zero
|
||||||
#define MC_RESERVED_BITS 0x20008
|
#define MC_RESERVED_BITS 0x20008
|
||||||
#define MC_OPEN_BIT 1
|
#define MC_OPEN_BIT 1
|
||||||
|
@ -64,44 +66,72 @@ static const char * getMcCode(max_32855_code code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void egtRead(board_configuration_s *boardConfiguration) {
|
static max_32855_code getResultCode(uint32_t egtPacket) {
|
||||||
|
if ((egtPacket & MC_RESERVED_BITS) != 0) {
|
||||||
|
return MC_INVALID;
|
||||||
|
} else if ((egtPacket & MC_OPEN_BIT) != 0) {
|
||||||
|
return MC_OPEN;
|
||||||
|
} else if ((egtPacket & MC_GND_BIT) != 0) {
|
||||||
|
return MC_SHORT_GND;
|
||||||
|
} else if ((egtPacket & MC_VCC_BIT) != 0) {
|
||||||
|
return MC_SHORT_VCC;
|
||||||
|
} else {
|
||||||
|
return MC_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scheduleMsg(&logger, "Reading egt");
|
uint32_t readEgtPacket(board_configuration_s *boardConfiguration, int egtChannel) {
|
||||||
|
uint32_t egtPacket;
|
||||||
|
SPIDriver *driver = getSpiDevice(boardConfiguration->max31855spiDevice);
|
||||||
|
if (driver == NULL) {
|
||||||
|
return 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
SPIDriver *driver = getSpiDevice(SPI_DEVICE_3);
|
spiStart(driver, &spiConfig[egtChannel]);
|
||||||
|
|
||||||
spiStart(driver, &spiConfig[0]);
|
|
||||||
spiSelect(driver);
|
spiSelect(driver);
|
||||||
|
|
||||||
spiReceive(driver, 4, &rx_buff);
|
spiReceive(driver, 4, &egtPacket);
|
||||||
|
|
||||||
spiUnselect(driver);
|
spiUnselect(driver);
|
||||||
spiStop(driver);
|
spiStop(driver);
|
||||||
|
egtPacket = SWAP_UINT32(egtPacket);
|
||||||
|
return egtPacket;
|
||||||
|
}
|
||||||
|
|
||||||
rx_buff = SWAP_UINT32(rx_buff);
|
#define GET_TEMPERATURE_C(x) (((x) >> 18) / 4)
|
||||||
|
|
||||||
max_32855_code code;
|
uint16_t getEgtValue(board_configuration_s *boardConfiguration, int egtChannel) {
|
||||||
|
uint32_t packet = readEgtPacket(boardConfiguration, egtChannel);
|
||||||
if ((rx_buff & MC_RESERVED_BITS) != 0) {
|
max_32855_code code = getResultCode(packet);
|
||||||
code = MC_INVALID;
|
if (code != MC_OK) {
|
||||||
} else if ((rx_buff & MC_OPEN_BIT) != 0) {
|
return EGT_ERROR_VALUE + code;
|
||||||
code = MC_OPEN;
|
|
||||||
} else if ((rx_buff & MC_GND_BIT) != 0) {
|
|
||||||
code = MC_SHORT_GND;
|
|
||||||
} else if ((rx_buff & MC_VCC_BIT) != 0) {
|
|
||||||
code = MC_SHORT_VCC;
|
|
||||||
} else {
|
} else {
|
||||||
code = MC_OK;
|
return GET_TEMPERATURE_C(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void egtRead(board_configuration_s *boardConfiguration) {
|
||||||
|
|
||||||
|
if (boardConfiguration->max31855spiDevice == SPI_NONE) {
|
||||||
|
scheduleMsg(&logger, "No SPI selected for EGT");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleMsg(&logger, "egt %x code=%d %s", rx_buff, code, getMcCode(code));
|
scheduleMsg(&logger, "Reading egt");
|
||||||
|
|
||||||
|
uint32_t egtPacket = readEgtPacket(boardConfiguration, 0);
|
||||||
|
|
||||||
|
max_32855_code code = getResultCode(egtPacket);
|
||||||
|
|
||||||
|
scheduleMsg(&logger, "egt %x code=%d %s", egtPacket, code, getMcCode(code));
|
||||||
|
|
||||||
if (code != MC_INVALID) {
|
if (code != MC_INVALID) {
|
||||||
int refBits = ((rx_buff & 0xFFFF) / 16); // bits 15:4
|
int refBits = ((egtPacket & 0xFFFF) / 16); // bits 15:4
|
||||||
float refTemp = refBits / 16.0;
|
float refTemp = refBits / 16.0;
|
||||||
scheduleMsg(&logger, "reference temperature %f", refTemp);
|
scheduleMsg(&logger, "reference temperature %f", refTemp);
|
||||||
}
|
|
||||||
|
|
||||||
|
scheduleMsg(&logger, "EGT temperature %d", GET_TEMPERATURE_C(egtPacket));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMax31855(board_configuration_s *boardConfiguration) {
|
void initMax31855(board_configuration_s *boardConfiguration) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern "C"
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void initMax31855(board_configuration_s *boardConfiguration);
|
void initMax31855(board_configuration_s *boardConfiguration);
|
||||||
|
uint16_t getEgtValue(board_configuration_s *boardConfiguration, int egtChannel);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue