auto-sync

This commit is contained in:
rusEfi 2014-10-25 07:03:11 -05:00
parent 6a18afb3f1
commit 18e1aab327
3 changed files with 49 additions and 9 deletions

View File

@ -138,13 +138,14 @@ typedef enum {
#define IO_PIN_COUNT 100
void initPrimaryPins(void);
void initOutputPins(void);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void initPrimaryPins(void);
void initOutputPins(void);
const char *getPinName(io_pin_e io_pin);
io_pin_e getPinByName(const char *name);
void turnOutputPinOn(io_pin_e pin);
@ -156,5 +157,4 @@ void outputPinRegisterExt2(const char *msg, io_pin_e ioPin, brain_pin_e brainPin
}
#endif /* __cplusplus */
#endif /* STATUS_LEDS_H_ */

View File

@ -178,6 +178,39 @@ const char *getPinName(io_pin_e io_pin) {
return "inj11";
case INJECTOR_12_OUTPUT:
return "inj12";
case GPIO_0:
return "gpio0";
case GPIO_1:
return "gpio1";
case GPIO_2:
return "gpio2";
case GPIO_3:
return "gpio3";
case GPIO_4:
return "gpio4";
case GPIO_5:
return "gpio5";
case GPIO_6:
return "gpio6";
case GPIO_7:
return "gpio7";
case GPIO_8:
return "gpio8";
case GPIO_9:
return "gpio9";
case GPIO_10:
return "gpio10";
case GPIO_11:
return "gpio11";
case GPIO_12:
return "gpio12";
case GPIO_13:
return "gpio13";
case GPIO_14:
return "gpio14";
case GPIO_15:
return "gpio15";
default:
return "Pin needs name";
}

View File

@ -189,13 +189,17 @@ static void cylinderCleanupControl(Engine *engine) {
}
static void handleGpio(Engine *engine, int index) {
brain_pin_e pin = boardConfiguration->gpioPins[index];
if(boardConfiguration->gpioPins[index]==GPIO_NONE)
return;
io_pin_e pin = (io_pin_e)((int)GPIO_0 + index);
int value = calc.getValue2(fuelPumpLogic, engine);
// if (value != getOutputPinValue(pin)) {
if (value != getOutputPinValue(pin)) {
// scheduleMsg(&logger, "setting %s %s", getIo_pin_e(pin), boolToString(value));
// setOutputPinValue(pin, value);
// }
setOutputPinValue(pin, value);
}
}
@ -325,6 +329,8 @@ static void setUserOutput(const char *indexStr, const char *quotedLine, Engine *
strcpy(engine->engineConfiguration->bc.le_formulas[index], l);
}
static pin_output_mode_e d = OM_DEFAULT;
void initEngineContoller(Engine *engine) {
if (hasFirmwareError()) {
return;
@ -413,10 +419,11 @@ void initEngineContoller(Engine *engine) {
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
if (boardConfiguration->gpioPins[i] != GPIO_NONE) {
mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
//mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
io_pin_e pin = (io_pin_e)((int)GPIO_0 + i);
outputPinRegisterExt2(getPinName(pin), pin, boardConfiguration->gpioPins[i], &d);
}
}
addConsoleActionSSP("set_user_out", (VoidCharPtrCharPtrVoidPtr) setUserOutput, engine);