de-pointerize outputMode #49
This commit is contained in:
parent
74e2592746
commit
f7e6ccd9e2
|
@ -4,10 +4,10 @@
|
||||||
BOARDCPPSRC += $(BOARDS_DIR)/hellen/hellen_common.cpp \
|
BOARDCPPSRC += $(BOARDS_DIR)/hellen/hellen_common.cpp \
|
||||||
$(BOARDS_DIR)/hellen/hellen_board_id.cpp
|
$(BOARDS_DIR)/hellen/hellen_board_id.cpp
|
||||||
|
|
||||||
DDEFS += -DLED_ERROR_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
DDEFS += -DLED_ERROR_BRAIN_PIN_MODE=OM_INVERTED
|
||||||
DDEFS += -DLED_RUNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
DDEFS += -DLED_RUNING_BRAIN_PIN_MODE=OM_INVERTED
|
||||||
DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
DDEFS += -DLED_WARNING_BRAIN_PIN_MODE=OM_INVERTED
|
||||||
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=INVERTED_OUTPUT
|
DDEFS += -DLED_COMMUNICATION_BRAIN_PIN_MODE=OM_INVERTED
|
||||||
|
|
||||||
# We are running on Hellen-One hardware!
|
# We are running on Hellen-One hardware!
|
||||||
DDEFS += -DHW_HELLEN=1
|
DDEFS += -DHW_HELLEN=1
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#undef LED_CRITICAL_ERROR_BRAIN_PIN
|
#undef LED_CRITICAL_ERROR_BRAIN_PIN
|
||||||
#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::A13
|
#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::A13
|
||||||
#undef LED_ERROR_BRAIN_PIN_MODE
|
#undef LED_ERROR_BRAIN_PIN_MODE
|
||||||
#define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
#define LED_ERROR_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
|
|
||||||
#undef CONSOLE_MODE_SWITCH_PORT
|
#undef CONSOLE_MODE_SWITCH_PORT
|
||||||
#undef CONFIG_RESET_SWITCH_PORT
|
#undef CONFIG_RESET_SWITCH_PORT
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
/* LEDs */
|
/* LEDs */
|
||||||
#undef LED_ERROR_BRAIN_PIN_MODE
|
#undef LED_ERROR_BRAIN_PIN_MODE
|
||||||
#define LED_ERROR_BRAIN_PIN_MODE INVERTED_OUTPUT
|
#define LED_ERROR_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#undef LED_WARNING_BRAIN_PIN_MODE
|
#undef LED_WARNING_BRAIN_PIN_MODE
|
||||||
#define LED_WARNING_BRAIN_PIN_MODE INVERTED_OUTPUT
|
#define LED_WARNING_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#undef LED_RUNING_BRAIN_PIN_MODE
|
#undef LED_RUNING_BRAIN_PIN_MODE
|
||||||
#define LED_RUNING_BRAIN_PIN_MODE INVERTED_OUTPUT
|
#define LED_RUNING_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
|
|
||||||
/* debug console */
|
/* debug console */
|
||||||
#define TS_PRIMARY_UxART_PORT SD1
|
#define TS_PRIMARY_UxART_PORT SD1
|
||||||
|
|
|
@ -424,7 +424,7 @@
|
||||||
#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::D14
|
#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::D14
|
||||||
#endif
|
#endif
|
||||||
#ifndef LED_ERROR_BRAIN_PIN_MODE
|
#ifndef LED_ERROR_BRAIN_PIN_MODE
|
||||||
#define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
#define LED_ERROR_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// USART1 -> check defined STM32_SERIAL_USE_USART1
|
// USART1 -> check defined STM32_SERIAL_USE_USART1
|
||||||
|
|
|
@ -85,17 +85,14 @@ extern WaveChart waveChart;
|
||||||
|
|
||||||
#include "sensor_chart.h"
|
#include "sensor_chart.h"
|
||||||
|
|
||||||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
|
||||||
extern pin_output_mode_e INVERTED_OUTPUT;
|
|
||||||
|
|
||||||
#ifndef LED_WARNING_BRAIN_PIN_MODE
|
#ifndef LED_WARNING_BRAIN_PIN_MODE
|
||||||
#define LED_WARNING_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
#define LED_WARNING_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#endif
|
#endif
|
||||||
#ifndef LED_RUNING_BRAIN_PIN_MODE
|
#ifndef LED_RUNING_BRAIN_PIN_MODE
|
||||||
#define LED_RUNING_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
#define LED_RUNING_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#endif
|
#endif
|
||||||
#ifndef LED_COMMUNICATION_BRAIN_PIN_MODE
|
#ifndef LED_COMMUNICATION_BRAIN_PIN_MODE
|
||||||
#define LED_COMMUNICATION_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
#define LED_COMMUNICATION_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int warningEnabled = true;
|
int warningEnabled = true;
|
||||||
|
@ -261,11 +258,11 @@ static OutputPin *leds[] = { &enginePins.warningLedPin, &enginePins.runningLedPi
|
||||||
&enginePins.errorLedPin, &enginePins.communicationLedPin, &enginePins.checkEnginePin };
|
&enginePins.errorLedPin, &enginePins.communicationLedPin, &enginePins.checkEnginePin };
|
||||||
|
|
||||||
static void initStatusLeds() {
|
static void initStatusLeds() {
|
||||||
enginePins.communicationLedPin.initPin("led: comm status", engineConfiguration->communicationLedPin, &LED_COMMUNICATION_BRAIN_PIN_MODE, true);
|
enginePins.communicationLedPin.initPin("led: comm status", engineConfiguration->communicationLedPin, LED_COMMUNICATION_BRAIN_PIN_MODE, true);
|
||||||
// checkEnginePin is already initialized by the time we get here
|
// checkEnginePin is already initialized by the time we get here
|
||||||
|
|
||||||
enginePins.warningLedPin.initPin("led: warning status", engineConfiguration->warningLedPin, &LED_WARNING_BRAIN_PIN_MODE, true);
|
enginePins.warningLedPin.initPin("led: warning status", engineConfiguration->warningLedPin, LED_WARNING_BRAIN_PIN_MODE, true);
|
||||||
enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin, &LED_RUNING_BRAIN_PIN_MODE, true);
|
enginePins.runningLedPin.initPin("led: running status", engineConfiguration->runningLedPin, LED_RUNING_BRAIN_PIN_MODE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
// todo: clean this mess, this should become 'static'/private
|
// todo: clean this mess, this should become 'static'/private
|
||||||
EnginePins enginePins;
|
EnginePins enginePins;
|
||||||
|
|
||||||
pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT;
|
|
||||||
pin_output_mode_e INVERTED_OUTPUT = OM_INVERTED;
|
|
||||||
|
|
||||||
static const char* const sparkNames[] = { "Coil 1", "Coil 2", "Coil 3", "Coil 4", "Coil 5", "Coil 6", "Coil 7", "Coil 8",
|
static const char* const sparkNames[] = { "Coil 1", "Coil 2", "Coil 3", "Coil 4", "Coil 5", "Coil 6", "Coil 7", "Coil 8",
|
||||||
"Coil 9", "Coil 10", "Coil 11", "Coil 12"};
|
"Coil 9", "Coil 10", "Coil 11", "Coil 12"};
|
||||||
|
|
||||||
|
@ -107,11 +104,11 @@ bool RegisteredOutputPin::isPinConfigurationChanged() {
|
||||||
void RegisteredOutputPin::init() {
|
void RegisteredOutputPin::init() {
|
||||||
brain_pin_e newPin = *(brain_pin_e *) ((void *) (&((char*) engineConfiguration)[m_pinOffset]));
|
brain_pin_e newPin = *(brain_pin_e *) ((void *) (&((char*) engineConfiguration)[m_pinOffset]));
|
||||||
|
|
||||||
pin_output_mode_e* newMode;
|
pin_output_mode_e newMode;
|
||||||
if (m_hasPinMode) {
|
if (m_hasPinMode) {
|
||||||
newMode = (pin_output_mode_e *) ((void *) (&((char*) engineConfiguration)[m_pinModeOffset]));
|
newMode = *(pin_output_mode_e *) ((void *) (&((char*) engineConfiguration)[m_pinModeOffset]));
|
||||||
} else {
|
} else {
|
||||||
newMode = &DEFAULT_OUTPUT;
|
newMode = OM_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPinConfigurationChanged()) {
|
if (isPinConfigurationChanged()) {
|
||||||
|
@ -296,12 +293,12 @@ void EnginePins::startIgnitionPins() {
|
||||||
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
|
||||||
NamedOutputPin *trailingOutput = &enginePins.trailingCoils[i];
|
NamedOutputPin *trailingOutput = &enginePins.trailingCoils[i];
|
||||||
if (isPinOrModeChanged(trailingCoilPins[i], ignitionPinMode)) {
|
if (isPinOrModeChanged(trailingCoilPins[i], ignitionPinMode)) {
|
||||||
trailingOutput->initPin(trailingOutput->name, engineConfiguration->trailingCoilPins[i], &engineConfiguration->ignitionPinMode);
|
trailingOutput->initPin(trailingOutput->name, engineConfiguration->trailingCoilPins[i], engineConfiguration->ignitionPinMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedOutputPin *output = &enginePins.coils[i];
|
NamedOutputPin *output = &enginePins.coils[i];
|
||||||
if (isPinOrModeChanged(ignitionPins[i], ignitionPinMode)) {
|
if (isPinOrModeChanged(ignitionPins[i], ignitionPinMode)) {
|
||||||
output->initPin(output->name, engineConfiguration->ignitionPins[i], &engineConfiguration->ignitionPinMode);
|
output->initPin(output->name, engineConfiguration->ignitionPins[i], engineConfiguration->ignitionPinMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
@ -314,7 +311,7 @@ void EnginePins::startInjectionPins() {
|
||||||
NamedOutputPin *output = &enginePins.injectors[i];
|
NamedOutputPin *output = &enginePins.injectors[i];
|
||||||
if (isPinOrModeChanged(injectionPins[i], injectionPinMode)) {
|
if (isPinOrModeChanged(injectionPins[i], injectionPinMode)) {
|
||||||
output->initPin(output->name, engineConfiguration->injectionPins[i],
|
output->initPin(output->name, engineConfiguration->injectionPins[i],
|
||||||
&engineConfiguration->injectionPinMode);
|
engineConfiguration->injectionPinMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
@ -453,10 +450,6 @@ void IgnitionOutputPin::reset() {
|
||||||
signalFallSparkId = 0;
|
signalFallSparkId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputPin::OutputPin() {
|
|
||||||
modePtr = &DEFAULT_OUTPUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OutputPin::isInitialized() {
|
bool OutputPin::isInitialized() {
|
||||||
#if EFI_GPIO_HARDWARE && EFI_PROD_CODE
|
#if EFI_GPIO_HARDWARE && EFI_PROD_CODE
|
||||||
#if (BOARD_EXT_GPIOCHIPS > 0)
|
#if (BOARD_EXT_GPIOCHIPS > 0)
|
||||||
|
@ -514,8 +507,6 @@ void OutputPin::setValue(int logicValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6621, modePtr!=NULL, "pin mode not initialized");
|
|
||||||
pin_output_mode_e mode = *modePtr;
|
|
||||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6622, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e");
|
efiAssertVoid(ObdCode::CUSTOM_ERR_6622, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e");
|
||||||
int electricalValue = getElectricalValue(logicValue, mode);
|
int electricalValue = getElectricalValue(logicValue, mode);
|
||||||
|
|
||||||
|
@ -541,11 +532,9 @@ bool OutputPin::getLogicValue() const {
|
||||||
return currentLogicValue == 1;
|
return currentLogicValue == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPin::setDefaultPinState(const pin_output_mode_e *outputMode) {
|
void OutputPin::setDefaultPinState(pin_output_mode_e outputMode) {
|
||||||
pin_output_mode_e mode = *outputMode;
|
|
||||||
/* may be*/UNUSED(mode);
|
|
||||||
assertOMode(mode);
|
assertOMode(mode);
|
||||||
this->modePtr = outputMode;
|
this->mode = outputMode;
|
||||||
setValue(false); // initial state
|
setValue(false); // initial state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,10 +564,10 @@ void initOutputPins() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPin::initPin(const char *msg, brain_pin_e brainPin) {
|
void OutputPin::initPin(const char *msg, brain_pin_e brainPin) {
|
||||||
initPin(msg, brainPin, &DEFAULT_OUTPUT);
|
initPin(msg, brainPin, OM_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_mode_e *outputMode, bool forceInitWithFatalError) {
|
void OutputPin::initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError) {
|
||||||
#if EFI_UNIT_TEST
|
#if EFI_UNIT_TEST
|
||||||
unitTestTurnedOnCounter = 0;
|
unitTestTurnedOnCounter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -603,17 +592,17 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*outputMode > OM_OPENDRAIN_INVERTED) {
|
if (outputMode > OM_OPENDRAIN_INVERTED) {
|
||||||
firmwareError(ObdCode::CUSTOM_INVALID_MODE_SETTING, "%s invalid pin_output_mode_e %d %s",
|
firmwareError(ObdCode::CUSTOM_INVALID_MODE_SETTING, "%s invalid pin_output_mode_e %d %s",
|
||||||
msg,
|
msg,
|
||||||
*outputMode,
|
outputMode,
|
||||||
hwPortname(brainPin)
|
hwPortname(brainPin)
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_GPIO_HARDWARE && EFI_PROD_CODE
|
#if EFI_GPIO_HARDWARE && EFI_PROD_CODE
|
||||||
iomode_t mode = (*outputMode == OM_DEFAULT || *outputMode == OM_INVERTED) ?
|
iomode_t mode = (outputMode == OM_DEFAULT || outputMode == OM_INVERTED) ?
|
||||||
PAL_MODE_OUTPUT_PUSHPULL : PAL_MODE_OUTPUT_OPENDRAIN;
|
PAL_MODE_OUTPUT_PUSHPULL : PAL_MODE_OUTPUT_OPENDRAIN;
|
||||||
|
|
||||||
#if (BOARD_EXT_GPIOCHIPS > 0)
|
#if (BOARD_EXT_GPIOCHIPS > 0)
|
||||||
|
@ -654,16 +643,16 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
||||||
// we had enough drama with pin configuration in board.h and else that we shall self-check
|
// we had enough drama with pin configuration in board.h and else that we shall self-check
|
||||||
|
|
||||||
// todo: handle OM_OPENDRAIN and OM_OPENDRAIN_INVERTED as well
|
// todo: handle OM_OPENDRAIN and OM_OPENDRAIN_INVERTED as well
|
||||||
if (*outputMode == OM_DEFAULT || *outputMode == OM_INVERTED) {
|
if (outputMode == OM_DEFAULT || outputMode == OM_INVERTED) {
|
||||||
const int logicalValue =
|
const int logicalValue =
|
||||||
(*outputMode == OM_INVERTED)
|
(outputMode == OM_INVERTED)
|
||||||
? !actualValue
|
? !actualValue
|
||||||
: actualValue;
|
: actualValue;
|
||||||
|
|
||||||
#ifndef DISABLE_PIN_STATE_VALIDATION
|
#ifndef DISABLE_PIN_STATE_VALIDATION
|
||||||
// if the pin was set to logical 1, then set an error and disable the pin so that things don't catch fire
|
// if the pin was set to logical 1, then set an error and disable the pin so that things don't catch fire
|
||||||
if (logicalValue) {
|
if (logicalValue) {
|
||||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "HARDWARE VALIDATION FAILED %s: unexpected startup pin state %s actual value=%d logical value=%d mode=%s", msg, hwPortname(brainPin), actualValue, logicalValue, getPin_output_mode_e(*outputMode));
|
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "HARDWARE VALIDATION FAILED %s: unexpected startup pin state %s actual value=%d logical value=%d mode=%s", msg, hwPortname(brainPin), actualValue, logicalValue, getPin_output_mode_e(outputMode));
|
||||||
OutputPin::deInit();
|
OutputPin::deInit();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -704,15 +693,15 @@ ioportmask_t criticalErrorLedPin;
|
||||||
uint8_t criticalErrorLedState;
|
uint8_t criticalErrorLedState;
|
||||||
|
|
||||||
#ifndef LED_ERROR_BRAIN_PIN_MODE
|
#ifndef LED_ERROR_BRAIN_PIN_MODE
|
||||||
#define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT
|
#define LED_ERROR_BRAIN_PIN_MODE OM_DEFAULT
|
||||||
#endif /* LED_ERROR_BRAIN_PIN_MODE */
|
#endif /* LED_ERROR_BRAIN_PIN_MODE */
|
||||||
|
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
static void initErrorLed(Gpio led) {
|
static void initErrorLed(Gpio led) {
|
||||||
enginePins.errorLedPin.initPin("led: CRITICAL status", led, &(LED_ERROR_BRAIN_PIN_MODE));
|
enginePins.errorLedPin.initPin("led: CRITICAL status", led, (LED_ERROR_BRAIN_PIN_MODE));
|
||||||
criticalErrorLedPort = getHwPort("CRITICAL", led);
|
criticalErrorLedPort = getHwPort("CRITICAL", led);
|
||||||
criticalErrorLedPin = getHwPin("CRITICAL", led);
|
criticalErrorLedPin = getHwPin("CRITICAL", led);
|
||||||
criticalErrorLedState = (LED_ERROR_BRAIN_PIN_MODE == INVERTED_OUTPUT) ? 0 : 1;
|
criticalErrorLedState = (LED_ERROR_BRAIN_PIN_MODE == OM_INVERTED) ? 0 : 1;
|
||||||
}
|
}
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
|
||||||
|
|
|
@ -20,21 +20,13 @@
|
||||||
*/
|
*/
|
||||||
class OutputPin {
|
class OutputPin {
|
||||||
public:
|
public:
|
||||||
OutputPin();
|
// initializes pin & registers it in pin repository
|
||||||
/**
|
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError = false);
|
||||||
* initializes pin & registers it in pin repository
|
|
||||||
* outputMode being a pointer allow us to change configuration (for example invert logical pin) in configuration and get resuts applied
|
// same as above, with OM_DEFAULT mode
|
||||||
* away, or at least I hope that's why
|
|
||||||
*/
|
|
||||||
void initPin(const char *msg, brain_pin_e brainPin, const pin_output_mode_e *outputMode, bool forceInitWithFatalError = false);
|
|
||||||
/**
|
|
||||||
* same as above, with DEFAULT_OUTPUT mode
|
|
||||||
*/
|
|
||||||
void initPin(const char *msg, brain_pin_e brainPin);
|
void initPin(const char *msg, brain_pin_e brainPin);
|
||||||
|
|
||||||
/**
|
// dissociates pin from this output and un-registers it in pin repository
|
||||||
* dissociates pin from this output and un-registers it in pin repository
|
|
||||||
*/
|
|
||||||
void deInit();
|
void deInit();
|
||||||
|
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
|
@ -69,11 +61,11 @@ public:
|
||||||
*/
|
*/
|
||||||
private:
|
private:
|
||||||
// todo: inline this method?
|
// todo: inline this method?
|
||||||
void setDefaultPinState(const pin_output_mode_e *defaultState);
|
void setDefaultPinState(pin_output_mode_e mode);
|
||||||
void setOnchipValue(int electricalValue);
|
void setOnchipValue(int electricalValue);
|
||||||
|
|
||||||
// 4 byte pointer is a bit of a memory waste here
|
// 4 byte pointer is a bit of a memory waste here
|
||||||
const pin_output_mode_e *modePtr = nullptr;
|
pin_output_mode_e mode = OM_DEFAULT;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@ SimpleTransmissionController simpleTransmissionController;
|
||||||
|
|
||||||
void SimpleTransmissionController::init() {
|
void SimpleTransmissionController::init() {
|
||||||
for (size_t i = 0; i < efi::size(engineConfiguration->tcu_solenoid); i++) {
|
for (size_t i = 0; i < efi::size(engineConfiguration->tcu_solenoid); i++) {
|
||||||
enginePins.tcuSolenoids[i].initPin("Transmission Solenoid", engineConfiguration->tcu_solenoid[i], &engineConfiguration->tcu_solenoid_mode[i]);
|
enginePins.tcuSolenoids[i].initPin("Transmission Solenoid", engineConfiguration->tcu_solenoid[i], engineConfiguration->tcu_solenoid_mode[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,24 +10,24 @@ static SimplePwm shift32Pwm("3-2 Shift Control");
|
||||||
|
|
||||||
void Gm4l6xTransmissionController::init() {
|
void Gm4l6xTransmissionController::init() {
|
||||||
for (size_t i = 0; i < efi::size(engineConfiguration->tcu_solenoid); i++) {
|
for (size_t i = 0; i < efi::size(engineConfiguration->tcu_solenoid); i++) {
|
||||||
enginePins.tcuSolenoids[i].initPin("Transmission Solenoid", engineConfiguration->tcu_solenoid[i], &engineConfiguration->tcu_solenoid_mode[i]);
|
enginePins.tcuSolenoids[i].initPin("Transmission Solenoid", engineConfiguration->tcu_solenoid[i], engineConfiguration->tcu_solenoid_mode[i]);
|
||||||
}
|
}
|
||||||
enginePins.tcuTccOnoffSolenoid.initPin("TCC On/Off Solenoid", engineConfiguration->tcu_tcc_onoff_solenoid, &engineConfiguration->tcu_tcc_onoff_solenoid_mode);
|
enginePins.tcuTccOnoffSolenoid.initPin("TCC On/Off Solenoid", engineConfiguration->tcu_tcc_onoff_solenoid, engineConfiguration->tcu_tcc_onoff_solenoid_mode);
|
||||||
enginePins.tcuTccPwmSolenoid.initPin("TCC PWM Solenoid", engineConfiguration->tcu_tcc_pwm_solenoid, &engineConfiguration->tcu_tcc_pwm_solenoid_mode);
|
enginePins.tcuTccPwmSolenoid.initPin("TCC PWM Solenoid", engineConfiguration->tcu_tcc_pwm_solenoid, engineConfiguration->tcu_tcc_pwm_solenoid_mode);
|
||||||
startSimplePwm(&tccPwm,
|
startSimplePwm(&tccPwm,
|
||||||
"TCC",
|
"TCC",
|
||||||
&engine->executor,
|
&engine->executor,
|
||||||
&enginePins.tcuTccPwmSolenoid,
|
&enginePins.tcuTccPwmSolenoid,
|
||||||
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
engineConfiguration->tcu_tcc_pwm_solenoid_freq,
|
||||||
0);
|
0);
|
||||||
enginePins.tcuPcSolenoid.initPin("Pressure Control Solenoid", engineConfiguration->tcu_pc_solenoid_pin, &engineConfiguration->tcu_pc_solenoid_pin_mode);
|
enginePins.tcuPcSolenoid.initPin("Pressure Control Solenoid", engineConfiguration->tcu_pc_solenoid_pin, engineConfiguration->tcu_pc_solenoid_pin_mode);
|
||||||
startSimplePwm(&pcPwm,
|
startSimplePwm(&pcPwm,
|
||||||
"Line Pressure",
|
"Line Pressure",
|
||||||
&engine->executor,
|
&engine->executor,
|
||||||
&enginePins.tcuPcSolenoid,
|
&enginePins.tcuPcSolenoid,
|
||||||
engineConfiguration->tcu_pc_solenoid_freq,
|
engineConfiguration->tcu_pc_solenoid_freq,
|
||||||
0);
|
0);
|
||||||
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, &engineConfiguration->tcu_32_solenoid_pin_mode);
|
enginePins.tcu32Solenoid.initPin("3-2 Shift Solenoid", engineConfiguration->tcu_32_solenoid_pin, engineConfiguration->tcu_32_solenoid_pin_mode);
|
||||||
startSimplePwm(&shift32Pwm,
|
startSimplePwm(&shift32Pwm,
|
||||||
"3-2 Solenoid",
|
"3-2 Solenoid",
|
||||||
&engine->executor,
|
&engine->executor,
|
||||||
|
|
|
@ -239,7 +239,7 @@ void startTriggerEmulatorPins() {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
if (isConfigurationChanged(triggerSimulatorPins[i])) {
|
if (isConfigurationChanged(triggerSimulatorPins[i])) {
|
||||||
triggerEmulatorSignal.outputPins[i]->initPin("Trigger emulator", pin,
|
triggerEmulatorSignal.outputPins[i]->initPin("Trigger emulator", pin,
|
||||||
&engineConfiguration->triggerSimulatorPinModes[i]);
|
engineConfiguration->triggerSimulatorPinModes[i]);
|
||||||
}
|
}
|
||||||
#endif // EFI_PROD_CODE
|
#endif // EFI_PROD_CODE
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,25 +335,25 @@ void stopSmartCsPins() {
|
||||||
void startSmartCsPins() {
|
void startSmartCsPins() {
|
||||||
#if (BOARD_TLE8888_COUNT > 0)
|
#if (BOARD_TLE8888_COUNT > 0)
|
||||||
tle8888Cs.initPin("tle8888 CS", engineConfiguration->tle8888_cs,
|
tle8888Cs.initPin("tle8888 CS", engineConfiguration->tle8888_cs,
|
||||||
&engineConfiguration->tle8888_csPinMode);
|
engineConfiguration->tle8888_csPinMode);
|
||||||
tle8888Cs.setValue(true);
|
tle8888Cs.setValue(true);
|
||||||
#endif /* BOARD_TLE8888_COUNT */
|
#endif /* BOARD_TLE8888_COUNT */
|
||||||
#if (BOARD_TLE6240_COUNT > 0)
|
#if (BOARD_TLE6240_COUNT > 0)
|
||||||
// todo: any way to reduce copy-paste? some convention between pin property name and pin mode property name?
|
// todo: any way to reduce copy-paste? some convention between pin property name and pin mode property name?
|
||||||
tle6240Cs.initPin("tle6240 CS", engineConfiguration->tle6240_cs,
|
tle6240Cs.initPin("tle6240 CS", engineConfiguration->tle6240_cs,
|
||||||
&engineConfiguration->tle6240_csPinMode);
|
engineConfiguration->tle6240_csPinMode);
|
||||||
tle6240Cs.setValue(true);
|
tle6240Cs.setValue(true);
|
||||||
#endif /* BOARD_TLE6240_COUNT */
|
#endif /* BOARD_TLE6240_COUNT */
|
||||||
#if (BOARD_MC33972_COUNT > 0)
|
#if (BOARD_MC33972_COUNT > 0)
|
||||||
// todo: any way to reduce copy-paste? some convention between pin property name and pin mode property name?
|
// todo: any way to reduce copy-paste? some convention between pin property name and pin mode property name?
|
||||||
mc33972Cs.initPin("mc33972 CS", engineConfiguration->mc33972_cs,
|
mc33972Cs.initPin("mc33972 CS", engineConfiguration->mc33972_cs,
|
||||||
&engineConfiguration->mc33972_csPinMode);
|
engineConfiguration->mc33972_csPinMode);
|
||||||
mc33972Cs.setValue(true);
|
mc33972Cs.setValue(true);
|
||||||
#endif /* BOARD_MC33972_COUNT */
|
#endif /* BOARD_MC33972_COUNT */
|
||||||
#if (BOARD_DRV8860_COUNT > 0)
|
#if (BOARD_DRV8860_COUNT > 0)
|
||||||
// todo: any way to reduce copy-paste? some convention between pin property name and pin mode property name?
|
// todo: any way to reduce copy-paste? some convention between pin property name and pin mode property name?
|
||||||
drv8860Cs.initPin("drv8860 CS", engineConfiguration->drv8860_cs,
|
drv8860Cs.initPin("drv8860 CS", engineConfiguration->drv8860_cs,
|
||||||
&engineConfiguration->drv8860_csPinMode);
|
engineConfiguration->drv8860_csPinMode);
|
||||||
drv8860Cs.setValue(true);
|
drv8860Cs.setValue(true);
|
||||||
#endif /* BOARD_DRV8860_COUNT */
|
#endif /* BOARD_DRV8860_COUNT */
|
||||||
#if (BOARD_MC33810_COUNT > 0)
|
#if (BOARD_MC33810_COUNT > 0)
|
||||||
|
|
|
@ -220,13 +220,13 @@ void StepDirectionStepper::initialize(brain_pin_e stepPin, brain_pin_e direction
|
||||||
setReactionTime(reactionTime);
|
setReactionTime(reactionTime);
|
||||||
|
|
||||||
this->directionPinMode = directionPinMode;
|
this->directionPinMode = directionPinMode;
|
||||||
this->directionPin.initPin("Stepper DIR", directionPin, &this->directionPinMode);
|
this->directionPin.initPin("Stepper DIR", directionPin, this->directionPinMode);
|
||||||
|
|
||||||
this->stepPinMode = OM_DEFAULT; // todo: do we need configurable stepPinMode?
|
this->stepPinMode = OM_DEFAULT; // todo: do we need configurable stepPinMode?
|
||||||
this->stepPin.initPin("Stepper step", stepPin, &this->stepPinMode);
|
this->stepPin.initPin("Stepper step", stepPin, this->stepPinMode);
|
||||||
|
|
||||||
this->enablePinMode = enablePinMode;
|
this->enablePinMode = enablePinMode;
|
||||||
this->enablePin.initPin("Stepper EN", enablePin, &this->enablePinMode);
|
this->enablePin.initPin("Stepper EN", enablePin, this->enablePinMode);
|
||||||
|
|
||||||
// All pins must be 0 for correct hardware startup (e.g. stepper auto-disabling circuit etc.).
|
// All pins must be 0 for correct hardware startup (e.g. stepper auto-disabling circuit etc.).
|
||||||
this->enablePin.setValue(true); // disable stepper
|
this->enablePin.setValue(true); // disable stepper
|
||||||
|
|
Loading…
Reference in New Issue