Hi,
See: https://community.st.com/t5/st25-nfc-rfid-tags-and-readers/how-to-control-two-st25r3916-chips-with-rfal-api-using-spi/td-p/140888
The rfal_platform.h can be tweaked to handle dynamically the CS and INT pins:
#define ST25R_SS_PIN ((globalReaderInstance == PLF_INST_ST25R3916_1) ? SPI1_CS_Pin : SPI2_CS_Pin) /*!< GPIO pin used for ST25R SPI SS */
#define ST25R_SS_PORT ((globalReaderInstance == PLF_INST_ST25R3916_1) ? SPI1_CS_GPIO_Port : SPI2_CS_GPIO_Port) /*!< GPIO port used for ST25R SPI SS port */
#define ST25R_INT_PIN ((globalReaderInstance == PLF_INST_ST25R3916_1) ? IRQ_3916_Pin : IRQ_3916_2_Pin) /*!< GPIO pin used for ST25R External Interrupt */
#define ST25R_INT_PORT ((globalReaderInstance == PLF_INST_ST25R3916_1) ? IRQ_3916_GPIO_Port : IRQ_3916_2_GPIO_Port) /*!< GPIO port used for ST25R External Interrupt */
Then you can add a function like the following one to select a given reader instance (code to be adapted)
/*******************************************************************************/
ReturnCode demoSetReaderInstance(readerInstance instance)
{
ReturnCode err = RFAL_ERR_NONE;
state = DEMO_ST_NOTINIT;
rfalDeinitialize();
globalReaderInstance = instance;
platformLog("[%d] ST25R reader instance: %d\r\n", platformGetSysTick(), globalReaderInstance);
spiInit((instance == PLF_INST_ST25R3916_1) ? &hspi1 : &hspi2 );
err = rfalNfcInitialize();
if(err == RFAL_ERR_NONE )
{
/* Check for valid configuration by calling Discover once */
err = rfalNfcDiscover( &discParam );;
if( err == RFAL_ERR_NONE )
{
state = DEMO_ST_START_DISCOVERY;
}
else
{
platformLog("rfalNfcDiscover: invalid param\r\n");
}
}
else
{
platformLog("rfalNfcInitialize returns %d\r\n", err);
}
return err;
}
Then in your main cycle you can move from reader1 to reader2 once the state machine has returned to RFAL_NFC_STATE_START_DISCOVERY.
Rgds
BT