For dozens (hundreds?) of common sensors and peripherals with I2C interface, a common I2C pattern is a write operation immediately followed by a read without releasing the I2C bus. Typically the write operation sends a command to the I2C slave (ie write one byte to specify register to read), followed by reading some number of bytes of data.
Does Kinetis I2C peripheral directly support this via DMA, so that the application can fire the DMA and only receive an interrupt after DMA has finished read the desired bytes into a buffer?
Thanks in advance,
Best Regards, Dave
PS: If not, what other processors provide this function?
Hi @davenadler
No, there isn't a "common access pattern" function (I would love it it there was) that works with (E)DMA.
I guess a wrapper method could provide a simple API that carried out (E)DMA operations (there would have to be an i2c_edma_init() API written as well) that handled transfers looking something like:
start-deviceAddressW-deviceRegisterAddress-writeDataByte(s)-stop
start-deviceAddressR-deviceRegisterAddress-readDataByte(s)-stop
I just spent a moment reviewing the available SDK APIs and I think it could be done reasonably efficiently with the big issue to be resolved is what happens if a "Nak" was received unexpectedly (which happens in some slave devices sending multiple bytes of data as a way of telling the master that there is no more data to send).
Now you have the juices flowing.
myke
I'm in a fight with the forum software trying editing my original response - let me try to reply again...