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

cpu/samd5x: handle CAN errors #20667

Merged
merged 3 commits into from
May 23, 2024

Conversation

firas-hamdi
Copy link
Contributor

Contribution description

This PR adds the handling of the CAN errors related interrupts.
The CAN errors are coded in this way:
image

Testing procedure

You can generate a CAN error by trying to send a CAN frame from the CAN controller (Board used is same54-xpro) without terminating the bus (i.e not connecting the CANH and CANL pins of the same54-xpro). An ACK error will be generated then and handled.

@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: tests Area: tests and testing framework Area: cpu Area: CPU/MCU ports labels May 14, 2024
@firas-hamdi firas-hamdi changed the title Feat/samd5x can handle errors cpu/samd5x: handle CAN errors May 14, 2024
@benpicco benpicco requested a review from kfessel May 14, 2024 08:26
@kfessel
Copy link
Contributor

kfessel commented May 14, 2024

code looks good to me,
could you provide some test results for evaluation

@kfessel kfessel added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 14, 2024
@firas-hamdi
Copy link
Contributor Author

code looks good to me, could you provide some test results for evaluation

Screenshot from 2024-05-14 13-47-41
This output is generated when trying to send a frame from the CAN controller without connecting another node / terminating the bus. I kept trying sending multiple times a frame in order to keep the transmission error counter incrementing until it reaches 96 (limit to get the warning status, section 39.8.14 PSR register bit 6), then it turns into the error passive state as a transmitter

@firas-hamdi
Copy link
Contributor Author

Maybe it would be useful to include the Tx/Rx errors counter into the debug output when an error is triggered

@kfessel
Copy link
Contributor

kfessel commented May 14, 2024

Maybe it would be useful to include the Tx/Rx errors counter into the debug output when an error is triggered

if there is a common interface (across all of our can drivers) 👍 else please not

@firas-hamdi
Copy link
Contributor Author

if there is a common interface (across all of our can drivers) 👍 else please not

I mean adding to the _isr interface of the SAMD5x CAN, not in the application level

@kfessel
Copy link
Contributor

kfessel commented May 14, 2024

if there is a common interface (across all of our can drivers) 👍 else please not

I mean adding to the _isr interface of the SAMD5x CAN, not in the application level

if you think that will help and shorten debug sessions 👍

you are thinking of a

DEBUG_PRINTF(" can controller 1 counted: %d erorrs", dev->ERR_COUNT);

in the isr ?
(paraphrasing - i didn't look up the register name)

@riot-ci
Copy link

riot-ci commented May 14, 2024

Murdock results

✔️ PASSED

31003bf tests/drivers/candev: add debug output concerning errors

Success Failures Total Runtime
10104 0 10105 13m:53s

Artifacts

@firas-hamdi
Copy link
Contributor Author

you are thinking of a

DEBUG_PRINTF(" can controller 1 counted: %d erorrs", dev->ERR_COUNT);

in the isr ? (paraphrasing - i didn't look up the register name)

Yes that's what I'm proposing, just showcasing the errors counter directly from the CAN register

@kfessel
Copy link
Contributor

kfessel commented May 15, 2024

Yes that's what I'm proposing, just showcasing the errors counter directly from the CAN register

waiting for this and will approve the PR then

@firas-hamdi firas-hamdi force-pushed the feat/samd5x_can_handle_errors branch from 08a8881 to 1a76669 Compare May 16, 2024 08:37
@firas-hamdi firas-hamdi force-pushed the feat/samd5x_can_handle_errors branch from 1a76669 to 31003bf Compare May 16, 2024 13:01
@benpicco
Copy link
Contributor

@kfessel have your change requests been addressed?

@benpicco benpicco added this pull request to the merge queue May 23, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 23, 2024
@dylad dylad added this pull request to the merge queue May 23, 2024
Merged via the queue into RIOT-OS:master with commit 47b74fc May 23, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants