greatfet_i2c

greatfet_i2c is a tool for talking to an I2C device with GreatFET.

Pin Usage

signal

symbol

pin

SDA

I2C0_SDA

J2.39

SCL

I2C0_SCL

J2.40

Example Usage

scan(GreatFET) - scans the GreatFET I2C Bus for connected I2C devices and displays responses from 7-bit addresses.

$ gf i2c -z
I2C address(es):
0x0 W
0x20 W
0x20 R
0x7c W

******** W/R bit set at each valid address ********
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: W- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: WR -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- W- -- -- --

read(GreatFET, address, receive_length, log_function) - reads a ‘receive_length’ amount of bytes over the I2C bus from a device with the specified 7-bit address. Optionally displays results.

write(GreatFET, address, data, log_function) - writes bytes over the I2C bus to a device with the specified 7-bit address. Optionally displays results.

$ gf i2c -a 0x20 -w 0x01 0x02 0x03 -r 2 -v
Trying to find a GreatFET device...
GreatFET One found. (Serial number: 000057cc67e630318c57)
Writing to address 0x20
I2C write status: 0x18
Bytes received from address 0x20:
0x3
0x3
I2C read status: 0x40

Transmits bytes ‘0x01’, ‘0x02’, and ‘0x03’ to an I2C device with address 0x20 (Crocus in this case), receives 2 bytes in response, and displays the results.

API