-
Notifications
You must be signed in to change notification settings - Fork 3k
Add CAN api filter support and LPC11CXX CAN implementation #91
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,768 changes: 1,768 additions & 0 deletions
1,768
libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11XX_11CXX/bitfields.h
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ | |
|
||
#include "LPC11xx.h" | ||
#include "cmsis_nvic.h" | ||
#include "bitfields.h" | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain a bit the usage of "handle" in this context (both in read and filter functions) ? Do you think that this "handle" mechanism is generic enough to implement CAN message filtering on all platforms with a CAN transceiver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the LPC11CXX the handle is the message object index (1-32). 32 is used for transmitting message and 1 is used by default as the accept-all mailbox, so by overriding it you disable acceptance of any message.
If there are no more mailboxes available the function will return 0.
Now that I think of it it might be better to make 31 the defailt object for accept-all, as messages are accepted and prioritized by the message boxes in order. This way you can make sure you don't loose the message you're interested in while still receiving any other message as well assuming you can read fast enough.
I think it should be relatively easy to implement the same scheme using the Acceptance Filter Mode on the LPC17XX. Everytime you call can->filter you add it to the identifier table, where handle returns the index in that table.
Here's a typical usage scenario:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed comment. I'm not at all that familiar with CAN, so I'd like to think a bit more if this method is really universal enough. The problem is not really in the HAL, but can_api.h (below) also uses an "int handle" and that has to be good enough for all platforms/CAN transceivers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "can_api.h also uses an int handle"?
Here's someone who implemented filtering for the LPC1768:
http://mbed.org/users/ym1784/code/CAN_MONITOR/file/fe1f886dff76/main.cpp
Here cnt1 would be the handle. If I understand the datasheet correctly the can peripheral can also automatically move the received message from the buffer to RAM. Calling can->read can then return the requested message from RAM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that the type of the handle in api/CAN.h (read and filter) is an int and I'm not sure if this is generic enough. Thanks for the link, I'll take a closer look at the LPC1768 implementation.