Example Summary
Sample application using the I2CTarget driver to be an I2C target device. The example implements a simple command interface (see cmdinterface.h).
This example is intended for use together with the i2ccontroller 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.
CONFIG_GPIO_LED_0- Indicator LED.CONFIG_GPIO_LED_1- Indicator LED toggling for incoming commands.CONFIG_I2C_0- I2C bus used to communicate with the TMP sensor.
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
Run the example.
CONFIG_GPIO_LED_0turns ON to indicate the I2CTarget driver initialization is complete.CONFIG_GPIO_LED_1toggles when commands are received over theCONFIG_I2C_0I2C bus.- The example implements 4 commands (see cmdinterface.h)
CMD_CTL_SET_STATUS: The example receives 1 byte and stores it inrxBuffer[0].CMD_CTL_GET_STATUS: The example returns the value stored inrxBuffer[0].CMD_CTL_WRITE_BLOCK: The example receives N bytes and stores it inrxBuffer.CMD_CTL_READ_BLOCK: The example fillstxBufferwith ‘Hello, I am the target!’ and returns the N bytes requested by the I2C controller.
Application Design Details
This application uses one task:
'mainThread' - performs the following actions:
Opens and initializes an I2CTarget driver object.
Starts I2CTarget driver to send/receive data over the defined command interface.
The task wakes up every 1 second.
FreeRTOS:
- Please view the
FreeRTOSConfig.hheader file for example configuration information.