Xwire: Some hints and ideas
Despite its apparent simplicity, Xwire is extremely versatile. Here are some more or less random thoughts:
Xwire is a simple exchange of a few bytes between master and slave. What you use those bytes to represent is entirely up to you. The limit is your imagination.
A byte can represent a command to a slave to do something.
Another byte back from the slave can signal completion.
Remember Xwire will transfer data at any random time. If you need to transfer several bytes, and it is important that they be used as a set (say X, Y and Z coordinates), use an extra byte for status. For example, have the status initially 0. The master fills the data bytes. While the master is doing that, any transmission received in the slave is ignored in your slave program because status=0. When all bytes have been written by the master it sets status<>0. The slave sees that and actions the data bytes. When it has finished it sets a return status byte to something.
You can send large amounts of data. Use a handshake like I outlined above, plus a block counter. Up to 255 blocks of data are easy to transfer.
Data received via Xwire is accurate. We use a 16-bit CRC checksum for error detection. Still, don’t use it for a bomb detonator.