The examples for slave i2c are very simplisted (they simply transfer a set amount of bytes each time). However, for most i2c applications as well as mine, we do read/write transactions. The biggest problem I am having is that I don’t know if it will be a read or write transaction until I see how many bytes I receive from the master (for a read, I just get the address, for a write, the data follows). So, I am not sure how to receive a undetermined amount of bytes from the example using the transactional method.
In the call back function, if I say to receive 4 bytes (but sometimes 2 bytes will come because it is a read), I get weird cyclical behavior with every i2c transaction. I was hoping just to give the max amount of bytes I expect to receive, and then look at the actual bytes transferred on the completion event, but it does not behave as expected.
Do you know of an app note that shows a more real-world i2c slave example?
IAR for ARM: 22.214.171.12424
IAR common components: 126.96.36.19924
info in this thread is referring to the slave interface.