...............................................................................
VIPER USB ADAPTER LOW LEVEL PROGRAMMING MANUAL V0.1
...............................................................................


The Viper USB Adapter is usually accessed using immediate commands to 
EXI channel 0, device 2.

When sending or receiving a 16-bit immediate value to/from EXI bus, make
sure the data is stored/is loaded in the 16 upper bits of the immediate 
register, this is how it works :)

NB: The GC is the reference for command descriptions: A "read" means a
    PC to GC transfer.


0. Commands
-----------

    A. Get Device ID
    B. Read Byte
    C. Write Byte
    D. Read & Write Byte
    E. Get Status
    F. Send Immediate


A. Get Device ID
----------------

Use this command to retrieve the ID of an EXI device. This command is not
specific to Viper USB Adapter: every device on the EXI bus should reply with
its ID when this command is issued.

NB: While Viper USB Adapter supports it, you should never use the full speed of
the EXI bus to get a device ID as some devices may not support it. To be 
fully compatible, use exi_freq=3 (~8MHz) instead of exi_freq=5 (full speed).
Full speed of the EXI bus can be used for any other commands.

    a) EXI IMM SEND, 2 BYTES    

       Sent:
        +--------------+---------------+
        |     0x00     |     0x00      |
        +--------------+---------------+
        
    b) EXI IMM RECV, 4 BYTES

       Recv:
        +--------------+---------------+--------------+--------------+
        |  0x56 ('V')  |   0x55 ('U')  |  0x41 ('A')  |   RRRRRRR1   |
        +--------------+---------------+--------------+--------------+
        
        R = Reserved 
        First 3 bytes = "VUA" (Viper USB Adapter)                              


B. Read Byte
------------

    Reads a byte from PC. 

    a) EXI IMM BIDIRECTIONAL, 2 BYTES    
       
       Sent:
        +--------------+---------------+
        |     0xc0     |     0x00      |
        +--------------+---------------+
        
       Recv:
        +--------------+---------------+
        |  RRRRXRRR    |    R_DATA     |
        +--------------+---------------+
        
        R = Reserved
        X = 1: A byte was read and is stored in R_DATA
            0: There was nothing to read
        R_DATA = The byte read if X = 1
        
        
C. Write Byte
-------------

    Sends one byte to the PC.

    a) EXI IMM BIDIRECTIONAL, 2 BYTES    
       
       Sent:
        +------+-------+-------+-------+
        | 1010 |     W_DATA    | 0000  |
        +------+-------+-------+-------+
        
       Recv:
        +--------------+---------------+
        |  RRRRRYRR    |   RRRRRRRR    |
        +--------------+---------------+
        
        R = Reserved
        Y = 1: The byte was written                  
            0: The byte couldn't be written (FIFO is full or PC is 
               not listening.) Usual behaviour is to try again.                            
        W_DATA = The byte to be written
        
            
D. Read & Write Byte
--------------------

    Reads on byte from PC & Send one byte to PC in only one EXI IMM access.
    In most cases it's easier to use separate write & read commands, but in
    some cases performing both at the same time can lead to better speed.

    a) EXI IMM BIDIRECTIONAL, 2 BYTES    
       
       Sent:
        +------+-------+-------+-------+
        | 1110 |     W_DATA    | 0000  |
        +------+-------+-------+-------+
        
       Recv:
        +--------------+---------------+
        |  RRRRXYRR    |    R_DATA     |
        +--------------+---------------+
        
        R = Reserved
        X = 1: A byte was read and is stored in R_DATA
            0: Nothing to read
        Y = 1: The byte was written                  
            0: The byte couldn't be written (PC is not listening or the FIFO
               is full.) Usual behaviour is to try again.                            
        R_DATA = The byte read if X = 1
        W_DATA = The byte to be written
            
            
E. Get Status
-------------

    Get the status of the Viper USB Adapter

    a) EXI IMM BIDIRECTIONAL, 2 BYTES    
       
       Sent:
        +--------------+---------------+
        |     0x80     |     0x00      |
        +--------------+---------------+
        
       Recv:
        +--------------+---------------+
        |   RUXYRRFE   |   RRRRRRRR    |
        +--------------+---------------+

        R = Reserved
        
        USB Status:
        U = 1: USB connection detected
            0: USB suspended or the USB cable is unplugged            
        
        FIFO status 
        X = 1: There's at least one byte to be read in the FIFO
            0: Nothing to read
        Y = 1: The write FIFO is not full yet, it's possible to write at 
               least one byte
            0: The write FIFO is full
                    

F. Send Immediate
-----------------
      
    Requests an immediate transfert of the data that is currently in the FIFO.
    You don't need to use this command under normal circumstances. When latency
    is a big issue, it might help.

    a) EXI IMM SEND, 2 BYTES    
       
       Sent:
        +--------------+---------------+
        |     0x60     |     0x00      |
        +--------------+---------------+
        
