MCUXpresso SDK API Reference Manual  Rev 2.12.1
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

Data Structures

struct  i2c_master_transfer_t
 Non-blocking transfer descriptor structure. More...
 
struct  i2c_master_gpdma_handle_t
 I2C master gpdma transfer structure. More...
 
struct  i2c_slave_transfer_t
 I2C slave transfer structure. More...
 
struct  i2c_slave_gpdma_handle_t
 I2C slave handle structure. More...
 

Macros

#define I2C_MAX_GPDMA_TRANSFER_COUNT   1024
 Maximum lenght of single GPDMA transfer (determined by capability of the GPDMA engine)
 

Typedefs

typedef void(* i2c_master_gpdma_transfer_callback_t )(I2C_Type *base, i2c_master_gpdma_handle_t *handle, status_t status, void *userData)
 I2C master gpdma transfer callback typedef. More...
 
typedef void(* i2c_slave_transfer_callback_t )(I2C_Type *base, volatile i2c_slave_transfer_t *transfer, void *userData)
 Slave event callback function pointer type. More...
 

Enumerations

enum  _i2c_master_transfer_flags {
  kI2C_TransferDefaultFlag = 0x00U,
  kI2C_TransferNoStartFlag = 0x01U,
  kI2C_TransferRepeatedStartFlag = 0x02U,
  kI2C_TransferNoStopFlag = 0x04U
}
 Transfer option flags. More...
 
enum  _i2c_transfer_states
 States for the state machine used by transactional APIs. More...
 
enum  i2c_slave_transfer_event_t {
  kI2C_SlaveAddressMatchEvent = 0x01U,
  kI2C_SlaveTransmitEvent = 0x02U,
  kI2C_SlaveReceiveEvent = 0x04U,
  kI2C_SlaveGpdmaErrorEvent = 0x08U,
  kI2C_SlaveCompletionEvent = 0x20U,
  kI2C_SlaveDeselectedEvent,
  kI2C_SlaveAllEvents
}
 Set of events sent to the callback for non blocking slave transfers. More...
 
enum  i2c_slave_fsm_t
 I2C slave software finite state machine states.
 

Driver version

#define FSL_I2C_GPDMA_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))
 I2C GPDMA driver version. More...
 

I2C master GPDMA Transfer Operation

void I2C_MasterTransferCreateHandleGPDMA (I2C_Type *base, i2c_master_gpdma_handle_t *handle, i2c_master_gpdma_transfer_callback_t callback, void *userData, gpdma_handle_t *gpdmaHandle)
 Init the I2C handle which is used in transactional functions. More...
 
status_t I2C_MasterTransferGPDMA (I2C_Type *base, i2c_master_gpdma_handle_t *handle, i2c_master_transfer_t *xfer)
 Performs a master gpdma non-blocking transfer on the I2C bus. More...
 
status_t I2C_MasterTransferGetCountGPDMA (I2C_Type *base, i2c_master_gpdma_handle_t *handle, size_t *count)
 Get master transfer status during a gpdma non-blocking transfer. More...
 
void I2C_MasterTransferAbortGPDMA (I2C_Type *base, i2c_master_gpdma_handle_t *handle)
 Abort a master gpdma non-blocking transfer in a early time. More...
 

I2C slave GPDMA Transfer Operation

void I2C_SlaveTransferCreateHandleGPDMA (I2C_Type *base, i2c_slave_gpdma_handle_t *handle, i2c_slave_transfer_callback_t callback, void *userData, gpdma_handle_t *gpdmaHandle)
 Creates a new handle for the I2C slave GPDMA APIs. More...
 
status_t I2C_SlaveTransferGPDMA (I2C_Type *base, i2c_slave_gpdma_handle_t *handle, uint32_t eventMask)
 Starts accepting slave transfers. More...
 
status_t I2C_SlaveTransferGetCountGPDMA (I2C_Type *base, i2c_slave_gpdma_handle_t *handle, size_t *count)
 Gets the count of how many bytes have been transfered. More...
 
void I2C_SlaveTransferAbortGPDMA (I2C_Type *base, i2c_slave_gpdma_handle_t *handle)
 Aborts the slave GPDMA transfers. More...
 
void I2C_SlaveTransferGPDMAHandleIRQ (I2C_Type *base, void *i2cHandle)
 Reusable routine to handle slave interrupts. More...
 

Data Structure Documentation

struct _i2c_master_transfer

I2C master transfer typedef.

This structure is used to pass transaction parameters to the I2C_MasterTransferNonBlocking() API.

Data Fields

uint32_t flags
 Bit mask of options for the transfer. More...
 
uint16_t slaveAddress
 The 7-bit slave address. More...
 
i2c_direction_t direction
 Either kI2C_Read or kI2C_Write. More...
 
uint32_t subaddress
 Sub address. More...
 
size_t subaddressSize
 Length of sub address to send in bytes. More...
 
void * data
 Pointer to data to transfer. More...
 
size_t dataSize
 Number of bytes to transfer. More...
 

Field Documentation

uint32_t i2c_master_transfer_t::flags

See enumeration _i2c_master_transfer_flags for available options. Set to 0 or kI2C_TransferDefaultFlag for normal transfers.

uint16_t i2c_master_transfer_t::slaveAddress
i2c_direction_t i2c_master_transfer_t::direction
uint32_t i2c_master_transfer_t::subaddress

Transferred MSB first.

size_t i2c_master_transfer_t::subaddressSize

Maximum size is 4 bytes.

void* i2c_master_transfer_t::data
size_t i2c_master_transfer_t::dataSize
struct _i2c_master_gpdma_handle

I2C master gpdma handle typedef.

Data Fields

uint8_t state
 Transfer state machine current state. More...
 
uint32_t remainingBytesGPDMA
 Remaining byte count to be transferred using GPDMA. More...
 
uint8_t * buf
 Buffer pointer for current state. More...
 
bool checkAddrNack
 Whether to check the nack signal is detected during addressing. More...
 
gpdma_handle_tgpdmaHandle
 The GPDMA handler used. More...
 
i2c_master_transfer_t transfer
 Copy of the current transfer info. More...
 
i2c_master_gpdma_transfer_callback_t completionCallback
 Callback function called after gpdma transfer finished. More...
 
void * userData
 Callback parameter passed to callback function. More...
 

Field Documentation

uint8_t i2c_master_gpdma_handle_t::state
uint32_t i2c_master_gpdma_handle_t::remainingBytesGPDMA
uint8_t* i2c_master_gpdma_handle_t::buf
bool i2c_master_gpdma_handle_t::checkAddrNack
gpdma_handle_t* i2c_master_gpdma_handle_t::gpdmaHandle
i2c_master_transfer_t i2c_master_gpdma_handle_t::transfer
i2c_master_gpdma_transfer_callback_t i2c_master_gpdma_handle_t::completionCallback
void* i2c_master_gpdma_handle_t::userData
struct i2c_slave_transfer_t

Data Fields

i2c_slave_gpdma_handle_t * handle
 Pointer to handle that contains this transfer. More...
 
i2c_slave_transfer_event_t event
 Reason the callback is being invoked. More...
 
uint8_t receivedAddress
 Matching address send by master. More...
 
uint32_t eventMask
 Mask of enabled events. More...
 
uint8_t * rxData
 Transfer buffer for receive data.
 
const uint8_t * txData
 Transfer buffer for transmit data.
 
size_t txSize
 Transfer size.
 
size_t rxSize
 Transfer size.
 
status_t completionStatus
 Success or error code describing how the transfer completed. More...
 

Field Documentation

i2c_slave_gpdma_handle_t* i2c_slave_transfer_t::handle
i2c_slave_transfer_event_t i2c_slave_transfer_t::event
uint8_t i2c_slave_transfer_t::receivedAddress

7-bits plus R/nW bit0

uint32_t i2c_slave_transfer_t::eventMask
status_t i2c_slave_transfer_t::completionStatus

Only applies for kI2C_SlaveCompletionEvent.

struct _i2c_slave_gpdma_handle

I2C slave handle typedef.

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

Data Fields

volatile i2c_slave_transfer_t transfer
 I2C slave transfer. More...
 
gpdma_handle_tgpdmaHandle
 The GPDMA handler used. More...
 
gpdma_transfer_config_t dmaXferConfig
 Structure to store GPDMA transfer configuration. More...
 
volatile bool isBusy
 Whether transfer is busy. More...
 
volatile i2c_slave_fsm_t slaveFsm
 slave transfer state machine. More...
 
i2c_slave_transfer_callback_t callback
 Callback function called at transfer event. More...
 
void * userData
 Callback parameter passed to callback. More...
 

Field Documentation

volatile i2c_slave_transfer_t i2c_slave_gpdma_handle_t::transfer
gpdma_handle_t* i2c_slave_gpdma_handle_t::gpdmaHandle
gpdma_transfer_config_t i2c_slave_gpdma_handle_t::dmaXferConfig
volatile bool i2c_slave_gpdma_handle_t::isBusy
volatile i2c_slave_fsm_t i2c_slave_gpdma_handle_t::slaveFsm
i2c_slave_transfer_callback_t i2c_slave_gpdma_handle_t::callback
void* i2c_slave_gpdma_handle_t::userData

Macro Definition Documentation

#define FSL_I2C_GPDMA_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))

Typedef Documentation

typedef void(* i2c_master_gpdma_transfer_callback_t)(I2C_Type *base, i2c_master_gpdma_handle_t *handle, status_t status, void *userData)
typedef void(* i2c_slave_transfer_callback_t)(I2C_Type *base, volatile i2c_slave_transfer_t *transfer, void *userData)

This callback is used only for the slave non-blocking transfer API. To install a callback, use the I2C_SlaveSetCallback() function after you have created a handle.

Parameters
baseBase address for the I2C instance on which the event occurred.
transferPointer to transfer descriptor containing values passed to and/or from the callback.
userDataArbitrary pointer-sized value passed from the application.

Enumeration Type Documentation

Note
These enumerations are intended to be OR'd together to form a bit mask of options for the _i2c_master_transfer::flags field.
Enumerator
kI2C_TransferDefaultFlag 

Transfer starts with a start signal, stops with a stop signal.

kI2C_TransferNoStartFlag 

Don't send a start condition, address, and sub address.

kI2C_TransferRepeatedStartFlag 

Send a repeated start condition.

kI2C_TransferNoStopFlag 

Don't send a stop condition.

These event enumerations are used for two related purposes. First, a bit mask created by OR'ing together events is passed to I2C_SlaveTransferNonBlocking() in order to specify which events to enable. Then, when the slave callback is invoked, it is passed the current event through its transfer parameter.

Note
These enumerations are meant to be OR'd together to form a bit mask of events.
Enumerator
kI2C_SlaveAddressMatchEvent 

Received the slave address after a start or repeated start.

kI2C_SlaveTransmitEvent 

Callback is requested to provide data to transmit (slave-transmitter role).

kI2C_SlaveReceiveEvent 

Callback is requested to provide a buffer in which to place received data (slave-receiver role).

kI2C_SlaveGpdmaErrorEvent 

Error occured during GPDMA transfer caused by AHB bus error.

kI2C_SlaveCompletionEvent 

All data in the active transfer have been consumed.

kI2C_SlaveDeselectedEvent 

