Staging:CC3220 I2C Application

Overview
The Inter-Integrated Circuit (I2C) bus provides bi-directional data transfer through a two-wire design (a serial data line SDA and a serial clock line SCL),and interfaces to external I2C devices.On the LaunchPad there are two sensors connected over the I2C namely Accelerometer and Temperature sensor. The I2C lines are also brought out on the header for further expansion (to connect to sensors on booster packs).

Application details
The objective of this application is act as an I2C diagnostic tool. The demo application is a generic implementation that allows the user to communicate with any I2C device over the lines. The features supported by the application are:
 * I2C write: Performs write operation to the specified I2C device address.
 * I2C Read: Performs I2C read from the specified I2C device address.
 * I2C Readreg: Is a combination of I2C write + I2C read. This is useful to get register values from the specified register offset from a I2C device. This command assumes the register offset to be 1 byte.


 * I2C Writereg: Performs an I2C writes from the specified offset register. This command assumes the register offset to be 1 byte.

The write and read are core APIs that follow the I2C specification for its operation. They are generic and can be used to communicate with any I2C device.

The readreg and writereg are ready to use APIs that internally invoke the read and write functionality. These have been provided for ease of use and is not guaranteed to work for all I2C devices due to some assumptions made.

Source Files briefly explained

 * main: - Prompts and services the user options by invoking the TI-Driver's i2c APIs.
 * cc_launchpad: - Contains mandatory board specific initialization. Also initializes the peripherals exercised.
 * pinmux: - Pinmux configurations as required by the application.
 * startup_*: - IDE specific startup functions (not required when working with TI-RTOS).
 * uart_if: - To display status information over the UART

 Available Configuration 


 * Non-blocking I2C read/write - Define I2C_NON_BLOCKING in project properties to enable I2C read/write in non-blocking mode.
 * Blocking I2C read/write - Undefined I2C_NON_BLOCKING in project properties to enable I2C read/write in blocking mode. By default this mode is enabled.

Usage
For this application to work, one needs to populate jumpers at J2 and J3 on LP'''


 * 1) Setup a serial communication application (HyperTerminal/TeraTerm). For detail info visit Terminal setup On the host PC, open a hyperterminal, with the following settings
 * 2) *Port: Enumerated COM port (XDS110 Class Application/User UART)
 * 3) *Baud rate: 115200
 * 4) *Data: 8 bit
 * 5) *Parity: None
 * 6) *Stop: 1 bit
 * 7) *Flow control: None
 * 8) Run the reference application (Flashing the bin/IAR/CCS).
 * 9) *Open the Project as mentioned in the 'docs\CC3220-Getting Started Guide.pdf'
 * 10) *Build and download the application to the board
 * 11) On the Hyperterminal, a prompt appears
 * 12) *The I2C commands need to be issued and the results can be seen

CC3220 I2C Example Usage

Commands:


 * write &lt;dev_addr&gt; &lt;wrlen&gt; &lt;&lt;byte0&gt; [&lt;byte1&gt; ... ]&gt;
 * read &lt;dev_addr&gt; &lt;rdlen&gt;
 * writereg &lt;dev_addr&gt; &lt;reg_offset&gt; &lt;wrlen&gt; &lt;&lt;byte0&gt; [&lt;byte1&gt; ... ]&gt; readreg &lt;dev_addr&gt; &lt;reg_offset&gt; &lt;rdlen&gt;

Parameters:

dev_addr - slave address of the i2c device, a hex value preceeded by '0x'          reg_offset - register address in the i2c device, a hex value preceded by '0x'

wrlen - number of bytes to be written, a decimal value          rdlen - number of bytes to be read, a decimal value

bytex - value of the data to be written, a hex value preceded by '0x'

The user can determine the device address of a particular component by looking at its respective datasheet.


 * The temperature sensor used is tmp006, and its device address (dev_addr) is 0x41
 * The accelerometer sensor used is bma222, and its device address (dev_addr) is 0x18

For instance


 * To read the manufacturer id register (0xFE) of the temperature sensor (0x41), the command will be

readreg 0x41 0xFE 2


 * To read the "who am i" register (0x00) of the accelerometer sensor (0x18), the command will be

readreg 0x18 0x00 1

Snapshot of the Hyperterminal when the application starts.



Limitations/Known Issues

 * 1) This example exercise only standard speeds(100Kbps and 400Kbps) for I2C clock. High speed(1 Mbps and 3.3 Mbps) I2C clocks are supported in driverlib, but not exercised in this example.
 * 2) Populating the jumpers J2 and J3 will turn the LED D5 and D6 on and hence will not be available for use.