This commit is contained in:
Philippe Teuwen
2017-02-18 13:05:59 +01:00
parent f184407cc5
commit e4df2f3334
16 changed files with 121 additions and 120 deletions

View File

@@ -120,19 +120,19 @@ static struct timespec __transaction_stop;
* @return length (in bytes) of read data, or driver error code (negative value)
*/
static ssize_t pn532_i2c_read(const i2c_device id,
uint8_t *buf, const size_t len)
uint8_t *buf, const size_t len)
{
struct timespec transaction_start, bus_free_time = { 0 };
ssize_t ret;
struct timespec transaction_start, bus_free_time = { 0 };
ssize_t ret;
clock_gettime(CLOCK_MONOTONIC, &transaction_start);
bus_free_time.tv_nsec = (PN532_BUS_FREE_TIME * 1000 * 1000) -
(transaction_start.tv_nsec - __transaction_stop.tv_nsec);
nanosleep(&bus_free_time, NULL);
clock_gettime(CLOCK_MONOTONIC, &transaction_start);
bus_free_time.tv_nsec = (PN532_BUS_FREE_TIME * 1000 * 1000) -
(transaction_start.tv_nsec - __transaction_stop.tv_nsec);
nanosleep(&bus_free_time, NULL);
ret = i2c_read(id, buf, len);
clock_gettime(CLOCK_MONOTONIC, &__transaction_stop);
return ret;
ret = i2c_read(id, buf, len);
clock_gettime(CLOCK_MONOTONIC, &__transaction_stop);
return ret;
}
/**
@@ -148,19 +148,19 @@ static ssize_t pn532_i2c_read(const i2c_device id,
* @return NFC_SUCCESS on success, otherwise driver error code
*/
static ssize_t pn532_i2c_write(const i2c_device id,
const uint8_t *buf, const size_t len)
const uint8_t *buf, const size_t len)
{
struct timespec transaction_start, bus_free_time = { 0 };
ssize_t ret;
struct timespec transaction_start, bus_free_time = { 0 };
ssize_t ret;
clock_gettime(CLOCK_MONOTONIC, &transaction_start);
bus_free_time.tv_nsec = (PN532_BUS_FREE_TIME * 1000 * 1000) -
(transaction_start.tv_nsec - __transaction_stop.tv_nsec);
nanosleep(&bus_free_time, NULL);
clock_gettime(CLOCK_MONOTONIC, &transaction_start);
bus_free_time.tv_nsec = (PN532_BUS_FREE_TIME * 1000 * 1000) -
(transaction_start.tv_nsec - __transaction_stop.tv_nsec);
nanosleep(&bus_free_time, NULL);
ret = i2c_write(id, buf, len);
clock_gettime(CLOCK_MONOTONIC, &__transaction_stop);
return ret;
ret = i2c_write(id, buf, len);
clock_gettime(CLOCK_MONOTONIC, &__transaction_stop);
return ret;
}
/**

View File

@@ -433,7 +433,7 @@ pn532_spi_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, int
goto error;
}
pnd->last_error = spi_send_receive(DRIVER_DATA(pnd)->port, &pn532_spi_cmd_dataread, 1, abtRxBuf , 4, true);
pnd->last_error = spi_send_receive(DRIVER_DATA(pnd)->port, &pn532_spi_cmd_dataread, 1, abtRxBuf, 4, true);
if (pnd->last_error < 0) {
goto error;

View File

@@ -351,7 +351,7 @@ pn53x_usb_open(const nfc_context *context, const nfc_connstring connstring)
}
switch (DRIVER_DATA(pnd)->model) {
// empirical tuning
// empirical tuning
case ASK_LOGO:
CHIP_DATA(pnd)->timer_correction = 50;
break;
@@ -697,12 +697,12 @@ pn53x_usb_set_property_bool(nfc_device *pnd, const nfc_property property, const
}
break;
case SCM_SCL3712:
if (NP_ACTIVATE_FIELD == property) {
// Switch on/off LED according to ACTIVATE_FIELD option
if ((res = pn53x_write_register(pnd, PN53X_SFR_P3, _BV(P32), bEnable ? 0 : _BV(P32))) < 0)
return res;
}
break;
if (NP_ACTIVATE_FIELD == property) {
// Switch on/off LED according to ACTIVATE_FIELD option
if ((res = pn53x_write_register(pnd, PN53X_SFR_P3, _BV(P32), bEnable ? 0 : _BV(P32))) < 0)
return res;
}
break;
case NXP_PN531:
case NXP_PN533:
case SONY_PN531: