From fe16649de3e58db8b79f3fb98595a3f3092997bd Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Tue, 6 May 2014 22:36:34 +0400 Subject: [PATCH] STM32 CAN driver fix --- libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp index 025408c565..70ffce0760 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_can.cpp @@ -732,9 +732,15 @@ fail: #if UAVCAN_STM32_NUTTX // TODO: Unattach and disable all IRQs - modifyreg32(STM32_RCC_APB1ENR, RCC_APB1ENR_CAN1EN | RCC_APB1ENR_CAN2EN, 0); + modifyreg32(STM32_RCC_APB1ENR, RCC_APB1ENR_CAN1EN, 0); +# if UAVCAN_STM32_NUM_IFACES > 1 + modifyreg32(STM32_RCC_APB1ENR, RCC_APB1ENR_CAN2EN, 0); +# endif #else - RCC->APB1ENR &= ~(RCC_APB1ENR_CAN1EN | RCC_APB1ENR_CAN2EN); + RCC->APB1ENR &= ~RCC_APB1ENR_CAN1EN; +# if UAVCAN_STM32_NUM_IFACES > 1 + RCC->APB1ENR &= ~RCC_APB1ENR_CAN2EN; +# endif #endif return res; }