Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Comments

Implements clock mode handling for bitbang/spi#267

Merged
maruel merged 2 commits intogoogle:masterfrom
Ulexus:bug-266
Aug 6, 2018
Merged

Implements clock mode handling for bitbang/spi#267
maruel merged 2 commits intogoogle:masterfrom
Ulexus:bug-266

Conversation

@Ulexus
Copy link
Contributor

@Ulexus Ulexus commented Aug 6, 2018

Handles clock-related Mode options for bitbanging SPI.

Fixes #266

Ulexus added 2 commits August 5, 2018 23:13
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
@maruel
Copy link
Contributor

maruel commented Aug 6, 2018

gohci

Copy link
Contributor

@maruel maruel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds nicer, yes.

}
if mode&spi.LSBFirst == spi.LSBFirst {
return nil, errors.New("bitbang-spi: LSBFirst mode not supported")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, you'd want to check explicitly for 0 <= mode <= 3, so that if new flags are added, they are not silently ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@maruel maruel merged commit ee192bf into google:master Aug 6, 2018
@Ulexus Ulexus deleted the bug-266 branch August 6, 2018 17:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants