This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_drv_twi_xfer: how many RX bytes?

NRF52, SDK 12.1

We are using I2C to communicate with a secure element. We got the basic system working and can send and receive APDUs. The problem we have is when receiving APDUs, we do not know how many bytes the data will be.

At this point we are using nrf_drv_twi_xfer() which requires a number of expected RX bytes (NRF_DRV_TWI_XFER_DESC_TXRX). You could say to simply read more than needed, then check the result afterwards with parsing. Problem is that the secure element will lock up if you try to read more bytes than needed and a reset is required to continue.

So how do people use this?

Related