Skip to content

Commit a33dc4e

Browse files
committed
M480 CAN API support mask feature
1 parent f6e165f commit a33dc4e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

targets/TARGET_NUVOTON/TARGET_M480/can_api.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,17 @@ int can_mode(can_t *obj, CanMode mode)
332332

333333
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle)
334334
{
335-
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id);
335+
uint32_t numask = mask;
336+
if( numask == 0x0000 )
337+
{
338+
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id);
339+
}
340+
if( format == CANStandard )
341+
{
342+
numask = (mask << 18);
343+
}
344+
numask = (numask | CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk);
345+
return CAN_SetRxMsgAndMsk((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id, numask);
336346
}
337347

338348

0 commit comments

Comments
 (0)