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

Update I2C Master read size

As a I2C master, I need to be able to read some data from a slave device the length of which I do not know beforehand. First byte I receive from slave is a packet type and usually packet size will come in the next 4 bytes(that may vary). So I need to start reading a packet the size of which I don't know until I start decoding its bytes.

I'm trying to use the driver in nrf_drv_twi.c (SDK12.2.0 on a nRF52832), but I can't figure out how to launch a read, start receiving data and then decode the packet length on the fly and update the driver with it.

I can't access the slave nor update its firmware so I simply can't split the read operation in smaller operations. I simply need to be able to start reading and then unpack the packet size as I receive it. Is there any way to do that with the Nordic driver?

Related