![]() |
MCUXpresso SDK API Reference Manual
Rev 2.12.1
NXP Semiconductors
|
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... | |
| 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... | |
| 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_t * | gpdmaHandle |
| 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... | |
| 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... | |
| 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.
Data Fields | |
| volatile i2c_slave_transfer_t | transfer |
| I2C slave transfer. More... | |
| gpdma_handle_t * | gpdmaHandle |
| 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... | |
| 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 |
| #define FSL_I2C_GPDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
| 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.
| base | Base address for the I2C instance on which the event occurred. |
| transfer | Pointer to transfer descriptor containing values passed to and/or from the callback. |
| userData | Arbitrary pointer-sized value passed from the application. |
| enum _i2c_transfer_states |
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.
| 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 | ||
| ) |
| base | I2C peripheral base address |
| handle | pointer to i2c_master_gpdma_handle_t structure |
| callback | pointer to user callback function |
| userData | user param passed to the callback function |
| gpdmaHandle | GPDMA handle pointer |
| status_t I2C_MasterTransferGPDMA | ( | I2C_Type * | base, |
| i2c_master_gpdma_handle_t * | handle, | ||
| i2c_master_transfer_t * | xfer | ||
| ) |
| base | I2C peripheral base address |
| handle | pointer to i2c_master_gpdma_handle_t structure |
| xfer | pointer to transfer structure of i2c_master_transfer_t |
| kStatus_Success | Sucessully complete the data transmission. |
| kStatus_I2C_Busy | Previous transmission still not finished. |
| kStatus_I2C_Timeout | Transfer error, wait signal timeout. |
| kStatus_I2C_ArbitrationLost | Transfer error, arbitration lost. |
| kStataus_I2C_Nak | Transfer error, receive Nak during transfer. |
| status_t I2C_MasterTransferGetCountGPDMA | ( | I2C_Type * | base, |
| i2c_master_gpdma_handle_t * | handle, | ||
| size_t * | count | ||
| ) |
| base | I2C peripheral base address |
| handle | pointer to i2c_master_gpdma_handle_t structure |
| count | Number of bytes transferred so far by the non-blocking transaction. |
| void I2C_MasterTransferAbortGPDMA | ( | I2C_Type * | base, |
| i2c_master_gpdma_handle_t * | handle | ||
| ) |
| base | I2C peripheral base address |
| handle | pointer 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.
| base | The I2C peripheral base address. | |
| [out] | handle | Pointer to the I2C slave driver handle. |
| callback | User provided pointer to the asynchronous callback function. | |
| userData | User provided pointer to the application callback data. | |
| gpdmaHandle | GPDMA 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.
| base | The I2C peripheral base address. |
| handle | Pointer to i2c_slave_gpdma_handle_t structure which stores the transfer state. |
| eventMask | Bit 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. |
| kStatus_Success | Slave transfers were successfully started. |
| kStatus_I2C_Busy | Slave transfers have already been started on this handle. |
| status_t I2C_SlaveTransferGetCountGPDMA | ( | I2C_Type * | base, |
| i2c_slave_gpdma_handle_t * | handle, | ||
| size_t * | count | ||
| ) |
| base | I2C base pointer. |
| handle | pointer to i2c_slave_gpdma_handle_t structure. |
| count | Number of bytes transferred so far by the GPDMA transaction. |
| kStatus_InvalidArgument | count is Invalid. |
| kStatus_Success | Successfully return the count. |
| void I2C_SlaveTransferAbortGPDMA | ( | I2C_Type * | base, |
| i2c_slave_gpdma_handle_t * | handle | ||
| ) |
| base | The I2C peripheral base address. |
| handle | Pointer to i2c_slave_gpdma_handle_t structure which stores the transfer state. |
| kStatus_Success | |
| kStatus_I2C_Idle |
| void I2C_SlaveTransferGPDMAHandleIRQ | ( | I2C_Type * | base, |
| void * | i2cHandle | ||
| ) |
| base | The I2C peripheral base address. |
| i2cHandle | Pointer to i2c_slave_gpdma_handle_t structure which stores the transfer state. |