| Kinetis SDK API Reference Manual 1.0.0-beta Freescale Semiconductor, Inc.

- Introduction
- Related Pages
- API Usage

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Enumerations
I2C Master peripheral
Inter-Integrated Circuit (I2C)

The section describes the programming interface of the I2C master mode Peripheral driver. More...

## Data Structures
struct | i2c_device_t
| Information necessary to communicate with an I2C slave device. More...
struct | i2c_master_t
| Internal driver state information. More...

## Enumerations
enum | i2c_direction_t { kI2CRead = 1, kI2CWrite = 0 }
| Constants for the direction of an I2C transfer. More...
enum | _i2c_transfer_flags { kI2CNoStart = 1 << 1, kI2CNoStop = 1 << 2 }
| Optional flags to control a transfer. More...

## I2C Master
void | i2c_master_init (uint32_t instance, i2c_master_t *master)
| Initialize the I2C master mode driver. More...
void | i2c_master_shutdown (i2c_master_t *master)
| Shut down the driver. More...
i2c_status_t | i2c_master_configure_bus (i2c_master_t *master, const i2c_device_t *device)
| Configure the I2C bus to access a device. More...
i2c_status_t | i2c_master_transfer_basic (i2c_master_t *master, uint32_t flags, i2c_direction_t direction, uint8_t *data, size_t dataLength, size_t *actualLengthTransferred, uint32_t timeout_ms)
| Low-level I2C transfer function. More...
i2c_status_t | i2c_master_transfer (i2c_master_t *master, const i2c_device_t *device, i2c_direction_t direction, bool stopAfterTransfer, uint32_t subaddress, size_t subaddressLength, uint8_t *data, size_t dataLength, size_t *actualLengthTransferred, uint32_t timeout_ms)
| Perform a blocking read or write transaction on the I2C bus. More...

## Data Structure Documentation

struct i2c_device_t

### Data Fields
uint8_t | address
| The slave's 7-bit address. More...
uint32_t | baudRate_kbps
| The baud rate in kbps to use with this slave device. More...

#### Field Documentation

uint8_t i2c_device_t::address

uint32_t i2c_device_t::baudRate_kbps

struct i2c_master_t

Note
  The contents of this structure are internal to the driver and should not be modified by users. Also, contents of the structure are subject to change in future releases.

### Data Fields
uint32_t | instance
bool | isTransferInProgress
uint32_t | flags
i2c_direction_t | direction
uint8_t * | data
volatile size_t | dataRemainingCount
volatile size_t | bytesTransferredCount
volatile bool | gotNak
uint32_t | lastBaudRate_kbps
sync_object_t | irqSync

## Enumeration Type Documentation

enum i2c_direction_t

Enumerator
kI2CRead | Read from slave device.
kI2CWrite | Write to slave device.

enum _i2c_transfer_flags

Enumerator
kI2CNoStart | Set this flag to prevent sending a START signal.
kI2CNoStop | Set this flag to prevent sending a STOP signal.

## Function Documentation

void i2c_master_init | ( | uint32_t | instance,
|  | i2c_master_t * | master
| ) |  |

Parameters

  instance | The I2C peripheral instance number.
  master | The pointer to the I2C master driver state structure.

void i2c_master_shutdown | ( | i2c_master_t * | master | ) |

Parameters

  master | The pointer to the I2C master driver state structure.

i2c_status_t i2c_master_configure_bus | ( | i2c_master_t * | master,
|  | const i2c_device_t * | device
| ) |  |

Parameters

  master | The pointer to the I2C master driver state structure.
  device | The pointer to the I2C device information struct.

i2c_status_t i2c_master_transfer_basic | ( | i2c_master_t * | master,
|  | uint32_t | flags,
|  | i2c_direction_t | direction,
|  | uint8_t * | data,
|  | size_t | dataLength,
|  | size_t * | actualLengthTransferred,
|  | uint32_t | timeout_ms
| ) |  |

Parameters

  master | The pointer to the I2C master driver state structure.
  flags | The flags to control a transfer.
  direction | The direction of an I2C transfer.
  data | The pointer to the data to be transfered.
  dataLength | The length in bytes of the data to be transfered.
  actualLengthTransferred | The length in bytes of the data thansfered.
  timeous_ms | A timeout for the transfer in microseconds.

i2c_status_t i2c_master_transfer | ( | i2c_master_t * | master,
|  | const i2c_device_t * | device,
|  | i2c_direction_t | direction,
|  | bool | stopAfterTransfer,
|  | uint32_t | subaddress,
|  | size_t | subaddressLength,
|  | uint8_t * | data,
|  | size_t | dataLength,
|  | size_t * | actualLengthTransferred,
|  | uint32_t | timeout_ms
| ) |  |

Parameters

  master | The pointer to the I2C master driver state structure.
  device | The pointer to the I2C device information struct.
  direction | The direction of an I2C transfer.
  stopAfterTransfer | Send STOP signal after this transfer or not.
  subaddress | The subaddress for a device if it has.
  subaddressLength | The length of the subaddress.
  data | The pointer to the data to be transfered.
  dataLength | The length in bytes of the data to be transfered.
  actualLengthTransferred | The length in bytes of the data thansfered.
  timeous_ms | A timeout for the transfer in microseconds.