The slave function has become deselected (SLVSEL flag changing from 1 to 0.

kI2C_SlaveAllEvents 

Bit mask of all available events.

Function Documentation

void I2C_MasterTransferCreateHandleGPDMA ( I2C_Type *  base,
i2c_master_gpdma_handle_t *  handle,
i2c_master_gpdma_transfer_callback_t  callback,
void *  userData,
gpdma_handle_t gpdmaHandle 
)
Parameters
baseI2C peripheral base address
handlepointer to i2c_master_gpdma_handle_t structure
callbackpointer to user callback function
userDatauser param passed to the callback function
gpdmaHandleGPDMA handle pointer
status_t I2C_MasterTransferGPDMA ( I2C_Type *  base,
i2c_master_gpdma_handle_t *  handle,
i2c_master_transfer_t *  xfer 
)
Parameters
baseI2C peripheral base address
handlepointer to i2c_master_gpdma_handle_t structure
xferpointer to transfer structure of i2c_master_transfer_t
Return values
kStatus_SuccessSucessully complete the data transmission.
kStatus_I2C_BusyPrevious transmission still not finished.
kStatus_I2C_TimeoutTransfer error, wait signal timeout.
kStatus_I2C_ArbitrationLostTransfer error, arbitration lost.
kStataus_I2C_NakTransfer error, receive Nak during transfer.
status_t I2C_MasterTransferGetCountGPDMA ( I2C_Type *  base,
i2c_master_gpdma_handle_t *  handle,
size_t *  count 
)
Parameters
baseI2C peripheral base address
handlepointer to i2c_master_gpdma_handle_t structure
countNumber of bytes transferred so far by the non-blocking transaction.
void I2C_MasterTransferAbortGPDMA ( I2C_Type *  base,
i2c_master_gpdma_handle_t *  handle 
)
Parameters
baseI2C peripheral base address
handlepointer to i2c_master_gpdma_handle_t structure
void I2C_SlaveTransferCreateHandleGPDMA ( I2C_Type *  base,
i2c_slave_gpdma_handle_t *  handle,
i2c_slave_transfer_callback_t  callback,
void *  userData,
gpdma_handle_t gpdmaHandle 
)

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

Parameters
baseThe I2C peripheral base address.
[out]handlePointer to the I2C slave driver handle.
callbackUser provided pointer to the asynchronous callback function.
userDataUser provided pointer to the application callback data.
gpdmaHandleGPDMA handle pointer
status_t I2C_SlaveTransferGPDMA ( I2C_Type *  base,
i2c_slave_gpdma_handle_t *  handle,
uint32_t  eventMask 
)

Call this API after calling I2C_SlaveInit() and I2C_SlaveTransferCreateHandleGPDMA() to start processing transactions driven by an I2C master. The slave monitors the I2C bus and pass events to the callback that was passed into the call to I2C_SlaveTransferCreateHandleGPDMA(). The callback is always invoked from the interrupt context.

If no slave Tx transfer is busy, a master read from slave request invokes kI2C_SlaveTransmitEvent callback. If no slave Rx transfer is busy, a master write to slave request invokes kI2C_SlaveReceiveEvent callback.

The set of events received by the callback is customizable. To do so, set the eventMask parameter to the OR'd combination of i2c_slave_transfer_event_t enumerators for the events you wish to receive. The kI2C_SlaveTransmitEvent and kI2C_SlaveReceiveEvent events are always enabled and do not need to be included in the mask. Alternatively, you can pass 0 to get a default set of only the transmit and receive events that are always enabled. In addition, the kI2C_SlaveAllEvents constant is provided as a convenient way to enable all events.

Parameters
baseThe I2C peripheral base address.
handlePointer to i2c_slave_gpdma_handle_t structure which stores the transfer state.
eventMaskBit mask formed by OR'ing together i2c_slave_transfer_event_t enumerators to specify which events to send to the callback. Other accepted values are 0 to get a default set of only the transmit and receive events, and kI2C_SlaveAllEvents to enable all events.
Return values
kStatus_SuccessSlave transfers were successfully started.
kStatus_I2C_BusySlave transfers have already been started on this handle.
status_t I2C_SlaveTransferGetCountGPDMA ( I2C_Type *  base,
i2c_slave_gpdma_handle_t *  handle,
size_t *  count 
)
Parameters
baseI2C base pointer.
handlepointer to i2c_slave_gpdma_handle_t structure.
countNumber of bytes transferred so far by the GPDMA transaction.
Return values
kStatus_InvalidArgumentcount is Invalid.
kStatus_SuccessSuccessfully return the count.
void I2C_SlaveTransferAbortGPDMA ( I2C_Type *  base,
i2c_slave_gpdma_handle_t *  handle 
)
Note
This API could be called at any time to stop slave for handling the bus events.
Parameters
baseThe I2C peripheral base address.
handlePointer to i2c_slave_gpdma_handle_t structure which stores the transfer state.
Return values
kStatus_Success
kStatus_I2C_Idle
void I2C_SlaveTransferGPDMAHandleIRQ ( I2C_Type *  base,
void *  i2cHandle 
)
Note
This function does not need to be called unless you are reimplementing the GPDMA API's interrupt handler routines to add special functionality.
Parameters
baseThe I2C peripheral base address.
i2cHandlePointer to i2c_slave_gpdma_handle_t structure which stores the transfer state.