From c5f05f05927068f80aa2d2a4e47238704c3d7233 Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Tue, 20 Dec 2011 13:37:54 +0000 Subject: [PATCH] pn53x_set_parameters() function returns now libnfc error code. --- libnfc/chips/pn53x.c | 17 +++++++++-------- libnfc/chips/pn53x.h | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 55a5c94..8d2495c 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -74,7 +74,7 @@ pn53x_init(struct nfc_device *pnd) // We can't read these parameters, so we set a default config by using the SetParameters wrapper // Note: pn53x_SetParameters() will save the sent value in pnd->ui8Parameters cache - if(!pn53x_SetParameters(pnd, PARAM_AUTO_ATR_RES | PARAM_AUTO_RATS)) { + if(pn53x_SetParameters(pnd, PARAM_AUTO_ATR_RES | PARAM_AUTO_RATS) < 0) { return false; } @@ -195,14 +195,14 @@ pn53x_transceive (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szT return ((0 == CHIP_DATA(pnd)->last_status_byte) ? NFC_SUCCESS : NFC_ECHIP); } -bool +int pn53x_set_parameters (struct nfc_device *pnd, const uint8_t ui8Parameter, const bool bEnable) { uint8_t ui8Value = (bEnable) ? (CHIP_DATA (pnd)->ui8Parameters | ui8Parameter) : (CHIP_DATA (pnd)->ui8Parameters & ~(ui8Parameter)); if (ui8Value != CHIP_DATA (pnd)->ui8Parameters) { return pn53x_SetParameters(pnd, ui8Value); } - return true; + return NFC_SUCCESS; } bool @@ -761,7 +761,7 @@ pn53x_set_property_bool (struct nfc_device *pnd, const nfc_property property, co // Nothing to do return NFC_SUCCESS; pnd->bAutoIso14443_4 = bEnable; - if (pn53x_set_parameters (pnd, PARAM_AUTO_RATS, bEnable)) + if (pn53x_set_parameters (pnd, PARAM_AUTO_RATS, bEnable) == 0) return NFC_SUCCESS; break; @@ -2010,17 +2010,18 @@ pn53x_RFConfiguration__MaxRetries (struct nfc_device *pnd, const uint8_t MxRtyAT return pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, -1); } -bool +int pn53x_SetParameters (struct nfc_device *pnd, const uint8_t ui8Value) { uint8_t abtCmd[] = { SetParameters, ui8Value }; + int res = 0; - if(pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, -1) < 0) { - return false; + if((res = pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL, -1)) < 0) { + return res; } // We save last parameters in register cache CHIP_DATA (pnd)->ui8Parameters = ui8Value; - return true; + return NFC_SUCCESS; } int diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index df1b846..30ea7ba 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -266,7 +266,7 @@ extern const uint8_t pn53x_nack_frame[6]; bool pn53x_init(struct nfc_device *pnd); int pn53x_transceive (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, size_t *pszRx, int timeout); -bool pn53x_set_parameters (struct nfc_device *pnd, const uint8_t ui8Value, const bool bEnable); +int pn53x_set_parameters (struct nfc_device *pnd, const uint8_t ui8Value, const bool bEnable); bool pn53x_set_tx_bits (struct nfc_device *pnd, const uint8_t ui8Bits); bool pn53x_wrap_frame (const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtFrame, size_t *pszFrameBits); @@ -322,7 +322,7 @@ bool pn53x_target_send_bytes (struct nfc_device *pnd, const uint8_t *pbtTx, c const char *pn53x_strerror (const struct nfc_device *pnd); // C wrappers for PN53x commands -bool pn53x_SetParameters (struct nfc_device *pnd, const uint8_t ui8Value); +int pn53x_SetParameters (struct nfc_device *pnd, const uint8_t ui8Value); int pn53x_SAMConfiguration (struct nfc_device *pnd, const pn532_sam_mode mode, int timeout); int pn53x_PowerDown (struct nfc_device *pnd); int pn53x_InListPassiveTarget (struct nfc_device *pnd, const pn53x_modulation pmInitModulation,