@@ -329,10 +329,12 @@ int can_frequency(can_t *obj, int f)
329
329
*/
330
330
int can_filter (can_t * obj , uint32_t id , uint32_t mask , CANFormat format , int32_t handle )
331
331
{
332
- UNUSED (handle ); // Not supported yet (seems to be a used in read function?)
333
-
334
332
FDCAN_FilterTypeDef sFilterConfig = {0 };
335
333
334
+ if (handle != 0 ) { // message filter handle is not supported for STM controllers
335
+ return 0 ;
336
+ }
337
+
336
338
if (format == CANStandard ) {
337
339
sFilterConfig .IdType = FDCAN_STANDARD_ID ;
338
340
sFilterConfig .FilterIndex = 0 ;
@@ -391,7 +393,7 @@ int can_write(can_t *obj, CAN_Message msg, int cc)
391
393
392
394
int can_read (can_t * obj , CAN_Message * msg , int handle )
393
395
{
394
- UNUSED (handle ); // Not supported yet (seems to be a handle to a filter configuration?)
396
+ UNUSED (handle ); // Not supported
395
397
396
398
if (HAL_FDCAN_GetRxFifoFillLevel (& obj -> CanHandle , FDCAN_RX_FIFO0 ) == 0 ) {
397
399
return 0 ; // No message arrived
@@ -1100,6 +1102,10 @@ int can_mode(can_t *obj, CanMode mode)
1100
1102
int can_filter (can_t * obj , uint32_t id , uint32_t mask , CANFormat format , int32_t handle )
1101
1103
{
1102
1104
int success = 0 ;
1105
+
1106
+ if (handle != 0 ) { // message filter handle not supported yet for STM controllers
1107
+ return 0 ;
1108
+ }
1103
1109
1104
1110
// filter for CANAny format cannot be configured for STM32
1105
1111
if ((format == CANStandard ) || (format == CANExtended )) {
@@ -1128,6 +1134,8 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
1128
1134
{
1129
1135
success = 1 ;
1130
1136
}
1137
+ } else if (format == CANAny ) {
1138
+ success = 0 ; // filter for CANAny is not supported by STM32, return a failure
1131
1139
}
1132
1140
1133
1141
return success ;
0 commit comments