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; }