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