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

adds twai_get_bitrate_timings function (IDFGH-6027) #7713

Closed

Conversation

kdschlosser
Copy link

This function will calculate the brp, tseg1, tseg2 and sjw values that are needed to create the twai interface.

see notes for further information

This is my first PR with esp-idf and as such I am sure there will be things that are not correct with it. I check out the contributing information but all of the links in it are not functional so I couldn't review past the single document. So that is going to need to be fixed.

All feedback is welcome good or bad and if I need to change something please give an example and explain what the benefit of the change is. I know enough C to just about get my toes a little wet. I have a decent understanding of C so not a complete noob. LOL.

I am a firm believer of the easier it is to use the more people will use it. It took me 6 months to fully wrap my brain around the whole CAN packet specification and of that information can be transparent to the user then it should be. The user needs to be able to provide the things that they will know like the target bitrate, length of the BUS and the processing delay of the transceiver which is gotten from the documentation for the transceiver. If an exact match cannot be found for their target bitrate then then next closest bitrate the interface is capable of should be returned. That is what this code does. It makes using a CAN interface as easy as using a serial interface.

Thank you for taking the time to review this

This function will calculate the brp, tseg1, tseg2 and sjw values that are needed to create the twai interface.

see notes for further information
@CLAassistant
Copy link

CLAassistant commented Oct 17, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 17, 2021
@github-actions github-actions bot changed the title adds twai_get_bitrate_timings function adds twai_get_bitrate_timings function (IDFGH-6027) Oct 17, 2021
@Alvin1Zhang
Copy link
Collaborator

Thanks for your contribution.

Removes double preprocessor definitions
Adds the TWAI_BRP_IS_VALID macros
Fixes setting the nominal sample point into the nominal bitrate variable
@kdschlosser
Copy link
Author

I have found a much better way to do the calculation it should take about 0.57 microseconds to do the work. It would return only a single match. I need to know what the APB oscillator tolerance is in order to have it work.

If someone knows what that tolerance is it would be really helpful. I would imagine it should be 0.1% or smaller

@kdschlosser kdschlosser deleted the twai_get_bitrate_timings branch July 11, 2023 03:15
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants