Skip to content

[Feature Request] Allow different CAN bit rates #295

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

Closed
fastbike opened this issue Apr 28, 2024 · 1 comment · Fixed by #296
Closed

[Feature Request] Allow different CAN bit rates #295

fastbike opened this issue Apr 28, 2024 · 1 comment · Fixed by #296
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@fastbike
Copy link
Contributor

Currently the CAN module only support bit rates of 125k, 250k, 500k and 1M bits per second.

Other libraries support the setting of bit rates in a more flexible way allowing an integer to be passed in.

I'm currently looking to build a project to work with Velbus which uses a bit rate of 16.7kbps.

There are many other products in the marketplace using a bit rate different to the 4 listed above.
I would looking for something like

bool R7FA4M1_CAN::begin2(int const can_bitrate)
fastbike added a commit to fastbike/ArduinoCore-renesas that referenced this issue Apr 29, 2024
@fastbike
Copy link
Contributor Author

I have created a fix by overloading the R7FA4M1_CAN::begin function to accept either the predefined bit rates or an integer value

  bool begin(CanBitRate const can_bitrate) override; // enum values
  bool begin(uint32_t const can_bitrate); // integer values

This has been tested with the four enum values, and also with 83300, 50000, 40000 and 16666 baud

Baud BRP TSEG1 TSEG2
1M 1 7 2
500,000 2 10 3
250,000 5 10 3
125,000 11 10 3
83,300 15 11 4
50,000 23 13 4
40,000 29 13 4
16,666 71 13 4

aentinger pushed a commit that referenced this issue Apr 29, 2024
Fix for #295 to allow flexible bit rate either one of the 4 predefined rates or a custom rate.
@per1234 per1234 added type: enhancement Proposed improvement conclusion: resolved Issue was resolved topic: code Related to content of the project itself labels Apr 29, 2024
aentinger pushed a commit to fastbike/ArduinoCore-renesas that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants