Home › Forums › EasyTransfer Library Support Forum › EasyTransfer-I2C two-way communication › Reply To: EasyTransfer-I2C two-way communication
I’ll have to learn about using Github, but for now here is what I have.
https://www.dropbox.com/s/w1aj0g0ef3r2juv/EasyTransferI2C_NL%206-19-2013.zip
These changes allow for sending and receiving data to a I2C Slave. I can get it to work on data structures 28 bytes and smaller. That’s the current outstanding bug. If I make a data structure >28 bytes, the communication fails. My understanding is that you can transfer as much as 256 bytes of data at a time over I2C, so with the 3 “check bytes” it seems like the real limitation would be 253 bytes of user data. I have some projects that need >28 bytes, so if I work this bug out I’ll repost some code.
In general the usage is as straight forward and simple as EasyTransfer. The only difference between the MASTER and SLAVE communication is that the MASTER addresses the SLAVE devices and the SLAVE just responds to the MASTER’s requests. So the MASTER’s function calls look like: ET.sendData(I2C_SLAVE_ADDRESS) and ET.receiveData(I2C_SLAVE_ADDRESS) and a SLAVE’s function calls look like: ET.sendData() and ET.receiveData(). In the ISR for a SLAVE when it receives a request from the MASTER, the ET.flagSlaveSend() function can be called so that a flag is set and ET.sendData() can then be called in the main program loop (if desired).
The included example is similar to the example for EasyTransfer. The MASTER rolls on a “blinks” and “pauses” value and outputs them to the SLAVE. The SLAVE does its blinking and sends the “blinks” and “pauses” values back to the MASTER. When the MASTER receives them it executes the same “blinks” and “pauses” routine. So you can see that the data is being communicated back and forth in circles.
-Nic