Compare commits

...

3 Commits

Author SHA1 Message Date
fc490c00fb [Bak] 备份 2024-07-16 10:21:38 +08:00
f272362680 [Mod] 支持Poll 模式 2024-07-12 15:03:23 +08:00
aaa4dda661 [Mod] 忽略文件更新 2024-07-11 10:23:28 +08:00
11 changed files with 644 additions and 38 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.svn/
output/
.cache/

View File

@ -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 */

View File

@ -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");
}
/******************************************************************************

View File

@ -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() {
@ -127,11 +132,22 @@ phOsal_SemObj_t timerwtx; /* Used in PICC ISO 10373-6 test bench
#endif /* ISO_10373_6_PICC_TEST_BENCH */
#endif /* NXPBUILD_EX8_MANDATORY_LAYERS */
/*******************************************************************************
** Static Defines
*******************************************************************************/
/* This is used to save restore Poll Config.
* If in case application has update/change PollCfg to resolve Tech
* when Multiple Tech was detected in previous poll cycle
*/
static uint16_t bSaveLisTechCfg, bSavePollTechCfg;
/*******************************************************************************
** Prototypes
*******************************************************************************/
void pWtoxCallBck(void);
void T4TCardEmulation(phStatus_t wDiscLoop_status);
/*******************************************************************************
** Code
@ -194,7 +210,7 @@ int main(void)
RdLib.pStackBuffer = aRdLibTaskBuffer;
RdLib.priority = RDLIB_TASK_PRIO;
RdLib.stackSizeInNum = RDLIB_TASK_STACK;
phOsal_ThreadCreate(&RdLib.ThreadHandle, &RdLib, &TReaderLibrary, NULL);
phOsal_ThreadCreate(&RdLib.ThreadHandle, &RdLib, &TReaderLibrary, pDiscLoop);
phOsal_ThreadObj_t HceApp;
@ -222,6 +238,497 @@ int main(void)
return 0;
}
#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
* \param bProfile Reader Library Profile
* \note Values used below are default and is for demonstration purpose.
*/
static phStatus_t LoadProfile(phacDiscLoop_Profile_t bProfile)
{
phStatus_t status = PH_ERR_SUCCESS;
uint16_t wPasPollConfig = 0;
uint16_t wActPollConfig = 0;
uint16_t wPasLisConfig = 0;
uint16_t wActLisConfig = 0;
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEA_TAGS
wPasPollConfig |= PHAC_DISCLOOP_POS_BIT_MASK_A;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEB_TAGS
wPasPollConfig |= PHAC_DISCLOOP_POS_BIT_MASK_B;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF_TAGS
wPasPollConfig |= (PHAC_DISCLOOP_POS_BIT_MASK_F212 | PHAC_DISCLOOP_POS_BIT_MASK_F424);
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEV_TAGS
wPasPollConfig |= PHAC_DISCLOOP_POS_BIT_MASK_V;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_I18000P3M3_TAGS
wPasPollConfig |= PHAC_DISCLOOP_POS_BIT_MASK_18000P3M3;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEA_P2P_ACTIVE
wActPollConfig |= PHAC_DISCLOOP_ACT_POS_BIT_MASK_106;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF212_P2P_ACTIVE
wActPollConfig |= PHAC_DISCLOOP_ACT_POS_BIT_MASK_212;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF424_P2P_ACTIVE
wActPollConfig |= PHAC_DISCLOOP_ACT_POS_BIT_MASK_424;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEA_TARGET_PASSIVE
wPasLisConfig |= PHAC_DISCLOOP_POS_BIT_MASK_A;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF212_TARGET_PASSIVE
wPasLisConfig |= PHAC_DISCLOOP_POS_BIT_MASK_F212;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF424_TARGET_PASSIVE
wPasLisConfig |= PHAC_DISCLOOP_POS_BIT_MASK_F424;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEA_TARGET_ACTIVE
wActLisConfig |= PHAC_DISCLOOP_POS_BIT_MASK_A;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF212_TARGET_ACTIVE
wActLisConfig |= PHAC_DISCLOOP_POS_BIT_MASK_F212;
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF424_TARGET_ACTIVE
wActLisConfig |= PHAC_DISCLOOP_POS_BIT_MASK_F424;
#endif
if(bProfile == PHAC_DISCLOOP_PROFILE_NFC)
{
/* passive Bailout bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_BAIL_OUT, 0x00);
CHECK_STATUS(status);
/* Set Passive poll bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, wPasPollConfig);
CHECK_STATUS(status);
/* Set Active poll bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ACT_POLL_TECH_CFG, wActPollConfig);
CHECK_STATUS(status);
/* Set Passive listen bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_PAS_LIS_TECH_CFG, wPasLisConfig);
CHECK_STATUS(status);
/* Set Active listen bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ACT_LIS_TECH_CFG, wActLisConfig);
CHECK_STATUS(status);
/* reset collision Pending */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_COLLISION_PENDING, PH_OFF);
CHECK_STATUS(status);
/* whether anti-collision is supported or not. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ANTI_COLL, PH_ON);
CHECK_STATUS(status);
/* Poll Mode default state*/
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_NEXT_POLL_STATE, PHAC_DISCLOOP_POLL_STATE_DETECTION);
CHECK_STATUS(status);
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEA_TAGS
/* Device limit for Type A */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
/* Passive polling Tx Guard times in micro seconds. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTA_VALUE_US, 5100);
CHECK_STATUS(status);
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEB_TAGS
/* Device limit for Type B */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTB_VALUE_US, 5100);
CHECK_STATUS(status);
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEF_TAGS
/* Device limit for Type F */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEF_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
/* Guard time for Type F. This guard time is applied when Type F poll before Type B */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTFB_VALUE_US, 20400);
CHECK_STATUS(status);
/* Guard time for Type F. This guard time is applied when Type B poll before Type F */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTBF_VALUE_US, 15300);
CHECK_STATUS(status);
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEV_TAGS
/* Device limit for Type V (ISO 15693) */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEV_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTV_VALUE_US, 5200);
CHECK_STATUS(status);
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_I18000P3M3_TAGS
/* Device limit for 18000P3M3 */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_18000P3M3_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GT18000P3M3_VALUE_US, 10000);
CHECK_STATUS(status);
#endif
/* Discovery loop Operation mode */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_OPE_MODE, RD_LIB_MODE_NFC);
CHECK_STATUS(status);
}
else if(bProfile == PHAC_DISCLOOP_PROFILE_EMVCO)
{
/* EMVCO */
/* passive Bailout bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_BAIL_OUT, 0x00);
CHECK_STATUS(status);
/* passive poll bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, (PHAC_DISCLOOP_POS_BIT_MASK_A | PHAC_DISCLOOP_POS_BIT_MASK_B));
CHECK_STATUS(status);
/* Active Listen bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_PAS_LIS_TECH_CFG, 0x00);
CHECK_STATUS(status);
/* Active Listen bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ACT_LIS_TECH_CFG, 0x00);
CHECK_STATUS(status);
/* Active Poll bitmap config. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ACT_POLL_TECH_CFG, 0x00);
CHECK_STATUS(status);
/* Bool to enable LPCD feature. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ENABLE_LPCD, PH_OFF);
CHECK_STATUS(status);
/* reset collision Pending */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_COLLISION_PENDING, PH_OFF);
CHECK_STATUS(status);
/* whether anti-collision is supported or not. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ANTI_COLL, PH_ON);
CHECK_STATUS(status);
/* Poll Mode default state*/
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_NEXT_POLL_STATE, PHAC_DISCLOOP_POLL_STATE_DETECTION);
CHECK_STATUS(status);
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEA_TAGS
/* Device limit for Type A */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
/* Passive polling Tx Guard times in micro seconds. */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTA_VALUE_US, 5100);
CHECK_STATUS(status);
/* Configure FSDI for the 14443P4A tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_I3P4_FSDI, 0x08);
CHECK_STATUS(status);
/* Configure CID for the 14443P4A tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_I3P4_CID, 0x00);
CHECK_STATUS(status);
/* Configure DRI for the 14443P4A tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_I3P4_DRI, 0x00);
CHECK_STATUS(status);
/* Configure DSI for the 14443P4A tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_I3P4_DSI, 0x00);
CHECK_STATUS(status);
#endif
#ifdef NXPBUILD__PHAC_DISCLOOP_TYPEB_TAGS
/* Device limit for Type B */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_DEVICE_LIMIT, 1);
CHECK_STATUS(status);
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_GTB_VALUE_US, 5100);
CHECK_STATUS(status);
/* Configure AFI for the type B tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_AFI_REQ, 0x00);
CHECK_STATUS(status);
/* Configure FSDI for the type B tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_FSDI, 0x08);
CHECK_STATUS(status);
/* Configure CID for the type B tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_CID, 0x00);
CHECK_STATUS(status);
/* Configure DRI for the type B tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_DRI, 0x00);
CHECK_STATUS(status);
/* Configure DSI for the type B tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_DSI, 0x00);
CHECK_STATUS(status);
/* Configure Extended ATQB support for the type B tags */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEB_EXTATQB, 0x00);
CHECK_STATUS(status);
#endif
/* Configure reader library mode */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_OPE_MODE, RD_LIB_MODE_EMVCO);
CHECK_STATUS(status);
}
else
{
/* Do Nothing */
}
return status;
}
#endif /* ENABLE_DISC_CONFIG */
uint16_t NFCForumProcess(uint16_t wEntryPoint, phStatus_t DiscLoopStatus)
{
phStatus_t status;
uint16_t wTechDetected = 0;
uint16_t wNumberOfTags = 0;
uint16_t wValue;
uint8_t bIndex;
uint16_t wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN;
if(wEntryPoint == PHAC_DISCLOOP_ENTRY_POINT_POLL)
{
if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_MULTI_TECH_DETECTED)
{
DEBUG_PRINTF (" \n Multiple technology detected: \n");
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTechDetected);
CHECK_STATUS(status);
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, PHAC_DISCLOOP_POS_BIT_MASK_A))
{
DEBUG_PRINTF (" \tType A detected... \n");
}
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, PHAC_DISCLOOP_POS_BIT_MASK_B))
{
DEBUG_PRINTF (" \tType B detected... \n");
}
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, PHAC_DISCLOOP_POS_BIT_MASK_F212))
{
DEBUG_PRINTF (" \tType F detected with baud rate 212... \n");
}
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, PHAC_DISCLOOP_POS_BIT_MASK_F424))
{
DEBUG_PRINTF (" \tType F detected with baud rate 424... \n");
}
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, PHAC_DISCLOOP_POS_BIT_MASK_V))
{
DEBUG_PRINTF(" \tType V / ISO 15693 / T5T detected... \n");
}
/* Select 1st Detected Technology to Resolve*/
for(bIndex = 0; bIndex < PHAC_DISCLOOP_PASS_POLL_MAX_TECHS_SUPPORTED; bIndex++)
{
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, (1 << bIndex)))
{
/* Configure for one of the detected technology */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, (1 << bIndex));
CHECK_STATUS(status);
break;
}
}
/* Print the technology resolved */
phApp_PrintTech((1 << bIndex));
/* Set Discovery Poll State to collision resolution */
status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_NEXT_POLL_STATE, PHAC_DISCLOOP_POLL_STATE_COLLISION_RESOLUTION);
CHECK_STATUS(status);
/* Restart discovery loop in poll mode from collision resolution phase */
DiscLoopStatus = phacDiscLoop_Run(pDiscLoop, wEntryPoint);
}
if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_MULTI_DEVICES_RESOLVED)
{
/* Get Detected Technology Type */
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTechDetected);
CHECK_STATUS(status);
/* Get number of tags detected */
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_NR_TAGS_FOUND, &wNumberOfTags);
CHECK_STATUS(status);
DEBUG_PRINTF (" \n Multiple cards resolved: %d cards \n",wNumberOfTags);
phApp_PrintTagInfo(pDiscLoop, wNumberOfTags, wTechDetected);
if(wNumberOfTags > 1)
{
/* Get 1st Detected Technology and Activate device at index 0 */
for(bIndex = 0; bIndex < PHAC_DISCLOOP_PASS_POLL_MAX_TECHS_SUPPORTED; bIndex++)
{
if(PHAC_DISCLOOP_CHECK_ANDMASK(wTechDetected, (1 << bIndex)))
{
DEBUG_PRINTF("\t Activating one card...\n");
status = phacDiscLoop_ActivateCard(pDiscLoop, bIndex, 0);
break;
}
}
if(((status & PH_ERR_MASK) == PHAC_DISCLOOP_DEVICE_ACTIVATED) ||
((status & PH_ERR_MASK) == PHAC_DISCLOOP_PASSIVE_TARGET_ACTIVATED) ||
((status & PH_ERR_MASK) == PHAC_DISCLOOP_MERGED_SEL_RES_FOUND))
{
/* Get Detected Technology Type */
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTechDetected);
CHECK_STATUS(status);
phApp_PrintTagInfo(pDiscLoop, 0x01, wTechDetected);
}
else
{
PRINT_INFO("\t\tCard activation failed...\n");
}
}
/* Switch to LISTEN mode after POLL mode */
}
else if (((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_NO_TECH_DETECTED) ||
((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_NO_DEVICE_RESOLVED))
{
/* Switch to LISTEN mode after POLL mode */
}
else if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_EXTERNAL_RFON)
{
/*
* If external RF is detected during POLL, return back so that the application
* can restart the loop in LISTEN mode
*/
}
else if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_MERGED_SEL_RES_FOUND)
{
DEBUG_PRINTF (" \n Device having T4T and NFC-DEP support detected... \n");
/* Get Detected Technology Type */
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTechDetected);
CHECK_STATUS(status);
phApp_PrintTagInfo(pDiscLoop, 1, wTechDetected);
/* Switch to LISTEN mode after POLL mode */
}
else if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_DEVICE_ACTIVATED)
{
DEBUG_PRINTF (" \n Card detected and activated successfully... \n");
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_NR_TAGS_FOUND, &wNumberOfTags);
CHECK_STATUS(status);
/* Get Detected Technology Type */
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTechDetected);
CHECK_STATUS(status);
phApp_PrintTagInfo(pDiscLoop, wNumberOfTags, wTechDetected);
/* Switch to LISTEN mode after POLL mode */
}
else if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_ACTIVE_TARGET_ACTIVATED)
{
DEBUG_PRINTF (" \n Active target detected... \n");
/* Switch to LISTEN mode after POLL mode */
}
else if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_PASSIVE_TARGET_ACTIVATED)
{
DEBUG_PRINTF (" \n Passive target detected... \n");
/* Get Detected Technology Type */
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTechDetected);
CHECK_STATUS(status);
phApp_PrintTagInfo(pDiscLoop, 1, wTechDetected);
/* Switch to LISTEN mode after POLL mode */
}
else if ((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_LPCD_NO_TECH_DETECTED)
{
/* LPCD is succeed but no tag is detected. */
}
else
{
if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_FAILURE)
{
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ADDITIONAL_INFO, &wValue);
CHECK_STATUS(status);
DEBUG_ERROR_PRINT(PrintErrorInfo(wValue));
}
else
{
DEBUG_ERROR_PRINT(PrintErrorInfo(status));
}
}
/* Update the Entry point to LISTEN mode. */
wReturnEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN;
}
else
{
if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_EXTERNAL_RFOFF)
{
/*
* Enters here if in the target/card mode and external RF is not available
* Wait for LISTEN timeout till an external RF is detected.
* Application may choose to go into standby at this point.
*/
status = phhalHw_EventConsume(pHal);
CHECK_STATUS(status);
status = phhalHw_SetConfig(pHal, PHHAL_HW_CONFIG_RFON_INTERRUPT, PH_ON);
CHECK_STATUS(status);
status = phhalHw_EventWait(pHal, LISTEN_PHASE_TIME_MS);
}
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)
{
/* In case of Front end used is RC663, then listen mode is not supported.
* Switch from listen mode to poll mode. */
}
else
{
if((DiscLoopStatus & PH_ERR_MASK) == PHAC_DISCLOOP_FAILURE)
{
status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_ADDITIONAL_INFO, &wValue);
CHECK_STATUS(status);
DEBUG_ERROR_PRINT(PrintErrorInfo(wValue));
}
else
{
DEBUG_ERROR_PRINT(PrintErrorInfo(DiscLoopStatus));
}
}
}
}
return wReturnEntryPoint;
}
#if NXPBUILD_EX8_MANDATORY_LAYERS
/**
@ -233,7 +740,9 @@ void TReaderLibrary(
void *pParams
)
{
phStatus_t status;
phStatus_t status, statustmp;
uint16_t wEntryPoint, wConfig, *pValue;
phacDiscLoop_Profile_t bProfile = PHAC_DISCLOOP_PROFILE_UNKNOWN;
/* This call shall allocate secure context before calling any secure function,
* when FreeRtos trust zone is enabled.
@ -242,15 +751,110 @@ void TReaderLibrary(
PRINT_INFO("Reader Library thread started...\n");
/* Configure target mode HAL parameters */
#ifdef NXPBUILD__PHHAL_HW_TARGET
/* Initialize the setting for Listen Mode */
status = phApp_HALConfigAutoColl();
CHECK_STATUS(status);
#endif /* NXPBUILD__PHHAL_HW_TARGET */
#if ENABLE_DISC_CONFIG
#ifndef ENABLE_EMVCO_PROF
bProfile = PHAC_DISCLOOP_PROFILE_NFC;
#else
bProfile = PHAC_DISCLOOP_PROFILE_EMVCO;
#endif
/* Load selected profile for Discovery loop */
LoadProfile(bProfile);
#endif /* ENABLE_DISC_CONFIG */
#if BSP_MOD
#if BSP_MOD_POLL_MODE
/* Get Poll Configuration */
status = phacDiscLoop_GetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, &bSavePollTechCfg);
CHECK_STATUS(status);
// /* Switch off RF field */
// statustmp = phhalHw_FieldOff(pHal);
// CHECK_STATUS(statustmp);
#endif /* BSP_MOD_POLL_MODE */
#endif /* BSP_MOD */
/* Get Poll Configuration */
status = phacDiscLoop_GetConfig(pParams, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG, &bSavePollTechCfg);
CHECK_STATUS(status);
/* 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)
{
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);
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();
//T4TCardEmulation(status);
#if BSP_MOD_POLL_MODE
/* Start in poll mode */
wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_POLL;
status = PHAC_DISCLOOP_LPCD_NO_TECH_DETECTED;
/* Before polling set Discovery Poll State to Detection , as later in the code it can be changed to e.g. PHAC_DISCLOOP_POLL_STATE_REMOVAL*/
statustmp = phacDiscLoop_SetConfig(pParams, PHAC_DISCLOOP_CONFIG_NEXT_POLL_STATE, PHAC_DISCLOOP_POLL_STATE_DETECTION);
CHECK_STATUS(statustmp);
/* Start discovery loop */
status = phacDiscLoop_Run(pParams, wEntryPoint);
if((status & PH_ERR_MASK) != PHAC_DISCLOOP_NO_TECH_DETECTED)
DEBUG_PRINTF("[%s|%u] Debug, Mode[Poll] State[0x%04X].\n",__FUNCTION__, __LINE__, status);
wEntryPoint = NFCForumProcess(wEntryPoint, status);
/* Set Poll Configuration */
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);
/* Wait for field-off time-out */
statustmp = phhalHw_Wait(pHal, PHHAL_HW_TIME_MICROSECONDS, 5100);
CHECK_STATUS(statustmp);
#endif /* BSP_MOD_POLL_MODE */
}
}
@ -260,21 +864,15 @@ void TReaderLibrary(
* This function calls phceT4T_Activate() to do T4T emulation.
* Refer phceT4T_Activate() in phceT4T.h for more info.
* */
void T4TCardEmulation(void)
void T4TCardEmulation(phStatus_t wDiscLoop_status)
{
phStatus_t status = 0;
phStatus_t wDiscLoop_status = 0;
#if ISO_10373_6_PICC_TEST_BENCH
#ifdef NXPBUILD__PHHAL_HW_PN7462AU
uint16_t wCMAState = 0;
#endif /* NXPBUILD__PHHAL_HW_PN7462AU */
#endif /* ISO_10373_6_PICC_TEST_BENCH */
/* Start discovery loop in listen mode */
wDiscLoop_status = phacDiscLoop_Run(
pDiscLoop,
PHAC_DISCLOOP_ENTRY_POINT_LISTEN);
if((wDiscLoop_status & PH_ERR_MASK) == PHAC_DISCLOOP_EXTERNAL_RFOFF)
{
/* Reset SLEEP_AF state (Respond to WupA ("52")/ReqA ("26")) as Field

View File

@ -21,6 +21,8 @@
#ifndef EX8_HCE_T4T_H
#define EX8_HCE_T4T_H
#define LISTEN_PHASE_TIME_MS 300 /* Listen Phase TIME */
/* Reader library layers required for this example */
#if (defined(NXPBUILD__PHHAL_HW_PN5180) \
|| defined(NXPBUILD__PHHAL_HW_PN5190) \
@ -71,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. */
@ -149,7 +151,7 @@ void TApplication(
* ISO 14443p4mC.
* Refer phceT4T_Activate() in phceT4T.h for info.
* */
void T4TCardEmulation(void);
void T4TCardEmulation(phStatus_t wDiscLoop_status);
/**
* Reader library thread. This is the main thread which starts discovery loop

View File

@ -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

View File

@ -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");
}
/******************************************************************************

View File

@ -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;

View File

@ -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

1
compile_commands.json Symbolic link
View File

@ -0,0 +1 @@
output/compile_commands.json

1
docs/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
NxpNfcRdLib/NXP-NFCReaderLibrary-apiguide/