Inter-Integrated Circuit (I2C)
12
Inter-Integrated Circuit (I2C)
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
12.1
Introduction
The Inter-Integrated Circuit (I2C) API provides a set of functions for using the I2C master and slave
modules. Functions are provided to initialize the I2C modules, to send and receive data, obtain
status, and to manage interrupts for the I2C modules.
The I2C master and slave modules provide the ability to communicate to other IC devices over an
I2C bus. The I2C bus is specified to support devices that can both transmit and receive (write and
read) data. Also, devices on the I2C bus can be designated as either a master or a slave. The I2C
modules support both sending and receiving data as either a master or a slave, and also support
the simultaneous operation as both a master and a slave. Finally, the I2C modules can operate at
two speeds: Standard (100 kb/s) and Fast (400 kb/s).
Both the master and slave I2C modules can generate interrupts. The I2C master module will
generate interrupts when a transmit or receive operation is completed (or aborted due to an error).
The I2C slave module will generate interrupts when data has been sent or requested by a master.
12.1.1
Master Operations
When using this API to drive the I2C master module, the user must first initialize the I2C master
module with a call to
. That function will set the bus speed and enable
the master module.
The user may transmit or receive data after the successful initialization of the I2C master module.
Data is transferred by first setting the slave address using
. That
function is also used to define whether the transfer is a send (a write to the slave from the master) or
a receive (a read from the slave by the master). Then, if connected to an I2C bus that has multiple
masters, the I2C master must first call
before attempting to initiate the
desired transaction. After determining that the bus is not busy, if trying to send data, the user must
call the
function. The transaction can then be initiated on the bus by
calling the
function with any of the following commands:
I2C_MASTER_CMD_SINGLE_SEND
I2C_MASTER_CMD_SINGLE_RECEIVE
I2C_MASTER_CMD_BURST_SEND_START
I2C_MASTER_CMD_BURST_RECEIVE_START
Any of those commands will result in the master arbitrating for the bus, driving the start sequence
onto the bus, and sending the slave address and direction bit across the bus. The remainder of the
transaction can then be driven using either a polling or interrupt-driven method.
For the single send and receive cases, the polling method will involve looping on the re-
turn from
Once that function indicates that the I2C master is
no longer busy, the bus transaction has been completed and can be checked for errors
April 8, 2013
123
Summary of Contents for Tiva TM4C123GH6PM
Page 26: ...Boot Loader 26 April 8 2013...
Page 68: ...Controller Area Network CAN 68 April 8 2013...
Page 122: ...Hibernation Module 122 April 8 2013...
Page 136: ...Inter Integrated Circuit I2C 136 April 8 2013...
Page 152: ...Memory Protection Unit MPU 152 April 8 2013...
Page 174: ...Pulse Width Modulator PWM Returns None 174 April 8 2013...
Page 196: ...Synchronous Serial Interface SSI 196 April 8 2013...
Page 222: ...System Control 222 April 8 2013...
Page 270: ...UART 270 April 8 2013...
Page 296: ...uDMA Controller 296 April 8 2013...
Page 351: ...April 8 2013 351...