RTEMS 6.1-rc6
Loading...
Searching...
No Matches
Modules | Data Structures | Typedefs | Enumerations
Lpi2c_master_driver

Modules

 Lpi2c_slave_driver
 

Data Structures

struct  _lpi2c_master_config
 Structure with settings to initialize the LPI2C master module. More...
 
struct  _lpi2c_match_config
 LPI2C master data match configuration structure. More...
 
struct  _lpi2c_master_transfer
 Non-blocking transfer descriptor structure. More...
 
struct  _lpi2c_master_handle
 Driver handle for master non-blocking APIs. More...
 

Typedefs

typedef enum _lpi2c_direction lpi2c_direction_t
 Direction of master and slave transfers.
 
typedef enum _lpi2c_master_pin_config lpi2c_master_pin_config_t
 LPI2C pin configuration.
 
typedef enum _lpi2c_host_request_source lpi2c_host_request_source_t
 LPI2C master host request selection.
 
typedef enum _lpi2c_host_request_polarity lpi2c_host_request_polarity_t
 LPI2C master host request pin polarity configuration.
 
typedef struct _lpi2c_master_config lpi2c_master_config_t
 Structure with settings to initialize the LPI2C master module.
 
typedef enum _lpi2c_data_match_config_mode lpi2c_data_match_config_mode_t
 LPI2C master data match configuration modes.
 
typedef struct _lpi2c_match_config lpi2c_data_match_config_t
 LPI2C master data match configuration structure.
 
typedef struct _lpi2c_master_transfer lpi2c_master_transfer_t
 
typedef struct _lpi2c_master_handle lpi2c_master_handle_t
 
typedef void(* lpi2c_master_transfer_callback_t) (LPI2C_Type *base, lpi2c_master_handle_t *handle, status_t completionStatus, void *userData)
 Master completion callback function pointer type.
 
typedef void(* lpi2c_master_isr_t) (LPI2C_Type *base, void *handle)
 Typedef for master interrupt handler, used internally for LPI2C master interrupt and EDMA transactional APIs.
 

Enumerations

enum  _lpi2c_master_flags {
  kLPI2C_MasterTxReadyFlag = LPI2C_MSR_TDF_MASK , kLPI2C_MasterRxReadyFlag = LPI2C_MSR_RDF_MASK , kLPI2C_MasterEndOfPacketFlag = LPI2C_MSR_EPF_MASK , kLPI2C_MasterStopDetectFlag = LPI2C_MSR_SDF_MASK ,
  kLPI2C_MasterNackDetectFlag = LPI2C_MSR_NDF_MASK , kLPI2C_MasterArbitrationLostFlag = LPI2C_MSR_ALF_MASK , kLPI2C_MasterFifoErrFlag = LPI2C_MSR_FEF_MASK , kLPI2C_MasterPinLowTimeoutFlag = LPI2C_MSR_PLTF_MASK ,
  kLPI2C_MasterDataMatchFlag = LPI2C_MSR_DMF_MASK , kLPI2C_MasterBusyFlag = LPI2C_MSR_MBF_MASK , kLPI2C_MasterBusBusyFlag = LPI2C_MSR_BBF_MASK , kLPI2C_MasterClearFlags ,
  kLPI2C_MasterIrqFlags , kLPI2C_MasterErrorFlags
}
 LPI2C master peripheral flags. More...
 
enum  _lpi2c_direction { kLPI2C_Write = 0U , kLPI2C_Read = 1U }
 Direction of master and slave transfers. More...
 
enum  _lpi2c_master_pin_config {
  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 { kLPI2C_HostRequestExternalPin = 0x0U , kLPI2C_HostRequestInputTrigger = 0x1U }
 LPI2C master host request selection. More...
 
enum  _lpi2c_host_request_polarity { kLPI2C_HostRequestPinActiveLow = 0x0U , kLPI2C_HostRequestPinActiveHigh = 0x1U }
 LPI2C master host request pin polarity configuration. More...
 
enum  _lpi2c_data_match_config_mode {
  kLPI2C_MatchDisabled = 0x0U , kLPI2C_1stWordEqualsM0OrM1 = 0x2U , kLPI2C_AnyWordEqualsM0OrM1 = 0x3U , kLPI2C_1stWordEqualsM0And2ndWordEqualsM1 ,
  kLPI2C_AnyWordEqualsM0AndNextWordEqualsM1 , kLPI2C_1stWordAndM1EqualsM0AndM1 , kLPI2C_AnyWordAndM1EqualsM0AndM1
}
 LPI2C master data match configuration modes. More...
 
enum  _lpi2c_master_transfer_flags { kLPI2C_TransferDefaultFlag = 0x00U , kLPI2C_TransferNoStartFlag = 0x01U , kLPI2C_TransferRepeatedStartFlag = 0x02U , kLPI2C_TransferNoStopFlag = 0x04U }
 Transfer option flags. More...
 

Initialization and deinitialization

void LPI2C_MasterGetDefaultConfig (lpi2c_master_config_t *masterConfig)
 Provides a default configuration for the LPI2C master peripheral.
 
void LPI2C_MasterInit (LPI2C_Type *base, const lpi2c_master_config_t *masterConfig, uint32_t sourceClock_Hz)
 Initializes the LPI2C master peripheral.
 
void LPI2C_MasterDeinit (LPI2C_Type *base)
 Deinitializes the LPI2C master peripheral.
 
void LPI2C_MasterConfigureDataMatch (LPI2C_Type *base, const lpi2c_data_match_config_t *matchConfig)
 Configures LPI2C master data match feature.
 
status_t LPI2C_MasterCheckAndClearError (LPI2C_Type *base, uint32_t status)
 Convert provided flags to status code, and clear any errors if present.
 
status_t LPI2C_CheckForBusyBus (LPI2C_Type *base)
 Make sure the bus isn't already busy.
 

Bus operations

void LPI2C_MasterSetBaudRate (LPI2C_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Hz)
 Sets the I2C bus frequency for master transactions.
 
status_t LPI2C_MasterStart (LPI2C_Type *base, uint8_t address, lpi2c_direction_t dir)
 Sends a START signal and slave address on the I2C bus.
 
status_t LPI2C_MasterSend (LPI2C_Type *base, void *txBuff, size_t txSize)
 Performs a polling send transfer on the I2C bus.
 
status_t LPI2C_MasterReceive (LPI2C_Type *base, void *rxBuff, size_t rxSize)
 Performs a polling receive transfer on the I2C bus.
 
status_t LPI2C_MasterStop (LPI2C_Type *base)
 Sends a STOP signal on the I2C bus.
 
status_t LPI2C_MasterTransferBlocking (LPI2C_Type *base, lpi2c_master_transfer_t *transfer)
 Performs a master polling transfer on the I2C bus.
 

Non-blocking

void LPI2C_MasterTransferCreateHandle (LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_callback_t callback, void *userData)
 Creates a new handle for the LPI2C master non-blocking APIs.
 
status_t LPI2C_MasterTransferNonBlocking (LPI2C_Type *base, lpi2c_master_handle_t *handle, lpi2c_master_transfer_t *transfer)
 Performs a non-blocking transaction on the I2C bus.
 
status_t LPI2C_MasterTransferGetCount (LPI2C_Type *base, lpi2c_master_handle_t *handle, size_t *count)
 Returns number of bytes transferred so far.
 
void LPI2C_MasterTransferAbort (LPI2C_Type *base, lpi2c_master_handle_t *handle)
 Terminates a non-blocking LPI2C master transmission early.
 

IRQ handler

void LPI2C_MasterTransferHandleIRQ (LPI2C_Type *base, void *lpi2cMasterHandle)
 Reusable routine to handle master interrupts.
 

Detailed Description

Typedef Documentation

◆ lpi2c_master_config_t

Structure with settings to initialize the LPI2C master module.

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.

◆ lpi2c_master_transfer_callback_t

typedef void(* lpi2c_master_transfer_callback_t) (LPI2C_Type *base, lpi2c_master_handle_t *handle, status_t completionStatus, void *userData)

Master completion callback function pointer type.

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
baseThe LPI2C peripheral base address.
completionStatusEither kStatus_Success or an error code describing how the transfer completed.
userDataArbitrary pointer-sized value passed from the application.

Enumeration Type Documentation

◆ _lpi2c_data_match_config_mode

LPI2C master data match configuration modes.

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

◆ _lpi2c_direction

Direction of master and slave transfers.

Enumerator
kLPI2C_Write 

Master transmit.

kLPI2C_Read 

Master receive.

◆ _lpi2c_host_request_polarity

LPI2C master host request pin polarity configuration.

Enumerator
kLPI2C_HostRequestPinActiveLow 

Configure the LPI2C_HREQ pin active low

kLPI2C_HostRequestPinActiveHigh 

Configure the LPI2C_HREQ pin active high

◆ _lpi2c_host_request_source

LPI2C master host request selection.

Enumerator
kLPI2C_HostRequestExternalPin 

Select the LPI2C_HREQ pin as the host request input

kLPI2C_HostRequestInputTrigger 

Select the input trigger as the host request input

◆ _lpi2c_master_flags

LPI2C master peripheral 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_MasterTxReadyFlag 

Transmit data flag

kLPI2C_MasterRxReadyFlag 

Receive data flag

kLPI2C_MasterEndOfPacketFlag 

End Packet flag

kLPI2C_MasterStopDetectFlag 

Stop detect flag

kLPI2C_MasterNackDetectFlag 

NACK detect flag

kLPI2C_MasterArbitrationLostFlag 

Arbitration lost flag

kLPI2C_MasterFifoErrFlag 

FIFO error flag

kLPI2C_MasterPinLowTimeoutFlag 

Pin low timeout flag

kLPI2C_MasterDataMatchFlag 

Data match flag

kLPI2C_MasterBusyFlag 

Master busy flag

kLPI2C_MasterBusBusyFlag 

Bus busy flag

kLPI2C_MasterClearFlags 

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

kLPI2C_MasterIrqFlags 

IRQ sources enabled by the non-blocking transactional API.

kLPI2C_MasterErrorFlags 

Errors to check for.

◆ _lpi2c_master_pin_config

LPI2C pin configuration.

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)

◆ _lpi2c_master_transfer_flags

Transfer option flags.

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

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.

Function Documentation

◆ LPI2C_CheckForBusyBus()

status_t LPI2C_CheckForBusyBus ( LPI2C_Type base)

Make sure the bus isn't already busy.

A busy bus is allowed if we are the one driving it.

Parameters
baseThe LPI2C peripheral base address.
Return values
kStatus_Success
kStatus_LPI2C_Busy

◆ LPI2C_MasterCheckAndClearError()

status_t LPI2C_MasterCheckAndClearError ( LPI2C_Type base,
uint32_t  status 
)

Convert provided flags to status code, and clear any errors if present.

Parameters
baseThe LPI2C peripheral base address.
statusCurrent status flags value that will be checked.
Return values
kStatus_Success
kStatus_LPI2C_PinLowTimeout
kStatus_LPI2C_ArbitrationLost
kStatus_LPI2C_Nak
kStatus_LPI2C_FifoError

◆ LPI2C_MasterConfigureDataMatch()

void LPI2C_MasterConfigureDataMatch ( LPI2C_Type base,
const lpi2c_data_match_config_t matchConfig 
)

Configures LPI2C master data match feature.

Parameters
baseThe LPI2C peripheral base address.
matchConfigSettings for the data match feature.

brief Configures LPI2C master data match feature.

param base The LPI2C peripheral base address. param matchConfig Settings for the data match feature.

◆ LPI2C_MasterDeinit()

void LPI2C_MasterDeinit ( LPI2C_Type base)

Deinitializes the LPI2C master peripheral.

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.

brief Deinitializes the LPI2C master peripheral.

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

param base The LPI2C peripheral base address.

◆ LPI2C_MasterGetDefaultConfig()

void LPI2C_MasterGetDefaultConfig ( lpi2c_master_config_t masterConfig)

Provides a default configuration for the LPI2C master peripheral.

This function provides the following default configuration for the LPI2C master peripheral:

masterConfig->enableMaster = true;
masterConfig->debugEnable = false;
masterConfig->ignoreAck = false;
masterConfig->pinConfig = kLPI2C_2PinOpenDrain;
masterConfig->baudRate_Hz = 100000U;
masterConfig->busIdleTimeout_ns = 0;
masterConfig->pinLowTimeout_ns = 0;
masterConfig->sdaGlitchFilterWidth_ns = 0;
masterConfig->sclGlitchFilterWidth_ns = 0;
masterConfig->hostRequest.enable = false;
masterConfig->hostRequest.source = kLPI2C_HostRequestExternalPin;
masterConfig->hostRequest.polarity = kLPI2C_HostRequestPinActiveHigh;
@ kLPI2C_HostRequestExternalPin
Definition: fsl_lpi2c.h:129
@ kLPI2C_HostRequestPinActiveHigh
Definition: fsl_lpi2c.h:137
@ kLPI2C_2PinOpenDrain
Definition: fsl_lpi2c.h:113

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
[out]masterConfigUser provided configuration structure for default values. Refer to lpi2c_master_config_t.

brief Provides a default configuration for the LPI2C master peripheral.

This function provides the following default configuration for the LPI2C master peripheral: code masterConfig->enableMaster = true; masterConfig->debugEnable = false; masterConfig->ignoreAck = false; masterConfig->pinConfig = kLPI2C_2PinOpenDrain; masterConfig->baudRate_Hz = 100000U; masterConfig->busIdleTimeout_ns = 0U; masterConfig->pinLowTimeout_ns = 0U; masterConfig->sdaGlitchFilterWidth_ns = 0U; masterConfig->sclGlitchFilterWidth_ns = 0U; masterConfig->hostRequest.enable = false; masterConfig->hostRequest.source = kLPI2C_HostRequestExternalPin; masterConfig->hostRequest.polarity = kLPI2C_HostRequestPinActiveHigh; endcode

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

param[out] masterConfig User provided configuration structure for default values. Refer to lpi2c_master_config_t.

◆ LPI2C_MasterInit()

void LPI2C_MasterInit ( LPI2C_Type base,
const lpi2c_master_config_t masterConfig,
uint32_t  sourceClock_Hz 
)

Initializes the LPI2C master peripheral.

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.

Parameters
baseThe LPI2C peripheral base address.
masterConfigUser provided peripheral configuration. Use LPI2C_MasterGetDefaultConfig() to get a set of defaults that you can override.
sourceClock_HzFrequency in Hertz of the LPI2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods.

brief Initializes the LPI2C master peripheral.

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.

param base The LPI2C peripheral base address. param masterConfig User provided peripheral configuration. Use LPI2C_MasterGetDefaultConfig() to get a set of defaults that you can override. param sourceClock_Hz Frequency in Hertz of the LPI2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods.

◆ LPI2C_MasterReceive()

status_t LPI2C_MasterReceive ( LPI2C_Type base,
void *  rxBuff,
size_t  rxSize 
)

Performs a polling receive transfer on the I2C bus.

Parameters
baseThe LPI2C peripheral base address.
rxBuffThe pointer to the data to be transferred.
rxSizeThe length in bytes of the data to be transferred.
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.

brief Performs a polling receive transfer on the I2C bus.

param base The LPI2C peripheral base address. param rxBuff The pointer to the data to be transferred. param rxSize The length in bytes of the data to be transferred. retval kStatus_Success Data was received successfully. retval kStatus_LPI2C_Busy Another master is currently utilizing the bus. retval kStatus_LPI2C_Nak The slave device sent a NAK in response to a byte. retval kStatus_LPI2C_FifoError FIFO under run or overrun. retval kStatus_LPI2C_ArbitrationLost Arbitration lost error. retval kStatus_LPI2C_PinLowTimeout SCL or SDA were held low longer than the timeout.

◆ LPI2C_MasterSend()

status_t LPI2C_MasterSend ( LPI2C_Type base,
void *  txBuff,
size_t  txSize 
)

Performs a polling send transfer on the I2C bus.

Sends up to txSize 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.
txBuffThe pointer to the data to be transferred.
txSizeThe length in bytes of the data to be transferred.
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.

brief Performs a polling send transfer on the I2C bus.

Sends up to a txSize 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.

param base The LPI2C peripheral base address. param txBuff The pointer to the data to be transferred. param txSize The length in bytes of the data to be transferred. retval kStatus_Success Data was sent successfully. retval kStatus_LPI2C_Busy Another master is currently utilizing the bus. retval kStatus_LPI2C_Nak The slave device sent a NAK in response to a byte. retval kStatus_LPI2C_FifoError FIFO under run or over run. retval kStatus_LPI2C_ArbitrationLost Arbitration lost error. retval kStatus_LPI2C_PinLowTimeout SCL or SDA were held low longer than the timeout.

◆ LPI2C_MasterSetBaudRate()

void LPI2C_MasterSetBaudRate ( LPI2C_Type base,
uint32_t  sourceClock_Hz,
uint32_t  baudRate_Hz 
)

Sets the I2C bus frequency for master transactions.

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.
sourceClock_HzLPI2C functional clock frequency in Hertz.
baudRate_HzRequested bus frequency in Hertz.

brief Sets the I2C bus frequency for master transactions.

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.

param base The LPI2C peripheral base address. param sourceClock_Hz LPI2C functional clock frequency in Hertz. param baudRate_Hz Requested bus frequency in Hertz.

◆ LPI2C_MasterStart()

status_t LPI2C_MasterStart ( LPI2C_Type base,
uint8_t  address,
lpi2c_direction_t  dir 
)

Sends a START signal and slave address on the I2C bus.

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.
address7-bit slave device address, in bits [6:0].
dirMaster 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.

brief Sends a START signal and slave address on the I2C bus.

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 a address parameter. Note that this function does not actually wait until the START and address are successfully sent on the bus before returning.

param base The LPI2C peripheral base address. param address 7-bit slave device address, in bits [6:0]. param dir Master 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. retval kStatus_Success START signal and address were successfully enqueued in the transmit FIFO. retval kStatus_LPI2C_Busy Another master is currently utilizing the bus.

◆ LPI2C_MasterStop()

status_t LPI2C_MasterStop ( LPI2C_Type base)

Sends a STOP signal on the I2C bus.

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.

brief Sends a STOP signal on the I2C bus.

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

param base The LPI2C peripheral base address. retval kStatus_Success The STOP signal was successfully sent on the bus and the transaction terminated. retval kStatus_LPI2C_Busy Another master is currently utilizing the bus. retval kStatus_LPI2C_Nak The slave device sent a NAK in response to a byte. retval kStatus_LPI2C_FifoError FIFO under run or overrun. retval kStatus_LPI2C_ArbitrationLost Arbitration lost error. retval kStatus_LPI2C_PinLowTimeout SCL or SDA were held low longer than the timeout.

◆ LPI2C_MasterTransferAbort()

void LPI2C_MasterTransferAbort ( LPI2C_Type base,
lpi2c_master_handle_t handle 
)

