auto-sync

This commit is contained in:
rusEfi 2014-12-30 14:03:24 -06:00
parent cb2421c243
commit 8b29a2ba42
5 changed files with 19 additions and 13 deletions

View File

@ -469,7 +469,7 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC
tsOutputChannels->checkEngine = hasErrorCodes(); tsOutputChannels->checkEngine = hasErrorCodes();
#if EFI_PROD_CODE #if EFI_PROD_CODE
tsOutputChannels->egtValues.values[0] = getEgtValue(boardConfiguration, 0); tsOutputChannels->egtValues.values[0] = getEgtValue(0);
tsOutputChannels->needBurn = getNeedToWriteConfiguration(); tsOutputChannels->needBurn = getNeedToWriteConfiguration();
tsOutputChannels->hasSdCard = isSdCardAlive(); tsOutputChannels->hasSdCard = isSdCardAlive();

View File

@ -53,6 +53,8 @@ typedef char le_formula_t[LE_COMMAND_LENGTH];
typedef float fuel_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT]; typedef float fuel_table_t[FUEL_LOAD_COUNT][FUEL_RPM_COUNT];
typedef float ignition_table_t[IGN_LOAD_COUNT][IGN_RPM_COUNT]; typedef float ignition_table_t[IGN_LOAD_COUNT][IGN_RPM_COUNT];
typedef brain_pin_e egt_cs_array_t[MAX31855_CS_COUNT];
#define DWELL_CURVE_SIZE 8 #define DWELL_CURVE_SIZE 8
typedef enum { typedef enum {
@ -217,7 +219,7 @@ typedef struct {
pin_output_mode_e mainRelayPinMode; pin_output_mode_e mainRelayPinMode;
brain_pin_e max31855_cs[MAX31855_CS_COUNT]; egt_cs_array_t max31855_cs;
spi_device_e max31855spiDevice; spi_device_e max31855spiDevice;

View File

@ -23,6 +23,8 @@
#define EGT_ERROR_VALUE -1000 #define EGT_ERROR_VALUE -1000
static SPIDriver *driver;
static Logging logger; static Logging logger;
static SPIConfig spiConfig[MAX31855_CS_COUNT]; static SPIConfig spiConfig[MAX31855_CS_COUNT];
@ -80,9 +82,8 @@ static max_32855_code getResultCode(uint32_t egtPacket) {
} }
} }
uint32_t readEgtPacket(board_configuration_s *boardConfiguration, int egtChannel) { static uint32_t readEgtPacket(int egtChannel) {
uint32_t egtPacket; uint32_t egtPacket;
SPIDriver *driver = getSpiDevice(boardConfiguration->max31855spiDevice);
if (driver == NULL) { if (driver == NULL) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
@ -90,7 +91,7 @@ uint32_t readEgtPacket(board_configuration_s *boardConfiguration, int egtChannel
spiStart(driver, &spiConfig[egtChannel]); spiStart(driver, &spiConfig[egtChannel]);
spiSelect(driver); spiSelect(driver);
spiReceive(driver, 4, &egtPacket); spiReceive(driver, sizeof(egtPacket), &egtPacket);
spiUnselect(driver); spiUnselect(driver);
spiStop(driver); spiStop(driver);
@ -100,8 +101,8 @@ uint32_t readEgtPacket(board_configuration_s *boardConfiguration, int egtChannel
#define GET_TEMPERATURE_C(x) (((x) >> 18) / 4) #define GET_TEMPERATURE_C(x) (((x) >> 18) / 4)
uint16_t getEgtValue(board_configuration_s *boardConfiguration, int egtChannel) { uint16_t getEgtValue(int egtChannel) {
uint32_t packet = readEgtPacket(boardConfiguration, egtChannel); uint32_t packet = readEgtPacket(egtChannel);
max_32855_code code = getResultCode(packet); max_32855_code code = getResultCode(packet);
if (code != MC_OK) { if (code != MC_OK) {
return EGT_ERROR_VALUE + code; return EGT_ERROR_VALUE + code;
@ -110,16 +111,16 @@ uint16_t getEgtValue(board_configuration_s *boardConfiguration, int egtChannel)
} }
} }
static void egtRead(board_configuration_s *boardConfiguration) { static void egtRead(void) {
if (boardConfiguration->max31855spiDevice == SPI_NONE) { if (driver == NULL) {
scheduleMsg(&logger, "No SPI selected for EGT"); scheduleMsg(&logger, "No SPI selected for EGT");
return; return;
} }
scheduleMsg(&logger, "Reading egt"); scheduleMsg(&logger, "Reading egt");
uint32_t egtPacket = readEgtPacket(boardConfiguration, 0); uint32_t egtPacket = readEgtPacket(0);
max_32855_code code = getResultCode(egtPacket); max_32855_code code = getResultCode(egtPacket);
@ -137,9 +138,12 @@ static void egtRead(board_configuration_s *boardConfiguration) {
void initMax31855(board_configuration_s *boardConfiguration) { void initMax31855(board_configuration_s *boardConfiguration) {
initLogging(&logger, "EGT"); initLogging(&logger, "EGT");
driver = getSpiDevice(boardConfiguration->max31855spiDevice);
addConsoleActionP("egtinfo", (VoidPtr) showEgtInfo, boardConfiguration); addConsoleActionP("egtinfo", (VoidPtr) showEgtInfo, boardConfiguration);
addConsoleActionP("egtread", (VoidPtr) egtRead, boardConfiguration); addConsoleAction("egtread", (Void) egtRead);
turnOnSpi(SPI_DEVICE_3); turnOnSpi(SPI_DEVICE_3);

View File

@ -17,7 +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); uint16_t getEgtValue(int egtChannel);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -265,5 +265,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE == 0) if (UNUSED_CCM_SIZE == 0)
return 1; // this is here to make the compiler happy about the unused array return 1; // this is here to make the compiler happy about the unused array
return 20141229; return 20141230;
} }