Hi,
I want to improve my understanding of the CAN message ID filtering with the S32K SDK.
More specifically, I want to understand how to only accept a range of IDs.
Thanks to the table in this answer, I know that to only accept a range of message ID from 0x404 to 0x407, I need to configure the mailbox as follows:
#define ACCEPTED_ID 0x404
#define MAILBOX_MASK 0x7FC
CAN_ConfigRxBuff(, ACCEPTED_ID);
CAN_SetRxFilter(, MAILBOX_MASK);
To be honest, I don't fully understand what is happening inside the CAN peripheral.
For learning purposes, here's my attempt at describing the ID filtering logic with C pseudo-code.
bool is_id_valid(uint16_t id)
{
return (id & MAILBOX_MASK) == (ACCEPTED_ID & MAILBOX_MASK);
}
Would you agree with this masking logic?
Thanks,
Gabriel