This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Implements clock mode handling for bitbang/spi#267
Merged
maruel merged 2 commits intogoogle:masterfrom Aug 6, 2018
Merged
Conversation
Handles clock-related Mode options for bitbanging SPI. Fixes google#266
- Adds error handling for each errorable operation in spiConn.Tx - Adds support for NoCS mode option - Re-adds early catch for unhandled modes, now just HalfDuplex and LSBFirst
Contributor
|
gohci |
maruel
approved these changes
Aug 6, 2018
Contributor
maruel
left a comment
There was a problem hiding this comment.
I think there's further room for improvement but that's already much better than it was, so I'm going to integrate as-is.
You're welcome to add yourself to AUTHORS/CONTRIBUTORS if you want.
| } | ||
|
|
||
| func (s *spiConn) clockOn() error { | ||
| if s.mode&spi.Mode2 == spi.Mode2 { |
Contributor
There was a problem hiding this comment.
One option is to add properties to spiConn for clock, i.e. at line 135, replace mode by:
clockIdle gpio.Level
readAfterClockPulse bool
and initialize them in Connect(). Then you can change the clockOn/clockOff functions to be:
s.sck.Out(s.clockIdle)
s.sck.Out(!s.clockIdle)
Contributor
Author
There was a problem hiding this comment.
That sounds nicer, yes.
| } | ||
| if mode&spi.LSBFirst == spi.LSBFirst { | ||
| return nil, errors.New("bitbang-spi: LSBFirst mode not supported") | ||
| } |
Contributor
There was a problem hiding this comment.
In practice, you'd want to check explicitly for 0 <= mode <= 3, so that if new flags are added, they are not silently ignored.
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Handles clock-related Mode options for bitbanging SPI.
Fixes #266