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.
|
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...
|
|
|
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...
|
|
|
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...
|
|
|
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...
|
|
|
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...
|
|
|
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...
|
|
|
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...
|
|
|
static void | LPI2C_SlaveEnableDMA (LPI2C_Type *base, bool bEnableAddressValid, bool bEnableRx, bool bEnableTx) |
| Enables or disables the LPI2C slave peripheral DMA requests. More...
|
|
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.
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 |
uint32_t lpi2c_master_config_t::u32PinLowTimeoutNs |
uint32_t lpi2c_master_config_t::u32SdaGlitchFilterWidthNs |
uint32_t lpi2c_master_config_t::u32SclGlitchFilterWidthNs |
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.
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 |
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.
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 |
uint32_t lpi2c_config_t::u32PinLowTimeoutNs |
uint32_t lpi2c_config_t::u32MasterSdaGlitchFilterWidthNs |
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 |
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.
uint8_t lpi2c_master_transfer_t::u8ControlFlagMask |
uint16_t lpi2c_master_transfer_t::u8SlaveAddress |
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.
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 |
status_t lpi2c_master_transfer_handle_t::completionStatus |
void* lpi2c_master_transfer_handle_t::pUserData |
struct _lpi2c_slave_transfer |
uint8_t lpi2c_slave_transfer_t::u8EventMask |
uint16_t lpi2c_slave_transfer_t::u16ReceivedAddress |
status_t lpi2c_slave_transfer_t::completionStatus |
uint16_t lpi2c_slave_transfer_t::u16TransferredCount |
struct _lpi2c_slave_transfer_handle |
- Note
- The contents of this structure are private and subject to change.
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 |
void* lpi2c_slave_transfer_handle_t::pUserData |
#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 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
-
psHandle | Pointer 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
-
psHandle | Pointer to the LPI2C slave driver handle. |
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.
|
void LPI2C_GetDefaultConfig |
( |
lpi2c_config_t * |
psConfig, |
|
|
uint16_t |
u16SlaveAddress, |
|
|
uint32_t |
u32SrcClockHz |
|
) |
| |
This is an example:
After calling this function, you can override any settings in order to customize the configuration, prior to initializing the driver with LPI2C_Init().
- Parameters
-
psConfig | User provided configuration structure for default values. Refer to lpi2c_config_t. |
u16SlaveAddress | Slave address raw value, driver will shift it. |
u32SrcClockHz | Frequency 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
-
base | The LPI2C peripheral base address. |
psConfig | User 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
-
base | The LPI2C peripheral base address. |
This is an example:
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
-
psMasterConfig | User provided configuration structure for default values. Refer to lpi2c_master_config_t. |
u32SrcClockHz | Frequency in Hertz of the LPI2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods. |
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
-
base | The LPI2C peripheral base address. |
psMasterConfig | User 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
-
base | The LPI2C peripheral base address. |
void LPI2C_SlaveGetDefaultConfig |
( |
lpi2c_slave_config_t * |
psSlaveConfig, |
|
|
uint16_t |
u16SlaveAddress, |
|
|
uint32_t |
u32SrcClockHz |
|
) |
| |
This is an example:
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
-
psSlaveConfig | User provided configuration structure that is set to default values. Refer to lpi2c_slave_config_t. |
u16SlaveAddress | Slave address raw value, driver will shift it. |
u32SrcClockHz | Frequency in Hertz of the LPI2C functional clock. Used to calculate the filter widths, data valid delay, and clock hold time. |
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
-
base | The LPI2C peripheral base address. |
psSlaveConfig | User 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
-
base | The 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
-
base | The 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
-
- 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
-
base | The 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
-
- See Also
- _lpi2c_slave_status_flags.
static void LPI2C_MasterEnableInterrupts |
( |
LPI2C_Type * |
base, |
|
|
uint16_t |
u16Interrupts |
|
) |
| |
|
inlinestatic |
static void LPI2C_MasterDisableInterrupts |
( |
LPI2C_Type * |
base, |
|
|
uint16_t |
u16Interrupts |
|
) |
| |
|
inlinestatic |
static uint16_t LPI2C_MasterGetEnabledInterrupts |
( |
LPI2C_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | The 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 |
static void LPI2C_SlaveDisableInterrupts |
( |
LPI2C_Type * |
base, |
|
|
uint16_t |
u16Interrupts |
|
) |
| |
|
inlinestatic |
static uint16_t LPI2C_SlaveGetEnabledInterrupts |
( |
LPI2C_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | The 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
-
base | The LPI2C peripheral base address. |
u32SrcClockHz | LPI2C functional clock frequency in Hertz. |
u32BaudRateBps | Requested 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
-
base | The LPI2C peripheral base address. |
u32SdaFilterWidthNs | The SDA glitch filter length in nano seconds. |
u32SclFilterWidthNs | The SCL glitch filter length in nano seconds. |
u32SrcClockHz | LPI2C peripheral clock frequency in Hz |
- Parameters
-
base | The LPI2C peripheral base address. |
psConfig | Settings for the data match feature. |
static void LPI2C_MasterReset |
( |
LPI2C_Type * |
base | ) |
|
|
inlinestatic |
Restores the LPI2C master peripheral to reset conditions.
- Parameters
-
base | The LPI2C peripheral base address. |
static void LPI2C_MasterEnable |
( |
LPI2C_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | The LPI2C peripheral base address. |
bEnable | Pass 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
-
base | The LPI2C peripheral base address. |
u16TxWords | Transmit 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. |
u16RxWords | Receive 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
-
base | The LPI2C peripheral base address. |
pu16RxCount | Pointer through which the current number of words in the transmit FIFO is returned. Pass NULL if this value is not required. |
pu16TxCount | Pointer 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
-
base | The LPI2C peripheral base address. |
u32SdaFilterWidthNs | The SDA glitch filter length in nano seconds. |
u32SclFilterWidthNs | The SCL glitch filter length in nano seconds. |
u32SrcClockHz | LPI2C 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
-
base | The LPI2C peripheral base address. |
eAddressMatchMode | The slave addressing match mode. |
u16Address0 | LPI2C slave address 0. For 7-bit address low 7-bit is used, for 10-bit address low 10-bit is used. |
u16Address1 | LPI2C 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
-
base | The LPI2C peripheral base address. |
static void LPI2C_SlaveEnable |
( |
LPI2C_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | The LPI2C peripheral base address. |
bEnable | Pass 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
-
base | The LPI2C peripheral base address. |
bEnableTx | Enable flag for transmit DMA request. Pass true for enable, false for disable. |
bEnableRx | Enable flag for receive DMA request. Pass true for enable, false for disable. |
static uint16_t* LPI2C_MasterGetTxFifoAddress |
( |
LPI2C_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | The LPI2C peripheral base address. |
- Returns
- The LPI2C Master Transmit Data Register address.
static uint16_t* LPI2C_MasterGetRxFifoAddress |
( |
LPI2C_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | The 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
-
base | The LPI2C peripheral base address. |
bEnableAddressValid | Enable 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. |
bEnableRx | Enable flag for the receive data DMA request. Pass true for enable, false for disable. |
bEnableTx | Enable flag for the transmit data DMA request. Pass true for enable, false for disable. |
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
-
base | The LPI2C peripheral base address. |
u8Address | 7-bit slave device address, in bits [6:0]. |
eDir | 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. |
- Return values
-
#kStatus_Success | START signal and address were successfully enqueued in the transmit FIFO. |
kStatus_LPI2C_Busy | Another master is currently utilizing the bus. |
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
-
base | The LPI2C peripheral base address. |
u8Address | 7-bit slave device address, in bits [6:0]. |
eDir | 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. |
- Return values
-
#kStatus_Success | Repeated START signal and address were successfully enqueued in the transmit FIFO. |
kStatus_LPI2C_Busy | Another 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
-
base | The LPI2C peripheral base address. |
- Return values
-
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
-
base | The LPI2C peripheral base address. |
pTxBuff | The pointer to the data to be transferred. |
u16TxSize | The length in bytes of the data to be transferred. |
bPecEnable | It decides whether one byte PEC is needed to send. |
- Return values
-
status_t LPI2C_MasterReceive |
( |
LPI2C_Type * |
base, |
|
|
void * |
pRxBuff, |
|
|
uint16_t |
u16RxSize, |
|
|
bool |
bPecEnable |
|
) |
| |
- Parameters
-
base | The LPI2C peripheral base address. |
pRxBuff | The pointer to the data to be transferred. |
u16RxSize | The length in bytes of the data to be transferred. |
bPecEnable | It decides whether one byte PEC is needed to receive. |
- Return values
-
static bool LPI2C_SlaveGetBusIdleState |
( |
LPI2C_Type * |
base | ) |
|
|
inlinestatic |
Requires the slave mode to be enabled.
- Parameters
-
base | The LPI2C peripheral base address. |
- Return values
-
true | Bus is busy. |
false | Bus 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
-
base | The LPI2C peripheral base address. |
bSendAck | Pass 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
-
base | The 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
-
base | The LPI2C peripheral base address. |
pTxBuff | The pointer to the data to be transferred. |
u16TxSize | The 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
-
base | The LPI2C peripheral base address. |
pRxBuff | The pointer to the data to be transferred. |
u16RxSize | The 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
-
base | The LPI2C peripheral base address. |
psTransfer | Pointer to the transfer structure. |
- Return values
-
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
-
base | The LPI2C peripheral base address. |
psHandle | Pointer to the LPI2C master driver handle. |
pfCallback | User provided pointer to the asynchronous callback function. |
pUserData | User provided pointer to the application callback data. |
status_t LPI2C_MasterTransferNonBlocking |
( |
lpi2c_master_transfer_handle_t * |
psHandle, |
|
|
lpi2c_master_transfer_t * |
psTransfer |
|
) |
| |
- Parameters
-
psHandle | Pointer to the LPI2C master driver handle. |
psTransfer | The pointer to the transfer descriptor. |
- Return values
-
#kStatus_Success | The transaction was started successfully. |
kStatus_LPI2C_Busy | Either another master is currently utilizing the bus, or a non-blocking transaction is already in progress. |
status_t LPI2C_MasterTransferGetCount |
( |
lpi2c_master_transfer_handle_t * |
psHandle, |
|
|
uint16_t * |
pu16Count |
|
) |
| |
- Parameters
-
psHandle | Pointer to the LPI2C master driver handle. |
pu16Count | Number of bytes transferred so far by the non-blocking transaction. |
- Return values
-
#kStatus_Success | |
#kStatus_NoTransferInProgress | There 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
-
psHandle | Pointer to the LPI2C master driver handle. |
- Return values
-
#kStatus_Success | A transaction was successfully aborted. |
kStatus_LPI2C_Idle | There 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
-
psHandle | Pointer 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
-
base | The LPI2C peripheral base address. |
psHandle | Pointer to the LPI2C slave driver handle. |
pfCallback | User provided pointer to the asynchronous callback function. |
pUserData | User 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
-
psHandle | Pointer to #lpi2c_slave_transfer_handle_t structure which stores the transfer state. |
u8EventMask | Bit 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_Success | Slave transfers were successfully started. |
kStatus_LPI2C_Busy | Slave transfers have already been started on this handle. |
status_t LPI2C_SlaveTransferGetCount |
( |
lpi2c_slave_transfer_handle_t * |
psHandle, |
|
|
uint16_t * |
pu16Count |
|
) |
| |
- Parameters
-
psHandle | Pointer to i2c_slave_handle_t structure. |
pu16Count | Pointer 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
-
psHandle | Pointer to #lpi2c_slave_transfer_handle_t structure which stores the transfer state. |
- Return values
-
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
-
handle | Pointer to #lpi2c_slave_transfer_handle_t structure which stores the transfer state. |