From f9bd5d79d2813d513b6ec688721a714c21ace560 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 28 Mar 2013 00:11:56 +0100 Subject: [PATCH] SPI: add 1ms sleep in wakeup() Without this delay I had troubles with a Raspberry-Pi: With debug enabled I could go as high as 7.8MHz but without debug I had to go lower than 500kHz otherwise I got following error: errorlibnfc.driver.pn532_spiUnable to wait for SPI data. (RX) pn53x_check_communication: Timeout It could work occassionally faster but very unreliable. So the delay introduced by printf() was enough to "fix" the problem, therefore this little extra sleep() in wakeup(). --- libnfc/drivers/pn532_spi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libnfc/drivers/pn532_spi.c b/libnfc/drivers/pn532_spi.c index f7a81ad..1202868 100644 --- a/libnfc/drivers/pn532_spi.c +++ b/libnfc/drivers/pn532_spi.c @@ -307,6 +307,7 @@ pn532_spi_wakeup(nfc_device *pnd) log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Got %x byte from SPI line before wakeup", spi_byte); CHIP_DATA(pnd)->power_mode = NORMAL; // PN532 will be awake soon + msleep(1); if (spi_byte == 0xff) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "Wakeup is needed");