-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add Infineon XMC4xxx CAN driver #67057
Add Infineon XMC4xxx CAN driver #67057
Conversation
0473eaa
to
62f8134
Compare
@talih0 Thank you for submitting this. I am currently reviewing. |
I'd like to postpone this until #67128 has been merged, since this driver will need reworking to work with the new RTR rejecting scheme. |
sounds good. |
62f8134
to
8c39571
Compare
In my branch with modified tests: $ west build -p -b xmc47_relax_kit tests/drivers/can/api && west flash SUITE PASS - 100.00% [can_classic]: pass = 32, fail = 0, skip = 3, total = 35 duration = 0.517 seconds
SUITE PASS - 100.00% [can_stats]: pass = 1, fail = 0, skip = 0, total = 1 duration = 0.001 seconds SUITE PASS - 100.00% [can_utilities]: pass = 3, fail = 0, skip = 0, total = 3 duration = 0.003 seconds SUITE SKIP - 0.00% [canfd]: pass = 0, fail = 0, skip = 8, total = 8 duration = 0.000 seconds ------ TESTSUITE SUMMARY END ------ west build -p -b xmc47_relax_kit tests/drivers/can/api -- -DCONFIG_CAN_ACCEPT_RTR=y && west flash; SUITE PASS - 100.00% [can_classic]: pass = 32, fail = 0, skip = 3, total = 35 duration = 0.336 seconds
SUITE PASS - 100.00% [can_stats]: pass = 1, fail = 0, skip = 0, total = 1 duration = 0.001 seconds SUITE PASS - 100.00% [can_utilities]: pass = 3, fail = 0, skip = 0, total = 3 duration = 0.003 seconds SUITE SKIP - 0.00% [canfd]: pass = 0, fail = 0, skip = 8, total = 8 duration = 0.000 seconds |
2fe87f5
to
2454074
Compare
Rebased to take into account recent api changes for struct can_driver_data/config common, and removal of get_max_bitrate(). |
2454074
to
ebac44a
Compare
rebased to take into can_transeive_enable() api change |
ebac44a
to
38793d9
Compare
Rebased to origin/main to fix CI |
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.
It would be nice to see support for CAN statistics in a later PR. A couple of minor suggestions/comments:
|
||
if (dev_data->state != CAN_STATE_STOPPED && new_state == CAN_STATE_BUS_OFF) { | ||
/* try to recover */ | ||
XMC_CAN_NODE_ResetInitBit(dev_cfg->can); |
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.
Couldn't this be used when automatic bus recovery is turned off as well?
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, yes, that's true, I'll work on this tomorrow.
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.
@henrikbrixandersen, my original comment was misleading here, sorry.
It's not possible to stop the bus auto-recovery process on the XMC4xxx.
This call to XMC_CAN_NODE_ResetInitBit() is needed to automatically re-enable the node after the bus-recovery completes.
Initially, I thought that we could move this XMC_CAN_NODE_ResetInitBit() call to the driver can_xmc4xxx_recover() function, but it looks tricky to implement because once the internal auto bus recovery completes, it will trigger the can_xmc4xxx_state_change_handler() to indicate that the bus is no longer in a bus-off state. This will then issue a callback to the user about the state change, perhaps, even before they call the recover function.
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.
No problem, we can leave the implementation as is for now. I plan on redesigning the auto-recovery/manual recovery functionality soon, effectively turning it into a can_mode_t
setting. This will allow for drivers to signal whether they support manual recovery at all, which quite a few CAN IPs do not.
thanks, yes, I'll add the statistics in a separate PR. I also need to add them for the mcp251xfd driver. |
Adds CAN drivers for XMC4xxx SoCs. XMC4xxx has multiple CAN nodes. The nodes share a common clock and a message object pool. The CAN nodes do not have a loopback mode. Instead there is an internal bus which can be used to exchange messages between nodes on the SoC. For this reason tests/samples which rely on the loopback feature have been disabled. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Adds CAN node to xmc47_relax_kit. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
38793d9
to
af83dc2
Compare
XMC4xxx has multiple CAN nodes. The nodes share a common clock and
a message object pool.
The CAN nodes do not have a loopback mode. Instead there is an
internal bus which can be used to exchange messages between
nodes on the SoC. For this reason tests/samples which rely on the
loopback feature have been disabled.
For testing I have also modified the tests/drivers/api and samples/can/counter
to have a separate transmit and receive node, instead of relying on loopback
from one node. I have not included these changes in the PR, but they can be found in this branch:
https://github.com/talih0/zephyr/tree/xmc4xxx_can