/
I2C smoke test user guide

I2C smoke test user guide

The I2C smoke test project, smoke_i2c, allows you to perform reads and writes to arbitrary I2C addresses and registers. By default, the smoke test does nothing, so you’ll need to customize projects/smoke_i2c/src/main.c in firmware_xiv to perform a read and/or a write.

Running the smoke test

Once you’ve got the development environment set up and have connected a controller board and customized the smoke test, do

make program PROJECT=smoke_i2c

Customizing the smoke test

You can perform a single I2C write and a single I2C read in a single invocation of the smoke test. If both a write and a read are performed, the write is performed first. To customize the smoke test, edit projects/smoke_i2c/src/main.c in firmware_xiv and perform the following changes.

Writing

To perform an I2C write during the smoke test, change the SHOULD_WRITE variable to true. Then, fill in the values of the following variables:

  • Set WRITE_I2C_PORT to I2C_PORT_1 to write over port 1 (with PB9/PB8) or to I2C_PORT_2 to write over port 2 (with PB11/PB10).

  • Set WRITE_I2C_ADDRESS to the I2C address you want to write to (e.g. 0x74).

  • Fill in the bytes_to_write array with the bytes you want to write to the above I2C address.

  • If you want to write to a register, set SHOULD_WRITE_REGISTER to true, and fill in REGISTER_TO_WRITE with the ID of the register you want to write to (e.g. 0x06)

A log of the write will be printed to minicom during the smoke test.

Reading

To perform an I2C read during the smoke test, change the SHOULD_READ variable to true. Then, fill in the values of the following variables:

  • Set READ_I2C_PORT to I2C_PORT_1 to read over port 1 (with PB9/PB8) or to I2C_PORT_2 to read over port 2 (with PB11/PB10).

  • Set READ_I2C_ADDRESS to the I2C address you want to read from (e.g. 0x74).

  • Fill in NUM_BYTES_TO_READ with the number of bytes you want to read.

  • If you want to read from a register, set SHOULD_READ_REGISTER to true, and fill in REGISTER_TO_READ with the ID of the register you want to read from (e.g. 0x06).

A log of the read, as well as the values of the bytes read, will be printed to minicom during the smoke test.

(Tip: if minicom is printing lines all over the place, press Ctrl+Z to bring up a menu, then press U to enable carriage return insertion.)

Related content

Babydriver
Babydriver
More like this
Firmware - Getting Started
Firmware - Getting Started
Read with this
MCP3427 smoke test user guide
MCP3427 smoke test user guide
More like this
BTS7040 smoke test user guide
BTS7040 smoke test user guide
More like this
BTS7200 smoke test user guide
BTS7200 smoke test user guide
More like this
Inter-Integrated Circuit (I2C)
Inter-Integrated Circuit (I2C)
More like this