Sun Nov 6 13:15:45 EST 2011

slow, synchronous bi-directional protocol

I need something to connect 2 slow devices, meaning that neither end
has a timing restriction and can take as long as it pleases inbetween
protocol phases.

This needs 4 lines on both ends, cross wired + ground.  Let's do

  DR = data ready
  RA = read ack
  Dx = data out/in

Timing diagram
      ___     ___
DR __|   |___|   |_____

DO    ///     ///
        ___     ___
RA ____|   |___|   |___

DI      ///     ///

The problem with this is that it is not symmetric.  It would be
simpler to make it fully ping-pong and only trigger on edges: every
transition on the sync line indicates that the next bit is valid.
Here 'X' means a data transition, all the other states are valid.

        ___     ___
DR   __|   |___|   |_____

DO  0 X 1 X 2 X 3 X 4
          ___     ___
RA   ____|   |___|   |___

DI    0 X 1 X 2 X 3 X 4

This is fully symmetric because only the edges count, not the levels.
In receive mode, we wait for a clock edge, then read the data, write
our data and flip our clock then switch back to receive mode.

Once this is locked we have a bi-directional bit stream that can go
arbitrarily slow.  It probably needs some logical protocol on top of
that for synchronization, to allow insertion of idle bit patterns.

So how to start it up?  Someone has to send the first edge, and it
needs to know that the other side will see that edge, meaning it was
listening.  From there on it is straightforward, but that first start
doesn't seem so simple.

It needs extra starting conditions:

  - Who will send the first bit.  This creates the initial a-symmetry
    to get the loop going: one will wait for reception and the other
    will cause the first write.

  - What edge will be used for the first bit.  This is necessary to
    initialize the edge detector (differentiator).