2022-08-17 01:52 AM
about declaration of BSP_SPI1_IRQ_Callback() in ST25NFC_Embedded_Lib_ST25R3916_1.4.0\Projects\STM32L476RG-Nucleo\Applications\X-NUCLEO-NFC06A1\FreeRTOS_polling
Dear Sir,
I am check the process flow of sample program which use FreeTROS.
I found that the function BSP_SPI1_IRQ_Callback() is declared in two place,
one is in nucleo_l476rg_bus.c, another is in plf_adaptation.c .
Could you tell me which one is used in this demo sample?
Also, in this sample code, st25r3916Isr() is called in two different place.
one is in
----------------------------------------
void nfcIsrTaskRunner(void *argument)
{
/* Infinite loop */
for(;;)
{
ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); /* Check if IRQ happen execute immediately, otherwise other execute Task meanwhile */
st25r3916Isr(); /* ISR called from main task avoid calling vTaskSuspendAll from ISR (SPI) - NFC IRQ pin is anyhow checked */
xSemaphoreGive(platformSem);
}
}
-------------------------------------------------------
another is in
--------------------------------------
__weak void BSP_SPI1_IRQ_Callback(void)
{
/* Prevent unused argument(s) compilation warning */
/* This function should be implemented by the user application.
* It is called into this driver when an event from ST25R3916 is triggered.
*/
st25r3916Isr();
}
---------------------------------------
Are there two manners used in this demo? What are the main differences for them?
Best regards
Dai Sai
Solved! Go to Solution.
2022-09-01 01:15 AM
Hi,
As the initial issue described in this post is fully solved, I would suggest to create a new post dedicated to the CRC issue on Read Multiple Block. I would recommend as well to share information about the tag manufacturer and tag model. Make sure to define a big enough rxBuf (should 1 byte for response flag + 2 bytes for CRC + blockSize * number of requested blocks). Note that the CRC is present in the buffer after the data. Also, blockNum should be 1 when requesting to read 2 blocks.
Rgds
BT
2022-08-17 06:18 PM
Dear sir
After I read code, It seems the following code is used in demo sample.
void nfcIsrTaskRunner(void *argument)
{
/* Infinite loop */
for(;;)
{
ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); /* Check if IRQ happen execute immediately, otherwise other execute Task meanwhile */
st25r3916Isr(); /* ISR called from main task avoid calling vTaskSuspendAll from ISR (SPI) - NFC IRQ pin is anyhow checked */
xSemaphoreGive(platformSem);
}
}
Also, BSP_SPI1_IRQ_Callback() that is declared in in plf_adaptation.c is used.
My understand are correct?
By the way, I have another question.
In void StartDefaultTask(void *argument), demoCycle() is called.
But I found there are several version for demoCycle(). Could you tell me the
path for demoCycle() that is used here. I want to verify demo for ISO15693.
The demo sample code ( FreeRTOS_polling ) I referred can be used for
ISO15693 by modifying platform.h only?
best regards
Dai Sai
2022-08-18 12:05 AM
Dear Sir,
May I use demoInit() and democycle() declared in T25NFC_Embedded_Lib_ST25R3916_1.4.0\Projects\STM32L476RG-Nucleo\Applications\X-NUCLEO-NFC06A1\FTM\Src\ftm_poller.c?
best regards
Dai Sai
2022-08-18 12:08 AM
Hi Dai Sai,
the actual used demoCycle() can be seen from the project you are using - worst case you can verify from map file the actual linked version.
There are various demoCycle implementations depending on the type of demo.
I think similar for the BSP_SPI1_IRQ_Callback(), the project should define which one is compiled/used. I think a different one is used whether you are compiling one of the bare-bone demos or the FreeRTOS demo.
If not clear, please ask again, a colleague of mine can have next week a look.
Best Regards, Ulysses
2022-08-18 12:38 AM
Dear Ulyssesk
thank you very much for your reply.
Because the tool ST25R3916-DISCO is not available from dealer in Japan,
I don't have compiling environment.
With my current environment, I can not confirm which implementation is used.
If possible, I hope you can give me information about these functions.
If so, we can port the driver faster.
I am porting the code for my ThreadX environment. Here I use a X-NUCLEO-NFC06A1
connecting to my SoC.
best regards
Dai Sai
2022-08-18 01:22 AM
Dear Ulyssesk,
I wrote a version for demoInit() and demoCycle() for testing the basic accessing function of ISO15693 card as following
bool rfal_demoIni(void)
{
ReturnCode err;
err = rfalNfcInitialize();
if (err == ERR_NONE)
{
discParam.compMode = RFAL_COMPLIANCE_MODE_NFC;
discParam.devLimit = 1U;
discParam.nfcfBR = RFAL_BR_212;
discParam.ap2pBR = RFAL_BR_424;
discParam.notifyCb = demoNotif;
discParam.totalDuration = 1000U;
discParam.wakeupEnabled = false;
discParam.wakeupConfigDefault = true;
discParam.techs2Find = RFAL_NFC_POLL_TECH_V;
state = DEMO_ST_START_DISCOVERY;
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////
void rfal_demoCycle(void)
{
static rfalNfcDevice *nfcDevice;
rfalNfcWorker(); /* Run RFAL worker periodically */
#if 0
/*******************************************************************************/
/* Check if USER button is pressed */
if (BSP_PB_GetState(BUTTON_USER) == GPIO_PIN_RESET)
{
discParam.wakeupEnabled = !discParam.wakeupEnabled; /* enable/disable wakeup */
state = DEMO_ST_START_DISCOVERY; /* restart loop */
platformLog("Toggling Wake Up mode %s\r\n", discParam.wakeupEnabled ? "ON" : "OFF");
/* Debounce button */
while (BSP_PB_GetState(BUTTON_USER) == GPIO_PIN_RESET);
}
#endif
discParam.wakeupEnabled = true; /* enable/disable wakeup */
state = DEMO_ST_START_DISCOVERY; /* restart loop */
//tx_thread_sleep(OS_MSECS_TO_TICKS(2000));
switch (state)
{
/*******************************************************************************/
case DEMO_ST_START_DISCOVERY:
rfalNfcDeactivate(false);
rfalNfcDiscover(&discParam);
state = DEMO_ST_DISCOVERY;
break;
/*******************************************************************************/
case DEMO_ST_DISCOVERY:
if (rfalNfcIsDevActivated(rfalNfcGetState()))
{
rfalNfcGetActiveDevice(&nfcDevice);
switch (nfcDevice->type)
{
/*******************************************************************************/
/*******************************************************************************/
case RFAL_NFC_LISTEN_TYPE_NFCV:
{
uint8_t devUID[RFAL_NFCV_UID_LEN];
ST_MEMCPY(devUID, nfcDevice->nfcid, nfcDevice->nfcidLen); /* Copy the UID into local var */
//REVERSE_BYTES(devUID, RFAL_NFCV_UID_LEN); /* Reverse the UID for display purposes */
//platformLog("ISO15693/NFC-V card found. UID: %s\r\n", hex2Str(devUID, RFAL_NFCV_UID_LEN));
//platformLedOn(PLATFORM_LED_V_PORT, PLATFORM_LED_V_PIN);
demoNfcv(&nfcDevice->dev.nfcv);
}
break;
/*******************************************************************************/
default:
break;
}
rfalNfcDeactivate(false);
platformDelay(500);
state = DEMO_ST_START_DISCOVERY;
}
break;
/*******************************************************************************/
case DEMO_ST_NOTINIT:
default:
break;
}
}
////////////////////////////////////////////////////////////////////////////////////
The rfal_demoCycyle() will be called at the same style of nfcStartDefaultTask(void *argument) in FreeRTOS_polling package. The following is my code.
----------------------------------------------
void ddi_Rfal_Tag_Rx_Thread(ULONG param)
{
//tx_thread_sleep(10);
tx_thread_sleep(OS_MSECS_TO_TICKS(1000));
//initialize the RFAL NFC ???
rfal_demoIni();
while (1)
{
rfal_demoCycle();
tx_semaphore_get((TX_SEMAPHORE_PTR)&g_pRfalSemaSt25r3916IRQ);
}//while
}
---------------------------------------------
Are there any problem?
Best regards
Dai Sai
2022-08-22 02:26 AM
Hi,
BSP_SPI1_IRQ_Callback definition in nucleo_l476rg_bus.c has the __weak attribute. Therefore, this definition is overridden by the one in plf_adaptation.c.
BSP_SPI1_IRQ_Callback notifies the ISR thread (nfcIsrTaskRunner) to process the ST25R3916 IRQ by calling st25r3916Isr().
Make sure to have the IRQ properly handled in your porting.
Rgds
BT
2022-08-22 06:34 PM
Dear Brian,
thank you very much for your reply.
I have the same idea with you. I ported the code based on the code in plf_adaptation.c.
Today, I did the rfalinitialize() and rfalFieldOnAndStartGT() with my ThreadX environment,
and got the a strong RF carrier, which is much stronger than one I did with TRF7960 before.
I was a little exciting for the good first step. I will try to read out UID of ISO15693 next try.
Attached figures is the IRQ and the output of RF carrier. Are they normal?
Best regards
Dai Sai
2022-08-22 07:29 PM
Dear Brian,
By checking the return value of rfalFieldOnandStartGT(), the return value is ERR_INTERNAL(12U).
I wonder if the return error should be checked at current stage?
best regards
Dai Sai
2022-08-23 12:44 AM
Hi,
rfalFieldOnandStartGT should return ERR_NONE. I suspect an issue in the adaptation to the threadX platform, likely in the timer management.
I would suggest to enable ST25R_SELFTEST and ST25R_SELFTEST_TIMER as global defines in the compiler command line. Then check the return code of st25r3916Initialize called in rfalInitialize.:
Rgds
BT