Page 1 of 1

I2C-tiny-USB data transfer

Posted: Mon Nov 03, 2008 9:54 pm
by alanp
Hi Guys,

I'm not sure if this is the right place to ask the question but here goes.

I'm writing a python module to access the I2C bus via I2C-tiny-USB.
I'm doing this through libUSB so it can be used on Linux and Windows. I'm using the pyUSB project as a wrapper to get to libUSB.

I'm not sure whether my questions relates to USB in general or libUSB.

My question is how many bytes can I transfer at a time to the I2C bus.

I want to be able to read/write to I2C memory (24LCxx parts) which are able to do page read and write. All the examples that come with I2C-tiny-USB only do a byte or word read and write.

Can I throw, say, 32 bytes at the device or will have I to do 32 individual read/write instruction.

Thanks

Alan

Posted: Tue Nov 04, 2008 12:52 am
by gert
Hi Alan

I2C-tiny-USB uses the control endpoint to transfer data, therefore it's limited to 8 Bytes at a time.

If you plan to transfer more than 8 bytes at a time you need to implement an interrupt endpoint in your USB device. It may be a good idea to take USBasp or USBaspLoader as a starting point.

One more thing: besides the time necessary to transer 32 bytes of data plus address and command to your EEPROM using (slow) software I2C, it takes 5-15msec until a EEPROM block write is finished (see data sheet). You shouldn't forget to test if the EEPROM is "ready" before accepting new data through USB.

Cheers
Gert

Posted: Tue Nov 04, 2008 2:35 pm
by henni
gert wrote:I2C-tiny-USB uses the control endpoint to transfer data, therefore it's limited to 8 Bytes at a time.

That's wrong. All versions of AVRUSB allow up to 254 bytes control data in both directions. Newer versions allow even more bytes. IMHO Windows limit control transfers to 4KB.
However, the I2C-tiny-USB firmware may lack of more-than-8-byte support, I don't know.

I have written a more general-use USB-to-I²C interface that supports a variety of chips with following features:
* Selectable I²C address (wIndexL[7:1])
* Selectable I²C speed (wIndexL[0])
* Selectable chip-internal address (wValue[15:0]), both 1-byte and 2-byte, Little Endian and Big Endian order (wIndexH[1:0])
* Selectable size of EEPROM page (wIndexH[7:4], 0 = automatic, 1 = byte per byte etc.)
* Automatic EEPROM page write inclusive ready waiting
* Automatic address repetition (and incrementation, necessary for some non-EEPROM chips) (wIndexH[7:4] = 1)
* Full control over start conditions and stop conditions (wIndexH[3:2]), allowing split-and-concatenate transfers (very long data streams)
* All non-data (address etc.) bytes packed to SETUP data block, no data copying necessary on host side
* Upward compatible to EzMr.exe I²C interfacing (Cypress EzUSB Manager)
However, the code is for 8051 (CY7C68013A) and here: http://www.tu-chemnitz.de/~heha/bastele ... sb2lpt.zip and inside src/firmware/USB2LPT2.A51