summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJizhou Liao <Jizhou.Liao@nxp.com>2016-03-01 12:41:46 -0800
committerMartijn Coenen <maco@google.com>2016-04-27 10:17:12 +0200
commit20580655b9cfe4b61845ca64dbe968d1c5c2a5c1 (patch)
tree983613e9f8212cf4b8b8ccd4f91b71271bfac65b
parent15c09be1b19562d8d84a79bd55dc18513a052598 (diff)
downloadlibnfc-nci-20580655b9cfe4b61845ca64dbe968d1c5c2a5c1.tar.gz
Support NXP PN551 NFC controller
The changes to support PN551 controller: - New firmware download sequence - New build option&configuration file - Remove all warnings - Bug fix Change-Id: I49c0a26a116c1c513968fc58d2736ee71eb05a22
-rw-r--r--halimpl/pn54x/Android.mk50
-rw-r--r--halimpl/pn54x/common/phNfcCommon.h23
-rw-r--r--halimpl/pn54x/dnld/phDnldNfc.c64
-rw-r--r--halimpl/pn54x/dnld/phDnldNfc.h4
-rw-r--r--halimpl/pn54x/dnld/phDnldNfc_Internal.c22
-rw-r--r--halimpl/pn54x/dnld/phNxpNciHal_Dnld.c20
-rw-r--r--halimpl/pn54x/hal/phNxpNciHal.c141
-rw-r--r--halimpl/pn54x/hal/phNxpNciHal.h3
-rw-r--r--halimpl/pn54x/hal/phNxpNciHal_NfcDepSWPrio.c37
-rw-r--r--halimpl/pn54x/hal/phNxpNciHal_ext.c20
-rw-r--r--halimpl/pn54x/libnfc-nxp-PN547C2_example.conf15
-rw-r--r--halimpl/pn54x/libnfc-nxp-PN548AD_example.conf18
-rw-r--r--halimpl/pn54x/libnfc-nxp-PN551_example.conf273
-rw-r--r--halimpl/pn54x/libnfc-nxp-PN65T_example.conf6
-rw-r--r--halimpl/pn54x/libnfc-nxp-PN66T_example.conf13
-rw-r--r--halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c86
-rw-r--r--halimpl/pn54x/tml/phDal4Nfc_messageQueueLib.c2
-rw-r--r--halimpl/pn54x/tml/phTmlNfc.c20
-rw-r--r--halimpl/pn54x/tml/phTmlNfc_i2c.c44
-rw-r--r--halimpl/pn54x/tml/phTmlNfc_i2c.h1
-rw-r--r--halimpl/pn54x/utils/phNxpConfig.h1
-rw-r--r--halimpl/pn54x/utils/phNxpNciHal_utils.c6
22 files changed, 638 insertions, 231 deletions
diff --git a/halimpl/pn54x/Android.mk b/halimpl/pn54x/Android.mk
index 4b8bc2a..8acf98f 100644
--- a/halimpl/pn54x/Android.mk
+++ b/halimpl/pn54x/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2014 NXP Semiconductors
+# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,6 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#variables for NFC_NXP_CHIP_TYPE
+PN547C2 := 1
+PN548C2 := 2
+PN551 := 3
+NQ110 := $PN547C2
+NQ120 := $PN547C2
+NQ210 := $PN548C2
+NQ220 := $PN548C2
+#NXP PN547 Enable
+ifeq ($(PN547C2),1)
+D_CFLAGS += -DPN547C2=1
+endif
+ifeq ($(PN548C2),2)
+D_CFLAGS += -DPN548C2=2
+endif
+ifeq ($(PN551),3)
+D_CFLAGS += -DPN551=3
+endif
+
+#### Select the CHIP ####
+ifeq ($(NXP_CHIP_TYPE),$(PN547C2))
+D_CFLAGS += -DNFC_NXP_CHIP_TYPE=PN547C2
+else ifeq ($(NXP_CHIP_TYPE),$(PN548C2))
+D_CFLAGS += -DNFC_NXP_CHIP_TYPE=PN548C2
+else ifeq ($(NXP_CHIP_TYPE),$(PN551))
+D_CFLAGS += -DNFC_NXP_CHIP_TYPE=PN551
+else
+D_CFLAGS += -DNFC_NXP_CHIP_TYPE=PN551
+endif
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := nfc_nci.$(TARGET_DEVICE)
@@ -19,6 +48,7 @@ LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := $(call all-subdir-c-files) $(call all-subdir-cpp-files)
LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware_legacy libdl libhardware
+LOCAL_CFLAGS := $(D_CFLAGS)
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/utils \
$(LOCAL_PATH)/inc \
@@ -29,24 +59,6 @@ LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/tml \
$(LOCAL_PATH)/self-test
-#variables for NFC_NXP_CHIP_TYPE
-PN547C2 := 1
-PN548C2 := 2
-
-ifeq ($(PN547C2),1)
-LOCAL_CFLAGS += -DPN547C2=1
-endif
-ifeq ($(PN548C2),2)
-LOCAL_CFLAGS += -DPN548C2=2
-endif
-
-#### Select the CHIP ####
-ifeq ($(NFC_NXP_CHIP_TYPE),PN547C2)
-LOCAL_CFLAGS += -DNFC_NXP_CHIP_TYPE=PN547C2
-else
-LOCAL_CFLAGS += -DNFC_NXP_CHIP_TYPE=PN548C2
-endif
-
LOCAL_CFLAGS += -DANDROID \
-DNXP_UICC_ENABLE -DNXP_HW_SELF_TEST
LOCAL_CFLAGS += -DNFC_NXP_HFO_SETTINGS=FALSE
diff --git a/halimpl/pn54x/common/phNfcCommon.h b/halimpl/pn54x/common/phNfcCommon.h
index c0700b7..fdd0f36 100644
--- a/halimpl/pn54x/common/phNfcCommon.h
+++ b/halimpl/pn54x/common/phNfcCommon.h
@@ -33,21 +33,28 @@
#include <phNfcCompId.h>
-# define FW_DLL_ROOT_DIR "/system/vendor/firmware/"
-# define FW_DLL_EXTENSION ".so"
+#define FW_DLL_ROOT_DIR "/system/vendor/firmware/"
+#define FW_DLL_EXTENSION ".so"
-#if(NFC_NXP_CHIP_TYPE != PN547C2)
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
/* Actual FW library name*/
#define FW_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw" FW_DLL_EXTENSION
-/* Restore Currupted PLL Setttings/etc */
+/* Restore Corrupted PLL Setttings/etc */
#define PLATFORM_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw_platform" FW_DLL_EXTENSION
/* Upgrade the public Key */
#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn548ad_fw_pku" FW_DLL_EXTENSION
+#elif(NFC_NXP_CHIP_TYPE == PN551)
+/* Actual FW library name*/
+#define FW_LIB_PATH FLASH_CONF_ROOT_DIR "libpn551_fw" FW_DLL_EXTENSION
+/* Restore Corrupted PLL Settings/etc */
+#define PLATFORM_LIB_PATH FW_DLL_ROOT_DIR "libpn551_fw_platform" FW_DLL_EXTENSION
+/* Upgrade the public Key */
+#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn551_fw_pku" FW_DLL_EXTENSION
#else
/* Actual FW library name*/
#define FW_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw" FW_DLL_EXTENSION
-/* Restore Currupted PLL Setttings/etc */
+/* Restore Corrupted PLL Settings/etc */
#define PLATFORM_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw_platform" FW_DLL_EXTENSION
/* Upgrade the public Key */
#define PKU_LIB_PATH FW_DLL_ROOT_DIR "libpn547_fw_pku" FW_DLL_EXTENSION
@@ -60,8 +67,8 @@
#endif
/* HAL Version number (Updated as per release) */
-#define NXP_MW_VERSION_MAJ (1U)
-#define NXP_MW_VERSION_MIN (0U)
+#define NXP_MW_VERSION_MAJ (3U)
+#define NXP_MW_VERSION_MIN (5U)
/*
*****************************************************************
@@ -95,7 +102,7 @@
#define NXP_SYS_CLK_FREQ_SEL CLK_FREQ_19_2MHZ /* Set to one of CLK_FREQ_<value> */
#define CLK_TO_CFG_DEF 1
-#define CLK_TO_CFG_MAX 26
+#define CLK_TO_CFG_MAX 6
/*
* information to configure OSAL
*/
diff --git a/halimpl/pn54x/dnld/phDnldNfc.c b/halimpl/pn54x/dnld/phDnldNfc.c
index a77f136..82a7682 100644
--- a/halimpl/pn54x/dnld/phDnldNfc.c
+++ b/halimpl/pn54x/dnld/phDnldNfc.c
@@ -24,11 +24,12 @@
#include <phTmlNfc.h>
#include <phNxpLog.h>
#include <dlfcn.h>
+#include <phNxpConfig.h>
static void *pFwLibHandle; /* Global firmware lib handle used in this file only */
uint16_t wMwVer = 0; /* Middleware version no */
uint16_t wFwVer = 0; /* Firmware version no */
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
uint8_t gRecFWDwnld; // flag set to true to indicate dummy FW download
#endif
static pphDnldNfc_DlContext_t gpphDnldContext = NULL; /* Download contex */
@@ -282,8 +283,13 @@ NFCSTATUS phDnldNfc_CheckIntegrity(uint8_t bChipVer, pphDnldNfc_Buff_t pCRCData,
}
else
{
- if((PHDNLDNFC_HWVER_MRA2_1 == bChipVer) || (PHDNLDNFC_HWVER_MRA2_2 == bChipVer) ||
- (PHDNLDNFC_HWVER_PN548AD_MRA1_0 == bChipVer))
+ if ((PHDNLDNFC_HWVER_MRA2_1 == bChipVer) || (PHDNLDNFC_HWVER_MRA2_2 == bChipVer)
+#if(NFC_NXP_CHIP_TYPE == PN551)
+ || (PHDNLDNFC_HWVER_PN551_MRA1_0 == bChipVer)
+#elif(NFC_NXP_CHIP_TYPE == PN548C2)
+ || (PHDNLDNFC_HWVER_PN548AD_MRA1_0 == bChipVer)
+#endif
+ )
{
(gpphDnldContext->FrameInp.Type) = phDnldNfc_ChkIntg;
}
@@ -867,20 +873,31 @@ NFCSTATUS phDnldNfc_InitImgInfo(void)
NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
uint8_t *pImageInfo = NULL;
uint16_t ImageInfoLen = 0;
+ char fwFileName[256];
+ char fwpathName[256];
+ char *pathName = NULL;
- /* if memory is not allocated then allocate memory for donwload context structure */
+ /* if memory is not allocated then allocate memory for download context structure */
phDnldNfc_SetHwDevHandle();
+ /*Read Firmware file name from config file*/
+ if (GetNxpStrValue(NAME_NXP_FW_NAME, fwFileName, sizeof (fwFileName)) == TRUE)
+ {
+ strcpy (fwpathName, FW_DLL_ROOT_DIR);
+ strncat (fwpathName, fwFileName, strlen (fwFileName));
+ pathName = fwpathName;
+ }
+
/* load the library and get the image info pointer */
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (gRecFWDwnld == TRUE)
- wStatus = phDnldNfc_LoadRecoveryFW (FW_LIB_PATH, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadRecoveryFW (pathName, &pImageInfo, &ImageInfoLen);
else
#endif
- wStatus = phDnldNfc_LoadFW (FW_LIB_PATH, &pImageInfo, &ImageInfoLen);
+ wStatus = phDnldNfc_LoadFW (pathName, &pImageInfo, &ImageInfoLen);
- NXPLOG_FWDNLD_D("FW Image Length - ImageInfoLen %d",ImageInfoLen);
- NXPLOG_FWDNLD_D("FW Image Info Pointer - pImageInfo %x",(uintptr_t)pImageInfo);
+ NXPLOG_FWDNLD_D("FW Image Length - ImageInfoLen %d", ImageInfoLen);
+ NXPLOG_FWDNLD_D("FW Image Info Pointer - pImageInfo %p", pImageInfo);
if((pImageInfo == NULL) || (ImageInfoLen == 0))
{
@@ -910,7 +927,7 @@ NFCSTATUS phDnldNfc_InitImgInfo(void)
NXPLOG_FWDNLD_D("FW Major Version Num - %x",gpphDnldContext->nxp_nfc_fw[5]);
NXPLOG_FWDNLD_D("FW Minor Version Num - %x",gpphDnldContext->nxp_nfc_fw[4]);
NXPLOG_FWDNLD_D("FW Image Length - %d",ImageInfoLen);
- NXPLOG_FWDNLD_D("FW Image Info Pointer - %x",(uintptr_t)pImageInfo);
+ NXPLOG_FWDNLD_D("FW Image Info Pointer - %p", pImageInfo);
/* get the FW version */
wFwVer = (((uint16_t)(gpphDnldContext->nxp_nfc_fw[5]) << 8U) | (gpphDnldContext->nxp_nfc_fw[4]));
@@ -947,7 +964,7 @@ NFCSTATUS phDnldNfc_LoadRecInfo(void)
/* if memory is not allocated then allocate memory for donwload context structure */
phDnldNfc_SetHwDevHandle();
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (gRecFWDwnld == TRUE)
wStatus = phDnldNfc_LoadRecoveryFW (PLATFORM_LIB_PATH, &pImageInfo, &ImageInfoLen);
else
@@ -973,7 +990,7 @@ NFCSTATUS phDnldNfc_LoadRecInfo(void)
if((NULL != gpphDnldContext->nxp_nfc_fwp) && (0 != gpphDnldContext->nxp_nfc_fwp_len))
{
NXPLOG_FWDNLD_D("Recovery Image Length - %d",ImageInfoLen);
- NXPLOG_FWDNLD_D("Recovery Image Info Pointer - %x",(uintptr_t)pImageInfo);
+ NXPLOG_FWDNLD_D("Recovery Image Info Pointer - %p", pImageInfo);
wStatus = NFCSTATUS_SUCCESS;
}
else
@@ -1008,7 +1025,7 @@ NFCSTATUS phDnldNfc_LoadPKInfo(void)
phDnldNfc_SetHwDevHandle();
/* load the PKU image library */
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (gRecFWDwnld == TRUE)
wStatus = phDnldNfc_LoadRecoveryFW (PKU_LIB_PATH, &pImageInfo, &ImageInfoLen);
else
@@ -1034,7 +1051,7 @@ NFCSTATUS phDnldNfc_LoadPKInfo(void)
if((NULL != gpphDnldContext->nxp_nfc_fwp) && (0 != gpphDnldContext->nxp_nfc_fwp_len))
{
NXPLOG_FWDNLD_D("PKU Image Length - %d",ImageInfoLen);
- NXPLOG_FWDNLD_D("PKU Image Info Pointer - %x",(uintptr_t)pImageInfo);
+ NXPLOG_FWDNLD_D("PKU Image Info Pointer - %p",pImageInfo);
wStatus = NFCSTATUS_SUCCESS;
}
else
@@ -1092,19 +1109,16 @@ NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t **pImgInfo, uint16_t* p
{
void* pImageInfo = NULL;
void* pImageInfoLen = NULL;
-
-#if(NFC_NXP_CHIP_TYPE != PN547C2)
- /* check for path name */
if(pathName == NULL)
{
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
pathName = "/system/vendor/firmware/libpn548ad_fw.so";
- }
+#elif(NFC_NXP_CHIP_TYPE == PN551)
+ pathName = "/system/vendor/firmware/libpn551_fw.so";
#else
- if(pathName == NULL)
- {
pathName = "/system/vendor/firmware/libpn547_fw.so";
- }
#endif
+ }
/* check if the handle is not NULL then free the library */
if(pFwLibHandle != NULL)
@@ -1148,7 +1162,7 @@ NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t **pImgInfo, uint16_t* p
return NFCSTATUS_SUCCESS;
}
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
/*******************************************************************************
**
** Function phDnldNfc_LoadRecoveryFW
@@ -1172,7 +1186,13 @@ NFCSTATUS phDnldNfc_LoadRecoveryFW (const char* pathName, uint8_t **pImgInfo, ui
/* check for path name */
if (pathName == NULL)
{
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
pathName = "/system/vendor/firmware/libpn548ad_fw.so";
+#elif(NFC_NXP_CHIP_TYPE == PN551)
+ pathName = "/system/vendor/firmware/libpn551_fw.so";
+#else
+ pathName = "/system/vendor/firmware/libpn547_fw.so";
+#endif
}
/* check if the handle is not NULL then free the library */
diff --git a/halimpl/pn54x/dnld/phDnldNfc.h b/halimpl/pn54x/dnld/phDnldNfc.h
index 331d39b..40a0577 100644
--- a/halimpl/pn54x/dnld/phDnldNfc.h
+++ b/halimpl/pn54x/dnld/phDnldNfc.h
@@ -42,6 +42,8 @@ typedef void (*pphDnldNfc_RspCb_t)(void* pContext, NFCSTATUS wStatus,void* pInfo
#define PHDNLDNFC_HWVER_MRA2_2 (0x05U) /* ChipVersion MRA2.2 */
#define PHDNLDNFC_HWVER_PN548AD_MRA1_0 (0x08U) /* PN548AD ChipVersion MRA1.0 */
+
+#define PHDNLDNFC_HWVER_PN551_MRA1_0 (0x08U) /* PN551 ChipVersion MRA1.0 */
/*
* Enum definition contains Download Life Cycle States
*/
@@ -104,7 +106,7 @@ extern NFCSTATUS phDnldNfc_LoadRecInfo(void);
extern NFCSTATUS phDnldNfc_LoadPKInfo(void);
extern void phDnldNfc_CloseFwLibHandle(void);
extern NFCSTATUS phDnldNfc_LoadFW(const char* pathName, uint8_t **pImgInfo, uint16_t* pImgInfoLen);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
extern NFCSTATUS phDnldNfc_LoadRecoveryFW (const char* pathName, uint8_t **pImgInfo, uint16_t* pImgInfoLen);
#endif
extern NFCSTATUS phDnldNfc_UnloadFW(void);
diff --git a/halimpl/pn54x/dnld/phDnldNfc_Internal.c b/halimpl/pn54x/dnld/phDnldNfc_Internal.c
index e97dd2f..6e8b0f4 100644
--- a/halimpl/pn54x/dnld/phDnldNfc_Internal.c
+++ b/halimpl/pn54x/dnld/phDnldNfc_Internal.c
@@ -52,19 +52,23 @@
#define PHDNLDNFC_USERDATA_EEPROM_OFFSIZE (0x02U) /* size of EEPROM offset */
#ifdef NXP_PN547C1_DOWNLOAD
-/* EEPROM offset and length value for C1 */
+/* EEPROM offset and length value for PN547C1 */
#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x003CU) /* 16 bits offset indicating user data area start location */
#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0DC0U) /* 16 bits length of user data area */
#else
-#if(NFC_NXP_CHIP_TYPE == PN547C2)
-/* EEPROM offset and length value for C2 */
-#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x023CU) /* 16 bits offset indicating user data area start location */
-#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0C80U) /* 16 bits length of user data area */
-#else
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
/* EEPROM offset and length value for PN548AD */
#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x02BCU) /* 16 bits offset indicating user data area start location */
#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0C00U) /* 16 bits length of user data area */
+#elif(NFC_NXP_CHIP_TYPE == PN551)
+/* EEPROM offset and length value for PN551 */
+#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x02BCU) /* 16 bits offset indicating user data area start location */
+#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0C00U) /* 16 bits length of user data area */
+#else
+/* EEPROM offset and length value for PN547C2 */
+#define PHDNLDNFC_USERDATA_EEPROM_OFFSET (0x023CU) /* 16 bits offset indicating user data area start location */
+#define PHDNLDNFC_USERDATA_EEPROM_LEN (0x0C80U) /* 16 bits length of user data area */
#endif
#endif
@@ -700,7 +704,11 @@ static NFCSTATUS phDnldNfc_BuildFramePkt(pphDnldNfc_DlContext_t pDlContext)
wFrameLen += PHDNLDNFC_FRAME_HDR_LEN;
}
}
-
+ if (wFrameLen > PHDNLDNFC_CMDRESP_MAX_BUFF_SIZE)
+ {
+ NXPLOG_FWDNLD_D ("wFrameLen exceeds the limit");
+ return NFCSTATUS_FAILED;
+ }
/* calculate CRC16 */
wCrcVal = phDnldNfc_CalcCrc16((pDlContext->tCmdRspFrameInfo.aFrameBuff),wFrameLen);
diff --git a/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c b/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
index 40e7f36..cd7583d 100644
--- a/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
+++ b/halimpl/pn54x/dnld/phNxpNciHal_Dnld.c
@@ -35,7 +35,7 @@
/* External global variable to get FW version */
extern uint16_t wFwVer;
extern uint16_t wMwVer;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
extern uint8_t gRecFWDwnld;
#endif
/* RF Configuration structure */
@@ -181,7 +181,7 @@ static NFCSTATUS (*phNxpNciHal_dwnld_seqhandler[])(
NULL
};
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
/* Array of pointers to start dummy fw download seq */
static NFCSTATUS (*phNxpNciHal_dummy_rec_dwnld_seqhandler[])(
void* pContext, NFCSTATUS status, void* pInfo) = {
@@ -564,8 +564,13 @@ static void phNxpNciHal_fw_dnld_get_version_cb(void* pContext,
bHwVer = (pRespBuff->pBuff[0]);
bHwVer &= 0x0F; /* 0x0F is the mask to extract chip version */
- if ((PHDNLDNFC_HWVER_MRA2_1 == bHwVer) || (PHDNLDNFC_HWVER_MRA2_2 == bHwVer) ||
- (PHDNLDNFC_HWVER_PN548AD_MRA1_0 == bHwVer))
+ if ((PHDNLDNFC_HWVER_MRA2_1 == bHwVer) || (PHDNLDNFC_HWVER_MRA2_2 == bHwVer)
+#if(NFC_NXP_CHIP_TYPE == PN551)
+ || (PHDNLDNFC_HWVER_PN551_MRA1_0 == bHwVer)
+#elif(NFC_NXP_CHIP_TYPE == PN548C2)
+ || (PHDNLDNFC_HWVER_PN548AD_MRA1_0 == bHwVer)
+#endif
+ )
{
bExpectedLen = PHLIBNFC_IOCTL_DNLD_GETVERLEN_MRA2_1;
(gphNxpNciHal_fw_IoctlCtx.bChipVer) = bHwVer;
@@ -1876,7 +1881,7 @@ NFCSTATUS phNxpNciHal_fw_download_seq(uint8_t bClkSrcVal, uint8_t bClkFreqVal)
if (NFCSTATUS_SUCCESS == phDnldNfc_InitImgInfo())
{
NXPLOG_FWDNLD_D("phDnldNfc_InitImgInfo:SUCCESS");
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (gRecFWDwnld == TRUE)
{
status = phNxpNciHal_fw_seq_handler (phNxpNciHal_dummy_rec_dwnld_seqhandler);
@@ -1910,8 +1915,13 @@ static
NFCSTATUS
phLibNfc_VerifyCrcStatus(uint8_t bCrcStatus)
{
+#if(NFC_NXP_CHIP_TYPE == PN551)
+ uint8_t bBitPos = 1;
+ uint8_t bShiftVal = 2;
+#else
uint8_t bBitPos = 0;
uint8_t bShiftVal = 1;
+#endif
NFCSTATUS wStatus = NFCSTATUS_SUCCESS;
while(bBitPos < 7)
{
diff --git a/halimpl/pn54x/hal/phNxpNciHal.c b/halimpl/pn54x/hal/phNxpNciHal.c
index 944b7b3..f3bc10a 100644
--- a/halimpl/pn54x/hal/phNxpNciHal.c
+++ b/halimpl/pn54x/hal/phNxpNciHal.c
@@ -33,6 +33,7 @@
/* Processing of ISO 15693 EOF */
extern uint8_t icode_send_eof;
+extern uint8_t icode_detected;
static uint8_t cmd_icode_eof[] = { 0x00, 0x00, 0x00 };
/* FW download success flag */
@@ -58,15 +59,17 @@ extern uint16_t rom_version;
extern int send_to_upper_kovio;
extern int kovio_detected;
extern int disable_kovio;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
extern uint8_t gRecFWDwnld;
static uint8_t gRecFwRetryCount; //variable to hold dummy FW recovery count
#endif
static uint8_t Rx_data[NCI_MAX_DATA_LEN];
+
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
uint8_t discovery_cmd[50] = { 0 };
uint8_t discovery_cmd_len = 0;
+#endif
extern bool_t rf_deactive_cmd;
-
uint32_t timeoutTimerId = 0;
phNxpNciHal_Sem_t config_data;
@@ -74,7 +77,7 @@ phNxpNciClock_t phNxpNciClock={0,};
phNxpNciRfSetting_t phNxpNciRfSet={0,};
-phNxpNciMwEepromArea_t phNxpNciMwEepromArea = {0};
+phNxpNciMwEepromArea_t phNxpNciMwEepromArea = {0,};
/**************** local methods used in this file only ************************/
static NFCSTATUS phNxpNciHal_fw_download(void);
@@ -98,7 +101,7 @@ static NFCSTATUS phNxpNciHal_set_mw_eeprom (void);
static int phNxpNciHal_fw_mw_ver_check ();
NFCSTATUS phNxpNciHal_check_clock_config(void);
NFCSTATUS phNxpNciHal_china_tianjin_rf_setting(void);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
static NFCSTATUS phNxpNciHalRFConfigCmdRecSequence ();
static NFCSTATUS phNxpNciHal_CheckRFCmdRespStatus ();
#endif
@@ -304,7 +307,11 @@ static NFCSTATUS phNxpNciHal_fw_download(void)
static NFCSTATUS phNxpNciHal_CheckValidFwVersion(void)
{
NFCSTATUS status = NFCSTATUS_NOT_ALLOWED;
+#if(NFC_NXP_CHIP_TYPE == PN551)
+ const unsigned char sfw_mobile_major_no = 0x05;
+#else
const unsigned char sfw_mobile_major_no = 0x01;
+#endif
const unsigned char sfw_infra_major_no = 0x02;
unsigned char ufw_current_major_no = 0x00;
unsigned long num = 0;
@@ -344,7 +351,7 @@ static NFCSTATUS phNxpNciHal_CheckValidFwVersion(void)
NXPLOG_NCIHAL_D("Firmware download not allowed (NXP_FW_PROTECION_OVERRIDE not defiend)");
}
}
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
else if (gRecFWDwnld == TRUE)
{
status = NFCSTATUS_SUCCESS;
@@ -441,13 +448,14 @@ int phNxpNciHal_open(nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p
NFCSTATUS wConfigStatus = NFCSTATUS_SUCCESS;
NFCSTATUS status = NFCSTATUS_SUCCESS;
/*NCI_INIT_CMD*/
- static uint8_t cmd_init_nci[] = {0x20,0x01,0x00};
+ static uint8_t cmd_init_nci[] = {0x20, 0x01, 0x00};
/*NCI_RESET_CMD*/
- static uint8_t cmd_reset_nci[] = {0x20,0x00,0x01,0x01};
+ static uint8_t cmd_reset_nci[] = {0x20, 0x00, 0x01, 0x00};
/* reset config cache */
resetNxpConfig();
- int init_retry_cnt=0;
+ int init_retry_cnt= 0;
+ int8_t ret_val = 0x00;
/* initialize trace level */
phNxpLog_InitializeLogLevel();
@@ -496,8 +504,10 @@ int phNxpNciHal_open(nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p
tOsalConfig.pLogFile = NULL;
tTmlConfig.dwGetMsgThreadId = (uintptr_t) nxpncihal_ctrl.gDrvCfg.nClientId;
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
memset (discovery_cmd, 0, sizeof(discovery_cmd));
discovery_cmd_len = 0;
+#endif
/* Initialize TML layer */
wConfigStatus = phTmlNfc_Init(&tTmlConfig);
@@ -519,11 +529,13 @@ int phNxpNciHal_open(nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&nxpncihal_ctrl.client_thread, &attr,
- phNxpNciHal_client_thread, &nxpncihal_ctrl) != 0)
+ ret_val = pthread_create (&nxpncihal_ctrl.client_thread, &attr,
+ phNxpNciHal_client_thread, &nxpncihal_ctrl);
+ pthread_attr_destroy (&attr);
+ if (ret_val != 0)
{
- NXPLOG_NCIHAL_E("pthread_create failed");
- wConfigStatus = phTmlNfc_Shutdown();
+ NXPLOG_NCIHAL_E ("pthread_create failed");
+ wConfigStatus = phTmlNfc_Shutdown ();
goto clean_and_return;
}
@@ -609,6 +621,12 @@ force_download:
if (NFCSTATUS_SUCCESS != phNxpNciHal_fw_mw_ver_check ())
{
NXPLOG_NCIHAL_D ("Chip Version Middleware Version mismatch!!!!");
+ /* Abort any pending read and write */
+ phNxpNciHal_send_ext_cmd (sizeof (cmd_reset_nci), cmd_reset_nci);
+ phTmlNfc_ReadAbort ();
+ phTmlNfc_WriteAbort ();
+ phTmlNfc_Shutdown ();
+ wConfigStatus = NFCSTATUS_FAILED;
goto clean_and_return;
}
NXPLOG_NCIHAL_E ("FW Download failed - NFCC init will continue");
@@ -673,8 +691,11 @@ force_download:
int phNxpNciHal_fw_mw_ver_check()
{
NFCSTATUS status = NFCSTATUS_FAILED;
-
- if (!strcmp (COMPILATION_MW, "PN548C2") && (rom_version == 0x10) && (fw_maj_ver == 0x01))
+ if(!strcmp (COMPILATION_MW, "PN551") && (rom_version == 0x10) && (fw_maj_ver == 0x05))
+ {
+ status = NFCSTATUS_SUCCESS;
+ }
+ else if (!strcmp (COMPILATION_MW, "PN548C2") && (rom_version == 0x10) && (fw_maj_ver == 0x01))
{
status = NFCSTATUS_SUCCESS;
}
@@ -736,7 +757,11 @@ int phNxpNciHal_write(uint16_t data_len, const uint8_t *p_data)
/* Create local copy of cmd_data */
memcpy(nxpncihal_ctrl.p_cmd_data, p_data, data_len);
nxpncihal_ctrl.cmd_len = data_len;
-
+ if (nxpncihal_ctrl.cmd_len > NCI_MAX_DATA_LEN)
+ {
+ NXPLOG_NCIHAL_D ("cmd_len exceeds limit NCI_MAX_DATA_LEN");
+ goto clean_and_return;
+ }
#ifdef P2P_PRIO_LOGIC_HAL_IMP
/* Specific logic to block RF disable when P2P priority logic is busy */
if (p_data[0] == 0x21&&
@@ -953,15 +978,20 @@ static void phNxpNciHal_read_complete(void *pContext, phTmlNfc_TransactInfo_t *p
phNxpNciHal_print_res_status(nxpncihal_ctrl.p_rx_data, &nxpncihal_ctrl.rx_data_len);
/* Check if response should go to hal module only */
if (nxpncihal_ctrl.hal_ext_enabled == 1
- && (nxpncihal_ctrl.p_rx_data[0x00] & 0x40) == 0x40)
+ && (nxpncihal_ctrl.p_rx_data[0x00] & 0xF0) == 0x40)
{
if(status == NFCSTATUS_FAILED)
{
NXPLOG_NCIHAL_D("enter into NFCC init recovery");
nxpncihal_ctrl.ext_cb_data.status = status;
}
- /* Unlock semaphore */
- SEM_POST(&(nxpncihal_ctrl.ext_cb_data));
+ /* Unlock semaphore only for responses*/
+ if ((nxpncihal_ctrl.p_rx_data[0x00] & 0xF0) == 0x40 ||
+ ((icode_detected == TRUE) &&(icode_send_eof == 3)))
+ {
+ /* Unlock semaphore */
+ SEM_POST (&(nxpncihal_ctrl.ext_cb_data));
+ }
}
/* Read successful send the event to higher layer */
else if ((nxpncihal_ctrl.p_nfc_stack_data_cback != NULL) &&
@@ -1037,9 +1067,9 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params)
long retlen = 0;
int isfound;
/* Temp fix to re-apply the proper clock setting */
- int temp_fix = 1;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+ int temp_fix = 1;
unsigned long num = 0;
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
//initialize dummy FW recovery variables
gRecFwRetryCount = 0;
gRecFWDwnld = 0;
@@ -1204,7 +1234,7 @@ retry_core_init:
retlen = 0;
fw_download_success = 0;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
NXPLOG_NCIHAL_D ("Performing TVDD Settings");
isfound = GetNxpNumValue(NAME_NXP_EXT_TVDD_CFG, &num, sizeof(num));
if (isfound > 0) {
@@ -1251,7 +1281,7 @@ retry_core_init:
}
#endif
retlen = 0;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
config_access = FALSE;
#endif
NXPLOG_NCIHAL_D ("Performing RF Settings BLK 1");
@@ -1259,7 +1289,7 @@ retry_core_init:
bufflen, &retlen);
if (retlen > 0) {
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1286,7 +1316,7 @@ retry_core_init:
bufflen, &retlen);
if (retlen > 0) {
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1313,7 +1343,7 @@ retry_core_init:
bufflen, &retlen);
if (retlen > 0) {
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1340,7 +1370,7 @@ retry_core_init:
bufflen, &retlen);
if (retlen > 0) {
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1367,7 +1397,7 @@ retry_core_init:
bufflen, &retlen);
if (retlen > 0) {
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1394,7 +1424,7 @@ retry_core_init:
bufflen, &retlen);
if (retlen > 0) {
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1415,7 +1445,7 @@ retry_core_init:
}
}
retlen = 0;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
config_access = TRUE;
#endif
NXPLOG_NCIHAL_D ("Performing NAME_NXP_CORE_CONF_EXTN Settings");
@@ -1446,7 +1476,7 @@ retry_core_init:
}
retlen = 0;
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
config_access = FALSE;
#endif
isfound = GetNxpByteArrayValue(NAME_NXP_CORE_RF_FIELD,
@@ -1454,7 +1484,7 @@ retry_core_init:
if (retlen > 0) {
/* NXP ACT Proprietary Ext */
status = phNxpNciHal_send_ext_cmd(retlen, buffer);
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
if (status == NFCSTATUS_SUCCESS)
{
status = phNxpNciHal_CheckRFCmdRespStatus ();
@@ -1474,12 +1504,12 @@ retry_core_init:
goto retry_core_init;
}
}
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
config_access = TRUE;
#endif
-#if(NFC_NXP_CHIP_TYPE != PN547C2)
- retlen = 0;
+ retlen = 0;
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
/* NXP SWP switch timeout Setting*/
if(GetNxpNumValue(NAME_NXP_SWP_SWITCH_TIMEOUT, (void *)&retlen, sizeof(retlen)))
{
@@ -1488,24 +1518,24 @@ retry_core_init:
{
if( 0 < retlen)
{
- uint16_t timeout = retlen * 1000;
- uint16_t timeoutHx = 0x0000;
+ unsigned int timeout = retlen * 1000;
+ unsigned int timeoutHx = 0x0000;
- uint8_t buffer[10];
- snprintf ( buffer, 10, "%04x", timeout );
- sscanf (buffer,"%x",&timeoutHx);
+ char tmpbuffer[10] = {0};
+ snprintf ((char*)tmpbuffer, 10, "%04x", timeout);
+ sscanf ((char*)tmpbuffer,"%x", &timeoutHx);
swp_switch_timeout_cmd[7]= (timeoutHx & 0xFF);
- swp_switch_timeout_cmd[8]= ((timeoutHx & 0xFF00) >> 8);
+ swp_switch_timeout_cmd[8]= ((timeoutHx & 0xFF00) >> 8);
}
status = phNxpNciHal_send_ext_cmd (sizeof(swp_switch_timeout_cmd),
swp_switch_timeout_cmd);
if (status != NFCSTATUS_SUCCESS)
{
- NXPLOG_NCIHAL_E("SWP switch timeout Setting Failed");
- retry_core_init_cnt++;
- goto retry_core_init;
+ NXPLOG_NCIHAL_E ("SWP switch timeout Setting Failed");
+ retry_core_init_cnt++;
+ goto retry_core_init;
}
}
else
@@ -1710,9 +1740,10 @@ retry_core_init:
if(p_core_init_rsp_params[35] > 0)
{ //if length of last command is 0 then it doesn't need to send last command.
if( !(((p_core_init_rsp_params[36] == 0x21) && (p_core_init_rsp_params[37] == 0x03))
- && (*(p_core_init_rsp_params + 1) == 1))&&
- !((p_core_init_rsp_params[36] == 0x21) && (p_core_init_rsp_params[37] == 0x06)))
- //if last command is discovery and RF staus is also discovery state, then it doesn't need to execute.
+ && (*(p_core_init_rsp_params + 1) == 1)) &&
+ !((p_core_init_rsp_params[36] == 0x21) && (p_core_init_rsp_params[37] == 0x06) && (p_core_init_rsp_params[39] == 0x00) &&(*(p_core_init_rsp_params + 1) == 0x00)))
+ //if last command is discovery and RF status is also discovery state, then it doesn't need to execute or similarly
+ // if the last command is deactivate to idle and RF status is also idle , no need to execute the command .
{
tmp_len = p_core_init_rsp_params[35];
@@ -1722,6 +1753,11 @@ retry_core_init:
nxpncihal_ctrl.p_rsp_data);
if (status != NFCSTATUS_SUCCESS)
{
+ if (buffer)
+ {
+ free (buffer);
+ buffer = NULL;
+ }
/* Do not send packet to PN54X, send response directly */
msg.eMsgType = NCI_HAL_RX_MSG;
msg.pMsgData = NULL;
@@ -1753,7 +1789,7 @@ retry_core_init:
free(buffer);
buffer = NULL;
}
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
//initialize dummy FW recovery variables
gRecFWDwnld = 0;
gRecFwRetryCount = 0;
@@ -1781,7 +1817,7 @@ invoke_callback:
#endif
return NFCSTATUS_SUCCESS;
}
-#if(NFC_NXP_CHIP_TYPE == PN548C2)
+#if(NFC_NXP_CHIP_TYPE != PN547C2)
/******************************************************************************
* Function phNxpNciHal_CheckRFCmdRespStatus
*
@@ -2528,14 +2564,14 @@ int check_config_parameter()
void phNxpNciHal_enable_i2c_fragmentation()
{
NFCSTATUS status = NFCSTATUS_FAILED;
- static uint8_t fragmentation_enable_config_cmd[] = { 0x20, 0x02, 0x05, 0x01, 0xA0, 0x05, 0x01, 0x10};
+ static uint8_t fragmentation_enable_config_cmd[] = {0x20, 0x02, 0x05, 0x01, 0xA0, 0x05, 0x01, 0x10};
int isfound = 0;
long i2c_status = 0x00;
long config_i2c_vlaue = 0xff;
/*NCI_RESET_CMD*/
- static uint8_t cmd_reset_nci[] = {0x20,0x00,0x01,0x01};
+ static uint8_t cmd_reset_nci[] = {0x20, 0x00, 0x01, 0x00};
/*NCI_INIT_CMD*/
- static uint8_t cmd_init_nci[] = {0x20,0x01,0x00};
+ static uint8_t cmd_init_nci[] = {0x20, 0x01, 0x00};
static uint8_t get_i2c_fragmentation_cmd[] = {0x20, 0x03, 0x03, 0x01 ,0xA0 ,0x05};
isfound = (GetNxpNumValue(NAME_NXP_I2C_FRAGMENTATION_ENABLED, (void *)&i2c_status, sizeof(i2c_status)));
status = phNxpNciHal_send_ext_cmd(sizeof(get_i2c_fragmentation_cmd),get_i2c_fragmentation_cmd);
@@ -2732,6 +2768,7 @@ static void phNxpNciHal_print_res_status( uint8_t *p_rx_data, uint16_t *p_len)
}
}
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
NFCSTATUS phNxpNciHal_core_reset_recovery ()
{
NFCSTATUS status = NFCSTATUS_FAILED;
@@ -2792,6 +2829,7 @@ retry_core_init:
retry_core_init_cnt++;
goto retry_core_init;
}
+
return NFCSTATUS_SUCCESS;
FAILURE:
abort ();
@@ -2806,3 +2844,4 @@ void phNxpNciHal_discovery_cmd_ext (uint8_t *p_cmd_data, uint16_t cmd_len)
discovery_cmd_len = cmd_len;
}
}
+#endif
diff --git a/halimpl/pn54x/hal/phNxpNciHal.h b/halimpl/pn54x/hal/phNxpNciHal.h
index ba094c9..8aa7303 100644
--- a/halimpl/pn54x/hal/phNxpNciHal.h
+++ b/halimpl/pn54x/hal/phNxpNciHal.h
@@ -129,7 +129,8 @@ typedef struct phNxpNciProfile_Control
void phNxpNciHal_request_control (void);
void phNxpNciHal_release_control (void);
int phNxpNciHal_write_unlocked (uint16_t data_len, const uint8_t *p_data);
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
NFCSTATUS phNxpNciHal_core_reset_recovery ();
void phNxpNciHal_discovery_cmd_ext (uint8_t *p_cmd_data, uint16_t cmd_len);
-
+#endif
#endif /* _PHNXPNCIHAL_H_ */
diff --git a/halimpl/pn54x/hal/phNxpNciHal_NfcDepSWPrio.c b/halimpl/pn54x/hal/phNxpNciHal_NfcDepSWPrio.c
index a2f51be..e1b6dab 100644
--- a/halimpl/pn54x/hal/phNxpNciHal_NfcDepSWPrio.c
+++ b/halimpl/pn54x/hal/phNxpNciHal_NfcDepSWPrio.c
@@ -129,12 +129,13 @@ static NFCSTATUS phNxpNciHal_stop_polling_loop()
discover_type = STOP_POLLING;
pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if(pthread_create(&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ if (pthread_create (&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
{
- NXPLOG_NCIHAL_E("phNxpNciHal_resume_polling_loop");
+ NXPLOG_NCIHAL_E("fail to create pthread");
}
+ pthread_attr_destroy (&attr);
return status;
}
@@ -155,12 +156,13 @@ static NFCSTATUS phNxpNciHal_resume_polling_loop()
discover_type = RESUME_POLLING;
pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if(pthread_create(&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ if (pthread_create (&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
{
- NXPLOG_NCIHAL_E("phNxpNciHal_resume_polling_loop");
+ NXPLOG_NCIHAL_E("fail to create pthread");
}
+ pthread_attr_destroy (&attr);
return status;
}
@@ -181,12 +183,13 @@ NFCSTATUS phNxpNciHal_start_polling_loop()
discover_type = START_POLLING;
pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if(pthread_create(&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ if (pthread_create (&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
{
- NXPLOG_NCIHAL_E("phNxpNciHal_resume_polling_loop");
+ NXPLOG_NCIHAL_E("fail to create pthread");
}
+ pthread_attr_destroy (&attr);
return status;
}
@@ -578,13 +581,13 @@ NFCSTATUS phNxpNciHal_select_RF_Discovery(unsigned int RfID,unsigned int RfProto
cmd_select_rf_discovery[4]=RfProtocolType;
pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if(pthread_create(&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ if (pthread_create (&pthread, &attr, tmp_thread, (void*) &discover_type) != 0)
{
- NXPLOG_NCIHAL_E("phNxpNciHal_resume_polling_loop");
+ NXPLOG_NCIHAL_E("fail to create pthread");
}
-
+ pthread_attr_destroy (&attr);
return status;
}
/*******************************************************************************
diff --git a/halimpl/pn54x/hal/phNxpNciHal_ext.c b/halimpl/pn54x/hal/phNxpNciHal_ext.c
index 19ed71f..893f986 100644
--- a/halimpl/pn54x/hal/phNxpNciHal_ext.c
+++ b/halimpl/pn54x/hal/phNxpNciHal_ext.c
@@ -34,9 +34,11 @@ extern int kovio_detected;
extern int disable_kovio;
extern int send_to_upper_kovio;
extern uint32_t cleanup_timer;
-static uint8_t icode_detected = 0x00;
+uint8_t icode_detected = 0x00;
uint8_t icode_send_eof = 0x00;
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
uint8_t nfcdep_detected = 0x00;
+#endif
static uint8_t ee_disc_done = 0x00;
uint8_t EnableP2P_PrioLogic = FALSE;
static uint32_t RfDiscID = 1;
@@ -165,10 +167,12 @@ NFCSTATUS phNxpNciHal_process_ext_rsp (uint8_t *p_ntf, uint16_t *p_len)
if (p_ntf[0] == 0x61 &&
p_ntf[1] == 0x05)
{
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
if (nfcdep_detected)
{
nfcdep_detected = 0x00;
}
+#endif
switch (p_ntf[4])
{
@@ -183,7 +187,9 @@ NFCSTATUS phNxpNciHal_process_ext_rsp (uint8_t *p_ntf, uint16_t *p_len)
break;
case 0x03:
NXPLOG_NCIHAL_D("NxpNci: RF Interface = NFC-DEP");
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
nfcdep_detected = 0x01;
+#endif
break;
case 0x80:
NXPLOG_NCIHAL_D("NxpNci: RF Interface = MIFARE");
@@ -296,8 +302,6 @@ NFCSTATUS phNxpNciHal_process_ext_rsp (uint8_t *p_ntf, uint16_t *p_len)
icode_send_eof == 2)
{
icode_send_eof = 3;
- status = NFCSTATUS_FAILED;
- return status;
}
else if (p_ntf[0] == 0x00 &&
p_ntf[1] == 0x00 &&
@@ -398,6 +402,7 @@ NFCSTATUS phNxpNciHal_process_ext_rsp (uint8_t *p_ntf, uint16_t *p_len)
else if(p_ntf[0] == 0x60 && p_ntf[1] == 0x00)
{
NXPLOG_NCIHAL_E ("CORE_RESET_NTF received!");
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
if ( nfcdep_detected &&
!(p_ntf[2] == 0x06 && p_ntf[3] == 0xA0 && p_ntf[4] == 0x00
&& ((p_ntf[5] == 0xC9 && p_ntf[6] == 0x95
@@ -407,6 +412,7 @@ NFCSTATUS phNxpNciHal_process_ext_rsp (uint8_t *p_ntf, uint16_t *p_len)
{
nfcdep_detected = 0x00;
}
+#endif
phNxpNciHal_emergency_recovery ();
status = NFCSTATUS_FAILED;
return status;
@@ -676,7 +682,7 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t *cmd_len, uint8_t *p_cmd_data,
*cmd_len = 8;
}
}
-#if(NFC_NXP_CHIP_TYPE == PN547C2)
+
if (retval == 0x01 &&
p_cmd_data[0] == 0x21 &&
p_cmd_data[1] == 0x00)
@@ -691,9 +697,7 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t *cmd_len, uint8_t *p_cmd_data,
status = NFCSTATUS_SUCCESS;
NXPLOG_NCIHAL_D ("Going through extns - Adding Mifare in RF Discovery - END");
}
- else
-#endif
- if (p_cmd_data[3] == 0x81 &&
+ else if (p_cmd_data[3] == 0x81 &&
p_cmd_data[4] == 0x01 &&
p_cmd_data[5] == 0x03)
{
@@ -743,8 +747,10 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t *cmd_len, uint8_t *p_cmd_data,
NXPLOG_NCIHAL_D ("> Polling Loop Started");
icode_detected = 0;
icode_send_eof = 0;
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
// Cache discovery cmd for recovery
phNxpNciHal_discovery_cmd_ext (p_cmd_data, *cmd_len);
+#endif
}
//22000100
else if (p_cmd_data[0] == 0x22 &&
diff --git a/halimpl/pn54x/libnfc-nxp-PN547C2_example.conf b/halimpl/pn54x/libnfc-nxp-PN547C2_example.conf
index b383474..913030f 100644
--- a/halimpl/pn54x/libnfc-nxp-PN547C2_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN547C2_example.conf
@@ -29,9 +29,8 @@ MIFARE_READER_ENABLE=0x01
# Vzw Feature enable
VZW_FEATURE_ENABLE=0x01
###############################################################################
-
-# File location for Firmware
-#FW_STORAGE="/vendor/firmware/libpn547_fw.so"
+# File name for Firmware
+NXP_FW_NAME="libpn547_fw.so"
###############################################################################
# System clock source selection configuration
@@ -53,7 +52,7 @@ NXP_SYS_CLK_FREQ_SEL=0x00
###############################################################################
# The timeout value to be used for clock request acknowledgment
-# min value = 0x01 to max = 0x19
+# min value = 0x01 to max = 0x06
NXP_SYS_CLOCK_TO_CFG=0x01
@@ -127,7 +126,7 @@ NXP_CORE_CONF_EXTN={20, 02, 16, 04,
}
###############################################################################
-# Core configuration rf field filter settings to enable set 01 ,to disable set to 00 last bit
+# Core configuration rf field filter settings to enable set to 01 to disable set to 00 last bit
NXP_CORE_RF_FIELD={ 20, 02, 05, 01, A0, 62, 01, 01
}
@@ -198,10 +197,12 @@ DEFAULT_DESFIRE_ROUTE=0x02
# UICC 0x02
DEFAULT_MIFARE_CLT_ROUTE=0x02
-###############################################################################
-#Chip type
+##############################################################################
+#### Select the CHIP ####
#PN547C2 0x01
#PN65T 0x02
+#PN548AD 0x03
+#PN66T 0x04
NXP_NFC_CHIP=0x01
diff --git a/halimpl/pn54x/libnfc-nxp-PN548AD_example.conf b/halimpl/pn54x/libnfc-nxp-PN548AD_example.conf
index 637448d..53121b2 100644
--- a/halimpl/pn54x/libnfc-nxp-PN548AD_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN548AD_example.conf
@@ -30,8 +30,8 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File location for Firmware
-#FW_STORAGE="/vendor/firmware/libpn548_fw.so"
+# File name for Firmware
+NXP_FW_NAME="libpn548ad_fw.so"
###############################################################################
# System clock source selection configuration
@@ -53,7 +53,7 @@ NXP_SYS_CLK_FREQ_SEL=0x02
###############################################################################
# The timeout value to be used for clock request acknowledgment
-# min value = 0x01 to max = 0x1A
+# min value = 0x01 to max = 0x06
NXP_SYS_CLOCK_TO_CFG=0x01
@@ -141,16 +141,17 @@ NXP_EXT_TVDD_CFG_3={20, 02, 0B, 02, A0, 66, 01, 01, A0, 0E, 03, 52, 64, 0A}
# Low Power mode A007
# Clock settings A002, A003
# PbF settings A008
-NXP_CORE_CONF_EXTN={20, 02, 15, 05,
+NXP_CORE_CONF_EXTN={20, 02, 19, 06,
A0, EC, 01, 01,
A0, ED, 01, 00,
A0, 5E, 01, 01,
A0, 40, 01, 01,
- A0, DD, 01, 2D
+ A0, DD, 01, 2D,
+ A0, 96, 01, 01
}
###############################################################################
-# Core configuration rf field filter settings to enable set 01 ,to disable set to 00 last bit
+# Core configuration rf field filter settings to enable set to 01 to disable set to 00 last bit
NXP_CORE_RF_FIELD={ 20, 02, 05, 01, A0, 62, 01, 01
}
@@ -160,16 +161,17 @@ NXP_I2C_FRAGMENTATION_ENABLED=0x00
###############################################################################
# Core configuration settings
-NXP_CORE_CONF={ 20, 02, 2B, 0D,
+NXP_CORE_CONF={ 20, 02, 2E, 0E,
28, 01, 00,
21, 01, 00,
30, 01, 08,
31, 01, 03,
+ 32, 01, 60,
+ 38, 01, 01,
33, 04, 01, 02, 03, 04,
54, 01, 06,
50, 01, 02,
5B, 01, 00,
- 60, 01, 0E,
80, 01, 01,
81, 01, 01,
82, 01, 0E,
diff --git a/halimpl/pn54x/libnfc-nxp-PN551_example.conf b/halimpl/pn54x/libnfc-nxp-PN551_example.conf
new file mode 100644
index 0000000..ba42b20
--- /dev/null
+++ b/halimpl/pn54x/libnfc-nxp-PN551_example.conf
@@ -0,0 +1,273 @@
+## This file is used by NFC NXP NCI HAL(external/libnfc-nci/halimpl/pn54x)
+## and NFC Service Java Native Interface Extensions (packages/apps/Nfc/nci/jni/extns/pn54x)
+
+###############################################################################
+# Application options
+# Logging Levels
+# NXPLOG_DEFAULT_LOGLEVEL 0x01
+# ANDROID_LOG_DEBUG 0x03
+# ANDROID_LOG_WARN 0x02
+# ANDROID_LOG_ERROR 0x01
+# ANDROID_LOG_SILENT 0x00
+#
+NXPLOG_EXTNS_LOGLEVEL=0x03
+NXPLOG_NCIHAL_LOGLEVEL=0x03
+NXPLOG_NCIX_LOGLEVEL=0x03
+NXPLOG_NCIR_LOGLEVEL=0x03
+NXPLOG_FWDNLD_LOGLEVEL=0x03
+NXPLOG_TML_LOGLEVEL=0x03
+
+###############################################################################
+# Nfc Device Node name
+NXP_NFC_DEV_NODE="/dev/pn544"
+
+###############################################################################
+# Extension for Mifare reader enable
+MIFARE_READER_ENABLE=0x01
+
+###############################################################################
+# Vzw Feature enable
+VZW_FEATURE_ENABLE=0x01
+
+###############################################################################
+# File name for Firmware
+NXP_FW_NAME="libpn551_fw.so"
+
+###############################################################################
+# System clock source selection configuration
+#define CLK_SRC_XTAL 1
+#define CLK_SRC_PLL 2
+
+NXP_SYS_CLK_SRC_SEL=0x02
+
+###############################################################################
+# System clock frequency selection configuration
+#define CLK_FREQ_13MHZ 1
+#define CLK_FREQ_19_2MHZ 2
+#define CLK_FREQ_24MHZ 3
+#define CLK_FREQ_26MHZ 4
+#define CLK_FREQ_38_4MHZ 5
+#define CLK_FREQ_52MHZ 6
+
+NXP_SYS_CLK_FREQ_SEL=0x02
+
+###############################################################################
+# The timeout value to be used for clock request acknowledgment
+# min value = 0x01 to max = 0x06
+
+NXP_SYS_CLOCK_TO_CFG=0x06
+
+###############################################################################
+# NXP proprietary settings
+NXP_ACT_PROP_EXTN={2F, 02, 00}
+
+###############################################################################
+# NFC forum profile settings
+NXP_NFC_PROFILE_EXTN={20, 02, 05, 01, A0, 44, 01, 00}
+
+###############################################################################
+# NFCC Configuration Control
+# Allow NFCC to manage RF Config 0x01
+# Don't allow NFCC to manage RF Config 0x00
+NXP_NFC_MERGE_RF_PARAMS={20, 02, 04, 01, 85, 01, 01}
+
+###############################################################################
+# Standby enable settings
+#NXP_CORE_STANDBY={2F, 00, 01, 01}
+
+###############################################################################
+# NXP TVDD configurations settings
+# Allow NFCC to configure External TVDD, There are currently three
+#configurations (1, 2 and 3) are supported, out of them only one can be
+#supported.
+
+NXP_EXT_TVDD_CFG=0x01
+
+###############################################################################
+#config1:SLALM, 3.3V for both RM and CM
+NXP_EXT_TVDD_CFG_1={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 02, 09, 00}
+
+###############################################################################
+#config2: use DCDC in CE, use Tx_Pwr_Req, set CFG2 mode, SLALM,
+#monitoring 5V from DCDC, 3.3V for both RM and CM, DCDCWaitTime=4.2ms
+NXP_EXT_TVDD_CFG_2={20, 02, 0B, 02, A0, 66, 01, 00, A0, 0E, 03, 56, 24, 08 }
+
+###############################################################################
+#config3: use DCDC in CE, use Tx_Pwr_Req, SLALM, monitoring 5V from DCDC,
+#DCDCWaitTime=4.2ms
+NXP_EXT_TVDD_CFG_3={20, 02, 0B, 02, A0, 66, 01, 01, A0, 0E, 03, 52, 40, 0A}
+
+###############################################################################
+# NXP RF configuration ALM/PLM settings
+# This section needs to be updated with the correct values based on the platform
+#NXP_RF_CONF_BLK_1={
+#}
+
+###############################################################################
+# NXP RF configuration ALM/PLM settings
+# This section needs to be updated with the correct values based on the platform
+#NXP_RF_CONF_BLK_2={
+#}
+
+###############################################################################
+# NXP RF configuration ALM/PLM settings
+# This section needs to be updated with the correct values based on the platform
+#NXP_RF_CONF_BLK_3={
+#}
+
+###############################################################################
+# NXP RF configuration ALM/PLM settings
+# This section needs to be updated with the correct values based on the platform
+#NXP_RF_CONF_BLK_4={
+#}
+
+###############################################################################
+# NXP RF configuration ALM/PLM settings
+# This section needs to be updated with the correct values based on the platform
+#NXP_RF_CONF_BLK_5={
+#}
+
+###############################################################################
+# NXP RF configuration ALM/PLM settings
+# This section needs to be updated with the correct values based on the platform
+#NXP_RF_CONF_BLK_6={
+#}
+
+###############################################################################
+# Core configuration extensions
+# It includes
+# Wired mode settings A0ED, A0EE
+# Tag Detector A040, A041, A043
+# Low Power mode A007
+# Clock settings A002, A003
+# PbF settings A008
+NXP_CORE_CONF_EXTN={20, 02, 19, 06,
+ A0, EC, 01, 01,
+ A0, ED, 01, 00,
+ A0, 5E, 01, 01,
+ A0, 40, 01, 01,
+ A0, DD, 01, 2D,
+ A0, 96, 01, 01
+ }
+
+###############################################################################
+# Core configuration rf field filter settings to enable set to 01 to disable set to 00 last bit
+NXP_CORE_RF_FIELD={ 20, 02, 05, 01, A0, 62, 01, 01
+ }
+
+###############################################################################
+# To enable i2c fragmentation set i2c fragmentation enable 0x01 to disable set to 0x00
+NXP_I2C_FRAGMENTATION_ENABLED=0x00
+
+###############################################################################
+# Core configuration settings
+NXP_CORE_CONF={ 20, 02, 2E, 0E,
+ 28, 01, 00,
+ 21, 01, 00,
+ 30, 01, 08,
+ 31, 01, 03,
+ 32, 01, 60,
+ 38, 01, 01,
+ 33, 04, 01, 02, 03, 04,
+ 54, 01, 06,
+ 50, 01, 02,
+ 5B, 01, 00,
+ 80, 01, 01,
+ 81, 01, 01,
+ 82, 01, 0E,
+ 18, 01, 01
+ }
+
+###############################################################################
+# Mifare Classic Key settings
+#NXP_CORE_MFCKEY_SETTING={20, 02, 25,04, A0, 51, 06, A0, A1, A2, A3, A4, A5,
+# A0, 52, 06, D3, F7, D3, F7, D3, F7,
+# A0, 53, 06, FF, FF, FF, FF, FF, FF,
+# A0, 54, 06, 00, 00, 00, 00, 00, 00}
+
+###############################################################################
+# Default SE Options
+# No secure element 0x00
+# eSE 0x01
+# UICC 0x02
+
+NXP_DEFAULT_SE=0x03
+
+###############################################################################
+#Enable SWP full power mode when phone is power off
+NXP_SWP_FULL_PWR_ON=0x00
+
+###############################################################################
+#### Select the CHIP ####
+#PN547C2 0x01
+#PN65T 0x02
+#PN548AD 0x03
+#PN66T 0x04
+#PN551 0x05
+#PN67T 0x06
+
+NXP_NFC_CHIP=0x05
+
+###############################################################################
+# CE when Screen state is locked
+# Disable 0x00
+# Enable 0x01
+NXP_CE_ROUTE_STRICT_DISABLE=0x01
+
+###############################################################################
+#Timeout in secs to get NFCEE Discover notification
+NXP_DEFAULT_NFCEE_DISC_TIMEOUT=20
+
+NXP_DEFAULT_NFCEE_TIMEOUT=0x06
+
+###############################################################################
+#Timeout in secs
+NXP_SWP_RD_START_TIMEOUT=0x0A
+
+###############################################################################
+#Timeout in secs
+NXP_SWP_RD_TAG_OP_TIMEOUT=0x01
+
+###############################################################################
+#Set the default AID route Location :
+#This settings will be used when application does not set this parameter
+# host 0x00
+# eSE 0x01
+# UICC 0x02
+DEFAULT_AID_ROUTE=0x00
+
+###############################################################################
+#Set the Mifare Desfire route Location :
+#This settings will be used when application does not set this parameter
+# host 0x00
+# eSE 0x01
+# UICC 0x02
+DEFAULT_DESFIRE_ROUTE=0x02
+
+###############################################################################
+#Set the Mifare CLT route Location :
+#This settings will be used when application does not set this parameter
+# host 0x00
+# eSE 0x01
+# UICC 0x02
+DEFAULT_MIFARE_CLT_ROUTE=0x02
+
+###############################################################################
+# AID Matching platform options
+# AID_MATCHING_L 0x01
+# AID_MATCHING_K 0x02
+AID_MATCHING_PLATFORM=0x01
+
+###############################################################################
+#CHINA_TIANJIN_RF_SETTING
+#Enable 0x01
+#Disable 0x00
+NXP_CHINA_TIANJIN_RF_ENABLED=0x01
+
+###############################################################################
+#SWP_SWITCH_TIMEOUT_SETTING
+# Allowed range of swp timeout setting is 0x00 to 0x3C [0 - 60].
+# Timeout in milliseconds, for example
+# No Timeout 0x00
+# 10 millisecond timeout 0x0A
+NXP_SWP_SWITCH_TIMEOUT=0x0A
diff --git a/halimpl/pn54x/libnfc-nxp-PN65T_example.conf b/halimpl/pn54x/libnfc-nxp-PN65T_example.conf
index a1fec14..317776c 100644
--- a/halimpl/pn54x/libnfc-nxp-PN65T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN65T_example.conf
@@ -30,8 +30,8 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File location for Firmware
-#FW_STORAGE="/vendor/firmware/libpn547_fw.so"
+# File name for Firmware
+NXP_FW_NAME="libpn547_fw.so"
###############################################################################
# System clock source selection configuration
@@ -53,7 +53,7 @@ NXP_SYS_CLK_FREQ_SEL=0x00
###############################################################################
# The timeout value to be used for clock request acknowledgment
-# min value = 0x01 to max = 0x19
+# min value = 0x01 to max = 0x06
NXP_SYS_CLOCK_TO_CFG=0x01
diff --git a/halimpl/pn54x/libnfc-nxp-PN66T_example.conf b/halimpl/pn54x/libnfc-nxp-PN66T_example.conf
index 269c49a..d63881f 100644
--- a/halimpl/pn54x/libnfc-nxp-PN66T_example.conf
+++ b/halimpl/pn54x/libnfc-nxp-PN66T_example.conf
@@ -29,8 +29,8 @@ MIFARE_READER_ENABLE=0x01
VZW_FEATURE_ENABLE=0x01
###############################################################################
-# File location for Firmware
-#FW_STORAGE="/vendor/firmware/libpn548_fw.so"
+# File name for Firmware
+NXP_FW_NAME="libpn548ad_fw.so"
###############################################################################
# System clock source selection configuration
@@ -52,9 +52,9 @@ NXP_SYS_CLK_FREQ_SEL=0x02
###############################################################################
# The timeout value to be used for clock request acknowledgment
-# min value = 0x01 to max = 0x1A
+# min value = 0x01 to max = 0x06
-NXP_SYS_CLOCK_TO_CFG=0x1A
+NXP_SYS_CLOCK_TO_CFG=0x01
###############################################################################
# NXP proprietary settings
@@ -162,16 +162,17 @@ NXP_I2C_FRAGMENTATION_ENABLED=0x00
###############################################################################
# Core configuration settings
-NXP_CORE_CONF={ 20, 02, 2B, 0D,
+NXP_CORE_CONF={ 20, 02, 2E, 0E,
28, 01, 00,
21, 01, 00,
30, 01, 08,
31, 01, 03,
+ 32, 01, 60,
+ 38, 01, 01,
33, 04, 01, 02, 03, 04,
54, 01, 06,
50, 01, 02,
5B, 01, 00,
- 60, 01, 0E,
80, 01, 01,
81, 01, 01,
82, 01, 0E,
diff --git a/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c b/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c
index 97a2a15..7f5bc12 100644
--- a/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c
+++ b/halimpl/pn54x/self-test/phNxpNciHal_SelfTest.c
@@ -81,13 +81,13 @@ NFCSTATUS phNxpNciHal_getPrbsCmd (uint8_t tech, uint8_t bitrate, uint8_t *prbs_c
static nci_test_data_t swp2_test_data[] = {
{
{
- 0x04, {0x20,0x00,0x01,0x01} /* cmd */
+ 0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
},
{
#if(NFC_NXP_CHIP_TYPE != PN547C2)
- 0x06, {0x40,0x00,0x03,0x00,0x11,0x01} /* exp_rsp */
+ 0x06, {0x40, 0x00, 0x03, 0x00, 0x11, 0x00} /* exp_rsp */
#else
- 0x06, {0x40,0x00,0x03,0x00,0x10,0x01} /* exp_rsp */
+ 0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00} /* exp_rsp */
#endif
},
{
@@ -151,13 +151,13 @@ static nci_test_data_t swp1_test_data[] = {
{
{
- 0x04, {0x20,0x00,0x01,0x01} /* cmd */
+ 0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
},
{
#if(NFC_NXP_CHIP_TYPE != PN547C2)
- 0x06, {0x40,0x00,0x03,0x00,0x11,0x01} /* exp_rsp */
+ 0x06, {0x40, 0x00, 0x03, 0x00, 0x11, 0x00} /* exp_rsp */
#else
- 0x06, {0x40,0x00,0x03,0x00,0x10,0x01} /* exp_rsp */
+ 0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00} /* exp_rsp */
#endif
},
{
@@ -479,13 +479,13 @@ static nci_test_data_t rf_field_off_test_data[] = {
static nci_test_data_t download_pin_test_data1[] = {
{
{
- 0x04, {0x20,0x00,0x01,0x01} /* cmd */
+ 0x04, {0x20, 0x00, 0x01, 0x00} /* cmd */
},
{
#if(NFC_NXP_CHIP_TYPE != PN547C2)
- 0x06, {0x40,0x00,0x03,0x00,0x11,0x01} /* exp_rsp */
+ 0x06, {0x40, 0x00, 0x03, 0x00, 0x11, 0x00} /* exp_rsp */
#else
- 0x06, {0x40,0x00,0x03,0x00,0x10,0x01} /* exp_rsp */
+ 0x06, {0x40, 0x00, 0x03, 0x00, 0x10, 0x00} /* exp_rsp */
#endif
},
{
@@ -1070,49 +1070,55 @@ static void hal_read_cb(void *pContext, phTmlNfc_TransactInfo_t *pInfo)
NXPLOG_NCIHAL_E("Response timer stop ERROR!!!");
p_cb_data->status = NFCSTATUS_FAILED;
}
-
- if (pInfo->wStatus == NFCSTATUS_SUCCESS)
+ if (pInfo == NULL)
{
- NXPLOG_NCIHAL_D("hal_read_cb successful status = 0x%x", pInfo->wStatus);
- p_cb_data->status = NFCSTATUS_SUCCESS;
+ NXPLOG_NCIHAL_E ("Empty TransactInfo");
+ p_cb_data->status = NFCSTATUS_FAILED;
}
else
{
- NXPLOG_NCIHAL_E("hal_read_cb error status = 0x%x", pInfo->wStatus);
- p_cb_data->status = NFCSTATUS_FAILED;
- }
+ if (pInfo->wStatus == NFCSTATUS_SUCCESS)
+ {
+ NXPLOG_NCIHAL_D ("hal_read_cb successful status = 0x%x", pInfo->wStatus);
+ p_cb_data->status = NFCSTATUS_SUCCESS;
+ }
+ else
+ {
+ NXPLOG_NCIHAL_E ("hal_read_cb error status = 0x%x", pInfo->wStatus);
+ p_cb_data->status = NFCSTATUS_FAILED;
+ }
- p_cb_data->status = pInfo->wStatus;
+ p_cb_data->status = pInfo->wStatus;
+ nci_test_data_t *test_data = (nci_test_data_t*) p_cb_data->pContext;
- nci_test_data_t *test_data = (nci_test_data_t*) p_cb_data->pContext;
+ if (test_data->exp_rsp.len == 0)
+ {
+ /* Compare the actual notification with expected notification.*/
+ if(test_data->ntf_validator (&(test_data->exp_ntf), pInfo) == 1 )
+ {
+ p_cb_data->status = NFCSTATUS_SUCCESS;
+ }
+ else
+ {
+ p_cb_data->status = NFCSTATUS_FAILED;
+ }
+ }
- if(test_data->exp_rsp.len == 0)
- {
- /* Compare the actual notification with expected notification.*/
- if( test_data->ntf_validator(&(test_data->exp_ntf),pInfo) == 1 )
+ /* Compare the actual response with expected response.*/
+ else if (test_data->rsp_validator (&(test_data->exp_rsp), pInfo) == 1)
{
p_cb_data->status = NFCSTATUS_SUCCESS;
}
else
{
p_cb_data->status = NFCSTATUS_FAILED;
-
}
- }
- /* Compare the actual response with expected response.*/
- else if( test_data->rsp_validator(&(test_data->exp_rsp),pInfo) == 1)
- {
- p_cb_data->status = NFCSTATUS_SUCCESS;
- }
- else
- {
- p_cb_data->status = NFCSTATUS_FAILED;
+ test_data->exp_rsp.len = 0;
}
- test_data->exp_rsp.len = 0;
}
- SEM_POST(p_cb_data);
+ SEM_POST (p_cb_data);
return;
}
@@ -1389,7 +1395,7 @@ NFCSTATUS phNxpNciHal_TestMode_open (void)
const uint16_t max_len = 260;
NFCSTATUS status = NFCSTATUS_SUCCESS;
uint16_t read_len = 255;
-
+ int8_t ret_val = 0x00;
/* initialize trace level */
phNxpLog_InitializeLogLevel();
@@ -1442,10 +1448,12 @@ NFCSTATUS phNxpNciHal_TestMode_open (void)
}
pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&test_rx_thread, &attr,
- phNxpNciHal_test_rx_thread, NULL) != 0)
+ pthread_attr_init (&attr);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ ret_val = pthread_create (&test_rx_thread, &attr,
+ phNxpNciHal_test_rx_thread, NULL);
+ pthread_attr_destroy (&attr);
+ if (ret_val != 0)
{
NXPLOG_NCIHAL_E("pthread_create failed");
phTmlNfc_Shutdown();
diff --git a/halimpl/pn54x/tml/phDal4Nfc_messageQueueLib.c b/halimpl/pn54x/tml/phDal4Nfc_messageQueueLib.c
index e19eaca..d09aa42 100644
--- a/halimpl/pn54x/tml/phDal4Nfc_messageQueueLib.c
+++ b/halimpl/pn54x/tml/phDal4Nfc_messageQueueLib.c
@@ -94,7 +94,7 @@ void phDal4Nfc_msgrelease(intptr_t msqid)
if(pQueue != NULL)
{
sem_post(&pQueue->nProcessSemaphore);
- usleep(300000);
+ usleep (3000);
if (sem_destroy(&pQueue->nProcessSemaphore))
{
NXPLOG_TML_E("Failed to destroy semaphore (errno=0x%08x)", errno);
diff --git a/halimpl/pn54x/tml/phTmlNfc.c b/halimpl/pn54x/tml/phTmlNfc.c
index e2ee759..e50b49e 100644
--- a/halimpl/pn54x/tml/phTmlNfc.c
+++ b/halimpl/pn54x/tml/phTmlNfc.c
@@ -42,7 +42,7 @@ static uint8_t bCurrentRetryCount = (2000 / PHTMLNFC_MAXTIME_RETRANSMIT) + 1;
/* Initialize Context structure pointer used to access context structure */
phTmlNfc_Context_t *gpphTmlNfc_Context = NULL;
-extern phTmlNfc_i2cfragmentation_t fragmentation_enabled = I2C_FRAGMENATATION_DISABLED;
+phTmlNfc_i2cfragmentation_t fragmentation_enabled = I2C_FRAGMENATATION_DISABLED;
/* Local Function prototypes */
static NFCSTATUS phTmlNfc_StartThread(void);
static void phTmlNfc_CleanUp(void);
@@ -112,7 +112,7 @@ NFCSTATUS phTmlNfc_Init(pphTmlNfc_Config_t pConfig)
if (NFCSTATUS_SUCCESS != wInitStatus)
{
wInitStatus = PHNFCSTVAL(CID_NFC_TML, NFCSTATUS_INVALID_DEVICE);
- gpphTmlNfc_Context->pDevHandle = (void *) NFCSTATUS_INVALID_DEVICE;
+ gpphTmlNfc_Context->pDevHandle = NULL;
}
else
{
@@ -356,7 +356,7 @@ static void phTmlNfc_TmlThread(void *pParam)
dwNoBytesWrRd = PH_TMLNFC_RESET_VALUE;
/* Read the data from the file onto the buffer */
- if (NFCSTATUS_INVALID_DEVICE != (uintptr_t)gpphTmlNfc_Context->pDevHandle)
+ if (NULL != gpphTmlNfc_Context->pDevHandle)
{
NXPLOG_TML_D("PN54X - Invoking I2C Read.....\n");
dwNoBytesWrRd = phTmlNfc_i2c_read(gpphTmlNfc_Context->pDevHandle, temp, 260);
@@ -366,6 +366,11 @@ static void phTmlNfc_TmlThread(void *pParam)
NXPLOG_TML_E("PN54X - Error in I2C Read.....\n");
sem_post(&gpphTmlNfc_Context->rxSemaphore);
}
+ else if (dwNoBytesWrRd > 260)
+ {
+ NXPLOG_TML_E ("Numer of bytes read exceeds the limit 260.....\n");
+ sem_post (&gpphTmlNfc_Context->rxSemaphore);
+ }
else
{
memcpy(gpphTmlNfc_Context->tReadInfo.pBuffer, temp, dwNoBytesWrRd);
@@ -416,7 +421,7 @@ static void phTmlNfc_TmlThread(void *pParam)
}
else
{
- NXPLOG_TML_D("PN54X - NFCSTATUS_INVALID_DEVICE == gpphTmlNfc_Context->pDevHandle");
+ NXPLOG_TML_D ("PN54X -gpphTmlNfc_Context->pDevHandle is NULL");
}
}
else
@@ -467,10 +472,9 @@ static void phTmlNfc_TmlWriterThread(void *pParam)
NXPLOG_TML_D("PN54X - Write requested.....\n");
/* Set the variable to success initially */
wStatus = NFCSTATUS_SUCCESS;
- if (NFCSTATUS_INVALID_DEVICE != (uintptr_t)gpphTmlNfc_Context->pDevHandle)
+ if (NULL != gpphTmlNfc_Context->pDevHandle)
{
- retry:
-
+ retry:
gpphTmlNfc_Context->tWriteInfo.bEnable = 0;
/* Variable to fetch the actual number of bytes written */
dwNoBytesWrRd = PH_TMLNFC_RESET_VALUE;
@@ -550,7 +554,7 @@ static void phTmlNfc_TmlWriterThread(void *pParam)
}
else
{
- NXPLOG_TML_D("PN54X - NFCSTATUS_INVALID_DEVICE != gpphTmlNfc_Context->pDevHandle");
+ NXPLOG_TML_D ("PN54X - gpphTmlNfc_Context->pDevHandle is NULL");
}
/* If Data packet is sent, then NO retransmission */
diff --git a/halimpl/pn54x/tml/phTmlNfc_i2c.c b/halimpl/pn54x/tml/phTmlNfc_i2c.c
index 7add07f..d057426 100644
--- a/halimpl/pn54x/tml/phTmlNfc_i2c.c
+++ b/halimpl/pn54x/tml/phTmlNfc_i2c.c
@@ -42,6 +42,7 @@
#define NORMAL_MODE_LEN_OFFSET 2
#define FRAGMENTSIZE_MAX PHNFC_I2C_FRAGMENT_SIZE
static bool_t bFwDnldFlag = FALSE;
+extern phTmlNfc_i2cfragmentation_t fragmentation_enabled;
/*******************************************************************************
**
@@ -85,7 +86,7 @@ NFCSTATUS phTmlNfc_i2c_open_and_configure(pphTmlNfc_Config_t pConfig, void ** pL
NXPLOG_TML_D("Opening port=%s\n", pConfig->pDevName);
/* open port */
- nHandle = open((char const *)pConfig->pDevName, O_RDWR);
+ nHandle = open ((const char *)pConfig->pDevName, O_RDWR);
if (nHandle < 0)
{
NXPLOG_TML_E("_i2c_open() Failed: retval %x",nHandle);
@@ -96,10 +97,8 @@ NFCSTATUS phTmlNfc_i2c_open_and_configure(pphTmlNfc_Config_t pConfig, void ** pL
*pLinkHandle = (void*) ((intptr_t)nHandle);
/*Reset PN54X*/
- phTmlNfc_i2c_reset((void *)((intptr_t)nHandle), 1);
- usleep(100 * 1000);
phTmlNfc_i2c_reset((void *)((intptr_t)nHandle), 0);
- usleep(100 * 1000);
+ usleep(10 * 1000);
phTmlNfc_i2c_reset((void *)((intptr_t)nHandle), 1);
return NFCSTATUS_SUCCESS;
@@ -211,25 +210,32 @@ int phTmlNfc_i2c_read(void *pDevHandle, uint8_t * pBuffer, int nNbBytesToRead)
{
totalBtyesToRead = pBuffer[NORMAL_MODE_LEN_OFFSET] + NORMAL_MODE_HEADER_LEN;
}
- ret_Read = read((intptr_t)pDevHandle, (pBuffer + numRead), totalBtyesToRead - numRead);
- if (ret_Read > 0)
- {
- numRead += ret_Read;
- }
- else if (ret_Read == 0)
+ if ((totalBtyesToRead - numRead) != 0)
{
- NXPLOG_TML_E("_i2c_read() [pyld] EOF");
- return -1;
+ ret_Read = read ((intptr_t)pDevHandle, (pBuffer + numRead), totalBtyesToRead - numRead);
+ if (ret_Read > 0)
+ {
+ numRead += ret_Read;
+ }
+ else if (ret_Read == 0)
+ {
+ NXPLOG_TML_E ("_i2c_read() [pyld] EOF");
+ return -1;
+ }
+ else
+ {
+ if (FALSE == bFwDnldFlag)
+ {
+ NXPLOG_TML_E ("_i2c_read() [hdr] received");
+ phNxpNciHal_print_packet ("RECV", pBuffer, NORMAL_MODE_HEADER_LEN);
+ }
+ NXPLOG_TML_E ("_i2c_read() [pyld] errno : %x",errno);
+ return -1;
+ }
}
else
{
- if(FALSE == bFwDnldFlag)
- {
- NXPLOG_TML_E("_i2c_read() [hdr] received");
- phNxpNciHal_print_packet("RECV",pBuffer, NORMAL_MODE_HEADER_LEN);
- }
- NXPLOG_TML_E("_i2c_read() [pyld] errno : %x",errno);
- return -1;
+ NXPLOG_TML_E ("_>>>>> Empty packet recieved !!");
}
}
return numRead;
diff --git a/halimpl/pn54x/tml/phTmlNfc_i2c.h b/halimpl/pn54x/tml/phTmlNfc_i2c.h
index 724a2bd..a74e615 100644
--- a/halimpl/pn54x/tml/phTmlNfc_i2c.h
+++ b/halimpl/pn54x/tml/phTmlNfc_i2c.h
@@ -29,4 +29,3 @@ int phTmlNfc_i2c_read(void *pDevHandle, uint8_t * pBuffer, int nNbBytesToRead);
int phTmlNfc_i2c_write(void *pDevHandle,uint8_t * pBuffer, int nNbBytesToWrite);
int phTmlNfc_i2c_reset(void *pDevHandle,long level);
bool_t getDownloadFlag(void);
-phTmlNfc_i2cfragmentation_t fragmentation_enabled;
diff --git a/halimpl/pn54x/utils/phNxpConfig.h b/halimpl/pn54x/utils/phNxpConfig.h
index f733501..a6aa299 100644
--- a/halimpl/pn54x/utils/phNxpConfig.h
+++ b/halimpl/pn54x/utils/phNxpConfig.h
@@ -65,6 +65,7 @@ int updateNxpConfigTimestamp();
#define NAME_MIFARE_READER_ENABLE "MIFARE_READER_ENABLE"
#define NAME_FW_STORAGE "FW_STORAGE"
#define NAME_NXP_NFC_DEV_NODE "NXP_NFC_DEV_NODE"
+#define NAME_NXP_FW_NAME "NXP_FW_NAME"
#define NAME_NXP_FW_PROTECION_OVERRIDE "NXP_FW_PROTECION_OVERRIDE"
#define NAME_NXP_SYS_CLK_SRC_SEL "NXP_SYS_CLK_SRC_SEL"
#define NAME_NXP_SYS_CLK_FREQ_SEL "NXP_SYS_CLK_FREQ_SEL"
diff --git a/halimpl/pn54x/utils/phNxpNciHal_utils.c b/halimpl/pn54x/utils/phNxpNciHal_utils.c
index 86be571..c6f3448 100644
--- a/halimpl/pn54x/utils/phNxpNciHal_utils.c
+++ b/halimpl/pn54x/utils/phNxpNciHal_utils.c
@@ -22,9 +22,11 @@
#include <phNxpNciHal.h>
#include <phNxpNciHal_utils.h>
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
extern uint8_t discovery_cmd[50];
extern uint8_t discovery_cmd_len;
extern uint8_t nfcdep_detected;
+#endif
/*********************** Link list functions **********************************/
@@ -507,17 +509,19 @@ void phNxpNciHal_print_packet(const char *pString, const uint8_t *p_data,
void phNxpNciHal_emergency_recovery (void)
{
+#if(NFC_NXP_CHIP_TYPE == PN548C2)
if (nfcdep_detected && discovery_cmd_len != 0)
{
pthread_t pthread;
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create (&pthread, &attr, phNxpNciHal_core_reset_recovery, NULL) == 0)
+ if (pthread_create (&pthread, &attr, (void *)phNxpNciHal_core_reset_recovery, NULL) == 0)
{
return;
}
}
+#endif
NXPLOG_NCIHAL_E ("%s: abort()", __FUNCTION__);
abort ();
}