USB Gecko API Information (Console)

USB Gecko uses a custom hardware protocol which is controlled by EXI (External Interface) commands being sent to the memory card port in either the Gamecube or Wii console. As the memory card slot is available on both Gamecube and Wii it allows a high speed serial connection between both the console and the PC

All USB functions can be found in file usb.c, all flash functions can be found in flash.c

USB EXI Functions:

USB Check Gecko
unsigned int usb_checkgecko();

This function checks to see if the USB Gecko is connected and will return 1 if it is connected, or return 0 if no ideas found. It is recommended to use at the start of programs before using the USB Flush function.

USB Flush
void usb_flush();

This function will flush any remaining data from the FIFO buffer in the USB chip, it is recommend to use at the start of all programs after the USB Check Gecko function to avoid any unwanted data.

USB Send Byte
unsigned int usb_sendbyte (unsigned char sendbyte);

This function sends a byte to the PC via the exi bus, if the byte was sent the function returns 1, else will return 0.

USB Receive Byte
unsigned int usb_receivebyte (unsigned char* receivebyte);

This function receives a byte from the PC via the exi bus, if the byte was received it will return 1, else will return 0.

USB Send Buffer
void usb_sendbuffer (void *buffer, unsigned int size);

This simple function sends data held in a buffer to the PC, pointer to the buffer and size of buffer is required. Checking the FIFO isnt required when sending buffers to PC.

USB Receive Buffer
void usb_receivebuffer (void *buffer, unsigned int size);

This function receives data from the PC to pointed buffer, it also performs an extra check status call so the FIFO on the USB chip doesn't overflow without any overhead. This allows developers to make routines without having to make extra checks or checksums for packet loss ect.

USB Check Send Status
unsigned int usb_checksendstatus();

This function checks to see if the FIFO is ok to send a byte to the PC, it isn't really needed.

USB Check Receive Status
unsigned int usb_checkreceivestatus();

This functions checks to see if it is ok to receive data from the PC and that buffer is not full, it is required in most cases to avoid packet loss and dropping, this saves having to retry packets and other things associated with USB, the USB Receive buffer fuctions calls this function to be safe when receiving data.

USB Flash Functions:

Flash Chip Erase
void flash_chiperase();

This function will erase the chip. This needs to be called before programming.

Flash Program Byte
void flash_programbyte(unsigned long flashaddress, unsigned char flashdata);

This function allows you to program a byte at the flash address given.

Flash Verify
int flash_verify();

This function will verify the chip, by checking the manufacture and device ID's. It is not required but could be useful.

Note: The flash used in the USB Gecko is SST 39VF040. Datasheet can be found on the website www.usbgecko.com