Skip to content
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

Comment handling of RDY byte #28

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ where
}

fn wait_ready(&mut self) -> Poll<Result<(), Self::Error>> {
// Wait for RDY byte to be 1
// See 6.2.4 I2C communication statement
let mut buf = [0];
if let Err(e) = self.i2c.read(I2C_ADDRESS, &mut buf) {
// It's possible that the PN532 does not ACK the read request when it is not ready.
Expand All @@ -54,7 +56,10 @@ where
fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error> {
self.i2c.transaction(
I2C_ADDRESS,
&mut [Operation::Read(&mut [0]), Operation::Read(buf)],
&mut [
Operation::Read(&mut [0]), // Strip RDY byte off the response
Operation::Read(buf),
],
)
}
}
Expand Down