cancel
Showing results for 
Search instead for 
Did you mean: 

NFC Scanning ST25R3916B with RFAL STSW-ST25RFAL002, FreeRTOS Polling

raj-muniraju
Associate II

Hi,
I am using /ST25NFC_Embedded_Lib_ST25R3916(B)_1.7.0/Projects/STM32L476RG-Nucleo/Applications/Common/Src/demo_edta.c.

It works as intended, but I am sharing the SPI with another interrupt-based peripheral. I want to start the discovery and process it for a few seconds at a time. Can you give me pointers on the best way to do it?

3 REPLIES 3
Ulysses HERNIOSUS
ST Employee

Hi,

options of what you can do (also possible to combine):

  1. Use ST25R_COM_SINGLETXRX forces to have all SPI frames done via one SPI driver call at the expense of more memory
  2. Have proper locking/mutex in platformSpiTxRx() to prevent its CS set to low and then being scheduled into your other peripheral.

 

Sometimes the SPI drivers (Linux, etc.) guarantee atomicity and even handle the chip select. Then option 1. might be the only thing you need.

 

Regards, Ulysses

Hi @Ulysses HERNIOSUS 

I have both ST25R_COM_SINGLETXRX and Mutex protection on SPI, but sometimes unable to service the interrupt in time with other peripherals actively using the SPI.

 

I am hoping to have application-level coordination as my other peripheral is supposed to give way for NFC. 

My application at high level:

  • Initialize SPI and  ST25R3916B 
  • Wait for trigger to start NFC discovery scans
  • On trigger, 
    • Take application level control over spi, 
    • Start NFC discovery scan for 800sec
    • if anything is discovered communicate using T4 commands
    • Release spi control
    • wait for 200msec
    • repeat these steps 5 times
  • Go back to sleep to wait for next trigger

Can you point me to an example of stopping and starting the discovery scans for a specified time?

Hi,

I think I would use in such case the rfalNfcGetState() + notification callback to pause and resume the NFC layer at certain states. I.e. check for RFAL_NFC_STATE_LISTEN_TECHDETECT and then stop calling its worker and perform other jobs. When done resume calling it - assuming the timers have already expired. Maybe you need to play with totalDuration parameter.

Ulysses