Skip to content

Commit f28181c

Browse files
committed
M451 CAN API support mask feature
1 parent a33dc4e commit f28181c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

targets/TARGET_NUVOTON/TARGET_M451/can_api.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,17 @@ int can_mode(can_t *obj, CanMode mode)
285285

286286
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle)
287287
{
288-
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle , (uint32_t)format, id);
288+
uint32_t numask = mask;
289+
if( numask == 0x0000 )
290+
{
291+
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id);
292+
}
293+
if( format == CANStandard )
294+
{
295+
numask = (mask << 18);
296+
}
297+
numask = (numask | CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk);
298+
return CAN_SetRxMsgAndMsk((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id, numask);
289299
}
290300

291301

0 commit comments

Comments
 (0)