I am running a discovery loop using the NFC reader library on an IMX7 processor. For some strange reason the loop is halting. I don't know why.
Here is my code:
bool result = false;
phStatus_t status = PHAC_DISCLOOP_LPCD_NO_TECH_DETECTED;
// Set Poll Configuration
result = (phacDiscLoop_SetConfig(m_pDiscLoop, PHAC_DISCLOOP_CONFIG_PAS_POLL_TECH_CFG,
PHAC_DISCLOOP_POS_BIT_MASK_A | PHAC_DISCLOOP_POS_BIT_MASK_B)) == PH_ERR_SUCCESS);
uint16_t stopped = 0;
// Set Discovery Poll State to Detection
result = result && (phacDiscLoop_SetConfig(m_pDiscLoop,
PHAC_DISCLOOP_POLL_STATE_DETECTION) == PH_ERR_SUCCESS);
std::cout << "discovery loop" << std::endl;
// Start discovery loop
status = phacDiscLoop_Run(m_pDiscLoop, PHAC_DISCLOOP_ENTRY_POINT_POLL);
//Check if loop was stopped
result = result && (phacDiscLoop_GetConfig(m_pDiscLoop,
&stopped) == PH_ERR_SUCCESS);
std::cout << "discovery loop 2" << std::endl;
} while (((status & PH_ERR_MASK) == PHAC_DISCLOOP_NO_TECH_DETECTED) && result && !stopped);
// Reset the stop detector
phacDiscLoop_SetConfig(m_pDiscLoop, PHAC_DISCLOOP_CONFIG_STOP_DETECTION_LOOP, 0);
I put some debug statements in to help me understand where things were going wrong. I found that the phacDiscLoop_Run doesn't return after some time, and therefore I never exit the do...while loop.
What could be going wrong? I have implemented an IRQ polling in another thread.
Could it be some synchronisation or resource problem?