| Kinetis SDK v.2.0 API Reference Manual Rev. 0 Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Typedefs
LPI2C Master DMA Driver
LPI2C: Low Power I2C Driver

## Overview

## Data Structures
struct | lpi2c_master_edma_handle_t
| Driver handle for master DMA APIs. More...

## Typedefs
typedef void(* | lpi2c_master_edma_transfer_callback_t )(LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, status_t completionStatus, void *userData)
| Master DMA completion callback function pointer type. More...

## Master DMA
void | LPI2C_MasterCreateEDMAHandle (LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, edma_handle_t *rxDmaHandle, edma_handle_t *txDmaHandle, lpi2c_master_edma_transfer_callback_t callback, void *userData)
| Create a new handle for the LPI2C master DMA APIs. More...
status_t | LPI2C_MasterTransferEDMA (LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, lpi2c_master_transfer_t *transfer)
| Performs a non-blocking DMA-based transaction on the I2C bus. More...
status_t | LPI2C_MasterTransferGetCountEDMA (LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, size_t *count)
| Returns number of bytes transferred so far. More...
status_t | LPI2C_MasterTransferAbortEDMA (LPI2C_Type *base, lpi2c_master_edma_handle_t *handle)
| Terminates a non-blocking LPI2C master transmission early. More...

## Data Structure Documentation

struct _lpi2c_master_edma_handle

Note
  The contents of this structure are private and subject to change.

### Data Fields
LPI2C_Type * | base
| LPI2C base pointer. More...
bool | isBusy
| Transfer state machine current state. More...
uint16_t | commandBuffer [7]
| LPI2C command sequence. More...
lpi2c_master_transfer_t | transfer
| Copy of the current transfer info. More...
lpi2c_master_edma_transfer_callback_t | completionCallback
| Callback function pointer. More...
void * | userData
| Application data passed to callback. More...
edma_handle_t * | rx
| Handle for receive DMA channel. More...
edma_handle_t * | tx
| Handle for transmit DMA channel. More...
edma_tcd_t | tcds [2]
| Software TCD. More...

#### Field Documentation

LPI2C_Type* lpi2c_master_edma_handle_t::base

bool lpi2c_master_edma_handle_t::isBusy

uint16_t lpi2c_master_edma_handle_t::commandBuffer[7]

lpi2c_master_transfer_t lpi2c_master_edma_handle_t::transfer

lpi2c_master_edma_transfer_callback_t lpi2c_master_edma_handle_t::completionCallback

void* lpi2c_master_edma_handle_t::userData

edma_handle_t* lpi2c_master_edma_handle_t::rx

edma_handle_t* lpi2c_master_edma_handle_t::tx

edma_tcd_t lpi2c_master_edma_handle_t::tcds[2]

Two are allocated to provide enough room to align to 32-bytes.

## Typedef Documentation

typedef void(* lpi2c_master_edma_transfer_callback_t)(LPI2C_Type *base, lpi2c_master_edma_handle_t *handle, status_t completionStatus, void *userData)

This callback is used only for the non-blocking master transfer API. Specify the callback you wish to use in the call to LPI2C_MasterCreateEDMAHandle().

Parameters

  base | The LPI2C peripheral base address.
  handle | Handle associated with the completed transfer.
  completionStatus | Either #kStatus_Success or an error code describing how the transfer completed.
  userData | Arbitrary pointer-sized value passed from the application.

## Function Documentation

void LPI2C_MasterCreateEDMAHandle | ( | LPI2C_Type * | base,
|  | lpi2c_master_edma_handle_t * | handle,
|  | edma_handle_t * | rxDmaHandle,
|  | edma_handle_t * | txDmaHandle,
|  | lpi2c_master_edma_transfer_callback_t | callback,
|  | void * | userData
| ) |  |

The creation of a handle is for use with the DMA APIs. Once a handle is created, there is not a corresponding destroy handle. If the user wants to terminate a transfer, the LPI2C_MasterTransferAbortEDMA() API shall be called.

For devices where the LPI2C send and receive DMA requests are OR'd together, the txDmaHandle parameter is ignored and may be set to NULL.

Parameters

  | base | The LPI2C peripheral base address.
  [out] | handle | Pointer to the LPI2C master driver handle.
  | rxDmaHandle | Handle for the eDMA receive channel. Created by the user prior to calling this function.
  | txDmaHandle | Handle for the eDMA transmit channel. Created by the user prior to calling this function.
  | callback | User provided pointer to the asynchronous callback function.
  | userData | User provided pointer to the application callback data.

status_t LPI2C_MasterTransferEDMA | ( | LPI2C_Type * | base,
|  | lpi2c_master_edma_handle_t * | handle,
|  | lpi2c_master_transfer_t * | transfer
| ) |  |

The callback specified when the handle was created is invoked when the transaction has completed.

Parameters

  base | The LPI2C peripheral base address.
  handle | Pointer to the LPI2C master driver handle.
  transfer | The pointer to the transfer descriptor.

Return values

  #kStatus_Success | The transaction was started successfully.
  kStatus_LPI2C_Busy | Either another master is currently utilizing the bus, or another DMA transaction is already in progress.

status_t LPI2C_MasterTransferGetCountEDMA | ( | LPI2C_Type * | base,
|  | lpi2c_master_edma_handle_t * | handle,
|  | size_t * | count
| ) |  |

Parameters

  | base | The LPI2C peripheral base address.
  | handle | Pointer to the LPI2C master driver handle.
  [out] | count | Number of bytes transferred so far by the non-blocking transaction.

Return values

  #kStatus_Success |
  #kStatus_NoTransferInProgress | There is not a DMA transaction currently in progress.

status_t LPI2C_MasterTransferAbortEDMA | ( | LPI2C_Type * | base,
|  | lpi2c_master_edma_handle_t * | handle
| ) |  |

Note
  It is not safe to call this function from an IRQ handler that has a higher priority than the eDMA peripheral's IRQ priority.

Parameters

  base | The LPI2C peripheral base address.
  handle | Pointer to the LPI2C master driver handle.

Return values

  #kStatus_Success | A transaction was successfully aborted.
  kStatus_LPI2C_Idle | There is not a DMA transaction currently in progress.