This is a tool for testing I2C devices from a terminal program. Setup the communication parameters to 8N1, 115,200 baud. Sample session with a PCA9555 device attached:
start:RS232 to I2C converter, V 0.1 w2002beef ok w2002r202 ok read:beef r208 read:beefbeefbeefbeef r212 error:nack wcc80 error:nack
The first line is returned on startup. Then the hex bytes 0x02, 0xbe and 0xef are sent to the device with the address 0x20 (PCA9555 device address with A0-A2 tied to low). The system prints "ok", because the device acknowledged each byte.
"w2002r202" writes 0x02 to the device 0x20, then the "r" command sends a restart with the address 0x20 and I2C read bit set and the final hex digit "2" is the number of bytes to read. The result is "read:", followed by the received bytes.
It is possible to read without a restart, but with a normal start condition. The PCA9555 saves the last register pair accessed and wraps around the read index, so a "r208" reads 8 bytes from the 0x20 device, at PCA9555 register address 2 and 3.
If a device doesn't acknowledge, the system returns "error:nack" and all commands for the rest of the line are discarded. The commands are evaluated on newline. Each write command results in an "ok" or an error and each read command results in a line, which begins with "read:", followed by the list of bytes, which were read from the device. Subsequent commands on a line sends a restart condition. At the end a stop condition is sent.
I've implemented the system with a CY8C21534 microcontroller from Cypress, but should be not too difficult to port the C code to other microcontrollers. You can download the PSoC Designer project with the C source code. I didn't use the Device Editor, but wrote most hardware initialization and routing in C, for learning the basics of the CPU in detail. Connect SDA to P1[5] and SCL to P1[7], both with external pullup resistors, e.g. 2.2k. P0[0] is the UART output and P0[1] is the input (you need a level converter, like the MAX232, for converting the TTL levels to RS232 levels).