auto-sync

This commit is contained in:
rusEfi 2014-09-20 14:03:00 -05:00
parent 6b799c9552
commit cb0b9b2a4e
10 changed files with 80 additions and 33 deletions

View File

@ -183,8 +183,8 @@ typedef struct {
brain_pin_e canTxPin; brain_pin_e canTxPin;
brain_pin_e canRxPin; brain_pin_e canRxPin;
brain_pin_e triggerSimulatorPins[3]; brain_pin_e triggerSimulatorPins[TRIGGER_SIMULATOR_PIN_COUNT];
pin_output_mode_e triggerSimulatorPinModes[3]; pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT];
brain_pin_e o2heaterPin; brain_pin_e o2heaterPin;
pin_output_mode_e o2heaterPinModeTodO; pin_output_mode_e o2heaterPinModeTodO;

View File

@ -19,6 +19,8 @@
#define DIGIPOT_COUNT 4 #define DIGIPOT_COUNT 4
#define TRIGGER_SIMULATOR_PIN_COUNT 3
#define LOGIC_ANALYZER_CHANNEL_COUNT 4 #define LOGIC_ANALYZER_CHANNEL_COUNT 4
typedef enum { typedef enum {

View File

@ -54,6 +54,11 @@ void printFloatArray(const char *prefix, float array[], int size) {
scheduleLogging(&logger); scheduleLogging(&logger);
} }
void printSpiState(Logging *logger, board_configuration_s *boardConfiguration) {
scheduleMsg(logger, "spi 1=%s/2=%s/3=%s", boolToString(boardConfiguration->is_enabled_spi_1),
boolToString(boardConfiguration->is_enabled_spi_2), boolToString(boardConfiguration->is_enabled_spi_3));
}
extern board_configuration_s *boardConfiguration; extern board_configuration_s *boardConfiguration;
/** /**
@ -150,8 +155,8 @@ void printConfiguration(engine_configuration_s *engineConfiguration, engine_conf
hwPortname(boardConfiguration->digitalPotentiometerChipSelect[i])); hwPortname(boardConfiguration->digitalPotentiometerChipSelect[i]));
} }
scheduleMsg(&logger, "spi 1=%s/2=%s/3=%s", boolToString(boardConfiguration->is_enabled_spi_1), printSpiState(&logger, boardConfiguration);
boolToString(boardConfiguration->is_enabled_spi_2), boolToString(boardConfiguration->is_enabled_spi_3));
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
} }
@ -504,7 +509,7 @@ static void setTriggerInputPin(const char *indexStr, const char *pinName) {
static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode) { static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode) {
int index = atoi(indexStr); int index = atoi(indexStr);
if (index < 0 || index > 2 || absI(index) == ERROR_CODE) { if (index < 0 || index > TRIGGER_SIMULATOR_PIN_COUNT || absI(index) == ERROR_CODE) {
return; return;
} }
int mode = atoi(modeCode); int mode = atoi(modeCode);
@ -514,9 +519,22 @@ static void setTriggerSimulatorMode(const char *indexStr, const char *modeCode)
boardConfiguration->triggerSimulatorPinModes[index] = (pin_output_mode_e) mode; boardConfiguration->triggerSimulatorPinModes[index] = (pin_output_mode_e) mode;
} }
static void setEgtCSPin(const char *indexStr, const char *pinName, board_configuration_s * board_configuration_s) {
int index = atoi(indexStr);
if (index < 0 || index > MAX31855_CS_COUNT || absI(index) == ERROR_CODE)
return;
brain_pin_e pin = parseBrainPin(pinName);
if (pin == GPIO_INVALID) {
scheduleMsg(&logger, "invalid pin name [%s]", pinName);
return;
}
scheduleMsg(&logger, "setting EGT CS pin[%d] to %s please save&restart", index, hwPortname(pin));
boardConfiguration->max31855_cs[index] = pin;
}
static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) { static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) {
int index = atoi(indexStr); int index = atoi(indexStr);
if (index < 0 || index > 2) if (index < 0 || index > TRIGGER_SIMULATOR_PIN_COUNT || absI(index) == ERROR_CODE)
return; return;
brain_pin_e pin = parseBrainPin(pinName); brain_pin_e pin = parseBrainPin(pinName);
if (pin == GPIO_INVALID) { if (pin == GPIO_INVALID) {
@ -780,6 +798,7 @@ 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);
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);

View File

@ -17,7 +17,7 @@ extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
void printSpiState(Logging *logger, board_configuration_s *boardConfiguration);
void pokeControl(void); void pokeControl(void);
void setEngineType(int value); void setEngineType(int value);

View File

@ -36,26 +36,6 @@
* *
*/ */
SPIDriver * getDigiralPotDevice(spi_device_e spiDevice) {
#if STM32_SPI_USE_SPI1 || defined(__DOXYGEN__)
if (spiDevice == SPI_DEVICE_1) {
return &SPID1;
}
#endif
#if STM32_SPI_USE_SPI2 || defined(__DOXYGEN__)
if (spiDevic e== SPI_DEVICE_2) {
return &SPID2;
}
#endif
#if STM32_SPI_USE_SPI3 || defined(__DOXYGEN__)
if (spiDevice == SPI_DEVICE_3) {
return &SPID3;
}
#endif
firmwareError("Unexpected SPI device: %d", spiDevice);
return NULL;
}
/* Low speed SPI configuration (281.250kHz, CPHA=0, CPOL=0, MSb first).*/ /* Low speed SPI configuration (281.250kHz, CPHA=0, CPOL=0, MSb first).*/
#define SPI_POT_CONFIG SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_DFF #define SPI_POT_CONFIG SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_DFF
@ -130,7 +110,7 @@ void initPotentiometers(board_configuration_s *boardConfiguration) {
continue; continue;
} }
initPotentiometer(&config[i], getDigiralPotDevice(boardConfiguration->digitalPotentiometerSpiDevice), initPotentiometer(&config[i], getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice),
getHwPort(csPin), getHwPin(csPin)); getHwPort(csPin), getHwPin(csPin));
} }

View File

@ -268,3 +268,24 @@ void initHardware(Logging *logger, Engine *engine) {
printMsg(logger, "initHardware() OK!"); printMsg(logger, "initHardware() OK!");
} }
SPIDriver * getSpiDevice(spi_device_e spiDevice) {
#if STM32_SPI_USE_SPI1 || defined(__DOXYGEN__)
if (spiDevice == SPI_DEVICE_1) {
return &SPID1;
}
#endif
#if STM32_SPI_USE_SPI2 || defined(__DOXYGEN__)
if (spiDevic e== SPI_DEVICE_2) {
return &SPID2;
}
#endif
#if STM32_SPI_USE_SPI3 || defined(__DOXYGEN__)
if (spiDevice == SPI_DEVICE_3) {
return &SPID3;
}
#endif
firmwareError("Unexpected SPI device: %d", spiDevice);
return NULL;
}

View File

@ -15,6 +15,7 @@ extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
SPIDriver * getSpiDevice(spi_device_e spiDevice);
void turnOnSpi(spi_device_e device); void turnOnSpi(spi_device_e device);
void lockSpi(spi_device_e device); void lockSpi(spi_device_e device);
void unlockSpi(void); void unlockSpi(void);

View File

@ -14,12 +14,16 @@
#include "max31855.h" #include "max31855.h"
#include "pin_repository.h" #include "pin_repository.h"
#include "settings.h"
#if EFI_MAX_31855 #if EFI_MAX_31855
static Logging logger; static Logging logger;
static void showEgtInfo(board_configuration_s *boardConfiguration) { static void showEgtInfo(board_configuration_s *boardConfiguration) {
printSpiState(&logger, boardConfiguration);
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]));

View File

