mirror of https://github.com/rusefi/rusefi-1.git
No pins should be restarted for no reason during config change #3151
This commit is contained in:
parent
81c9726ae0
commit
bd410d0c1b
|
@ -196,33 +196,18 @@ void enableFrankensoCan(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
engineConfiguration->canReadEnabled = false;
|
engineConfiguration->canReadEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: we usually use 'activeConfiguration' for 'stopPin' why this unusual code here?
|
|
||||||
// this is related to #1375
|
|
||||||
static brain_pin_e currentTxPin = GPIO_UNASSIGNED;
|
|
||||||
static brain_pin_e currentRxPin = GPIO_UNASSIGNED;
|
|
||||||
|
|
||||||
void stopCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void stopCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
efiSetPadUnused(currentTxPin);
|
if (isConfigurationChanged(canTxPin)) {
|
||||||
efiSetPadUnused(currentRxPin);
|
efiSetPadUnused(activeConfiguration.canTxPin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isConfigurationChanged(canRxPin)) {
|
||||||
|
efiSetPadUnused(activeConfiguration.canRxPin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// at the moment we support only very limited runtime configuration change, still not supporting online CAN toggle
|
||||||
void startCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void startCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
// Store pins so we can disable later
|
|
||||||
currentTxPin = CONFIG(canTxPin);
|
|
||||||
currentRxPin = CONFIG(canRxPin);
|
|
||||||
|
|
||||||
efiSetPadMode("CAN TX", currentTxPin, PAL_MODE_ALTERNATE(EFI_CAN_TX_AF));
|
|
||||||
efiSetPadMode("CAN RX", currentRxPin, PAL_MODE_ALTERNATE(EFI_CAN_RX_AF));
|
|
||||||
}
|
|
||||||
|
|
||||||
void initCan(void) {
|
|
||||||
addConsoleAction("caninfo", canInfo);
|
|
||||||
|
|
||||||
isCanEnabled =
|
|
||||||
(isBrainPinValid(CONFIG(canTxPin))) && // both pins are set...
|
|
||||||
(isBrainPinValid(CONFIG(canRxPin))) &&
|
|
||||||
(CONFIG(canWriteEnabled) || CONFIG(canReadEnabled)) ; // ...and either read or write is enabled
|
|
||||||
|
|
||||||
// nothing to do if we aren't enabled...
|
// nothing to do if we aren't enabled...
|
||||||
if (!isCanEnabled) {
|
if (!isCanEnabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -239,6 +224,27 @@ void initCan(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isConfigurationChanged(canTxPin)) {
|
||||||
|
efiSetPadMode("CAN TX", CONFIG(canTxPin), PAL_MODE_ALTERNATE(EFI_CAN_TX_AF));
|
||||||
|
}
|
||||||
|
if (isConfigurationChanged(canRxPin)) {
|
||||||
|
efiSetPadMode("CAN RX", CONFIG(canRxPin), PAL_MODE_ALTERNATE(EFI_CAN_RX_AF));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void initCan(void) {
|
||||||
|
addConsoleAction("caninfo", canInfo);
|
||||||
|
|
||||||
|
isCanEnabled =
|
||||||
|
(isBrainPinValid(CONFIG(canTxPin))) && // both pins are set...
|
||||||
|
(isBrainPinValid(CONFIG(canRxPin))) &&
|
||||||
|
(CONFIG(canWriteEnabled) || CONFIG(canReadEnabled)) ; // ...and either read or write is enabled
|
||||||
|
|
||||||
|
// nothing to do if we aren't enabled...
|
||||||
|
if (!isCanEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (CONFIG(canBaudRate)) {
|
switch (CONFIG(canBaudRate)) {
|
||||||
case B100KBPS:
|
case B100KBPS:
|
||||||
canConfig = &canConfig100;
|
canConfig = &canConfig100;
|
||||||
|
@ -256,8 +262,6 @@ void initCan(void) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
startCanPins();
|
|
||||||
|
|
||||||
// Initialize hardware
|
// Initialize hardware
|
||||||
#if STM32_CAN_USE_CAN2
|
#if STM32_CAN_USE_CAN2
|
||||||
// CAN1 is required for CAN2
|
// CAN1 is required for CAN2
|
||||||
|
|
|
@ -375,10 +375,6 @@ void applyNewHardwareSettings(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
enginePins.startPins();
|
enginePins.startPins();
|
||||||
|
|
||||||
#if EFI_CAN_SUPPORT
|
|
||||||
startCanPins();
|
|
||||||
#endif /* EFI_CAN_SUPPORT */
|
|
||||||
|
|
||||||
#if EFI_AUX_SERIAL
|
#if EFI_AUX_SERIAL
|
||||||
startAuxSerialPins();
|
startAuxSerialPins();
|
||||||
#endif /* EFI_AUX_SERIAL */
|
#endif /* EFI_AUX_SERIAL */
|
||||||
|
@ -508,6 +504,10 @@ void startHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
startTriggerDebugPins(PASS_ENGINE_PARAMETER_SIGNATURE);
|
startTriggerDebugPins(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
startPedalPins(PASS_ENGINE_PARAMETER_SIGNATURE);
|
startPedalPins(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
|
#if EFI_CAN_SUPPORT
|
||||||
|
startCanPins();
|
||||||
|
#endif /* EFI_CAN_SUPPORT */
|
||||||
}
|
}
|
||||||
|
|
||||||
void initHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
void initHardware(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
Loading…
Reference in New Issue