From 21fcb756aa31415f1717a2f76399b0f0dba4d60b Mon Sep 17 00:00:00 2001 From: bcostm Date: Wed, 15 Nov 2017 10:36:03 +0100 Subject: [PATCH] STM32: fix error with CAN_3 not defined --- targets/TARGET_STM/TARGET_STM32F4/can_device.h | 2 +- targets/TARGET_STM/TARGET_STM32F7/can_device.h | 2 +- targets/TARGET_STM/can_api.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F4/can_device.h b/targets/TARGET_STM/TARGET_STM32F4/can_device.h index 81485b0ef7..16377c24c9 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/can_device.h +++ b/targets/TARGET_STM/TARGET_STM32F4/can_device.h @@ -25,7 +25,7 @@ extern "C" { #ifdef DEVICE_CAN -#if defined(CAN3_BASE) +#if defined(CAN3_BASE) && defined(CAN_3) #define CAN_NUM 3 // Number of CAN peripherals present in the STM32 serie diff --git a/targets/TARGET_STM/TARGET_STM32F7/can_device.h b/targets/TARGET_STM/TARGET_STM32F7/can_device.h index 729b36177a..0581da5584 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/can_device.h +++ b/targets/TARGET_STM/TARGET_STM32F7/can_device.h @@ -25,7 +25,7 @@ extern "C" { #ifdef DEVICE_CAN -#if defined(CAN3_BASE) +#if defined(CAN3_BASE) && defined(CAN_3) #define CAN_NUM 3 // Number of CAN peripherals present in the STM32 serie diff --git a/targets/TARGET_STM/can_api.c b/targets/TARGET_STM/can_api.c index ea4f0d295d..bd2d734247 100644 --- a/targets/TARGET_STM/can_api.c +++ b/targets/TARGET_STM/can_api.c @@ -57,14 +57,14 @@ void can_init_freq (can_t *obj, PinName rd, PinName td, int hz) __HAL_RCC_CAN1_CLK_ENABLE(); obj->index = 0; } -#if defined(CAN2_BASE) && (CAN_NUM > 1) +#if defined(CAN2_BASE) && defined(CAN_2) else if (can == CAN_2) { __HAL_RCC_CAN1_CLK_ENABLE(); // needed to set filters __HAL_RCC_CAN2_CLK_ENABLE(); obj->index = 1; } #endif -#if defined(CAN3_BASE) && (CAN_NUM > 2) +#if defined(CAN3_BASE) && defined(CAN_3) else if (can == CAN_3) { __HAL_RCC_CAN3_CLK_ENABLE(); obj->index = 2; @@ -132,14 +132,14 @@ void can_free(can_t *obj) __HAL_RCC_CAN1_RELEASE_RESET(); __HAL_RCC_CAN1_CLK_DISABLE(); } -#if defined(CAN2_BASE) && (CAN_NUM > 1) +#if defined(CAN2_BASE) && defined(CAN_2) if (can == CAN_2) { __HAL_RCC_CAN2_FORCE_RESET(); __HAL_RCC_CAN2_RELEASE_RESET(); __HAL_RCC_CAN2_CLK_DISABLE(); } #endif -#if defined(CAN3_BASE) && (CAN_NUM > 2) +#if defined(CAN3_BASE) && defined(CAN_3) if (can == CAN_3) { __HAL_RCC_CAN3_FORCE_RESET(); __HAL_RCC_CAN3_RELEASE_RESET(); @@ -562,7 +562,7 @@ void CAN1_SCE_IRQHandler(void) { can_irq(CAN_1, 0); } -#if defined(CAN2_BASE) && (CAN_NUM > 1) +#if defined(CAN2_BASE) && defined(CAN_2) void CAN2_RX0_IRQHandler(void) { can_irq(CAN_2, 1); @@ -576,7 +576,7 @@ void CAN2_SCE_IRQHandler(void) can_irq(CAN_2, 1); } #endif -#if defined(CAN3_BASE) && (CAN_NUM > 2) +#if defined(CAN3_BASE) && defined(CAN_3) void CAN3_RX0_IRQHandler(void) { can_irq(CAN_3, 1); @@ -630,7 +630,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) return; } } -#if defined(CAN2_BASE) && (CAN_NUM > 1) +#if defined(CAN2_BASE) && defined(CAN_2) else if ((CANName) can == CAN_2) { switch (type) { case IRQ_RX: @@ -663,7 +663,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) } } #endif -#if defined(CAN3_BASE) && (CAN_NUM > 2) +#if defined(CAN3_BASE) && defined(CAN_3) else if ((CANName) can == CAN_3) { switch (type) { case IRQ_RX: