I understand the section as follows:
To send 11 = 0xb = %1011, you would do the following (in pseudo code):
Code: Select all
$18023 = %1110 : REM Send a "1" bit
REPEAT
UNTIL $18020 & %1000000 == 0
$18023 = %1100 : REM Send a "0" bit
REPEAT
UNTIL $18020 & %1000000 == 0
$18023 = %1110 : REM Send a "1" bit
REPEAT
UNTIL $18020 & %1000000 == 0
$18023 = %1110 : REM Send a "1" bit
REPEAT
UNTIL $18020 & %1000000 == 0
That is, bit 1 of what's written to $18023 is the actual data bit (MSB first), Bit 6 of $18020 going "0" signals you can do the next bit
In order to decide whether you send or receive, look at this section:
Receiving data from the IPC is done by writing %1110 to pc_ipcwr for each bit of the data, once again waiting for bit 6 at pc_ipcrd to go to zero, and* then reading bit 7 there as the data bit. The data is received msb first.
The reason behind effectively sending a one bit for each read is the way the hardware functions. There are only two wires between the PC and IPC to work with, and only one is bi-directional. Even this is limited, in that either end can force it to zero, but both ends must agree to make it a one. Hence when the PC is trying to read data from the IPC, it must be asserting a one in order to see whether the IPC is returning a one or zero bit.
That is, actually, there is no difference in sending and receiving. For sending, you ticker out the bits one after the other, effectially ignoring what comes back from the IPC (bit 7 in $18023) and only looking at the ready bit (bit 6), for receiving, you need to ticker out a "1" bit for every bit you want to receive (and then, obviously check that received bit in {7|$18023}. Works similar to the SPI protocol used by, for example SD cards, in case you happen to know that.
And, obviously, you need to know exactly when, what, and how many bits you want to send or receive, according to the protocol.
Thus
To receive 4 bits, you would do the following (in pseudo code):
Code: Select all
$18023 = %1110 : REM Send a don't care bit (needs to be "1" to actually do something, but will be ignored on other end)
REPEAT
UNTIL $18020 & %1000000 == 0
rec[3] = $18020 & %10000000
$18023 = %1110 : REM Send a don't care bit (needs to be "1" to actually do something, but will be ignored on other end)
REPEAT
UNTIL $18020 & %1000000 == 0
rec[2] = $18020 & %10000000
$18023 = %1110 : REM Send a don't care bit (needs to be "1" to actually do something, but will be ignored on other end)
REPEAT
UNTIL $18020 & %1000000 == 0
rec[1] = $18020 & %10000000
$18023 = %1110 : REM Send a don't care bit (needs to be "1" to actually do something, but will be ignored on other end)
REPEAT
UNTIL $18020 & %1000000 == 0
rec[0] = $18020 & %10000000
Tobias