-
Notifications
You must be signed in to change notification settings - Fork 971
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
added spi_get_baudrate() + some consistency changes #395
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ecc002c
added spi_get_baudrate() + some consistency changes
Reneg973 f385948
fixed docu
Reneg973 ae375ab
Merge branch 'develop' into SPI-Helpers
Reneg973 b43ac69
Update spi.h
Reneg973 272bd55
Merge branch 'SPI-Helpers' of https://github.com/Reneg973/pico-sdk in…
Reneg973 05224d2
another misleading docu removed
Reneg973 5a043a2
improved const correctness
Reneg973 b0e2b1e
fixed kitchen_sink issues
Reneg973 5b2f444
reverted size_t return value to int
Reneg973 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
don't think this should be const; sure the method itself doesn't write thru it, but it sure does cast it to a mutable pointer
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.
I propose an alternative, add an additional function:
static inline const spi_hw_t *spi_get_hw_const(const spi_inst_t *spi) {
Needs some more changes. Agreed?
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.
we don't do this for any hardware; not least there may be registers for which reading has side effects.
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.
Your decision, both ways are possible. Anyway my experience is that const correctness can expose possible issues in code.
E.g. check function hw_is_claimed(), the function name says it just checks, but in reality it claims, so it does more than expected. One of the rules I try to follow - no surprises. And if hw_is_claimed() modifies something another function (hw_claim_or_assert) is made for, IMO this is a surprise
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.
ha - yes that is a bug! I'm all for const pointers to any data struct, i was just on the fence in the h/w pointer case. Anyway, we can't do this as it requires a cast away of const... as you say we could add a spi_get_hw_const which I'm not whoilly against, but I don't think is necessary.
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.
right, that's ok here, it's just a simple function where const correctness is not of any meaning. I'll remove it - but then it must be removed for every const correct function which uses it... compiler thingy
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.
I made a proposal with commit 5a043a2. Please check whether it's ok or needs a revert