Skip to content

Commit

Permalink
Merge pull request #15020 from OpenNuvoton/nvt_can_mask
Browse files Browse the repository at this point in the history
Nuvoton: M480/M451 CAN API support mask feature
  • Loading branch information
0xc0170 authored Aug 26, 2021
2 parents f6e165f + f28181c commit 1ac928e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion targets/TARGET_NUVOTON/TARGET_M451/can_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,17 @@ int can_mode(can_t *obj, CanMode mode)

int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle)
{
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle , (uint32_t)format, id);
uint32_t numask = mask;
if( numask == 0x0000 )
{
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id);
}
if( format == CANStandard )
{
numask = (mask << 18);
}
numask = (numask | CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk);
return CAN_SetRxMsgAndMsk((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id, numask);
}


Expand Down
12 changes: 11 additions & 1 deletion targets/TARGET_NUVOTON/TARGET_M480/can_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,17 @@ int can_mode(can_t *obj, CanMode mode)

int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle)
{
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id);
uint32_t numask = mask;
if( numask == 0x0000 )
{
return CAN_SetRxMsg((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id);
}
if( format == CANStandard )
{
numask = (mask << 18);
}
numask = (numask | CAN_IF_MASK2_MDIR_Msk | CAN_IF_MASK2_MXTD_Msk);
return CAN_SetRxMsgAndMsk((CAN_T *)NU_MODBASE(obj->can), handle, (uint32_t)format, id, numask);
}


Expand Down

0 comments on commit 1ac928e

Please sign in to comment.