@ -50,6 +50,10 @@ void addConsoleActionP(const char *token, VoidPtr callback, void *param) {
doAddAction(token, NO_PARAMETER_P, (Void) callback, param); doAddAction(token, NO_PARAMETER_P, (Void) callback, param);
} }
void addConsoleActionSSP(const char *token, VoidCharPtrCharPtrVoidPtr callback, void *param) {
doAddAction(token, STRING2_PARAMETER_P, (Void) callback, param);
}
/** /**
* @brief Register console action without parameters * @brief Register console action without parameters
*/ */
@ -105,8 +109,11 @@ static int getParameterCount(action_type_e parameterType) {
case STRING_PARAMETER: case STRING_PARAMETER:
return 1; return 1;
case FLOAT_FLOAT_PARAMETER: case FLOAT_FLOAT_PARAMETER:
case FLOAT_FLOAT_PARAMETER_P:
case STRING2_PARAMETER: case STRING2_PARAMETER:
case STRING2_PARAMETER_P:
case TWO_INTS_PARAMETER: case TWO_INTS_PARAMETER:
case TWO_INTS_PARAMETER_P:
return 2; return 2;
case STRING3_PARAMETER: case STRING3_PARAMETER:
return 3; return 3;
@ -152,7 +159,7 @@ void handleActionWithParameter(TokenCallback *current, char *parameter) {
} }
// todo: refactor this hell! // todo: refactor this hell!
if (current->parameterType == STRING2_PARAMETER) { if (current->parameterType == STRING2_PARAMETER || current->parameterType == STRING2_PARAMETER_P) {
int spaceIndex = indexOf(parameter, ' '); int spaceIndex = indexOf(parameter, ' ');
if (spaceIndex == -1) { if (spaceIndex == -1) {
return; return;
@ -163,10 +170,14 @@ void handleActionWithParameter(TokenCallback *current, char *parameter) {
parameter += spaceIndex + 1; parameter += spaceIndex + 1;
char * param1 = parameter; char * param1 = parameter;
VoidCharPtrCharPtr callbackS = (VoidCharPtrCharPtr) current->callback; if (current->parameterType == STRING2_PARAMETER) {
(*callbackS)(param0, param1); VoidCharPtrCharPtr callbackS = (VoidCharPtrCharPtr) current->callback;
(*callbackS)(param0, param1);
} else {
VoidCharPtrCharPtrVoidPtr callbackS = (VoidCharPtrCharPtrVoidPtr) current->callback;
(*callbackS)(param0, param1, current->param);
}
return; return;
} }
if (current->parameterType == STRING3_PARAMETER) { if (current->parameterType == STRING3_PARAMETER) {

View File

@ -23,10 +23,13 @@ typedef enum {
FLOAT_PARAMETER, FLOAT_PARAMETER,
STRING_PARAMETER, STRING_PARAMETER,
STRING2_PARAMETER, STRING2_PARAMETER,
STRING2_PARAMETER_P,
STRING3_PARAMETER, STRING3_PARAMETER,
STRING5_PARAMETER, STRING5_PARAMETER,
TWO_INTS_PARAMETER, TWO_INTS_PARAMETER,
FLOAT_FLOAT_PARAMETER TWO_INTS_PARAMETER_P,
FLOAT_FLOAT_PARAMETER,
FLOAT_FLOAT_PARAMETER_P,
} action_type_e; } action_type_e;
typedef struct { typedef struct {
@ -49,7 +52,10 @@ typedef void (*VoidFloat)(float);
typedef void (*VoidFloatFloat)(float, float); typedef void (*VoidFloatFloat)(float, float);
typedef void (*VoidIntInt)(int, int); typedef void (*VoidIntInt)(int, int);
typedef void (*VoidCharPtr)(const char *); typedef void (*VoidCharPtr)(const char *);
typedef void (*VoidCharPtrCharPtr)(const char *, const char *); typedef void (*VoidCharPtrCharPtr)(const char *, const char *);
typedef void (*VoidCharPtrCharPtrVoidPtr)(const char *, const char *, void*);
typedef void (*VoidCharPtrCharPtrCharPtr)(const char *, const char *, const char *); typedef void (*VoidCharPtrCharPtrCharPtr)(const char *, const char *, const char *);
typedef void (*VoidCharPtrCharPtrCharPtrCharPtrCharPtr)(const char *, const char *, const char *, const char *, const char *); typedef void (*VoidCharPtrCharPtrCharPtrCharPtrCharPtr)(const char *, const char *, const char *, const char *, const char *);
@ -68,7 +74,10 @@ void addConsoleActionII(const char *token, VoidIntInt callback);
void addConsoleActionF(const char *token, VoidFloat callback); void addConsoleActionF(const char *token, VoidFloat callback);
void addConsoleActionFF(const char *token, VoidFloatFloat callback); void addConsoleActionFF(const char *token, VoidFloatFloat callback);
void addConsoleActionS(const char *token, VoidCharPtr callback); void addConsoleActionS(const char *token, VoidCharPtr callback);
void addConsoleActionSS(const char *token, VoidCharPtrCharPtr callback); void addConsoleActionSS(const char *token, VoidCharPtrCharPtr callback);
void addConsoleActionSSP(const char *token, VoidCharPtrCharPtrVoidPtr callback, void *param);
void addConsoleActionSSS(const char *token, VoidCharPtrCharPtrCharPtr callback); void addConsoleActionSSS(const char *token, VoidCharPtrCharPtrCharPtr callback);
void addConsoleActionSSSSS(const char *token, VoidCharPtrCharPtrCharPtrCharPtrCharPtr callback); void addConsoleActionSSSSS(const char *token, VoidCharPtrCharPtrCharPtrCharPtrCharPtr callback);