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

SPI fix, new begin command and allow oneshotmode #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

milesfrankland
Copy link

Fixes SPI issues some people were having by moving SPI.begin into a new mcp2515.begin() command. This also replaces mcp2515.reset() so you can remove 2 lines from the ino and replace with 1 easier one.
Added one shot mode sending enable by replacing a not used CANCTRL_REQOP_POWERUP (that was also incorrect in accordance with the spec sheet and not a mode - just a statment).

@manchoz
Copy link

manchoz commented Nov 23, 2020

Without this PR the library will fail at run-time on MbedOS-based Arduino boards (and actually works by chance on every other board)

Please, @autowp review and merge it!

@autowp
Copy link
Owner

autowp commented Nov 23, 2020

Can't test for back compatibility. Are you checked that improvements on legacy boards?

@manchoz
Copy link

manchoz commented Nov 23, 2020

@autowp works as usual on legacy boards.

SPI (or I2C) initialization in the constructor has always been a cause of major issues in several Arduino libraries. This is the reason why almost every SPI-based library has a ::begin() method to be called before starting the actual operations.

As proposed by this PR, is a best practice for the constructor to just initialize the internal statuses and let the ::begin() and other ad-hoc methods to deal with external dependencies at run-time.

Thanks for your work and your time!

@autowp
Copy link
Owner

autowp commented Nov 23, 2020

But now all library users must replace reset with begin. It' bc chage

@manchoz
Copy link

manchoz commented Nov 23, 2020

Uhm, I see.

Would be better to move theSPI.begin() to the ::reset() method, maybe? Would that be safer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants