diff --git a/libnfc/drivers/pn532_spi.c b/libnfc/drivers/pn532_spi.c index cef5a38..05cb000 100644 --- a/libnfc/drivers/pn532_spi.c +++ b/libnfc/drivers/pn532_spi.c @@ -34,8 +34,6 @@ #include #include #include -#include - #include #include "drivers.h" @@ -51,6 +49,22 @@ #define LOG_CATEGORY "libnfc.driver.pn532_spi" #define LOG_GROUP NFC_LOG_GROUP_DRIVER +#ifndef _WIN32 +// Needed by sleep() under Unix +# include +# include +# define msleep(x) do { \ + struct timespec xsleep; \ + xsleep.tv_sec = x / 1000; \ + xsleep.tv_nsec = (x - xsleep.tv_sec * 1000) * 1000 * 1000; \ + nanosleep(&xsleep, NULL); \ + } while (0) +#else +// Needed by Sleep() under Windows +# include +# define msleep Sleep +#endif + // Internal data structs const struct pn53x_io pn532_spi_io; struct pn532_spi_data { @@ -336,7 +350,7 @@ pn532_spi_wait_for_data(nfc_device *pnd, int timeout) return NFC_ETIMEOUT; } - usleep(pn532_spi_poll_interval * 1000); + msleep(pn532_spi_poll_interval); } }