From cb668e5234216861a839ccd938963e42d6622019 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Tue, 28 Apr 2020 05:08:41 -0700 Subject: [PATCH] fix master (#1375) * fix * put back how it was * missed a spot --- firmware/hw_layer/drivers/can/can_hw.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/firmware/hw_layer/drivers/can/can_hw.cpp b/firmware/hw_layer/drivers/can/can_hw.cpp index 6145c15e2f..dcaea01624 100644 --- a/firmware/hw_layer/drivers/can/can_hw.cpp +++ b/firmware/hw_layer/drivers/can/can_hw.cpp @@ -145,14 +145,21 @@ void enableFrankensoCan(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->canReadEnabled = false; } +static brain_pin_e currentTxPin = GPIO_UNASSIGNED; +static brain_pin_e currentRxPin = GPIO_UNASSIGNED; + void stopCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - brain_pin_markUnused(activeConfiguration.canTxPin); - brain_pin_markUnused(activeConfiguration.canRxPin); + brain_pin_markUnused(currentTxPin); + brain_pin_markUnused(currentRxPin); } void startCanPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - efiSetPadMode("CAN TX", CONFIG_OVERRIDE(canTxPin), PAL_MODE_ALTERNATE(EFI_CAN_TX_AF)); - efiSetPadMode("CAN RX", CONFIG_OVERRIDE(canRxPin), PAL_MODE_ALTERNATE(EFI_CAN_RX_AF)); + // Store pins so we can disable later + currentTxPin = CONFIG_OVERRIDE(canTxPin); + currentRxPin = CONFIG_OVERRIDE(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) {