Fix cppcheck warning "Obsolete function 'usleep' called"
This commit is contained in:
parent
05b9cde966
commit
ff11c8ac87
1 changed files with 17 additions and 3 deletions
|
@ -34,8 +34,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <nfc/nfc.h>
|
#include <nfc/nfc.h>
|
||||||
|
|
||||||
#include "drivers.h"
|
#include "drivers.h"
|
||||||
|
@ -51,6 +49,22 @@
|
||||||
#define LOG_CATEGORY "libnfc.driver.pn532_spi"
|
#define LOG_CATEGORY "libnfc.driver.pn532_spi"
|
||||||
#define LOG_GROUP NFC_LOG_GROUP_DRIVER
|
#define LOG_GROUP NFC_LOG_GROUP_DRIVER
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
// Needed by sleep() under Unix
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <time.h>
|
||||||
|
# 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 <winbase.h>
|
||||||
|
# define msleep Sleep
|
||||||
|
#endif
|
||||||
|
|
||||||
// Internal data structs
|
// Internal data structs
|
||||||
const struct pn53x_io pn532_spi_io;
|
const struct pn53x_io pn532_spi_io;
|
||||||
struct pn532_spi_data {
|
struct pn532_spi_data {
|
||||||
|
@ -336,7 +350,7 @@ pn532_spi_wait_for_data(nfc_device *pnd, int timeout)
|
||||||
return NFC_ETIMEOUT;
|
return NFC_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(pn532_spi_poll_interval * 1000);
|
msleep(pn532_spi_poll_interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue