MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
LPI2C: Low Power Inter-Integrated Circuit Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 LPI2C Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current LPI2C driver version is 2.0.0.
 

Data Structures

struct  lpi2c_master_config_t
 Structure with settings to initialize the LPI2C master module. More...
 
struct  lpi2c_slave_config_t
 Structure with settings to initialize the LPI2C slave module. More...
 
struct  lpi2c_config_t
 Structure with settings to initialize the LPI2C module. More...
 
struct  lpi2c_data_match_config_t
 LPI2C master data match configuration structure. More...
 
struct  lpi2c_master_transfer_t
 Non-blocking transfer descriptor structure. More...
 
struct  lpi2c_master_transfer_handle_t
 Driver handle for master non-blocking APIs. More...
 
struct  lpi2c_slave_transfer_t
 LPI2C slave transfer structure. More...
 
struct  lpi2c_slave_transfer_handle_t
 LPI2C slave handle structure. More...
 

Macros

#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL   0U
 Clock enable/disable controlled by driver or not. More...
 
#define I2C_RETRY_TIMES   0U /* Define to zero means keep waiting until the flag is assert/deassert. */
 Retry times for waiting flag. More...
 
#define I2C_SMBUS_ENABLE   0U /* Default defines to zero, driver uses simple I2C transfer. */
 Control whether to use SMBus features. More...
 

Enumerations

enum  {
  kStatus_LPI2C_Busy = MAKE_STATUS(kStatusGroup_LPI2C, 0),
  kStatus_LPI2C_Idle = MAKE_STATUS(kStatusGroup_LPI2C, 1),
  kStatus_LPI2C_Nak = MAKE_STATUS(kStatusGroup_LPI2C, 2),
  kStatus_LPI2C_FifoError = MAKE_STATUS(kStatusGroup_LPI2C, 3),
  kStatus_LPI2C_BitError = MAKE_STATUS(kStatusGroup_LPI2C, 4),
  kStatus_LPI2C_ArbitrationLost = MAKE_STATUS(kStatusGroup_LPI2C, 5),
  kStatus_LPI2C_PinLowTimeout,
  kStatus_LPI2C_NoTransferInProgress,
  kStatus_LPI2C_DmaRequestFail = MAKE_STATUS(kStatusGroup_LPI2C, 8),
  kStatus_LPI2C_Timeout = MAKE_STATUS(kStatusGroup_LPI2C, 9)
}
 LPI2C status return codes. More...
 

Driver version

#define FSL_LPI2C_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 

Hardware Status Flags Sub-group

enum  _lpi2c_master_status_flags {
  kLPI2C_MasterTxReadyInterruptFlag = LPI2C_MSR_TDF_MASK,
  kLPI2C_MasterRxReadyInterruptFlag = LPI2C_MSR_RDF_MASK,
  kLPI2C_MasterEndOfPacketInterruptFlag = LPI2C_MSR_EPF_MASK,
  kLPI2C_MasterStopDetectInterruptFlag = LPI2C_MSR_SDF_MASK,
  kLPI2C_MasterNackDetectInterruptFlag = LPI2C_MSR_NDF_MASK,
  kLPI2C_MasterArbitrationLostInterruptFlag = LPI2C_MSR_ALF_MASK,
  kLPI2C_MasterFifoErrInterruptFlag = LPI2C_MSR_FEF_MASK,
  kLPI2C_MasterPinLowTimeoutInterruptFlag = LPI2C_MSR_PLTF_MASK,
  kLPI2C_MasterDataMatchInterruptFlag = LPI2C_MSR_DMF_MASK,
  kLPI2C_MasterBusyFlag = LPI2C_MSR_MBF_MASK,
  kLPI2C_MasterBusBusyFlag = LPI2C_MSR_BBF_MASK ,
  kLPI2C_MasterClearInterruptFlags,
  kLPI2C_MasterIrqFlags,
  kLPI2C_MasterErrorInterruptFlags
}
 LPI2C master peripheral flags. More...
 
enum  _lpi2c_slave_status_flags {
  kLPI2C_SlaveTxReadyInterruptFlag = LPI2C_SSR_TDF_MASK,
  kLPI2C_SlaveRxReadyInterruptFlag = LPI2C_SSR_RDF_MASK,
  kLPI2C_SlaveAddressValidInterruptFlag = LPI2C_SSR_AVF_MASK,
  kLPI2C_SlaveTransmitAckInterruptFlag = LPI2C_SSR_TAF_MASK,
  kLPI2C_SlaveRepeatedStartDetectInterruptFlag = LPI2C_SSR_RSF_MASK,
  kLPI2C_SlaveStopDetectInterruptFlag = LPI2C_SSR_SDF_MASK,
  kLPI2C_SlaveBitErrInterruptFlag = LPI2C_SSR_BEF_MASK,
  kLPI2C_SlaveFifoErrInterruptFlag = LPI2C_SSR_FEF_MASK,
  kLPI2C_SlaveAddressMatch0InterruptFlag = LPI2C_SSR_AM0F_MASK,
  kLPI2C_SlaveAddressMatch1InterruptFlag = LPI2C_SSR_AM1F_MASK,
  kLPI2C_SlaveGeneralCallInterruptFlag = LPI2C_SSR_GCF_MASK,
  kLPI2C_SlaveSmbusAlertRespInterruptFlag = LPI2C_SSR_SARF_MASK,
  kLPI2C_SlaveBusyFlag = LPI2C_SSR_SBF_MASK,
  kLPI2C_SlaveBusBusyFlag = LPI2C_SSR_BBF_MASK ,
  kLPI2C_SlaveClearInterruptFlags,
  kLPI2C_SlaveIrqFlags,
  kLPI2C_SlaveErrorInterruptFlags = kLPI2C_SlaveFifoErrInterruptFlag | kLPI2C_SlaveBitErrInterruptFlag
}
 LPI2C slave peripheral flags. More...
 
static uint16_t LPI2C_MasterGetStatusFlags (LPI2C_Type *base)
 Gets the LPI2C master status flags. More...
 
static void LPI2C_MasterClearStatusFlags (LPI2C_Type *base, uint16_t u16StatusFlags)
 Clears the LPI2C master status flag state. More...
 
static uint16_t LPI2C_SlaveGetStatusFlags (LPI2C_Type *base)
 Gets the LPI2C slave status flags. More...
 
static void LPI2C_SlaveClearStatusFlags (LPI2C_Type *base, uint16_t u16StatusFlags)
 Clears the LPI2C status flag state. More...
 

Module Init/Deinit Sub-group

void LPI2C_GetDefaultConfig (lpi2c_config_t *psConfig, uint16_t u16SlaveAddress, uint32_t u32SrcClockHz)
 Provides a default configuration for the LPI2C peripheral, including master and slave. More...
 
void LPI2C_Init (LPI2C_Type *base, const lpi2c_config_t *psConfig)
 Initializes the LPI2C peripheral, including master and slave. More...
 
void LPI2C_Deinit (LPI2C_Type *base)
 Deinitializes the LPI2C peripheral, including master and slave. More...
 
void LPI2C_MasterGetDefaultConfig (lpi2c_master_config_t *psMasterConfig, uint32_t u32SrcClockHz)
 Provides a default configuration for the LPI2C master peripheral. More...
 
void LPI2C_MasterInit (LPI2C_Type *base, const lpi2c_master_config_t *psMasterConfig)
 Initializes the LPI2C master peripheral. More...
 
void LPI2C_MasterDeinit (LPI2C_Type *base)
 Deinitializes the LPI2C master peripheral. More...
 
void LPI2C_SlaveGetDefaultConfig (lpi2c_slave_config_t *psSlaveConfig, uint16_t u16SlaveAddress, uint32_t u32SrcClockHz)
 Provides a default configuration for the LPI2C slave peripheral. More...
 
void LPI2C_SlaveInit (LPI2C_Type *base, const lpi2c_slave_config_t *psSlaveConfig)
 Initializes the LPI2C slave peripheral. More...
 
void LPI2C_SlaveDeinit (LPI2C_Type *base)
 Deinitializes the LPI2C slave peripheral. More...
 

Master Module Configuration Sub-group

enum  lpi2c_master_pin_config_t {
  kLPI2C_2PinOpenDrain = 0x0U,
  kLPI2C_2PinOutputOnly = 0x1U,
  kLPI2C_2PinPushPull = 0x2U,
  kLPI2C_4PinPushPull = 0x3U,
  kLPI2C_2PinOpenDrainWithSeparateSlave,
  kLPI2C_2PinOutputOnlyWithSeparateSlave,
  kLPI2C_2PinPushPullWithSeparateSlave,
  kLPI2C_4PinPushPullWithInvertedOutput = 0x7U
}
 LPI2C pin configuration. More...
 
enum  lpi2c_host_request_source_t {
  kLPI2C_HostRequestExternalPin = 0x0U,
  kLPI2C_HostRequestInputTrigger = 0x1U
}
 LPI2C master host request selection. More...
 
enum  lpi2c_host_request_polarity_t {
  kLPI2C_HostRequestPinActiveLow = 0x0U,
  kLPI2C_HostRequestPinActiveHigh = 0x1U
}
 LPI2C master host request pin polarity configuration. More...
 
enum  lpi2c_data_match_config_mode_t {
  kLPI2C_MatchDisabled = 0x0U,
  kLPI2C_1stWordEqualsM0OrM1 = 0x2U,
  kLPI2C_AnyWordEqualsM0OrM1 = 0x3U,
  kLPI2C_1stWordEqualsM0And2ndWordEqualsM1,
  kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1,
  kLPI2C_1stWordAndM1EqualsM0AndM1,
  kLPI2C_AnyWordAndM1EqualsM0AndM1
}
 LPI2C master data match configuration modes. More...
 
void LPI2C_MasterSetBaudRate (LPI2C_Type *base, uint32_t u32SrcClockHz, uint32_t u32BaudRateBps)
 Sets the I2C bus frequency for master transactions. More...
 
void LPI2C_MasterSetGlitchFilter (LPI2C_Type *base, uint32_t u32SdaFilterWidthNs, uint32_t u32SclFilterWidthNs, uint32_t u32SrcClockHz)
 Sets the LPI2C master glitch filter width. More...
 
void LPI2C_MasterSetDataMatch (LPI2C_Type *base, const lpi2c_data_match_config_t *psConfig)
 Configures LPI2C master data match feature. More...
 
static void LPI2C_MasterReset (LPI2C_Type *base)
 Performs a software reset. More...
 
static void LPI2C_MasterEnable (LPI2C_Type *base, bool bEnable)
 Enables or disables the LPI2C module as master. More...
 
static void LPI2C_MasterSetWatermarks (LPI2C_Type *base, uint16_t u16TxWords, uint16_t u16RxWords)
 Sets the watermarks for LPI2C master FIFOs. More...
 
static void LPI2C_MasterGetFifoCounts (LPI2C_Type *base, uint16_t *pu16RxCount, uint16_t *pu16TxCount)
 Gets the current number of words in the LPI2C master FIFOs. More...
 

Slave Module Configuration Sub-group

enum  lpi2c_slave_address_match_t {
  kLPI2C_Match7BitAddress0 = 0U,
  kLPI2C_Match10BitAddress0 = 1U,
  kLPI2C_Match7BitAddress0Or7BitAddress1 = 2U,
  kLPI2C_Match10BitAddress0Or10BitAddress1 = 3U,
  kLPI2C_Match7BitAddress0Or10BitAddress1 = 4U,
  kLPI2C_Match10BitAddress0Or7BitAddress1 = 5U,
  kLPI2C_Match7BitAddress0Through7BitAddress1,
  kLPI2C_Match10BitAddress0Through10BitAddress1
}
 LPI2C slave address match options. More...
 
void LPI2C_SlaveSetGlitchFilter (LPI2C_Type *base, uint32_t u32SdaFilterWidthNs, uint32_t u32SclFilterWidthNs, uint32_t u32SrcClockHz)
 Sets the LPI2C slave glitch filter width. More...
 
void LPI2C_SlaveSetAddressingMode (LPI2C_Type *base, lpi2c_slave_address_match_t eAddressMatchMode, uint16_t u16Address0, uint16_t u16Address1)
 Configure the slave addressing mode. More...
 
static void LPI2C_SlaveReset (LPI2C_Type *base)
 Performs a software reset of the LPI2C slave peripheral. More...
 
static void LPI2C_SlaveEnable (LPI2C_Type *base, bool bEnable)
 Enables or disables the LPI2C module as slave. More...
 

Master Bus operations Sub-Group

enum  lpi2c_data_direction_t {
  kLPI2C_Write = 0U,
  kLPI2C_Read = 1U
}
 Direction of master and slave transfers. More...
 
status_t LPI2C_MasterCheckAndClearError (LPI2C_Type *base, uint16_t u16Status)
 
status_t LPI2C_MasterCheckForBusyBus (LPI2C_Type *base)
 
status_t LPI2C_MasterStartInternal (LPI2C_Type *base, uint8_t u8Address, lpi2c_data_direction_t eDir, bool bIsRepeatedStart)
 
static status_t LPI2C_MasterStart (LPI2C_Type *base, uint8_t u8Address, lpi2c_data_direction_t eDir)
 Sends a START signal and slave address on the I2C bus. More...
 
static status_t LPI2C_MasterRepeatedStart (LPI2C_Type *base, uint8_t u8Address, lpi2c_data_direction_t eDir)
 Sends a repeated START signal and slave address on the I2C bus. More...
 
status_t LPI2C_MasterStop (LPI2C_Type *base)
 Sends a STOP signal on the I2C bus. More...
 
status_t LPI2C_MasterSend (LPI2C_Type *base, void *pTxBuff, uint16_t u16TxSize, bool bPecEnable)
 Performs a polling send transfer on the I2C bus. More...
 
status_t LPI2C_MasterReceive (LPI2C_Type *base, void *pRxBuff, uint16_t u16RxSize, bool bPecEnable)
 Performs a polling receive transfer on the I2C bus. More...
 

Master Transfer Sub-group

enum  _lpi2c_master_transfer_control_flags {
  kLPI2C_TransferStartStopFlag = 0x00U,
  kLPI2C_TransferNoStartFlag = 0x01U,
  kLPI2C_TransferRepeatedStartFlag = 0x02U,
  kLPI2C_TransferNoStopFlag = 0x04U
}
 Transfer option flags. More...
 
typedef void(* lpi2c_master_transfer_callback_t )(lpi2c_master_transfer_handle_t *psHandle)
 Master completion callback function pointer type. More...
 
status_t LPI2C_MasterTransferBlocking (LPI2C_Type *base, lpi2c_master_transfer_t *psTransfer)
 Performs a master polling transfer on the I2C bus. More...
 
void LPI2C_MasterTransferCreateHandle (LPI2C_Type *base, lpi2c_master_transfer_handle_t *psHandle, lpi2c_master_transfer_callback_t pfCallback, void *pUserData)
 Creates a new handle for the LPI2C master non-blocking APIs. More...
 
status_t LPI2C_MasterTransferNonBlocking (lpi2c_master_transfer_handle_t *psHandle, lpi2c_master_transfer_t *psTransfer)
 Performs a non-blocking transaction on the I2C bus. More...
 
status_t LPI2C_MasterTransferGetCount (lpi2c_master_transfer_handle_t *psHandle, uint16_t *pu16Count)
 Returns number of bytes transferred so far. More...
 
void LPI2C_MasterTransferAbort (lpi2c_master_transfer_handle_t *psHandle)
 Terminates a non-blocking LPI2C master transmission early. More...
 
void LPI2C_MasterTransferHandleIRQ (lpi2c_master_transfer_handle_t *psHandle)
 Reusable routine to handle master interrupts. More...
 

Slave Transfer Sub-group

enum  lpi2c_slave_transfer_event_t {
  kLPI2C_SlaveAddressMatchEvent = 0x01U,
  kLPI2C_SlaveTransmitEvent = 0x02U,
  kLPI2C_SlaveReceiveEvent = 0x04U,
  kLPI2C_SlaveTransmitAckEvent = 0x08U,
  kLPI2C_SlaveRepeatedStartEvent = 0x10U,
  kLPI2C_SlaveCompletionEvent = 0x20U,
  kLPI2C_SlaveAllEvents
}
 Set of events sent to the callback for non blocking slave transfers. More...
 
typedef void(* lpi2c_slave_transfer_callback_t )(lpi2c_slave_transfer_handle_t *psHandle)
 Slave event callback function pointer type. More...
 
void LPI2C_SlaveTransferCreateHandle (LPI2C_Type *base, lpi2c_slave_transfer_handle_t *psHandle, lpi2c_slave_transfer_callback_t pfCallback, void *pUserData)
 Creates a new handle for the LPI2C slave non-blocking APIs. More...
 
status_t LPI2C_SlaveTransferNonBlocking (lpi2c_slave_transfer_handle_t *psHandle, uint8_t u8EventMask)
 Starts accepting slave transfers. More...
 
status_t LPI2C_SlaveTransferGetCount (lpi2c_slave_transfer_handle_t *psHandle, uint16_t *pu16Count)
 Gets the slave transfer status during a non-blocking transfer. More...
 
void LPI2C_SlaveTransferAbort (lpi2c_slave_transfer_handle_t *psHandle)
 Aborts the slave non-blocking transfers. More...
 
void LPI2C_SlaveTransferHandleIRQ (lpi2c_slave_transfer_handle_t *psHandle)
 Reusable routine to handle slave interrupts. More...
 

Interrupt Sub-group

static void LPI2C_MasterEnableInterrupts (LPI2C_Type *base, uint16_t u16Interrupts)
 Enables the LPI2C master interrupt requests. More...
 
static void LPI2C_MasterDisableInterrupts (LPI2C_Type *base, uint16_t u16Interrupts)
 Disables the LPI2C master interrupt requests. More...
 
static uint16_t LPI2C_MasterGetEnabledInterrupts (LPI2C_Type *base)
 Returns the set of currently enabled LPI2C master interrupt requests. More...
 
static void LPI2C_SlaveEnableInterrupts (LPI2C_Type *base, uint16_t u16Interrupts)
 Enables the LPI2C slave interrupt requests. More...
 
static void LPI2C_SlaveDisableInterrupts (LPI2C_Type *base, uint16_t u16Interrupts)
 Disables the LPI2C slave interrupt requests. More...
 
static uint16_t LPI2C_SlaveGetEnabledInterrupts (LPI2C_Type *base)
 Returns the set of currently enabled LPI2C slave interrupt requests. More...
 

Master DMA control Sub-group

static void LPI2C_MasterEnableDMA (LPI2C_Type *base, bool bEnableTx, bool bEnableRx)
 Enables or disables LPI2C master DMA requests. More...
 
static uint16_t * LPI2C_MasterGetTxFifoAddress (LPI2C_Type *base)
 Gets LPI2C master transmit data register address for DMA transfer. More...
 
static uint16_t * LPI2C_MasterGetRxFifoAddress (LPI2C_Type *base)
 Gets LPI2C master receive data register address for DMA transfer. More...
 

Slave DMA control Sub-group

static void LPI2C_SlaveEnableDMA (LPI2C_Type *base, bool bEnableAddressValid, bool bEnableRx, bool bEnableTx)
 Enables or disables the LPI2C slave peripheral DMA requests. More...
 

Slave Bus operations Sub-Group

static bool LPI2C_SlaveGetBusIdleState (LPI2C_Type *base)
 Returns whether the bus is idle. More...
 
static void LPI2C_SlaveTransmitAck (LPI2C_Type *base, bool bSendAck)
 Transmits either an ACK or NAK on the I2C bus in response to a byte from the master. More...
 
static uint16_t LPI2C_SlaveGetReceivedAddress (LPI2C_Type *base)
 Returns the slave address sent by the I2C master. More...
 
status_t LPI2C_SlaveSend (LPI2C_Type *base, void *pTxBuff, uint16_t u16TxSize, uint16_t *pu16ActualTxSize)
 Performs a polling send transfer on the I2C bus. More...
 
status_t LPI2C_SlaveReceive (LPI2C_Type *base, void *pRxBuff, uint16_t u16RxSize, uint16_t *pu16ActualRxSize)
 Performs a polling receive transfer on the I2C bus. More...
 

Data Structure Documentation

struct lpi2c_master_config_t

This structure holds configuration settings for the LPI2C peripheral. To initialize this structure to reasonable defaults, call the LPI2C_MasterGetDefaultConfig() function and pass a pointer to your configuration structure instance.

The configuration structure can be made constant so it resides in flash.

Data Fields

uint16_t bEnableMaster: 1
 Whether to enable master mode. More...
 
uint16_t bEnableDoze: 1
 Whether master is enabled in doze mode. More...
 
uint16_t bDebugEnable: 1
 Enable transfers to continue when halted in debug mode. More...
 
uint16_t bIgnoreAck: 1
 Whether to ignore ACK/NACK. More...
 
uint16_t ePinConfig: 5
 The pin configuration option chosen from lpi2c_master_pin_config_t. More...
 
struct {
   uint16_t   bEnable: 1
 Whether to enable host request. More...
 
   uint16_t   eSource: 3
 Host request source chosen from lpi2c_host_request_source_t. More...
 
   uint16_t   ePolarity: 3
 Host request pin polarity chosen from lpi2c_host_request_polarity_t. More...
 
hostRequest
 Host request options. More...
 
uint32_t u32SrcClockHz
 Frequency in Hertz of the LPI2C functional clock. More...
 
uint32_t u32BaudRateBps
 Desired baud rate in Hertz. More...
 
uint32_t u32BusIdleTimeoutNs
 Bus idle timeout in nanoseconds. More...
 
uint32_t u32PinLowTimeoutNs
 Pin low timeout in nanoseconds. More...
 
uint32_t u32SdaGlitchFilterWidthNs
 Width in nanoseconds of glitch filter on SDA pin. More...
 
uint32_t u32SclGlitchFilterWidthNs
 Width in nanoseconds of glitch filter on SCL pin. More...
 

Field Documentation

uint16_t lpi2c_master_config_t::bEnableMaster
uint16_t lpi2c_master_config_t::bEnableDoze
uint16_t lpi2c_master_config_t::bDebugEnable
uint16_t lpi2c_master_config_t::bIgnoreAck
uint16_t lpi2c_master_config_t::ePinConfig
uint16_t lpi2c_master_config_t::bEnable
uint16_t lpi2c_master_config_t::eSource
uint16_t lpi2c_master_config_t::ePolarity
struct { ... } lpi2c_master_config_t::hostRequest
uint32_t lpi2c_master_config_t::u32SrcClockHz
uint32_t lpi2c_master_config_t::u32BaudRateBps
uint32_t lpi2c_master_config_t::u32BusIdleTimeoutNs

Set to 0 to disable.

uint32_t lpi2c_master_config_t::u32PinLowTimeoutNs

Set to 0 to disable.

uint32_t lpi2c_master_config_t::u32SdaGlitchFilterWidthNs

Set to 0 to disable.

uint32_t lpi2c_master_config_t::u32SclGlitchFilterWidthNs

Set to 0 to disable.

struct lpi2c_slave_config_t

This structure holds configuration settings for the LPI2C slave peripheral. To initialize this structure to reasonable defaults, call the LPI2C_SlaveGetDefaultConfig() function and pass a pointer to your configuration structure instance.

The configuration structure can be made constant so it resides in flash.

Data Fields

uint16_t bEnableSlave: 1
 Enable slave mode. More...
 
uint16_t bFilterDozeEnable: 1
 Enable digital glitch filter in doze mode. More...
 
uint16_t bFilterEnable: 1
 Enable digital glitch filter. More...
 
uint16_t bIgnoreAck: 1
 Continue transfers after a NACK is detected. More...
 
uint16_t bEnableGeneralCall: 1
 Enable general call address matching. More...
 
uint16_t bEnableSmbusAlert: 1
 Enable SMBus Alert. More...
 
uint16_t bEnableReceivedAddressRead: 1
 Enable reading the address received address as the first byte of data. More...
 
uint16_t eAddressMatchMode: 3
 Address matching options chosen from lpi2c_slave_address_match_t. More...
 
uint16_t u16Address0
 Slave's 7-bit address. More...
 
uint16_t u16Address1
 Alternate slave 7-bit address. More...
 
uint32_t u32SdaGlitchFilterWidthNs
 Width in nanoseconds of the digital filter on the SDA signal. More...
 
uint32_t u32SclGlitchFilterWidthNs
 Width in nanoseconds of the digital filter on the SCL signal. More...
 
uint32_t u32DataValidDelayNs
 Width in nanoseconds of the data valid delay. More...
 
uint32_t u32ClockHoldTimeNs
 Width in nanoseconds of the clock hold time. More...
 
uint32_t u32SrcClockHz
 Frequency in Hertz of the LPI2C functional clock. More...
 
uint16_t bEnableAck: 1
 Enables SCL clock stretching during slave-transmit address byte(s) and slave-receiver address and data byte(s) to allow software to write the Transmit ACK Register before the ACK or NACK is transmitted. More...
 
uint16_t bEnableTx: 1
 Enables SCL clock stretching when the transmit data flag is set during a slave-transmit transfer. More...
 
uint16_t bEnableRx: 1
 Enables SCL clock stretching when receive data flag is set during a slave-receive transfer. More...
 
uint16_t bEnableAddress: 1
 Enables SCL clock stretching when the address valid flag is asserted. More...
 

Field Documentation

uint16_t lpi2c_slave_config_t::bEnableSlave
uint16_t lpi2c_slave_config_t::bFilterDozeEnable
uint16_t lpi2c_slave_config_t::bFilterEnable
uint16_t lpi2c_slave_config_t::bIgnoreAck
uint16_t lpi2c_slave_config_t::bEnableAck

Clock stretching occurs when transmitting the 9th bit. When enableAckSCLStall is enabled, there is no need to set either enableRxDataSCLStall or enableAddressSCLStall.

uint16_t lpi2c_slave_config_t::bEnableTx
uint16_t lpi2c_slave_config_t::bEnableRx
uint16_t lpi2c_slave_config_t::bEnableAddress
uint16_t lpi2c_slave_config_t::bEnableGeneralCall
uint16_t lpi2c_slave_config_t::bEnableSmbusAlert
uint16_t lpi2c_slave_config_t::bEnableReceivedAddressRead
uint16_t lpi2c_slave_config_t::eAddressMatchMode
uint16_t lpi2c_slave_config_t::u16Address0
uint16_t lpi2c_slave_config_t::u16Address1
uint32_t lpi2c_slave_config_t::u32SdaGlitchFilterWidthNs
uint32_t lpi2c_slave_config_t::u32SclGlitchFilterWidthNs
uint32_t lpi2c_slave_config_t::u32DataValidDelayNs
uint32_t lpi2c_slave_config_t::u32ClockHoldTimeNs
uint32_t lpi2c_slave_config_t::u32SrcClockHz
struct lpi2c_config_t

This structure holds configuration settings for the LPI2C peripheral. To initialize this structure to reasonable defaults, call the LPI2C_GetDefaultConfig function and pass a pointer to your configuration structure instance.

The configuration structure can be made constant so it resides in flash.

Data Fields

uint16_t bEnableMaster: 1
 < Master configuration. More...
 
uint16_t bEnableDoze: 1
 Whether master is enabled in doze mode. More...
 
uint16_t bDebugEnable: 1
 Enable transfers to continue when halted in debug mode. More...
 
uint16_t bMasterIgnoreAck: 1
 Whether to ignore ACK/NACK. More...
 
uint16_t ePinConfig: 5
 The pin configuration option chosen from lpi2c_master_pin_config_t. More...
 
struct {
   uint16_t   bEnable: 1
 Whether to enable host request. More...
 
   uint16_t   eSource: 3
 Host request source chosen from lpi2c_host_request_source_t. More...
 
   uint16_t   ePolarity: 3
 Host request pin polarity chosen from lpi2c_host_request_polarity_t. More...
 
hostRequest
 Host request options. More...
 
uint32_t u32BaudRateBps
 Desired baud rate in Hertz. More...
 
uint32_t u32BusIdleTimeoutNs
 Bus idle timeout in nanoseconds. More...
 
uint32_t u32PinLowTimeoutNs
 Pin low timeout in nanoseconds. More...
 
uint32_t u32MasterSdaGlitchFilterWidthNs
 Width in nanoseconds of glitch filter on SDA pin. More...
 
uint32_t u32MasterSclGlitchFilterWidthNs
 Width in nanoseconds of glitch filter on SCL pin. More...
 
uint8_t bEnableSlave: 1
 Enable slave mode. More...
 
uint8_t bFilterDozeEnable: 1
 Enable digital glitch filter in doze mode. More...
 
uint8_t bFilterEnable: 1
 Enable digital glitch filter. More...
 
uint8_t bSlaveIgnoreAck: 1
 Continue transfers after a NACK is detected. More...
 
uint8_t bEnableGeneralCall: 1
 Enable general call address matching. More...
 
uint8_t bEnableSmbusAlert: 1
 Enable SMBus Alert. More...
 
uint8_t bEnableReceivedAddressRead: 1
 Enable reading the address received address as the first byte of data. More...
 
uint8_t eAddressMatchMode: 3
 Address matching options chosen from lpi2c_slave_address_match_t. More...
 
uint16_t u16Address0
 Slave's 7-bit address. More...
 
uint16_t u16Address1
 Alternate slave 7-bit address. More...
 
uint32_t u32SlaveSdaGlitchFilterWidthNs
 Width in nanoseconds of the digital filter on the SDA signal. More...
 
uint32_t u32SlaveSclGlitchFilterWidthNs
 Width in nanoseconds of the digital filter on the SCL signal. More...
 
uint32_t u32DataValidDelayNs
 Width in nanoseconds of the data valid delay. More...
 
uint32_t u32ClockHoldTimeNs
 Width in nanoseconds of the clock hold time. More...
 
uint32_t u32SrcClockHz
 Frequency in Hertz of the LPI2C functional clock. More...
 
uint8_t bEnableAck: 1
 Enables SCL clock stretching during slave-transmit address byte(s) and slave-receiver address and data byte(s) to allow software to write the Transmit ACK Register before the ACK or NACK is transmitted. More...
 
uint8_t bEnableTx: 1
 Enables SCL clock stretching when the transmit data flag is set during a slave-transmit transfer. More...
 
uint8_t bEnableRx: 1
 Enables SCL clock stretching when receive data flag is set during a slave-receive transfer. More...
 
uint8_t bEnableAddress: 1
 Enables SCL clock stretching when the address valid flag is asserted. More...
 

Field Documentation

uint16_t lpi2c_config_t::bEnableMaster

Whether to enable master mode.

uint16_t lpi2c_config_t::bEnableDoze
uint16_t lpi2c_config_t::bDebugEnable
uint16_t lpi2c_config_t::bMasterIgnoreAck
uint16_t lpi2c_config_t::ePinConfig
uint16_t lpi2c_config_t::bEnable
uint16_t lpi2c_config_t::eSource
uint16_t lpi2c_config_t::ePolarity
struct { ... } lpi2c_config_t::hostRequest
uint32_t lpi2c_config_t::u32BaudRateBps
uint32_t lpi2c_config_t::u32BusIdleTimeoutNs

Set to 0 to disable.

uint32_t lpi2c_config_t::u32PinLowTimeoutNs

Set to 0 to disable.

uint32_t lpi2c_config_t::u32MasterSdaGlitchFilterWidthNs

Set to 0 to disable.

uint32_t lpi2c_config_t::u32MasterSclGlitchFilterWidthNs

Set to 0 to disable. Slave configuration.

uint8_t lpi2c_config_t::bEnableSlave
uint8_t lpi2c_config_t::bFilterDozeEnable
uint8_t lpi2c_config_t::bFilterEnable
uint8_t lpi2c_config_t::bSlaveIgnoreAck
uint8_t lpi2c_config_t::bEnableAck

Clock stretching occurs when transmitting the 9th bit. When enableAckSCLStall is enabled, there is no need to set either enableRxDataSCLStall or enableAddressSCLStall.

uint8_t lpi2c_config_t::bEnableTx
uint8_t lpi2c_config_t::bEnableRx
uint8_t lpi2c_config_t::bEnableAddress
uint8_t lpi2c_config_t::bEnableGeneralCall
uint8_t lpi2c_config_t::bEnableSmbusAlert
uint8_t lpi2c_config_t::bEnableReceivedAddressRead
uint8_t lpi2c_config_t::eAddressMatchMode
uint16_t lpi2c_config_t::u16Address0
uint16_t lpi2c_config_t::u16Address1
uint32_t lpi2c_config_t::u32SlaveSdaGlitchFilterWidthNs
uint32_t lpi2c_config_t::u32SlaveSclGlitchFilterWidthNs
uint32_t lpi2c_config_t::u32DataValidDelayNs
uint32_t lpi2c_config_t::u32ClockHoldTimeNs
uint32_t lpi2c_config_t::u32SrcClockHz
struct lpi2c_data_match_config_t

Data Fields

lpi2c_data_match_config_mode_t eMatchMode
 Data match configuration setting. More...
 
bool bRxDataMatchOnly
 When set to true, received data is ignored until a successful match. More...
 
uint8_t u8Match0
 Match value 0. More...
 
uint8_t u8Match1
 Match value 1. More...
 

Field Documentation

lpi2c_data_match_config_mode_t lpi2c_data_match_config_t::eMatchMode
bool lpi2c_data_match_config_t::bRxDataMatchOnly
uint8_t lpi2c_data_match_config_t::u8Match0
uint8_t lpi2c_data_match_config_t::u8Match1
struct _lpi2c_master_transfer

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

Data Fields

uint8_t u8ControlFlagMask
 Bit mask of options for the transfer. More...
 
uint16_t u8SlaveAddress
 The 7-bit slave address. More...
 
lpi2c_data_direction_t eDirection
 Either kLPI2C_Read or kLPI2C_Write. More...
 
uint8_t * pu8Command
 Pointer to command code. More...
 
uint8_t u8CommandSize
 Length of sub address to send in bytes. More...
 
void * pData
 Pointer to data to transfer. More...
 
uint16_t u16DataSize
 Number of bytes to transfer. More...
 

Field Documentation

uint8_t lpi2c_master_transfer_t::u8ControlFlagMask

See enumeration _lpi2c_master_transfer_control_flags for available options. Set to 0 or kLPI2C_TransferStartStopFlag for normal transfers.

uint16_t lpi2c_master_transfer_t::u8SlaveAddress
lpi2c_data_direction_t lpi2c_master_transfer_t::eDirection
uint8_t* lpi2c_master_transfer_t::pu8Command
uint8_t lpi2c_master_transfer_t::u8CommandSize
void* lpi2c_master_transfer_t::pData
uint16_t lpi2c_master_transfer_t::u16DataSize
struct _lpi2c_master_transfer_handle
Note
The contents of this structure are private and subject to change.

Data Fields

LPI2C_Type * base
 The peripheral register address base. More...
 
uint8_t u8State
 Transfer state machine current state. More...
 
uint16_t u16RemainingBytes
 Remaining byte count in current state. More...
 
uint8_t * pu8Buf
 Buffer pointer for current state. More...
 
uint16_t u16CommandBuffer [7]
 LPI2C command sequence. More...
 
lpi2c_master_transfer_t sTransfer
 Copy of the current transfer info. More...
 
lpi2c_master_transfer_callback_t pfCompletionCallback
 Callback function pointer. More...
 
status_t completionStatus
 Master transfer complete status indicating how the transfer ends. More...
 
void * pUserData
 Application data passed to callback. More...
 

Field Documentation

LPI2C_Type* lpi2c_master_transfer_handle_t::base
uint8_t lpi2c_master_transfer_handle_t::u8State
uint16_t lpi2c_master_transfer_handle_t::u16RemainingBytes
uint8_t* lpi2c_master_transfer_handle_t::pu8Buf
uint16_t lpi2c_master_transfer_handle_t::u16CommandBuffer[7]
lpi2c_master_transfer_t lpi2c_master_transfer_handle_t::sTransfer
lpi2c_master_transfer_callback_t lpi2c_master_transfer_handle_t::pfCompletionCallback
status_t lpi2c_master_transfer_handle_t::completionStatus
void* lpi2c_master_transfer_handle_t::pUserData
struct _lpi2c_slave_transfer

Data Fields

uint8_t u8EventMask
 Mask of enabled events, set correspond bit if user wants to handle this event. More...
 
lpi2c_slave_transfer_event_t eEvent
 Reason the callback is being invoked lpi2c_slave_transfer_event_t. More...
 
uint16_t u16ReceivedAddress
 Matching address send by master. More...
 
uint8_t * pu8Data
 Transfer buffer.
 
uint16_t u16DataSize
 Transfer size.
 
status_t completionStatus
 Success or error code describing how the transfer completed. More...
 
uint16_t u16TransferredCount
 Number of bytes actually transferred since start or last repeated start. More...
 

Field Documentation

uint8_t lpi2c_slave_transfer_t::u8EventMask
lpi2c_slave_transfer_event_t lpi2c_slave_transfer_t::eEvent
uint16_t lpi2c_slave_transfer_t::u16ReceivedAddress
status_t lpi2c_slave_transfer_t::completionStatus

Only applies for kLPI2C_SlaveCompletionEvent.

uint16_t lpi2c_slave_transfer_t::u16TransferredCount
struct _lpi2c_slave_transfer_handle
Note
The contents of this structure are private and subject to change.

Data Fields

LPI2C_Type * base
 The peripheral register address base. More...
 
lpi2c_slave_transfer_t sTransfer
 LPI2C slave transfer copy. More...
 
bool bIsBusy
 Whether transfer is busy. More...
 
bool bWasTransmit
 Whether the last transfer was a transmit. More...
 
uint8_t u8State
 A transfer state maintained during transfer. More...
 
uint16_t u16TransferredCount
 Count of bytes transferred. More...
 
lpi2c_slave_transfer_callback_t pfCallback
 Callback function called at transfer event. More...
 
void * pUserData
 Callback parameter passed to callback. More...
 

Field Documentation

LPI2C_Type* lpi2c_slave_transfer_handle_t::base
lpi2c_slave_transfer_t lpi2c_slave_transfer_handle_t::sTransfer
bool lpi2c_slave_transfer_handle_t::bIsBusy
bool lpi2c_slave_transfer_handle_t::bWasTransmit
uint8_t lpi2c_slave_transfer_handle_t::u8State
uint16_t lpi2c_slave_transfer_handle_t::u16TransferredCount
lpi2c_slave_transfer_callback_t lpi2c_slave_transfer_handle_t::pfCallback
void* lpi2c_slave_transfer_handle_t::pUserData

Macro Definition Documentation

#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL   0U
#define I2C_RETRY_TIMES   0U /* Define to zero means keep waiting until the flag is assert/deassert. */
#define I2C_SMBUS_ENABLE   0U /* Default defines to zero, driver uses simple I2C transfer. */

Typedef Documentation

typedef void(* lpi2c_master_transfer_callback_t)(lpi2c_master_transfer_handle_t *psHandle)

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

Parameters
psHandlePointer to the LPI2C master driver handle.
typedef void(* lpi2c_slave_transfer_callback_t)(lpi2c_slave_transfer_handle_t *psHandle)

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

Parameters
psHandlePointer to the LPI2C slave driver handle.

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_LPI2C_Busy 

The master is already performing a transfer.

kStatus_LPI2C_Idle 

The slave driver is idle.

kStatus_LPI2C_Nak 

The slave device sent a NAK in response to a byte.

kStatus_LPI2C_FifoError 

FIFO under run or overrun.

kStatus_LPI2C_BitError 

Transferred bit was not seen on the bus.

kStatus_LPI2C_ArbitrationLost 

Arbitration lost error.

kStatus_LPI2C_PinLowTimeout 

SCL or SDA were held low longer than the timeout.

kStatus_LPI2C_NoTransferInProgress 

Attempt to abort a transfer when one is not in progress.

kStatus_LPI2C_DmaRequestFail 

DMA request failed.

kStatus_LPI2C_Timeout 

Timeout polling status flags.

The following status register flags can be cleared:

All flags except kLPI2C_MasterBusyFlag and kLPI2C_MasterBusBusyFlag can be enabled as interrupts.

Note
These enums are meant to be OR'd together to form a bit mask.
Enumerator
kLPI2C_MasterTxReadyInterruptFlag 

Transmit data interrupt flag.

kLPI2C_MasterRxReadyInterruptFlag 

Receive data interrupt flag.

kLPI2C_MasterEndOfPacketInterruptFlag 

End Packet interrupt flag.

kLPI2C_MasterStopDetectInterruptFlag 

Stop detect interrupt flag.

kLPI2C_MasterNackDetectInterruptFlag 

NACK detect interrupt flag.

kLPI2C_MasterArbitrationLostInterruptFlag 

Arbitration lost interrupt flag.

kLPI2C_MasterFifoErrInterruptFlag 

FIFO error interrupt flag.

kLPI2C_MasterPinLowTimeoutInterruptFlag 

Pin low timeout interrupt flag.

kLPI2C_MasterDataMatchInterruptFlag 

Data match interrupt flag.

kLPI2C_MasterBusyFlag 

Master busy flag.

kLPI2C_MasterBusBusyFlag 

Bus busy flag.

All flags

kLPI2C_MasterClearInterruptFlags 

All flags which are cleared by the driver upon starting a transfer.

kLPI2C_MasterIrqFlags 

IRQ sources enabled by the non-blocking transactional API.

kLPI2C_MasterErrorInterruptFlags 

Errors to check for.

The following status register flags can be cleared:

All flags except kLPI2C_SlaveBusyFlag and kLPI2C_SlaveBusBusyFlag can be enabled as interrupts.

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

Transmit data interrupt flag.

kLPI2C_SlaveRxReadyInterruptFlag 

Receive data interrupt flag.

kLPI2C_SlaveAddressValidInterruptFlag 

Address valid interrupt flag.

kLPI2C_SlaveTransmitAckInterruptFlag 

Transmit ACK interrupt flag.

kLPI2C_SlaveRepeatedStartDetectInterruptFlag 

Repeated start detect interrupt flag.

kLPI2C_SlaveStopDetectInterruptFlag 

Stop detect interrupt flag.

kLPI2C_SlaveBitErrInterruptFlag 

Bit error interrupt flag.

kLPI2C_SlaveFifoErrInterruptFlag 

FIFO error interrupt flag.

kLPI2C_SlaveAddressMatch0InterruptFlag 

Address match 0 interrupt flag.

kLPI2C_SlaveAddressMatch1InterruptFlag 

Address match 1 interrupt flag.

kLPI2C_SlaveGeneralCallInterruptFlag 

General call interrupt flag.

kLPI2C_SlaveSmbusAlertRespInterruptFlag 

SMBus alert response interrupt flag.

kLPI2C_SlaveBusyFlag 

Master busy flag.

kLPI2C_SlaveBusBusyFlag 

Bus busy flag.

All flags

kLPI2C_SlaveClearInterruptFlags 

All flags which are cleared by the driver upon starting a transfer.

kLPI2C_SlaveIrqFlags 

IRQ sources enabled by the non-blocking transactional API.

kLPI2C_SlaveErrorInterruptFlags 

Errors to check for.

Enumerator
kLPI2C_2PinOpenDrain 

LPI2C Configured for 2-pin open drain mode.

kLPI2C_2PinOutputOnly 

LPI2C Configured for 2-pin output only mode (ultra-fast mode)

kLPI2C_2PinPushPull 

LPI2C Configured for 2-pin push-pull mode.

kLPI2C_4PinPushPull 

LPI2C Configured for 4-pin push-pull mode.

kLPI2C_2PinOpenDrainWithSeparateSlave 

LPI2C Configured for 2-pin open drain mode with separate LPI2C slave.

kLPI2C_2PinOutputOnlyWithSeparateSlave 

LPI2C Configured for 2-pin output only mode(ultra-fast mode) with separate LPI2C slave.

kLPI2C_2PinPushPullWithSeparateSlave 

LPI2C Configured for 2-pin push-pull mode with separate LPI2C slave.

kLPI2C_4PinPushPullWithInvertedOutput 

LPI2C Configured for 4-pin push-pull mode(inverted outputs)

Enumerator
kLPI2C_HostRequestExternalPin 

Select the LPI2C_HREQ pin as the host request input.

kLPI2C_HostRequestInputTrigger 

Select the input trigger as the host request input.

Enumerator
kLPI2C_HostRequestPinActiveLow 

Configure the LPI2C_HREQ pin active low.

kLPI2C_HostRequestPinActiveHigh 

Configure the LPI2C_HREQ pin active high.

Enumerator
kLPI2C_MatchDisabled 

LPI2C Match Disabled.

kLPI2C_1stWordEqualsM0OrM1 

LPI2C Match Enabled and 1st data word equals MATCH0 OR MATCH1.

kLPI2C_AnyWordEqualsM0OrM1 

LPI2C Match Enabled and any data word equals MATCH0 OR MATCH1.

kLPI2C_1stWordEqualsM0And2ndWordEqualsM1 

LPI2C Match Enabled and 1st data word equals MATCH0, 2nd data equals MATCH1.

kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1 

LPI2C Match Enabled and any data word equals MATCH0, next data equals MATCH1.

kLPI2C_1stWordAndM1EqualsM0AndM1 

LPI2C Match Enabled and 1st data word and MATCH0 equals MATCH0 and MATCH1.

kLPI2C_AnyWordAndM1EqualsM0AndM1 

LPI2C Match Enabled and any data word and MATCH0 equals MATCH0 and MATCH1.

Enumerator
kLPI2C_Match7BitAddress0 

Match only 7 bit address 0.

kLPI2C_Match10BitAddress0 

Match only 10 bit address 0.

kLPI2C_Match7BitAddress0Or7BitAddress1 

Match either 7 bit address 0 or 7 bit address 1.

kLPI2C_Match10BitAddress0Or10BitAddress1 

Match either 10 bit address 0 or 10 bit address 1.

kLPI2C_Match7BitAddress0Or10BitAddress1 

Match either 7 bit address 0 or 10 bit address 1.

kLPI2C_Match10BitAddress0Or7BitAddress1 

Match either 10 bit address 0 or 7 bit address 1.

kLPI2C_Match7BitAddress0Through7BitAddress1 

Match a range of slave addresses from 7 bit address 0 through 7 bit address 1.

kLPI2C_Match10BitAddress0Through10BitAddress1 

Match a range of slave addresses from 10 bit address 0 through 10 bit address 1.

Enumerator
kLPI2C_Write 

Master transmit.

kLPI2C_Read 

Master receive.

Note
These enumerations are intended to be OR'd together to form a bit mask of options for the _lpi2c_master_transfer::u8ControlFlagMask field.
Enumerator
kLPI2C_TransferStartStopFlag 

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

kLPI2C_TransferNoStartFlag 

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

kLPI2C_TransferRepeatedStartFlag 

Send a repeated start condition.

kLPI2C_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 LPI2C_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
kLPI2C_SlaveAddressMatchEvent 

Received the slave address after a start or repeated start.

kLPI2C_SlaveTransmitEvent 

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

kLPI2C_SlaveReceiveEvent 

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

kLPI2C_SlaveTransmitAckEvent 

Callback needs to either transmit an ACK or NACK.

kLPI2C_SlaveRepeatedStartEvent 

A repeated start was detected.

kLPI2C_SlaveCompletionEvent 

A stop was detected, completing the transfer.

kLPI2C_SlaveAllEvents 

Bit mask of all available events.

Function Documentation

void LPI2C_GetDefaultConfig ( lpi2c_config_t psConfig,
uint16_t  u16SlaveAddress,
uint32_t  u32SrcClockHz 
)

This is an example:

* lpi2c_config_t sConfig;
* LPI2C_GetDefaultConfig(&sConfig, u16SlaveAddress, u32SrcClockHz);
* sConfig.u32BaudRateBps = 100000U;
* LPI2C_Init(LPI2C0, &sConfig);
*

After calling this function, you can override any settings in order to customize the configuration, prior to initializing the driver with LPI2C_Init().

Parameters
psConfigUser provided configuration structure for default values. Refer to lpi2c_config_t.
u16SlaveAddressSlave address raw value, driver will shift it.
u32SrcClockHzFrequency in Hertz of the LPI2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods.
void LPI2C_Init ( LPI2C_Type *  base,
const lpi2c_config_t psConfig 
)

This function enables the peripheral clock and initializes the LPI2C peripheral as described by the user provided configuration. A software reset is performed prior to configuration. This function can enable master and slave together. If only want to use one of them, please call LPI2C_MasterInit or LPI2C_SlaveInit.

Note
If FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL is enabled by user, the init function will not ungate I2C clock source before initialization, to avoid hardfault, user has to manually enable ungate the clock source before calling the API.
Parameters
baseThe LPI2C peripheral base address.
psConfigUser provided peripheral configuration. Use LPI2C_GetDefaultConfig to get a set of defaults that you can override.
void LPI2C_Deinit ( LPI2C_Type *  base)

This function disables the LPI2C peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.

Parameters
baseThe LPI2C peripheral base address.
void LPI2C_MasterGetDefaultConfig ( lpi2c_master_config_t psMasterConfig,
uint32_t  u32SrcClockHz 
)

This is an example:

* LPI2C_MasterGetDefaultConfig(&sConfig, 12000000U);
* sConfig.u32BaudRateBps = 100000U;
* LPI2C_MasterInit(LPI2C1, &sConfig);
*

After calling this function, you can override any settings in order to customize the configuration, prior to initializing the master driver with LPI2C_MasterInit().

Parameters
psMasterConfigUser provided configuration structure for default values. Refer to lpi2c_master_config_t.
u32SrcClockHzFrequency in Hertz of the LPI2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods.
void LPI2C_MasterInit ( LPI2C_Type *  base,
const lpi2c_master_config_t psMasterConfig 
)

This function enables the peripheral clock and initializes the LPI2C master peripheral as described by the user provided configuration. A software reset is performed prior to configuration. User just needs to call this function to enable LPI2C master if only use I2C master operation.

Note
If FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL is enabled by user, the init function will not ungate I2C clock source before initialization, to avoid hardfault, user has to manually enable ungate the clock source before calling the API.
Parameters
baseThe LPI2C peripheral base address.
psMasterConfigUser provided peripheral configuration. Use LPI2C_MasterGetDefaultConfig() to get a set of defaults that you can override.
void LPI2C_MasterDeinit ( LPI2C_Type *  base)

This function disables the LPI2C master peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.

Parameters
baseThe LPI2C peripheral base address.
void LPI2C_SlaveGetDefaultConfig ( lpi2c_slave_config_t psSlaveConfig,
uint16_t  u16SlaveAddress,
uint32_t  u32SrcClockHz 
)

This is an example:

* LPI2C_SlaveGetDefaultConfig(&sConfig, u16SlaveAddress, u32SrcClockHz);
* LPI2C_SlaveInit(LPI2C1, &sConfig);
*

After calling this function, override any settings to customize the configuration, prior to initializing the master driver with LPI2C_SlaveInit(). Be sure to override at least the u8Address0 member of the configuration structure with the desired slave address.

Parameters
psSlaveConfigUser provided configuration structure that is set to default values. Refer to lpi2c_slave_config_t.
u16SlaveAddressSlave address raw value, driver will shift it.
u32SrcClockHzFrequency in Hertz of the LPI2C functional clock. Used to calculate the filter widths, data valid delay, and clock hold time.
void LPI2C_SlaveInit ( LPI2C_Type *  base,
const lpi2c_slave_config_t psSlaveConfig 
)

This function enables the peripheral clock and initializes the LPI2C slave peripheral as described by the user provided configuration. User just needs to call this function to enable LPI2C slave if only use I2C slave operation.

Note
If FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL is enabled by user, the init function will not ungate I2C clock source before initialization, to avoid hardfault, user has to manually enable ungate the clock source before calling the API.
Parameters
baseThe LPI2C peripheral base address.
psSlaveConfigUser provided peripheral configuration. Use LPI2C_SlaveGetDefaultConfig() to get a set of defaults that you can override.
void LPI2C_SlaveDeinit ( LPI2C_Type *  base)

This function disables the LPI2C slave peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.

Parameters
baseThe LPI2C peripheral base address.
static uint16_t LPI2C_MasterGetStatusFlags ( LPI2C_Type *  base)
inlinestatic

A bit mask with the state of all LPI2C master status flags is returned. For each flag, the corresponding bit in the return value is set if the flag is asserted.

Parameters
baseThe LPI2C peripheral base address.
Returns
State of the status flags:
  • 1: related status flag is set.
  • 0: related status flag is not set.
See Also
_lpi2c_master_status_flags
static void LPI2C_MasterClearStatusFlags ( LPI2C_Type *  base,
uint16_t  u16StatusFlags 
)
inlinestatic

The following status register flags can be cleared:

Attempts to clear other flags has no effect.

Parameters
baseThe LPI2C peripheral base address.
u16StatusFlagsA bitmask of status flags that are to be cleared. The mask is composed of _lpi2c_master_status_flags enumerators OR'd together. You may pass the result of a previous call to LPI2C_MasterGetStatusFlags().
See Also
_lpi2c_master_status_flags.
static uint16_t LPI2C_SlaveGetStatusFlags ( LPI2C_Type *  base)
inlinestatic

A bit mask with the state of all LPI2C slave status flags is returned. For each flag, the corresponding bit in the return value is set if the flag is asserted.

Parameters
baseThe LPI2C peripheral base address.
Returns
State of the status flags:
  • 1: related status flag is set.
  • 0: related status flag is not set.
See Also
_lpi2c_slave_status_flags
static void LPI2C_SlaveClearStatusFlags ( LPI2C_Type *  base,
uint16_t  u16StatusFlags 
)
inlinestatic

The following status register flags can be cleared:

Attempts to clear other flags has no effect.

Parameters
baseThe LPI2C peripheral base address.
u16StatusFlagsA bitmask of status flags that are to be cleared. The mask is composed of _lpi2c_slave_status_flags enumerators OR'd together. You may pass the result of a previous call to LPI2C_SlaveGetStatusFlags().
See Also
_lpi2c_slave_status_flags.
static void LPI2C_MasterEnableInterrupts ( LPI2C_Type *  base,
uint16_t  u16Interrupts 
)
inlinestatic

All flags except kLPI2C_MasterBusyFlag and kLPI2C_MasterBusBusyFlag can be enabled as interrupts.

Parameters
baseThe LPI2C peripheral base address.
u16InterruptsBit mask of interrupts to enable. See _lpi2c_master_status_flags for the set of constants that should be OR'd together to form the bit mask.
static void LPI2C_MasterDisableInterrupts ( LPI2C_Type *  base,
uint16_t  u16Interrupts 
)
inlinestatic

All flags except kLPI2C_MasterBusyFlag and kLPI2C_MasterBusBusyFlag can be enabled as interrupts.

Parameters
baseThe LPI2C peripheral base address.
u16InterruptsBit mask of interrupts to disable. See _lpi2c_master_status_flags for the set of constants that should be OR'd together to form the bit mask.
static uint16_t LPI2C_MasterGetEnabledInterrupts ( LPI2C_Type *  base)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
Returns
A bitmask composed of _lpi2c_master_status_flags enumerators OR'd together to indicate the set of enabled interrupts.
static void LPI2C_SlaveEnableInterrupts ( LPI2C_Type *  base,
uint16_t  u16Interrupts 
)
inlinestatic

All flags except kLPI2C_SlaveBusyFlag and kLPI2C_SlaveBusBusyFlag can be enabled as interrupts.

Parameters
baseThe LPI2C peripheral base address.
u16InterruptsBit mask of interrupts to enable. See _lpi2c_slave_status_flags for the set of constants that should be OR'd together to form the bit mask.
static void LPI2C_SlaveDisableInterrupts ( LPI2C_Type *  base,
uint16_t  u16Interrupts 
)
inlinestatic

All flags except kLPI2C_SlaveBusyFlag and kLPI2C_SlaveBusBusyFlag can be enabled as interrupts.

Parameters
baseThe LPI2C peripheral base address.
u16InterruptsBit mask of interrupts to disable. See _lpi2c_slave_status_flags for the set of constants that should be OR'd together to form the bit mask.
static uint16_t LPI2C_SlaveGetEnabledInterrupts ( LPI2C_Type *  base)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
Returns
A bitmask composed of _lpi2c_slave_status_flags enumerators OR'd together to indicate the set of enabled interrupts.
void LPI2C_MasterSetBaudRate ( LPI2C_Type *  base,
uint32_t  u32SrcClockHz,
uint32_t  u32BaudRateBps 
)

The LPI2C master is automatically disabled and re-enabled as necessary to configure the baud rate. Do not call this function during a transfer, or the transfer is aborted.

Note
Please note that the second parameter is the clock frequency of LPI2C module, the third parameter means user configured bus baudrate, this implementation is different from other I2C drivers which use baudrate configuration as second parameter and source clock frequency as third parameter.
Parameters
baseThe LPI2C peripheral base address.
u32SrcClockHzLPI2C functional clock frequency in Hertz.
u32BaudRateBpsRequested bus frequency in Hertz.
void LPI2C_MasterSetGlitchFilter ( LPI2C_Type *  base,
uint32_t  u32SdaFilterWidthNs,
uint32_t  u32SclFilterWidthNs,
uint32_t  u32SrcClockHz 
)

After the LPI2C module is initialized as master, user can call this function to change the glitch filter width.

Parameters
baseThe LPI2C peripheral base address.
u32SdaFilterWidthNsThe SDA glitch filter length in nano seconds.
u32SclFilterWidthNsThe SCL glitch filter length in nano seconds.
u32SrcClockHzLPI2C peripheral clock frequency in Hz
void LPI2C_MasterSetDataMatch ( LPI2C_Type *  base,
const lpi2c_data_match_config_t psConfig 
)
Parameters
baseThe LPI2C peripheral base address.
psConfigSettings for the data match feature.
static void LPI2C_MasterReset ( LPI2C_Type *  base)
inlinestatic

Restores the LPI2C master peripheral to reset conditions.

Parameters
baseThe LPI2C peripheral base address.
static void LPI2C_MasterEnable ( LPI2C_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
bEnablePass true to enable or false to disable the specified LPI2C as master.
static void LPI2C_MasterSetWatermarks ( LPI2C_Type *  base,
uint16_t  u16TxWords,
uint16_t  u16RxWords 
)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
u16TxWordsTransmit FIFO watermark value in words. The #kLPI2C_MasterTxReadyFlag flag is set whenever the number of words in the transmit FIFO is equal or less than u16TxWords. Writing a value equal or greater than the FIFO size is truncated.
u16RxWordsReceive FIFO watermark value in words. The kLPI2C_MasterRxReadyInterruptFlag flag is set whenever the number of words in the receive FIFO is greater than u16RxWords. Writing a value equal or greater than the FIFO size is truncated.
static void LPI2C_MasterGetFifoCounts ( LPI2C_Type *  base,
uint16_t *  pu16RxCount,
uint16_t *  pu16TxCount 
)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
pu16RxCountPointer through which the current number of words in the transmit FIFO is returned. Pass NULL if this value is not required.
pu16TxCountPointer through which the current number of words in the receive FIFO is returned. Pass NULL if this value is not required.
void LPI2C_SlaveSetGlitchFilter ( LPI2C_Type *  base,
uint32_t  u32SdaFilterWidthNs,
uint32_t  u32SclFilterWidthNs,
uint32_t  u32SrcClockHz 
)

After the LPI2C module is initialized as slave, user can call this function to change the glitch filter width.

Parameters
baseThe LPI2C peripheral base address.
u32SdaFilterWidthNsThe SDA glitch filter length in nano seconds.
u32SclFilterWidthNsThe SCL glitch filter length in nano seconds.
u32SrcClockHzLPI2C peripheral clock frequency in Hz
void LPI2C_SlaveSetAddressingMode ( LPI2C_Type *  base,
lpi2c_slave_address_match_t  eAddressMatchMode,
uint16_t  u16Address0,
uint16_t  u16Address1 
)

After the LPI2C module is initialized as slave, user can call this function to change the configuration of slave addressing mode.

Parameters
baseThe LPI2C peripheral base address.
eAddressMatchModeThe slave addressing match mode.
u16Address0LPI2C slave address 0. For 7-bit address low 7-bit is used, for 10-bit address low 10-bit is used.
u16Address1LPI2C slave address 1. For 7-bit address low 7-bit is used, for 10-bit address low 10-bit is used.
static void LPI2C_SlaveReset ( LPI2C_Type *  base)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
static void LPI2C_SlaveEnable ( LPI2C_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
bEnablePass true to enable or false to disable the specified LPI2C as slave.
static void LPI2C_MasterEnableDMA ( LPI2C_Type *  base,
bool  bEnableTx,
bool  bEnableRx 
)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
bEnableTxEnable flag for transmit DMA request. Pass true for enable, false for disable.
bEnableRxEnable flag for receive DMA request. Pass true for enable, false for disable.
static uint16_t* LPI2C_MasterGetTxFifoAddress ( LPI2C_Type *  base)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
Returns
The LPI2C Master Transmit Data Register address.
static uint16_t* LPI2C_MasterGetRxFifoAddress ( LPI2C_Type *  base)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
Returns
The LPI2C Master Receive Data Register address.
static void LPI2C_SlaveEnableDMA ( LPI2C_Type *  base,
bool  bEnableAddressValid,
bool  bEnableRx,
bool  bEnableTx 
)
inlinestatic
Parameters
baseThe LPI2C peripheral base address.
bEnableAddressValidEnable flag for the address valid DMA request. Pass true for enable, false for disable. The address valid DMA request is shared with the receive data DMA request.
bEnableRxEnable flag for the receive data DMA request. Pass true for enable, false for disable.
bEnableTxEnable flag for the transmit data DMA request. Pass true for enable, false for disable.
static status_t LPI2C_MasterStart ( LPI2C_Type *  base,
uint8_t  u8Address,
lpi2c_data_direction_t  eDir 
)
inlinestatic

This function is used to initiate a new master mode transfer. First, the bus state is checked to ensure that another master is not occupying the bus. Then a START signal is transmitted, followed by the 7-bit address specified in the address parameter. Note that this function does not actually wait until the START and address are successfully sent on the bus before returning.

Parameters
baseThe LPI2C peripheral base address.
u8Address7-bit slave device address, in bits [6:0].
eDirMaster transfer direction, either kLPI2C_Read or kLPI2C_Write. This parameter is used to set the R/w bit (bit 0) in the transmitted slave address.
Return values
#kStatus_SuccessSTART signal and address were successfully enqueued in the transmit FIFO.
kStatus_LPI2C_BusyAnother master is currently utilizing the bus.
static status_t LPI2C_MasterRepeatedStart ( LPI2C_Type *  base,
uint8_t  u8Address,
lpi2c_data_direction_t  eDir 
)
inlinestatic

This function is used to send a Repeated START signal when a transfer is already in progress. Like LPI2C_MasterStart(), it also sends the specified 7-bit address.

Note
This function exists primarily to maintain compatible APIs between LPI2C and I2C drivers, as well as to better document the intent of code that uses these APIs.
Parameters
baseThe LPI2C peripheral base address.
u8Address7-bit slave device address, in bits [6:0].
eDirMaster transfer direction, either kLPI2C_Read or kLPI2C_Write. This parameter is used to set the R/w bit (bit 0) in the transmitted slave address.
Return values
#kStatus_SuccessRepeated START signal and address were successfully enqueued in the transmit FIFO.
kStatus_LPI2C_BusyAnother master is currently utilizing the bus.
status_t LPI2C_MasterStop ( LPI2C_Type *  base)

This function does not return until the STOP signal is seen on the bus, or an error occurs.

Parameters
baseThe LPI2C peripheral base address.
Return values
#kStatus_SuccessThe STOP signal was successfully sent on the bus and the transaction terminated.
kStatus_LPI2C_BusyAnother master is currently utilizing the bus.
kStatus_LPI2C_NakThe slave device sent a NAK in response to a byte.
kStatus_LPI2C_FifoErrorFIFO under run or overrun.
kStatus_LPI2C_ArbitrationLostArbitration lost error.
kStatus_LPI2C_PinLowTimeoutSCL or SDA were held low longer than the timeout.
status_t LPI2C_MasterSend ( LPI2C_Type *  base,
void *  pTxBuff,
uint16_t  u16TxSize,
bool  bPecEnable 
)

Sends up to u16TxSize number of bytes to the previously addressed slave device. The slave may reply with a NAK to any byte in order to terminate the transfer early. If this happens, this function returns kStatus_LPI2C_Nak.

Parameters
baseThe LPI2C peripheral base address.
pTxBuffThe pointer to the data to be transferred.
u16TxSizeThe length in bytes of the data to be transferred.
bPecEnableIt decides whether one byte PEC is needed to send.
Return values
#kStatus_SuccessData was sent successfully.
kStatus_LPI2C_BusyAnother master is currently utilizing the bus.
kStatus_LPI2C_NakThe slave device sent a NAK in response to a byte.
kStatus_LPI2C_FifoErrorFIFO under run or over run.
kStatus_LPI2C_ArbitrationLostArbitration lost error.
kStatus_LPI2C_PinLowTimeoutSCL or SDA were held low longer than the timeout.
status_t LPI2C_MasterReceive ( LPI2C_Type *  base,
void *  pRxBuff,
uint16_t  u16RxSize,
bool  bPecEnable 
)
Parameters
baseThe LPI2C peripheral base address.
pRxBuffThe pointer to the data to be transferred.
u16RxSizeThe length in bytes of the data to be transferred.
bPecEnableIt decides whether one byte PEC is needed to receive.
Return values
#kStatus_SuccessData was received successfully.
kStatus_LPI2C_BusyAnother master is currently utilizing the bus.
kStatus_LPI2C_NakThe slave device sent a NAK in response to a byte.
kStatus_LPI2C_FifoErrorFIFO under run or overrun.
kStatus_LPI2C_ArbitrationLostArbitration lost error.
kStatus_LPI2C_PinLowTimeoutSCL or SDA were held low longer than the timeout.
static bool LPI2C_SlaveGetBusIdleState ( LPI2C_Type *  base)
inlinestatic

Requires the slave mode to be enabled.

Parameters
baseThe LPI2C peripheral base address.
Return values
trueBus is busy.
falseBus is idle.
static void LPI2C_SlaveTransmitAck ( LPI2C_Type *  base,
bool  bSendAck 
)
inlinestatic

Use this function to send an ACK or NAK when the kLPI2C_SlaveTransmitAckInterruptFlag is asserted. This only happens if you enable the sclStall.enableAck field of the lpi2c_slave_config_t configuration structure used to initialize the slave peripheral.

Parameters
baseThe LPI2C peripheral base address.
bSendAckPass true for an ACK or false for a NAK.
static uint16_t LPI2C_SlaveGetReceivedAddress ( LPI2C_Type *  base)
inlinestatic

This function should only be called if the #kLPI2C_SlaveAddressInterruptValidFlag is asserted.

Parameters
baseThe LPI2C peripheral base address.
Returns
The 8-bit address matched by the LPI2C slave. Bit 0 contains the R/w direction bit, and the 7-bit slave address is in the upper 7 bits.
status_t LPI2C_SlaveSend ( LPI2C_Type *  base,
void *  pTxBuff,
uint16_t  u16TxSize,
uint16_t *  pu16ActualTxSize 
)
Parameters
baseThe LPI2C peripheral base address.
pTxBuffThe pointer to the data to be transferred.
u16TxSizeThe length in bytes of the data to be transferred.
pu16ActualTxSize
Returns
Error or success status returned by API.
status_t LPI2C_SlaveReceive ( LPI2C_Type *  base,
void *  pRxBuff,
uint16_t  u16RxSize,
uint16_t *  pu16ActualRxSize 
)
Parameters
baseThe LPI2C peripheral base address.
pRxBuffThe pointer to the data to be transferred.
u16RxSizeThe length in bytes of the data to be transferred.
pu16ActualRxSize
Returns
Error or success status returned by API.
status_t LPI2C_MasterTransferBlocking ( LPI2C_Type *  base,
lpi2c_master_transfer_t *  psTransfer 
)
Note
The API does not return until the transfer succeeds or fails due to error happens during transfer.
Parameters
baseThe LPI2C peripheral base address.
psTransferPointer to the transfer structure.
Return values
#kStatus_SuccessData was received successfully.
kStatus_LPI2C_BusyAnother master is currently utilizing the bus.
kStatus_LPI2C_NakThe slave device sent a NAK in response to a byte.
kStatus_LPI2C_FifoErrorFIFO under run or overrun.
kStatus_LPI2C_ArbitrationLostArbitration lost error.
kStatus_LPI2C_PinLowTimeoutSCL or SDA were held low longer than the timeout.
void LPI2C_MasterTransferCreateHandle ( LPI2C_Type *  base,
lpi2c_master_transfer_handle_t *  psHandle,
lpi2c_master_transfer_callback_t  pfCallback,
void *  pUserData 
)

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

Note
The function also enables the NVIC IRQ for the input LPI2C. Need to notice that on some SoCs the LPI2C IRQ is connected to INTMUX, in this case user needs to enable the associated INTMUX IRQ in application.
Parameters
baseThe LPI2C peripheral base address.
psHandlePointer to the LPI2C master driver handle.
pfCallbackUser provided pointer to the asynchronous callback function.
pUserDataUser provided pointer to the application callback data.
status_t LPI2C_MasterTransferNonBlocking ( lpi2c_master_transfer_handle_t *  psHandle,
lpi2c_master_transfer_t *  psTransfer 
)
Parameters
psHandlePointer to the LPI2C master driver handle.
psTransferThe pointer to the transfer descriptor.
Return values
#kStatus_SuccessThe transaction was started successfully.
kStatus_LPI2C_BusyEither another master is currently utilizing the bus, or a non-blocking transaction is already in progress.
status_t LPI2C_MasterTransferGetCount ( lpi2c_master_transfer_handle_t *  psHandle,
uint16_t *  pu16Count 
)
Parameters
psHandlePointer to the LPI2C master driver handle.
pu16CountNumber of bytes transferred so far by the non-blocking transaction.
Return values
#kStatus_Success
#kStatus_NoTransferInProgressThere is not a non-blocking transaction currently in progress.
void LPI2C_MasterTransferAbort ( lpi2c_master_transfer_handle_t *  psHandle)
Note
It is not safe to call this function from an IRQ handler that has a higher priority than the LPI2C peripheral's IRQ priority.
Parameters
psHandlePointer to the LPI2C master driver handle.
Return values
#kStatus_SuccessA transaction was successfully aborted.
kStatus_LPI2C_IdleThere is not a non-blocking transaction currently in progress.
void LPI2C_MasterTransferHandleIRQ ( lpi2c_master_transfer_handle_t *  psHandle)
Note
This function does not need to be called unless you are reimplementing the nonblocking API's interrupt handler routines to add special functionality.
Parameters
psHandlePointer to the LPI2C master driver handle.
void LPI2C_SlaveTransferCreateHandle ( LPI2C_Type *  base,
lpi2c_slave_transfer_handle_t *  psHandle,
lpi2c_slave_transfer_callback_t  pfCallback,
void *  pUserData 
)

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

Note
The function also enables the NVIC IRQ for the input LPI2C. Need to notice that on some SoCs the LPI2C IRQ is connected to INTMUX, in this case user needs to enable the associated INTMUX IRQ in application.
Parameters
baseThe LPI2C peripheral base address.
psHandlePointer to the LPI2C slave driver handle.
pfCallbackUser provided pointer to the asynchronous callback function.
pUserDataUser provided pointer to the application callback data.
status_t LPI2C_SlaveTransferNonBlocking ( lpi2c_slave_transfer_handle_t *  psHandle,
uint8_t  u8EventMask 
)

Call this API after calling I2C_SlaveInit() and LPI2C_SlaveTransferCreateHandle() 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 LPI2C_SlaveTransferCreateHandle(). The callback is always invoked from the interrupt context.

The set of events received by the callback is customizable. To do so, set the eventMask parameter to the OR'd combination of lpi2c_slave_transfer_event_t enumerators for the events you wish to receive. The kLPI2C_SlaveTransmitEvent and kLPI2C_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 kLPI2C_SlaveAllEvents constant is provided as a convenient way to enable all events.

Parameters
psHandlePointer to #lpi2c_slave_transfer_handle_t structure which stores the transfer state.
u8EventMaskBit mask formed by OR'ing together lpi2c_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 kLPI2C_SlaveAllEvents to enable all events.
Return values
#kStatus_SuccessSlave transfers were successfully started.
kStatus_LPI2C_BusySlave transfers have already been started on this handle.
status_t LPI2C_SlaveTransferGetCount ( lpi2c_slave_transfer_handle_t *  psHandle,
uint16_t *  pu16Count 
)
Parameters
psHandlePointer to i2c_slave_handle_t structure.
pu16CountPointer to a value to hold the number of bytes transferred. May be NULL if the count is not required.
Return values
#kStatus_Success
#kStatus_NoTransferInProgress
void LPI2C_SlaveTransferAbort ( lpi2c_slave_transfer_handle_t *  psHandle)
Note
This API could be called at any time to stop slave for handling the bus events.
Parameters
psHandlePointer to #lpi2c_slave_transfer_handle_t structure which stores the transfer state.
Return values
#kStatus_Success
kStatus_LPI2C_Idle
void LPI2C_SlaveTransferHandleIRQ ( lpi2c_slave_transfer_handle_t *  psHandle)
Note
This function does not need to be called unless you are reimplementing the non blocking API's interrupt handler routines to add special functionality.
Parameters
handlePointer to #lpi2c_slave_transfer_handle_t structure which stores the transfer state.