extract method setupTLE9201

This commit is contained in:
rusefillc 2024-07-26 23:08:04 -04:00
parent d7758c6d48
commit 935b96e628
7 changed files with 29 additions and 97 deletions

View File

@ -36,24 +36,6 @@ static void setInjectorPins() {
engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned;
}
static void setupEtb() {
// TLE9201 driver
// This chip has three control pins:
// DIR - sets direction of the motor
// PWM - pwm control (enable high, coast low)
// DIS - disables motor (enable low)
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_PWM2;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_GP_IO1;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::H144_GP_IO2;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}
static void setIgnitionPins() {
engineConfiguration->ignitionPins[0] = Gpio::H144_IGN_1;
engineConfiguration->ignitionPins[1] = Gpio::H144_IGN_2;
@ -160,7 +142,7 @@ void setBoardConfigOverrides() {
void setBoardDefaultConfiguration() {
setInjectorPins();
setIgnitionPins();
setupEtb();
setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM2, /*directionPin1*/Gpio::H144_GP_IO1, /*disablePin*/Gpio::H144_GP_IO2);
if (is_F_OrOlder()) {
engineConfiguration->tachOutputPin = Gpio::H144_OUT_IO13;
engineConfiguration->vvtPins[0] = Gpio::H144_OUT_PWM7;

View File

@ -38,30 +38,6 @@ static void setInjectorPins() {
engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned;
}
static void setupEtb() {
// TLE9201 driver
// This chip has three control pins:
// DIR - sets direction of the motor
// PWM - pwm control (enable high, coast low)
// DIS - disables motor (enable low)
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_PWM2;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_GP_IO1;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::H144_GP_IO5;
// PWM pin
engineConfiguration->etbIo[1].controlPin = Gpio::H144_GP_IO4;
// DIR pin
engineConfiguration->etbIo[1].directionPin1 = Gpio::H144_GP_IO3;
// Disable pin
engineConfiguration->etbIo[1].disablePin = Gpio::Unassigned;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}
static void setIgnitionPins() {
engineConfiguration->ignitionPins[0] = Gpio::H144_IGN_1;
engineConfiguration->ignitionPins[1] = Gpio::H144_IGN_2;
@ -143,7 +119,10 @@ void setBoardConfigOverrides() {
void setBoardDefaultConfiguration() {
setInjectorPins();
setIgnitionPins();
setupEtb();
setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM2, Gpio::H144_GP_IO1, Gpio::H144_GP_IO5);
setupTLE9201(/*controlPin*/Gpio::H144_GP_IO4, Gpio::H144_GP_IO3, Gpio::Unassigned, 1);
engineConfiguration->vvtPins[0] = Gpio::H144_OUT_PWM7;
engineConfiguration->vvtPins[1] = Gpio::H144_OUT_PWM8;

View File

@ -38,31 +38,6 @@ static void setInjectorPins() {
engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned;
}
static void setupEtb() {
// TLE9201 driver
// This chip has three control pins:
// DIR - sets direction of the motor
// PWM - pwm control (enable high, coast low)
// DIS - disables motor (enable low)
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::MM176_OUT_PWM9;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::MM176_GP6;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::MM176_GP7;
// PWM pin
engineConfiguration->etbIo[1].controlPin = Gpio::MM176_OUT_PWM18;
// DIR pin
engineConfiguration->etbIo[1].directionPin1 = Gpio::MM176_GP10;
// Disable pin
engineConfiguration->etbIo[1].disablePin = Gpio::MM176_GP11;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}
static void setIgnitionPins() {
engineConfiguration->ignitionPins[0] = Gpio::MM176_IGN1;
engineConfiguration->ignitionPins[1] = Gpio::MM176_IGN2;
@ -136,7 +111,8 @@ void setBoardConfigOverrides() {
void setBoardDefaultConfiguration() {
setInjectorPins();
setIgnitionPins();
setupEtb();
setupTLE9201(/*controlPin*/Gpio::MM176_OUT_PWM9, Gpio::MM176_GP6, Gpio::MM176_GP7);
setupTLE9201(/*controlPin*/Gpio::MM176_OUT_PWM18, Gpio::MM176_GP10, Gpio::MM176_GP11, 1);
// engineConfiguration->vvtPins[0] = Gpio::H144_OUT_PWM7;
// engineConfiguration->vvtPins[1] = Gpio::H144_OUT_PWM8;

View File

@ -70,19 +70,7 @@ void setBoardConfigOverrides() {
setHellenCan();
// TLE9201 driver
// This chip has three control pins:
// DIR - sets direction of the motor
// PWM - pwm control (enable high, coast low)
// DIS - disables motor (enable low)
//ETB1
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_PWM8;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_OUT_IO13;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::H144_OUT_IO4;
setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM8, Gpio::H144_OUT_IO13, Gpio::H144_OUT_IO4);
}
/**

View File

@ -67,22 +67,10 @@ void setBoardConfigOverrides() {
// todo You would not believe how you invert TLE9201 #4579
engineConfiguration->stepperDcInvertedPins = true;
//ETB1
// PWM pin
engineConfiguration->etbIo[0].controlPin = Gpio::H144_OUT_PWM2;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = Gpio::H144_OUT_PWM3;
// Disable pin
engineConfiguration->etbIo[0].disablePin = Gpio::H144_OUT_IO12;
setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM2, Gpio::H144_OUT_PWM3, Gpio::H144_OUT_IO12);
// wastegate DC motor
//ETB2
// PWM pin
engineConfiguration->etbIo[1].controlPin = Gpio::H144_OUT_PWM4;
// DIR pin
engineConfiguration->etbIo[1].directionPin1 = Gpio::H144_OUT_PWM5;
// Disable pin
engineConfiguration->etbIo[1].disablePin = Gpio::H144_OUT_IO13;
setupTLE9201(/*controlPin*/Gpio::H144_OUT_PWM4, Gpio::H144_OUT_PWM5, Gpio::H144_OUT_IO13, 1);
}
/**

View File

@ -142,3 +142,21 @@ void detectHellenBoardType() {
engine->engineState.hellenBoardId = hackHellenBoardId(detectHellenBoardId());
#endif /* EFI_BOOTLOADER */
}
void setupTLE9201(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex) {
// TLE9201 driver
// This chip has three control pins:
// DIR - sets direction of the motor
// PWM - pwm control (enable high, coast low)
// DIS - disables motor (enable low)
// PWM pin
engineConfiguration->etbIo[0].controlPin = controlPin;
// DIR pin
engineConfiguration->etbIo[0].directionPin1 = direction;
// Disable pin
engineConfiguration->etbIo[0].disablePin = disable;
// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}

View File

@ -30,6 +30,7 @@ void setHellenCan();
void setHellen64Can();
void setHellenVbatt();
void setupTLE9201(Gpio controlPin, Gpio direction, Gpio disable, int dcIndex = 0);
int detectHellenBoardId();
void detectHellenBoardType();