Example Summary

Sample application that implements a simple command interface to an I2C target (see cmdinterface.h).

This example is intended for use together with the i2ctarget example.

Peripherals & Pin Assignments

When this project is built, the SysConfig tool will generate the TI-Driver configurations into the ti_drivers_config.c and ti_drivers_config.h files. Information on pins and resources used is present in both generated files. Additionally, the System Configuration file (*.syscfg) present in the project may be opened with SysConfig’s graphical user interface to determine pins and resources used.

BoosterPacks, Board Resources & Jumper Settings

For board specific jumper settings, resources and BoosterPack modifications, refer to the Board.html file.

If you’re using an IDE such as Code Composer Studio (CCS) or IAR, please refer to Board.html in your project directory for resources used and board-specific jumper settings.

The Board.html can also be found in your SDK installation:

<SDK_INSTALL_DIR>/source/ti/boards/<BOARD>

Before running the example the following pins must be connected between the I2C controller and I2C target devices, in addition to GND.

I2C Controller LaunchPad I2C Target LaunchPad
CONFIG_GPIO_I2C_0_SCL CONFIG_GPIO_I2C_0_SCL
CONFIG_GPIO_I2C_0_SDA CONFIG_GPIO_I2C_0_SDA

Example Usage

The connection will have the following settings:

Baud-rate:     115200
Data bits:          8
Stop bits:          1
Parity:          None
Flow Control:    None

Run the example.

  1. CONFIG_GPIO_LED_0 turns ON to indicate the I2C driver initialization is complete.

    Starting the i2ccontroller example
  2. The I2C controller sends the CMD_CTL_GET_STATUS command until a valid response is received.

    Sending GET_STATUS until target responds
  3. When a valid response is received, the example displays this over UART:

    Target responded!
  4. The I2C controller now enters a loop where it will loop through 4 commands.
    1. CMD_CTL_SET_STATUS: Writes a status byte to the target (the status value is incremented for each iteration).
    2. CMD_CTL_GET_STATUS: Reads status byte from the target.
    3. CMD_CTL_WRITE_BLOCK: Write data block to the target.
    4. CMD_CTL_READ_BLOCK: Read data block from the target

    For each command, the controller displays the result over UART and the task sleeps for 1 second.

    Sending SET_STATUS = 0
    Sending GET_STATUS
    GET_STATUS returned 0
    Sending WRITE_BLOCK 'Hi, I am the controller'
    Sending READ_BLOCK
    READ_BLOCK returned 'Hello, I am the target!'

Application Design Details

This application uses one task:

'mainThread' - performs the following actions:

  1. Opens and initializes an I2C driver object.

  2. Uses the I2C driver in blocking mode to send commands over the defined command interface.

  3. Prints command information via the UART.

  4. The task sleeps for 1 second between each command.

FreeRTOS: