Skip to content

Commit

Permalink
Warn when reading non-ready frame from PN532
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Sep 14, 2024
1 parent 64a356e commit 43cb142
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion firmware/src/pn532.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use core::fmt::Debug;
use embassy_time::{with_timeout, Duration};
use embedded_hal_async::digital::Wait;
use embedded_hal_async::i2c::I2c;
use log::warn;
use pn532::i2c::{I2C_ADDRESS, PN532_I2C_READY};
use pn532::requests::BorrowedRequest;

Expand Down Expand Up @@ -82,7 +83,11 @@ impl<I2C: I2c, IRQ: Wait<Error = Infallible>> Interface for I2CInterfaceWithIrq<
self.i2c
.read(I2C_ADDRESS, &mut buf[..frame.len() + 1])
.await?;
debug_assert_eq!(buf[0], PN532_I2C_READY, "PN532 read while not ready");
// Status in a read frame should always indicate ready since `read` is always called after
// `wait_ready`. But sometimes it doesn't, which we ignore for now.
if buf[0] != PN532_I2C_READY {
warn!("PN532: read while not ready");
}
frame.copy_from_slice(&buf[1..frame.len() + 1]);
Ok(())
}
Expand Down

0 comments on commit 43cb142

Please sign in to comment.