Terminates a non-blocking LPI2C master transmission early.

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
baseThe LPI2C peripheral base address.
handlePointer 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.

brief Terminates a non-blocking LPI2C master transmission early.

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.

param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. retval kStatus_Success A transaction was successfully aborted. retval kStatus_LPI2C_Idle There is not a non-blocking transaction currently in progress.

◆ LPI2C_MasterTransferBlocking()

status_t LPI2C_MasterTransferBlocking ( LPI2C_Type base,
lpi2c_master_transfer_t transfer 
)

Performs a master polling transfer on the I2C bus.

Note
The API does not return until the transfer succeeds or fails due to error happens during transfer.
Parameters
baseThe LPI2C peripheral base address.
transferPointer 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.

brief Performs a master polling transfer on the I2C bus.

note The API does not return until the transfer succeeds or fails due to error happens during transfer.

param base The LPI2C peripheral base address. param transfer Pointer to the transfer structure. retval kStatus_Success Data was received successfully. retval kStatus_LPI2C_Busy Another master is currently utilizing the bus. retval kStatus_LPI2C_Nak The slave device sent a NAK in response to a byte. retval kStatus_LPI2C_FifoError FIFO under run or overrun. retval kStatus_LPI2C_ArbitrationLost Arbitration lost error. retval kStatus_LPI2C_PinLowTimeout SCL or SDA were held low longer than the timeout.

◆ LPI2C_MasterTransferCreateHandle()

void LPI2C_MasterTransferCreateHandle ( LPI2C_Type base,
lpi2c_master_handle_t handle,
lpi2c_master_transfer_callback_t  callback,
void *  userData 
)

Creates a new handle for the LPI2C master non-blocking APIs.

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.
[out]handlePointer to the LPI2C master driver handle.
callbackUser provided pointer to the asynchronous callback function.
userDataUser provided pointer to the application callback data.

brief Creates a new handle for the LPI2C master non-blocking APIs.

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.

param base The LPI2C peripheral base address. param[out] handle Pointer to the LPI2C master driver handle. param callback User provided pointer to the asynchronous callback function. param userData User provided pointer to the application callback data.

◆ LPI2C_MasterTransferGetCount()

status_t LPI2C_MasterTransferGetCount ( LPI2C_Type base,
lpi2c_master_handle_t handle,
size_t *  count 
)

Returns number of bytes transferred so far.

Parameters
baseThe LPI2C peripheral base address.
handlePointer to the LPI2C master driver handle.
[out]countNumber 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.

brief Returns number of bytes transferred so far. param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param[out] count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_Success retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.

◆ LPI2C_MasterTransferHandleIRQ()

void LPI2C_MasterTransferHandleIRQ ( LPI2C_Type base,
void *  lpi2cMasterHandle 
)

Reusable routine to handle master interrupts.

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
baseThe LPI2C peripheral base address.
lpi2cMasterHandlePointer to the LPI2C master driver handle.

brief Reusable routine to handle master interrupts. note This function does not need to be called unless you are reimplementing the nonblocking API's interrupt handler routines to add special functionality. param base The LPI2C peripheral base address. param lpi2cMasterHandle Pointer to the LPI2C master driver handle.

◆ LPI2C_MasterTransferNonBlocking()

status_t LPI2C_MasterTransferNonBlocking ( LPI2C_Type base,
lpi2c_master_handle_t handle,
lpi2c_master_transfer_t transfer 
)

Performs a non-blocking transaction on the I2C bus.

Parameters
baseThe LPI2C peripheral base address.
handlePointer to the LPI2C master driver handle.
transferThe 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.

brief Performs a non-blocking transaction on the I2C bus.

param base The LPI2C peripheral base address. param handle Pointer to the LPI2C master driver handle. param transfer The pointer to the transfer descriptor. retval kStatus_Success The transaction was started successfully. retval kStatus_LPI2C_Busy Either another master is currently utilizing the bus, or a non-blocking transaction is already in progress.