Acrosser AIV-HM76V1FL User Manual

Page 53

Advertising
background image

AIV-HM76V1FL Series User Manual

53

www.acrosser.com

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).

For example:

struct CanFilter varFilter;

i32 result;

varFilter.filterId = 3;

varFilter.filterType = STD_ID;

varFilter.filter = 0x555;

result = setCanFilter(&varFilter);

if( result != 0)

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

Return Value:

If this function sets the filter successfully, it returns 0, any

other returned value stands for error.

Advertising