auto-sync
This commit is contained in:
parent
573ceec20b
commit
408c31e968
|
@ -12,31 +12,12 @@
|
||||||
|
|
||||||
#define GPIO_NULL NULL
|
#define GPIO_NULL NULL
|
||||||
|
|
||||||
|
#define NAMED_PIN_COUNT 24
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logical pins. See brain_pin_e for physical pins.
|
* Logical pins. See brain_pin_e for physical pins.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
IO_INVALID,
|
|
||||||
LED_WARNING, // Orange on-board LED
|
|
||||||
LED_RUNNING, // Green on-board LED
|
|
||||||
LED_ERROR, // Red on-board LED
|
|
||||||
LED_COMMUNICATION_1, // Blue on-board LED
|
|
||||||
LED_EXT_1, // external board LED
|
|
||||||
LED_EXT_2, // external board LED
|
|
||||||
LED_EXT_3, // external board LED
|
|
||||||
LED_DEBUG,
|
|
||||||
LED_EMULATOR,
|
|
||||||
|
|
||||||
LED_TRIGGER_ERROR,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* see board_configuration_s->idleValvePin
|
|
||||||
*/
|
|
||||||
IDLE_VALVE,
|
|
||||||
TRIGGER_EMULATOR_PRIMARY,
|
|
||||||
TRIGGER_EMULATOR_SECONDARY,
|
|
||||||
TRIGGER_EMULATOR_3RD,
|
|
||||||
|
|
||||||
SPARKOUT_1_OUTPUT,
|
SPARKOUT_1_OUTPUT,
|
||||||
SPARKOUT_2_OUTPUT,
|
SPARKOUT_2_OUTPUT,
|
||||||
SPARKOUT_3_OUTPUT,
|
SPARKOUT_3_OUTPUT,
|
||||||
|
@ -63,6 +44,45 @@ typedef enum {
|
||||||
INJECTOR_11_OUTPUT,
|
INJECTOR_11_OUTPUT,
|
||||||
INJECTOR_12_OUTPUT,
|
INJECTOR_12_OUTPUT,
|
||||||
|
|
||||||
|
GPIO_0,
|
||||||
|
GPIO_1,
|
||||||
|
GPIO_2,
|
||||||
|
GPIO_3,
|
||||||
|
GPIO_4,
|
||||||
|
GPIO_5,
|
||||||
|
GPIO_6,
|
||||||
|
GPIO_7,
|
||||||
|
GPIO_8,
|
||||||
|
GPIO_9,
|
||||||
|
GPIO_10,
|
||||||
|
GPIO_11,
|
||||||
|
GPIO_12,
|
||||||
|
GPIO_13,
|
||||||
|
GPIO_14,
|
||||||
|
GPIO_15,
|
||||||
|
|
||||||
|
IO_INVALID,
|
||||||
|
LED_WARNING, // Orange on-board LED
|
||||||
|
LED_RUNNING, // Green on-board LED
|
||||||
|
LED_ERROR, // Red on-board LED
|
||||||
|
LED_COMMUNICATION_1, // Blue on-board LED
|
||||||
|
LED_EXT_1, // external board LED
|
||||||
|
LED_EXT_2, // external board LED
|
||||||
|
LED_EXT_3, // external board LED
|
||||||
|
LED_DEBUG,
|
||||||
|
LED_EMULATOR,
|
||||||
|
|
||||||
|
LED_TRIGGER_ERROR,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* see board_configuration_s->idleValvePin
|
||||||
|
*/
|
||||||
|
IDLE_VALVE,
|
||||||
|
TRIGGER_EMULATOR_PRIMARY,
|
||||||
|
TRIGGER_EMULATOR_SECONDARY,
|
||||||
|
TRIGGER_EMULATOR_3RD,
|
||||||
|
|
||||||
|
|
||||||
ELECTRONIC_THROTTLE_CONTROL_1,
|
ELECTRONIC_THROTTLE_CONTROL_1,
|
||||||
ELECTRONIC_THROTTLE_CONTROL_2,
|
ELECTRONIC_THROTTLE_CONTROL_2,
|
||||||
ELECTRONIC_THROTTLE_CONTROL_3,
|
ELECTRONIC_THROTTLE_CONTROL_3,
|
||||||
|
@ -113,22 +133,6 @@ typedef enum {
|
||||||
|
|
||||||
MAIN_RELAY,
|
MAIN_RELAY,
|
||||||
|
|
||||||
GPIO_0,
|
|
||||||
GPIO_1,
|
|
||||||
GPIO_2,
|
|
||||||
GPIO_3,
|
|
||||||
GPIO_4,
|
|
||||||
GPIO_5,
|
|
||||||
GPIO_6,
|
|
||||||
GPIO_7,
|
|
||||||
GPIO_8,
|
|
||||||
GPIO_9,
|
|
||||||
GPIO_10,
|
|
||||||
GPIO_11,
|
|
||||||
GPIO_12,
|
|
||||||
GPIO_13,
|
|
||||||
GPIO_14,
|
|
||||||
GPIO_15,
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +152,6 @@ extern "C"
|
||||||
{
|
{
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
const char *getPinName(io_pin_e io_pin);
|
|
||||||
io_pin_e getPinByName(const char *name);
|
io_pin_e getPinByName(const char *name);
|
||||||
|
|
||||||
void setDefaultPinState(io_pin_e pin, pin_output_mode_e *defaultState);
|
void setDefaultPinState(io_pin_e pin, pin_output_mode_e *defaultState);
|
||||||
|
|
|
@ -52,6 +52,11 @@ void initOutputSignal(OutputSignal *signal, io_pin_e ioPin) {
|
||||||
signal->io_pin = ioPin;
|
signal->io_pin = ioPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t dbgStart;
|
||||||
|
uint32_t dbgDurr;
|
||||||
|
|
||||||
|
extern const char *namedPinsArray[NAMED_PIN_COUNT];
|
||||||
|
|
||||||
void turnPinHigh(io_pin_e pin) {
|
void turnPinHigh(io_pin_e pin) {
|
||||||
#if EFI_DEFAILED_LOGGING
|
#if EFI_DEFAILED_LOGGING
|
||||||
// signal->hi_time = hTimeNow();
|
// signal->hi_time = hTimeNow();
|
||||||
|
@ -71,8 +76,13 @@ void turnPinHigh(io_pin_e pin) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EFI_WAVE_CHART
|
#if EFI_WAVE_CHART
|
||||||
addWaveChartEvent(getPinName(pin), WC_UP);
|
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
|
||||||
|
const char *pinName = namedPinsArray[pin];
|
||||||
|
dbgDurr = hal_lld_get_counter_value() - dbgStart;
|
||||||
|
|
||||||
|
addWaveChartEvent(pinName, WC_UP);
|
||||||
#endif /* EFI_WAVE_ANALYZER */
|
#endif /* EFI_WAVE_ANALYZER */
|
||||||
|
dbgDurr = hal_lld_get_counter_value() - dbgStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void turnPinLow(io_pin_e pin) {
|
void turnPinLow(io_pin_e pin) {
|
||||||
|
@ -87,7 +97,10 @@ void turnPinLow(io_pin_e pin) {
|
||||||
#endif /* EFI_DEFAILED_LOGGING */
|
#endif /* EFI_DEFAILED_LOGGING */
|
||||||
|
|
||||||
#if EFI_WAVE_CHART
|
#if EFI_WAVE_CHART
|
||||||
addWaveChartEvent(getPinName(pin), WC_DOWN);
|
// this is a performance optimization - array index is cheaper then invoking a method with 'switch'
|
||||||
|
const char *pinName = namedPinsArray[pin];
|
||||||
|
|
||||||
|
addWaveChartEvent(pinName, WC_DOWN);
|
||||||
#endif /* EFI_WAVE_ANALYZER */
|
#endif /* EFI_WAVE_ANALYZER */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,104 +128,14 @@ void scheduleOutput(OutputSignal *signal, float delayMs, float durationMs) {
|
||||||
scheduling_s * sUp = &signal->signalTimerUp[index];
|
scheduling_s * sUp = &signal->signalTimerUp[index];
|
||||||
scheduling_s * sDown = &signal->signalTimerDown[index];
|
scheduling_s * sDown = &signal->signalTimerDown[index];
|
||||||
|
|
||||||
scheduleTask("out up", sUp, (int)MS2US(delayMs), (schfunc_t) &turnPinHigh, (void *) signal->io_pin);
|
scheduleTask("out up", sUp, (int) MS2US(delayMs), (schfunc_t) &turnPinHigh, (void *) signal->io_pin);
|
||||||
scheduleTask("out down", sDown, (int)MS2US(delayMs + durationMs), (schfunc_t) &turnPinLow, (void*) signal->io_pin);
|
scheduleTask("out down", sDown, (int) MS2US(delayMs + durationMs), (schfunc_t) &turnPinLow, (void*) signal->io_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
io_pin_e getPinByName(const char *name) {
|
io_pin_e getPinByName(const char *name) {
|
||||||
if(startsWith(name, "spa")) {
|
if (startsWith(name, "spa")) {
|
||||||
int index = atoi(name + 3);
|
int index = atoi(name + 3);
|
||||||
return (io_pin_e)((int)SPARKOUT_1_OUTPUT - 1 + index);
|
return (io_pin_e) ((int) SPARKOUT_1_OUTPUT - 1 + index);
|
||||||
}
|
}
|
||||||
return IO_INVALID;
|
return IO_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getPinName(io_pin_e io_pin) {
|
|
||||||
switch (io_pin) {
|
|
||||||
// todo: refactor this hell - introduce arrays & checks?
|
|
||||||
case SPARKOUT_1_OUTPUT:
|
|
||||||
return "spa1";
|
|
||||||
case SPARKOUT_2_OUTPUT:
|
|
||||||
return "spa2";
|
|
||||||
case SPARKOUT_3_OUTPUT:
|
|
||||||
return "spa3";
|
|
||||||
case SPARKOUT_4_OUTPUT:
|
|
||||||
return "spa4";
|
|
||||||
case SPARKOUT_5_OUTPUT:
|
|
||||||
return "spa5";
|
|
||||||
case SPARKOUT_6_OUTPUT:
|
|
||||||
return "spa6";
|
|
||||||
case SPARKOUT_7_OUTPUT:
|
|
||||||
return "spa7";
|
|
||||||
case SPARKOUT_8_OUTPUT:
|
|
||||||
return "spa8";
|
|
||||||
case SPARKOUT_9_OUTPUT:
|
|
||||||
return "spa9";
|
|
||||||
case SPARKOUT_10_OUTPUT:
|
|
||||||
return "spa10";
|
|
||||||
case SPARKOUT_11_OUTPUT:
|
|
||||||
return "spa11";
|
|
||||||
case SPARKOUT_12_OUTPUT:
|
|
||||||
return "spa12";
|
|
||||||
|
|
||||||
case INJECTOR_1_OUTPUT:
|
|
||||||
return "inj1";
|
|
||||||
case INJECTOR_2_OUTPUT:
|
|
||||||
return "inj2";
|
|
||||||
case INJECTOR_3_OUTPUT:
|
|
||||||
return "inj3";
|
|
||||||
case INJECTOR_4_OUTPUT:
|
|
||||||
return "inj4";
|
|
||||||
case INJECTOR_5_OUTPUT:
|
|
||||||
return "inj5";
|
|
||||||
case INJECTOR_6_OUTPUT:
|
|
||||||
return "inj6";
|
|
||||||
case INJECTOR_7_OUTPUT:
|
|
||||||
return "inj7";
|
|
||||||
case INJECTOR_8_OUTPUT:
|
|
||||||
return "inj8";
|
|
||||||
case INJECTOR_9_OUTPUT:
|
|
||||||
return "inj9";
|
|
||||||
case INJECTOR_10_OUTPUT:
|
|
||||||
return "inj10";
|
|
||||||
case INJECTOR_11_OUTPUT:
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -62,13 +62,13 @@ void idleDebug(const char *msg, int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void showIdleInfo(void) {
|
static void showIdleInfo(void) {
|
||||||
scheduleMsg(&logger, "isIdleControlActive=%d", engineConfiguration->idleMode);
|
scheduleMsg(&logger, "idleMode=%s", getIdle_mode_e(engineConfiguration->idleMode));
|
||||||
scheduleMsg(&logger, "idle valve freq=%d on %s", boardConfiguration->idleSolenoidFrequency,
|
scheduleMsg(&logger, "idle valve freq=%d on %s", boardConfiguration->idleSolenoidFrequency,
|
||||||
hwPortname(boardConfiguration->idleValvePin));
|
hwPortname(boardConfiguration->idleValvePin));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setIdleControlEnabled(int value, Engine *engine) {
|
static void setIdleControlEnabled(int value, Engine *engine) {
|
||||||
engineConfiguration->idleMode = value ? IM_MANUAL : IM_AUTO;
|
engineConfiguration->idleMode = value ? IM_AUTO : IM_MANUAL;
|
||||||
showIdleInfo();
|
showIdleInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ static msg_t ivThread(int param) {
|
||||||
chRegSetThreadName("IdleValve");
|
chRegSetThreadName("IdleValve");
|
||||||
|
|
||||||
int currentIdleValve = -1;
|
int currentIdleValve = -1;
|
||||||
while (TRUE) {
|
while (true) {
|
||||||
chThdSleepMilliseconds(boardConfiguration->idleThreadPeriod);
|
chThdSleepMilliseconds(boardConfiguration->idleThreadPeriod);
|
||||||
|
|
||||||
// this value is not used yet
|
// this value is not used yet
|
||||||
|
@ -129,7 +129,7 @@ void startIdleThread(Engine *engine) {
|
||||||
boardConfiguration->idleValvePin,
|
boardConfiguration->idleValvePin,
|
||||||
IDLE_VALVE,
|
IDLE_VALVE,
|
||||||
boardConfiguration->idleSolenoidFrequency,
|
boardConfiguration->idleSolenoidFrequency,
|
||||||
0.5);
|
boardConfiguration->idleSolenoidPwm);
|
||||||
|
|
||||||
idleInit(&idle);
|
idleInit(&idle);
|
||||||
scheduleMsg(&logger, "initial idle %d", idle.value);
|
scheduleMsg(&logger, "initial idle %d", idle.value);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "signal_executor.h"
|
#include "signal_executor.h"
|
||||||
#include "main_trigger_callback.h"
|
#include "main_trigger_callback.h"
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
|
#include "efiGpio.h"
|
||||||
|
|
||||||
extern engine_configuration_s *engineConfiguration;
|
extern engine_configuration_s *engineConfiguration;
|
||||||
extern board_configuration_s *boardConfiguration;
|
extern board_configuration_s *boardConfiguration;
|
||||||
|
|
|
@ -17,11 +17,84 @@ int getOutputPinValue(io_pin_e pin) {
|
||||||
return getLogicPinValue(&outputs[pin]);
|
return getLogicPinValue(&outputs[pin]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *namedPinsArray[NAMED_PIN_COUNT] = { "spa1", "spa2", "spa3", "spa4", "spa5", "spa6", "spa7", "spa8",
|
||||||
|
"spa9", "spa10", "spa11", "spa12", "inj1", "inj2", "inj3", "inj4", "inj5", "inj6", "inj7", "inj8", "inj9",
|
||||||
|
"inj10", "inj11", "inj12", };
|
||||||
|
|
||||||
|
const char *getPinName(io_pin_e io_pin) {
|
||||||
|
switch (io_pin) {
|
||||||
|
// todo: refactor this hell - introduce arrays & checks?
|
||||||
|
case SPARKOUT_1_OUTPUT:
|
||||||
|
case SPARKOUT_2_OUTPUT:
|
||||||
|
case SPARKOUT_3_OUTPUT:
|
||||||
|
case SPARKOUT_4_OUTPUT:
|
||||||
|
case SPARKOUT_5_OUTPUT:
|
||||||
|
case SPARKOUT_6_OUTPUT:
|
||||||
|
case SPARKOUT_7_OUTPUT:
|
||||||
|
case SPARKOUT_8_OUTPUT:
|
||||||
|
case SPARKOUT_9_OUTPUT:
|
||||||
|
case SPARKOUT_10_OUTPUT:
|
||||||
|
case SPARKOUT_11_OUTPUT:
|
||||||
|
case SPARKOUT_12_OUTPUT:
|
||||||
|
case INJECTOR_1_OUTPUT:
|
||||||
|
case INJECTOR_2_OUTPUT:
|
||||||
|
case INJECTOR_3_OUTPUT:
|
||||||
|
case INJECTOR_4_OUTPUT:
|
||||||
|
case INJECTOR_5_OUTPUT:
|
||||||
|
case INJECTOR_6_OUTPUT:
|
||||||
|
case INJECTOR_7_OUTPUT:
|
||||||
|
case INJECTOR_8_OUTPUT:
|
||||||
|
case INJECTOR_9_OUTPUT:
|
||||||
|
case INJECTOR_10_OUTPUT:
|
||||||
|
case INJECTOR_11_OUTPUT:
|
||||||
|
case INJECTOR_12_OUTPUT:
|
||||||
|
return namedPinsArray[io_pin];
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the value according to current electrical settings
|
* @brief Sets the value according to current electrical settings
|
||||||
*
|
*
|
||||||
* This method costs about 85 ticks
|
* This method costs about 85 ticks
|
||||||
*/
|
*/
|
||||||
|
extern uint32_t dbgStart;
|
||||||
|
extern uint32_t dbgDurr;
|
||||||
|
|
||||||
void setOutputPinValue(io_pin_e pin, int logicValue) {
|
void setOutputPinValue(io_pin_e pin, int logicValue) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
if (outputs[pin].port == GPIO_NULL)
|
if (outputs[pin].port == GPIO_NULL)
|
||||||
|
|
|
@ -77,6 +77,7 @@ extern "C"
|
||||||
int getOutputPinValue(io_pin_e pin);
|
int getOutputPinValue(io_pin_e pin);
|
||||||
void setOutputPinValue(io_pin_e pin, int logicValue);
|
void setOutputPinValue(io_pin_e pin, int logicValue);
|
||||||
bool isPinAssigned(io_pin_e pin);
|
bool isPinAssigned(io_pin_e pin);
|
||||||
|
const char *getPinName(io_pin_e io_pin);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue