ST25R3916B controlled by ESP32 not working
Hi there,
first of all: I'm a software engineer and working with electronics only as a hobbyist. Therefore expect *** errors :)
I'm trying to use a ST25R3916B in my ESP32 project. The I2C communication to the ST25R3916B is working.
The call to rfalNfcInitialize succeeds but the next call to rfalFieldOnAndStartGT causes the ESP32 to crash with a " Core 1 panic'ed (Interrupt wdt timeout on CPU1).". The interrupt is taking too long.
Looking into the code, I found this function:
/*******************************************************************************/
void RfalRfST25R3916Class::st25r3916CheckForReceivedInterrupts(void)
{
uint8_t iregs[ST25R3916_INT_REGS_LEN];
uint32_t irqStatus;
/* Initialize iregs */
irqStatus = ST25R3916_IRQ_MASK_NONE;
ST_MEMSET(iregs, (int32_t)(ST25R3916_IRQ_MASK_ALL & 0xFFU), ST25R3916_INT_REGS_LEN);
/* In case the IRQ is Edge (not Level) triggered read IRQs until done */
while (digitalRead(int_pin) == HIGH) {
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN);
irqStatus |= (uint32_t)iregs[0];
irqStatus |= (uint32_t)iregs[1] << 8;
irqStatus |= (uint32_t)iregs[2] << 16;
irqStatus |= (uint32_t)iregs[3] << 24;
}
/* Forward all interrupts, even masked ones to application */
st25r3916interrupt.status |= irqStatus;
}
Commenting out the call to st25r3916ReadMultipleRegisters solves the crash but will also cause the interrupt to not work anymore (not a surprise).
This function is called by the interrupt and the call to st25r3916ReadMultipleRegisters does some I2C communication which (as far as I understand) should not be done in an interrupt handler.
Is this an incompatibility issue between the STM32duino ST25R3916 library and ESP32? Or am I doing something wrong? Has anyone gotten this IC to work on a ESP32?
Thanks for your time and your help :)
