auto-sync
This commit is contained in:
parent
b4e6b56972
commit
e747b729d2
|
@ -26,9 +26,9 @@ EXTERN_ENGINE
|
|||
static Logging *logger;
|
||||
|
||||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||
extern engine_pins_s enginePins;
|
||||
|
||||
static SimplePwm alternatorControl;
|
||||
static OutputPin alternatorPin;
|
||||
static pid_s *altPidS = &persistentState.persistentConfiguration.engineConfiguration.alternatorControl;
|
||||
static Pid altPid(altPidS, 1, 90);
|
||||
|
||||
|
@ -71,7 +71,7 @@ static msg_t AltCtrlThread(int param) {
|
|||
if (boardConfiguration->onOffAlternatorLogic) {
|
||||
float h = 0.1;
|
||||
bool newState = (vBatt < targetVoltage - h) || (currentPlainOnOffState && vBatt < targetVoltage);
|
||||
alternatorPin.setValue(newState);
|
||||
enginePins.alternatorPin.setValue(newState);
|
||||
currentPlainOnOffState = newState;
|
||||
if (engineConfiguration->debugMode == ALTERNATOR) {
|
||||
tsOutputChannels.debugIntField1 = newState;
|
||||
|
@ -151,12 +151,12 @@ void initAlternatorCtrl(Logging *sharedLogger) {
|
|||
return;
|
||||
|
||||
if (boardConfiguration->onOffAlternatorLogic) {
|
||||
outputPinRegisterExt2("on/off alternator", &alternatorPin, boardConfiguration->alternatorControlPin,
|
||||
outputPinRegisterExt2("on/off alternator", &enginePins.alternatorPin, boardConfiguration->alternatorControlPin,
|
||||
&DEFAULT_OUTPUT);
|
||||
|
||||
} else {
|
||||
startSimplePwmExt(&alternatorControl, "Alternator control", boardConfiguration->alternatorControlPin,
|
||||
&alternatorPin,
|
||||
&enginePins.alternatorPin,
|
||||
engineConfiguration->alternatorPwmFrequency, 0.1, applyAlternatorPinState);
|
||||
}
|
||||
chThdCreateStatic(alternatorControlThreadStack, sizeof(alternatorControlThreadStack), LOWPRIO,
|
||||
|
|
|
@ -40,11 +40,11 @@ static THD_WORKING_AREA(ivThreadStack, UTILITY_THREAD_STACK_SIZE);
|
|||
|
||||
static Logging *logger;
|
||||
extern TunerStudioOutputChannels tsOutputChannels;
|
||||
extern engine_pins_s enginePins;
|
||||
EXTERN_ENGINE
|
||||
;
|
||||
|
||||
// todo: extract interface for idle valve hardware, with solenoid and stepper implementations?
|
||||
static OutputPin idleSolenoidPin;
|
||||
static SimplePwm idleSolenoid;
|
||||
|
||||
static StepperMotor iacMotor;
|
||||
|
@ -290,7 +290,7 @@ static void initIdleHardware() {
|
|||
/**
|
||||
* Start PWM for idleValvePin
|
||||
*/
|
||||
startSimplePwmExt(&idleSolenoid, "Idle Valve", boardConfiguration->idle.solenoidPin, &idleSolenoidPin,
|
||||
startSimplePwmExt(&idleSolenoid, "Idle Valve", boardConfiguration->idle.solenoidPin, &enginePins.idleSolenoidPin,
|
||||
boardConfiguration->idle.solenoidFrequency, boardConfiguration->manIdlePosition / 100,
|
||||
applyIdleSolenoidPinState);
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ static msg_t benchThread(int param) {
|
|||
|
||||
extern engine_configuration_s activeConfiguration;
|
||||
|
||||
static void unregister(brain_pin_e currentPin, OutputPin *output) {
|
||||
void unregister(brain_pin_e currentPin, OutputPin *output) {
|
||||
if (currentPin == GPIO_UNASSIGNED)
|
||||
return;
|
||||
scheduleMsg(logger, "unregistering %s", hwPortname(currentPin));
|
||||
|
@ -232,7 +232,7 @@ static void unregister(brain_pin_e currentPin, OutputPin *output) {
|
|||
|
||||
void stopIgnitionPins(void) {
|
||||
for (int i = 0; i < IGNITION_PIN_COUNT; i++) {
|
||||
NamedOutputPin *output = &enginePins.injectors[i];
|
||||
NamedOutputPin *output = &enginePins.coils[i];
|
||||
brain_pin_e currentPin = activeConfiguration.bc.ignitionPins[i];
|
||||
if (engineConfiguration->bc.ignitionPins[i] != currentPin) {
|
||||
unregister(currentPin, output);
|
||||
|
|
|
@ -24,6 +24,7 @@ void assertCylinderId(int cylinderId, const char *msg);
|
|||
|
||||
void stopInjectionPins(void);
|
||||
void startInjectionPins(void);
|
||||
void unregister(brain_pin_e currentPin, OutputPin *output);
|
||||
|
||||
void stopIgnitionPins(void);
|
||||
void startIgnitionPins(void);
|
||||
|
|
|
@ -65,6 +65,9 @@ public:
|
|||
OutputPin o2heater;
|
||||
// OutputPin alternatorField;
|
||||
OutputPin errorLedPin;
|
||||
OutputPin idleSolenoidPin;
|
||||
OutputPin alternatorPin;
|
||||
|
||||
|
||||
InjectorOutputPin injectors[INJECTION_PIN_COUNT];
|
||||
NamedOutputPin coils[IGNITION_PIN_COUNT];
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
EXTERN_ENGINE
|
||||
;
|
||||
extern bool hasFirmwareErrorFlag;
|
||||
extern engine_configuration_s activeConfiguration;
|
||||
extern engine_pins_s enginePins;
|
||||
|
||||
static Mutex spiMtx;
|
||||
|
||||
|
@ -201,13 +203,79 @@ void turnOnHardware(Logging *sharedLogger) {
|
|||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
}
|
||||
|
||||
static void unregisterPin(brain_pin_e currentPin, brain_pin_e prevPin) {
|
||||
if (currentPin != prevPin) {
|
||||
unmarkPin(prevPin);
|
||||
}
|
||||
}
|
||||
|
||||
void stopSpi(spi_device_e device) {
|
||||
if (!isSpiInitialized[device])
|
||||
return; // not turned on
|
||||
isSpiInitialized[device] = false;
|
||||
unmarkPin(getSckPin(device));
|
||||
unmarkPin(getMisoPin(device));
|
||||
unmarkPin(getMosiPin(device));
|
||||
}
|
||||
|
||||
void applyNewHardwareSettings(void) {
|
||||
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
||||
applyNewTriggerInputPins();
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
|
||||
// all 'stop' methods need to go before we begin starting pins
|
||||
|
||||
stopInjectionPins();
|
||||
stopIgnitionPins();
|
||||
|
||||
if (engineConfiguration->bc.is_enabled_spi_2 != activeConfiguration.bc.is_enabled_spi_2)
|
||||
stopSpi(SPI_DEVICE_2);
|
||||
|
||||
if (engineConfiguration->bc.is_enabled_spi_2 != activeConfiguration.bc.is_enabled_spi_2)
|
||||
stopSpi(SPI_DEVICE_3);
|
||||
|
||||
|
||||
{
|
||||
brain_pin_e currentPin = activeConfiguration.bc.fuelPumpPin;
|
||||
if (engineConfiguration->bc.fuelPumpPin != currentPin) {
|
||||
unregister(currentPin, &enginePins.fuelPumpRelay);
|
||||
}
|
||||
}
|
||||
unregisterPin(engineConfiguration->bc.HD44780_rs, activeConfiguration.bc.HD44780_rs);
|
||||
unregisterPin(engineConfiguration->bc.HD44780_e, activeConfiguration.bc.HD44780_e);
|
||||
unregisterPin(engineConfiguration->bc.HD44780_db4, activeConfiguration.bc.HD44780_db4);
|
||||
unregisterPin(engineConfiguration->bc.HD44780_db5, activeConfiguration.bc.HD44780_db5);
|
||||
unregisterPin(engineConfiguration->bc.HD44780_db6, activeConfiguration.bc.HD44780_db6);
|
||||
unregisterPin(engineConfiguration->bc.HD44780_db7, activeConfiguration.bc.HD44780_db7);
|
||||
|
||||
unregisterPin(engineConfiguration->bc.clutchUpPin, activeConfiguration.bc.clutchUpPin);
|
||||
|
||||
|
||||
{
|
||||
brain_pin_e currentPin = activeConfiguration.bc.fanPin;
|
||||
if (engineConfiguration->bc.fanPin != currentPin) {
|
||||
unregister(currentPin, &enginePins.fanRelay);
|
||||
}
|
||||
}
|
||||
{
|
||||
brain_pin_e currentPin = activeConfiguration.bc.idle.solenoidPin;
|
||||
if (engineConfiguration->bc.idle.solenoidPin != currentPin) {
|
||||
unregister(currentPin, &enginePins.idleSolenoidPin);
|
||||
}
|
||||
}
|
||||
{
|
||||
brain_pin_e currentPin = activeConfiguration.bc.alternatorControlPin;
|
||||
if (engineConfiguration->bc.alternatorControlPin != currentPin) {
|
||||
unregister(currentPin, &enginePins.alternatorPin);
|
||||
}
|
||||
}
|
||||
{
|
||||
brain_pin_e currentPin = activeConfiguration.bc.mainRelayPin;
|
||||
if (engineConfiguration->bc.mainRelayPin != currentPin) {
|
||||
unregister(currentPin, &enginePins.mainRelay);
|
||||
}
|
||||
}
|
||||
|
||||
startInjectionPins();
|
||||
startIgnitionPins();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ const char *portname(ioportid_t GPIOx) {
|
|||
}
|
||||
|
||||
static int getPortIndex(ioportid_t port) {
|
||||
efiAssert(port != NULL, "null port", -1);
|
||||
if (port == GPIOA)
|
||||
return 0;
|
||||
if (port == GPIOB)
|
||||
|
@ -79,7 +80,7 @@ static int getPortIndex(ioportid_t port) {
|
|||
if (port == GPIOH)
|
||||
return 6;
|
||||
#endif /* defined(STM32F4XX) */
|
||||
firmwareError("portindex");
|
||||
firmwareError("unknown port");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ void firmwareError(const char *errorMsg, ...) {
|
|||
}
|
||||
}
|
||||
|
||||
static char UNUSED_RAM_SIZE[1400];
|
||||
static char UNUSED_RAM_SIZE[1300];
|
||||
|
||||
static char UNUSED_CCM_SIZE[8500] CCM_OPTIONAL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue