PC to Adapter Serial Protocol
The R8C/13 processor is connected through a serial (COM) cable to the PC. The COM port settings are:
- 38400 Baud Rate
- 8 Bit Data
- One Stop Bit
- No Parity and No Flow Control
Protocol
The flow control is solved internaly, every byte the adapter receives have to be confirmed.
Data to the PC are buffered from the com driver, so no confirmation neccassary.
Here are the protocol bytes:
PC -> Adpater
0 = RECEIVED | NOT USED |
1 = DATA | The next byte is a data byte. |
2 = DEVICE_MODE | Switch the adapter into device mode (adapter works like a floppy for the real C64). |
3 = COMPUTER_MODE | Switch the adapter into computer mode (adapter works like a C64 for the real floppy). |
4 = DEBUG_MODE | The leds on the adpter shows the IN signals. |
5 = RESET | Reset |
6 = STATUS | Request Status |
7 = EOI | End of Indicator (Last Byte) |
8 = ERROR | NOT USED |
9 = ATN_ON | Switch ATN to ON. |
10 = ATN_OFF | Switch ATN to OFF. |
11 = RST_ON | Switch RST to ON. |
12 = RST_OFF | Switch RST to OFF. |
13 = CLK_ON | NOT USED - Only in Status Response. |
14 = CLK_OFF | NOT USED - Only in Status Response. |
15 = DTA_ON | NOT USED - Only in Status Response. |
16 = DTA_OFF | NOT USED - Only in Status Response. |
17 = DEV_ADDR | Set a new device address, +1 Byte Address. (Default: 8) |
18 = TIMEOUT | Set the timeouts, +1 Byte Type, +1 Byte Value. (See Below) |
Adpater -> PC
0 = RECEIVED | Byte was received from adapter and now confirmed. |
1 = DATA | The next byte is a data byte. |
2 = DEVICE_MODE | Mode Confirmed. |
3 = COMPUTER_MODE | Mode Confirmed. |
4 = DEBUG_MODE | Mode Confirmed. |
5 = RESET | Reset Confirmed |
6 = STATUS | Status Response, +8 Bytes, see below. |
7 = EOI | End of Indicator (Last Byte) |
8 = ERROR | An Error occurs +1 Byte Error Code, see below. |
9 = ATN_ON | ATN switched to ON (From request or from Serial). |
10 = ATN_OFF | ATN switched to OFF (From request or from Serial). |
11 = RST_ON | RST switched to ON (From request or from Serial). |
12 = RST_OFF | RST switched to OFF (From request or from Serial). |
13 = CLK_ON | NOT USED - Only in Status Response. |
14 = CLK_OFF | NOT USED - Only in Status Response. |
15 = DTA_ON | NOT USED - Only in Status Response. |
16 = DTA_OFF | NOT USED - Only in Status Response. |
17 = DEV_ADDR | New device address confirmed, +1 Byte Address. |
18 = TIMEOUT | Timeout Confirmed, +1 Byte Type. (See Below) |
STATUS RESPONSE
Byte 1 | Version (Actually 1) |
Byte 2 | Mode (COMPUTER_MODE or DEVICE_MODE). |
Byte 3 | Device Address (Default 8) |
Byte 4 | Error Code (see below) |
Byte 5 | ATN (ATN_ON or ATN_OFF) |
Byte 6 | RST (RST_ON or RST_OFF) |
Byte 7 | DTA (DTA_ON or DTA_OFF) |
Byte 8 | CLK (CLK_ON or CLK_OFF) |
ERROR CODES
0 | None |
1 | Frame Error |
2 | Device Not Present |
3 | Timeout |
4 | Error Receive Byte |
5 | Error Ready to Send |
6 | Error Ready to Receive |
7 | Error Ack EOI |
8 | Error Ack Frame |
9 | Error Turn Sender/Receiver |
TIMEOUT TYPES
0 | All |
1 | Timeout TS [us] - SendByte 1 (70 us) |
2 | Timeout TV [us] - SendByte 2 (60 us) |
3 | Timeout TBB [us] - Time Between Bytes (100 us) |
4 | Timeout TAT [us*10] - Ready To Send 1 (1000 us) |
5 | Timeout TNE [us] - Ready To Send 2 (40 us) |
Example
Open channel 15 on the floppy and initialize (same as OPEN 1,8,15,"I").
COMPUTER_MODE, ATN_ON, DATA, 0x28, DATA, 0xFF, ATN_OFF, EOI, DATA, 0x49, ATN_ON, DATA, 0x3F, ATN_OFF
- 0x28 = LISTEN device 8
- 0xFF = OPEN channel 15
- 0x49 = "I"
- 0x3F = UNLISTEN
Full Byte Sequence:
0x03, 0x09, 0x01, 0x28, 0x01, 0xFF, 0x0A, 0x07, 0x01, 0x49, 0x09, 0x01, 0x3F, 0x0A
Every Byte you send, a RECEIVED is returned (0x00) and optionaly a command specific response. So just send the next byte if you got a RECEIVED byte after your last send byte.