Snap for 6747166 from b9c65c10aa96f43147c49ca8b744a1f52097aa5a to rvc-d1-release
Change-Id: I3921db43fe5eafb703ecf729c4cee2f38e474cea
diff --git a/1.2/hal_st21nfc.cc b/1.2/hal_st21nfc.cc
index 1ac5d0d..0aa6b89 100644
--- a/1.2/hal_st21nfc.cc
+++ b/1.2/hal_st21nfc.cc
@@ -43,7 +43,7 @@
nfc_stack_callback_t* p_cback_unwrap;
} st21nfc_dev_t;
-const char* halVersion = "ST21NFC HAL1.2 Version 3.2.5";
+const char* halVersion = "ST21NFC HAL1.2 Version 3.2.52";
uint8_t cmd_set_nfc_mode_enable[] = {0x2f, 0x02, 0x02, 0x02, 0x01};
uint8_t hal_is_closed = 1;
diff --git a/st21nfc/adaptation/i2clayer.cc b/st21nfc/adaptation/i2clayer.cc
index 7e78afc..049ef08 100644
--- a/st21nfc/adaptation/i2clayer.cc
+++ b/st21nfc/adaptation/i2clayer.cc
@@ -104,6 +104,7 @@
STLOG_HAL_V("echo thread wakeup from chip...\n");
uint8_t buffer[300];
+ int count = 0;
do {
// load first four bytes:
@@ -159,8 +160,8 @@
readOk = false;
memset(buffer, 0xca, sizeof(buffer));
- /* read while we have data available */
- } while (i2cGetGPIOState(fidI2c) == 1);
+ /* read while we have data available, up to 2 times then allow writes */
+ } while ((i2cGetGPIOState(fidI2c) == 1) && (count++ < 2));
}
if (event_table[1].revents & POLLIN) {
diff --git a/st21nfc/hal_wrapper.cc b/st21nfc/hal_wrapper.cc
index d8cd9cf..4449d2d 100644
--- a/st21nfc/hal_wrapper.cc
+++ b/st21nfc/hal_wrapper.cc
@@ -128,7 +128,7 @@
mHalWrapperState = HAL_WRAPPER_STATE_CLOSING;
// Send PROP_NFC_MODE_SET_CMD
if (!HalSendDownstreamTimer(mHalHandle, propNfcModeSetCmdQb,
- sizeof(propNfcModeSetCmdQb), 100)) {
+ sizeof(propNfcModeSetCmdQb), 40)) {
STLOG_HAL_E("NFC-NCI HAL: %s HalSendDownstreamTimer failed", __func__);
return -1;
}
@@ -508,6 +508,16 @@
uint8_t propNfcModeSetCmdOn[] = {0x2f, 0x02, 0x02, 0x02, 0x01};
switch (mHalWrapperState) {
+ case HAL_WRAPPER_STATE_CLOSING:
+ if (event == HAL_WRAPPER_TIMEOUT_EVT) {
+ STLOG_HAL_D("NFC-NCI HAL: %s Timeout. Close anyway", __func__);
+ HalSendDownstreamStopTimer(mHalHandle);
+ hal_fd_close();
+ mHalWrapperState = HAL_WRAPPER_STATE_CLOSED;
+ return;
+ }
+ break;
+
case HAL_WRAPPER_STATE_CLOSED:
if (event == HAL_WRAPPER_TIMEOUT_EVT) {
STLOG_HAL_D("NFC-NCI HAL: %s Timeout. Close anyway", __func__);