-
Notifications
You must be signed in to change notification settings - Fork 235
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
Support 3-wire-SPI #2919
Support 3-wire-SPI #2919
Conversation
esp-hal/src/spi/master.rs
Outdated
|| (address != Address::None && address.mode() != DataMode::SingleThreeWire) | ||
|| data_mode != DataMode::SingleThreeWire) | ||
{ | ||
return Err(Error::ArgumentsInvalid); |
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.
Should we use Unsupported instead?
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 was considering that (and actually I used it first) but the description suggests something else (well I could change the description ofc) - but on the other hand looking at how it's currently used it might be fine - I don't have a preference - happy to change it
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 don't think we want to have two different error variants that mean the same thing. Why something isn't supported is, in my opinion, not that important.
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.
really no preference on my side - maybe there are more opinions on that - if not I will remove ArgumentsInvalid
(maybe rename Unsupported
to OperationUnsupported
?)
9e5dde9
to
dbc6922
Compare
esp-hal/src/spi/mod.rs
Outdated
pub enum DataMode { | ||
/// `Single` Data Mode - 1 bit, 2 wires. | ||
/// Clock, CS and one data line (SIO0) | ||
SingleThreeWire, | ||
/// `Single` Data Mode - 1 bit, two data lines. (SIO0, SIO1) | ||
Single, | ||
/// `Dual` Data Mode - 2 bit, 2 wires | ||
/// `Dual` Data Mode - 2 bits, two data lines. (SIO0, SIO1) | ||
Dual, | ||
/// `Quad` Data Mode - 4 bit, 4 wires | ||
/// `Quad` Data Mode - 4 bit, 4 data lines. (SIO0 .. SIO3) | ||
Quad, | ||
#[cfg(spi_octal)] | ||
/// `Octal` Data Mode - 8 bit, 8 wires | ||
/// `Octal` Data Mode - 8 bit, 8 data lines. (SIO0 .. SIO7) | ||
Octal, | ||
} |
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.
Wild thought here with regards to naming consistency.
I think it actually makes more sense for Single
to mean "3 wire half duplex".
This way, Single
, Dual
, Quad
and Octal
all mean half duplex and the name strictly refers to the number of data pins used.
Then there can be a special mode for when there are two data lines that aren't used at the same time.
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.
Makes sense - and did that. Maybe the now Single
variant should be named ThreeWire
to make things more obvious? I think three-wire and four-wire are more common names
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.
My issue with the "FourWire" name is that both Dual and Quad use four wires and it'll be somewhat unclear that this means "Single" but over the full duplex wiring.
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.
yeah - I'm open to naming suggestions
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.
Some inspiration
HalfAndHalf
DualHalves
Couple
Half
TwoHalves
SingleSplit
Split
Pair
Serial
SingleWithTwoWires
Single(SingleMode::ThreeWire)
c177bd6
to
7091b11
Compare
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.
My concerns have been resolved
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.
Thanks. I guess we might want to mark the half-duplex pin setters as unstable as the half duplex transfers themselves are unstable, but that's not a huge deal.
ae64707
to
5f16261
Compare
5f16261
to
098ab64
Compare
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
Implement 3-wire half-duplex SPI.
Closes #2687
Closes #1826
Testing
While there is an adapted hil-test I used a C3 to simulate a slave-device and checked the implementation works for me