I2C Examples (Blocking API)

Overview

The blocking I2C examples are available for both C and C++:

  • C: examples/blocking_api/i2c/c/

  • C++: examples/blocking_api/i2c/cpp/

These examples are intended for Supernova and Pulsar USB host adapters.

Hardware Setup

Required hardware:

  1. One Binho Supernova or Pulsar

  2. One I2C target device with 7-bit address 0x50 (EEPROM-like/register-based target)

What The I2C Examples Do

The C and C++ examples implement the same workflow:

  1. Connect to the device.

  2. Read adapter information.

  3. Configure I2C bus voltage to 3300 mV.

  4. Initialize I2C controller on I2C_BUS_A at 200 kHz with I2C_PULLUP_330Ohm.

  5. Re-apply I2C parameters and pull-up resistor configuration.

  6. Perform a non-stop write/read transfer to target 0x50 and verify readback.

  7. Perform a standard write/read transfer to target 0x50 and verify readback.

  8. Scan the I2C bus and print discovered 7-bit and 10-bit addresses.

Transfer Notes

  • The examples exercise both transfer styles:
    • Non-stop transfer (repeated start style).

    • Standard transfer (normal stop behavior).

  • Readback verification is done after each write/read stage.

  • The target subaddress used in both examples is {0x01, 0x00}.

Build and Run (I2C C/C++)

I2C example directories build binaries with the following names:

  • C (examples/blocking_api/i2c/c/):
    • example_c_dynamic

    • example_c_static

  • C++ (examples/blocking_api/i2c/cpp/):
    • example_cpp_dynamic

    • example_cpp_static

See: