STM32 CAN3: remove test of CAN_2 and CAN_3

CAN_2 and CAN_3 are enum and not #define and this causes compilation error with GCC_ARM

Instead put back the test of CAN_NUM (which are defined in can_device.h).
pull/5667/head
bcostm 2017-12-07 16:44:13 +01:00 committed by Adam Heinrich
parent d33c0a6fa5
commit bfc4d68ae0
3 changed files with 10 additions and 11 deletions
targets/TARGET_STM
TARGET_STM32F4
TARGET_STM32F7

View File

@ -25,7 +25,7 @@ extern "C" {
#ifdef DEVICE_CAN
#if defined(CAN3_BASE) && defined(CAN_3)
#if defined(CAN3_BASE)
#define CAN_NUM 3 // Number of CAN peripherals present in the STM32 serie

View File

@ -25,7 +25,7 @@ extern "C" {
#ifdef DEVICE_CAN
#if defined(CAN3_BASE) && defined(CAN_3)
#if defined(CAN3_BASE)
#define CAN_NUM 3 // Number of CAN peripherals present in the STM32 serie

View File

@ -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) && defined(CAN_2)
#if defined(CAN2_BASE) && (CAN_NUM > 1)
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) && defined(CAN_3)
#if defined(CAN3_BASE) && (CAN_NUM > 2)
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) && defined(CAN_2)
#if defined(CAN2_BASE) && (CAN_NUM > 1)
if (can == CAN_2) {
__HAL_RCC_CAN2_FORCE_RESET();
__HAL_RCC_CAN2_RELEASE_RESET();
__HAL_RCC_CAN2_CLK_DISABLE();
}
#endif
#if defined(CAN3_BASE) && defined(CAN_3)
#if defined(CAN3_BASE) && (CAN_NUM > 2)
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) && defined(CAN_2)
#if defined(CAN2_BASE) && (CAN_NUM > 1)
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) && defined(CAN_3)
#if defined(CAN3_BASE) && (CAN_NUM > 2)
void CAN3_RX0_IRQHandler(void)
{
can_irq(CAN_3, 2);
@ -630,7 +630,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
return;
}
}
#if defined(CAN2_BASE) && defined(CAN_2)
#if defined(CAN2_BASE) && (CAN_NUM > 1)
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) && defined(CAN_3)
#if defined(CAN3_BASE) && (CAN_NUM > 2)
else if ((CANName) can == CAN_3) {
switch (type) {
case IRQ_RX:
@ -711,4 +711,3 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
}
#endif // DEVICE_CAN