Skip to content

Commit a97cf28

Browse files
committed
Merge pull request #1713 from BartSX/stm32f4_can
[STM32F4 family] Assign CAN filter number properly
2 parents 8ea1244 + 1244d15 commit a97cf28

File tree

1 file changed

+5
-1
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4

1 file changed

+5
-1
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F4/can_api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static can_irq_handler irq_handler;
3131

3232
void can_init(can_t *obj, PinName rd, PinName td)
3333
{
34+
uint32_t filter_number;
3435
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
3536
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
3637
obj->can = (CANName)pinmap_merge(can_rd, can_td);
@@ -71,7 +72,10 @@ void can_init(can_t *obj, PinName rd, PinName td)
7172
if (HAL_CAN_Init(&CanHandle) != HAL_OK) {
7273
error("Cannot initialize CAN");
7374
}
74-
can_filter(obj, 0, 0, CANStandard, 0);
75+
76+
filter_number = (obj->can == CAN_1) ? 0 : 14;
77+
78+
can_filter(obj, 0, 0, CANStandard, filter_number);
7579
}
7680

7781
void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id)

0 commit comments

Comments
 (0)