Acrosser AR-B6051 User Manual

Page 51

Advertising
background image

For example:

struct CanFilter varFilter;

i32

result;

result = getCanFilter(&varFilter);

if(result != 0)

printf(“Fail to get the filter!\n”);

Return Value: If this function gets the filter successfully, it returns 0,

any other returned value

stands for error.

9. Syntax:

i32 setCanFilter(struct CanFilter *varFilter)

Description: This function sets the bit pattern to the filter. By indicating the ‘filterType’ field in the

‘varFilter’ variable, the bit pattern in the ‘filter’ field will be taken as an ‘Standard ID’ filter or

‘Extended ID’ filter.

struct CanFilter {

u8

filterId; // There are six filters so the filterId = 0 ~ 5

u8

filterType; // filterType = STD_ID or filterType = EXT_ID

u32

filter;

}

If a filter is configured as a ‘Standard ID’ filter, only bit18 ~ bit28 in the mask take effect when

filtering the CAN packet.

Parameters: This function takes a pointer to a variable of type ‘CanFilter’ as the parameter. Users

set up the ‘filterId’. There are six filters so the ‘filterId’ could be 0 ~ 5. Filter0 and filter1 are

associated with mask0. Filter2 ~ filter5 are associated with mask1.

By setting up ‘filterType’, users indicate the type of the filter. Filter type could be ‘STD_ID’ or

‘EXT_ID’.

Depending on the filter type, the ‘filter’ field in the CanFilter variable could be 0x0 ~ 0x7FF (11 bits)

when filter type is ‘STD_ID’. If the filter type is ‘EXT_ID’, the ‘filter’ field in the CanFilter variable

could be 0x0 ~ 0x1FFFFFFF (29 bits).

51

Advertising