Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatic CAN filter configuration #20

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add limit (NUM_FILTERS * NUM_IDS_PER_FILTER) to the can id finder loop
  • Loading branch information
rureverek committed May 4, 2023
commit 3008cd31ab673903dba90f58a28c2af2ee8e99c3
10 changes: 9 additions & 1 deletion src/rtcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,21 @@ rtcan_status_t rtcan_start(rtcan_handle_t* rtcan_h)
/* Subscriber found! */
can_id_list[number_ids] = node->can_id;
number_ids++;
if(number_ids > (NUM_FILTERS * NUM_IDS_PER_FILTER))
{
break;
}

while(node->chained_node_ptr != NULL)
{
/* Chained node found! */
node = node->chained_node_ptr;
can_id_list[number_ids] = node->can_id;
number_ids++;
if(number_ids > (NUM_FILTERS * NUM_IDS_PER_FILTER))
{
break;
}
}

}
Expand All @@ -237,7 +245,7 @@ rtcan_status_t rtcan_start(rtcan_handle_t* rtcan_h)
filter.FilterMaskIdHigh = can_id_list[NUM_IDS_PER_FILTER * i + 2] << 5U;
filter.FilterMaskIdLow = can_id_list[NUM_IDS_PER_FILTER * i + 3] << 5U;
filter.FilterBank = i;

/* Alternate between FIFO0 and FIFO1 to share the load evenly */
if(i % 2)
{
Expand Down