Skip to content

Commit 6b6512b

Browse files
authored
Merge pull request #13401 from GewoonMaarten/GewoonMaarten-patch-1
Added error checking to can_filter() for Classic CAN
2 parents e127bb2 + e6150ac commit 6b6512b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ int can_mode(can_t *obj, CanMode mode)
999999

10001000
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle)
10011001
{
1002+
int success = 0;
1003+
10021004
// filter for CANAny format cannot be configured for STM32
10031005
if ((format == CANStandard) || (format == CANExtended)) {
10041006
CAN_FilterConfTypeDef sFilterConfig;
@@ -1022,10 +1024,13 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
10221024
sFilterConfig.FilterActivation = ENABLE;
10231025
sFilterConfig.BankNumber = 14 + handle;
10241026

1025-
HAL_CAN_ConfigFilter(&obj->CanHandle, &sFilterConfig);
1027+
if (HAL_CAN_ConfigFilter(&obj->CanHandle, &sFilterConfig) == HAL_OK)
1028+
{
1029+
success = 1;
1030+
}
10261031
}
10271032

1028-
return 1;
1033+
return success;
10291034
}
10301035

10311036
static void can_irq(CANName name, int id)

0 commit comments

Comments
 (0)