17 (22)
13.1.9
simply_set_filter
Sets the 11 or 29 bit message filter of the CAN controller. To set the 29 bit message filter, the
MSB in parameter value must be set.
bool simply_set_filter(uint32_t mask, uint32_t value);
Parameter
Parameter
Dir.
Description
mask
[in]
11 or 29 bit CAN message identifier mask
value
[in]
11 or 29 bit CAN message identifier value, set MSB to set the 29 bit message filter
Return Value
Return value
Description
true
Function succeeded
false
Error occurred, call
simply_get_last_error
for more information.
Remark
With the mask/value filter (available for 11 bit and 29 bit identifiers) possible valid identifiers
based on bit masks can be defined.
Binary representation of mask:
•
binary positions with value 1 are relevant for the filter
•
binary positions with value 0 are not relevant for the filter
Binary representation of value:
•
Defines the values for the positions that are marked as relevant (1) in mask.
•
Values in positions that are marked as not relevant (0) in mask are ignored.
The following formula expresses the condition under which an identifier passes the filter:
•
if (value & mask) == (identifier & mask) then identifier is valid
Example 11 Bit Identifier
hex
bin
Value
0x700
0111:0000:0000
Mask
0x700
0111:0000:0000
Result
0x700
0111:0000:0000
Any identifier between 0x700 and 0x7FF passes the filter, as only the first 3 bits of the mask are
marked as relevant.
Example 29 Bit Identifier
hex
bin
Value
0x90003344
1001:0000:0000:0000:0011:0011:0100:0100
Mask
0x1F00FFFF
0001:1111:0000:0000:1111:1111:1111:1111
Result
0x10003344
0001:0000:0000:0000:0011:0011:0100:0100
256 identifier between 0x10003344 and 0x10FF3344 pass the filter, where the last two bytes
are 0x3344.
To allow 29 bit messages to pass the filter, the MSB in parameter value must be set.
Further Examples
Value
Mask
Valid message identifiers which pass the filter
0x100
0x7FF
0x100
0x100
0x700
0x100–0x1FF
0x000
0x000
0x000–0x7FF
simplyCAN User Manual
4.01.0001.22001 1.0 en-US