I'm working on a project that involves connecting directly from the TRS jack of an iPhone to a SPI port on a microcontroller.
So the iPhone is the master and the microcontroller is the slave
So let's say the left speaker channel of the iPhone is responsible for generating clock signals
Now how do I transmit for example a single ASCII byte 'A' from the master to the slave?
I can see that each time the clock edge rises ( let's say passes zero ), both master and slave read off a new bit -- whatever the state of the respective MISO/MOSI
But how to byte-align?
Binary for 'A' is 0100 0001
How do we distinguish that leading 0 from the silence that preceded?
It seems to me that a sensible protocol would be to use 0xFF or something as a start Sentinel, and have the next byte dictate the number of bytes ( between 1 and 256 ) in the packet that is to come.
And then these bytes get sent one after the other, may be followed by a parity byte.
Maybe each byte would have parity bit...?
As soon as this ' packet ' has arrived, the decoder could start looking for another start Sentinel.
So that's how I would go about designing SPI. so I'm trying to find some documentation that tells me how it is actually done.
But I'm getting really frustrated bouncing around Google / Wikipedia / IRC
Is there someone out there who understands this protocol, and wouldn't mind giving me a really simple example usage -- sending the single character 'A' via SPI