-
Notifications
You must be signed in to change notification settings - Fork 227
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
Remove the single byte read/write inherent functions #2915
Conversation
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 for working on this, left some nitpicks, some of them can be ignored, I guess
We should also remove the |
137a1e6
to
3e219b9
Compare
I made private functions from |
@@ -459,6 +471,12 @@ The Address and Command enums have similarly had their variants changed from e.g | |||
+ Command::_1Bit | |||
``` | |||
|
|||
`write_byte` and `read_byte` were removed and `write_bytes` and `read_bytes` can be used as replacement. |
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.
You could expand on this a little bit - like mentioning to use a one byte sized buffer and checking the returned length
3e219b9
to
f2c40fd
Compare
@@ -526,6 +512,11 @@ where | |||
Ok(()) | |||
} | |||
|
|||
/// Read bytes from SPI. | |||
pub fn read_bytes(&mut self, words: &mut [u8]) -> Result<(), Error> { |
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'll have to take a bit of care here. UART's read_bytes
is not blocking, SPI's read_bytes
is blocking. As the peripherals work differently, it makes logical sense, but I'm not sure if we want the function use the same name, but do different things.
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 guess this should be resolved in #2882 which is a bit stalled due to this PR
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.
Please elaborate how it will be resolved, that PR still has a non-blocking pub fn read_bytes(&mut self, buf: &mut [u8]) -> usize {
. Non-blocking in the sense that it doesn't fill up the buffer, but returns early if there is not enough data to read.
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 guess we could add some documentation or rename, it can also be done here, no hard opinions
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.
Imo this is fine as is, and if anything we should change uart's read_bytes
back to being blocking and introduce a nb API post 1.0
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.
A little bit more documentation wouldn't hurt probably. "Read bytes from SPI" is very brief
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.
A little bit more documentation wouldn't hurt probably. "Read bytes from SPI" is very brief
Well, it matches write_bytes
and transfer
😆
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'll do the UART changes once these PRs land.
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.
Please leave a non-blocking one around, in my application I don't know how much data the transmitter is going to send so I need the non-blocking version to just read what is available 😅
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.
LGTM
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.
LGTM!
closes #2808
cc #2882