summaryrefslogtreecommitdiffstats
path: root/Linux_x86/phDal4Nfc.c
diff options
context:
space:
mode:
Diffstat (limited to 'Linux_x86/phDal4Nfc.c')
-rw-r--r--Linux_x86/phDal4Nfc.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index 3e031f1..8683a17 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -543,17 +543,17 @@ NFCSTATUS phDal4Nfc_Config(pphDal4Nfc_sConfig_t config,void **phwref)
/* Retrieve the hw module from the Android NFC HAL */
ret = hw_get_module(NFC_HARDWARE_MODULE_ID, &hw_module);
if (ret) {
- LOGE("hw_get_module() failed");
+ ALOGE("hw_get_module() failed");
return NFCSTATUS_FAILED;
}
ret = nfc_pn544_open(hw_module, &pn544_dev);
if (ret) {
- LOGE("Could not open pn544 hw_module");
+ ALOGE("Could not open pn544 hw_module");
return NFCSTATUS_FAILED;
}
config->deviceNode = pn544_dev->device_node;
if (config->deviceNode == NULL) {
- LOGE("deviceNode NULL");
+ ALOGE("deviceNode NULL");
return NFCSTATUS_FAILED;
}
@@ -718,10 +718,19 @@ int phDal4Nfc_ReaderThread(void * pArg)
int i;
int i2c_error_count;
int i2c_workaround;
+ int i2c_device_address = 0x57;
if (gDalContext.pDev != NULL) {
i2c_workaround = gDalContext.pDev->enable_i2c_workaround;
+ if (gDalContext.pDev->i2c_device_address) {
+ i2c_device_address = gDalContext.pDev->i2c_device_address;
+ if (i2c_workaround && i2c_device_address < 32)
+ {
+ ALOGE("i2c_device_address not set to valid value");
+ return NFCSTATUS_FAILED;
+ }
+ }
} else {
- LOGE("gDalContext.pDev is not set");
+ ALOGE("gDalContext.pDev is not set");
return NFCSTATUS_FAILED;
}
@@ -758,15 +767,17 @@ retry:
/* Wait for IRQ !!! */
gReadWriteContext.nNbOfBytesRead = gLinkFunc.read(gReadWriteContext.pReadBuffer, gReadWriteContext.nNbOfBytesToRead);
- /* Reading the value 0x57 indicates a HW I2C error at I2C address 0x57
+ /* A read value equal to the i2c_device_address indicates a HW I2C error at I2C address i2c_device_address
* (pn544). There should not be false positives because a read of length 1
- * must be a HCI length read, and a length of 0x57 is impossible (max is 33).
+ * must be a HCI length read, and a length of i2c_device_address is impossible (max is 33).
*/
- if(i2c_workaround && gReadWriteContext.nNbOfBytesToRead == 1 &&
- gReadWriteContext.pReadBuffer[0] == 0x57)
+ if (i2c_workaround && gReadWriteContext.nNbOfBytesToRead == 1 &&
+ gReadWriteContext.pReadBuffer[0] == i2c_device_address)
{
i2c_error_count++;
- DAL_DEBUG("RX Thread Read 0x57 %d times\n", i2c_error_count);
+ DAL_DEBUG("RX Thread Read 0x%02x ", i2c_device_address);
+ DAL_DEBUG("%d times\n", i2c_error_count);
+
if (i2c_error_count < 5) {
usleep(2000);
goto retry;