When using CLRC663 NXPReaderLib 05.22.01 with FreeRTOS, after the Discovery Loop activates a Mifare Plus S/X Card, if then calling "phpalI14443p3a_ActivateCard(...)" on the already activated tag, the reader library will lock up.
The location of the lockup is at:
phOsal_Freertos.c
phStatus_t phOsal_EventPend(volatile phOsal_Event_t * eventHandle, phOsal_EventOpt_t options, phOsal_Ticks_t ticksToWait, phOsal_EventBits_t FlagsToWait, phOsal_EventBits_t *pCurrFlags) {
...
CurrentFlags = xEventGroupWaitBits(*eventHandle, FlagsToWait,
(options & E_OS_EVENT_OPT_PEND_CLEAR_ON_EXIT) >> E_OS_EVENT_OPT_POS_PEND_CLEAR_ON_EXIT,
(options & E_OS_EVENT_OPT_PEND_SET_ALL) >> E_OS_EVENT_OPT_POS_PEND_SET_ALL,
ticksToWait); // BLOCKS Forever
Since xEventGroupWaitBits is called with ticksToWait = 0xFFFF it will pretty much hang.
To hack this to bits (and to show one bad way of preventing the hang) you can modify:
"NxpNfcRdLib/comps/phhalHw/src/Rc663/phhalHw_Rc663.c"
phStatus_t phhalHw_Rc663_Exchange....
if(pDataParams->bCheckEmdErr != PH_ON || 1 ) // EVIL HACK TO IGNORE EMD Flag
{
// Force this block to run to avoid BLOCK/LOCKUP
...
}
else
{
/* EMD Suppression is requested, Special Handling required */
dwSaveReg = 0x00;
/* Set wait IRQs this required below */
bIrq0WaitFor = PHHAL_HW_RC663_BIT_RXIRQ | PHHAL_HW_RC663_BIT_HIALERTIRQ | PHHAL_HW_RC663_BIT_IDLEIRQ | PHHAL_HW_RC663_BIT_EMDIRQ;
bIrq1WaitFor = PHHAL_HW_RC663_BIT_TIMER1IRQ;
//printf("phhalHw_Rc663_CheckForEmdError(pDataParams, bIrq0WaitFor, bIrq1WaitFor, &dwMultiReg, &dwSaveReg);\n");
status = phhalHw_Rc663_CheckForEmdError(pDataParams, bIrq0WaitFor, bIrq1WaitFor, &dwMultiReg, &dwSaveReg); // <-- this call will BLOCK/LOCKUP
/* Parse Irq0 and Irq1 data */
bIrq0Reg = (uint8_t)dwMultiReg;
bIrq1Reg = (uint8_t)(dwMultiReg >> 8U);
}
Not sure if the intent is to actually lock up/block forever, or if it's a "don't do that" kinda bug, or if it truly is a bug.
Any comment?