Skip to content

Commit 2d8d8ae

Browse files
committed
STM32: fix error with CAN_3 not defined
1 parent 2e2b408 commit 2d8d8ae

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

targets/TARGET_STM/TARGET_STM32F4/can_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525

2626
#ifdef DEVICE_CAN
2727

28-
#if defined(CAN3_BASE)
28+
#if defined(CAN3_BASE) && defined(CAN_3)
2929

3030
#define CAN_NUM 3 // Number of CAN peripherals present in the STM32 serie
3131

targets/TARGET_STM/TARGET_STM32F7/can_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525

2626
#ifdef DEVICE_CAN
2727

28-
#if defined(CAN3_BASE)
28+
#if defined(CAN3_BASE) && defined(CAN_3)
2929

3030
#define CAN_NUM 3 // Number of CAN peripherals present in the STM32 serie
3131

targets/TARGET_STM/can_api.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ void can_init_freq (can_t *obj, PinName rd, PinName td, int hz)
5757
__HAL_RCC_CAN1_CLK_ENABLE();
5858
obj->index = 0;
5959
}
60-
#if defined(CAN2_BASE) && (CAN_NUM > 1)
60+
#if defined(CAN2_BASE) && defined(CAN_2)
6161
else if (can == CAN_2) {
6262
__HAL_RCC_CAN1_CLK_ENABLE(); // needed to set filters
6363
__HAL_RCC_CAN2_CLK_ENABLE();
6464
obj->index = 1;
6565
}
6666
#endif
67-
#if defined(CAN3_BASE) && (CAN_NUM > 2)
67+
#if defined(CAN3_BASE) && defined(CAN_3)
6868
else if (can == CAN_3) {
6969
__HAL_RCC_CAN3_CLK_ENABLE();
7070
obj->index = 2;
@@ -132,14 +132,14 @@ void can_free(can_t *obj)
132132
__HAL_RCC_CAN1_RELEASE_RESET();
133133
__HAL_RCC_CAN1_CLK_DISABLE();
134134
}
135-
#if defined(CAN2_BASE) && (CAN_NUM > 1)
135+
#if defined(CAN2_BASE) && defined(CAN_2)
136136
if (can == CAN_2) {
137137
__HAL_RCC_CAN2_FORCE_RESET();
138138
__HAL_RCC_CAN2_RELEASE_RESET();
139139
__HAL_RCC_CAN2_CLK_DISABLE();
140140
}
141141
#endif
142-
#if defined(CAN3_BASE) && (CAN_NUM > 2)
142+
#if defined(CAN3_BASE) && defined(CAN_3)
143143
if (can == CAN_3) {
144144
__HAL_RCC_CAN3_FORCE_RESET();
145145
__HAL_RCC_CAN3_RELEASE_RESET();
@@ -562,7 +562,7 @@ void CAN1_SCE_IRQHandler(void)
562562
{
563563
can_irq(CAN_1, 0);
564564
}
565-
#if defined(CAN2_BASE) && (CAN_NUM > 1)
565+
#if defined(CAN2_BASE) && defined(CAN_2)
566566
void CAN2_RX0_IRQHandler(void)
567567
{
568568
can_irq(CAN_2, 1);
@@ -576,7 +576,7 @@ void CAN2_SCE_IRQHandler(void)
576576
can_irq(CAN_2, 1);
577577
}
578578
#endif
579-
#if defined(CAN3_BASE) && (CAN_NUM > 2)
579+
#if defined(CAN3_BASE) && defined(CAN_3)
580580
void CAN3_RX0_IRQHandler(void)
581581
{
582582
can_irq(CAN_3, 1);
@@ -630,7 +630,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
630630
return;
631631
}
632632
}
633-
#if defined(CAN2_BASE) && (CAN_NUM > 1)
633+
#if defined(CAN2_BASE) && defined(CAN_2)
634634
else if ((CANName) can == CAN_2) {
635635
switch (type) {
636636
case IRQ_RX:
@@ -663,7 +663,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
663663
}
664664
}
665665
#endif
666-
#if defined(CAN3_BASE) && (CAN_NUM > 2)
666+
#if defined(CAN3_BASE) && defined(CAN_3)
667667
else if ((CANName) can == CAN_3) {
668668
switch (type) {
669669
case IRQ_RX:

0 commit comments

Comments
 (0)