diff --git a/Examples/NfcrdlibEx1_DiscoveryLoop/intfs/NfcrdlibEx1_DiscoveryLoop.h b/Examples/NfcrdlibEx1_DiscoveryLoop/intfs/NfcrdlibEx1_DiscoveryLoop.h index 46c518d..3240a46 100644 --- a/Examples/NfcrdlibEx1_DiscoveryLoop/intfs/NfcrdlibEx1_DiscoveryLoop.h +++ b/Examples/NfcrdlibEx1_DiscoveryLoop/intfs/NfcrdlibEx1_DiscoveryLoop.h @@ -29,7 +29,7 @@ defined (NXPBUILD__PHHAL_HW_RC663) || \ defined (NXPBUILD__PHHAL_HW_PN7462AU) || \ defined (NXPBUILD__PHHAL_HW_PN7642) - #define PH_EXAMPLE1_LPCD_ENABLE /* If LPCD needs to be configured and used over HAL or over DiscLoop */ +// #define PH_EXAMPLE1_LPCD_ENABLE /* If LPCD needs to be configured and used over HAL or over DiscLoop */ #endif #define LISTEN_PHASE_TIME_MS 300 /* Listen Phase TIME */ diff --git a/Examples/NfcrdlibEx6_LPCD/src/phApp_Helper.c b/Examples/NfcrdlibEx6_LPCD/src/phApp_Helper.c index 99868a6..cd4f311 100644 --- a/Examples/NfcrdlibEx6_LPCD/src/phApp_Helper.c +++ b/Examples/NfcrdlibEx6_LPCD/src/phApp_Helper.c @@ -299,7 +299,7 @@ void PrintErrorInfo(phStatus_t wStatus) DEBUG_PRINTF("\t PH_COMP_OSAL"); break; default: - DEBUG_PRINTF("\t 0x%x",(wStatus & PH_COMPID_MASK)); + DEBUG_PRINTF("\t 0x%x",(wStatus & PH_COMP_MASK)); break; } @@ -368,6 +368,7 @@ void PrintErrorInfo(phStatus_t wStatus) DEBUG_PRINTF("\t 0x%x",(wStatus & PH_ERR_MASK)); break; } + DEBUG_PRINTF("\n"); } /****************************************************************************** diff --git a/Examples/NfcrdlibEx8_HCE_T4T/NfcrdlibEx8_HCE_T4T.c b/Examples/NfcrdlibEx8_HCE_T4T/NfcrdlibEx8_HCE_T4T.c index de4e3f0..d7ce645 100644 --- a/Examples/NfcrdlibEx8_HCE_T4T/NfcrdlibEx8_HCE_T4T.c +++ b/Examples/NfcrdlibEx8_HCE_T4T/NfcrdlibEx8_HCE_T4T.c @@ -25,6 +25,7 @@ /* Local headers */ #include "NfcrdlibEx8_HCE_T4T.h" +#include "phacDiscLoop.h" #ifdef NXPBUILD__PHHAL_HW_PN7462AU #include "phhalRng.h" @@ -34,6 +35,10 @@ ** Definitions *******************************************************************************/ +#define BSP_MOD 1 +#define BSP_MOD_POLL_MODE 0 +#define ENABLE_DISC_CONFIG 1 + #ifdef NXPBUILD__PHHAL_HW_RC663 # warning "This example is not supported for RC663" int main() { @@ -233,7 +238,7 @@ int main(void) return 0; } -#ifdef ENABLE_DISC_CONFIG +#if ENABLE_DISC_CONFIG /** * This function will load/configure Discovery loop with default values based on interested profile * Application can read these values from EEPROM area and load/configure Discovery loop via SetConfig @@ -499,7 +504,7 @@ uint16_t NFCForumProcess(uint16_t wEntryPoint, phStatus_t DiscLoopStatus) uint16_t wNumberOfTags = 0; uint16_t wValue; uint8_t bIndex; - uint16_t wReturnEntryPoint; + uint16_t wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN; if(wEntryPoint == PHAC_DISCLOOP_ENTRY_POINT_POLL) { @@ -673,7 +678,6 @@ uint16_t NFCForumProcess(uint16_t wEntryPoint, phStatus_t DiscLoopStatus) /* Update the Entry point to LISTEN mode. */ wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN; - } else { @@ -691,20 +695,15 @@ uint16_t NFCForumProcess(uint16_t wEntryPoint, phStatus_t DiscLoopStatus) CHECK_STATUS(status); status = phhalHw_EventWait(pHal, LISTEN_PHASE_TIME_MS); - if((status & PH_ERR_MASK) == PH_ERR_IO_TIMEOUT) - { - wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_POLL; - } - else - { - wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN; - } } else { if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_ACTIVATED_BY_PEER) { DEBUG_PRINTF (" \n Device activated in listen mode... \n"); + + /* On successful activated by Peer, switch to LISTEN mode */ + wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_POLL; } else if ((DiscLoopStatus & PH_ERR_MASK) == PH_ERR_INVALID_PARAMETER) { @@ -721,14 +720,12 @@ uint16_t NFCForumProcess(uint16_t wEntryPoint, phStatus_t DiscLoopStatus) } else { - DEBUG_ERROR_PRINT(PrintErrorInfo(status)); + DEBUG_ERROR_PRINT(PrintErrorInfo(DiscLoopStatus)); } } - - /* On successful activated by Peer, switch to LISTEN mode */ - wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_POLL; } } + return wReturnEntryPoint; } @@ -744,7 +741,7 @@ void TReaderLibrary( ) { phStatus_t status, statustmp; - uint16_t wEntryPoint; + uint16_t wEntryPoint, wConfig, *pValue; phacDiscLoop_Profile_t bProfile = PHAC_DISCLOOP_PROFILE_UNKNOWN; /* This call shall allocate secure context before calling any secure function, @@ -760,7 +757,7 @@ void TReaderLibrary( CHECK_STATUS(status); #endif /* NXPBUILD__PHHAL_HW_TARGET */ -#ifdef ENABLE_DISC_CONFIG +#if ENABLE_DISC_CONFIG #ifndef ENABLE_EMVCO_PROF bProfile = PHAC_DISCLOOP_PROFILE_NFC; #else @@ -770,13 +767,7 @@ void TReaderLibrary( LoadProfile(bProfile); #endif /* ENABLE_DISC_CONFIG */ -#define BSP_MOD 1 - #if BSP_MOD - /* Get Listen Configuration */ - status = phacDiscLoop_GetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_LIS_TECH_CFG, &bSaveLisTechCfg); - CHECK_STATUS(status); - #if BSP_MOD_POLL_MODE /* Get Poll Configuration */ status = phacDiscLoop_GetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, &bSavePollTechCfg); @@ -788,23 +779,53 @@ void TReaderLibrary( #endif /* BSP_MOD_POLL_MODE */ #endif /* BSP_MOD */ - /* Be in card emulation mode */ - while(bInfLoop) - { - /* Start in listem mode */ - wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN; + /* Get Poll Configuration */ + status = phacDiscLoop_GetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, &bSavePollTechCfg); + CHECK_STATUS(status); - /* Set Listem Configuration */ - statustmp = phacDiscLoop_SetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_LIS_TECH_CFG, bSaveLisTechCfg); - CHECK_STATUS(statustmp); + /* Get Passive Configuration */ + status = phacDiscLoop_GetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_LIS_TECH_CFG, &bSaveLisTechCfg); + CHECK_STATUS(status); + + /* Start in listem mode */ + wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN; + + /* Be in card emulation mode */ + while(bInfLoop) { +// wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN; + wConfig = wEntryPoint ? PHAC_DISCLOOP_CONFIG_PAS_LIS_TECH_CFG : PHAC_DISCLOOP_CONFIG_ACT_POLL_TECH_CFG; + pValue = wEntryPoint ? &bSaveLisTechCfg : &bSavePollTechCfg; + + /* Set Configuration */ + status = phacDiscLoop_SetConfig(pParams, wConfig, *pValue); + CHECK_STATUS(status); + + if (wEntryPoint) { + /* Set Discovery poll state to detection */ + status = phacDiscLoop_SetConfig(pParams, PHAC_DISCLOOP_CONFIG_NEXT_POLL_STATE, PHAC_DISCLOOP_POLL_STATE_DETECTION); + CHECK_STATUS(status); + + /* Switch off RF field */ + status = phhalHw_FieldOff(pHal); + CHECK_STATUS(status); + + /* Wait for field-off time-out */ + status = phhalHw_Wait(pHal, PHHAL_HW_TIME_MICROSECONDS, 5100); + CHECK_STATUS(status); + } /* Start discovery loop in listen mode */ status = phacDiscLoop_Run(pParams, wEntryPoint); - if((status & PH_ERR_MASK) != PHAC_DISCLOOP_EXTERNAL_RFOFF) - DEBUG_PRINTF("[%s|%u] Debug, Mode[Listen] State[0x%04X].\n",__FUNCTION__, __LINE__, status); + DEBUG_PRINTF("[%s|%u] Debug, Mode[%s] State[0x%04X].\n",__FUNCTION__, __LINE__, wEntryPoint ? "Listen" : "Poll", status); + + wEntryPoint = NFCForumProcess(wEntryPoint, status); + +// /* Wait for field-off time-out */ +// statustmp = phhalHw_Wait(pHal, PHHAL_HW_TIME_MICROSECONDS, 5100); +// CHECK_STATUS(statustmp); /* T4T Card Emulation mode */ - T4TCardEmulation(status); + //T4TCardEmulation(status); #if BSP_MOD_POLL_MODE /* Start in poll mode */ @@ -826,9 +847,9 @@ void TReaderLibrary( statustmp = phacDiscLoop_SetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, bSavePollTechCfg); CHECK_STATUS(statustmp); -// /* Switch off RF field */ -// statustmp = phhalHw_FieldOff(pHal); -// CHECK_STATUS(statustmp); + /* Switch off RF field */ + statustmp = phhalHw_FieldOff(pHal); + CHECK_STATUS(statustmp); /* Wait for field-off time-out */ statustmp = phhalHw_Wait(pHal, PHHAL_HW_TIME_MICROSECONDS, 5100); diff --git a/Examples/NfcrdlibEx8_HCE_T4T/intfs/NfcrdlibEx8_HCE_T4T.h b/Examples/NfcrdlibEx8_HCE_T4T/intfs/NfcrdlibEx8_HCE_T4T.h index a5f3a2a..375e809 100644 --- a/Examples/NfcrdlibEx8_HCE_T4T/intfs/NfcrdlibEx8_HCE_T4T.h +++ b/Examples/NfcrdlibEx8_HCE_T4T/intfs/NfcrdlibEx8_HCE_T4T.h @@ -73,15 +73,15 @@ (((((uint16_t)(x[0]) << 8) & 0xFF00) | (x[1])) + 2) : 0) /* Enable(1) / Disable(0) printing error/info */ -#define DETECT_ERROR 0 - -#if DETECT_ERROR - #define DEBUG_ERROR_PRINT CHECK_STATUS - #define PRINT_INFO(...) DEBUG_PRINTF(__VA_ARGS__) -#else /* DETECT_ERROR */ - #define DEBUG_ERROR_PRINT(x) - #define PRINT_INFO(...) -#endif /* DETECT_ERROR */ +//#define DETECT_ERROR 0 +// +//#if DETECT_ERROR +// #define DEBUG_ERROR_PRINT CHECK_STATUS +// #define PRINT_INFO(...) DEBUG_PRINTF(__VA_ARGS__) +//#else /* DETECT_ERROR */ +// #define DEBUG_ERROR_PRINT(x) +// #define PRINT_INFO(...) +//#endif /* DETECT_ERROR */ /* Print system critical errors (with which execution can't proceed further) * and halt the execution. */ diff --git a/Examples/NfcrdlibEx8_HCE_T4T/intfs/phApp_Init.h b/Examples/NfcrdlibEx8_HCE_T4T/intfs/phApp_Init.h index 5681739..86bd95b 100644 --- a/Examples/NfcrdlibEx8_HCE_T4T/intfs/phApp_Init.h +++ b/Examples/NfcrdlibEx8_HCE_T4T/intfs/phApp_Init.h @@ -143,7 +143,7 @@ extern phhalHw_Pn76xx_DataParams_t * pHal; /**************************************************Prints if error is detected**************************************************************/ /* Enable(1) / Disable(0) printing error/info */ -#define DETECT_ERROR 0 +#define DETECT_ERROR 1 #if DETECT_ERROR #define DEBUG_ERROR_PRINT(x) x diff --git a/Examples/NfcrdlibEx8_HCE_T4T/src/phApp_Helper.c b/Examples/NfcrdlibEx8_HCE_T4T/src/phApp_Helper.c index d5ca9e1..2e4470c 100644 --- a/Examples/NfcrdlibEx8_HCE_T4T/src/phApp_Helper.c +++ b/Examples/NfcrdlibEx8_HCE_T4T/src/phApp_Helper.c @@ -249,9 +249,9 @@ void phApp_PrintTagInfo(phacDiscLoop_Sw_DataParams_t *pDataParams, uint16_t wNum */ void PrintErrorInfo(phStatus_t wStatus) { - DEBUG_PRINTF("\n ErrorInfo Comp:"); + DEBUG_PRINTF("\t ErrorInfo Comp:"); - switch(wStatus & 0xFF00) + switch(wStatus & PH_COMP_MASK) { case PH_COMP_BAL: DEBUG_PRINTF("\t PH_COMP_BAL"); @@ -299,7 +299,7 @@ void PrintErrorInfo(phStatus_t wStatus) DEBUG_PRINTF("\t PH_COMP_OSAL"); break; default: - DEBUG_PRINTF("\t 0x%x",(wStatus & PH_COMPID_MASK)); + DEBUG_PRINTF("\t %#X",(wStatus & PH_COMP_MASK)); break; } @@ -365,9 +365,10 @@ void PrintErrorInfo(phStatus_t wStatus) DEBUG_PRINTF("\t PHAC_DISCLOOP_COLLISION_PENDING"); break; default: - DEBUG_PRINTF("\t 0x%x",(wStatus & PH_ERR_MASK)); + DEBUG_PRINTF("\t %#X", (wStatus & PH_ERR_MASK)); break; } + DEBUG_PRINTF("\n"); } /****************************************************************************** diff --git a/NxpNfcRdLib/comps/phhalHw/src/Pn5180/phhalHw_Pn5180.c b/NxpNfcRdLib/comps/phhalHw/src/Pn5180/phhalHw_Pn5180.c index b556a00..5c30daa 100644 --- a/NxpNfcRdLib/comps/phhalHw/src/Pn5180/phhalHw_Pn5180.c +++ b/NxpNfcRdLib/comps/phhalHw/src/Pn5180/phhalHw_Pn5180.c @@ -318,7 +318,7 @@ phStatus_t phhalHw_Pn5180_Init( pDataParams->bSkipSend = PH_OFF; pDataParams->bTransmited = PH_OFF; pDataParams->bMfcCryptoEnabled = PH_OFF; - pDataParams->bCardMode = PH_OFF; + pDataParams->bCardMode = PH_ON; pDataParams->bBalConnectionType = PHHAL_HW_BAL_CONNECTION_SPI; pDataParams->pRFISRCallback = &phhalHw_Pn5180_EventCallback; pDataParams->pTimerISRCallBack = &phhalHw_Pn5180_GuardTimeCallBck; diff --git a/NxpNfcRdLib/types/ph_NxpBuild_Platform.h b/NxpNfcRdLib/types/ph_NxpBuild_Platform.h index b5dbbeb..076d948 100644 --- a/NxpNfcRdLib/types/ph_NxpBuild_Platform.h +++ b/NxpNfcRdLib/types/ph_NxpBuild_Platform.h @@ -152,7 +152,7 @@ defined (NXPBUILD__PHHAL_HW_RC663) || \ defined (NXPBUILD__PHHAL_HW_PN7462AU) || \ defined (NXPBUILD__PHHAL_HW_PN7642) - #define NXPBUILD__PHAC_DISCLOOP_LPCD /**< SRC to enable LPCD is included. */ +// #define NXPBUILD__PHAC_DISCLOOP_LPCD /**< SRC to enable LPCD is included. */ #endif #ifdef NXPBUILD__PHPAL_I14443P3A_SW