From b69974397366a57f6f7d420c9ef2dcd2d046e6cb Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Wed, 4 Jan 2012 15:43:08 +0000 Subject: [PATCH] nfc_initiator_transceive_bits_timed() function does not now use pszRxBits as parameter because this function returns it. --- examples/nfc-anticol.c | 2 +- include/nfc/nfc.h | 2 +- libnfc/chips/pn53x.c | 12 ++++++------ libnfc/chips/pn53x.h | 3 +-- libnfc/nfc-internal.h | 2 +- libnfc/nfc.c | 4 ++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/nfc-anticol.c b/examples/nfc-anticol.c index 1080802..3ab2c78 100644 --- a/examples/nfc-anticol.c +++ b/examples/nfc-anticol.c @@ -52,7 +52,7 @@ #define MAX_FRAME_LEN 264 static uint8_t abtRx[MAX_FRAME_LEN]; -static size_t szRxBits; +static int szRxBits; static size_t szRx = sizeof(abtRx); static uint8_t abtRawUid[12]; static uint8_t abtAtqa[2]; diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index f7c2640..b2f387a 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -80,7 +80,7 @@ extern "C" { NFC_EXPORT int nfc_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout); NFC_EXPORT int nfc_initiator_transceive_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar); NFC_EXPORT int nfc_initiator_transceive_bytes_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, uint32_t *cycles); - NFC_EXPORT int nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar, uint32_t *cycles); + NFC_EXPORT int nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles); /* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */ NFC_EXPORT int nfc_target_init (nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx); diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index aaeb8be..99247ff 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1318,7 +1318,7 @@ uint32_t __pn53x_get_timer(struct nfc_device *pnd, const uint8_t last_cmd_byte) int pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, - const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar, uint32_t *cycles) + const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles) { // TODO Do something with these bytes... (void) pbtTxPar; @@ -1326,6 +1326,7 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb uint16_t i; uint8_t sz; int res = 0; + size_t szRxBits = 0; // Sorry, no arbitrary parity bits support for now if (!pnd->bPar) { @@ -1373,7 +1374,6 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb } // Recv data - *pszRxBits = 0; // we've to watch for coming data until we decide to timeout. // our PN53x timer saturates after 4.8ms so this function shouldn't be used for // responses coming very late anyway. @@ -1404,19 +1404,19 @@ pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pb return res; } for (i = 0; i < sz; i++) { - pbtRx[i+*pszRxBits] = abtRes[i+off]; + pbtRx[i+szRxBits] = abtRes[i+off]; } - *pszRxBits += (size_t) (sz & SYMBOL_FIFO_LEVEL); + szRxBits += (size_t) (sz & SYMBOL_FIFO_LEVEL); sz = abtRes[sz+off]; if (sz == 0) break; } - *pszRxBits *= 8; // in bits, not bytes + szRxBits *= 8; // in bits, not bytes // Recv corrected timer value *cycles = __pn53x_get_timer (pnd, pbtTx[szTxBits / 8]); - return *pszRxBits; + return szRxBits; } int diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index d193612..057fe4a 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -302,8 +302,7 @@ int pn53x_initiator_transceive_bits (struct nfc_device *pnd, const uint8_t *p int pn53x_initiator_transceive_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout); int pn53x_initiator_transceive_bits_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, - const uint8_t *pbtTxPar, uint8_t *pbtRx, size_t *pszRxBits, - uint8_t *pbtRxPar, uint32_t *cycles); + const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles); int pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, uint32_t *cycles); int pn53x_initiator_deselect_target (struct nfc_device *pnd); diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index abebdd3..1477c2e 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -140,7 +140,7 @@ struct nfc_driver_t { int (*initiator_transceive_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, int timeout); int (*initiator_transceive_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, uint8_t * pbtRxPar); int (*initiator_transceive_bytes_timed) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, size_t * pszRx, uint32_t * cycles); - int (*initiator_transceive_bits_timed) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, size_t * pszRxBits, uint8_t * pbtRxPar, uint32_t * cycles); + int (*initiator_transceive_bits_timed) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, uint8_t * pbtRxPar, uint32_t * cycles); int (*target_init) (struct nfc_device *pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx); int (*target_send_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, int timeout); diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 1f620f4..8e532ac 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -593,9 +593,9 @@ nfc_initiator_transceive_bytes_timed (nfc_device *pnd, const uint8_t *pbtTx, con */ int nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, - uint8_t *pbtRx, size_t *pszRxBits, uint8_t *pbtRxPar, uint32_t *cycles) + uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles) { - HAL (initiator_transceive_bits_timed, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pszRxBits, pbtRxPar, cycles); + HAL (initiator_transceive_bits_timed, pnd, pbtTx, szTxBits, pbtTxPar, pbtRx, pbtRxPar, cycles); } /**