Skip to main content

Module serial

Module serial 

Source
Expand description

Byte exchange over the link cable.

A transfer is always an exchange. Eight bits leave as eight arrive, and one cannot be had without the other. One of the two Game Boys supplies the clock and so decides when it happens: drive is that side, follow the other.

let answer = serial::exchange(b'?', Rate::Slow);

§Waiting

Nothing here gives up on its own. A follow with nothing at the far end waits for a clock that never comes. Count the frames and abort it. drive always finishes, reading $FF off a cable with nothing on it.

A Game Boy about to be clocked has to be waiting before the other one starts, so the clocking side has to pause between bytes. How long depends on what the far end does with them.

See https://gbdev.io/pandocs/Serial_Data_Transfer_(Link_Cable).html.

Structs§

Transfer
A byte on its way out with another on its way in.

Enums§

Rate
How fast this Game Boy clocks the wire.

Functions§

drive
Clock the wire and carry on.
exchange
Clock the wire and wait for the byte coming the other way.
follow
Hold a byte out for the other Game Boy to clock when it is ready.